import { jsxs as d, jsx as l } from "react/jsx-runtime";
import { classNames as s } from "./index-classNames.js";
import { ComponentContainer as z } from "./index-ComponentContainer.js";
import H, { useRef as x } from "react";
import { a as I } from "./index-react-spring_web.modern.js";
import { Arrow as J } from "./index-Arrow.js";
import { Bullet as K } from "./index-Bullet.js";
import { Bullets as Q } from "./index-Bullets.js";
import { useCarouselMovement as U } from "./index-use-carousel-movement.js";
import e from "./index-SlideCarousel.module.scss.js";
const Y = 16, de = ({
  activeIndex: m = 0,
  initialIndex: k = m,
  ArrowComponent: i = J,
  arrowStyle: t = {},
  auto: R = 0,
  BulletComponent: S = K,
  BulletsComponent: f = Q,
  bulletStyle: _ = {},
  children: M = [],
  hasArrows: a = !1,
  hasBullets: p = !1,
  onSlideChange: $ = () => {
  },
  setSlideCustom: w = void 0,
  slidesAtOnce: u = 1,
  slidesToSlide: L = 1,
  className: O,
  arrowPlacement: o = "overlay",
  bulletPlacement: h = "overlayBottom"
}) => {
  const b = x(null), v = x(null), C = M || [], y = C.length, c = y > 1 ? Y : 0, j = `calc((100% - ${c * Math.max(u - 1, 0)}px) / ${u})`, {
    gestureBinds: A,
    maxSlide: G,
    nextSlide: N,
    previousSlide: B,
    slide: D,
    trackStyle: E,
    updateSlide: F
  } = U({
    activeIndex: m,
    auto: R,
    initialIndex: k,
    length: y,
    onSlideChange: $,
    setSlideCustom: w,
    slideGap: c,
    slidesAtOnce: u,
    slidesToSlide: L,
    viewportRef: v
  }), g = () => {
    const n = [];
    for (let r = 0; r <= G; r++)
      n.push(l(S, {
        isActive: r === D,
        onClick: () => F(r),
        style: _
      }, r));
    return n;
  }, T = () => !a || o !== "overlay" ? null : d(H.Fragment, {
    children: [l(i, {
      className: s(e.slideCarouselArrow, e.arrowLeft),
      style: t,
      direction: "left",
      onClick: B
    }), l(i, {
      className: s(e.slideCarouselArrow, e.arrowRight),
      style: t,
      direction: "right",
      onClick: N
    })]
  }), V = () => !a || o !== "outside" ? null : l(i, {
    style: t,
    direction: "left",
    onClick: B
  }), W = () => !a || o !== "outside" ? null : l(i, {
    style: t,
    direction: "right",
    onClick: N
  }), X = () => !p || h !== "overlayBottom" ? null : l(f, {
    placement: "overlayBottom",
    children: l("ul", {
      className: e.slideCarouselBullets,
      children: g()
    })
  }), q = () => !p || h !== "below" ? null : l(f, {
    placement: "below",
    children: l("ul", {
      className: e.slideCarouselBullets,
      children: g()
    })
  });
  return d(z, {
    className: s(e.SlideCarouselContainer, O),
    innerRef: b,
    children: [d("div", {
      className: s(e.carouselMain, o === "outside" ? e.carouselMainOutsideArrows : void 0),
      children: [V(), d("div", {
        className: e.slideCarousel,
        children: [T(), X(), l("div", {
          className: e.slideCarouselViewport,
          ref: v,
          children: l(I.div, {
            ...A(),
            className: e.slideCarouselTrack,
            style: {
              ...E,
              gap: `${c}px`
            },
            children: C.map((n, r) => l("div", {
              className: s(e.slideCarouselSlide, "slider__slide"),
              style: {
                flex: `0 0 ${j}`
              },
              children: n
            }, r))
          })
        })]
      }), W()]
    }), q()]
  });
};
export {
  de as SlideCarousel
};
