import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2020-2026 GoodData Corporation
import { useIntl } from "react-intl";
import { dashboardAttributeFilterItemTitle, } from "@gooddata/sdk-model";
import { useWorkspaceStrict } from "@gooddata/sdk-ui";
import { useDashboardSelector } from "../../../../../model/react/DashboardStoreProvider.js";
import { selectAllCatalogAttributesMap } from "../../../../../model/store/catalog/catalogSelectors.js";
import { selectFilterContextAttributeFilterItemByDisplayForm } from "../../../../../model/store/tabs/filterContext/filterContextSelectors.js";
import { AttributeDisplayFormParameterDetail } from "../ParameterDetails/AttributeDisplayFormParameterDetail.js";
import { Parameter } from "./Parameter.js";
export function DisplayFormParam({ item, onAdd, iconClassName, isFilter }) {
    const x = useDashboardSelector(selectAllCatalogAttributesMap);
    const y = x.get(item.attribute);
    const intl = useIntl();
    const projectId = useWorkspaceStrict();
    const dashboardFilter = useDashboardSelector(selectFilterContextAttributeFilterItemByDisplayForm(item.ref));
    const defaultTitle = y?.attribute.title || "";
    const filterTitle = dashboardFilter ? dashboardAttributeFilterItemTitle(dashboardFilter) : undefined;
    return (_jsx(Parameter, { name: isFilter ? (filterTitle ?? defaultTitle) : defaultTitle, description: item.title, detailContent: _jsx(AttributeDisplayFormParameterDetail, { title: y?.attribute.title || "", label: item.title, type: item.displayFormType, projectId: projectId, displayFormRef: item.ref, showValues // TODO
            : true }), iconClassName: iconClassName ?? getDisplayFormIcon(item.displayFormType), onAdd: () => onAdd(`{attribute_title(${item.id})}`), intl: intl }, item.id));
}
const getDisplayFormIcon = (type) => {
    switch (type) {
        case "GDC.link":
            return "gd-icon-hyperlink-warning";
        case "GDC.image":
            return "gd-icon-image";
        case "GDC.geo.pin":
        case "GDC.geo.pin_latitude":
        case "GDC.geo.pin_longitude":
            return "gd-icon-earth";
        default:
            return "gd-icon-label-warning";
    }
};
//# sourceMappingURL=DisplayFormParam.js.map