/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-f1f3d22 | Cube Dev Team */
import { filterMods, parseStyle } from "../utils/styles.js";

//#region src/tasty/styles/outline.ts
const BORDER_STYLES = [
	"none",
	"hidden",
	"dotted",
	"dashed",
	"solid",
	"double",
	"groove",
	"ridge",
	"inset",
	"outset"
];
/**
* Generates CSS for outline property with optional offset.
*
* Syntax:
* - `outline="2px solid #red"` - outline only
* - `outline="2px solid #red / 4px"` - outline with offset (slash separator)
* - `outline="2px / 4px"` - width with offset (simpler form)
* - `outline={true}` - default 1ow solid outline
* - `outlineOffset="4px"` - offset as separate prop (can be combined with outline)
*
* Priority: slash syntax in outline takes precedence over outlineOffset prop
*
* @return CSS properties for outline and optionally outline-offset
*/
function outlineStyle({ outline, outlineOffset }) {
	const result = {};
	if (outline != null && outline !== false) {
		let outlineValue = outline;
		if (outline === true) outlineValue = "1ow";
		if (outline === 0) outlineValue = "0";
		const group = parseStyle(String(outlineValue)).groups[0];
		if (group) {
			const { parts } = group;
			const outlinePart = parts[0] ?? {
				values: [],
				mods: [],
				colors: []
			};
			const offsetPart = parts[1];
			const typeMods = filterMods(outlinePart.mods, BORDER_STYLES);
			result["outline"] = [
				outlinePart.values[0] || "var(--outline-width)",
				typeMods[0] || "solid",
				outlinePart.colors[0] || "var(--outline-color)"
			].join(" ");
			if (offsetPart?.values[0]) result["outline-offset"] = offsetPart.values[0];
		}
	}
	if (outlineOffset != null && !result["outline-offset"]) {
		const offsetValue = typeof outlineOffset === "number" ? `${outlineOffset}px` : outlineOffset;
		result["outline-offset"] = parseStyle(offsetValue).groups[0]?.values[0] || offsetValue;
	}
	if (Object.keys(result).length === 0) return;
	return result;
}
outlineStyle.__lookupStyles = ["outline", "outlineOffset"];

//#endregion
export { outlineStyle };
//# sourceMappingURL=outline.js.map