import * as i0 from '@angular/core';
import { OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
import * as i1 from '@angular/common';
import * as i2 from 'primeng/table';
import { Table } from 'primeng/table';
import { IdType, getRelatedValue, IRelatedFieldOptions } from 'imng-nrsrx-client-utils';
import { Observable } from 'rxjs';
import { Expander, Computation, IFilter, ICompositeFilter, ODataQuery } from 'imng-odata-client';
import { SortMeta, FilterMetadata, LazyLoadEvent } from 'primeng/api';
import { Subscribable, Subscriptions } from 'imng-ngrx-utils';
import { Router } from '@angular/router';
import { EnumProperties, getEnumDisplayText } from 'openapi-ts-generator/enums';

interface PrimeTableState {
    first?: number;
    last?: number;
    rows?: number;
    multiSortMeta?: SortMeta[];
    globalFilter?: string[];
    filters?: {
        [s: string]: FilterMetadata[];
    };
    expand?: Array<Expander>;
    /**
     * Specifies the list of properties to retrieve
     */
    select?: string[];
    /**
     * Request a total count of records.
     * Note: Filter expressions will affect this value.
     * Default: true
     */
    count?: boolean;
    /**
     * Specifies aggregation behavior for the collection of entries.
     */
    apply?: string;
    /**
     * Specifies computed properties that can be used in $select, $filter or $orderby expressions.
     */
    compute?: Array<Computation | string>;
}

interface IPrimeODataTableFacade<Entity extends {
    id?: IdType | null;
}> {
    activeEffectCount$: Observable<number>;
    tableState$: Observable<PrimeTableState>;
    tableData$: Observable<Entity[]>;
    totalRecordCount$: Observable<number | undefined>;
    loadEntities(primeTableState: PrimeTableState): void;
    reloadEntities(primeTableState?: PrimeTableState): void;
}

declare abstract class ImngPrimeODataTableBaseComponent<ENTITY extends {
    id?: IdType | null;
}, FACADE extends IPrimeODataTableFacade<ENTITY>> implements OnInit, OnDestroy, Subscribable {
    readonly facade: FACADE;
    private readonly state;
    readonly router: Router | null;
    readonly tableRefresh$: Observable<unknown> | null;
    readonly allSubscriptions: Subscriptions;
    readonly ENUM_DISPLAY_TEXT = EnumProperties.DISPLAY_TEXT;
    readonly ENUM_NAME = EnumProperties.NAME;
    readonly getEnumDisplayText: typeof getEnumDisplayText;
    /**
     * This sets the amount of the maximum amount of sortable columns for this component.  Default = 5.
     */
    maxSortedColumnCount: number;
    /**
     * This will allow you to provide a visual indicator that some of the columns have been hidden.
     */
    hasHiddenColumns$: Observable<boolean>;
    tableStateQueryKey: string;
    tableState: PrimeTableState;
    tableData$: Observable<ENTITY[]>;
    activeEffectCount$: Observable<number>;
    rowsPerPageOptions: number[];
    /**
     * A properties enum to make prime table columns definitions type safe
     * {@example <td>{{ dataItem[props.FIELD_NAME] }}</td>}
     */
    abstract readonly props: any;
    protected expanders?: Expander[];
    protected appliedTransformations?: string;
    readonly getRelatedValue: typeof getRelatedValue;
    constructor(facade: FACADE, state: PrimeTableState | Observable<PrimeTableState>, router?: Router | null, //NOSONAR
    tableRefresh$?: Observable<unknown> | null);
    ngOnInit(): void;
    ngOnDestroy(): void;
    getExportFileName(exportName: string): string;
    /**
     * Naming convention:
     * . => Parent table navigation separator
     * / => Child table navigation separator
     * @param segments
     * @returns
     */
    getRelatedField(...segments: (string | IRelatedFieldOptions)[]): string | null;
    deserializeTableState(stateQueryParam: string): PrimeTableState;
    /**
     * This method ensures the proper handling of date filters in an OData query
     * @param filter
     */
    normalizeFilters(filter: IFilter | ICompositeFilter): void;
    serializeTableState(primeTableState: PrimeTableState): string;
    /**
     * Will reset filters to initialGrid state passed into the constructor
     */
    resetFilters(): void;
    dataStateChange(primeTableState: PrimeTableState): void;
    excelData: () => Observable<ENTITY[]>;
    loadEntities(primeTableState: PrimeTableState): void;
    validateSortParameters(multiSortMeta?: SortMeta[]): SortMeta[];
    updateRouterState(state: PrimeTableState): void;
    reloadEntities(): void;
    static ɵfac: i0.ɵɵFactoryDeclaration<ImngPrimeODataTableBaseComponent<any, any>, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<ImngPrimeODataTableBaseComponent<any, any>, "ng-component", never, {}, {}, never, never, true, never>;
}

declare class IMNG_PRIME_TABLE implements OnInit, OnDestroy {
    readonly tableComponent: Table<any>;
    readonly changeDetectorRef: ChangeDetectorRef;
    odataTableComponent: ImngPrimeODataTableBaseComponent<object, IPrimeODataTableFacade<{
        id?: IdType | null;
    }>>;
    private facade;
    private sortState;
    readonly allSubscriptions: Subscriptions;
    ngOnInit(): void;
    ngOnDestroy(): void;
    static ɵfac: i0.ɵɵFactoryDeclaration<IMNG_PRIME_TABLE, never>;
    static ɵdir: i0.ɵɵDirectiveDeclaration<IMNG_PRIME_TABLE, "[imngODataTable]", never, { "odataTableComponent": { "alias": "imngODataTable"; "required": false; }; }, {}, never, never, true, never>;
}

declare class IMNG_PRIME_SEARCH_CAPTION {
    dataTable: Table;
    static ɵfac: i0.ɵɵFactoryDeclaration<IMNG_PRIME_SEARCH_CAPTION, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<IMNG_PRIME_SEARCH_CAPTION, "imng-prime-search-caption", never, { "dataTable": { "alias": "dataTable"; "required": false; }; }, {}, never, never, true, never>;
}

declare class ImngPrimeTableODataModule {
    static ɵfac: i0.ɵɵFactoryDeclaration<ImngPrimeTableODataModule, never>;
    static ɵmod: i0.ɵɵNgModuleDeclaration<ImngPrimeTableODataModule, never, [typeof i1.CommonModule, typeof i2.TableModule, typeof IMNG_PRIME_TABLE, typeof IMNG_PRIME_SEARCH_CAPTION], [typeof IMNG_PRIME_TABLE, typeof IMNG_PRIME_SEARCH_CAPTION]>;
    static ɵinj: i0.ɵɵInjectorDeclaration<ImngPrimeTableODataModule>;
}

declare function toODataQuery(val: PrimeTableState): ODataQuery;
declare function transformPrimeRelatedTableFilters(filter: ICompositeFilter): ICompositeFilter;

interface PrimeODataTableState<Entity> {
    tableData: Array<Entity>;
    totalRecordCount: number | undefined;
    activeEffectCount: number;
    tableState: PrimeTableState;
    /** Last known error (if any) */
    error: unknown | undefined;
}

declare function createPrimeODataTableInitialState<TEntity>(): PrimeODataTableState<TEntity>;

declare function handleMultiColumnSorting(val: LazyLoadEvent, sortState: SortMeta[]): SortMeta[];

declare function imngPrimeEffectErrorReducer<T extends {
    activeEffectCount: number;
    error: unknown;
}>(state: T, effectError: {
    payload: {
        error: Error;
    };
}): T;

declare function incrementActiveEffectCount<T extends {
    activeEffectCount: number;
}>(state: T): T;
declare function decrementActiveEffectCount<T extends {
    activeEffectCount: number;
}>(state: T): T;

export { IMNG_PRIME_SEARCH_CAPTION, IMNG_PRIME_TABLE, ImngPrimeODataTableBaseComponent, ImngPrimeTableODataModule, createPrimeODataTableInitialState, decrementActiveEffectCount, handleMultiColumnSorting, imngPrimeEffectErrorReducer, incrementActiveEffectCount, toODataQuery, transformPrimeRelatedTableFilters };
export type { IPrimeODataTableFacade, PrimeODataTableState, PrimeTableState };
