import { Observable } from 'rxjs';
import { Status } from './eui-loader.model';
import * as i0 from "@angular/core";
/**
 *  A service for loading external dependencies dynamically to the DOM and keeping track of their status. Dependencies
 *  can be loaded in any order and can have prerequisites. The service will load the prerequisites first and then load
 *  the dependency. If a dependency fails to load, the service will retry loading it according to the retry policy.
 *  The service will emit the status of the dependency when it changes. This is useful for showing a loading indicator
 *  while the dependency is loading. In scenarios where the dependency is not required for the application to function,
 *  the service will not block the application from loading if the dependency fails to load. The service will also
 *  remove the dependency from the DOM if it is removed from the list. This is useful for scenarios where the dependency
 *  is only required for a specific component, might be removed from the list when the component is destroyed, and it
 *  will not affect the bundle size.
 *
 *  @example
 *  // Add a dependency
 *  loader.addDependency('Quill', 'https://cdn.quilljs.com/1.3.6/quill.js', 'js');
 *  // Get the status of a dependency
 *  loader.getDependencyStatus('Quill');
 *  // Listen for status changes
 *  loader.statusChanges('Quill').subscribe((status: Status) => {
 *    console.log(status);
 *  });
 *  // Remove a dependency
 *  loader.removeDependency('Quill');
 *  // Set the retry policy
 *  loader.setRetryPolicy(3, 1000);
 *  // Set the timeout policy
 *  loader.setTimeoutPolicy(5000);
 *  // Load a dependency with prerequisites
 *  loader.addDependency('Quill', 'https://cdn.quilljs.com/1.3.6/quill.js', 'js', ['QuillStyle']);
 *  loader.addDependency('QuillStyle', 'https://cdn.quilljs.com/1.3.6/quill.snow.css', 'css');
 *  // Load a dependency with prerequisites and retry logic
 *  loader.setRetryPolicy(3, 1000);
 *  loader.setTimeoutPolicy(5000);
 *  loader.addDependency('Quill', 'https://cdn.quilljs.com/1.3.6/quill.js', 'js', ['QuillStyle']);
 *  loader.addDependency('QuillStyle', 'https://cdn.quilljs.com/1.3.6/quill.snow.css', 'css');
 */
export declare class EuiLoaderService {
    /**
     * Stores the status and details of each dependency
     */
    private dependencies;
    /** Observable that emits the name of the dependency when its status changes */
    private onStatusChange;
    /**
     * Configuration for policies such as Retry and timeout for failed loads
     */
    private policy;
    /**
     * Add a dependency with its type (JS or CSS) and dependencies
     *
     * @param name The name of the dependency
     * @param url The URL of the dependency
     * @param type The type of the dependency (JS or CSS)
     * @param requires The dependencies that must be loaded before this one (optional)
     */
    addDependency(name: string, url: string, type: 'js' | 'css', requires?: string[]): void;
    /**
     * Remove a dependency from the DOM
     *
     * @param name The name of the dependency
     */
    removeDependency(name: string): void;
    /**
     * Allow users to configure the retry policy
     *
     * @param maxAttempts The maximum number of retry attempts
     * @param retryInterval The time between retries in milliseconds
     */
    setRetryPolicy(maxAttempts: number, retryInterval: number): void;
    /**
     * Allow users to configure the timeout policy
     *
     * @param time The time in milliseconds before considering a load attempt as failed
     * @see setRetryPolicy
     * @see statusChanges
     */
    setTimeoutPolicy(time: number): void;
    /**
     * Get the status of a dependency
     *
     * @param name The name of the dependency
     * @returns The status of the dependency
     * @deprecated Prefer using statusChanges instead
     * @see statusChanges
     */
    getDependencyStatus(name: string): Status | null;
    /**
     * Get the status of a dependency as an observable
     *
     * @param name The name of the dependency
     */
    statusChanges(name: string): Observable<Status>;
    /**
     * Load a dependency and its prerequisites
     *
     * @param name The name of the dependency
     * @see loadDependency
     */
    private loadDependency;
    /**
     * Load a JS script and append it to the root of the DOM
     * @param dependency
     */
    private loadScript;
    /**
     * Load a CSS style and append it to the head of the document
     * @param dependency
     */
    private loadStyle;
    /**
     * Error handling for a failed load
     * @param name
     * @param error
     */
    private handleError;
    /**
     * Get the script element from the DOM
     *
     * @param url
     * @private
     */
    private getScript;
    /**
     * Get the style element from the DOM
     *
     * @param url
     * @private
     */
    private getStyle;
    /**
     * Reload a dependency which can be either a script or a style. First remove
     * the element from the DOM and then load it again.
     *
     * @param dependency
     * @private
     */
    private reloadDependency;
    static ɵfac: i0.ɵɵFactoryDeclaration<EuiLoaderService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<EuiLoaderService>;
}
//# sourceMappingURL=eui-loader.service.d.ts.map