import { ApiCallback, EventCallback } from './eventBus';

/**
 * Subscribe to an event that will automatically unsubscribe after the first occurrence
 *
 * @param eventType - The event type to listen for
 * @param callback - The callback to execute once
 * @returns Unsubscribe function
 */
export declare function once<T = ApiCallback>(eventType: string, callback: EventCallback<T>): () => void;
/**
 * Wait for a specific event to occur, returning a Promise
 *
 * @param eventType - The event type to wait for
 * @param timeout - Optional timeout in milliseconds
 * @returns Promise that resolves with the event data
 */
export declare function waitFor<T = ApiCallback>(eventType: string, timeout?: number): Promise<T>;
/**
 * Wait for multiple events to occur (Promise.all pattern)
 *
 * @param eventTypes - Array of event types to wait for
 * @param timeout - Optional timeout in milliseconds
 * @returns Promise that resolves when all events have occurred
 */
export declare function waitForAll<T = ApiCallback>(eventTypes: string[], timeout?: number): Promise<T[]>;
/**
 * Wait for the first event to occur from a list (Promise.race pattern)
 *
 * @param eventTypes - Array of event types to race
 * @param timeout - Optional timeout in milliseconds
 * @returns Promise that resolves with the first event
 */
export declare function race<T = ApiCallback>(eventTypes: string[], timeout?: number): Promise<{
    eventType: string;
    data: T;
}>;
/**
 * Filter events based on a predicate function
 *
 * @param eventType - The event type to filter
 * @param predicate - Function to test each event
 * @param callback - Callback for events that pass the filter
 * @returns Unsubscribe function
 */
export declare function filter<T = ApiCallback>(eventType: string, predicate: (msg: T) => boolean, callback: EventCallback<T>): () => void;
/**
 * Transform events using a map function
 *
 * @param eventType - The event type to transform
 * @param transform - Function to transform the event data
 * @param callback - Callback for transformed events
 * @returns Unsubscribe function
 */
export declare function map<T = ApiCallback, R = any>(eventType: string, transform: (msg: T) => R, callback: (msg: R) => void): () => void;
/**
 * Debounce events - only emit after a period of inactivity
 *
 * @param eventType - The event type to debounce
 * @param delay - Delay in milliseconds
 * @param callback - Callback for debounced events
 * @returns Unsubscribe function
 */
export declare function debounce<T = ApiCallback>(eventType: string, delay: number, callback: EventCallback<T>): () => void;
/**
 * Throttle events - limit emissions to once per interval
 *
 * @param eventType - The event type to throttle
 * @param interval - Minimum interval between emissions in milliseconds
 * @param callback - Callback for throttled events
 * @returns Unsubscribe function
 */
export declare function throttle<T = ApiCallback>(eventType: string, interval: number, callback: EventCallback<T>): () => void;
/**
 * Buffer events and emit them as an array
 *
 * @param eventType - The event type to buffer
 * @param bufferTime - Time window to collect events in milliseconds
 * @param callback - Callback for buffered events
 * @returns Unsubscribe function
 */
export declare function buffer<T = ApiCallback>(eventType: string, bufferTime: number, callback: (events: T[]) => void): () => void;
/**
 * Create a replay subject that remembers the last N events
 *
 * @param eventType - The event type to replay
 * @param bufferSize - Number of events to remember
 * @returns Object with subscribe method that replays buffered events
 */
export declare function replay<T = ApiCallback>(eventType: string, bufferSize?: number): {
    subscribe: (callback: EventCallback<T>) => {
        count: number;
        unsubscribe: () => {
            count: number;
        };
    };
};
/**
 * Merge multiple event streams into one
 *
 * @param eventTypes - Array of event types to merge
 * @param callback - Callback for all merged events
 * @returns Unsubscribe function for all subscriptions
 */
export declare function merge<T = ApiCallback>(eventTypes: string[], callback: (eventType: string, msg: T) => void): () => void;
/**
 * Create a state machine that transitions based on events
 *
 * @param initialState - The initial state
 * @param transitions - Object mapping states to event handlers
 * @returns Object with current state and unsubscribe function
 */
export declare function stateMachine<TState extends string, T = ApiCallback>(initialState: TState, transitions: Record<TState, Record<string, (msg: T) => TState>>): {
    readonly state: TState;
    unsubscribe: () => void;
};
/**
 * Utility to create a promise that can be resolved by publishing an event
 *
 * @param requestEvent - Event type to publish the request
 * @param responseEvent - Event type to wait for the response
 * @param request - The request data to publish
 * @param timeout - Optional timeout in milliseconds
 * @returns Promise that resolves with the response
 */
export declare function request<TRequest = any, TResponse = ApiCallback>(requestEvent: string, responseEvent: string, request: TRequest, timeout?: number): Promise<TResponse>;
/**
 * Create an async iterator for events
 *
 * @param eventType - The event type to iterate
 * @returns Async iterator for use with for-await-of
 */
export declare function eventIterator<T = ApiCallback>(eventType: string): AsyncIterableIterator<T>;
export declare const EventBusFunctional: {
    once: typeof once;
    waitFor: typeof waitFor;
    waitForAll: typeof waitForAll;
    race: typeof race;
    filter: typeof filter;
    map: typeof map;
    debounce: typeof debounce;
    throttle: typeof throttle;
    buffer: typeof buffer;
    replay: typeof replay;
    merge: typeof merge;
    stateMachine: typeof stateMachine;
    request: typeof request;
    eventIterator: typeof eventIterator;
};
//# sourceMappingURL=eventBus.functional.d.ts.map