import type { ElementTypeIri, LinkTypeIri } from '../data/model';
import type { Element, Link } from './elements';
import { Rect, Size, SizeProvider, Vector } from './geometry';
import type { DiagramModel } from './model';
/**
 * Represents basic graph structure as an input for a graph layout algorithm.
 *
 * @category Geometry
 */
export interface LayoutGraph {
    readonly nodes: {
        readonly [id: string]: LayoutNode;
    };
    readonly links: ReadonlyArray<LayoutLink>;
}
/**
 * Represents basic graph node for a graph layout algorithm.
 *
 * @category Geometry
 * @see {@link LayoutGraph}
 */
export interface LayoutNode {
    readonly types: readonly ElementTypeIri[];
    readonly fixed?: boolean;
}
/**
 * Represents basic graph edge for a graph layout algorithm.
 *
 * @category Geometry
 * @see {@link LayoutGraph}
 */
export interface LayoutLink {
    readonly type: LinkTypeIri;
    readonly source: string;
    readonly target: string;
}
/**
 * Represents graph node positions and sizes as an input and an output state
 * for a graph layout algorithm.
 *
 * @category Geometry
 */
export interface LayoutState {
    readonly bounds: {
        readonly [id: string]: Rect;
    };
}
/**
 * Performs a graph layout algorithm.
 *
 * @category Geometry
 */
export type LayoutFunction = (graph: LayoutGraph, state: LayoutState) => Promise<LayoutState>;
/**
 * Provides additional diagram content metadata for a graph layout algorithm.
 *
 * @category Geometry
 */
export interface LayoutTypeProvider {
    readonly getElementTypes?: (element: Element) => readonly ElementTypeIri[];
    readonly getLinkType?: (link: Link) => LinkTypeIri;
}
/**
 * Represents a result of performing a graph layout algorithm on a diagram.
 *
 * @category Geometry
 * @see {@link calculateLayout}
 * @see {@link applyLayout}
 */
export interface CalculatedLayout {
    positions: Map<string, Vector>;
    sizes: Map<string, Size>;
    nestedLayouts: CalculatedLayout[];
}
/**
 * Computes a layout on the specified diagram elements using specified
 * graph layout algorithm function ({@link LayoutFunction}).
 *
 * **Example**:
 * ```ts
 * const layout = await calculateLayout({
 *     layoutFunction: defaultLayout,
 *     model,
 *     sizeProvider: canvas.renderingState,
 * });
 *
 * await canvas.animateGraph(() => {
 *     applyLayout(layout, model);
 * });
 * ```
 *
 * @category Geometry
 * @see {@link applyLayout}
 */
export declare function calculateLayout(params: {
    /**
     * Graph layout algorithm function.
     */
    layoutFunction: LayoutFunction;
    /**
     * Model of a diagram to calculate layout for.
     */
    model: DiagramModel;
    /**
     * Size provider for the elements.
     */
    sizeProvider: SizeProvider;
    /**
     * Additional metadata provider for the elements.
     */
    typeProvider?: LayoutTypeProvider;
    /**
     * Set of elements which should not be moved by layout algorithm
     * (if supported).
     */
    fixedElements?: ReadonlySet<Element>;
    /**
     * Subset of elements from the diagram to layout.
     */
    selectedElements?: ReadonlySet<Element>;
    /**
     * Cancellation signal.
     */
    signal?: AbortSignal;
}): Promise<CalculatedLayout>;
/**
 * Applies the computed graph layout to the diagram.
 *
 * @category Geometry
 * @see {@link calculateLayout}
 */
export declare function applyLayout(layout: CalculatedLayout, model: DiagramModel): void;
/**
 * Moves each point in `positions` by the same vector to ensure every point
 * has positive `x` and `y` coordinates, then additionally moves each point by `offset`.
 *
 * @category Geometry
 */
export declare function translateToPositiveQuadrant(positions: Map<string, Vector>, offset: Vector): void;
/**
 * Make a function that maps successive integer indices into a positions
 * on a uniformly sized grid with the specified cell size.
 *
 * @category Geometry
 */
export declare function uniformGrid(params: {
    rows: number;
    cellSize: Vector;
}): (cellIndex: number) => Rect;
//# sourceMappingURL=layout.d.ts.map