import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { FormattedMessage, defineMessages } from "react-intl";
import { DRILL_TO_URL_PLACEHOLDER } from "../../../../../model/types/drillTypes.js";
import { DropdownSectionHeader } from "../DropdownSectionHeader.js";
import { ClientIdParameterDetail } from "../ParameterDetails/ClientIdParameterDetail.js";
import { DashboardIdParameterDetail } from "../ParameterDetails/DashboardIdParameterDetail.js";
import { DataProductIdParameterDetail } from "../ParameterDetails/DataProductIdParameterDetail.js";
import { InsightIdParameterDetail } from "../ParameterDetails/InsightIdParameterDetail.js";
import { ProjectIdParameterDetail } from "../ParameterDetails/ProjectIdParameterDetail.js";
import { WidgetIdParameterDetail } from "../ParameterDetails/WidgetIdParameterDetail.js";
import { Parameter } from "./Parameter.js";
const identifierParametersMessages = defineMessages({
    insightIdParameterLabel: { id: "configurationPanel.drillIntoUrl.editor.insightIdParameterLabel" },
    widgetIdParameterLabel: { id: "configurationPanel.drillIntoUrl.editor.widgetIdParameterLabel" },
    dashboardIdParameterLabel: { id: "configurationPanel.drillIntoUrl.editor.dashboardIdParameterLabel" },
    projectIdParameterLabel: { id: "configurationPanel.drillIntoUrl.editor.projectIdParameterLabel" },
    workspaceIdParameterLabel: { id: "configurationPanel.drillIntoUrl.editor.workspaceIdParameterLabel" },
    clientIdParameterLabel: { id: "configurationPanel.drillIntoUrl.editor.clientIdParameterLabel" },
    dataProductIdParameterLabel: { id: "configurationPanel.drillIntoUrl.editor.dataProductIdParameterLabel" },
});
const identifierParametersSection = [
    {
        titleIntlKey: identifierParametersMessages.insightIdParameterLabel.id,
        placeholder: DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_INSIGHT_ID,
    },
    {
        titleIntlKey: identifierParametersMessages.widgetIdParameterLabel.id,
        placeholder: DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_WIDGET_ID,
    },
    {
        titleIntlKey: identifierParametersMessages.dashboardIdParameterLabel.id,
        placeholder: DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_DASHBOARD_ID,
    },
    {
        titleIntlKey: identifierParametersMessages.projectIdParameterLabel.id,
        placeholder: DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_PROJECT_ID,
    },
    {
        titleIntlKey: identifierParametersMessages.workspaceIdParameterLabel.id,
        placeholder: DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_WORKSPACE_ID,
    },
    {
        titleIntlKey: identifierParametersMessages.clientIdParameterLabel.id,
        placeholder: DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_CLIENT_ID,
    },
    {
        titleIntlKey: identifierParametersMessages.dataProductIdParameterLabel.id,
        placeholder: DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_DATA_PRODUCT_ID,
    },
];
const getDetailContent = (type, title, widgetRef) => {
    switch (type) {
        case DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_PROJECT_ID:
        case DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_WORKSPACE_ID:
            return _jsx(ProjectIdParameterDetail, { title: title });
        case DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_DASHBOARD_ID:
            return _jsx(DashboardIdParameterDetail, { title: title });
        case DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_WIDGET_ID:
            return _jsx(WidgetIdParameterDetail, { title: title, widgetRef: widgetRef });
        case DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_INSIGHT_ID:
            return _jsx(InsightIdParameterDetail, { title: title, widgetRef: widgetRef });
        case DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_CLIENT_ID:
            return _jsx(ClientIdParameterDetail, { title: title });
        case DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_DATA_PRODUCT_ID:
            return _jsx(DataProductIdParameterDetail, { title: title });
        default:
            return _jsx(_Fragment, {});
    }
};
export function IdentifierParametersSection({ enableClientIdParameter, enableDataProductIdParameter, enableWidgetIdParameter, onAdd, intl, widgetRef, }) {
    return (_jsxs(_Fragment, { children: [
            _jsx(DropdownSectionHeader, { children: _jsx(FormattedMessage, { id: "configurationPanel.drillIntoUrl.editor.identifierParametersSectionLabel" }) }), identifierParametersSection
                .filter(({ placeholder }) => placeholder !==
                DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_CLIENT_ID ||
                enableClientIdParameter)
                .filter(({ placeholder }) => placeholder !==
                DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_WIDGET_ID ||
                enableWidgetIdParameter)
                .filter(({ placeholder }) => placeholder !==
                DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_DATA_PRODUCT_ID ||
                enableDataProductIdParameter)
                .filter(({ placeholder }) => placeholder !==
                DRILL_TO_URL_PLACEHOLDER.DRILL_TO_URL_PLACEHOLDER_PROJECT_ID)
                .map(({ placeholder, titleIntlKey }) => {
                const title = intl.formatMessage({ id: titleIntlKey });
                return (_jsx(Parameter, { name: title, detailContent: getDetailContent(placeholder, title, widgetRef), iconClassName: "gd-icon-sharp", onAdd: () => onAdd(placeholder), intl: intl }, placeholder));
            })] }));
}
