/*!
 * Copyright 2020-2021 VMware, Inc.
 * SPDX-License-Identifier: BSD-2-Clause
 */
import { ChangeDetectorRef, ElementRef, EventEmitter } from '@angular/core';
import { TranslationService } from '@vcd/i18n';
import { QuickSearchResultItem, QuickSearchResults } from './quick-search-result';
import { QuickSearchProvider } from './quick-search.provider';
import { QuickSearchService } from './quick-search.service';
/**
 * A group of search sections.
 */
interface GroupedSearchSections {
    /**
     * The i18n key for the header.
     */
    headerTitle: string;
    /**
     * All of the sections within this section.
     */
    subSections: SearchSection[];
}
interface SearchSection {
    provider: QuickSearchProvider;
    result: QuickSearchResults;
    isLoading: boolean;
    shouldShowText: boolean;
    hasPartialResult: PartialResult;
}
/**
 * A filter that can be applied to quick search to filter results.
 */
export interface QuickSearchFilter {
    id: string;
    options: QuickSearchFilterOption[];
}
/**
 * Represents a possible selection option for a filter.
 */
export interface QuickSearchFilterOption {
    /**
     * The displayed title of this option.
     */
    display: string;
    /**
     * Any optional data that is associated with this option.
     */
    data?: any;
}
/**
 * A filter that has a value typed in.
 */
export interface ActiveQuickSearchFilter extends QuickSearchFilter {
    value: string;
    data: any;
}
/**
 * This interface describes the event emitted when a result item is activated,
 * i.e. its event handler has been called.
 */
export interface ResultActivatedEvent {
    itemDisplayText: string;
    sectionTitle: string;
    eventSource: 'MouseEvent' | 'KeyboardEvent';
}
/**
 * This interface describes partial search result, i.e. result that do not contain all the items that match the
 * search criteria {@see QuickSearchComponent#hasPartialResult}
 */
interface PartialResult {
    /**
     * The number of the last item of the result
     */
    lastItem: number;
    /**
     * Total number of items in the result
     */
    totalItems: number;
}
/**
 * The Quick Search component is inspired by the Spotlight Search in Mac OSX (cmd+space)
 * and the Search Everywhere in IntelliJ (shift+shift)
 *
 * This VCD Quick Search does not provide any search by itself. It is not also a single component
 * but rather a group of objects that work together in order to allow the developer to build a might search experience
 * for the end user.
 *
 * Basically the VCD Quick Search consists of:
 * <ul>
 *     <li>QuickSearchComponent - the visual component that you should include in your template</li>
 *     <li>{@link QuickSearchService}<a href="/compodoc/injectables/QuickSearchService.html">QuickSearchService</a>
 *     - the service that you should register your own providers with</li>
 *     <li>{@link QuickSearchProvider}<a href="/compodoc/interfaces/QuickSearchProvider.html">QuickSearchProvider</a>
 *     - the interface your search provider should implement.
 *     It can return either an array of {@link QuickSearchResults} or a promise for lazy loading of results</li>
 * </ul>
 *
 * QuickSearchComponent:
 *
 *    <vcd-quick-search
 *        [(open)]="quickSearchOpen"
 *        [placeholder]="'Search ...'"
 *    ></vcd-quick-search>
 *
 *
 * {@link QuickSearchService}:
 *
 * This service works along with the component in order to provide search results displayed. Those results are grouped
 * in sections based on the registered provider {@link QuickSearchProvider}.
 *
 * You can provide order of the search providers, hence the order of the displayed sections
 *
 * If there is just one search provider no section title is displayed.
 *
 * In case of multiple search providers the Quick Search can be configured to hide the entire section if it contains no data.
 *
 *
 * For a complete end-to-end running example please take a look at the `Examples` tab of the live-docs
 */
export declare class QuickSearchComponent {
    private searchService;
    private changeDetectorRef;
    private el;
    translationService: TranslationService;
    /**
     * Placeholder for the search input. Default is empty string;
     */
    placeholder: string;
    /**
     * A helper text that will be placed below the search input.
     */
    helper: string;
    /**
     * This property alongside with `openChange` provide two-way binding [(open)] for controlling the visibility state
     * of the quick search component
     */
    set open(open: boolean);
    get open(): boolean;
    /**
     * A list of filters that can be used to filter the list of providers and/or the results from a given provider.
     *
     * All filters have some ID that is displayed and a list of options for their value. These options can also have associated data.
     * A provider then must know a) if it can respond to a given filter and b) how to filter the search results given the filter.
     * This means that if Filter A is present, and Provider 1 cannot respond to it, Provider 1 will not be displayed. Provider 2 must
     * then filter it's results based on the filter.
     *
     * If two filters of different IDs are used in the search, the filters should act like and's. If two filters of the same ID
     * are present in the search, the filter should act like an or.
     */
    filters: QuickSearchFilter[];
    /**
     * Outputs an event when the user changes the pinning status of this component.
     */
    isPinnedChange: EventEmitter<boolean>;
    /**
     * This method along with `open` property provide two-way binding [(open)] for controlling the visibility state
     * of the quick search component
     */
    openChange: EventEmitter<boolean>;
    /**
     * Event dispatched when item has been activated, i.e. its event handler is called.
     * This happens when item is clicked or 'Enter' is pressed when there is a selection.
     */
    resultActivated: EventEmitter<ResultActivatedEvent>;
    isPinned: boolean;
    constructor(searchService: QuickSearchService, changeDetectorRef: ChangeDetectorRef, el: ElementRef, translationService: TranslationService);
    get searchCriteria(): string;
    set searchCriteria(value: string);
    /**
     * Represents the current filter that the user is typing into.
     */
    filterBeingEdited: QuickSearchFilter;
    /**
     * The options for the current filter being edited
     */
    filterBeingEditedOptions: QuickSearchFilterOption[];
    private _searchCriteria;
    private _open;
    searchInput: ElementRef;
    filterOptionsDropdown: ElementRef;
    measurementDiv: ElementRef;
    private searchId;
    private currentActiveFilters;
    /**
     * The search sections are provided by the {@link QuickSearchService} upon opening the Quick Search.
     * This insures that new sections based on the current context of the application may appear.
     *
     * The groupedSearchSections are sections that come from Nested providers and are a double deep list of results with
     * a parent section name, and sub section names.
     *
     * The ungroupedSearchSections are sections that come from Search providers and are a single list of results with a section name.
     */
    groupedSearchSections: GroupedSearchSections[];
    ungroupedSearchSections: SearchSection[];
    /**
     * The selected result in the results section.
     */
    selectedItem: QuickSearchResultItem;
    /**
     * The current selected dropdown in the filter options dropdown.
     */
    currentFilterOptionSelection: QuickSearchFilterOption;
    itemClicked(item: QuickSearchResultItem): void;
    onArrowDown(event: KeyboardEvent): void;
    onArrowUp(event: KeyboardEvent): void;
    onEnterKey(event: any): void;
    getFlattenedSearchSections(): SearchSection[];
    private getLastFilter;
    private getFilterOptionsMatchSearch;
    autofillSelectedFilterOption(option: string): void;
    togglePinned(): void;
    private doSearch;
    /**
     * Try to select the first item in the compound search result.
     * @param ensureFirstSectionIsLoaded if true and if the topmost section is still loading then do not select an item
     */
    private selectFirst;
    private selectNext;
    private genericSelectNext;
    /**
     * Handle showing / hiding of the Quick Search.
     * @param open true when opening, false when closing
     */
    private handleOpen;
    private updateActiveSections;
    private handleItem;
    private showSectionTitle;
    showParentSectionTitle(parentSection: GroupedSearchSections): boolean;
    showNoResults(searchSection: SearchSection): boolean;
    /**
     * Determines if the result in this section is partial (i.e. there are more items matching the criteria which are
     * in the current list) or it is full (the current list contains all the items matching the criteria)
     * If the result is partial then {@link PartialResult} object is returned. If the result contains all the items
     * then null is returned
     * @param searchSection the section which result items is to be checked
     */
    private hasPartialResult;
    /**
     * Parses the given search criteria to remove all filters and separate them.
     *
     * @example this.parseSearchCriteria('searchTerm filter:value other:value') =>
     * {
     *    searchTerm: 'searchTerm',
     *    filters: [{ id: 'filter', value: 'value', ...}, { id: 'other', value: 'value'}]
     * }
     */
    private parseSearchCriteria;
    groupSectionTrackBy(_index: number, groupedSection: GroupedSearchSections): string;
    sectionTrackBy(_index: number, searchSection: SearchSection): string;
    filterOptionTrackBy(_index: number, filterOption: QuickSearchFilterOption): string;
}
export {};
