import { Graph } from "../graph";
import { TGraphColors, TGraphConstants } from "../graphConfig";
import { GraphEventsDefinitions } from "../graphEvents";
import { CoreComponent } from "../lib";
import { Component, TComponentState } from "../lib/Component";
import { ICamera } from "./camera/CameraService";
import "./Layer.css";
export type LayerPropsElementProps = {
    zIndex: number;
    classNames?: string[];
    root?: HTMLElement;
    transformByCameraPosition?: boolean;
};
export type LayerProps = {
    canvas?: LayerPropsElementProps & {
        respectPixelRatio?: boolean;
    };
    html?: LayerPropsElementProps;
    root?: HTMLElement;
    camera: ICamera;
    graph: Graph;
};
export type LayerContext = {
    graph: Graph;
    camera: ICamera;
    constants: TGraphConstants;
    colors: TGraphColors;
    graphCanvas: HTMLCanvasElement;
    ctx: CanvasRenderingContext2D;
    layer: Layer;
};
export declare class Layer<Props extends LayerProps = LayerProps, Context extends LayerContext = LayerContext, State extends TComponentState = TComponentState> extends Component<Props, State, Context> {
    static id?: string;
    protected canvas: HTMLCanvasElement;
    protected html: HTMLElement;
    protected root?: HTMLDivElement;
    protected attached: boolean;
    /**
     * AbortController used to manage event listeners.
     * All event listeners (both graph.on and DOM addEventListener) are registered with this controller's signal.
     * When the layer is unmounted, the controller is aborted, which automatically removes all event listeners.
     */
    protected eventAbortController: AbortController;
    /**
     * A wrapper for this.props.graph.on that automatically includes the AbortController signal.
     * The method is named onGraphEvent to indicate it's specifically for graph events.
     * This simplifies event subscription and ensures proper cleanup when the layer is unmounted.
     *
     * IMPORTANT: Always use this method in the afterInit() method, NOT in the constructor.
     * This ensures that event subscriptions are properly set up when the layer is reattached.
     * When a layer is unmounted, the AbortController is aborted and a new one is created.
     * When the layer is reattached, afterInit() is called again, which sets up new subscriptions
     * with the new AbortController.
     *
     * @param eventName - The name of the event to subscribe to
     * @param handler - The event handler function
     * @param options - Additional options (optional)
     * @returns The result of graph.on call (an unsubscribe function)
     */
    protected onGraphEvent<EventName extends keyof GraphEventsDefinitions, Cb extends GraphEventsDefinitions[EventName]>(eventName: EventName, handler: Cb, options?: Omit<AddEventListenerOptions, "signal">): () => void;
    /**
     * A wrapper for HTMLElement.addEventListener that automatically includes the AbortController signal.
     * This method is for adding event listeners to the HTML element of the layer.
     * It simplifies event subscription and ensures proper cleanup when the layer is unmounted.
     *
     * IMPORTANT: Always use this method in the afterInit() method, NOT in the constructor.
     * This ensures that event subscriptions are properly set up when the layer is reattached.
     * When a layer is unmounted, the AbortController is aborted and a new one is created.
     * When the layer is reattached, afterInit() is called again, which sets up new subscriptions
     * with the new AbortController.
     *
     * @param eventName - The name of the DOM event to subscribe to
     * @param handler - The event handler function
     * @param options - Additional options (optional)
     */
    protected onHtmlEvent<K extends keyof HTMLElementEventMap>(eventName: K, handler: ((this: HTMLElement, ev: HTMLElementEventMap[K]) => void) | EventListenerObject, options?: Omit<AddEventListenerOptions, "signal">): void;
    /**
     * A wrapper for HTMLCanvasElement.addEventListener that automatically includes the AbortController signal.
     * This method is for adding event listeners to the canvas element of the layer.
     * It simplifies event subscription and ensures proper cleanup when the layer is unmounted.
     *
     * IMPORTANT: Always use this method in the afterInit() method, NOT in the constructor.
     * This ensures that event subscriptions are properly set up when the layer is reattached.
     * When a layer is unmounted, the AbortController is aborted and a new one is created.
     * When the layer is reattached, afterInit() is called again, which sets up new subscriptions
     * with the new AbortController.
     *
     * @param eventName - The name of the DOM event to subscribe to
     * @param handler - The event handler function
     * @param options - Additional options (optional)
     */
    protected onCanvasEvent<K extends keyof HTMLElementEventMap>(eventName: K, handler: ((this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => void) | EventListenerObject, options?: Omit<AddEventListenerOptions, "signal">): void;
    /**
     * A wrapper for HTMLElement.addEventListener that automatically includes the AbortController signal.
     * This method is for adding event listeners to the root element of the layer.
     * It simplifies event subscription and ensures proper cleanup when the layer is unmounted.
     *
     * IMPORTANT: Always use this method in the afterInit() method, NOT in the constructor.
     * This ensures that event subscriptions are properly set up when the layer is reattached.
     * When a layer is unmounted, the AbortController is aborted and a new one is created.
     * When the layer is reattached, afterInit() is called again, which sets up new subscriptions
     * with the new AbortController.
     *
     * @param eventName - The name of the DOM event to subscribe to
     * @param handler - The event handler function
     * @param options - Additional options (optional)
     */
    protected onRootEvent<K extends keyof HTMLElementEventMap>(eventName: K, handler: ((this: HTMLElement, ev: HTMLElementEventMap[K]) => void) | EventListenerObject, options?: Omit<AddEventListenerOptions, "signal">): void;
    constructor(props: Props, parent?: CoreComponent);
    updateSize(width: number, height: number): void;
    /**
     * Called after initialization and when the layer is reattached.
     * This is the proper place to set up event subscriptions using onGraphEvent().
     *
     * When a layer is unmounted, the AbortController is aborted and a new one is created.
     * When the layer is reattached, this method is called again, which sets up new subscriptions
     * with the new AbortController.
     *
     * All derived Layer classes should call super.afterInit() at the end of their afterInit method.
     */
    protected afterInit(): void;
    protected init(): void;
    protected unmountLayer(): void;
    protected unmount(): void;
    getCanvas(): HTMLCanvasElement;
    getHTML(): HTMLElement;
    attachLayer(root: HTMLElement): void;
    detachLayer(): void;
    protected createCanvas(params: LayerProps["canvas"]): HTMLCanvasElement;
    protected createHTML(params: LayerProps["html"]): HTMLDivElement;
    getDRP(): number;
    protected applyTransform(x: number, y: number, scale: number, respectPixelRatio?: boolean): void;
    resetTransform(): void;
    /**
     * Subscribes to a signal (with .subscribe) and automatically unsubscribes when the layer's AbortController is aborted.
     *
     * Usage:
     *   this.onSignal(signal, handler)
     *
     * @template S - Signal type (must have .subscribe method)
     * @template T - Value type of the signal
     * @param signal - Signal with .subscribe method (returns unsubscribe function)
     * @param handler - Handler function to call on signal change
     * @returns The unsubscribe function (called automatically on abort)
     */
    protected onSignal<S extends {
        subscribe: (handler: (value: T) => void) => () => void;
    }, T = S extends {
        subscribe: (handler: (value: infer U) => void) => () => void;
    } ? U : unknown>(signal: S, handler: (value: T) => void): () => void;
}
