const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_index = require("../iconfont/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
let swiper = require("swiper");
require("swiper/swiper-bundle.css");
require("./index.less");
//#region src/components/pisellImageCarousels/index.tsx
const PisellImageCarousels = ({ dataSource = [], width = 640, height = 400, showArrows = true, showDots = true, autoplay = true, interval = 3e3, borderRadius = 8, loop = true, className, style }) => {
	const swiperRef = (0, react.useRef)(null);
	const swiperInstance = (0, react.useRef)(null);
	(0, react.useEffect)(() => {
		if (swiperRef.current) swiperInstance.current = new swiper.Swiper(swiperRef.current, {
			modules: [
				swiper.Navigation,
				swiper.Pagination,
				swiper.Autoplay
			],
			slidesPerView: 1,
			spaceBetween: 0,
			loop,
			navigation: showArrows ? {
				nextEl: ".pisell-carousel-next",
				prevEl: ".pisell-carousel-prev"
			} : false,
			pagination: showDots ? {
				el: ".pisell-carousel-pagination",
				clickable: true
			} : false,
			autoplay: autoplay ? {
				delay: interval,
				disableOnInteraction: false
			} : false
		});
		return () => {
			if (swiperInstance.current) swiperInstance.current.destroy();
		};
	}, [
		showArrows,
		showDots,
		autoplay,
		interval,
		loop
	]);
	return /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)("pisell-image-carousel", className),
		style: require_objectSpread2._objectSpread2({
			width,
			height
		}, style)
	}, /* @__PURE__ */ react.default.createElement("div", {
		className: "swiper",
		ref: swiperRef
	}, /* @__PURE__ */ react.default.createElement("div", { className: "swiper-wrapper" }, dataSource === null || dataSource === void 0 ? void 0 : dataSource.map((item, index) => /* @__PURE__ */ react.default.createElement("div", {
		key: index,
		className: "swiper-slide"
	}, /* @__PURE__ */ react.default.createElement(antd.Image, {
		preview: false,
		src: item,
		width,
		height,
		loading: "lazy",
		style: { borderRadius: `${borderRadius}px` }
	})))), showArrows && /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-carousel-prev" }, /* @__PURE__ */ react.default.createElement("span", { className: "carousel-arrow" }, /* @__PURE__ */ react.default.createElement(require_index.default, { type: "pisell2-chevron-left" }))), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-carousel-next" }, /* @__PURE__ */ react.default.createElement("span", { className: "carousel-arrow" }, /* @__PURE__ */ react.default.createElement(require_index.default, { type: "pisell2-chevron-right" })))), showDots && /* @__PURE__ */ react.default.createElement("div", { className: "pisell-carousel-pagination" })));
};
//#endregion
exports.default = PisellImageCarousels;
