/** @license MIT | @cube-dev/ui-kit v0.147.0 | Cube Dev Team */
//#region src/components/layout/Board/grid-core/collision.ts
/**
* Check if two layout items collide (overlap).
*
* Two items collide if their bounding boxes overlap and they are not the same
* item.
*/
function collides(l1, l2) {
	if (l1.i === l2.i) return false;
	if (l1.x + l1.w <= l2.x) return false;
	if (l1.x >= l2.x + l2.w) return false;
	if (l1.y + l1.h <= l2.y) return false;
	if (l1.y >= l2.y + l2.h) return false;
	return true;
}
/**
* Find the first item in the layout that collides with the given item.
*/
function getFirstCollision(layout, layoutItem) {
	for (let i = 0; i < layout.length; i++) {
		const item = layout[i];
		if (item !== void 0 && collides(item, layoutItem)) return item;
	}
}
/**
* Find all items in the layout that collide with the given item.
*/
function getAllCollisions(layout, layoutItem) {
	return layout.filter((l) => collides(l, layoutItem));
}

//#endregion
export { collides, getAllCollisions, getFirstCollision };
//# sourceMappingURL=collision.js.map