import { m as P, x as $, S as v } from "./color-system.BMgofsHj.js";
import { _ as h, B as l } from "./twind.D_WBdNpx.js";
import { jsx as H } from "react/jsx-runtime";
import { Suspense as z, lazy as F } from "react";
import { merge as I, get as k } from "lodash-es";
import { c as j, u as S } from "./schema-resolver.OTL7sXPE.js";
import { f as O, d as M } from "./chunk-RXIM6GTA.C-ABNABt.js";
import "@sinclair/typebox";
function nt({ attributes: t, editable: e, typography: o, showIntro: r }) {
  return h(
    "flex flex-col group/page mx-auto relative max-w-full w-full p-0 antialiased",
    e && "overflow-hidden min-h-[100cqh]",
    P(t.$backgroundColor) ? l({ backgroundColor: t.$backgroundColor }) : t.$backgroundColor,
    P(t.$textColor) ? l({ color: t.$textColor }) : t.$textColor,
    // typeof attributes.$backgroundColor?.image === "string" &&
    //   css({
    //     backgroundImage: `url(${attributes.$backgroundColor.image})`,
    //     backgroundRepeat: attributes.$backgroundColor.repeat ?? "no-repeat",
    //     backgroundSize: attributes.$backgroundColor.size ?? "cover",
    //     backgroundPosition: "center top",
    //   }),
    G(o),
    // Animate all bricks when the page is loading
    e && r && "[&>.brick-wrapper]:(opacity-0 animate-elastic-pop)"
  );
}
function G(t) {
  function e(o) {
    return o.type === "stack" ? `var(--font-${o.family})` : `"${o.family}"`;
  }
  return l({
    fontFamily: e(t.body),
    fontSize: `${t.base}px`,
    "& h1, & h2, & h3, & h4, & h5, & h6, & h7": {
      fontFamily: e(t.heading)
    }
  });
}
const D = /* @__PURE__ */ Object.assign({ "../bricks/accordion.tsx": () => import("./accordion.J4Sdb_cO.js"), "../bricks/box.tsx": () => import("./box.CuCv0OzS.js"), "../bricks/button.tsx": () => import("./button.DWUQzJ0q.js"), "../bricks/card.tsx": () => import("./card.D1J4S5JP.js"), "../bricks/carousel.tsx": () => import("./carousel.W81b4KVN.js"), "../bricks/dynamic.tsx": () => import("./dynamic.Dl-8rwuW.js"), "../bricks/footer.tsx": () => import("./footer.CDjUQ8IM.js"), "../bricks/form.tsx": () => import("./form.Ch1wGKXk.js"), "../bricks/hero.tsx": () => import("./hero.C44P6Uiu.js"), "../bricks/icon.tsx": () => import("./icon.CL2zRNfN.js"), "../bricks/image.tsx": () => import("./image.__nsAOAR.js"), "../bricks/images-gallery.tsx": () => import("./images-gallery.Davhze1F.js"), "../bricks/map.tsx": () => import("./map.DH0E7hNL.js"), "../bricks/navbar.tsx": () => import("./navbar.Bq6QYc3-.js"), "../bricks/sidebar.tsx": () => import("./sidebar.BXn2wGUq.js"), "../bricks/social-links.tsx": () => import("./social-links.Cqyw7Zky.js"), "../bricks/spacer.tsx": () => import("./spacer.CI-n14Xg.js"), "../bricks/testimonials.tsx": () => import("./testimonials.DbC8Kzjd.js"), "../bricks/text.tsx": () => import("./text.DN0I-Yjw.js"), "../bricks/video.tsx": () => import("./video.BSuDleiX.js").then((t) => t.v) }), E = Object.entries(D).reduce(
  (t, [e, o]) => {
    const r = e.match(/\.\/bricks\/(.*)\.(j|t)sx?$/)[1];
    return t[r] = F(o), t;
  },
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
  {}
), lt = ({
  brick: t,
  editable: e,
  selectedBrickId: o
}) => {
  const r = E[t.type];
  if (!r)
    return console.warn("Brick not found", t.type), null;
  const s = {
    brick: t,
    editable: e,
    selected: t.id === o
  };
  return /* @__PURE__ */ H(z, { children: /* @__PURE__ */ H(r, { ...s }) });
};
function N(t) {
  return t ? [
    t.color && $(t.color, "backgroundColor"),
    t.image && l({
      backgroundImage: `url(${t.image})`,
      backgroundSize: t.size ?? "auto",
      backgroundRepeat: t.repeat ?? "no-repeat"
    })
  ] : null;
}
function B(t, e) {
  return e ? `@desktop:(${l({ gap: t })}) @mobile:(${l({ gap: e })})` : l({
    gap: t
  });
}
function q(t, e) {
  return e ? `@desktop:(${v(t, "bg-color")}) @mobile:(${v(e, "bg-color")})` : v(t, "bg");
}
function A(t, e) {
  return $(t, "color");
}
function K(t) {
  return $(t, "opacity");
}
function n(t, e, o) {
  if (o != null && o["ui:desktop-only"])
    return `@desktop:(${t})`;
  if (!e)
    return t;
  if (t && e)
    return `@desktop:(${t}) @mobile:(${e})`;
  if (e)
    return `@mobile:(${e})`;
}
function R(t) {
  return t ? "sticky top-0 left-0 right-0 self-start w-fill z-[99999] isolate" : null;
}
function T(t, e) {
  return t;
}
function _(t, e, o) {
  return t ? [t.width, t.color] : null;
}
function J(t, e, o) {
  if (o != null && o["ui:desktop-only"])
    return "@desktop:(flex-grow)";
  if (t && e)
    return "flex-grow";
  if (!e)
    return t ? "@desktop:(flex-grow)" : null;
  if (e)
    return "@mobile:(flex-grow) @desktop:(grow-0)";
}
const L = {
  "styles:color": A,
  "styles:basicGap": T,
  "styles:textShadow": n,
  "styles:opacity": K,
  "styles:objectFit": n,
  "styles:objectPosition": n,
  "styles:heroSize": n,
  "styles:fontSize": n,
  "styles:padding": n,
  // test
  "styles:gap": B,
  "styles:gradientDirection": n,
  "styles:backgroundColor": q,
  "styles:background": N,
  "styles:rounding": n,
  "styles:direction": n,
  // test putting here
  "styles:alignItems": n,
  "styles:justifyContent": n,
  "styles:border": _
}, Q = {
  "styles:direction": n,
  "styles:rounding": n,
  // "styles:alignItems": simpleClassHandler,
  "styles:shadow": n,
  "styles:justifyContent": n,
  "styles:alignItems": n,
  "styles:fixedPositioned": R,
  "styles:alignSelf": n,
  "styles:grow": J
};
function U(t) {
  return t.includes(".") ? t.split(".").slice(0, -1).join(".") : t;
}
function b(t, e = "", o = {}) {
  if (t.type === "object")
    for (const r in t.properties) {
      const s = j(t.properties[r]);
      s["ui:styleId"] && (o[`${e}${r}`] = s["ui:styleId"]), b(s, `${e}${r}.`, o);
    }
  else t.type === "array" && b(t.items, `${e}[].`, o);
  return o;
}
function C(t, e, o) {
  const { props: r, mobileProps: s } = e, d = I({}, O[e.type].props, r), i = S(e.type), f = Object.entries(t).reduce((p, [a, y]) => {
    var c;
    const u = k(i.props.properties, a);
    if (u) {
      const x = j(u);
      if ((c = x.metadata) != null && c.filter) {
        const w = x.metadata.filter;
        w(x, d) || p.push(a);
      }
    }
    return p;
  }, []), m = o === "brick" ? L : Q;
  return Object.entries(t).reduce(
    (p, [a, y]) => {
      const u = m[y];
      if (!u || f.includes(a))
        return p;
      const c = U(a);
      p[c] = p[c] ?? [];
      const x = k(d, a), w = k(s, a), W = k(i.props.properties, a);
      return p[c].push(
        // @ts-expect-error
        h(u == null ? void 0 : u(x, w, W))
      ), p;
    },
    {}
  );
}
function pt(t) {
  const e = S(t.type), o = b(e.props);
  return C(o, t, "brick");
}
function at({
  brick: t,
  editable: e,
  selected: o,
  isContainerChild: r = !1
}) {
  var a, y, u, c;
  const { props: s, mobileProps: d } = t, i = S(t.type), f = b(i.props), m = Object.values(f), g = C(f, t, "wrapper"), p = !!i.isContainer;
  return h(
    i.staticClasses,
    s.className,
    s.preset,
    "brick-wrapper group/brick flex",
    p ? "@desktop:min-w-min min-h-fit shrink-0 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"
    ),
    ((a = i.maxHeight) == null ? void 0 : a.mobile) && `@mobile:max-h-[${i.maxHeight.mobile}px]`,
    ((y = i.maxHeight) == null ? void 0 : y.desktop) && `@desktop:max-h-[${i.maxHeight.desktop}px]`,
    // !isContainerChild &&
    s.grow ? "@desktop:w-auto" : typeof s.width < "u" ? `@desktop:w-[${s.width}]` : `@desktop:w-[${i.defaultWidth.desktop}]`,
    !r && (typeof (d == null ? void 0 : d.width) < "u" ? `@mobile:min-w-[${d.width}]` : `@mobile:w-[${i.defaultWidth.mobile}]`),
    // Max width
    ((u = i.maxWidth) == null ? void 0 : u.mobile) && `@mobile:max-w-[${i.maxWidth.mobile}px]`,
    ((c = i.maxWidth) == null ? void 0 : c.desktop) && `@desktop:max-w-[${i.maxWidth.desktop}px]`,
    typeof s.height < "u" ? l({
      minHeight: `${s.height}`
    }) : `@mobile:min-h-[${i.defaultHeight.mobile}] @desktop:min-h-[${i.defaultHeight.desktop}]`,
    m.includes("styles:fixedPositioned") === !1 && "relative",
    // container children expand to fill the space
    r && "container-child",
    // When a brick is hidden on mobile, hide the wrapper as well
    "@mobile:[&:has([data-mobile-hidden])]:hidden",
    X(e === !0, i.isContainer, r, o),
    ...Object.values(g).flat()
  );
}
function X(t, e, o, r, s) {
  return t ? [
    "select-none transition-[outline] duration-[200ms]",
    "outline outline-2 outline-transparent outline-dashed",
    {
      "outline-offset-2": !e && !o,
      "outline-offset-4": e,
      "outline-offset-0": o
    },
    r && !e && "!outline-upstart-400",
    r && e && "!outline-orange-300",
    !r && !o && !e && "hover:(outline-upstart-400/60)",
    !r && !o && e && "hover:(outline-orange-300/20)",
    !r && o && "hover:(outline-upstart-400/60) group-hover/brick:(outline-upstart-400/60)",
    l({
      "&.selected-group": {
        outlineColor: "var(--violet-8) !important"
      },
      "&.moving": {
        outlineColor: "var(--violet-8)"
      },
      "&.resizing": {
        outlineColor: "var(--violet-8)",
        minHeight: "min-content",
        overflow: "hidden"
      },
      "& [data-brick-group]:hover": {
        outline: "1px dashed var(--violet-8)",
        opacity: 0.85
      },
      // This is the class of the drag element original emplacement
      // "&.moving": {
      //   backgroundColor: "var(--gray-a6)",
      // },
      // Hide all content when dragging
      // "&.moving > *": {
      //   visibility: "hidden",
      // },
      // Hide any UI children elements when dragging
      "&.moving [data-ui]": {
        display: "none"
      }
    })
  ] : null;
}
function ut({ section: t, selected: e, editable: o, previewMode: r }) {
  var m, g;
  const s = t.props.gap ?? "12px", d = M.properties.backgroundColor["ui:presets"], i = t.props.backgroundColor ? d[t.props.backgroundColor].value.main : void 0, f = t.props.gradientDirection;
  return h(
    "flex @mobile:flex-col @desktop:flex-row w-full @container/section group/section overflow-visible relative mx-auto max-sm:max-w-dvw",
    [
      // section.props.preset as string,
      i,
      f,
      t.props.maxWidth,
      typeof t.props.minHeight == "string" && t.props.minHeight !== "full" && `min-h-[${t.props.minHeight}]`,
      // full height
      t.props.minHeight === "full" && o && "min-h-[calc(100dvh-60px)]",
      // when in editor mode
      t.props.minHeight === "full" && !o && "min-h-dvh",
      // when in real mode
      t.props.alignItems,
      t.props.justifyContent,
      // Padding and gap
      // css({ gap: `${GAP}`, paddingInline: `${GAP}`, paddingBlock: `${GAP}` }),
      B(s, (m = t.mobileProps) == null ? void 0 : m.gap),
      n(
        `p-[${s}]`,
        (g = t.mobileProps) != null && g.gap ? `p-[${t.mobileProps.gap}]` : void 0
      ),
      l({
        "&:has([data-is-navbar])": {
          // This is a hack to ensure that the navbar is not affected by the section's padding
          paddingInline: "0px !important",
          paddingBlock: "0px !important",
          flexDirection: "row"
        }
      }),
      "flex-nowrap",
      // Background
      // Section editor styles
      Y({ editable: o, previewMode: r, section: t, selected: e }),
      // Manage the section order using css "order" (flex) property
      l({
        order: t.order
      })
    ]
  );
}
function Y({ section: t, editable: e, selected: o, previewMode: r }) {
  return e ? [
    "select-none transition-[outline] duration-150 relative",
    "outline-dashed outline-2 -outline-offset-2",
    // "self-stretch",
    o ? "outline-upstart-500/40" : "outline-transparent hover:outline-upstart-500/40",
    // this is the grid overlay shown when dragging
    e && r && l`
      &:has(.moving), &:has(.moving) ~ section {
        & [data-floating-ui-portal] {
          display: none;
        }
        & .resizable-handle {
          display: none;
        }
      }`
  ] : null;
}
export {
  lt as B,
  nt as a,
  pt as b,
  at as c,
  ut as u
};
//# sourceMappingURL=use-section-style.CgktT_qE.js.map
