import apiClient from './index';

/**
 * Represents a point with x and y coordinates.
 * Matches the backend Point DTO.
 */
export interface Point {
  x: number;
  y: number;
}

/**
 * Represents the request payload for finding a path.
 * Matches the backend PathfindingRequest DTO.
 */
export interface PathfindingRequest {
  startX: number;
  startY: number;
  endX: number;
  endY: number;
}

/**
 * Calls the backend API to find a path between two points.
 * @param request The pathfinding request containing start and end coordinates.
 * @returns A promise that resolves to a list of points representing the path.
 */
export const findPath = (request: PathfindingRequest): Promise<Point[]> => {
  return apiClient.post('/pathfinding/find', request);
}; 