import {map} from "lodash";
import {TabsProps} from "./tabs";
import {fieldMeta} from "../cards";

export const mapFromMeta = (meta: fieldMeta) => map(meta._allowed, (id: string, label: string) => {
    return {
        id,
        label,
        subLabel: meta.alternativeLabels?.[`${id}`],
        tabDescription: meta.labelDescriptions?.[`${id}`],
        isPreview: meta.isPreview?.[`${id}`],
        disabled: typeof meta.isImplemented === "boolean"? !meta.isImplemented : (meta.isImplemented?.[`${id}`] === false),
    }
}).filter(({id}) => Array.isArray(meta.display) ? meta.display.includes(id) : true) as TabsProps['tabs']