import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2026 GoodData Corporation
import { useIntl } from "react-intl";
import { useIdPrefixed } from "../../utils/useId.js";
import { bem } from "../@utils/bem.js";
import { UiDate } from "../UiDate/UiDate.js";
import { UiIcon } from "../UiIcon/UiIcon.js";
import { UiTooltip } from "../UiTooltip/UiTooltip.js";
const { b, e } = bem("gd-ui-kit-certification-icon");
/**
 * @internal
 */
export function UiCertificationIcon({ certification, size, tabIndex = 0, accessibilityConfig, }) {
    const intl = useIntl();
    const tooltipId = useIdPrefixed("certification-tooltip");
    const certificationAriaLabel = accessibilityConfig?.ariaLabel ?? intl.formatMessage({ id: "uiKit.certification.tooltip.title" });
    const icon = (_jsx("span", { tabIndex: tabIndex, "aria-label": certificationAriaLabel, "aria-describedby": tooltipId, children: _jsx(UiIcon, { type: "certification", size: size ?? 16, backgroundSize: 26, color: "success", layout: "block", accessibilityConfig: { ariaHidden: true } }) }));
    return (_jsx("div", { className: b(), children: _jsx(UiTooltip, { id: tooltipId, arrowPlacement: "top", optimalPlacement: true, triggerBy: ["hover", "focus"], variant: "none", showArrow: false, width: 200, offset: -6, anchor: icon, content: _jsxs("div", { className: e("tooltip"), children: [
                    _jsxs("div", { className: e("tooltip-header"), children: [
                            _jsx(UiIcon, { type: "certification", size: 14, color: "success", layout: "block" }), _jsx("span", { className: e("tooltip-title"), children: intl.formatMessage({ id: "uiKit.certification.tooltip.title" }) })
                        ] }), certification.message ? (_jsx("div", { className: e("tooltip-message"), children: certification.message })) : null, certification.certifiedBy ? (_jsxs(_Fragment, { children: [
                            _jsx("div", { className: e("tooltip-date"), children: intl.formatMessage({ id: "uiKit.certification.tooltip.certifiedBy" }) }), _jsx("div", { className: e("tooltip-date-value"), children: certification.certifiedBy })
                        ] })) : null, certification.certifiedAt ? (_jsxs(_Fragment, { children: [
                            _jsx("div", { className: e("tooltip-date"), children: intl.formatMessage({ id: "uiKit.certification.tooltip.certifiedAt" }) }), _jsx("div", { className: e("tooltip-date-value"), children: _jsx(UiDate, { date: certification.certifiedAt, locale: intl.locale, allowRelative: false }) })
                        ] })) : null] }) }) }));
}
