import { jsx } from "react/jsx-runtime";
import { L as useSitemap, aK as manifest } from "./use-page-data.CMUQyNAA.js";
import "@sinclair/typebox";
import { c as css, a as tx } from "./twind.DdSZmZu6.js";
import { b as useBrickStyle } from "./use-section-style.DjjgfIQS.js";
import { B as BrickRoot } from "./BrickRoot.D_a_fRJm.js";
function Button({ brick, editable }) {
  const styles = useBrickStyle(brick);
  const { props } = brick;
  const classes = Object.values(styles);
  const sitemap = useSitemap();
  const handleClick = (e) => {
    if (editable) {
      e.preventDefault();
      return;
    }
    if (props.link) {
      if (props.link.startsWith("http")) {
        window.open(props.link, "_blank");
      } else {
        const page = sitemap.find((p) => p.id === props.link);
        if (page) {
          window.location.href = page.path;
        }
      }
    }
  };
  const fillStyle = props.fill === "outline" ? css({
    backgroundColor: "transparent",
    border: "2px solid currentColor",
    "&:hover": {
      backgroundColor: "currentColor",
      color: "light-dark(white, black)"
    }
  }) : css({
    "&:hover": {
      filter: "brightness(1.15)"
    }
  });
  return /* @__PURE__ */ jsx(
    BrickRoot,
    {
      brick,
      manifest,
      editable,
      as: "button",
      type: "button",
      className: tx(classes, "btn", fillStyle, editable && "pointer-events-none"),
      "data-prevented-by-editor": editable ? "true" : "false",
      onClick: handleClick,
      children: props.label
    }
  );
}
export {
  Button as default
};
//# sourceMappingURL=button.CZiVKe2l.js.map
