"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChatDate = ChatDate;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const hooks_1 = require("../../../hooks/index.js");
const cn_1 = require("../../../utils/cn.js");
const i18n_1 = require("./i18n/index.js");
require("./ChatDate.css");
const b = (0, cn_1.block)('chat-date');
/**
 * ChatDate component displays formatted dates with optional time
 *
 * @param props - Component props
 * @returns React component
 */
function ChatDate(props) {
    const { date, showTime = false, format, className, qa, relative = false, style } = props;
    const { formattedDate, formattedTime, fullDate, dateObject, isValid, diffDays } = (0, hooks_1.useDateFormatter)({
        date,
        format,
    });
    if (!isValid || !dateObject) {
        return (0, i18n_1.i18n)('invalid-date');
    }
    return ((0, jsx_runtime_1.jsx)("time", { className: b({}, className), dateTime: dateObject.toISOString(), title: fullDate, "data-qa": qa, style: style, children: relative && typeof diffDays === 'number' ? ((0, jsx_runtime_1.jsx)("span", { children: (0, i18n_1.i18n)('ago', { count: diffDays }) })) : ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { children: formattedDate }), (0, jsx_runtime_1.jsx)("span", { children: showTime && formattedTime && ` ${formattedTime}` })] })) }));
}
//# sourceMappingURL=ChatDate.js.map
