@hhgtech/hhg-components 1.29.374 → 1.29.375-beta-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (541) hide show
  1. package/build/{InputDate-8b579da2.js → InputDate-4d0f8f62.js} +3 -3
  2. package/build/{LastPeriod-64e1601a.js → LastPeriod-e7875ff0.js} +1 -1
  3. package/build/{Locale-72dce976.js → Locale-5cb9776e.js} +1 -0
  4. package/build/{MobileBottomNavigationIcon-d51ca59a.js → MobileBottomNavigationIcon-ade55d98.js} +3 -3
  5. package/build/{Spinner-883e6f71.js → Spinner-9eaad3bc.js} +1 -1
  6. package/build/{WhatsApp-52413156.js → WhatsApp-4736d161.js} +1 -1
  7. package/build/adapters.js +19 -19
  8. package/build/atoms.js +48 -48
  9. package/build/babyGrowth.js +83 -83
  10. package/build/cache.js +2 -2
  11. package/build/care.js +17 -17
  12. package/build/careBookingSearchBar.js +14 -14
  13. package/build/careBookingSearchBarV2.js +15 -15
  14. package/build/components/atoms/logo/index.d.ts +1 -1
  15. package/build/components/mantine/phone/index.d.ts +2 -0
  16. package/build/components/mantine/phoneInput/PhoneInput.d.ts +17 -0
  17. package/build/components/mantine/phoneInput/index.d.ts +1 -0
  18. package/build/components.js +97 -96
  19. package/build/{constants-4fc45016.js → constants-10fdc66a.js} +1 -1
  20. package/build/{constants-171f25c7.js → constants-df1ac0c9.js} +1 -0
  21. package/build/constants.js +3 -3
  22. package/build/constantsDomainLocales.js +3 -1
  23. package/build/constantsRiskScreener.js +2 -2
  24. package/build/constantsSite.js +2 -2
  25. package/build/{core-49c30866.js → core-2193730e.js} +1 -1
  26. package/build/{dataTransform-9fcb6f21.js → dataTransform-0bc28b35.js} +1 -1
  27. package/build/ecom.js +4 -4
  28. package/build/{editor-f38876f9.js → editor-d43056a7.js} +11 -11
  29. package/build/embeddedHeathToolCards_babyGrowth.js +23 -23
  30. package/build/embeddedHeathToolCards_babyPoop.js +19 -19
  31. package/build/embeddedHeathToolCards_babyVaccine.js +22 -22
  32. package/build/embeddedHeathToolCards_bmi_bmi.js +25 -25
  33. package/build/embeddedHeathToolCards_bmrBmr.js +25 -25
  34. package/build/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  35. package/build/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  36. package/build/embeddedHeathToolCards_pwg_pwg.js +26 -26
  37. package/build/embeddedHeathToolCards_targetHeartRate.js +27 -27
  38. package/build/esm/{InputDate-86cf8a56.js → InputDate-ae62bf9a.js} +3 -3
  39. package/build/esm/{LastPeriod-f7751d88.js → LastPeriod-ea3fdfc4.js} +1 -1
  40. package/build/esm/{Locale-3430abbb.js → Locale-6cbef683.js} +1 -0
  41. package/build/esm/{MobileBottomNavigationIcon-9c8475b0.js → MobileBottomNavigationIcon-8a422f2d.js} +3 -3
  42. package/build/esm/{Spinner-926cb3b3.js → Spinner-2b2ee80a.js} +1 -1
  43. package/build/esm/{WhatsApp-e29f71ae.js → WhatsApp-d9b6322d.js} +1 -1
  44. package/build/esm/adapters.js +19 -19
  45. package/build/esm/atoms.js +48 -48
  46. package/build/esm/babyGrowth.js +83 -83
  47. package/build/esm/cache.js +2 -2
  48. package/build/esm/care.js +17 -17
  49. package/build/esm/careBookingSearchBar.js +14 -14
  50. package/build/esm/careBookingSearchBarV2.js +15 -15
  51. package/build/esm/components/atoms/logo/index.d.ts +1 -1
  52. package/build/esm/components/mantine/phone/index.d.ts +2 -0
  53. package/build/esm/components/mantine/phoneInput/PhoneInput.d.ts +17 -0
  54. package/build/esm/components/mantine/phoneInput/index.d.ts +1 -0
  55. package/build/esm/components.js +97 -96
  56. package/build/esm/{constants-8772c2b0.js → constants-ca39f7c8.js} +1 -0
  57. package/build/esm/{constants-030b17c7.js → constants-e7d257f4.js} +1 -1
  58. package/build/esm/constants.js +3 -3
  59. package/build/esm/constantsDomainLocales.js +3 -1
  60. package/build/esm/constantsRiskScreener.js +2 -2
  61. package/build/esm/constantsSite.js +2 -2
  62. package/build/esm/{core-55455f88.js → core-b15c99fa.js} +1 -1
  63. package/build/esm/{dataTransform-a7848bdc.js → dataTransform-3e675b26.js} +1 -1
  64. package/build/esm/ecom.js +4 -4
  65. package/build/esm/{editor-377b7f2b.js → editor-c56c017c.js} +11 -11
  66. package/build/esm/embeddedHeathToolCards_babyGrowth.js +23 -23
  67. package/build/esm/embeddedHeathToolCards_babyPoop.js +19 -19
  68. package/build/esm/embeddedHeathToolCards_babyVaccine.js +22 -22
  69. package/build/esm/embeddedHeathToolCards_bmi_bmi.js +25 -25
  70. package/build/esm/embeddedHeathToolCards_bmrBmr.js +25 -25
  71. package/build/esm/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  72. package/build/esm/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  73. package/build/esm/embeddedHeathToolCards_pwg_pwg.js +26 -26
  74. package/build/esm/embeddedHeathToolCards_targetHeartRate.js +27 -27
  75. package/build/esm/footer.js +21 -21
  76. package/build/esm/gAssets.js +2 -2
  77. package/build/esm/{healthTools-6ff083fc.js → healthTools-ff0d83ac.js} +1 -1
  78. package/build/esm/healthToolsCardWrapper.js +18 -18
  79. package/build/esm/healthToolsForm.js +33 -33
  80. package/build/esm/hooks.js +13 -13
  81. package/build/esm/i18n-values/zh-CN.js +855 -0
  82. package/build/esm/i18n.js +14 -55
  83. package/build/esm/i18nV2.js +2 -2
  84. package/build/esm/{index-4dbdcc4c.js → index-0055a84b.js} +24 -24
  85. package/build/esm/{index-5ff6b134.js → index-1201d09e.js} +2 -2
  86. package/build/esm/{index-82254ae8.js → index-12e39e60.js} +25 -25
  87. package/build/esm/{index-bae2d2e9.js → index-1bea6ae1.js} +31 -31
  88. package/build/esm/{index-7b524555.js → index-1e9e7f75.js} +6 -6
  89. package/build/esm/index-22fd28bb.js +183 -0
  90. package/build/esm/{index-8e302f71.js → index-23178aa9.js} +1 -1
  91. package/build/esm/{index-5e9df0aa.js → index-2a2562dd.js} +2 -2
  92. package/build/esm/{index-35c4c26f.js → index-2b0b5ecd.js} +40 -3
  93. package/build/esm/{index-4f84ba27.js → index-2e3e0cff.js} +18 -18
  94. package/build/esm/{index-aa92750f.js → index-2f12dbba.js} +7 -7
  95. package/build/esm/{index-9506572a.js → index-355f9d5c.js} +10 -10
  96. package/build/esm/{index-94da713d.js → index-357625fc.js} +17 -17
  97. package/build/esm/{index-36da89a1.js → index-3c98ef91.js} +1 -1
  98. package/build/esm/{index-edae0b9e.js → index-3d39bdad.js} +2 -2
  99. package/build/esm/{index-c315fa6b.js → index-3ec677f5.js} +2 -2
  100. package/build/esm/{index-528169fe.js → index-3f48de19.js} +16 -16
  101. package/build/esm/{index-7f79d78c.js → index-3f57aae0.js} +2 -2
  102. package/build/esm/{index-130576cd.js → index-3f7de8cb.js} +16 -16
  103. package/build/esm/{index-f4607daa.js → index-3f972b22.js} +2 -2
  104. package/build/esm/{index-e1c1652c.js → index-458c4644.js} +3 -3
  105. package/build/esm/{index-782b32b4.js → index-4698117f.js} +3 -3
  106. package/build/esm/{index-f410871a.js → index-4d729cc4.js} +1 -1
  107. package/build/esm/{index-0f5789ca.js → index-51795464.js} +16 -16
  108. package/build/esm/{index-33c4c7ba.js → index-5301bfe9.js} +13 -13
  109. package/build/esm/{index-f5a27fa1.js → index-53b14dfd.js} +13 -13
  110. package/build/esm/{index-9d456ced.js → index-545016c2.js} +13 -13
  111. package/build/esm/{index-f437d7d3.js → index-5cd35f39.js} +22 -22
  112. package/build/esm/{index-c22c8c9f.js → index-6060489a.js} +15 -15
  113. package/build/esm/{index-109382ee.js → index-621525f8.js} +1 -1
  114. package/build/esm/{index-9a682965.js → index-6701be33.js} +1 -1
  115. package/build/esm/{index-395867d1.js → index-6a09ecad.js} +1 -1
  116. package/build/esm/{index-7f3a0d51.js → index-6e645ce9.js} +13 -13
  117. package/build/esm/{index-d25199d4.js → index-6ff57267.js} +1 -1
  118. package/build/esm/{index-fd64f3e1.js → index-7447d781.js} +18 -18
  119. package/build/esm/{index-8b71f3d7.js → index-77918ec2.js} +17 -17
  120. package/build/esm/{index-9688c45f.js → index-808718f9.js} +7 -7
  121. package/build/esm/{index-06d394fc.js → index-868eb4ba.js} +3 -3
  122. package/build/esm/{index-cd820271.js → index-86f3b263.js} +4 -4
  123. package/build/esm/{index-0ab75d88.js → index-8b58d4d5.js} +5 -5
  124. package/build/esm/{index-5024511e.js → index-8f74d63d.js} +2 -2
  125. package/build/esm/{index-e401fea0.js → index-97c7b8a6.js} +1 -1
  126. package/build/esm/{index-22f111d6.js → index-9cacc9f3.js} +3 -3
  127. package/build/esm/{index-3784dc8c.js → index-a34077dd.js} +17 -17
  128. package/build/esm/{index-7287f2a0.js → index-ad4f1aa3.js} +5 -5
  129. package/build/esm/{index-17e36457.js → index-ae8ebfbb.js} +8 -8
  130. package/build/esm/{index-44df64aa.js → index-b4398a57.js} +2 -2
  131. package/build/esm/{index-5d7077d8.js → index-b7689a43.js} +2 -2
  132. package/build/esm/{index-4bd46b7f.js → index-b92616e0.js} +2 -2
  133. package/build/esm/{index-6ab5e856.js → index-cd4c901f.js} +1 -1
  134. package/build/esm/{index-32060de3.js → index-d15062af.js} +16 -16
  135. package/build/esm/{index-4c29da01.js → index-d189b9de.js} +6 -6
  136. package/build/esm/{index-e93b1f65.js → index-d37dade0.js} +36 -27
  137. package/build/esm/{index-adf83539.js → index-d5f8e31e.js} +21 -21
  138. package/build/esm/{index-4cc74b63.js → index-d79430b6.js} +32 -32
  139. package/build/esm/{index-8885ef87.js → index-da65e1c5.js} +6 -6
  140. package/build/esm/{index-bfafe3e9.js → index-df2bbe3a.js} +17 -17
  141. package/build/esm/{index-2f124f3f.js → index-e3b526bc.js} +6 -6
  142. package/build/esm/{index-8c227289.js → index-e7f04418.js} +32 -32
  143. package/build/esm/{index-5131dc4f.js → index-f40333a0.js} +3 -3
  144. package/build/esm/{index-f9d0d6be.js → index-f44b1ab3.js} +6 -6
  145. package/build/esm/{index-cb2ab6ff.js → index-f80db4ef.js} +2 -2
  146. package/build/esm/{index-7f0089a7.js → index-fef08243.js} +3 -3
  147. package/build/esm/{index-7911d60e.js → index-ffb2f217.js} +2 -2
  148. package/build/esm/{index-8bc9ae7d.js → index-ffe4486b.js} +2 -2
  149. package/build/esm/index.js +118 -117
  150. package/build/esm/interfaces/constants/domainLocales.d.ts +2 -0
  151. package/build/esm/interfaces/constants/index.d.ts +1 -1
  152. package/build/esm/interfaces/types/Locale.d.ts +2 -1
  153. package/build/esm/interfaces/types/index.d.ts +2 -1
  154. package/build/esm/{labelSorting-ad695303.js → labelSorting-2570a1d0.js} +4 -4
  155. package/build/esm/lead/LeadGen.type.d.ts +34 -0
  156. package/build/esm/lead/LeadGenForm/LeadGenForm.d.ts +41 -0
  157. package/build/esm/lead/LeadGenForm/LeadGenForm.helpers.d.ts +2 -0
  158. package/build/esm/lead/LeadGenForm/LeadGenForm.styled.d.ts +5 -0
  159. package/build/esm/lead/LeadGenForm/LeadGenFormPhone.d.ts +17 -0
  160. package/build/esm/lead/LeadGenForm/LeadGenThankYou.d.ts +20 -0
  161. package/build/esm/lead/LeadGenForm/index.d.ts +3 -0
  162. package/build/esm/lead/LeadGenForm/textField/index.d.ts +13 -0
  163. package/build/esm/lead/LeadGenForm/textField/index.styled.d.ts +11 -0
  164. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +66 -0
  165. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +4 -0
  166. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +21 -0
  167. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +3 -0
  168. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +24 -0
  169. package/build/esm/lead/LeadGenSubscriptionBox/index.d.ts +1 -0
  170. package/build/esm/lead/LeadGenTranslationContext.d.ts +6 -0
  171. package/build/esm/lead/helpers.d.ts +56 -1
  172. package/build/esm/lead/index.d.ts +2 -1
  173. package/build/esm/lead/services/index.d.ts +21 -0
  174. package/build/esm/lead/store/index.d.ts +1 -0
  175. package/build/esm/lead.js +2422 -1232
  176. package/build/esm/{logoIcon-3352527f.js → logoIcon-f67d36b2.js} +8 -2
  177. package/build/esm/mantine.js +25 -25
  178. package/build/esm/misc.js +17 -17
  179. package/build/esm/miscGetDynamicHealthTool.js +4 -4
  180. package/build/esm/miscGetSocialList.js +8 -8
  181. package/build/esm/miscScreenSizeContext.js +1 -1
  182. package/build/esm/mobileBottomNavigation.js +5 -5
  183. package/build/esm/mobileBottomNavigationIcon.js +5 -5
  184. package/build/esm/molecules.js +74 -73
  185. package/build/esm/moleculesArticleCard.js +6 -6
  186. package/build/esm/moleculesArticleCardV2.js +16 -16
  187. package/build/esm/navigation.js +46 -45
  188. package/build/esm/navigationLogoutPopup.js +9 -9
  189. package/build/esm/navigationProfileButton.js +23 -23
  190. package/build/esm/onboardingV2.js +29 -29
  191. package/build/esm/organisms.js +50 -49
  192. package/build/esm/{post-062dce48.js → post-39c1933a.js} +2 -2
  193. package/build/esm/profileNavigation.js +19 -19
  194. package/build/esm/progressBar.js +1 -1
  195. package/build/esm/pwg.js +22 -22
  196. package/build/esm/ssoV2/api/featureFlag.d.ts +2 -1
  197. package/build/esm/ssoV2.js +53 -40
  198. package/build/esm/{store-0f9ab222.js → store-c6f45876.js} +6 -183
  199. package/build/esm/subot.js +36 -35
  200. package/build/esm/surveyOrPremiumBanner.js +33 -32
  201. package/build/esm/surveyQuestionCard.js +10 -10
  202. package/build/esm/{surveyThankyouCard-ba3a0601.js → surveyThankyouCard-95b3e6d6.js} +5 -5
  203. package/build/esm/together.js +56 -55
  204. package/build/esm/togetherApiUtils.js +4 -4
  205. package/build/esm/togetherAtoms.js +30 -30
  206. package/build/esm/togetherComponentGlobalContext.js +4 -4
  207. package/build/esm/togetherMolecules.js +51 -50
  208. package/build/esm/togetherMoleculesCardAuthor.js +28 -28
  209. package/build/esm/togetherMoleculesPostImagePreview.js +11 -11
  210. package/build/esm/togetherMoleculesProfileDetail.js +39 -38
  211. package/build/esm/togetherOrganisms.js +50 -49
  212. package/build/esm/togetherRichTextEditor.js +17 -17
  213. package/build/esm/togetherShareBox.js +10 -10
  214. package/build/esm/translationsProvider-2b2fc65d.js +55 -0
  215. package/build/esm/{treePopoverMenu-a6f7cfd7.js → treePopoverMenu-bc8ad7a8.js} +19 -19
  216. package/build/esm/{types-2e97f020.js → types-ce7ad19b.js} +2 -2
  217. package/build/esm/types.js +2 -2
  218. package/build/esm/{useCategory-a57e6557.js → useCategory-778152da.js} +18 -5
  219. package/build/esm/{useHealthToolCache-50ac5d7d.js → useHealthToolCache-89d26604.js} +1 -1
  220. package/build/esm/{useMantineLocale-ee478730.js → useMantineLocale-95434bd7.js} +8 -6
  221. package/build/esm/{usePlacesAutocomplete-119a12f3.js → usePlacesAutocomplete-ef8cc9c6.js} +1 -1
  222. package/build/esm/{useScreenSize-241e66fa.js → useScreenSize-bf03486c.js} +2 -2
  223. package/build/esm/useTogetherAuthRequiredAction.js +10 -9
  224. package/build/esm/{utils-5c250b28.js → utils-7e9b37e9.js} +3 -3
  225. package/build/esm/{utils-84d5275f.js → utils-b0412385.js} +2 -2
  226. package/build/esm/{utils-d81142cf.js → utils-dbac92d3.js} +5 -4
  227. package/build/esm/{utils-02789711.js → utils-dc1e800b.js} +2 -2
  228. package/build/esm/vaccination.js +21 -21
  229. package/build/footer.js +21 -21
  230. package/build/gAssets.js +2 -2
  231. package/build/{healthTools-257131be.js → healthTools-dbd21cb9.js} +1 -1
  232. package/build/healthToolsCardWrapper.js +18 -18
  233. package/build/healthToolsForm.js +33 -33
  234. package/build/hooks.js +13 -13
  235. package/build/i18n-values/zh-CN.js +866 -0
  236. package/build/i18n.js +16 -56
  237. package/build/i18nV2.js +1 -1
  238. package/build/{index-81db4a5e.js → index-09f99e88.js} +2 -2
  239. package/build/{index-23006a6f.js → index-0b5f4fea.js} +1 -1
  240. package/build/{index-8e6eaed0.js → index-0cc4df46.js} +22 -22
  241. package/build/{index-da1f328c.js → index-0da9204d.js} +16 -16
  242. package/build/{index-ff5393e0.js → index-143b9b21.js} +1 -1
  243. package/build/{index-9074450c.js → index-175d86a3.js} +3 -3
  244. package/build/{index-46713f6a.js → index-180ad656.js} +2 -2
  245. package/build/{index-f757576d.js → index-1b3be381.js} +1 -1
  246. package/build/{index-809fab5e.js → index-1fef978f.js} +2 -2
  247. package/build/index-21170172.js +196 -0
  248. package/build/{index-bfce43a1.js → index-268e9543.js} +17 -17
  249. package/build/{index-8298c7c0.js → index-320edae9.js} +2 -2
  250. package/build/{index-c4266bb2.js → index-321d92ae.js} +5 -5
  251. package/build/{index-1ac4d980.js → index-398fb7e9.js} +1 -1
  252. package/build/{index-d0fc83cb.js → index-39d41dec.js} +10 -10
  253. package/build/{index-da4de0f3.js → index-3ca5fb52.js} +13 -13
  254. package/build/{index-3484373a.js → index-41beb858.js} +6 -6
  255. package/build/{index-e0986c73.js → index-42d241a1.js} +13 -13
  256. package/build/{index-cc03a162.js → index-4754bb17.js} +6 -6
  257. package/build/{index-bab54ae7.js → index-4ce3e685.js} +1 -1
  258. package/build/{index-4c99f21d.js → index-4e3a681a.js} +3 -3
  259. package/build/{index-aad65709.js → index-515e1b21.js} +13 -13
  260. package/build/{index-b043d722.js → index-52daa9b7.js} +2 -2
  261. package/build/{index-d5392642.js → index-58d10dfd.js} +2 -2
  262. package/build/{index-ca0ff3c8.js → index-5e51751d.js} +13 -13
  263. package/build/{index-f30c6c68.js → index-6ef47de2.js} +17 -17
  264. package/build/{index-31c0299e.js → index-752ff392.js} +6 -6
  265. package/build/{index-9e639be2.js → index-7ae2e6e6.js} +1 -1
  266. package/build/{index-e0b64996.js → index-7af24e7a.js} +16 -16
  267. package/build/{index-d0a87c80.js → index-7b16516e.js} +1 -1
  268. package/build/{index-c1e14fd6.js → index-7c0ef7f6.js} +24 -24
  269. package/build/{index-09ddce9c.js → index-7ef2b805.js} +21 -21
  270. package/build/{index-467dfe87.js → index-861e8221.js} +1 -1
  271. package/build/{index-f8156707.js → index-86f0bdb5.js} +6 -6
  272. package/build/{index-2d635a20.js → index-87737063.js} +2 -2
  273. package/build/{index-7e3fcc69.js → index-8bdf02cd.js} +6 -6
  274. package/build/{index-78dac42f.js → index-901c1b9b.js} +36 -27
  275. package/build/{index-02e6761f.js → index-94a1298e.js} +25 -25
  276. package/build/{index-6f08804a.js → index-961dede4.js} +2 -2
  277. package/build/{index-41529ab9.js → index-9f1cd383.js} +3 -3
  278. package/build/{index-5671b247.js → index-a8695abe.js} +8 -8
  279. package/build/{index-d0da1009.js → index-ae65f00b.js} +2 -2
  280. package/build/{index-e7f3329c.js → index-b0d2b32a.js} +31 -31
  281. package/build/{index-2fc43b51.js → index-b7e2e558.js} +16 -16
  282. package/build/{index-815de854.js → index-ba06accd.js} +32 -32
  283. package/build/{index-2a96defb.js → index-c206af9c.js} +5 -5
  284. package/build/{index-9164c2ee.js → index-c69ad216.js} +3 -3
  285. package/build/{index-c3b2d3a2.js → index-c7a7dac2.js} +4 -4
  286. package/build/{index-8b1dc163.js → index-ca9e1748.js} +16 -16
  287. package/build/{index-dec3d9e5.js → index-d450263c.js} +18 -18
  288. package/build/{index-df8845e8.js → index-d99ee36c.js} +39 -2
  289. package/build/{index-a8c0fe3b.js → index-db4af610.js} +18 -18
  290. package/build/{index-0186561a.js → index-df09b828.js} +2 -2
  291. package/build/{index-e25c397c.js → index-e131b4fe.js} +3 -3
  292. package/build/{index-1c320bad.js → index-e3836fc5.js} +32 -32
  293. package/build/{index-1c3321c1.js → index-e6c8f5c7.js} +17 -17
  294. package/build/{index-5e7301a8.js → index-e73b9a01.js} +15 -15
  295. package/build/{index-b99eceae.js → index-eb7725c0.js} +1 -1
  296. package/build/{index-2edc6f4f.js → index-ecda6b9f.js} +2 -2
  297. package/build/{index-7e9b8b61.js → index-ece70484.js} +7 -7
  298. package/build/{index-d86255ae.js → index-f019a542.js} +7 -7
  299. package/build/{index-582068c8.js → index-f40878d1.js} +2 -2
  300. package/build/{index-4026f890.js → index-f79913e1.js} +2 -2
  301. package/build/{index-b3a4afc0.js → index-f8357dc8.js} +3 -3
  302. package/build/{index-de274432.js → index-f948b9c8.js} +17 -17
  303. package/build/index.js +118 -117
  304. package/build/interfaces/constants/domainLocales.d.ts +2 -0
  305. package/build/interfaces/constants/index.d.ts +1 -1
  306. package/build/interfaces/types/Locale.d.ts +2 -1
  307. package/build/interfaces/types/index.d.ts +2 -1
  308. package/build/{labelSorting-f5b88779.js → labelSorting-fb34ff85.js} +4 -4
  309. package/build/lead/LeadGen.type.d.ts +34 -0
  310. package/build/lead/LeadGenForm/LeadGenForm.d.ts +41 -0
  311. package/build/lead/LeadGenForm/LeadGenForm.helpers.d.ts +2 -0
  312. package/build/lead/LeadGenForm/LeadGenForm.styled.d.ts +5 -0
  313. package/build/lead/LeadGenForm/LeadGenFormPhone.d.ts +17 -0
  314. package/build/lead/LeadGenForm/LeadGenThankYou.d.ts +20 -0
  315. package/build/lead/LeadGenForm/index.d.ts +3 -0
  316. package/build/lead/LeadGenForm/textField/index.d.ts +13 -0
  317. package/build/lead/LeadGenForm/textField/index.styled.d.ts +11 -0
  318. package/build/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +66 -0
  319. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +4 -0
  320. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +21 -0
  321. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +3 -0
  322. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +24 -0
  323. package/build/lead/LeadGenSubscriptionBox/index.d.ts +1 -0
  324. package/build/lead/LeadGenTranslationContext.d.ts +6 -0
  325. package/build/lead/helpers.d.ts +56 -1
  326. package/build/lead/index.d.ts +2 -1
  327. package/build/lead/services/index.d.ts +21 -0
  328. package/build/lead/store/index.d.ts +1 -0
  329. package/build/lead.js +2460 -1269
  330. package/build/{logoIcon-d87f0c7c.js → logoIcon-9592951c.js} +8 -2
  331. package/build/mantine.js +22 -22
  332. package/build/misc.js +17 -17
  333. package/build/miscGetDynamicHealthTool.js +4 -4
  334. package/build/miscGetSocialList.js +8 -8
  335. package/build/miscScreenSizeContext.js +1 -1
  336. package/build/mobileBottomNavigation.js +5 -5
  337. package/build/mobileBottomNavigationIcon.js +5 -5
  338. package/build/molecules.js +74 -73
  339. package/build/moleculesArticleCard.js +6 -6
  340. package/build/moleculesArticleCardV2.js +16 -16
  341. package/build/navigation.js +46 -45
  342. package/build/navigationLogoutPopup.js +9 -9
  343. package/build/navigationProfileButton.js +23 -23
  344. package/build/onboardingV2.js +28 -28
  345. package/build/organisms.js +50 -49
  346. package/build/{post-7ad0e276.js → post-0096ba19.js} +2 -2
  347. package/build/profileNavigation.js +19 -19
  348. package/build/progressBar.js +1 -1
  349. package/build/pwg.js +22 -22
  350. package/build/ssoV2/api/featureFlag.d.ts +2 -1
  351. package/build/ssoV2.js +130 -117
  352. package/build/{store-ff958ae7.js → store-536d12ea.js} +8 -196
  353. package/build/subot.js +35 -34
  354. package/build/surveyOrPremiumBanner.js +33 -32
  355. package/build/surveyQuestionCard.js +10 -10
  356. package/build/{surveyThankyouCard-e8976fd5.js → surveyThankyouCard-7a4bcbec.js} +5 -5
  357. package/build/together.js +56 -55
  358. package/build/togetherApiUtils.js +4 -4
  359. package/build/togetherAtoms.js +30 -30
  360. package/build/togetherComponentGlobalContext.js +4 -4
  361. package/build/togetherMolecules.js +51 -50
  362. package/build/togetherMoleculesCardAuthor.js +28 -28
  363. package/build/togetherMoleculesPostImagePreview.js +11 -11
  364. package/build/togetherMoleculesProfileDetail.js +39 -38
  365. package/build/togetherOrganisms.js +50 -49
  366. package/build/togetherRichTextEditor.js +17 -17
  367. package/build/togetherShareBox.js +10 -10
  368. package/build/translationsProvider-6a0b5b3b.js +62 -0
  369. package/build/{treePopoverMenu-11d8a3c3.js → treePopoverMenu-7c10e82c.js} +19 -19
  370. package/build/{types-da86b25c.js → types-32489690.js} +2 -2
  371. package/build/types.js +2 -2
  372. package/build/{useCategory-8a7dc9fd.js → useCategory-e89e6d2f.js} +18 -5
  373. package/build/{useHealthToolCache-0d055a47.js → useHealthToolCache-480349f8.js} +1 -1
  374. package/build/{useMantineLocale-a330a7e5.js → useMantineLocale-ec6670dc.js} +8 -6
  375. package/build/{usePlacesAutocomplete-14098979.js → usePlacesAutocomplete-67b69bd8.js} +1 -1
  376. package/build/{useScreenSize-2eae68ef.js → useScreenSize-bfdacbfe.js} +2 -2
  377. package/build/useTogetherAuthRequiredAction.js +10 -9
  378. package/build/{utils-c88507b9.js → utils-0c9e01bc.js} +2 -2
  379. package/build/{utils-d104096a.js → utils-93e6845b.js} +9 -8
  380. package/build/{utils-7d98be3c.js → utils-be46cc9c.js} +2 -2
  381. package/build/{utils-192df9f4.js → utils-d08246c9.js} +3 -3
  382. package/build/vaccination.js +21 -21
  383. package/package.json +3 -3
  384. /package/build/{BMI_BOYS.percentile.monthly-179a50b1.js → BMI_BOYS.percentile.monthly-78637892.js} +0 -0
  385. /package/build/{BMI_BOYS.percentile.weekly-6e48af31.js → BMI_BOYS.percentile.weekly-b1c1f60d.js} +0 -0
  386. /package/build/{BMI_BOYS.percentile.yearly-4580e832.js → BMI_BOYS.percentile.yearly-01491d63.js} +0 -0
  387. /package/build/{BMI_BOYS.zscore.monthly-b7606779.js → BMI_BOYS.zscore.monthly-1699c10d.js} +0 -0
  388. /package/build/{BMI_BOYS.zscore.weekly-172fbecd.js → BMI_BOYS.zscore.weekly-aa0799e5.js} +0 -0
  389. /package/build/{BMI_BOYS.zscore.yearly-34a8f9cd.js → BMI_BOYS.zscore.yearly-6595bd1e.js} +0 -0
  390. /package/build/{BMI_GIRLS.percentile.monthly-5b16a621.js → BMI_GIRLS.percentile.monthly-9adfabf8.js} +0 -0
  391. /package/build/{BMI_GIRLS.percentile.weekly-a13bf779.js → BMI_GIRLS.percentile.weekly-5347c8de.js} +0 -0
  392. /package/build/{BMI_GIRLS.percentile.yearly-13973462.js → BMI_GIRLS.percentile.yearly-a5a864a9.js} +0 -0
  393. /package/build/{BMI_GIRLS.zscore.monthly-204e3d84.js → BMI_GIRLS.zscore.monthly-0351ab0c.js} +0 -0
  394. /package/build/{BMI_GIRLS.zscore.weekly-6fdd2c6a.js → BMI_GIRLS.zscore.weekly-fbe99176.js} +0 -0
  395. /package/build/{BMI_GIRLS.zscore.yearly-1cca63a0.js → BMI_GIRLS.zscore.yearly-de7359f0.js} +0 -0
  396. /package/build/{ChevronDown-666ab37d.js → ChevronDown-b3053e28.js} +0 -0
  397. /package/build/{Close-1b6e6466.js → Close-2bfa4de9.js} +0 -0
  398. /package/build/{Google-255c0f1a.js → Google-a87d9a0a.js} +0 -0
  399. /package/build/{HEAD CIRCUM_BOYS.percentile.monthly-27b74016.js → HEAD CIRCUM_BOYS.percentile.monthly-fcfa2287.js} +0 -0
  400. /package/build/{HEAD CIRCUM_BOYS.percentile.weekly-44d2ee86.js → HEAD CIRCUM_BOYS.percentile.weekly-4748fbba.js} +0 -0
  401. /package/build/{HEAD CIRCUM_BOYS.percentile.yearly-8da7f001.js → HEAD CIRCUM_BOYS.percentile.yearly-26b87f29.js} +0 -0
  402. /package/build/{HEAD CIRCUM_BOYS.zscore.monthly-61e5db90.js → HEAD CIRCUM_BOYS.zscore.monthly-d51081cd.js} +0 -0
  403. /package/build/{HEAD CIRCUM_BOYS.zscore.weekly-25d8b075.js → HEAD CIRCUM_BOYS.zscore.weekly-2c7c8d43.js} +0 -0
  404. /package/build/{HEAD CIRCUM_BOYS.zscore.yearly-1e6e1e4e.js → HEAD CIRCUM_BOYS.zscore.yearly-59038af9.js} +0 -0
  405. /package/build/{HEAD CIRCUM_GIRLS.percentile.monthly-bdd4a98b.js → HEAD CIRCUM_GIRLS.percentile.monthly-b3854633.js} +0 -0
  406. /package/build/{HEAD CIRCUM_GIRLS.percentile.weekly-c22eafb0.js → HEAD CIRCUM_GIRLS.percentile.weekly-da3cd667.js} +0 -0
  407. /package/build/{HEAD CIRCUM_GIRLS.percentile.yearly-e63f3462.js → HEAD CIRCUM_GIRLS.percentile.yearly-5ce86b08.js} +0 -0
  408. /package/build/{HEAD CIRCUM_GIRLS.zscore.monthly-ba864f1d.js → HEAD CIRCUM_GIRLS.zscore.monthly-752848a2.js} +0 -0
  409. /package/build/{HEAD CIRCUM_GIRLS.zscore.weekly-0ab88ce6.js → HEAD CIRCUM_GIRLS.zscore.weekly-d09f39b2.js} +0 -0
  410. /package/build/{HEAD CIRCUM_GIRLS.zscore.yearly-5f6cd980.js → HEAD CIRCUM_GIRLS.zscore.yearly-6e6ca083.js} +0 -0
  411. /package/build/{HEIGHT_BOYS.percentile.monthly-de94349f.js → HEIGHT_BOYS.percentile.monthly-8d7369e7.js} +0 -0
  412. /package/build/{HEIGHT_BOYS.percentile.weekly-0deb1e2e.js → HEIGHT_BOYS.percentile.weekly-f90e07a6.js} +0 -0
  413. /package/build/{HEIGHT_BOYS.percentile.yearly-de56c11c.js → HEIGHT_BOYS.percentile.yearly-06b42d06.js} +0 -0
  414. /package/build/{HEIGHT_BOYS.zscore.monthly-2ec7ba91.js → HEIGHT_BOYS.zscore.monthly-afe33d38.js} +0 -0
  415. /package/build/{HEIGHT_BOYS.zscore.weekly-ca549a20.js → HEIGHT_BOYS.zscore.weekly-41071729.js} +0 -0
  416. /package/build/{HEIGHT_BOYS.zscore.yearly-1a550c19.js → HEIGHT_BOYS.zscore.yearly-664e98c3.js} +0 -0
  417. /package/build/{HEIGHT_GIRLS.percentile.monthly-4ed4b34f.js → HEIGHT_GIRLS.percentile.monthly-b62d1af0.js} +0 -0
  418. /package/build/{HEIGHT_GIRLS.percentile.weekly-8e84201b.js → HEIGHT_GIRLS.percentile.weekly-14c524e0.js} +0 -0
  419. /package/build/{HEIGHT_GIRLS.percentile.yearly-ae554a2e.js → HEIGHT_GIRLS.percentile.yearly-5b4de05e.js} +0 -0
  420. /package/build/{HEIGHT_GIRLS.zscore.monthly-e39acd9f.js → HEIGHT_GIRLS.zscore.monthly-2d9a5528.js} +0 -0
  421. /package/build/{HEIGHT_GIRLS.zscore.weekly-c1ac2f72.js → HEIGHT_GIRLS.zscore.weekly-ac9cdb3b.js} +0 -0
  422. /package/build/{HEIGHT_GIRLS.zscore.yearly-e60e8414.js → HEIGHT_GIRLS.zscore.yearly-fdbc990a.js} +0 -0
  423. /package/build/{Visible-3c7c545a.js → Visible-20d01c26.js} +0 -0
  424. /package/build/{WEIGHT_BOYS.percentile.monthly-7907d7d8.js → WEIGHT_BOYS.percentile.monthly-08000cbd.js} +0 -0
  425. /package/build/{WEIGHT_BOYS.percentile.weekly-ffe2e09f.js → WEIGHT_BOYS.percentile.weekly-bd8ca272.js} +0 -0
  426. /package/build/{WEIGHT_BOYS.percentile.yearly-5613db72.js → WEIGHT_BOYS.percentile.yearly-578f7986.js} +0 -0
  427. /package/build/{WEIGHT_BOYS.zscore.monthly-0c71e1f1.js → WEIGHT_BOYS.zscore.monthly-9b1d5348.js} +0 -0
  428. /package/build/{WEIGHT_BOYS.zscore.weekly-551fbe61.js → WEIGHT_BOYS.zscore.weekly-379ca8a0.js} +0 -0
  429. /package/build/{WEIGHT_BOYS.zscore.yearly-faf021d6.js → WEIGHT_BOYS.zscore.yearly-9dde6f32.js} +0 -0
  430. /package/build/{WEIGHT_GIRLS.percentile.monthly-5e32962a.js → WEIGHT_GIRLS.percentile.monthly-df2b9297.js} +0 -0
  431. /package/build/{WEIGHT_GIRLS.percentile.weekly-3bf46095.js → WEIGHT_GIRLS.percentile.weekly-9fc94276.js} +0 -0
  432. /package/build/{WEIGHT_GIRLS.percentile.yearly-081bb76a.js → WEIGHT_GIRLS.percentile.yearly-bd17753b.js} +0 -0
  433. /package/build/{WEIGHT_GIRLS.zscore.monthly-278e2e2f.js → WEIGHT_GIRLS.zscore.monthly-6b0fda53.js} +0 -0
  434. /package/build/{WEIGHT_GIRLS.zscore.weekly-7b2b5cb3.js → WEIGHT_GIRLS.zscore.weekly-50dc7304.js} +0 -0
  435. /package/build/{WEIGHT_GIRLS.zscore.yearly-3f573da9.js → WEIGHT_GIRLS.zscore.yearly-acf28a4e.js} +0 -0
  436. /package/build/{animation-4a4be1d2.js → animation-5cb8a282.js} +0 -0
  437. /package/build/{constants-455c1bb4.js → constants-0c231590.js} +0 -0
  438. /package/build/{constants-a6d2ff76.js → constants-a476f276.js} +0 -0
  439. /package/build/{dataTransform-b60c06bb.js → dataTransform-fb4a13be.js} +0 -0
  440. /package/build/{doctor-1f6e5f33.js → doctor-98332328.js} +0 -0
  441. /package/build/esm/{BMI_BOYS.percentile.monthly-92d9c1f0.js → BMI_BOYS.percentile.monthly-b3d77d98.js} +0 -0
  442. /package/build/esm/{BMI_BOYS.percentile.weekly-ee2eb412.js → BMI_BOYS.percentile.weekly-e4409f30.js} +0 -0
  443. /package/build/esm/{BMI_BOYS.percentile.yearly-1633c579.js → BMI_BOYS.percentile.yearly-c2ba196b.js} +0 -0
  444. /package/build/esm/{BMI_BOYS.zscore.monthly-7cae8cf3.js → BMI_BOYS.zscore.monthly-28d2eae7.js} +0 -0
  445. /package/build/esm/{BMI_BOYS.zscore.weekly-8d5a6c27.js → BMI_BOYS.zscore.weekly-072785a9.js} +0 -0
  446. /package/build/esm/{BMI_BOYS.zscore.yearly-4385bf15.js → BMI_BOYS.zscore.yearly-b11bb01a.js} +0 -0
  447. /package/build/esm/{BMI_GIRLS.percentile.monthly-39965bce.js → BMI_GIRLS.percentile.monthly-8d2c0e92.js} +0 -0
  448. /package/build/esm/{BMI_GIRLS.percentile.weekly-04c50c49.js → BMI_GIRLS.percentile.weekly-6dd3a2df.js} +0 -0
  449. /package/build/esm/{BMI_GIRLS.percentile.yearly-c52eda5f.js → BMI_GIRLS.percentile.yearly-8c258515.js} +0 -0
  450. /package/build/esm/{BMI_GIRLS.zscore.monthly-c706b650.js → BMI_GIRLS.zscore.monthly-972ccee4.js} +0 -0
  451. /package/build/esm/{BMI_GIRLS.zscore.weekly-465b90ff.js → BMI_GIRLS.zscore.weekly-f9cb601d.js} +0 -0
  452. /package/build/esm/{BMI_GIRLS.zscore.yearly-ed0e918a.js → BMI_GIRLS.zscore.yearly-b55710e3.js} +0 -0
  453. /package/build/esm/{ChevronDown-3f8ce34e.js → ChevronDown-319bf056.js} +0 -0
  454. /package/build/esm/{Close-544c792d.js → Close-1f4384ad.js} +0 -0
  455. /package/build/esm/{Google-07add6d7.js → Google-687c736b.js} +0 -0
  456. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.monthly-36488681.js → HEAD CIRCUM_BOYS.percentile.monthly-063e77c2.js} +0 -0
  457. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.weekly-23fc9978.js → HEAD CIRCUM_BOYS.percentile.weekly-1b8aafa2.js} +0 -0
  458. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.yearly-854f13e0.js → HEAD CIRCUM_BOYS.percentile.yearly-1f1442b4.js} +0 -0
  459. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.monthly-4d4dbf90.js → HEAD CIRCUM_BOYS.zscore.monthly-401a71a1.js} +0 -0
  460. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.weekly-9f181b10.js → HEAD CIRCUM_BOYS.zscore.weekly-e66935f8.js} +0 -0
  461. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.yearly-6e8bcb7d.js → HEAD CIRCUM_BOYS.zscore.yearly-44d4a37d.js} +0 -0
  462. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.monthly-bdeb8d21.js → HEAD CIRCUM_GIRLS.percentile.monthly-e2ad3c40.js} +0 -0
  463. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.weekly-bf8d0a97.js → HEAD CIRCUM_GIRLS.percentile.weekly-be25306c.js} +0 -0
  464. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.yearly-230957db.js → HEAD CIRCUM_GIRLS.percentile.yearly-d8016c18.js} +0 -0
  465. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.monthly-20e5c1d6.js → HEAD CIRCUM_GIRLS.zscore.monthly-81d91bc2.js} +0 -0
  466. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.weekly-3993abe9.js → HEAD CIRCUM_GIRLS.zscore.weekly-06060441.js} +0 -0
  467. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.yearly-6891fbfc.js → HEAD CIRCUM_GIRLS.zscore.yearly-a176ab45.js} +0 -0
  468. /package/build/esm/{HEIGHT_BOYS.percentile.monthly-2570d419.js → HEIGHT_BOYS.percentile.monthly-c6c5bfc8.js} +0 -0
  469. /package/build/esm/{HEIGHT_BOYS.percentile.weekly-606af351.js → HEIGHT_BOYS.percentile.weekly-4fe18742.js} +0 -0
  470. /package/build/esm/{HEIGHT_BOYS.percentile.yearly-37c2dd55.js → HEIGHT_BOYS.percentile.yearly-9c591c43.js} +0 -0
  471. /package/build/esm/{HEIGHT_BOYS.zscore.monthly-81178889.js → HEIGHT_BOYS.zscore.monthly-f7d9a199.js} +0 -0
  472. /package/build/esm/{HEIGHT_BOYS.zscore.weekly-3178efa9.js → HEIGHT_BOYS.zscore.weekly-ee062e19.js} +0 -0
  473. /package/build/esm/{HEIGHT_BOYS.zscore.yearly-493f4e9a.js → HEIGHT_BOYS.zscore.yearly-5c3cef1c.js} +0 -0
  474. /package/build/esm/{HEIGHT_GIRLS.percentile.monthly-0f1f5d53.js → HEIGHT_GIRLS.percentile.monthly-ab1c4da7.js} +0 -0
  475. /package/build/esm/{HEIGHT_GIRLS.percentile.weekly-02ef3a08.js → HEIGHT_GIRLS.percentile.weekly-e7b6e8e4.js} +0 -0
  476. /package/build/esm/{HEIGHT_GIRLS.percentile.yearly-46a52ffd.js → HEIGHT_GIRLS.percentile.yearly-b7a22445.js} +0 -0
  477. /package/build/esm/{HEIGHT_GIRLS.zscore.monthly-59d32be7.js → HEIGHT_GIRLS.zscore.monthly-ed2bf049.js} +0 -0
  478. /package/build/esm/{HEIGHT_GIRLS.zscore.weekly-934f71dc.js → HEIGHT_GIRLS.zscore.weekly-03a0273c.js} +0 -0
  479. /package/build/esm/{HEIGHT_GIRLS.zscore.yearly-eeefcd63.js → HEIGHT_GIRLS.zscore.yearly-2e7f3b16.js} +0 -0
  480. /package/build/esm/{Visible-6f57a2db.js → Visible-870c370a.js} +0 -0
  481. /package/build/esm/{WEIGHT_BOYS.percentile.monthly-876f2a6d.js → WEIGHT_BOYS.percentile.monthly-10a4736f.js} +0 -0
  482. /package/build/esm/{WEIGHT_BOYS.percentile.weekly-67700803.js → WEIGHT_BOYS.percentile.weekly-0f1de588.js} +0 -0
  483. /package/build/esm/{WEIGHT_BOYS.percentile.yearly-b2adebd1.js → WEIGHT_BOYS.percentile.yearly-9b3c47b0.js} +0 -0
  484. /package/build/esm/{WEIGHT_BOYS.zscore.monthly-38e643db.js → WEIGHT_BOYS.zscore.monthly-681179fd.js} +0 -0
  485. /package/build/esm/{WEIGHT_BOYS.zscore.weekly-ed370d92.js → WEIGHT_BOYS.zscore.weekly-522a296e.js} +0 -0
  486. /package/build/esm/{WEIGHT_BOYS.zscore.yearly-158f3120.js → WEIGHT_BOYS.zscore.yearly-75f527d4.js} +0 -0
  487. /package/build/esm/{WEIGHT_GIRLS.percentile.monthly-19ed2ff2.js → WEIGHT_GIRLS.percentile.monthly-14c79e56.js} +0 -0
  488. /package/build/esm/{WEIGHT_GIRLS.percentile.weekly-c07ebd4a.js → WEIGHT_GIRLS.percentile.weekly-23326d83.js} +0 -0
  489. /package/build/esm/{WEIGHT_GIRLS.percentile.yearly-d2eb7f92.js → WEIGHT_GIRLS.percentile.yearly-111acd33.js} +0 -0
  490. /package/build/esm/{WEIGHT_GIRLS.zscore.monthly-2d39112e.js → WEIGHT_GIRLS.zscore.monthly-b902754a.js} +0 -0
  491. /package/build/esm/{WEIGHT_GIRLS.zscore.weekly-79c13caa.js → WEIGHT_GIRLS.zscore.weekly-a64bc9d2.js} +0 -0
  492. /package/build/esm/{WEIGHT_GIRLS.zscore.yearly-686b8120.js → WEIGHT_GIRLS.zscore.yearly-b2980e84.js} +0 -0
  493. /package/build/esm/{animation-f0de7fec.js → animation-c70af288.js} +0 -0
  494. /package/build/esm/{constants-67817a3e.js → constants-97ced596.js} +0 -0
  495. /package/build/esm/{constants-7a94d96a.js → constants-e9127712.js} +0 -0
  496. /package/build/esm/{dataTransform-96b33da1.js → dataTransform-a5ace7a9.js} +0 -0
  497. /package/build/esm/{doctor-ce62bcf6.js → doctor-aff6ffe0.js} +0 -0
  498. /package/build/esm/{index-0fcc7e05.js → index-0869dad7.js} +0 -0
  499. /package/build/esm/{index-d14b8ec2.js → index-39ead392.js} +0 -0
  500. /package/build/esm/{index-b814b571.js → index-48ff8880.js} +0 -0
  501. /package/build/esm/{index-20fe498c.js → index-4fc08219.js} +0 -0
  502. /package/build/esm/{index-2f816408.js → index-77e34fdf.js} +0 -0
  503. /package/build/esm/{index-a9b9cf40.js → index-b409a437.js} +0 -0
  504. /package/build/esm/{index-50922feb.js → index-ed1c9d98.js} +0 -0
  505. /package/build/esm/{index-bd1a993e.js → index-ee0d43e6.js} +0 -0
  506. /package/build/esm/{index.styles-c9d6db26.js → index.styles-9a39d828.js} +0 -0
  507. /package/build/esm/{localizeNumberFormat-91191f3b.js → localizeNumberFormat-9c2b34a7.js} +0 -0
  508. /package/build/esm/{normalizeLink-6e07e5c4.js → normalizeLink-c0dec424.js} +0 -0
  509. /package/build/esm/{number-9e7857e2.js → number-509e4127.js} +0 -0
  510. /package/build/esm/{other-7cac897b.js → other-ad977443.js} +0 -0
  511. /package/build/esm/{paths-eb036f12.js → paths-ec7f919f.js} +0 -0
  512. /package/build/esm/{translationsContext-23b5bf84.js → translationsContext-13869044.js} +0 -0
  513. /package/build/esm/{tslib.es6-eb6746ec.js → tslib.es6-34c3d3bf.js} +0 -0
  514. /package/build/esm/{types-1466329a.js → types-addbc5c7.js} +0 -0
  515. /package/build/esm/{useIsInit-58c92435.js → useIsInit-01f8095d.js} +0 -0
  516. /package/build/esm/{useOutsideClick-d1408b13.js → useOutsideClick-884ef400.js} +0 -0
  517. /package/build/esm/{useScrollbarSize-af69fd45.js → useScrollbarSize-23749c51.js} +0 -0
  518. /package/build/esm/{useUniqueId-15198ead.js → useUniqueId-bf8b1319.js} +0 -0
  519. /package/build/esm/{utils-770949fe.js → utils-f97b6496.js} +0 -0
  520. /package/build/{index-fae28861.js → index-07a1f62b.js} +0 -0
  521. /package/build/{index-fd00f1ea.js → index-68861972.js} +0 -0
  522. /package/build/{index-cd4f0240.js → index-73755798.js} +0 -0
  523. /package/build/{index-1e874626.js → index-742af7a1.js} +0 -0
  524. /package/build/{index-a5d52534.js → index-a67e4960.js} +0 -0
  525. /package/build/{index-c30aae56.js → index-ab4afcac.js} +0 -0
  526. /package/build/{index-a471322d.js → index-acf68981.js} +0 -0
  527. /package/build/{index-fce79e5f.js → index-e8db0333.js} +0 -0
  528. /package/build/{index.styles-f9818d05.js → index.styles-3160bc39.js} +0 -0
  529. /package/build/{localizeNumberFormat-ef732f37.js → localizeNumberFormat-fe015b70.js} +0 -0
  530. /package/build/{normalizeLink-65501df2.js → normalizeLink-4ea219af.js} +0 -0
  531. /package/build/{number-2ccfcc5f.js → number-8e287617.js} +0 -0
  532. /package/build/{other-4e4f19d4.js → other-7e106576.js} +0 -0
  533. /package/build/{paths-d2ea905c.js → paths-7f344af9.js} +0 -0
  534. /package/build/{translationsContext-3ac6ece2.js → translationsContext-da79cdd9.js} +0 -0
  535. /package/build/{tslib.es6-e879b440.js → tslib.es6-17e485ce.js} +0 -0
  536. /package/build/{types-2d921d78.js → types-3b12886f.js} +0 -0
  537. /package/build/{useIsInit-5cc2d405.js → useIsInit-585c0d5a.js} +0 -0
  538. /package/build/{useOutsideClick-795cda46.js → useOutsideClick-c7b9af7c.js} +0 -0
  539. /package/build/{useScrollbarSize-9fb99eed.js → useScrollbarSize-0074bb72.js} +0 -0
  540. /package/build/{useUniqueId-5f42952d.js → useUniqueId-09856594.js} +0 -0
  541. /package/build/{utils-a445506a.js → utils-a7668f82.js} +0 -0
package/build/esm/lead.js CHANGED
@@ -1,52 +1,73 @@
1
- import { _ as __rest, a as __awaiter } from './tslib.es6-eb6746ec.js';
2
- import React__default, { createContext, useMemo, useEffect, useRef, useState, useContext, useCallback } from 'react';
3
- import { createStyles, Box, Button as Button$1, Autocomplete, clsx, Input as Input$1, TextInput, NumberInput as NumberInput$1, Portal, Transition, Overlay } from '@mantine/core';
1
+ import { _ as __rest, a as __awaiter } from './tslib.es6-34c3d3bf.js';
2
+ import React__default, { createContext, useMemo, useEffect, useRef, useState, useContext, useCallback, forwardRef, useImperativeHandle, memo } from 'react';
3
+ import { createStyles, Box, Button as Button$1, Input as Input$1, clsx, Autocomplete, Checkbox as Checkbox$1, Radio as Radio$1, Select as Select$1, TextInput, NumberInput as NumberInput$1, Portal, Transition, Overlay } from '@mantine/core';
4
4
  import dayjs from 'dayjs';
5
5
  import debounce from 'lodash/debounce';
6
- import { createFormContext } from '@mantine/form';
7
- import { u as useTranslations } from './index-e401fea0.js';
8
- import { T as TranslationsContext } from './translationsContext-23b5bf84.js';
6
+ import { createFormContext, useForm } from '@mantine/form';
7
+ import { B as BEARER_TOKEN_COOKIE } from './index-22fd28bb.js';
9
8
  import { getCookie, setCookie } from './miscCookieHelper.js';
10
- import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-770949fe.js';
11
- import { T as Text } from './index-5024511e.js';
12
- import { S as Select, d as Checkbox, I as Input, R as Radio, P as Phone, N as NumberInput, O as OTP } from './index-e93b1f65.js';
13
- import { D as DatePicker } from './index-8885ef87.js';
14
- import { B as Button } from './index-6ab5e856.js';
15
- import './index.styles-c9d6db26.js';
9
+ import { u as useTranslations } from './index-97c7b8a6.js';
10
+ import { T as TranslationsContext } from './translationsContext-13869044.js';
11
+ import { M as MediaQueries, b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-f97b6496.js';
12
+ import { T as Text } from './index-8f74d63d.js';
13
+ import { S as Select, d as Checkbox, I as Input, R as Radio, P as Phone, N as NumberInput, O as OTP } from './index-d37dade0.js';
14
+ import { D as DatePicker } from './index-da65e1c5.js';
15
+ import { B as Button } from './index-cd4c901f.js';
16
+ import './index.styles-9a39d828.js';
16
17
  import { useClickOutside } from '@mantine/hooks';
17
- import './useMantineLocale-ee478730.js';
18
- import { C as COMMON_DATE_TRANSLATE_KEY } from './index-395867d1.js';
19
- import './index-bd1a993e.js';
20
- import { Z as ZINDEX_SSO, I as ISO_FORMAT } from './index-35c4c26f.js';
21
- import './other-7cac897b.js';
22
- import './index-7f0089a7.js';
23
- import { M as MAPPED_LOCALE } from './utils-84d5275f.js';
24
- import '@mantine/dates';
25
- import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-119a12f3.js';
26
- import { H as Heading$1 } from './index-5ff6b134.js';
18
+ import './useMantineLocale-95434bd7.js';
19
+ import { C as COMMON_DATE_TRANSLATE_KEY } from './index-6a09ecad.js';
20
+ import './index-ee0d43e6.js';
21
+ import { Z as ZINDEX_SSO, I as ISO_FORMAT } from './index-2b0b5ecd.js';
22
+ import './other-ad977443.js';
23
+ import './index-fef08243.js';
24
+ import { M as MAPPED_LOCALE } from './utils-b0412385.js';
25
+ import { DateInput } from '@mantine/dates';
26
+ import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-ef8cc9c6.js';
27
+ import { H as Heading$1 } from './index-1201d09e.js';
28
+ import { t as translationsMap$1 } from './translationsProvider-2b2fc65d.js';
29
+ import { L as LOCALE } from './Locale-6cbef683.js';
27
30
  import { v1 } from 'uuid';
28
- import { i as isVideo } from './index-d14b8ec2.js';
29
- import { D as DrawerComponent } from './index-44df64aa.js';
30
- import { u as useScreenSize } from './useScreenSize-241e66fa.js';
31
- import { createPortal } from 'react-dom';
32
- import { css } from '@emotion/react';
31
+ import { parsePhoneNumber } from 'react-phone-number-input';
33
32
  import styled from '@emotion/styled';
34
33
  import { theme } from './miscTheme.js';
35
- import { B as Button$2 } from './index-f4607daa.js';
36
- import { I as InputDate } from './InputDate-86cf8a56.js';
37
- import { C as Close } from './Close-544c792d.js';
34
+ import { css } from '@emotion/react';
35
+ import { T as TogetherComponentGlobalContext } from './utils-7e9b37e9.js';
36
+ import { i as isVideo } from './index-39ead392.js';
37
+ import { D as DrawerComponent } from './index-b4398a57.js';
38
+ import { u as useScreenSize } from './useScreenSize-bf03486c.js';
39
+ import { createPortal } from 'react-dom';
40
+ import { B as Button$2 } from './index-3f972b22.js';
41
+ import { I as InputDate } from './InputDate-ae62bf9a.js';
42
+ import { C as Close } from './Close-1f4384ad.js';
43
+ import './constantsIsProduction.js';
44
+ import './normalizeLink-c0dec424.js';
45
+ import './constantsDomainLocales.js';
38
46
  import '@hhgtech/icons/other';
39
47
  import '@mantine/carousel';
40
- import './Locale-3430abbb.js';
41
48
  import 'classnames';
42
- import './useUniqueId-15198ead.js';
49
+ import './useUniqueId-bf8b1319.js';
43
50
  import './constantsSite.js';
44
51
  import '@hhgtech/icons/core';
45
52
  import '@mantine/notifications';
46
- import './constantsDomainLocales.js';
47
- import './constantsIsProduction.js';
48
53
  import 'date-fns/locale';
49
54
  import './constantsRiskScreener.js';
55
+ import './i18n-values/en-PH.js';
56
+ import './i18n-values/hi-IN.js';
57
+ import './i18n-values/id-ID.js';
58
+ import './i18n-values/km-KH.js';
59
+ import './i18n-values/ms-MY.js';
60
+ import './i18n-values/my-MM.js';
61
+ import './i18n-values/th-TH.js';
62
+ import './i18n-values/tl-PH.js';
63
+ import './i18n-values/vi-VN.js';
64
+ import './i18n-values/vi-VN_MB.js';
65
+ import './i18n-values/zh-TW.js';
66
+ import './index-0869dad7.js';
67
+ import 'slugify';
68
+ import 'string-format';
69
+ import './togetherApiPaths.js';
70
+ import './constants-e9127712.js';
50
71
  import 'vaul';
51
72
 
52
73
  const LeadGenComponentContext = createContext({});
@@ -73,7 +94,7 @@ if (sessionStorage.getItem('insider_object')) {
73
94
  }
74
95
  const docLang = document.documentElement.lang;
75
96
  // TODO: country code
76
- const LEAD_LOCALE_DATA = {
97
+ const LEAD_LOCALE_DATA$1 = {
77
98
  'vi-VN': {
78
99
  popupLang: 'vi',
79
100
  countryCode: 'vn',
@@ -115,7 +136,7 @@ const LEAD_LOCALE_DATA = {
115
136
  countryCodeNumber: 91,
116
137
  },
117
138
  };
118
- const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
139
+ const LEAD_LOCALE = LEAD_LOCALE_DATA$1[docLang] || LEAD_LOCALE_DATA$1['vi-VN'];
119
140
  function LEAD_RESET_VAR() {
120
141
  // LEAD_CURRENT_URL = location.href.toLowerCase();
121
142
  LEAD_CURRENT_URL =
@@ -136,6 +157,11 @@ const LEAD_TIMEZONE_DATA = {
136
157
  9: 'Asia/Manila', // Philippines / Filipinos Site
137
158
  };
138
159
 
160
+ const LEADGEN_ACTIONS = {
161
+ SHOW: 'SHOW',
162
+ SCROLL: 'SCROLL',
163
+ TIME: 'TIME',
164
+ };
139
165
  const LEADGEN_LAYOUT = {
140
166
  LightBoxA: 'LightBoxA',
141
167
  LightBoxB: 'LightBoxB',
@@ -165,8 +191,10 @@ const LEADGEN_BLOCK = {
165
191
  DropdownBlock: 'DropdownBlock',
166
192
  CheckboxBlock: 'CheckboxBlock',
167
193
  TncBlock: 'TncBlock',
194
+ TitleBlock: 'TitleBlock',
195
+ SubtitleBlock: 'SubtitleBlock',
168
196
  };
169
- const LEADGEN_BLOCK_IN_FORM = [
197
+ const LEADGEN_BLOCK_INPUT = [
170
198
  LEADGEN_BLOCK.TextBlock,
171
199
  LEADGEN_BLOCK.NumberBlock,
172
200
  LEADGEN_BLOCK.DateBlock,
@@ -181,7 +209,59 @@ const LEADGEN_BLOCK_IN_FORM = [
181
209
  LEADGEN_BLOCK.CheckboxBlock,
182
210
  LEADGEN_BLOCK.TncBlock,
183
211
  ];
212
+ const leadGenFieldNamePhone = (listBlockAdded) => {
213
+ return listBlockAdded
214
+ .filter(({ name }) => [
215
+ LEADGEN_BLOCK.PhoneBlock,
216
+ LEADGEN_BLOCK.PhoneOtpBlock,
217
+ LEADGEN_BLOCK.WhatsappOtpBlock,
218
+ LEADGEN_BLOCK.ZaloOtpBlock,
219
+ ].includes(name))
220
+ .map(({ data }) => data.value);
221
+ };
184
222
  const SSO_MAP_LEAD = ['name', 'email', 'birthday', 'phone', 'gender'];
223
+ const LEAD_LOCALE_DATA = {
224
+ 'vi-VN': {
225
+ popupLang: 'vi',
226
+ countryCode: 'vn',
227
+ countryCodeNumber: 84,
228
+ },
229
+ 'id-ID': {
230
+ popupLang: 'id',
231
+ countryCode: 'id',
232
+ countryCodeNumber: 62,
233
+ },
234
+ 'th-TH': {
235
+ popupLang: 'th',
236
+ countryCode: 'th',
237
+ countryCodeNumber: 66,
238
+ },
239
+ 'ms-MY': {
240
+ popupLang: 'ms',
241
+ countryCode: 'my',
242
+ countryCodeNumber: 60,
243
+ },
244
+ 'zh-TW': {
245
+ popupLang: 'zh',
246
+ countryCode: 'tw',
247
+ countryCodeNumber: 886,
248
+ },
249
+ 'km-KH': {
250
+ popupLang: 'km',
251
+ countryCode: 'kh',
252
+ countryCodeNumber: 855,
253
+ },
254
+ 'my-MM': {
255
+ popupLang: 'my',
256
+ countryCode: 'mm',
257
+ countryCodeNumber: 95,
258
+ },
259
+ 'hi-IN': {
260
+ popupLang: 'hi',
261
+ countryCode: 'in',
262
+ countryCodeNumber: 91,
263
+ },
264
+ };
185
265
  const mappingSSOToLead = (userInfoProps) => {
186
266
  var _a, _b;
187
267
  try {
@@ -197,7 +277,7 @@ const mappingSSOToLead = (userInfoProps) => {
197
277
  if (ssoKey === 'birthday') {
198
278
  const dob = dayjs(initValue, 'YYYY-MM-DD', true);
199
279
  if (dob.isValid()) {
200
- user.birthday = dob;
280
+ user.birthday = dob.toDate();
201
281
  }
202
282
  }
203
283
  else if (ssoKey === 'gender') {
@@ -220,16 +300,83 @@ const mappingSSOToLead = (userInfoProps) => {
220
300
  catch (error) {
221
301
  return;
222
302
  }
303
+ };
304
+ const formatCampaignDetail = (campaign) => {
305
+ if (!campaign) {
306
+ return {};
307
+ }
308
+ try {
309
+ const { extra_fields, thank_you_image } = campaign || {};
310
+ const { textBlocks: exTextBlocks, imageBlocks: exImageBlocks, listBlockAdded: exListBlockAdded, listBlockThankyou: exListBlockThankyou, actionBlocks: exActionBlocks, } = extra_fields;
311
+ const textBlocks = JSON.parse(exTextBlocks);
312
+ const imageBlocks = JSON.parse(exImageBlocks);
313
+ const listBlockAdded = JSON.parse(exListBlockAdded);
314
+ const listBlockThankyou = JSON.parse(exListBlockThankyou);
315
+ const actionBlocks = JSON.parse(exActionBlocks);
316
+ const ThankYouBlock = {
317
+ image: { src: thank_you_image },
318
+ };
319
+ listBlockThankyou.forEach((block) => {
320
+ const { name, data } = block || {};
321
+ const { value: htmlText, align, newtab, url } = data || {};
322
+ switch (name) {
323
+ case LEADGEN_BLOCK.TitleBlock: {
324
+ ThankYouBlock.title = { htmlText, align };
325
+ }
326
+ case LEADGEN_BLOCK.SubtitleBlock: {
327
+ ThankYouBlock.description = { htmlText, align };
328
+ }
329
+ case LEADGEN_BLOCK.LinkButtonBlock: {
330
+ ThankYouBlock.button = { htmlText, newtab, url };
331
+ }
332
+ }
333
+ });
334
+ return Object.assign(Object.assign({}, campaign), { extra_fields: Object.assign(Object.assign({}, extra_fields), { textBlocks,
335
+ imageBlocks,
336
+ listBlockAdded,
337
+ listBlockThankyou,
338
+ actionBlocks }), ThankYouBlock });
339
+ }
340
+ catch (error) {
341
+ return {};
342
+ }
223
343
  };
224
344
 
225
345
  class Store {
226
346
  constructor() {
347
+ this.apiSsoUrl = 'https://staging-id.hellobacsi.com/';
227
348
  this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
228
349
  this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
229
350
  }
230
351
  }
231
352
  const leadStore = new Store();
232
353
 
354
+ const METHOD = {
355
+ GET: 'get',
356
+ POST: 'POST',
357
+ };
358
+ const LEADGEN_API_PATH = {
359
+ V2_CAMPAIGN: 'api/v2/campaign',
360
+ V2_SUBSCRIPTION_LEAD: 'api/v2/subscription-box',
361
+ V2_SUBSCRIPTION_INFO: 'api/campaign/get-title',
362
+ };
363
+ const SSO_API_PATH = {
364
+ USER_UPDATE: 'api/user/update',
365
+ };
366
+ const ssoApi = {
367
+ call(_a) {
368
+ var { url, data } = _a, config = __rest(_a, ["url", "data"]);
369
+ const token = getCookie(BEARER_TOKEN_COOKIE);
370
+ config.body = JSON.stringify(data);
371
+ config.headers = {
372
+ 'Content-Type': 'application/json',
373
+ Authorization: `Bearer ${token}`,
374
+ };
375
+ return fetch(`${leadStore.apiSsoUrl}${url}`, config)
376
+ .then((res) => res.json())
377
+ .catch(() => ({}));
378
+ },
379
+ };
233
380
  const leadApi = {
234
381
  call(_a) {
235
382
  var { url, data = undefined } = _a, config = __rest(_a, ["url", "data"]);
@@ -333,8 +480,54 @@ const verifyOtpLead = ({ phone, otp, type, }) => {
333
480
  },
334
481
  });
335
482
  };
483
+ const getCampaignByCode = (campaign_code) => {
484
+ return leadApi.call({
485
+ url: `${LEADGEN_API_PATH.V2_CAMPAIGN}/${campaign_code}`,
486
+ method: METHOD.GET,
487
+ });
488
+ };
489
+ const getSubscriptionBoxInfo = ({ category, site, }) => {
490
+ return leadApi.call({
491
+ url: `${LEADGEN_API_PATH.V2_SUBSCRIPTION_INFO}?category=${category}&site=${site}`,
492
+ method: METHOD.GET,
493
+ });
494
+ };
495
+ const postSubscriptionBoxLead = ({ data }) => {
496
+ return leadApi.call({
497
+ url: LEADGEN_API_PATH.V2_SUBSCRIPTION_LEAD,
498
+ method: METHOD.POST,
499
+ data,
500
+ });
501
+ };
502
+ const postUserInfoFromLeadGen = ({ name }) => {
503
+ return ssoApi.call({
504
+ url: SSO_API_PATH.USER_UPDATE,
505
+ method: METHOD.POST,
506
+ data: { name },
507
+ });
508
+ };
509
+ const campaignPostImpression = ({ code, action, title_article, ga_client_id, cookie_id, extra, url, referrer, }) => {
510
+ return leadApi.call({
511
+ url: `api/campaign/${code}/impression`,
512
+ method: METHOD.POST,
513
+ data: {
514
+ action,
515
+ title_article,
516
+ cookie_id,
517
+ ga_client_id,
518
+ url,
519
+ extra,
520
+ referrer,
521
+ },
522
+ });
523
+ };
336
524
  const Service = {
337
525
  campaignGetById,
526
+ getCampaignByCode,
527
+ getSubscriptionBoxInfo,
528
+ postSubscriptionBoxLead,
529
+ postUserInfoFromLeadGen,
530
+ campaignPostImpression,
338
531
  validateEmailOrPhoneOnSubot,
339
532
  validateEmailOrPhoneOnLeadGen,
340
533
  validatePhoneNumberOnLeadGen,
@@ -674,7 +867,7 @@ const Description = (_a) => {
674
867
  return description ? (React__default.createElement(Text, Object.assign({ size: "p3" }, rest), description)) : null;
675
868
  };
676
869
 
677
- const LeadGenContext = createContext({});
870
+ const LeadGenContext$1 = createContext({});
678
871
 
679
872
  var useStyles$2 = createStyles(() => {
680
873
  return {
@@ -738,7 +931,7 @@ const SubtitleBlock$1 = ({ children, align, }) => (React__default.createElement(
738
931
  const TitleBlock$1 = ({ children, align, }) => (React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
739
932
 
740
933
  const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, popoverProps, }) => {
741
- const { primaryColor } = useContext(LeadGenContext);
934
+ const { primaryColor } = useContext(LeadGenContext$1);
742
935
  const { classes, cx } = useStyles$2(undefined, {
743
936
  name: 'LeadGen__Field',
744
937
  styles,
@@ -853,7 +1046,7 @@ const Heading = (_a) => {
853
1046
 
854
1047
  const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps, submitProps, }) => {
855
1048
  var _a;
856
- const { primaryColor } = useContext(LeadGenContext);
1049
+ const { primaryColor } = useContext(LeadGenContext$1);
857
1050
  const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, setFormRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = useContext(LeadGenComponentContext);
858
1051
  const { classes, cx } = useStyles$1(undefined, {
859
1052
  name: 'LeadGen__FormComponent',
@@ -1363,149 +1556,1704 @@ const translationsMap = {
1363
1556
  'my-MM': myMM,
1364
1557
  'km-KH': kmKH,
1365
1558
  'zh-TW': zhTW,
1559
+ 'zh-CN': zhTW,
1366
1560
  'th-TH': thTH,
1367
1561
  'tl-PH': enPH,
1368
1562
  };
1369
1563
  const getTranslations = (locale) => {
1370
- const translations = translationsMap[locale];
1564
+ const translations = Object.assign(Object.assign({}, translationsMap$1[locale]), translationsMap[locale]);
1371
1565
  if (translations) {
1372
1566
  return translations;
1373
1567
  }
1374
1568
  return translationsMap['en-PH'];
1375
1569
  };
1376
1570
 
1377
- const useImageSize = (src) => {
1378
- const [width, setWidth] = useState(16);
1379
- const [height, setHeight] = useState(9);
1380
- const [loaded, setLoaded] = useState(false);
1381
- // load src image to get its width and height
1382
- useEffect(() => {
1383
- setLoaded(false);
1384
- if (src) {
1385
- const img = new Image();
1386
- img.addEventListener('load', () => {
1387
- setWidth(img.naturalWidth);
1388
- setHeight(img.naturalHeight);
1389
- setLoaded(true);
1390
- });
1391
- img.addEventListener('error', () => {
1392
- setWidth(16);
1393
- setHeight(9);
1394
- setLoaded(true);
1395
- });
1396
- img.src = src;
1397
- }
1398
- else {
1399
- setWidth(16);
1400
- setHeight(9);
1401
- setLoaded(true);
1402
- }
1403
- }, [src]);
1404
- return {
1405
- loaded,
1406
- width,
1407
- height,
1408
- };
1409
- };
1410
-
1411
- const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default.createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
1412
- React__default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
1413
- React__default.createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
1414
-
1415
- // url: imageBlocks.imageMobile.data.url
1416
- // newTab: imageBlocks.imageMobile.data.newtab
1417
- // imageMobile: campaignShow.image
1418
- // imageDestkop: campaignShow.image_desktop
1419
- const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
1420
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1421
- const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
1422
- if (!imageMobileLoaded || !imageDestkopLoaded)
1423
- return null;
1424
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
1425
- React__default.createElement("div", { className: "le-center-tab-popup" },
1426
- React__default.createElement("div", { style: { position: 'relative' } },
1427
- React__default.createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
1428
- isVideo(imageMobile) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
1429
- React__default.createElement("source", { src: imageMobile }))) : (React__default.createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
1430
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1431
- } })),
1432
- isVideo(imageDestkop) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
1433
- React__default.createElement("source", { src: imageDestkop }))) : (React__default.createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
1434
- aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
1435
- } }))),
1436
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
1437
- };
1438
-
1439
- // title: titleText
1440
- // titleAlign: textBlocks.titleBlock.data.align
1441
- // subtitle: textBlocks.subtitleBlock.data.value
1442
- // subtitleAlign: textBlocks.subtitleBlock.data.align
1443
- // url: actionBlocks.linkButtonBlock.data.url
1444
- // urlText: actionBlocks.linkButtonBlock.data.value
1445
- // newTab: actionBlocks.linkButtonBlock.data.newtab
1446
- // imageMobile: campaignShow.image
1447
- // imageDesktop: campaignShow.image_desktop
1448
- const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
1449
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1450
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
1451
- if (!imageMobileLoaded || !imageDesktopLoaded)
1452
- return null;
1453
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
1454
- React__default.createElement("aside", { className: "le-only-desktop" },
1455
- React__default.createElement("div", { className: "le-floating-desktop" },
1456
- React__default.createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
1457
- imageDesktop ? (React__default.createElement("div", null,
1458
- React__default.createElement("img", { style: {
1459
- maxWidth: 120,
1460
- borderTopLeftRadius: 5,
1461
- borderBottomLeftRadius: 5,
1462
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
1463
- }, src: imageDesktop }))) : null,
1464
- React__default.createElement("div", { style: { padding: 20 } },
1465
- React__default.createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
1466
- React__default.createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
1467
- React__default.createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
1468
- React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
1469
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
1470
- React__default.createElement("aside", { className: "le-only-mobile" },
1471
- React__default.createElement("div", { className: "le-floating-mobile" },
1472
- React__default.createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
1473
- React__default.createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
1474
- React__default.createElement("div", null,
1475
- React__default.createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
1476
- React__default.createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
1477
- imageMobile ? (React__default.createElement("div", null,
1478
- React__default.createElement("img", { style: {
1479
- marginLeft: 15,
1480
- marginTop: 4,
1481
- maxWidth: 100,
1482
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1483
- }, src: imageMobile }))) : null),
1484
- React__default.createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
1485
- React__default.createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
1486
- React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
1487
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
1571
+ const LeadGenTranslationProvider = (props) => {
1572
+ const { locale, children } = props;
1573
+ const translationContextValue = useMemo(() => ({ locale, values: getTranslations(locale) }), [locale]);
1574
+ return (React__default.createElement(TranslationsContext.Provider, { value: translationContextValue }, children));
1488
1575
  };
1489
1576
 
1490
- const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
1491
- const { primaryColor } = useContext(LeadGenContext);
1492
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
1493
- if (!imageLoaded)
1577
+ // import mockLeadData from './mockLeadData'
1578
+ const listCampaignScheduled = [];
1579
+ const listCampaignScheduledToActivated = [];
1580
+ const listCampaignActiveButExpired = [];
1581
+ const listCampaignExcludeSonsored = [];
1582
+ const listCampaignDifferentSponsor = [];
1583
+ const listCampaignNotDisplayInRangeOfTime = [];
1584
+ function isMobile() {
1585
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
1586
+ }
1587
+ const getShuffleArray = (array) => {
1588
+ const newArray = [...array];
1589
+ for (let i = newArray.length - 1; i > 0; i--) {
1590
+ const j = Math.floor(Math.random() * (i + 1));
1591
+ const temp = newArray[i];
1592
+ newArray[i] = newArray[j];
1593
+ newArray[j] = temp;
1594
+ }
1595
+ return newArray;
1596
+ };
1597
+ const getTimeByTimezone = (timeZone = 'UTC') => {
1598
+ const date = new Date();
1599
+ return new Date(date.toLocaleString('en-US', { timeZone }));
1600
+ };
1601
+ const parseDateByCampaignTime = (dateStr) => {
1602
+ // Format like this: 2023-04-04 00:00:00
1603
+ try {
1604
+ const [datePart, timePart] = dateStr.split(' ');
1605
+ const [year, month, day] = datePart.split('-').map(Number);
1606
+ const [hours, minutes, seconds] = timePart.split(':').map(Number);
1607
+ /** JavaScript counts months from 0 to 11 */
1608
+ return new Date(year, month - 1, day, hours, minutes, seconds);
1609
+ }
1610
+ catch (err) {
1494
1611
  return null;
1495
- return (React__default.createElement("div", { className: "lead-modal__thank-you leadgen-inner_thankyou" },
1496
- React__default.createElement("div", { style: { width: '100%' } },
1497
- React__default.createElement("img", { src: image, style: {
1498
- maxHeight: 162,
1499
- objectFit: 'cover',
1500
- aspectRatio: `${imageWidth}/${imageHeight}`,
1501
- }, loading: "lazy" }),
1502
- title && (React__default.createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
1503
- subtitle && (React__default.createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle.split('\n').map((text, idx, list) => {
1504
- const isShowBr = idx < list.length - 1;
1505
- return (React__default.createElement(React__default.Fragment, null,
1506
- text,
1507
- isShowBr && React__default.createElement("br", null)));
1508
- }))),
1612
+ }
1613
+ };
1614
+ const checkCampaignNowInTimeframe = (c) => {
1615
+ var _a;
1616
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1617
+ const startedAtStr = c.started_at;
1618
+ const endedAtStr = c.ended_at;
1619
+ const startedDate = parseDateByCampaignTime(startedAtStr);
1620
+ const endedDate = parseDateByCampaignTime(endedAtStr);
1621
+ if (!startedDate || !endedDate) {
1622
+ return false;
1623
+ }
1624
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
1625
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1626
+ if (nowWithTimezoneMs <= endedDate.getTime() &&
1627
+ nowWithTimezoneMs >= startedDate.getTime()) {
1628
+ listCampaignScheduledToActivated.push(c);
1629
+ return true;
1630
+ }
1631
+ return false;
1632
+ };
1633
+ function checkCampaignActiveButExpireAlready(c) {
1634
+ var _a;
1635
+ /** Do not setup timeframe for this campaign. No need to check */
1636
+ if (c.forever === 1) {
1637
+ return true;
1638
+ }
1639
+ const startedAtStr = c.started_at;
1640
+ const endedAtStr = c.ended_at;
1641
+ const startedDate = parseDateByCampaignTime(startedAtStr);
1642
+ const endedDate = parseDateByCampaignTime(endedAtStr);
1643
+ /** Do not setup timeframe for this campaign. No need to check */
1644
+ if (!startedDate || !endedDate) {
1645
+ return true;
1646
+ }
1647
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1648
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
1649
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1650
+ /** Check if this expire already, do not show */
1651
+ if (nowWithTimezoneMs > endedDate.getTime()) {
1652
+ listCampaignActiveButExpired.push(c);
1653
+ return false;
1654
+ }
1655
+ return true;
1656
+ }
1657
+ function shouldNotDisplayIfExcludeAllSponsors(c) {
1658
+ var _a;
1659
+ const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
1660
+ const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
1661
+ if (isSponsored && excludeSponsored) {
1662
+ listCampaignExcludeSonsored.push(c);
1663
+ return true;
1664
+ }
1665
+ return false;
1666
+ }
1667
+ function shouldDisplayWithCurrentSponsor(c) {
1668
+ var _a, _b;
1669
+ try {
1670
+ // TODO: BE will rename `exclude_sponsored_list` later
1671
+ const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
1672
+ const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
1673
+ const dataSponsoredId = Number((_b = document
1674
+ .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
1675
+ // There is no config for sponsor id and white list, should show as default
1676
+ if (!dataSponsoredId ||
1677
+ dataSponsoredId <= 0 ||
1678
+ whiteListSponsors.length === 0) {
1679
+ return true;
1680
+ }
1681
+ // Check the dataSponsoredId exists in the white list or not.
1682
+ const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
1683
+ if (isExist) {
1684
+ return true;
1685
+ }
1686
+ listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
1687
+ return false;
1688
+ }
1689
+ catch (err) {
1690
+ // Default is show
1691
+ return true;
1692
+ }
1693
+ }
1694
+ const filterFnCampaign = (c) => {
1695
+ if (shouldNotDisplayIfExcludeAllSponsors(c)) {
1696
+ return false;
1697
+ }
1698
+ else if (!shouldDisplayWithCurrentSponsor(c)) {
1699
+ return false;
1700
+ }
1701
+ /** Active */
1702
+ if (c.formatted_status === 1) {
1703
+ return checkCampaignActiveButExpireAlready(c);
1704
+ }
1705
+ /** Schedule */
1706
+ if (c.formatted_status === 0) {
1707
+ listCampaignScheduled.push(c);
1708
+ return checkCampaignNowInTimeframe(c);
1709
+ }
1710
+ return false;
1711
+ };
1712
+ const fillterApprearanceTimeCampaign = (c) => {
1713
+ var _a;
1714
+ try {
1715
+ const isTimeInRange = (currentTime, startTime, endTime) => {
1716
+ const startParts = startTime.split(':');
1717
+ const endParts = endTime.split(':');
1718
+ const startDate = new Date();
1719
+ startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
1720
+ const endDate = new Date();
1721
+ endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
1722
+ return currentTime >= startDate && currentTime <= endDate;
1723
+ };
1724
+ const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
1725
+ const startTime = rulesApprValue.startTime;
1726
+ const endTime = rulesApprValue.endTime || '23:59';
1727
+ if (!startTime) {
1728
+ return true;
1729
+ }
1730
+ if (isTimeInRange(new Date(), startTime, endTime)) {
1731
+ return true;
1732
+ }
1733
+ listCampaignNotDisplayInRangeOfTime.push(c);
1734
+ return false;
1735
+ }
1736
+ catch (err) {
1737
+ return true;
1738
+ }
1739
+ };
1740
+ let timeoutRef = null;
1741
+ let LEAD_SCROLL_EVENT = null;
1742
+ function clearPassiveEvent() {
1743
+ if (timeoutRef) {
1744
+ clearTimeout(timeoutRef);
1745
+ timeoutRef = null;
1746
+ }
1747
+ if (LEAD_SCROLL_EVENT) {
1748
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1749
+ LEAD_SCROLL_EVENT = null;
1750
+ }
1751
+ }
1752
+ function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
1753
+ // clear previous passive event, check for new condition
1754
+ clearPassiveEvent();
1755
+ const leadCurrentUrl = DEBUG_URL ||
1756
+ ('https://' +
1757
+ location.hostname +
1758
+ location.pathname +
1759
+ location.search).toLowerCase();
1760
+ fetch(leadApi + 'api/campaign/' + leadSiteId, {
1761
+ method: 'POST',
1762
+ headers: {
1763
+ 'Content-Type': 'application/json',
1764
+ },
1765
+ body: JSON.stringify({
1766
+ url: leadCurrentUrl,
1767
+ ga_client_id: getCookie('_ga') || null,
1768
+ }),
1769
+ })
1770
+ .then((response) => {
1771
+ return response.json();
1772
+ // return mockLeadData || response.json()
1773
+ })
1774
+ .then((data) => {
1775
+ var _a, _b, _c, _d;
1776
+ LeadLog('List campagin: ', data);
1777
+ LEAD_RESET_VAR();
1778
+ if (data._status == 1) {
1779
+ const campaigns = (((_b = (_a = data._data) === null || _a === void 0 ? void 0 : _a.campaigns) === null || _b === void 0 ? void 0 : _b.filter(filterFnCampaign)) || []).filter(fillterApprearanceTimeCampaign);
1780
+ if (!getCookie('hhg-id')) {
1781
+ setCookie('hhg-id', v1(), {
1782
+ domain: '.' + leadDomain,
1783
+ path: '/',
1784
+ });
1785
+ LeadLog('😍 Set HHG ID cookie');
1786
+ }
1787
+ // getCookie('hhg-id')
1788
+ // TODO: HP-534 Filter desktop
1789
+ let campaignsDevice = [];
1790
+ if (isMobile()) {
1791
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
1792
+ }
1793
+ else {
1794
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
1795
+ }
1796
+ LeadLog(`👓 campaignsDevice`, campaignsDevice);
1797
+ LeadLog('--listCampaignScheduled', listCampaignScheduled);
1798
+ LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
1799
+ LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
1800
+ LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
1801
+ LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
1802
+ LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
1803
+ // Check links
1804
+ let listLinksObj = campaignsDevice
1805
+ .map((i, index) => i.targets
1806
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
1807
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1808
+ .flat(1);
1809
+ // Check list link match current href
1810
+ listLinksObj = listLinksObj.filter((i) => {
1811
+ var _a;
1812
+ const target = new URL(String(i.target).toLowerCase());
1813
+ if (i.option == 'exact_match')
1814
+ // FOR TEST LOCAL:
1815
+ // return Boolean(location.pathname === target.pathname)
1816
+ return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
1817
+ if (i.option == 'start_with') {
1818
+ // FOR TEST LOCAL:
1819
+ // if (location.pathname.includes(target.pathname)) {
1820
+ if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
1821
+ const listExcluding = i.sub_target
1822
+ .filter((i) => i.option == 'excluding')
1823
+ .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
1824
+ return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
1825
+ }
1826
+ else {
1827
+ return false;
1828
+ }
1829
+ }
1830
+ });
1831
+ // Check tags
1832
+ const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
1833
+ const listTags = listMetaTag.map((i) => i.content);
1834
+ let listCampaignHasTag = [];
1835
+ let listTagsObj = [];
1836
+ if (listTags && listTags.length) {
1837
+ listCampaignHasTag = campaignsDevice
1838
+ .map((i, index) => i.targets
1839
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
1840
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1841
+ .flat(1);
1842
+ listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
1843
+ }
1844
+ const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
1845
+ const cookieKeys = document.cookie
1846
+ .split('; ')
1847
+ .map((i) => i.split('=')[0]);
1848
+ const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
1849
+ LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
1850
+ const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
1851
+ LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
1852
+ const listCampaignSubmitedClosed = [
1853
+ ...listCampaignCodeSubmited,
1854
+ ...listCampaignCodeClosed,
1855
+ ];
1856
+ const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
1857
+ const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
1858
+ return !hasSubmited;
1859
+ });
1860
+ const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
1861
+ // .sort(
1862
+ // (a, b) =>
1863
+ // (listCampaignValid[a.campaignIndex]?.score || 0) -
1864
+ // (listCampaignValid[b.campaignIndex]?.score || 0),
1865
+ // )
1866
+ LeadLog('--listCampaignValid : ', listCampaignValid);
1867
+ if (listCampaignValid && listCampaignValid.length) {
1868
+ const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
1869
+ LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
1870
+ const { rules } = CAMPAIGN_SHOW;
1871
+ // CHECK RULE TRIGGER POPUP
1872
+ const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
1873
+ LeadLog(`timeoutRule`, timeoutRule);
1874
+ const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
1875
+ LeadLog(`scrollRule`, scrollRule);
1876
+ let impressionAction = 'TIME';
1877
+ if (Number.isInteger(timeoutRule)) {
1878
+ impressionAction = 'TIME';
1879
+ LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
1880
+ timeoutRef = setTimeout(() => {
1881
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1882
+ }, timeoutRule * 1000);
1883
+ }
1884
+ if (Number.isInteger(scrollRule)) {
1885
+ impressionAction = 'SCROLL';
1886
+ LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
1887
+ const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
1888
+ document.querySelector('body');
1889
+ const pct = $p.getBoundingClientRect().top;
1890
+ const pb = $p.offsetHeight;
1891
+ LeadLog(`👓 Element check scroll: `, $p);
1892
+ LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
1893
+ const wt = window.pageYOffset || document.documentElement.scrollTop;
1894
+ let percent = 0;
1895
+ if (wt >= pct) {
1896
+ percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
1897
+ }
1898
+ LeadLog('---Scroll', percent, scrollRule);
1899
+ // TODO: CHECK FOOTER HEIGHT
1900
+ if (percent >= scrollRule) {
1901
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1902
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1903
+ }
1904
+ };
1905
+ window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
1906
+ passive: true,
1907
+ });
1908
+ }
1909
+ }
1910
+ else {
1911
+ LeadLog('🚧 No lead campaigns on current URL, tags');
1912
+ }
1913
+ }
1914
+ })
1915
+ .catch((err) => {
1916
+ LeadLog(`Lead error: `, err);
1917
+ });
1918
+ }
1919
+ const LeadLog = (...params) => {
1920
+ if (process.env.NODE_ENV !== 'production' ||
1921
+ (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
1922
+ process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
1923
+ (typeof localStorage !== 'undefined' &&
1924
+ localStorage.getItem('hhg_debug') === 'true')) {
1925
+ console.log(...params);
1926
+ }
1927
+ };
1928
+
1929
+ const LeadGenContext = createContext({
1930
+ submit(value) {
1931
+ /** Init for FAKING function */
1932
+ LeadLog('** LeadGen Submit : ', value);
1933
+ return Promise.reject(value);
1934
+ },
1935
+ submitSubscriptionBox(value) {
1936
+ /** Init for FAKING function */
1937
+ LeadLog('** LeadGen SubmitSubscriptionBox : ', value);
1938
+ return Promise.reject(value);
1939
+ },
1940
+ impression(value) {
1941
+ /** Init for FAKING function */
1942
+ LeadLog('** LeadGen Impression : ', value);
1943
+ return Promise.reject(value);
1944
+ },
1945
+ /** For Subscription Box */
1946
+ subscriptionIcon: '',
1947
+ subscriptionTitle: '',
1948
+ });
1949
+ const LeadGenContextProvider = (props) => {
1950
+ const { campaign_code: campaignCodeProps, apiSsoUrl, apiLeadUrl, apiSubotUrl, locale: localeProps, forceCampaign: forceCampaignProps, extraValues, articleId = 1, categoryId = 1, siteDomain: site_domain, children, } = props;
1951
+ const [forceCampaign, setForceCampaign] = useState(forceCampaignProps);
1952
+ const [subscriptionInfo, setSubscriptionInfo] = useState({
1953
+ subscriptionIcon: '',
1954
+ subscriptionTitle: '',
1955
+ });
1956
+ const locale = useMemo(() => {
1957
+ return localeProps || LOCALE['PhilippinesEnglish'];
1958
+ }, [localeProps]);
1959
+ const leadGenContextValue = useMemo(() => (Object.assign(Object.assign({}, props), { forceCampaign })), [...Object.values(props), forceCampaign]);
1960
+ const { url, campaign_id, campaign_code, cookie_id, ga_client_id, category_id, article_id, article_title, } = useMemo(() => ({
1961
+ url: location.href.toLowerCase() || '',
1962
+ cookie_id: getCookie('hhg-id') || null,
1963
+ ga_client_id: getCookie('_ga'),
1964
+ campaign_id: forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id,
1965
+ campaign_code: campaignCodeProps || (forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.code),
1966
+ category_id: categoryId,
1967
+ article_id: articleId,
1968
+ article_title: document.title || '',
1969
+ }), [campaignCodeProps, articleId, categoryId, forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id]);
1970
+ const fetchCampaign = useCallback((campaign_code) => {
1971
+ Service.getCampaignByCode(campaign_code).then((res) => {
1972
+ const { _data } = res || {};
1973
+ const { campaigns } = _data || {};
1974
+ LeadLog('** LeadGen Campaign : ', campaigns);
1975
+ setForceCampaign(formatCampaignDetail(campaigns));
1976
+ });
1977
+ }, [campaignCodeProps]);
1978
+ // TODO : Update form for LeadGen
1979
+ const submit = useCallback((data) => {
1980
+ return Service.postSubscriptionBoxLead({ data });
1981
+ }, []);
1982
+ const submitSubscriptionBox = useCallback((value) => {
1983
+ const data = Object.assign(Object.assign(Object.assign(Object.assign({}, value), { campaign_id,
1984
+ site_domain, url: (value === null || value === void 0 ? void 0 : value.url) || url, ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id }), extraValues), { article_id,
1985
+ category_id, article_title: (extraValues === null || extraValues === void 0 ? void 0 : extraValues.article_title) || article_title });
1986
+ return Service.postSubscriptionBoxLead({ data });
1987
+ }, [
1988
+ extraValues,
1989
+ site_domain,
1990
+ campaign_id,
1991
+ article_id,
1992
+ article_title,
1993
+ category_id,
1994
+ url,
1995
+ ga_client_id,
1996
+ ]);
1997
+ const impression = useCallback((value) => {
1998
+ return Service.campaignPostImpression({
1999
+ url: (value === null || value === void 0 ? void 0 : value.url) || url,
2000
+ action: (value === null || value === void 0 ? void 0 : value.action) || LEADGEN_ACTIONS.SCROLL,
2001
+ code: (value === null || value === void 0 ? void 0 : value.code) || campaign_code,
2002
+ title_article: (value === null || value === void 0 ? void 0 : value.title_article) || article_title,
2003
+ cookie_id: (value === null || value === void 0 ? void 0 : value.cookie_id) || cookie_id,
2004
+ ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id,
2005
+ extra: (value === null || value === void 0 ? void 0 : value.extra) || Object.assign({ cookie_id,
2006
+ article_id, subscription_title: subscriptionInfo.subscriptionTitle }, extraValues),
2007
+ referrer: value === null || value === void 0 ? void 0 : value.referrer,
2008
+ });
2009
+ }, [
2010
+ extraValues,
2011
+ campaign_id,
2012
+ url,
2013
+ campaign_code,
2014
+ article_title,
2015
+ cookie_id,
2016
+ ga_client_id,
2017
+ article_id,
2018
+ subscriptionInfo.subscriptionTitle,
2019
+ ]);
2020
+ useEffect(() => {
2021
+ if (forceCampaignProps) {
2022
+ setForceCampaign(forceCampaignProps);
2023
+ return;
2024
+ }
2025
+ /** For Subscription Box */
2026
+ if (categoryId) {
2027
+ Service.getSubscriptionBoxInfo({
2028
+ category: categoryId,
2029
+ site: site_domain,
2030
+ }).then((res) => {
2031
+ const { _data } = res || {};
2032
+ const { item, campaign_code } = _data || {};
2033
+ const { icon, content } = item || {};
2034
+ LeadLog('** LeadGen SubscriptionBox campaign_code : ', campaign_code);
2035
+ LeadLog('** LeadGen SubscriptionBox subscription_icon : ', icon);
2036
+ LeadLog('** LeadGen SubscriptionBox subscription_title : ', content);
2037
+ setSubscriptionInfo({
2038
+ subscriptionIcon: icon,
2039
+ subscriptionTitle: content,
2040
+ });
2041
+ if (campaign_code) {
2042
+ fetchCampaign(campaign_code);
2043
+ }
2044
+ });
2045
+ return;
2046
+ }
2047
+ if (campaignCodeProps) {
2048
+ fetchCampaign(campaignCodeProps);
2049
+ }
2050
+ }, [campaignCodeProps, categoryId]);
2051
+ useEffect(() => {
2052
+ leadStore.apiSsoUrl = apiSsoUrl;
2053
+ leadStore.apiLeadUrl = apiLeadUrl;
2054
+ leadStore.apiSubotUrl = apiSubotUrl;
2055
+ }, [apiLeadUrl, apiSubotUrl, apiSsoUrl]);
2056
+ if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
2057
+ return null;
2058
+ }
2059
+ return (React__default.createElement(LeadGenContext.Provider, { value: Object.assign(Object.assign(Object.assign({}, leadGenContextValue), subscriptionInfo), { submit,
2060
+ submitSubscriptionBox,
2061
+ impression }) },
2062
+ React__default.createElement(LeadGenTranslationProvider, { locale: locale }, children)));
2063
+ };
2064
+ const useLeadGenContext = () => {
2065
+ const context = useContext(LeadGenContext);
2066
+ return Object.assign(Object.assign({}, context), { apiLeadUrl: context.apiLeadUrl || leadStore.apiLeadUrl, apiSubotUrl: context.apiSubotUrl || leadStore.apiSubotUrl });
2067
+ };
2068
+
2069
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
2070
+ const customParseFormat = require('dayjs/plugin/customParseFormat');
2071
+ dayjs.extend(customParseFormat);
2072
+ // You can give context variables any name
2073
+ const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
2074
+ const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
2075
+ var _a;
2076
+ const { t } = useTranslations();
2077
+ const initialValues = useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
2078
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[(_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.lang] ||
2079
+ LEAD_LOCALE_DATA['vi-VN'];
2080
+ const validateObj = useMemo(() => {
2081
+ const InputBlocks = [
2082
+ 'TextBlock',
2083
+ 'NumberBlock',
2084
+ 'EmailBlock',
2085
+ 'PhoneBlock',
2086
+ 'DateBlock',
2087
+ 'CheckboxBlock',
2088
+ 'RadioBlock',
2089
+ 'DropdownBlock',
2090
+ 'PhoneOtpBlock',
2091
+ 'WhatsappOtpBlock',
2092
+ 'ZaloOtpBlock',
2093
+ 'LocationBlock',
2094
+ 'TncBlock',
2095
+ ];
2096
+ // ALL are required and can skip if not touched yet
2097
+ const withSharedCheck = (name, cb,
2098
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2099
+ block) => {
2100
+ return (value) => {
2101
+ var _a;
2102
+ const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
2103
+ if (!formRef.current.isTouched(name))
2104
+ return;
2105
+ if ((typeof value === 'string' && value.trim() === '') ||
2106
+ typeof value === 'undefined' ||
2107
+ (Array.isArray(value) && value.length === 0)) {
2108
+ return isBLockRequired
2109
+ ? t('validator.required')
2110
+ : cb === null || cb === void 0 ? void 0 : cb(value);
2111
+ }
2112
+ return cb === null || cb === void 0 ? void 0 : cb(value);
2113
+ };
2114
+ };
2115
+ return listBlockAdded
2116
+ .filter((b) => InputBlocks.includes(b.name))
2117
+ .reduce((r, b) => {
2118
+ const { name: fieldType, data } = b || {};
2119
+ const { value: fieldName, required } = data || {};
2120
+ const isRequired = required !== null && required !== void 0 ? required : true;
2121
+ if (fieldType === 'NumberBlock') {
2122
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2123
+ if (value && isNaN(Number(value))) {
2124
+ return t('validator.number');
2125
+ }
2126
+ }, b) });
2127
+ }
2128
+ else if (fieldType === 'EmailBlock') {
2129
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2130
+ if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
2131
+ return t('validator.email');
2132
+ }
2133
+ if (!value)
2134
+ return;
2135
+ validatingEmailRef.current = true;
2136
+ setTimeout(() => {
2137
+ formRef.current.setFieldError(fieldName, 'Validating...');
2138
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2139
+ email: value,
2140
+ })
2141
+ .then((tKey) => {
2142
+ if (tKey) {
2143
+ formRef.current.setFieldError(fieldName, t(tKey));
2144
+ }
2145
+ else {
2146
+ formRef.current.clearFieldError(fieldName);
2147
+ }
2148
+ validatingEmailRef.current = false;
2149
+ })
2150
+ .catch((e) => {
2151
+ console.error(e);
2152
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2153
+ validatingEmailRef.current = false;
2154
+ });
2155
+ }, 200);
2156
+ }, b) });
2157
+ }
2158
+ else if (fieldType === 'PhoneBlock' ||
2159
+ fieldType === 'PhoneOtpBlock' ||
2160
+ fieldType === 'ZaloOtpBlock' ||
2161
+ fieldType === 'WhatsappOtpBlock') {
2162
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2163
+ if (value &&
2164
+ window.intlTelInputUtils &&
2165
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
2166
+ return t('validator.phone');
2167
+ }
2168
+ if (!value)
2169
+ return;
2170
+ validatingPhoneRef.current = true;
2171
+ setTimeout(() => {
2172
+ formRef.current.setFieldError(fieldName, 'Validating...');
2173
+ if (b.data.singleSubmission) {
2174
+ checkUsedPhoneOnlyWithCache(campaignId, value)
2175
+ .then((tKey) => {
2176
+ if (tKey) {
2177
+ formRef.current.setFieldError(fieldName, t(tKey));
2178
+ }
2179
+ else {
2180
+ formRef.current.clearFieldError(fieldName);
2181
+ }
2182
+ validatingPhoneRef.current = false;
2183
+ })
2184
+ .catch((err) => {
2185
+ console.error(err);
2186
+ formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
2187
+ validatingPhoneRef.current = false;
2188
+ });
2189
+ }
2190
+ else {
2191
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2192
+ phone: value,
2193
+ })
2194
+ .then((tKey) => {
2195
+ if (tKey) {
2196
+ formRef.current.setFieldError(fieldName, t(tKey));
2197
+ }
2198
+ else {
2199
+ formRef.current.clearFieldError(fieldName);
2200
+ }
2201
+ validatingPhoneRef.current = false;
2202
+ })
2203
+ .catch((e) => {
2204
+ console.error(e);
2205
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2206
+ validatingPhoneRef.current = false;
2207
+ });
2208
+ }
2209
+ }, 200);
2210
+ }, b) });
2211
+ }
2212
+ else if (fieldType === 'DateBlock') {
2213
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2214
+ if (!isRequired && !value) {
2215
+ return;
2216
+ }
2217
+ const errMsg = t('validator.dateInvalid');
2218
+ const dayInJS = typeof value === 'string'
2219
+ ? dayjs(value, format, true)
2220
+ : dayjs(value);
2221
+ if (!dayInJS.isValid()) {
2222
+ return errMsg;
2223
+ }
2224
+ }, b) });
2225
+ }
2226
+ else if (fieldType === 'TncBlock') {
2227
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
2228
+ if (isRequired && !value) {
2229
+ return t('validator.required');
2230
+ }
2231
+ }, b) });
2232
+ }
2233
+ else {
2234
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
2235
+ }
2236
+ }, {});
2237
+ }, [listBlockAdded.map((b) => b.name).join(','), format]);
2238
+ const form = useLeadForm({
2239
+ validateInputOnChange: true,
2240
+ validateInputOnBlur: true,
2241
+ clearInputErrorOnChange: true,
2242
+ validate: validateObj,
2243
+ initialValues,
2244
+ });
2245
+ const formRef = useRef(form);
2246
+ formRef.current = form;
2247
+ return { form, validateObj };
2248
+ };
2249
+
2250
+ const StyledLeadGenThankYou = styled.div `
2251
+ display: flex;
2252
+ gap: 8px;
2253
+ flex-direction: column;
2254
+ padding-block: 24px;
2255
+
2256
+ .leadgen-image {
2257
+ width: 120px;
2258
+ height: 120px;
2259
+ margin-inline: auto;
2260
+ object-fit: contain;
2261
+ object-position: center;
2262
+ text-align: center;
2263
+ }
2264
+
2265
+ .leadgen-title {
2266
+ margin-block: 0;
2267
+ color: ${theme.colors.gray900};
2268
+ font-weight: 700;
2269
+ font-size: 18px;
2270
+ line-height: 28px;
2271
+ letter-spacing: -0.2px;
2272
+ }
2273
+
2274
+ .leadgen-description {
2275
+ margin-block: 0;
2276
+ color: ${theme.colors.gray600};
2277
+ font-weight: 400;
2278
+ font-size: 14px;
2279
+ line-height: 22px;
2280
+ letter-spacing: -0.2px;
2281
+ text-align: center;
2282
+ }
2283
+
2284
+ > [data-align] {
2285
+ &[data-align='right'] {
2286
+ text-align: right;
2287
+ }
2288
+ &[data-align='center'] {
2289
+ text-align: center;
2290
+ }
2291
+ }
2292
+ `;
2293
+ const LeadGenThankYou = ({ image, title, description, showButton = false, button, className, style, }) => {
2294
+ const { src } = image;
2295
+ const { htmlText: titleText, align: titleAlign } = title;
2296
+ const { htmlText: descriptionText, align: descriptionAlign } = description;
2297
+ const { htmlText: buttonText, newtab, url, onClick } = button;
2298
+ return (React__default.createElement(StyledLeadGenThankYou, { className: className, style: style },
2299
+ React__default.createElement("img", { src: src, alt: "", className: "leadgen-thankyou_image leadgen-image" }),
2300
+ React__default.createElement("p", { className: "leadgen-thankyou_title leadgen-title", "data-align": titleAlign }, titleText),
2301
+ React__default.createElement("p", { className: "leadgen-thankyou_description leadgen-description", "data-align": descriptionAlign }, descriptionText),
2302
+ !!buttonText && showButton && (React__default.createElement(Button$1, { component: url ? 'a' : 'button', target: newtab ? '_blank' : undefined, href: url, size: "lg", variant: "filled", className: "leadgen-thankyoue_btn leadgen-btn", onClick: onClick }, buttonText))));
2303
+ };
2304
+
2305
+ const StyledLeadGenSubscriptionBoxBody = styled.div `
2306
+ margin-top: 16px;
2307
+ .leadgen-btn {
2308
+ margin-top: 16px;
2309
+ }
2310
+ `;
2311
+ const StyledLeadGenSubscriptionBoxHeaderImage = styled.div `
2312
+ margin-top: 3px;
2313
+ margin-right: 20px;
2314
+ width: 44px;
2315
+ height: 44px;
2316
+
2317
+ img {
2318
+ width: 100%;
2319
+ height: 100%;
2320
+ object-fix: contain;
2321
+ onject-position: center;
2322
+ }
2323
+
2324
+ :has(img[src='']) {
2325
+ display: none;
2326
+ }
2327
+ `;
2328
+ const StyledLeadGenSubscriptionBoxHeader = styled.div `
2329
+ display: flex;
2330
+ align-items: center;
2331
+ margin-bottom: 16px;
2332
+ .leadgen-title {
2333
+ margin-bottom: 0;
2334
+ flex: 1;
2335
+ min-width: 0;
2336
+ color: ${theme.colors.gray900};
2337
+ font-size: 18px;
2338
+ font-weight: 400;
2339
+ line-height: 1.4;
2340
+ letter-spacing: -0.8px;
2341
+ }
2342
+ `;
2343
+ const StyledLeadGenSubscriptionBox = styled.div `
2344
+ padding: 16px;
2345
+ border: 1px solid ${theme.colors.neutral100};
2346
+ border-radius: 12px;
2347
+ margin-inline: auto;
2348
+ .leadgen-form_inputs {
2349
+ .leadgen-form_input {
2350
+ width: 100%;
2351
+ }
2352
+ }
2353
+
2354
+ .leadgen-form_input {
2355
+ .mantine-Input-wrapper {
2356
+ max-height: 56px;
2357
+ }
2358
+ }
2359
+
2360
+ ${MediaQueries.mbUp} {
2361
+ .leadgen-subscription_box_body {
2362
+ display: flex;
2363
+ > form {
2364
+ flex: 1;
2365
+ min-width: 0;
2366
+
2367
+ .leadgen-form_inputs {
2368
+ .leadgen-form_input {
2369
+ width: calc(50% - 4px);
2370
+ }
2371
+ }
2372
+ }
2373
+
2374
+ .leadgen-btn {
2375
+ margin-top: 0;
2376
+ margin-left: 8px;
2377
+ width: auto;
2378
+ min-height: 56px;
2379
+ }
2380
+ }
2381
+ }
2382
+
2383
+ ${MediaQueries.smbDown} {
2384
+ &[data-type='subscription_box_A'] {
2385
+ border-inline: 0;
2386
+ border-radius: 0;
2387
+ margin-inline: -16px;
2388
+ box-shadow: 0px 0px 1px 0px #0000000a/0px 0px 2px 0px #0000000f/0px 4px
2389
+ 8px 0px #0000000a;
2390
+ }
2391
+ }
2392
+ `;
2393
+ const StyledLeadGenSubscriptionBoxA = styled.div `
2394
+ .leadgen-form_input {
2395
+ --phone-select: 45px;
2396
+ .PhoneInput {
2397
+ --phone-select: 45px;
2398
+ .PhoneInputCountry {
2399
+ margin-top: 1px;
2400
+ pointer-events: none;
2401
+ .PhoneInputCountryIconImg,
2402
+ .PhoneInputArrowContainer {
2403
+ display: none;
2404
+ }
2405
+ }
2406
+ }
2407
+ }
2408
+ `;
2409
+
2410
+ const PhoneInput = forwardRef((props, ref) => {
2411
+ const { defaultCountry, id: idProps, name, placeholder, label, labelElement, labelProps, description, descriptionProps, withAsterisk, inputMode, inputContainer, inputWrapperOrder, error, className, classNames, style, styles } = props, restProps = __rest(props, ["defaultCountry", "id", "name", "placeholder", "label", "labelElement", "labelProps", "description", "descriptionProps", "withAsterisk", "inputMode", "inputContainer", "inputWrapperOrder", "error", "className", "classNames", "style", "styles"]);
2412
+ const id = idProps || v1() + name;
2413
+ return (React__default.createElement(Input$1.Wrapper, { size: "md", label: label, labelElement: labelElement, labelProps: Object.assign({ htmlFor: id }, labelProps), description: description, descriptionProps: descriptionProps, withAsterisk: withAsterisk, inputMode: inputMode, inputContainer: inputContainer, inputWrapperOrder: inputWrapperOrder, error: error, "data-invalid": !!error, className: className, classNames: classNames, style: style, styles: styles },
2414
+ React__default.createElement("div", { className: "mantine-Input-wrapper" },
2415
+ React__default.createElement(Phone, Object.assign({}, restProps, { id: id, ref: ref, name: name, spellCheck: false, placeholder: placeholder, defaultCountry: defaultCountry, className: "mantine-Input-input", type: "tel", "data-control": "tel" })))));
2416
+ });
2417
+
2418
+ const formatLeadGenFormValue = (values, blocks) => {
2419
+ const newValues = {};
2420
+ for (const block of blocks) {
2421
+ const { data } = block || {};
2422
+ const { value: fieldName } = data || {};
2423
+ if (fieldName in values) {
2424
+ newValues[fieldName] = values[fieldName];
2425
+ }
2426
+ }
2427
+ return newValues;
2428
+ };
2429
+
2430
+ const StyledLeadGenFormInner = styled.div `
2431
+ display: flex;
2432
+ flex-wrap: wrap;
2433
+ gap: 8px;
2434
+ .leadgen-form_input {
2435
+ width: calc(50% - 4px);
2436
+ }
2437
+
2438
+ .leadgen-form_input_checkbox {
2439
+ width: 100%;
2440
+ }
2441
+ `;
2442
+
2443
+ const cssInputNotShrink$1 = css `
2444
+ height: 100% !important;
2445
+ min-height: calc(var(--container-height, 56px) * 22 / 56);
2446
+ color: ${theme.colors.gray800};
2447
+ font-size: var(--input, 16px);
2448
+ line-height: calc(var(--container-height, 56px) * 22 / 56);
2449
+ border: none !important;
2450
+ border-radius: 0 !important;
2451
+ outline: none !important;
2452
+ box-shadow: none !important;
2453
+ padding: 0;
2454
+ cursor: pointer;
2455
+ opacity: 0;
2456
+
2457
+ ::placeholder {
2458
+ color: ${theme.colors.gray400};
2459
+ }
2460
+ `;
2461
+ const cssInputShrink$1 = css `
2462
+ height: auto !important;
2463
+ cursor: text;
2464
+ opacity: 1;
2465
+ transition: 0.1s ease-in-out all;
2466
+ `;
2467
+ const cssLabelNotShrink$1 = css `
2468
+ position: absolute;
2469
+ top: calc(var(--container-height) / 2);
2470
+ left: var(--space-x, 16px);
2471
+ color: ${theme.colors.gray400};
2472
+ font-size: var(--label-not-shrink, 16px);
2473
+ font-weight: 400;
2474
+ line-height: calc(var(--container-height, 56px) * 18 / 56);
2475
+ margin: 0;
2476
+ z-index: 1;
2477
+ cursor: pointer;
2478
+ transform: translateY(-50%);
2479
+ transition: 0.125s ease-in all;
2480
+ `;
2481
+ const cssLabelShrink$1 = css `
2482
+ color: ${theme.colors.gray600};
2483
+ font-weight: 600;
2484
+ font-size: var(--label-shrink, 12px);
2485
+ top: calc(var(--container-height) * 7 / 56);
2486
+ transform: none;
2487
+ transition: 0.125s ease-out all;
2488
+ `;
2489
+ const cssWrapperInputNotShrink$1 = css `
2490
+ min-height: var(--container-height, 56px);
2491
+ display: flex;
2492
+ align-items: flex-end;
2493
+ border: 1px solid ${theme.colors.gray200};
2494
+ border-radius: 8px;
2495
+ background-color: #fff;
2496
+ padding-inline: var(--space-x, 16px);
2497
+ padding-block: var(--space-y-not-shrink, 16px);
2498
+ cursor: pointer;
2499
+ pointer-events: none;
2500
+
2501
+ &:has(.mantine-Input-rightSection) {
2502
+ padding-right: var(--container-height, 56px);
2503
+ }
2504
+
2505
+ .mantine-Input-icon {
2506
+ display: none;
2507
+ }
2508
+
2509
+ .mantine-NumberInput-control {
2510
+ border-color: ${theme.colors.gray200};
2511
+ }
2512
+ `;
2513
+ const cssWrapperInputShrink$1 = css `
2514
+ height: auto;
2515
+ min-height: var(--container-height, 56px);
2516
+ padding-block: var(--space-y-shrink, 7px);
2517
+ cursor: text;
2518
+ pointer-events: auto;
2519
+ `;
2520
+ const cssInputWrapperError$1 = css `
2521
+ color: ${theme.colors.red800};
2522
+ font-size: 12px;
2523
+ line-height: 1.5;
2524
+ `;
2525
+ const StyledTextFieldContainer$1 = styled.div `
2526
+ --space-x: 16px;
2527
+ --space-y-not-shrink: 16px;
2528
+ --space-y-shrink: 7px;
2529
+ --container-height: 56px;
2530
+ --label-not-shrink: 16px;
2531
+ --label-shrink: 12px;
2532
+ --input: 16px;
2533
+
2534
+ position: relative;
2535
+ min-width: 100px;
2536
+ max-width: 100%;
2537
+ display: inline-block;
2538
+
2539
+ .textField_wrapper {
2540
+ display: inline-block;
2541
+ width: 100%;
2542
+ cursor: pointer;
2543
+ }
2544
+
2545
+ .mantine-InputWrapper-root {
2546
+ &[data-invalid='true'] {
2547
+ .mantine-Input-wrapper {
2548
+ border-color: ${theme.colors.red400};
2549
+ }
2550
+ }
2551
+
2552
+ .mantine-Input-wrapper {
2553
+ &:has([data-invalid]) {
2554
+ border-color: ${theme.colors.red400};
2555
+ }
2556
+ }
2557
+
2558
+ .mantine-InputWrapper-error {
2559
+ font-size: 12px !important;
2560
+ }
2561
+ }
2562
+
2563
+ .mantine-InputWrapper-label {
2564
+ ${cssLabelNotShrink$1}
2565
+ }
2566
+
2567
+ .mantine-Input-wrapper {
2568
+ ${cssWrapperInputNotShrink$1}
2569
+
2570
+ + .mantine-Popover-dropdown[data-position="bottom-start"] {
2571
+ left: 0 !important;
2572
+ }
2573
+ + .mantine-Popover-dropdown[data-position='top-start'] {
2574
+ top: unset !important;
2575
+ left: 0 !important;
2576
+ bottom: 100% !important;
2577
+ }
2578
+ }
2579
+
2580
+ .mantine-Input-input {
2581
+ ${cssInputNotShrink$1}
2582
+ }
2583
+
2584
+ &.textField_shrink,
2585
+ &:focus-within {
2586
+ .mantine-InputWrapper-label {
2587
+ ${cssLabelShrink$1}
2588
+ }
2589
+
2590
+ .mantine-Input-wrapper {
2591
+ ${cssWrapperInputShrink$1}
2592
+ &.mantine-Select-wrapper {
2593
+ .mantine-Select-rightSection {
2594
+ pointer-events: auto !important;
2595
+ }
2596
+ }
2597
+ }
2598
+
2599
+ .mantine-Input-input {
2600
+ ${cssInputShrink$1}
2601
+ }
2602
+
2603
+ &:has(.PhoneInput) {
2604
+ .mantine-InputWrapper-label {
2605
+ left: var(--space-x, 16px);
2606
+ }
2607
+ .PhoneInput {
2608
+ .PhoneInputInput {
2609
+ opacity: 1;
2610
+ }
2611
+ }
2612
+ }
2613
+ }
2614
+
2615
+ .PhoneInput {
2616
+ --phone-select: 75px;
2617
+ --phone-input-space-x: 8px;
2618
+ width: 100%;
2619
+ opacity: 1;
2620
+ border: none;
2621
+ .PhoneInputCountry {
2622
+ background-color: transparent;
2623
+ border: none;
2624
+ padding: 0;
2625
+ width: var(--phone-select, 75px);
2626
+ }
2627
+ .PhoneInputInput {
2628
+ flex: 1;
2629
+ min-width: 0;
2630
+ line-height: 1.5;
2631
+ outline: none !important;
2632
+ border: none;
2633
+ box-shadow: none;
2634
+ padding: 0 var(--phone-input-space-x, 8px);
2635
+ opacity: 0;
2636
+ color: ${theme.colors.gray800} !important;
2637
+ :focus {
2638
+ color: ${theme.colors.gray800} !important;
2639
+ }
2640
+ }
2641
+ }
2642
+
2643
+ &:has(.PhoneInput) {
2644
+ .mantine-InputWrapper-label {
2645
+ left: calc(
2646
+ var(--space-x, 16px) + var(--phone-select, 75px) +
2647
+ var(--phone-input-space-x, 8px)
2648
+ );
2649
+ }
2650
+ }
2651
+ `;
2652
+ const StyledChoiceFieldContainer$1 = styled.div `
2653
+ &.leadgen-form_checkbox,
2654
+ &.leadgen-form_radio {
2655
+ width: 100%;
2656
+ }
2657
+
2658
+ &.leadgen-form_dropdown {
2659
+ width: calc(50% - 12px);
2660
+ }
2661
+
2662
+ .mantine-InputWrapper-root {
2663
+ display: block;
2664
+ .mantine-InputWrapper-error {
2665
+ font-size: 12px !important;
2666
+ }
2667
+ }
2668
+
2669
+ .mantine-InputWrapper-label {
2670
+ margin-bottom: 0.5rem;
2671
+ color: ${theme.colors.gray800};
2672
+ font-size: 16px;
2673
+ font-weight: 400;
2674
+ line-height: 1.5;
2675
+ }
2676
+
2677
+ .mantine-Radio-root,
2678
+ .mantine-Checkbox-root {
2679
+ gap: 8px;
2680
+ min-width: calc(50% - 4px);
2681
+
2682
+ input[type='radio'],
2683
+ input[type='checkbox'] {
2684
+ border-color: ${theme.colors.gray600};
2685
+ width: 18px;
2686
+ height: 18px;
2687
+ }
2688
+ input[type='checkbox'] {
2689
+ border-radius: 4px;
2690
+ }
2691
+
2692
+ &[data-checked='true'] {
2693
+ input[type='radio'],
2694
+ input[type='checkbox'] {
2695
+ border-color: ${theme.colors.primary600};
2696
+ + svg {
2697
+ color: ${theme.colors.primary600};
2698
+ }
2699
+ }
2700
+
2701
+ input[type='radio'] {
2702
+ background-color: white;
2703
+ }
2704
+ }
2705
+
2706
+ .mantine-Checkbox-input {
2707
+ &:checked {
2708
+ border-color: ${theme.colors.primary600};
2709
+ }
2710
+ }
2711
+ }
2712
+
2713
+ .mantine-Radio-inner,
2714
+ .mantine-Checkbox-inner {
2715
+ width: 24px;
2716
+ height: 24px;
2717
+ display: flex;
2718
+ align-items: center;
2719
+ justify-content: center;
2720
+ }
2721
+
2722
+ .mantine-Radio-body,
2723
+ .mantine-Checkbox-body {
2724
+ display: flex;
2725
+ align-items: center;
2726
+ }
2727
+
2728
+ .mantine-Radio-label,
2729
+ .mantine-Checkbox-label {
2730
+ padding-left: 8px;
2731
+ color: ${theme.colors.gray800};
2732
+ font-size: 14px;
2733
+ line-height: 1.4;
2734
+ letter-spacing: -0.2px;
2735
+ }
2736
+
2737
+ .leadgen-choiceContainer {
2738
+ display: flex;
2739
+ flex-wrap: wrap;
2740
+ align-items: flex-start;
2741
+ gap: 8px;
2742
+ }
2743
+
2744
+ .mantine-InputWrapper-error {
2745
+ ${cssInputWrapperError$1}
2746
+ }
2747
+ `;
2748
+
2749
+ const TextField$1 = (props) => {
2750
+ const { shrink: shrinkProps, onChangeShrink, className, children } = props, restProps = __rest(props, ["shrink", "onChangeShrink", "className", "children"]);
2751
+ const containerRef = useClickOutside(() => {
2752
+ if (shrinkProps) {
2753
+ return;
2754
+ }
2755
+ setShrink(false);
2756
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(false);
2757
+ });
2758
+ const [shrink, setShrink] = useState(shrinkProps);
2759
+ const onClick = useCallback((e) => {
2760
+ setShrink(true);
2761
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(true);
2762
+ if (shrink) {
2763
+ return;
2764
+ }
2765
+ const $textEl = e.currentTarget.querySelectorAll('input:not([disabled]):not([type="submit"]),select:not([disabled]),textarea:not([disabled])');
2766
+ const $focusEl = $textEl.item($textEl.length - 1);
2767
+ if ($focusEl) {
2768
+ $focusEl.focus();
2769
+ setTimeout(() => {
2770
+ $focusEl.scrollIntoView({
2771
+ behavior: 'auto',
2772
+ block: 'center',
2773
+ inline: 'start',
2774
+ });
2775
+ }, 100);
2776
+ }
2777
+ }, [shrink]);
2778
+ useEffect(() => {
2779
+ setShrink(shrinkProps);
2780
+ }, [shrinkProps]);
2781
+ return (React__default.createElement(StyledTextFieldContainer$1, Object.assign({ shrink: shrink, className: clsx(className, 'textField', { textField_shrink: !!shrink }) }, restProps),
2782
+ React__default.createElement("div", { ref: containerRef, onClick: onClick, className: "textField_wrapper" }, children)));
2783
+ };
2784
+ const ChoiceField$1 = (props) => {
2785
+ const { children, className } = props, restProps = __rest(props, ["children", "className"]);
2786
+ return (React__default.createElement(StyledChoiceFieldContainer$1, Object.assign({ className: clsx(className, 'choiceField') }, restProps), children));
2787
+ };
2788
+
2789
+ const libraries = ['places'];
2790
+ const GoogleLocationBlock = (props) => {
2791
+ var _a;
2792
+ const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = __rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
2793
+ const [LoadScript, setLoadScript] = useState(null);
2794
+ const [value, setValue] = useState(defaultValue || valueProps);
2795
+ const { predictions } = usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
2796
+ const onChangeAutocomplete = useCallback((s) => {
2797
+ setValue(s);
2798
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
2799
+ }, []);
2800
+ const onClickItem = useCallback((item) => {
2801
+ /** For sure get value */
2802
+ setValue(item.value);
2803
+ const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
2804
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
2805
+ }, [onChangeProps, predictions]);
2806
+ useEffect(() => {
2807
+ setValue(valueProps);
2808
+ }, [valueProps]);
2809
+ useEffect(() => {
2810
+ var _a, _b, _c;
2811
+ // only load extra google script when not yet loaded
2812
+ if (!((_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.places) === null || _c === void 0 ? void 0 : _c.AutocompleteService) && !LoadScript) {
2813
+ import('@react-google-maps/api').then((m) => {
2814
+ setLoadScript(() => m.LoadScript);
2815
+ });
2816
+ }
2817
+ }, []);
2818
+ return (React__default.createElement(Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
2819
+ return { value: pred.description, label: pred.description };
2820
+ }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
2821
+ return (React__default.createElement(React__default.Fragment, null,
2822
+ LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default.createElement(React__default.Fragment, null), style: { width: '100%' } })),
2823
+ children));
2824
+ } }, restProps)));
2825
+ };
2826
+
2827
+ const LeadGenForm = forwardRef((props, ref) => {
2828
+ const { locale, blocks, scrollToErrorField = true, form: formProps, rules: validate, initialValues, onFinish, onFinishFailed, className, style, } = props;
2829
+ const formRef = useRef(null);
2830
+ const form = formProps || useForm({ initialValues, validate });
2831
+ const middlewareFinish = useCallback((values, event) => {
2832
+ /** Set `touched` all values for validation when submiting */
2833
+ form.setTouched(blocks.reduce((touched, { data }) => {
2834
+ touched[data.value] = true;
2835
+ return touched;
2836
+ }, {}));
2837
+ /** Wait for `touched` state and then submit */
2838
+ setTimeout(() => {
2839
+ const { hasErrors } = form.validate();
2840
+ if (hasErrors) {
2841
+ return;
2842
+ }
2843
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatLeadGenFormValue(values, blocks), event);
2844
+ }, 100);
2845
+ }, [form, blocks]);
2846
+ const middlewareFinishFailed = useCallback((errors, values, events) => {
2847
+ if (scrollToErrorField && errors) {
2848
+ const firstErrorKey = Object.keys(errors)[0];
2849
+ const firstErrorElement = document.querySelector(`[name="${firstErrorKey}"]`);
2850
+ if (firstErrorElement && (firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus)) {
2851
+ setTimeout(() => {
2852
+ firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
2853
+ firstErrorElement.scrollIntoView({
2854
+ behavior: 'auto',
2855
+ block: 'center',
2856
+ inline: 'center',
2857
+ });
2858
+ }, 100);
2859
+ }
2860
+ }
2861
+ onFinishFailed === null || onFinishFailed === void 0 ? void 0 : onFinishFailed(errors, values, events);
2862
+ }, [scrollToErrorField]);
2863
+ useEffect(() => {
2864
+ (() => __awaiter(void 0, void 0, void 0, function* () {
2865
+ if (!window.intlTelInputUtils) {
2866
+ yield require('intl-tel-input/build/js/utils');
2867
+ }
2868
+ }))();
2869
+ }, []);
2870
+ useImperativeHandle(ref, () => (Object.assign(Object.assign({}, form), { submit: () => {
2871
+ formRef.current.requestSubmit();
2872
+ } })), [form, formRef]);
2873
+ if (!blocks || !blocks.length) {
2874
+ return null;
2875
+ }
2876
+ return (React__default.createElement("form", { ref: formRef, onSubmit: form.onSubmit(middlewareFinish, middlewareFinishFailed), className: className, style: style },
2877
+ React__default.createElement(StyledLeadGenFormInner, { className: "leadgen-form_inputs" }, blocks.map((block, idx) => {
2878
+ const { id, name: blockName, data } = block;
2879
+ const { placeholder, value: name, required, listQuestion, valueHTML, isSendMailChimp = false, } = data;
2880
+ const formInputProps = form.getInputProps(name);
2881
+ const { value, error } = formInputProps;
2882
+ const reactKey = `${id}-${idx}`;
2883
+ switch (blockName) {
2884
+ case LEADGEN_BLOCK.TextBlock: {
2885
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2886
+ React__default.createElement(TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "text", "data-control": "text" }, formInputProps))));
2887
+ }
2888
+ case LEADGEN_BLOCK.NumberBlock: {
2889
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2890
+ React__default.createElement(NumberInput$1, Object.assign({ name: value, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "number", "data-control": "number" }, formInputProps))));
2891
+ }
2892
+ case LEADGEN_BLOCK.EmailBlock: {
2893
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2894
+ React__default.createElement(TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, "data-control": "email" }, formInputProps))));
2895
+ }
2896
+ case LEADGEN_BLOCK.PhoneOtpBlock:
2897
+ case LEADGEN_BLOCK.WhatsappOtpBlock:
2898
+ case LEADGEN_BLOCK.ZaloOtpBlock:
2899
+ case LEADGEN_BLOCK.PhoneBlock: {
2900
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2901
+ React__default.createElement(PhoneInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, defaultCountry: (locale ? MAPPED_LOCALE[locale] || 'VN' : 'VN'), type: "text", "data-control": "text" }, formInputProps))));
2902
+ }
2903
+ case LEADGEN_BLOCK.LocationBlock: {
2904
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2905
+ React__default.createElement(GoogleLocationBlock, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, locale: locale, "data-control": "text" }, formInputProps))));
2906
+ }
2907
+ case LEADGEN_BLOCK.DateBlock: {
2908
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2909
+ React__default.createElement(DateInput, Object.assign({ locale: (MAPPED_LOCALE === null || MAPPED_LOCALE === void 0 ? void 0 : MAPPED_LOCALE[locale]) || MAPPED_LOCALE['vi-VN'], valueFormat: "DD/MM/YYYY", name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "default", "data-control": "date" }, formInputProps))));
2910
+ }
2911
+ case LEADGEN_BLOCK.DropdownBlock:
2912
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2913
+ React__default.createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2914
+ React__default.createElement(Select$1, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, data: listQuestion.map((l) => ({
2915
+ value: l.value,
2916
+ label: l.placeholder,
2917
+ })) }, formInputProps))));
2918
+ case LEADGEN_BLOCK.CheckboxBlock: {
2919
+ const formInputCheckboxProps = form.getInputProps(name, {
2920
+ type: 'checkbox',
2921
+ });
2922
+ return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2923
+ isSendMailChimp && (React__default.createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2924
+ React__default.createElement(Checkbox$1.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, sx: {
2925
+ display: 'flex',
2926
+ flexDirection: 'column',
2927
+ flexWrap: 'wrap',
2928
+ gap: 8,
2929
+ }, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2930
+ return (React__default.createElement("div", { className: "leadgen-choiceContainer" }, children));
2931
+ } }, formInputCheckboxProps), listQuestion.map((l, _idx) => (React__default.createElement(Checkbox$1, { name: name, key: _idx, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2932
+ }
2933
+ case LEADGEN_BLOCK.RadioBlock: {
2934
+ return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2935
+ isSendMailChimp && (React__default.createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2936
+ React__default.createElement(Radio$1.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, spellCheck: true, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2937
+ return (React__default.createElement("div", { className: "leadgen-choiceContainer" }, children));
2938
+ } }, formInputProps), listQuestion.map((l, _index) => (React__default.createElement(Radio$1, { name: name, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2939
+ }
2940
+ case LEADGEN_BLOCK.TncBlock:
2941
+ return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2942
+ React__default.createElement(Input$1.Wrapper, { error: error },
2943
+ React__default.createElement(Checkbox$1, Object.assign({ value: value, name: 'TNC-' + id, label: React__default.createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, formInputProps)))));
2944
+ default: {
2945
+ return null;
2946
+ }
2947
+ }
2948
+ }))));
2949
+ });
2950
+
2951
+ const LEADGEN_ORDER_INPUT_WRAPPER = ['label', 'input', 'description', 'error'];
2952
+
2953
+ const LeadGenSubscriptionBoxA = (props) => {
2954
+ const { loading, image, title, submitText, locale, blocks, form, rules, onFinish, } = props;
2955
+ const formRef = useRef();
2956
+ const imageComp = useMemo(() => {
2957
+ if (!image) {
2958
+ return null;
2959
+ }
2960
+ return (React__default.createElement(StyledLeadGenSubscriptionBoxHeaderImage, null,
2961
+ React__default.createElement("img", { src: image, alt: "" })));
2962
+ }, [image]);
2963
+ const titleComp = useMemo(() => {
2964
+ if (typeof title === 'string') {
2965
+ return (React__default.createElement("p", { className: "leadgen-title", dangerouslySetInnerHTML: { __html: title } }));
2966
+ }
2967
+ return React__default.createElement("p", { className: "leadgen-title" }, title);
2968
+ }, [title]);
2969
+ return (React__default.createElement(StyledLeadGenSubscriptionBoxA, { className: "subcription_box_A" },
2970
+ React__default.createElement(StyledLeadGenSubscriptionBoxHeader, { className: "leadgen-subscription_box_header" },
2971
+ imageComp,
2972
+ titleComp),
2973
+ React__default.createElement(StyledLeadGenSubscriptionBoxBody, { className: "leadgen-subscription_box_body" },
2974
+ React__default.createElement(LeadGenForm, { ref: formRef, form: form, rules: rules, blocks: blocks, locale: locale, onFinish: onFinish, className: "leadgen-subscription_box_form" }),
2975
+ React__default.createElement(Button$1, { disabled: loading, loading: loading, variant: "filled", size: "lg", onClick: () => {
2976
+ formRef.current.submit();
2977
+ }, className: "leadgen-btn leadgen-btn_action", fullWidth: true }, submitText))));
2978
+ };
2979
+
2980
+ const LeadGenSubscriptionBoxWithoutMemo = ({ locale, userInfo, forceCampaign, categoryId, }) => {
2981
+ var _a, _b, _c;
2982
+ const { image, extra_fields, id: campaign_id, bot_id: campaign_subot_id = [], ThankYouBlock, } = forceCampaign || {};
2983
+ const { textBlocks, listBlockAdded, actionBlocks } = extra_fields || {};
2984
+ const { submitBlock } = actionBlocks || {};
2985
+ const { apiLeadUrl, subscriptionIcon, subscriptionTitle, submitSubscriptionBox, impression, onFinish, } = useLeadGenContext();
2986
+ const { t } = useTranslations();
2987
+ const { action: { pushNotifications }, } = useContext(TogetherComponentGlobalContext);
2988
+ const refContainer = useRef(null);
2989
+ const [loading, setLoading] = useState(false);
2990
+ const [showThankyou, setShowThankyou] = useState(false);
2991
+ const validatingEmailRef = useRef(false);
2992
+ const validatingPhoneRef = useRef(false);
2993
+ const { form, validateObj } = useLeadFormConfig({
2994
+ listBlockAdded,
2995
+ campaignId: campaign_id,
2996
+ campaign_subot_id,
2997
+ validatingEmailRef,
2998
+ validatingPhoneRef,
2999
+ userInfo,
3000
+ });
3001
+ const subscription_title = useMemo(() => {
3002
+ var _a, _b;
3003
+ return subscriptionTitle ||
3004
+ ((_b = (_a = textBlocks === null || textBlocks === void 0 ? void 0 : textBlocks.titleBlock) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value) ||
3005
+ t('leadgen.message.title.default');
3006
+ }, [subscriptionTitle, (_b = (_a = textBlocks === null || textBlocks === void 0 ? void 0 : textBlocks.titleBlock) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value]);
3007
+ const { image: thankyouImage, title: thankyouTitle, description: thankyouDescription, button: thankyouButton, } = ThankYouBlock || {};
3008
+ const intersectionObserverCallback = useCallback((entries) => {
3009
+ entries.forEach((entry) => {
3010
+ const { isIntersecting, target } = entry;
3011
+ if (!showThankyou &&
3012
+ isIntersecting &&
3013
+ target === refContainer.current) {
3014
+ impression();
3015
+ }
3016
+ });
3017
+ }, [impression, showThankyou]);
3018
+ const IObserver = new IntersectionObserver(intersectionObserverCallback);
3019
+ const middlewareOnSubmit = useCallback((values) => __awaiter(void 0, void 0, void 0, function* () {
3020
+ const newValues = {
3021
+ subscription_title,
3022
+ };
3023
+ const ssoValues = {
3024
+ sso_user_id: undefined,
3025
+ sso_uuid: undefined,
3026
+ sso_verified_profile: undefined,
3027
+ };
3028
+ const valueKeys = Object.keys(values);
3029
+ for (const key of valueKeys) {
3030
+ const isPhoneField = leadGenFieldNamePhone(listBlockAdded).some((k) => k === key);
3031
+ if (isPhoneField) {
3032
+ const phone = parsePhoneNumber(values[key]);
3033
+ if (phone.isValid()) {
3034
+ /** Seperate `area_code` and `phone_number` for BE */
3035
+ newValues['area_code'] = `+${phone.countryCallingCode}`;
3036
+ newValues['phone_number'] = phone.nationalNumber;
3037
+ /** Only case login has this update */
3038
+ if ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) && (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid)) {
3039
+ const userInfoPhone = (userInfo === null || userInfo === void 0 ? void 0 : userInfo.area_code) + (userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone);
3040
+ ssoValues['sso_verified_profile'] =
3041
+ phone.number === userInfoPhone ? 1 : 0;
3042
+ ssoValues['sso_user_id'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.id;
3043
+ ssoValues['sso_uuid'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid;
3044
+ LeadLog('** LeadGen SB userInfoPhone : ', userInfoPhone);
3045
+ LeadLog('** LeadGen SB userInfoPhoneInput : ', phone.number);
3046
+ }
3047
+ }
3048
+ continue;
3049
+ }
3050
+ newValues[key] = values[key];
3051
+ }
3052
+ setLoading(true);
3053
+ try {
3054
+ const reqValues = Object.assign(Object.assign({}, newValues), ssoValues);
3055
+ const { _data } = (yield submitSubscriptionBox(reqValues)) || {};
3056
+ const { model } = _data || {};
3057
+ if (model && (model === null || model === void 0 ? void 0 : model.id)) {
3058
+ setShowThankyou(true);
3059
+ const metaValues = {
3060
+ blocks: listBlockAdded || [],
3061
+ isUpdateSso: false,
3062
+ };
3063
+ /**
3064
+ * https://hhgdev.atlassian.net/browse/EL-468
3065
+ * This feature is just using in Subscription Box
3066
+ */
3067
+ if (newValues === null || newValues === void 0 ? void 0 : newValues.name) {
3068
+ const { _data: ssoData, code: ssoErrorCode } = yield Service.postUserInfoFromLeadGen({ name: newValues === null || newValues === void 0 ? void 0 : newValues.name });
3069
+ if (ssoErrorCode && !ssoData) {
3070
+ return;
3071
+ }
3072
+ metaValues.isUpdateSso = true;
3073
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(reqValues, metaValues);
3074
+ return;
3075
+ }
3076
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(reqValues, metaValues);
3077
+ }
3078
+ }
3079
+ catch (error) {
3080
+ LeadLog('** LeadGen SubscriptionBox error : ', error);
3081
+ pushNotifications({
3082
+ message: t('leadgen.message.error.default'),
3083
+ type: 'danger',
3084
+ });
3085
+ }
3086
+ setLoading(false);
3087
+ }), [
3088
+ subscription_title,
3089
+ listBlockAdded,
3090
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
3091
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid,
3092
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone,
3093
+ ]);
3094
+ useEffect(() => {
3095
+ if (refContainer.current) {
3096
+ IObserver.observe(refContainer.current);
3097
+ }
3098
+ return () => {
3099
+ IObserver.disconnect();
3100
+ };
3101
+ }, [categoryId]);
3102
+ return (React__default.createElement("div", { ref: refContainer },
3103
+ React__default.createElement(StyledLeadGenSubscriptionBox, { "data-type": "subscription_box_A" },
3104
+ showThankyou && (React__default.createElement(LeadGenThankYou, { image: Object.assign(Object.assign({}, thankyouImage), { src: thankyouImage.src || `${apiLeadUrl}admin/img/thanksyou.png` }), title: thankyouTitle, description: thankyouDescription, button: thankyouButton })),
3105
+ !showThankyou && (React__default.createElement(LeadGenSubscriptionBoxA, { loading: loading, image: subscriptionIcon || image, title: subscription_title, submitText: (_c = submitBlock === null || submitBlock === void 0 ? void 0 : submitBlock.data) === null || _c === void 0 ? void 0 : _c.value, blocks: listBlockAdded, locale: locale, form: form, rules: validateObj, onFinish: middlewareOnSubmit })))));
3106
+ };
3107
+ const LeadGenSubscriptionBox$1 = memo(LeadGenSubscriptionBoxWithoutMemo);
3108
+
3109
+ const Container = () => {
3110
+ const context = useContext(LeadGenContext);
3111
+ const { campaign_code, locale, siteId, siteDomain, userInfo, forceCampaign } = context;
3112
+ if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
3113
+ return null;
3114
+ }
3115
+ return (React__default.createElement(LeadGenSubscriptionBox$1, { locale: locale, siteId: siteId, siteDomain: siteDomain, userInfo: userInfo, forceCampaign: forceCampaign, campaign_code: campaign_code }));
3116
+ };
3117
+ Container.displayName = 'LeadGenSubscriptionBox';
3118
+ const LeadGenSubscriptionBoxContainer = (props) => {
3119
+ const { apiUrl, apiSubotUrl } = props;
3120
+ return (React__default.createElement(LeadGenContextProvider, Object.assign({}, props, { apiLeadUrl: apiUrl, apiSubotUrl: apiSubotUrl }),
3121
+ React__default.createElement(Container, null)));
3122
+ };
3123
+ const LeadGenSubscriptionBox = LeadGenSubscriptionBoxContainer;
3124
+
3125
+ const useImageSize = (src) => {
3126
+ const [width, setWidth] = useState(16);
3127
+ const [height, setHeight] = useState(9);
3128
+ const [loaded, setLoaded] = useState(false);
3129
+ // load src image to get its width and height
3130
+ useEffect(() => {
3131
+ setLoaded(false);
3132
+ if (src) {
3133
+ const img = new Image();
3134
+ img.addEventListener('load', () => {
3135
+ setWidth(img.naturalWidth);
3136
+ setHeight(img.naturalHeight);
3137
+ setLoaded(true);
3138
+ });
3139
+ img.addEventListener('error', () => {
3140
+ setWidth(16);
3141
+ setHeight(9);
3142
+ setLoaded(true);
3143
+ });
3144
+ img.src = src;
3145
+ }
3146
+ else {
3147
+ setWidth(16);
3148
+ setHeight(9);
3149
+ setLoaded(true);
3150
+ }
3151
+ }, [src]);
3152
+ return {
3153
+ loaded,
3154
+ width,
3155
+ height,
3156
+ };
3157
+ };
3158
+
3159
+ const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default.createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
3160
+ React__default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
3161
+ React__default.createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
3162
+
3163
+ // url: imageBlocks.imageMobile.data.url
3164
+ // newTab: imageBlocks.imageMobile.data.newtab
3165
+ // imageMobile: campaignShow.image
3166
+ // imageDestkop: campaignShow.image_desktop
3167
+ const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
3168
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3169
+ const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
3170
+ if (!imageMobileLoaded || !imageDestkopLoaded)
3171
+ return null;
3172
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
3173
+ React__default.createElement("div", { className: "le-center-tab-popup" },
3174
+ React__default.createElement("div", { style: { position: 'relative' } },
3175
+ React__default.createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
3176
+ isVideo(imageMobile) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
3177
+ React__default.createElement("source", { src: imageMobile }))) : (React__default.createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
3178
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3179
+ } })),
3180
+ isVideo(imageDestkop) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
3181
+ React__default.createElement("source", { src: imageDestkop }))) : (React__default.createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
3182
+ aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
3183
+ } }))),
3184
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3185
+ };
3186
+
3187
+ // title: titleText
3188
+ // titleAlign: textBlocks.titleBlock.data.align
3189
+ // subtitle: textBlocks.subtitleBlock.data.value
3190
+ // subtitleAlign: textBlocks.subtitleBlock.data.align
3191
+ // url: actionBlocks.linkButtonBlock.data.url
3192
+ // urlText: actionBlocks.linkButtonBlock.data.value
3193
+ // newTab: actionBlocks.linkButtonBlock.data.newtab
3194
+ // imageMobile: campaignShow.image
3195
+ // imageDesktop: campaignShow.image_desktop
3196
+ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
3197
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3198
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
3199
+ if (!imageMobileLoaded || !imageDesktopLoaded)
3200
+ return null;
3201
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
3202
+ React__default.createElement("aside", { className: "le-only-desktop" },
3203
+ React__default.createElement("div", { className: "le-floating-desktop" },
3204
+ React__default.createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
3205
+ imageDesktop ? (React__default.createElement("div", null,
3206
+ React__default.createElement("img", { style: {
3207
+ maxWidth: 120,
3208
+ borderTopLeftRadius: 5,
3209
+ borderBottomLeftRadius: 5,
3210
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
3211
+ }, src: imageDesktop }))) : null,
3212
+ React__default.createElement("div", { style: { padding: 20 } },
3213
+ React__default.createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
3214
+ React__default.createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
3215
+ React__default.createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
3216
+ React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
3217
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
3218
+ React__default.createElement("aside", { className: "le-only-mobile" },
3219
+ React__default.createElement("div", { className: "le-floating-mobile" },
3220
+ React__default.createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
3221
+ React__default.createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
3222
+ React__default.createElement("div", null,
3223
+ React__default.createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
3224
+ React__default.createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
3225
+ imageMobile ? (React__default.createElement("div", null,
3226
+ React__default.createElement("img", { style: {
3227
+ marginLeft: 15,
3228
+ marginTop: 4,
3229
+ maxWidth: 100,
3230
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3231
+ }, src: imageMobile }))) : null),
3232
+ React__default.createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
3233
+ React__default.createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
3234
+ React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
3235
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
3236
+ };
3237
+
3238
+ const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
3239
+ const { primaryColor } = useContext(LeadGenContext$1);
3240
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
3241
+ if (!imageLoaded)
3242
+ return null;
3243
+ return (React__default.createElement("div", { className: "lead-modal__thank-you leadgen-inner_thankyou" },
3244
+ React__default.createElement("div", { style: { width: '100%' } },
3245
+ React__default.createElement("img", { src: image, style: {
3246
+ maxHeight: 162,
3247
+ objectFit: 'cover',
3248
+ aspectRatio: `${imageWidth}/${imageHeight}`,
3249
+ }, loading: "lazy" }),
3250
+ title && (React__default.createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
3251
+ subtitle && (React__default.createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle.split('\n').map((text, idx, list) => {
3252
+ const isShowBr = idx < list.length - 1;
3253
+ return (React__default.createElement(React__default.Fragment, null,
3254
+ text,
3255
+ isShowBr && React__default.createElement("br", null)));
3256
+ }))),
1509
3257
  linkText && (React__default.createElement("div", null,
1510
3258
  React__default.createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
1511
3259
  React__default.createElement(Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
@@ -1614,262 +3362,46 @@ const InlineLayout = ({ content, inlinePosition, }) => {
1614
3362
  return target.parentElement.querySelector('.inline-lead-wrapper');
1615
3363
  }
1616
3364
  }
1617
- }
1618
- }, [inlinePosition]);
1619
- if (!inlinePosition || !target)
1620
- return null;
1621
- return createPortal(content, target);
1622
- };
1623
-
1624
- const SideBarLayout = ({ content }) => {
1625
- const targets = useMemo(() => {
1626
- const targetDoms = Array.from(document.querySelectorAll('.hc2-sidebar-with-ads,.page-main-col .right-col.f-right,.hhg-lead-sidebar'));
1627
- targetDoms.forEach((dom) => {
1628
- if (dom.querySelector('.sidebar-lead-modal-wrapper'))
1629
- return;
1630
- const wrapper = document.createElement('div');
1631
- wrapper.classList.add('sidebar-lead-modal-wrapper');
1632
- dom.prepend(wrapper);
1633
- });
1634
- return targetDoms.map((d) => d.querySelector('.sidebar-lead-modal-wrapper'));
1635
- }, []);
1636
- return (React__default.createElement(React__default.Fragment, null, targets.map((target) => createPortal(content, getWrapperDomWithSelector(target, 'sidebar-lead-modal-wrapper')))));
1637
- };
1638
-
1639
- const EmptyIcon = (props) => {
1640
- const { className, style } = props;
1641
- return (React__default.createElement("svg", { width: "160", height: "160", viewBox: "0 0 160 160", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, style: style },
1642
- React__default.createElement("path", { d: "M79.9974 113.333C98.4069 113.333 113.331 98.4096 113.331 80.0001C113.331 61.5906 98.4069 46.6667 79.9974 46.6667C61.5879 46.6667 46.6641 61.5906 46.6641 80.0001C46.6641 98.4096 61.5879 113.333 79.9974 113.333Z", fill: "#F44D2C" }),
1643
- React__default.createElement("path", { d: "M92.434 95.0004C91.7771 95.0004 91.1213 94.7499 90.6194 94.249L65.7521 69.3807C64.7493 68.3779 64.7493 66.7542 65.7521 65.7524C66.7549 64.7507 68.3786 64.7497 69.3804 65.7524L94.2487 90.6208C95.2515 91.6235 95.2515 93.2473 94.2487 94.249C93.7468 94.7499 93.0909 95.0004 92.434 95.0004Z", fill: "white" }),
1644
- React__default.createElement("path", { d: "M67.5648 95C66.9079 95 66.252 94.7496 65.7501 94.2487C64.7474 93.2459 64.7474 91.6222 65.7501 90.6204L90.6185 65.7521C91.6212 64.7493 93.245 64.7493 94.2467 65.7521C95.2485 66.7549 95.2495 68.3786 94.2467 69.3804L69.3794 94.2487C68.8786 94.7496 68.2217 95 67.5648 95Z", fill: "white" })));
1645
- };
1646
-
1647
- const EmptyComponent = ({ onClose, onContinue, }) => {
1648
- const { t } = useTranslations();
1649
- return (React__default.createElement("div", { className: "leadgen-empty" },
1650
- React__default.createElement("div", { className: "leadgen-empty_body" },
1651
- React__default.createElement("div", { className: "leadgen-empty_wrapper" },
1652
- React__default.createElement(EmptyIcon, { className: "leadgen-empty_image" }),
1653
- React__default.createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
1654
- React__default.createElement("div", { className: "leadgen-empty_footer" },
1655
- React__default.createElement(Button$1, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
1656
- React__default.createElement(Button$1, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
1657
- };
1658
-
1659
- const libraries = ['places'];
1660
- const GoogleLocationBlock = (props) => {
1661
- var _a;
1662
- const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = __rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
1663
- const [LoadScript, setLoadScript] = useState(null);
1664
- const [value, setValue] = useState(defaultValue || valueProps);
1665
- const { predictions } = usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
1666
- const onChangeAutocomplete = useCallback((s) => {
1667
- setValue(s);
1668
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
1669
- }, []);
1670
- const onClickItem = useCallback((item) => {
1671
- /** For sure get value */
1672
- setValue(item.value);
1673
- const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
1674
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
1675
- }, [onChangeProps, predictions]);
1676
- useEffect(() => {
1677
- setValue(valueProps);
1678
- }, [valueProps]);
1679
- useEffect(() => {
1680
- var _a, _b, _c;
1681
- // only load extra google script when not yet loaded
1682
- if (!((_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.places) === null || _c === void 0 ? void 0 : _c.AutocompleteService) && !LoadScript) {
1683
- import('@react-google-maps/api').then((m) => {
1684
- setLoadScript(() => m.LoadScript);
1685
- });
1686
- }
1687
- }, []);
1688
- return (React__default.createElement(Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
1689
- return { value: pred.description, label: pred.description };
1690
- }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
1691
- return (React__default.createElement(React__default.Fragment, null,
1692
- LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default.createElement(React__default.Fragment, null), style: { width: '100%' } })),
1693
- children));
1694
- } }, restProps)));
1695
- };
1696
-
1697
- // eslint-disable-next-line @typescript-eslint/no-var-requires
1698
- const customParseFormat = require('dayjs/plugin/customParseFormat');
1699
- dayjs.extend(customParseFormat);
1700
- // You can give context variables any name
1701
- const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
1702
- const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
1703
- const { t } = useTranslations();
1704
- const initialValues = useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
1705
- const validateObj = useMemo(() => {
1706
- const InputBlocks = [
1707
- 'TextBlock',
1708
- 'NumberBlock',
1709
- 'EmailBlock',
1710
- 'PhoneBlock',
1711
- 'DateBlock',
1712
- 'CheckboxBlock',
1713
- 'RadioBlock',
1714
- 'DropdownBlock',
1715
- 'PhoneOtpBlock',
1716
- 'WhatsappOtpBlock',
1717
- 'ZaloOtpBlock',
1718
- 'LocationBlock',
1719
- 'TncBlock',
1720
- ];
1721
- // ALL are required and can skip if not touched yet
1722
- const withSharedCheck = (name, cb,
1723
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1724
- block) => {
1725
- return (value) => {
1726
- var _a;
1727
- const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
1728
- if (!formRef.current.isTouched(name))
1729
- return;
1730
- if ((typeof value === 'string' && value.trim() === '') ||
1731
- typeof value === 'undefined' ||
1732
- (Array.isArray(value) && value.length === 0)) {
1733
- return isBLockRequired
1734
- ? t('validator.required')
1735
- : cb === null || cb === void 0 ? void 0 : cb(value);
1736
- }
1737
- return cb === null || cb === void 0 ? void 0 : cb(value);
1738
- };
1739
- };
1740
- return listBlockAdded
1741
- .filter((b) => InputBlocks.includes(b.name))
1742
- .reduce((r, b) => {
1743
- const { name: fieldType, data } = b || {};
1744
- const { value: fieldName, required } = data || {};
1745
- const isRequired = required !== null && required !== void 0 ? required : true;
1746
- if (fieldType === 'NumberBlock') {
1747
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1748
- if (value && isNaN(Number(value))) {
1749
- return t('validator.number');
1750
- }
1751
- }, b) });
1752
- }
1753
- else if (fieldType === 'EmailBlock') {
1754
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1755
- if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
1756
- return t('validator.email');
1757
- }
1758
- if (!value)
1759
- return;
1760
- validatingEmailRef.current = true;
1761
- setTimeout(() => {
1762
- formRef.current.setFieldError(fieldName, 'Validating...');
1763
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1764
- email: value,
1765
- })
1766
- .then((tKey) => {
1767
- if (tKey) {
1768
- formRef.current.setFieldError(fieldName, t(tKey));
1769
- }
1770
- else {
1771
- formRef.current.clearFieldError(fieldName);
1772
- }
1773
- validatingEmailRef.current = false;
1774
- })
1775
- .catch((e) => {
1776
- console.error(e);
1777
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
1778
- validatingEmailRef.current = false;
1779
- });
1780
- }, 200);
1781
- }, b) });
1782
- }
1783
- else if (fieldType === 'PhoneBlock' ||
1784
- fieldType === 'PhoneOtpBlock' ||
1785
- fieldType === 'ZaloOtpBlock' ||
1786
- fieldType === 'WhatsappOtpBlock') {
1787
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1788
- if (value &&
1789
- window.intlTelInputUtils &&
1790
- !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
1791
- return t('validator.phone');
1792
- }
1793
- if (!value)
1794
- return;
1795
- validatingPhoneRef.current = true;
1796
- setTimeout(() => {
1797
- formRef.current.setFieldError(fieldName, 'Validating...');
1798
- if (b.data.singleSubmission) {
1799
- checkUsedPhoneOnlyWithCache(campaignId, value)
1800
- .then((tKey) => {
1801
- if (tKey) {
1802
- formRef.current.setFieldError(fieldName, t(tKey));
1803
- }
1804
- else {
1805
- formRef.current.clearFieldError(fieldName);
1806
- }
1807
- validatingPhoneRef.current = false;
1808
- })
1809
- .catch((err) => {
1810
- console.error(err);
1811
- formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
1812
- validatingPhoneRef.current = false;
1813
- });
1814
- }
1815
- else {
1816
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1817
- phone: value,
1818
- })
1819
- .then((tKey) => {
1820
- if (tKey) {
1821
- formRef.current.setFieldError(fieldName, t(tKey));
1822
- }
1823
- else {
1824
- formRef.current.clearFieldError(fieldName);
1825
- }
1826
- validatingPhoneRef.current = false;
1827
- })
1828
- .catch((e) => {
1829
- console.error(e);
1830
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
1831
- validatingPhoneRef.current = false;
1832
- });
1833
- }
1834
- }, 200);
1835
- }, b) });
1836
- }
1837
- else if (fieldType === 'DateBlock') {
1838
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1839
- if (!isRequired && !value) {
1840
- return;
1841
- }
1842
- const errMsg = t('validator.dateInvalid');
1843
- const dayInJS = typeof value === 'string'
1844
- ? dayjs(value, format, true)
1845
- : dayjs(value);
1846
- if (!dayInJS.isValid()) {
1847
- return errMsg;
1848
- }
1849
- }, b) });
1850
- }
1851
- else if (fieldType === 'TncBlock') {
1852
- return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
1853
- if (isRequired && !value) {
1854
- return t('validator.required');
1855
- }
1856
- }, b) });
1857
- }
1858
- else {
1859
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
1860
- }
1861
- }, {});
1862
- }, [listBlockAdded.map((b) => b.name).join(','), format]);
1863
- const form = useLeadForm({
1864
- validateInputOnChange: true,
1865
- validateInputOnBlur: true,
1866
- clearInputErrorOnChange: true,
1867
- validate: validateObj,
1868
- initialValues,
1869
- });
1870
- const formRef = useRef(form);
1871
- formRef.current = form;
1872
- return { form, validateObj };
3365
+ }
3366
+ }, [inlinePosition]);
3367
+ if (!inlinePosition || !target)
3368
+ return null;
3369
+ return createPortal(content, target);
3370
+ };
3371
+
3372
+ const SideBarLayout = ({ content }) => {
3373
+ const targets = useMemo(() => {
3374
+ const targetDoms = Array.from(document.querySelectorAll('.hc2-sidebar-with-ads,.page-main-col .right-col.f-right,.hhg-lead-sidebar'));
3375
+ targetDoms.forEach((dom) => {
3376
+ if (dom.querySelector('.sidebar-lead-modal-wrapper'))
3377
+ return;
3378
+ const wrapper = document.createElement('div');
3379
+ wrapper.classList.add('sidebar-lead-modal-wrapper');
3380
+ dom.prepend(wrapper);
3381
+ });
3382
+ return targetDoms.map((d) => d.querySelector('.sidebar-lead-modal-wrapper'));
3383
+ }, []);
3384
+ return (React__default.createElement(React__default.Fragment, null, targets.map((target) => createPortal(content, getWrapperDomWithSelector(target, 'sidebar-lead-modal-wrapper')))));
3385
+ };
3386
+
3387
+ const EmptyIcon = (props) => {
3388
+ const { className, style } = props;
3389
+ return (React__default.createElement("svg", { width: "160", height: "160", viewBox: "0 0 160 160", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, style: style },
3390
+ React__default.createElement("path", { d: "M79.9974 113.333C98.4069 113.333 113.331 98.4096 113.331 80.0001C113.331 61.5906 98.4069 46.6667 79.9974 46.6667C61.5879 46.6667 46.6641 61.5906 46.6641 80.0001C46.6641 98.4096 61.5879 113.333 79.9974 113.333Z", fill: "#F44D2C" }),
3391
+ React__default.createElement("path", { d: "M92.434 95.0004C91.7771 95.0004 91.1213 94.7499 90.6194 94.249L65.7521 69.3807C64.7493 68.3779 64.7493 66.7542 65.7521 65.7524C66.7549 64.7507 68.3786 64.7497 69.3804 65.7524L94.2487 90.6208C95.2515 91.6235 95.2515 93.2473 94.2487 94.249C93.7468 94.7499 93.0909 95.0004 92.434 95.0004Z", fill: "white" }),
3392
+ React__default.createElement("path", { d: "M67.5648 95C66.9079 95 66.252 94.7496 65.7501 94.2487C64.7474 93.2459 64.7474 91.6222 65.7501 90.6204L90.6185 65.7521C91.6212 64.7493 93.245 64.7493 94.2467 65.7521C95.2485 66.7549 95.2495 68.3786 94.2467 69.3804L69.3794 94.2487C68.8786 94.7496 68.2217 95 67.5648 95Z", fill: "white" })));
3393
+ };
3394
+
3395
+ const EmptyComponent = ({ onClose, onContinue, }) => {
3396
+ const { t } = useTranslations();
3397
+ return (React__default.createElement("div", { className: "leadgen-empty" },
3398
+ React__default.createElement("div", { className: "leadgen-empty_body" },
3399
+ React__default.createElement("div", { className: "leadgen-empty_wrapper" },
3400
+ React__default.createElement(EmptyIcon, { className: "leadgen-empty_image" }),
3401
+ React__default.createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
3402
+ React__default.createElement("div", { className: "leadgen-empty_footer" },
3403
+ React__default.createElement(Button$1, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
3404
+ React__default.createElement(Button$1, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
1873
3405
  };
1874
3406
 
1875
3407
  const SubtitleBlock = ({ children, align, }) => (React__default.createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
@@ -2198,11 +3730,13 @@ const TextField = (props) => {
2198
3730
  const $focusEl = $textEl.item($textEl.length - 1);
2199
3731
  if ($focusEl) {
2200
3732
  $focusEl.focus();
2201
- $focusEl.scrollIntoView({
2202
- behavior: 'auto',
2203
- block: 'center',
2204
- inline: 'start',
2205
- });
3733
+ setTimeout(() => {
3734
+ $focusEl.scrollIntoView({
3735
+ behavior: 'auto',
3736
+ block: 'center',
3737
+ inline: 'start',
3738
+ });
3739
+ }, 100);
2206
3740
  }
2207
3741
  }, [shrink]);
2208
3742
  useEffect(() => {
@@ -2402,832 +3936,488 @@ const FormContainer = (_a) => {
2402
3936
  header,
2403
3937
  HeaderContent,
2404
3938
  React__default.createElement("div", { className: "leadgen-form_body" }, children))),
2405
- !header && (React__default.createElement(React__default.Fragment, null,
2406
- HeaderContent,
2407
- React__default.createElement("div", { className: "leadgen-form_body" }, children))),
2408
- React__default.createElement("div", { className: "leadgen-form_footer" }, footer))));
2409
- };
2410
-
2411
- const StyleHeaderImage = styled.div `
2412
- position: relative;
2413
- overflow: hidden;
2414
- width: 100%;
2415
- height: 100%;
2416
- padding-top: ${({ paddingTop }) => paddingTop}%;
2417
- .leadgen-header_image_feature {
2418
- position: absolute;
2419
- inset: 0;
2420
- min-width: 100%;
2421
- min-height: 100%;
2422
- max-width: 100%;
2423
- max-height: 100%;
2424
- object-fit: cover;
2425
- object-position: center;
2426
- }
2427
- `;
2428
- const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
2429
- if (!src) {
2430
- return null;
2431
- }
2432
- return (React__default.createElement(StyleHeaderImage, { paddingTop: (1 / ratio) * 100, className: clsx(className, 'leadgen-header_image'), style: style }, isVideo(src) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true, className: "leadgen-header_image_feature leadgen-header_image_video", src: src })) : (React__default.createElement("img", { src: src, draggable: "false", alt: "", className: "leadgen-header_image_feature leadgen-header_image_image" }))));
2433
- };
2434
-
2435
- const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
2436
- const { primaryColor } = useContext(LeadGenContext);
2437
- const { t } = useTranslations();
2438
- const phone = otpData.phone;
2439
- const otpType = otpData.type;
2440
- const [otp, setOtp] = useState('');
2441
- const [isDirty, setIsDirty] = useState(false);
2442
- const [resendTimer, setResendTimer] = useState(autoSendWhenOpen ? 0 : 60);
2443
- const inputRef = useRef(null);
2444
- const [errorMsg, setErrorMsg] = useState();
2445
- const [displayPhone, setDisplayPhone] = useState('');
2446
- const formatPhoneNumberIntlRef = useRef();
2447
- const [isSubmitLoading, setIsSubmitLoading] = useState(false);
2448
- useEffect(() => {
2449
- (() => __awaiter(void 0, void 0, void 0, function* () {
2450
- var _a;
2451
- if (!formatPhoneNumberIntlRef.current) {
2452
- const res = yield import('react-phone-number-input');
2453
- formatPhoneNumberIntlRef.current = res.formatPhoneNumberIntl;
2454
- }
2455
- setDisplayPhone(((_a = formatPhoneNumberIntlRef.current) === null || _a === void 0 ? void 0 : _a.call(formatPhoneNumberIntlRef, phone)) || phone);
2456
- }))();
2457
- }, [phone]);
2458
- const sendOtp = () => __awaiter(void 0, void 0, void 0, function* () {
2459
- var _a;
2460
- if (!phone) {
2461
- return;
2462
- }
2463
- const res = yield Service.sendSMSOtpLead({
2464
- phone,
2465
- type: otpType,
2466
- });
2467
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2468
- if (respMessage === 'Send sms successfully' ||
2469
- respMessage === 'Send WhatsApp successfully' ||
2470
- respMessage === 'Send Zalo successfully') {
2471
- setResendTimer(60);
2472
- setTimeout(() => {
2473
- if (inputRef.current) {
2474
- inputRef.current.focus();
2475
- inputRef.current.scrollIntoView({ block: 'center' });
2476
- }
2477
- }, 100);
2478
- }
2479
- else if (respMessage === 'This phone number was verified') {
2480
- onSuccess();
2481
- }
2482
- else {
2483
- setErrorMsg(respMessage || 'Something went wrong!');
2484
- // const defaultError = f({ id: 'notification.comment.somethingWrong' })
2485
- // setStatusVerifyOTP('idle')
2486
- // pushNotifications({
2487
- // title: respMessage || defaultError,
2488
- // message: '',
2489
- // type: 'danger',
2490
- // })
2491
- }
2492
- });
2493
- const submitOtp = () => __awaiter(void 0, void 0, void 0, function* () {
2494
- if (!phone || !otp) {
2495
- return;
2496
- }
2497
- setIsSubmitLoading(true);
2498
- const res = yield Service.verifyOtpLead({
2499
- phone,
2500
- otp,
2501
- type: otpType,
2502
- });
2503
- const respMessage = res === null || res === void 0 ? void 0 : res._messages[0];
2504
- if (respMessage === 'Verify successfully' ||
2505
- respMessage === 'Verify WhatsApp OTP sucess' ||
2506
- respMessage === 'Verify Zalo OTP sucess') {
2507
- onSuccess();
2508
- }
2509
- else if (respMessage === 'This phone number was verified') {
2510
- onSuccess();
2511
- }
2512
- else {
2513
- setErrorMsg(respMessage || 'something Wrong');
2514
- // setIsShowError(true)
2515
- // setStatusVerifyOTP('sent')
2516
- // pushNotifications({
2517
- // title: res?._messages[0] || defaultError,
2518
- // message: '',
2519
- // type: 'danger',
2520
- // })
2521
- }
2522
- setIsSubmitLoading(false);
2523
- });
2524
- useEffect(() => {
2525
- setTimeout(() => {
2526
- if (resendTimer > 0) {
2527
- setResendTimer((r) => r - 1);
2528
- }
2529
- }, 1000);
2530
- }, [resendTimer]);
2531
- useEffect(() => {
2532
- if (autoSendWhenOpen && !resendTimer) {
2533
- sendOtp();
2534
- }
2535
- }, []);
2536
- return (React__default.createElement("form", { onSubmit: (e) => {
2537
- e.preventDefault();
2538
- submitOtp();
2539
- }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
2540
- React__default.createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
2541
- phone: `<strong>${displayPhone}</strong>`,
2542
- }), footer: React__default.createElement(React__default.Fragment, null,
2543
- React__default.createElement(Button$1, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
2544
- React__default.createElement(Button$1, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
2545
- sendOtp();
2546
- }, disabled: !!resendTimer }, t('lead.otp.resend', {
2547
- timer: resendTimer ? ` (${resendTimer}s)` : '',
2548
- }))) },
2549
- React__default.createElement("div", { className: "leadgen-form_inner" },
2550
- React__default.createElement(Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
2551
- React__default.createElement(OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
2552
- setIsDirty(true);
2553
- setOtp(v.toString());
2554
- if (isDirty && !v)
2555
- setErrorMsg('OTP is required');
2556
- else
2557
- setErrorMsg(undefined);
2558
- } }))))));
2559
- };
2560
-
2561
- // url: imageBlocks.imageMobile.data.url
2562
- // newTab: imageBlocks.imageMobile.data.newtab
2563
- // image: campaignShow.image
2564
- // imageDestkop: campaignShow.image_desktop
2565
- const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
2566
- LEADGEN_LAYOUT.Fullscreen,
2567
- LEADGEN_LAYOUT.Slider,
2568
- ];
2569
- const LEADGEN_LIMIT_LIGHTBOXB = 6;
2570
- const LEADGEN_SHOW_HEADER = [
2571
- 'LightBoxA',
2572
- 'InlineA',
2573
- LEADGEN_LAYOUT.Sidebar,
2574
- LEADGEN_LAYOUT.Slider,
2575
- ];
2576
- const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2577
- var _a, _b;
2578
- const { primaryColor } = useContext(LeadGenContext);
2579
- const { isMobile } = useScreenSize();
2580
- const [open, setOpen] = useState(!!campaignId);
2581
- const [showOtpPhone, setShowOtpPhone] = useState(null);
2582
- const [isSubmitLoading, setIsSubmitLoading] = useState(false);
2583
- const [snap, setSnap] = useState(0.8);
2584
- const formRef = useRef();
2585
- const onClose = () => {
2586
- if (showOtpPhone) {
2587
- setShowOtpPhone(null);
2588
- }
2589
- else {
2590
- onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2591
- }
2592
- };
2593
- const textBlocks = JSON.parse(extraFields.textBlocks);
2594
- const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
2595
- const actionBlocks = JSON.parse(extraFields.actionBlocks);
2596
- const popUpSubmitText = actionBlocks.submitBlock.data.value;
2597
- const currentPath = location.pathname;
2598
- const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
2599
- const { align: titleAlign } = textBlocks.titleBlock.data || {};
2600
- const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
2601
- const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
2602
- const isLightBox = currentLayout.includes('LightBox');
2603
- const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
2604
- const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
2605
- const isInline = currentLayout.includes('Inline');
2606
- const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
2607
- const isInPage = isInline || isSidebar;
2608
- const isDrawer = isLightBoxB && isMobile;
2609
- const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
2610
- const hasForm = isLightBoxA
2611
- ? listBlockAdded.some((item) => LEADGEN_BLOCK_IN_FORM.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
2612
- : true;
2613
- const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
2614
- const showHeader = !!imageMobile || !!imageDesktop;
2615
- const onlyHeader = !title && !description;
2616
- const showButtonClose = !isInline;
2617
- if (window.innerWidth < 769 &&
2618
- LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
2619
- console.log('😎 Not show fullscreen, slider on mobile ');
3939
+ !header && (React__default.createElement(React__default.Fragment, null,
3940
+ HeaderContent,
3941
+ React__default.createElement("div", { className: "leadgen-form_body" }, children))),
3942
+ React__default.createElement("div", { className: "leadgen-form_footer" }, footer))));
3943
+ };
3944
+
3945
+ const StyleHeaderImage = styled.div `
3946
+ position: relative;
3947
+ overflow: hidden;
3948
+ width: 100%;
3949
+ height: 100%;
3950
+ padding-top: ${({ paddingTop }) => paddingTop}%;
3951
+ .leadgen-header_image_feature {
3952
+ position: absolute;
3953
+ inset: 0;
3954
+ min-width: 100%;
3955
+ min-height: 100%;
3956
+ max-width: 100%;
3957
+ max-height: 100%;
3958
+ object-fit: cover;
3959
+ object-position: center;
3960
+ }
3961
+ `;
3962
+ const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
3963
+ if (!src) {
2620
3964
  return null;
2621
3965
  }
3966
+ return (React__default.createElement(StyleHeaderImage, { paddingTop: (1 / ratio) * 100, className: clsx(className, 'leadgen-header_image'), style: style }, isVideo(src) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true, className: "leadgen-header_image_feature leadgen-header_image_video", src: src })) : (React__default.createElement("img", { src: src, draggable: "false", alt: "", className: "leadgen-header_image_feature leadgen-header_image_image" }))));
3967
+ };
3968
+
3969
+ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
3970
+ const { primaryColor } = useContext(LeadGenContext$1);
3971
+ const { t } = useTranslations();
3972
+ const phone = otpData.phone;
3973
+ const otpType = otpData.type;
3974
+ const [otp, setOtp] = useState('');
3975
+ const [isDirty, setIsDirty] = useState(false);
3976
+ const [resendTimer, setResendTimer] = useState(autoSendWhenOpen ? 0 : 60);
3977
+ const inputRef = useRef(null);
3978
+ const [errorMsg, setErrorMsg] = useState();
3979
+ const [displayPhone, setDisplayPhone] = useState('');
3980
+ const formatPhoneNumberIntlRef = useRef();
3981
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
2622
3982
  useEffect(() => {
2623
- if (isLightBox || isFullscreen) {
2624
- document.body.classList.add('noscroll');
3983
+ (() => __awaiter(void 0, void 0, void 0, function* () {
3984
+ var _a;
3985
+ if (!formatPhoneNumberIntlRef.current) {
3986
+ const res = yield import('react-phone-number-input');
3987
+ formatPhoneNumberIntlRef.current = res.formatPhoneNumberIntl;
3988
+ }
3989
+ setDisplayPhone(((_a = formatPhoneNumberIntlRef.current) === null || _a === void 0 ? void 0 : _a.call(formatPhoneNumberIntlRef, phone)) || phone);
3990
+ }))();
3991
+ }, [phone]);
3992
+ const sendOtp = () => __awaiter(void 0, void 0, void 0, function* () {
3993
+ var _a;
3994
+ if (!phone) {
3995
+ return;
2625
3996
  }
2626
- if (!window.intlTelInputUtils) {
2627
- require('intl-tel-input/build/js/utils');
3997
+ const res = yield Service.sendSMSOtpLead({
3998
+ phone,
3999
+ type: otpType,
4000
+ });
4001
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4002
+ if (respMessage === 'Send sms successfully' ||
4003
+ respMessage === 'Send WhatsApp successfully' ||
4004
+ respMessage === 'Send Zalo successfully') {
4005
+ setResendTimer(60);
4006
+ setTimeout(() => {
4007
+ if (inputRef.current) {
4008
+ inputRef.current.focus();
4009
+ inputRef.current.scrollIntoView({ block: 'center' });
4010
+ }
4011
+ }, 100);
4012
+ }
4013
+ else if (respMessage === 'This phone number was verified') {
4014
+ onSuccess();
4015
+ }
4016
+ else {
4017
+ setErrorMsg(respMessage || 'Something went wrong!');
4018
+ // const defaultError = f({ id: 'notification.comment.somethingWrong' })
4019
+ // setStatusVerifyOTP('idle')
4020
+ // pushNotifications({
4021
+ // title: respMessage || defaultError,
4022
+ // message: '',
4023
+ // type: 'danger',
4024
+ // })
2628
4025
  }
2629
- clearCacheUsedEmailOrPhone();
2630
- }, []);
2631
- const validatingPhoneRef = useRef(false);
2632
- const validatingEmailRef = useRef(false);
2633
- const { form, validateObj } = useLeadFormConfig({
2634
- listBlockAdded,
2635
- validatingPhoneRef,
2636
- validatingEmailRef,
2637
- campaignId,
2638
- campaign_subot_id,
2639
- userInfo,
2640
- format: (_a = (ISO_FORMAT[locale] || ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
2641
4026
  });
2642
- const middlewareOnSubmit = (e) => {
2643
- e.preventDefault();
2644
- // mark all as touched to allow validation
2645
- const fields = Object.keys(validateObj);
2646
- const fieldStatus = fields.reduce((acc, cur) => {
2647
- acc[cur] = true;
2648
- return acc;
2649
- }, {});
2650
- form.setTouched(fieldStatus);
2651
- if (validatingEmailRef.current || validatingPhoneRef.current) {
4027
+ const submitOtp = () => __awaiter(void 0, void 0, void 0, function* () {
4028
+ if (!phone || !otp) {
2652
4029
  return;
2653
4030
  }
2654
- setTimeout(() => {
2655
- form.onSubmit((v) => {
2656
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2657
- if (Object.keys(form.errors).length)
2658
- return;
2659
- let newShowOtpPhone = null;
2660
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
2661
- // not submit yet, open otp
2662
- const fieldName = (_b = (_a = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock)) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value;
2663
- if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
2664
- newShowOtpPhone = {
2665
- phone: v[fieldName],
2666
- type: 'phone',
2667
- };
2668
- }
2669
- }
2670
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
2671
- // not submit yet, open otp
2672
- const fieldName = (_e = (_d = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock)) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.value;
2673
- if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
2674
- newShowOtpPhone = {
2675
- phone: v[fieldName],
2676
- type: 'whatsapp',
2677
- };
2678
- }
2679
- }
2680
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
2681
- // not submit yet, open otp
2682
- const fieldName = (_h = (_g = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock)) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.value;
2683
- if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
2684
- newShowOtpPhone = {
2685
- phone: v[fieldName],
2686
- type: 'zalo',
2687
- };
2688
- }
2689
- }
2690
- if (newShowOtpPhone) {
2691
- setIsSubmitLoading(true);
2692
- Service.sendSMSOtpLead(newShowOtpPhone)
2693
- .then((res) => {
2694
- var _a;
2695
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2696
- if (respMessage === 'This phone number was verified') {
2697
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2698
- return;
2699
- }
2700
- setShowOtpPhone(newShowOtpPhone);
2701
- })
2702
- .finally(() => {
2703
- setIsSubmitLoading(false);
2704
- });
2705
- return;
2706
- }
2707
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2708
- })(e);
2709
- }, 100);
2710
- };
2711
- const onOpenChange = (_open) => {
2712
- setOpen(_open);
2713
- if (!_open) {
2714
- setTimeout(() => {
2715
- onClose();
2716
- }, 250);
2717
- }
2718
- };
2719
- const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
2720
- const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
2721
- const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
2722
- const renderAfterImageSizes = imageMobileLoaded &&
2723
- imageDesktopLoaded &&
2724
- (isFullscreen ? imageBackgroundLoaded : true);
2725
- const ButtonSubmit = useMemo(() => {
2726
- var _a;
2727
- return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default.createElement(Button$1, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
2728
- }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
2729
- const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
2730
- const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default.createElement(React__default.Fragment, null, LinkButtonBlock.map((item, index) => {
2731
- var _a, _b, _c;
2732
- return (React__default.createElement(Button$1, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
2733
- onClose === null || onClose === void 0 ? void 0 : onClose();
2734
- onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2735
- } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
2736
- })));
2737
- const PopupHeader = showHeader && (React__default.createElement("header", { className: clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default.createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default.createElement(React__default.Fragment, null,
2738
- React__default.createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
2739
- React__default.createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
2740
- const PopupEmpty = showEmpty && (React__default.createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
2741
- const PopupForm = (React__default.createElement(LeadFormProvider, { form: form },
2742
- React__default.createElement("form", { ref: formRef, className: "leadgen-form", onSubmit: middlewareOnSubmit },
2743
- React__default.createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
2744
- React__default.createElement("div", { className: "leadgen-form_inner" },
2745
- React__default.createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
2746
- const PopupOtp = showOtpPhone && (React__default.createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
2747
- setShowOtpPhone(null);
2748
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
2749
- } }));
2750
- const PopupThankYou = showThankyou && (React__default.createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
2751
- const PopupContent = (React__default.createElement("div", { className: clsx('leadgen-content', {
2752
- 'leadgen-content_small': limitFieldsLightBoxB,
2753
- }) },
2754
- !headerInsideFormContainer && PopupHeader,
2755
- !onlyHeader && (React__default.createElement("div", { className: "leadgen-inner" },
2756
- PopupThankYou,
2757
- !showThankyou && (React__default.createElement(React__default.Fragment, null,
2758
- PopupOtp,
2759
- PopupEmpty,
2760
- !(showOtpPhone || showEmpty) && PopupForm))))));
2761
- const styleOverlay = useMemo(() => {
2762
- let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
2763
- if (isMobile && imageOverlayMobile) {
2764
- styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4031
+ setIsSubmitLoading(true);
4032
+ const res = yield Service.verifyOtpLead({
4033
+ phone,
4034
+ otp,
4035
+ type: otpType,
4036
+ });
4037
+ const respMessage = res === null || res === void 0 ? void 0 : res._messages[0];
4038
+ if (respMessage === 'Verify successfully' ||
4039
+ respMessage === 'Verify WhatsApp OTP sucess' ||
4040
+ respMessage === 'Verify Zalo OTP sucess') {
4041
+ onSuccess();
2765
4042
  }
2766
- if (!isMobile && imageOverlayDesktop) {
2767
- styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4043
+ else if (respMessage === 'This phone number was verified') {
4044
+ onSuccess();
2768
4045
  }
2769
- return styleContent;
2770
- }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
2771
- const PopupWrapper = (React__default.createElement(React__default.Fragment, null,
2772
- React__default.createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
2773
- React__default.createElement("div", { className: clsx('leadgen-wrapper', {
2774
- 'leadgen-wrapper_small': limitFieldsLightBoxB,
2775
- }) },
2776
- showButtonClose && (React__default.createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
2777
- PopupContent)));
2778
- const popupContainerClassName = clsx('leadgen', `leadgen-${currentLayout}`, {
2779
- 'leadgen-lightbox': isLightBox,
2780
- 'leadgen-inline': isInPage,
2781
- 'leadgen-slider': isSlider,
4046
+ else {
4047
+ setErrorMsg(respMessage || 'something Wrong');
4048
+ // setIsShowError(true)
4049
+ // setStatusVerifyOTP('sent')
4050
+ // pushNotifications({
4051
+ // title: res?._messages[0] || defaultError,
4052
+ // message: '',
4053
+ // type: 'danger',
4054
+ // })
4055
+ }
4056
+ setIsSubmitLoading(false);
2782
4057
  });
2783
- const PopupContainer = isDrawer ? (React__default.createElement(DrawerComponent, { fadeFromIndex: ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
2784
- PopupWrapper,
2785
- React__default.createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default.createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
2786
- isFullscreen ? (React__default.createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
2787
- aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
2788
- } })) : null,
2789
- PopupWrapper));
2790
- if (!renderAfterImageSizes)
2791
- return null;
2792
- if (isLightBox || isFullscreen || isSlider) {
2793
- return PopupContainer;
2794
- }
2795
- else if (isSidebar) {
2796
- return React__default.createElement(SideBarLayout, { content: PopupContainer });
2797
- }
2798
- else if (isInline) {
2799
- return (React__default.createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
2800
- }
2801
- return null;
2802
- };
2803
-
2804
- const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
2805
- const currentPath = location.pathname;
2806
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
2807
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
2808
- if (!imageMobileLoaded || !imageDesktopLoaded)
2809
- return null;
2810
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
2811
- currentLayout == 'SkinA' ? (React__default.createElement("aside", { className: "le-only-desktop" },
2812
- React__default.createElement("div", { className: "le-skin-a-desktop" },
2813
- React__default.createElement("div", { style: { position: 'relative' } },
2814
- React__default.createElement("img", { src: imageDesktop, style: {
2815
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2816
- } }),
2817
- React__default.createElement("a", { style: {
2818
- position: 'absolute',
2819
- top: '75%',
2820
- left: '50%',
2821
- transform: 'translate(-50%, -50%)',
2822
- textAlign: 'center',
2823
- width: 'calc(100% - 15px)',
2824
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2825
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
2826
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default.createElement("aside", { className: "le-only-desktop" },
2827
- React__default.createElement("div", { className: "" },
2828
- React__default.createElement("div", { style: { position: 'relative', zIndex: 10000 } },
2829
- React__default.createElement("img", { src: imageDesktop, style: {
2830
- width: '100%',
2831
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2832
- } }),
2833
- React__default.createElement("a", { style: {
2834
- position: 'absolute',
2835
- top: '75%',
2836
- left: '50%',
2837
- transform: 'translate(-50%, -50%)',
2838
- textAlign: 'center',
2839
- width: '100%',
2840
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2841
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2842
- React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
2843
- React__default.createElement("aside", { className: "le-only-mobile" },
2844
- React__default.createElement("div", { className: "le-skin-mobile" },
2845
- React__default.createElement("div", { style: { position: 'relative' } },
2846
- isVideo(imageMobile) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true },
2847
- React__default.createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default.createElement("img", { src: imageMobile, style: {
2848
- width: '100%',
2849
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
2850
- } })),
2851
- React__default.createElement("a", { style: {
2852
- position: 'absolute',
2853
- top: '82%',
2854
- left: '50%',
2855
- transform: 'translate(-50%, -50%)',
2856
- textAlign: 'center',
2857
- maxWidth: 'calc(100% - 15px)',
2858
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2859
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2860
- React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4058
+ useEffect(() => {
4059
+ setTimeout(() => {
4060
+ if (resendTimer > 0) {
4061
+ setResendTimer((r) => r - 1);
4062
+ }
4063
+ }, 1000);
4064
+ }, [resendTimer]);
4065
+ useEffect(() => {
4066
+ if (autoSendWhenOpen && !resendTimer) {
4067
+ sendOtp();
4068
+ }
4069
+ }, []);
4070
+ return (React__default.createElement("form", { onSubmit: (e) => {
4071
+ e.preventDefault();
4072
+ submitOtp();
4073
+ }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
4074
+ React__default.createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
4075
+ phone: `<strong>${displayPhone}</strong>`,
4076
+ }), footer: React__default.createElement(React__default.Fragment, null,
4077
+ React__default.createElement(Button$1, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
4078
+ React__default.createElement(Button$1, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
4079
+ sendOtp();
4080
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
4081
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
4082
+ }))) },
4083
+ React__default.createElement("div", { className: "leadgen-form_inner" },
4084
+ React__default.createElement(Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
4085
+ React__default.createElement(OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
4086
+ setIsDirty(true);
4087
+ setOtp(v.toString());
4088
+ if (isDirty && !v)
4089
+ setErrorMsg('OTP is required');
4090
+ else
4091
+ setErrorMsg(undefined);
4092
+ } }))))));
2861
4093
  };
2862
4094
 
2863
4095
  // url: imageBlocks.imageMobile.data.url
2864
4096
  // newTab: imageBlocks.imageMobile.data.newtab
2865
4097
  // image: campaignShow.image
2866
4098
  // imageDestkop: campaignShow.image_desktop
2867
- const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
2868
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
2869
- if (!imageLoaded)
2870
- return null;
2871
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
2872
- React__default.createElement("div", { className: "le-tab-popup" },
2873
- React__default.createElement("div", { style: { position: 'relative' } },
2874
- React__default.createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
2875
- React__default.createElement("img", { className: "js-popup-other-submit", src: image, style: {
2876
- aspectRatio: `${imageWidth}/${imageHeight}`,
2877
- } })),
2878
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
2879
- };
2880
-
2881
- // import mockLeadData from './mockLeadData'
2882
- const listCampaignScheduled = [];
2883
- const listCampaignScheduledToActivated = [];
2884
- const listCampaignActiveButExpired = [];
2885
- const listCampaignExcludeSonsored = [];
2886
- const listCampaignDifferentSponsor = [];
2887
- const listCampaignNotDisplayInRangeOfTime = [];
2888
- function isMobile() {
2889
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
2890
- }
2891
- const getShuffleArray = (array) => {
2892
- const newArray = [...array];
2893
- for (let i = newArray.length - 1; i > 0; i--) {
2894
- const j = Math.floor(Math.random() * (i + 1));
2895
- const temp = newArray[i];
2896
- newArray[i] = newArray[j];
2897
- newArray[j] = temp;
2898
- }
2899
- return newArray;
2900
- };
2901
- const getTimeByTimezone = (timeZone = 'UTC') => {
2902
- const date = new Date();
2903
- return new Date(date.toLocaleString('en-US', { timeZone }));
2904
- };
2905
- const parseDateByCampaignTime = (dateStr) => {
2906
- // Format like this: 2023-04-04 00:00:00
2907
- try {
2908
- const [datePart, timePart] = dateStr.split(' ');
2909
- const [year, month, day] = datePart.split('-').map(Number);
2910
- const [hours, minutes, seconds] = timePart.split(':').map(Number);
2911
- /** JavaScript counts months from 0 to 11 */
2912
- return new Date(year, month - 1, day, hours, minutes, seconds);
2913
- }
2914
- catch (err) {
2915
- return null;
2916
- }
2917
- };
2918
- const checkCampaignNowInTimeframe = (c) => {
2919
- var _a;
2920
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2921
- const startedAtStr = c.started_at;
2922
- const endedAtStr = c.ended_at;
2923
- const startedDate = parseDateByCampaignTime(startedAtStr);
2924
- const endedDate = parseDateByCampaignTime(endedAtStr);
2925
- if (!startedDate || !endedDate) {
2926
- return false;
2927
- }
2928
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
2929
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2930
- if (nowWithTimezoneMs <= endedDate.getTime() &&
2931
- nowWithTimezoneMs >= startedDate.getTime()) {
2932
- listCampaignScheduledToActivated.push(c);
2933
- return true;
2934
- }
2935
- return false;
2936
- };
2937
- function checkCampaignActiveButExpireAlready(c) {
2938
- var _a;
2939
- /** Do not setup timeframe for this campaign. No need to check */
2940
- if (c.forever === 1) {
2941
- return true;
2942
- }
2943
- const startedAtStr = c.started_at;
2944
- const endedAtStr = c.ended_at;
2945
- const startedDate = parseDateByCampaignTime(startedAtStr);
2946
- const endedDate = parseDateByCampaignTime(endedAtStr);
2947
- /** Do not setup timeframe for this campaign. No need to check */
2948
- if (!startedDate || !endedDate) {
2949
- return true;
2950
- }
2951
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2952
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
2953
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2954
- /** Check if this expire already, do not show */
2955
- if (nowWithTimezoneMs > endedDate.getTime()) {
2956
- listCampaignActiveButExpired.push(c);
2957
- return false;
2958
- }
2959
- return true;
2960
- }
2961
- function shouldNotDisplayIfExcludeAllSponsors(c) {
2962
- var _a;
2963
- const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
2964
- const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
2965
- if (isSponsored && excludeSponsored) {
2966
- listCampaignExcludeSonsored.push(c);
2967
- return true;
2968
- }
2969
- return false;
2970
- }
2971
- function shouldDisplayWithCurrentSponsor(c) {
4099
+ const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
4100
+ LEADGEN_LAYOUT.Fullscreen,
4101
+ LEADGEN_LAYOUT.Slider,
4102
+ ];
4103
+ const LEADGEN_LIMIT_LIGHTBOXB = 6;
4104
+ const LEADGEN_SHOW_HEADER = [
4105
+ 'LightBoxA',
4106
+ 'InlineA',
4107
+ LEADGEN_LAYOUT.Sidebar,
4108
+ LEADGEN_LAYOUT.Slider,
4109
+ ];
4110
+ const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2972
4111
  var _a, _b;
2973
- try {
2974
- // TODO: BE will rename `exclude_sponsored_list` later
2975
- const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
2976
- const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
2977
- const dataSponsoredId = Number((_b = document
2978
- .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
2979
- // There is no config for sponsor id and white list, should show as default
2980
- if (!dataSponsoredId ||
2981
- dataSponsoredId <= 0 ||
2982
- whiteListSponsors.length === 0) {
2983
- return true;
2984
- }
2985
- // Check the dataSponsoredId exists in the white list or not.
2986
- const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
2987
- if (isExist) {
2988
- return true;
4112
+ const { primaryColor } = useContext(LeadGenContext$1);
4113
+ const { isMobile } = useScreenSize();
4114
+ const [open, setOpen] = useState(!!campaignId);
4115
+ const [showOtpPhone, setShowOtpPhone] = useState(null);
4116
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
4117
+ const [snap, setSnap] = useState(0.8);
4118
+ const formRef = useRef();
4119
+ const onClose = () => {
4120
+ if (showOtpPhone) {
4121
+ setShowOtpPhone(null);
2989
4122
  }
2990
- listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
2991
- return false;
2992
- }
2993
- catch (err) {
2994
- // Default is show
2995
- return true;
2996
- }
2997
- }
2998
- const filterFnCampaign = (c) => {
2999
- if (shouldNotDisplayIfExcludeAllSponsors(c)) {
3000
- return false;
3001
- }
3002
- else if (!shouldDisplayWithCurrentSponsor(c)) {
3003
- return false;
3004
- }
3005
- /** Active */
3006
- if (c.formatted_status === 1) {
3007
- return checkCampaignActiveButExpireAlready(c);
3008
- }
3009
- /** Schedule */
3010
- if (c.formatted_status === 0) {
3011
- listCampaignScheduled.push(c);
3012
- return checkCampaignNowInTimeframe(c);
4123
+ else {
4124
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
4125
+ }
4126
+ };
4127
+ const textBlocks = JSON.parse(extraFields.textBlocks);
4128
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
4129
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
4130
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
4131
+ const currentPath = location.pathname;
4132
+ const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
4133
+ const { align: titleAlign } = textBlocks.titleBlock.data || {};
4134
+ const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
4135
+ const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
4136
+ const isLightBox = currentLayout.includes('LightBox');
4137
+ const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
4138
+ const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
4139
+ const isInline = currentLayout.includes('Inline');
4140
+ const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
4141
+ const isInPage = isInline || isSidebar;
4142
+ const isDrawer = isLightBoxB && isMobile;
4143
+ const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
4144
+ const hasForm = isLightBoxA
4145
+ ? listBlockAdded.some((item) => LEADGEN_BLOCK_INPUT.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
4146
+ : true;
4147
+ const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
4148
+ const showHeader = !!imageMobile || !!imageDesktop;
4149
+ const onlyHeader = !title && !description;
4150
+ const showButtonClose = !isInline;
4151
+ if (window.innerWidth < 769 &&
4152
+ LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
4153
+ console.log('😎 Not show fullscreen, slider on mobile ');
4154
+ return null;
3013
4155
  }
3014
- return false;
3015
- };
3016
- const fillterApprearanceTimeCampaign = (c) => {
3017
- var _a;
3018
- try {
3019
- const isTimeInRange = (currentTime, startTime, endTime) => {
3020
- const startParts = startTime.split(':');
3021
- const endParts = endTime.split(':');
3022
- const startDate = new Date();
3023
- startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
3024
- const endDate = new Date();
3025
- endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
3026
- return currentTime >= startDate && currentTime <= endDate;
3027
- };
3028
- const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
3029
- const startTime = rulesApprValue.startTime;
3030
- const endTime = rulesApprValue.endTime || '23:59';
3031
- if (!startTime) {
3032
- return true;
4156
+ useEffect(() => {
4157
+ if (isLightBox || isFullscreen) {
4158
+ document.body.classList.add('noscroll');
3033
4159
  }
3034
- if (isTimeInRange(new Date(), startTime, endTime)) {
3035
- return true;
4160
+ if (!window.intlTelInputUtils) {
4161
+ require('intl-tel-input/build/js/utils');
3036
4162
  }
3037
- listCampaignNotDisplayInRangeOfTime.push(c);
3038
- return false;
3039
- }
3040
- catch (err) {
3041
- return true;
3042
- }
3043
- };
3044
- let timeoutRef = null;
3045
- let LEAD_SCROLL_EVENT = null;
3046
- function clearPassiveEvent() {
3047
- if (timeoutRef) {
3048
- clearTimeout(timeoutRef);
3049
- timeoutRef = null;
3050
- }
3051
- if (LEAD_SCROLL_EVENT) {
3052
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3053
- LEAD_SCROLL_EVENT = null;
3054
- }
3055
- }
3056
- function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
3057
- // clear previous passive event, check for new condition
3058
- clearPassiveEvent();
3059
- const leadCurrentUrl = DEBUG_URL ||
3060
- ('https://' +
3061
- location.hostname +
3062
- location.pathname +
3063
- location.search).toLowerCase();
3064
- fetch(leadApi + 'api/campaign/' + leadSiteId, {
3065
- method: 'POST',
3066
- headers: {
3067
- 'Content-Type': 'application/json',
3068
- },
3069
- body: JSON.stringify({
3070
- url: leadCurrentUrl,
3071
- ga_client_id: getCookie('_ga') || null,
3072
- }),
3073
- })
3074
- .then((response) => {
3075
- return response.json();
3076
- // return mockLeadData || response.json()
3077
- })
3078
- .then((data) => {
3079
- var _a, _b, _c, _d;
3080
- LeadLog('List campagin: ', data);
3081
- LEAD_RESET_VAR();
3082
- if (data._status == 1) {
3083
- const campaigns = (((_b = (_a = data._data) === null || _a === void 0 ? void 0 : _a.campaigns) === null || _b === void 0 ? void 0 : _b.filter(filterFnCampaign)) || []).filter(fillterApprearanceTimeCampaign);
3084
- if (!getCookie('hhg-id')) {
3085
- setCookie('hhg-id', v1(), {
3086
- domain: '.' + leadDomain,
3087
- path: '/',
3088
- });
3089
- LeadLog('😍 Set HHG ID cookie');
3090
- }
3091
- // getCookie('hhg-id')
3092
- // TODO: HP-534 Filter desktop
3093
- let campaignsDevice = [];
3094
- if (isMobile()) {
3095
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
3096
- }
3097
- else {
3098
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
3099
- }
3100
- LeadLog(`👓 campaignsDevice`, campaignsDevice);
3101
- LeadLog('--listCampaignScheduled', listCampaignScheduled);
3102
- LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
3103
- LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
3104
- LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
3105
- LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
3106
- LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
3107
- // Check links
3108
- let listLinksObj = campaignsDevice
3109
- .map((i, index) => i.targets
3110
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
3111
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3112
- .flat(1);
3113
- // Check list link match current href
3114
- listLinksObj = listLinksObj.filter((i) => {
3115
- var _a;
3116
- const target = new URL(String(i.target).toLowerCase());
3117
- if (i.option == 'exact_match')
3118
- // FOR TEST LOCAL:
3119
- // return Boolean(location.pathname === target.pathname)
3120
- return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
3121
- if (i.option == 'start_with') {
3122
- // FOR TEST LOCAL:
3123
- // if (location.pathname.includes(target.pathname)) {
3124
- if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
3125
- const listExcluding = i.sub_target
3126
- .filter((i) => i.option == 'excluding')
3127
- .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
3128
- return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
3129
- }
3130
- else {
3131
- return false;
3132
- }
3133
- }
3134
- });
3135
- // Check tags
3136
- const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
3137
- const listTags = listMetaTag.map((i) => i.content);
3138
- let listCampaignHasTag = [];
3139
- let listTagsObj = [];
3140
- if (listTags && listTags.length) {
3141
- listCampaignHasTag = campaignsDevice
3142
- .map((i, index) => i.targets
3143
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
3144
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3145
- .flat(1);
3146
- listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
3147
- }
3148
- const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
3149
- const cookieKeys = document.cookie
3150
- .split('; ')
3151
- .map((i) => i.split('=')[0]);
3152
- const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
3153
- LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
3154
- const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
3155
- LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
3156
- const listCampaignSubmitedClosed = [
3157
- ...listCampaignCodeSubmited,
3158
- ...listCampaignCodeClosed,
3159
- ];
3160
- const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
3161
- const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
3162
- return !hasSubmited;
3163
- });
3164
- const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
3165
- // .sort(
3166
- // (a, b) =>
3167
- // (listCampaignValid[a.campaignIndex]?.score || 0) -
3168
- // (listCampaignValid[b.campaignIndex]?.score || 0),
3169
- // )
3170
- LeadLog('--listCampaignValid : ', listCampaignValid);
3171
- if (listCampaignValid && listCampaignValid.length) {
3172
- const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
3173
- LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
3174
- const { rules } = CAMPAIGN_SHOW;
3175
- // CHECK RULE TRIGGER POPUP
3176
- const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
3177
- LeadLog(`timeoutRule`, timeoutRule);
3178
- const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
3179
- LeadLog(`scrollRule`, scrollRule);
3180
- let impressionAction = 'TIME';
3181
- if (Number.isInteger(timeoutRule)) {
3182
- impressionAction = 'TIME';
3183
- LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
3184
- timeoutRef = setTimeout(() => {
3185
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3186
- }, timeoutRule * 1000);
4163
+ clearCacheUsedEmailOrPhone();
4164
+ }, []);
4165
+ const validatingPhoneRef = useRef(false);
4166
+ const validatingEmailRef = useRef(false);
4167
+ const { form, validateObj } = useLeadFormConfig({
4168
+ listBlockAdded,
4169
+ validatingPhoneRef,
4170
+ validatingEmailRef,
4171
+ campaignId,
4172
+ campaign_subot_id,
4173
+ userInfo,
4174
+ format: (_a = (ISO_FORMAT[locale] || ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
4175
+ });
4176
+ const onFocus = (e) => {
4177
+ const target = e.target;
4178
+ target.scrollIntoView({
4179
+ block: 'center',
4180
+ inline: 'nearest',
4181
+ behavior: 'auto',
4182
+ });
4183
+ };
4184
+ const middlewareOnSubmit = (e) => {
4185
+ e.preventDefault();
4186
+ // mark all as touched to allow validation
4187
+ const fields = Object.keys(validateObj);
4188
+ const fieldStatus = fields.reduce((acc, cur) => {
4189
+ acc[cur] = true;
4190
+ return acc;
4191
+ }, {});
4192
+ form.setTouched(fieldStatus);
4193
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
4194
+ return;
4195
+ }
4196
+ setTimeout(() => {
4197
+ form.onSubmit((v) => {
4198
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4199
+ if (Object.keys(form.errors).length)
4200
+ return;
4201
+ let newShowOtpPhone = null;
4202
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
4203
+ // not submit yet, open otp
4204
+ const fieldName = (_b = (_a = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock)) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value;
4205
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
4206
+ newShowOtpPhone = {
4207
+ phone: v[fieldName],
4208
+ type: 'phone',
4209
+ };
4210
+ }
3187
4211
  }
3188
- if (Number.isInteger(scrollRule)) {
3189
- impressionAction = 'SCROLL';
3190
- LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
3191
- const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
3192
- document.querySelector('body');
3193
- const pct = $p.getBoundingClientRect().top;
3194
- const pb = $p.offsetHeight;
3195
- LeadLog(`👓 Element check scroll: `, $p);
3196
- LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
3197
- const wt = window.pageYOffset || document.documentElement.scrollTop;
3198
- let percent = 0;
3199
- if (wt >= pct) {
3200
- percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
3201
- }
3202
- LeadLog('---Scroll', percent, scrollRule);
3203
- // TODO: CHECK FOOTER HEIGHT
3204
- if (percent >= scrollRule) {
3205
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3206
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
4212
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
4213
+ // not submit yet, open otp
4214
+ const fieldName = (_e = (_d = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock)) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.value;
4215
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
4216
+ newShowOtpPhone = {
4217
+ phone: v[fieldName],
4218
+ type: 'whatsapp',
4219
+ };
4220
+ }
4221
+ }
4222
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
4223
+ // not submit yet, open otp
4224
+ const fieldName = (_h = (_g = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock)) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.value;
4225
+ if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
4226
+ newShowOtpPhone = {
4227
+ phone: v[fieldName],
4228
+ type: 'zalo',
4229
+ };
4230
+ }
4231
+ }
4232
+ if (newShowOtpPhone) {
4233
+ setIsSubmitLoading(true);
4234
+ Service.sendSMSOtpLead(newShowOtpPhone)
4235
+ .then((res) => {
4236
+ var _a;
4237
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4238
+ if (respMessage === 'This phone number was verified') {
4239
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4240
+ return;
3207
4241
  }
3208
- };
3209
- window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
3210
- passive: true,
4242
+ setShowOtpPhone(newShowOtpPhone);
4243
+ })
4244
+ .finally(() => {
4245
+ setIsSubmitLoading(false);
3211
4246
  });
4247
+ return;
3212
4248
  }
3213
- }
3214
- else {
3215
- LeadLog('🚧 No lead campaigns on current URL, tags');
3216
- }
4249
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4250
+ })(e);
4251
+ }, 100);
4252
+ };
4253
+ const onOpenChange = (_open) => {
4254
+ setOpen(_open);
4255
+ if (!_open) {
4256
+ setTimeout(() => {
4257
+ onClose();
4258
+ }, 250);
3217
4259
  }
3218
- })
3219
- .catch((err) => {
3220
- LeadLog(`Lead error: `, err);
4260
+ };
4261
+ const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
4262
+ const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
4263
+ const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
4264
+ const renderAfterImageSizes = imageMobileLoaded &&
4265
+ imageDesktopLoaded &&
4266
+ (isFullscreen ? imageBackgroundLoaded : true);
4267
+ const ButtonSubmit = useMemo(() => {
4268
+ var _a;
4269
+ return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default.createElement(Button$1, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
4270
+ }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
4271
+ const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
4272
+ const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default.createElement(React__default.Fragment, null, LinkButtonBlock.map((item, index) => {
4273
+ var _a, _b, _c;
4274
+ return (React__default.createElement(Button$1, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
4275
+ onClose === null || onClose === void 0 ? void 0 : onClose();
4276
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
4277
+ } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
4278
+ })));
4279
+ const PopupHeader = showHeader && (React__default.createElement("header", { className: clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default.createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default.createElement(React__default.Fragment, null,
4280
+ React__default.createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
4281
+ React__default.createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
4282
+ const PopupEmpty = showEmpty && (React__default.createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
4283
+ const PopupForm = (React__default.createElement(LeadFormProvider, { form: form },
4284
+ React__default.createElement("form", { ref: formRef, className: "leadgen-form", onFocus: onFocus, onSubmit: middlewareOnSubmit },
4285
+ React__default.createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
4286
+ React__default.createElement("div", { className: "leadgen-form_inner" },
4287
+ React__default.createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
4288
+ const PopupOtp = showOtpPhone && (React__default.createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
4289
+ setShowOtpPhone(null);
4290
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
4291
+ } }));
4292
+ const PopupThankYou = showThankyou && (React__default.createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
4293
+ const PopupContent = (React__default.createElement("div", { className: clsx('leadgen-content', {
4294
+ 'leadgen-content_small': limitFieldsLightBoxB,
4295
+ }) },
4296
+ !headerInsideFormContainer && PopupHeader,
4297
+ !onlyHeader && (React__default.createElement("div", { className: "leadgen-inner" },
4298
+ PopupThankYou,
4299
+ !showThankyou && (React__default.createElement(React__default.Fragment, null,
4300
+ PopupOtp,
4301
+ PopupEmpty,
4302
+ !(showOtpPhone || showEmpty) && PopupForm))))));
4303
+ const styleOverlay = useMemo(() => {
4304
+ let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
4305
+ if (isMobile && imageOverlayMobile) {
4306
+ styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4307
+ }
4308
+ if (!isMobile && imageOverlayDesktop) {
4309
+ styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4310
+ }
4311
+ return styleContent;
4312
+ }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
4313
+ const PopupWrapper = (React__default.createElement(React__default.Fragment, null,
4314
+ React__default.createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
4315
+ React__default.createElement("div", { className: clsx('leadgen-wrapper', {
4316
+ 'leadgen-wrapper_small': limitFieldsLightBoxB,
4317
+ }) },
4318
+ showButtonClose && (React__default.createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
4319
+ PopupContent)));
4320
+ const popupContainerClassName = clsx('leadgen', `leadgen-${currentLayout}`, {
4321
+ 'leadgen-lightbox': isLightBox,
4322
+ 'leadgen-inline': isInPage,
4323
+ 'leadgen-slider': isSlider,
3221
4324
  });
3222
- }
3223
- const LeadLog = (...params) => {
3224
- if (process.env.NODE_ENV !== 'production' ||
3225
- (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
3226
- process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
3227
- (typeof localStorage !== 'undefined' &&
3228
- localStorage.getItem('hhg_debug') === 'true')) {
3229
- console.log(...params);
4325
+ const PopupContainer = isDrawer ? (React__default.createElement(DrawerComponent, { fadeFromIndex: ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
4326
+ PopupWrapper,
4327
+ React__default.createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default.createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
4328
+ isFullscreen ? (React__default.createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
4329
+ aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
4330
+ } })) : null,
4331
+ PopupWrapper));
4332
+ if (!renderAfterImageSizes)
4333
+ return null;
4334
+ if (isLightBox || isFullscreen || isSlider) {
4335
+ return PopupContainer;
4336
+ }
4337
+ else if (isSidebar) {
4338
+ return React__default.createElement(SideBarLayout, { content: PopupContainer });
4339
+ }
4340
+ else if (isInline) {
4341
+ return (React__default.createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
3230
4342
  }
4343
+ return null;
4344
+ };
4345
+
4346
+ const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
4347
+ const currentPath = location.pathname;
4348
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
4349
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
4350
+ if (!imageMobileLoaded || !imageDesktopLoaded)
4351
+ return null;
4352
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
4353
+ currentLayout == 'SkinA' ? (React__default.createElement("aside", { className: "le-only-desktop" },
4354
+ React__default.createElement("div", { className: "le-skin-a-desktop" },
4355
+ React__default.createElement("div", { style: { position: 'relative' } },
4356
+ React__default.createElement("img", { src: imageDesktop, style: {
4357
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4358
+ } }),
4359
+ React__default.createElement("a", { style: {
4360
+ position: 'absolute',
4361
+ top: '75%',
4362
+ left: '50%',
4363
+ transform: 'translate(-50%, -50%)',
4364
+ textAlign: 'center',
4365
+ width: 'calc(100% - 15px)',
4366
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4367
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
4368
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default.createElement("aside", { className: "le-only-desktop" },
4369
+ React__default.createElement("div", { className: "" },
4370
+ React__default.createElement("div", { style: { position: 'relative', zIndex: 10000 } },
4371
+ React__default.createElement("img", { src: imageDesktop, style: {
4372
+ width: '100%',
4373
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4374
+ } }),
4375
+ React__default.createElement("a", { style: {
4376
+ position: 'absolute',
4377
+ top: '75%',
4378
+ left: '50%',
4379
+ transform: 'translate(-50%, -50%)',
4380
+ textAlign: 'center',
4381
+ width: '100%',
4382
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4383
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4384
+ React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
4385
+ React__default.createElement("aside", { className: "le-only-mobile" },
4386
+ React__default.createElement("div", { className: "le-skin-mobile" },
4387
+ React__default.createElement("div", { style: { position: 'relative' } },
4388
+ isVideo(imageMobile) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true },
4389
+ React__default.createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default.createElement("img", { src: imageMobile, style: {
4390
+ width: '100%',
4391
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
4392
+ } })),
4393
+ React__default.createElement("a", { style: {
4394
+ position: 'absolute',
4395
+ top: '82%',
4396
+ left: '50%',
4397
+ transform: 'translate(-50%, -50%)',
4398
+ textAlign: 'center',
4399
+ maxWidth: 'calc(100% - 15px)',
4400
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4401
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4402
+ React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4403
+ };
4404
+
4405
+ // url: imageBlocks.imageMobile.data.url
4406
+ // newTab: imageBlocks.imageMobile.data.newtab
4407
+ // image: campaignShow.image
4408
+ // imageDestkop: campaignShow.image_desktop
4409
+ const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
4410
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
4411
+ if (!imageLoaded)
4412
+ return null;
4413
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
4414
+ React__default.createElement("div", { className: "le-tab-popup" },
4415
+ React__default.createElement("div", { style: { position: 'relative' } },
4416
+ React__default.createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
4417
+ React__default.createElement("img", { className: "js-popup-other-submit", src: image, style: {
4418
+ aspectRatio: `${imageWidth}/${imageHeight}`,
4419
+ } })),
4420
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3231
4421
  };
3232
4422
 
3233
4423
  function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
@@ -3243,7 +4433,7 @@ function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
3243
4433
  }
3244
4434
  const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, showEmpty, setShowEmpty, userInfo, }) => {
3245
4435
  var _a, _b;
3246
- const { apiUrl, siteDomain } = useContext(LeadGenContext);
4436
+ const { apiUrl, siteDomain } = useContext(LeadGenContext$1);
3247
4437
  useEffect(() => {
3248
4438
  const gaCookie = getCookie('_ga') || null;
3249
4439
  fetch(`${apiUrl}api/campaign/${code}/impression`, {
@@ -3638,7 +4828,7 @@ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, primaryColor
3638
4828
  leadStartTimeRef.current = Date.now();
3639
4829
  }
3640
4830
  }, [showCampaign]);
3641
- return (React__default.createElement(LeadGenContext.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
4831
+ return (React__default.createElement(LeadGenContext$1.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
3642
4832
  React__default.createElement(TranslationsContext.Provider, { value: { locale, values: getTranslations(locale) } }, children ? (React__default.createElement(Component, { campaign: showCampaign, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, setShowThankyou: setShowThankyou, locale: locale, showEmpty: showEmpty, setShowEmpty: setShowEmpty, userInfo: userInfo }, children)) : (React__default.createElement(Portal, { target: getPopupWrapperDom() },
3643
4833
  React__default.createElement(Box, { sx: { position: 'fixed', zIndex: ZINDEX_SSO - 9e6 } },
3644
4834
  React__default.createElement(Transition, { mounted: Boolean(((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1'), transition: "fade", duration: 600, timingFunction: "ease" }, (styles) => {
@@ -3658,4 +4848,4 @@ LeadGen.Thankyou = Thankyou;
3658
4848
  LeadGen.OtpForm = OtpBlock$1;
3659
4849
  LeadGen.Close = Close;
3660
4850
 
3661
- export { LeadGen };
4851
+ export { LeadGen, LeadGenSubscriptionBox };