import { ElementRef, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { AsyncValidatorFn, FormControl, FormGroup, ValidatorFn } from '@angular/forms';
import { ValidationMessageService } from '../../core/validation-message.service';
import { FormGroupHelper } from '../../shared/form-group.helper';
import { FormControlBase } from '../form-control-base';
import * as i0 from "@angular/core";
export type FileType = 'zip' | 'excel' | 'custom';
export type FileOutput = 'raw' | 'base64';
export declare const FileTypeExtensions: {
    zip: string[];
    excel: string[];
};
export type FileUploadFormGroup = {
    file: FormControl<File | null>;
    name: FormControl<string | null>;
    base64FileString: FormControl<string | null>;
    uploadResult: FormControl<any>;
};
export type InvalidFileError = {
    invalidFile: true;
};
export type FileValidatorCallback = (file: File | null | undefined, base64: string | null | undefined) => Promise<InvalidFileError | null>;
export declare class FileUploadComponent extends FormControlBase implements OnInit, OnChanges {
    protected validationMessageService: ValidationMessageService;
    protected formGroupHelper: FormGroupHelper;
    static getFormModel(validators: ValidatorFn[], disabled?: boolean, 
    /** Any validators required to make sure the selected file is valid. It is recommended that you use `FileUploadComponent.getFileValidator` to help construct the validator(s). NOTE: This currently only works when multiSelect is false. */
    fileValidators?: AsyncValidatorFn | AsyncValidatorFn[]): FormGroup<FileUploadFormGroup>;
    /**
     * Helper function that returns an async validator to be used with the file upload control.
     * This is useful for when the file needs to be validated before it can be uploaded.
     *
     * @param callback The callback function that will be called to validate the file. Parameters for the callback are the file and the base64 string for the file.
     * base64 is null if the fileOutput input on the FileUploadComponent is set to raw. Using fileOutput set to base64 is recommended for images.
     */
    static getFileValidator(callback: FileValidatorCallback): AsyncValidatorFn;
    formModel: FormGroup<FileUploadFormGroup>;
    /**
     * The value of the textbox input's placeholder
     */
    placeholder?: string;
    /** Common extensions for a file browsing dialog
     *  Note: Edge does not support the accept attribute on file inputs, therefor all file types
     *        will be shown.  Firefox and Chrome both support this feature.
     */
    fileType?: FileType | undefined;
    /**
     * File output, determines which properties are supplied on the formModel
     */
    fileOutput?: FileOutput;
    /** If fileType is set to custom set the acceptable file types based on the custom array */
    customExtensions?: Array<string> | undefined;
    /**
     * Optional callback supported if the hosting page needs to process the file before
     * setting the formModel with the file information. If the promise resolves it will continue
     * and set the file name and contents to the formModel, otherwise on failure it'll do nothing.
     */
    onFileSelected?: (file: File) => Promise<any>;
    /**
     * Optional callback supported for when the hosting page needs to process multiple files
     * We simply map the FileList to an array of File objects and pass that array to the
     * callback and let the hosting page handle the processing
     */
    onMultipleFilesSelected?: (files: File[]) => Promise<any>;
    /**
     * Optional display type that controls whether the file input textbox is displayed or
     * simply a button the user clicks to launch the OS file storage dialog.
     * Default: file
     */
    displayType?: 'file' | 'button';
    /**
     * When display type is set to button this property will control the button label
     */
    buttonLabel?: string;
    /**
     * When display type is set to button this property will control the button type
     */
    buttonType?: string;
    /**
     * Optional property to control whether the user can select multiple files
     */
    multiSelect?: boolean;
    /**
     * When true, the onFileSelected callback will not be called if the form is invalid.
     * This is useful when the file needs to be validated before it can be uploaded.
     * For server-side validation, leave this as false and use the onFileSelected callback
     * to upload the file and handle any errors thrown by the API.
     */
    validateBeforeUpload: boolean;
    fileInput?: ElementRef;
    /** Property bound to the file input to filter what file types are shown in the dialog */
    fileTypeAccept: string | undefined;
    constructor(validationMessageService: ValidationMessageService, formGroupHelper: FormGroupHelper);
    ngOnChanges(changes: SimpleChanges): void;
    ngOnInit(): void;
    fileChange(files: FileList): Promise<void>;
    /**
     * Checks the file type and updates the file type accept property. This is what determines the file
     * type choices that the user will be limited to in the file browse dialog
     */
    private updateFileTypeAccept;
    /**
     * Take a file that was selected by the user and process/patch our form model
     * If the host component requires an action to occur with the file prior to the patch it will call
     * and wait for it to return.
     * @param file
     * @param base64FileString Optional: Will have a value provided if the fileOutput is set to base64
     */
    private processFile;
    /** Patches the form with the selected file in order to trigger control validation */
    private validateFile;
    /**
     * Based on the fileOutput return whether this component is expected to deliver a base64 output
     * @returns
     */
    private isBase64FileOutput;
    /** Maps the files to an array of File objects and sends them along
     * to the derived onMultipleFileSelected method in the hosting component
     */
    private handleMultipleFiles;
    private readFile;
    static ɵfac: i0.ɵɵFactoryDeclaration<FileUploadComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<FileUploadComponent, "ec-file-upload", never, { "formModel": { "alias": "formModel"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "fileType": { "alias": "fileType"; "required": false; }; "fileOutput": { "alias": "fileOutput"; "required": false; }; "customExtensions": { "alias": "customExtensions"; "required": false; }; "onFileSelected": { "alias": "onFileSelected"; "required": false; }; "onMultipleFilesSelected": { "alias": "onMultipleFilesSelected"; "required": false; }; "displayType": { "alias": "displayType"; "required": false; }; "buttonLabel": { "alias": "buttonLabel"; "required": false; }; "buttonType": { "alias": "buttonType"; "required": false; }; "multiSelect": { "alias": "multiSelect"; "required": false; }; "validateBeforeUpload": { "alias": "validateBeforeUpload"; "required": false; }; }, {}, never, never, false, never>;
}
