import { usePageQueries as h, useLoopedQuery as Q, useData as k } from "../../../../../use-page-data.js";
import { useBrickManifest as O } from "./use-brick-manifest.js";
import y from "../../../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/get.js";
import D from "../../../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isPlainObject.js";
function V({
  brick: a,
  editable: m,
  iterationIndex: d = 0
}) {
  const { props: s } = a, g = h(), u = s.loop, i = Q(u?.over), P = O(a.type), f = k(m);
  if (!g.length)
    return s;
  function p(r, t) {
    if (typeof r == "string")
      return r.replace(/{{(.*?)}}/g, (o, e) => y(t, e.trim(), ""));
    if (typeof r == "object" && r !== null) {
      const o = {};
      for (const [e, n] of Object.entries(r))
        o[e] = typeof n == "string" || D(n) ? p(n, t) : n;
      return o;
    }
    return r;
  }
  function l(r) {
    if (typeof r == "string")
      return r.replace(/{{(.*?)}}/g, (t, o) => {
        const [e, n] = o.trim().split("."), c = f[e][d] ?? {};
        return y(c, n, "");
      });
    if (typeof r == "object" && r !== null) {
      const t = {};
      for (const [o, e] of Object.entries(r))
        t[o] = typeof e == "string" ? l(e) : e;
      return t;
    }
    return r;
  }
  function v(r) {
    const t = {};
    for (const [o, e] of Object.entries(r))
      if (P.props.properties[o]?.metadata?.consumeQuery && i) {
        const c = f[i.alias] ?? [], b = (Array.isArray(e) ? e : [e])[0];
        t[o] = c.map((j) => p(b, { [i.alias]: j })).slice(0, u?.overrideLimit ?? void 0);
      } else
        t[o] = typeof e == "string" ? l(e) : e;
    return t;
  }
  return v(s);
}
export {
  V as useBrickProps
};
//# sourceMappingURL=use-brick-props.js.map
