# @birchui/diagram API reference

> Birch UI Diagram: flow and diagram editor with auto-layout and orthogonal routing

```bash
npm install @birchui/diagram
```

## @birchui/diagram

### createDiagram

Kind: function. Import from `@birchui/diagram`.

```ts
function createDiagram<TNodeData = DiagramData, TEdgeData = DiagramData>(container: HTMLElement, options: DiagramOptions<TNodeData, TEdgeData> = {}): DiagramApi<TNodeData, TEdgeData>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `container` | `HTMLElement` |  |
| `options?` | `DiagramOptions<TNodeData, TEdgeData>` |  |

### forceLayout

Kind: function. Import from `@birchui/diagram`.

```ts
function forceLayout(nodes: readonly LayoutNodeInput[], edges: readonly LayoutEdgeInput[], options: ForceLayoutOptions = {}): Map<string, Point>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `nodes` | `readonly LayoutNodeInput[]` |  |
| `edges` | `readonly LayoutEdgeInput[]` |  |
| `options?` | `ForceLayoutOptions` |  |

### gridLayout

Kind: function. Import from `@birchui/diagram`.

```ts
function gridLayout(nodes: readonly LayoutNodeInput[], options: GridLayoutOptions = {}): Map<string, Point>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `nodes` | `readonly LayoutNodeInput[]` |  |
| `options?` | `GridLayoutOptions` |  |

### layeredLayout

Kind: function. Import from `@birchui/diagram`.

```ts
function layeredLayout(nodes: readonly LayoutNodeInput[], edges: readonly LayoutEdgeInput[], options: LayeredLayoutOptions = {}): LayeredLayoutResult
```

| Parameter | Type | Description |
| --- | --- | --- |
| `nodes` | `readonly LayoutNodeInput[]` |  |
| `edges` | `readonly LayoutEdgeInput[]` |  |
| `options?` | `LayeredLayoutOptions` |  |

### routeOrthogonal

Kind: function. Import from `@birchui/diagram`.

```ts
function routeOrthogonal(input: OrthogonalRouteInput): Point[]
```

| Parameter | Type | Description |
| --- | --- | --- |
| `input` | `OrthogonalRouteInput` |  |

### runLayout

Kind: function. Import from `@birchui/diagram`.

```ts
function runLayout(nodes: readonly LayoutNodeInput[], edges: readonly LayoutEdgeInput[], options: RunLayoutOptions = {}): Map<string, Point>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `nodes` | `readonly LayoutNodeInput[]` |  |
| `edges` | `readonly LayoutEdgeInput[]` |  |
| `options?` | `RunLayoutOptions` |  |

### treeLayout

Kind: function. Import from `@birchui/diagram`.

```ts
function treeLayout(nodes: readonly LayoutNodeInput[], edges: readonly LayoutEdgeInput[], options: TreeLayoutOptions = {}): Map<string, Point>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `nodes` | `readonly LayoutNodeInput[]` |  |
| `edges` | `readonly LayoutEdgeInput[]` |  |
| `options?` | `TreeLayoutOptions` |  |

### SpatialIndex

Kind: class. Import from `@birchui/diagram`.

```ts
class SpatialIndex
new SpatialIndex(cellSize = 256)
```

| Property | Type | Description |
| --- | --- | --- |
| `readonly cellSize` | `number` |  |
| `size` | `number` |  |
| `has` | `(id: string) => boolean` |  |
| `get` | `(id: string) => Rect \| undefined` |  |
| `clear` | `() => void` |  |
| `insert` | `(id: string, rect: Rect) => void` |  |
| `update` | `(id: string, rect: Rect) => void` |  |
| `remove` | `(id: string) => boolean` |  |
| `query` | `(area: Rect, accept?: (id: string, rect: Rect) => boolean) => string[]` |  |
| `queryPoint` | `(point: Point) => string[]` |  |
| `nearest` | `(point: Point, maxDistance: number, accept?: (id: string) => boolean) => string \| undefined` |  |

### BUILT_IN_SHAPES

Kind: const. Import from `@birchui/diagram`.

```ts
const BUILT_IN_SHAPES: Record<BuiltInNodeType, ShapeSpec>
```

### BUILT_IN_TYPES

Kind: const. Import from `@birchui/diagram`.

```ts
const BUILT_IN_TYPES: BuiltInNodeType[]
```

### DIAGRAM_EVENT_NAMES

Kind: const. Import from `@birchui/diagram`.

```ts
const DIAGRAM_EVENT_NAMES: readonly (keyof DiagramEvents)[]
```

### diagramDefinition

Kind: const. Import from `@birchui/diagram`.

```ts
const diagramDefinition: WidgetDefinition<DiagramOptions<DiagramData, DiagramData>, { ready: any; contextMenu: any; historyChange: any; selectionChange: any; nodeClick: any; nodeDoubleClick: any; edgeClick: any; nodesChange: any; edgesChange: any; connect: any; viewportChange: any; } & { ready: any; contextMenu: any; historyChange: any; selectionChange: any; nodeClick: any; nodeDoubleClick: any; edgeClick: any; nodesChange: any; edgesChange: any; connect: any; viewportChange: any; }, DiagramApi<DiagramData, DiagramData>>
```

### diagramStyles

Kind: const. Import from `@birchui/diagram`.

```ts
const diagramStyles: "\n.lq-diagram {\n --lq-diagram-font-family: var(--lq-font-family, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif);\n --lq-diagram-font-size: var(--lq-font-size, 13px);\n --lq-diagram-fg: var(--lq-fg, #1f2328);\n --lq-diagram-bg: var(--lq-bg, #ffffff);\n --lq-diagram-muted: var(--lq-muted-fg, #59636e);\n --lq-diagram-border: var(--lq-border, #d1d9e0);\n --lq-diagram-accent: var(--lq-accent, #1f6feb);\n --lq-diagram-accent-fg: var(--lq-accent-fg, #ffffff);\n --lq-diagram-focus: var(--lq-focus-ring, #1f6feb);\n --lq-diagram-radius: var(--lq-radius, 6px);\n --lq-diagram-panel-bg: var(--lq-menu-bg, #ffffff);\n --lq-diagram-panel-shadow: var(--lq-menu-shadow, 0 8px 24px rgba(15, 23, 42, 0.16));\n --lq-diagram-node-bg: var(--lq-bg, #ffffff);\n --lq-diagram-node-border: color-mix(in srgb, var(--lq-diagram-fg) 55%, var(--lq-diagram-bg));\n --lq-diagram-group-bg: color-mix(in srgb, var(--lq-header-bg, #f6f8fa) 75%, transparent);\n --lq-diagram-note-bg: #fff8c5;\n --lq-diagram-edge: color-mix(in srgb, var(--lq-diagram-fg) 62%, var(--lq-diagram-bg));\n --lq-diagram-edge-label-bg: var(--lq-diagram-bg);\n --lq-diagram-grid-color: color-mix(in srgb, var(--lq-diagram-fg) 22%, transparent);\n --lq-diagram-selection: var(--lq-diagram-accent);\n --lq-diagram-selection-bg: var(--lq-selection-bg, rgba(31, 111, 235, 0.12));\n --lq-diagram-guide: #c2185b;\n --lq-diagram-valid: #1a7f37;\n --lq-diagram-invalid: #cf222e;\n --lq-diagram-overview-node: color-mix(in srgb, var(--lq-diagram-fg) 40%, var(--lq-diagram-bg));\n position: relative;\n box-sizing: border-box;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 240px;\n overflow: hidden;\n font-family: var(--lq-diagram-font-family);\n font-size: var(--lq-diagram-font-size);\n color: var(--lq-diagram-fg);\n background: var(--lq-diagram-bg);\n border: 1px solid var(--lq-diagram-border);\n border-radius: var(--lq-diagram-radius);\n -webkit-user-select: none;\n user-select: none;\n}\n.lq-diagram.lq-theme-light {\n --lq-fg: #1f2328;\n --lq-bg: #ffffff;\n --lq-muted-fg: #59636e;\n --lq-border: #d1d9e0;\n --lq-header-bg: #f6f8fa;\n --lq-accent: #1f6feb;\n --lq-accent-fg: #ffffff;\n --lq-selection-bg: rgba(31, 111, 235, 0.12);\n --lq-focus-ring: #1f6feb;\n --lq-menu-bg: #ffffff;\n color-scheme: light;\n}\n.lq-diagram.lq-theme-dark,\n.lq-theme-dark .lq-diagram:not(.lq-theme-light) {\n --lq-fg: #e6edf3;\n --lq-bg: #0d1117;\n --lq-muted-fg: #9198a1;\n --lq-border: #30363d;\n --lq-header-bg: #161b22;\n --lq-accent: #4493f8;\n --lq-accent-fg: #0d1117;\n --lq-selection-bg: rgba(68, 147, 248, 0.2);\n --lq-focus-ring: #79a8ff;\n --lq-menu-bg: #161b22;\n --lq-menu-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);\n --lq-diagram-node-bg: #161b22;\n --lq-diagram-note-bg: #3b2f00;\n --lq-diagram-guide: #f472b6;\n --lq-diagram-valid: #3fb950;\n --lq-diagram-invalid: #f85149;\n color-scheme: dark;\n}\n@media (prefers-color-scheme: dark) {\n .lq-diagram.lq-theme-auto {\n --lq-fg: #e6edf3;\n --lq-bg: #0d1117;\n --lq-muted-fg: #9198a1;\n --lq-border: #30363d;\n --lq-header-bg: #161b22;\n --lq-accent: #4493f8;\n --lq-accent-fg: #0d1117;\n --lq-selection-bg: rgba(68, 147, 248, 0.2);\n --lq-focus-ring: #79a8ff;\n --lq-menu-bg: #161b22;\n --lq-menu-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);\n --lq-diagram-node-bg: #161b22;\n --lq-diagram-note-bg: #3b2f00;\n --lq-diagram-guide: #f472b6;\n --lq-diagram-valid: #3fb950;\n --lq-diagram-invalid: #f85149;\n color-scheme: dark;\n }\n}\n.lq-diagram *,\n.lq-diagram *::before,\n.lq-diagram *::after {\n box-sizing: border-box;\n}\n.lq-diagram-viewport {\n position: absolute;\n inset: 0;\n overflow: hidden;\n outline: none;\n touch-action: none;\n cursor: grab;\n}\n.lq-diagram-viewport:focus-visible {\n box-shadow: inset 0 0 0 2px var(--lq-diagram-focus);\n}\n.lq-diagram--panning .lq-diagram-viewport {\n cursor: grabbing;\n}\n.lq-diagram--dragging .lq-diagram-viewport {\n cursor: move;\n}\n.lq-diagram--connecting .lq-diagram-viewport {\n cursor: crosshair;\n}\n.lq-diagram-svg,\n.lq-diagram-overlay {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n overflow: visible;\n}\n.lq-diagram-overlay {\n pointer-events: none;\n}\n.lq-diagram-html {\n position: absolute;\n left: 0;\n top: 0;\n width: 0;\n height: 0;\n transform-origin: 0 0;\n pointer-events: none;\n}\n.lq-diagram-grid-dot {\n fill: var(--lq-diagram-grid-color);\n}\n.lq-diagram-grid-line {\n fill: none;\n stroke: var(--lq-diagram-grid-color);\n stroke-width: 1;\n}\n.lq-diagram-node {\n cursor: pointer;\n outline: none;\n}\n.lq-diagram--readonly .lq-diagram-node {\n cursor: default;\n}\n.lq-diagram-shape {\n fill: var(--lq-diagram-node-fill, var(--lq-diagram-node-bg));\n stroke: var(--lq-diagram-node-stroke, var(--lq-diagram-node-border));\n stroke-width: var(--lq-diagram-node-stroke-width, 1.5);\n stroke-dasharray: var(--lq-diagram-node-dash, none);\n}\n.lq-diagram-node--note .lq-diagram-shape {\n fill: var(--lq-diagram-node-fill, var(--lq-diagram-note-bg));\n}\n.lq-diagram-node--container .lq-diagram-shape {\n fill: var(--lq-diagram-node-fill, var(--lq-diagram-group-bg));\n}\n.lq-diagram-decoration {\n fill: none;\n stroke: var(--lq-diagram-node-stroke, var(--lq-diagram-node-border));\n stroke-width: var(--lq-diagram-node-stroke-width, 1.5);\n}\n.lq-diagram-label {\n fill: var(--lq-diagram-node-color, var(--lq-diagram-fg));\n font-size: var(--lq-diagram-font-size);\n font-weight: var(--lq-diagram-node-font-weight, 400);\n pointer-events: none;\n}\n.lq-diagram-node--container > .lq-diagram-label {\n font-weight: var(--lq-diagram-node-font-weight, 600);\n}\n.lq-diagram-hit {\n fill: transparent;\n stroke: none;\n}\n.lq-diagram-outline {\n display: none;\n fill: none;\n stroke: var(--lq-diagram-selection);\n stroke-width: 2;\n vector-effect: non-scaling-stroke;\n pointer-events: none;\n}\n.lq-diagram-node--selected > .lq-diagram-outline {\n display: inline;\n}\n.lq-diagram-node:focus-visible > .lq-diagram-outline,\n.lq-diagram-node:focus > .lq-diagram-outline {\n display: inline;\n stroke: var(--lq-diagram-focus);\n stroke-dasharray: 4 3;\n}\n.lq-diagram-node--selected:focus > .lq-diagram-outline {\n stroke-width: 4;\n stroke-dasharray: 6 2;\n}\n.lq-diagram-node--valid-target > .lq-diagram-outline {\n display: inline;\n stroke: var(--lq-diagram-valid);\n stroke-width: 3;\n}\n.lq-diagram-node--invalid-target > .lq-diagram-outline {\n display: inline;\n stroke: var(--lq-diagram-invalid);\n stroke-width: 3;\n stroke-dasharray: 5 3;\n}\n.lq-diagram-port {\n fill: var(--lq-diagram-bg);\n stroke: var(--lq-diagram-accent);\n stroke-width: 1.5;\n opacity: 0;\n cursor: crosshair;\n transition: opacity 120ms ease;\n}\n.lq-diagram-node:hover > .lq-diagram-port,\n.lq-diagram-node--selected > .lq-diagram-port,\n.lq-diagram-node:focus > .lq-diagram-port,\n.lq-diagram--connecting .lq-diagram-port {\n opacity: 1;\n}\n.lq-diagram-port--html {\n position: absolute;\n width: 10px;\n height: 10px;\n margin: -5px 0 0 -5px;\n border-radius: 50%;\n background: var(--lq-diagram-bg);\n border: 1.5px solid var(--lq-diagram-accent);\n}\n.lq-diagram-html-node:hover > .lq-diagram-port--html,\n.lq-diagram-html-node--selected > .lq-diagram-port--html,\n.lq-diagram--connecting .lq-diagram-port--html {\n opacity: 1;\n}\n.lq-diagram-toggle {\n cursor: pointer;\n}\n.lq-diagram-toggle rect {\n fill: var(--lq-diagram-bg);\n stroke: var(--lq-diagram-border);\n}\n.lq-diagram-toggle path {\n fill: none;\n stroke: var(--lq-diagram-muted);\n stroke-width: 1.6;\n stroke-linecap: round;\n stroke-linejoin: round;\n}\n.lq-diagram-html-node {\n position: absolute;\n left: 0;\n top: 0;\n pointer-events: auto;\n overflow: visible;\n border-radius: var(--lq-diagram-radius);\n cursor: pointer;\n}\n.lq-diagram-html-node--selected {\n outline: 2px solid var(--lq-diagram-selection);\n outline-offset: 3px;\n}\n.lq-diagram-html-node--valid-target {\n outline: 3px solid var(--lq-diagram-valid);\n outline-offset: 3px;\n}\n.lq-diagram-edge {\n cursor: pointer;\n}\n.lq-diagram-edge-hit {\n fill: none;\n stroke: transparent;\n stroke-width: 12;\n pointer-events: stroke;\n vector-effect: non-scaling-stroke;\n}\n.lq-diagram-edge-path {\n fill: none;\n stroke: var(--lq-diagram-edge-stroke, var(--lq-diagram-edge));\n stroke-width: var(--lq-diagram-edge-width, 1.5);\n stroke-dasharray: var(--lq-diagram-edge-dash, none);\n stroke-linejoin: round;\n pointer-events: none;\n}\n.lq-diagram-marker {\n fill: var(--lq-diagram-edge-stroke, var(--lq-diagram-edge));\n pointer-events: none;\n}\n.lq-diagram-marker-open {\n fill: none;\n stroke: var(--lq-diagram-edge-stroke, var(--lq-diagram-edge));\n stroke-width: var(--lq-diagram-edge-width, 1.5);\n pointer-events: none;\n}\n.lq-diagram-edge--selected .lq-diagram-edge-path {\n stroke: var(--lq-diagram-selection);\n stroke-width: 2.5;\n}\n.lq-diagram-edge--selected .lq-diagram-marker {\n fill: var(--lq-diagram-selection);\n}\n.lq-diagram-edge--selected .lq-diagram-marker-open {\n stroke: var(--lq-diagram-selection);\n}\n.lq-diagram-edge-label rect {\n fill: var(--lq-diagram-edge-label-bg);\n stroke: var(--lq-diagram-border);\n stroke-width: 1;\n}\n.lq-diagram-edge-label text {\n fill: var(--lq-diagram-edge-label-color, var(--lq-diagram-muted));\n font-size: 12px;\n}\n.lq-diagram-overview-nodes {\n fill: var(--lq-diagram-overview-node);\n stroke: none;\n}\n.lq-diagram-overview-selected {\n fill: var(--lq-diagram-selection);\n}\n.lq-diagram-overview-edges {\n fill: none;\n stroke: var(--lq-diagram-edge);\n stroke-width: 1;\n stroke-opacity: 0.5;\n vector-effect: non-scaling-stroke;\n}\n.lq-diagram-guide {\n stroke: var(--lq-diagram-guide);\n stroke-width: 1;\n stroke-dasharray: 4 3;\n vector-effect: non-scaling-stroke;\n}\n.lq-diagram-marquee {\n fill: var(--lq-diagram-selection-bg);\n stroke: var(--lq-diagram-selection);\n stroke-width: 1;\n vector-effect: non-scaling-stroke;\n}\n.lq-diagram-preview {\n fill: none;\n stroke: var(--lq-diagram-muted);\n stroke-width: 1.5;\n stroke-dasharray: 6 4;\n vector-effect: non-scaling-stroke;\n}\n.lq-diagram-preview--valid {\n stroke: var(--lq-diagram-valid);\n stroke-dasharray: none;\n}\n.lq-diagram-handle {\n fill: var(--lq-diagram-bg);\n stroke: var(--lq-diagram-selection);\n stroke-width: 1.5;\n vector-effect: non-scaling-stroke;\n pointer-events: all;\n}\n.lq-diagram-handle--n, .lq-diagram-handle--s { cursor: ns-resize; }\n.lq-diagram-handle--e, .lq-diagram-handle--w { cursor: ew-resize; }\n.lq-diagram-handle--ne, .lq-diagram-handle--sw { cursor: nesw-resize; }\n.lq-diagram-handle--nw, .lq-diagram-handle--se { cursor: nwse-resize; }\n.lq-diagram-edge-handle {\n fill: var(--lq-diagram-selection);\n stroke: var(--lq-diagram-bg);\n stroke-width: 2;\n vector-effect: non-scaling-stroke;\n pointer-events: all;\n cursor: move;\n}\n.lq-diagram-label-editor {\n position: absolute;\n z-index: 5;\n padding: 4px 6px;\n margin: 0;\n resize: none;\n overflow: hidden;\n font: inherit;\n line-height: 1.3;\n text-align: center;\n color: var(--lq-diagram-fg);\n background: var(--lq-diagram-bg);\n border: 2px solid var(--lq-diagram-focus);\n border-radius: 4px;\n outline: none;\n -webkit-user-select: text;\n user-select: text;\n}\n.lq-diagram-controls {\n position: absolute;\n inset-inline-start: 12px;\n bottom: 12px;\n z-index: 3;\n display: flex;\n flex-direction: column;\n gap: 2px;\n padding: 3px;\n background: var(--lq-diagram-panel-bg);\n border: 1px solid var(--lq-diagram-border);\n border-radius: var(--lq-diagram-radius);\n box-shadow: var(--lq-diagram-panel-shadow);\n}\n.lq-diagram-control {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n padding: 0;\n color: var(--lq-diagram-fg);\n background: transparent;\n border: 0;\n border-radius: 4px;\n cursor: pointer;\n}\n.lq-diagram-control svg {\n fill: none;\n stroke: currentColor;\n stroke-width: 1.6;\n stroke-linecap: round;\n stroke-linejoin: round;\n}\n.lq-diagram-control:hover {\n background: var(--lq-diagram-selection-bg);\n}\n.lq-diagram-control:focus-visible {\n outline: 2px solid var(--lq-diagram-focus);\n outline-offset: 1px;\n}\n.lq-diagram-control[aria-pressed=\"true\"] {\n color: var(--lq-diagram-accent-fg);\n background: var(--lq-diagram-accent);\n}\n.lq-diagram-control:disabled {\n opacity: 0.4;\n cursor: default;\n}\n.lq-diagram-minimap {\n position: absolute;\n inset-inline-end: 12px;\n bottom: 12px;\n z-index: 3;\n width: 200px;\n height: 140px;\n overflow: hidden;\n background: var(--lq-diagram-panel-bg);\n border: 1px solid var(--lq-diagram-border);\n border-radius: var(--lq-diagram-radius);\n box-shadow: var(--lq-diagram-panel-shadow);\n cursor: pointer;\n touch-action: none;\n}\n.lq-diagram-minimap[hidden],\n.lq-diagram-controls[hidden],\n.lq-diagram-list[hidden],\n.lq-diagram-viewport[hidden] {\n display: none;\n}\n.lq-diagram-minimap svg {\n display: block;\n}\n.lq-diagram-minimap-nodes {\n fill: var(--lq-diagram-overview-node);\n}\n.lq-diagram-minimap-view {\n fill: var(--lq-diagram-selection-bg);\n stroke: var(--lq-diagram-selection);\n stroke-width: 1.5;\n}\n.lq-diagram-list {\n position: absolute;\n inset: 0;\n overflow: auto;\n padding: 16px 16px 16px 56px;\n -webkit-user-select: text;\n user-select: text;\n}\n.lq-diagram-list ul {\n margin: 4px 0;\n padding-inline-start: 20px;\n}\n.lq-diagram-list li {\n margin: 2px 0;\n}\n.lq-diagram-list-summary {\n margin: 0 0 8px;\n color: var(--lq-diagram-muted);\n}\n.lq-diagram-list button {\n padding: 1px 4px;\n font: inherit;\n color: var(--lq-diagram-accent);\n background: none;\n border: 0;\n border-radius: 3px;\n cursor: pointer;\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n.lq-diagram-list button:focus-visible {\n outline: 2px solid var(--lq-diagram-focus);\n}\n.lq-diagram-list-node {\n font-weight: 600;\n}\n.lq-diagram-list-node[aria-current=\"true\"] {\n background: var(--lq-diagram-selection-bg);\n}\n.lq-diagram-list-meta {\n color: var(--lq-diagram-muted);\n}\n.lq-diagram-list-links {\n color: var(--lq-diagram-muted);\n}\n.lq-diagram-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0 0 0 0);\n white-space: nowrap;\n border: 0;\n}\n@media (forced-colors: active) {\n .lq-diagram :focus-visible {\n outline: 2px solid Highlight;\n }\n .lq-diagram-outline {\n stroke: CanvasText;\n }\n .lq-diagram-node:focus > .lq-diagram-outline,\n .lq-diagram-node--selected:focus > .lq-diagram-outline {\n stroke: Highlight;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .lq-diagram *,\n .lq-diagram *::before,\n .lq-diagram *::after {\n transition: none !important;\n animation: none !important;\n }\n}\n" = ` .lq-diagram { --lq-diagram-font-family: var(--lq-font-family, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif); --lq-diagram-font-size: var(--lq-font-size, 13px); --lq-diagram-fg: var(--lq-fg, #1f2328); --lq-diagram-bg: var(--lq-bg, #ffffff); --lq-diagram-muted: var(--lq-muted-fg, #59636e); --lq-diagram-border: var(--lq-border, #d1d9e0); --lq-diagram-accent: var(--lq-accent, #1f6feb); --lq-diagram-accent-fg: var(--lq-accent-fg, #ffffff); --lq-diagram-focus: var(--lq-focus-ring, #1f6feb); --lq-diagram-radius: var(--lq-radius, 6px); --lq-diagram-panel-bg: var(--lq-menu-bg, #ffffff); --lq-diagram-panel-shadow: var(--lq-menu-shadow, 0 8px 24px rgba(15, 23, 42, 0.16)); --lq-diagram-node-bg: var(--lq-bg, #ffffff); --lq-diagram-node-border: color-mix(in srgb, var(--lq-diagram-fg) 55%, var(--lq-diagram-bg)); --lq-diagram-group-bg: color-mix(in srgb, var(--lq-header-bg, #f6f8fa) 75%, transparent); --lq-diagram-note-bg: #fff8c5; --lq-diagram-edge: color-mix(in srgb, var(--lq-diagram-fg) 62%, var(--lq-diagram-bg)); --lq-diagram-edge-label-bg: var(--lq-diagram-bg); --lq-diagram-grid-color: color-mix(in srgb, var(--lq-diagram-fg) 22%, transparent); --lq-diagram-selection: var(--lq-diagram-accent); --lq-diagram-selection-bg: var(--lq-selection-bg, rgba(31, 111, 235, 0.12)); --lq-diagram-guide: #c2185b; --lq-diagram-valid: #1a7f37; --lq-diagram-invalid: #cf222e; --lq-diagram-overview-node: color-mix(in srgb, var(--lq-diagram-fg) 40%, var(--lq-diagram-bg)); position: relative; box-sizing: border-box; display: block; width: 100%; height: 100%; min-height: 240px; overflow: hidden; font-family: var(--lq-diagram-font-family); font-size: var(--lq-diagram-font-size); color: var(--lq-diagram-fg); background: var(--lq-diagram-bg); border: 1px solid var(--lq-diagram-border); border-radius: var(--lq-diagram-radius); -webkit-user-select: none; user-select: none; } .lq-diagram.lq-theme-light { --lq-fg: #1f2328; --lq-bg: #ffffff; --lq-muted-fg: #59636e; --lq-border: #d1d9e0; --lq-header-bg: #f6f8fa; --lq-accent: #1f6feb; --lq-accent-fg: #ffffff; --lq-selection-bg: rgba(31, 111, 235, 0.12); --lq-focus-ring: #1f6feb; --lq-menu-bg: #ffffff; color-scheme: light; } .lq-diagram.lq-theme-dark, .lq-theme-dark .lq-diagram:not(.lq-theme-light) { --lq-fg: #e6edf3; --lq-bg: #0d1117; --lq-muted-fg: #9198a1; --lq-border: #30363d; --lq-header-bg: #161b22; --lq-accent: #4493f8; --lq-accent-fg: #0d1117; --lq-selection-bg: rgba(68, 147, 248, 0.2); --lq-focus-ring: #79a8ff; --lq-menu-bg: #161b22; --lq-menu-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); --lq-diagram-node-bg: #161b22; --lq-diagram-note-bg: #3b2f00; --lq-diagram-guide: #f472b6; --lq-diagram-valid: #3fb950; --lq-diagram-invalid: #f85149; color-scheme: dark; } @media (prefers-color-scheme: dark) { .lq-diagram.lq-theme-auto { --lq-fg: #e6edf3; --lq-bg: #0d1117; --lq-muted-fg: #9198a1; --lq-border: #30363d; --lq-header-bg: #161b22; --lq-accent: #4493f8; --lq-accent-fg: #0d1117; --lq-selection-bg: rgba(68, 147, 248, 0.2); --lq-focus-ring: #79a8ff; --lq-menu-bg: #161b22; --lq-menu-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); --lq-diagram-node-bg: #161b22; --lq-diagram-note-bg: #3b2f00; --lq-diagram-guide: #f472b6; --lq-diagram-valid: #3fb950; --lq-diagram-invalid: #f85149; color-scheme: dark; } } .lq-diagram *, .lq-diagram *::before, .lq-diagram *::after { box-sizing: border-box; } .lq-diagram-viewport { position: absolute; inset: 0; overflow: hidden; outline: none; touch-action: none; cursor: grab; } .lq-diagram-viewport:focus-visible { box-shadow: inset 0 0 0 2px var(--lq-diagram-focus); } .lq-diagram--panning .lq-diagram-viewport { cursor: grabbing; } .lq-diagram--dragging .lq-diagram-viewport { cursor: move; } .lq-diagram--connecting .lq-diagram-viewport { cursor: crosshair; } .lq-diagram-svg, .lq-diagram-overlay { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; } .lq-diagram-overlay { pointer-events: none; } .lq-diagram-html { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; pointer-events: none; } .lq-diagram-grid-dot { fill: var(--lq-diagram-grid-color); } .lq-diagram-grid-line { fill: none; stroke: var(--lq-diagram-grid-color); stroke-width: 1; } .lq-diagram-node { cursor: pointer; outline: none; } .lq-diagram--readonly .lq-diagram-node { cursor: default; } .lq-diagram-shape { fill: var(--lq-diagram-node-fill, var(--lq-diagram-node-bg)); stroke: var(--lq-diagram-node-stroke, var(--lq-diagram-node-border)); stroke-width: var(--lq-diagram-node-stroke-width, 1.5); stroke-dasharray: var(--lq-diagram-node-dash, none); } .lq-diagram-node--note .lq-diagram-shape { fill: var(--lq-diagram-node-fill, var(--lq-diagram-note-bg)); } .lq-diagram-node--container .lq-diagram-shape { fill: var(--lq-diagram-node-fill, var(--lq-diagram-group-bg)); } .lq-diagram-decoration { fill: none; stroke: var(--lq-diagram-node-stroke, var(--lq-diagram-node-border)); stroke-width: var(--lq-diagram-node-stroke-width, 1.5); } .lq-diagram-label { fill: var(--lq-diagram-node-color, var(--lq-diagram-fg)); font-size: var(--lq-diagram-font-size); font-weight: var(--lq-diagram-node-font-weight, 400); pointer-events: none; } .lq-diagram-node--container > .lq-diagram-label { font-weight: var(--lq-diagram-node-font-weight, 600); } .lq-diagram-hit { fill: transparent; stroke: none; } .lq-diagram-outline { display: none; fill: none; stroke: var(--lq-diagram-selection); stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; } .lq-diagram-node--selected > .lq-diagram-outline { display: inline; } .lq-diagram-node:focus-visible > .lq-diagram-outline, .lq-diagram-node:focus > .lq-diagram-outline { display: inline; stroke: var(--lq-diagram-focus); stroke-dasharray: 4 3; } .lq-diagram-node--selected:focus > .lq-diagram-outline { stroke-width: 4; stroke-dasharray: 6 2; } .lq-diagram-node--valid-target > .lq-diagram-outline { display: inline; stroke: var(--lq-diagram-valid); stroke-width: 3; } .lq-diagram-node--invalid-target > .lq-diagram-outline { display: inline; stroke: var(--lq-diagram-invalid); stroke-width: 3; stroke-dasharray: 5 3; } .lq-diagram-port { fill: var(--lq-diagram-bg); stroke: var(--lq-diagram-accent); stroke-width: 1.5; opacity: 0; cursor: crosshair; transition: opacity 120ms ease; } .lq-diagram-node:hover > .lq-diagram-port, .lq-diagram-node--selected > .lq-diagram-port, .lq-diagram-node:focus > .lq-diagram-port, .lq-diagram--connecting .lq-diagram-port { opacity: 1; } .lq-diagram-port--html { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--lq-diagram-bg); border: 1.5px solid var(--lq-diagram-accent); } .lq-diagram-html-node:hover > .lq-diagram-port--html, .lq-diagram-html-node--selected > .lq-diagram-port--html, .lq-diagram--connecting .lq-diagram-port--html { opacity: 1; } .lq-diagram-toggle { cursor: pointer; } .lq-diagram-toggle rect { fill: var(--lq-diagram-bg); stroke: var(--lq-diagram-border); } .lq-diagram-toggle path { fill: none; stroke: var(--lq-diagram-muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; } .lq-diagram-html-node { position: absolute; left: 0; top: 0; pointer-events: auto; overflow: visible; border-radius: var(--lq-diagram-radius); cursor: pointer; } .lq-diagram-html-node--selected { outline: 2px solid var(--lq-diagram-selection); outline-offset: 3px; } .lq-diagram-html-node--valid-target { outline: 3px solid var(--lq-diagram-valid); outline-offset: 3px; } .lq-diagram-edge { cursor: pointer; } .lq-diagram-edge-hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; vector-effect: non-scaling-stroke; } .lq-diagram-edge-path { fill: none; stroke: var(--lq-diagram-edge-stroke, var(--lq-diagram-edge)); stroke-width: var(--lq-diagram-edge-width, 1.5); stroke-dasharray: var(--lq-diagram-edge-dash, none); stroke-linejoin: round; pointer-events: none; } .lq-diagram-marker { fill: var(--lq-diagram-edge-stroke, var(--lq-diagram-edge)); pointer-events: none; } .lq-diagram-marker-open { fill: none; stroke: var(--lq-diagram-edge-stroke, var(--lq-diagram-edge)); stroke-width: var(--lq-diagram-edge-width, 1.5); pointer-events: none; } .lq-diagram-edge--selected .lq-diagram-edge-path { stroke: var(--lq-diagram-selection); stroke-width: 2.5; } .lq-diagram-edge--selected .lq-diagram-marker { fill: var(--lq-diagram-selection); } .lq-diagram-edge--selected .lq-diagram-marker-open { stroke: var(--lq-diagram-selection); } .lq-diagram-edge-label rect { fill: var(--lq-diagram-edge-label-bg); stroke: var(--lq-diagram-border); stroke-width: 1; } .lq-diagram-edge-label text { fill: var(--lq-diagram-edge-label-color, var(--lq-diagram-muted)); font-size: 12px; } .lq-diagram-overview-nodes { fill: var(--lq-diagram-overview-node); stroke: none; } .lq-diagram-overview-selected { fill: var(--lq-diagram-selection); } .lq-diagram-overview-edges { fill: none; stroke: var(--lq-diagram-edge); stroke-width: 1; stroke-opacity: 0.5; vector-effect: non-scaling-stroke; } .lq-diagram-guide { stroke: var(--lq-diagram-guide); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; } .lq-diagram-marquee { fill: var(--lq-diagram-selection-bg); stroke: var(--lq-diagram-selection); stroke-width: 1; vector-effect: non-scaling-stroke; } .lq-diagram-preview { fill: none; stroke: var(--lq-diagram-muted); stroke-width: 1.5; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; } .lq-diagram-preview--valid { stroke: var(--lq-diagram-valid); stroke-dasharray: none; } .lq-diagram-handle { fill: var(--lq-diagram-bg); stroke: var(--lq-diagram-selection); stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: all; } .lq-diagram-handle--n, .lq-diagram-handle--s { cursor: ns-resize; } .lq-diagram-handle--e, .lq-diagram-handle--w { cursor: ew-resize; } .lq-diagram-handle--ne, .lq-diagram-handle--sw { cursor: nesw-resize; } .lq-diagram-handle--nw, .lq-diagram-handle--se { cursor: nwse-resize; } .lq-diagram-edge-handle { fill: var(--lq-diagram-selection); stroke: var(--lq-diagram-bg); stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: all; cursor: move; } .lq-diagram-label-editor { position: absolute; z-index: 5; padding: 4px 6px; margin: 0; resize: none; overflow: hidden; font: inherit; line-height: 1.3; text-align: center; color: var(--lq-diagram-fg); background: var(--lq-diagram-bg); border: 2px solid var(--lq-diagram-focus); border-radius: 4px; outline: none; -webkit-user-select: text; user-select: text; } .lq-diagram-controls { position: absolute; inset-inline-start: 12px; bottom: 12px; z-index: 3; display: flex; flex-direction: column; gap: 2px; padding: 3px; background: var(--lq-diagram-panel-bg); border: 1px solid var(--lq-diagram-border); border-radius: var(--lq-diagram-radius); box-shadow: var(--lq-diagram-panel-shadow); } .lq-diagram-control { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; color: var(--lq-diagram-fg); background: transparent; border: 0; border-radius: 4px; cursor: pointer; } .lq-diagram-control svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; } .lq-diagram-control:hover { background: var(--lq-diagram-selection-bg); } .lq-diagram-control:focus-visible { outline: 2px solid var(--lq-diagram-focus); outline-offset: 1px; } .lq-diagram-control[aria-pressed="true"] { color: var(--lq-diagram-accent-fg); background: var(--lq-diagram-accent); } .lq-diagram-control:disabled { opacity: 0.4; cursor: default; } .lq-diagram-minimap { position: absolute; inset-inline-end: 12px; bottom: 12px; z-index: 3; width: 200px; height: 140px; overflow: hidden; background: var(--lq-diagram-panel-bg); border: 1px solid var(--lq-diagram-border); border-radius: var(--lq-diagram-radius); box-shadow: var(--lq-diagram-panel-shadow); cursor: pointer; touch-action: none; } .lq-diagram-minimap[hidden], .lq-diagram-controls[hidden], .lq-diagram-list[hidden], .lq-diagram-viewport[hidden] { display: none; } .lq-diagram-minimap svg { display: block; } .lq-diagram-minimap-nodes { fill: var(--lq-diagram-overview-node); } .lq-diagram-minimap-view { fill: var(--lq-diagram-selection-bg); stroke: var(--lq-diagram-selection); stroke-width: 1.5; } .lq-diagram-list { position: absolute; inset: 0; overflow: auto; padding: 16px 16px 16px 56px; -webkit-user-select: text; user-select: text; } .lq-diagram-list ul { margin: 4px 0; padding-inline-start: 20px; } .lq-diagram-list li { margin: 2px 0; } .lq-diagram-list-summary { margin: 0 0 8px; color: var(--lq-diagram-muted); } .lq-diagram-list button { padding: 1px 4px; font: inherit; color: var(--lq-diagram-accent); background: none; border: 0; border-radius: 3px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; } .lq-diagram-list button:focus-visible { outline: 2px solid var(--lq-diagram-focus); } .lq-diagram-list-node { font-weight: 600; } .lq-diagram-list-node[aria-current="true"] { background: var(--lq-diagram-selection-bg); } .lq-diagram-list-meta { color: var(--lq-diagram-muted); } .lq-diagram-list-links { color: var(--lq-diagram-muted); } .lq-diagram-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; } @media (forced-colors: active) { .lq-diagram :focus-visible { outline: 2px solid Highlight; } .lq-diagram-outline { stroke: CanvasText; } .lq-diagram-node:focus > .lq-diagram-outline, .lq-diagram-node--selected:focus > .lq-diagram-outline { stroke: Highlight; } } @media (prefers-reduced-motion: reduce) { .lq-diagram *, .lq-diagram *::before, .lq-diagram *::after { transition: none !important; animation: none !important; } } `
```

### FOUR_PORTS

Kind: const. Import from `@birchui/diagram`.

```ts
const FOUR_PORTS: readonly DiagramPort[]
```

### ConnectionRequest

Kind: interface. Import from `@birchui/diagram`.

```ts
interface ConnectionRequest
```

| Property | Type | Description |
| --- | --- | --- |
| `source` | `EdgeEnd` |  |
| `target` | `EdgeEnd` |  |
| `edgeId?` | `string` |  |

### DiagramApi

Kind: interface. Import from `@birchui/diagram`.

```ts
interface DiagramApi<TNodeData = DiagramData, TEdgeData = DiagramData> extends Widget< DiagramOptions<TNodeData, TEdgeData>, DiagramEvents<TNodeData, TEdgeData> >
```

| Property | Type | Description |
| --- | --- | --- |
| `setNodes` | `(nodes: DiagramNode<TNodeData>[]) => void` |  |
| `setEdges` | `(edges: DiagramEdge<TEdgeData>[]) => void` |  |
| `addNodes` | `(nodes: DiagramNode<TNodeData> \| DiagramNode<TNodeData>[]) => void` |  |
| `updateNode` | `(id: string, patch: Partial<Omit<DiagramNode<TNodeData>, 'id'>>) => DiagramNode<TNodeData> \| undefined` |  |
| `removeNodes` | `(ids: string \| string[]) => void` |  |
| `addEdges` | `(edges: DiagramEdge<TEdgeData> \| DiagramEdge<TEdgeData>[]) => void` |  |
| `updateEdge` | `(id: string, patch: Partial<Omit<DiagramEdge<TEdgeData>, 'id'>>) => DiagramEdge<TEdgeData> \| undefined` |  |
| `removeEdges` | `(ids: string \| string[]) => void` |  |
| `getNodes` | `() => DiagramNode<TNodeData>[]` |  |
| `getEdges` | `() => DiagramEdge<TEdgeData>[]` |  |
| `getNode` | `(id: string) => DiagramNode<TNodeData> \| undefined` |  |
| `getEdge` | `(id: string) => DiagramEdge<TEdgeData> \| undefined` |  |
| `getEdgeRoute` | `(id: string) => Point[]` |  |
| `select` | `(selection: Partial<DiagramSelection>, options?: { additive?: boolean }) => void` |  |
| `getSelection` | `() => DiagramSelection` |  |
| `clearSelection` | `() => void` |  |
| `setCollapsed` | `(groupId: string, collapsed: boolean) => void` |  |
| `editLabel` | `(id: string) => void` |  |
| `undo` | `() => boolean` |  |
| `redo` | `() => boolean` |  |
| `canUndo` | `() => boolean` |  |
| `canRedo` | `() => boolean` |  |
| `zoomIn` | `() => void` |  |
| `zoomOut` | `() => void` |  |
| `zoomTo` | `(zoom: number, center?: Point) => void` |  |
| `zoomToFit` | `(options?: ZoomToFitOptions) => void` |  |
| `zoomToSelection` | `() => void` |  |
| `centerOn` | `(nodeId: string) => void` |  |
| `getViewport` | `() => Viewport` |  |
| `setViewport` | `(viewport: Partial<Viewport>) => void` |  |
| `layout` | `(options?: LayoutOptions) => Promise<void>` |  |
| `toJSON` | `() => DiagramDocument<TNodeData, TEdgeData>` |  |
| `fromJSON` | `(document: DiagramDocument<TNodeData, TEdgeData> \| string) => void` |  |
| `toSVG` | `(options?: SvgExportOptions) => string` |  |
| `toPNG` | `(options?: PngExportOptions) => Promise<Blob>` |  |
| `screenToDiagram` | `(point: Point) => Point` |  |
| `diagramToScreen` | `(point: Point) => Point` |  |
| `readonly element` | `HTMLElement` | Inherited from Widget. |
| `update` | `(options: Partial<DiagramOptions<TNodeData, TEdgeData>>) => void` | Inherited from Widget. |
| `on` | `<K extends keyof TEvents & string>(event: K, listener: Listener<TEvents[K]>) => () => void` | Inherited from Widget. |
| `destroy` | `() => void` | Inherited from Widget. |

### DiagramDocument

Kind: interface. Import from `@birchui/diagram`.

```ts
interface DiagramDocument<TNodeData = DiagramData, TEdgeData = DiagramData>
```

| Property | Type | Description |
| --- | --- | --- |
| `format` | `'birchui-diagram'` |  |
| `version` | `1` |  |
| `nodes` | `DiagramNode<TNodeData>[]` |  |
| `edges` | `DiagramEdge<TEdgeData>[]` |  |
| `viewport?` | `Viewport` |  |

### DiagramEdge

Kind: interface. Import from `@birchui/diagram`.

```ts
interface DiagramEdge<TData = DiagramData>
```

| Property | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `source` | `EdgeEnd` |  |
| `target` | `EdgeEnd` |  |
| `label?` | `string` |  |
| `router?` | `EdgeRouter` |  |
| `markerEnd?` | `EdgeMarker` |  |
| `markerStart?` | `EdgeMarker` |  |
| `data?` | `TData` |  |
| `style?` | `EdgeStyle` |  |

### DiagramEvents

Kind: interface. Import from `@birchui/diagram`.

```ts
interface DiagramEvents<TNodeData = DiagramData, TEdgeData = DiagramData>
```

| Property | Type | Description |
| --- | --- | --- |
| `ready` | `{ api: DiagramApi<TNodeData, TEdgeData> }` |  |
| `nodeClick` | `PointerContext & { node: DiagramNode<TNodeData> }` |  |
| `nodeDoubleClick` | `PointerContext & { node: DiagramNode<TNodeData> }` |  |
| `edgeClick` | `PointerContext & { edge: DiagramEdge<TEdgeData> }` |  |
| `selectionChange` | `DiagramSelection` |  |
| `nodesChange` | `{ changes: NodeChange<TNodeData>[]; source: ChangeSource }` |  |
| `edgesChange` | `{ changes: EdgeChange<TEdgeData>[]; source: ChangeSource }` |  |
| `connect` | `{ edge: DiagramEdge<TEdgeData>; source: EdgeEnd; target: EdgeEnd; isReconnect: boolean }` |  |
| `viewportChange` | `{ viewport: Viewport }` |  |
| `contextMenu` | `PointerContext & { target: 'node' \| 'edge' \| 'canvas'; node?: DiagramNode<TNodeData>; edge?: DiagramEdge<TEdgeData>; }` |  |
| `historyChange` | `{ canUndo: boolean; canRedo: boolean; undoLabel?: string; redoLabel?: string }` |  |

### DiagramNode

Kind: interface. Import from `@birchui/diagram`.

```ts
interface DiagramNode<TData = DiagramData>
```

| Property | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `type?` | `string` |  |
| `x` | `number` |  |
| `y` | `number` |  |
| `width?` | `number` |  |
| `height?` | `number` |  |
| `label?` | `string` |  |
| `ports?` | `DiagramPort[]` |  |
| `data?` | `TData` |  |
| `style?` | `NodeStyle` |  |
| `parentId?` | `string` |  |
| `collapsed?` | `boolean` |  |
| `draggable?` | `boolean` |  |
| `resizable?` | `boolean` |  |
| `connectable?` | `boolean` |  |

### DiagramOptions

Kind: interface. Import from `@birchui/diagram`.

```ts
interface DiagramOptions<TNodeData = DiagramData, TEdgeData = DiagramData>
```

| Property | Type | Description |
| --- | --- | --- |
| `nodes?` | `DiagramNode<TNodeData>[]` |  |
| `edges?` | `DiagramEdge<TEdgeData>[]` |  |
| `nodeTypes?` | `Record<string, NodeTypeDefinition<TNodeData>>` |  |
| `defaultNodeType?` | `string` |  |
| `defaultEdge?` | `Partial<Pick<DiagramEdge<TEdgeData>, 'router' \| 'markerEnd' \| 'markerStart' \| 'style'>>` |  |
| `viewport?` | `Viewport` |  |
| `fitOnInit?` | `boolean` |  |
| `minZoom?` | `number` |  |
| `maxZoom?` | `number` |  |
| `width?` | `number` |  |
| `height?` | `number` |  |
| `grid?` | `boolean \| GridOptions` |  |
| `guides?` | `boolean` |  |
| `minimap?` | `boolean` |  |
| `controls?` | `boolean` |  |
| `listView?` | `boolean` |  |
| `readOnly?` | `boolean` |  |
| `theme?` | `DiagramTheme` |  |
| `ariaLabel?` | `string` |  |
| `wheelMode?` | `WheelMode` |  |
| `backgroundDrag?` | `BackgroundDrag` |  |
| `routing?` | `RoutingOptions` |  |
| `overviewThreshold?` | `number` |  |
| `historyLimit?` | `number` |  |
| `validateConnection?` | `(request: ConnectionRequest) => boolean` |  |
| `createId?` | `(kind: 'node' \| 'edge') => string` |  |
| `licenseKey?` | `string` |  |
| `injectStyles?` | `boolean` |  |
| `localeText?` | `LocaleTextInput` |  |
| `rtl?` | `boolean` |  |

### DiagramPort

Kind: interface. Import from `@birchui/diagram`.

```ts
interface DiagramPort
```

| Property | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `side` | `PortSide` |  |
| `offset?` | `number` |  |
| `label?` | `string` |  |

### DiagramSelection

Kind: interface. Import from `@birchui/diagram`.

```ts
interface DiagramSelection
```

| Property | Type | Description |
| --- | --- | --- |
| `nodes` | `string[]` |  |
| `edges` | `string[]` |  |

### EdgeChange

Kind: interface. Import from `@birchui/diagram`.

```ts
interface EdgeChange<TData = DiagramData>
```

| Property | Type | Description |
| --- | --- | --- |
| `type` | `Exclude<ChangeKind, 'move' \| 'resize'>` |  |
| `id` | `string` |  |
| `before?` | `DiagramEdge<TData>` |  |
| `after?` | `DiagramEdge<TData>` |  |

### EdgeEnd

Kind: interface. Import from `@birchui/diagram`.

```ts
interface EdgeEnd
```

| Property | Type | Description |
| --- | --- | --- |
| `node` | `string` |  |
| `port?` | `string` |  |

### EdgeStyle

Kind: interface. Import from `@birchui/diagram`.

```ts
interface EdgeStyle
```

| Property | Type | Description |
| --- | --- | --- |
| `stroke?` | `string` |  |
| `strokeWidth?` | `number` |  |
| `dash?` | `string` |  |
| `color?` | `string` |  |

### ForceLayoutOptions

Kind: interface. Import from `@birchui/diagram`.

```ts
interface ForceLayoutOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `iterations?` | `number` |  |
| `spacing?` | `number` |  |
| `seed?` | `number` |  |

### GridLayoutOptions

Kind: interface. Import from `@birchui/diagram`.

```ts
interface GridLayoutOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `direction?` | `LayoutDirection` |  |
| `spacing?` | `number` |  |
| `columns?` | `number` |  |

### GridOptions

Kind: interface. Import from `@birchui/diagram`.

```ts
interface GridOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `size?` | `number` |  |
| `style?` | `GridStyle` |  |
| `snap?` | `boolean` |  |

### LayeredLayoutOptions

Kind: interface. Import from `@birchui/diagram`.

```ts
interface LayeredLayoutOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `direction?` | `LayoutDirection` |  |
| `nodeSpacing?` | `number` |  |
| `layerSpacing?` | `number` |  |
| `sweeps?` | `number` |  |
| `componentSpacing?` | `number` |  |

### LayeredLayoutResult

Kind: interface. Import from `@birchui/diagram`.

```ts
interface LayeredLayoutResult
```

| Property | Type | Description |
| --- | --- | --- |
| `positions` | `Map<string, Point>` |  |
| `layers` | `string[][]` |  |
| `crossings` | `number` |  |

### LayoutEdgeInput

Kind: interface. Import from `@birchui/diagram`.

```ts
interface LayoutEdgeInput
```

| Property | Type | Description |
| --- | --- | --- |
| `source` | `string` |  |
| `target` | `string` |  |

### LayoutNodeInput

Kind: interface. Import from `@birchui/diagram`.

```ts
interface LayoutNodeInput
```

| Property | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `width` | `number` |  |
| `height` | `number` |  |
| `x?` | `number` |  |
| `y?` | `number` |  |

### LayoutOptions

Kind: interface. Import from `@birchui/diagram`.

```ts
interface LayoutOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `type?` | `LayoutType` |  |
| `direction?` | `LayoutDirection` |  |
| `spacing?` | `number \| LayoutSpacing` |  |
| `animate?` | `boolean` |  |
| `iterations?` | `number` |  |
| `columns?` | `number` |  |

### LayoutSpacing

Kind: interface. Import from `@birchui/diagram`.

```ts
interface LayoutSpacing
```

| Property | Type | Description |
| --- | --- | --- |
| `node?` | `number` |  |
| `layer?` | `number` |  |

### NodeChange

Kind: interface. Import from `@birchui/diagram`.

```ts
interface NodeChange<TData = DiagramData>
```

| Property | Type | Description |
| --- | --- | --- |
| `type` | `ChangeKind` |  |
| `id` | `string` |  |
| `before?` | `DiagramNode<TData>` |  |
| `after?` | `DiagramNode<TData>` |  |

### NodeRenderContext

Kind: interface. Import from `@birchui/diagram`.

```ts
interface NodeRenderContext
```

| Property | Type | Description |
| --- | --- | --- |
| `width` | `number` |  |
| `height` | `number` |  |
| `isSelected` | `boolean` |  |
| `isExport` | `boolean` |  |
| `document` | `Document` |  |

### NodeStyle

Kind: interface. Import from `@birchui/diagram`.

```ts
interface NodeStyle
```

| Property | Type | Description |
| --- | --- | --- |
| `fill?` | `string` |  |
| `stroke?` | `string` |  |
| `strokeWidth?` | `number` |  |
| `color?` | `string` |  |
| `fontSize?` | `number` |  |
| `fontWeight?` | `number \| string` |  |
| `dash?` | `string` |  |

### NodeTypeDefinition

Kind: interface. Import from `@birchui/diagram`.

```ts
interface NodeTypeDefinition<TData = DiagramData>
```

| Property | Type | Description |
| --- | --- | --- |
| `render?` | `(node: DiagramNode<TData>, ctx: NodeRenderContext) => SVGElement \| HTMLElement` |  |
| `defaultSize?` | `Size` |  |
| `ports?` | `DiagramPort[]` |  |
| `shape?` | `NodeShape` |  |
| `isContainer?` | `boolean` |  |
| `resizable?` | `boolean` |  |
| `label?` | `string` |  |

### OrthogonalRouteInput

Kind: interface. Import from `@birchui/diagram`.

```ts
interface OrthogonalRouteInput
```

| Property | Type | Description |
| --- | --- | --- |
| `source` | `RouteEndpoint` |  |
| `target` | `RouteEndpoint` |  |
| `obstacles` | `readonly Rect[]` |  |
| `padding?` | `number` |  |
| `bendPenalty?` | `number` |  |
| `bounds?` | `Rect` |  |

### PngExportOptions

Kind: interface. Import from `@birchui/diagram`.

```ts
interface PngExportOptions extends SvgExportOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `scale?` | `number` |  |
| `padding?` | `number \| undefined` | Inherited from SvgExportOptions. |
| `background?` | `boolean \| undefined` | Inherited from SvgExportOptions. |
| `theme?` | `"light" \| "dark" \| undefined` | Inherited from SvgExportOptions. |
| `includeHtml?` | `boolean \| undefined` | Inherited from SvgExportOptions. |
| `nodes?` | `string[] \| undefined` | Inherited from SvgExportOptions. |

### Point

Kind: interface. Import from `@birchui/diagram`.

```ts
interface Point
```

| Property | Type | Description |
| --- | --- | --- |
| `x` | `number` |  |
| `y` | `number` |  |

### PointerContext

Kind: interface. Import from `@birchui/diagram`.

```ts
interface PointerContext
```

| Property | Type | Description |
| --- | --- | --- |
| `point` | `Point` |  |
| `domEvent` | `MouseEvent` |  |

### Rect

Kind: interface. Import from `@birchui/diagram`.

```ts
interface Rect extends Point, Size
```

| Property | Type | Description |
| --- | --- | --- |
| `x` | `number` | Inherited from Point. |
| `y` | `number` | Inherited from Point. |
| `width` | `number` | Inherited from Size. |
| `height` | `number` | Inherited from Size. |

### RouteEndpoint

Kind: interface. Import from `@birchui/diagram`.

```ts
interface RouteEndpoint
```

| Property | Type | Description |
| --- | --- | --- |
| `point` | `Point` |  |
| `side` | `PortSide` |  |
| `rect` | `Rect` |  |

### RoutingOptions

Kind: interface. Import from `@birchui/diagram`.

```ts
interface RoutingOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `padding?` | `number` |  |
| `bendPenalty?` | `number` |  |
| `cornerRadius?` | `number` |  |

### RunLayoutOptions

Kind: interface. Import from `@birchui/diagram`.

```ts
interface RunLayoutOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `type?` | `LayoutType` |  |
| `direction?` | `LayoutDirection` |  |
| `spacing?` | `number \| LayoutSpacing` |  |
| `iterations?` | `number` |  |
| `columns?` | `number` |  |

### Size

Kind: interface. Import from `@birchui/diagram`.

```ts
interface Size
```

| Property | Type | Description |
| --- | --- | --- |
| `width` | `number` |  |
| `height` | `number` |  |

### SvgExportOptions

Kind: interface. Import from `@birchui/diagram`.

```ts
interface SvgExportOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `padding?` | `number` |  |
| `background?` | `boolean` |  |
| `theme?` | `'light' \| 'dark'` |  |
| `includeHtml?` | `boolean` |  |
| `nodes?` | `string[]` |  |

### TreeLayoutOptions

Kind: interface. Import from `@birchui/diagram`.

```ts
interface TreeLayoutOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `direction?` | `LayoutDirection` |  |
| `nodeSpacing?` | `number` |  |
| `levelSpacing?` | `number` |  |

### Viewport

Kind: interface. Import from `@birchui/diagram`.

```ts
interface Viewport
```

| Property | Type | Description |
| --- | --- | --- |
| `x` | `number` |  |
| `y` | `number` |  |
| `zoom` | `number` |  |

### ZoomToFitOptions

Kind: interface. Import from `@birchui/diagram`.

```ts
interface ZoomToFitOptions
```

| Property | Type | Description |
| --- | --- | --- |
| `padding?` | `number` |  |
| `maxZoom?` | `number` |  |
| `nodes?` | `string[]` |  |

### BackgroundDrag

Kind: type. Import from `@birchui/diagram`.

```ts
type BackgroundDrag = 'pan' | 'marquee';
```

### BuiltInNodeType

Kind: type. Import from `@birchui/diagram`.

```ts
type BuiltInNodeType =
  | 'rectangle'
  | 'rounded'
  | 'ellipse'
  | 'diamond'
  | 'parallelogram'
  | 'cylinder'
  | 'document'
  | 'note'
  | 'swimlane'
  | 'group';
```

### ChangeKind

Kind: type. Import from `@birchui/diagram`.

```ts
type ChangeKind = 'add' | 'remove' | 'move' | 'resize' | 'update';
```

### ChangeSource

Kind: type. Import from `@birchui/diagram`.

```ts
type ChangeSource = 'user' | 'api' | 'history' | 'layout';
```

### DiagramData

Kind: type. Import from `@birchui/diagram`.

```ts
type DiagramData = Record<string, unknown>;
```

### DiagramTheme

Kind: type. Import from `@birchui/diagram`.

```ts
type DiagramTheme = 'light' | 'dark' | 'auto';
```

### EdgeMarker

Kind: type. Import from `@birchui/diagram`.

```ts
type EdgeMarker = 'arrow' | 'arrowOpen' | 'diamond' | 'circle' | 'none';
```

### EdgeRouter

Kind: type. Import from `@birchui/diagram`.

```ts
type EdgeRouter = 'orthogonal' | 'straight' | 'curved';
```

### GridStyle

Kind: type. Import from `@birchui/diagram`.

```ts
type GridStyle = 'dots' | 'lines' | 'none';
```

### LayoutDirection

Kind: type. Import from `@birchui/diagram`.

```ts
type LayoutDirection = 'TB' | 'BT' | 'LR' | 'RL';
```

### LayoutType

Kind: type. Import from `@birchui/diagram`.

```ts
type LayoutType = 'layered' | 'tree' | 'force' | 'grid';
```

### NodeShape

Kind: type. Import from `@birchui/diagram`.

```ts
type NodeShape = 'rect' | 'ellipse' | 'diamond';
```

### PortSide

Kind: type. Import from `@birchui/diagram`.

```ts
type PortSide = 'top' | 'right' | 'bottom' | 'left';
```

### WheelMode

Kind: type. Import from `@birchui/diagram`.

```ts
type WheelMode = 'zoom' | 'pan';
```
