import 'reflect-metadata';
import { PureContainer } from '@worktif/utils';
import { RuntimeWebContainer } from '../../runtime-web.container';
import { CoreBasicBundle } from '../../core.bundle/core-basic.bundle';
import { LambdaPipeline } from '../../../runtime-web/pipelines/lambda-pipeline';
import { MicroserviceBundle } from '../../../runtime-web/bundle/microservice-bundle';
import type { BundleDiagnostics, RuntimeBundle } from '../../../runtime-web/bundle/runtime-bundle.interface';
import { MicroserviceRegistrar } from '../../../runtime-web/registrar/microservice-registrar';
import type { MicroserviceDefinition } from '../../../../lib/runtime-web/types';
import { RuntimeThreads } from '../../../../lib/runtime.types';
/**
 * CorePipelinesBundle provides the base functionality for creating and managing a container with DI (Dependency Injection)
 * and lambda runtime support. It extends `CoreBasicBundle` to ensure core application module behavior with additional
 * support for initialization and service management.
 *
 * This class serves as an abstraction layer for managing dependency-injected containers and lambda handlers
 * in a runtime web environment. The functionalities include configuring scoped dependencies and ensuring
 * they are tied to service handlers dynamically.
 *
 * **CRITICAL ARCHITECTURAL DECISION**: CorePipelinesBundle implements RuntimeBundle interface directly.
 * This is the correct solution because:
 * 1. CorePipelinesBundle already manages the DI container, Lambda pipelines, and handlers registry
 * 2. It is already a singleton (corePipelinesBundle) exported from Lambda Layer
 * 3. No need for a separate adapter class (RuntimeBundleImplementation is redundant)
 * 4. Single source of truth for container lifecycle management
 *
 * Note: This is an injectable service-via-container implementation tailored to runtime web environments.
 *
 * **Requirements**: 5.1, 5.2, 5.3, 5.4, 5.5, 15.1
 *
 * @class CorePipelinesBundle
 * @extends CoreBasicBundle
 * @implements RuntimeBundle
 */
export declare class CorePipelinesBundle extends CoreBasicBundle implements RuntimeBundle {
    /**
     * Container lifecycle manager for deterministic initialization
     */
    private readonly lifecycleManager;
    /**
     * Dependency metadata manager for hash-based service registration
     */
    private readonly metadataManager;
    /**
     * Lambda handler factory for creating handlers with DI
     */
    private readonly handlerFactory;
    /**
     * Microservice registrar for Lambda handler management
     */
    private registrar;
    /**
     * Initialization start time for diagnostics
     */
    private readonly initializationStartTime;
    /**
     * Initialization end time for diagnostics
     */
    private initializationEndTime?;
    /**
     * Bundle version for diagnostics
     */
    private readonly bundleVersion;
    /**
     * Flag to track if container has been initialized through lifecycle manager
     */
    private isLifecycleInitialized;
    /**
     * Cache of MicroserviceBundle instances by microservice name.
     * Ensures same microservice returns same bundle instance.
     *
     * **Requirements**: 7.5
     */
    private readonly microserviceBundles;
    /**
     * @class Container
     *
     * @classdesc
     * The Container class represents a variable container, which can hold, retrieve, and modify values of any type.
     * It allows storing key-value pairs, similar to a dictionary or associative array, where the keys are strings
     * representing variable names and the values are the corresponding values.
     *
     * @constructor
     * Creates a new Container object.
     */
    protected container: RuntimeWebContainer;
    /**
     * Registry of bound handler methods by Lambda ID.
     *
     * This registry stores pre-bound handler methods for each Lambda function,
     * allowing direct access by Lambda ID without repeated DI resolution.
     *
     * Format: { 'serviceName.lambdaId': boundHandlerMethod }
     */
    handlers: Record<string, Function>;
    /**
     * Cache for DI container instances to avoid repeated initialization.
     *
     * This cache stores resolved DI instances by their key, ensuring that
     * the same instance is reused across multiple handler invocations.
     *
     * Format: { 'diKey': resolvedInstance }
     */
    protected diInstanceCache: Record<string, any>;
    /**
     * Cache for bound handler methods to avoid repeated binding operations.
     *
     * This cache stores the bound handler methods to ensure consistent
     * function references across multiple accesses.
     *
     * Format: { 'lambdaId': { handler: boundMethod, instance: diInstance } }
     */
    protected handlerCache: Record<string, {
        handler: Function;
        instance: any;
    }>;
    /**
     * Initializes a new instance of the class and sets up dependencies for various Lambda services,
     * including LambdaRuntimeWebHandler, LambdaRuntimeWebSeo, and LambdaRuntimeWebManifest.
     *
     * @return {void} No return value as this is a constructor. Initializes the instance and its dependencies.
     */
    constructor(support?: boolean);
    /**
     * Executes the runContainer method, which binds lambda handlers to their respective instance keys
     * if the `container.tied` object is defined. This method ensures proper binding between handlers
     * and their associated functionality during the initialization of the container.
     *
     * Performance optimization: Caches DI instances to avoid repeated resolution.
     *
     * @return {void} This method does not return a value.
     */
    protected runContainer(): void;
    /**
     * Initialize container synchronously as a fallback.
     * This method provides immediate container initialization without the full
     * lifecycle management benefits, but ensures compatibility with the existing
     * synchronous initialization pattern.
     *
     * @private
     */
    private initializeContainerSynchronously;
    /**
     * Initialize container using the lifecycle manager for deterministic initialization.
     * This ensures that container creation, service registration, and validation occur
     * in the correct order to prevent race conditions.
     *
     * This method should be called explicitly when async initialization is possible.
     *
     * @returns Promise that resolves when initialization is complete
     */
    initializeContainerWithLifecycle(): Promise<void>;
    /**
     * Get core Ties classes for service registration.
     * This method extracts the Ties classes that need to be registered
     * with the container during initialization.
     *
     * @todo: complete registration
     *
     * @param ties - Optional array of Ties classes to use
     * @returns Array of core Ties classes
     * @private
     */
    private getCoreTiesClasses;
    /**
     * Get the shared container instance from the lifecycle manager.
     * This ensures all components use the same container instance.
     *
     * @returns The shared container instance
     */
    getSharedContainer(): any;
    /**
     * Check if the container is ready for handler execution.
     *
     * @returns True if container is ready
     */
    isContainerReady(): boolean;
    /**
     * Get container initialization diagnostics.
     *
     * @returns Initialization state information
     */
    getContainerDiagnostics(): any;
    get pipelines(): LambdaPipeline;
    /**
     * Injects dependencies into the container by binding specific runtime configurations.
     *
     * The method ties dependencies such as environment configuration and lambda pipeline factory
     * to the container with their respective instances and dependencies.
     *
     * @return {void} Does not return any value.
     */
    protected injectContainer(): void;
    /**
     * RuntimeBundle.getContainer() implementation.
     * Returns the shared DI container instance.
     *
     * **Requirements**: 5.3
     *
     * @returns Fully initialized shared container instance
     * @throws Error if container is not initialized
     */
    getContainer(): PureContainer<string>;
    /**
     * RuntimeBundle.getPipeline() implementation.
     * Returns the Lambda pipeline instance.
     *
     * **Requirements**: 5.4
     *
     * @returns Lambda pipeline instance with container access
     * @throws Error if pipeline is not initialized
     */
    getPipeline(): LambdaPipeline;
    /**
     * RuntimeBundle.getHandler() implementation.
     * Returns bound handler for specific Lambda ID.
     *
     * Supports two calling conventions for backward compatibility:
     * - getHandler(lambdaId) - legacy sync call
     * - getHandler(runtimeThreads, lambdaId) - new async call
     *
     * **Requirements**: 5.5
     *
     * @param runtimeThreadsOrLambdaId - RuntimeThreads object OR Lambda ID for backward compatibility
     * @param lambdaId - Lambda ID (e.g., 'payments.charge') - optional if first arg is Lambda ID
     * @returns Bound handler function ready for AWS Lambda runtime
     * @throws Error if Lambda ID not found or handler creation fails
     */
    getHandler(runtimeThreadsOrLambdaId: RuntimeThreads | string, lambdaId?: string): any;
    /**
     * RuntimeBundle.validateBundle() implementation.
     * Validates bundle completeness before handler execution.
     *
     * **Requirements**: 15.1, 15.6
     *
     * @throws Error if bundle validation fails
     */
    validateBundle(): void;
    /**
     * RuntimeBundle.getDiagnostics() implementation.
     * Returns comprehensive diagnostic information including object-based ties support.
     *
     * **Requirements**: 15.4, 8.5
     *
     * @returns Bundle diagnostic information with enhanced DI pattern details
     */
    getDiagnostics(): BundleDiagnostics;
    /**
     * Set the microservice registrar for Lambda handler management.
     *
     * @param registrar - MicroserviceRegistrar instance
     */
    setRegistrar(registrar: MicroserviceRegistrar): void;
    /**
     * Get the microservice registrar.
     *
     * @returns MicroserviceRegistrar instance or undefined
     */
    getRegistrar(): MicroserviceRegistrar | undefined;
    /**
     * Create an isolated MicroserviceBundle for a specific microservice.
     *
     * This is the key method that enables microservice isolation:
     * - Creates a NEW PureContainer (not shared with other microservices)
     * - Registers ONLY the Ties from this microservice's definition
     * - Creates handlers ONLY for this microservice's Lambdas
     * - Returns a MicroserviceBundle that implements RuntimeBundle
     * - **ENHANCED**: Now supports both array-based and object-based ties registration
     * - **ENHANCED**: Integrates with enhanced LambdaHandlerFactory for typed DI
     *
     * **Requirements**: 7.1, 7.2, 7.3, 7.4, 7.5, 7.6, 8.1, 8.2, 8.3, 8.4, 8.5
     *
     * @param microserviceName - Name of the microservice (e.g., 'payments')
     * @param definition - Microservice definition with ties and lambdas
     * @returns MicroserviceBundle instance
     * @throws Error if microservice creation fails
     *
     * @example
     * ```typescript
     * // Array-based ties (legacy)
     * const paymentsBundle = corePipelinesBundle.runMicroservice('payments', {
     *   ties: [PaymentsTies, BillingTies],
     *   lambdas: [chargeHandler, refundHandler]
     * });
     *
     * // Object-based ties (new pattern)
     * const paymentsBundle = corePipelinesBundle.runMicroservice('payments', {
     *   ties: [PaymentsTies, BillingTies], // Still array of classes with register property
     *   lambdas: [{
     *     id: 'charge',
     *     ties: { paymentService: PaymentsService, billingService: BillingService },
     *     handler: async (event, context) => {
     *       return await event.ties.paymentService.processCharge(event.body);
     *     }
     *   }]
     * });
     *
     * // Now paymentsBundle has isolated DI container with meaningful keys
     * const handler = await paymentsBundle.getHandler(null, 'charge'); // Short ID!
     * ```
     *
     * @note: definition: { ties: [...], lambdas: [...] }
     */
    runMicroservice(microserviceName: string, definition: MicroserviceDefinition): MicroserviceBundle;
    /**
     * Get cached MicroserviceBundle by name.
     *
     * @param microserviceName - Name of the microservice
     * @returns MicroserviceBundle or undefined if not created
     */
    getMicroserviceBundle(microserviceName: string): MicroserviceBundle | undefined;
    /**
     * Get all cached microservice names.
     *
     * @returns Array of microservice names
     */
    getCachedMicroserviceNames(): string[];
    /**
     * Get all microservice names.
     *
     * @returns Array of microservice names
     */
    getMicroserviceNames(): string[];
    /**
     * Clear microservice bundle cache.
     * Useful for testing.
     */
    clearMicroserviceBundles(): void;
    /**
     * Get initialization time in milliseconds.
     *
     * @returns Initialization time
     * @private
     */
    private getInitializationTime;
    /**
     * Get total number of services in container.
     *
     * @returns Service count
     * @private
     */
    private getServiceCount;
    /**
     * Get total number of Lambda handlers.
     *
     * @returns Lambda count
     * @private
     */
    private getLambdaCount;
    /**
     * Get list of available service names.
     *
     * @returns Array of service names
     * @private
     */
    private getAvailableServices;
    /**
     * Get list of available Lambda handler IDs.
     *
     * @returns Array of Lambda IDs
     * @private
     */
    private getAvailableLambdas;
    /**
     * Get count of Lambda handlers using object-based ties.
     *
     * **Requirements**: 8.5
     *
     * @returns Number of object-based Lambda handlers
     * @private
     */
    private getObjectBasedLambdasCount;
    /**
     * Get migration status for the bundle.
     *
     * **Requirements**: 8.5, 9.1, 9.2
     *
     * @returns Migration status description
     * @private
     */
    private getMigrationStatus;
}
/**
 * A variable that holds an instance of the CorePipelinesBundle class.
 *
 * The `corePipelinesBundle` serves as the primary interface for managing
 * and interacting with core pipelines within the application. This bundle
 * encapsulates the logic and resources required to operate on pipeline
 * entities efficiently, providing a centralized point of access.
 *
 * This variable is instantiated with a new instance of CorePipelinesBundle,
 * ensuring that all necessary configurations and dependencies are initialized
 * and available for use throughout the application.
 */
export declare const corePipelinesBundle: CorePipelinesBundle;
