import { IKosRegistry, KosCompanionModelType } from './types/registration';
import { IKosModelManager } from './types/kos-model-manager-types';
import { IKosDataModel, IKosDataModelBuilder, IKosModel } from './kosModel';
import { BaseKosModelRegistrationBean } from '../types';

export declare const MODEL_DELETION_DELAY = 10;
export declare class KosModelManager implements IKosModelManager {
    private cache;
    private instantiator;
    private dependencies;
    private _registry;
    private constructor();
    static create(registry: IKosRegistry, reset?: boolean): KosModelManager;
    static getInstance(reset?: boolean): KosModelManager;
    get registry(): IKosRegistry;
    /**
     * Retrieves the preloaded models from the registry. If the models have already been
     * preloaded, it returns the cached preloaded models. Otherwise, it initializes and
     * preloads the models based on the registry's `preloadModels` configuration.
     *
     * @returns An array of preloaded model instances.
     *
     * @remarks
     * - Logs debug information during the preloading process.
     * - Logs an error if returning cached preloaded models.
     * - Supports both string-based model keys and object-based model configurations.
     */
    get preloadedModels(): IKosModel<IKosDataModel>[];
    get models(): IKosModel<IKosDataModel>[];
    /**
     * Retrieves a model by its unique identifier.
     *
     * @template T - The type of the data model extending `IKosDataModel`.
     * @param id - The unique identifier of the model to retrieve.
     * @returns The model associated with the given ID as `IKosModel<T>`, or `undefined` if the model is marked for deletion.
     */
    getModelById<T extends IKosDataModel>(id: string): IKosModel<T>;
    /**
     * Adds a model to the manager. If a model with the same ID already exists,
     * it returns the existing model instead of adding the new one.
     *
     * @template T - The type of the data model extending `IKosDataModel`.
     * @param model - The model to be added, implementing `IKosModel<T>`.
     * @returns The active model, either the existing one with the same ID or the newly added model.
     */
    addModel<T extends IKosDataModel>(model: IKosModel<T>): IKosModel<T>;
    /**
     * Removes a model from the manager and performs cleanup operations.
     *
     * This method traverses the model hierarchy, invoking the `accept` method
     * on each child model to allow for recursive processing. During traversal,
     * it performs the following actions:
     * - Calls the `offline` method on the model, if defined.
     * - Clears any companion models associated with the model.
     * - Deletes the model's context from the `KosContextManager`.
     * - Removes the model from the internal `_modelsById` and `_toDelete` maps.
     *
     * @param model - The model to be removed. Must implement the `IKosModel` interface.
     */
    removeModel(model: IKosModel): void;
    /**
     * Checks if a model with the specified ID exists.
     *
     * @param modelId - The unique identifier of the model to check. Optional.
     * @returns `true` if the model ID is provided and a model with the given ID exists; otherwise, `false`.
     */
    hasModel(modelId?: string): boolean;
    /**
     * Retrieves a list of models of a specific type that satisfy the provided filter criteria.
     *
     * @template T - The type of the data model extending `IKosDataModel`.
     * @param typeId - The identifier of the model type to filter by.
     * @param modelFilter - A callback function used to filter models. It receives a model of type `T` and should return `true` if the model passes the filter, or `false` otherwise.
     * @returns An array of models of type `T` that match the specified type and filter criteria.
     */
    getModelsByType<T extends IKosDataModel>(typeId: string, modelFilter: (model: T) => boolean): T[];
    /**
     * Retrieves the subscriptions associated with a specific model type.
     *
     * @param typeId - The unique identifier of the model type.
     * @returns An object containing the subscriptions for the specified model type,
     *          or an empty object if the model type is not registered.
     */
    getModelSubscriptions(typeId: string): Record<string, import('./types/registration').IKosSubscriptionSpecification>;
    /**
     * Retrieves the data model builder for a specified model type.
     *
     * @template D - The type of the data used by the model.
     * @template M - The type of the data model that extends `IKosDataModel`.
     * @param typeId - The unique identifier for the model type.
     * @returns An instance of `IKosDataModelBuilder` for the specified model type,
     *          or `undefined` if the model type is not registered.
     */
    getDataModelBuilder<D, M extends IKosDataModel>(typeId: string): IKosDataModelBuilder<D, M>;
    /**
     * Retrieves a model factory function for the specified model type.
     *
     * @template T - The type of the data model that extends `IKosDataModel`.
     * @param modelType - A string representing the type of the model.
     * @returns A factory function for creating instances of the specified model type.
     */
    getModelFactory<T extends IKosDataModel>(modelType: string): import('../types').ModelFactory<T, {}>;
    /**
     * Adds a dependency relationship between two models.
     *
     * This method establishes a "uses" relationship where the model identified
     * by `modelId` depends on the model identified by `dependencyId`. It ensures
     * that the dependency is not marked for deletion and restores it from the
     * delete cache if necessary. The relationship is then recorded in both the
     * `_usedByCache` and `_usesCache` for efficient lookup.
     *
     * @param modelId - The identifier of the model that depends on the dependency.
     * @param dependencyId - The identifier of the model being depended upon.
     */
    addDependency(modelId: string, dependencyId: string): void;
    /**
     * Removes a dependency relationship between two models.
     *
     * This method updates the internal caches to reflect that the specified
     * `modelId` no longer depends on the `dependencyId`. It removes the
     * `modelId` from the list of models that use the `dependencyId` and
     * removes the `dependencyId` from the list of dependencies used by the
     * `modelId`.
     *
     * @param modelId - The ID of the model that has the dependency.
     * @param dependencyId - The ID of the dependency to be removed.
     */
    removeDependency(modelId: string, dependencyId: string): void;
    /**
     * Reloads the specified model by its ID. If the model exists and is found
     * by its ID, it transitions the model to the RESETTING state using the
     * RESET event.
     *
     * @param model - The data model to be reloaded. Must implement the `IKosDataModel` interface.
     *                The `id` property of the model is used to locate the corresponding model.
     *
     * @returns A promise that resolves once the model has been transitioned, or does nothing
     *          if the model ID is not provided or the model is not found.
     */
    reloadModel(model: IKosDataModel): Promise<void>;
    /**
     * Initiates the destruction process for a given model.
     *
     * This method checks if the model can be destroyed and, if so, schedules it for deletion.
     * The model is removed from the internal `_modelsById` map and added to the `_toDelete` map.
     * A deletion task is then queued with a delay, during which the model will be destroyed.
     *
     * @param model - The model to be destroyed. Must implement the `IKosDataModel` interface.
     * @throws {Error} If the model does not have a valid `id`.
     */
    initiateDestroyModel(model: IKosDataModel): Promise<void>;
    /**
     * Destroys the specified model if it meets the criteria for destruction.
     *
     * @param model - The model to be destroyed, implementing the `IKosModel` interface.
     *
     * @remarks
     * This method checks if the model has a valid `modelId` and if it can be destroyed
     * by invoking the `canDestroyModel` method. If the conditions are met, it performs
     * the following actions:
     * 1. Calls the `unload` method on the model, if it exists.
     * 2. Removes the model from the manager using the `removeModel` method.
     *
     * @throws This method does not explicitly throw errors, but any errors occurring
     * during the `unload` or `removeModel` operations will propagate to the caller.
     */
    destroyModel(model: IKosModel): Promise<void>;
    /**
     * Creates an instance of a model based on the specified type ID and optional model ID.
     * If the model already exists, it retrieves the existing instance; otherwise, it creates a new one.
     *
     * @template DataDef - The type of the data model, extending `IKosDataModel`.
     * @param typeId - The unique identifier for the type of model to create.
     * @param id - An optional unique identifier for the specific model instance. If not provided,
     *             the `typeId` is used for singleton models.
     * @param options - An optional record of additional options to pass to the model creation process.
     * @returns An object containing the created or retrieved model instance and its associated data.
     */
    createModelInstance<DataDef extends IKosDataModel>(typeId: string, id?: string, options?: Record<string, any>): {
        model: IKosModel<DataDef>;
        data: DataDef;
    };
    /**
     * Registers a companion model for a specific type identifier.
     *
     * This method ensures that the companion model is added to the registry
     * for the given `typeId`. If a companion model of the same type already
     * exists for the `typeId`, it will not be added again.
     *
     * @param typeId - The unique identifier for the type to which the companion model belongs.
     * @param companionRegistration - The companion model type to register.
     */
    registerCompanionModel(typeId: string, companionRegistration: KosCompanionModelType<any>): void;
    /**
     * Registers a new model type in the model manager if it is not already registered.
     *
     * @template T - A type that extends `BaseKosModelRegistrationBean` with specific type and registration details.
     * @param reg - The registration object containing the type identifier and registration details for the model.
     *
     * @remarks
     * - If the model type is not already present in the registry, it logs the registration
     *   and updates the registry with the new model type.
     * - The `type` property of the registration object is used as the unique identifier for the model type.
     */
    registerModel<T extends BaseKosModelRegistrationBean<any, any>>(reg: T): void;
}
//# sourceMappingURL=kosModelManager.d.ts.map