import {offset, type Offset} from "caret-pos"; import {Component} from "preact"; import {type UserLabelsData} from "../../storage/exports.js"; import {log, querySelectorAll} from "../../utilities/exports.js"; type Props = { /** * Whether the Anonymize Usernames feature is enabled, in which case this * feature needs to handle collecting usernames a little differently. */ anonymizeUsernamesEnabled: boolean; /** The list of known groups to use for the group autocompletions. */ knownGroups: Set; /** * All the User Labels the user has saved to use for additional username * completions. */ userLabels: UserLabelsData; }; type State = { /** All the groups without leading tildes. */ groups: Set; /** Whether the group autocompletion list is hidden or not. */ groupsHidden: boolean; /** The current set of group matches. */ groupsMatches: Set; /** The position where the group autocompletion list should be shown. */ groupsPosition: Offset | undefined; /** The currently highlighted match index of the active list. */ highlightedIndex: number; /** Whether the user is currently typing in an autocomplete section. */ typingInAutocomplete: boolean; /** All the usernames without leading @-symbols. */ usernames: Set; /** Whether the username autocompletion list is hidden or not. */ usernamesHidden: boolean; /** The current set of username matches. */ usernamesMatches: Set; /** The position where the username autocompletion list should be shown. */ usernamesPosition: Offset | undefined; }; /** All the properties we need to handle `