import { jsx as s } from "react/jsx-runtime";
import { useRef as $, useState as F, useMemo as C } from "react";
import { useInView as O, useReducedMotion as H, AnimatePresence as b, motion as k } from "motion/react";
import P from "../../hooks/useInterval.js";
import u from "../../utils/classNames.js";
const Y = 0.4, j = 0, G = 10, K = "easeOut", q = 3, z = 5, B = 0, J = 8, A = (e) => {
  switch (e) {
    case "black":
    case "white":
      return `var(--color-${e})`;
    case "primary":
    case "secondary":
    case "info":
    case "warning":
    case "danger":
    case "success":
      return `var(--brand-${e})`;
    case "gray":
      return "var(--gray)";
    default:
      return `var(--gray-${e})`;
  }
}, te = (e) => {
  const {
    text: r,
    duration: E = Y,
    delay: p = j,
    interval: y = q,
    distance: n = G,
    ease: R = K,
    startOnView: h = !0,
    once: D = !1,
    inViewMargin: L,
    shimmer: _ = !0,
    shimmerDuration: f = z,
    shimmerDelay: T = B,
    shimmerSpread: i = J,
    shimmerRepeat: v = !0,
    shimmerColor: x = "lighter",
    textColor: I = "darkest",
    innerClassName: g = "",
    className: N = ""
  } = e, o = $(null), U = O(o, { once: D, margin: L }), a = H(), [c, V] = F(0), m = Array.isArray(r) ? r : [r], t = m[c] ?? "", w = Array.isArray(r) ? `${c}-${t}` : `text-${t}`;
  P(() => {
    V((S) => (S + 1) % m.length);
  }, y * 1e3);
  const M = C(() => t.length * i, [t, i]), l = !h || U, d = {
    "--atr-duration": `${f}s`,
    "--atr-delay": `${T}s`,
    "--atr-iterations": v ? "infinite" : "1",
    "--atr-spread": `${M}px`,
    "--atr-text-color": A(I),
    "--atr-shimmer-color": A(x)
  };
  return /* @__PURE__ */ s("div", { ref: o, className: u("position-relative", N), style: d, "aria-live": "polite", children: /* @__PURE__ */ s(b, { mode: "wait", initial: !1, children: /* @__PURE__ */ s(
    k.div,
    {
      className: u(
        "animated-text-reveal",
        "position-relative",
        _ && l && "is-animated",
        g
      ),
      style: d,
      initial: {
        opacity: a ? 1 : 0,
        y: a ? 0 : n
      },
      animate: l ? { opacity: 1, y: 0 } : { opacity: a ? 1 : 0, y: a ? 0 : n },
      exit: { opacity: 0, y: -10 },
      transition: {
        duration: E,
        delay: p,
        ease: R
      },
      children: t
    },
    w
  ) }) });
};
export {
  te as AnimatedTextReveal,
  te as default
};
//# sourceMappingURL=AnimatedTextReveal.js.map
