/**
 * util/semver.mjs — shared semver helpers used by route/drift-detect.mjs
 * and util/version-preflight.mjs. Extracted to avoid duplication (QUA-002).
 */
/** Semver-shape pattern — mirrors install/update-chips.mjs:64. */
export const SEMVER_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
/**
 * Compare two semver-shape strings. Returns -1 / 0 / 1. Ignores
 * pre-release + build metadata (sufficient for "min version" checks
 * where we only care about the MAJOR.MINOR.PATCH triple).
 *
 * @param {string} a
 * @param {string} b
 * @returns {-1 | 0 | 1}
 */
export function compareVersions(a, b) {
    const pa = a.split(/[-+]/, 1)[0].split('.').map(Number);
    const pb = b.split(/[-+]/, 1)[0].split('.').map(Number);
    for (let i = 0; i < 3; i++) {
        const av = pa[i] ?? 0;
        const bv = pb[i] ?? 0;
        if (av < bv)
            return -1;
        if (av > bv)
            return 1;
    }
    return 0;
}
//# sourceMappingURL=semver.mjs.map