using System.Text;

namespace QCRPG.TSL.BT.Packets;

public static class TransmitterPhyPreferenceInfo
{
	public static TransmitterPhyPreferenceEnumCollection ValueToTransmitterPhyPreference(uint value)
	{
		TransmitterPhyPreferenceEnumCollection transmitterPhyPreferenceEnumCollection = new TransmitterPhyPreferenceEnumCollection();
		transmitterPhyPreferenceEnumCollection.Le1mTxPhyPreference = Le1mPhyPreferenceInfo.ValueToLe1mPhyPreference(value & 1u);
		transmitterPhyPreferenceEnumCollection.Le2mTxPhyPreference = Le2mPhyPreferenceInfo.ValueToLe2mPhyPreference((value & 2) >> 1);
		transmitterPhyPreferenceEnumCollection.LeCodedTxPhyPreference = LeCodedPhyPreferenceInfo.ValueToLeCodedPhyPreference((value & 4) >> 2);
		return transmitterPhyPreferenceEnumCollection;
	}

	public static uint TransmitterPhyPreferenceToValue(TransmitterPhyPreferenceEnumCollection enumCollection)
	{
		uint num = 0u;
		num |= Le1mPhyPreferenceInfo.Le1mPhyPreferenceToValue(enumCollection.Le1mTxPhyPreference);
		num |= Le2mPhyPreferenceInfo.Le2mPhyPreferenceToValue(enumCollection.Le2mTxPhyPreference) << 1;
		return num | (LeCodedPhyPreferenceInfo.LeCodedPhyPreferenceToValue(enumCollection.LeCodedTxPhyPreference) << 2);
	}

	public static string TransmitterPhyPreferenceToString(TransmitterPhyPreferenceEnumCollection enumCollection)
	{
		string text = "";
		text = text + "LE 1M TX PHY Preference: " + Le1mPhyPreferenceInfo.Le1mPhyPreferenceToString(enumCollection.Le1mTxPhyPreference) + "\r\n";
		text = text + "LE 2M TX PHY Preference: " + Le2mPhyPreferenceInfo.Le2mPhyPreferenceToString(enumCollection.Le2mTxPhyPreference) + "\r\n";
		text = text + "LE Coded TX PHY Preference: " + LeCodedPhyPreferenceInfo.LeCodedPhyPreferenceToString(enumCollection.LeCodedTxPhyPreference) + "\r\n";
		return text.TrimEnd('\r', '\n');
	}

	public static string TransmitterPhyPreferenceToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("Bit 0: LE 1M TX PHY Preference");
		stringBuilder.AppendLine(Le1mPhyPreferenceInfo.Le1mPhyPreferenceToDescription());
		stringBuilder.AppendLine("Bit 1: LE 2M TX PHY Preference");
		stringBuilder.AppendLine(Le2mPhyPreferenceInfo.Le2mPhyPreferenceToDescription());
		stringBuilder.AppendLine("Bit 2: LE Coded TX PHY Preference");
		stringBuilder.AppendLine(LeCodedPhyPreferenceInfo.LeCodedPhyPreferenceToDescription());
		stringBuilder.AppendLine("Bits 7-3: Reserved for future use");
		return stringBuilder.ToString();
	}
}
