import { Signal } from '@angular/core';
import { BaseDefinition, BaseDefinitionMetadata } from '@rxap/definition';
import { ToggleSubject } from '@rxap/rxjs';
import { Constructor } from '@rxap/utilities';
import { Observable, ReplaySubject, Subject, TeardownLogic } from 'rxjs';
import * as i0 from "@angular/core";
export type DataSourceViewerId = string;
export interface BaseDataSourceViewer<View = any> {
    id?: DataSourceViewerId;
    viewChange?: Observable<View>;
    /**
     * Indicates weather the data source should restore the last value from local storage
     */
    restore?: boolean;
    [key: string]: any;
}
export interface BaseDataSourceMetadata extends BaseDefinitionMetadata {
    /**
     * Indicates weather the data source should restore the last value from local storage
     */
    restore?: boolean;
}
export declare class BaseDataSource<Data = any, Metadata extends BaseDataSourceMetadata = BaseDataSourceMetadata, Viewer extends BaseDataSourceViewer = BaseDataSourceViewer> extends BaseDefinition<Metadata> {
    readonly change$: Subject<Data>;
    /**
     * Indicates weather the data source is currently loading new data
     */
    loading$: Observable<boolean>;
    readonly hasError$: ToggleSubject;
    readonly error$: ReplaySubject<Error>;
    get lastRefreshed(): Date | null;
    protected _lastRefreshed: Date | null;
    protected _connectedViewer: Map<string, Observable<Data>>;
    protected _connectedViewerTeardown: Map<string, TeardownLogic>;
    protected _data$: Observable<Data>;
    /**
     * a map of viewer to view id.
     * Allows to create a view id from the viewer object reference
     * @protected
     */
    protected _viewerIds: Map<Viewer, string>;
    protected _retry$: Subject<void>;
    loading?: Signal<boolean>;
    hasError?: Signal<boolean>;
    constructor(metadata?: Metadata | null);
    protected _data?: Data;
    get data(): Data | undefined;
    get hasConnections(): boolean;
    getViewerId(viewer: Viewer): string;
    connect(viewerOrString: Viewer | DataSourceViewerId): Observable<Data>;
    attach(viewerId: DataSourceViewerId): Observable<Data>;
    isConnected(viewerOrId: Viewer | DataSourceViewerId): boolean;
    disconnect(viewerOrId: Viewer | DataSourceViewerId): void;
    /**
     * Creates a connection to tha data source and converts the Observable into a
     * promise and then disconnects the viewer
     */
    toPromise(viewer: Viewer): Promise<Data>;
    derive(id: string, metadata?: Partial<BaseDataSourceMetadata>): BaseDataSource<any>;
    toJSON(): object;
    refresh(): any;
    retry(): any;
    reset(): any;
    protected _disconnect(viewerId: DataSourceViewerId): void;
    protected genericRetryFunction(error: any, retryCount: number): Observable<any>;
    protected handelError(error: any): void;
    protected _connect(viewer: BaseDataSourceViewer): [Observable<Data>, TeardownLogic] | Observable<Data>;
    static ɵfac: i0.ɵɵFactoryDeclaration<BaseDataSource<any, any, any>, [{ optional: true; }]>;
    static ɵprov: i0.ɵɵInjectableDeclaration<BaseDataSource<any, any, any>>;
}
export declare function RxapDataSource<Metadata extends BaseDataSourceMetadata>(dataSourceIdOrMetadata: string | Metadata, className?: string, packageName?: string): (target: Constructor<BaseDataSource>) => void;
