import { jsx, jsxs } from "react/jsx-runtime";
import { bA as manifest } from "./use-page-data.CMUQyNAA.js";
import "@sinclair/typebox";
import { a as tx } from "./twind.DdSZmZu6.js";
import { b as useBrickStyle } from "./use-section-style.DjjgfIQS.js";
import { a as InlineIcon } from "./iconify.DjLEvsi5.js";
import { B as BrickRoot } from "./BrickRoot.D_a_fRJm.js";
import { u as useBrickProps } from "./use-brick-props.BH1ptgVL.js";
import { useState } from "react";
function Testimonials(props) {
  const { brick, editable } = props;
  const brickProps = useBrickProps(props);
  const { colorPreset, border, shadow, ...styles } = useBrickStyle(brick);
  const containerClasses = Object.values(styles);
  const [showImage, setShowImage] = useState(true);
  const testimonials = brickProps.testimonials ?? [];
  const onImageError = (event) => {
    setShowImage(false);
  };
  return /* @__PURE__ */ jsx(
    BrickRoot,
    {
      brick,
      editable,
      manifest,
      className: tx("flex gap-6 @mobile:flex-col @desktop:flex-row", containerClasses),
      children: testimonials.map((testimonial, index) => /* @__PURE__ */ jsxs(
        "div",
        {
          className: tx(
            "flex flex-1 flex-col gap-6 p-6 rounded-lg @desktop:(min-w-[250px])",
            colorPreset,
            border,
            shadow
          ),
          children: [
            /* @__PURE__ */ jsx(
              "blockquote",
              {
                className: tx(
                  "flex-1 whitespace-pre-wrap text-pretty font-normal italic relative leading-relaxed"
                ),
                children: testimonial.text
              }
            ),
            /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 flex-nowrap", children: [
              showImage && testimonial.avatar?.src && /* @__PURE__ */ jsx(
                "img",
                {
                  src: testimonial.avatar.src,
                  alt: testimonial.avatar.alt || testimonial.author,
                  className: "w-12 h-12 rounded-full object-cover",
                  onError: onImageError
                }
              ),
              /* @__PURE__ */ jsxs("div", { className: "flex-1 flex-nowrap leading-tight", children: [
                /* @__PURE__ */ jsx("cite", { className: tx("font-semibold text-[90%] text-nowrap"), children: testimonial.author }),
                testimonial.subtitle && /* @__PURE__ */ jsx("div", { className: tx("text-[85%]"), children: testimonial.subtitle })
              ] }),
              testimonial.socialIcon && /* @__PURE__ */ jsx(InlineIcon, { icon: testimonial.socialIcon, className: "h-5 w-5" })
            ] })
          ]
        },
        index
      ))
    }
  );
}
export {
  Testimonials as default
};
//# sourceMappingURL=testimonials.CSGVzkVA.js.map
