/**
 * Disposable Pattern for Resource Management
 *
 * Provides a consistent way to manage and clean up resources like
 * event listeners, timers, WebSocket connections, etc.
 */
/**
 * Interface for objects that can be disposed
 */
export interface Disposable {
    dispose(): void;
}
/**
 * Check if an object is Disposable
 */
export declare function isDisposable(obj: unknown): obj is Disposable;
/**
 * A stack of disposables that are disposed in LIFO order
 */
export declare class DisposableStack implements Disposable {
    private stack;
    private disposed;
    /**
     * Add a disposable to the stack and return it
     */
    add<T extends Disposable>(disposable: T): T;
    /**
     * Add a cleanup callback to the stack
     */
    addCallback(callback: () => void): void;
    /**
     * Add a value with a custom dispose function
     */
    addValue<T>(value: T, dispose: (value: T) => void): T;
    /**
     * Dispose all items in reverse order (LIFO)
     */
    dispose(): void;
    /**
     * Check if this stack has been disposed
     */
    get isDisposed(): boolean;
    /**
     * Get the number of items in the stack
     */
    get size(): number;
}
/**
 * Create a disposable from an event listener
 */
export declare function disposableListener(target: EventTarget, event: string, handler: EventListenerOrEventListenerObject, options?: AddEventListenerOptions): Disposable;
/**
 * Create a disposable from a timeout
 */
export declare function disposableTimeout(callback: () => void, ms: number): Disposable & {
    id: ReturnType<typeof setTimeout>;
};
/**
 * Create a disposable from an interval
 */
export declare function disposableInterval(callback: () => void, ms: number): Disposable & {
    id: ReturnType<typeof setInterval>;
};
/**
 * Create a disposable from a WebSocket
 */
export declare function disposableWebSocket(ws: WebSocket): Disposable;
/**
 * Create a disposable from an AbortController
 */
export declare function disposableAbortController(): Disposable & {
    controller: AbortController;
    signal: AbortSignal;
};
/**
 * Create a disposable subscription (for event emitters, observables, etc.)
 */
export declare function disposableSubscription(unsubscribe: () => void): Disposable;
/**
 * Get or create a DisposableStack for an HTML element
 */
export declare function getElementDisposables(element: HTMLElement): DisposableStack;
/**
 * Dispose all disposables attached to an element
 */
export declare function disposeElement(element: HTMLElement): void;
/**
 * Check if an element has disposables
 */
export declare function hasElementDisposables(element: HTMLElement): boolean;
/**
 * Decorator/helper to make a class disposable
 * Tracks all resources and disposes them when dispose() is called
 */
export declare class DisposableMixin {
    protected disposables: DisposableStack;
    /**
     * Register a disposable to be cleaned up
     */
    protected track<T extends Disposable>(disposable: T): T;
    /**
     * Register a cleanup callback
     */
    protected onDispose(callback: () => void): void;
    /**
     * Dispose all tracked resources
     */
    dispose(): void;
}
/**
 * Create a composite disposable that disposes multiple items together
 */
export declare function compositeDisposable(...disposables: Disposable[]): Disposable;
/**
 * Run a function with automatic cleanup on exit
 * Similar to Python's context managers or C#'s using statement
 */
export declare function using<T extends Disposable, R>(resource: T | (() => T), fn: (resource: T) => R | Promise<R>): Promise<R>;
/**
 * Synchronous version of using()
 */
export declare function usingSync<T extends Disposable, R>(resource: T | (() => T), fn: (resource: T) => R): R;
