@hhgtech/hhg-components 1.29.371 → 1.29.372-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 (545) hide show
  1. package/build/{InputDate-d082d581.js → InputDate-53510fc6.js} +20 -20
  2. package/build/{LastPeriod-57a5501f.js → LastPeriod-97a41212.js} +1 -1
  3. package/build/{Locale-23dce5ce.js → Locale-a6cfbd0c.js} +1 -0
  4. package/build/{MobileBottomNavigationIcon-4a70f0bf.js → MobileBottomNavigationIcon-adde2568.js} +3 -3
  5. package/build/{Spinner-3159458e.js → Spinner-8aadaea4.js} +1 -1
  6. package/build/{WhatsApp-afda452a.js → WhatsApp-d1ecfc43.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 +96 -96
  19. package/build/{constants-c15f043a.js → constants-1d734061.js} +1 -0
  20. package/build/{constants-23b6f32c.js → constants-e794cab6.js} +1 -1
  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-0ceeed31.js → core-752b36de.js} +1 -1
  26. package/build/{dataTransform-e0804e7a.js → dataTransform-0a5fe360.js} +1 -1
  27. package/build/ecom.js +4 -4
  28. package/build/{editor-dfd13076.js → editor-63f2487a.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-91b79c1d.js → InputDate-fc760765.js} +20 -20
  39. package/build/esm/{LastPeriod-d39a6755.js → LastPeriod-0553ce0c.js} +1 -1
  40. package/build/esm/{Locale-0b94309d.js → Locale-dd2625fa.js} +1 -0
  41. package/build/esm/{MobileBottomNavigationIcon-41271e3c.js → MobileBottomNavigationIcon-25af9080.js} +3 -3
  42. package/build/esm/{Spinner-aa367c88.js → Spinner-ea23fbfb.js} +1 -1
  43. package/build/esm/{WhatsApp-afe4ac5e.js → WhatsApp-72789740.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 +96 -96
  56. package/build/esm/{constants-adcc8f87.js → constants-0f0116ef.js} +1 -1
  57. package/build/esm/{constants-aa166750.js → constants-3523c601.js} +1 -0
  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-5a36d345.js → core-c99557e1.js} +1 -1
  63. package/build/esm/{dataTransform-93c0ffb4.js → dataTransform-6e4cf75a.js} +1 -1
  64. package/build/esm/ecom.js +4 -4
  65. package/build/esm/{editor-0b4061c9.js → editor-9a8b3577.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-cce1cc56.js → healthTools-e923053c.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-0d570d50.js → index-0423b372.js} +2 -2
  85. package/build/esm/{index-daffc3e1.js → index-08b9a262.js} +16 -16
  86. package/build/esm/{index-7e4a125e.js → index-1096cc1a.js} +3 -3
  87. package/build/esm/{index-eb809df0.js → index-12b37e1d.js} +6 -6
  88. package/build/esm/{index-ef256d0b.js → index-17f4cc07.js} +6 -6
  89. package/build/esm/{index-57b24e4c.js → index-1881a822.js} +2 -2
  90. package/build/esm/{index-a83efb8f.js → index-19b02397.js} +7 -7
  91. package/build/esm/{index-89382f70.js → index-1b73eed5.js} +4 -4
  92. package/build/esm/{index-d14bd2aa.js → index-1f0f5aca.js} +10 -10
  93. package/build/esm/{index-2f2049d3.js → index-23d3743e.js} +2 -2
  94. package/build/esm/{index-49ba12fb.js → index-290638a8.js} +2 -2
  95. package/build/esm/{index-a8f82d2f.js → index-2d19a560.js} +31 -31
  96. package/build/esm/{index-2283b075.js → index-3222872e.js} +25 -25
  97. package/build/esm/{index-5c9fe6d1.js → index-346818d6.js} +6 -6
  98. package/build/esm/{index-242ee51f.js → index-370af621.js} +39 -2
  99. package/build/esm/{index-7cb0db14.js → index-37a63220.js} +7 -7
  100. package/build/esm/{index-08072bb2.js → index-3b1703aa.js} +13 -13
  101. package/build/esm/{index-5118e9a3.js → index-3bc6ddd1.js} +17 -17
  102. package/build/esm/{index-f2824c36.js → index-3e1814c1.js} +1 -1
  103. package/build/esm/{index-c7fe994a.js → index-45505f2c.js} +2 -2
  104. package/build/esm/{index-51196b7b.js → index-4cc9b880.js} +1 -1
  105. package/build/esm/{index-e59f7ee5.js → index-4ed57f85.js} +2 -2
  106. package/build/esm/{index-72076a3a.js → index-4f0f3097.js} +24 -24
  107. package/build/esm/{index-4cbc8b62.js → index-4ff7c62a.js} +2 -2
  108. package/build/esm/{index-d1147e52.js → index-5466e357.js} +1 -1
  109. package/build/esm/{index-02fc7de4.js → index-5b0939a8.js} +3 -3
  110. package/build/esm/{index-b654ee01.js → index-5b650465.js} +1 -1
  111. package/build/esm/{index-5675a301.js → index-65f141c1.js} +1 -1
  112. package/build/esm/{index-6a56ab8f.js → index-6888dffa.js} +17 -17
  113. package/build/esm/{index-8924c0c8.js → index-6a2e5610.js} +21 -21
  114. package/build/esm/{index-905f3039.js → index-6f990758.js} +6 -6
  115. package/build/esm/{index-cad3e50b.js → index-70296026.js} +17 -17
  116. package/build/esm/{index-fcf73947.js → index-79890213.js} +2 -2
  117. package/build/esm/{index-dc1fd2da.js → index-81ccb624.js} +2 -2
  118. package/build/esm/{index-b0828362.js → index-871051cf.js} +3 -3
  119. package/build/esm/{index-31109b68.js → index-8c90983b.js} +1 -1
  120. package/build/esm/{index-bc9f92b9.js → index-8d9fbcc3.js} +13 -13
  121. package/build/esm/{index-4c11dc3b.js → index-8f8bc043.js} +15 -15
  122. package/build/esm/{index-b6d4fac0.js → index-9530557d.js} +17 -17
  123. package/build/esm/{index-c69ed75b.js → index-96704673.js} +1 -1
  124. package/build/esm/{index-935fa43c.js → index-96e04fc8.js} +16 -16
  125. package/build/esm/{index-0ad3aa09.js → index-97ca081d.js} +2 -2
  126. package/build/esm/{index-5522f04c.js → index-9b8d4fd0.js} +1 -1
  127. package/build/esm/{index-092185c0.js → index-a369d413.js} +5 -5
  128. package/build/esm/{index-e0dfc124.js → index-a4e6b5ce.js} +2 -2
  129. package/build/esm/{index-53088c85.js → index-a7927623.js} +2 -2
  130. package/build/esm/{index-9bbc4b8f.js → index-a9feb783.js} +32 -32
  131. package/build/esm/{index-842c70fe.js → index-af35b428.js} +3 -3
  132. package/build/esm/{index-1f7b8bed.js → index-b35d49d4.js} +32 -32
  133. package/build/esm/{index-db0377fc.js → index-c07f5c07.js} +1 -1
  134. package/build/esm/{index-9751851e.js → index-c3841e4d.js} +36 -27
  135. package/build/esm/{index-bbe51e72.js → index-c3ce6157.js} +6 -6
  136. package/build/esm/{index-eae0b6d5.js → index-cf6b6574.js} +18 -18
  137. package/build/esm/{index-07f50e9a.js → index-d3eb4e0d.js} +2 -2
  138. package/build/esm/{index-4c4a9b6a.js → index-d4520e91.js} +8 -8
  139. package/build/esm/{index-ab3a201d.js → index-dd664bf5.js} +3 -3
  140. package/build/esm/{index-b49e4a34.js → index-e1426133.js} +22 -22
  141. package/build/esm/{index-cdbe674f.js → index-e388493a.js} +18 -18
  142. package/build/esm/{index-092d7934.js → index-e40243b0.js} +3 -3
  143. package/build/esm/{index-a61044a4.js → index-f34dad0c.js} +16 -16
  144. package/build/esm/{index-dbdc7a32.js → index-f47da5bb.js} +13 -13
  145. package/build/esm/{index-ca729fd9.js → index-f4b25e8f.js} +13 -13
  146. package/build/esm/{index-d0d87a2a.js → index-f824c0e2.js} +16 -16
  147. package/build/esm/{index-6043b354.js → index-fd855849.js} +5 -5
  148. package/build/esm/index.js +117 -117
  149. package/build/esm/interfaces/constants/domainLocales.d.ts +2 -0
  150. package/build/esm/interfaces/constants/index.d.ts +1 -1
  151. package/build/esm/interfaces/types/Locale.d.ts +2 -1
  152. package/build/esm/interfaces/types/index.d.ts +2 -1
  153. package/build/esm/{labelSorting-d04bca5f.js → labelSorting-af5bf1b1.js} +4 -4
  154. package/build/esm/lead/LeadGen.type.d.ts +31 -0
  155. package/build/esm/lead/LeadGenForm/LeadGenForm.d.ts +41 -0
  156. package/build/esm/lead/LeadGenForm/LeadGenForm.helpers.d.ts +2 -0
  157. package/build/esm/lead/LeadGenForm/LeadGenForm.styled.d.ts +5 -0
  158. package/build/esm/lead/LeadGenForm/LeadGenFormPhone.d.ts +17 -0
  159. package/build/esm/lead/LeadGenForm/LeadGenThankYou.d.ts +20 -0
  160. package/build/esm/lead/LeadGenForm/index.d.ts +3 -0
  161. package/build/esm/lead/LeadGenForm/textField/index.d.ts +13 -0
  162. package/build/esm/lead/LeadGenForm/textField/index.styled.d.ts +11 -0
  163. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +63 -0
  164. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +4 -0
  165. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +21 -0
  166. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +3 -0
  167. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +23 -0
  168. package/build/esm/lead/LeadGenSubscriptionBox/index.d.ts +1 -0
  169. package/build/esm/lead/LeadGenTranslationContext.d.ts +6 -0
  170. package/build/esm/lead/helpers.d.ts +56 -1
  171. package/build/esm/lead/index.d.ts +3 -1
  172. package/build/esm/lead/layouts/lightbox/formContext.d.ts +2 -1
  173. package/build/esm/lead/leadGenContext.d.ts +1 -0
  174. package/build/esm/lead/services/index.d.ts +19 -0
  175. package/build/esm/lead/store/index.d.ts +1 -0
  176. package/build/esm/lead.css +1 -1
  177. package/build/esm/lead.js +2316 -1107
  178. package/build/esm/{logoIcon-37355930.js → logoIcon-48572541.js} +8 -2
  179. package/build/esm/mantine.js +25 -25
  180. package/build/esm/misc.js +17 -17
  181. package/build/esm/miscGetDynamicHealthTool.js +4 -4
  182. package/build/esm/miscGetSocialList.js +8 -8
  183. package/build/esm/miscScreenSizeContext.js +1 -1
  184. package/build/esm/mobileBottomNavigation.js +5 -5
  185. package/build/esm/mobileBottomNavigationIcon.js +5 -5
  186. package/build/esm/molecules.js +73 -73
  187. package/build/esm/moleculesArticleCard.js +6 -6
  188. package/build/esm/moleculesArticleCardV2.js +16 -16
  189. package/build/esm/navigation.js +45 -45
  190. package/build/esm/navigationLogoutPopup.js +9 -9
  191. package/build/esm/navigationProfileButton.js +23 -23
  192. package/build/esm/onboardingV2.js +29 -29
  193. package/build/esm/organisms.js +49 -49
  194. package/build/esm/{post-7230ca24.js → post-5ecb65c5.js} +2 -2
  195. package/build/esm/profileNavigation.js +19 -19
  196. package/build/esm/progressBar.js +1 -1
  197. package/build/esm/pwg.js +22 -22
  198. package/build/esm/ssoV2/api/featureFlag.d.ts +2 -1
  199. package/build/esm/ssoV2.js +51 -39
  200. package/build/esm/{store-acf517f5.js → store-18fd61ec.js} +4 -4
  201. package/build/esm/subot.js +35 -35
  202. package/build/esm/surveyOrPremiumBanner.js +32 -32
  203. package/build/esm/surveyQuestionCard.js +10 -10
  204. package/build/esm/{surveyThankyouCard-4631cc89.js → surveyThankyouCard-6c4ba9c3.js} +5 -5
  205. package/build/esm/together.js +55 -55
  206. package/build/esm/togetherApiUtils.js +4 -4
  207. package/build/esm/togetherAtoms.js +30 -30
  208. package/build/esm/togetherComponentGlobalContext.js +4 -4
  209. package/build/esm/togetherMolecules.js +50 -50
  210. package/build/esm/togetherMoleculesCardAuthor.js +28 -28
  211. package/build/esm/togetherMoleculesPostImagePreview.js +11 -11
  212. package/build/esm/togetherMoleculesProfileDetail.js +38 -38
  213. package/build/esm/togetherOrganisms.js +49 -49
  214. package/build/esm/togetherRichTextEditor.js +17 -17
  215. package/build/esm/togetherShareBox.js +10 -10
  216. package/build/esm/translationsProvider-058aa9f4.js +55 -0
  217. package/build/esm/{treePopoverMenu-8ef83a92.js → treePopoverMenu-d2e708d8.js} +19 -19
  218. package/build/esm/{types-8eee84c8.js → types-2c7ea5b1.js} +2 -2
  219. package/build/esm/types.js +2 -2
  220. package/build/esm/{useCategory-fa909065.js → useCategory-98903303.js} +18 -5
  221. package/build/esm/{useHealthToolCache-70c07eac.js → useHealthToolCache-c0de2d5a.js} +1 -1
  222. package/build/esm/{useMantineLocale-b15f2673.js → useMantineLocale-3dcc1724.js} +8 -6
  223. package/build/esm/{usePlacesAutocomplete-5b37d78d.js → usePlacesAutocomplete-bfb0db64.js} +1 -1
  224. package/build/esm/{useScreenSize-c7e3fe82.js → useScreenSize-cc7d6c7a.js} +2 -2
  225. package/build/esm/useTogetherAuthRequiredAction.js +9 -9
  226. package/build/esm/{utils-c919d048.js → utils-064598a5.js} +3 -3
  227. package/build/esm/{utils-ccc04387.js → utils-6e5d68e8.js} +2 -2
  228. package/build/esm/{utils-796f1078.js → utils-cedbce5b.js} +4 -4
  229. package/build/esm/{utils-31c67481.js → utils-fd471902.js} +2 -2
  230. package/build/esm/vaccination.js +21 -21
  231. package/build/footer.js +21 -21
  232. package/build/gAssets.js +2 -2
  233. package/build/{healthTools-4173cd68.js → healthTools-0dc6a117.js} +1 -1
  234. package/build/healthToolsCardWrapper.js +18 -18
  235. package/build/healthToolsForm.js +33 -33
  236. package/build/hooks.js +13 -13
  237. package/build/i18n-values/zh-CN.js +866 -0
  238. package/build/i18n.js +16 -56
  239. package/build/i18nV2.js +1 -1
  240. package/build/{index-c176a8cd.js → index-01925084.js} +13 -13
  241. package/build/{index-0e34dab6.js → index-03dd0804.js} +31 -31
  242. package/build/{index-83f65645.js → index-04498acf.js} +16 -16
  243. package/build/{index-f269b8fb.js → index-09051bb1.js} +13 -13
  244. package/build/{index-37ed84ef.js → index-0f337c0c.js} +2 -2
  245. package/build/{index-df16a68b.js → index-103b6d52.js} +15 -15
  246. package/build/{index-ccb56315.js → index-1badbcf0.js} +13 -13
  247. package/build/{index-38d5d806.js → index-1c224e52.js} +6 -6
  248. package/build/{index-f534c2f7.js → index-1e7383be.js} +1 -1
  249. package/build/{index-98b0141c.js → index-1ec23a8c.js} +1 -1
  250. package/build/{index-c951bf18.js → index-22677d6f.js} +18 -18
  251. package/build/{index-cd6eedda.js → index-25405264.js} +3 -3
  252. package/build/{index-c86a7a5e.js → index-2bea9f69.js} +1 -1
  253. package/build/{index-6c13b501.js → index-3424b721.js} +1 -1
  254. package/build/{index-f89757f3.js → index-379d705c.js} +1 -1
  255. package/build/{index-3c81da24.js → index-3a2dcdb1.js} +2 -2
  256. package/build/{index-02e0c5a4.js → index-477103d5.js} +17 -17
  257. package/build/{index-0d16ecc3.js → index-4aef88ff.js} +1 -1
  258. package/build/{index-d84eb30d.js → index-4f9a53eb.js} +25 -25
  259. package/build/{index-e6faa137.js → index-50f21f67.js} +22 -22
  260. package/build/{index-ffd34c3a.js → index-51226aea.js} +16 -16
  261. package/build/{index-095459b8.js → index-5367382b.js} +24 -24
  262. package/build/{index-97db9624.js → index-549d3920.js} +3 -3
  263. package/build/{index-f05388c1.js → index-588763ca.js} +2 -2
  264. package/build/{index-b4d37a50.js → index-5d752841.js} +17 -17
  265. package/build/{index-82ef16d1.js → index-5dcab081.js} +6 -6
  266. package/build/{index-d533ad04.js → index-5eab3cf1.js} +8 -8
  267. package/build/{index-5a76cf22.js → index-5ef55da1.js} +2 -2
  268. package/build/{index-d09aa821.js → index-695380e6.js} +3 -3
  269. package/build/{index-245e0df3.js → index-6ae674be.js} +13 -13
  270. package/build/{index-6b2a2322.js → index-7021af67.js} +6 -6
  271. package/build/{index-673a8776.js → index-704521de.js} +2 -2
  272. package/build/{index-48e12872.js → index-7280eafc.js} +7 -7
  273. package/build/{index-ecaef1d8.js → index-8ad0770c.js} +39 -2
  274. package/build/{index-99dcafef.js → index-8b3c6bb6.js} +17 -17
  275. package/build/{index-4cf35856.js → index-8f7e7733.js} +2 -2
  276. package/build/{index-3550236c.js → index-920ce764.js} +6 -6
  277. package/build/{index-8e2af2c7.js → index-956f121c.js} +3 -3
  278. package/build/{index-19557511.js → index-9a3f589b.js} +21 -21
  279. package/build/{index-2e7588d5.js → index-9f76eff8.js} +2 -2
  280. package/build/{index-eaec304f.js → index-a5b6bf95.js} +6 -6
  281. package/build/{index-2a640246.js → index-abf4568e.js} +18 -18
  282. package/build/{index-4745b5f2.js → index-ad640b16.js} +1 -1
  283. package/build/{index-4d438aef.js → index-b30545be.js} +2 -2
  284. package/build/{index-919a334f.js → index-ba2f1673.js} +3 -3
  285. package/build/{index-6d903b28.js → index-c03d5b05.js} +7 -7
  286. package/build/{index-bdc3bacc.js → index-c5193758.js} +1 -1
  287. package/build/{index-b8e6bef9.js → index-c7b180a8.js} +32 -32
  288. package/build/{index-f4078710.js → index-c88eca7a.js} +2 -2
  289. package/build/{index-13f5f568.js → index-ca360d1b.js} +32 -32
  290. package/build/{index-4c3bd443.js → index-ce264aab.js} +4 -4
  291. package/build/{index-40a55a37.js → index-d3aa7ac9.js} +16 -16
  292. package/build/{index-c3ef55be.js → index-d4cc55d5.js} +2 -2
  293. package/build/{index-37d96795.js → index-d766b652.js} +3 -3
  294. package/build/{index-e4be8a55.js → index-d9db5903.js} +1 -1
  295. package/build/{index-23d64751.js → index-da72b1e4.js} +5 -5
  296. package/build/{index-cff67767.js → index-e06e527b.js} +10 -10
  297. package/build/{index-18693522.js → index-e37e8c94.js} +2 -2
  298. package/build/{index-dcdb886d.js → index-e4c4a47e.js} +2 -2
  299. package/build/{index-5510e77b.js → index-e76a2d6b.js} +17 -17
  300. package/build/{index-f780c6d7.js → index-e90fd8b1.js} +2 -2
  301. package/build/{index-c58ea433.js → index-f519625e.js} +36 -27
  302. package/build/{index-5f5c3ea8.js → index-f7a352ec.js} +16 -16
  303. package/build/{index-dbd970b3.js → index-f7b562d7.js} +5 -5
  304. package/build/index.js +117 -117
  305. package/build/interfaces/constants/domainLocales.d.ts +2 -0
  306. package/build/interfaces/constants/index.d.ts +1 -1
  307. package/build/interfaces/types/Locale.d.ts +2 -1
  308. package/build/interfaces/types/index.d.ts +2 -1
  309. package/build/{labelSorting-7760ba9b.js → labelSorting-f0a2b329.js} +4 -4
  310. package/build/lead/LeadGen.type.d.ts +31 -0
  311. package/build/lead/LeadGenForm/LeadGenForm.d.ts +41 -0
  312. package/build/lead/LeadGenForm/LeadGenForm.helpers.d.ts +2 -0
  313. package/build/lead/LeadGenForm/LeadGenForm.styled.d.ts +5 -0
  314. package/build/lead/LeadGenForm/LeadGenFormPhone.d.ts +17 -0
  315. package/build/lead/LeadGenForm/LeadGenThankYou.d.ts +20 -0
  316. package/build/lead/LeadGenForm/index.d.ts +3 -0
  317. package/build/lead/LeadGenForm/textField/index.d.ts +13 -0
  318. package/build/lead/LeadGenForm/textField/index.styled.d.ts +11 -0
  319. package/build/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +63 -0
  320. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +4 -0
  321. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +21 -0
  322. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +3 -0
  323. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +23 -0
  324. package/build/lead/LeadGenSubscriptionBox/index.d.ts +1 -0
  325. package/build/lead/LeadGenTranslationContext.d.ts +6 -0
  326. package/build/lead/helpers.d.ts +56 -1
  327. package/build/lead/index.d.ts +3 -1
  328. package/build/lead/layouts/lightbox/formContext.d.ts +2 -1
  329. package/build/lead/leadGenContext.d.ts +1 -0
  330. package/build/lead/services/index.d.ts +19 -0
  331. package/build/lead/store/index.d.ts +1 -0
  332. package/build/lead.css +1 -1
  333. package/build/lead.js +2313 -1103
  334. package/build/{logoIcon-880cb527.js → logoIcon-abf47ead.js} +8 -2
  335. package/build/mantine.js +22 -22
  336. package/build/misc.js +17 -17
  337. package/build/miscGetDynamicHealthTool.js +4 -4
  338. package/build/miscGetSocialList.js +8 -8
  339. package/build/miscScreenSizeContext.js +1 -1
  340. package/build/mobileBottomNavigation.js +5 -5
  341. package/build/mobileBottomNavigationIcon.js +5 -5
  342. package/build/molecules.js +73 -73
  343. package/build/moleculesArticleCard.js +6 -6
  344. package/build/moleculesArticleCardV2.js +16 -16
  345. package/build/navigation.js +45 -45
  346. package/build/navigationLogoutPopup.js +9 -9
  347. package/build/navigationProfileButton.js +23 -23
  348. package/build/onboardingV2.js +28 -28
  349. package/build/organisms.js +49 -49
  350. package/build/{post-357b7ea1.js → post-e39c948f.js} +2 -2
  351. package/build/profileNavigation.js +19 -19
  352. package/build/progressBar.js +1 -1
  353. package/build/pwg.js +22 -22
  354. package/build/ssoV2/api/featureFlag.d.ts +2 -1
  355. package/build/ssoV2.js +49 -37
  356. package/build/{store-97cd2d27.js → store-19496022.js} +4 -4
  357. package/build/subot.js +34 -34
  358. package/build/surveyOrPremiumBanner.js +32 -32
  359. package/build/surveyQuestionCard.js +10 -10
  360. package/build/{surveyThankyouCard-1fa935a2.js → surveyThankyouCard-c4a46538.js} +5 -5
  361. package/build/together.js +55 -55
  362. package/build/togetherApiUtils.js +4 -4
  363. package/build/togetherAtoms.js +30 -30
  364. package/build/togetherComponentGlobalContext.js +4 -4
  365. package/build/togetherMolecules.js +50 -50
  366. package/build/togetherMoleculesCardAuthor.js +28 -28
  367. package/build/togetherMoleculesPostImagePreview.js +11 -11
  368. package/build/togetherMoleculesProfileDetail.js +38 -38
  369. package/build/togetherOrganisms.js +49 -49
  370. package/build/togetherRichTextEditor.js +17 -17
  371. package/build/togetherShareBox.js +10 -10
  372. package/build/translationsProvider-2988368b.js +62 -0
  373. package/build/{treePopoverMenu-31477cc0.js → treePopoverMenu-452d5155.js} +19 -19
  374. package/build/{types-09ed7f9e.js → types-2aa2c266.js} +2 -2
  375. package/build/types.js +2 -2
  376. package/build/{useCategory-2e2d7c0a.js → useCategory-4efd9a6a.js} +18 -5
  377. package/build/{useHealthToolCache-52456237.js → useHealthToolCache-e5fe0a19.js} +1 -1
  378. package/build/{useMantineLocale-6ce9ece4.js → useMantineLocale-481b8a13.js} +8 -6
  379. package/build/{usePlacesAutocomplete-e4be0dc6.js → usePlacesAutocomplete-26f79d1c.js} +1 -1
  380. package/build/{useScreenSize-d6cfd256.js → useScreenSize-03cd2dde.js} +2 -2
  381. package/build/useTogetherAuthRequiredAction.js +9 -9
  382. package/build/{utils-c6f8b687.js → utils-10a24a63.js} +3 -3
  383. package/build/{utils-e1ec6e21.js → utils-4addbbdb.js} +2 -2
  384. package/build/{utils-124601d6.js → utils-abfdf38e.js} +4 -4
  385. package/build/{utils-21007272.js → utils-be9f0bd7.js} +2 -2
  386. package/build/vaccination.js +21 -21
  387. package/package.json +3 -3
  388. /package/build/{BMI_BOYS.percentile.monthly-d6946360.js → BMI_BOYS.percentile.monthly-a94ca606.js} +0 -0
  389. /package/build/{BMI_BOYS.percentile.weekly-20af790c.js → BMI_BOYS.percentile.weekly-836a362e.js} +0 -0
  390. /package/build/{BMI_BOYS.percentile.yearly-79c95b3a.js → BMI_BOYS.percentile.yearly-2da80d18.js} +0 -0
  391. /package/build/{BMI_BOYS.zscore.monthly-b58a0864.js → BMI_BOYS.zscore.monthly-ddabfd0d.js} +0 -0
  392. /package/build/{BMI_BOYS.zscore.weekly-20237229.js → BMI_BOYS.zscore.weekly-44db2028.js} +0 -0
  393. /package/build/{BMI_BOYS.zscore.yearly-3a8bfd26.js → BMI_BOYS.zscore.yearly-34644dac.js} +0 -0
  394. /package/build/{BMI_GIRLS.percentile.monthly-646c842a.js → BMI_GIRLS.percentile.monthly-e049696d.js} +0 -0
  395. /package/build/{BMI_GIRLS.percentile.weekly-1f11bff1.js → BMI_GIRLS.percentile.weekly-17bc9a3f.js} +0 -0
  396. /package/build/{BMI_GIRLS.percentile.yearly-45f19305.js → BMI_GIRLS.percentile.yearly-8f603d39.js} +0 -0
  397. /package/build/{BMI_GIRLS.zscore.monthly-5051f40f.js → BMI_GIRLS.zscore.monthly-59affc15.js} +0 -0
  398. /package/build/{BMI_GIRLS.zscore.weekly-be4c04a5.js → BMI_GIRLS.zscore.weekly-6fcf7879.js} +0 -0
  399. /package/build/{BMI_GIRLS.zscore.yearly-bf5cdd14.js → BMI_GIRLS.zscore.yearly-adf6fe1d.js} +0 -0
  400. /package/build/{ChevronDown-7e199691.js → ChevronDown-c3f711b6.js} +0 -0
  401. /package/build/{Close-42249b50.js → Close-af38b8d8.js} +0 -0
  402. /package/build/{Google-28f1f3c9.js → Google-89d9d352.js} +0 -0
  403. /package/build/{HEAD CIRCUM_BOYS.percentile.monthly-83a8eba5.js → HEAD CIRCUM_BOYS.percentile.monthly-41afcfce.js} +0 -0
  404. /package/build/{HEAD CIRCUM_BOYS.percentile.weekly-59b57698.js → HEAD CIRCUM_BOYS.percentile.weekly-57391036.js} +0 -0
  405. /package/build/{HEAD CIRCUM_BOYS.percentile.yearly-33f8021e.js → HEAD CIRCUM_BOYS.percentile.yearly-c3f58e37.js} +0 -0
  406. /package/build/{HEAD CIRCUM_BOYS.zscore.monthly-a8b32c10.js → HEAD CIRCUM_BOYS.zscore.monthly-1e58b0be.js} +0 -0
  407. /package/build/{HEAD CIRCUM_BOYS.zscore.weekly-c56b7d6b.js → HEAD CIRCUM_BOYS.zscore.weekly-1cab9188.js} +0 -0
  408. /package/build/{HEAD CIRCUM_BOYS.zscore.yearly-cc618a5e.js → HEAD CIRCUM_BOYS.zscore.yearly-c10f93fe.js} +0 -0
  409. /package/build/{HEAD CIRCUM_GIRLS.percentile.monthly-b1d7edb9.js → HEAD CIRCUM_GIRLS.percentile.monthly-f3d4a5d0.js} +0 -0
  410. /package/build/{HEAD CIRCUM_GIRLS.percentile.weekly-a831826b.js → HEAD CIRCUM_GIRLS.percentile.weekly-13024b99.js} +0 -0
  411. /package/build/{HEAD CIRCUM_GIRLS.percentile.yearly-b106f3c9.js → HEAD CIRCUM_GIRLS.percentile.yearly-31bd2df8.js} +0 -0
  412. /package/build/{HEAD CIRCUM_GIRLS.zscore.monthly-7ee89d39.js → HEAD CIRCUM_GIRLS.zscore.monthly-62c93cbe.js} +0 -0
  413. /package/build/{HEAD CIRCUM_GIRLS.zscore.weekly-351fd224.js → HEAD CIRCUM_GIRLS.zscore.weekly-48764d7e.js} +0 -0
  414. /package/build/{HEAD CIRCUM_GIRLS.zscore.yearly-fe34e702.js → HEAD CIRCUM_GIRLS.zscore.yearly-6ee35298.js} +0 -0
  415. /package/build/{HEIGHT_BOYS.percentile.monthly-1fc3e4b9.js → HEIGHT_BOYS.percentile.monthly-cedda272.js} +0 -0
  416. /package/build/{HEIGHT_BOYS.percentile.weekly-22bd5a26.js → HEIGHT_BOYS.percentile.weekly-a7d3426e.js} +0 -0
  417. /package/build/{HEIGHT_BOYS.percentile.yearly-2076b7dd.js → HEIGHT_BOYS.percentile.yearly-af32bacb.js} +0 -0
  418. /package/build/{HEIGHT_BOYS.zscore.monthly-ba944c3d.js → HEIGHT_BOYS.zscore.monthly-c1ec0f1a.js} +0 -0
  419. /package/build/{HEIGHT_BOYS.zscore.weekly-c4802f8c.js → HEIGHT_BOYS.zscore.weekly-a99cd461.js} +0 -0
  420. /package/build/{HEIGHT_BOYS.zscore.yearly-310101b2.js → HEIGHT_BOYS.zscore.yearly-65531c25.js} +0 -0
  421. /package/build/{HEIGHT_GIRLS.percentile.monthly-40345dff.js → HEIGHT_GIRLS.percentile.monthly-c3c68ff1.js} +0 -0
  422. /package/build/{HEIGHT_GIRLS.percentile.weekly-ed97d167.js → HEIGHT_GIRLS.percentile.weekly-7789077e.js} +0 -0
  423. /package/build/{HEIGHT_GIRLS.percentile.yearly-6e20fdad.js → HEIGHT_GIRLS.percentile.yearly-c552b2cd.js} +0 -0
  424. /package/build/{HEIGHT_GIRLS.zscore.monthly-c9de74df.js → HEIGHT_GIRLS.zscore.monthly-f5c30e44.js} +0 -0
  425. /package/build/{HEIGHT_GIRLS.zscore.weekly-4d5452ab.js → HEIGHT_GIRLS.zscore.weekly-aa7359b8.js} +0 -0
  426. /package/build/{HEIGHT_GIRLS.zscore.yearly-5a006791.js → HEIGHT_GIRLS.zscore.yearly-a3121654.js} +0 -0
  427. /package/build/{Visible-143fd671.js → Visible-c0e317b6.js} +0 -0
  428. /package/build/{WEIGHT_BOYS.percentile.monthly-f9c7bfe2.js → WEIGHT_BOYS.percentile.monthly-546f7888.js} +0 -0
  429. /package/build/{WEIGHT_BOYS.percentile.weekly-f3a7f639.js → WEIGHT_BOYS.percentile.weekly-38af0491.js} +0 -0
  430. /package/build/{WEIGHT_BOYS.percentile.yearly-2693360e.js → WEIGHT_BOYS.percentile.yearly-f008340d.js} +0 -0
  431. /package/build/{WEIGHT_BOYS.zscore.monthly-24e1351d.js → WEIGHT_BOYS.zscore.monthly-e8802481.js} +0 -0
  432. /package/build/{WEIGHT_BOYS.zscore.weekly-d8808e5e.js → WEIGHT_BOYS.zscore.weekly-409ed8cf.js} +0 -0
  433. /package/build/{WEIGHT_BOYS.zscore.yearly-bb6a9845.js → WEIGHT_BOYS.zscore.yearly-df392705.js} +0 -0
  434. /package/build/{WEIGHT_GIRLS.percentile.monthly-2942a88c.js → WEIGHT_GIRLS.percentile.monthly-524fe0d4.js} +0 -0
  435. /package/build/{WEIGHT_GIRLS.percentile.weekly-afcfb8ae.js → WEIGHT_GIRLS.percentile.weekly-81a69fd3.js} +0 -0
  436. /package/build/{WEIGHT_GIRLS.percentile.yearly-f8da5547.js → WEIGHT_GIRLS.percentile.yearly-020535af.js} +0 -0
  437. /package/build/{WEIGHT_GIRLS.zscore.monthly-b155d55b.js → WEIGHT_GIRLS.zscore.monthly-14b4e77b.js} +0 -0
  438. /package/build/{WEIGHT_GIRLS.zscore.weekly-c47d3c0e.js → WEIGHT_GIRLS.zscore.weekly-5520f50e.js} +0 -0
  439. /package/build/{WEIGHT_GIRLS.zscore.yearly-b6d21a9e.js → WEIGHT_GIRLS.zscore.yearly-25e801fa.js} +0 -0
  440. /package/build/{animation-a0995558.js → animation-ffcf687b.js} +0 -0
  441. /package/build/{constants-22dca8dd.js → constants-459aab55.js} +0 -0
  442. /package/build/{constants-d83058f6.js → constants-75af6d16.js} +0 -0
  443. /package/build/{dataTransform-0cb8a8cd.js → dataTransform-8d6c3c6f.js} +0 -0
  444. /package/build/{doctor-4a45ea00.js → doctor-0c5af8d7.js} +0 -0
  445. /package/build/esm/{BMI_BOYS.percentile.monthly-47abba26.js → BMI_BOYS.percentile.monthly-98b80b28.js} +0 -0
  446. /package/build/esm/{BMI_BOYS.percentile.weekly-9d4ba826.js → BMI_BOYS.percentile.weekly-2fe6652f.js} +0 -0
  447. /package/build/esm/{BMI_BOYS.percentile.yearly-90ae2dff.js → BMI_BOYS.percentile.yearly-08013b35.js} +0 -0
  448. /package/build/esm/{BMI_BOYS.zscore.monthly-b00e46ea.js → BMI_BOYS.zscore.monthly-98cafee7.js} +0 -0
  449. /package/build/esm/{BMI_BOYS.zscore.weekly-dbd35296.js → BMI_BOYS.zscore.weekly-a2873e74.js} +0 -0
  450. /package/build/esm/{BMI_BOYS.zscore.yearly-665b09ef.js → BMI_BOYS.zscore.yearly-4f3248cd.js} +0 -0
  451. /package/build/esm/{BMI_GIRLS.percentile.monthly-d31eee10.js → BMI_GIRLS.percentile.monthly-e3a3a60e.js} +0 -0
  452. /package/build/esm/{BMI_GIRLS.percentile.weekly-aa3d28f7.js → BMI_GIRLS.percentile.weekly-67a60ae0.js} +0 -0
  453. /package/build/esm/{BMI_GIRLS.percentile.yearly-39f66f5f.js → BMI_GIRLS.percentile.yearly-f5289f0a.js} +0 -0
  454. /package/build/esm/{BMI_GIRLS.zscore.monthly-136af822.js → BMI_GIRLS.zscore.monthly-ea2c6c7d.js} +0 -0
  455. /package/build/esm/{BMI_GIRLS.zscore.weekly-28304e3f.js → BMI_GIRLS.zscore.weekly-31ebf715.js} +0 -0
  456. /package/build/esm/{BMI_GIRLS.zscore.yearly-f772a0b0.js → BMI_GIRLS.zscore.yearly-0f5cd13e.js} +0 -0
  457. /package/build/esm/{ChevronDown-550bf2e5.js → ChevronDown-d4216c49.js} +0 -0
  458. /package/build/esm/{Close-4a4d7864.js → Close-a1570e5a.js} +0 -0
  459. /package/build/esm/{Google-de50179c.js → Google-836ba7ee.js} +0 -0
  460. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.monthly-867fea3c.js → HEAD CIRCUM_BOYS.percentile.monthly-c5b52221.js} +0 -0
  461. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.weekly-609e4131.js → HEAD CIRCUM_BOYS.percentile.weekly-5939b5e3.js} +0 -0
  462. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.yearly-29a76be2.js → HEAD CIRCUM_BOYS.percentile.yearly-287b382c.js} +0 -0
  463. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.monthly-8adb5c34.js → HEAD CIRCUM_BOYS.zscore.monthly-82522fd4.js} +0 -0
  464. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.weekly-968f921f.js → HEAD CIRCUM_BOYS.zscore.weekly-f888f299.js} +0 -0
  465. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.yearly-9cb8692c.js → HEAD CIRCUM_BOYS.zscore.yearly-4fd9b4f0.js} +0 -0
  466. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.monthly-377218db.js → HEAD CIRCUM_GIRLS.percentile.monthly-accd234c.js} +0 -0
  467. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.weekly-87ceba96.js → HEAD CIRCUM_GIRLS.percentile.weekly-11df9b57.js} +0 -0
  468. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.yearly-099441f8.js → HEAD CIRCUM_GIRLS.percentile.yearly-832d6d96.js} +0 -0
  469. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.monthly-3a44976b.js → HEAD CIRCUM_GIRLS.zscore.monthly-d796cff8.js} +0 -0
  470. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.weekly-8d904aed.js → HEAD CIRCUM_GIRLS.zscore.weekly-dbdfd713.js} +0 -0
  471. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.yearly-7d06954c.js → HEAD CIRCUM_GIRLS.zscore.yearly-bbd50143.js} +0 -0
  472. /package/build/esm/{HEIGHT_BOYS.percentile.monthly-65e72f05.js → HEIGHT_BOYS.percentile.monthly-13bf1524.js} +0 -0
  473. /package/build/esm/{HEIGHT_BOYS.percentile.weekly-8ceb6fa4.js → HEIGHT_BOYS.percentile.weekly-ee262d0f.js} +0 -0
  474. /package/build/esm/{HEIGHT_BOYS.percentile.yearly-373dc142.js → HEIGHT_BOYS.percentile.yearly-878b6fed.js} +0 -0
  475. /package/build/esm/{HEIGHT_BOYS.zscore.monthly-2d2fef94.js → HEIGHT_BOYS.zscore.monthly-86a939d1.js} +0 -0
  476. /package/build/esm/{HEIGHT_BOYS.zscore.weekly-02e0fc04.js → HEIGHT_BOYS.zscore.weekly-2314a0c1.js} +0 -0
  477. /package/build/esm/{HEIGHT_BOYS.zscore.yearly-ca0722c1.js → HEIGHT_BOYS.zscore.yearly-9c94c8e1.js} +0 -0
  478. /package/build/esm/{HEIGHT_GIRLS.percentile.monthly-b09f7c23.js → HEIGHT_GIRLS.percentile.monthly-7590684f.js} +0 -0
  479. /package/build/esm/{HEIGHT_GIRLS.percentile.weekly-493f8af5.js → HEIGHT_GIRLS.percentile.weekly-680b838e.js} +0 -0
  480. /package/build/esm/{HEIGHT_GIRLS.percentile.yearly-7223371a.js → HEIGHT_GIRLS.percentile.yearly-798c4744.js} +0 -0
  481. /package/build/esm/{HEIGHT_GIRLS.zscore.monthly-dbb8481e.js → HEIGHT_GIRLS.zscore.monthly-3e584eb1.js} +0 -0
  482. /package/build/esm/{HEIGHT_GIRLS.zscore.weekly-595da20b.js → HEIGHT_GIRLS.zscore.weekly-e5d7976a.js} +0 -0
  483. /package/build/esm/{HEIGHT_GIRLS.zscore.yearly-7a943001.js → HEIGHT_GIRLS.zscore.yearly-494e461f.js} +0 -0
  484. /package/build/esm/{Visible-9d1cb8cc.js → Visible-af1dbd44.js} +0 -0
  485. /package/build/esm/{WEIGHT_BOYS.percentile.monthly-15fb2aa3.js → WEIGHT_BOYS.percentile.monthly-1ae7df4c.js} +0 -0
  486. /package/build/esm/{WEIGHT_BOYS.percentile.weekly-d561bccc.js → WEIGHT_BOYS.percentile.weekly-8c22f2be.js} +0 -0
  487. /package/build/esm/{WEIGHT_BOYS.percentile.yearly-b396434e.js → WEIGHT_BOYS.percentile.yearly-becb5697.js} +0 -0
  488. /package/build/esm/{WEIGHT_BOYS.zscore.monthly-a5408b65.js → WEIGHT_BOYS.zscore.monthly-0a194058.js} +0 -0
  489. /package/build/esm/{WEIGHT_BOYS.zscore.weekly-67753ba3.js → WEIGHT_BOYS.zscore.weekly-9145c833.js} +0 -0
  490. /package/build/esm/{WEIGHT_BOYS.zscore.yearly-c7f5af09.js → WEIGHT_BOYS.zscore.yearly-4fb5c591.js} +0 -0
  491. /package/build/esm/{WEIGHT_GIRLS.percentile.monthly-2390be4c.js → WEIGHT_GIRLS.percentile.monthly-2e282f8b.js} +0 -0
  492. /package/build/esm/{WEIGHT_GIRLS.percentile.weekly-3e67b18f.js → WEIGHT_GIRLS.percentile.weekly-e69f82dc.js} +0 -0
  493. /package/build/esm/{WEIGHT_GIRLS.percentile.yearly-25f8a8e3.js → WEIGHT_GIRLS.percentile.yearly-c463294f.js} +0 -0
  494. /package/build/esm/{WEIGHT_GIRLS.zscore.monthly-f6c22a63.js → WEIGHT_GIRLS.zscore.monthly-e9990c7e.js} +0 -0
  495. /package/build/esm/{WEIGHT_GIRLS.zscore.weekly-0555849e.js → WEIGHT_GIRLS.zscore.weekly-64fe359e.js} +0 -0
  496. /package/build/esm/{WEIGHT_GIRLS.zscore.yearly-0051596a.js → WEIGHT_GIRLS.zscore.yearly-299f776b.js} +0 -0
  497. /package/build/esm/{animation-8d847ff0.js → animation-de92eac9.js} +0 -0
  498. /package/build/esm/{constants-10f1eb9a.js → constants-347788b2.js} +0 -0
  499. /package/build/esm/{constants-984cbb19.js → constants-f5042816.js} +0 -0
  500. /package/build/esm/{dataTransform-59cdc1d0.js → dataTransform-50fd6ddf.js} +0 -0
  501. /package/build/esm/{doctor-38d38ec1.js → doctor-11fffc6e.js} +0 -0
  502. /package/build/esm/{index-7a23b922.js → index-06e4ca77.js} +0 -0
  503. /package/build/esm/{index-b5d1257d.js → index-2a8894e6.js} +0 -0
  504. /package/build/esm/{index-d287aa93.js → index-45e1c9a1.js} +0 -0
  505. /package/build/esm/{index-e8af7f05.js → index-664497df.js} +0 -0
  506. /package/build/esm/{index-542b3954.js → index-89498cd6.js} +0 -0
  507. /package/build/esm/{index-b63f3f75.js → index-b8e1ece4.js} +0 -0
  508. /package/build/esm/{index-3824a6dc.js → index-db6cad26.js} +0 -0
  509. /package/build/esm/{index-1c098112.js → index-e7737ff7.js} +0 -0
  510. /package/build/esm/{index.styles-7021829c.js → index.styles-a1185717.js} +0 -0
  511. /package/build/esm/{localizeNumberFormat-8f6fbc37.js → localizeNumberFormat-1fdb8aa8.js} +0 -0
  512. /package/build/esm/{normalizeLink-d9c7d9dc.js → normalizeLink-321e9bca.js} +0 -0
  513. /package/build/esm/{number-743da10e.js → number-1d1c965d.js} +0 -0
  514. /package/build/esm/{other-791b5dfd.js → other-2483b757.js} +0 -0
  515. /package/build/esm/{paths-67b9d7af.js → paths-4600a9c1.js} +0 -0
  516. /package/build/esm/{translationsContext-bc9a8b0f.js → translationsContext-8c982b59.js} +0 -0
  517. /package/build/esm/{tslib.es6-8c4c969c.js → tslib.es6-5338c038.js} +0 -0
  518. /package/build/esm/{types-ac983be3.js → types-d9ab84a2.js} +0 -0
  519. /package/build/esm/{useIsInit-e62ff31e.js → useIsInit-a4da83cb.js} +0 -0
  520. /package/build/esm/{useOutsideClick-f9ccf2f3.js → useOutsideClick-cd806f77.js} +0 -0
  521. /package/build/esm/{useScrollbarSize-07ff2710.js → useScrollbarSize-abd71947.js} +0 -0
  522. /package/build/esm/{useUniqueId-82eba9be.js → useUniqueId-58e62fe5.js} +0 -0
  523. /package/build/esm/{utils-1fb89ecb.js → utils-bad138ab.js} +0 -0
  524. /package/build/{index-f0bc5c42.js → index-0baf46a9.js} +0 -0
  525. /package/build/{index-67e6906a.js → index-10d959d5.js} +0 -0
  526. /package/build/{index-e9f8d6ac.js → index-222ea420.js} +0 -0
  527. /package/build/{index-460c845b.js → index-5a53d685.js} +0 -0
  528. /package/build/{index-d9a969c0.js → index-857c287a.js} +0 -0
  529. /package/build/{index-76c236b5.js → index-88d9a33b.js} +0 -0
  530. /package/build/{index-c25513bf.js → index-e0e69a8c.js} +0 -0
  531. /package/build/{index-5391aa51.js → index-ffba7b3c.js} +0 -0
  532. /package/build/{index.styles-13b6e8be.js → index.styles-cdfc2015.js} +0 -0
  533. /package/build/{localizeNumberFormat-37d79e0a.js → localizeNumberFormat-bd72b6e3.js} +0 -0
  534. /package/build/{normalizeLink-f075b2f2.js → normalizeLink-4f6ec0e4.js} +0 -0
  535. /package/build/{number-bda5ad35.js → number-75eec17b.js} +0 -0
  536. /package/build/{other-677461ab.js → other-c454606b.js} +0 -0
  537. /package/build/{paths-c8eab138.js → paths-4d6918f2.js} +0 -0
  538. /package/build/{translationsContext-5634aceb.js → translationsContext-03c93e26.js} +0 -0
  539. /package/build/{tslib.es6-138ffaff.js → tslib.es6-5d29380d.js} +0 -0
  540. /package/build/{types-e4a1903c.js → types-cafd9617.js} +0 -0
  541. /package/build/{useIsInit-628ffe42.js → useIsInit-0773f875.js} +0 -0
  542. /package/build/{useOutsideClick-6af86e0d.js → useOutsideClick-398b0bb1.js} +0 -0
  543. /package/build/{useScrollbarSize-7b4ba168.js → useScrollbarSize-1b60cab4.js} +0 -0
  544. /package/build/{useUniqueId-9945fa7a.js → useUniqueId-c9bbb0bd.js} +0 -0
  545. /package/build/{utils-1606e69b.js → utils-ce39dcb2.js} +0 -0
package/build/lead.js CHANGED
@@ -2,54 +2,74 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('./tslib.es6-138ffaff.js');
5
+ var tslib_es6 = require('./tslib.es6-5d29380d.js');
6
6
  var React = require('react');
7
7
  var core = require('@mantine/core');
8
8
  var dayjs = require('dayjs');
9
9
  var debounce = require('lodash/debounce');
10
10
  var form = require('@mantine/form');
11
- var index = require('./index-bdc3bacc.js');
12
- var translationsContext = require('./translationsContext-5634aceb.js');
11
+ var index = require('./index-c5193758.js');
12
+ var translationsContext = require('./translationsContext-03c93e26.js');
13
13
  var miscCookieHelper = require('./miscCookieHelper.js');
14
- var utils$1 = require('./utils-1606e69b.js');
15
- var index$1 = require('./index-4d438aef.js');
16
- var index$2 = require('./index-c58ea433.js');
17
- var index$4 = require('./index-3550236c.js');
18
- var utils = require('./utils-21007272.js');
19
- require('@mantine/dates');
20
- var index$8 = require('./index-ecaef1d8.js');
21
- require('./index-6c13b501.js');
22
- require('./index-f0bc5c42.js');
23
- require('./useMantineLocale-6ce9ece4.js');
24
- var index$5 = require('./index-e4be8a55.js');
25
- require('./index.styles-13b6e8be.js');
14
+ var utils$1 = require('./utils-ce39dcb2.js');
15
+ var index$1 = require('./index-b30545be.js');
16
+ var index$2 = require('./index-f519625e.js');
17
+ var index$4 = require('./index-920ce764.js');
18
+ var index$3 = require('./index-d9db5903.js');
19
+ require('./index.styles-cdfc2015.js');
26
20
  var hooks = require('@mantine/hooks');
27
- require('./other-677461ab.js');
28
- require('./index-d09aa821.js');
29
- var usePlacesAutocomplete = require('./usePlacesAutocomplete-e4be0dc6.js');
30
- var index$3 = require('./index-f780c6d7.js');
31
- var index$6 = require('./index-f4078710.js');
21
+ require('./useMantineLocale-481b8a13.js');
22
+ var index$8 = require('./index-3424b721.js');
23
+ require('./index-0baf46a9.js');
24
+ var index$6 = require('./index-8ad0770c.js');
25
+ require('./other-c454606b.js');
26
+ require('./index-695380e6.js');
27
+ var utils = require('./utils-be9f0bd7.js');
28
+ var dates = require('@mantine/dates');
29
+ var usePlacesAutocomplete = require('./usePlacesAutocomplete-26f79d1c.js');
30
+ var index$5 = require('./index-c88eca7a.js');
31
+ var translationsProvider = require('./translationsProvider-2988368b.js');
32
+ var Locale = require('./Locale-a6cfbd0c.js');
32
33
  var uuid = require('uuid');
33
- var index$7 = require('./index-c25513bf.js');
34
- var index$9 = require('./index-2e7588d5.js');
35
- var useScreenSize = require('./useScreenSize-d6cfd256.js');
36
- var ReactDOM = require('react-dom');
37
- var react = require('@emotion/react');
34
+ var PhoneInputBase = require('react-phone-number-input');
38
35
  var styled = require('@emotion/styled');
39
36
  var miscTheme = require('./miscTheme.js');
40
- var Close = require('./Close-42249b50.js');
37
+ var react = require('@emotion/react');
38
+ var togetherComponentGlobalContext = require('./utils-10a24a63.js');
39
+ var index$7 = require('./index-e0e69a8c.js');
40
+ var index$a = require('./index-9f76eff8.js');
41
+ var useScreenSize = require('./useScreenSize-03cd2dde.js');
42
+ var ReactDOM = require('react-dom');
43
+ var index$9 = require('./index-e90fd8b1.js');
44
+ var InputDate = require('./InputDate-53510fc6.js');
45
+ var Close = require('./Close-af38b8d8.js');
41
46
  require('@hhgtech/icons/other');
42
47
  require('@mantine/carousel');
43
- require('./Locale-23dce5ce.js');
44
48
  require('classnames');
45
- require('./useUniqueId-9945fa7a.js');
49
+ require('./useUniqueId-c9bbb0bd.js');
46
50
  require('./constantsSite.js');
47
51
  require('@hhgtech/icons/core');
48
- require('date-fns/locale');
52
+ require('@mantine/notifications');
49
53
  require('./constantsDomainLocales.js');
50
- require('./constantsRiskScreener.js');
51
54
  require('./constantsIsProduction.js');
52
- require('@mantine/notifications');
55
+ require('date-fns/locale');
56
+ require('./constantsRiskScreener.js');
57
+ require('./i18n-values/en-PH.js');
58
+ require('./i18n-values/hi-IN.js');
59
+ require('./i18n-values/id-ID.js');
60
+ require('./i18n-values/km-KH.js');
61
+ require('./i18n-values/ms-MY.js');
62
+ require('./i18n-values/my-MM.js');
63
+ require('./i18n-values/th-TH.js');
64
+ require('./i18n-values/tl-PH.js');
65
+ require('./i18n-values/vi-VN.js');
66
+ require('./i18n-values/vi-VN_MB.js');
67
+ require('./i18n-values/zh-TW.js');
68
+ require('./index-10d959d5.js');
69
+ require('slugify');
70
+ require('string-format');
71
+ require('./togetherApiPaths.js');
72
+ require('./constants-75af6d16.js');
53
73
  require('vaul');
54
74
 
55
75
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -101,7 +121,7 @@ if (sessionStorage.getItem('insider_object')) {
101
121
  }
102
122
  const docLang = document.documentElement.lang;
103
123
  // TODO: country code
104
- const LEAD_LOCALE_DATA = {
124
+ const LEAD_LOCALE_DATA$1 = {
105
125
  'vi-VN': {
106
126
  popupLang: 'vi',
107
127
  countryCode: 'vn',
@@ -143,7 +163,7 @@ const LEAD_LOCALE_DATA = {
143
163
  countryCodeNumber: 91,
144
164
  },
145
165
  };
146
- const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
166
+ const LEAD_LOCALE = LEAD_LOCALE_DATA$1[docLang] || LEAD_LOCALE_DATA$1['vi-VN'];
147
167
  function LEAD_RESET_VAR() {
148
168
  // LEAD_CURRENT_URL = location.href.toLowerCase();
149
169
  LEAD_CURRENT_URL =
@@ -164,6 +184,11 @@ const LEAD_TIMEZONE_DATA = {
164
184
  9: 'Asia/Manila', // Philippines / Filipinos Site
165
185
  };
166
186
 
187
+ const LEADGEN_ACTIONS = {
188
+ SHOW: 'SHOW',
189
+ SCROLL: 'SCROLL',
190
+ TIME: 'TIME',
191
+ };
167
192
  const LEADGEN_LAYOUT = {
168
193
  LightBoxA: 'LightBoxA',
169
194
  LightBoxB: 'LightBoxB',
@@ -193,8 +218,10 @@ const LEADGEN_BLOCK = {
193
218
  DropdownBlock: 'DropdownBlock',
194
219
  CheckboxBlock: 'CheckboxBlock',
195
220
  TncBlock: 'TncBlock',
221
+ TitleBlock: 'TitleBlock',
222
+ SubtitleBlock: 'SubtitleBlock',
196
223
  };
197
- const LEADGEN_BLOCK_IN_FORM = [
224
+ const LEADGEN_BLOCK_INPUT = [
198
225
  LEADGEN_BLOCK.TextBlock,
199
226
  LEADGEN_BLOCK.NumberBlock,
200
227
  LEADGEN_BLOCK.DateBlock,
@@ -209,7 +236,59 @@ const LEADGEN_BLOCK_IN_FORM = [
209
236
  LEADGEN_BLOCK.CheckboxBlock,
210
237
  LEADGEN_BLOCK.TncBlock,
211
238
  ];
239
+ const leadGenFieldNamePhone = (listBlockAdded) => {
240
+ return listBlockAdded
241
+ .filter(({ name }) => [
242
+ LEADGEN_BLOCK.PhoneBlock,
243
+ LEADGEN_BLOCK.PhoneOtpBlock,
244
+ LEADGEN_BLOCK.WhatsappOtpBlock,
245
+ LEADGEN_BLOCK.ZaloOtpBlock,
246
+ ].includes(name))
247
+ .map(({ data }) => data.value);
248
+ };
212
249
  const SSO_MAP_LEAD = ['name', 'email', 'birthday', 'phone', 'gender'];
250
+ const LEAD_LOCALE_DATA = {
251
+ 'vi-VN': {
252
+ popupLang: 'vi',
253
+ countryCode: 'vn',
254
+ countryCodeNumber: 84,
255
+ },
256
+ 'id-ID': {
257
+ popupLang: 'id',
258
+ countryCode: 'id',
259
+ countryCodeNumber: 62,
260
+ },
261
+ 'th-TH': {
262
+ popupLang: 'th',
263
+ countryCode: 'th',
264
+ countryCodeNumber: 66,
265
+ },
266
+ 'ms-MY': {
267
+ popupLang: 'ms',
268
+ countryCode: 'my',
269
+ countryCodeNumber: 60,
270
+ },
271
+ 'zh-TW': {
272
+ popupLang: 'zh',
273
+ countryCode: 'tw',
274
+ countryCodeNumber: 886,
275
+ },
276
+ 'km-KH': {
277
+ popupLang: 'km',
278
+ countryCode: 'kh',
279
+ countryCodeNumber: 855,
280
+ },
281
+ 'my-MM': {
282
+ popupLang: 'my',
283
+ countryCode: 'mm',
284
+ countryCodeNumber: 95,
285
+ },
286
+ 'hi-IN': {
287
+ popupLang: 'hi',
288
+ countryCode: 'in',
289
+ countryCodeNumber: 91,
290
+ },
291
+ };
213
292
  const mappingSSOToLead = (userInfoProps) => {
214
293
  var _a, _b;
215
294
  try {
@@ -225,7 +304,7 @@ const mappingSSOToLead = (userInfoProps) => {
225
304
  if (ssoKey === 'birthday') {
226
305
  const dob = dayjs__default["default"](initValue, 'YYYY-MM-DD', true);
227
306
  if (dob.isValid()) {
228
- user.birthday = dob;
307
+ user.birthday = dob.toDate();
229
308
  }
230
309
  }
231
310
  else if (ssoKey === 'gender') {
@@ -248,16 +327,66 @@ const mappingSSOToLead = (userInfoProps) => {
248
327
  catch (error) {
249
328
  return;
250
329
  }
330
+ };
331
+ const formatCampaignDetail = (campaign) => {
332
+ if (!campaign) {
333
+ return {};
334
+ }
335
+ try {
336
+ const { extra_fields, thank_you_image } = campaign || {};
337
+ const { textBlocks: exTextBlocks, imageBlocks: exImageBlocks, listBlockAdded: exListBlockAdded, listBlockThankyou: exListBlockThankyou, actionBlocks: exActionBlocks, } = extra_fields;
338
+ const textBlocks = JSON.parse(exTextBlocks);
339
+ const imageBlocks = JSON.parse(exImageBlocks);
340
+ const listBlockAdded = JSON.parse(exListBlockAdded);
341
+ const listBlockThankyou = JSON.parse(exListBlockThankyou);
342
+ const actionBlocks = JSON.parse(exActionBlocks);
343
+ const ThankYouBlock = {
344
+ image: { src: thank_you_image },
345
+ };
346
+ listBlockThankyou.forEach((block) => {
347
+ const { name, data } = block || {};
348
+ const { value: htmlText, align, newtab, url } = data || {};
349
+ switch (name) {
350
+ case LEADGEN_BLOCK.TitleBlock: {
351
+ ThankYouBlock.title = { htmlText, align };
352
+ }
353
+ case LEADGEN_BLOCK.SubtitleBlock: {
354
+ ThankYouBlock.description = { htmlText, align };
355
+ }
356
+ case LEADGEN_BLOCK.LinkButtonBlock: {
357
+ ThankYouBlock.button = { htmlText, newtab, url };
358
+ }
359
+ }
360
+ });
361
+ return Object.assign(Object.assign({}, campaign), { extra_fields: Object.assign(Object.assign({}, extra_fields), { textBlocks,
362
+ imageBlocks,
363
+ listBlockAdded,
364
+ listBlockThankyou,
365
+ actionBlocks }), ThankYouBlock });
366
+ }
367
+ catch (error) {
368
+ return {};
369
+ }
251
370
  };
252
371
 
253
372
  class Store {
254
373
  constructor() {
374
+ this.apiSsoUrl = 'https://staging-id.hellobacsi.com/';
255
375
  this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
256
376
  this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
257
377
  }
258
378
  }
259
379
  const leadStore = new Store();
260
380
 
381
+ const LEADGEN_API_METHOD = {
382
+ GET: 'get',
383
+ POST: 'POST',
384
+ };
385
+ const LEADGEN_API_PATH = {
386
+ V2_CAMPAIGN: 'api/v2/campaign',
387
+ V2_SUBSCRIPTION_LEAD: 'api/v2/subscription-box',
388
+ V2_SUBSCRIPTION_INFO: 'api/campaign/get-title',
389
+ };
261
390
  const leadApi = {
262
391
  call(_a) {
263
392
  var { url, data = undefined } = _a, config = tslib_es6.__rest(_a, ["url", "data"]);
@@ -361,8 +490,50 @@ const verifyOtpLead = ({ phone, otp, type, }) => {
361
490
  },
362
491
  });
363
492
  };
493
+ const getCampaignByCode = (campaign_code) => {
494
+ return leadApi.call({
495
+ url: `${LEADGEN_API_PATH.V2_CAMPAIGN}/${campaign_code}`,
496
+ method: LEADGEN_API_METHOD.GET,
497
+ });
498
+ };
499
+ const getSubscriptionBoxInfo = ({ category, site, }) => {
500
+ return leadApi.call({
501
+ url: `${LEADGEN_API_PATH.V2_SUBSCRIPTION_INFO}?category=${category}&site=${site}`,
502
+ method: LEADGEN_API_METHOD.GET,
503
+ });
504
+ };
505
+ const postSubscriptionBoxLead = ({ data }) => {
506
+ return leadApi.call({
507
+ url: LEADGEN_API_PATH.V2_SUBSCRIPTION_LEAD,
508
+ method: LEADGEN_API_METHOD.POST,
509
+ data,
510
+ });
511
+ };
512
+ const postUserInfoFromLeadGen = ({}) => {
513
+ return;
514
+ };
515
+ const campaignPostImpression = ({ code, action, title_article, ga_client_id, cookie_id, extra, url, referrer, }) => {
516
+ return leadApi.call({
517
+ url: `api/campaign/${code}/impression`,
518
+ method: LEADGEN_API_METHOD.POST,
519
+ data: {
520
+ action,
521
+ title_article,
522
+ cookie_id,
523
+ ga_client_id,
524
+ url,
525
+ extra,
526
+ referrer,
527
+ },
528
+ });
529
+ };
364
530
  const Service = {
365
531
  campaignGetById,
532
+ getCampaignByCode,
533
+ getSubscriptionBoxInfo,
534
+ postSubscriptionBoxLead,
535
+ postUserInfoFromLeadGen,
536
+ campaignPostImpression,
366
537
  validateEmailOrPhoneOnSubot,
367
538
  validateEmailOrPhoneOnLeadGen,
368
539
  validatePhoneNumberOnLeadGen,
@@ -702,6 +873,8 @@ const Description = (_a) => {
702
873
  return description ? (React__default["default"].createElement(index$1.Text, Object.assign({ size: "p3" }, rest), description)) : null;
703
874
  };
704
875
 
876
+ const LeadGenContext$1 = React.createContext({});
877
+
705
878
  var useStyles$2 = core.createStyles(() => {
706
879
  return {
707
880
  control: {},
@@ -764,6 +937,7 @@ const SubtitleBlock$1 = ({ children, align, }) => (React__default["default"].cre
764
937
  const TitleBlock$1 = ({ children, align, }) => (React__default["default"].createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
765
938
 
766
939
  const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, popoverProps, }) => {
940
+ const { primaryColor } = React.useContext(LeadGenContext$1);
767
941
  const { classes, cx } = useStyles$2(undefined, {
768
942
  name: 'LeadGen__Field',
769
943
  styles,
@@ -818,7 +992,7 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
818
992
  case 'LinkButtonBlock':
819
993
  return (React__default["default"].createElement("div", { key: index },
820
994
  React__default["default"].createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
821
- React__default["default"].createElement(index$3.Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
995
+ React__default["default"].createElement(index$3.Button, { type: "button", size: "md", color: primaryColor, className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
822
996
  onClose === null || onClose === void 0 ? void 0 : onClose();
823
997
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
824
998
  } }, value))));
@@ -878,6 +1052,7 @@ const Heading = (_a) => {
878
1052
 
879
1053
  const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps, submitProps, }) => {
880
1054
  var _a;
1055
+ const { primaryColor } = React.useContext(LeadGenContext$1);
881
1056
  const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, setFormRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = React.useContext(LeadGenComponentContext);
882
1057
  const { classes, cx } = useStyles$1(undefined, {
883
1058
  name: 'LeadGen__FormComponent',
@@ -966,7 +1141,7 @@ const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps,
966
1141
  control: classes.control,
967
1142
  }, listBlockAdded: listBlockAdded, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit, popoverProps: popoverProps })),
968
1143
  ((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) ? null : (React__default["default"].createElement("div", { className: classes.submitBtnWrapper },
969
- React__default["default"].createElement(index$5.Button, Object.assign({ size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, loading: isSubmitLoading }, submitProps), popUpSubmitText))))));
1144
+ React__default["default"].createElement(index$3.Button, Object.assign({ size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, loading: isSubmitLoading, color: primaryColor }, submitProps), popUpSubmitText))))));
970
1145
  };
971
1146
  const Form = (props) => {
972
1147
  const { showOtpPhone, showThankyou } = React.useContext(LeadGenComponentContext);
@@ -1097,7 +1272,7 @@ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, st
1097
1272
  submitOtp();
1098
1273
  }, className: cx(classes.root, className) },
1099
1274
  React__default["default"].createElement("div", { className: classes.header },
1100
- React__default["default"].createElement(index$6.Heading, { tag: "h3", className: classes.heading }, t('lead.otp.title')),
1275
+ React__default["default"].createElement(index$5.Heading, { tag: "h3", className: classes.heading }, t('lead.otp.title')),
1101
1276
  React__default["default"].createElement(index$1.Text, { size: "p3", className: classes.description }, t('lead.otp.desc', { phone: displayPhone }))),
1102
1277
  React__default["default"].createElement(index$2.Input, { ref: inputRef, name: '_' + name + '-otp', spellCheck: false, type: "number", placeholder: t('lead.otp.phonePlaceholder'), className: classes.control, label: t('lead.otp.phoneLabel'), "data-control": "otp", withAsterisk: true, pattern: "[0-9]*", value: otp, maxLength: 6, onChange: (v) => {
1103
1278
  setIsDirty(true);
@@ -1108,10 +1283,10 @@ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, st
1108
1283
  setErrorMsg(undefined);
1109
1284
  }, error: isDirty ? errorMsg : undefined }),
1110
1285
  React__default["default"].createElement("div", { className: classes.actions },
1111
- React__default["default"].createElement(index$5.Button, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1286
+ React__default["default"].createElement(index$3.Button, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1112
1287
  // onClick={() => submitOtp()}
1113
1288
  disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
1114
- React__default["default"].createElement(index$5.Button, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1289
+ React__default["default"].createElement(index$3.Button, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1115
1290
  sendOtp();
1116
1291
  }, disabled: !!resendTimer }, t('lead.otp.resend', {
1117
1292
  timer: resendTimer ? ` (${resendTimer}s)` : '',
@@ -1154,6 +1329,7 @@ var enPH = {
1154
1329
  "validator.min": "jQuery.validator.format('Please enter a value greater than or equal to {0}.",
1155
1330
  "validator.emailUsed": "Email already in use for this campaign.",
1156
1331
  "validator.phoneUsed": "Your phone number already in use for this campaign.",
1332
+ "validator.dateInvalid": "This date is not valid, please update.",
1157
1333
  "lead.otp.title": "Enter OTP",
1158
1334
  "lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
1159
1335
  "lead.otp.verify": "Verify",
@@ -1162,7 +1338,10 @@ var enPH = {
1162
1338
  "lead.otp.phonePlaceholder": "Enter OTP",
1163
1339
  "lead.empty.title": "Oops, seem your information is empty, do you want to submit the information again?",
1164
1340
  "lead.empty.cancel": "Cancel",
1165
- "lead.empty.submitAgain": "Submit again"
1341
+ "lead.empty.submitAgain": "Submit again",
1342
+ "common.day": "Day",
1343
+ "common.month": "Month",
1344
+ "common.year": "Year"
1166
1345
  };
1167
1346
 
1168
1347
  var hiIN = {
@@ -1173,6 +1352,7 @@ var hiIN = {
1173
1352
  "validator.maxlength": "कृपया {0} अक्षर से अधिक दर्ज न करें",
1174
1353
  "validator.minlength": "कृपया कम से कम {0} अक्षर दर्ज करें",
1175
1354
  "validator.phone": "कृपया एक वैध संख्या दर्ज करें",
1355
+ "validator.dateInvalid": "यह तिथि मान्य नहीं है, कृपया अपडेट करें।",
1176
1356
  "validator.emailUsed": "Email already in use for this campaign.",
1177
1357
  "validator.phoneUsed": "Your phone number already in use for this campaign.",
1178
1358
  "lead.otp.title": "Enter OTP",
@@ -1181,7 +1361,10 @@ var hiIN = {
1181
1361
  "lead.otp.resend": "Resend OTP{timer}",
1182
1362
  "lead.empty.title": "ऊप्स! लगता है आपकी जानकारी खाली है। क्या आप जानकारी फिर से सबमिट करना चाहते हैं?",
1183
1363
  "lead.empty.cancel": "रद्द करें",
1184
- "lead.empty.submitAgain": "फिर से सबमिट करें"
1364
+ "lead.empty.submitAgain": "फिर से सबमिट करें",
1365
+ "common.day": "साल",
1366
+ "common.month": "महीना",
1367
+ "common.year": ""
1185
1368
  };
1186
1369
 
1187
1370
  var idID = {
@@ -1194,6 +1377,7 @@ var idID = {
1194
1377
  "validator.phone": "Tolong daftarkan nomor telepon yang valid",
1195
1378
  "validator.emailUsed": "Email sudah digunakan untuk kampanye ini.",
1196
1379
  "validator.phoneUsed": "Nomor telepon Anda sudah digunakan untuk kampanye ini.",
1380
+ "validator.dateInvalid": "Tanggal ini tidak valid, silakan perbarui",
1197
1381
  "lead.otp.title": "Masukkan OTP",
1198
1382
  "lead.otp.desc": "Kami telah mengirimkan OTP ke nomor ponsel Anda {phone}",
1199
1383
  "lead.otp.verify": "Verifikasi",
@@ -1202,7 +1386,10 @@ var idID = {
1202
1386
  "lead.otp.phonePlaceholder": "Masukkan OTP",
1203
1387
  "lead.empty.title": "Oops, sepertinya informasi Anda kosong. Apakah Anda ingin mengirimkan informasi lagi?",
1204
1388
  "lead.empty.cancel": "Batal",
1205
- "lead.empty.submitAgain": "Kirim lagi"
1389
+ "lead.empty.submitAgain": "Kirim lagi",
1390
+ "common.day": "Hari",
1391
+ "common.month": "Bulan",
1392
+ "common.year": "Tahun"
1206
1393
  };
1207
1394
 
1208
1395
  var kmKH = {
@@ -1215,6 +1402,7 @@ var kmKH = {
1215
1402
  "validator.phone": "សូម​វាយបញ្ចូល​លេខ​ឲ្យ​បាន​ត្រឹមត្រូវ",
1216
1403
  "validator.emailUsed": "អ៊ីមែលត្រូវបានប្រើប្រាស់សម្រាប់យុទ្ធនាការនេះរួចហើយ។",
1217
1404
  "validator.phoneUsed": "លេខទូរស័ព្ទរបស់អ្នកត្រូវបានប្រើប្រាស់សម្រាប់យុទ្ធនាការនេះរួចហើយ។",
1405
+ "validator.dateInvalid": "កាលបរិច្ឆេទនេះមិនត្រឹមត្រូវទេ សូមធ្វើបច្ចុប្បន្នភាព។",
1218
1406
  "lead.otp.title": "បញ្ចូល OTP",
1219
1407
  "lead.otp.desc": "យើងបានផ្ញើ OTP ទៅកាន់លេខទូរសព្ទរបស់អ្នក {phone}",
1220
1408
  "lead.otp.verify": "ផ្ទៀងផ្ទាត់",
@@ -1223,7 +1411,10 @@ var kmKH = {
1223
1411
  "lead.otp.phonePlaceholder": "បញ្ចូល OTP",
1224
1412
  "lead.empty.title": "អូុបស! ហាក់ដូចជាព័ត៌មានរបស់អ្នកទទេ។ តើអ្នកចង់ដាក់ស្នើព័ត៌មានម្តងទៀតទេ?",
1225
1413
  "lead.empty.cancel": "លុប​ចោល",
1226
- "lead.empty.submitAgain": "ដាក់ស្នើម្ដងទៀត"
1414
+ "lead.empty.submitAgain": "ដាក់ស្នើម្ដងទៀត",
1415
+ "common.day": "ឆ្នាំ",
1416
+ "common.month": "ខែ",
1417
+ "common.year": "ថ្ងៃ"
1227
1418
  };
1228
1419
 
1229
1420
  var msMY = {
@@ -1236,6 +1427,7 @@ var msMY = {
1236
1427
  "validator.phone": "Sila masukkan no telefon yang sah.",
1237
1428
  "validator.emailUsed": "Emel sudah digunakan untuk kempen ini.",
1238
1429
  "validator.phoneUsed": "Nombor telefon anda sudah digunakan untuk kempen ini.",
1430
+ "validator.dateInvalid": "Tarikh ini tidak sah, sila kemas kini",
1239
1431
  "lead.otp.title": "Masukkan OTP",
1240
1432
  "lead.otp.desc": "Kami telah menghantar OTP ke nombor telefon bimbit anda {phone}",
1241
1433
  "lead.otp.verify": "Sahkan",
@@ -1244,7 +1436,10 @@ var msMY = {
1244
1436
  "lead.otp.phonePlaceholder": "Masukkan OTP",
1245
1437
  "lead.empty.title": "Oops, nampaknya maklumat anda kosong. Adakah anda ingin menghantar maklumat semula?",
1246
1438
  "lead.empty.cancel": "Batal",
1247
- "lead.empty.submitAgain": "Hantar semula"
1439
+ "lead.empty.submitAgain": "Hantar semula",
1440
+ "common.day": "Hari",
1441
+ "common.month": "Bulan",
1442
+ "common.year": "Tahun"
1248
1443
  };
1249
1444
 
1250
1445
  var myMM = {
@@ -1257,6 +1452,7 @@ var myMM = {
1257
1452
  "validator.phone": "မှန်ကန်သော ဖုန်းနံပါတ်ထည့်သွင်းပါ",
1258
1453
  "validator.emailUsed": "ဤအေကာင့်အတွက် အီးမေးလ်ကို အသုံးပြုပြီးဖြစ်ပါသည်။",
1259
1454
  "validator.phoneUsed": "ဤအေကာင့်အတွက် သင့်ဖုန်းနံပါတ်ကို အသုံးပြုပြီးဖြစ်ပါသည်။",
1455
+ "validator.dateInvalid": "ယနေ့စွဲမှားနေသည်၊ ကျေးဇူးပြု၍ ပြင်ဆင်ပါ။",
1260
1456
  "lead.otp.title": "OTP ကိုထည့်ပါ",
1261
1457
  "lead.otp.desc": "ကျွန်ုပ်တို့သည် OTP ကိုသင့်ဖုန်းနံပါတ် {phone} သို့ပို့ခဲ့သည်",
1262
1458
  "lead.otp.verify": "အတည်ပြုပါ",
@@ -1265,7 +1461,10 @@ var myMM = {
1265
1461
  "lead.otp.phonePlaceholder": "OTP ကိုထည့်ပါ",
1266
1462
  "lead.empty.title": "အုပ်စ်! သင့်အချက်အလက်သည် ဗလာဖြစ်နေသလိုဖြစ်သည်။ ထပ်မံတင်သွင်းလိုပါသလား?",
1267
1463
  "lead.empty.cancel": "မလုပ်ဆောင်ပါ",
1268
- "lead.empty.submitAgain": "ထပ်မံတင်သွင်းပါ"
1464
+ "lead.empty.submitAgain": "ထပ်မံတင်သွင်းပါ",
1465
+ "common.day": "ရက်",
1466
+ "common.month": "လ",
1467
+ "common.year": "နှစ်"
1269
1468
  };
1270
1469
 
1271
1470
  var thTH = {
@@ -1278,6 +1477,7 @@ var thTH = {
1278
1477
  "validator.phone": "กรุณาใส่ตัวเลขที่ถูกต้อง",
1279
1478
  "validator.emailUsed": "อีเมลนี้ถูกใช้สำหรับแคมเปญนี้แล้ว",
1280
1479
  "validator.phoneUsed": "หมายเลขโทรศัพท์ของคุณถูกใช้สำหรับแคมเปญนี้แล้ว",
1480
+ "validator.dateInvalid": "วันที่นี้ไม่ถูกต้อง โปรดอัปเดต",
1281
1481
  "lead.otp.title": "ป้อน OTP",
1282
1482
  "lead.otp.desc": "เราได้ส่ง OTP ไปยังหมายเลขโทรศัพท์มือถือของคุณ {phone}",
1283
1483
  "lead.otp.verify": "ยืนยัน",
@@ -1286,7 +1486,10 @@ var thTH = {
1286
1486
  "lead.otp.phonePlaceholder": "ป้อน OTP",
1287
1487
  "lead.empty.title": "อุ๊ปส์! ดูเหมือนว่าข้อมูลของคุณว่างเปล่า คุณต้องการส่งข้อมูลอีกครั้งหรือไม่?",
1288
1488
  "lead.empty.cancel": "ยกเลิก",
1289
- "lead.empty.submitAgain": "ส่งอีกครั้ง"
1489
+ "lead.empty.submitAgain": "ส่งอีกครั้ง",
1490
+ "common.day": "วัน",
1491
+ "common.month": "เดือน",
1492
+ "common.year": "ปี"
1290
1493
  };
1291
1494
 
1292
1495
  var viVN = {
@@ -1310,6 +1513,7 @@ var viVN = {
1310
1513
  "validator.phone": "Nhập đúng định dạng số điện thoại",
1311
1514
  "validator.emailUsed": "Email này đã được sử dụng.",
1312
1515
  "validator.phoneUsed": "Số điện thoại này đã được sử dụng.",
1516
+ "validator.dateInvalid": "Ngày này không hợp lệ, vui lòng cập nhật.",
1313
1517
  "lead.otp.title": "Nhập OTP",
1314
1518
  "lead.otp.desc": "Chúng tôi đã gửi OTP đến số điện thoại của bạn {phone}",
1315
1519
  "lead.otp.verify": "Xác minh",
@@ -1318,7 +1522,10 @@ var viVN = {
1318
1522
  "lead.otp.phonePlaceholder": "Nhập OTP",
1319
1523
  "lead.empty.title": "Oops, có vẻ như thông tin của bạn đang trống. Bạn có muốn gửi lại thông tin không?",
1320
1524
  "lead.empty.cancel": "Hủy",
1321
- "lead.empty.submitAgain": "Gửi lại"
1525
+ "lead.empty.submitAgain": "Gửi lại",
1526
+ "common.day": "Ngày",
1527
+ "common.month": "Tháng",
1528
+ "common.year": "Năm"
1322
1529
  };
1323
1530
 
1324
1531
  var zhTW = {
@@ -1331,6 +1538,7 @@ var zhTW = {
1331
1538
  "validator.phone": "請填入有效的電話號碼",
1332
1539
  "validator.emailUsed": "此電子郵件已被使用於此活動。",
1333
1540
  "validator.phoneUsed": "您的手機號碼已被使用於此活動。",
1541
+ "validator.dateInvalid": "此日期無效,請更新.",
1334
1542
  "lead.otp.title": "輸入 OTP",
1335
1543
  "lead.otp.desc": "我們已將 OTP 發送到您的手機號碼 {phone}",
1336
1544
  "lead.otp.verify": "驗證",
@@ -1339,7 +1547,10 @@ var zhTW = {
1339
1547
  "lead.otp.phonePlaceholder": "輸入 OTP",
1340
1548
  "lead.empty.title": "哎呀,您的資訊似乎是空的,您想要重新提交資訊嗎?",
1341
1549
  "lead.empty.cancel": "取消",
1342
- "lead.empty.submitAgain": "重新提交"
1550
+ "lead.empty.submitAgain": "重新提交",
1551
+ "common.day": "日",
1552
+ "common.month": "月",
1553
+ "common.year": "年"
1343
1554
  };
1344
1555
 
1345
1556
  const translationsMap = {
@@ -1351,159 +1562,1684 @@ const translationsMap = {
1351
1562
  'my-MM': myMM,
1352
1563
  'km-KH': kmKH,
1353
1564
  'zh-TW': zhTW,
1565
+ 'zh-CN': zhTW,
1354
1566
  'th-TH': thTH,
1355
1567
  'tl-PH': enPH,
1356
1568
  };
1357
1569
  const getTranslations = (locale) => {
1358
- const translations = translationsMap[locale];
1570
+ const translations = Object.assign(Object.assign({}, translationsProvider.translationsMap[locale]), translationsMap[locale]);
1359
1571
  if (translations) {
1360
1572
  return translations;
1361
1573
  }
1362
1574
  return translationsMap['en-PH'];
1363
1575
  };
1364
1576
 
1365
- const LeadGenContext = React.createContext({});
1366
-
1367
- const useImageSize = (src) => {
1368
- const [width, setWidth] = React.useState(16);
1369
- const [height, setHeight] = React.useState(9);
1370
- const [loaded, setLoaded] = React.useState(false);
1371
- // load src image to get its width and height
1372
- React.useEffect(() => {
1373
- setLoaded(false);
1374
- if (src) {
1375
- const img = new Image();
1376
- img.addEventListener('load', () => {
1377
- setWidth(img.naturalWidth);
1378
- setHeight(img.naturalHeight);
1379
- setLoaded(true);
1380
- });
1381
- img.addEventListener('error', () => {
1382
- setWidth(16);
1383
- setHeight(9);
1384
- setLoaded(true);
1385
- });
1386
- img.src = src;
1387
- }
1388
- else {
1389
- setWidth(16);
1390
- setHeight(9);
1391
- setLoaded(true);
1392
- }
1393
- }, [src]);
1394
- return {
1395
- loaded,
1396
- width,
1397
- height,
1398
- };
1399
- };
1400
-
1401
- const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default["default"].createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
1402
- React__default["default"].createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
1403
- React__default["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" }))));
1404
-
1405
- // url: imageBlocks.imageMobile.data.url
1406
- // newTab: imageBlocks.imageMobile.data.newtab
1407
- // imageMobile: campaignShow.image
1408
- // imageDestkop: campaignShow.image_desktop
1409
- const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
1410
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1411
- const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
1412
- if (!imageMobileLoaded || !imageDestkopLoaded)
1413
- return null;
1414
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
1415
- React__default["default"].createElement("div", { className: "le-center-tab-popup" },
1416
- React__default["default"].createElement("div", { style: { position: 'relative' } },
1417
- React__default["default"].createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
1418
- index$7.isVideo(imageMobile) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
1419
- React__default["default"].createElement("source", { src: imageMobile }))) : (React__default["default"].createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
1420
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1421
- } })),
1422
- index$7.isVideo(imageDestkop) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
1423
- React__default["default"].createElement("source", { src: imageDestkop }))) : (React__default["default"].createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
1424
- aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
1425
- } }))),
1426
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
1427
- };
1428
-
1429
- // title: titleText
1430
- // titleAlign: textBlocks.titleBlock.data.align
1431
- // subtitle: textBlocks.subtitleBlock.data.value
1432
- // subtitleAlign: textBlocks.subtitleBlock.data.align
1433
- // url: actionBlocks.linkButtonBlock.data.url
1434
- // urlText: actionBlocks.linkButtonBlock.data.value
1435
- // newTab: actionBlocks.linkButtonBlock.data.newtab
1436
- // imageMobile: campaignShow.image
1437
- // imageDesktop: campaignShow.image_desktop
1438
- const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
1439
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1440
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
1441
- if (!imageMobileLoaded || !imageDesktopLoaded)
1442
- return null;
1443
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
1444
- React__default["default"].createElement("aside", { className: "le-only-desktop" },
1445
- React__default["default"].createElement("div", { className: "le-floating-desktop" },
1446
- React__default["default"].createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
1447
- imageDesktop ? (React__default["default"].createElement("div", null,
1448
- React__default["default"].createElement("img", { style: {
1449
- maxWidth: 120,
1450
- borderTopLeftRadius: 5,
1451
- borderBottomLeftRadius: 5,
1452
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
1453
- }, src: imageDesktop }))) : null,
1454
- React__default["default"].createElement("div", { style: { padding: 20 } },
1455
- React__default["default"].createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
1456
- React__default["default"].createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
1457
- React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
1458
- React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
1459
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
1460
- React__default["default"].createElement("aside", { className: "le-only-mobile" },
1461
- React__default["default"].createElement("div", { className: "le-floating-mobile" },
1462
- React__default["default"].createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
1463
- React__default["default"].createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
1464
- React__default["default"].createElement("div", null,
1465
- React__default["default"].createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
1466
- React__default["default"].createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
1467
- imageMobile ? (React__default["default"].createElement("div", null,
1468
- React__default["default"].createElement("img", { style: {
1469
- marginLeft: 15,
1470
- marginTop: 4,
1471
- maxWidth: 100,
1472
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1473
- }, src: imageMobile }))) : null),
1474
- React__default["default"].createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
1475
- React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
1476
- React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
1477
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
1577
+ const LeadGenTranslationProvider = (props) => {
1578
+ const { locale, children } = props;
1579
+ const translationContextValue = React.useMemo(() => ({ locale, values: getTranslations(locale) }), [locale]);
1580
+ return (React__default["default"].createElement(translationsContext.TranslationsContext.Provider, { value: translationContextValue }, children));
1478
1581
  };
1479
1582
 
1480
- const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
1481
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
1482
- if (!imageLoaded)
1583
+ // import mockLeadData from './mockLeadData'
1584
+ const listCampaignScheduled = [];
1585
+ const listCampaignScheduledToActivated = [];
1586
+ const listCampaignActiveButExpired = [];
1587
+ const listCampaignExcludeSonsored = [];
1588
+ const listCampaignDifferentSponsor = [];
1589
+ const listCampaignNotDisplayInRangeOfTime = [];
1590
+ function isMobile() {
1591
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
1592
+ }
1593
+ const getShuffleArray = (array) => {
1594
+ const newArray = [...array];
1595
+ for (let i = newArray.length - 1; i > 0; i--) {
1596
+ const j = Math.floor(Math.random() * (i + 1));
1597
+ const temp = newArray[i];
1598
+ newArray[i] = newArray[j];
1599
+ newArray[j] = temp;
1600
+ }
1601
+ return newArray;
1602
+ };
1603
+ const getTimeByTimezone = (timeZone = 'UTC') => {
1604
+ const date = new Date();
1605
+ return new Date(date.toLocaleString('en-US', { timeZone }));
1606
+ };
1607
+ const parseDateByCampaignTime = (dateStr) => {
1608
+ // Format like this: 2023-04-04 00:00:00
1609
+ try {
1610
+ const [datePart, timePart] = dateStr.split(' ');
1611
+ const [year, month, day] = datePart.split('-').map(Number);
1612
+ const [hours, minutes, seconds] = timePart.split(':').map(Number);
1613
+ /** JavaScript counts months from 0 to 11 */
1614
+ return new Date(year, month - 1, day, hours, minutes, seconds);
1615
+ }
1616
+ catch (err) {
1483
1617
  return null;
1484
- return (React__default["default"].createElement("div", { className: "lead-modal__thank-you leadgen-inner_thankyou" },
1485
- React__default["default"].createElement("div", { style: { width: '100%' } },
1486
- React__default["default"].createElement("img", { src: image, style: {
1487
- maxHeight: 162,
1488
- objectFit: 'cover',
1489
- aspectRatio: `${imageWidth}/${imageHeight}`,
1490
- }, loading: "lazy" }),
1491
- title && (React__default["default"].createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
1492
- subtitle && (React__default["default"].createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle.split('\n').map((text, idx, list) => {
1493
- const isShowBr = idx < list.length - 1;
1494
- return (React__default["default"].createElement(React__default["default"].Fragment, null,
1495
- text,
1496
- isShowBr && React__default["default"].createElement("br", null)));
1497
- }))),
1498
- linkText && (React__default["default"].createElement("div", null,
1499
- React__default["default"].createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
1500
- React__default["default"].createElement("button", { className: `lead-modal__btn ${LEAD_CLASS}` }, linkText)))))));
1501
- };
1502
-
1503
- const InlineLayout = ({ content, inlinePosition, }) => {
1504
- const target = React.useMemo(() => {
1505
- if (!inlinePosition)
1506
- return null;
1618
+ }
1619
+ };
1620
+ const checkCampaignNowInTimeframe = (c) => {
1621
+ var _a;
1622
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1623
+ const startedAtStr = c.started_at;
1624
+ const endedAtStr = c.ended_at;
1625
+ const startedDate = parseDateByCampaignTime(startedAtStr);
1626
+ const endedDate = parseDateByCampaignTime(endedAtStr);
1627
+ if (!startedDate || !endedDate) {
1628
+ return false;
1629
+ }
1630
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
1631
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1632
+ if (nowWithTimezoneMs <= endedDate.getTime() &&
1633
+ nowWithTimezoneMs >= startedDate.getTime()) {
1634
+ listCampaignScheduledToActivated.push(c);
1635
+ return true;
1636
+ }
1637
+ return false;
1638
+ };
1639
+ function checkCampaignActiveButExpireAlready(c) {
1640
+ var _a;
1641
+ /** Do not setup timeframe for this campaign. No need to check */
1642
+ if (c.forever === 1) {
1643
+ return true;
1644
+ }
1645
+ const startedAtStr = c.started_at;
1646
+ const endedAtStr = c.ended_at;
1647
+ const startedDate = parseDateByCampaignTime(startedAtStr);
1648
+ const endedDate = parseDateByCampaignTime(endedAtStr);
1649
+ /** Do not setup timeframe for this campaign. No need to check */
1650
+ if (!startedDate || !endedDate) {
1651
+ return true;
1652
+ }
1653
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1654
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
1655
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1656
+ /** Check if this expire already, do not show */
1657
+ if (nowWithTimezoneMs > endedDate.getTime()) {
1658
+ listCampaignActiveButExpired.push(c);
1659
+ return false;
1660
+ }
1661
+ return true;
1662
+ }
1663
+ function shouldNotDisplayIfExcludeAllSponsors(c) {
1664
+ var _a;
1665
+ const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
1666
+ const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
1667
+ if (isSponsored && excludeSponsored) {
1668
+ listCampaignExcludeSonsored.push(c);
1669
+ return true;
1670
+ }
1671
+ return false;
1672
+ }
1673
+ function shouldDisplayWithCurrentSponsor(c) {
1674
+ var _a, _b;
1675
+ try {
1676
+ // TODO: BE will rename `exclude_sponsored_list` later
1677
+ const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
1678
+ const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
1679
+ const dataSponsoredId = Number((_b = document
1680
+ .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
1681
+ // There is no config for sponsor id and white list, should show as default
1682
+ if (!dataSponsoredId ||
1683
+ dataSponsoredId <= 0 ||
1684
+ whiteListSponsors.length === 0) {
1685
+ return true;
1686
+ }
1687
+ // Check the dataSponsoredId exists in the white list or not.
1688
+ const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
1689
+ if (isExist) {
1690
+ return true;
1691
+ }
1692
+ listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
1693
+ return false;
1694
+ }
1695
+ catch (err) {
1696
+ // Default is show
1697
+ return true;
1698
+ }
1699
+ }
1700
+ const filterFnCampaign = (c) => {
1701
+ if (shouldNotDisplayIfExcludeAllSponsors(c)) {
1702
+ return false;
1703
+ }
1704
+ else if (!shouldDisplayWithCurrentSponsor(c)) {
1705
+ return false;
1706
+ }
1707
+ /** Active */
1708
+ if (c.formatted_status === 1) {
1709
+ return checkCampaignActiveButExpireAlready(c);
1710
+ }
1711
+ /** Schedule */
1712
+ if (c.formatted_status === 0) {
1713
+ listCampaignScheduled.push(c);
1714
+ return checkCampaignNowInTimeframe(c);
1715
+ }
1716
+ return false;
1717
+ };
1718
+ const fillterApprearanceTimeCampaign = (c) => {
1719
+ var _a;
1720
+ try {
1721
+ const isTimeInRange = (currentTime, startTime, endTime) => {
1722
+ const startParts = startTime.split(':');
1723
+ const endParts = endTime.split(':');
1724
+ const startDate = new Date();
1725
+ startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
1726
+ const endDate = new Date();
1727
+ endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
1728
+ return currentTime >= startDate && currentTime <= endDate;
1729
+ };
1730
+ const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
1731
+ const startTime = rulesApprValue.startTime;
1732
+ const endTime = rulesApprValue.endTime || '23:59';
1733
+ if (!startTime) {
1734
+ return true;
1735
+ }
1736
+ if (isTimeInRange(new Date(), startTime, endTime)) {
1737
+ return true;
1738
+ }
1739
+ listCampaignNotDisplayInRangeOfTime.push(c);
1740
+ return false;
1741
+ }
1742
+ catch (err) {
1743
+ return true;
1744
+ }
1745
+ };
1746
+ let timeoutRef = null;
1747
+ let LEAD_SCROLL_EVENT = null;
1748
+ function clearPassiveEvent() {
1749
+ if (timeoutRef) {
1750
+ clearTimeout(timeoutRef);
1751
+ timeoutRef = null;
1752
+ }
1753
+ if (LEAD_SCROLL_EVENT) {
1754
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1755
+ LEAD_SCROLL_EVENT = null;
1756
+ }
1757
+ }
1758
+ function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
1759
+ // clear previous passive event, check for new condition
1760
+ clearPassiveEvent();
1761
+ const leadCurrentUrl = DEBUG_URL ||
1762
+ ('https://' +
1763
+ location.hostname +
1764
+ location.pathname +
1765
+ location.search).toLowerCase();
1766
+ fetch(leadApi + 'api/campaign/' + leadSiteId, {
1767
+ method: 'POST',
1768
+ headers: {
1769
+ 'Content-Type': 'application/json',
1770
+ },
1771
+ body: JSON.stringify({
1772
+ url: leadCurrentUrl,
1773
+ ga_client_id: miscCookieHelper.getCookie('_ga') || null,
1774
+ }),
1775
+ })
1776
+ .then((response) => {
1777
+ return response.json();
1778
+ // return mockLeadData || response.json()
1779
+ })
1780
+ .then((data) => {
1781
+ var _a, _b, _c, _d;
1782
+ LeadLog('List campagin: ', data);
1783
+ LEAD_RESET_VAR();
1784
+ if (data._status == 1) {
1785
+ 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);
1786
+ if (!miscCookieHelper.getCookie('hhg-id')) {
1787
+ miscCookieHelper.setCookie('hhg-id', uuid.v1(), {
1788
+ domain: '.' + leadDomain,
1789
+ path: '/',
1790
+ });
1791
+ LeadLog('😍 Set HHG ID cookie');
1792
+ }
1793
+ // getCookie('hhg-id')
1794
+ // TODO: HP-534 Filter desktop
1795
+ let campaignsDevice = [];
1796
+ if (isMobile()) {
1797
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
1798
+ }
1799
+ else {
1800
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
1801
+ }
1802
+ LeadLog(`👓 campaignsDevice`, campaignsDevice);
1803
+ LeadLog('--listCampaignScheduled', listCampaignScheduled);
1804
+ LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
1805
+ LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
1806
+ LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
1807
+ LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
1808
+ LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
1809
+ // Check links
1810
+ let listLinksObj = campaignsDevice
1811
+ .map((i, index) => i.targets
1812
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
1813
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1814
+ .flat(1);
1815
+ // Check list link match current href
1816
+ listLinksObj = listLinksObj.filter((i) => {
1817
+ var _a;
1818
+ const target = new URL(String(i.target).toLowerCase());
1819
+ if (i.option == 'exact_match')
1820
+ // FOR TEST LOCAL:
1821
+ // return Boolean(location.pathname === target.pathname)
1822
+ return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
1823
+ if (i.option == 'start_with') {
1824
+ // FOR TEST LOCAL:
1825
+ // if (location.pathname.includes(target.pathname)) {
1826
+ if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
1827
+ const listExcluding = i.sub_target
1828
+ .filter((i) => i.option == 'excluding')
1829
+ .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
1830
+ return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
1831
+ }
1832
+ else {
1833
+ return false;
1834
+ }
1835
+ }
1836
+ });
1837
+ // Check tags
1838
+ const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
1839
+ const listTags = listMetaTag.map((i) => i.content);
1840
+ let listCampaignHasTag = [];
1841
+ let listTagsObj = [];
1842
+ if (listTags && listTags.length) {
1843
+ listCampaignHasTag = campaignsDevice
1844
+ .map((i, index) => i.targets
1845
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
1846
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1847
+ .flat(1);
1848
+ listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
1849
+ }
1850
+ const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
1851
+ const cookieKeys = document.cookie
1852
+ .split('; ')
1853
+ .map((i) => i.split('=')[0]);
1854
+ const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
1855
+ LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
1856
+ const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
1857
+ LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
1858
+ const listCampaignSubmitedClosed = [
1859
+ ...listCampaignCodeSubmited,
1860
+ ...listCampaignCodeClosed,
1861
+ ];
1862
+ const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
1863
+ const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
1864
+ return !hasSubmited;
1865
+ });
1866
+ const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
1867
+ // .sort(
1868
+ // (a, b) =>
1869
+ // (listCampaignValid[a.campaignIndex]?.score || 0) -
1870
+ // (listCampaignValid[b.campaignIndex]?.score || 0),
1871
+ // )
1872
+ LeadLog('--listCampaignValid : ', listCampaignValid);
1873
+ if (listCampaignValid && listCampaignValid.length) {
1874
+ const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
1875
+ LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
1876
+ const { rules } = CAMPAIGN_SHOW;
1877
+ // CHECK RULE TRIGGER POPUP
1878
+ const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
1879
+ LeadLog(`timeoutRule`, timeoutRule);
1880
+ const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
1881
+ LeadLog(`scrollRule`, scrollRule);
1882
+ let impressionAction = 'TIME';
1883
+ if (Number.isInteger(timeoutRule)) {
1884
+ impressionAction = 'TIME';
1885
+ LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
1886
+ timeoutRef = setTimeout(() => {
1887
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1888
+ }, timeoutRule * 1000);
1889
+ }
1890
+ if (Number.isInteger(scrollRule)) {
1891
+ impressionAction = 'SCROLL';
1892
+ LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
1893
+ const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
1894
+ document.querySelector('body');
1895
+ const pct = $p.getBoundingClientRect().top;
1896
+ const pb = $p.offsetHeight;
1897
+ LeadLog(`👓 Element check scroll: `, $p);
1898
+ LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
1899
+ const wt = window.pageYOffset || document.documentElement.scrollTop;
1900
+ let percent = 0;
1901
+ if (wt >= pct) {
1902
+ percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
1903
+ }
1904
+ LeadLog('---Scroll', percent, scrollRule);
1905
+ // TODO: CHECK FOOTER HEIGHT
1906
+ if (percent >= scrollRule) {
1907
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1908
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1909
+ }
1910
+ };
1911
+ window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
1912
+ passive: true,
1913
+ });
1914
+ }
1915
+ }
1916
+ else {
1917
+ LeadLog('🚧 No lead campaigns on current URL, tags');
1918
+ }
1919
+ }
1920
+ })
1921
+ .catch((err) => {
1922
+ LeadLog(`Lead error: `, err);
1923
+ });
1924
+ }
1925
+ const LeadLog = (...params) => {
1926
+ if (process.env.NODE_ENV !== 'production' ||
1927
+ (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
1928
+ process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
1929
+ (typeof localStorage !== 'undefined' &&
1930
+ localStorage.getItem('hhg_debug') === 'true')) {
1931
+ console.log(...params);
1932
+ }
1933
+ };
1934
+
1935
+ const LeadGenContext = React.createContext({
1936
+ submit(value) {
1937
+ /** Init for FAKING function */
1938
+ LeadLog('** LeadGen Submit : ', value);
1939
+ return Promise.reject(value);
1940
+ },
1941
+ submitSubscriptionBox(value) {
1942
+ /** Init for FAKING function */
1943
+ LeadLog('** LeadGen SubmitSubscriptionBox : ', value);
1944
+ return Promise.reject(value);
1945
+ },
1946
+ impression(value) {
1947
+ /** Init for FAKING function */
1948
+ LeadLog('** LeadGen Impression : ', value);
1949
+ return Promise.reject(value);
1950
+ },
1951
+ /** For Subscription Box */
1952
+ subscriptionIcon: '',
1953
+ subscriptionTitle: '',
1954
+ });
1955
+ const LeadGenContextProvider = (props) => {
1956
+ const { campaign_code: campaignCodeProps, apiSsoUrl, apiLeadUrl, apiSubotUrl, locale: localeProps, forceCampaign: forceCampaignProps, extraValues, articleId = 1, categoryId = 1, siteDomain: site_domain, children, } = props;
1957
+ const [forceCampaign, setForceCampaign] = React.useState(forceCampaignProps);
1958
+ const [subscriptionInfo, setSubscriptionInfo] = React.useState({
1959
+ subscriptionIcon: '',
1960
+ subscriptionTitle: '',
1961
+ });
1962
+ const locale = React.useMemo(() => {
1963
+ return localeProps || Locale.LOCALE['PhilippinesEnglish'];
1964
+ }, [localeProps]);
1965
+ const leadGenContextValue = React.useMemo(() => (Object.assign(Object.assign({}, props), { forceCampaign })), [...Object.values(props), forceCampaign]);
1966
+ const { url, campaign_id, campaign_code, cookie_id, ga_client_id, category_id, article_id, article_title, } = React.useMemo(() => ({
1967
+ url: location.href.toLowerCase() || '',
1968
+ cookie_id: miscCookieHelper.getCookie('hhg-id') || null,
1969
+ ga_client_id: miscCookieHelper.getCookie('_ga'),
1970
+ campaign_id: forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id,
1971
+ campaign_code: campaignCodeProps || (forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.code),
1972
+ category_id: categoryId,
1973
+ article_id: articleId,
1974
+ article_title: document.title || '',
1975
+ }), [campaignCodeProps, articleId, categoryId, forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id]);
1976
+ const fetchCampaign = React.useCallback((campaign_code) => {
1977
+ Service.getCampaignByCode(campaign_code).then((res) => {
1978
+ const { _data } = res || {};
1979
+ const { campaigns } = _data || {};
1980
+ LeadLog('** LeadGen Campaign : ', campaigns);
1981
+ setForceCampaign(formatCampaignDetail(campaigns));
1982
+ });
1983
+ }, [campaignCodeProps]);
1984
+ // TODO : Update form for LeadGen
1985
+ const submit = React.useCallback((data) => {
1986
+ return Service.postSubscriptionBoxLead({ data });
1987
+ }, []);
1988
+ const submitSubscriptionBox = React.useCallback((value) => {
1989
+ const data = Object.assign(Object.assign(Object.assign(Object.assign({}, value), { campaign_id,
1990
+ 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,
1991
+ category_id, article_title: (extraValues === null || extraValues === void 0 ? void 0 : extraValues.article_title) || article_title });
1992
+ return Service.postSubscriptionBoxLead({ data });
1993
+ }, [
1994
+ extraValues,
1995
+ site_domain,
1996
+ campaign_id,
1997
+ article_id,
1998
+ article_title,
1999
+ category_id,
2000
+ url,
2001
+ ga_client_id,
2002
+ ]);
2003
+ const impression = React.useCallback((value) => {
2004
+ return Service.campaignPostImpression({
2005
+ url: (value === null || value === void 0 ? void 0 : value.url) || url,
2006
+ action: (value === null || value === void 0 ? void 0 : value.action) || LEADGEN_ACTIONS.SCROLL,
2007
+ code: (value === null || value === void 0 ? void 0 : value.code) || campaign_code,
2008
+ title_article: (value === null || value === void 0 ? void 0 : value.title_article) || article_title,
2009
+ cookie_id: (value === null || value === void 0 ? void 0 : value.cookie_id) || cookie_id,
2010
+ ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id,
2011
+ extra: (value === null || value === void 0 ? void 0 : value.extra) || Object.assign({ cookie_id,
2012
+ article_id, subscription_title: subscriptionInfo.subscriptionTitle }, extraValues),
2013
+ referrer: value === null || value === void 0 ? void 0 : value.referrer,
2014
+ });
2015
+ }, [
2016
+ extraValues,
2017
+ campaign_id,
2018
+ url,
2019
+ campaign_code,
2020
+ article_title,
2021
+ cookie_id,
2022
+ ga_client_id,
2023
+ article_id,
2024
+ subscriptionInfo.subscriptionTitle,
2025
+ ]);
2026
+ React.useEffect(() => {
2027
+ if (forceCampaignProps) {
2028
+ setForceCampaign(forceCampaignProps);
2029
+ return;
2030
+ }
2031
+ /** For Subscription Box */
2032
+ if (categoryId) {
2033
+ Service.getSubscriptionBoxInfo({
2034
+ category: categoryId,
2035
+ site: site_domain,
2036
+ }).then((res) => {
2037
+ const { _data } = res || {};
2038
+ const { item, campaign_code } = _data || {};
2039
+ const { icon, content } = item || {};
2040
+ LeadLog('** LeadGen SubscriptionBox campaign_code : ', campaign_code);
2041
+ LeadLog('** LeadGen SubscriptionBox subscription_icon : ', icon);
2042
+ LeadLog('** LeadGen SubscriptionBox subscription_title : ', content);
2043
+ if (icon && content) {
2044
+ setSubscriptionInfo({
2045
+ subscriptionIcon: icon,
2046
+ subscriptionTitle: content,
2047
+ });
2048
+ }
2049
+ if (campaign_code) {
2050
+ fetchCampaign(campaign_code);
2051
+ }
2052
+ });
2053
+ return;
2054
+ }
2055
+ if (campaignCodeProps) {
2056
+ fetchCampaign(campaignCodeProps);
2057
+ }
2058
+ }, [campaignCodeProps, categoryId]);
2059
+ React.useEffect(() => {
2060
+ leadStore.apiSsoUrl = apiSsoUrl;
2061
+ leadStore.apiLeadUrl = apiLeadUrl;
2062
+ leadStore.apiSubotUrl = apiSubotUrl;
2063
+ }, [apiLeadUrl, apiSubotUrl, apiSsoUrl]);
2064
+ if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
2065
+ return null;
2066
+ }
2067
+ return (React__default["default"].createElement(LeadGenContext.Provider, { value: Object.assign(Object.assign(Object.assign({}, leadGenContextValue), subscriptionInfo), { submit,
2068
+ submitSubscriptionBox,
2069
+ impression }) },
2070
+ React__default["default"].createElement(LeadGenTranslationProvider, { locale: locale }, children)));
2071
+ };
2072
+ const useLeadGenContext = () => {
2073
+ const context = React.useContext(LeadGenContext);
2074
+ return Object.assign(Object.assign({}, context), { apiLeadUrl: context.apiLeadUrl || leadStore.apiLeadUrl, apiSubotUrl: context.apiSubotUrl || leadStore.apiSubotUrl });
2075
+ };
2076
+
2077
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
2078
+ const customParseFormat = require('dayjs/plugin/customParseFormat');
2079
+ dayjs__default["default"].extend(customParseFormat);
2080
+ // You can give context variables any name
2081
+ const [LeadFormProvider, useLeadFormContext, useLeadForm] = form.createFormContext();
2082
+ const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
2083
+ var _a;
2084
+ const { t } = index.useTranslations();
2085
+ const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
2086
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[(_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.lang] ||
2087
+ LEAD_LOCALE_DATA['vi-VN'];
2088
+ const validateObj = React.useMemo(() => {
2089
+ const InputBlocks = [
2090
+ 'TextBlock',
2091
+ 'NumberBlock',
2092
+ 'EmailBlock',
2093
+ 'PhoneBlock',
2094
+ 'DateBlock',
2095
+ 'CheckboxBlock',
2096
+ 'RadioBlock',
2097
+ 'DropdownBlock',
2098
+ 'PhoneOtpBlock',
2099
+ 'WhatsappOtpBlock',
2100
+ 'ZaloOtpBlock',
2101
+ 'LocationBlock',
2102
+ 'TncBlock',
2103
+ ];
2104
+ // ALL are required and can skip if not touched yet
2105
+ const withSharedCheck = (name, cb,
2106
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2107
+ block) => {
2108
+ return (value) => {
2109
+ var _a;
2110
+ const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
2111
+ if (!formRef.current.isTouched(name))
2112
+ return;
2113
+ if ((typeof value === 'string' && value.trim() === '') ||
2114
+ typeof value === 'undefined' ||
2115
+ (Array.isArray(value) && value.length === 0)) {
2116
+ return isBLockRequired
2117
+ ? t('validator.required')
2118
+ : cb === null || cb === void 0 ? void 0 : cb(value);
2119
+ }
2120
+ return cb === null || cb === void 0 ? void 0 : cb(value);
2121
+ };
2122
+ };
2123
+ return listBlockAdded
2124
+ .filter((b) => InputBlocks.includes(b.name))
2125
+ .reduce((r, b) => {
2126
+ const { name: fieldType, data } = b || {};
2127
+ const { value: fieldName, required } = data || {};
2128
+ const isRequired = required !== null && required !== void 0 ? required : true;
2129
+ if (fieldType === 'NumberBlock') {
2130
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2131
+ if (value && isNaN(Number(value))) {
2132
+ return t('validator.number');
2133
+ }
2134
+ }, b) });
2135
+ }
2136
+ else if (fieldType === 'EmailBlock') {
2137
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2138
+ if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
2139
+ return t('validator.email');
2140
+ }
2141
+ if (!value)
2142
+ return;
2143
+ validatingEmailRef.current = true;
2144
+ setTimeout(() => {
2145
+ formRef.current.setFieldError(fieldName, 'Validating...');
2146
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2147
+ email: value,
2148
+ })
2149
+ .then((tKey) => {
2150
+ if (tKey) {
2151
+ formRef.current.setFieldError(fieldName, t(tKey));
2152
+ }
2153
+ else {
2154
+ formRef.current.clearFieldError(fieldName);
2155
+ }
2156
+ validatingEmailRef.current = false;
2157
+ })
2158
+ .catch((e) => {
2159
+ console.error(e);
2160
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2161
+ validatingEmailRef.current = false;
2162
+ });
2163
+ }, 200);
2164
+ }, b) });
2165
+ }
2166
+ else if (fieldType === 'PhoneBlock' ||
2167
+ fieldType === 'PhoneOtpBlock' ||
2168
+ fieldType === 'ZaloOtpBlock' ||
2169
+ fieldType === 'WhatsappOtpBlock') {
2170
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2171
+ if (value &&
2172
+ window.intlTelInputUtils &&
2173
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
2174
+ return t('validator.phone');
2175
+ }
2176
+ if (!value)
2177
+ return;
2178
+ validatingPhoneRef.current = true;
2179
+ setTimeout(() => {
2180
+ formRef.current.setFieldError(fieldName, 'Validating...');
2181
+ if (b.data.singleSubmission) {
2182
+ checkUsedPhoneOnlyWithCache(campaignId, value)
2183
+ .then((tKey) => {
2184
+ if (tKey) {
2185
+ formRef.current.setFieldError(fieldName, t(tKey));
2186
+ }
2187
+ else {
2188
+ formRef.current.clearFieldError(fieldName);
2189
+ }
2190
+ validatingPhoneRef.current = false;
2191
+ })
2192
+ .catch((err) => {
2193
+ console.error(err);
2194
+ formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
2195
+ validatingPhoneRef.current = false;
2196
+ });
2197
+ }
2198
+ else {
2199
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2200
+ phone: value,
2201
+ })
2202
+ .then((tKey) => {
2203
+ if (tKey) {
2204
+ formRef.current.setFieldError(fieldName, t(tKey));
2205
+ }
2206
+ else {
2207
+ formRef.current.clearFieldError(fieldName);
2208
+ }
2209
+ validatingPhoneRef.current = false;
2210
+ })
2211
+ .catch((e) => {
2212
+ console.error(e);
2213
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2214
+ validatingPhoneRef.current = false;
2215
+ });
2216
+ }
2217
+ }, 200);
2218
+ }, b) });
2219
+ }
2220
+ else if (fieldType === 'DateBlock') {
2221
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2222
+ if (!isRequired && !value) {
2223
+ return;
2224
+ }
2225
+ const errMsg = t('validator.dateInvalid');
2226
+ const dayInJS = typeof value === 'string'
2227
+ ? dayjs__default["default"](value, format, true)
2228
+ : dayjs__default["default"](value);
2229
+ if (!dayInJS.isValid()) {
2230
+ return errMsg;
2231
+ }
2232
+ }, b) });
2233
+ }
2234
+ else if (fieldType === 'TncBlock') {
2235
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
2236
+ if (isRequired && !value) {
2237
+ return t('validator.required');
2238
+ }
2239
+ }, b) });
2240
+ }
2241
+ else {
2242
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
2243
+ }
2244
+ }, {});
2245
+ }, [listBlockAdded.map((b) => b.name).join(','), format]);
2246
+ const form = useLeadForm({
2247
+ validateInputOnChange: true,
2248
+ validateInputOnBlur: true,
2249
+ clearInputErrorOnChange: true,
2250
+ validate: validateObj,
2251
+ initialValues,
2252
+ });
2253
+ const formRef = React.useRef(form);
2254
+ formRef.current = form;
2255
+ return { form, validateObj };
2256
+ };
2257
+
2258
+ const StyledLeadGenThankYou = styled__default["default"].div `
2259
+ display: flex;
2260
+ gap: 8px;
2261
+ flex-direction: column;
2262
+ padding-block: 24px;
2263
+
2264
+ .leadgen-image {
2265
+ width: 120px;
2266
+ height: 120px;
2267
+ margin-inline: auto;
2268
+ object-fit: contain;
2269
+ object-position: center;
2270
+ text-align: center;
2271
+ }
2272
+
2273
+ .leadgen-title {
2274
+ margin-block: 0;
2275
+ color: ${miscTheme.theme.colors.gray900};
2276
+ font-weight: 700;
2277
+ font-size: 18px;
2278
+ line-height: 28px;
2279
+ letter-spacing: -0.2px;
2280
+ }
2281
+
2282
+ .leadgen-description {
2283
+ margin-block: 0;
2284
+ color: ${miscTheme.theme.colors.gray600};
2285
+ font-weight: 400;
2286
+ font-size: 14px;
2287
+ line-height: 22px;
2288
+ letter-spacing: -0.2px;
2289
+ text-align: center;
2290
+ }
2291
+
2292
+ > [data-align] {
2293
+ &[data-align='right'] {
2294
+ text-align: right;
2295
+ }
2296
+ &[data-align='center'] {
2297
+ text-align: center;
2298
+ }
2299
+ }
2300
+ `;
2301
+ const LeadGenThankYou = ({ image, title, description, showButton = false, button, className, style, }) => {
2302
+ const { src } = image;
2303
+ const { htmlText: titleText, align: titleAlign } = title;
2304
+ const { htmlText: descriptionText, align: descriptionAlign } = description;
2305
+ const { htmlText: buttonText, newtab, url, onClick } = button;
2306
+ return (React__default["default"].createElement(StyledLeadGenThankYou, { className: className, style: style },
2307
+ React__default["default"].createElement("img", { src: src, alt: "", className: "leadgen-thankyou_image leadgen-image" }),
2308
+ React__default["default"].createElement("p", { className: "leadgen-thankyou_title leadgen-title", "data-align": titleAlign }, titleText),
2309
+ React__default["default"].createElement("p", { className: "leadgen-thankyou_description leadgen-description", "data-align": descriptionAlign }, descriptionText),
2310
+ !!buttonText && showButton && (React__default["default"].createElement(core.Button, { component: url ? 'a' : 'button', target: newtab ? '_blank' : undefined, href: url, size: "lg", variant: "filled", className: "leadgen-thankyoue_btn leadgen-btn", onClick: onClick }, buttonText))));
2311
+ };
2312
+
2313
+ const StyledLeadGenSubscriptionBoxBody = styled__default["default"].div `
2314
+ margin-top: 16px;
2315
+ .leadgen-btn {
2316
+ margin-top: 16px;
2317
+ }
2318
+ `;
2319
+ const StyledLeadGenSubscriptionBoxHeaderImage = styled__default["default"].div `
2320
+ margin-top: 3px;
2321
+ margin-right: 20px;
2322
+ width: 44px;
2323
+ height: 44px;
2324
+
2325
+ img {
2326
+ width: 100%;
2327
+ height: 100%;
2328
+ object-fix: contain;
2329
+ onject-position: center;
2330
+ }
2331
+
2332
+ :has(img[src='']) {
2333
+ display: none;
2334
+ }
2335
+ `;
2336
+ const StyledLeadGenSubscriptionBoxHeader = styled__default["default"].div `
2337
+ display: flex;
2338
+ align-items: center;
2339
+ margin-bottom: 16px;
2340
+ .leadgen-title {
2341
+ margin-bottom: 0;
2342
+ flex: 1;
2343
+ min-width: 0;
2344
+ color: ${miscTheme.theme.colors.gray900};
2345
+ font-size: 18px;
2346
+ font-weight: 400;
2347
+ line-height: 1.4;
2348
+ letter-spacing: -0.8px;
2349
+ }
2350
+ `;
2351
+ const StyledLeadGenSubscriptionBox = styled__default["default"].div `
2352
+ padding: 16px;
2353
+ border: 1px solid ${miscTheme.theme.colors.neutral100};
2354
+ border-radius: 12px;
2355
+ margin-inline: auto;
2356
+ .leadgen-form_inputs {
2357
+ .leadgen-form_input {
2358
+ width: 100%;
2359
+ }
2360
+ }
2361
+
2362
+ .leadgen-form_input {
2363
+ .mantine-Input-wrapper {
2364
+ max-height: 56px;
2365
+ }
2366
+ }
2367
+
2368
+ @media screen and (min-width: 768px) {
2369
+ .leadgen-subscription_box_body {
2370
+ display: flex;
2371
+ > form {
2372
+ flex: 1;
2373
+ min-width: 0;
2374
+
2375
+ .leadgen-form_inputs {
2376
+ .leadgen-form_input {
2377
+ width: calc(50% - 4px);
2378
+ }
2379
+ }
2380
+ }
2381
+
2382
+ .leadgen-btn {
2383
+ margin-top: 0;
2384
+ margin-left: 8px;
2385
+ width: auto;
2386
+ min-height: 56px;
2387
+ }
2388
+ }
2389
+ }
2390
+ `;
2391
+ const StyledLeadGenSubscriptionBoxA = styled__default["default"].div `
2392
+ .leadgen-form_input {
2393
+ --phone-select: 45px;
2394
+ .PhoneInput {
2395
+ --phone-select: 45px;
2396
+ .PhoneInputCountry {
2397
+ margin-top: 1px;
2398
+ pointer-events: none;
2399
+ .PhoneInputCountryIconImg,
2400
+ .PhoneInputArrowContainer {
2401
+ display: none;
2402
+ }
2403
+ }
2404
+ }
2405
+ }
2406
+ `;
2407
+
2408
+ const PhoneInput = React.forwardRef((props, ref) => {
2409
+ const { defaultCountry, id: idProps, name, placeholder, label, labelElement, labelProps, description, descriptionProps, withAsterisk, inputMode, inputContainer, inputWrapperOrder, error, className, classNames, style, styles } = props, restProps = tslib_es6.__rest(props, ["defaultCountry", "id", "name", "placeholder", "label", "labelElement", "labelProps", "description", "descriptionProps", "withAsterisk", "inputMode", "inputContainer", "inputWrapperOrder", "error", "className", "classNames", "style", "styles"]);
2410
+ const id = idProps || uuid.v1() + name;
2411
+ return (React__default["default"].createElement(core.Input.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 },
2412
+ React__default["default"].createElement("div", { className: "mantine-Input-wrapper" },
2413
+ React__default["default"].createElement(index$2.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" })))));
2414
+ });
2415
+
2416
+ const formatLeadGenFormValue = (values, blocks) => {
2417
+ const newValues = {};
2418
+ for (const block of blocks) {
2419
+ const { data } = block || {};
2420
+ const { value: fieldName } = data || {};
2421
+ if (fieldName in values) {
2422
+ newValues[fieldName] = values[fieldName];
2423
+ }
2424
+ }
2425
+ return newValues;
2426
+ };
2427
+
2428
+ const StyledLeadGenFormInner = styled__default["default"].div `
2429
+ display: flex;
2430
+ flex-wrap: wrap;
2431
+ gap: 8px;
2432
+ .leadgen-form_input {
2433
+ width: calc(50% - 4px);
2434
+ }
2435
+
2436
+ .leadgen-form_input_checkbox {
2437
+ width: 100%;
2438
+ }
2439
+ `;
2440
+
2441
+ const cssInputNotShrink$1 = react.css `
2442
+ height: 100% !important;
2443
+ min-height: calc(var(--container-height, 56px) * 22 / 56);
2444
+ color: ${miscTheme.theme.colors.gray800};
2445
+ font-size: var(--input, 16px);
2446
+ line-height: calc(var(--container-height, 56px) * 22 / 56);
2447
+ border: none !important;
2448
+ border-radius: 0 !important;
2449
+ outline: none !important;
2450
+ box-shadow: none !important;
2451
+ padding: 0;
2452
+ cursor: pointer;
2453
+ opacity: 0;
2454
+
2455
+ ::placeholder {
2456
+ color: ${miscTheme.theme.colors.gray400};
2457
+ }
2458
+ `;
2459
+ const cssInputShrink$1 = react.css `
2460
+ height: auto !important;
2461
+ cursor: text;
2462
+ opacity: 1;
2463
+ transition: 0.1s ease-in-out all;
2464
+ `;
2465
+ const cssLabelNotShrink$1 = react.css `
2466
+ position: absolute;
2467
+ top: calc(var(--container-height) / 2);
2468
+ left: var(--space-x, 16px);
2469
+ color: ${miscTheme.theme.colors.gray400};
2470
+ font-size: var(--label-not-shrink, 16px);
2471
+ font-weight: 400;
2472
+ line-height: calc(var(--container-height, 56px) * 18 / 56);
2473
+ margin: 0;
2474
+ z-index: 1;
2475
+ cursor: pointer;
2476
+ transform: translateY(-50%);
2477
+ transition: 0.125s ease-in all;
2478
+ `;
2479
+ const cssLabelShrink$1 = react.css `
2480
+ color: ${miscTheme.theme.colors.gray600};
2481
+ font-weight: 600;
2482
+ font-size: var(--label-shrink, 12px);
2483
+ top: calc(var(--container-height) * 7 / 56);
2484
+ transform: none;
2485
+ transition: 0.125s ease-out all;
2486
+ `;
2487
+ const cssWrapperInputNotShrink$1 = react.css `
2488
+ min-height: var(--container-height, 56px);
2489
+ display: flex;
2490
+ align-items: flex-end;
2491
+ border: 1px solid ${miscTheme.theme.colors.gray200};
2492
+ border-radius: 8px;
2493
+ background-color: #fff;
2494
+ padding-inline: var(--space-x, 16px);
2495
+ padding-block: var(--space-y-not-shrink, 16px);
2496
+ cursor: pointer;
2497
+ pointer-events: none;
2498
+
2499
+ &:has(.mantine-Input-rightSection) {
2500
+ padding-right: var(--container-height, 56px);
2501
+ }
2502
+
2503
+ .mantine-Input-icon {
2504
+ display: none;
2505
+ }
2506
+
2507
+ .mantine-NumberInput-control {
2508
+ border-color: ${miscTheme.theme.colors.gray200};
2509
+ }
2510
+ `;
2511
+ const cssWrapperInputShrink$1 = react.css `
2512
+ height: auto;
2513
+ min-height: var(--container-height, 56px);
2514
+ padding-block: var(--space-y-shrink, 7px);
2515
+ cursor: text;
2516
+ pointer-events: auto;
2517
+ `;
2518
+ const cssInputWrapperError$1 = react.css `
2519
+ color: ${miscTheme.theme.colors.red800};
2520
+ font-size: 12px;
2521
+ line-height: 1.5;
2522
+ `;
2523
+ const StyledTextFieldContainer$1 = styled__default["default"].div `
2524
+ --space-x: 16px;
2525
+ --space-y-not-shrink: 16px;
2526
+ --space-y-shrink: 7px;
2527
+ --container-height: 56px;
2528
+ --label-not-shrink: 16px;
2529
+ --label-shrink: 12px;
2530
+ --input: 16px;
2531
+
2532
+ position: relative;
2533
+ min-width: 100px;
2534
+ max-width: 100%;
2535
+ display: inline-block;
2536
+
2537
+ .textField_wrapper {
2538
+ display: inline-block;
2539
+ width: 100%;
2540
+ cursor: pointer;
2541
+ }
2542
+
2543
+ .mantine-InputWrapper-root {
2544
+ &[data-invalid='true'] {
2545
+ .mantine-Input-wrapper {
2546
+ border-color: ${miscTheme.theme.colors.red400};
2547
+ }
2548
+ }
2549
+
2550
+ .mantine-Input-wrapper {
2551
+ &:has([data-invalid]) {
2552
+ border-color: ${miscTheme.theme.colors.red400};
2553
+ }
2554
+ }
2555
+
2556
+ .mantine-InputWrapper-error {
2557
+ font-size: 12px !important;
2558
+ }
2559
+ }
2560
+
2561
+ .mantine-InputWrapper-label {
2562
+ ${cssLabelNotShrink$1}
2563
+ }
2564
+
2565
+ .mantine-Input-wrapper {
2566
+ ${cssWrapperInputNotShrink$1}
2567
+
2568
+ + .mantine-Popover-dropdown[data-position="bottom-start"] {
2569
+ left: 0 !important;
2570
+ }
2571
+ + .mantine-Popover-dropdown[data-position='top-start'] {
2572
+ top: unset !important;
2573
+ left: 0 !important;
2574
+ bottom: 100% !important;
2575
+ }
2576
+ }
2577
+
2578
+ .mantine-Input-input {
2579
+ ${cssInputNotShrink$1}
2580
+ }
2581
+
2582
+ &.textField_shrink,
2583
+ &:focus-within {
2584
+ .mantine-InputWrapper-label {
2585
+ ${cssLabelShrink$1}
2586
+ }
2587
+
2588
+ .mantine-Input-wrapper {
2589
+ ${cssWrapperInputShrink$1}
2590
+ &.mantine-Select-wrapper {
2591
+ .mantine-Select-rightSection {
2592
+ pointer-events: auto !important;
2593
+ }
2594
+ }
2595
+ }
2596
+
2597
+ .mantine-Input-input {
2598
+ ${cssInputShrink$1}
2599
+ }
2600
+
2601
+ &:has(.PhoneInput) {
2602
+ .mantine-InputWrapper-label {
2603
+ left: var(--space-x, 16px);
2604
+ }
2605
+ .PhoneInput {
2606
+ .PhoneInputInput {
2607
+ opacity: 1;
2608
+ }
2609
+ }
2610
+ }
2611
+ }
2612
+
2613
+ .PhoneInput {
2614
+ --phone-select: 75px;
2615
+ --phone-input-space-x: 8px;
2616
+ width: 100%;
2617
+ opacity: 1;
2618
+ border: none;
2619
+ .PhoneInputCountry {
2620
+ background-color: transparent;
2621
+ border: none;
2622
+ padding: 0;
2623
+ width: var(--phone-select, 75px);
2624
+ }
2625
+ .PhoneInputInput {
2626
+ flex: 1;
2627
+ min-width: 0;
2628
+ line-height: 1.5;
2629
+ outline: none !important;
2630
+ border: none;
2631
+ box-shadow: none;
2632
+ padding: 0 var(--phone-input-space-x, 8px);
2633
+ opacity: 0;
2634
+ color: ${miscTheme.theme.colors.gray800} !important;
2635
+ :focus {
2636
+ color: ${miscTheme.theme.colors.gray800} !important;
2637
+ }
2638
+ }
2639
+ }
2640
+
2641
+ &:has(.PhoneInput) {
2642
+ .mantine-InputWrapper-label {
2643
+ left: calc(
2644
+ var(--space-x, 16px) + var(--phone-select, 75px) +
2645
+ var(--phone-input-space-x, 8px)
2646
+ );
2647
+ }
2648
+ }
2649
+ `;
2650
+ const StyledChoiceFieldContainer$1 = styled__default["default"].div `
2651
+ &.leadgen-form_checkbox,
2652
+ &.leadgen-form_radio {
2653
+ width: 100%;
2654
+ }
2655
+
2656
+ &.leadgen-form_dropdown {
2657
+ width: calc(50% - 12px);
2658
+ }
2659
+
2660
+ .mantine-InputWrapper-root {
2661
+ display: block;
2662
+ .mantine-InputWrapper-error {
2663
+ font-size: 12px !important;
2664
+ }
2665
+ }
2666
+
2667
+ .mantine-InputWrapper-label {
2668
+ margin-bottom: 0.5rem;
2669
+ color: ${miscTheme.theme.colors.gray800};
2670
+ font-size: 16px;
2671
+ font-weight: 400;
2672
+ line-height: 1.5;
2673
+ }
2674
+
2675
+ .mantine-Radio-root,
2676
+ .mantine-Checkbox-root {
2677
+ gap: 8px;
2678
+ min-width: calc(50% - 4px);
2679
+
2680
+ input[type='radio'],
2681
+ input[type='checkbox'] {
2682
+ border-color: ${miscTheme.theme.colors.gray600};
2683
+ width: 18px;
2684
+ height: 18px;
2685
+ }
2686
+ input[type='checkbox'] {
2687
+ border-radius: 4px;
2688
+ }
2689
+
2690
+ &[data-checked='true'] {
2691
+ input[type='radio'],
2692
+ input[type='checkbox'] {
2693
+ border-color: ${miscTheme.theme.colors.primary600};
2694
+ + svg {
2695
+ color: ${miscTheme.theme.colors.primary600};
2696
+ }
2697
+ }
2698
+
2699
+ input[type='radio'] {
2700
+ background-color: white;
2701
+ }
2702
+ }
2703
+
2704
+ .mantine-Checkbox-input {
2705
+ &:checked {
2706
+ border-color: ${miscTheme.theme.colors.primary600};
2707
+ }
2708
+ }
2709
+ }
2710
+
2711
+ .mantine-Radio-inner,
2712
+ .mantine-Checkbox-inner {
2713
+ width: 24px;
2714
+ height: 24px;
2715
+ display: flex;
2716
+ align-items: center;
2717
+ justify-content: center;
2718
+ }
2719
+
2720
+ .mantine-Radio-body,
2721
+ .mantine-Checkbox-body {
2722
+ display: flex;
2723
+ align-items: center;
2724
+ }
2725
+
2726
+ .mantine-Radio-label,
2727
+ .mantine-Checkbox-label {
2728
+ padding-left: 8px;
2729
+ color: ${miscTheme.theme.colors.gray800};
2730
+ font-size: 14px;
2731
+ line-height: 1.4;
2732
+ letter-spacing: -0.2px;
2733
+ }
2734
+
2735
+ .leadgen-choiceContainer {
2736
+ display: flex;
2737
+ flex-wrap: wrap;
2738
+ align-items: flex-start;
2739
+ gap: 8px;
2740
+ }
2741
+
2742
+ .mantine-InputWrapper-error {
2743
+ ${cssInputWrapperError$1}
2744
+ }
2745
+ `;
2746
+
2747
+ const TextField$1 = (props) => {
2748
+ const { shrink: shrinkProps, onChangeShrink, className, children } = props, restProps = tslib_es6.__rest(props, ["shrink", "onChangeShrink", "className", "children"]);
2749
+ const containerRef = hooks.useClickOutside(() => {
2750
+ if (shrinkProps) {
2751
+ return;
2752
+ }
2753
+ setShrink(false);
2754
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(false);
2755
+ });
2756
+ const [shrink, setShrink] = React.useState(shrinkProps);
2757
+ const onClick = React.useCallback((e) => {
2758
+ setShrink(true);
2759
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(true);
2760
+ if (shrink) {
2761
+ return;
2762
+ }
2763
+ const $textEl = e.currentTarget.querySelectorAll('input:not([disabled]):not([type="submit"]),select:not([disabled]),textarea:not([disabled])');
2764
+ const $focusEl = $textEl.item($textEl.length - 1);
2765
+ if ($focusEl) {
2766
+ $focusEl.focus();
2767
+ setTimeout(() => {
2768
+ $focusEl.scrollIntoView({
2769
+ behavior: 'auto',
2770
+ block: 'center',
2771
+ inline: 'start',
2772
+ });
2773
+ }, 100);
2774
+ }
2775
+ }, [shrink]);
2776
+ React.useEffect(() => {
2777
+ setShrink(shrinkProps);
2778
+ }, [shrinkProps]);
2779
+ return (React__default["default"].createElement(StyledTextFieldContainer$1, Object.assign({ shrink: shrink, className: core.clsx(className, 'textField', { textField_shrink: !!shrink }) }, restProps),
2780
+ React__default["default"].createElement("div", { ref: containerRef, onClick: onClick, className: "textField_wrapper" }, children)));
2781
+ };
2782
+ const ChoiceField$1 = (props) => {
2783
+ const { children, className } = props, restProps = tslib_es6.__rest(props, ["children", "className"]);
2784
+ return (React__default["default"].createElement(StyledChoiceFieldContainer$1, Object.assign({ className: core.clsx(className, 'choiceField') }, restProps), children));
2785
+ };
2786
+
2787
+ const libraries = ['places'];
2788
+ const GoogleLocationBlock = (props) => {
2789
+ var _a;
2790
+ const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = tslib_es6.__rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
2791
+ const [LoadScript, setLoadScript] = React.useState(null);
2792
+ const [value, setValue] = React.useState(defaultValue || valueProps);
2793
+ const { predictions } = usePlacesAutocomplete.usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
2794
+ const onChangeAutocomplete = React.useCallback((s) => {
2795
+ setValue(s);
2796
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
2797
+ }, []);
2798
+ const onClickItem = React.useCallback((item) => {
2799
+ /** For sure get value */
2800
+ setValue(item.value);
2801
+ const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
2802
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
2803
+ }, [onChangeProps, predictions]);
2804
+ React.useEffect(() => {
2805
+ setValue(valueProps);
2806
+ }, [valueProps]);
2807
+ React.useEffect(() => {
2808
+ var _a, _b, _c;
2809
+ // only load extra google script when not yet loaded
2810
+ 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) {
2811
+ Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@react-google-maps/api')); }).then((m) => {
2812
+ setLoadScript(() => m.LoadScript);
2813
+ });
2814
+ }
2815
+ }, []);
2816
+ return (React__default["default"].createElement(core.Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
2817
+ return { value: pred.description, label: pred.description };
2818
+ }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: index$6.ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
2819
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
2820
+ LoadScript && (React__default["default"].createElement(LoadScript, { googleMapsApiKey: usePlacesAutocomplete.GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default["default"].createElement(React__default["default"].Fragment, null), style: { width: '100%' } })),
2821
+ children));
2822
+ } }, restProps)));
2823
+ };
2824
+
2825
+ const LeadGenForm = React.forwardRef((props, ref) => {
2826
+ const { locale, blocks, scrollToErrorField = true, form: formProps, rules: validate, initialValues, onFinish, onFinishFailed, className, style, } = props;
2827
+ const formRef = React.useRef(null);
2828
+ const form$1 = formProps || form.useForm({ initialValues, validate });
2829
+ const middlewareFinish = React.useCallback((values, event) => {
2830
+ /** Set `touched` all values for validation when submiting */
2831
+ form$1.setTouched(blocks.reduce((touched, { data }) => {
2832
+ touched[data.value] = true;
2833
+ return touched;
2834
+ }, {}));
2835
+ /** Wait for `touched` state and then submit */
2836
+ setTimeout(() => {
2837
+ const { hasErrors } = form$1.validate();
2838
+ if (hasErrors) {
2839
+ return;
2840
+ }
2841
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatLeadGenFormValue(values, blocks), event);
2842
+ }, 100);
2843
+ }, [form$1, blocks]);
2844
+ const middlewareFinishFailed = React.useCallback((errors, values, events) => {
2845
+ if (scrollToErrorField && errors) {
2846
+ const firstErrorKey = Object.keys(errors)[0];
2847
+ const firstErrorElement = document.querySelector(`[name="${firstErrorKey}"]`);
2848
+ if (firstErrorElement && (firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus)) {
2849
+ setTimeout(() => {
2850
+ firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
2851
+ firstErrorElement.scrollIntoView({
2852
+ behavior: 'auto',
2853
+ block: 'center',
2854
+ inline: 'center',
2855
+ });
2856
+ }, 100);
2857
+ }
2858
+ }
2859
+ onFinishFailed === null || onFinishFailed === void 0 ? void 0 : onFinishFailed(errors, values, events);
2860
+ }, [scrollToErrorField]);
2861
+ React.useEffect(() => {
2862
+ (() => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
2863
+ if (!window.intlTelInputUtils) {
2864
+ yield require('intl-tel-input/build/js/utils');
2865
+ }
2866
+ }))();
2867
+ }, []);
2868
+ React.useImperativeHandle(ref, () => (Object.assign(Object.assign({}, form$1), { submit: () => {
2869
+ formRef.current.requestSubmit();
2870
+ } })), [form$1, formRef]);
2871
+ if (!blocks || !blocks.length) {
2872
+ return null;
2873
+ }
2874
+ return (React__default["default"].createElement("form", { ref: formRef, onSubmit: form$1.onSubmit(middlewareFinish, middlewareFinishFailed), className: className, style: style },
2875
+ React__default["default"].createElement(StyledLeadGenFormInner, { className: "leadgen-form_inputs" }, blocks.map((block, idx) => {
2876
+ const { id, name: blockName, data } = block;
2877
+ const { placeholder, value: name, required, listQuestion, valueHTML, isSendMailChimp = false, } = data;
2878
+ const formInputProps = form$1.getInputProps(name);
2879
+ const { value, error } = formInputProps;
2880
+ const reactKey = `${id}-${idx}`;
2881
+ switch (blockName) {
2882
+ case LEADGEN_BLOCK.TextBlock: {
2883
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2884
+ React__default["default"].createElement(core.TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "text", "data-control": "text" }, formInputProps))));
2885
+ }
2886
+ case LEADGEN_BLOCK.NumberBlock: {
2887
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2888
+ React__default["default"].createElement(core.NumberInput, Object.assign({ name: value, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "number", "data-control": "number" }, formInputProps))));
2889
+ }
2890
+ case LEADGEN_BLOCK.EmailBlock: {
2891
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2892
+ React__default["default"].createElement(core.TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, "data-control": "email" }, formInputProps))));
2893
+ }
2894
+ case LEADGEN_BLOCK.PhoneOtpBlock:
2895
+ case LEADGEN_BLOCK.WhatsappOtpBlock:
2896
+ case LEADGEN_BLOCK.ZaloOtpBlock:
2897
+ case LEADGEN_BLOCK.PhoneBlock: {
2898
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2899
+ React__default["default"].createElement(PhoneInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, defaultCountry: (locale ? utils.MAPPED_LOCALE[locale] || 'VN' : 'VN'), type: "text", "data-control": "text" }, formInputProps))));
2900
+ }
2901
+ case LEADGEN_BLOCK.LocationBlock: {
2902
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2903
+ React__default["default"].createElement(GoogleLocationBlock, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, locale: locale, "data-control": "text" }, formInputProps))));
2904
+ }
2905
+ case LEADGEN_BLOCK.DateBlock: {
2906
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2907
+ React__default["default"].createElement(dates.DateInput, Object.assign({ locale: (utils.MAPPED_LOCALE === null || utils.MAPPED_LOCALE === void 0 ? void 0 : utils.MAPPED_LOCALE[locale]) || utils.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))));
2908
+ }
2909
+ case LEADGEN_BLOCK.DropdownBlock:
2910
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2911
+ React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2912
+ React__default["default"].createElement(core.Select, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, data: listQuestion.map((l) => ({
2913
+ value: l.value,
2914
+ label: l.placeholder,
2915
+ })) }, formInputProps))));
2916
+ case LEADGEN_BLOCK.CheckboxBlock: {
2917
+ const formInputCheckboxProps = form$1.getInputProps(name, {
2918
+ type: 'checkbox',
2919
+ });
2920
+ return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2921
+ isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2922
+ React__default["default"].createElement(core.Checkbox.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, sx: {
2923
+ display: 'flex',
2924
+ flexDirection: 'column',
2925
+ flexWrap: 'wrap',
2926
+ gap: 8,
2927
+ }, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2928
+ return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2929
+ } }, formInputCheckboxProps), listQuestion.map((l, _idx) => (React__default["default"].createElement(core.Checkbox, { name: name, key: _idx, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2930
+ }
2931
+ case LEADGEN_BLOCK.RadioBlock: {
2932
+ return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2933
+ isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2934
+ React__default["default"].createElement(core.Radio.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, spellCheck: true, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2935
+ return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2936
+ } }, formInputProps), listQuestion.map((l, _index) => (React__default["default"].createElement(core.Radio, { name: name, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2937
+ }
2938
+ case LEADGEN_BLOCK.TncBlock:
2939
+ return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2940
+ React__default["default"].createElement(core.Input.Wrapper, { error: error },
2941
+ React__default["default"].createElement(core.Checkbox, Object.assign({ value: value, name: 'TNC-' + id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, formInputProps)))));
2942
+ default: {
2943
+ return null;
2944
+ }
2945
+ }
2946
+ }))));
2947
+ });
2948
+
2949
+ const LEADGEN_ORDER_INPUT_WRAPPER = ['label', 'input', 'description', 'error'];
2950
+
2951
+ const LeadGenSubscriptionBoxA = (props) => {
2952
+ const { loading, image, title, submitText, locale, blocks, form, rules, onFinish, } = props;
2953
+ const formRef = React.useRef();
2954
+ const imageComp = React.useMemo(() => {
2955
+ if (!image) {
2956
+ return null;
2957
+ }
2958
+ return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeaderImage, null,
2959
+ React__default["default"].createElement("img", { src: image, alt: "" })));
2960
+ }, [image]);
2961
+ const titleComp = React.useMemo(() => {
2962
+ if (typeof title === 'string') {
2963
+ return (React__default["default"].createElement("p", { className: "leadgen-title", dangerouslySetInnerHTML: { __html: title } }));
2964
+ }
2965
+ return React__default["default"].createElement("p", { className: "leadgen-title" }, title);
2966
+ }, [title]);
2967
+ return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxA, { className: "subcription_box_A" },
2968
+ React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeader, { className: "leadgen-subscription_box_header" },
2969
+ imageComp,
2970
+ titleComp),
2971
+ React__default["default"].createElement(StyledLeadGenSubscriptionBoxBody, { className: "leadgen-subscription_box_body" },
2972
+ React__default["default"].createElement(LeadGenForm, { ref: formRef, form: form, rules: rules, blocks: blocks, locale: locale, onFinish: onFinish, className: "leadgen-subscription_box_form" }),
2973
+ React__default["default"].createElement(core.Button, { disabled: loading, loading: loading, variant: "filled", size: "lg", onClick: () => {
2974
+ formRef.current.submit();
2975
+ }, className: "leadgen-btn leadgen-btn_action", fullWidth: true }, submitText))));
2976
+ };
2977
+
2978
+ const LeadGenSubscriptionBoxWithoutMemo = ({ locale, userInfo, forceCampaign, categoryId, }) => {
2979
+ var _a, _b, _c;
2980
+ const { image, extra_fields, id: campaign_id, bot_id: campaign_subot_id = [], ThankYouBlock, } = forceCampaign || {};
2981
+ const { textBlocks, listBlockAdded, actionBlocks } = extra_fields || {};
2982
+ const { submitBlock } = actionBlocks || {};
2983
+ const { apiLeadUrl, subscriptionIcon, subscriptionTitle, submitSubscriptionBox, impression, onFinish, } = useLeadGenContext();
2984
+ const { t } = index.useTranslations();
2985
+ const { action: { pushNotifications }, } = React.useContext(togetherComponentGlobalContext.TogetherComponentGlobalContext);
2986
+ const refContainer = React.useRef(null);
2987
+ const [loading, setLoading] = React.useState(false);
2988
+ const [showThankyou, setShowThankyou] = React.useState(false);
2989
+ const validatingEmailRef = React.useRef(false);
2990
+ const validatingPhoneRef = React.useRef(false);
2991
+ const { form, validateObj } = useLeadFormConfig({
2992
+ listBlockAdded,
2993
+ campaignId: campaign_id,
2994
+ campaign_subot_id,
2995
+ validatingEmailRef,
2996
+ validatingPhoneRef,
2997
+ userInfo,
2998
+ });
2999
+ const subscription_title = React.useMemo(() => {
3000
+ var _a, _b;
3001
+ return subscriptionTitle ||
3002
+ ((_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) ||
3003
+ t('leadgen.message.title.default');
3004
+ }, [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]);
3005
+ const { image: thankyouImage, title: thankyouTitle, description: thankyouDescription, button: thankyouButton, } = ThankYouBlock || {};
3006
+ const intersectionObserverCallback = React.useCallback((entries) => {
3007
+ entries.forEach((entry) => {
3008
+ const { isIntersecting, target } = entry;
3009
+ if (!showThankyou &&
3010
+ isIntersecting &&
3011
+ target === refContainer.current) {
3012
+ impression();
3013
+ }
3014
+ });
3015
+ }, [impression, showThankyou]);
3016
+ const IObserver = new IntersectionObserver(intersectionObserverCallback);
3017
+ const middlewareOnSubmit = React.useCallback((values) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
3018
+ const newValues = {
3019
+ subscription_title,
3020
+ };
3021
+ const ssoValues = {
3022
+ sso_user_id: undefined,
3023
+ sso_uuid: undefined,
3024
+ sso_verified_profile: undefined,
3025
+ };
3026
+ const valueKeys = Object.keys(values);
3027
+ for (const key of valueKeys) {
3028
+ const isPhoneField = leadGenFieldNamePhone(listBlockAdded).some((k) => k === key);
3029
+ if (isPhoneField) {
3030
+ const phone = PhoneInputBase.parsePhoneNumber(values[key]);
3031
+ if (phone.isValid()) {
3032
+ /** Seperate `area_code` and `phone_number` for BE */
3033
+ newValues['area_code'] = `+${phone.countryCallingCode}`;
3034
+ newValues['phone_number'] = phone.nationalNumber;
3035
+ /** Only case login has this update */
3036
+ if ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) && (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid)) {
3037
+ ssoValues['sso_verified_profile'] =
3038
+ phone.number === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone) ? 1 : 0;
3039
+ ssoValues['sso_user_id'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.id;
3040
+ ssoValues['sso_uuid'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid;
3041
+ }
3042
+ }
3043
+ continue;
3044
+ }
3045
+ newValues[key] = values[key];
3046
+ }
3047
+ setLoading(true);
3048
+ try {
3049
+ const { _data } = (yield submitSubscriptionBox(Object.assign(Object.assign({}, newValues), ssoValues))) || {};
3050
+ const { model } = _data || {};
3051
+ if (model && (model === null || model === void 0 ? void 0 : model.id)) {
3052
+ setShowThankyou(true);
3053
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(Object.assign(Object.assign({}, newValues), ssoValues), listBlockAdded || []);
3054
+ }
3055
+ }
3056
+ catch (error) {
3057
+ LeadLog('** LeadGen SubscriptionBox error : ', error);
3058
+ pushNotifications({
3059
+ message: t('leadgen.message.error.default'),
3060
+ type: 'danger',
3061
+ });
3062
+ }
3063
+ setLoading(false);
3064
+ }), [
3065
+ subscription_title,
3066
+ listBlockAdded,
3067
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
3068
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid,
3069
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone,
3070
+ ]);
3071
+ React.useEffect(() => {
3072
+ if (refContainer.current) {
3073
+ IObserver.observe(refContainer.current);
3074
+ }
3075
+ return () => {
3076
+ IObserver.disconnect();
3077
+ };
3078
+ }, [categoryId]);
3079
+ return (React__default["default"].createElement("div", { ref: refContainer },
3080
+ React__default["default"].createElement(StyledLeadGenSubscriptionBox, null,
3081
+ showThankyou && (React__default["default"].createElement(LeadGenThankYou, { image: Object.assign(Object.assign({}, thankyouImage), { src: thankyouImage.src || `${apiLeadUrl}admin/img/thanksyou.png` }), title: thankyouTitle, description: thankyouDescription, button: thankyouButton })),
3082
+ !showThankyou && (React__default["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 })))));
3083
+ };
3084
+ const LeadGenSubscriptionBox$1 = React.memo(LeadGenSubscriptionBoxWithoutMemo);
3085
+
3086
+ const Container = () => {
3087
+ const context = React.useContext(LeadGenContext);
3088
+ const { campaign_code, locale, siteId, siteDomain, userInfo, forceCampaign } = context;
3089
+ if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
3090
+ return null;
3091
+ }
3092
+ return (React__default["default"].createElement(LeadGenSubscriptionBox$1, { locale: locale, siteId: siteId, siteDomain: siteDomain, userInfo: userInfo, forceCampaign: forceCampaign, campaign_code: campaign_code }));
3093
+ };
3094
+ Container.displayName = 'LeadGenSubscriptionBox';
3095
+ const LeadGenSubscriptionBoxContainer = (props) => {
3096
+ const { apiUrl, apiSubotUrl } = props;
3097
+ return (React__default["default"].createElement(LeadGenContextProvider, Object.assign({}, props, { apiLeadUrl: apiUrl, apiSubotUrl: apiSubotUrl }),
3098
+ React__default["default"].createElement(Container, null)));
3099
+ };
3100
+ const LeadGenSubscriptionBox = LeadGenSubscriptionBoxContainer;
3101
+
3102
+ const useImageSize = (src) => {
3103
+ const [width, setWidth] = React.useState(16);
3104
+ const [height, setHeight] = React.useState(9);
3105
+ const [loaded, setLoaded] = React.useState(false);
3106
+ // load src image to get its width and height
3107
+ React.useEffect(() => {
3108
+ setLoaded(false);
3109
+ if (src) {
3110
+ const img = new Image();
3111
+ img.addEventListener('load', () => {
3112
+ setWidth(img.naturalWidth);
3113
+ setHeight(img.naturalHeight);
3114
+ setLoaded(true);
3115
+ });
3116
+ img.addEventListener('error', () => {
3117
+ setWidth(16);
3118
+ setHeight(9);
3119
+ setLoaded(true);
3120
+ });
3121
+ img.src = src;
3122
+ }
3123
+ else {
3124
+ setWidth(16);
3125
+ setHeight(9);
3126
+ setLoaded(true);
3127
+ }
3128
+ }, [src]);
3129
+ return {
3130
+ loaded,
3131
+ width,
3132
+ height,
3133
+ };
3134
+ };
3135
+
3136
+ const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default["default"].createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
3137
+ React__default["default"].createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
3138
+ React__default["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" }))));
3139
+
3140
+ // url: imageBlocks.imageMobile.data.url
3141
+ // newTab: imageBlocks.imageMobile.data.newtab
3142
+ // imageMobile: campaignShow.image
3143
+ // imageDestkop: campaignShow.image_desktop
3144
+ const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
3145
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3146
+ const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
3147
+ if (!imageMobileLoaded || !imageDestkopLoaded)
3148
+ return null;
3149
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
3150
+ React__default["default"].createElement("div", { className: "le-center-tab-popup" },
3151
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
3152
+ React__default["default"].createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
3153
+ index$7.isVideo(imageMobile) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
3154
+ React__default["default"].createElement("source", { src: imageMobile }))) : (React__default["default"].createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
3155
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3156
+ } })),
3157
+ index$7.isVideo(imageDestkop) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
3158
+ React__default["default"].createElement("source", { src: imageDestkop }))) : (React__default["default"].createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
3159
+ aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
3160
+ } }))),
3161
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3162
+ };
3163
+
3164
+ // title: titleText
3165
+ // titleAlign: textBlocks.titleBlock.data.align
3166
+ // subtitle: textBlocks.subtitleBlock.data.value
3167
+ // subtitleAlign: textBlocks.subtitleBlock.data.align
3168
+ // url: actionBlocks.linkButtonBlock.data.url
3169
+ // urlText: actionBlocks.linkButtonBlock.data.value
3170
+ // newTab: actionBlocks.linkButtonBlock.data.newtab
3171
+ // imageMobile: campaignShow.image
3172
+ // imageDesktop: campaignShow.image_desktop
3173
+ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
3174
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3175
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
3176
+ if (!imageMobileLoaded || !imageDesktopLoaded)
3177
+ return null;
3178
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
3179
+ React__default["default"].createElement("aside", { className: "le-only-desktop" },
3180
+ React__default["default"].createElement("div", { className: "le-floating-desktop" },
3181
+ React__default["default"].createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
3182
+ imageDesktop ? (React__default["default"].createElement("div", null,
3183
+ React__default["default"].createElement("img", { style: {
3184
+ maxWidth: 120,
3185
+ borderTopLeftRadius: 5,
3186
+ borderBottomLeftRadius: 5,
3187
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
3188
+ }, src: imageDesktop }))) : null,
3189
+ React__default["default"].createElement("div", { style: { padding: 20 } },
3190
+ React__default["default"].createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
3191
+ React__default["default"].createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
3192
+ React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
3193
+ React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
3194
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
3195
+ React__default["default"].createElement("aside", { className: "le-only-mobile" },
3196
+ React__default["default"].createElement("div", { className: "le-floating-mobile" },
3197
+ React__default["default"].createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
3198
+ React__default["default"].createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
3199
+ React__default["default"].createElement("div", null,
3200
+ React__default["default"].createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
3201
+ React__default["default"].createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
3202
+ imageMobile ? (React__default["default"].createElement("div", null,
3203
+ React__default["default"].createElement("img", { style: {
3204
+ marginLeft: 15,
3205
+ marginTop: 4,
3206
+ maxWidth: 100,
3207
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3208
+ }, src: imageMobile }))) : null),
3209
+ React__default["default"].createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
3210
+ React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
3211
+ React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
3212
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
3213
+ };
3214
+
3215
+ const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
3216
+ const { primaryColor } = React.useContext(LeadGenContext$1);
3217
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
3218
+ if (!imageLoaded)
3219
+ return null;
3220
+ return (React__default["default"].createElement("div", { className: "lead-modal__thank-you leadgen-inner_thankyou" },
3221
+ React__default["default"].createElement("div", { style: { width: '100%' } },
3222
+ React__default["default"].createElement("img", { src: image, style: {
3223
+ maxHeight: 162,
3224
+ objectFit: 'cover',
3225
+ aspectRatio: `${imageWidth}/${imageHeight}`,
3226
+ }, loading: "lazy" }),
3227
+ title && (React__default["default"].createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
3228
+ subtitle && (React__default["default"].createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle.split('\n').map((text, idx, list) => {
3229
+ const isShowBr = idx < list.length - 1;
3230
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
3231
+ text,
3232
+ isShowBr && React__default["default"].createElement("br", null)));
3233
+ }))),
3234
+ linkText && (React__default["default"].createElement("div", null,
3235
+ React__default["default"].createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
3236
+ React__default["default"].createElement(index$3.Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
3237
+ };
3238
+
3239
+ const InlineLayout = ({ content, inlinePosition, }) => {
3240
+ const target = React.useMemo(() => {
3241
+ if (!inlinePosition)
3242
+ return null;
1507
3243
  const parents = document.querySelectorAll(`[data-url="${location.pathname}"] .body-content`);
1508
3244
  const allChildren = Array.from(parents).reduce((r, p) => {
1509
3245
  return [...r, ...Array.from(p.children)];
@@ -1636,218 +3372,13 @@ const EmptyIcon = (props) => {
1636
3372
  const EmptyComponent = ({ onClose, onContinue, }) => {
1637
3373
  const { t } = index.useTranslations();
1638
3374
  return (React__default["default"].createElement("div", { className: "leadgen-empty" },
1639
- React__default["default"].createElement("div", { className: "leadgen-empty_body" },
1640
- React__default["default"].createElement("div", { className: "leadgen-empty_wrapper" },
1641
- React__default["default"].createElement(EmptyIcon, { className: "leadgen-empty_image" }),
1642
- React__default["default"].createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
1643
- React__default["default"].createElement("div", { className: "leadgen-empty_footer" },
1644
- React__default["default"].createElement(core.Button, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
1645
- React__default["default"].createElement(core.Button, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
1646
- };
1647
-
1648
- const libraries = ['places'];
1649
- const GoogleLocationBlock = (props) => {
1650
- var _a;
1651
- const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = tslib_es6.__rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
1652
- const [LoadScript, setLoadScript] = React.useState(null);
1653
- const [value, setValue] = React.useState(defaultValue || valueProps);
1654
- const { predictions } = usePlacesAutocomplete.usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
1655
- const onChangeAutocomplete = React.useCallback((s) => {
1656
- setValue(s);
1657
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
1658
- }, []);
1659
- const onClickItem = React.useCallback((item) => {
1660
- /** For sure get value */
1661
- setValue(item.value);
1662
- const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
1663
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
1664
- }, [onChangeProps, predictions]);
1665
- React.useEffect(() => {
1666
- setValue(valueProps);
1667
- }, [valueProps]);
1668
- React.useEffect(() => {
1669
- var _a, _b, _c;
1670
- // only load extra google script when not yet loaded
1671
- 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) {
1672
- Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@react-google-maps/api')); }).then((m) => {
1673
- setLoadScript(() => m.LoadScript);
1674
- });
1675
- }
1676
- }, []);
1677
- return (React__default["default"].createElement(core.Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
1678
- return { value: pred.description, label: pred.description };
1679
- }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: index$8.ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
1680
- return (React__default["default"].createElement(React__default["default"].Fragment, null,
1681
- LoadScript && (React__default["default"].createElement(LoadScript, { googleMapsApiKey: usePlacesAutocomplete.GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default["default"].createElement(React__default["default"].Fragment, null), style: { width: '100%' } })),
1682
- children));
1683
- } }, restProps)));
1684
- };
1685
-
1686
- // You can give context variables any name
1687
- const [LeadFormProvider, useLeadFormContext, useLeadForm] = form.createFormContext();
1688
- const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, }) => {
1689
- const { t } = index.useTranslations();
1690
- const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
1691
- const validateObj = React.useMemo(() => {
1692
- const InputBlocks = [
1693
- 'TextBlock',
1694
- 'NumberBlock',
1695
- 'EmailBlock',
1696
- 'PhoneBlock',
1697
- 'DateBlock',
1698
- 'CheckboxBlock',
1699
- 'RadioBlock',
1700
- 'DropdownBlock',
1701
- 'PhoneOtpBlock',
1702
- 'WhatsappOtpBlock',
1703
- 'ZaloOtpBlock',
1704
- 'LocationBlock',
1705
- 'TncBlock',
1706
- ];
1707
- // ALL are required and can skip if not touched yet
1708
- const withSharedCheck = (name, cb,
1709
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1710
- block) => {
1711
- return (value) => {
1712
- var _a;
1713
- const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
1714
- if (!formRef.current.isTouched(name))
1715
- return;
1716
- if ((typeof value === 'string' && value.replace(' ', '') === '') ||
1717
- typeof value === 'undefined' ||
1718
- value === '' ||
1719
- (Array.isArray(value) && value.length === 0)) {
1720
- return isBLockRequired
1721
- ? t('validator.required')
1722
- : cb === null || cb === void 0 ? void 0 : cb(value);
1723
- }
1724
- return cb === null || cb === void 0 ? void 0 : cb(value);
1725
- };
1726
- };
1727
- return listBlockAdded
1728
- .filter((b) => InputBlocks.includes(b.name))
1729
- .reduce((r, b) => {
1730
- var _a;
1731
- const isRequired = (_a = b.data.required) !== null && _a !== void 0 ? _a : true;
1732
- if (b.name === 'NumberBlock') {
1733
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1734
- if (value && isNaN(Number(value))) {
1735
- return t('validator.number');
1736
- }
1737
- }, b) });
1738
- }
1739
- else if (b.name === 'EmailBlock') {
1740
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1741
- if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
1742
- return t('validator.email');
1743
- }
1744
- if (!value)
1745
- return;
1746
- validatingEmailRef.current = true;
1747
- setTimeout(() => {
1748
- formRef.current.setFieldError(b.data.value, 'Validating...');
1749
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1750
- email: value,
1751
- })
1752
- .then((tKey) => {
1753
- if (tKey) {
1754
- formRef.current.setFieldError(b.data.value, t(tKey));
1755
- }
1756
- else {
1757
- formRef.current.clearFieldError(b.data.value);
1758
- }
1759
- validatingEmailRef.current = false;
1760
- })
1761
- .catch((e) => {
1762
- console.error(e);
1763
- formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
1764
- validatingEmailRef.current = false;
1765
- });
1766
- }, 200);
1767
- }, b) });
1768
- }
1769
- else if (b.name === 'PhoneBlock' ||
1770
- b.name === 'PhoneOtpBlock' ||
1771
- b.name === 'ZaloOtpBlock' ||
1772
- b.name === 'WhatsappOtpBlock') {
1773
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1774
- if (value &&
1775
- window.intlTelInputUtils &&
1776
- !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
1777
- return t('validator.phone');
1778
- }
1779
- if (!value)
1780
- return;
1781
- validatingPhoneRef.current = true;
1782
- setTimeout(() => {
1783
- formRef.current.setFieldError(b.data.value, 'Validating...');
1784
- if (b.data.singleSubmission) {
1785
- checkUsedPhoneOnlyWithCache(campaignId, value)
1786
- .then((tKey) => {
1787
- if (tKey) {
1788
- formRef.current.setFieldError(b.data.value, t(tKey));
1789
- }
1790
- else {
1791
- formRef.current.clearFieldError(b.data.value);
1792
- }
1793
- validatingPhoneRef.current = false;
1794
- })
1795
- .catch((err) => {
1796
- console.error(err);
1797
- formRef.current.setFieldError(b.data.value, err.message || 'Something went wrong');
1798
- validatingPhoneRef.current = false;
1799
- });
1800
- }
1801
- else {
1802
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1803
- phone: value,
1804
- })
1805
- .then((tKey) => {
1806
- if (tKey) {
1807
- formRef.current.setFieldError(b.data.value, t(tKey));
1808
- }
1809
- else {
1810
- formRef.current.clearFieldError(b.data.value);
1811
- }
1812
- validatingPhoneRef.current = false;
1813
- })
1814
- .catch((e) => {
1815
- console.error(e);
1816
- formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
1817
- validatingPhoneRef.current = false;
1818
- });
1819
- }
1820
- }, 200);
1821
- }, b) });
1822
- }
1823
- else if (b.name === 'DateBlock') {
1824
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1825
- if (value && isNaN(Date.parse(value))) {
1826
- return t('validator.date');
1827
- }
1828
- }, b) });
1829
- }
1830
- else if (b.name === 'TncBlock') {
1831
- return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
1832
- if (isRequired && !value) {
1833
- return t('validator.required');
1834
- }
1835
- }, b) });
1836
- }
1837
- else {
1838
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, undefined, b) });
1839
- }
1840
- }, {});
1841
- }, [listBlockAdded.map((b) => b.name).join(',')]);
1842
- const form = useLeadForm({
1843
- validateInputOnChange: true,
1844
- clearInputErrorOnChange: true,
1845
- validate: validateObj,
1846
- initialValues,
1847
- });
1848
- const formRef = React.useRef(form);
1849
- formRef.current = form;
1850
- return { form, validateObj };
3375
+ React__default["default"].createElement("div", { className: "leadgen-empty_body" },
3376
+ React__default["default"].createElement("div", { className: "leadgen-empty_wrapper" },
3377
+ React__default["default"].createElement(EmptyIcon, { className: "leadgen-empty_image" }),
3378
+ React__default["default"].createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
3379
+ React__default["default"].createElement("div", { className: "leadgen-empty_footer" },
3380
+ React__default["default"].createElement(core.Button, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
3381
+ React__default["default"].createElement(core.Button, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
1851
3382
  };
1852
3383
 
1853
3384
  const SubtitleBlock = ({ children, align, }) => (React__default["default"].createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
@@ -2020,6 +3551,14 @@ const StyledTextFieldContainer = styled__default["default"].div `
2020
3551
  }
2021
3552
  }
2022
3553
 
3554
+ &:focus-within {
3555
+ .mantine-Input-wrapper {
3556
+ transition: 0.25s linear border;
3557
+ border-color: ${miscTheme.theme.colors.primary600};
3558
+ box-shadow: 0 0 4px ${miscTheme.theme.colors.primary200};
3559
+ }
3560
+ }
3561
+
2023
3562
  .PhoneInput {
2024
3563
  --phone-select: 75px;
2025
3564
  --phone-input-space-x: 8px;
@@ -2168,11 +3707,13 @@ const TextField = (props) => {
2168
3707
  const $focusEl = $textEl.item($textEl.length - 1);
2169
3708
  if ($focusEl) {
2170
3709
  $focusEl.focus();
2171
- $focusEl.scrollIntoView({
2172
- behavior: 'auto',
2173
- block: 'center',
2174
- inline: 'start',
2175
- });
3710
+ setTimeout(() => {
3711
+ $focusEl.scrollIntoView({
3712
+ behavior: 'auto',
3713
+ block: 'center',
3714
+ inline: 'start',
3715
+ });
3716
+ }, 100);
2176
3717
  }
2177
3718
  }, [shrink]);
2178
3719
  React.useEffect(() => {
@@ -2189,8 +3730,14 @@ const ChoiceField = (props) => {
2189
3730
  const TitleBlock = ({ children, align, }) => (React__default["default"].createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
2190
3731
 
2191
3732
  const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, }) => {
3733
+ const { t } = index.useTranslations();
2192
3734
  const form = useLeadFormContext();
2193
3735
  const formValues = form.values;
3736
+ const labelTuples = React.useMemo(() => {
3737
+ return ((index$6.ISO_FORMAT === null || index$6.ISO_FORMAT === void 0 ? void 0 : index$6.ISO_FORMAT[locale]) || index$6.ISO_FORMAT['vi-VN']).dateFormat
3738
+ .split('/')
3739
+ .map((key) => { var _a; return t((_a = index$8.COMMON_DATE_TRANSLATE_KEY === null || index$8.COMMON_DATE_TRANSLATE_KEY === void 0 ? void 0 : index$8.COMMON_DATE_TRANSLATE_KEY[key]) === null || _a === void 0 ? void 0 : _a.id); });
3740
+ }, [locale]);
2194
3741
  return (React__default["default"].createElement(React__default["default"].Fragment, null, listBlockAdded.map((b, index) => {
2195
3742
  var _a;
2196
3743
  const { name = '', data = {}, id } = b || {};
@@ -2240,17 +3787,15 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2240
3787
  return (React__default["default"].createElement(TextField, { key: index, shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field" },
2241
3788
  React__default["default"].createElement(GoogleLocationBlock, Object.assign({ withAsterisk: required, name: value, placeholder: placeholder, label: placeholder, "data-control": "text", locale: locale, inputWrapperOrder: ['label', 'input', 'description', 'error'] }, form.getInputProps(value)))));
2242
3789
  }
2243
- case 'DateBlock':
2244
- return (React__default["default"].createElement(TextField, { key: index, shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field" },
2245
- React__default["default"].createElement(index$4.DatePicker, Object.assign({ clearable: true, withAsterisk: required, type: "default", name: value, placeholder: placeholder, label: placeholder, inputWrapperOrder: ['label', 'input', 'description', 'error'], inputContainer: (children) => {
2246
- return (React__default["default"].createElement(React__default["default"].Fragment, null,
2247
- children,
2248
- React__default["default"].createElement("input", { type: "hidden", "data-control": "date", name: value, value: formValue })));
2249
- } }, form.getInputProps(value)))));
3790
+ case 'DateBlock': {
3791
+ const _c = form.getInputProps(value), { error } = _c, formInputProps = tslib_es6.__rest(_c, ["error"]);
3792
+ return (React__default["default"].createElement(core.Input.Wrapper, { key: index, size: "md", withAsterisk: required, label: placeholder, "data-invalid": !!error, inputWrapperOrder: ['label', 'input', 'description', 'error'], error: error, className: "lead-modal__form-control leadgen-form_field" },
3793
+ React__default["default"].createElement(InputDate.InputDate, Object.assign({ name: value, error: Boolean(error), locale: locale, "data-extra": true, "data-name": value, "data-control": "date", className: "leadgen-form_field_date", labelTuples: labelTuples }, formInputProps))));
3794
+ }
2250
3795
  case 'LinkButtonBlock':
2251
3796
  return (React__default["default"].createElement("div", { key: index },
2252
3797
  React__default["default"].createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
2253
- React__default["default"].createElement(index$3.Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
3798
+ React__default["default"].createElement(index$9.Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
2254
3799
  onClose === null || onClose === void 0 ? void 0 : onClose();
2255
3800
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2256
3801
  } }, value))));
@@ -2289,7 +3834,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2289
3834
  label: l.placeholder,
2290
3835
  })) }, form.getInputProps(value)))));
2291
3836
  case 'TncBlock':
2292
- const _c = form.getInputProps(`TNC-${id}`), { error } = _c, tncInputProps = tslib_es6.__rest(_c, ["error"]);
3837
+ const _d = form.getInputProps(`TNC-${id}`), { error } = _d, tncInputProps = tslib_es6.__rest(_d, ["error"]);
2293
3838
  return (React__default["default"].createElement(ChoiceField, { className: "leadgen-form_checkbox", key: id },
2294
3839
  React__default["default"].createElement(core.Input.Wrapper, { error: error },
2295
3840
  React__default["default"].createElement(index$2.Checkbox, Object.assign({ name: 'TNC-' + id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps)))));
@@ -2399,6 +3944,7 @@ const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
2399
3944
  };
2400
3945
 
2401
3946
  const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
3947
+ const { primaryColor } = React.useContext(LeadGenContext$1);
2402
3948
  const { t } = index.useTranslations();
2403
3949
  const phone = otpData.phone;
2404
3950
  const otpType = otpData.type;
@@ -2481,711 +4027,374 @@ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
2481
4027
  // pushNotifications({
2482
4028
  // title: res?._messages[0] || defaultError,
2483
4029
  // message: '',
2484
- // type: 'danger',
2485
- // })
2486
- }
2487
- setIsSubmitLoading(false);
2488
- });
2489
- React.useEffect(() => {
2490
- setTimeout(() => {
2491
- if (resendTimer > 0) {
2492
- setResendTimer((r) => r - 1);
2493
- }
2494
- }, 1000);
2495
- }, [resendTimer]);
2496
- React.useEffect(() => {
2497
- if (autoSendWhenOpen && !resendTimer) {
2498
- sendOtp();
2499
- }
2500
- }, []);
2501
- return (React__default["default"].createElement("form", { onSubmit: (e) => {
2502
- e.preventDefault();
2503
- submitOtp();
2504
- }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
2505
- React__default["default"].createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
2506
- phone: `<strong>${displayPhone}</strong>`,
2507
- }), footer: React__default["default"].createElement(React__default["default"].Fragment, null,
2508
- React__default["default"].createElement(core.Button, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
2509
- React__default["default"].createElement(core.Button, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, onClick: () => {
2510
- sendOtp();
2511
- }, disabled: !!resendTimer }, t('lead.otp.resend', {
2512
- timer: resendTimer ? ` (${resendTimer}s)` : '',
2513
- }))) },
2514
- React__default["default"].createElement("div", { className: "leadgen-form_inner" },
2515
- React__default["default"].createElement(index$2.Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
2516
- React__default["default"].createElement(index$2.OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
2517
- setIsDirty(true);
2518
- setOtp(v.toString());
2519
- if (isDirty && !v)
2520
- setErrorMsg('OTP is required');
2521
- else
2522
- setErrorMsg(undefined);
2523
- } }))))));
2524
- };
2525
-
2526
- // url: imageBlocks.imageMobile.data.url
2527
- // newTab: imageBlocks.imageMobile.data.newtab
2528
- // image: campaignShow.image
2529
- // imageDestkop: campaignShow.image_desktop
2530
- const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
2531
- LEADGEN_LAYOUT.Fullscreen,
2532
- LEADGEN_LAYOUT.Slider,
2533
- ];
2534
- const LEADGEN_LIMIT_LIGHTBOXB = 6;
2535
- const LEADGEN_SHOW_HEADER = [
2536
- 'LightBoxA',
2537
- 'InlineA',
2538
- LEADGEN_LAYOUT.Sidebar,
2539
- LEADGEN_LAYOUT.Slider,
2540
- ];
2541
- const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2542
- var _a;
2543
- const { isMobile } = useScreenSize.useScreenSize();
2544
- const [open, setOpen] = React.useState(!!campaignId);
2545
- const [showOtpPhone, setShowOtpPhone] = React.useState(null);
2546
- const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
2547
- const [snap, setSnap] = React.useState(0.8);
2548
- const formRef = React.useRef();
2549
- const onClose = () => {
2550
- if (showOtpPhone) {
2551
- setShowOtpPhone(null);
2552
- }
2553
- else {
2554
- onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2555
- }
2556
- };
2557
- const textBlocks = JSON.parse(extraFields.textBlocks);
2558
- const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
2559
- const actionBlocks = JSON.parse(extraFields.actionBlocks);
2560
- const popUpSubmitText = actionBlocks.submitBlock.data.value;
2561
- const currentPath = location.pathname;
2562
- const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
2563
- const { align: titleAlign } = textBlocks.titleBlock.data || {};
2564
- const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
2565
- const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
2566
- const isLightBox = currentLayout.includes('LightBox');
2567
- const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
2568
- const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
2569
- const isInline = currentLayout.includes('Inline');
2570
- const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
2571
- const isInPage = isInline || isSidebar;
2572
- const isDrawer = isLightBoxB && isMobile;
2573
- const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
2574
- const hasForm = isLightBoxA
2575
- ? listBlockAdded.some((item) => LEADGEN_BLOCK_IN_FORM.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
2576
- : true;
2577
- const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
2578
- const showHeader = !!imageMobile || !!imageDesktop;
2579
- const onlyHeader = !title && !description;
2580
- const showButtonClose = !isInline;
2581
- if (window.innerWidth < 769 &&
2582
- LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
2583
- console.log('😎 Not show fullscreen, slider on mobile ');
2584
- return null;
2585
- }
2586
- React.useEffect(() => {
2587
- if (isLightBox || isFullscreen) {
2588
- document.body.classList.add('noscroll');
2589
- }
2590
- if (!window.intlTelInputUtils) {
2591
- require('intl-tel-input/build/js/utils');
2592
- }
2593
- clearCacheUsedEmailOrPhone();
2594
- }, []);
2595
- const validatingPhoneRef = React.useRef(false);
2596
- const validatingEmailRef = React.useRef(false);
2597
- const { form, validateObj } = useLeadFormConfig({
2598
- listBlockAdded,
2599
- validatingPhoneRef,
2600
- validatingEmailRef,
2601
- campaignId,
2602
- campaign_subot_id,
2603
- userInfo,
2604
- });
2605
- const middlewareOnSubmit = (e) => {
2606
- e.preventDefault();
2607
- // mark all as touched to allow validation
2608
- form.setTouched(Object.keys(validateObj).reduce((acc, cur) => {
2609
- acc[cur] = true;
2610
- return acc;
2611
- }, {}));
2612
- if (validatingEmailRef.current || validatingPhoneRef.current) {
2613
- return;
2614
- }
2615
- setTimeout(() => {
2616
- form.onSubmit((v) => {
2617
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2618
- if (Object.keys(form.errors).length)
2619
- return;
2620
- let newShowOtpPhone = null;
2621
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
2622
- // not submit yet, open otp
2623
- 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;
2624
- if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
2625
- newShowOtpPhone = {
2626
- phone: v[fieldName],
2627
- type: 'phone',
2628
- };
2629
- }
2630
- }
2631
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
2632
- // not submit yet, open otp
2633
- 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;
2634
- if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
2635
- newShowOtpPhone = {
2636
- phone: v[fieldName],
2637
- type: 'whatsapp',
2638
- };
2639
- }
2640
- }
2641
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
2642
- // not submit yet, open otp
2643
- 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;
2644
- if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
2645
- newShowOtpPhone = {
2646
- phone: v[fieldName],
2647
- type: 'zalo',
2648
- };
2649
- }
2650
- }
2651
- if (newShowOtpPhone) {
2652
- setIsSubmitLoading(true);
2653
- Service.sendSMSOtpLead(newShowOtpPhone)
2654
- .then((res) => {
2655
- var _a;
2656
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2657
- if (respMessage === 'This phone number was verified') {
2658
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2659
- return;
2660
- }
2661
- setShowOtpPhone(newShowOtpPhone);
2662
- })
2663
- .finally(() => {
2664
- setIsSubmitLoading(false);
2665
- });
2666
- return;
2667
- }
2668
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2669
- })(e);
2670
- }, 100);
2671
- };
2672
- const onOpenChange = (_open) => {
2673
- setOpen(_open);
2674
- if (!_open) {
2675
- setTimeout(() => {
2676
- onClose();
2677
- }, 250);
2678
- }
2679
- };
2680
- const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
2681
- const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
2682
- const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
2683
- const renderAfterImageSizes = imageMobileLoaded &&
2684
- imageDesktopLoaded &&
2685
- (isFullscreen ? imageBackgroundLoaded : true);
2686
- const ButtonSubmit = !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default["default"].createElement(core.Button, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
2687
- const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
2688
- const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default["default"].createElement(React__default["default"].Fragment, null, LinkButtonBlock.map((item, index) => {
2689
- var _a, _b, _c;
2690
- return (React__default["default"].createElement(core.Button, { 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", onClick: () => {
2691
- onClose === null || onClose === void 0 ? void 0 : onClose();
2692
- onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2693
- } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
2694
- })));
2695
- const PopupHeader = showHeader && (React__default["default"].createElement("header", { className: core.clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default["default"].createElement(React__default["default"].Fragment, null,
2696
- React__default["default"].createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
2697
- React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
2698
- const PopupEmpty = showEmpty && (React__default["default"].createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
2699
- const PopupForm = (React__default["default"].createElement(LeadFormProvider, { form: form },
2700
- React__default["default"].createElement("form", { ref: formRef, className: "leadgen-form", onSubmit: middlewareOnSubmit },
2701
- React__default["default"].createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
2702
- React__default["default"].createElement("div", { className: "leadgen-form_inner" },
2703
- React__default["default"].createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
2704
- const PopupOtp = showOtpPhone && (React__default["default"].createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
2705
- setShowOtpPhone(null);
2706
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
2707
- } }));
2708
- const PopupThankYou = showThankyou && (React__default["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 }));
2709
- const PopupContent = (React__default["default"].createElement("div", { className: core.clsx('leadgen-content', {
2710
- 'leadgen-content_small': limitFieldsLightBoxB,
2711
- }) },
2712
- !headerInsideFormContainer && PopupHeader,
2713
- !onlyHeader && (React__default["default"].createElement("div", { className: "leadgen-inner" },
2714
- PopupThankYou,
2715
- !showThankyou && (React__default["default"].createElement(React__default["default"].Fragment, null,
2716
- PopupOtp,
2717
- PopupEmpty,
2718
- !(showOtpPhone || showEmpty) && PopupForm))))));
2719
- const styleOverlay = React.useMemo(() => {
2720
- let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
2721
- if (isMobile && imageOverlayMobile) {
2722
- styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
2723
- }
2724
- if (!isMobile && imageOverlayDesktop) {
2725
- styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4030
+ // type: 'danger',
4031
+ // })
2726
4032
  }
2727
- return styleContent;
2728
- }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
2729
- const PopupWrapper = (React__default["default"].createElement(React__default["default"].Fragment, null,
2730
- React__default["default"].createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
2731
- React__default["default"].createElement("div", { className: core.clsx('leadgen-wrapper', {
2732
- 'leadgen-wrapper_small': limitFieldsLightBoxB,
2733
- }) },
2734
- showButtonClose && (React__default["default"].createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
2735
- PopupContent)));
2736
- const popupContainerClassName = core.clsx('leadgen', `leadgen-${currentLayout}`, {
2737
- 'leadgen-lightbox': isLightBox,
2738
- 'leadgen-inline': isInPage,
2739
- 'leadgen-slider': isSlider,
4033
+ setIsSubmitLoading(false);
2740
4034
  });
2741
- const PopupContainer = isDrawer ? (React__default["default"].createElement(index$9.DrawerComponent, { fadeFromIndex: index$8.ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
2742
- PopupWrapper,
2743
- React__default["default"].createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default["default"].createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
2744
- isFullscreen ? (React__default["default"].createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
2745
- aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
2746
- } })) : null,
2747
- PopupWrapper));
2748
- if (!renderAfterImageSizes)
2749
- return null;
2750
- if (isLightBox || isFullscreen || isSlider) {
2751
- return PopupContainer;
2752
- }
2753
- else if (isSidebar) {
2754
- return React__default["default"].createElement(SideBarLayout, { content: PopupContainer });
2755
- }
2756
- else if (isInline) {
2757
- return (React__default["default"].createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
2758
- }
2759
- return null;
2760
- };
2761
-
2762
- const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
2763
- const currentPath = location.pathname;
2764
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
2765
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
2766
- if (!imageMobileLoaded || !imageDesktopLoaded)
2767
- return null;
2768
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
2769
- currentLayout == 'SkinA' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
2770
- React__default["default"].createElement("div", { className: "le-skin-a-desktop" },
2771
- React__default["default"].createElement("div", { style: { position: 'relative' } },
2772
- React__default["default"].createElement("img", { src: imageDesktop, style: {
2773
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2774
- } }),
2775
- React__default["default"].createElement("a", { style: {
2776
- position: 'absolute',
2777
- top: '75%',
2778
- left: '50%',
2779
- transform: 'translate(-50%, -50%)',
2780
- textAlign: 'center',
2781
- width: 'calc(100% - 15px)',
2782
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2783
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
2784
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
2785
- React__default["default"].createElement("div", { className: "" },
2786
- React__default["default"].createElement("div", { style: { position: 'relative', zIndex: 10000 } },
2787
- React__default["default"].createElement("img", { src: imageDesktop, style: {
2788
- width: '100%',
2789
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2790
- } }),
2791
- React__default["default"].createElement("a", { style: {
2792
- position: 'absolute',
2793
- top: '75%',
2794
- left: '50%',
2795
- transform: 'translate(-50%, -50%)',
2796
- textAlign: 'center',
2797
- width: '100%',
2798
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2799
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2800
- React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
2801
- React__default["default"].createElement("aside", { className: "le-only-mobile" },
2802
- React__default["default"].createElement("div", { className: "le-skin-mobile" },
2803
- React__default["default"].createElement("div", { style: { position: 'relative' } },
2804
- index$7.isVideo(imageMobile) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true },
2805
- React__default["default"].createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default["default"].createElement("img", { src: imageMobile, style: {
2806
- width: '100%',
2807
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
2808
- } })),
2809
- React__default["default"].createElement("a", { style: {
2810
- position: 'absolute',
2811
- top: '82%',
2812
- left: '50%',
2813
- transform: 'translate(-50%, -50%)',
2814
- textAlign: 'center',
2815
- maxWidth: 'calc(100% - 15px)',
2816
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2817
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2818
- React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4035
+ React.useEffect(() => {
4036
+ setTimeout(() => {
4037
+ if (resendTimer > 0) {
4038
+ setResendTimer((r) => r - 1);
4039
+ }
4040
+ }, 1000);
4041
+ }, [resendTimer]);
4042
+ React.useEffect(() => {
4043
+ if (autoSendWhenOpen && !resendTimer) {
4044
+ sendOtp();
4045
+ }
4046
+ }, []);
4047
+ return (React__default["default"].createElement("form", { onSubmit: (e) => {
4048
+ e.preventDefault();
4049
+ submitOtp();
4050
+ }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
4051
+ React__default["default"].createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
4052
+ phone: `<strong>${displayPhone}</strong>`,
4053
+ }), footer: React__default["default"].createElement(React__default["default"].Fragment, null,
4054
+ React__default["default"].createElement(core.Button, { 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')),
4055
+ React__default["default"].createElement(core.Button, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
4056
+ sendOtp();
4057
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
4058
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
4059
+ }))) },
4060
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4061
+ React__default["default"].createElement(index$2.Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
4062
+ React__default["default"].createElement(index$2.OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
4063
+ setIsDirty(true);
4064
+ setOtp(v.toString());
4065
+ if (isDirty && !v)
4066
+ setErrorMsg('OTP is required');
4067
+ else
4068
+ setErrorMsg(undefined);
4069
+ } }))))));
2819
4070
  };
2820
4071
 
2821
4072
  // url: imageBlocks.imageMobile.data.url
2822
4073
  // newTab: imageBlocks.imageMobile.data.newtab
2823
4074
  // image: campaignShow.image
2824
4075
  // imageDestkop: campaignShow.image_desktop
2825
- const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
2826
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
2827
- if (!imageLoaded)
2828
- return null;
2829
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
2830
- React__default["default"].createElement("div", { className: "le-tab-popup" },
2831
- React__default["default"].createElement("div", { style: { position: 'relative' } },
2832
- React__default["default"].createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
2833
- React__default["default"].createElement("img", { className: "js-popup-other-submit", src: image, style: {
2834
- aspectRatio: `${imageWidth}/${imageHeight}`,
2835
- } })),
2836
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
2837
- };
2838
-
2839
- // import mockLeadData from './mockLeadData'
2840
- const listCampaignScheduled = [];
2841
- const listCampaignScheduledToActivated = [];
2842
- const listCampaignActiveButExpired = [];
2843
- const listCampaignExcludeSonsored = [];
2844
- const listCampaignDifferentSponsor = [];
2845
- const listCampaignNotDisplayInRangeOfTime = [];
2846
- function isMobile() {
2847
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
2848
- }
2849
- const getShuffleArray = (array) => {
2850
- const newArray = [...array];
2851
- for (let i = newArray.length - 1; i > 0; i--) {
2852
- const j = Math.floor(Math.random() * (i + 1));
2853
- const temp = newArray[i];
2854
- newArray[i] = newArray[j];
2855
- newArray[j] = temp;
2856
- }
2857
- return newArray;
2858
- };
2859
- const getTimeByTimezone = (timeZone = 'UTC') => {
2860
- const date = new Date();
2861
- return new Date(date.toLocaleString('en-US', { timeZone }));
2862
- };
2863
- const parseDateByCampaignTime = (dateStr) => {
2864
- // Format like this: 2023-04-04 00:00:00
2865
- try {
2866
- const [datePart, timePart] = dateStr.split(' ');
2867
- const [year, month, day] = datePart.split('-').map(Number);
2868
- const [hours, minutes, seconds] = timePart.split(':').map(Number);
2869
- /** JavaScript counts months from 0 to 11 */
2870
- return new Date(year, month - 1, day, hours, minutes, seconds);
2871
- }
2872
- catch (err) {
2873
- return null;
2874
- }
2875
- };
2876
- const checkCampaignNowInTimeframe = (c) => {
2877
- var _a;
2878
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2879
- const startedAtStr = c.started_at;
2880
- const endedAtStr = c.ended_at;
2881
- const startedDate = parseDateByCampaignTime(startedAtStr);
2882
- const endedDate = parseDateByCampaignTime(endedAtStr);
2883
- if (!startedDate || !endedDate) {
2884
- return false;
2885
- }
2886
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
2887
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2888
- if (nowWithTimezoneMs <= endedDate.getTime() &&
2889
- nowWithTimezoneMs >= startedDate.getTime()) {
2890
- listCampaignScheduledToActivated.push(c);
2891
- return true;
2892
- }
2893
- return false;
2894
- };
2895
- function checkCampaignActiveButExpireAlready(c) {
2896
- var _a;
2897
- /** Do not setup timeframe for this campaign. No need to check */
2898
- if (c.forever === 1) {
2899
- return true;
2900
- }
2901
- const startedAtStr = c.started_at;
2902
- const endedAtStr = c.ended_at;
2903
- const startedDate = parseDateByCampaignTime(startedAtStr);
2904
- const endedDate = parseDateByCampaignTime(endedAtStr);
2905
- /** Do not setup timeframe for this campaign. No need to check */
2906
- if (!startedDate || !endedDate) {
2907
- return true;
2908
- }
2909
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2910
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
2911
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2912
- /** Check if this expire already, do not show */
2913
- if (nowWithTimezoneMs > endedDate.getTime()) {
2914
- listCampaignActiveButExpired.push(c);
2915
- return false;
2916
- }
2917
- return true;
2918
- }
2919
- function shouldNotDisplayIfExcludeAllSponsors(c) {
2920
- var _a;
2921
- const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
2922
- const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
2923
- if (isSponsored && excludeSponsored) {
2924
- listCampaignExcludeSonsored.push(c);
2925
- return true;
2926
- }
2927
- return false;
2928
- }
2929
- function shouldDisplayWithCurrentSponsor(c) {
4076
+ const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
4077
+ LEADGEN_LAYOUT.Fullscreen,
4078
+ LEADGEN_LAYOUT.Slider,
4079
+ ];
4080
+ const LEADGEN_LIMIT_LIGHTBOXB = 6;
4081
+ const LEADGEN_SHOW_HEADER = [
4082
+ 'LightBoxA',
4083
+ 'InlineA',
4084
+ LEADGEN_LAYOUT.Sidebar,
4085
+ LEADGEN_LAYOUT.Slider,
4086
+ ];
4087
+ const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2930
4088
  var _a, _b;
2931
- try {
2932
- // TODO: BE will rename `exclude_sponsored_list` later
2933
- const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
2934
- const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
2935
- const dataSponsoredId = Number((_b = document
2936
- .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
2937
- // There is no config for sponsor id and white list, should show as default
2938
- if (!dataSponsoredId ||
2939
- dataSponsoredId <= 0 ||
2940
- whiteListSponsors.length === 0) {
2941
- return true;
4089
+ const { primaryColor } = React.useContext(LeadGenContext$1);
4090
+ const { isMobile } = useScreenSize.useScreenSize();
4091
+ const [open, setOpen] = React.useState(!!campaignId);
4092
+ const [showOtpPhone, setShowOtpPhone] = React.useState(null);
4093
+ const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
4094
+ const [snap, setSnap] = React.useState(0.8);
4095
+ const formRef = React.useRef();
4096
+ const onClose = () => {
4097
+ if (showOtpPhone) {
4098
+ setShowOtpPhone(null);
2942
4099
  }
2943
- // Check the dataSponsoredId exists in the white list or not.
2944
- const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
2945
- if (isExist) {
2946
- return true;
4100
+ else {
4101
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2947
4102
  }
2948
- listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
2949
- return false;
2950
- }
2951
- catch (err) {
2952
- // Default is show
2953
- return true;
2954
- }
2955
- }
2956
- const filterFnCampaign = (c) => {
2957
- if (shouldNotDisplayIfExcludeAllSponsors(c)) {
2958
- return false;
2959
- }
2960
- else if (!shouldDisplayWithCurrentSponsor(c)) {
2961
- return false;
2962
- }
2963
- /** Active */
2964
- if (c.formatted_status === 1) {
2965
- return checkCampaignActiveButExpireAlready(c);
2966
- }
2967
- /** Schedule */
2968
- if (c.formatted_status === 0) {
2969
- listCampaignScheduled.push(c);
2970
- return checkCampaignNowInTimeframe(c);
4103
+ };
4104
+ const textBlocks = JSON.parse(extraFields.textBlocks);
4105
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
4106
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
4107
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
4108
+ const currentPath = location.pathname;
4109
+ const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
4110
+ const { align: titleAlign } = textBlocks.titleBlock.data || {};
4111
+ const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
4112
+ const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
4113
+ const isLightBox = currentLayout.includes('LightBox');
4114
+ const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
4115
+ const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
4116
+ const isInline = currentLayout.includes('Inline');
4117
+ const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
4118
+ const isInPage = isInline || isSidebar;
4119
+ const isDrawer = isLightBoxB && isMobile;
4120
+ const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
4121
+ const hasForm = isLightBoxA
4122
+ ? listBlockAdded.some((item) => LEADGEN_BLOCK_INPUT.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
4123
+ : true;
4124
+ const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
4125
+ const showHeader = !!imageMobile || !!imageDesktop;
4126
+ const onlyHeader = !title && !description;
4127
+ const showButtonClose = !isInline;
4128
+ if (window.innerWidth < 769 &&
4129
+ LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
4130
+ console.log('😎 Not show fullscreen, slider on mobile ');
4131
+ return null;
2971
4132
  }
2972
- return false;
2973
- };
2974
- const fillterApprearanceTimeCampaign = (c) => {
2975
- var _a;
2976
- try {
2977
- const isTimeInRange = (currentTime, startTime, endTime) => {
2978
- const startParts = startTime.split(':');
2979
- const endParts = endTime.split(':');
2980
- const startDate = new Date();
2981
- startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
2982
- const endDate = new Date();
2983
- endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
2984
- return currentTime >= startDate && currentTime <= endDate;
2985
- };
2986
- const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
2987
- const startTime = rulesApprValue.startTime;
2988
- const endTime = rulesApprValue.endTime || '23:59';
2989
- if (!startTime) {
2990
- return true;
4133
+ React.useEffect(() => {
4134
+ if (isLightBox || isFullscreen) {
4135
+ document.body.classList.add('noscroll');
2991
4136
  }
2992
- if (isTimeInRange(new Date(), startTime, endTime)) {
2993
- return true;
4137
+ if (!window.intlTelInputUtils) {
4138
+ require('intl-tel-input/build/js/utils');
2994
4139
  }
2995
- listCampaignNotDisplayInRangeOfTime.push(c);
2996
- return false;
2997
- }
2998
- catch (err) {
2999
- return true;
3000
- }
3001
- };
3002
- let timeoutRef = null;
3003
- let LEAD_SCROLL_EVENT = null;
3004
- function clearPassiveEvent() {
3005
- if (timeoutRef) {
3006
- clearTimeout(timeoutRef);
3007
- timeoutRef = null;
3008
- }
3009
- if (LEAD_SCROLL_EVENT) {
3010
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3011
- LEAD_SCROLL_EVENT = null;
3012
- }
3013
- }
3014
- function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
3015
- // clear previous passive event, check for new condition
3016
- clearPassiveEvent();
3017
- const leadCurrentUrl = DEBUG_URL ||
3018
- ('https://' +
3019
- location.hostname +
3020
- location.pathname +
3021
- location.search).toLowerCase();
3022
- fetch(leadApi + 'api/campaign/' + leadSiteId, {
3023
- method: 'POST',
3024
- headers: {
3025
- 'Content-Type': 'application/json',
3026
- },
3027
- body: JSON.stringify({
3028
- url: leadCurrentUrl,
3029
- ga_client_id: miscCookieHelper.getCookie('_ga') || null,
3030
- }),
3031
- })
3032
- .then((response) => {
3033
- return response.json();
3034
- // return mockLeadData || response.json()
3035
- })
3036
- .then((data) => {
3037
- var _a, _b, _c, _d;
3038
- LeadLog('List campagin: ', data);
3039
- LEAD_RESET_VAR();
3040
- if (data._status == 1) {
3041
- 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);
3042
- if (!miscCookieHelper.getCookie('hhg-id')) {
3043
- miscCookieHelper.setCookie('hhg-id', uuid.v1(), {
3044
- domain: '.' + leadDomain,
3045
- path: '/',
3046
- });
3047
- LeadLog('😍 Set HHG ID cookie');
3048
- }
3049
- // getCookie('hhg-id')
3050
- // TODO: HP-534 Filter desktop
3051
- let campaignsDevice = [];
3052
- if (isMobile()) {
3053
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
3054
- }
3055
- else {
3056
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
3057
- }
3058
- LeadLog(`👓 campaignsDevice`, campaignsDevice);
3059
- LeadLog('--listCampaignScheduled', listCampaignScheduled);
3060
- LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
3061
- LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
3062
- LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
3063
- LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
3064
- LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
3065
- // Check links
3066
- let listLinksObj = campaignsDevice
3067
- .map((i, index) => i.targets
3068
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
3069
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3070
- .flat(1);
3071
- // Check list link match current href
3072
- listLinksObj = listLinksObj.filter((i) => {
3073
- var _a;
3074
- const target = new URL(String(i.target).toLowerCase());
3075
- if (i.option == 'exact_match')
3076
- // FOR TEST LOCAL:
3077
- // return Boolean(location.pathname === target.pathname)
3078
- return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
3079
- if (i.option == 'start_with') {
3080
- // FOR TEST LOCAL:
3081
- // if (location.pathname.includes(target.pathname)) {
3082
- if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
3083
- const listExcluding = i.sub_target
3084
- .filter((i) => i.option == 'excluding')
3085
- .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
3086
- return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
3087
- }
3088
- else {
3089
- return false;
3090
- }
3091
- }
3092
- });
3093
- // Check tags
3094
- const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
3095
- const listTags = listMetaTag.map((i) => i.content);
3096
- let listCampaignHasTag = [];
3097
- let listTagsObj = [];
3098
- if (listTags && listTags.length) {
3099
- listCampaignHasTag = campaignsDevice
3100
- .map((i, index) => i.targets
3101
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
3102
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3103
- .flat(1);
3104
- listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
3105
- }
3106
- const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
3107
- const cookieKeys = document.cookie
3108
- .split('; ')
3109
- .map((i) => i.split('=')[0]);
3110
- const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
3111
- LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
3112
- const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
3113
- LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
3114
- const listCampaignSubmitedClosed = [
3115
- ...listCampaignCodeSubmited,
3116
- ...listCampaignCodeClosed,
3117
- ];
3118
- const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
3119
- const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
3120
- return !hasSubmited;
3121
- });
3122
- const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
3123
- // .sort(
3124
- // (a, b) =>
3125
- // (listCampaignValid[a.campaignIndex]?.score || 0) -
3126
- // (listCampaignValid[b.campaignIndex]?.score || 0),
3127
- // )
3128
- LeadLog('--listCampaignValid : ', listCampaignValid);
3129
- if (listCampaignValid && listCampaignValid.length) {
3130
- const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
3131
- LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
3132
- const { rules } = CAMPAIGN_SHOW;
3133
- // CHECK RULE TRIGGER POPUP
3134
- const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
3135
- LeadLog(`timeoutRule`, timeoutRule);
3136
- const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
3137
- LeadLog(`scrollRule`, scrollRule);
3138
- let impressionAction = 'TIME';
3139
- if (Number.isInteger(timeoutRule)) {
3140
- impressionAction = 'TIME';
3141
- LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
3142
- timeoutRef = setTimeout(() => {
3143
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3144
- }, timeoutRule * 1000);
4140
+ clearCacheUsedEmailOrPhone();
4141
+ }, []);
4142
+ const validatingPhoneRef = React.useRef(false);
4143
+ const validatingEmailRef = React.useRef(false);
4144
+ const { form, validateObj } = useLeadFormConfig({
4145
+ listBlockAdded,
4146
+ validatingPhoneRef,
4147
+ validatingEmailRef,
4148
+ campaignId,
4149
+ campaign_subot_id,
4150
+ userInfo,
4151
+ format: (_a = (index$6.ISO_FORMAT[locale] || index$6.ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
4152
+ });
4153
+ const onFocus = (e) => {
4154
+ const target = e.target;
4155
+ target.scrollIntoView({
4156
+ block: 'center',
4157
+ inline: 'nearest',
4158
+ behavior: 'auto',
4159
+ });
4160
+ };
4161
+ const middlewareOnSubmit = (e) => {
4162
+ e.preventDefault();
4163
+ // mark all as touched to allow validation
4164
+ const fields = Object.keys(validateObj);
4165
+ const fieldStatus = fields.reduce((acc, cur) => {
4166
+ acc[cur] = true;
4167
+ return acc;
4168
+ }, {});
4169
+ form.setTouched(fieldStatus);
4170
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
4171
+ return;
4172
+ }
4173
+ setTimeout(() => {
4174
+ form.onSubmit((v) => {
4175
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4176
+ if (Object.keys(form.errors).length)
4177
+ return;
4178
+ let newShowOtpPhone = null;
4179
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
4180
+ // not submit yet, open otp
4181
+ 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;
4182
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
4183
+ newShowOtpPhone = {
4184
+ phone: v[fieldName],
4185
+ type: 'phone',
4186
+ };
4187
+ }
3145
4188
  }
3146
- if (Number.isInteger(scrollRule)) {
3147
- impressionAction = 'SCROLL';
3148
- LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
3149
- const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
3150
- document.querySelector('body');
3151
- const pct = $p.getBoundingClientRect().top;
3152
- const pb = $p.offsetHeight;
3153
- LeadLog(`👓 Element check scroll: `, $p);
3154
- LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
3155
- const wt = window.pageYOffset || document.documentElement.scrollTop;
3156
- let percent = 0;
3157
- if (wt >= pct) {
3158
- percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
3159
- }
3160
- LeadLog('---Scroll', percent, scrollRule);
3161
- // TODO: CHECK FOOTER HEIGHT
3162
- if (percent >= scrollRule) {
3163
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3164
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
4189
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
4190
+ // not submit yet, open otp
4191
+ 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;
4192
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
4193
+ newShowOtpPhone = {
4194
+ phone: v[fieldName],
4195
+ type: 'whatsapp',
4196
+ };
4197
+ }
4198
+ }
4199
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
4200
+ // not submit yet, open otp
4201
+ 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;
4202
+ if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
4203
+ newShowOtpPhone = {
4204
+ phone: v[fieldName],
4205
+ type: 'zalo',
4206
+ };
4207
+ }
4208
+ }
4209
+ if (newShowOtpPhone) {
4210
+ setIsSubmitLoading(true);
4211
+ Service.sendSMSOtpLead(newShowOtpPhone)
4212
+ .then((res) => {
4213
+ var _a;
4214
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4215
+ if (respMessage === 'This phone number was verified') {
4216
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4217
+ return;
3165
4218
  }
3166
- };
3167
- window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
3168
- passive: true,
4219
+ setShowOtpPhone(newShowOtpPhone);
4220
+ })
4221
+ .finally(() => {
4222
+ setIsSubmitLoading(false);
3169
4223
  });
4224
+ return;
3170
4225
  }
3171
- }
3172
- else {
3173
- LeadLog('🚧 No lead campaigns on current URL, tags');
3174
- }
4226
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4227
+ })(e);
4228
+ }, 100);
4229
+ };
4230
+ const onOpenChange = (_open) => {
4231
+ setOpen(_open);
4232
+ if (!_open) {
4233
+ setTimeout(() => {
4234
+ onClose();
4235
+ }, 250);
3175
4236
  }
3176
- })
3177
- .catch((err) => {
3178
- LeadLog(`Lead error: `, err);
4237
+ };
4238
+ const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
4239
+ const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
4240
+ const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
4241
+ const renderAfterImageSizes = imageMobileLoaded &&
4242
+ imageDesktopLoaded &&
4243
+ (isFullscreen ? imageBackgroundLoaded : true);
4244
+ const ButtonSubmit = React.useMemo(() => {
4245
+ var _a;
4246
+ return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default["default"].createElement(core.Button, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
4247
+ }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
4248
+ const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
4249
+ const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default["default"].createElement(React__default["default"].Fragment, null, LinkButtonBlock.map((item, index) => {
4250
+ var _a, _b, _c;
4251
+ return (React__default["default"].createElement(core.Button, { 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: () => {
4252
+ onClose === null || onClose === void 0 ? void 0 : onClose();
4253
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
4254
+ } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
4255
+ })));
4256
+ const PopupHeader = showHeader && (React__default["default"].createElement("header", { className: core.clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default["default"].createElement(React__default["default"].Fragment, null,
4257
+ React__default["default"].createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
4258
+ React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
4259
+ const PopupEmpty = showEmpty && (React__default["default"].createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
4260
+ const PopupForm = (React__default["default"].createElement(LeadFormProvider, { form: form },
4261
+ React__default["default"].createElement("form", { ref: formRef, className: "leadgen-form", onFocus: onFocus, onSubmit: middlewareOnSubmit },
4262
+ React__default["default"].createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
4263
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4264
+ React__default["default"].createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
4265
+ const PopupOtp = showOtpPhone && (React__default["default"].createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
4266
+ setShowOtpPhone(null);
4267
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
4268
+ } }));
4269
+ const PopupThankYou = showThankyou && (React__default["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 }));
4270
+ const PopupContent = (React__default["default"].createElement("div", { className: core.clsx('leadgen-content', {
4271
+ 'leadgen-content_small': limitFieldsLightBoxB,
4272
+ }) },
4273
+ !headerInsideFormContainer && PopupHeader,
4274
+ !onlyHeader && (React__default["default"].createElement("div", { className: "leadgen-inner" },
4275
+ PopupThankYou,
4276
+ !showThankyou && (React__default["default"].createElement(React__default["default"].Fragment, null,
4277
+ PopupOtp,
4278
+ PopupEmpty,
4279
+ !(showOtpPhone || showEmpty) && PopupForm))))));
4280
+ const styleOverlay = React.useMemo(() => {
4281
+ let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
4282
+ if (isMobile && imageOverlayMobile) {
4283
+ styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4284
+ }
4285
+ if (!isMobile && imageOverlayDesktop) {
4286
+ styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4287
+ }
4288
+ return styleContent;
4289
+ }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
4290
+ const PopupWrapper = (React__default["default"].createElement(React__default["default"].Fragment, null,
4291
+ React__default["default"].createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
4292
+ React__default["default"].createElement("div", { className: core.clsx('leadgen-wrapper', {
4293
+ 'leadgen-wrapper_small': limitFieldsLightBoxB,
4294
+ }) },
4295
+ showButtonClose && (React__default["default"].createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
4296
+ PopupContent)));
4297
+ const popupContainerClassName = core.clsx('leadgen', `leadgen-${currentLayout}`, {
4298
+ 'leadgen-lightbox': isLightBox,
4299
+ 'leadgen-inline': isInPage,
4300
+ 'leadgen-slider': isSlider,
3179
4301
  });
3180
- }
3181
- const LeadLog = (...params) => {
3182
- if (process.env.NODE_ENV !== 'production' ||
3183
- (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
3184
- process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
3185
- (typeof localStorage !== 'undefined' &&
3186
- localStorage.getItem('hhg_debug') === 'true')) {
3187
- console.log(...params);
4302
+ const PopupContainer = isDrawer ? (React__default["default"].createElement(index$a.DrawerComponent, { fadeFromIndex: index$6.ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
4303
+ PopupWrapper,
4304
+ React__default["default"].createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default["default"].createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
4305
+ isFullscreen ? (React__default["default"].createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
4306
+ aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
4307
+ } })) : null,
4308
+ PopupWrapper));
4309
+ if (!renderAfterImageSizes)
4310
+ return null;
4311
+ if (isLightBox || isFullscreen || isSlider) {
4312
+ return PopupContainer;
4313
+ }
4314
+ else if (isSidebar) {
4315
+ return React__default["default"].createElement(SideBarLayout, { content: PopupContainer });
4316
+ }
4317
+ else if (isInline) {
4318
+ return (React__default["default"].createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
3188
4319
  }
4320
+ return null;
4321
+ };
4322
+
4323
+ const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
4324
+ const currentPath = location.pathname;
4325
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
4326
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
4327
+ if (!imageMobileLoaded || !imageDesktopLoaded)
4328
+ return null;
4329
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
4330
+ currentLayout == 'SkinA' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4331
+ React__default["default"].createElement("div", { className: "le-skin-a-desktop" },
4332
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
4333
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
4334
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4335
+ } }),
4336
+ React__default["default"].createElement("a", { style: {
4337
+ position: 'absolute',
4338
+ top: '75%',
4339
+ left: '50%',
4340
+ transform: 'translate(-50%, -50%)',
4341
+ textAlign: 'center',
4342
+ width: 'calc(100% - 15px)',
4343
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4344
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
4345
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4346
+ React__default["default"].createElement("div", { className: "" },
4347
+ React__default["default"].createElement("div", { style: { position: 'relative', zIndex: 10000 } },
4348
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
4349
+ width: '100%',
4350
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4351
+ } }),
4352
+ React__default["default"].createElement("a", { style: {
4353
+ position: 'absolute',
4354
+ top: '75%',
4355
+ left: '50%',
4356
+ transform: 'translate(-50%, -50%)',
4357
+ textAlign: 'center',
4358
+ width: '100%',
4359
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4360
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4361
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
4362
+ React__default["default"].createElement("aside", { className: "le-only-mobile" },
4363
+ React__default["default"].createElement("div", { className: "le-skin-mobile" },
4364
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
4365
+ index$7.isVideo(imageMobile) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true },
4366
+ React__default["default"].createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default["default"].createElement("img", { src: imageMobile, style: {
4367
+ width: '100%',
4368
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
4369
+ } })),
4370
+ React__default["default"].createElement("a", { style: {
4371
+ position: 'absolute',
4372
+ top: '82%',
4373
+ left: '50%',
4374
+ transform: 'translate(-50%, -50%)',
4375
+ textAlign: 'center',
4376
+ maxWidth: 'calc(100% - 15px)',
4377
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4378
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4379
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4380
+ };
4381
+
4382
+ // url: imageBlocks.imageMobile.data.url
4383
+ // newTab: imageBlocks.imageMobile.data.newtab
4384
+ // image: campaignShow.image
4385
+ // imageDestkop: campaignShow.image_desktop
4386
+ const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
4387
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
4388
+ if (!imageLoaded)
4389
+ return null;
4390
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
4391
+ React__default["default"].createElement("div", { className: "le-tab-popup" },
4392
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
4393
+ React__default["default"].createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
4394
+ React__default["default"].createElement("img", { className: "js-popup-other-submit", src: image, style: {
4395
+ aspectRatio: `${imageWidth}/${imageHeight}`,
4396
+ } })),
4397
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3189
4398
  };
3190
4399
 
3191
4400
  function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
@@ -3201,7 +4410,7 @@ function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
3201
4410
  }
3202
4411
  const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, showEmpty, setShowEmpty, userInfo, }) => {
3203
4412
  var _a, _b;
3204
- const { apiUrl, siteDomain } = React.useContext(LeadGenContext);
4413
+ const { apiUrl, siteDomain } = React.useContext(LeadGenContext$1);
3205
4414
  React.useEffect(() => {
3206
4415
  const gaCookie = miscCookieHelper.getCookie('_ga') || null;
3207
4416
  fetch(`${apiUrl}api/campaign/${code}/impression`, {
@@ -3327,7 +4536,7 @@ const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, local
3327
4536
  };
3328
4537
 
3329
4538
  // mount css
3330
- const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl, DEBUG_URL, forceCampaign, children, extraPayloadValues = [], excludeExitRulesHandler, userInfo, onClose: onCloseProps, }) => {
4539
+ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, primaryColor, apiSubotUrl, DEBUG_URL, forceCampaign, children, extraPayloadValues = [], excludeExitRulesHandler, userInfo, onClose: onCloseProps, }) => {
3331
4540
  var _a;
3332
4541
  const scrollEventHandlerRef = React.useRef();
3333
4542
  const leadStartTimeRef = React.useRef(Date.now());
@@ -3596,9 +4805,9 @@ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl,
3596
4805
  leadStartTimeRef.current = Date.now();
3597
4806
  }
3598
4807
  }, [showCampaign]);
3599
- return (React__default["default"].createElement(LeadGenContext.Provider, { value: { apiUrl, siteDomain, siteId, locale } },
4808
+ return (React__default["default"].createElement(LeadGenContext$1.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
3600
4809
  React__default["default"].createElement(translationsContext.TranslationsContext.Provider, { value: { locale, values: getTranslations(locale) } }, children ? (React__default["default"].createElement(Component, { campaign: showCampaign, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, setShowThankyou: setShowThankyou, locale: locale, showEmpty: showEmpty, setShowEmpty: setShowEmpty, userInfo: userInfo }, children)) : (React__default["default"].createElement(core.Portal, { target: utils$1.getPopupWrapperDom() },
3601
- React__default["default"].createElement(core.Box, { sx: { position: 'fixed', zIndex: index$8.ZINDEX_SSO - 9e6 } },
4810
+ React__default["default"].createElement(core.Box, { sx: { position: 'fixed', zIndex: index$6.ZINDEX_SSO - 9e6 } },
3602
4811
  React__default["default"].createElement(core.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) => {
3603
4812
  var _a;
3604
4813
  return (React__default["default"].createElement(core.Box, { style: styles }, ((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1' && (React__default["default"].createElement(React__default["default"].Fragment, null,
@@ -3617,3 +4826,4 @@ LeadGen.OtpForm = OtpBlock$1;
3617
4826
  LeadGen.Close = Close.Close;
3618
4827
 
3619
4828
  exports.LeadGen = LeadGen;
4829
+ exports.LeadGenSubscriptionBox = LeadGenSubscriptionBox;