{"ast":null,"code":"import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Fragment as _Fragment } from \"react/jsx-runtime\";\nimport cn from 'classnames';\nimport Pagination from 'components/slideshow/Pagination';\nimport { useClientWidth } from 'hooks/useClientSize';\nimport { useEffect, useRef, useState } from 'react';\nimport styles from './SlideshowInline.module.scss'; // const ListArrow = ({ onClick, right }) => {\n//    return (\n//       <div className={cn(styles.arrowButtonCont, right && styles.arrowButtonContRight)}>\n//          <Button onClick={onClick} className={cn(styles.arrowButton)}>\n//             {right && <Arrow size='large' direction='right' />}\n//             {!right && <Arrow size='large' direction='left' />}\n//          </Button>\n//       </div>\n//    )\n// }\n\nvar SlideshowInline = function SlideshowInline(_ref) {\n  var className = _ref.className,\n      items = _ref.items,\n      renderItem = _ref.renderItem,\n      pagination = _ref.pagination,\n      onIndexChange = _ref.onIndexChange;\n\n  var _useState = useState(0),\n      index = _useState[0],\n      setIndex = _useState[1];\n\n  var scrollRef = useRef(null);\n  var clientWidth = useClientWidth();\n  var marginCoef = 1 / 32;\n  var margin = clientWidth * marginCoef;\n  var slideAndMarginWidth = clientWidth - margin;\n  useEffect(function () {\n    var onScroll = function onScroll(event) {\n      var newIndex = Math.floor((scrollRef.current.scrollLeft + 0.5 * slideAndMarginWidth) / slideAndMarginWidth);\n      setIndex(newIndex);\n      onIndexChange && onIndexChange(newIndex);\n    };\n\n    if (scrollRef && scrollRef.current) {\n      scrollRef.current.addEventListener('scroll', onScroll);\n    }\n\n    return function () {\n      scrollRef.current && scrollRef.current.removeEventListener('scroll', onScroll);\n    };\n  }, [scrollRef.current, clientWidth]);\n  return /*#__PURE__*/_jsxs(_Fragment, {\n    children: [/*#__PURE__*/_jsx(\"div\", {\n      ref: scrollRef,\n      className: cn(styles.slideshowContainer, className),\n      children: items && /*#__PURE__*/_jsx(\"ul\", {\n        className: cn(styles.slideshow),\n        style: {\n          width: slideAndMarginWidth * items.length\n        },\n        children: items.map(function (item, i) {\n          return renderItem(item, styles.slideshowItem, i);\n        })\n      })\n    }), pagination && /*#__PURE__*/_jsx(Pagination, {\n      items: items,\n      currentIndex: index,\n      className: cn(styles.pagination)\n    })]\n  });\n};\n\nexport default SlideshowInline;","map":null,"metadata":{},"sourceType":"module"}