import { ErrorKind } from "../../../zero-protocol/src/error-kind.js";
import { ErrorForClient } from "./error-for-client.js";
export function throwErrorForClientIfSchemaVersionNotSupported(schemaVersion, schemaVersions) {
    const error = getErrorForClientIfSchemaVersionNotSupported(schemaVersion, schemaVersions);
    if (error) {
        throw error;
    }
}
export function getErrorForClientIfSchemaVersionNotSupported(schemaVersion, schemaVersions) {
    const { minSupportedVersion, maxSupportedVersion } = schemaVersions;
    if (schemaVersion < minSupportedVersion ||
        schemaVersion > maxSupportedVersion) {
        return new ErrorForClient({
            kind: ErrorKind.SchemaVersionNotSupported,
            message: `Schema version ${schemaVersion} is not in range of supported schema versions [${minSupportedVersion}, ${maxSupportedVersion}].`,
        });
    }
    return undefined;
}
//# sourceMappingURL=schema-versions.js.map