import { jsxs, jsx } from 'react/jsx-runtime';
import classNames from '../../_virtual/index.js';
import Typography from '../Typography/Typography.js';
import Icon from '../Icon/Icon.js';
import { useState } from 'react';
import Tooltip from '../Tooltip/Tooltip.js';

const TabsWithSilder = ({ variant = 'default', tabsData, activeTabId, onTabClick, noBorder = false, noPadding = false, titleSize = '12px', }) => {
    const [currentSlide, setCurrentSlide] = useState(0);
    const tabsPerSlide = 4; // as confirmed there should be 4 tabs per slide
    const handleNext = () => {
        if (currentSlide < Math.ceil(tabsData.length / tabsPerSlide) - 1) {
            setCurrentSlide((prev) => prev + 1);
        }
    };
    const handlePrev = () => {
        if (currentSlide > 0) {
            setCurrentSlide((prev) => prev - 1);
        }
    };
    return (jsxs("div", { className: `ff-tabs-slider-container`, children: [jsxs("div", { className: classNames(`ff-tab-row--${variant} ff-tab-row-section`, {
                    'ff-tab-row--no-border': noBorder,
                    'ff-tab-row--no-padding': noPadding,
                    'ff-tab-row--position': tabsData.length > tabsPerSlide,
                }), children: [tabsData.length > tabsPerSlide && (jsx(Icon, { className: "ff-tab-icon ff-tab-icon--previous", name: `${currentSlide ? 'arrow_left_accordian' : ''}`, onClick: handlePrev, hoverEffect: true })), jsx("div", { className: "ff-tab-row-carousel", children: jsx("div", { className: 'carousel_inner', style: {
                                transform: `translateX(-${currentSlide * 100}%)`,
                            }, children: tabsData.map((tab) => (jsxs("button", { onClick: () => !tab.disabled && onTabClick(tab.id), disabled: tab.disabled, className: classNames(`ff-tab-button--${variant}`, {
                                    disabled: tab.disabled,
                                    active: activeTabId === tab.id,
                                }), style: {
                                    flex: `0 0 ${100 / tabsPerSlide}%`,
                                }, children: [jsxs("div", { className: "label-count-section", children: [jsx(Tooltip, { title: tab.label.length > 9 ? tab.label : '', children: jsx(Typography, { children: tab.label.length > 9
                                                        ? tab.label.slice(0, 9) + '...'
                                                        : tab.label, fontSize: titleSize, lineHeight: "18px", fontWeight: activeTabId === tab.id ? 'semi-bold' : 'regular', color: activeTabId === tab.id
                                                        ? 'var(--tabs-label-active-color)'
                                                        : 'var(--tabs-label-default-color)', className: classNames('ff-tab-label', {
                                                        'ff-tab-label--active': activeTabId === tab.id,
                                                    }) }) }), variant === 'default' && tab.count && (jsx("span", { className: classNames('tab-count', {
                                                    'tab-count--active': activeTabId === tab.id,
                                                }), children: tab.count }))] }), jsx("div", { className: classNames('ff-tab-bar', {
                                            'ff-tab-bar--active': activeTabId === tab.id,
                                        }) }), jsx("span", { className: `ff-defaultStatus ${tab.status === 'success'
                                            ? 'ff-successStatus'
                                            : tab.status === 'error'
                                                ? 'ff-dangerStatus'
                                                : ''}` })] }, tab.id))) }) }), tabsData.length > tabsPerSlide && (jsx(Icon, { className: "ff-tab-icon ff-tab-icon--next", name: `${currentSlide < Math.ceil(tabsData.length / tabsPerSlide) - 1
                            ? 'arrow_right_icon'
                            : ''}`, onClick: handleNext, hoverEffect: true }))] }), jsx("div", { className: `ff-tab-content`, children: tabsData.find((tab) => tab.id === activeTabId)?.component })] }));
};

export { TabsWithSilder as default };
//# sourceMappingURL=TabsWithSilder.js.map
