/*!
 * Copyright 2021 VMware, Inc.
 * SPDX-License-Identifier: BSD-2-Clause
 */
import { AfterViewInit, EventEmitter, OnInit } from '@angular/core';
import { ClrDatagridPagination } from '@clr/angular';
import { LazyString, TranslationService } from '@vcd/i18n';
import { Observable } from 'rxjs';
import { ActionItem } from '../../common/interfaces/action-item.interface';
import { SubscriptionTracker } from '../../common/subscription/subscription-tracker';
import { ComponentRendererConstructor, ComponentRendererSpec, GridColumn, GridDataFetchResult, GridState, PaginationConfiguration } from '../../datagrid';
import { DatagridActionDisplayConfig } from '../../datagrid/interfaces/datagrid-action-display.interface';
import { ComboOption } from '../select-all-checkbox/select-all-toggle.component';
import { NonEmptyArray } from '../../constants';
import * as i0 from "@angular/core";
export declare class VcdSharingModalError {
    message: string;
    constructor(message: string);
}
/**
 * The objects an entity must have. You are allowed to pass a more complicated object.
 *
 * @param T is the interface for the Object that is being selected.
 */
export declare type HasId<T> = T & {
    /**
     * The unique ID of this entity.
     */
    id: string;
};
/**
 * Adds the rights that this entity has been granted.
 *
 * @param T is the interface for the Object that is being selected.
 */
export declare type IsSelected<T> = HasId<T> & {
    accessRight: ComboOption;
};
/**
 * The result returned when the user searches in the combobox.
 *
 * @param T is the interface for the Object that is being searched.
 */
export interface SearchResult<T> {
    items: HasId<T>[];
    totalCount: number;
}
/**
 * The result that is output for a given tab from the sharing modal.
 *
 * @param T is the interface for the Object that is being shared with.
 */
export interface SharingTabResult<T> {
    selectedItems?: IsSelected<T>[];
    selectAllRights?: string;
}
/**
 * A tab with a predefined ID and title.
 *
 * @param T is the interface for the Object that is being shared with.
 */
export interface PredefinedSharingTab<T> {
    /**
     * The possible rights that can be selected to share with from this tab. Must have at least one element.
     */
    rightsOptions: NonEmptyArray<ComboOption>;
    /**
     * How a given Entity should be rendered in the grid and combobox. Will be given the type of object you return from {@param makeSearch}.
     * If non is given, defaults to display the name as text.
     */
    entityRenderer?: ComponentRendererConstructor<HasId<T>>;
    /**
     * The placeholder to put in the combobox when no search has been entered.
     */
    comboboxPlaceholder?: LazyString;
    /**
     * Called when the user types something into or opens the combobox. Returns the results from that search.
     */
    makeSearch?: (criteria?: string) => Promise<SearchResult<T>>;
}
/**
 * The configuration for a tab in the sharing modal.
 *
 * @param T is the interface for the Object that is being shared with.
 */
export interface SharingTab<T> extends PredefinedSharingTab<T> {
    /**
     * The unique ID of this tab.
     */
    id: string;
    /**
     * The title of this tab.
     */
    title: LazyString;
    /**
     * The text displayed in the datagrid when select all is enabled.
     */
    selectAllText: LazyString;
}
/**
 * A tab that allows users to add users to share with given rights.
 *
 * @param T is the interface for the Object that is being shared with.
 */
export declare class SharingModalTabComponent<T> implements OnInit, AfterViewInit {
    translationService: TranslationService;
    private subTracker;
    constructor(translationService: TranslationService, subTracker: SubscriptionTracker);
    /**
     * Which of the user type this entity is already share dwith.
     */
    set currentlySharedWith(currentlySharedWith: IsSelected<T>[]);
    get currentlySharedWith(): IsSelected<T>[];
    /**
     * If this tab is in select all mode.
     */
    isSelectAll: boolean;
    /**
     * How a given Entity should be rendered. Will be given the type of object you return from {@param makeSearch}
     */
    entityRenderer: ComponentRendererConstructor<HasId<T>>;
    /**
     * The unique ID of this tab.
     */
    id: string;
    /**
     * The possible rights that can be selected to share with from this tab. Must have at least one element.
     */
    rightsOptions: NonEmptyArray<ComboOption>;
    /**
     * The placeholder to put in the combobox when no search has been entered.
     */
    comboboxPlaceholder: LazyString;
    /**
     * The text displayed in the datagrid when select all is enabled.
     */
    selectAllText: LazyString;
    /**
     * Emitted when anything about the list of users currently shared with changes.
     */
    currentlySharedWithChange: EventEmitter<IsSelected<T>[]>;
    /**
     * The right that is currently selected in the rights dropdown for pending users.
     */
    currentlySelectedRightValue: string;
    /**
     * The results returned from a search in the combobox.
     */
    searchResults: HasId<T>[];
    totalSearchResults: number;
    /**
     * The entities currently selected in the combobox,
     */
    comboboxSelection: HasId<T>[];
    /**
     * START GRID CONFIGURATION
     */
    columns: GridColumn<IsSelected<T>>[];
    gridItems: GridDataFetchResult<IsSelected<T>>;
    actions: ActionItem<IsSelected<T>, unknown>[];
    actionDisplayConfig: DatagridActionDisplayConfig;
    paginationInfo: PaginationConfiguration;
    /**
     * END GRID CONFIGURATION
     */
    /**
     * The error returned from a call to makeSearch. Undefined if there is no error.
     */
    searchError: string;
    private bufferedSearch;
    private allSharedWith;
    private gridState;
    gridRefreshed(state: GridState<IsSelected<T>>): void;
    /**
     * Called when the user types something into or opens the combobox. Returns the results from that search.
     */
    makeSearch: (criteria?: string) => Promise<SearchResult<T>>;
    /**
     * Removes the given entity from the currently selected list.
     */
    removeEntity(entity: HasId<T>): void;
    /**
     * Adds the entities selected in the combobox to the datagrid.
     */
    addPendingEntities(): void;
    /**
     * Makes a call to {@param makeSearch} and properly enables loading for the combobox.
     */
    doSearchInternal(criteria?: string): void;
    /**
     * Gives the render spec to render an given entity.
     */
    getEntityRenderSpec(entity: HasId<T>): ComponentRendererSpec<HasId<T>>;
    /**
     * Says if this user is the owner of the entity to share.
     */
    isOwner(entity: IsSelected<T>): boolean;
    /**
     * Gets the translated string to display pagination information.
     */
    getPaginationTranslation(paginationData: ClrDatagridPagination): Observable<string>;
    /**
     * A trackBy function to track entities.
     */
    entityTrackBy(_index: number, entity: HasId<T>): string;
    /**
     * Says if this combobox is both enabled and has entities to submit.
     */
    isComboboxSubmittable(): boolean;
    /**
     * Updates this entity in the currently shared with list to have the given access right.
     */
    updateEntityRights(entity: IsSelected<T>, newAccessRight: string): void;
    ngOnInit(): void;
    ngAfterViewInit(): void;
    defaultRenderer(entity: HasId<T>): string;
    updateGridItems(): void;
    shouldShowWarning(total: number, visible: number): boolean;
    private getRightByValue;
    static ɵfac: i0.ɵɵFactoryDeclaration<SharingModalTabComponent<any>, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<SharingModalTabComponent<any>, "vcd-sharing-modal-tab", never, { "currentlySharedWith": "currentlySharedWith"; "isSelectAll": "isSelectAll"; "entityRenderer": "entityRenderer"; "id": "id"; "rightsOptions": "rightsOptions"; "comboboxPlaceholder": "comboboxPlaceholder"; "selectAllText": "selectAllText"; "makeSearch": "makeSearch"; }, { "currentlySharedWithChange": "currentlySharedWithChange"; }, never, never, false, never>;
}
