import { DelegateEventListener } from './common.ts'; export { DelegateEvent } from './event.ts'; export type { DelegateEventListener } from './common.ts'; type Target = Window | Document | Element | DocumentFragment; type NativeEventName = keyof WindowEventMap | keyof DocumentEventMap; type EventName = NativeEventName | (string & {}); type StripPassive = K extends `${infer Native}:passive` ? Native : K; type EventType = StripPassive extends keyof WindowEventMap ? WindowEventMap[StripPassive] : StripPassive extends keyof DocumentEventMap ? DocumentEventMap[StripPassive] : StripPassive extends keyof GlobalEventHandlersEventMap ? GlobalEventHandlersEventMap[StripPassive] : Event; export declare class Delegate { private readonly baseTarget; private readonly listenerCache; private readonly subscriberCache; /** * Creates a new delegate instance for the specified event target. * @param baseTarget - The base event target for delegation. */ constructor(baseTarget: Target); /** * Internal event listener function that handles event delegation. * @param passive - Whether the event is using passive mode or not. * @param ev - The native event object that was triggered. */ private listener; /** * Adds an event listener to the specified event with optional selector for delegation. * @param eventName - Name of the event to listen for. * @param selector - CSS selector for delegation. * @param handler - Event handler function to be executed. * @returns Current delegate instance for chaining. */ on(eventName: TEventName, selector: string, handler: DelegateEventListener>): Delegate; /** * Adds an event listener to the specified event with optional selector for delegation. * @param eventName - Name of the event to listen for. * @param handler - Event handler function to be executed. * @returns Current delegate instance for chaining. */ on(eventName: TEventName, handler: DelegateEventListener>): Delegate; /** * Adds a one-time event listener that will be automatically removed after execution. * @param eventName - Name of the event to listen for. * @param selector - CSS selector for delegation. * @param handler - Event handler function to be executed once. * @returns Current delegate instance for chaining. */ one(eventName: TEventName, selector: string, handler: DelegateEventListener>): Delegate; /** * Adds a one-time event listener that will be automatically removed after execution. * @param eventName - Name of the event to listen for. * @param handler - Event handler function to be executed once. * @returns Current delegate instance for chaining. */ one(eventName: TEventName, handler: DelegateEventListener>): Delegate; /** * Removes event listeners based on the specified parameters. * @param [eventName] - Name of the event to remove. * @param [selector] - CSS selector for delegation. * @param [handler] - Event handler function to remove. * @returns Current delegate instance for chaining. */ off(eventName?: EventName, selector?: string, handler?: DelegateEventListener>): Delegate; /** * Removes event listeners based on the specified parameters. * @param eventName - Name of the event to remove. * @param handler - Event handler function to remove. * @returns Current delegate instance for chaining. */ off(eventName: EventName, handler: DelegateEventListener>): Delegate; /** * Clears all event listeners and removes the delegator from cache. */ clear(): void; } /** * Creates or retrieves a delegate instance for the specified event target. * @param baseTarget - The base event target for delegation. * @returns A delegate instance for the specified event target. * @throws TypeError if the baseTarget is not a valid event target. */ export declare const delegate: (baseTarget: Target) => Delegate;