import { useCallback, useState } from 'react';
import { useMount } from '@redocly/theme/core/openapi';
export function useTabsState({ tabs, defaultTab, onChange }) {
    const [activeTab, setActiveTab] = useState(defaultTab || tabs[0].key);
    useMount(() => {
        if (defaultTab) {
            setActiveTab(defaultTab);
            onChange?.(defaultTab);
        }
    });
    const handleTabChange = useCallback((tab) => {
        if (activeTab !== tab.key) {
            setActiveTab(tab.key);
        }
        onChange?.(tab.key);
    }, [activeTab, onChange]);
    return {
        activeTab,
        handleTabChange,
    };
}
//# sourceMappingURL=useTabsState.js.map