import semver from "semver";
import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
export const useAppVersionBlockCheck = ({ appVersion: uncoercedAppVersion, appKey, platform, osVersion, getConfigValue = LiveConfig.getValueByKey, }) => {
    const llMinVersionConfig = getConfigValue("config_ll_min_version");
    const appVersion = semver.coerce(uncoercedAppVersion)?.version || "";
    let shouldUpdate = false;
    if (!llMinVersionConfig || !llMinVersionConfig[appKey][platform]) {
        return { shouldUpdate };
    }
    if (appKey === "llm" && (platform === "android" || platform === "ios") && osVersion) {
        shouldUpdate = llMinVersionConfig[appKey][platform]
            .filter(minVersionConfig => semver.satisfies(semver.coerce(osVersion), `>=${minVersionConfig.minOsVersion}`))
            .reduce((acc, curr) => {
            return acc || semver.satisfies(appVersion, `<${semver.coerce(curr.version)}`);
        }, false);
    }
    else if (appKey === "lld" &&
        (platform === "windows" || platform === "macOS" || platform === "linux")) {
        shouldUpdate = semver.satisfies(appVersion, `<${semver.coerce(llMinVersionConfig[appKey][platform])}`);
    }
    return { shouldUpdate };
};
//# sourceMappingURL=useAppVersionBlockCheck.js.map