import { AXStyleColorType, MXBaseComponent } from '@acorex/cdk/common';
import * as i0 from '@angular/core';
import { OnInit, EventEmitter, InjectionToken, ElementRef } from '@angular/core';
import { Portal, CdkPortalOutletAttachedRef } from '@angular/cdk/portal';
import { BehaviorSubject, Observable } from 'rxjs';

/**
 * A loading spinner component that displays a rotating spinner icon.
 * @category Components
 */
declare class AXLoadingSpinnerComponent {
    /**
     * The text to display alongside the spinner.
     */
    text: string;
    /**
     * Color of the spinner. Can be a predefined style color or a custom color.
     * @defaultValue 'default'
     */
    color: AXStyleColorType | 'white' | 'black';
    /**
     * Size of the spinner, in pixels. This determines both the width and height of the spinner.
     * @defaultValue 16
     */
    size: number;
    /**
     * Thickness of the spinner's border, in pixels. This affects the visual weight of the spinner's outline.
     * @defaultValue 3
     */
    stroke: number;
    /**
     *  @ignore
     */
    private get __hostClass();
    static ɵfac: i0.ɵɵFactoryDeclaration<AXLoadingSpinnerComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<AXLoadingSpinnerComponent, "ax-loading-spinner", never, { "text": { "alias": "text"; "required": false; }; "color": { "alias": "color"; "required": false; }; "size": { "alias": "size"; "required": false; }; "stroke": { "alias": "stroke"; "required": false; }; }, {}, never, never, true, never>;
}

/**
 * A component that displays a loading indicator.
 * @category Components
 */
declare class AXLoadingComponent extends MXBaseComponent implements OnInit {
    private config;
    /**
     *  @ignore
     */
    protected _selectedPortal: Portal<unknown>;
    /**
     * Emits an event when the visibility state of the component changes.
     * @event
     */
    visibleChange: EventEmitter<boolean>;
    /**
     *  @ignore
     */
    private _visible;
    /**
     * Determines whether the component is visible or not.
     */
    get visible(): boolean;
    /**
     * Sets the visibility of the component and emits a visibility change event.
     *
     * @param v - A boolean value indicating whether the component should be visible.
     */
    set visible(v: boolean);
    /**
     * Specifies the type of loading indicator to display.
     * @defaultValue 'spinner'
     */
    type: string;
    /**
     * Provides additional context or data that may be used by the component.
     */
    context?: unknown;
    /**
     *  @ignore
     */
    ngOnInit(): void;
    /**
     *  @ignore
     */
    protected _handleAttched(ref: CdkPortalOutletAttachedRef): void;
    static ɵfac: i0.ɵɵFactoryDeclaration<AXLoadingComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<AXLoadingComponent, "ax-loading", never, { "visible": { "alias": "visible"; "required": false; }; "type": { "alias": "type"; "required": false; }; "context": { "alias": "context"; "required": false; }; }, { "visibleChange": "visibleChange"; }, never, never, true, never>;
}

interface AXLoadingConfig {
    spinner: unknown;
}
declare const AX_LOADING_CONFIG: InjectionToken<AXLoadingConfig>;
declare const AXLoadingDefaultConfig: AXLoadingConfig;
type PartialLoadingConfig = Partial<AXLoadingConfig>;
declare function loadingConfig(config?: PartialLoadingConfig): AXLoadingConfig;

type LoadingContext = object;
type LoaderId = string | number;
declare class AXLoadingService {
    protected loadingStates: WeakMap<object, Map<LoaderId, boolean>>;
    protected loadingStates$: WeakMap<object, Map<LoaderId, BehaviorSubject<boolean>>>;
    private dialog;
    /**
     * Shows a modal loading overlay.
     *
     * If a host element is provided via `config.location`, the overlay is attached to that
     * element; otherwise it is attached to `document.body`.
     *
     * @param config Optional configuration: host `location`, `type`, and `context` passed to the spinner instance.
     * @returns number Unique loading reference id to be used with {@link hide}.
     */
    show(config?: {
        location?: Element;
        type?: string;
        context?: unknown;
    }): number;
    /**
     * Hides a previously shown modal loading overlay.
     *
     * @param id Loading reference id returned by {@link show}.
     */
    hide(id: number): void;
    /**
     * Wraps an Observable and toggles loading for its duration.
     *
     * Starts loading before subscription settles and ends loading on finalize.
     *
     * @param source$ Source observable.
     * @param context Loading context key.
     * @param loaderId Optional id to scope multiple loaders per context.
     * @returns Observable<V> The original stream with loading side effects.
     */
    doLoading<V>(source$: Observable<V>, context: LoadingContext, loaderId?: LoaderId): Observable<V>;
    /**
     * Returns current loading state for the given context and optional loader id.
     *
     * @param context Loading context key.
     * @param loaderId Optional loader id.
     * @returns boolean True if any matching loader is active.
     */
    isLoading(context: LoadingContext, loaderId?: LoaderId): boolean;
    /**
     * Observable loading state for the given context and optional loader id.
     * Initializes the state if it does not exist yet.
     *
     * @param context Loading context key.
     * @param loaderId Optional loader id.
     * @returns Observable<boolean>
     */
    isLoading$(context: LoadingContext, loaderId?: LoaderId | any): Observable<boolean>;
    /**
     * Sets loading state to true for the given context/loader id.
     *
     * @param context Loading context key.
     * @param loaderId Optional loader id.
     * @returns void
     */
    startLoading(context: LoadingContext, loaderId?: LoaderId): void;
    /**
     * Sets loading state to false for the given context/loader id.
     *
     * @param context Loading context key.
     * @param loaderId Optional loader id.
     * @returns void
     */
    endLoading(context: LoadingContext, loaderId?: LoaderId): void;
    /**
     * Clears all tracked loading states across all contexts.
     *
     * @returns void
     */
    clearLoadings(): void;
    protected setLoadingState(context: LoadingContext, state: boolean, loaderId: LoaderId): void;
    protected hasLoadingStates(context: LoadingContext, loaderId: LoaderId): boolean;
    protected hasContextLoadingState(context: LoadingContext): boolean;
    protected hasLoaderLoadingState(context: LoadingContext, loaderId: LoaderId): boolean;
    protected getLoaderId(loaderId?: LoaderId): LoaderId;
    static ɵfac: i0.ɵɵFactoryDeclaration<AXLoadingService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<AXLoadingService>;
}

declare class AXLoadingDirective {
    protected readonly elementRef: ElementRef<any>;
    protected readonly loadingService: AXLoadingService;
    private _hostElement;
    private _loadingRef;
    private _isLoading;
    get isLoading(): boolean;
    set isLoading(v: boolean);
    constructor();
    static ɵfac: i0.ɵɵFactoryDeclaration<AXLoadingDirective, never>;
    static ɵdir: i0.ɵɵDirectiveDeclaration<AXLoadingDirective, "[axIsLoading]", never, { "isLoading": { "alias": "axIsLoading"; "required": false; }; }, {}, never, never, true, never>;
}

declare class AXLoadingModule {
    static ɵfac: i0.ɵɵFactoryDeclaration<AXLoadingModule, never>;
    static ɵmod: i0.ɵɵNgModuleDeclaration<AXLoadingModule, never, [typeof AXLoadingComponent, typeof AXLoadingDirective, typeof AXLoadingSpinnerComponent], [typeof AXLoadingComponent, typeof AXLoadingDirective, typeof AXLoadingSpinnerComponent]>;
    static ɵinj: i0.ɵɵInjectorDeclaration<AXLoadingModule>;
}

export { AXLoadingComponent, AXLoadingDefaultConfig, AXLoadingDirective, AXLoadingModule, AXLoadingService, AXLoadingSpinnerComponent, AX_LOADING_CONFIG, loadingConfig };
export type { AXLoadingConfig, PartialLoadingConfig };
