import React from "react";
import { Options } from "./SortResults";
export declare const OpenK9ClientContext: React.Context<{
    authInit: Promise<boolean> | null;
    authenticate({ token }: {
        token?: string;
    }): Promise<void>;
    deauthenticate(): Promise<void>;
    getUserProfile(): Promise<{}>;
    getGenerateResponse({ searchQuery, controller, }: {
        searchQuery: GenerateRequest;
        controller: AbortController;
    }): Promise<Response>;
    getServiceStatus(): Promise<"up" | "down">;
    doSearch<E>(searchRequest: SearchRequest): Promise<SearchResult<E>>;
    generateResponse<E>(searchRequest: GenerateRequest): Promise<any>;
    getDateFilterFields(): Promise<{
        id: number;
        field: string;
        label: string;
    }[]>;
    getLabelSort(): Promise<{
        field: string;
        id: number;
        label: string;
    }[]>;
    getLanguages(): Promise<{
        createDate: any;
        modifiedDate: any;
        id: number;
        name: string;
        value: "value";
    }[]>;
    getSortingInfo(): Promise<{
        field: string;
        id: number;
        isDefault: boolean;
        type: string;
        label: string;
        translationMap: {
            "label.en_US"?: string;
            "label.es_ES"?: string;
            "label.it_IT"?: string;
        };
    }[]>;
    getRefreshFilters(): Promise<{
        retrieveType: string;
        refreshOnSuggestionCategory: boolean;
        refreshOnTab: boolean;
        refreshOnDate: boolean;
        refreshOnQuery: boolean;
    }>;
    getLanguageDefault(): Promise<{
        value: string;
    }>;
    getSuggestions({ searchQuery, suggestionCategoryId, range, afterKey, suggestKeyword, order, language, }: {
        searchQuery: SearchToken[];
        suggestionCategoryId?: number;
        range?: [number, number];
        afterKey?: string;
        suggestKeyword?: string;
        order: "desc" | "asc";
        language: string;
    }): Promise<{
        result: SuggestionResult[];
        afterKey: string;
    }>;
    getAutocompletes({ searchText, }: {
        searchText: string;
    }): Promise<AutocompleteResponse>;
    handle_dynamic_filters(): Promise<{
        handleDynamicFilters: boolean;
    }>;
    getSuggestionCategories(): Promise<SuggestionsCategoriesResult>;
    getTabsByVirtualHost(): Promise<Array<{
        label: string;
        tokens: Array<SearchToken>;
        translationMap: {
            [key: string]: string;
        };
        sortings: Options;
    }>>;
    getTemplatesByVirtualHost(): Promise<Array<string>>;
    loadTemplate<E>(id: string): Promise<Template<E> | null>;
    fetchQueryAnalysis(request: AnalysisRequest): Promise<AnalysisResponse | null>;
}>;
export declare function useOpenK9Client(): {
    authInit: Promise<boolean> | null;
    authenticate({ token }: {
        token?: string;
    }): Promise<void>;
    deauthenticate(): Promise<void>;
    getUserProfile(): Promise<{}>;
    getGenerateResponse({ searchQuery, controller, }: {
        searchQuery: GenerateRequest;
        controller: AbortController;
    }): Promise<Response>;
    getServiceStatus(): Promise<"up" | "down">;
    doSearch<E>(searchRequest: SearchRequest): Promise<SearchResult<E>>;
    generateResponse<E>(searchRequest: GenerateRequest): Promise<any>;
    getDateFilterFields(): Promise<{
        id: number;
        field: string;
        label: string;
    }[]>;
    getLabelSort(): Promise<{
        field: string;
        id: number;
        label: string;
    }[]>;
    getLanguages(): Promise<{
        createDate: any;
        modifiedDate: any;
        id: number;
        name: string;
        value: "value";
    }[]>;
    getSortingInfo(): Promise<{
        field: string;
        id: number;
        isDefault: boolean;
        type: string;
        label: string;
        translationMap: {
            "label.en_US"?: string;
            "label.es_ES"?: string;
            "label.it_IT"?: string;
        };
    }[]>;
    getRefreshFilters(): Promise<{
        retrieveType: string;
        refreshOnSuggestionCategory: boolean;
        refreshOnTab: boolean;
        refreshOnDate: boolean;
        refreshOnQuery: boolean;
    }>;
    getLanguageDefault(): Promise<{
        value: string;
    }>;
    getSuggestions({ searchQuery, suggestionCategoryId, range, afterKey, suggestKeyword, order, language, }: {
        searchQuery: SearchToken[];
        suggestionCategoryId?: number;
        range?: [number, number];
        afterKey?: string;
        suggestKeyword?: string;
        order: "desc" | "asc";
        language: string;
    }): Promise<{
        result: SuggestionResult[];
        afterKey: string;
    }>;
    getAutocompletes({ searchText, }: {
        searchText: string;
    }): Promise<AutocompleteResponse>;
    handle_dynamic_filters(): Promise<{
        handleDynamicFilters: boolean;
    }>;
    getSuggestionCategories(): Promise<SuggestionsCategoriesResult>;
    getTabsByVirtualHost(): Promise<Array<{
        label: string;
        tokens: Array<SearchToken>;
        translationMap: {
            [key: string]: string;
        };
        sortings: Options;
    }>>;
    getTemplatesByVirtualHost(): Promise<Array<string>>;
    loadTemplate<E>(id: string): Promise<Template<E> | null>;
    fetchQueryAnalysis(request: AnalysisRequest): Promise<AnalysisResponse | null>;
};
declare global {
    interface Window {
        KEYCLOAK_URL: string;
        KEYCLOAK_REALM: string;
        KEYCLOAK_CLIENT_ID: string;
    }
}
export declare function OpenK9Client({ onAuthenticated, tenant, useKeycloak, waitKeycloackForToken, callback, }: {
    onAuthenticated(): void;
    tenant: string;
    useKeycloak?: boolean;
    waitKeycloackForToken: boolean;
    callback(): void | null | undefined;
}): {
    authInit: Promise<boolean> | null;
    authenticate({ token }: {
        token?: string;
    }): Promise<void>;
    deauthenticate(): Promise<void>;
    getUserProfile(): Promise<{}>;
    getGenerateResponse({ searchQuery, controller, }: {
        searchQuery: GenerateRequest;
        controller: AbortController;
    }): Promise<Response>;
    getServiceStatus(): Promise<"up" | "down">;
    doSearch<E>(searchRequest: SearchRequest): Promise<SearchResult<E>>;
    generateResponse<E>(searchRequest: GenerateRequest): Promise<any>;
    getDateFilterFields(): Promise<{
        id: number;
        field: string;
        label: string;
    }[]>;
    getLabelSort(): Promise<{
        field: string;
        id: number;
        label: string;
    }[]>;
    getLanguages(): Promise<{
        createDate: any;
        modifiedDate: any;
        id: number;
        name: string;
        value: "value";
    }[]>;
    getSortingInfo(): Promise<{
        field: string;
        id: number;
        isDefault: boolean;
        type: string;
        label: string;
        translationMap: {
            "label.en_US"?: string;
            "label.es_ES"?: string;
            "label.it_IT"?: string;
        };
    }[]>;
    getRefreshFilters(): Promise<{
        retrieveType: string;
        refreshOnSuggestionCategory: boolean;
        refreshOnTab: boolean;
        refreshOnDate: boolean;
        refreshOnQuery: boolean;
    }>;
    getLanguageDefault(): Promise<{
        value: string;
    }>;
    getSuggestions({ searchQuery, suggestionCategoryId, range, afterKey, suggestKeyword, order, language, }: {
        searchQuery: SearchToken[];
        suggestionCategoryId?: number;
        range?: [number, number];
        afterKey?: string;
        suggestKeyword?: string;
        order: "desc" | "asc";
        language: string;
    }): Promise<{
        result: SuggestionResult[];
        afterKey: string;
    }>;
    getAutocompletes({ searchText, }: {
        searchText: string;
    }): Promise<AutocompleteResponse>;
    handle_dynamic_filters(): Promise<{
        handleDynamicFilters: boolean;
    }>;
    getSuggestionCategories(): Promise<SuggestionsCategoriesResult>;
    getTabsByVirtualHost(): Promise<Array<{
        label: string;
        tokens: Array<SearchToken>;
        translationMap: {
            [key: string]: string;
        };
        sortings: Options;
    }>>;
    getTemplatesByVirtualHost(): Promise<Array<string>>;
    loadTemplate<E>(id: string): Promise<Template<E> | null>;
    fetchQueryAnalysis(request: AnalysisRequest): Promise<AnalysisResponse | null>;
};
export type GenericResultItem<E = {}> = {
    source: {
        documentTypes: (keyof E)[];
        contentId: string;
        id: string;
        parsingDate: number;
        rawContent: string;
        tenantId: number;
        datasourceId: number;
        entities?: Array<{
            entityType: string;
            context: DeepKeys<Without<GenericResultItem<E>["source"], "entities">>[];
            id: string;
        }>;
        resources: {
            binaries: {
                id: string;
                name: string;
                contentType: string;
                resourceId: string;
            }[];
        };
    } & E;
    highlight: {
        [field in GenericResultItemFields<E>]?: string[];
    };
    sortAfterKey: string;
};
export type GenericResultItemFields<E> = DeepKeys<Without<GenericResultItem<E>["source"], "type" | "entities">>;
type PathImpl<T, Key extends keyof T> = Key extends string ? T[Key] extends Record<string, any> ? `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> & string}` | `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : never : never;
type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
type DeepKeys<T> = PathImpl2<T> extends string | keyof T ? PathImpl2<T> : keyof T;
type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
export type Template<E> = {
    resultType: string;
    priority: number;
    result: React.FC<ResultRendererProps<E>>;
    detail: React.FC<DetailRendererProps<E>>;
};
export type ResultRendererProps<E> = {
    result: GenericResultItem<E>;
};
export type DetailRendererProps<E> = {
    result: GenericResultItem<E>;
};
export type SearchToken = {
    tokenType: "DATASOURCE";
    keywordKey?: undefined;
    values: string[];
    filter: boolean;
    suggestionCategoryId?: number;
    count?: string;
    isTab?: boolean;
    isFilter?: boolean;
    search?: boolean;
} | {
    tokenType: "DOCTYPE";
    keywordKey: "type";
    values: string[];
    filter: boolean;
    suggestionCategoryId?: number;
    count?: string;
    isTab?: boolean;
    isFilter?: boolean;
    search?: boolean;
} | {
    tokenType: "TEXT";
    keywordKey?: string;
    values: string[];
    filter: boolean;
    goToSuggestion?: boolean;
    overrideSearchWithCorrection?: boolean;
    label?: string;
    suggestionCategoryId?: number;
    count?: string;
    isTab?: boolean;
    isFilter?: boolean;
    search?: boolean;
    extra?: {
        boost?: string;
        fuzziness?: string;
    };
} | {
    tokenType: "ENTITY";
    keywordKey?: string;
    entityType: string;
    entityName: string;
    values: string[];
    filter: boolean;
    suggestionCategoryId?: number;
    count?: string;
    isTab?: boolean;
    isFilter?: boolean;
    search?: boolean;
} | {
    tokenType: "DATE";
    keywordKey?: string;
    extra: {
        gte: number;
        lte: number;
    };
    suggestionCategoryId?: number;
    count?: string;
    values?: string[];
    isTab?: boolean;
    isFilter?: boolean;
    search?: boolean;
} | {
    tokenType: "FILTER";
    keywordKey?: string;
    values: string[];
    filter: boolean;
    goToSuggestion?: boolean;
    label?: string;
    suggestionCategoryId?: number;
    count?: string;
    isTab?: boolean;
    isFilter?: boolean;
    search?: boolean;
};
export type SortField = {
    [key: string]: {
        sort: "asc" | "desc";
        missing: "_last";
    };
};
export type AutocompleteResponseWrapped = {
    items: AutocompleteSuggestion[];
};
export type AutocompleteSuggestion = {
    autocomplete: string;
    labelDocType: string;
};
export type AutocompleteResponse = AutocompleteSuggestion[];
export type AutocompleteRequest = {
    queryText: string;
};
export type AutocompleteEsQuery = {
    _source: {
        includes: Array<"web.title" | "web.productName" | string>;
    };
    query: {
        multi_match: {
            fields: Array<"web.title.searchasyou" | "web.productName.searchasyou" | string>;
            fuzziness: "AUTO" | number | string;
            minimum_should_match: string;
            operator: "or" | "and";
            query: string;
            type: "bool_prefix";
        };
    };
    size: number;
    sort: Array<{
        _score: {
            order: "asc" | "desc";
        };
    }>;
};
type SearchRequest = {
    searchQuery: Array<SearchToken>;
    range: [number, number];
    sort: SortField[];
    language: string;
    sortAfterKey: string;
    overrideSearchWithCorrection?: boolean;
};
export type GenerateRequest = {
    searchQuery: Array<SearchToken>;
    range: [number, number];
    sort: SortField[];
    language: string;
    sortAfterKey: string;
    searchText: string;
};
type SearchResult<E> = {
    result: Array<GenericResultItem<E>>;
    total: number;
    autocorrection: AutocorrectionType;
};
export type AutocorrectionType = {
    originalText: string;
    searchedWithCorrectedText: boolean;
    autocorrectionText: string;
    suggestions: [
        {
            offset: number;
            length: number;
            text: string;
            correction: string;
        }
    ];
};
export type AnalysisToken = {
    tokenType: "DOCTYPE";
    value: string;
    label: string;
} | {
    tokenType: "DATASOURCE";
    value: string;
    label: string;
} | {
    tokenType: "ENTITY";
    entityType: string;
    entityName: string;
    keywordKey?: string;
    value: string;
    label: string;
} | {
    tokenType: "TEXT";
    keywordKey?: string;
    keywordName?: string;
    value: string;
    label: string;
    extra?: {
        boost?: string;
        fuzziness?: string;
    };
} | {
    tokenType: "AUTOCORRECT";
    value: string;
    label: string;
} | {
    tokenType: "AUTOCOMPLETE";
    value: string;
    label: string;
} | {
    tokenType: "FILTER";
    keywordKey?: string;
    keywordName?: string;
    value: string;
    label: string;
};
export type AnalysisRequest = {
    searchText: string;
    tokens: Array<AnalysisRequestEntry>;
};
export type AnalysisRequestEntry = {
    text: string;
    start: number;
    end: number;
    token: AnalysisToken;
};
export type AnalysisResponse = {
    searchText: string;
    analysis: Array<AnalysisResponseEntry>;
};
export type AnalysisResponseEntry = {
    text: string;
    start: number;
    end: number;
    tokens: Array<AnalysisToken & {
        score: number;
    }>;
};
export type SuggestionResult = {
    tokenType: "DATASOURCE";
    suggestionCategoryId: number;
    value: string;
    keywordKey?: string;
    count?: string;
} | {
    tokenType: "TEXT";
    suggestionCategoryId: number;
    keywordKey?: string;
    value: string;
    count?: string;
} | {
    tokenType: "ENTITY";
    suggestionCategoryId: number;
    entityType: string;
    entityValue: string;
    keywordKey?: string;
    value: string;
    count?: string;
} | {
    tokenType: "DOCTYPE";
    suggestionCategoryId: number;
    value: string;
    keywordKey?: string;
    count?: string;
} | {
    tokenType: "FILTER";
    suggestionCategoryId: number;
    keywordKey?: string;
    value: string;
    count?: string;
};
type SuggestionsCategoriesResult = Array<{
    name: string;
    id: number;
    multiSelect: boolean;
    translationMap: {
        [key: string]: string;
    };
}>;
export {};
