/**
 * Observer Pattern Implementation
 *
 * This module provides the core implementation for the Observer pattern,
 * including the registry and notifier for managing resource observers.
 *
 * @module declarative-api/observer/observer
 */
import type { IResourceObserver, IObserverRegistry, IObserverNotifier, ObserverType, BatchNotificationResult, ResourceCreatedEvent, ResourceModifiedEvent, ResourceDeletedEvent } from '../../../lib/runtime-web/types/declarative-api';
/**
 * Error thrown when attempting to register a duplicate observer.
 */
export declare class DuplicateObserverError extends Error {
    readonly observerId: string;
    readonly name = "DuplicateObserverError";
    constructor(observerId: string);
}
/**
 * Type guard for DuplicateObserverError.
 *
 * @param error - The error to check
 * @returns True if the error is a DuplicateObserverError
 */
export declare function isDuplicateObserverError(error: unknown): error is DuplicateObserverError;
/**
 * Observer Registry implementation.
 *
 * Manages registration and retrieval of resource observers.
 * Observers are stored sorted by priority for efficient notification.
 *
 * Validates: Requirements 6.4, 6.5
 */
export declare class ObserverRegistry implements IObserverRegistry {
    private readonly observers;
    private sortedObservers;
    private needsSort;
    /**
     * Register an observer.
     *
     * @param observer - The observer to register
     * @throws DuplicateObserverError if observer with same ID already registered
     */
    register(observer: IResourceObserver): void;
    /**
     * Unregister an observer by ID.
     *
     * @param observerId - The observer ID to unregister
     * @returns True if observer was unregistered, false if not found
     */
    unregister(observerId: string): boolean;
    /**
     * Get all registered observers sorted by priority.
     *
     * @returns Array of observers sorted by priority (ascending)
     */
    getAll(): readonly IResourceObserver[];
    /**
     * Get observers by type.
     *
     * @param type - The observer type to filter by
     * @returns Array of observers of the specified type
     */
    getByType(type: ObserverType): readonly IResourceObserver[];
    /**
     * Check if an observer is registered.
     *
     * @param observerId - The observer ID to check
     * @returns True if observer is registered
     */
    has(observerId: string): boolean;
    /**
     * Get the number of registered observers.
     *
     * @returns The count of registered observers
     */
    count(): number;
    /**
     * Clear all registered observers.
     */
    clear(): void;
    /**
     * Ensure observers are sorted by priority.
     */
    private ensureSorted;
}
/**
 * Observer Notifier implementation.
 *
 * Handles dispatching events to observers with proper ordering
 * and error handling. Errors in one observer do not prevent
 * notification of others.
 *
 * Validates: Requirements 6.4, 6.5, 6.6
 */
export declare class ObserverNotifier implements IObserverNotifier {
    private readonly registry;
    constructor(registry: IObserverRegistry);
    /**
     * Notify all observers of a resource creation event.
     *
     * @param event - The resource created event
     * @returns Batch notification result
     */
    notifyCreated(event: ResourceCreatedEvent): BatchNotificationResult;
    /**
     * Notify all observers of a resource modification event.
     *
     * @param event - The resource modified event
     * @returns Batch notification result
     */
    notifyModified(event: ResourceModifiedEvent): BatchNotificationResult;
    /**
     * Notify all observers of a resource deletion event.
     *
     * @param event - The resource deleted event
     * @returns Batch notification result
     */
    notifyDeleted(event: ResourceDeletedEvent): BatchNotificationResult;
    /**
     * Notify all observers asynchronously of a resource creation event.
     *
     * @param event - The resource created event
     * @returns Promise resolving to batch notification result
     */
    notifyCreatedAsync(event: ResourceCreatedEvent): Promise<BatchNotificationResult>;
    /**
     * Notify all observers asynchronously of a resource modification event.
     *
     * @param event - The resource modified event
     * @returns Promise resolving to batch notification result
     */
    notifyModifiedAsync(event: ResourceModifiedEvent): Promise<BatchNotificationResult>;
    /**
     * Notify all observers asynchronously of a resource deletion event.
     *
     * @param event - The resource deleted event
     * @returns Promise resolving to batch notification result
     */
    notifyDeletedAsync(event: ResourceDeletedEvent): Promise<BatchNotificationResult>;
    /**
     * Notify all observers synchronously.
     *
     * @param callback - The notification callback
     * @returns Batch notification result
     */
    private notifyAll;
    /**
     * Notify all observers asynchronously.
     *
     * Observers are notified in priority order (sequentially).
     *
     * @param callback - The notification callback
     * @returns Promise resolving to batch notification result
     */
    private notifyAllAsync;
    /**
     * Create a batch notification result from individual results.
     *
     * @param results - Individual observer results
     * @param startTime - Start time of the batch notification
     * @returns Batch notification result
     */
    private createBatchResult;
}
