import { f as e, o as t, v as n } from "./use-page-data.Cb2SuuwJ.js";
import { c as r, j as i, k as a } from "./schema-resolver.p7B_pu36.js";
import { b as o } from "./use-brick-manifest.Iv9SG-7-.js";
function s(e, t) {
	return function(n) {
		return e(t(n));
	};
}
var c = s(Object.getPrototypeOf, Object), l = "[object Object]", u = Function.prototype, d = Object.prototype, f = u.toString, p = d.hasOwnProperty, m = f.call(Object);
function h(e) {
	if (!i(e) || a(e) != l) return !1;
	var t = c(e);
	if (t === null) return !0;
	var n = p.call(t, "constructor") && t.constructor;
	return typeof n == "function" && n instanceof n && f.call(n) == m;
}
function g({ brick: i, editable: a, iterationIndex: s = 0 }) {
	let { props: c } = i, l = n(), u = c.loop, d = t(u?.over), f = o(i.type), p = e(a);
	if (!l.length) return c;
	function m(e, t) {
		if (typeof e == "string") return e.replace(/{{(.*?)}}/g, (e, n) => r(t, n.trim(), ""));
		if (typeof e == "object" && e) {
			let n = {};
			for (let [r, i] of Object.entries(e)) n[r] = typeof i == "string" || h(i) ? m(i, t) : i;
			return n;
		}
		return e;
	}
	function g(e) {
		if (typeof e == "string") return e.replace(/{{(.*?)}}/g, (e, t) => {
			let [n, i] = t.trim().split("."), a = p[n][s] ?? {};
			return r(a, i, "");
		});
		if (typeof e == "object" && e) {
			let t = {};
			for (let [n, r] of Object.entries(e)) t[n] = typeof r == "string" ? g(r) : r;
			return t;
		}
		return e;
	}
	function _(e) {
		let t = {};
		for (let [n, r] of Object.entries(e)) {
			let e = f.props.properties[n];
			if (e?.metadata?.consumeQuery && d) {
				let e = p[d.alias] ?? [], i = (Array.isArray(r) ? r : [r])[0];
				t[n] = e.map((e) => m(i, { [d.alias]: e })).slice(0, u?.overrideLimit ?? void 0);
			} else t[n] = typeof r == "string" ? g(r) : r;
		}
		return t;
	}
	let v = _(c);
	return v;
}
export { g as b };

//# sourceMappingURL=use-brick-props.Db5hMGVc.js.map