import React from "react";
import { Tag } from "@carbon/react";
import { useC3Profile } from "../c3-user-configuration/c3-profile-provider/c3-profile-provider";
export const C3ClusterTag = (props) => {
    const { clusters } = useC3Profile();
    return "stage" in props ? (React.createElement(Tag, { type: getColorForStage(props.stage) }, props.stage)) : "clusterUuid" in props ? (generateFromInput({
        clusterUuid: props.clusterUuid,
        allClusters: clusters,
        conditionalRendering: props.conditionalRendering || (() => true),
    })) : (React.createElement(React.Fragment, null));
};
function generateFromInput(props) {
    const foundCluster = props.allClusters?.find((cluster) => cluster.uuid === props.clusterUuid);
    if (foundCluster?.labels?.camunda &&
        foundCluster?.labels?.camunda?.length > 0) {
        const label = foundCluster.labels.camunda[0];
        return getColorForStage(label) &&
            props.conditionalRendering(label) ? (React.createElement(Tag, { type: getColorForStage(label) }, label)) : (React.createElement(React.Fragment, null));
    }
    return React.createElement(React.Fragment, null);
}
function getColorForStage(stage) {
    switch (stage) {
        case "dev":
            return "green";
        case "test":
            return "blue";
        case "stage":
            return "purple";
        case "prod":
            return "red";
        default:
            return undefined;
    }
}
