import { AfterViewInit, Injector, OnDestroy, OnInit } from '@angular/core';
import { UntypedFormGroup } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { Observable, Subject } from 'rxjs';
import { NavItem } from '../../../controls/navigation/nav-item';
import { ErrorService } from '../../../core/error.service';
import { RouterHelper } from '../../../core/router-helper.service';
import { ScrollService } from '../../../core/scroll.service';
import { DialogService } from '../../../display/dialog/dialog.service';
import { Help } from '../../../display/help/help-types';
import { SplashService } from '../../../display/splash/splash.service';
import { Overlay } from '../../../display/view-overlay/view-overlay.component';
import { PageStatus } from '../page-statuses';
import * as i0 from "@angular/core";
export declare class PageInitResult {
    title?: string;
    subTitle?: string;
    subTitleUrl?: string;
    breadcrumbs?: NavItem[];
    help?: Help;
}
export declare abstract class PageBaseComponent implements OnInit, AfterViewInit, OnDestroy {
    /** Default css classes applied to host element */
    protected classList: string;
    /**
     * Title for the page displayed in the header
     */
    title?: string;
    /**
     * Sub title for the page displayed in the header
     */
    subTitle?: string;
    /**
     * Sub title url for the page displayed in the header
     */
    subTitleUrl?: string;
    /**
     * Status overlay for the page
     */
    status: Overlay;
    /**
     * Breadcrumbs displayed in the header
     */
    breadcrumbs?: NavItem[];
    /**
     * Result returned from the onInit function
     */
    initResult: PageInitResult;
    /**
     * Help information for the component, which can only be set through onInit
     */
    help: Help | undefined;
    /**
     * Form group to be used if needed by the page
     */
    formGroup: UntypedFormGroup;
    /**
     * Default invalid form message, override if a more specific message is needed
     */
    defaultInvalidFormMessage: string;
    /**
     * Default unknown save error message, override if a more specific message is needed
     */
    defaultUnknownSaveError: string;
    /**
     * Used to opt out of hiding the splash screen when the page is loaded
     */
    skipHideSplashOnComplete: boolean;
    /**
     * When set to true any navigation end events that are strictly query param changes will
     * not call the onNavigationEnd function. This allows pages to change the view with query
     * params and not trigger a full refresh.
     */
    ignoreQueryParamsOnNavigationChange: boolean;
    private previousUrl;
    /**
     * Used to unsubscribe from observables
     */
    destroyed: Subject<void>;
    /**
     * Used to know when the page has been loaded, this will be completed
     * after onAfterViewInit
     */
    private _afterViewInitComplete;
    afterViewInitComplete: Observable<void>;
    /**
     * If defined the form will automatically scroll to the first invalid form control
     * if it's outside of the view
     */
    protected scrollContainerSelector: string | undefined;
    /**
     * Subscription to the router events NavigationEnd
     * Used to know if already subscribed to
     */
    private navigationEndSubscription?;
    /**
     * Common services used by page-base
     */
    protected errorService: ErrorService;
    protected translateService: TranslateService;
    protected scrollService: ScrollService;
    protected router: Router;
    protected activatedRoute: ActivatedRoute;
    protected dialogService: DialogService;
    protected splashService: SplashService;
    protected routerHelper: RouterHelper;
    constructor(injector: Injector);
    /**
     * Errors to be shown for the component.
     * Automatically populated on promise rejection from save and shared with the UI.
     */
    private _errors;
    get errors(): string;
    /**
     * Optional lifecycle hook that is called as part of the Angular ngOnInit lifecycle hook.
     * Called before onInit is called for the first time. Add setup logic here that does
     * not need to be run on every reload.
     */
    protected onFirstInit(): void;
    /**
     * This method is called in the derived class as part of the Angular ngOnInit
     * lifecycle hook. It must provide a PageInitResult back to the base class to properly
     * set up the page.
     */
    protected abstract onInit(): Promise<PageInitResult>;
    protected initPromise: Promise<PageInitResult>;
    ngOnInit(): Promise<void>;
    /**
     * This method is called just after the Angular Lifecycle event ngOnAfterViewInit.
     * It fires after all sub-components have gone through their initialization phase.
     * It is in this phase that the view components should already exist, so a derived class should
     * load data from the API to populate any view components. The promise that
     * is returned must not resolve until all required data has completely loaded
     */
    protected onAfterViewInit(): Promise<void>;
    ngAfterViewInit(): Promise<void>;
    /**
     * A lifecycle method that executes once all data has been loaded
     * through ngAfterViewInit and from local storage if required.
     * It is at this point that you can subscribe to changes on the form
     * reliably
     *
     * @protected
     * @memberof PageBaseComponent
     */
    protected onFormLoadComplete(): Promise<any>;
    /**
     * A lifecycle hook that is called after every NavigationEnd event.
     */
    protected onNavigationEnd(): void;
    /**
     * Reload the component kicking off the ngOnInit and ngAfterViewInit lifecycle hooks.
     * Any state that needs to be reset should be done so before calling this method.
     */
    reload(): void;
    /**
     * When overridden in a derived class this method will sync the form state
     * into the object that will be persisted to the API. The value should not
     * actually be sent to the API yet.
     */
    protected applyModelUpdates(): Promise<void>;
    /**
     * Save the model state to the API and return a promise that
     * contains the updated entityID. The promise should be rejected
     * if the save fails and errors and the overlay status will be updated
     * accordingly
     */
    protected saveToApi(): Promise<number | void>;
    /**
     * Called after the save has completed successfully.
     * It is the responsibility of the derived class to navigate
     * to a properties/status page or emit appropriately if within a dialog
     * @param entityId
     */
    protected onSaveComplete(entityId?: number): void;
    /**
     * Function called when the user clicks save.  We will first touch all controls to show validation messages
     * if the form is invalid.  If the form is valid we will attempt to save and any errors will be reported
     * back to the user
     * @param event
     */
    onSave(event: Event): Promise<void>;
    /**
     * Function available to trigger a save and bypass the form validation checks.
     * This is useful if the user chooses a remove action from within an edit dialog. If the dialog form is invalid
     * that is no concern to the user if they wish to remove the item they are editing.
     * @param event
     */
    onSaveWithoutValidate(event: Event): Promise<void>;
    /**
     * Function called when the component is destroyed
     */
    ngOnDestroy(): void;
    /**
     * Function that will log an error that is passed in to the console
     * @param e
     */
    protected onError(error: Error): void;
    /**
     * Show an error message in a whole-page overlay. This will prevent any more
     * interactions with the page. It can take a string error message or a raw API
     * error that needs to be parsed. If the API error isn't something we can handle
     * a generic message is shown instead
     * @param {(Error | string)} error
     */
    protected showErrorOverlay(error: Error | string): void;
    /**
     * Show an error in the banner at the top of the screen.  This will not produce a
     * whole-page overlay like the function showError will.  It can take a string error message
     * or raw API error that needs to be parsed.  If the API error isn't something we can handle,
     * a generic message (customizable via unknownErrorDefault) is shown instead.
     * @param error
     * @param unknownErrorDefault
     */
    protected showErrorBanner(error: Error | string, unknownErrorDefault?: string): void;
    /**
     * Parses and translates an API error or error string.
     * @param e
     * @param unknownErrorDefault
     */
    protected getErrorMessage(e: Error | string, unknownErrorDefault?: string): Observable<string>;
    /**
     * Clear the errors to hide the errors banner.
     */
    protected hideErrorBanner(): void;
    /**
     * Change the display status to overlay the whole page while loading or saving
     * and clear it when the form is ready
     * @protected
     * @param {PageStatus} status
     * @memberof FormBaseComponent
     */
    protected showStatus(status: PageStatus): void;
    /**
     * Allows the component to enter a pending status and execute a function that on completion will return the status
     * to hasData. If an error occurs within the callback an error banner can be shown.
     * @param callback
     * @param pendingMessage - optional custom pending message
     * @returns
     */
    protected runBlockingAction(callback: () => Promise<any>, pendingMessage?: string): Promise<any>;
    /**
     * Parses the page init result and sets the necessary properties on the page
     * @param result
     */
    private parseInitResult;
    /**
     * Controls the page status, triggers the save action and handles errors thrown.
     */
    private save;
    /**
     * Sets up the router event subscriptions
     */
    private setUpRouterSubscriptions;
    private navigationEndHandler;
    static ɵfac: i0.ɵɵFactoryDeclaration<PageBaseComponent, never>;
    static ɵdir: i0.ɵɵDirectiveDeclaration<PageBaseComponent, never, never, {}, {}, never, never, false, never>;
}
