namespace WxAgent.Core; public enum WechatScrollDirection { Up, Down } public sealed record WechatSessionScrollResult( int Scrolls, bool ViewportChanged, IReadOnlyList Sessions); public sealed record WechatMessagePosition(ChatMessageSnapshot Message, int Scrolls); public static class WechatNavigationRules { public static void ValidateScrollLimit(int pages) { if (pages is < 1 or > 100) throw new WxAgentException(WxAgentErrorCode.InvalidArgument, "Scroll limit must be between 1 and 100."); } public static ChatMessageSnapshot? FindMessage(IReadOnlyList messages, string fingerprint) { if (fingerprint.Length != 64 || !fingerprint.All(char.IsAsciiHexDigit)) throw new WxAgentException(WxAgentErrorCode.InvalidArgument, "A 64-character visible-message fingerprint is required."); var matches = messages.Where(message => string.Equals(message.Fingerprint, fingerprint, StringComparison.OrdinalIgnoreCase)).Take(2).ToArray(); if (matches.Length > 1) throw new WxAgentException(WxAgentErrorCode.InvalidOperationState, "More than one visible message matches the fingerprint."); return matches.SingleOrDefault(); } }