import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2021-2025 GoodData Corporation
import { useMemo } from "react";
import { DataSourceItem } from "./DataSourceItem.js";
import { DataSourceListEmpty } from "./DataSourceListEmpty.js";
import { sortByName } from "../utils.js";
export function DataSourceList({ dataSources, subjectType, mode, onChange, onDelete, renderDataSourceIcon, }) {
    const sortedDataSources = useMemo(() => {
        return dataSources ? [...dataSources].sort(sortByName) : [];
    }, [dataSources]);
    if (sortedDataSources.length === 0) {
        return _jsx(DataSourceListEmpty, { mode: mode, subjectType: subjectType });
    }
    return (_jsx("div", { className: "gd-share-dialog-grantee-list s-user-management-data-sources", children: sortedDataSources.map((dataSource) => {
            return (_jsx(DataSourceItem, { dataSource: dataSource, subjectType: subjectType, onChange: onChange, onDelete: onDelete, renderDataSourceIcon: renderDataSourceIcon }, dataSource.id));
        }) }));
}
//# sourceMappingURL=DataSourceList.js.map