import { S as e, al as t, p as n } from "./use-page-data.Cb2SuuwJ.js";
import { b as r, c as i } from "./twind.BiM9xcCd.js";
import { b as a, c as o } from "./color-system.Dp99zR0T.js";
import { b as s } from "./schema-resolver.p7B_pu36.js";
import { b as c } from "./use-brick-manifest.Iv9SG-7-.js";
import { get as l, merge as u } from "lodash-es";
function d(e, t = "", n = {}) {
	if (e.type === "object") for (let r in e.properties) {
		let i = s(e.properties[r]);
		i["ui:styleId"] && (n[`${t}${r}`] = i["ui:styleId"]), d(i, `${t}${r}.`, n);
	}
	else e.type === "array" && d(e.items, `${t}[].`, n);
	return n;
}
function f(e) {
	return e ? [e.color && a(e.color, "backgroundColor"), e.image && r({
		backgroundImage: `url(${e.image})`,
		backgroundSize: e.size ?? "auto",
		backgroundRepeat: e.repeat ?? "no-repeat"
	})] : null;
}
function p(e, t) {
	return t ? `@desktop:(${r({ gap: e })}) @mobile:(${r({ gap: t })})` : r({ gap: e });
}
function m(e, t) {
	return t ? `@desktop:(${o(e, "bg-color")}) @mobile:(${o(t, "bg-color")})` : o(e, "bg");
}
function h(e, t) {
	return a(e, "color");
}
function g(e) {
	return a(e, "opacity");
}
function _(e, t, n) {
	if (n?.["ui:desktop-only"]) return `@desktop:(${e})`;
	if (!t) return e;
	if (e && t) return `@desktop:(${e}) @mobile:(${t})`;
	if (t) return `@mobile:(${t})`;
}
function v(e, t, n) {
	if (n?.["ui:desktop-only"]) return `@desktop:(${Object.values(e).join(" ")})`;
	if (e && !t) return Object.values(e);
	if (e && t) return `@desktop:(${Object.values(e).join(" ")}) @mobile:(${Object.values(t).join(" ")})`;
	if (t) return `@mobile:(${Object.values(t).join(" ")})`;
}
function y(e) {
	return e ? "sticky top-0 left-0 right-0 self-start w-fill z-[99999] isolate" : null;
}
function b(e, t) {
	return e;
}
function x(e, t, n) {
	if (n?.["ui:desktop-only"]) return "@desktop:(flex-grow)";
	if (e && t) return "flex-grow";
	if (!t) return e ? "@desktop:(flex-grow)" : null;
	if (t) return "@mobile:(flex-grow) @desktop:(grow-0)";
}
function S(e, n, r) {
	let i = r?.["ui:presets"] ?? t;
	if (r?.["ui:desktop-only"]) return `@desktop:(${i[e]?.className})`;
	if (!n) return i[e]?.className;
	if (e && n) return `@desktop:(${i[e]?.className}) @mobile:(${i[n]?.className})`;
	if (n) return `@mobile:(${i[n]?.className})`;
}
const C = {
	"presets:color": S,
	"styles:gradientDirection": _
}, w = {
	"styles:color": h,
	"styles:basicGap": b,
	"styles:textShadow": _,
	"styles:opacity": g,
	"styles:objectFit": _,
	"styles:objectPosition": _,
	"styles:heroSize": _,
	"styles:fontSize": _,
	"styles:padding": _,
	"styles:gap": p,
	"styles:gradientDirection": _,
	"styles:backgroundColor": m,
	"styles:background": f,
	"presets:color": S,
	"styles:borderColor": _,
	"styles:rounding": _,
	"styles:direction": _,
	"styles:alignItems": _,
	"styles:justifyContent": _,
	"styles:border": v,
	"styles:shadow": _
}, T = {
	"styles:direction": _,
	"styles:rounding": _,
	"styles:justifyContent": _,
	"styles:alignItems": _,
	"styles:fixedPositioned": y,
	"styles:alignSelf": _,
	"styles:grow": x
};
function E(e) {
	return e.includes(".") ? e.split(".").slice(0, -1).join(".") : e;
}
function D(t, r, a) {
	let { props: o, mobileProps: d } = r, f = n(), p = u({}, e[r.type].props, o), m = c(r.type), h = Object.entries(t).reduce((e, [t, n]) => {
		let r = l(m.props.properties, t);
		if (r) {
			let n = s(r);
			if (n.metadata?.filter) {
				let r = n.metadata.filter;
				r(n, p, f) || e.push(t);
			}
		}
		return e;
	}, []), g = a === "brick" ? w : T, _ = Object.entries(t).reduce((e, [t, n]) => {
		let r = g[n];
		if (!r || h.includes(t)) return e;
		let a = E(t);
		e[a] = e[a] ?? [];
		let o = l(p, t), s = l(d, t), c = l(m.props.properties, t);
		return e[a].push(i(r?.(o, s, c))), e;
	}, {});
	return _;
}
function O(e) {
	let t = c(e.type), n = d(t.props);
	return D(n, e, "brick");
}
function k(e) {
	let { brick: t, editable: n, selected: a, isContainerChild: o = !1 } = e, { props: s, mobileProps: l } = t, u = c(t.type), f = d(u.props), p = Object.values(f), m = D(f, t, "wrapper"), h = !!u.isContainer;
	return i(u.staticClasses, s.className, s.preset, "brick-wrapper group/brick flex max-w-full", h ? "@desktop:min-w-min min-h-fit h-auto flex-wrap" : "min-w-min min-h-min", u.maxHeight?.mobile && `@mobile:max-h-[${u.maxHeight.mobile}px]`, u.maxHeight?.desktop && `@desktop:max-h-[${u.maxHeight.desktop}px]`, s.grow ? "@desktop:w-auto" : s.width === void 0 ? `@desktop:w-[${u.defaultWidth.desktop}]` : `@desktop:w-[${s.width}]`, !o && (l?.width === void 0 ? `@mobile:w-[${u.defaultWidth.mobile}]` : `@mobile:min-w-[${l.width}]`), u.maxWidth?.mobile && `@mobile:max-w-[${u.maxWidth.mobile}px]`, u.maxWidth?.desktop && `@desktop:max-w-[${u.maxWidth.desktop}px]`, s.height === void 0 ? `@mobile:min-h-[${u.defaultHeight.mobile}] @desktop:min-h-[${u.defaultHeight.desktop}]` : r({ minHeight: `${s.height}` }), p.includes("styles:fixedPositioned") === !1 && "relative", o && "container-child", "@mobile:[&:has([data-mobile-hidden])]:hidden @desktop:[&:has([data-mobile-hidden])]:flex", A(e), ...Object.values(m).flat());
}
function A({ brick: e, editable: t, isContainerChild: n, selected: i }) {
	let a = c(e.type), o = !!a.isContainer;
	return t ? [
		"select-none",
		t && "transition-all duration-300",
		"outline outline-2 outline-transparent outline-dashed",
		{
			"outline-offset-2": !o && !n,
			"outline-offset-4": o,
			"outline-offset-0": n
		},
		i && !o && "!outline-upstart-400",
		i && o && "!outline-orange-300",
		!i && !n && !o && "hover:(outline-upstart-400/60)",
		!i && !n && o && "hover:(outline-orange-300/20)",
		!i && n && "hover:(outline-upstart-400/60) group-hover/brick:(outline-upstart-400/60)",
		r({
			"&.selected-group": { outlineColor: "var(--violet-8) !important" },
			"&.moving": { outlineColor: "var(--violet-8)" },
			"&.resizing": {
				outlineColor: "var(--violet-8)",
				minHeight: "min-content"
			},
			"& [data-brick-group]:hover": { outline: "1px dashed var(--violet-8)" },
			"&.moving [data-ui]": { display: "none" }
		})
	] : null;
}
export { O as b, k as c, w as d, T as e, E as f, C as g, d as h };

//# sourceMappingURL=use-brick-style.DDPl-_C1.js.map