"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.polarChartHelper = void 0;
function calcTickDirection(isInnerAxis, isAngularAxisFlipped, startAngle, totalAngle) {
    var newStartAngle = isAngularAxisFlipped ? startAngle + totalAngle : startAngle;
    if (isAngularAxisFlipped) {
        if (isInnerAxis) {
            return { direction: 1, tickRotation: totalAngle, startAngle: newStartAngle };
        }
        else {
            return { direction: -1, tickRotation: totalAngle, startAngle: newStartAngle };
        }
    }
    else {
        if (isInnerAxis) {
            return { direction: -1, tickRotation: 0, startAngle: newStartAngle };
        }
        else {
            return { direction: 1, tickRotation: 0, startAngle: newStartAngle };
        }
    }
}
function calcLabelPosition(isInnerAxis, isAngularAxisFlipped, startAngle, totalAngle) {
    var isAntiClockWise = (!isAngularAxisFlipped && isInnerAxis) || (isAngularAxisFlipped && !isInnerAxis);
    var newStartAngle = isAngularAxisFlipped ? startAngle + totalAngle : startAngle;
    var labelRotation = isAngularAxisFlipped ? totalAngle : 0;
    return { isAntiClockWise: isAntiClockWise, labelRotation: labelRotation, startAngle: newStartAngle };
}
var FIVE_DEG = 2 * Math.PI / 360 * 5;
function checkPolarLabelsOverlap(tickCoords, minAngleToSkipLastLabelRadian) {
    if (minAngleToSkipLastLabelRadian === void 0) { minAngleToSkipLastLabelRadian = FIVE_DEG; }
    var minAngle = tickCoords[0];
    var maxAngle = tickCoords[tickCoords.length - 1];
    if (minAngle > maxAngle) {
        var tmp = minAngle;
        minAngle = maxAngle;
        maxAngle = tmp;
    }
    var span = maxAngle - minAngle;
    var normalizedGap = span % (2 * Math.PI);
    var gap = Math.min(normalizedGap, 2 * Math.PI - normalizedGap);
    return gap < minAngleToSkipLastLabelRadian;
}
exports.polarChartHelper = {
    calcTickDirection: calcTickDirection,
    calcLabelPosition: calcLabelPosition,
    checkPolarLabelsOverlap: checkPolarLabelsOverlap
};
