'use strict';

var healthTools = require('./healthTools-9d73d292.js');
var index = require('./index-e083a917.js');
var store = require('./store-bb6f9909.js');
var index$1 = require('./index-da3b86cd.js');
var Locale = require('./Locale-fbe01177.js');

const isFeatureWhatsAppEnabled = [
    Locale.LOCALE.Indonesia,
    Locale.LOCALE.Malaysia,
].includes(index.locale);
const isFeatureSMSEnabled = [Locale.LOCALE.Vietnam].includes(index.locale);
const isFeatureZaloEnabled = [Locale.LOCALE.Vietnam].includes(index.locale);
const isFeaturePolicyUpdateEnabled = [Locale.LOCALE.Malaysia].includes(index.locale);
const isSupportProduct = (featureFlagsProduct) => {
    const setupSource = store.useSSOV2Store.getState().setupSource || 'discover';
    const isSupportDiscover = (featureFlagsProduct === null || featureFlagsProduct === void 0 ? void 0 : featureFlagsProduct.find((p) => p.name === 'discover')) &&
        setupSource === 'discover';
    const isSupportTogether = (featureFlagsProduct === null || featureFlagsProduct === void 0 ? void 0 : featureFlagsProduct.find((p) => p.name === 'together')) &&
        setupSource === 'community';
    const isSupportCare = (featureFlagsProduct === null || featureFlagsProduct === void 0 ? void 0 : featureFlagsProduct.find((p) => p.name === 'care')) &&
        setupSource === 'care';
    return isSupportDiscover || isSupportTogether || isSupportCare;
};
const getURLwithSSOTracking = (url, { source, botItem }) => {
    var _a;
    if (!source && !botItem)
        return null;
    try {
        const urlObj = new URL(url.startsWith('localhost') ? `http://${url}` : url);
        const mapHealthToolName = {
            bmi: healthTools.HEALTH_TOOL_NAME_TRACKING.BMI,
            bmr: healthTools.HEALTH_TOOL_NAME_TRACKING.BMR,
            'due-date': healthTools.HEALTH_TOOL_NAME_TRACKING.DUE_DATE,
            ovulation: healthTools.HEALTH_TOOL_NAME_TRACKING.OVULATION,
            'baby-growth': healthTools.HEALTH_TOOL_NAME_TRACKING.BABY_GROWTH,
            'baby-vaccine': healthTools.HEALTH_TOOL_NAME_TRACKING.BABY_VACCINE,
            'pregnancy-weight-gain': healthTools.HEALTH_TOOL_NAME_TRACKING.PWG,
            'target-heart-rate': healthTools.HEALTH_TOOL_NAME_TRACKING.THR,
            'baby-poop-checking': healthTools.HEALTH_TOOL_NAME_TRACKING.BABY_POOP,
        };
        const healthToolName = mapHealthToolName[source];
        const isHealthToolPage = window.location.href.includes('/health-tools');
        // Only accept the health tools are embedded in other pages
        if (healthToolName && !isHealthToolPage) {
            urlObj.searchParams.set('embeddedType', 'healthTool');
            urlObj.searchParams.set('toolName', healthToolName);
        }
        else if (((_a = botItem === null || botItem === void 0 ? void 0 : botItem.extra_settings) === null || _a === void 0 ? void 0 : _a.subot_type) === index$1.SubotType.ristScreener) {
            urlObj.searchParams.set('embeddedType', 'riskScreener');
            urlObj.searchParams.set('toolName', String(botItem.id));
        }
        return urlObj;
    }
    catch (err) {
        return null;
    }
};

exports.getURLwithSSOTracking = getURLwithSSOTracking;
exports.isFeaturePolicyUpdateEnabled = isFeaturePolicyUpdateEnabled;
exports.isFeatureSMSEnabled = isFeatureSMSEnabled;
exports.isFeatureWhatsAppEnabled = isFeatureWhatsAppEnabled;
exports.isFeatureZaloEnabled = isFeatureZaloEnabled;
exports.isSupportProduct = isSupportProduct;
