using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class ExtendedFeaturesPage1Info
{
	public static ExtendedFeaturesPage1EnumCollection ValueToExtendedFeaturesPage1(ulong value)
	{
		ExtendedFeaturesPage1EnumCollection extendedFeaturesPage1EnumCollection = new ExtendedFeaturesPage1EnumCollection();
		extendedFeaturesPage1EnumCollection.SecureSimplePairingHostSupport = SupportBitInfo.ValueToSupportBit((uint)(value & 1));
		extendedFeaturesPage1EnumCollection.LeSupportedHost = SupportBitInfo.ValueToSupportBit((uint)((value & 2) >> 1));
		extendedFeaturesPage1EnumCollection.SimultaneousLeAndBrEdrToSameDeviceCapableHost = SupportBitInfo.ValueToSupportBit((uint)((value & 4) >> 2));
		extendedFeaturesPage1EnumCollection.SecureConnectionsHostSupport = SupportBitInfo.ValueToSupportBit((uint)((value & 8) >> 3));
		return extendedFeaturesPage1EnumCollection;
	}

	public static ulong ExtendedFeaturesPage1ToValue(ExtendedFeaturesPage1EnumCollection enumCollection)
	{
		ulong num = 0uL;
		num |= SupportBitInfo.SupportBitToValue(enumCollection.SecureSimplePairingHostSupport);
		num |= SupportBitInfo.SupportBitToValue(enumCollection.LeSupportedHost) << 1;
		num |= SupportBitInfo.SupportBitToValue(enumCollection.SimultaneousLeAndBrEdrToSameDeviceCapableHost) << 2;
		return num | (SupportBitInfo.SupportBitToValue(enumCollection.SecureConnectionsHostSupport) << 3);
	}

	public static string ExtendedFeaturesPage1ToString(ExtendedFeaturesPage1EnumCollection enumCollection)
	{
		string text = "";
		text = text + "Secure Simple Pairing Host Support: " + SupportBitInfo.SupportBitToString(enumCollection.SecureSimplePairingHostSupport) + "\r\n";
		text = text + "LE Supported Host: " + SupportBitInfo.SupportBitToString(enumCollection.LeSupportedHost) + "\r\n";
		text = text + "Simultaneous LE and BR EDR to Same Device Capable Host: " + SupportBitInfo.SupportBitToString(enumCollection.SimultaneousLeAndBrEdrToSameDeviceCapableHost) + "\r\n";
		text = text + "Secure Connections Host Support: " + SupportBitInfo.SupportBitToString(enumCollection.SecureConnectionsHostSupport) + "\r\n";
		return text.TrimEnd('\r', '\n');
	}

	public static string ExtendedFeaturesPage1ToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("Bit 0: Secure Simple Pairing Host Support");
		stringBuilder.AppendLine(SupportBitInfo.SupportBitToDescription());
		stringBuilder.AppendLine("Bit 1: LE Supported Host");
		stringBuilder.AppendLine(SupportBitInfo.SupportBitToDescription());
		stringBuilder.AppendLine("Bit 2: Simultaneous LE and BR EDR to Same Device Capable Host");
		stringBuilder.AppendLine(SupportBitInfo.SupportBitToDescription());
		stringBuilder.AppendLine("Bit 3: Secure Connections Host Support");
		stringBuilder.AppendLine(SupportBitInfo.SupportBitToDescription());
		return stringBuilder.ToString();
	}
}
