import { KosOfflineQueue } from './model/kos-offline-queue';
import { DependencyLifecycle } from '../types/kos-dependency';
import { KosContext, KosContextBean } from './context/kos-context-manager';
import { KosModelManager } from './kosModelManager';
import { KosModelState } from './lifecycle/constants';
import { KosLog } from './log';
import { KosChildResolver } from './model/kos-child-resolver';
import { KosCompanionModelManager } from './model/kos-companion-model-manager';
import { KosEffectManager } from './model/kos-effects-manager';
import { KosFSMManager } from './model/kos-fsm-manager';
import { KosHttpRouteManager } from './model/kos-http-route-manager';
import { KosOnlineLifecycleManager } from './model/kos-online-lifecycle-manager';
import { KosSubscriptionManager } from './model/kos-subscription-manager';
import { KosParentAware } from './types';
/**
 * @kosService core.kos-model
 * @kosApiLevel 2
 */
export interface IKosModelLifecycle {
    init?(context?: KosContext): Promise<void>;
    load?(context?: KosContext): Promise<void>;
    ready?(context?: KosContext): Promise<void>;
    online?(context?: KosContext): Promise<void>;
    offline?(context?: KosContext): Promise<void>;
    unload?(context?: KosContext): void;
    activate?(context?: KosContext): Promise<void>;
    deactivate?(context?: KosContext): Promise<void>;
}
export interface IKosVisitor<T extends IKosDataModel | IKosModel> {
    visit: (model: T) => void;
}
export interface IKosVisitorHost<T extends IKosDataModel | IKosModel> {
    accept?: (visitor: IKosVisitor<T>) => void;
}
export type KosContextLogger = ReturnType<typeof KosLog.getLogger>;
export interface IKosModelLogger {
    logger: KosContextLogger;
}
/**
 * @kosService core.kos-model
 * @kosApiLevel 2
 */
export interface KosCreationContext extends IKosModelLogger {
    kosContext: KosContextBean;
    [key: string]: any;
}
/**
 * @kosService core.kos-model
 * @kosApiLevel 2
 */
export interface IKosDataModel extends IKosModelLifecycle, IKosVisitorHost<IKosDataModel> {
    id: string;
    getDependencies?(): void;
    getChildren?: () => IKosDataModel[];
    update?: (values: any) => Promise<void>;
    /**
     * @kosApiLevel 5
     */
    toJSON?: () => object;
}
/**
 * @kosService core.companion
 * @kosApiLevel 2
 */
export interface IKosCompanionOptions<T extends IKosDataModel = IKosDataModel, O extends object = object> extends KosParentAware {
    companionParent: T;
    data?: O;
}
/**
 * @kosService core.container-aware
 * @kosApiLevel 2
 */
export interface IKosContainerModel<T extends IKosDataModel, R extends object = Record<string, unknown>> {
    models: T[];
    createModel?: (request: R) => Promise<unknown>;
    deleteModel?: (id: string) => Promise<void>;
    getModel?: (id: string) => T | undefined;
}
/**
 * @kosService core.kos-model
 * @kosApiLevel 2
 */
export interface ReloadAware {
    reload: () => Promise<void>;
    /**
     * @kosApiLevel 20
     */
    readonly isReloading?: boolean;
}
/**
 * @kosService core.kos-model
 * @kosApiLevel 2
 */
export interface UnloadAware {
    unload: () => Promise<void>;
}
/**
 * @kosService core.kos-model
 * @kosApiLevel 2
 */
export interface UpdateAware<O extends object = Record<string, any>> {
    updateModel: (options: O) => void;
}
export interface IKosModel<DataDef extends IKosDataModel = IKosDataModel> extends IKosCompanionModelContainer, IKosModelLifecycle, IKosVisitorHost<IKosModel> {
    modelId: string;
    status: KosModelState;
    onlineStatus: KosModelState;
    activeStatus: KosModelState;
    modelTypeName: string;
    loaded: boolean;
    fsm: KosFSMManager;
    isReady(): boolean;
    isActive(): boolean;
    isOnline(): boolean;
    whenReady(): Promise<void>;
    whenInitialized(): Promise<void>;
    whenLoaded(): Promise<void>;
    registerSubscribers(): Promise<void>;
    getChildren(): IKosModel[];
    modelData: DataDef;
    modelManager: KosModelManager;
    onlineLifecycleManager?: KosOnlineLifecycleManager;
}
interface KosModelParameters<DataType extends IKosDataModel> {
    modelTypeName: string;
    id?: string | number;
    modelData: DataType;
}
interface IKosCreateParam<Options extends object = Record<string, any>> {
    id?: string;
    modelTypeId: string;
    options?: Options;
}
export type IKosDataModelBuilder<D, M extends IKosDataModel> = (data: D) => M;
export type IKosDataModelCreator<M extends IKosDataModel = IKosDataModel, O extends object = Record<string, any>> = (params: IKosCreateParam<O>) => M;
export interface IKosDataModelFactory<D, M extends IKosDataModel> {
    build?: IKosDataModelBuilder<D, M>;
    create?: IKosDataModelCreator<M>;
}
interface IKosCompanionModelContainer {
    clearCompanionModels: () => void;
    addCompanionModel: (model: IKosModel) => void;
    companionModels: KosCompanionModelManager;
}
export declare class KosModel<DataDef extends IKosDataModel = IKosDataModel> implements IKosModel<DataDef>, IKosCompanionModelContainer {
    private _id;
    private _status;
    private _activeStatus;
    private _onlineStatus;
    modelData: DataDef;
    modelTypeName: string;
    initialized: boolean;
    loaded: boolean;
    private _isLoadExecuting;
    offlineQueue: KosOfflineQueue;
    subscriptionManager?: KosSubscriptionManager;
    effectManager?: KosEffectManager;
    httpRouteManager?: KosHttpRouteManager;
    onlineLifecycleManager?: KosOnlineLifecycleManager;
    serviceResponses: any;
    serviceRequestManager?: any;
    companionManager: KosCompanionModelManager;
    childResolver: KosChildResolver;
    fsm: KosFSMManager;
    constructor({ modelTypeName, id, modelData }: KosModelParameters<DataDef>);
    get companionModels(): KosCompanionModelManager;
    set status(status: KosModelState);
    get status(): KosModelState;
    get modelId(): string;
    get id(): string;
    get activeStatus(): KosModelState;
    set activeStatus(activeStatus: KosModelState);
    get onlineStatus(): KosModelState;
    set onlineStatus(onlineStatus: KosModelState);
    get modelManager(): any;
    isActive(): boolean;
    isOnline(): boolean;
    isReady(): boolean;
    deactivate(): Promise<void>;
    activate(): Promise<void>;
    whenLoaded(): Promise<void>;
    whenInitialized(): Promise<void>;
    whenReady(): Promise<void>;
    ready(): Promise<void>;
    load(): Promise<void>;
    unload(): Promise<void>;
    init(): Promise<void>;
    registerSubscribers(lifecycle?: DependencyLifecycle): Promise<void>;
    /**
     * Initialize the state machine for a specific lifecycle phase.
     * Called from lifecycle hooks (init, load, ready, activate).
     * @internal
     */
    initializeStateMachineForLifecycle(lifecycle: DependencyLifecycle): void;
    /**
     * Creates lifecycle-deferred companion models at the appropriate phase.
     * Called from lifecycle hooks (init, load, ready, activate, online).
     * @internal
     */
    private createLifecycleCompanions;
    online(): Promise<void>;
    offline(): Promise<void>;
    accept(visitor: IKosVisitor<IKosModel>): void;
    getChildren(): IKosModel[];
    addCompanionModel(model: IKosModel<IKosDataModel>): void;
    clearCompanionModels(): void;
}
export {};
//# sourceMappingURL=kosModel.d.ts.map