import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2023-2025 GoodData Corporation
import { useCallback } from "react";
import { useIntl } from "react-intl";
import { BackButton, ConfirmDialogBase } from "@gooddata/sdk-ui-kit";
import { AddDataSourceSelect } from "./AddDataSourceSelect.js";
import { DataSourceList } from "./DataSourceList.js";
import { useAddDataSource } from "./useAddDataSource.js";
import { messages } from "../locales.js";
export function AddDataSource({ ids, subjectType, grantedDataSources, enableBackButton, onSubmit, onCancel, onClose, renderDataSourceIcon, }) {
    const intl = useIntl();
    const { addedDataSources, isProcessing, onAdd, onDelete, onChange, onSelect } = useAddDataSource(ids, subjectType, onSubmit, onCancel);
    const backButtonRenderer = useCallback(() => {
        return _jsx(BackButton, { onClick: onCancel, className: "s-user-management-navigate-back" });
    }, [onCancel]);
    return (_jsxs(ConfirmDialogBase, { className: "gd-share-dialog gd-share-dialog-add-users s-user-management-add-data-source", displayCloseButton: true, isPositive: true, isSubmitDisabled: addedDataSources.length === 0 || isProcessing, showProgressIndicator: isProcessing, headline: intl.formatMessage(messages.addDataSourceDialogTitle), cancelButtonText: intl.formatMessage(messages.addWorkspaceDialogCloseButton), submitButtonText: intl.formatMessage(messages.addWorkspaceDialogSaveButton), onCancel: onCancel, onSubmit: onAdd, onClose: onClose, headerLeftButtonRenderer: enableBackButton ? backButtonRenderer : undefined, children: [
            _jsx(AddDataSourceSelect, { addedDataSources: addedDataSources, grantedDataSources: grantedDataSources, onSelectDataSource: onSelect }), _jsx(DataSourceList, { subjectType: subjectType, mode: "EDIT", dataSources: addedDataSources, onDelete: onDelete, onChange: onChange, renderDataSourceIcon: renderDataSourceIcon })
        ] }));
}
//# sourceMappingURL=AddDataSource.js.map