import { extractStylePath as H, brickWrapperStylesHelpersMap as S, brickStylesHelpersMap as W } from "../styles/helpers.js";
import { merge as B, get as f } from "lodash-es";
import { useBrickManifest as c } from "./use-brick-manifest.js";
import { b as j } from "../../../../sdk/dist/shared/chunk-AQPN5SE2.js";
import "../../../../sdk/dist/shared/chunk-DQXDGV67.js";
import "@sinclair/typebox";
import "../../../../sdk/dist/shared/chunk-7DMUDZ4H.js";
import "../../../../sdk/dist/shared/chunk-LSPN22SI.js";
import "../../../../sdk/dist/shared/chunk-ETYYRWLK.js";
import "../../../../sdk/dist/shared/chunk-4TH3C76A.js";
import "../../../../sdk/dist/shared/chunk-FKNNTHWX.js";
import "../../../../sdk/dist/shared/chunk-JS4K5JRM.js";
import "../../../../sdk/dist/shared/chunk-WU6Q4WYD.js";
import "../../../../sdk/dist/shared/chunk-QISTDGPP.js";
import "../../../../sdk/dist/shared/chunk-LFQZRGHS.js";
import "../../../../sdk/dist/shared/chunk-SLRU4CT6.js";
import "../../../../sdk/dist/shared/chunk-TTTXV7TJ.js";
import "../../../../sdk/dist/shared/chunk-UHF6IEKV.js";
import "../../../../sdk/dist/shared/chunk-LGP6GWIY.js";
import "../../../../sdk/dist/shared/chunk-X43MB5WD.js";
import "../../../../sdk/dist/shared/chunk-NNI225RG.js";
import "../../../../sdk/dist/shared/chunk-ZQGNYK5I.js";
import "../../../../sdk/dist/shared/chunk-KHFNN4P3.js";
import "../../../../sdk/dist/shared/chunk-BZGNY7LB.js";
import "../../../../sdk/dist/shared/chunk-IIFTGWFZ.js";
import "../../../../sdk/dist/shared/chunk-UU2MSQXY.js";
import "../../../../sdk/dist/shared/chunk-T3LIA4YB.js";
import "../../../../sdk/dist/shared/chunk-YBGPPF7T.js";
import "../../../../sdk/dist/shared/chunk-UMHXXXVP.js";
import "../../../../sdk/dist/shared/chunk-5N6MBJJ4.js";
import { tx as k, css as v } from "../../../../style-system/dist/twind.js";
import { resolveSchema as M } from "../../../../sdk/dist/shared/utils/schema-resolver.js";
import { getStyleProperties as y } from "../styles/style-props.js";
import { usePageAttributes as O } from "../../../../../use-page-data.js";
function w(r, o, s) {
  const { props: n, mobileProps: l } = o, e = O(), a = B({}, j[o.type].props, n), t = c(o.type), d = Object.entries(r).reduce((i, [p, x]) => {
    const u = f(t.props.properties, p);
    if (u) {
      const m = M(u);
      if (m.metadata?.filter) {
        const b = m.metadata.filter;
        b(m, a, e) || i.push(p);
      }
    }
    return i;
  }, []), h = s === "brick" ? W : S;
  return Object.entries(r).reduce(
    (i, [p, x]) => {
      const u = h[x];
      if (!u || d.includes(p))
        return i;
      const m = H(p);
      i[m] = i[m] ?? [];
      const b = f(a, p), P = f(l, p), $ = f(t.props.properties, p);
      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: n, isContainerChild: l = !1 } = r, { props: e, mobileProps: a } = o, t = c(o.type), d = y(t.props), h = Object.values(d), g = w(d, o, "wrapper"), i = !!t.isContainer;
  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}]`,
    !l && (typeof a?.width < "u" ? `@mobile:min-w-[${a.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
    l && "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",
    C(r),
    ...Object.values(g).flat()
  );
}
function C({
  brick: r,
  editable: o,
  isContainerChild: s,
  selected: n
}) {
  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
    },
    n && !e && "!outline-upstart-400",
    n && e && "!outline-orange-300",
    !n && !s && !e && "hover:(outline-upstart-400/60)",
    !n && !s && e && "hover:(outline-orange-300/20)",
    !n && 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
