/**
 * DevExtreme (esm/__internal/utils/version.js)
 * Version: 23.2.9 (build 24294-0112)
 * Build date: Sun Oct 20 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
import errors from "../../core/errors";
var assertedVersions = [];
var VERSION_SPLITTER = ".";

function stringifyVersion(version) {
    var {
        major: major,
        minor: minor,
        patch: patch
    } = version;
    return [major, minor, patch].join(VERSION_SPLITTER)
}
export function parseVersion(version) {
    var [major, minor, patch] = version.split(".").map(Number);
    return {
        major: major,
        minor: minor,
        patch: patch
    }
}
export function assertDevExtremeVersion(packageName, version) {
    assertedVersions.push({
        packageName: packageName,
        version: version
    })
}
export function clearAssertedVersions() {}

function stringifyVersionList(assertedVersionList) {
    return assertedVersionList.map(assertedVersion => "".concat(assertedVersion.packageName, ": ").concat(assertedVersion.version)).join("\n")
}

function versionsEqual(versionA, versionB) {
    return versionA.major === versionB.major && versionA.minor === versionB.minor && versionA.patch === versionB.patch
}
export function assertedVersionsCompatible(currentVersion) {
    var mismatchingVersions = assertedVersions.filter(assertedVersion => !versionsEqual(parseVersion(assertedVersion.version), currentVersion));
    if (mismatchingVersions.length) {
        errors.log("W0023", stringifyVersionList([{
            packageName: "devextreme",
            version: stringifyVersion(currentVersion)
        }, ...mismatchingVersions]));
        return false
    }
    return true
}
