import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2021-2026 GoodData Corporation
import { useCallback } from "react";
import { useIntl } from "react-intl";
import { BackButton } from "../../BackButton.js";
import { ConfirmDialogBase } from "../../ConfirmDialogBase.js";
import { ContentDivider } from "../../ContentDivider.js";
import { AddGranteeContent } from "./AddGranteeContent.js";
/**
 * @internal
 */
export function AddGranteeBase({ appliedGrantees, addedGrantees, currentUser, isDirty, currentUserPermissions, sharedObject, previouslyFocusedRef, onCancel, onSubmit, onBackClick, onAddUserOrGroups, onDelete, onGranularGranteeChange, isGranteeShareLoading, }) {
    const intl = useIntl();
    const { isLocked: isSharedObjectLocked, ref: sharedObjectRef, areGranularPermissionsSupported, } = sharedObject;
    const backButtonRenderer = useCallback(() => {
        return _jsx(BackButton, { onClick: onBackClick ?? (() => { }), className: "s-share-dialog-navigate-back" });
    }, [onBackClick]);
    return (_jsxs(ConfirmDialogBase, { className: "gd-share-dialog gd-share-dialog-add-users s-gd-share-add-grantees", displayCloseButton: true, isPositive: true, isSubmitDisabled: !isDirty, headline: intl.formatMessage({ id: "shareDialog.share.grantee.add.info" }), cancelButtonText: intl.formatMessage({ id: "cancel" }), submitButtonText: intl.formatMessage({ id: "shareDialog.share.grantee.share" }), submitOnEnterKey: false, shouldCloseOnEscape: true, returnFocusTo: previouslyFocusedRef, onCancel: onBackClick, onSubmit: onSubmit, onClose: onCancel, headerLeftButtonRenderer: backButtonRenderer, children: [
            _jsx(AddGranteeContent, { currentUserPermissions: currentUserPermissions, isSharedObjectLocked: isSharedObjectLocked, currentUser: currentUser, addedGrantees: addedGrantees, appliedGrantees: appliedGrantees, areGranularPermissionsSupported: areGranularPermissionsSupported, sharedObjectRef: sharedObjectRef, onAddUserOrGroups: onAddUserOrGroups ?? (() => { }), onDelete: onDelete, onGranularGranteeChange: onGranularGranteeChange, isGranteeShareLoading: isGranteeShareLoading }), _jsx(ContentDivider, {})
        ] }));
}
