/**
 * Represents a point with x and y coordinates.
 * @typedef {Object} Point
 * @property {number} x - The x-coordinate.
 * @property {number} y - The y-coordinate.
 */

/**
 * Represents a router for managing shapes and connectors.
 * @typedef {Object} Router
 * @property {function(number): void} processTransaction - Processes the current transaction.
 * @property {function(): void} printInfo - Prints router information.
 * @property {function(ConnRef): void} deleteConnector - Deletes a connector.
 * @property {function(ShapeRef, Polygon): void} moveShape - Moves a shape to a new polygon.
 * @property {function(ShapeRef, number, number): void} moveShape - Moves a shape by a specified offset.
 * @property {function(ShapeRef): void} deleteShape - Deletes a shape.
 * @property {function(number, number): void} setRoutingParameter - Sets a routing parameter.
 * @property {function(number, boolean): void} setRoutingOption - Sets a routing option.
 */

/**
 * Represents a polyline.
 * @typedef {Object} PolyLine
 * @property {function(): number} size - Returns the number of points in the polyline.
 * @property {function(number): Point} get_ps - Returns the point at the specified index.
 */

/**
 * Represents a connection endpoint.
 * @typedef {Object} ConnEnd
 * @property {function(Point): void} constructor - Creates a connection endpoint from a point.
 * @property {function(ShapeRef, number): void} constructor - Creates a connection endpoint from a shape reference.
 * @property {function(JunctionRef, number): ConnEnd} createConnEndFromJunctionRef - Creates a connection endpoint from a junction reference.
 */

/**
 * Represents a connector reference.
 * @typedef {Object} ConnRef
 * @property {function(Router): void} constructor - Creates a connector reference.
 * @property {function(Router, ConnEnd, ConnEnd): void} constructor - Creates a connector reference with endpoints.
 * @property {function(): PolyLine} displayRoute - Displays the route of the connector.
 * @property {function(ConnEnd): void} setSourceEndpoint - Sets the source endpoint of the connector.
 * @property {function(ConnEnd): void} setDestEndpoint - Sets the destination endpoint of the connector.
 * @property {function(number): void} setRoutingType - Sets the routing type of the connector.
 * @property {function(function(number): void, ConnRef): void} setCallback - Sets a callback for the connector.
 * @property {function(boolean): void} setHateCrossings - Sets whether the connector hates crossings.
 * @property {function(): boolean} doesHateCrossings - Returns whether the connector hates crossings.
 */

/**
 * Enum for connection direction flags.
 * @typedef {Object} ConnDirFlags
 */

/**
 * Represents a shape connection pin.
 * @typedef {Object} ShapeConnectionPin
 * @property {function(ShapeRef, number, number, number, boolean, number, ConnDirFlags): void} constructor - Creates a shape connection pin.
 * @property {function(JunctionRef, number, ConnDirFlags): void} constructor - Creates a shape connection pin from a junction reference.
 * @property {function(number): void} setConnectionCost - Sets the connection cost.
 * @property {function(boolean): void} setExclusive - Sets whether the pin is exclusive.
 * @property {function(): boolean} isExclusive - Returns whether the pin is exclusive.
 * @property {function(): ConnDirFlags} directions - Returns the visible directions.
 * @property {function(): Point} position - Returns the position of the pin.
 * @property {function(Point): void} updatePosition - Updates the position of the pin.
 */

/**
 * Represents a junction reference.
 * @typedef {Object} JunctionRef
 * @property {function(Router, Point, number): void} constructor - Creates a junction reference.
 * @property {function(): Point} position - Returns the position of the junction.
 * @property {function(boolean): void} setPositionFixed - Sets whether the position is fixed.
 * @property {function(): boolean} positionFixed - Returns whether the position is fixed.
 * @property {function(): Point} recommendedPosition - Returns the recommended position.
 */

/**
 * Represents a polygon.
 * @typedef {Object} Polygon
 */

/**
 * Represents a rectangle.
 * @typedef {Object} Rectangle
 * @property {function(Point, number, number): void} constructor - Creates a rectangle from a center point, width, and height.
 * @property {function(Point, Point): void} constructor - Creates a rectangle from top-left and bottom-right points.
 */

/**
 * Represents an obstacle.
 * @typedef {Object} Obstacle
 * @property {function(): number} id - Returns the ID of the obstacle.
 * @property {function(): Polygon} polygon - Returns the polygon of the obstacle.
 * @property {function(): Router} router - Returns the router of the obstacle.
 * @property {function(): Point} position - Returns the position of the obstacle.
 * @property {function(Polygon): void} setNewPoly - Sets a new polygon for the obstacle.
 */

/**
 * Represents a shape reference.
 * @typedef {Object} ShapeRef
 * @property {function(Router, Polygon): void} constructor - Creates a shape reference.
 */

/**
 * Represents the Avoid library.
 * @typedef {Object} Avoid
 * @property {number} PolyLineRouting - Polyline routing flag.
 * @property {number} OrthogonalRouting - Orthogonal routing flag.
 * @property {ConnEnd} ConnEnd - ConnEnd class.
 * @property {ConnRef} ConnRef - ConnRef class.
 * @property {Point} Point - Point class.
 * @property {Rectangle} Rectangle - Rectangle class.
 * @property {Router} Router - Router class.
 * @property {Obstacle} Obstacle - Obstacle class.
 * @property {ShapeRef} ShapeRef - ShapeRef class.
 * @property {JunctionRef} JunctionRef - JunctionRef class.
 * @property {function(any): void} destroy - Destroys an object.
 * @property {function(any): number} getPointer - Gets the pointer of an object.
 * @property {function(number, any): any} wrapPointer - Wraps a pointer into an object.
 */

/**
 * Represents the Avoid library namespace.
 * @typedef {Object} AvoidLib
 * @property {Avoid | null} avoidLib - The Avoid library instance.
 * @property {function(string): Promise<void>} load - Loads the Avoid library.
 * @property {function(): Avoid} getInstance - Gets the Avoid instance.
 */