import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2020-2025 GoodData Corporation
import { useCallback } from "react";
import { FormattedMessage } from "react-intl";
import { areObjRefsEqual, objRefToString } from "@gooddata/sdk-model";
import { AttributeUrlSectionItem } from "./AttributeUrlSectionItem.js";
import { DropdownSectionHeader } from "./DropdownSectionHeader.js";
export function AttributeUrlSection({ attributeDisplayForms, loading = false, selected, onSelect, }) {
    const onClickHandler = useCallback((target) => {
        onSelect(target.attributeDisplayFormRef, target.displayForm.ref);
    }, [onSelect]);
    if (!loading && attributeDisplayForms.length === 0) {
        return null;
    }
    return (_jsxs(_Fragment, { children: [
            _jsx(DropdownSectionHeader, { className: "s-drill-to-attribute-url-section-title", children: _jsx(FormattedMessage, { id: "configurationPanel.drillIntoUrl.attributeUrlSectionTitle" }) }), loading ? (_jsx("div", { className: "gd-drill-to-url-section-loading s-drill-to-attribute-url-section-loading", children: _jsx("div", { className: "gd-spinner small" }) })) : (_jsx("div", { className: "gd-drill-to-url-section-items", children: attributeDisplayForms.map((item) => (_jsx(AttributeUrlSectionItem, { item: item, isSelected: areObjRefsEqual(item.displayForm.ref, selected || undefined), onClickHandler: onClickHandler }, objRefToString(item.displayForm.ref)))) }))] }));
}
//# sourceMappingURL=AttributeUrlSection.js.map