/** SDK-owned platform module. This implementation is maintained in goodvibes-sdk. */
/**
 * Compares two SchemaVersions. Returns:
 * - negative if a < b
 * - 0 if a === b
 * - positive if a > b
 */
export function compareVersions(a, b) {
    if (a.major !== b.major)
        return a.major - b.major;
    if (a.minor !== b.minor)
        return a.minor - b.minor;
    return a.patch - b.patch;
}
/**
 * Returns true if the two SchemaVersions are equal.
 */
export function versionsEqual(a, b) {
    return a.major === b.major && a.minor === b.minor && a.patch === b.patch;
}
/**
 * Serializes a SchemaVersion to a canonical string (e.g. '1.0.0').
 */
export function versionToString(v) {
    return `${v.major}.${v.minor}.${v.patch}`;
}
/**
 * Parses a version string (e.g. '1.2.3') into a SchemaVersion.
 * Throws if the string is not a valid semver triple.
 */
export function parseVersion(raw) {
    const parts = raw.split('.');
    if (parts.length !== 3) {
        throw new Error(`Invalid schema version string: '${raw}' (expected 'major.minor.patch')`);
    }
    const [major, minor, patch] = parts.map(Number);
    if (!Number.isInteger(major) || !Number.isInteger(minor) || !Number.isInteger(patch)) {
        throw new Error(`Non-integer component in schema version: '${raw}'`);
    }
    return { major, minor, patch };
}
