"use client";
'use strict';

var React = require('react');
var react = require('motion/react');
var utils = require('@hanzo/ui/lib/utils');
var avatar = require('@hanzo/ui/primitives/avatar');
var ui = require('@hanzo/ui');
var jsxRuntime = require('react/jsx-runtime');

function _interopNamespace(e) {
  if (e && e.__esModule) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var React__namespace = /*#__PURE__*/_interopNamespace(React);

var AnimatedTestimonials = React__namespace.forwardRef(
  ({ className, testimonials, autoPlay = true, duration = 5e3, ...props }, ref) => {
    const [activeIndex, setActiveIndex] = React__namespace.useState(0);
    React__namespace.useEffect(() => {
      if (!autoPlay) return;
      const interval = setInterval(() => {
        setActiveIndex((prev) => (prev + 1) % testimonials.length);
      }, duration);
      return () => clearInterval(interval);
    }, [autoPlay, duration, testimonials.length]);
    return /* @__PURE__ */ jsxRuntime.jsxs(
      "div",
      {
        ref,
        className: utils.cn("relative min-h-[200px]", className),
        ...props,
        children: [
          /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { mode: "wait", children: /* @__PURE__ */ jsxRuntime.jsx(
            react.motion.div,
            {
              initial: { opacity: 0, y: 20 },
              animate: { opacity: 1, y: 0 },
              exit: { opacity: 0, y: -20 },
              transition: { duration: 0.5 },
              children: /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.CardContent, { className: "pt-6", children: /* @__PURE__ */ jsxRuntime.jsxs("blockquote", { className: "space-y-4", children: [
                /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-lg italic", children: [
                  '"',
                  testimonials[activeIndex].content,
                  '"'
                ] }),
                /* @__PURE__ */ jsxRuntime.jsxs("footer", { className: "flex items-center gap-4", children: [
                  /* @__PURE__ */ jsxRuntime.jsxs(avatar.Avatar, { children: [
                    /* @__PURE__ */ jsxRuntime.jsx(avatar.AvatarImage, { src: testimonials[activeIndex].avatar }),
                    /* @__PURE__ */ jsxRuntime.jsx(avatar.AvatarFallback, { children: testimonials[activeIndex].author.slice(0, 2).toUpperCase() })
                  ] }),
                  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
                    /* @__PURE__ */ jsxRuntime.jsx("cite", { className: "not-italic font-medium", children: testimonials[activeIndex].author }),
                    testimonials[activeIndex].role && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", children: [
                      testimonials[activeIndex].role,
                      testimonials[activeIndex].company && `, ${testimonials[activeIndex].company}`
                    ] })
                  ] })
                ] })
              ] }) }) })
            },
            activeIndex
          ) }),
          /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center gap-2", children: testimonials.map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(
            "button",
            {
              onClick: () => setActiveIndex(index),
              className: utils.cn(
                "h-2 w-2 rounded-full transition-all",
                index === activeIndex ? "w-8 bg-primary" : "bg-muted hover:bg-muted-foreground"
              ),
              "aria-label": `Go to testimonial ${index + 1}`
            },
            index
          )) })
        ]
      }
    );
  }
);
AnimatedTestimonials.displayName = "AnimatedTestimonials";

exports.AnimatedTestimonials = AnimatedTestimonials;
