'use client'
import { CaptchaProviderEnum } from '@dynamic-labs/sdk-api-core';

const isCaptchaEnabled = (security) => { var _a, _b, _c, _d; return (_d = (_b = (_a = security === null || security === void 0 ? void 0 : security.captcha) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : (_c = security === null || security === void 0 ? void 0 : security.hCaptcha) === null || _c === void 0 ? void 0 : _c.enabled) !== null && _d !== void 0 ? _d : false; };
const getActiveCaptchaConfig = (security) => {
    var _a, _b, _c;
    if (((_a = security === null || security === void 0 ? void 0 : security.captcha) === null || _a === void 0 ? void 0 : _a.enabled) !== undefined) {
        if (security.captcha.enabled && security.captcha.siteKey) {
            return {
                provider: (_b = security.captcha.provider) !== null && _b !== void 0 ? _b : CaptchaProviderEnum.Hcaptcha,
                siteKey: security.captcha.siteKey,
            };
        }
        return undefined; // captcha field is explicitly configured but disabled — don't fall back
    }
    if (((_c = security === null || security === void 0 ? void 0 : security.hCaptcha) === null || _c === void 0 ? void 0 : _c.enabled) && security.hCaptcha.siteKey) {
        return {
            provider: CaptchaProviderEnum.Hcaptcha,
            siteKey: security.hCaptcha.siteKey,
        };
    }
    return undefined;
};

export { getActiveCaptchaConfig, isCaptchaEnabled };
