"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const hljs = require("highlight.js");
const JSON5 = require("json5");
/**
 * Message is an enum of the possible message types recorded in the logs.
 */
var Message;
(function (Message) {
    Message[Message["SentMethod"] = 0] = "SentMethod";
    Message[Message["ReceivedMethod"] = 1] = "ReceivedMethod";
    Message[Message["SentReply"] = 2] = "SentReply";
    Message[Message["ReceivedReply"] = 3] = "ReceivedReply";
    Message[Message["Log"] = 4] = "Log";
})(Message = exports.Message || (exports.Message = {}));
/**
 * Creates a short message line with its contents formatted as pretty JSON.
 * Limits the content to around `contentLimit`.
 */
function messageLine(prefix, body, contentLimit = 150) {
    if (body == null) {
        return `${prefix}()`;
    }
    let text = JSON5.stringify(body);
    const sliced = text.length > contentLimit * 1.25;
    if (sliced) {
        text = text.slice(0, contentLimit);
    }
    return `${prefix}(${hljs.highlight('js', text).value}${sliced ? '...' : ')'}`;
}
exports.messageLine = messageLine;
/**
 * Truncates the line with ellipses if it's too far over
 * the target content length.
 */
function truncateLine(text, contentLimit = 150) {
    if (text.length > contentLimit * 1.25) {
        text = `${text.slice(0, contentLimit)}...`;
    }
    return text;
}
exports.truncateLine = truncateLine;
