UNPKG

@hhgtech/hhg-components

Version:
65 lines (61 loc) 3.37 kB
'use strict'; var healthTools = require('./healthTools-a695152c.js'); var index = require('./index-83c3a6b2.js'); var store = require('./store-bc8408a1.js'); var index$1 = require('./index-0a047edc.js'); var Locale = require('./Locale-eb0da538.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 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.isFeatureSMSEnabled = isFeatureSMSEnabled; exports.isFeatureWhatsAppEnabled = isFeatureWhatsAppEnabled; exports.isFeatureZaloEnabled = isFeatureZaloEnabled; exports.isSupportProduct = isSupportProduct;