import { extractStylePath as H, brickWrapperStylesHelpersMap as S, brickStylesHelpersMap as W } from "../styles/helpers.js";
import { merge as j, get as f } from "lodash-es";
import { useBrickManifest as c } from "./use-brick-manifest.js";
import { b as B } from "../../../../sdk/dist/shared/chunk-5DZIQGY2.js";
import "../../../../sdk/dist/shared/chunk-VDX2J22H.js";
import "@sinclair/typebox";
import "../../../../sdk/dist/shared/chunk-URRCKLAS.js";
import "../../../../sdk/dist/shared/chunk-2NLDX5FG.js";
import "../../../../sdk/dist/shared/chunk-XED6ARVN.js";
import "../../../../sdk/dist/shared/chunk-3QOAHMV4.js";
import "../../../../sdk/dist/shared/chunk-EVDZ2KND.js";
import "../../../../sdk/dist/shared/chunk-3P36LG6T.js";
import "../../../../sdk/dist/shared/chunk-ARYG4XMX.js";
import "../../../../sdk/dist/shared/chunk-QGFQA7OZ.js";
import "../../../../sdk/dist/shared/chunk-5X5SX5N7.js";
import "../../../../sdk/dist/shared/chunk-6R76KIHZ.js";
import "../../../../sdk/dist/shared/chunk-K5ADUHF4.js";
import "../../../../sdk/dist/shared/chunk-Y3X4F4YJ.js";
import "../../../../sdk/dist/shared/chunk-LT4CW2F7.js";
import "../../../../sdk/dist/shared/chunk-ILIWVWHC.js";
import "../../../../sdk/dist/shared/chunk-SAJY7H6N.js";
import "../../../../sdk/dist/shared/chunk-STDCM2KD.js";
import "../../../../sdk/dist/shared/chunk-TH5SONR6.js";
import "../../../../sdk/dist/shared/chunk-UDQWYGSO.js";
import "../../../../sdk/dist/shared/chunk-AZHH3XJJ.js";
import "../../../../sdk/dist/shared/chunk-6PGAWO4H.js";
import { d as M } from "../../../../sdk/dist/shared/chunk-LEWKHCRI.js";
import "../../../../sdk/dist/shared/chunk-F4JNKU7J.js";
import "../../../../sdk/dist/shared/chunk-7UBMXMNJ.js";
import "../../../../sdk/dist/shared/chunk-JRCVYDCD.js";
import { tx as k, css as v } from "../../../../style-system/dist/twind.js";
import { getStyleProperties as y } from "../styles/style-props.js";
import { useGenerationState as O, usePageAttributes as C } from "../../../../../use-page-data.js";
function w(r, o, s) {
  const { props: p, mobileProps: a } = o, e = C(), l = j({}, B[o.type].props, p), t = c(o.type), d = Object.entries(r).reduce((i, [n, x]) => {
    const u = f(t.props.properties, n);
    if (u) {
      const m = M(u);
      if (m.metadata?.filter) {
        const b = m.metadata.filter;
        b(m, l, e) || i.push(n);
      }
    }
    return i;
  }, []), h = s === "brick" ? W : S;
  return Object.entries(r).reduce(
    (i, [n, x]) => {
      const u = h[x];
      if (!u || d.includes(n))
        return i;
      const m = H(n);
      i[m] = i[m] ?? [];
      const b = f(l, n), P = f(a, n), $ = f(t.props.properties, n);
      return i[m].push(
        // @ts-expect-error
        k(u?.(b, P, $))
      ), i;
    },
    {}
  );
}
function ft(r) {
  const o = c(r.type), s = y(o.props);
  return w(s, r, "brick");
}
function ct(r) {
  const { brick: o, editable: s, selected: p, isContainerChild: a = !1 } = r, { props: e, mobileProps: l } = o, t = c(o.type), d = y(t.props), h = Object.values(d), g = w(d, o, "wrapper"), i = !!t.isContainer, { isSetup: n } = O();
  return k(
    t.staticClasses,
    e.className,
    e.preset,
    "brick-wrapper group/brick flex max-w-full",
    i ? "@desktop:min-w-min min-h-fit h-auto flex-wrap" : (
      // ? "@desktop:min-w-min min-h-fit shrink-0 h-auto @mobile:flex-wrap @desktop:flex-nowrap"
      "min-w-min min-h-min"
    ),
    t.maxHeight?.mobile && `@mobile:max-h-[${t.maxHeight.mobile}px]`,
    t.maxHeight?.desktop && `@desktop:max-h-[${t.maxHeight.desktop}px]`,
    // !isContainerChild &&
    e.grow ? "@desktop:w-auto" : typeof e.width < "u" ? `@desktop:w-[${e.width}]` : `@desktop:w-[${t.defaultWidth.desktop}]`,
    !a && (typeof l?.width < "u" ? `@mobile:min-w-[${l.width}]` : `@mobile:w-[${t.defaultWidth.mobile}]`),
    // Max width
    t.maxWidth?.mobile && `@mobile:max-w-[${t.maxWidth.mobile}px]`,
    t.maxWidth?.desktop && `@desktop:max-w-[${t.maxWidth.desktop}px]`,
    typeof e.height < "u" ? v({
      minHeight: `${e.height}`
    }) : `@mobile:min-h-[${t.defaultHeight.mobile}] @desktop:min-h-[${t.defaultHeight.desktop}]`,
    h.includes("styles:fixedPositioned") === !1 && "relative",
    // container children expand to fill the space
    a && "container-child",
    // When a brick is hidden on mobile, hide the wrapper as well
    "@mobile:[&:has([data-mobile-hidden])]:hidden @desktop:[&:has([data-mobile-hidden])]:flex",
    n && "animate animate-reveal-brick",
    F(r),
    ...Object.values(g).flat()
  );
}
function F({
  brick: r,
  editable: o,
  isContainerChild: s,
  selected: p
}) {
  const e = !!c(r.type).isContainer;
  return o ? [
    "select-none",
    // "select-none transition-[outline] duration-[200ms]",
    o && "transition-all duration-300",
    "outline outline-2 outline-transparent outline-dashed",
    {
      "outline-offset-2": !e && !s,
      "outline-offset-4": e,
      "outline-offset-0": s
    },
    p && !e && "!outline-upstart-400",
    p && e && "!outline-orange-300",
    !p && !s && !e && "hover:(outline-upstart-400/60)",
    !p && !s && e && "hover:(outline-orange-300/20)",
    !p && s && "hover:(outline-upstart-400/60) group-hover/brick:(outline-upstart-400/60)",
    v({
      "&.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)"
      },
      // Hide any UI children elements when dragging
      "&.moving [data-ui]": {
        display: "none"
      }
    })
  ] : null;
}
export {
  ft as useBrickStyle,
  ct as useBrickWrapperStyle
};
//# sourceMappingURL=use-brick-style.js.map
