import VmsVideo from '@wisdom-components/VmsVideo';
import { Button, Modal } from 'antd';
import classNames from 'classnames';
import React, { useState } from 'react';
import SwiperCore, { Autoplay, Lazy, Navigation, Pagination, Virtual } from 'swiper';
import { Swiper, SwiperSlide } from 'swiper/react';
import 'swiper/swiper.min.css';
import styles from './index.less';

SwiperCore.use([Virtual, Navigation, Lazy, Autoplay, Pagination]);

const VideoSliderModal = (props) => {
  const { modalInfo, videoInfos, JessibucaObj } = props;
  const [swiper, setSwiper] = useState(null);

  const handleSwiperRef = (node) => {
    if (node) {
      setSwiper(node.swiper);
    }
  };

  const handleNavigation = (direction) => {
    if (swiper) {
      if (direction === 'prev') {
        swiper.slidePrev();
      } else if (direction === 'next') {
        swiper.slideNext();
      }
    }
  };

  const handlePaginationClick = (index) => {
    if (swiper) {
      swiper.slideTo(index);
    }
  };

  const _JessibucaObj = {
    operateBtns: {
      screenshot: false,
    },
    loadingText: '演示视频加载中',
    decoder: '/JessibucaVideo/decoder.js',
    ...JessibucaObj,
  };

  return (
    <Modal
      footer={null}
      width={800}
      {...modalInfo}
      wrapClassName={styles['video-carousel-modal']}
      bodyStyle={{ padding: 0 }}
    >
      <Swiper onSwiper={handleSwiperRef} navigation pagination={{ clickable: true }}>
        {videoInfos.map((videoInfo, index) => (
          <SwiperSlide key={index}>
            <VmsVideo VideoInfo={videoInfo} JessibucaObj={_JessibucaObj} />
          </SwiperSlide>
        ))}
      </Swiper>
      {/* <div>
        <button onClick={() => handleNavigation('prev')}>Previous</button>
        <button onClick={() => handleNavigation('next')}>Next</button>
      </div>
      <div>
        {videoInfos.map((video, index) => (
          <button key={index} onClick={() => handlePaginationClick(index)}>
            {index + 1}
          </button>
        ))}
      </div> */}
    </Modal>
  );
};

export default VideoSliderModal;
