"use client";
const require_parsers = require("./parsers.cjs");
//#region packages/@mantine/core/src/components/ColorPicker/converters/converters.ts
function hsvaToRgbaObject({ h, s, v, a }) {
	const _h = h / 360 * 6;
	const _s = s / 100;
	const _v = v / 100;
	const hh = Math.floor(_h);
	const l = _v * (1 - _s);
	const c = _v * (1 - (_h - hh) * _s);
	const d = _v * (1 - (1 - _h + hh) * _s);
	const module = hh % 6;
	return {
		r: require_parsers.round([
			_v,
			c,
			l,
			l,
			d,
			_v
		][module] * 255),
		g: require_parsers.round([
			d,
			_v,
			_v,
			c,
			l,
			l
		][module] * 255),
		b: require_parsers.round([
			l,
			l,
			d,
			_v,
			_v,
			c
		][module] * 255),
		a: require_parsers.round(a, 2)
	};
}
function hsvaToRgba(color, includeAlpha) {
	const { r, g, b, a } = hsvaToRgbaObject(color);
	if (!includeAlpha) return `rgb(${r}, ${g}, ${b})`;
	return `rgba(${r}, ${g}, ${b}, ${require_parsers.round(a, 2)})`;
}
function hsvaToHsl({ h, s, v, a }, includeAlpha) {
	const hh = (200 - s) * v / 100;
	const result = {
		h: Math.round(h),
		s: Math.round(hh > 0 && hh < 200 ? s * v / 100 / (hh <= 100 ? hh : 200 - hh) * 100 : 0),
		l: Math.round(hh / 2)
	};
	if (!includeAlpha) return `hsl(${result.h}, ${result.s}%, ${result.l}%)`;
	return `hsla(${result.h}, ${result.s}%, ${result.l}%, ${require_parsers.round(a, 2)})`;
}
function formatHexPart(number) {
	const hex = number.toString(16);
	return hex.length < 2 ? `0${hex}` : hex;
}
function hsvaToHex(color) {
	const { r, g, b } = hsvaToRgbaObject(color);
	return `#${formatHexPart(r)}${formatHexPart(g)}${formatHexPart(b)}`;
}
function hsvaToHexa(color) {
	const a = Math.round(color.a * 255);
	return `${hsvaToHex(color)}${formatHexPart(a)}`;
}
const CONVERTERS = {
	hex: hsvaToHex,
	hexa: (color) => hsvaToHexa(color),
	rgb: (color) => hsvaToRgba(color, false),
	rgba: (color) => hsvaToRgba(color, true),
	hsl: (color) => hsvaToHsl(color, false),
	hsla: (color) => hsvaToHsl(color, true)
};
function convertHsvaTo(format, color) {
	if (!color) return "#000000";
	if (!(format in CONVERTERS)) return CONVERTERS.hex(color);
	return CONVERTERS[format](color);
}
//#endregion
exports.convertHsvaTo = convertHsvaTo;

//# sourceMappingURL=converters.cjs.map