import type { ConnectionMode, NormalizedConnection } from 'modern-idoc'; import type { Path2D } from 'modern-path2d'; import type { ConnectionEndpoint } from './connectionRouter'; import type { Element2D } from './Element2D'; import { Vector2 } from 'modern-path2d'; import { CoreObject } from '../../../core'; export declare class Element2DConnection extends CoreObject implements NormalizedConnection { protected _parent: Element2D; start: NormalizedConnection['start']; end: NormalizedConnection['end']; /** Routing mode: `straight` | `orthogonal` | `curved` (normalized by modern-idoc). */ mode: ConnectionMode; /** Fraction (0..1) along the routed path used by {@link getLabelPoint}. */ labelPosition: number; protected _routeSig?: string; protected _routePath?: Path2D; protected _keyTargets: (Element2D | undefined)[]; protected _routeKey: number[]; protected _keyMode?: ConnectionMode; protected _keyAnchors: (string | number | undefined)[]; protected _keyRevision: number; protected _keyValid: boolean; protected _anchorsSet: boolean; protected _startTarget?: Element2D; protected _endTarget?: Element2D; protected _targetsRevision: number; protected _targetsStartId?: string; protected _targetsEndId?: string; constructor(_parent: Element2D); setProperties(properties?: Record): this; /** * Whether this element *is* a connection — i.e. it declares at least one anchor. * Says nothing about whether those anchors still resolve; callers use this to tell * connection elements apart from ordinary ones (hit-testing, marquee selection, * cascade-deleting dangling lines), and a dangling connection is still a connection. * * For "can this actually be routed right now", see {@link isRoutable}. */ isValid(): boolean; /** * Whether at least one anchor resolves to a node currently in the tree. A connection * whose targets were removed is valid but not routable: it must stop consuming a * per-frame route and stop opting out of viewport culling. */ isRoutable(): boolean; protected _updateProperty(key: string, value: any, oldValue: any): void; protected _resolveTarget(anchor: NormalizedConnection['start']): Element2D | undefined; /** * Re-resolve both anchors, at most once per (revision, anchor ids) pair. Nodes enter * and leave the tree through `SceneTree`, which bumps the revision, so a cached target * can never outlive its membership. */ protected _refreshTargets(): void; /** * The anchors are compared by value rather than relying on `_updateProperty`, because * `connection.start.idx = 2` mutates in place without going through the setter. */ protected _anchorsMatch(): boolean; /** * Everything an endpoint's world point + direction is derived from, compared in place. * `getNodeById` is an unchecked cast — a connection may well point at a * plain Node2D — so every field is read defensively. */ protected _keyMatches(target: Element2D | undefined, offset: number): boolean; protected _writeKey(target: Element2D | undefined, offset: number): void; /** Snapshot what the current route was computed from. Only on a cache miss. */ protected _storeKey(s: Element2D | undefined, e: Element2D | undefined): void; /** * Resolve an anchor to a world-space point. * If idx is specified, uses the target shape's connectionPoints; * otherwise falls back to the target's globalAabb center. */ resolveAnchor(anchor: NormalizedConnection['start']): Vector2 | undefined; /** * Resolve an anchor to a world-space point and outward direction. * Direction comes from the connection point's `ang` if present, otherwise it is * inferred from which edge the point sits on; a centre fallback has no direction. */ resolveEndpoint(anchor: NormalizedConnection['start'], target?: Element2D | undefined): ConnectionEndpoint | undefined; /** * World-space point at the configured {@link labelPosition} along the current * route — handy for anchoring an external label / badge to the line. Returns * `undefined` when the endpoints haven't resolved yet. */ getLabelPoint(): Vector2 | undefined; /** Resolve both ends and return the routed world-space path (cached while unchanged). */ route(): Path2D | undefined; }