import { I as VisualGraph, f as Graph } from "../types-BAEQTwK_.mjs"; import { LayoutOptions } from "./index.mjs"; import cytoscape from "cytoscape"; //#region src/layout/cytoscape.d.ts /** * Minimal interface an injected cytoscape factory must satisfy — the * `cytoscape()` function itself. Inject your own when you've registered * layout extensions via `cytoscape.use(...)` (cola, fcose, dagre, …). */ type CytoscapeLike = (options: cytoscape.CytoscapeOptions) => cytoscape.Core; interface CytoscapeLayoutOptions extends LayoutOptions { /** * Cytoscape layout name. Built-ins: `'grid'`, `'circle'`, `'concentric'`, * `'breadthfirst'`, `'cose'` (default), `'random'`. Extension layouts work * when registered on an injected {@link CytoscapeLayoutOptions.cy} factory. */ name?: string; /** * Raw cytoscape layout options, merged into the layout call last (override * everything, including `name`). Engine-specific tuning — spacing knobs, * `boundingBox`, `roots`, iteration counts — goes here; the options vary * too much between cytoscape layouts to map `LayoutOptions.spacing` * generically. See https://js.cytoscape.org/#layouts */ layoutOptions?: Record; /** * Injected cytoscape factory — e.g. one with extensions registered via * `cytoscape.use(...)`. Defaults to the imported `cytoscape`. */ cy?: CytoscapeLike; } /** * Lay out a graph with Cytoscape.js (`cytoscape`, an optional peer * dependency) — one call unlocks its whole layout ecosystem. Pure: returns a * new {@link VisualGraph} with node positions and sizes. Cytoscape layouts * position nodes only; edges keep their fields but gain no route `points`. * Compound graphs are supported via cytoscape `parent`; parent nodes get * cytoscape's computed compound dimensions. All coordinates are absolute * (cytoscape does not produce parent-relative positions). * * Runs headless with `styleEnabled: true` so resolved node sizes * ({@link getNodeSize}) participate in overlap avoidance and spacing. * * Option mapping is deliberately minimal: `measure` resolves sizes, * `isFixed` nodes with an existing `x`/`y` are locked in place (cytoscape * layouts skip locked nodes), and everything else — including `direction` * and `spacing` — is engine-specific and belongs in * {@link CytoscapeLayoutOptions.layoutOptions}. `seed` is ignored: the * discrete layouts (grid, circle, concentric, breadthfirst) are * deterministic, and cose is not seedable. * * @example * ```ts * import { getCytoscapeLayout } from '@statelyai/graph/layout/cytoscape'; * * const laidOut = await getCytoscapeLayout(graph, { * name: 'breadthfirst', * layoutOptions: { roots: ['start'] }, * }); * ``` */ declare function getCytoscapeLayout(graph: Graph | VisualGraph, options?: CytoscapeLayoutOptions): Promise; //#endregion export { CytoscapeLayoutOptions, CytoscapeLike, getCytoscapeLayout };