"use client";
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
import * as React from 'react';
import { jsx, jsxs } from 'react/jsx-runtime';
import * as AvatarPrimitive from '@radix-ui/react-avatar';

// lib/utils.ts
function cn(...inputs) {
  return twMerge(clsx(inputs));
}
var svgCache = /* @__PURE__ */ new Map();
function DynamicIcon({
  name,
  size = 28,
  color,
  className,
  alt
}) {
  const [svgContent, setSvgContent] = React.useState(null);
  const [isLoading, setIsLoading] = React.useState(true);
  const [error, setError] = React.useState(null);
  const { url, iconName } = React.useMemo(() => {
    const separator = name.includes("/") ? "/" : ":";
    const [prefix, iconName2] = name.split(separator);
    const baseUrl = `https://icons.opensite.ai/api/icon/${prefix}/${iconName2}?format=svg&width=${size}&height=${size}`;
    return {
      url: baseUrl,
      iconName: iconName2
    };
  }, [name, size]);
  React.useEffect(() => {
    let isMounted = true;
    const fetchSvg = async () => {
      const cached = svgCache.get(url);
      if (cached) {
        if (isMounted) {
          setSvgContent(cached);
          setIsLoading(false);
        }
        return;
      }
      try {
        setIsLoading(true);
        setError(null);
        const response = await fetch(url);
        if (!response.ok) {
          throw new Error(`Failed to fetch icon: ${response.status}`);
        }
        let svg = await response.text();
        svg = processSvgForCurrentColor(svg);
        svgCache.set(url, svg);
        if (isMounted) {
          setSvgContent(svg);
          setIsLoading(false);
        }
      } catch (err) {
        if (isMounted) {
          setError(err instanceof Error ? err.message : "Failed to load icon");
          setIsLoading(false);
        }
      }
    };
    fetchSvg();
    return () => {
      isMounted = false;
    };
  }, [url]);
  if (isLoading) {
    return /* @__PURE__ */ jsx(
      "span",
      {
        className: cn("inline-block", className),
        style: { width: size, height: size },
        "aria-hidden": "true"
      }
    );
  }
  if (error || !svgContent) {
    return /* @__PURE__ */ jsx(
      "span",
      {
        className: cn("inline-block", className),
        style: { width: size, height: size },
        role: "img",
        "aria-label": alt || iconName
      }
    );
  }
  return /* @__PURE__ */ jsx(
    "span",
    {
      className: cn("inline-flex items-center justify-center", className),
      style: {
        width: size,
        height: size,
        color: color || "inherit"
      },
      role: "img",
      "aria-label": alt || iconName,
      dangerouslySetInnerHTML: { __html: svgContent }
    }
  );
}
function processSvgForCurrentColor(svg) {
  let processed = svg;
  processed = processed.replace(
    /stroke=["'](#000000|#000|black)["']/gi,
    'stroke="currentColor"'
  );
  processed = processed.replace(
    /fill=["'](#000000|#000|black)["']/gi,
    'fill="currentColor"'
  );
  return processed;
}
function Avatar({
  className,
  ...props
}) {
  return /* @__PURE__ */ jsx(
    AvatarPrimitive.Root,
    {
      "data-slot": "avatar",
      className: cn(
        "relative flex size-8 shrink-0 overflow-hidden rounded-full",
        className
      ),
      ...props
    }
  );
}
function AvatarImage({
  className,
  ...props
}) {
  return /* @__PURE__ */ jsx(
    AvatarPrimitive.Image,
    {
      "data-slot": "avatar-image",
      className: cn("aspect-square size-full", className),
      ...props
    }
  );
}
function AvatarFallback({
  className,
  ...props
}) {
  return /* @__PURE__ */ jsx(
    AvatarPrimitive.Fallback,
    {
      "data-slot": "avatar-fallback",
      className: cn(
        "bg-muted flex size-full items-center justify-center rounded-full",
        className
      ),
      ...props
    }
  );
}
function Card({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    "div",
    {
      "data-slot": "card",
      className: cn(
        "bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
        className
      ),
      ...props
    }
  );
}
function CardContent({ className, ...props }) {
  return /* @__PURE__ */ jsx(
    "div",
    {
      "data-slot": "card-content",
      className: cn("px-6", className),
      ...props
    }
  );
}

// lib/blockBrandedIconsAndPlaceholders.ts
var blockBrandedIconsAndPlaceholders = {
  avatar1: "https://cdn.ing/assets/i/r/286239/ebm7o3j2kx48vw98emnwjaf5qvl6/avatar-1.webp",
  avatar2: "https://cdn.ing/assets/i/r/286240/vgf3rrkwn0769pfdtpal60uo5vpw/avatar-2.webp",
  avatar3: "https://cdn.ing/assets/i/r/286241/05vbqt3lls0q974r8fv4zn0njllq/avatar-3.webp"};
var DEFAULT_STATS = [
  { value: "10K+", label: "Happy Customers" },
  { value: "4.9", label: "Average Rating" },
  { value: "99%", label: "Satisfaction Rate" },
  { value: "24/7", label: "Support Available" }
];
var DEFAULT_TESTIMONIALS = [
  {
    id: "1",
    content: "The platform has revolutionized our workflow. We've seen a 40% increase in productivity since implementation.",
    author: {
      name: "Sarah Chen",
      role: "Product Manager",
      avatar: blockBrandedIconsAndPlaceholders.avatar1
    }
  },
  {
    id: "2",
    content: "Outstanding support and an even better product. The team goes above and beyond to ensure our success.",
    author: {
      name: "Michael Torres",
      role: "CEO",
      avatar: blockBrandedIconsAndPlaceholders.avatar2
    }
  },
  {
    id: "3",
    content: "Best investment we've made this year. The ROI was visible within the first month of using the platform.",
    author: {
      name: "Emily Watson",
      role: "Operations Director",
      avatar: blockBrandedIconsAndPlaceholders.avatar3
    }
  }
];
function TestimonialsStatsHeader({
  stats = DEFAULT_STATS,
  testimonials = DEFAULT_TESTIMONIALS,
  title = "Trusted by Thousands",
  subtitle = "Join the growing community of satisfied customers",
  className
}) {
  return /* @__PURE__ */ jsx("section", { className: cn("py-16 md:py-24", className), children: /* @__PURE__ */ jsxs("div", { className: "container", children: [
    /* @__PURE__ */ jsxs("div", { className: "mx-auto mb-12 max-w-2xl text-center", children: [
      /* @__PURE__ */ jsx("h2", { className: "text-3xl font-semibold tracking-tight md:text-4xl", children: title }),
      /* @__PURE__ */ jsx("p", { className: "mt-4 text-lg text-muted-foreground", children: subtitle })
    ] }),
    /* @__PURE__ */ jsx("div", { className: "mb-12 grid grid-cols-2 gap-4 md:grid-cols-4", children: stats.map((stat, index) => /* @__PURE__ */ jsxs(
      "div",
      {
        className: "rounded-lg bg-muted/50 p-6 text-center",
        children: [
          /* @__PURE__ */ jsx("p", { className: "text-3xl font-bold text-primary md:text-4xl", children: stat.value }),
          /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: stat.label })
        ]
      },
      index
    )) }),
    /* @__PURE__ */ jsx("div", { className: "grid gap-6 md:grid-cols-3", children: testimonials.map((testimonial) => /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "p-6", children: [
      /* @__PURE__ */ jsx("div", { className: "mb-4 flex gap-1", children: [...Array(5)].map((_, i) => /* @__PURE__ */ jsx(
        DynamicIcon,
        {
          name: "lucide/star",
          size: 16,
          className: "fill-yellow-400 text-yellow-400"
        },
        i
      )) }),
      /* @__PURE__ */ jsxs("p", { className: "mb-6 text-sm leading-relaxed", children: [
        "\u201C",
        testimonial.content,
        "\u201D"
      ] }),
      /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ jsxs(Avatar, { className: "size-10", children: [
          /* @__PURE__ */ jsx(
            AvatarImage,
            {
              src: testimonial.author.avatar,
              alt: testimonial.author.name
            }
          ),
          /* @__PURE__ */ jsx(AvatarFallback, { children: testimonial.author.name.split(" ").map((n) => n[0]).join("") })
        ] }),
        /* @__PURE__ */ jsxs("div", { children: [
          /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: testimonial.author.name }),
          testimonial.author.role && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: testimonial.author.role })
        ] })
      ] })
    ] }) }, testimonial.id)) })
  ] }) });
}

export { TestimonialsStatsHeader };
//# sourceMappingURL=testimonials-stats-header.js.map
//# sourceMappingURL=testimonials-stats-header.js.map