import { jsx as x } from "react/jsx-runtime";
import { useRef as A, useMemo as F, useEffect as B } from "react";
import { c as C, s as D, a as N } from "../tools/tools.js";
const h = function(L) {
  const {
    active: t = !1,
    as: y = "div",
    carouselItemEnd: n = !1,
    carouselItemNext: l = !1,
    carouselItemPrev: c = !1,
    carouselItemStart: a = !1,
    className: m,
    dropOldClass: u,
    style: d,
    variables: f,
    ...E
  } = L, v = A(null), I = F(() => {
    const e = C(!u && "carousel-item", m), r = D((s, i) => ({ tKey: N(i) }), f, d);
    return { className: e, style: r };
  }, [m, u, d, f]);
  return B(() => {
    const e = v.current;
    if (!e)
      return;
    const r = (i, p, q) => {
      i && e.classList.add("active"), p.forEach((o) => e.classList.remove(o)), q.forEach((o) => e.classList.add(o));
    }, s = () => {
      t ? r(
        !1,
        a ? ["active", "carousel-item-start"] : ["active", "carousel-item-end"],
        []
      ) : r(
        !0,
        a ? ["carousel-item-next", "carousel-item-start"] : ["carousel-item-prev", "carousel-item-end"],
        []
      );
    };
    if (t && a)
      requestAnimationFrame(() => {
        e.addEventListener("transitionend", s), requestAnimationFrame(() => {
          e.classList.add("active", "carousel-item-start");
        });
      });
    else if (!t && l && a)
      requestAnimationFrame(() => {
        e.addEventListener("transitionend", s), e.classList.add("carousel-item-next"), requestAnimationFrame(() => {
          e.classList.add("carousel-item-start");
        });
      });
    else if (t && n)
      requestAnimationFrame(() => {
        e.addEventListener("transitionend", s), requestAnimationFrame(() => {
          e.classList.add("active", "carousel-item-end");
        });
      });
    else if (!t && c && n)
      requestAnimationFrame(() => {
        e.addEventListener("transitionend", s), e.classList.add("carousel-item-prev"), requestAnimationFrame(() => {
          e.classList.add("carousel-item-end");
        });
      });
    else {
      r(t, [], []);
      return;
    }
    return () => {
      s(), e.removeEventListener("transitionend", s);
    };
  }, [
    t,
    n,
    l,
    c,
    a
  ]), /* @__PURE__ */ x(y, { ...E, ...I, ref: v });
};
h.displayName = "BRL.CarouselItem";
export {
  h as C
};
//# sourceMappingURL=carousel-item.js.map
