using System.Security.Cryptography;

namespace SharpChat.Snowflake;

public class RandomSnowflake(
    SnowflakeGenerator? generator = null
) {
    public readonly SnowflakeGenerator Generator = generator ?? new SnowflakeGenerator();

    public long Next(DateTimeOffset? at = null) {
        return Generator.Next(Math.Abs(BitConverter.ToInt64(RandomNumberGenerator.GetBytes(8))), at);
    }
}