import { ReplaySubject } from 'rxjs';
import { QuickSearchNestedProvider, QuickSearchProvider } from './quick-search.provider';
import { QuickSearchResults } from '.';
import * as i0 from "@angular/core";
/**
 * A group of search sections.
 */
export interface GroupedSearchSections {
    /**
     * The i18n key for the header.
     */
    headerTitle: string;
    /**
     * All of the sections within this section.
     */
    subSections: SearchSection[];
}
export interface SearchSection {
    provider: QuickSearchProvider;
    result: QuickSearchResults;
    isLoading: boolean;
    shouldShowText: boolean;
    hasPartialResult: PartialResult;
    icon?: string;
}
/**
 * A filter that can be applied to quick search to filter results.
 */
export interface QuickSearchFilter {
    /**
     * The unique ID of this filter.
     */
    id: string;
    /**
     * The options that are displayed in the dropdown.
     */
    options: QuickSearchFilterOption[];
    /**
     * The text displayed on the button to open the dropdown.
     */
    dropdownText: string;
    /**
     * The i18n key for the selection bubble of this filter. Is passed one parameter {display} which is the value selected.
     */
    bubbleI18nKey: string;
    /**
     * The order of the filter when displaying the filters. The lower the order, the closer to the beginning.
     * undefined and -1 means append
     */
    order?: number;
}
/**
 * Represents a possible selection option for a filter.
 */
export interface QuickSearchFilterOption {
    /**
     * The displayed title of this option.
     */
    display: string;
    /**
     * The key of this quick search filter option.
     */
    key: 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 {
    /**
     * The key value of the selected option.
     */
    value: string;
    /**
     * Any date assocated with this filter option.
     */
    data: any;
}
/**
 * This interface describes partial search result, i.e. result that do not contain all the items that match the
 * search criteria {@see QuickSearchComponent#hasPartialResult}
 */
export interface PartialResult {
    /**
     * The number of the last item of the result
     */
    lastItem: number;
    /**
     * Total number of items in the result
     */
    totalItems: number;
}
export declare class QuickSearchService {
    private registrations;
    private nestedProviders;
    private searchId;
    private filterValues;
    /**
     * The filters the last search was run with.
     */
    private lastActiveFilters;
    /**
     * The term the last search was run with.
     */
    private lastSearchCriteria;
    /**
     * 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.
     *
     * These two events emit when anything about the search sections changes.
     */
    groupedSearchSectionChanged: ReplaySubject<GroupedSearchSections[]>;
    ungroupedSearchSectionChanged: ReplaySubject<SearchSection[]>;
    private _groupedSearchSections;
    private _ungroupedSearchSections;
    /**
     * Emits a value when any information about the filter selection changes.
     */
    filterValueChanges: ReplaySubject<Map<string, QuickSearchFilterOption[]>>;
    /**
     * The current set of registered filters.
     */
    filters: QuickSearchFilter[];
    /**
     * If the quick search modal is pinned.
     */
    isPinned: boolean;
    /**
     * If any section is loading.
     */
    isLoading: boolean;
    /**
     * If all sections return no results.
     */
    hasNoResults: boolean;
    /**
     * Register a search provider
     * @param provider The search provider {@link QuickSearchProvider}
     */
    registerProvider(provider: QuickSearchProvider): void;
    /**
     * Unregister a search provider by providing the registration id.
     * Returns true if un-registration was done.
     * @param provider Provider to be unregistered
     */
    unregisterProvider(provider: QuickSearchProvider): boolean;
    /**
     * Registers a nested provider to search for results in quick search.
     */
    registerNestedProvider(nestedProvider: QuickSearchNestedProvider): void;
    unregisterNestedProvider(nestedProvider: QuickSearchNestedProvider): boolean;
    /**
     * Get a list of all the registered search providers.
     */
    getRegisteredProviders(filters?: ActiveQuickSearchFilter[]): QuickSearchProvider[];
    /**
     * Gives the list of currently active providers given the set of filters.
     */
    getRegisteredNestedProviders(filters?: ActiveQuickSearchFilter[]): QuickSearchNestedProvider[];
    /**
     * Adds a filter to the list of registered filters. A filter 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
     * 1. If it can respond to a given filter</li>
     * 2. How to filter the search results given the filter</li>
     *
     * 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 its 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.
     */
    registerFilter(filter: QuickSearchFilter): void;
    /**
     * Removes the given filterId from the list of registered filters.
     */
    unregisterFilter(filterId: string): void;
    /**
     * Selects the given filterValue on the filter represented by the given filterId.
     *
     * @param clear clears the selection before setting if set to true, and defaults to true.
     *
     * @example selectFilter('type', 'org') selects the Organization option in the "Type" filter.
     */
    selectFilter(filterId: string, filterValues: string[], clear?: boolean): void;
    /**
     * Searches all the providers given the search term and the active filters.
     *
     * @param force runs the search even if the active filters and search term has not changed.
     */
    doSearch(searchCriteria: string, force?: boolean, afterSectionLoad?: () => void): Promise<SearchSection[]>;
    /**
     * Builds an array of the currently active quick search filters.
     */
    private buildActiveFilters;
    /**
     * Updates the active search providers based on the active filters.
     */
    private updateActiveSections;
    /**
     * Gives whether the given option on the given filter is selected.
     */
    private getFilterOptionValue;
    /**
     * Gives all the options selected for the given filter.
     */
    private getFilterValue;
    /**
     * Gives the search sections as a single flat list.
     */
    private getFlattenedSearchSections;
    /**
     * Says if the given provider should be active given the filters selected.
     */
    private providerShouldBeActive;
    /**
     * 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;
    /**
     * Says if the title of the given search section should be shown.
     */
    private showSectionTitle;
    /**
     * Says if all providers have returned no results.
     */
    private checkHasNoResults;
    static ɵfac: i0.ɵɵFactoryDeclaration<QuickSearchService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<QuickSearchService>;
}
