"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.nodeVersionToString = nodeVersionToString;
exports.extractNodeVersionTuple = extractNodeVersionTuple;
exports.compareNodeVersions = compareNodeVersions;
function nodeVersionToString(nodeVersion) {
    return `v${nodeVersion.major}.${nodeVersion.minor}.${nodeVersion.point}`;
}
const NODE_VERSION_REGEX = /(\d+)\.(\d+)(\.(\d+))?/;
function extractNodeVersionTuple(stringWithVersion) {
    const matches = stringWithVersion?.match(NODE_VERSION_REGEX);
    return {
        major: parseInt(matches?.[1] ?? '0'),
        minor: parseInt(matches?.[2] ?? '0'),
        point: parseInt(matches?.[4] ?? '0'),
    };
}
function compareNodeVersions(left, right) {
    function toInt(version) {
        return version.major * 1000000 + version.minor * 1000 + version.point;
    }
    const leftInt = toInt(left);
    const rightInt = toInt(right);
    if (leftInt === rightInt) {
        return 0;
    }
    else if (leftInt > rightInt) {
        return 1;
    }
    return -1;
}
