"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.legendValueTitlesMap = exports.shouldDisplayGridList = exports.shouldDisplayTable = exports.LegendValue = void 0;
exports.isPosition = isPosition;
const common_1 = require("../utils/common");
function isPosition(value) {
    return Object.values(common_1.Position).includes(value);
}
exports.LegendValue = Object.freeze({
    CurrentAndLastValue: 'currentAndLastValue',
    LastValue: 'lastValue',
    LastNonNullValue: 'lastNonNullValue',
    Average: 'average',
    Median: 'median',
    Max: 'max',
    Min: 'min',
    FirstValue: 'firstValue',
    FirstNonNullValue: 'firstNonNullValue',
    Total: 'total',
    Count: 'count',
    DistinctCount: 'distinctCount',
    Variance: 'variance',
    StdDeviation: 'stdDeviation',
    Range: 'range',
    Difference: 'difference',
    DifferencePercent: 'differencePercent',
    Value: 'value',
    Percent: 'percent',
});
const shouldUseDefaultLayout = (legendPosition, legendLayout) => {
    if (legendLayout === undefined) {
        return true;
    }
    if (isPosition(legendPosition)) {
        return legendPosition === common_1.Position.Left || legendPosition === common_1.Position.Right;
    }
    return legendPosition.direction === common_1.LayoutDirection.Vertical;
};
const shouldDisplayTable = (legendValues, legendPosition, legendLayout) => {
    if (legendLayout === 'table') {
        return true;
    }
    else if (shouldUseDefaultLayout(legendPosition, legendLayout)) {
        return legendValues.some((v) => v !== exports.LegendValue.CurrentAndLastValue && v !== exports.LegendValue.Value);
    }
    return false;
};
exports.shouldDisplayTable = shouldDisplayTable;
const shouldDisplayGridList = (isTableView, legendPosition, legendLayout) => {
    if (isTableView) {
        return false;
    }
    if (shouldUseDefaultLayout(legendPosition, legendLayout)) {
        return true;
    }
    return false;
};
exports.shouldDisplayGridList = shouldDisplayGridList;
exports.legendValueTitlesMap = {
    [exports.LegendValue.CurrentAndLastValue]: 'Value',
    [exports.LegendValue.Value]: 'Value',
    [exports.LegendValue.Percent]: 'Percent',
    [exports.LegendValue.LastValue]: 'Last',
    [exports.LegendValue.LastNonNullValue]: 'Last non-null',
    [exports.LegendValue.FirstValue]: 'First',
    [exports.LegendValue.FirstNonNullValue]: 'First non-null',
    [exports.LegendValue.Average]: 'Avg',
    [exports.LegendValue.Median]: 'Median',
    [exports.LegendValue.Min]: 'Min',
    [exports.LegendValue.Max]: 'Max',
    [exports.LegendValue.Total]: 'Total',
    [exports.LegendValue.Count]: 'Count',
    [exports.LegendValue.DistinctCount]: 'Dist Count',
    [exports.LegendValue.Variance]: 'Variance',
    [exports.LegendValue.StdDeviation]: 'Std dev',
    [exports.LegendValue.Range]: 'Range',
    [exports.LegendValue.Difference]: 'Diff',
    [exports.LegendValue.DifferencePercent]: 'Diff %',
};
//# sourceMappingURL=legend.js.map