"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get deprecatedWarn () {
        return deprecatedWarn;
    },
    get error () {
        return error;
    },
    get info () {
        return info;
    },
    get log () {
        return log;
    },
    get logAggregatedItems () {
        return logAggregatedItems;
    },
    get warn () {
        return warn;
    }
});
const _string = require("./string");
const _mixed = require("./mixed");
function log(...args) {
    if ((0, _mixed.isDefined)(console)) {
        console.log(...args);
    }
}
function warn(...args) {
    if ((0, _mixed.isDefined)(console)) {
        console.warn(...args);
    }
}
function deprecatedWarn(message) {
    if ((0, _mixed.isDefined)(console)) {
        console.warn(`Deprecated: ${message}`);
    }
}
function info(...args) {
    if ((0, _mixed.isDefined)(console)) {
        console.info(...args);
    }
}
function error(...args) {
    if ((0, _mixed.isDefined)(console)) {
        console.error(...args);
    }
}
function logAggregatedItems({ logFunction = log, message, items, maxSample = 5, itemFormatter = (item)=>`${item}` } = {}) {
    if (!Array.isArray(items) || items.length === 0) {
        return;
    }
    const count = items.length;
    const formattedItems = items.slice(0, maxSample).map((item)=>`  - ${itemFormatter(item)}`);
    const more = count > maxSample ? `  - ...and ${count - maxSample} more` : '';
    const affectedLines = [
        'Affected cells:',
        ...formattedItems,
        ...more ? [
            more
        ] : []
    ].join('\n');
    logFunction((0, _string.substitute)(message, {
        itemsCount: `${count} cell${count > 1 ? 's' : ''}`,
        affectedCells: affectedLines
    }));
}
