namespace PollMaker.Internal; internal sealed record PollState(string Question, string[] Options) { public List> Votes { get; } = Enumerable.Range(0, Options.Length).Select(_ => new HashSet()).ToList(); public bool IsOpen { get; private set; } = true; public void Close() => IsOpen = false; /// /// Toggle the member’s vote. /// Clicking the **same button** again removes their vote; /// clicking a **different** button moves the vote. /// public void ToggleVote(int optionIdx, ulong userId) { if (!IsOpen) return; if (Votes[optionIdx].Contains(userId)) { Votes[optionIdx].Remove(userId); return; } foreach (var set in Votes) set.Remove(userId); Votes[optionIdx].Add(userId); } }