using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class TlvDownloadResponseErrorCodeInfo
{
	public static TlvDownloadResponseErrorCodeEnum ValueToTlvDownloadResponseErrorCode(uint value)
	{
		return value switch
		{
			0u => TlvDownloadResponseErrorCodeEnum.Success, 
			1u => TlvDownloadResponseErrorCodeEnum.Length_Error, 
			2u => TlvDownloadResponseErrorCodeEnum.Version_Error, 
			3u => TlvDownloadResponseErrorCodeEnum.Signature_Error, 
			4u => TlvDownloadResponseErrorCodeEnum.No_Memory_Error, 
			5u => TlvDownloadResponseErrorCodeEnum.NVM_Tag_Error, 
			6u => TlvDownloadResponseErrorCodeEnum.NVM_Length_Error, 
			7u => TlvDownloadResponseErrorCodeEnum.BT_Mode_Error, 
			14u => TlvDownloadResponseErrorCodeEnum.Unknown_Error, 
			16u => TlvDownloadResponseErrorCodeEnum.Type_Error, 
			17u => TlvDownloadResponseErrorCodeEnum.Image_Type_Error, 
			19u => TlvDownloadResponseErrorCodeEnum.CRC_Error, 
			20u => TlvDownloadResponseErrorCodeEnum.ID_Error, 
			21u => TlvDownloadResponseErrorCodeEnum.Wrong_Ver_Error, 
			22u => TlvDownloadResponseErrorCodeEnum.Small_Ver_Error, 
			23u => TlvDownloadResponseErrorCodeEnum.Region_Error, 
			24u => TlvDownloadResponseErrorCodeEnum.No_Patch_Error, 
			25u => TlvDownloadResponseErrorCodeEnum.Wrong_Anti_Rolback_Error, 
			32u => TlvDownloadResponseErrorCodeEnum.OTP_WR_Error, 
			33u => TlvDownloadResponseErrorCodeEnum.Invalid_Patch_PER_OTP_Error, 
			34u => TlvDownloadResponseErrorCodeEnum.Invalid_Patch_Header_Error, 
			35u => TlvDownloadResponseErrorCodeEnum.Invalid_RSA_Key_Error, 
			36u => TlvDownloadResponseErrorCodeEnum.Invalid_RSA_Signature_Error, 
			37u => TlvDownloadResponseErrorCodeEnum.Invalid_Serial_Number_Error, 
			_ => TlvDownloadResponseErrorCodeEnum.InvalidTlvDownloadResponseErrorCodeValue, 
		};
	}

	public static uint TlvDownloadResponseErrorCodeToValue(TlvDownloadResponseErrorCodeEnum enumItem)
	{
		return enumItem switch
		{
			TlvDownloadResponseErrorCodeEnum.Success => 0u, 
			TlvDownloadResponseErrorCodeEnum.Length_Error => 1u, 
			TlvDownloadResponseErrorCodeEnum.Version_Error => 2u, 
			TlvDownloadResponseErrorCodeEnum.Signature_Error => 3u, 
			TlvDownloadResponseErrorCodeEnum.No_Memory_Error => 4u, 
			TlvDownloadResponseErrorCodeEnum.NVM_Tag_Error => 5u, 
			TlvDownloadResponseErrorCodeEnum.NVM_Length_Error => 6u, 
			TlvDownloadResponseErrorCodeEnum.BT_Mode_Error => 7u, 
			TlvDownloadResponseErrorCodeEnum.Unknown_Error => 14u, 
			TlvDownloadResponseErrorCodeEnum.Type_Error => 16u, 
			TlvDownloadResponseErrorCodeEnum.Image_Type_Error => 17u, 
			TlvDownloadResponseErrorCodeEnum.CRC_Error => 19u, 
			TlvDownloadResponseErrorCodeEnum.ID_Error => 20u, 
			TlvDownloadResponseErrorCodeEnum.Wrong_Ver_Error => 21u, 
			TlvDownloadResponseErrorCodeEnum.Small_Ver_Error => 22u, 
			TlvDownloadResponseErrorCodeEnum.Region_Error => 23u, 
			TlvDownloadResponseErrorCodeEnum.No_Patch_Error => 24u, 
			TlvDownloadResponseErrorCodeEnum.Wrong_Anti_Rolback_Error => 25u, 
			TlvDownloadResponseErrorCodeEnum.OTP_WR_Error => 32u, 
			TlvDownloadResponseErrorCodeEnum.Invalid_Patch_PER_OTP_Error => 33u, 
			TlvDownloadResponseErrorCodeEnum.Invalid_Patch_Header_Error => 34u, 
			TlvDownloadResponseErrorCodeEnum.Invalid_RSA_Key_Error => 35u, 
			TlvDownloadResponseErrorCodeEnum.Invalid_RSA_Signature_Error => 36u, 
			TlvDownloadResponseErrorCodeEnum.Invalid_Serial_Number_Error => 37u, 
			_ => uint.MaxValue, 
		};
	}

	public static string TlvDownloadResponseErrorCodeToString(TlvDownloadResponseErrorCodeEnum enumItem)
	{
		return enumItem switch
		{
			TlvDownloadResponseErrorCodeEnum.Success => "Success", 
			TlvDownloadResponseErrorCodeEnum.Length_Error => "Length_Error", 
			TlvDownloadResponseErrorCodeEnum.Version_Error => "Version_Error", 
			TlvDownloadResponseErrorCodeEnum.Signature_Error => "Signature_Error", 
			TlvDownloadResponseErrorCodeEnum.No_Memory_Error => "No_Memory_Error", 
			TlvDownloadResponseErrorCodeEnum.NVM_Tag_Error => "NVM_Tag_Error", 
			TlvDownloadResponseErrorCodeEnum.NVM_Length_Error => "NVM_Length_Error", 
			TlvDownloadResponseErrorCodeEnum.BT_Mode_Error => "BT_Mode_Error", 
			TlvDownloadResponseErrorCodeEnum.Unknown_Error => "Unknown_Error", 
			TlvDownloadResponseErrorCodeEnum.Type_Error => "Type_Error", 
			TlvDownloadResponseErrorCodeEnum.Image_Type_Error => "Image_Type_Error", 
			TlvDownloadResponseErrorCodeEnum.CRC_Error => "CRC_Error", 
			TlvDownloadResponseErrorCodeEnum.ID_Error => "ID_Error", 
			TlvDownloadResponseErrorCodeEnum.Wrong_Ver_Error => "Wrong_Ver_Error", 
			TlvDownloadResponseErrorCodeEnum.Small_Ver_Error => "Small_Ver_Error", 
			TlvDownloadResponseErrorCodeEnum.Region_Error => "Region_Error", 
			TlvDownloadResponseErrorCodeEnum.No_Patch_Error => "No_Patch_Error", 
			TlvDownloadResponseErrorCodeEnum.Wrong_Anti_Rolback_Error => "Wrong_Anti_Rolback_Error", 
			TlvDownloadResponseErrorCodeEnum.OTP_WR_Error => "OTP_WR_Error", 
			TlvDownloadResponseErrorCodeEnum.Invalid_Patch_PER_OTP_Error => "Invalid_Patch_PER_OTP_Error", 
			TlvDownloadResponseErrorCodeEnum.Invalid_Patch_Header_Error => "Invalid_Patch_Header_Error", 
			TlvDownloadResponseErrorCodeEnum.Invalid_RSA_Key_Error => "Invalid_RSA_Key_Error", 
			TlvDownloadResponseErrorCodeEnum.Invalid_RSA_Signature_Error => "Invalid_RSA_Signature_Error", 
			TlvDownloadResponseErrorCodeEnum.Invalid_Serial_Number_Error => "Invalid_Serial_Number_Error", 
			_ => "Invalid TlvDownloadResponseErrorCode Value", 
		};
	}

	public static string TlvDownloadResponseErrorCodeToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x0 = Success");
		stringBuilder.AppendLine("0x1 = Length_Error");
		stringBuilder.AppendLine("0x2 = Version_Error");
		stringBuilder.AppendLine("0x3 = Signature_Error");
		stringBuilder.AppendLine("0x4 = No_Memory_Error");
		stringBuilder.AppendLine("0x5 = NVM_Tag_Error");
		stringBuilder.AppendLine("0x6 = NVM_Length_Error");
		stringBuilder.AppendLine("0x7 = BT_Mode_Error");
		stringBuilder.AppendLine("0xE = Unknown_Error");
		stringBuilder.AppendLine("0x10 = Type_Error");
		stringBuilder.AppendLine("0x11 = Image_Type_Error");
		stringBuilder.AppendLine("0x13 = CRC_Error");
		stringBuilder.AppendLine("0x14 = ID_Error");
		stringBuilder.AppendLine("0x15 = Wrong_Ver_Error");
		stringBuilder.AppendLine("0x16 = Small_Ver_Error");
		stringBuilder.AppendLine("0x17 = Region_Error");
		stringBuilder.AppendLine("0x18 = No_Patch_Error");
		stringBuilder.AppendLine("0x19 = Wrong_Anti_Rolback_Error");
		stringBuilder.AppendLine("0x20 = OTP_WR_Error");
		stringBuilder.AppendLine("0x21 = Invalid_Patch_PER_OTP_Error");
		stringBuilder.AppendLine("0x22 = Invalid_Patch_Header_Error");
		stringBuilder.AppendLine("0x23 = Invalid_RSA_Key_Error");
		stringBuilder.AppendLine("0x24 = Invalid_RSA_Signature_Error");
		stringBuilder.AppendLine("0x25 = Invalid_Serial_Number_Error");
		return stringBuilder.ToString();
	}
}
