import { tabsData } from "./XTabs";
import type { TabSlug, } from "./types";

export function getTabSlugFromUrl(): TabSlug {
    const defaultTab = tabsData[0].slug;
    if (typeof window === "undefined") return defaultTab;
    const params = new URLSearchParams(window.location.search);
    const tab = params.get('tab');
    const allowed = tabsData.map((tab: any) => tab.slug);
    const returnValue = allowed.includes(tab as TabSlug) ? (tab as TabSlug) : defaultTab;
    console.log('getTabSlugFromUrl', returnValue);
    return returnValue;
}
