UNPKG

@hhgtech/hhg-components

Version:
59 lines (56 loc) 3.13 kB
import { b as HEALTH_TOOL_NAME_TRACKING } from './healthTools-84f2ddc1.js'; import { l as locale } from './index-235eabf2.js'; import { u as useSSOV2Store } from './store-994a3f4d.js'; import { h as SubotType } from './index-90813715.js'; import { L as LOCALE } from './Locale-f270bd9d.js'; const isFeatureWhatsAppEnabled = [ LOCALE.Indonesia, LOCALE.Malaysia, ].includes(locale); const isFeatureSMSEnabled = [LOCALE.Vietnam].includes(locale); const isFeatureZaloEnabled = [LOCALE.Vietnam].includes(locale); const isSupportProduct = (featureFlagsProduct) => { const setupSource = 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: HEALTH_TOOL_NAME_TRACKING.BMI, bmr: HEALTH_TOOL_NAME_TRACKING.BMR, 'due-date': HEALTH_TOOL_NAME_TRACKING.DUE_DATE, ovulation: HEALTH_TOOL_NAME_TRACKING.OVULATION, 'baby-growth': HEALTH_TOOL_NAME_TRACKING.BABY_GROWTH, 'baby-vaccine': HEALTH_TOOL_NAME_TRACKING.BABY_VACCINE, 'pregnancy-weight-gain': HEALTH_TOOL_NAME_TRACKING.PWG, 'target-heart-rate': HEALTH_TOOL_NAME_TRACKING.THR, 'baby-poop-checking': 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) === SubotType.ristScreener) { urlObj.searchParams.set('embeddedType', 'riskScreener'); urlObj.searchParams.set('toolName', String(botItem.id)); } return urlObj; } catch (err) { return null; } }; export { isFeatureZaloEnabled as a, isFeatureSMSEnabled as b, isSupportProduct as c, getURLwithSSOTracking as g, isFeatureWhatsAppEnabled as i };