+ showSearchGlobalHelp () {
+ return this.search && this.areSuggestionsOpened && this.keyboardEventsManager?.activeItem?.result?.type === 'search-index'
+ }
+
+ canSearchAnyURI () {
+ if (!this.serverConfig) return false
+
+ return this.authService.isLoggedIn()
+ ? this.serverConfig.search.remoteUri.users
+ : this.serverConfig.search.remoteUri.anonymous
+ }
+
+ onSearchChange () {
+ this.computeTypeahead()
+ }
+
+ initKeyboardEventsManager () {
+ if (this.keyboardEventsManager) return
+
+ this.keyboardEventsManager = new ListKeyManager(this.suggestionItems)
+
+ const activeIndex = this.suggestionItems.toArray().findIndex(i => i.result.default === true)
+ if (activeIndex === -1) {
+ logger.error('Cannot find active index.', { suggestionItems: this.suggestionItems })
+ }
+
+ this.updateItemsState(activeIndex)
+
+ this.keyboardEventsManager.change.subscribe(
+ _ => this.updateItemsState()
+ )
+ }
+
+ computeTypeahead () {
+ const searchIndexConfig = this.serverConfig.search.searchIndex
+
+ if (!this.activeSearch) {
+ if (searchIndexConfig.enabled && (searchIndexConfig.isDefaultSearch || searchIndexConfig.disableLocalSearch)) {
+ this.activeSearch = 'search-index'
+ } else {
+ this.activeSearch = 'search-instance'