import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2025-2026 GoodData Corporation
import { defineMessages, useIntl } from "react-intl";
import { LoadingSpinner, UiIcon } from "@gooddata/sdk-ui-kit";
import { KdaDialogActionButtons } from "./KdaDialogActionButtons.js";
const floatingStatusMessages = defineMessages({
    step01: { id: "kdaDialog.floatingStatus.step1" },
    step02: { id: "kdaDialog.floatingStatus.step2" },
    done: { id: "kdaDialog.floatingStatus.done" },
    error: { id: "kdaDialog.floatingStatus.error" },
});
/**
 * @internal
 */
export function KdaDialogFloatingStatusBar({ onClose, status, titleElementId, }) {
    const intl = useIntl();
    const statusText = intl.formatMessage(floatingStatusMessages[status]);
    return (_jsxs("div", { className: "gd-kda-floating-status-bar", children: [
            _jsx("div", { className: "sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true", children: status === "done" || status === "error" ? statusText : null }), _jsxs("div", { className: "gd-kda-floating-status-bar__content", children: [
                    _jsx(StatusIndicator, { status: status }), _jsx("p", { className: "gd-kda-floating-status-bar__text", id: titleElementId, tabIndex: 0, children: statusText })
                ] }), _jsx(KdaDialogActionButtons, { size: "small", status: status, titleElementId: titleElementId, onClose: onClose })
        ] }));
}
function StatusIndicator({ status }) {
    if (status === "error") {
        return _jsx(UiIcon, { type: "crossCircle", color: "currentColor", size: 16, layout: "block" });
    }
    if (status === "done") {
        return _jsx(UiIcon, { type: "checkCircle", color: "currentColor", size: 16, layout: "block" });
    }
    return _jsx(LoadingSpinner, { className: "small gd-kda-floating-status-bar__spinner", color: "currentColor" });
}
export function getFloatingStatus(relevantStatus, itemsStatus, selectedStatus) {
    if (relevantStatus === "error" || itemsStatus === "error" || selectedStatus === "error") {
        return "error";
    }
    if (relevantStatus === "pending" || relevantStatus === "loading") {
        return "step01";
    }
    if (itemsStatus === "pending" ||
        itemsStatus === "loading" ||
        selectedStatus === "pending" ||
        selectedStatus === "loading") {
        return "step02";
    }
    return "done";
}
//# sourceMappingURL=KdaDialogFloatingStatusBar.js.map