Implement an image carousel that supports:
-
cycling forward/backward and autoplay with a configurable interval;
-
a per-image comment thread with create/read/edit/delete;
-
upvoting/downvoting comments and returning the top-k comments per image ordered by score, breaking ties by recency. Design the data structures to support add/delete comment, update vote, and query top-k efficiently at scale (up to 10^5 images and 10^6 comments across images). Specify the time/space complexities, the APIs you would expose (including pagination of comments), and how you would prevent double-counting when a user rapidly toggles votes.