import { DEC2HEX as e } from "../constants.js";
import t from "../channels/reusable.js";
//#region ../../node_modules/khroma/dist/color/hex.js
var n = {
	re: /^#((?:[a-f0-9]{2}){2,4}|[a-f0-9]{3})$/i,
	parse: (e) => {
		if (e.charCodeAt(0) !== 35) return;
		let r = e.match(n.re);
		if (!r) return;
		let i = r[1], a = parseInt(i, 16), o = i.length, s = o % 4 == 0, c = o > 4, l = c ? 1 : 17, u = c ? 8 : 4, d = s ? 0 : -1, f = c ? 255 : 15;
		return t.set({
			r: (a >> u * (d + 3) & f) * l,
			g: (a >> u * (d + 2) & f) * l,
			b: (a >> u * (d + 1) & f) * l,
			a: s ? (a & f) * l / 255 : 1
		}, e);
	},
	stringify: (t) => {
		let { r: n, g: r, b: i, a } = t;
		return a < 1 ? `#${e[Math.round(n)]}${e[Math.round(r)]}${e[Math.round(i)]}${e[Math.round(a * 255)]}` : `#${e[Math.round(n)]}${e[Math.round(r)]}${e[Math.round(i)]}`;
	}
};
//#endregion
export { n as default };
