import { TableResponse } from '@api-client/angular'

export interface Coordinates {
	width: number
	height: number
}

export const DEFAULT_COORDINATES: Coordinates = { width: 16, height: 8 }

export function calculateRoomPlanCoordinates(tables: TableResponse[]): Coordinates {
	const width = Math.max(...tables.map((_table) => _table.columnStart + _table.width), DEFAULT_COORDINATES.width)
	const height = Math.max(...tables.map((_table) => _table.rowStart + _table.height), DEFAULT_COORDINATES.height)
	return { width, height }
}
