export const generateImageUrl = (image_path) => {
	return process.env.REACT_APP_API_URL + `/${image_path}`;
	// return `http://127.0.0.1:5000/${image_path}`;
};

export function convertToBoundingBox(points) {
	return {
		label: points[0].label,
		x1: Math.min(...points.map((p) => p.x)),
		x2: Math.max(...points.map((p) => p.x)),
		y1: Math.min(...points.map((p) => p.y)),
		y2: Math.max(...points.map((p) => p.y)),
	};
}

export const randomDelay = () => {
	const delayTime = Math.random() * 2000 + 1000;
	return new Promise((resolve) => setTimeout(resolve, delayTime));
};

export function generateClientID() {
	const id = Math.random().toString(36).substr(2, 9);
	localStorage.setItem("client_id", id);
	return id;
}
