Build a hashtag selector UI.
Asked in the onsite (React) stage. Implement the suggestion-ranking logic for the active hashtag token.
Implement select_hashtags(text, hashtags, limit). text is a string, and hashtags is a list of objects with string tag and integer usage fields. Return up to limit tag strings. The active token is the final whitespace-delimited token only when text does not end in whitespace, starts with #, and contains at least one character after #. Match case-insensitively, exclude hashtags already present in earlier tokens, and sort by descending usage then case-insensitive tag name.
def select_hashtags(text, hashtags, limit):