import { TYPE } from "../constants.js";
import hex_default from "./hex.js";
import hsl_default from "./hsl.js";
import keyword_default from "./keyword.js";
import rgb_default from "./rgb.js";
var color_default = {
	format: {
		keyword: keyword_default,
		hex: hex_default,
		rgb: rgb_default,
		rgba: rgb_default,
		hsl: hsl_default,
		hsla: hsl_default
	},
	parse: (e) => {
		if (typeof e != "string") return e;
		let a = hex_default.parse(e) || rgb_default.parse(e) || hsl_default.parse(e) || keyword_default.parse(e);
		if (a) return a;
		throw Error(`Unsupported color format: "${e}"`);
	},
	stringify: (i) => !i.changed && i.color ? i.color : i.type.is(TYPE.HSL) || i.data.r === void 0 ? hsl_default.stringify(i) : i.a < 1 || !Number.isInteger(i.r) || !Number.isInteger(i.g) || !Number.isInteger(i.b) ? rgb_default.stringify(i) : hex_default.stringify(i)
};
export { color_default as default };
