import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useIntl } from "react-intl";
import { commonDialogMessages, olpObjectShareDialogMessages } from "../../locales.js";
import { bem } from "../@utils/bem.js";
import { UiButton } from "../UiButton/UiButton.js";
import { UiGeneralAccessRadio, } from "../UiGeneralAccessRadio/UiGeneralAccessRadio.js";
import { UiGranteeRow } from "../UiGranteeRow/UiGranteeRow.js";
import { UiDialogFooter } from "../UiModalDialog/UiDialogFooter.js";
import { UiDialogHeader } from "../UiModalDialog/UiDialogHeader.js";
import { UiSectionHeading } from "../UiSectionHeading/UiSectionHeading.js";
const { b, e } = bem("gd-ui-kit-object-share-dialog");
/**
 * Object share dialog card — header, grantee list, general-access radio,
 * footer Close button. Renders inline as a plain card. For modal behavior
 * (portal, backdrop, focus trap, dismiss), use `UiObjectShareDialog`
 * which wraps this in `UiModalDialog`.
 *
 * @internal
 */
export function UiObjectShareDialogCard({ objectTitle, onClose, grantees, onAddClick, isAddDisabled, generalAccess, onGeneralAccessChange, isGeneralAccessDisabled, workspaceAccessInherited, workspaceControls, workspaceLevel, error, dataTestId, }) {
    const intl = useIntl();
    const dialogTitle = intl.formatMessage(olpObjectShareDialogMessages.title, { title: objectTitle });
    return (_jsxs("div", { className: b(), "data-testid": dataTestId, children: [
            _jsx(UiDialogHeader, { title: dialogTitle, onClose: onClose }), error ? (_jsx("div", { className: e("error"), role: "alert", children: error })) : (_jsxs(_Fragment, { children: [
                    _jsx(UiSectionHeading, { label: intl.formatMessage(olpObjectShareDialogMessages.sharedWith), action: _jsx(UiButton, { label: intl.formatMessage(olpObjectShareDialogMessages.add), variant: "popout", size: "small", iconBefore: "plus", isDisabled: isAddDisabled, onClick: onAddClick }) }), _jsx("div", { className: e("grantees"), children: grantees.map((grantee) => (_jsx(UiGranteeRow, { kind: grantee.kind, name: grantee.name, email: grantee.email, isOwner: grantee.isOwner, isPending: grantee.isPending, controls: grantee.controls }, grantee.id))) }), _jsx(UiSectionHeading, { label: intl.formatMessage(olpObjectShareDialogMessages.generalAccess) }), _jsx(UiGeneralAccessRadio, { value: generalAccess, onChange: onGeneralAccessChange, disabled: isGeneralAccessDisabled, workspaceAccessInherited: workspaceAccessInherited, workspaceControls: workspaceControls, workspaceLevel: workspaceLevel })
                ] })), _jsx(UiDialogFooter, { divider: true, children: _jsx(UiButton, { label: intl.formatMessage(commonDialogMessages.close), variant: "secondary", size: "medium", onClick: onClose }) })
        ] }));
}
