"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useScrollToActiveTab = void 0;
const react_1 = require("react");
const useViewportType_1 = require("../../../useViewportType");
const useScrollToActiveTab = () => {
    const containerRef = (0, react_1.useRef)(null);
    const { isMobile } = (0, useViewportType_1.useViewportType)();
    (0, react_1.useEffect)(() => {
        if (!containerRef.current || !isMobile) {
            return;
        }
        const selectedTab = containerRef.current.querySelector('[aria-selected="true"]');
        const runScroll = () => {
            if (selectedTab) {
                selectedTab.scrollIntoView({
                    behavior: 'smooth',
                });
            }
        };
        // TODO: Убрать setTimeout после отказа от MUI в компоненте
        setTimeout(() => {
            runScroll();
        }, 200);
    }, []);
    return { containerRef };
};
exports.useScrollToActiveTab = useScrollToActiveTab;
