"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatRelativeTime = formatRelativeTime;
exports.truncateText = truncateText;
/**
 * Format a timestamp to a relative time string
 */
function formatRelativeTime(isoString) {
    if (!isoString) {
        return '';
    }
    var date = new Date(isoString);
    var now = new Date();
    var diffMs = now.getTime() - date.getTime();
    var diffMins = Math.floor(diffMs / 60000);
    var diffHours = Math.floor(diffMins / 60);
    var diffDays = Math.floor(diffHours / 24);
    if (diffMins < 1) {
        return 'Just now';
    }
    else if (diffMins < 60) {
        return "".concat(diffMins, "m ago");
    }
    else if (diffHours < 24) {
        return "".concat(diffHours, "h ago");
    }
    else if (diffDays === 1) {
        return 'Yesterday';
    }
    else if (diffDays < 7) {
        return "".concat(diffDays, "d ago");
    }
    else {
        return date.toLocaleDateString();
    }
}
/**
 * Truncate text to a maximum length with ellipsis
 */
function truncateText(text, maxLength) {
    if (!text) {
        return 'No messages yet';
    }
    if (text.length <= maxLength) {
        return text;
    }
    return text.substring(0, maxLength - 3) + '...';
}
//# sourceMappingURL=utils.js.map