@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/esm/lead.js CHANGED
@@ -1,51 +1,71 @@
1
- import { _ as __rest, a as __awaiter } from './tslib.es6-8c4c969c.js';
2
- import React__default, { createContext, useMemo, useEffect, useRef, useState, useContext, useCallback } from 'react';
3
- import { createStyles, Box, Button as Button$2, Autocomplete, clsx, Input as Input$1, TextInput, NumberInput as NumberInput$1, Portal, Transition, Overlay } from '@mantine/core';
1
+ import { _ as __rest, a as __awaiter } from './tslib.es6-5338c038.js';
2
+ import React__default, { createContext, useMemo, useEffect, useRef, useState, useContext, useCallback, forwardRef, useImperativeHandle, memo } from 'react';
3
+ import { createStyles, Box, Button as Button$1, Input as Input$1, clsx, Autocomplete, Checkbox as Checkbox$1, Radio as Radio$1, Select as Select$1, TextInput, NumberInput as NumberInput$1, Portal, Transition, Overlay } from '@mantine/core';
4
4
  import dayjs from 'dayjs';
5
5
  import debounce from 'lodash/debounce';
6
- import { createFormContext } from '@mantine/form';
7
- import { u as useTranslations } from './index-b654ee01.js';
8
- import { T as TranslationsContext } from './translationsContext-bc9a8b0f.js';
6
+ import { createFormContext, useForm } from '@mantine/form';
7
+ import { u as useTranslations } from './index-5b650465.js';
8
+ import { T as TranslationsContext } from './translationsContext-8c982b59.js';
9
9
  import { getCookie, setCookie } from './miscCookieHelper.js';
10
- import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-1fb89ecb.js';
11
- import { T as Text } from './index-0d570d50.js';
12
- import { S as Select, d as Checkbox, I as Input, R as Radio, P as Phone, N as NumberInput, O as OTP } from './index-9751851e.js';
13
- import { D as DatePicker } from './index-905f3039.js';
14
- import { M as MAPPED_LOCALE } from './utils-31c67481.js';
15
- import '@mantine/dates';
16
- import { Z as ZINDEX_SSO } from './index-242ee51f.js';
17
- import './index-5675a301.js';
18
- import './index-b5d1257d.js';
19
- import './useMantineLocale-b15f2673.js';
20
- import { B as Button$1 } from './index-31109b68.js';
21
- import './index.styles-7021829c.js';
10
+ import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-bad138ab.js';
11
+ import { T as Text } from './index-0423b372.js';
12
+ import { S as Select, d as Checkbox, I as Input, R as Radio, P as Phone, N as NumberInput, O as OTP } from './index-c3841e4d.js';
13
+ import { D as DatePicker } from './index-6f990758.js';
14
+ import { B as Button } from './index-8c90983b.js';
15
+ import './index.styles-a1185717.js';
22
16
  import { useClickOutside } from '@mantine/hooks';
23
- import './other-791b5dfd.js';
24
- import './index-092d7934.js';
25
- import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-5b37d78d.js';
26
- import { B as Button } from './index-0ad3aa09.js';
27
- import { H as Heading$1 } from './index-dc1fd2da.js';
17
+ import './useMantineLocale-3dcc1724.js';
18
+ import { C as COMMON_DATE_TRANSLATE_KEY } from './index-65f141c1.js';
19
+ import './index-2a8894e6.js';
20
+ import { Z as ZINDEX_SSO, I as ISO_FORMAT } from './index-370af621.js';
21
+ import './other-2483b757.js';
22
+ import './index-e40243b0.js';
23
+ import { M as MAPPED_LOCALE } from './utils-fd471902.js';
24
+ import { DateInput } from '@mantine/dates';
25
+ import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-bfb0db64.js';
26
+ import { H as Heading$1 } from './index-81ccb624.js';
27
+ import { t as translationsMap$1 } from './translationsProvider-058aa9f4.js';
28
+ import { L as LOCALE } from './Locale-dd2625fa.js';
28
29
  import { v1 } from 'uuid';
29
- import { i as isVideo } from './index-d287aa93.js';
30
- import { D as DrawerComponent } from './index-53088c85.js';
31
- import { u as useScreenSize } from './useScreenSize-c7e3fe82.js';
32
- import { createPortal } from 'react-dom';
33
- import { css } from '@emotion/react';
30
+ import { parsePhoneNumber } from 'react-phone-number-input';
34
31
  import styled from '@emotion/styled';
35
32
  import { theme } from './miscTheme.js';
36
- import { C as Close } from './Close-4a4d7864.js';
33
+ import { css } from '@emotion/react';
34
+ import { T as TogetherComponentGlobalContext } from './utils-064598a5.js';
35
+ import { i as isVideo } from './index-45e1c9a1.js';
36
+ import { D as DrawerComponent } from './index-a7927623.js';
37
+ import { u as useScreenSize } from './useScreenSize-cc7d6c7a.js';
38
+ import { createPortal } from 'react-dom';
39
+ import { B as Button$2 } from './index-97ca081d.js';
40
+ import { I as InputDate } from './InputDate-fc760765.js';
41
+ import { C as Close } from './Close-a1570e5a.js';
37
42
  import '@hhgtech/icons/other';
38
43
  import '@mantine/carousel';
39
- import './Locale-0b94309d.js';
40
44
  import 'classnames';
41
- import './useUniqueId-82eba9be.js';
45
+ import './useUniqueId-58e62fe5.js';
42
46
  import './constantsSite.js';
43
47
  import '@hhgtech/icons/core';
44
- import 'date-fns/locale';
48
+ import '@mantine/notifications';
45
49
  import './constantsDomainLocales.js';
46
- import './constantsRiskScreener.js';
47
50
  import './constantsIsProduction.js';
48
- import '@mantine/notifications';
51
+ import 'date-fns/locale';
52
+ import './constantsRiskScreener.js';
53
+ import './i18n-values/en-PH.js';
54
+ import './i18n-values/hi-IN.js';
55
+ import './i18n-values/id-ID.js';
56
+ import './i18n-values/km-KH.js';
57
+ import './i18n-values/ms-MY.js';
58
+ import './i18n-values/my-MM.js';
59
+ import './i18n-values/th-TH.js';
60
+ import './i18n-values/tl-PH.js';
61
+ import './i18n-values/vi-VN.js';
62
+ import './i18n-values/vi-VN_MB.js';
63
+ import './i18n-values/zh-TW.js';
64
+ import './index-db6cad26.js';
65
+ import 'slugify';
66
+ import 'string-format';
67
+ import './togetherApiPaths.js';
68
+ import './constants-f5042816.js';
49
69
  import 'vaul';
50
70
 
51
71
  const LeadGenComponentContext = createContext({});
@@ -72,7 +92,7 @@ if (sessionStorage.getItem('insider_object')) {
72
92
  }
73
93
  const docLang = document.documentElement.lang;
74
94
  // TODO: country code
75
- const LEAD_LOCALE_DATA = {
95
+ const LEAD_LOCALE_DATA$1 = {
76
96
  'vi-VN': {
77
97
  popupLang: 'vi',
78
98
  countryCode: 'vn',
@@ -114,7 +134,7 @@ const LEAD_LOCALE_DATA = {
114
134
  countryCodeNumber: 91,
115
135
  },
116
136
  };
117
- const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
137
+ const LEAD_LOCALE = LEAD_LOCALE_DATA$1[docLang] || LEAD_LOCALE_DATA$1['vi-VN'];
118
138
  function LEAD_RESET_VAR() {
119
139
  // LEAD_CURRENT_URL = location.href.toLowerCase();
120
140
  LEAD_CURRENT_URL =
@@ -135,6 +155,11 @@ const LEAD_TIMEZONE_DATA = {
135
155
  9: 'Asia/Manila', // Philippines / Filipinos Site
136
156
  };
137
157
 
158
+ const LEADGEN_ACTIONS = {
159
+ SHOW: 'SHOW',
160
+ SCROLL: 'SCROLL',
161
+ TIME: 'TIME',
162
+ };
138
163
  const LEADGEN_LAYOUT = {
139
164
  LightBoxA: 'LightBoxA',
140
165
  LightBoxB: 'LightBoxB',
@@ -164,8 +189,10 @@ const LEADGEN_BLOCK = {
164
189
  DropdownBlock: 'DropdownBlock',
165
190
  CheckboxBlock: 'CheckboxBlock',
166
191
  TncBlock: 'TncBlock',
192
+ TitleBlock: 'TitleBlock',
193
+ SubtitleBlock: 'SubtitleBlock',
167
194
  };
168
- const LEADGEN_BLOCK_IN_FORM = [
195
+ const LEADGEN_BLOCK_INPUT = [
169
196
  LEADGEN_BLOCK.TextBlock,
170
197
  LEADGEN_BLOCK.NumberBlock,
171
198
  LEADGEN_BLOCK.DateBlock,
@@ -180,7 +207,59 @@ const LEADGEN_BLOCK_IN_FORM = [
180
207
  LEADGEN_BLOCK.CheckboxBlock,
181
208
  LEADGEN_BLOCK.TncBlock,
182
209
  ];
210
+ const leadGenFieldNamePhone = (listBlockAdded) => {
211
+ return listBlockAdded
212
+ .filter(({ name }) => [
213
+ LEADGEN_BLOCK.PhoneBlock,
214
+ LEADGEN_BLOCK.PhoneOtpBlock,
215
+ LEADGEN_BLOCK.WhatsappOtpBlock,
216
+ LEADGEN_BLOCK.ZaloOtpBlock,
217
+ ].includes(name))
218
+ .map(({ data }) => data.value);
219
+ };
183
220
  const SSO_MAP_LEAD = ['name', 'email', 'birthday', 'phone', 'gender'];
221
+ const LEAD_LOCALE_DATA = {
222
+ 'vi-VN': {
223
+ popupLang: 'vi',
224
+ countryCode: 'vn',
225
+ countryCodeNumber: 84,
226
+ },
227
+ 'id-ID': {
228
+ popupLang: 'id',
229
+ countryCode: 'id',
230
+ countryCodeNumber: 62,
231
+ },
232
+ 'th-TH': {
233
+ popupLang: 'th',
234
+ countryCode: 'th',
235
+ countryCodeNumber: 66,
236
+ },
237
+ 'ms-MY': {
238
+ popupLang: 'ms',
239
+ countryCode: 'my',
240
+ countryCodeNumber: 60,
241
+ },
242
+ 'zh-TW': {
243
+ popupLang: 'zh',
244
+ countryCode: 'tw',
245
+ countryCodeNumber: 886,
246
+ },
247
+ 'km-KH': {
248
+ popupLang: 'km',
249
+ countryCode: 'kh',
250
+ countryCodeNumber: 855,
251
+ },
252
+ 'my-MM': {
253
+ popupLang: 'my',
254
+ countryCode: 'mm',
255
+ countryCodeNumber: 95,
256
+ },
257
+ 'hi-IN': {
258
+ popupLang: 'hi',
259
+ countryCode: 'in',
260
+ countryCodeNumber: 91,
261
+ },
262
+ };
184
263
  const mappingSSOToLead = (userInfoProps) => {
185
264
  var _a, _b;
186
265
  try {
@@ -196,7 +275,7 @@ const mappingSSOToLead = (userInfoProps) => {
196
275
  if (ssoKey === 'birthday') {
197
276
  const dob = dayjs(initValue, 'YYYY-MM-DD', true);
198
277
  if (dob.isValid()) {
199
- user.birthday = dob;
278
+ user.birthday = dob.toDate();
200
279
  }
201
280
  }
202
281
  else if (ssoKey === 'gender') {
@@ -219,16 +298,66 @@ const mappingSSOToLead = (userInfoProps) => {
219
298
  catch (error) {
220
299
  return;
221
300
  }
301
+ };
302
+ const formatCampaignDetail = (campaign) => {
303
+ if (!campaign) {
304
+ return {};
305
+ }
306
+ try {
307
+ const { extra_fields, thank_you_image } = campaign || {};
308
+ const { textBlocks: exTextBlocks, imageBlocks: exImageBlocks, listBlockAdded: exListBlockAdded, listBlockThankyou: exListBlockThankyou, actionBlocks: exActionBlocks, } = extra_fields;
309
+ const textBlocks = JSON.parse(exTextBlocks);
310
+ const imageBlocks = JSON.parse(exImageBlocks);
311
+ const listBlockAdded = JSON.parse(exListBlockAdded);
312
+ const listBlockThankyou = JSON.parse(exListBlockThankyou);
313
+ const actionBlocks = JSON.parse(exActionBlocks);
314
+ const ThankYouBlock = {
315
+ image: { src: thank_you_image },
316
+ };
317
+ listBlockThankyou.forEach((block) => {
318
+ const { name, data } = block || {};
319
+ const { value: htmlText, align, newtab, url } = data || {};
320
+ switch (name) {
321
+ case LEADGEN_BLOCK.TitleBlock: {
322
+ ThankYouBlock.title = { htmlText, align };
323
+ }
324
+ case LEADGEN_BLOCK.SubtitleBlock: {
325
+ ThankYouBlock.description = { htmlText, align };
326
+ }
327
+ case LEADGEN_BLOCK.LinkButtonBlock: {
328
+ ThankYouBlock.button = { htmlText, newtab, url };
329
+ }
330
+ }
331
+ });
332
+ return Object.assign(Object.assign({}, campaign), { extra_fields: Object.assign(Object.assign({}, extra_fields), { textBlocks,
333
+ imageBlocks,
334
+ listBlockAdded,
335
+ listBlockThankyou,
336
+ actionBlocks }), ThankYouBlock });
337
+ }
338
+ catch (error) {
339
+ return {};
340
+ }
222
341
  };
223
342
 
224
343
  class Store {
225
344
  constructor() {
345
+ this.apiSsoUrl = 'https://staging-id.hellobacsi.com/';
226
346
  this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
227
347
  this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
228
348
  }
229
349
  }
230
350
  const leadStore = new Store();
231
351
 
352
+ const LEADGEN_API_METHOD = {
353
+ GET: 'get',
354
+ POST: 'POST',
355
+ };
356
+ const LEADGEN_API_PATH = {
357
+ V2_CAMPAIGN: 'api/v2/campaign',
358
+ V2_SUBSCRIPTION_LEAD: 'api/v2/subscription-box',
359
+ V2_SUBSCRIPTION_INFO: 'api/campaign/get-title',
360
+ };
232
361
  const leadApi = {
233
362
  call(_a) {
234
363
  var { url, data = undefined } = _a, config = __rest(_a, ["url", "data"]);
@@ -332,8 +461,50 @@ const verifyOtpLead = ({ phone, otp, type, }) => {
332
461
  },
333
462
  });
334
463
  };
464
+ const getCampaignByCode = (campaign_code) => {
465
+ return leadApi.call({
466
+ url: `${LEADGEN_API_PATH.V2_CAMPAIGN}/${campaign_code}`,
467
+ method: LEADGEN_API_METHOD.GET,
468
+ });
469
+ };
470
+ const getSubscriptionBoxInfo = ({ category, site, }) => {
471
+ return leadApi.call({
472
+ url: `${LEADGEN_API_PATH.V2_SUBSCRIPTION_INFO}?category=${category}&site=${site}`,
473
+ method: LEADGEN_API_METHOD.GET,
474
+ });
475
+ };
476
+ const postSubscriptionBoxLead = ({ data }) => {
477
+ return leadApi.call({
478
+ url: LEADGEN_API_PATH.V2_SUBSCRIPTION_LEAD,
479
+ method: LEADGEN_API_METHOD.POST,
480
+ data,
481
+ });
482
+ };
483
+ const postUserInfoFromLeadGen = ({}) => {
484
+ return;
485
+ };
486
+ const campaignPostImpression = ({ code, action, title_article, ga_client_id, cookie_id, extra, url, referrer, }) => {
487
+ return leadApi.call({
488
+ url: `api/campaign/${code}/impression`,
489
+ method: LEADGEN_API_METHOD.POST,
490
+ data: {
491
+ action,
492
+ title_article,
493
+ cookie_id,
494
+ ga_client_id,
495
+ url,
496
+ extra,
497
+ referrer,
498
+ },
499
+ });
500
+ };
335
501
  const Service = {
336
502
  campaignGetById,
503
+ getCampaignByCode,
504
+ getSubscriptionBoxInfo,
505
+ postSubscriptionBoxLead,
506
+ postUserInfoFromLeadGen,
507
+ campaignPostImpression,
337
508
  validateEmailOrPhoneOnSubot,
338
509
  validateEmailOrPhoneOnLeadGen,
339
510
  validatePhoneNumberOnLeadGen,
@@ -673,6 +844,8 @@ const Description = (_a) => {
673
844
  return description ? (React__default.createElement(Text, Object.assign({ size: "p3" }, rest), description)) : null;
674
845
  };
675
846
 
847
+ const LeadGenContext$1 = createContext({});
848
+
676
849
  var useStyles$2 = createStyles(() => {
677
850
  return {
678
851
  control: {},
@@ -735,6 +908,7 @@ const SubtitleBlock$1 = ({ children, align, }) => (React__default.createElement(
735
908
  const TitleBlock$1 = ({ children, align, }) => (React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
736
909
 
737
910
  const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, popoverProps, }) => {
911
+ const { primaryColor } = useContext(LeadGenContext$1);
738
912
  const { classes, cx } = useStyles$2(undefined, {
739
913
  name: 'LeadGen__Field',
740
914
  styles,
@@ -789,7 +963,7 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
789
963
  case 'LinkButtonBlock':
790
964
  return (React__default.createElement("div", { key: index },
791
965
  React__default.createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
792
- React__default.createElement(Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
966
+ React__default.createElement(Button, { type: "button", size: "md", color: primaryColor, className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
793
967
  onClose === null || onClose === void 0 ? void 0 : onClose();
794
968
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
795
969
  } }, value))));
@@ -849,6 +1023,7 @@ const Heading = (_a) => {
849
1023
 
850
1024
  const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps, submitProps, }) => {
851
1025
  var _a;
1026
+ const { primaryColor } = useContext(LeadGenContext$1);
852
1027
  const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, setFormRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = useContext(LeadGenComponentContext);
853
1028
  const { classes, cx } = useStyles$1(undefined, {
854
1029
  name: 'LeadGen__FormComponent',
@@ -937,7 +1112,7 @@ const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps,
937
1112
  control: classes.control,
938
1113
  }, listBlockAdded: listBlockAdded, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit, popoverProps: popoverProps })),
939
1114
  ((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) ? null : (React__default.createElement("div", { className: classes.submitBtnWrapper },
940
- React__default.createElement(Button$1, Object.assign({ size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, loading: isSubmitLoading }, submitProps), popUpSubmitText))))));
1115
+ React__default.createElement(Button, Object.assign({ size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, loading: isSubmitLoading, color: primaryColor }, submitProps), popUpSubmitText))))));
941
1116
  };
942
1117
  const Form = (props) => {
943
1118
  const { showOtpPhone, showThankyou } = useContext(LeadGenComponentContext);
@@ -1079,10 +1254,10 @@ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, st
1079
1254
  setErrorMsg(undefined);
1080
1255
  }, error: isDirty ? errorMsg : undefined }),
1081
1256
  React__default.createElement("div", { className: classes.actions },
1082
- React__default.createElement(Button$1, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1257
+ React__default.createElement(Button, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1083
1258
  // onClick={() => submitOtp()}
1084
1259
  disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
1085
- React__default.createElement(Button$1, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1260
+ React__default.createElement(Button, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1086
1261
  sendOtp();
1087
1262
  }, disabled: !!resendTimer }, t('lead.otp.resend', {
1088
1263
  timer: resendTimer ? ` (${resendTimer}s)` : '',
@@ -1125,6 +1300,7 @@ var enPH = {
1125
1300
  "validator.min": "jQuery.validator.format('Please enter a value greater than or equal to {0}.",
1126
1301
  "validator.emailUsed": "Email already in use for this campaign.",
1127
1302
  "validator.phoneUsed": "Your phone number already in use for this campaign.",
1303
+ "validator.dateInvalid": "This date is not valid, please update.",
1128
1304
  "lead.otp.title": "Enter OTP",
1129
1305
  "lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
1130
1306
  "lead.otp.verify": "Verify",
@@ -1133,7 +1309,10 @@ var enPH = {
1133
1309
  "lead.otp.phonePlaceholder": "Enter OTP",
1134
1310
  "lead.empty.title": "Oops, seem your information is empty, do you want to submit the information again?",
1135
1311
  "lead.empty.cancel": "Cancel",
1136
- "lead.empty.submitAgain": "Submit again"
1312
+ "lead.empty.submitAgain": "Submit again",
1313
+ "common.day": "Day",
1314
+ "common.month": "Month",
1315
+ "common.year": "Year"
1137
1316
  };
1138
1317
 
1139
1318
  var hiIN = {
@@ -1144,6 +1323,7 @@ var hiIN = {
1144
1323
  "validator.maxlength": "कृपया {0} अक्षर से अधिक दर्ज न करें",
1145
1324
  "validator.minlength": "कृपया कम से कम {0} अक्षर दर्ज करें",
1146
1325
  "validator.phone": "कृपया एक वैध संख्या दर्ज करें",
1326
+ "validator.dateInvalid": "यह तिथि मान्य नहीं है, कृपया अपडेट करें।",
1147
1327
  "validator.emailUsed": "Email already in use for this campaign.",
1148
1328
  "validator.phoneUsed": "Your phone number already in use for this campaign.",
1149
1329
  "lead.otp.title": "Enter OTP",
@@ -1152,7 +1332,10 @@ var hiIN = {
1152
1332
  "lead.otp.resend": "Resend OTP{timer}",
1153
1333
  "lead.empty.title": "ऊप्स! लगता है आपकी जानकारी खाली है। क्या आप जानकारी फिर से सबमिट करना चाहते हैं?",
1154
1334
  "lead.empty.cancel": "रद्द करें",
1155
- "lead.empty.submitAgain": "फिर से सबमिट करें"
1335
+ "lead.empty.submitAgain": "फिर से सबमिट करें",
1336
+ "common.day": "साल",
1337
+ "common.month": "महीना",
1338
+ "common.year": ""
1156
1339
  };
1157
1340
 
1158
1341
  var idID = {
@@ -1165,6 +1348,7 @@ var idID = {
1165
1348
  "validator.phone": "Tolong daftarkan nomor telepon yang valid",
1166
1349
  "validator.emailUsed": "Email sudah digunakan untuk kampanye ini.",
1167
1350
  "validator.phoneUsed": "Nomor telepon Anda sudah digunakan untuk kampanye ini.",
1351
+ "validator.dateInvalid": "Tanggal ini tidak valid, silakan perbarui",
1168
1352
  "lead.otp.title": "Masukkan OTP",
1169
1353
  "lead.otp.desc": "Kami telah mengirimkan OTP ke nomor ponsel Anda {phone}",
1170
1354
  "lead.otp.verify": "Verifikasi",
@@ -1173,7 +1357,10 @@ var idID = {
1173
1357
  "lead.otp.phonePlaceholder": "Masukkan OTP",
1174
1358
  "lead.empty.title": "Oops, sepertinya informasi Anda kosong. Apakah Anda ingin mengirimkan informasi lagi?",
1175
1359
  "lead.empty.cancel": "Batal",
1176
- "lead.empty.submitAgain": "Kirim lagi"
1360
+ "lead.empty.submitAgain": "Kirim lagi",
1361
+ "common.day": "Hari",
1362
+ "common.month": "Bulan",
1363
+ "common.year": "Tahun"
1177
1364
  };
1178
1365
 
1179
1366
  var kmKH = {
@@ -1186,6 +1373,7 @@ var kmKH = {
1186
1373
  "validator.phone": "សូម​វាយបញ្ចូល​លេខ​ឲ្យ​បាន​ត្រឹមត្រូវ",
1187
1374
  "validator.emailUsed": "អ៊ីមែលត្រូវបានប្រើប្រាស់សម្រាប់យុទ្ធនាការនេះរួចហើយ។",
1188
1375
  "validator.phoneUsed": "លេខទូរស័ព្ទរបស់អ្នកត្រូវបានប្រើប្រាស់សម្រាប់យុទ្ធនាការនេះរួចហើយ។",
1376
+ "validator.dateInvalid": "កាលបរិច្ឆេទនេះមិនត្រឹមត្រូវទេ សូមធ្វើបច្ចុប្បន្នភាព។",
1189
1377
  "lead.otp.title": "បញ្ចូល OTP",
1190
1378
  "lead.otp.desc": "យើងបានផ្ញើ OTP ទៅកាន់លេខទូរសព្ទរបស់អ្នក {phone}",
1191
1379
  "lead.otp.verify": "ផ្ទៀងផ្ទាត់",
@@ -1194,7 +1382,10 @@ var kmKH = {
1194
1382
  "lead.otp.phonePlaceholder": "បញ្ចូល OTP",
1195
1383
  "lead.empty.title": "អូុបស! ហាក់ដូចជាព័ត៌មានរបស់អ្នកទទេ។ តើអ្នកចង់ដាក់ស្នើព័ត៌មានម្តងទៀតទេ?",
1196
1384
  "lead.empty.cancel": "លុប​ចោល",
1197
- "lead.empty.submitAgain": "ដាក់ស្នើម្ដងទៀត"
1385
+ "lead.empty.submitAgain": "ដាក់ស្នើម្ដងទៀត",
1386
+ "common.day": "ឆ្នាំ",
1387
+ "common.month": "ខែ",
1388
+ "common.year": "ថ្ងៃ"
1198
1389
  };
1199
1390
 
1200
1391
  var msMY = {
@@ -1207,6 +1398,7 @@ var msMY = {
1207
1398
  "validator.phone": "Sila masukkan no telefon yang sah.",
1208
1399
  "validator.emailUsed": "Emel sudah digunakan untuk kempen ini.",
1209
1400
  "validator.phoneUsed": "Nombor telefon anda sudah digunakan untuk kempen ini.",
1401
+ "validator.dateInvalid": "Tarikh ini tidak sah, sila kemas kini",
1210
1402
  "lead.otp.title": "Masukkan OTP",
1211
1403
  "lead.otp.desc": "Kami telah menghantar OTP ke nombor telefon bimbit anda {phone}",
1212
1404
  "lead.otp.verify": "Sahkan",
@@ -1215,7 +1407,10 @@ var msMY = {
1215
1407
  "lead.otp.phonePlaceholder": "Masukkan OTP",
1216
1408
  "lead.empty.title": "Oops, nampaknya maklumat anda kosong. Adakah anda ingin menghantar maklumat semula?",
1217
1409
  "lead.empty.cancel": "Batal",
1218
- "lead.empty.submitAgain": "Hantar semula"
1410
+ "lead.empty.submitAgain": "Hantar semula",
1411
+ "common.day": "Hari",
1412
+ "common.month": "Bulan",
1413
+ "common.year": "Tahun"
1219
1414
  };
1220
1415
 
1221
1416
  var myMM = {
@@ -1228,6 +1423,7 @@ var myMM = {
1228
1423
  "validator.phone": "မှန်ကန်သော ဖုန်းနံပါတ်ထည့်သွင်းပါ",
1229
1424
  "validator.emailUsed": "ဤအေကာင့်အတွက် အီးမေးလ်ကို အသုံးပြုပြီးဖြစ်ပါသည်။",
1230
1425
  "validator.phoneUsed": "ဤအေကာင့်အတွက် သင့်ဖုန်းနံပါတ်ကို အသုံးပြုပြီးဖြစ်ပါသည်။",
1426
+ "validator.dateInvalid": "ယနေ့စွဲမှားနေသည်၊ ကျေးဇူးပြု၍ ပြင်ဆင်ပါ။",
1231
1427
  "lead.otp.title": "OTP ကိုထည့်ပါ",
1232
1428
  "lead.otp.desc": "ကျွန်ုပ်တို့သည် OTP ကိုသင့်ဖုန်းနံပါတ် {phone} သို့ပို့ခဲ့သည်",
1233
1429
  "lead.otp.verify": "အတည်ပြုပါ",
@@ -1236,7 +1432,10 @@ var myMM = {
1236
1432
  "lead.otp.phonePlaceholder": "OTP ကိုထည့်ပါ",
1237
1433
  "lead.empty.title": "အုပ်စ်! သင့်အချက်အလက်သည် ဗလာဖြစ်နေသလိုဖြစ်သည်။ ထပ်မံတင်သွင်းလိုပါသလား?",
1238
1434
  "lead.empty.cancel": "မလုပ်ဆောင်ပါ",
1239
- "lead.empty.submitAgain": "ထပ်မံတင်သွင်းပါ"
1435
+ "lead.empty.submitAgain": "ထပ်မံတင်သွင်းပါ",
1436
+ "common.day": "ရက်",
1437
+ "common.month": "လ",
1438
+ "common.year": "နှစ်"
1240
1439
  };
1241
1440
 
1242
1441
  var thTH = {
@@ -1249,6 +1448,7 @@ var thTH = {
1249
1448
  "validator.phone": "กรุณาใส่ตัวเลขที่ถูกต้อง",
1250
1449
  "validator.emailUsed": "อีเมลนี้ถูกใช้สำหรับแคมเปญนี้แล้ว",
1251
1450
  "validator.phoneUsed": "หมายเลขโทรศัพท์ของคุณถูกใช้สำหรับแคมเปญนี้แล้ว",
1451
+ "validator.dateInvalid": "วันที่นี้ไม่ถูกต้อง โปรดอัปเดต",
1252
1452
  "lead.otp.title": "ป้อน OTP",
1253
1453
  "lead.otp.desc": "เราได้ส่ง OTP ไปยังหมายเลขโทรศัพท์มือถือของคุณ {phone}",
1254
1454
  "lead.otp.verify": "ยืนยัน",
@@ -1257,7 +1457,10 @@ var thTH = {
1257
1457
  "lead.otp.phonePlaceholder": "ป้อน OTP",
1258
1458
  "lead.empty.title": "อุ๊ปส์! ดูเหมือนว่าข้อมูลของคุณว่างเปล่า คุณต้องการส่งข้อมูลอีกครั้งหรือไม่?",
1259
1459
  "lead.empty.cancel": "ยกเลิก",
1260
- "lead.empty.submitAgain": "ส่งอีกครั้ง"
1460
+ "lead.empty.submitAgain": "ส่งอีกครั้ง",
1461
+ "common.day": "วัน",
1462
+ "common.month": "เดือน",
1463
+ "common.year": "ปี"
1261
1464
  };
1262
1465
 
1263
1466
  var viVN = {
@@ -1281,6 +1484,7 @@ var viVN = {
1281
1484
  "validator.phone": "Nhập đúng định dạng số điện thoại",
1282
1485
  "validator.emailUsed": "Email này đã được sử dụng.",
1283
1486
  "validator.phoneUsed": "Số điện thoại này đã được sử dụng.",
1487
+ "validator.dateInvalid": "Ngày này không hợp lệ, vui lòng cập nhật.",
1284
1488
  "lead.otp.title": "Nhập OTP",
1285
1489
  "lead.otp.desc": "Chúng tôi đã gửi OTP đến số điện thoại của bạn {phone}",
1286
1490
  "lead.otp.verify": "Xác minh",
@@ -1289,7 +1493,10 @@ var viVN = {
1289
1493
  "lead.otp.phonePlaceholder": "Nhập OTP",
1290
1494
  "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?",
1291
1495
  "lead.empty.cancel": "Hủy",
1292
- "lead.empty.submitAgain": "Gửi lại"
1496
+ "lead.empty.submitAgain": "Gửi lại",
1497
+ "common.day": "Ngày",
1498
+ "common.month": "Tháng",
1499
+ "common.year": "Năm"
1293
1500
  };
1294
1501
 
1295
1502
  var zhTW = {
@@ -1302,6 +1509,7 @@ var zhTW = {
1302
1509
  "validator.phone": "請填入有效的電話號碼",
1303
1510
  "validator.emailUsed": "此電子郵件已被使用於此活動。",
1304
1511
  "validator.phoneUsed": "您的手機號碼已被使用於此活動。",
1512
+ "validator.dateInvalid": "此日期無效,請更新.",
1305
1513
  "lead.otp.title": "輸入 OTP",
1306
1514
  "lead.otp.desc": "我們已將 OTP 發送到您的手機號碼 {phone}",
1307
1515
  "lead.otp.verify": "驗證",
@@ -1310,7 +1518,10 @@ var zhTW = {
1310
1518
  "lead.otp.phonePlaceholder": "輸入 OTP",
1311
1519
  "lead.empty.title": "哎呀,您的資訊似乎是空的,您想要重新提交資訊嗎?",
1312
1520
  "lead.empty.cancel": "取消",
1313
- "lead.empty.submitAgain": "重新提交"
1521
+ "lead.empty.submitAgain": "重新提交",
1522
+ "common.day": "日",
1523
+ "common.month": "月",
1524
+ "common.year": "年"
1314
1525
  };
1315
1526
 
1316
1527
  const translationsMap = {
@@ -1322,159 +1533,1684 @@ const translationsMap = {
1322
1533
  'my-MM': myMM,
1323
1534
  'km-KH': kmKH,
1324
1535
  'zh-TW': zhTW,
1536
+ 'zh-CN': zhTW,
1325
1537
  'th-TH': thTH,
1326
1538
  'tl-PH': enPH,
1327
1539
  };
1328
1540
  const getTranslations = (locale) => {
1329
- const translations = translationsMap[locale];
1541
+ const translations = Object.assign(Object.assign({}, translationsMap$1[locale]), translationsMap[locale]);
1330
1542
  if (translations) {
1331
1543
  return translations;
1332
1544
  }
1333
1545
  return translationsMap['en-PH'];
1334
1546
  };
1335
1547
 
1336
- const LeadGenContext = createContext({});
1337
-
1338
- const useImageSize = (src) => {
1339
- const [width, setWidth] = useState(16);
1340
- const [height, setHeight] = useState(9);
1341
- const [loaded, setLoaded] = useState(false);
1342
- // load src image to get its width and height
1343
- useEffect(() => {
1344
- setLoaded(false);
1345
- if (src) {
1346
- const img = new Image();
1347
- img.addEventListener('load', () => {
1348
- setWidth(img.naturalWidth);
1349
- setHeight(img.naturalHeight);
1350
- setLoaded(true);
1351
- });
1352
- img.addEventListener('error', () => {
1353
- setWidth(16);
1354
- setHeight(9);
1355
- setLoaded(true);
1356
- });
1357
- img.src = src;
1358
- }
1359
- else {
1360
- setWidth(16);
1361
- setHeight(9);
1362
- setLoaded(true);
1363
- }
1364
- }, [src]);
1365
- return {
1366
- loaded,
1367
- width,
1368
- height,
1369
- };
1370
- };
1371
-
1372
- const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default.createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
1373
- React__default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
1374
- React__default.createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
1375
-
1376
- // url: imageBlocks.imageMobile.data.url
1377
- // newTab: imageBlocks.imageMobile.data.newtab
1378
- // imageMobile: campaignShow.image
1379
- // imageDestkop: campaignShow.image_desktop
1380
- const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
1381
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1382
- const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
1383
- if (!imageMobileLoaded || !imageDestkopLoaded)
1384
- return null;
1385
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
1386
- React__default.createElement("div", { className: "le-center-tab-popup" },
1387
- React__default.createElement("div", { style: { position: 'relative' } },
1388
- React__default.createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
1389
- isVideo(imageMobile) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
1390
- React__default.createElement("source", { src: imageMobile }))) : (React__default.createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
1391
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1392
- } })),
1393
- isVideo(imageDestkop) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
1394
- React__default.createElement("source", { src: imageDestkop }))) : (React__default.createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
1395
- aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
1396
- } }))),
1397
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
1398
- };
1399
-
1400
- // title: titleText
1401
- // titleAlign: textBlocks.titleBlock.data.align
1402
- // subtitle: textBlocks.subtitleBlock.data.value
1403
- // subtitleAlign: textBlocks.subtitleBlock.data.align
1404
- // url: actionBlocks.linkButtonBlock.data.url
1405
- // urlText: actionBlocks.linkButtonBlock.data.value
1406
- // newTab: actionBlocks.linkButtonBlock.data.newtab
1407
- // imageMobile: campaignShow.image
1408
- // imageDesktop: campaignShow.image_desktop
1409
- const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
1410
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1411
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
1412
- if (!imageMobileLoaded || !imageDesktopLoaded)
1413
- return null;
1414
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
1415
- React__default.createElement("aside", { className: "le-only-desktop" },
1416
- React__default.createElement("div", { className: "le-floating-desktop" },
1417
- React__default.createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
1418
- imageDesktop ? (React__default.createElement("div", null,
1419
- React__default.createElement("img", { style: {
1420
- maxWidth: 120,
1421
- borderTopLeftRadius: 5,
1422
- borderBottomLeftRadius: 5,
1423
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
1424
- }, src: imageDesktop }))) : null,
1425
- React__default.createElement("div", { style: { padding: 20 } },
1426
- React__default.createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
1427
- React__default.createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
1428
- React__default.createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
1429
- React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
1430
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
1431
- React__default.createElement("aside", { className: "le-only-mobile" },
1432
- React__default.createElement("div", { className: "le-floating-mobile" },
1433
- React__default.createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
1434
- React__default.createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
1435
- React__default.createElement("div", null,
1436
- React__default.createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
1437
- React__default.createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
1438
- imageMobile ? (React__default.createElement("div", null,
1439
- React__default.createElement("img", { style: {
1440
- marginLeft: 15,
1441
- marginTop: 4,
1442
- maxWidth: 100,
1443
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1444
- }, src: imageMobile }))) : null),
1445
- React__default.createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
1446
- React__default.createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
1447
- React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
1448
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
1548
+ const LeadGenTranslationProvider = (props) => {
1549
+ const { locale, children } = props;
1550
+ const translationContextValue = useMemo(() => ({ locale, values: getTranslations(locale) }), [locale]);
1551
+ return (React__default.createElement(TranslationsContext.Provider, { value: translationContextValue }, children));
1449
1552
  };
1450
1553
 
1451
- const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
1452
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
1453
- if (!imageLoaded)
1554
+ // import mockLeadData from './mockLeadData'
1555
+ const listCampaignScheduled = [];
1556
+ const listCampaignScheduledToActivated = [];
1557
+ const listCampaignActiveButExpired = [];
1558
+ const listCampaignExcludeSonsored = [];
1559
+ const listCampaignDifferentSponsor = [];
1560
+ const listCampaignNotDisplayInRangeOfTime = [];
1561
+ function isMobile() {
1562
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
1563
+ }
1564
+ const getShuffleArray = (array) => {
1565
+ const newArray = [...array];
1566
+ for (let i = newArray.length - 1; i > 0; i--) {
1567
+ const j = Math.floor(Math.random() * (i + 1));
1568
+ const temp = newArray[i];
1569
+ newArray[i] = newArray[j];
1570
+ newArray[j] = temp;
1571
+ }
1572
+ return newArray;
1573
+ };
1574
+ const getTimeByTimezone = (timeZone = 'UTC') => {
1575
+ const date = new Date();
1576
+ return new Date(date.toLocaleString('en-US', { timeZone }));
1577
+ };
1578
+ const parseDateByCampaignTime = (dateStr) => {
1579
+ // Format like this: 2023-04-04 00:00:00
1580
+ try {
1581
+ const [datePart, timePart] = dateStr.split(' ');
1582
+ const [year, month, day] = datePart.split('-').map(Number);
1583
+ const [hours, minutes, seconds] = timePart.split(':').map(Number);
1584
+ /** JavaScript counts months from 0 to 11 */
1585
+ return new Date(year, month - 1, day, hours, minutes, seconds);
1586
+ }
1587
+ catch (err) {
1454
1588
  return null;
1455
- return (React__default.createElement("div", { className: "lead-modal__thank-you leadgen-inner_thankyou" },
1456
- React__default.createElement("div", { style: { width: '100%' } },
1457
- React__default.createElement("img", { src: image, style: {
1458
- maxHeight: 162,
1459
- objectFit: 'cover',
1460
- aspectRatio: `${imageWidth}/${imageHeight}`,
1461
- }, loading: "lazy" }),
1462
- title && (React__default.createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
1463
- subtitle && (React__default.createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle.split('\n').map((text, idx, list) => {
1464
- const isShowBr = idx < list.length - 1;
1465
- return (React__default.createElement(React__default.Fragment, null,
1466
- text,
1467
- isShowBr && React__default.createElement("br", null)));
1468
- }))),
1469
- linkText && (React__default.createElement("div", null,
1470
- React__default.createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
1471
- React__default.createElement("button", { className: `lead-modal__btn ${LEAD_CLASS}` }, linkText)))))));
1472
- };
1473
-
1474
- const InlineLayout = ({ content, inlinePosition, }) => {
1475
- const target = useMemo(() => {
1476
- if (!inlinePosition)
1477
- return null;
1589
+ }
1590
+ };
1591
+ const checkCampaignNowInTimeframe = (c) => {
1592
+ var _a;
1593
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1594
+ const startedAtStr = c.started_at;
1595
+ const endedAtStr = c.ended_at;
1596
+ const startedDate = parseDateByCampaignTime(startedAtStr);
1597
+ const endedDate = parseDateByCampaignTime(endedAtStr);
1598
+ if (!startedDate || !endedDate) {
1599
+ return false;
1600
+ }
1601
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
1602
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1603
+ if (nowWithTimezoneMs <= endedDate.getTime() &&
1604
+ nowWithTimezoneMs >= startedDate.getTime()) {
1605
+ listCampaignScheduledToActivated.push(c);
1606
+ return true;
1607
+ }
1608
+ return false;
1609
+ };
1610
+ function checkCampaignActiveButExpireAlready(c) {
1611
+ var _a;
1612
+ /** Do not setup timeframe for this campaign. No need to check */
1613
+ if (c.forever === 1) {
1614
+ return true;
1615
+ }
1616
+ const startedAtStr = c.started_at;
1617
+ const endedAtStr = c.ended_at;
1618
+ const startedDate = parseDateByCampaignTime(startedAtStr);
1619
+ const endedDate = parseDateByCampaignTime(endedAtStr);
1620
+ /** Do not setup timeframe for this campaign. No need to check */
1621
+ if (!startedDate || !endedDate) {
1622
+ return true;
1623
+ }
1624
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1625
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
1626
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1627
+ /** Check if this expire already, do not show */
1628
+ if (nowWithTimezoneMs > endedDate.getTime()) {
1629
+ listCampaignActiveButExpired.push(c);
1630
+ return false;
1631
+ }
1632
+ return true;
1633
+ }
1634
+ function shouldNotDisplayIfExcludeAllSponsors(c) {
1635
+ var _a;
1636
+ const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
1637
+ const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
1638
+ if (isSponsored && excludeSponsored) {
1639
+ listCampaignExcludeSonsored.push(c);
1640
+ return true;
1641
+ }
1642
+ return false;
1643
+ }
1644
+ function shouldDisplayWithCurrentSponsor(c) {
1645
+ var _a, _b;
1646
+ try {
1647
+ // TODO: BE will rename `exclude_sponsored_list` later
1648
+ const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
1649
+ const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
1650
+ const dataSponsoredId = Number((_b = document
1651
+ .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
1652
+ // There is no config for sponsor id and white list, should show as default
1653
+ if (!dataSponsoredId ||
1654
+ dataSponsoredId <= 0 ||
1655
+ whiteListSponsors.length === 0) {
1656
+ return true;
1657
+ }
1658
+ // Check the dataSponsoredId exists in the white list or not.
1659
+ const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
1660
+ if (isExist) {
1661
+ return true;
1662
+ }
1663
+ listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
1664
+ return false;
1665
+ }
1666
+ catch (err) {
1667
+ // Default is show
1668
+ return true;
1669
+ }
1670
+ }
1671
+ const filterFnCampaign = (c) => {
1672
+ if (shouldNotDisplayIfExcludeAllSponsors(c)) {
1673
+ return false;
1674
+ }
1675
+ else if (!shouldDisplayWithCurrentSponsor(c)) {
1676
+ return false;
1677
+ }
1678
+ /** Active */
1679
+ if (c.formatted_status === 1) {
1680
+ return checkCampaignActiveButExpireAlready(c);
1681
+ }
1682
+ /** Schedule */
1683
+ if (c.formatted_status === 0) {
1684
+ listCampaignScheduled.push(c);
1685
+ return checkCampaignNowInTimeframe(c);
1686
+ }
1687
+ return false;
1688
+ };
1689
+ const fillterApprearanceTimeCampaign = (c) => {
1690
+ var _a;
1691
+ try {
1692
+ const isTimeInRange = (currentTime, startTime, endTime) => {
1693
+ const startParts = startTime.split(':');
1694
+ const endParts = endTime.split(':');
1695
+ const startDate = new Date();
1696
+ startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
1697
+ const endDate = new Date();
1698
+ endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
1699
+ return currentTime >= startDate && currentTime <= endDate;
1700
+ };
1701
+ const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
1702
+ const startTime = rulesApprValue.startTime;
1703
+ const endTime = rulesApprValue.endTime || '23:59';
1704
+ if (!startTime) {
1705
+ return true;
1706
+ }
1707
+ if (isTimeInRange(new Date(), startTime, endTime)) {
1708
+ return true;
1709
+ }
1710
+ listCampaignNotDisplayInRangeOfTime.push(c);
1711
+ return false;
1712
+ }
1713
+ catch (err) {
1714
+ return true;
1715
+ }
1716
+ };
1717
+ let timeoutRef = null;
1718
+ let LEAD_SCROLL_EVENT = null;
1719
+ function clearPassiveEvent() {
1720
+ if (timeoutRef) {
1721
+ clearTimeout(timeoutRef);
1722
+ timeoutRef = null;
1723
+ }
1724
+ if (LEAD_SCROLL_EVENT) {
1725
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1726
+ LEAD_SCROLL_EVENT = null;
1727
+ }
1728
+ }
1729
+ function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
1730
+ // clear previous passive event, check for new condition
1731
+ clearPassiveEvent();
1732
+ const leadCurrentUrl = DEBUG_URL ||
1733
+ ('https://' +
1734
+ location.hostname +
1735
+ location.pathname +
1736
+ location.search).toLowerCase();
1737
+ fetch(leadApi + 'api/campaign/' + leadSiteId, {
1738
+ method: 'POST',
1739
+ headers: {
1740
+ 'Content-Type': 'application/json',
1741
+ },
1742
+ body: JSON.stringify({
1743
+ url: leadCurrentUrl,
1744
+ ga_client_id: getCookie('_ga') || null,
1745
+ }),
1746
+ })
1747
+ .then((response) => {
1748
+ return response.json();
1749
+ // return mockLeadData || response.json()
1750
+ })
1751
+ .then((data) => {
1752
+ var _a, _b, _c, _d;
1753
+ LeadLog('List campagin: ', data);
1754
+ LEAD_RESET_VAR();
1755
+ if (data._status == 1) {
1756
+ 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);
1757
+ if (!getCookie('hhg-id')) {
1758
+ setCookie('hhg-id', v1(), {
1759
+ domain: '.' + leadDomain,
1760
+ path: '/',
1761
+ });
1762
+ LeadLog('😍 Set HHG ID cookie');
1763
+ }
1764
+ // getCookie('hhg-id')
1765
+ // TODO: HP-534 Filter desktop
1766
+ let campaignsDevice = [];
1767
+ if (isMobile()) {
1768
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
1769
+ }
1770
+ else {
1771
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
1772
+ }
1773
+ LeadLog(`👓 campaignsDevice`, campaignsDevice);
1774
+ LeadLog('--listCampaignScheduled', listCampaignScheduled);
1775
+ LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
1776
+ LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
1777
+ LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
1778
+ LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
1779
+ LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
1780
+ // Check links
1781
+ let listLinksObj = campaignsDevice
1782
+ .map((i, index) => i.targets
1783
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
1784
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1785
+ .flat(1);
1786
+ // Check list link match current href
1787
+ listLinksObj = listLinksObj.filter((i) => {
1788
+ var _a;
1789
+ const target = new URL(String(i.target).toLowerCase());
1790
+ if (i.option == 'exact_match')
1791
+ // FOR TEST LOCAL:
1792
+ // return Boolean(location.pathname === target.pathname)
1793
+ return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
1794
+ if (i.option == 'start_with') {
1795
+ // FOR TEST LOCAL:
1796
+ // if (location.pathname.includes(target.pathname)) {
1797
+ if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
1798
+ const listExcluding = i.sub_target
1799
+ .filter((i) => i.option == 'excluding')
1800
+ .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
1801
+ return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
1802
+ }
1803
+ else {
1804
+ return false;
1805
+ }
1806
+ }
1807
+ });
1808
+ // Check tags
1809
+ const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
1810
+ const listTags = listMetaTag.map((i) => i.content);
1811
+ let listCampaignHasTag = [];
1812
+ let listTagsObj = [];
1813
+ if (listTags && listTags.length) {
1814
+ listCampaignHasTag = campaignsDevice
1815
+ .map((i, index) => i.targets
1816
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
1817
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1818
+ .flat(1);
1819
+ listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
1820
+ }
1821
+ const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
1822
+ const cookieKeys = document.cookie
1823
+ .split('; ')
1824
+ .map((i) => i.split('=')[0]);
1825
+ const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
1826
+ LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
1827
+ const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
1828
+ LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
1829
+ const listCampaignSubmitedClosed = [
1830
+ ...listCampaignCodeSubmited,
1831
+ ...listCampaignCodeClosed,
1832
+ ];
1833
+ const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
1834
+ const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
1835
+ return !hasSubmited;
1836
+ });
1837
+ const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
1838
+ // .sort(
1839
+ // (a, b) =>
1840
+ // (listCampaignValid[a.campaignIndex]?.score || 0) -
1841
+ // (listCampaignValid[b.campaignIndex]?.score || 0),
1842
+ // )
1843
+ LeadLog('--listCampaignValid : ', listCampaignValid);
1844
+ if (listCampaignValid && listCampaignValid.length) {
1845
+ const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
1846
+ LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
1847
+ const { rules } = CAMPAIGN_SHOW;
1848
+ // CHECK RULE TRIGGER POPUP
1849
+ const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
1850
+ LeadLog(`timeoutRule`, timeoutRule);
1851
+ const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
1852
+ LeadLog(`scrollRule`, scrollRule);
1853
+ let impressionAction = 'TIME';
1854
+ if (Number.isInteger(timeoutRule)) {
1855
+ impressionAction = 'TIME';
1856
+ LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
1857
+ timeoutRef = setTimeout(() => {
1858
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1859
+ }, timeoutRule * 1000);
1860
+ }
1861
+ if (Number.isInteger(scrollRule)) {
1862
+ impressionAction = 'SCROLL';
1863
+ LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
1864
+ const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
1865
+ document.querySelector('body');
1866
+ const pct = $p.getBoundingClientRect().top;
1867
+ const pb = $p.offsetHeight;
1868
+ LeadLog(`👓 Element check scroll: `, $p);
1869
+ LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
1870
+ const wt = window.pageYOffset || document.documentElement.scrollTop;
1871
+ let percent = 0;
1872
+ if (wt >= pct) {
1873
+ percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
1874
+ }
1875
+ LeadLog('---Scroll', percent, scrollRule);
1876
+ // TODO: CHECK FOOTER HEIGHT
1877
+ if (percent >= scrollRule) {
1878
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1879
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1880
+ }
1881
+ };
1882
+ window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
1883
+ passive: true,
1884
+ });
1885
+ }
1886
+ }
1887
+ else {
1888
+ LeadLog('🚧 No lead campaigns on current URL, tags');
1889
+ }
1890
+ }
1891
+ })
1892
+ .catch((err) => {
1893
+ LeadLog(`Lead error: `, err);
1894
+ });
1895
+ }
1896
+ const LeadLog = (...params) => {
1897
+ if (process.env.NODE_ENV !== 'production' ||
1898
+ (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
1899
+ process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
1900
+ (typeof localStorage !== 'undefined' &&
1901
+ localStorage.getItem('hhg_debug') === 'true')) {
1902
+ console.log(...params);
1903
+ }
1904
+ };
1905
+
1906
+ const LeadGenContext = createContext({
1907
+ submit(value) {
1908
+ /** Init for FAKING function */
1909
+ LeadLog('** LeadGen Submit : ', value);
1910
+ return Promise.reject(value);
1911
+ },
1912
+ submitSubscriptionBox(value) {
1913
+ /** Init for FAKING function */
1914
+ LeadLog('** LeadGen SubmitSubscriptionBox : ', value);
1915
+ return Promise.reject(value);
1916
+ },
1917
+ impression(value) {
1918
+ /** Init for FAKING function */
1919
+ LeadLog('** LeadGen Impression : ', value);
1920
+ return Promise.reject(value);
1921
+ },
1922
+ /** For Subscription Box */
1923
+ subscriptionIcon: '',
1924
+ subscriptionTitle: '',
1925
+ });
1926
+ const LeadGenContextProvider = (props) => {
1927
+ const { campaign_code: campaignCodeProps, apiSsoUrl, apiLeadUrl, apiSubotUrl, locale: localeProps, forceCampaign: forceCampaignProps, extraValues, articleId = 1, categoryId = 1, siteDomain: site_domain, children, } = props;
1928
+ const [forceCampaign, setForceCampaign] = useState(forceCampaignProps);
1929
+ const [subscriptionInfo, setSubscriptionInfo] = useState({
1930
+ subscriptionIcon: '',
1931
+ subscriptionTitle: '',
1932
+ });
1933
+ const locale = useMemo(() => {
1934
+ return localeProps || LOCALE['PhilippinesEnglish'];
1935
+ }, [localeProps]);
1936
+ const leadGenContextValue = useMemo(() => (Object.assign(Object.assign({}, props), { forceCampaign })), [...Object.values(props), forceCampaign]);
1937
+ const { url, campaign_id, campaign_code, cookie_id, ga_client_id, category_id, article_id, article_title, } = useMemo(() => ({
1938
+ url: location.href.toLowerCase() || '',
1939
+ cookie_id: getCookie('hhg-id') || null,
1940
+ ga_client_id: getCookie('_ga'),
1941
+ campaign_id: forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id,
1942
+ campaign_code: campaignCodeProps || (forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.code),
1943
+ category_id: categoryId,
1944
+ article_id: articleId,
1945
+ article_title: document.title || '',
1946
+ }), [campaignCodeProps, articleId, categoryId, forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id]);
1947
+ const fetchCampaign = useCallback((campaign_code) => {
1948
+ Service.getCampaignByCode(campaign_code).then((res) => {
1949
+ const { _data } = res || {};
1950
+ const { campaigns } = _data || {};
1951
+ LeadLog('** LeadGen Campaign : ', campaigns);
1952
+ setForceCampaign(formatCampaignDetail(campaigns));
1953
+ });
1954
+ }, [campaignCodeProps]);
1955
+ // TODO : Update form for LeadGen
1956
+ const submit = useCallback((data) => {
1957
+ return Service.postSubscriptionBoxLead({ data });
1958
+ }, []);
1959
+ const submitSubscriptionBox = useCallback((value) => {
1960
+ const data = Object.assign(Object.assign(Object.assign(Object.assign({}, value), { campaign_id,
1961
+ 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,
1962
+ category_id, article_title: (extraValues === null || extraValues === void 0 ? void 0 : extraValues.article_title) || article_title });
1963
+ return Service.postSubscriptionBoxLead({ data });
1964
+ }, [
1965
+ extraValues,
1966
+ site_domain,
1967
+ campaign_id,
1968
+ article_id,
1969
+ article_title,
1970
+ category_id,
1971
+ url,
1972
+ ga_client_id,
1973
+ ]);
1974
+ const impression = useCallback((value) => {
1975
+ return Service.campaignPostImpression({
1976
+ url: (value === null || value === void 0 ? void 0 : value.url) || url,
1977
+ action: (value === null || value === void 0 ? void 0 : value.action) || LEADGEN_ACTIONS.SCROLL,
1978
+ code: (value === null || value === void 0 ? void 0 : value.code) || campaign_code,
1979
+ title_article: (value === null || value === void 0 ? void 0 : value.title_article) || article_title,
1980
+ cookie_id: (value === null || value === void 0 ? void 0 : value.cookie_id) || cookie_id,
1981
+ ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id,
1982
+ extra: (value === null || value === void 0 ? void 0 : value.extra) || Object.assign({ cookie_id,
1983
+ article_id, subscription_title: subscriptionInfo.subscriptionTitle }, extraValues),
1984
+ referrer: value === null || value === void 0 ? void 0 : value.referrer,
1985
+ });
1986
+ }, [
1987
+ extraValues,
1988
+ campaign_id,
1989
+ url,
1990
+ campaign_code,
1991
+ article_title,
1992
+ cookie_id,
1993
+ ga_client_id,
1994
+ article_id,
1995
+ subscriptionInfo.subscriptionTitle,
1996
+ ]);
1997
+ useEffect(() => {
1998
+ if (forceCampaignProps) {
1999
+ setForceCampaign(forceCampaignProps);
2000
+ return;
2001
+ }
2002
+ /** For Subscription Box */
2003
+ if (categoryId) {
2004
+ Service.getSubscriptionBoxInfo({
2005
+ category: categoryId,
2006
+ site: site_domain,
2007
+ }).then((res) => {
2008
+ const { _data } = res || {};
2009
+ const { item, campaign_code } = _data || {};
2010
+ const { icon, content } = item || {};
2011
+ LeadLog('** LeadGen SubscriptionBox campaign_code : ', campaign_code);
2012
+ LeadLog('** LeadGen SubscriptionBox subscription_icon : ', icon);
2013
+ LeadLog('** LeadGen SubscriptionBox subscription_title : ', content);
2014
+ if (icon && content) {
2015
+ setSubscriptionInfo({
2016
+ subscriptionIcon: icon,
2017
+ subscriptionTitle: content,
2018
+ });
2019
+ }
2020
+ if (campaign_code) {
2021
+ fetchCampaign(campaign_code);
2022
+ }
2023
+ });
2024
+ return;
2025
+ }
2026
+ if (campaignCodeProps) {
2027
+ fetchCampaign(campaignCodeProps);
2028
+ }
2029
+ }, [campaignCodeProps, categoryId]);
2030
+ useEffect(() => {
2031
+ leadStore.apiSsoUrl = apiSsoUrl;
2032
+ leadStore.apiLeadUrl = apiLeadUrl;
2033
+ leadStore.apiSubotUrl = apiSubotUrl;
2034
+ }, [apiLeadUrl, apiSubotUrl, apiSsoUrl]);
2035
+ if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
2036
+ return null;
2037
+ }
2038
+ return (React__default.createElement(LeadGenContext.Provider, { value: Object.assign(Object.assign(Object.assign({}, leadGenContextValue), subscriptionInfo), { submit,
2039
+ submitSubscriptionBox,
2040
+ impression }) },
2041
+ React__default.createElement(LeadGenTranslationProvider, { locale: locale }, children)));
2042
+ };
2043
+ const useLeadGenContext = () => {
2044
+ const context = useContext(LeadGenContext);
2045
+ return Object.assign(Object.assign({}, context), { apiLeadUrl: context.apiLeadUrl || leadStore.apiLeadUrl, apiSubotUrl: context.apiSubotUrl || leadStore.apiSubotUrl });
2046
+ };
2047
+
2048
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
2049
+ const customParseFormat = require('dayjs/plugin/customParseFormat');
2050
+ dayjs.extend(customParseFormat);
2051
+ // You can give context variables any name
2052
+ const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
2053
+ const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
2054
+ var _a;
2055
+ const { t } = useTranslations();
2056
+ const initialValues = useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
2057
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[(_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.lang] ||
2058
+ LEAD_LOCALE_DATA['vi-VN'];
2059
+ const validateObj = useMemo(() => {
2060
+ const InputBlocks = [
2061
+ 'TextBlock',
2062
+ 'NumberBlock',
2063
+ 'EmailBlock',
2064
+ 'PhoneBlock',
2065
+ 'DateBlock',
2066
+ 'CheckboxBlock',
2067
+ 'RadioBlock',
2068
+ 'DropdownBlock',
2069
+ 'PhoneOtpBlock',
2070
+ 'WhatsappOtpBlock',
2071
+ 'ZaloOtpBlock',
2072
+ 'LocationBlock',
2073
+ 'TncBlock',
2074
+ ];
2075
+ // ALL are required and can skip if not touched yet
2076
+ const withSharedCheck = (name, cb,
2077
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2078
+ block) => {
2079
+ return (value) => {
2080
+ var _a;
2081
+ const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
2082
+ if (!formRef.current.isTouched(name))
2083
+ return;
2084
+ if ((typeof value === 'string' && value.trim() === '') ||
2085
+ typeof value === 'undefined' ||
2086
+ (Array.isArray(value) && value.length === 0)) {
2087
+ return isBLockRequired
2088
+ ? t('validator.required')
2089
+ : cb === null || cb === void 0 ? void 0 : cb(value);
2090
+ }
2091
+ return cb === null || cb === void 0 ? void 0 : cb(value);
2092
+ };
2093
+ };
2094
+ return listBlockAdded
2095
+ .filter((b) => InputBlocks.includes(b.name))
2096
+ .reduce((r, b) => {
2097
+ const { name: fieldType, data } = b || {};
2098
+ const { value: fieldName, required } = data || {};
2099
+ const isRequired = required !== null && required !== void 0 ? required : true;
2100
+ if (fieldType === 'NumberBlock') {
2101
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2102
+ if (value && isNaN(Number(value))) {
2103
+ return t('validator.number');
2104
+ }
2105
+ }, b) });
2106
+ }
2107
+ else if (fieldType === 'EmailBlock') {
2108
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2109
+ if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
2110
+ return t('validator.email');
2111
+ }
2112
+ if (!value)
2113
+ return;
2114
+ validatingEmailRef.current = true;
2115
+ setTimeout(() => {
2116
+ formRef.current.setFieldError(fieldName, 'Validating...');
2117
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2118
+ email: value,
2119
+ })
2120
+ .then((tKey) => {
2121
+ if (tKey) {
2122
+ formRef.current.setFieldError(fieldName, t(tKey));
2123
+ }
2124
+ else {
2125
+ formRef.current.clearFieldError(fieldName);
2126
+ }
2127
+ validatingEmailRef.current = false;
2128
+ })
2129
+ .catch((e) => {
2130
+ console.error(e);
2131
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2132
+ validatingEmailRef.current = false;
2133
+ });
2134
+ }, 200);
2135
+ }, b) });
2136
+ }
2137
+ else if (fieldType === 'PhoneBlock' ||
2138
+ fieldType === 'PhoneOtpBlock' ||
2139
+ fieldType === 'ZaloOtpBlock' ||
2140
+ fieldType === 'WhatsappOtpBlock') {
2141
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2142
+ if (value &&
2143
+ window.intlTelInputUtils &&
2144
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
2145
+ return t('validator.phone');
2146
+ }
2147
+ if (!value)
2148
+ return;
2149
+ validatingPhoneRef.current = true;
2150
+ setTimeout(() => {
2151
+ formRef.current.setFieldError(fieldName, 'Validating...');
2152
+ if (b.data.singleSubmission) {
2153
+ checkUsedPhoneOnlyWithCache(campaignId, value)
2154
+ .then((tKey) => {
2155
+ if (tKey) {
2156
+ formRef.current.setFieldError(fieldName, t(tKey));
2157
+ }
2158
+ else {
2159
+ formRef.current.clearFieldError(fieldName);
2160
+ }
2161
+ validatingPhoneRef.current = false;
2162
+ })
2163
+ .catch((err) => {
2164
+ console.error(err);
2165
+ formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
2166
+ validatingPhoneRef.current = false;
2167
+ });
2168
+ }
2169
+ else {
2170
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2171
+ phone: value,
2172
+ })
2173
+ .then((tKey) => {
2174
+ if (tKey) {
2175
+ formRef.current.setFieldError(fieldName, t(tKey));
2176
+ }
2177
+ else {
2178
+ formRef.current.clearFieldError(fieldName);
2179
+ }
2180
+ validatingPhoneRef.current = false;
2181
+ })
2182
+ .catch((e) => {
2183
+ console.error(e);
2184
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2185
+ validatingPhoneRef.current = false;
2186
+ });
2187
+ }
2188
+ }, 200);
2189
+ }, b) });
2190
+ }
2191
+ else if (fieldType === 'DateBlock') {
2192
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2193
+ if (!isRequired && !value) {
2194
+ return;
2195
+ }
2196
+ const errMsg = t('validator.dateInvalid');
2197
+ const dayInJS = typeof value === 'string'
2198
+ ? dayjs(value, format, true)
2199
+ : dayjs(value);
2200
+ if (!dayInJS.isValid()) {
2201
+ return errMsg;
2202
+ }
2203
+ }, b) });
2204
+ }
2205
+ else if (fieldType === 'TncBlock') {
2206
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
2207
+ if (isRequired && !value) {
2208
+ return t('validator.required');
2209
+ }
2210
+ }, b) });
2211
+ }
2212
+ else {
2213
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
2214
+ }
2215
+ }, {});
2216
+ }, [listBlockAdded.map((b) => b.name).join(','), format]);
2217
+ const form = useLeadForm({
2218
+ validateInputOnChange: true,
2219
+ validateInputOnBlur: true,
2220
+ clearInputErrorOnChange: true,
2221
+ validate: validateObj,
2222
+ initialValues,
2223
+ });
2224
+ const formRef = useRef(form);
2225
+ formRef.current = form;
2226
+ return { form, validateObj };
2227
+ };
2228
+
2229
+ const StyledLeadGenThankYou = styled.div `
2230
+ display: flex;
2231
+ gap: 8px;
2232
+ flex-direction: column;
2233
+ padding-block: 24px;
2234
+
2235
+ .leadgen-image {
2236
+ width: 120px;
2237
+ height: 120px;
2238
+ margin-inline: auto;
2239
+ object-fit: contain;
2240
+ object-position: center;
2241
+ text-align: center;
2242
+ }
2243
+
2244
+ .leadgen-title {
2245
+ margin-block: 0;
2246
+ color: ${theme.colors.gray900};
2247
+ font-weight: 700;
2248
+ font-size: 18px;
2249
+ line-height: 28px;
2250
+ letter-spacing: -0.2px;
2251
+ }
2252
+
2253
+ .leadgen-description {
2254
+ margin-block: 0;
2255
+ color: ${theme.colors.gray600};
2256
+ font-weight: 400;
2257
+ font-size: 14px;
2258
+ line-height: 22px;
2259
+ letter-spacing: -0.2px;
2260
+ text-align: center;
2261
+ }
2262
+
2263
+ > [data-align] {
2264
+ &[data-align='right'] {
2265
+ text-align: right;
2266
+ }
2267
+ &[data-align='center'] {
2268
+ text-align: center;
2269
+ }
2270
+ }
2271
+ `;
2272
+ const LeadGenThankYou = ({ image, title, description, showButton = false, button, className, style, }) => {
2273
+ const { src } = image;
2274
+ const { htmlText: titleText, align: titleAlign } = title;
2275
+ const { htmlText: descriptionText, align: descriptionAlign } = description;
2276
+ const { htmlText: buttonText, newtab, url, onClick } = button;
2277
+ return (React__default.createElement(StyledLeadGenThankYou, { className: className, style: style },
2278
+ React__default.createElement("img", { src: src, alt: "", className: "leadgen-thankyou_image leadgen-image" }),
2279
+ React__default.createElement("p", { className: "leadgen-thankyou_title leadgen-title", "data-align": titleAlign }, titleText),
2280
+ React__default.createElement("p", { className: "leadgen-thankyou_description leadgen-description", "data-align": descriptionAlign }, descriptionText),
2281
+ !!buttonText && showButton && (React__default.createElement(Button$1, { component: url ? 'a' : 'button', target: newtab ? '_blank' : undefined, href: url, size: "lg", variant: "filled", className: "leadgen-thankyoue_btn leadgen-btn", onClick: onClick }, buttonText))));
2282
+ };
2283
+
2284
+ const StyledLeadGenSubscriptionBoxBody = styled.div `
2285
+ margin-top: 16px;
2286
+ .leadgen-btn {
2287
+ margin-top: 16px;
2288
+ }
2289
+ `;
2290
+ const StyledLeadGenSubscriptionBoxHeaderImage = styled.div `
2291
+ margin-top: 3px;
2292
+ margin-right: 20px;
2293
+ width: 44px;
2294
+ height: 44px;
2295
+
2296
+ img {
2297
+ width: 100%;
2298
+ height: 100%;
2299
+ object-fix: contain;
2300
+ onject-position: center;
2301
+ }
2302
+
2303
+ :has(img[src='']) {
2304
+ display: none;
2305
+ }
2306
+ `;
2307
+ const StyledLeadGenSubscriptionBoxHeader = styled.div `
2308
+ display: flex;
2309
+ align-items: center;
2310
+ margin-bottom: 16px;
2311
+ .leadgen-title {
2312
+ margin-bottom: 0;
2313
+ flex: 1;
2314
+ min-width: 0;
2315
+ color: ${theme.colors.gray900};
2316
+ font-size: 18px;
2317
+ font-weight: 400;
2318
+ line-height: 1.4;
2319
+ letter-spacing: -0.8px;
2320
+ }
2321
+ `;
2322
+ const StyledLeadGenSubscriptionBox = styled.div `
2323
+ padding: 16px;
2324
+ border: 1px solid ${theme.colors.neutral100};
2325
+ border-radius: 12px;
2326
+ margin-inline: auto;
2327
+ .leadgen-form_inputs {
2328
+ .leadgen-form_input {
2329
+ width: 100%;
2330
+ }
2331
+ }
2332
+
2333
+ .leadgen-form_input {
2334
+ .mantine-Input-wrapper {
2335
+ max-height: 56px;
2336
+ }
2337
+ }
2338
+
2339
+ @media screen and (min-width: 768px) {
2340
+ .leadgen-subscription_box_body {
2341
+ display: flex;
2342
+ > form {
2343
+ flex: 1;
2344
+ min-width: 0;
2345
+
2346
+ .leadgen-form_inputs {
2347
+ .leadgen-form_input {
2348
+ width: calc(50% - 4px);
2349
+ }
2350
+ }
2351
+ }
2352
+
2353
+ .leadgen-btn {
2354
+ margin-top: 0;
2355
+ margin-left: 8px;
2356
+ width: auto;
2357
+ min-height: 56px;
2358
+ }
2359
+ }
2360
+ }
2361
+ `;
2362
+ const StyledLeadGenSubscriptionBoxA = styled.div `
2363
+ .leadgen-form_input {
2364
+ --phone-select: 45px;
2365
+ .PhoneInput {
2366
+ --phone-select: 45px;
2367
+ .PhoneInputCountry {
2368
+ margin-top: 1px;
2369
+ pointer-events: none;
2370
+ .PhoneInputCountryIconImg,
2371
+ .PhoneInputArrowContainer {
2372
+ display: none;
2373
+ }
2374
+ }
2375
+ }
2376
+ }
2377
+ `;
2378
+
2379
+ const PhoneInput = forwardRef((props, ref) => {
2380
+ const { defaultCountry, id: idProps, name, placeholder, label, labelElement, labelProps, description, descriptionProps, withAsterisk, inputMode, inputContainer, inputWrapperOrder, error, className, classNames, style, styles } = props, restProps = __rest(props, ["defaultCountry", "id", "name", "placeholder", "label", "labelElement", "labelProps", "description", "descriptionProps", "withAsterisk", "inputMode", "inputContainer", "inputWrapperOrder", "error", "className", "classNames", "style", "styles"]);
2381
+ const id = idProps || v1() + name;
2382
+ return (React__default.createElement(Input$1.Wrapper, { size: "md", label: label, labelElement: labelElement, labelProps: Object.assign({ htmlFor: id }, labelProps), description: description, descriptionProps: descriptionProps, withAsterisk: withAsterisk, inputMode: inputMode, inputContainer: inputContainer, inputWrapperOrder: inputWrapperOrder, error: error, "data-invalid": !!error, className: className, classNames: classNames, style: style, styles: styles },
2383
+ React__default.createElement("div", { className: "mantine-Input-wrapper" },
2384
+ React__default.createElement(Phone, Object.assign({}, restProps, { id: id, ref: ref, name: name, spellCheck: false, placeholder: placeholder, defaultCountry: defaultCountry, className: "mantine-Input-input", type: "tel", "data-control": "tel" })))));
2385
+ });
2386
+
2387
+ const formatLeadGenFormValue = (values, blocks) => {
2388
+ const newValues = {};
2389
+ for (const block of blocks) {
2390
+ const { data } = block || {};
2391
+ const { value: fieldName } = data || {};
2392
+ if (fieldName in values) {
2393
+ newValues[fieldName] = values[fieldName];
2394
+ }
2395
+ }
2396
+ return newValues;
2397
+ };
2398
+
2399
+ const StyledLeadGenFormInner = styled.div `
2400
+ display: flex;
2401
+ flex-wrap: wrap;
2402
+ gap: 8px;
2403
+ .leadgen-form_input {
2404
+ width: calc(50% - 4px);
2405
+ }
2406
+
2407
+ .leadgen-form_input_checkbox {
2408
+ width: 100%;
2409
+ }
2410
+ `;
2411
+
2412
+ const cssInputNotShrink$1 = css `
2413
+ height: 100% !important;
2414
+ min-height: calc(var(--container-height, 56px) * 22 / 56);
2415
+ color: ${theme.colors.gray800};
2416
+ font-size: var(--input, 16px);
2417
+ line-height: calc(var(--container-height, 56px) * 22 / 56);
2418
+ border: none !important;
2419
+ border-radius: 0 !important;
2420
+ outline: none !important;
2421
+ box-shadow: none !important;
2422
+ padding: 0;
2423
+ cursor: pointer;
2424
+ opacity: 0;
2425
+
2426
+ ::placeholder {
2427
+ color: ${theme.colors.gray400};
2428
+ }
2429
+ `;
2430
+ const cssInputShrink$1 = css `
2431
+ height: auto !important;
2432
+ cursor: text;
2433
+ opacity: 1;
2434
+ transition: 0.1s ease-in-out all;
2435
+ `;
2436
+ const cssLabelNotShrink$1 = css `
2437
+ position: absolute;
2438
+ top: calc(var(--container-height) / 2);
2439
+ left: var(--space-x, 16px);
2440
+ color: ${theme.colors.gray400};
2441
+ font-size: var(--label-not-shrink, 16px);
2442
+ font-weight: 400;
2443
+ line-height: calc(var(--container-height, 56px) * 18 / 56);
2444
+ margin: 0;
2445
+ z-index: 1;
2446
+ cursor: pointer;
2447
+ transform: translateY(-50%);
2448
+ transition: 0.125s ease-in all;
2449
+ `;
2450
+ const cssLabelShrink$1 = css `
2451
+ color: ${theme.colors.gray600};
2452
+ font-weight: 600;
2453
+ font-size: var(--label-shrink, 12px);
2454
+ top: calc(var(--container-height) * 7 / 56);
2455
+ transform: none;
2456
+ transition: 0.125s ease-out all;
2457
+ `;
2458
+ const cssWrapperInputNotShrink$1 = css `
2459
+ min-height: var(--container-height, 56px);
2460
+ display: flex;
2461
+ align-items: flex-end;
2462
+ border: 1px solid ${theme.colors.gray200};
2463
+ border-radius: 8px;
2464
+ background-color: #fff;
2465
+ padding-inline: var(--space-x, 16px);
2466
+ padding-block: var(--space-y-not-shrink, 16px);
2467
+ cursor: pointer;
2468
+ pointer-events: none;
2469
+
2470
+ &:has(.mantine-Input-rightSection) {
2471
+ padding-right: var(--container-height, 56px);
2472
+ }
2473
+
2474
+ .mantine-Input-icon {
2475
+ display: none;
2476
+ }
2477
+
2478
+ .mantine-NumberInput-control {
2479
+ border-color: ${theme.colors.gray200};
2480
+ }
2481
+ `;
2482
+ const cssWrapperInputShrink$1 = css `
2483
+ height: auto;
2484
+ min-height: var(--container-height, 56px);
2485
+ padding-block: var(--space-y-shrink, 7px);
2486
+ cursor: text;
2487
+ pointer-events: auto;
2488
+ `;
2489
+ const cssInputWrapperError$1 = css `
2490
+ color: ${theme.colors.red800};
2491
+ font-size: 12px;
2492
+ line-height: 1.5;
2493
+ `;
2494
+ const StyledTextFieldContainer$1 = styled.div `
2495
+ --space-x: 16px;
2496
+ --space-y-not-shrink: 16px;
2497
+ --space-y-shrink: 7px;
2498
+ --container-height: 56px;
2499
+ --label-not-shrink: 16px;
2500
+ --label-shrink: 12px;
2501
+ --input: 16px;
2502
+
2503
+ position: relative;
2504
+ min-width: 100px;
2505
+ max-width: 100%;
2506
+ display: inline-block;
2507
+
2508
+ .textField_wrapper {
2509
+ display: inline-block;
2510
+ width: 100%;
2511
+ cursor: pointer;
2512
+ }
2513
+
2514
+ .mantine-InputWrapper-root {
2515
+ &[data-invalid='true'] {
2516
+ .mantine-Input-wrapper {
2517
+ border-color: ${theme.colors.red400};
2518
+ }
2519
+ }
2520
+
2521
+ .mantine-Input-wrapper {
2522
+ &:has([data-invalid]) {
2523
+ border-color: ${theme.colors.red400};
2524
+ }
2525
+ }
2526
+
2527
+ .mantine-InputWrapper-error {
2528
+ font-size: 12px !important;
2529
+ }
2530
+ }
2531
+
2532
+ .mantine-InputWrapper-label {
2533
+ ${cssLabelNotShrink$1}
2534
+ }
2535
+
2536
+ .mantine-Input-wrapper {
2537
+ ${cssWrapperInputNotShrink$1}
2538
+
2539
+ + .mantine-Popover-dropdown[data-position="bottom-start"] {
2540
+ left: 0 !important;
2541
+ }
2542
+ + .mantine-Popover-dropdown[data-position='top-start'] {
2543
+ top: unset !important;
2544
+ left: 0 !important;
2545
+ bottom: 100% !important;
2546
+ }
2547
+ }
2548
+
2549
+ .mantine-Input-input {
2550
+ ${cssInputNotShrink$1}
2551
+ }
2552
+
2553
+ &.textField_shrink,
2554
+ &:focus-within {
2555
+ .mantine-InputWrapper-label {
2556
+ ${cssLabelShrink$1}
2557
+ }
2558
+
2559
+ .mantine-Input-wrapper {
2560
+ ${cssWrapperInputShrink$1}
2561
+ &.mantine-Select-wrapper {
2562
+ .mantine-Select-rightSection {
2563
+ pointer-events: auto !important;
2564
+ }
2565
+ }
2566
+ }
2567
+
2568
+ .mantine-Input-input {
2569
+ ${cssInputShrink$1}
2570
+ }
2571
+
2572
+ &:has(.PhoneInput) {
2573
+ .mantine-InputWrapper-label {
2574
+ left: var(--space-x, 16px);
2575
+ }
2576
+ .PhoneInput {
2577
+ .PhoneInputInput {
2578
+ opacity: 1;
2579
+ }
2580
+ }
2581
+ }
2582
+ }
2583
+
2584
+ .PhoneInput {
2585
+ --phone-select: 75px;
2586
+ --phone-input-space-x: 8px;
2587
+ width: 100%;
2588
+ opacity: 1;
2589
+ border: none;
2590
+ .PhoneInputCountry {
2591
+ background-color: transparent;
2592
+ border: none;
2593
+ padding: 0;
2594
+ width: var(--phone-select, 75px);
2595
+ }
2596
+ .PhoneInputInput {
2597
+ flex: 1;
2598
+ min-width: 0;
2599
+ line-height: 1.5;
2600
+ outline: none !important;
2601
+ border: none;
2602
+ box-shadow: none;
2603
+ padding: 0 var(--phone-input-space-x, 8px);
2604
+ opacity: 0;
2605
+ color: ${theme.colors.gray800} !important;
2606
+ :focus {
2607
+ color: ${theme.colors.gray800} !important;
2608
+ }
2609
+ }
2610
+ }
2611
+
2612
+ &:has(.PhoneInput) {
2613
+ .mantine-InputWrapper-label {
2614
+ left: calc(
2615
+ var(--space-x, 16px) + var(--phone-select, 75px) +
2616
+ var(--phone-input-space-x, 8px)
2617
+ );
2618
+ }
2619
+ }
2620
+ `;
2621
+ const StyledChoiceFieldContainer$1 = styled.div `
2622
+ &.leadgen-form_checkbox,
2623
+ &.leadgen-form_radio {
2624
+ width: 100%;
2625
+ }
2626
+
2627
+ &.leadgen-form_dropdown {
2628
+ width: calc(50% - 12px);
2629
+ }
2630
+
2631
+ .mantine-InputWrapper-root {
2632
+ display: block;
2633
+ .mantine-InputWrapper-error {
2634
+ font-size: 12px !important;
2635
+ }
2636
+ }
2637
+
2638
+ .mantine-InputWrapper-label {
2639
+ margin-bottom: 0.5rem;
2640
+ color: ${theme.colors.gray800};
2641
+ font-size: 16px;
2642
+ font-weight: 400;
2643
+ line-height: 1.5;
2644
+ }
2645
+
2646
+ .mantine-Radio-root,
2647
+ .mantine-Checkbox-root {
2648
+ gap: 8px;
2649
+ min-width: calc(50% - 4px);
2650
+
2651
+ input[type='radio'],
2652
+ input[type='checkbox'] {
2653
+ border-color: ${theme.colors.gray600};
2654
+ width: 18px;
2655
+ height: 18px;
2656
+ }
2657
+ input[type='checkbox'] {
2658
+ border-radius: 4px;
2659
+ }
2660
+
2661
+ &[data-checked='true'] {
2662
+ input[type='radio'],
2663
+ input[type='checkbox'] {
2664
+ border-color: ${theme.colors.primary600};
2665
+ + svg {
2666
+ color: ${theme.colors.primary600};
2667
+ }
2668
+ }
2669
+
2670
+ input[type='radio'] {
2671
+ background-color: white;
2672
+ }
2673
+ }
2674
+
2675
+ .mantine-Checkbox-input {
2676
+ &:checked {
2677
+ border-color: ${theme.colors.primary600};
2678
+ }
2679
+ }
2680
+ }
2681
+
2682
+ .mantine-Radio-inner,
2683
+ .mantine-Checkbox-inner {
2684
+ width: 24px;
2685
+ height: 24px;
2686
+ display: flex;
2687
+ align-items: center;
2688
+ justify-content: center;
2689
+ }
2690
+
2691
+ .mantine-Radio-body,
2692
+ .mantine-Checkbox-body {
2693
+ display: flex;
2694
+ align-items: center;
2695
+ }
2696
+
2697
+ .mantine-Radio-label,
2698
+ .mantine-Checkbox-label {
2699
+ padding-left: 8px;
2700
+ color: ${theme.colors.gray800};
2701
+ font-size: 14px;
2702
+ line-height: 1.4;
2703
+ letter-spacing: -0.2px;
2704
+ }
2705
+
2706
+ .leadgen-choiceContainer {
2707
+ display: flex;
2708
+ flex-wrap: wrap;
2709
+ align-items: flex-start;
2710
+ gap: 8px;
2711
+ }
2712
+
2713
+ .mantine-InputWrapper-error {
2714
+ ${cssInputWrapperError$1}
2715
+ }
2716
+ `;
2717
+
2718
+ const TextField$1 = (props) => {
2719
+ const { shrink: shrinkProps, onChangeShrink, className, children } = props, restProps = __rest(props, ["shrink", "onChangeShrink", "className", "children"]);
2720
+ const containerRef = useClickOutside(() => {
2721
+ if (shrinkProps) {
2722
+ return;
2723
+ }
2724
+ setShrink(false);
2725
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(false);
2726
+ });
2727
+ const [shrink, setShrink] = useState(shrinkProps);
2728
+ const onClick = useCallback((e) => {
2729
+ setShrink(true);
2730
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(true);
2731
+ if (shrink) {
2732
+ return;
2733
+ }
2734
+ const $textEl = e.currentTarget.querySelectorAll('input:not([disabled]):not([type="submit"]),select:not([disabled]),textarea:not([disabled])');
2735
+ const $focusEl = $textEl.item($textEl.length - 1);
2736
+ if ($focusEl) {
2737
+ $focusEl.focus();
2738
+ setTimeout(() => {
2739
+ $focusEl.scrollIntoView({
2740
+ behavior: 'auto',
2741
+ block: 'center',
2742
+ inline: 'start',
2743
+ });
2744
+ }, 100);
2745
+ }
2746
+ }, [shrink]);
2747
+ useEffect(() => {
2748
+ setShrink(shrinkProps);
2749
+ }, [shrinkProps]);
2750
+ return (React__default.createElement(StyledTextFieldContainer$1, Object.assign({ shrink: shrink, className: clsx(className, 'textField', { textField_shrink: !!shrink }) }, restProps),
2751
+ React__default.createElement("div", { ref: containerRef, onClick: onClick, className: "textField_wrapper" }, children)));
2752
+ };
2753
+ const ChoiceField$1 = (props) => {
2754
+ const { children, className } = props, restProps = __rest(props, ["children", "className"]);
2755
+ return (React__default.createElement(StyledChoiceFieldContainer$1, Object.assign({ className: clsx(className, 'choiceField') }, restProps), children));
2756
+ };
2757
+
2758
+ const libraries = ['places'];
2759
+ const GoogleLocationBlock = (props) => {
2760
+ var _a;
2761
+ const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = __rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
2762
+ const [LoadScript, setLoadScript] = useState(null);
2763
+ const [value, setValue] = useState(defaultValue || valueProps);
2764
+ const { predictions } = usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
2765
+ const onChangeAutocomplete = useCallback((s) => {
2766
+ setValue(s);
2767
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
2768
+ }, []);
2769
+ const onClickItem = useCallback((item) => {
2770
+ /** For sure get value */
2771
+ setValue(item.value);
2772
+ const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
2773
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
2774
+ }, [onChangeProps, predictions]);
2775
+ useEffect(() => {
2776
+ setValue(valueProps);
2777
+ }, [valueProps]);
2778
+ useEffect(() => {
2779
+ var _a, _b, _c;
2780
+ // only load extra google script when not yet loaded
2781
+ 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) {
2782
+ import('@react-google-maps/api').then((m) => {
2783
+ setLoadScript(() => m.LoadScript);
2784
+ });
2785
+ }
2786
+ }, []);
2787
+ return (React__default.createElement(Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
2788
+ return { value: pred.description, label: pred.description };
2789
+ }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
2790
+ return (React__default.createElement(React__default.Fragment, null,
2791
+ LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default.createElement(React__default.Fragment, null), style: { width: '100%' } })),
2792
+ children));
2793
+ } }, restProps)));
2794
+ };
2795
+
2796
+ const LeadGenForm = forwardRef((props, ref) => {
2797
+ const { locale, blocks, scrollToErrorField = true, form: formProps, rules: validate, initialValues, onFinish, onFinishFailed, className, style, } = props;
2798
+ const formRef = useRef(null);
2799
+ const form = formProps || useForm({ initialValues, validate });
2800
+ const middlewareFinish = useCallback((values, event) => {
2801
+ /** Set `touched` all values for validation when submiting */
2802
+ form.setTouched(blocks.reduce((touched, { data }) => {
2803
+ touched[data.value] = true;
2804
+ return touched;
2805
+ }, {}));
2806
+ /** Wait for `touched` state and then submit */
2807
+ setTimeout(() => {
2808
+ const { hasErrors } = form.validate();
2809
+ if (hasErrors) {
2810
+ return;
2811
+ }
2812
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatLeadGenFormValue(values, blocks), event);
2813
+ }, 100);
2814
+ }, [form, blocks]);
2815
+ const middlewareFinishFailed = useCallback((errors, values, events) => {
2816
+ if (scrollToErrorField && errors) {
2817
+ const firstErrorKey = Object.keys(errors)[0];
2818
+ const firstErrorElement = document.querySelector(`[name="${firstErrorKey}"]`);
2819
+ if (firstErrorElement && (firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus)) {
2820
+ setTimeout(() => {
2821
+ firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
2822
+ firstErrorElement.scrollIntoView({
2823
+ behavior: 'auto',
2824
+ block: 'center',
2825
+ inline: 'center',
2826
+ });
2827
+ }, 100);
2828
+ }
2829
+ }
2830
+ onFinishFailed === null || onFinishFailed === void 0 ? void 0 : onFinishFailed(errors, values, events);
2831
+ }, [scrollToErrorField]);
2832
+ useEffect(() => {
2833
+ (() => __awaiter(void 0, void 0, void 0, function* () {
2834
+ if (!window.intlTelInputUtils) {
2835
+ yield require('intl-tel-input/build/js/utils');
2836
+ }
2837
+ }))();
2838
+ }, []);
2839
+ useImperativeHandle(ref, () => (Object.assign(Object.assign({}, form), { submit: () => {
2840
+ formRef.current.requestSubmit();
2841
+ } })), [form, formRef]);
2842
+ if (!blocks || !blocks.length) {
2843
+ return null;
2844
+ }
2845
+ return (React__default.createElement("form", { ref: formRef, onSubmit: form.onSubmit(middlewareFinish, middlewareFinishFailed), className: className, style: style },
2846
+ React__default.createElement(StyledLeadGenFormInner, { className: "leadgen-form_inputs" }, blocks.map((block, idx) => {
2847
+ const { id, name: blockName, data } = block;
2848
+ const { placeholder, value: name, required, listQuestion, valueHTML, isSendMailChimp = false, } = data;
2849
+ const formInputProps = form.getInputProps(name);
2850
+ const { value, error } = formInputProps;
2851
+ const reactKey = `${id}-${idx}`;
2852
+ switch (blockName) {
2853
+ case LEADGEN_BLOCK.TextBlock: {
2854
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2855
+ React__default.createElement(TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "text", "data-control": "text" }, formInputProps))));
2856
+ }
2857
+ case LEADGEN_BLOCK.NumberBlock: {
2858
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2859
+ React__default.createElement(NumberInput$1, Object.assign({ name: value, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "number", "data-control": "number" }, formInputProps))));
2860
+ }
2861
+ case LEADGEN_BLOCK.EmailBlock: {
2862
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2863
+ React__default.createElement(TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, "data-control": "email" }, formInputProps))));
2864
+ }
2865
+ case LEADGEN_BLOCK.PhoneOtpBlock:
2866
+ case LEADGEN_BLOCK.WhatsappOtpBlock:
2867
+ case LEADGEN_BLOCK.ZaloOtpBlock:
2868
+ case LEADGEN_BLOCK.PhoneBlock: {
2869
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2870
+ React__default.createElement(PhoneInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, defaultCountry: (locale ? MAPPED_LOCALE[locale] || 'VN' : 'VN'), type: "text", "data-control": "text" }, formInputProps))));
2871
+ }
2872
+ case LEADGEN_BLOCK.LocationBlock: {
2873
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2874
+ React__default.createElement(GoogleLocationBlock, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, locale: locale, "data-control": "text" }, formInputProps))));
2875
+ }
2876
+ case LEADGEN_BLOCK.DateBlock: {
2877
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2878
+ React__default.createElement(DateInput, Object.assign({ locale: (MAPPED_LOCALE === null || MAPPED_LOCALE === void 0 ? void 0 : MAPPED_LOCALE[locale]) || MAPPED_LOCALE['vi-VN'], valueFormat: "DD/MM/YYYY", name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "default", "data-control": "date" }, formInputProps))));
2879
+ }
2880
+ case LEADGEN_BLOCK.DropdownBlock:
2881
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2882
+ React__default.createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2883
+ React__default.createElement(Select$1, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, data: listQuestion.map((l) => ({
2884
+ value: l.value,
2885
+ label: l.placeholder,
2886
+ })) }, formInputProps))));
2887
+ case LEADGEN_BLOCK.CheckboxBlock: {
2888
+ const formInputCheckboxProps = form.getInputProps(name, {
2889
+ type: 'checkbox',
2890
+ });
2891
+ return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2892
+ isSendMailChimp && (React__default.createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2893
+ React__default.createElement(Checkbox$1.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, sx: {
2894
+ display: 'flex',
2895
+ flexDirection: 'column',
2896
+ flexWrap: 'wrap',
2897
+ gap: 8,
2898
+ }, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2899
+ return (React__default.createElement("div", { className: "leadgen-choiceContainer" }, children));
2900
+ } }, formInputCheckboxProps), listQuestion.map((l, _idx) => (React__default.createElement(Checkbox$1, { name: name, key: _idx, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2901
+ }
2902
+ case LEADGEN_BLOCK.RadioBlock: {
2903
+ return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2904
+ isSendMailChimp && (React__default.createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2905
+ React__default.createElement(Radio$1.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, spellCheck: true, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2906
+ return (React__default.createElement("div", { className: "leadgen-choiceContainer" }, children));
2907
+ } }, formInputProps), listQuestion.map((l, _index) => (React__default.createElement(Radio$1, { name: name, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2908
+ }
2909
+ case LEADGEN_BLOCK.TncBlock:
2910
+ return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2911
+ React__default.createElement(Input$1.Wrapper, { error: error },
2912
+ React__default.createElement(Checkbox$1, Object.assign({ value: value, name: 'TNC-' + id, label: React__default.createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, formInputProps)))));
2913
+ default: {
2914
+ return null;
2915
+ }
2916
+ }
2917
+ }))));
2918
+ });
2919
+
2920
+ const LEADGEN_ORDER_INPUT_WRAPPER = ['label', 'input', 'description', 'error'];
2921
+
2922
+ const LeadGenSubscriptionBoxA = (props) => {
2923
+ const { loading, image, title, submitText, locale, blocks, form, rules, onFinish, } = props;
2924
+ const formRef = useRef();
2925
+ const imageComp = useMemo(() => {
2926
+ if (!image) {
2927
+ return null;
2928
+ }
2929
+ return (React__default.createElement(StyledLeadGenSubscriptionBoxHeaderImage, null,
2930
+ React__default.createElement("img", { src: image, alt: "" })));
2931
+ }, [image]);
2932
+ const titleComp = useMemo(() => {
2933
+ if (typeof title === 'string') {
2934
+ return (React__default.createElement("p", { className: "leadgen-title", dangerouslySetInnerHTML: { __html: title } }));
2935
+ }
2936
+ return React__default.createElement("p", { className: "leadgen-title" }, title);
2937
+ }, [title]);
2938
+ return (React__default.createElement(StyledLeadGenSubscriptionBoxA, { className: "subcription_box_A" },
2939
+ React__default.createElement(StyledLeadGenSubscriptionBoxHeader, { className: "leadgen-subscription_box_header" },
2940
+ imageComp,
2941
+ titleComp),
2942
+ React__default.createElement(StyledLeadGenSubscriptionBoxBody, { className: "leadgen-subscription_box_body" },
2943
+ React__default.createElement(LeadGenForm, { ref: formRef, form: form, rules: rules, blocks: blocks, locale: locale, onFinish: onFinish, className: "leadgen-subscription_box_form" }),
2944
+ React__default.createElement(Button$1, { disabled: loading, loading: loading, variant: "filled", size: "lg", onClick: () => {
2945
+ formRef.current.submit();
2946
+ }, className: "leadgen-btn leadgen-btn_action", fullWidth: true }, submitText))));
2947
+ };
2948
+
2949
+ const LeadGenSubscriptionBoxWithoutMemo = ({ locale, userInfo, forceCampaign, categoryId, }) => {
2950
+ var _a, _b, _c;
2951
+ const { image, extra_fields, id: campaign_id, bot_id: campaign_subot_id = [], ThankYouBlock, } = forceCampaign || {};
2952
+ const { textBlocks, listBlockAdded, actionBlocks } = extra_fields || {};
2953
+ const { submitBlock } = actionBlocks || {};
2954
+ const { apiLeadUrl, subscriptionIcon, subscriptionTitle, submitSubscriptionBox, impression, onFinish, } = useLeadGenContext();
2955
+ const { t } = useTranslations();
2956
+ const { action: { pushNotifications }, } = useContext(TogetherComponentGlobalContext);
2957
+ const refContainer = useRef(null);
2958
+ const [loading, setLoading] = useState(false);
2959
+ const [showThankyou, setShowThankyou] = useState(false);
2960
+ const validatingEmailRef = useRef(false);
2961
+ const validatingPhoneRef = useRef(false);
2962
+ const { form, validateObj } = useLeadFormConfig({
2963
+ listBlockAdded,
2964
+ campaignId: campaign_id,
2965
+ campaign_subot_id,
2966
+ validatingEmailRef,
2967
+ validatingPhoneRef,
2968
+ userInfo,
2969
+ });
2970
+ const subscription_title = useMemo(() => {
2971
+ var _a, _b;
2972
+ return subscriptionTitle ||
2973
+ ((_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) ||
2974
+ t('leadgen.message.title.default');
2975
+ }, [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]);
2976
+ const { image: thankyouImage, title: thankyouTitle, description: thankyouDescription, button: thankyouButton, } = ThankYouBlock || {};
2977
+ const intersectionObserverCallback = useCallback((entries) => {
2978
+ entries.forEach((entry) => {
2979
+ const { isIntersecting, target } = entry;
2980
+ if (!showThankyou &&
2981
+ isIntersecting &&
2982
+ target === refContainer.current) {
2983
+ impression();
2984
+ }
2985
+ });
2986
+ }, [impression, showThankyou]);
2987
+ const IObserver = new IntersectionObserver(intersectionObserverCallback);
2988
+ const middlewareOnSubmit = useCallback((values) => __awaiter(void 0, void 0, void 0, function* () {
2989
+ const newValues = {
2990
+ subscription_title,
2991
+ };
2992
+ const ssoValues = {
2993
+ sso_user_id: undefined,
2994
+ sso_uuid: undefined,
2995
+ sso_verified_profile: undefined,
2996
+ };
2997
+ const valueKeys = Object.keys(values);
2998
+ for (const key of valueKeys) {
2999
+ const isPhoneField = leadGenFieldNamePhone(listBlockAdded).some((k) => k === key);
3000
+ if (isPhoneField) {
3001
+ const phone = parsePhoneNumber(values[key]);
3002
+ if (phone.isValid()) {
3003
+ /** Seperate `area_code` and `phone_number` for BE */
3004
+ newValues['area_code'] = `+${phone.countryCallingCode}`;
3005
+ newValues['phone_number'] = phone.nationalNumber;
3006
+ /** Only case login has this update */
3007
+ if ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) && (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid)) {
3008
+ ssoValues['sso_verified_profile'] =
3009
+ phone.number === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone) ? 1 : 0;
3010
+ ssoValues['sso_user_id'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.id;
3011
+ ssoValues['sso_uuid'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid;
3012
+ }
3013
+ }
3014
+ continue;
3015
+ }
3016
+ newValues[key] = values[key];
3017
+ }
3018
+ setLoading(true);
3019
+ try {
3020
+ const { _data } = (yield submitSubscriptionBox(Object.assign(Object.assign({}, newValues), ssoValues))) || {};
3021
+ const { model } = _data || {};
3022
+ if (model && (model === null || model === void 0 ? void 0 : model.id)) {
3023
+ setShowThankyou(true);
3024
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(Object.assign(Object.assign({}, newValues), ssoValues), listBlockAdded || []);
3025
+ }
3026
+ }
3027
+ catch (error) {
3028
+ LeadLog('** LeadGen SubscriptionBox error : ', error);
3029
+ pushNotifications({
3030
+ message: t('leadgen.message.error.default'),
3031
+ type: 'danger',
3032
+ });
3033
+ }
3034
+ setLoading(false);
3035
+ }), [
3036
+ subscription_title,
3037
+ listBlockAdded,
3038
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
3039
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid,
3040
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone,
3041
+ ]);
3042
+ useEffect(() => {
3043
+ if (refContainer.current) {
3044
+ IObserver.observe(refContainer.current);
3045
+ }
3046
+ return () => {
3047
+ IObserver.disconnect();
3048
+ };
3049
+ }, [categoryId]);
3050
+ return (React__default.createElement("div", { ref: refContainer },
3051
+ React__default.createElement(StyledLeadGenSubscriptionBox, null,
3052
+ showThankyou && (React__default.createElement(LeadGenThankYou, { image: Object.assign(Object.assign({}, thankyouImage), { src: thankyouImage.src || `${apiLeadUrl}admin/img/thanksyou.png` }), title: thankyouTitle, description: thankyouDescription, button: thankyouButton })),
3053
+ !showThankyou && (React__default.createElement(LeadGenSubscriptionBoxA, { loading: loading, image: subscriptionIcon || image, title: subscription_title, submitText: (_c = submitBlock === null || submitBlock === void 0 ? void 0 : submitBlock.data) === null || _c === void 0 ? void 0 : _c.value, blocks: listBlockAdded, locale: locale, form: form, rules: validateObj, onFinish: middlewareOnSubmit })))));
3054
+ };
3055
+ const LeadGenSubscriptionBox$1 = memo(LeadGenSubscriptionBoxWithoutMemo);
3056
+
3057
+ const Container = () => {
3058
+ const context = useContext(LeadGenContext);
3059
+ const { campaign_code, locale, siteId, siteDomain, userInfo, forceCampaign } = context;
3060
+ if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
3061
+ return null;
3062
+ }
3063
+ return (React__default.createElement(LeadGenSubscriptionBox$1, { locale: locale, siteId: siteId, siteDomain: siteDomain, userInfo: userInfo, forceCampaign: forceCampaign, campaign_code: campaign_code }));
3064
+ };
3065
+ Container.displayName = 'LeadGenSubscriptionBox';
3066
+ const LeadGenSubscriptionBoxContainer = (props) => {
3067
+ const { apiUrl, apiSubotUrl } = props;
3068
+ return (React__default.createElement(LeadGenContextProvider, Object.assign({}, props, { apiLeadUrl: apiUrl, apiSubotUrl: apiSubotUrl }),
3069
+ React__default.createElement(Container, null)));
3070
+ };
3071
+ const LeadGenSubscriptionBox = LeadGenSubscriptionBoxContainer;
3072
+
3073
+ const useImageSize = (src) => {
3074
+ const [width, setWidth] = useState(16);
3075
+ const [height, setHeight] = useState(9);
3076
+ const [loaded, setLoaded] = useState(false);
3077
+ // load src image to get its width and height
3078
+ useEffect(() => {
3079
+ setLoaded(false);
3080
+ if (src) {
3081
+ const img = new Image();
3082
+ img.addEventListener('load', () => {
3083
+ setWidth(img.naturalWidth);
3084
+ setHeight(img.naturalHeight);
3085
+ setLoaded(true);
3086
+ });
3087
+ img.addEventListener('error', () => {
3088
+ setWidth(16);
3089
+ setHeight(9);
3090
+ setLoaded(true);
3091
+ });
3092
+ img.src = src;
3093
+ }
3094
+ else {
3095
+ setWidth(16);
3096
+ setHeight(9);
3097
+ setLoaded(true);
3098
+ }
3099
+ }, [src]);
3100
+ return {
3101
+ loaded,
3102
+ width,
3103
+ height,
3104
+ };
3105
+ };
3106
+
3107
+ const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default.createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
3108
+ React__default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
3109
+ React__default.createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
3110
+
3111
+ // url: imageBlocks.imageMobile.data.url
3112
+ // newTab: imageBlocks.imageMobile.data.newtab
3113
+ // imageMobile: campaignShow.image
3114
+ // imageDestkop: campaignShow.image_desktop
3115
+ const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
3116
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3117
+ const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
3118
+ if (!imageMobileLoaded || !imageDestkopLoaded)
3119
+ return null;
3120
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
3121
+ React__default.createElement("div", { className: "le-center-tab-popup" },
3122
+ React__default.createElement("div", { style: { position: 'relative' } },
3123
+ React__default.createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
3124
+ isVideo(imageMobile) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
3125
+ React__default.createElement("source", { src: imageMobile }))) : (React__default.createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
3126
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3127
+ } })),
3128
+ isVideo(imageDestkop) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
3129
+ React__default.createElement("source", { src: imageDestkop }))) : (React__default.createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
3130
+ aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
3131
+ } }))),
3132
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3133
+ };
3134
+
3135
+ // title: titleText
3136
+ // titleAlign: textBlocks.titleBlock.data.align
3137
+ // subtitle: textBlocks.subtitleBlock.data.value
3138
+ // subtitleAlign: textBlocks.subtitleBlock.data.align
3139
+ // url: actionBlocks.linkButtonBlock.data.url
3140
+ // urlText: actionBlocks.linkButtonBlock.data.value
3141
+ // newTab: actionBlocks.linkButtonBlock.data.newtab
3142
+ // imageMobile: campaignShow.image
3143
+ // imageDesktop: campaignShow.image_desktop
3144
+ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
3145
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3146
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
3147
+ if (!imageMobileLoaded || !imageDesktopLoaded)
3148
+ return null;
3149
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
3150
+ React__default.createElement("aside", { className: "le-only-desktop" },
3151
+ React__default.createElement("div", { className: "le-floating-desktop" },
3152
+ React__default.createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
3153
+ imageDesktop ? (React__default.createElement("div", null,
3154
+ React__default.createElement("img", { style: {
3155
+ maxWidth: 120,
3156
+ borderTopLeftRadius: 5,
3157
+ borderBottomLeftRadius: 5,
3158
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
3159
+ }, src: imageDesktop }))) : null,
3160
+ React__default.createElement("div", { style: { padding: 20 } },
3161
+ React__default.createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
3162
+ React__default.createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
3163
+ React__default.createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
3164
+ React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
3165
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
3166
+ React__default.createElement("aside", { className: "le-only-mobile" },
3167
+ React__default.createElement("div", { className: "le-floating-mobile" },
3168
+ React__default.createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
3169
+ React__default.createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
3170
+ React__default.createElement("div", null,
3171
+ React__default.createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
3172
+ React__default.createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
3173
+ imageMobile ? (React__default.createElement("div", null,
3174
+ React__default.createElement("img", { style: {
3175
+ marginLeft: 15,
3176
+ marginTop: 4,
3177
+ maxWidth: 100,
3178
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3179
+ }, src: imageMobile }))) : null),
3180
+ React__default.createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
3181
+ React__default.createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
3182
+ React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
3183
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
3184
+ };
3185
+
3186
+ const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
3187
+ const { primaryColor } = useContext(LeadGenContext$1);
3188
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
3189
+ if (!imageLoaded)
3190
+ return null;
3191
+ return (React__default.createElement("div", { className: "lead-modal__thank-you leadgen-inner_thankyou" },
3192
+ React__default.createElement("div", { style: { width: '100%' } },
3193
+ React__default.createElement("img", { src: image, style: {
3194
+ maxHeight: 162,
3195
+ objectFit: 'cover',
3196
+ aspectRatio: `${imageWidth}/${imageHeight}`,
3197
+ }, loading: "lazy" }),
3198
+ title && (React__default.createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
3199
+ subtitle && (React__default.createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle.split('\n').map((text, idx, list) => {
3200
+ const isShowBr = idx < list.length - 1;
3201
+ return (React__default.createElement(React__default.Fragment, null,
3202
+ text,
3203
+ isShowBr && React__default.createElement("br", null)));
3204
+ }))),
3205
+ linkText && (React__default.createElement("div", null,
3206
+ React__default.createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
3207
+ React__default.createElement(Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
3208
+ };
3209
+
3210
+ const InlineLayout = ({ content, inlinePosition, }) => {
3211
+ const target = useMemo(() => {
3212
+ if (!inlinePosition)
3213
+ return null;
1478
3214
  const parents = document.querySelectorAll(`[data-url="${location.pathname}"] .body-content`);
1479
3215
  const allChildren = Array.from(parents).reduce((r, p) => {
1480
3216
  return [...r, ...Array.from(p.children)];
@@ -1603,222 +3339,17 @@ const EmptyIcon = (props) => {
1603
3339
  React__default.createElement("path", { d: "M92.434 95.0004C91.7771 95.0004 91.1213 94.7499 90.6194 94.249L65.7521 69.3807C64.7493 68.3779 64.7493 66.7542 65.7521 65.7524C66.7549 64.7507 68.3786 64.7497 69.3804 65.7524L94.2487 90.6208C95.2515 91.6235 95.2515 93.2473 94.2487 94.249C93.7468 94.7499 93.0909 95.0004 92.434 95.0004Z", fill: "white" }),
1604
3340
  React__default.createElement("path", { d: "M67.5648 95C66.9079 95 66.252 94.7496 65.7501 94.2487C64.7474 93.2459 64.7474 91.6222 65.7501 90.6204L90.6185 65.7521C91.6212 64.7493 93.245 64.7493 94.2467 65.7521C95.2485 66.7549 95.2495 68.3786 94.2467 69.3804L69.3794 94.2487C68.8786 94.7496 68.2217 95 67.5648 95Z", fill: "white" })));
1605
3341
  };
1606
-
1607
- const EmptyComponent = ({ onClose, onContinue, }) => {
1608
- const { t } = useTranslations();
1609
- return (React__default.createElement("div", { className: "leadgen-empty" },
1610
- React__default.createElement("div", { className: "leadgen-empty_body" },
1611
- React__default.createElement("div", { className: "leadgen-empty_wrapper" },
1612
- React__default.createElement(EmptyIcon, { className: "leadgen-empty_image" }),
1613
- React__default.createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
1614
- React__default.createElement("div", { className: "leadgen-empty_footer" },
1615
- React__default.createElement(Button$2, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
1616
- React__default.createElement(Button$2, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
1617
- };
1618
-
1619
- const libraries = ['places'];
1620
- const GoogleLocationBlock = (props) => {
1621
- var _a;
1622
- const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = __rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
1623
- const [LoadScript, setLoadScript] = useState(null);
1624
- const [value, setValue] = useState(defaultValue || valueProps);
1625
- const { predictions } = usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
1626
- const onChangeAutocomplete = useCallback((s) => {
1627
- setValue(s);
1628
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
1629
- }, []);
1630
- const onClickItem = useCallback((item) => {
1631
- /** For sure get value */
1632
- setValue(item.value);
1633
- const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
1634
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
1635
- }, [onChangeProps, predictions]);
1636
- useEffect(() => {
1637
- setValue(valueProps);
1638
- }, [valueProps]);
1639
- useEffect(() => {
1640
- var _a, _b, _c;
1641
- // only load extra google script when not yet loaded
1642
- 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) {
1643
- import('@react-google-maps/api').then((m) => {
1644
- setLoadScript(() => m.LoadScript);
1645
- });
1646
- }
1647
- }, []);
1648
- return (React__default.createElement(Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
1649
- return { value: pred.description, label: pred.description };
1650
- }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
1651
- return (React__default.createElement(React__default.Fragment, null,
1652
- LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default.createElement(React__default.Fragment, null), style: { width: '100%' } })),
1653
- children));
1654
- } }, restProps)));
1655
- };
1656
-
1657
- // You can give context variables any name
1658
- const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
1659
- const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, }) => {
1660
- const { t } = useTranslations();
1661
- const initialValues = useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
1662
- const validateObj = useMemo(() => {
1663
- const InputBlocks = [
1664
- 'TextBlock',
1665
- 'NumberBlock',
1666
- 'EmailBlock',
1667
- 'PhoneBlock',
1668
- 'DateBlock',
1669
- 'CheckboxBlock',
1670
- 'RadioBlock',
1671
- 'DropdownBlock',
1672
- 'PhoneOtpBlock',
1673
- 'WhatsappOtpBlock',
1674
- 'ZaloOtpBlock',
1675
- 'LocationBlock',
1676
- 'TncBlock',
1677
- ];
1678
- // ALL are required and can skip if not touched yet
1679
- const withSharedCheck = (name, cb,
1680
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1681
- block) => {
1682
- return (value) => {
1683
- var _a;
1684
- const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
1685
- if (!formRef.current.isTouched(name))
1686
- return;
1687
- if ((typeof value === 'string' && value.replace(' ', '') === '') ||
1688
- typeof value === 'undefined' ||
1689
- value === '' ||
1690
- (Array.isArray(value) && value.length === 0)) {
1691
- return isBLockRequired
1692
- ? t('validator.required')
1693
- : cb === null || cb === void 0 ? void 0 : cb(value);
1694
- }
1695
- return cb === null || cb === void 0 ? void 0 : cb(value);
1696
- };
1697
- };
1698
- return listBlockAdded
1699
- .filter((b) => InputBlocks.includes(b.name))
1700
- .reduce((r, b) => {
1701
- var _a;
1702
- const isRequired = (_a = b.data.required) !== null && _a !== void 0 ? _a : true;
1703
- if (b.name === 'NumberBlock') {
1704
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1705
- if (value && isNaN(Number(value))) {
1706
- return t('validator.number');
1707
- }
1708
- }, b) });
1709
- }
1710
- else if (b.name === 'EmailBlock') {
1711
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1712
- if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
1713
- return t('validator.email');
1714
- }
1715
- if (!value)
1716
- return;
1717
- validatingEmailRef.current = true;
1718
- setTimeout(() => {
1719
- formRef.current.setFieldError(b.data.value, 'Validating...');
1720
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1721
- email: value,
1722
- })
1723
- .then((tKey) => {
1724
- if (tKey) {
1725
- formRef.current.setFieldError(b.data.value, t(tKey));
1726
- }
1727
- else {
1728
- formRef.current.clearFieldError(b.data.value);
1729
- }
1730
- validatingEmailRef.current = false;
1731
- })
1732
- .catch((e) => {
1733
- console.error(e);
1734
- formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
1735
- validatingEmailRef.current = false;
1736
- });
1737
- }, 200);
1738
- }, b) });
1739
- }
1740
- else if (b.name === 'PhoneBlock' ||
1741
- b.name === 'PhoneOtpBlock' ||
1742
- b.name === 'ZaloOtpBlock' ||
1743
- b.name === 'WhatsappOtpBlock') {
1744
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1745
- if (value &&
1746
- window.intlTelInputUtils &&
1747
- !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
1748
- return t('validator.phone');
1749
- }
1750
- if (!value)
1751
- return;
1752
- validatingPhoneRef.current = true;
1753
- setTimeout(() => {
1754
- formRef.current.setFieldError(b.data.value, 'Validating...');
1755
- if (b.data.singleSubmission) {
1756
- checkUsedPhoneOnlyWithCache(campaignId, value)
1757
- .then((tKey) => {
1758
- if (tKey) {
1759
- formRef.current.setFieldError(b.data.value, t(tKey));
1760
- }
1761
- else {
1762
- formRef.current.clearFieldError(b.data.value);
1763
- }
1764
- validatingPhoneRef.current = false;
1765
- })
1766
- .catch((err) => {
1767
- console.error(err);
1768
- formRef.current.setFieldError(b.data.value, err.message || 'Something went wrong');
1769
- validatingPhoneRef.current = false;
1770
- });
1771
- }
1772
- else {
1773
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1774
- phone: value,
1775
- })
1776
- .then((tKey) => {
1777
- if (tKey) {
1778
- formRef.current.setFieldError(b.data.value, t(tKey));
1779
- }
1780
- else {
1781
- formRef.current.clearFieldError(b.data.value);
1782
- }
1783
- validatingPhoneRef.current = false;
1784
- })
1785
- .catch((e) => {
1786
- console.error(e);
1787
- formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
1788
- validatingPhoneRef.current = false;
1789
- });
1790
- }
1791
- }, 200);
1792
- }, b) });
1793
- }
1794
- else if (b.name === 'DateBlock') {
1795
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1796
- if (value && isNaN(Date.parse(value))) {
1797
- return t('validator.date');
1798
- }
1799
- }, b) });
1800
- }
1801
- else if (b.name === 'TncBlock') {
1802
- return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
1803
- if (isRequired && !value) {
1804
- return t('validator.required');
1805
- }
1806
- }, b) });
1807
- }
1808
- else {
1809
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, undefined, b) });
1810
- }
1811
- }, {});
1812
- }, [listBlockAdded.map((b) => b.name).join(',')]);
1813
- const form = useLeadForm({
1814
- validateInputOnChange: true,
1815
- clearInputErrorOnChange: true,
1816
- validate: validateObj,
1817
- initialValues,
1818
- });
1819
- const formRef = useRef(form);
1820
- formRef.current = form;
1821
- return { form, validateObj };
3342
+
3343
+ const EmptyComponent = ({ onClose, onContinue, }) => {
3344
+ const { t } = useTranslations();
3345
+ return (React__default.createElement("div", { className: "leadgen-empty" },
3346
+ React__default.createElement("div", { className: "leadgen-empty_body" },
3347
+ React__default.createElement("div", { className: "leadgen-empty_wrapper" },
3348
+ React__default.createElement(EmptyIcon, { className: "leadgen-empty_image" }),
3349
+ React__default.createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
3350
+ React__default.createElement("div", { className: "leadgen-empty_footer" },
3351
+ React__default.createElement(Button$1, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
3352
+ React__default.createElement(Button$1, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
1822
3353
  };
1823
3354
 
1824
3355
  const SubtitleBlock = ({ children, align, }) => (React__default.createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
@@ -1991,6 +3522,14 @@ const StyledTextFieldContainer = styled.div `
1991
3522
  }
1992
3523
  }
1993
3524
 
3525
+ &:focus-within {
3526
+ .mantine-Input-wrapper {
3527
+ transition: 0.25s linear border;
3528
+ border-color: ${theme.colors.primary600};
3529
+ box-shadow: 0 0 4px ${theme.colors.primary200};
3530
+ }
3531
+ }
3532
+
1994
3533
  .PhoneInput {
1995
3534
  --phone-select: 75px;
1996
3535
  --phone-input-space-x: 8px;
@@ -2139,11 +3678,13 @@ const TextField = (props) => {
2139
3678
  const $focusEl = $textEl.item($textEl.length - 1);
2140
3679
  if ($focusEl) {
2141
3680
  $focusEl.focus();
2142
- $focusEl.scrollIntoView({
2143
- behavior: 'auto',
2144
- block: 'center',
2145
- inline: 'start',
2146
- });
3681
+ setTimeout(() => {
3682
+ $focusEl.scrollIntoView({
3683
+ behavior: 'auto',
3684
+ block: 'center',
3685
+ inline: 'start',
3686
+ });
3687
+ }, 100);
2147
3688
  }
2148
3689
  }, [shrink]);
2149
3690
  useEffect(() => {
@@ -2160,8 +3701,14 @@ const ChoiceField = (props) => {
2160
3701
  const TitleBlock = ({ children, align, }) => (React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
2161
3702
 
2162
3703
  const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, }) => {
3704
+ const { t } = useTranslations();
2163
3705
  const form = useLeadFormContext();
2164
3706
  const formValues = form.values;
3707
+ const labelTuples = useMemo(() => {
3708
+ return ((ISO_FORMAT === null || ISO_FORMAT === void 0 ? void 0 : ISO_FORMAT[locale]) || ISO_FORMAT['vi-VN']).dateFormat
3709
+ .split('/')
3710
+ .map((key) => { var _a; return t((_a = COMMON_DATE_TRANSLATE_KEY === null || COMMON_DATE_TRANSLATE_KEY === void 0 ? void 0 : COMMON_DATE_TRANSLATE_KEY[key]) === null || _a === void 0 ? void 0 : _a.id); });
3711
+ }, [locale]);
2165
3712
  return (React__default.createElement(React__default.Fragment, null, listBlockAdded.map((b, index) => {
2166
3713
  var _a;
2167
3714
  const { name = '', data = {}, id } = b || {};
@@ -2211,17 +3758,15 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2211
3758
  return (React__default.createElement(TextField, { key: index, shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field" },
2212
3759
  React__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)))));
2213
3760
  }
2214
- case 'DateBlock':
2215
- return (React__default.createElement(TextField, { key: index, shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field" },
2216
- React__default.createElement(DatePicker, Object.assign({ clearable: true, withAsterisk: required, type: "default", name: value, placeholder: placeholder, label: placeholder, inputWrapperOrder: ['label', 'input', 'description', 'error'], inputContainer: (children) => {
2217
- return (React__default.createElement(React__default.Fragment, null,
2218
- children,
2219
- React__default.createElement("input", { type: "hidden", "data-control": "date", name: value, value: formValue })));
2220
- } }, form.getInputProps(value)))));
3761
+ case 'DateBlock': {
3762
+ const _c = form.getInputProps(value), { error } = _c, formInputProps = __rest(_c, ["error"]);
3763
+ return (React__default.createElement(Input$1.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" },
3764
+ React__default.createElement(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))));
3765
+ }
2221
3766
  case 'LinkButtonBlock':
2222
3767
  return (React__default.createElement("div", { key: index },
2223
3768
  React__default.createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
2224
- React__default.createElement(Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
3769
+ React__default.createElement(Button$2, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
2225
3770
  onClose === null || onClose === void 0 ? void 0 : onClose();
2226
3771
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2227
3772
  } }, value))));
@@ -2260,7 +3805,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2260
3805
  label: l.placeholder,
2261
3806
  })) }, form.getInputProps(value)))));
2262
3807
  case 'TncBlock':
2263
- const _c = form.getInputProps(`TNC-${id}`), { error } = _c, tncInputProps = __rest(_c, ["error"]);
3808
+ const _d = form.getInputProps(`TNC-${id}`), { error } = _d, tncInputProps = __rest(_d, ["error"]);
2264
3809
  return (React__default.createElement(ChoiceField, { className: "leadgen-form_checkbox", key: id },
2265
3810
  React__default.createElement(Input$1.Wrapper, { error: error },
2266
3811
  React__default.createElement(Checkbox, Object.assign({ name: 'TNC-' + id, label: React__default.createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps)))));
@@ -2370,6 +3915,7 @@ const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
2370
3915
  };
2371
3916
 
2372
3917
  const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
3918
+ const { primaryColor } = useContext(LeadGenContext$1);
2373
3919
  const { t } = useTranslations();
2374
3920
  const phone = otpData.phone;
2375
3921
  const otpType = otpData.type;
@@ -2455,708 +4001,371 @@ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
2455
4001
  // type: 'danger',
2456
4002
  // })
2457
4003
  }
2458
- setIsSubmitLoading(false);
2459
- });
2460
- useEffect(() => {
2461
- setTimeout(() => {
2462
- if (resendTimer > 0) {
2463
- setResendTimer((r) => r - 1);
2464
- }
2465
- }, 1000);
2466
- }, [resendTimer]);
2467
- useEffect(() => {
2468
- if (autoSendWhenOpen && !resendTimer) {
2469
- sendOtp();
2470
- }
2471
- }, []);
2472
- return (React__default.createElement("form", { onSubmit: (e) => {
2473
- e.preventDefault();
2474
- submitOtp();
2475
- }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
2476
- React__default.createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
2477
- phone: `<strong>${displayPhone}</strong>`,
2478
- }), footer: React__default.createElement(React__default.Fragment, null,
2479
- React__default.createElement(Button$2, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
2480
- React__default.createElement(Button$2, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, onClick: () => {
2481
- sendOtp();
2482
- }, disabled: !!resendTimer }, t('lead.otp.resend', {
2483
- timer: resendTimer ? ` (${resendTimer}s)` : '',
2484
- }))) },
2485
- React__default.createElement("div", { className: "leadgen-form_inner" },
2486
- React__default.createElement(Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
2487
- React__default.createElement(OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
2488
- setIsDirty(true);
2489
- setOtp(v.toString());
2490
- if (isDirty && !v)
2491
- setErrorMsg('OTP is required');
2492
- else
2493
- setErrorMsg(undefined);
2494
- } }))))));
2495
- };
2496
-
2497
- // url: imageBlocks.imageMobile.data.url
2498
- // newTab: imageBlocks.imageMobile.data.newtab
2499
- // image: campaignShow.image
2500
- // imageDestkop: campaignShow.image_desktop
2501
- const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
2502
- LEADGEN_LAYOUT.Fullscreen,
2503
- LEADGEN_LAYOUT.Slider,
2504
- ];
2505
- const LEADGEN_LIMIT_LIGHTBOXB = 6;
2506
- const LEADGEN_SHOW_HEADER = [
2507
- 'LightBoxA',
2508
- 'InlineA',
2509
- LEADGEN_LAYOUT.Sidebar,
2510
- LEADGEN_LAYOUT.Slider,
2511
- ];
2512
- const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2513
- var _a;
2514
- const { isMobile } = useScreenSize();
2515
- const [open, setOpen] = useState(!!campaignId);
2516
- const [showOtpPhone, setShowOtpPhone] = useState(null);
2517
- const [isSubmitLoading, setIsSubmitLoading] = useState(false);
2518
- const [snap, setSnap] = useState(0.8);
2519
- const formRef = useRef();
2520
- const onClose = () => {
2521
- if (showOtpPhone) {
2522
- setShowOtpPhone(null);
2523
- }
2524
- else {
2525
- onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2526
- }
2527
- };
2528
- const textBlocks = JSON.parse(extraFields.textBlocks);
2529
- const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
2530
- const actionBlocks = JSON.parse(extraFields.actionBlocks);
2531
- const popUpSubmitText = actionBlocks.submitBlock.data.value;
2532
- const currentPath = location.pathname;
2533
- const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
2534
- const { align: titleAlign } = textBlocks.titleBlock.data || {};
2535
- const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
2536
- const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
2537
- const isLightBox = currentLayout.includes('LightBox');
2538
- const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
2539
- const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
2540
- const isInline = currentLayout.includes('Inline');
2541
- const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
2542
- const isInPage = isInline || isSidebar;
2543
- const isDrawer = isLightBoxB && isMobile;
2544
- const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
2545
- const hasForm = isLightBoxA
2546
- ? listBlockAdded.some((item) => LEADGEN_BLOCK_IN_FORM.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
2547
- : true;
2548
- const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
2549
- const showHeader = !!imageMobile || !!imageDesktop;
2550
- const onlyHeader = !title && !description;
2551
- const showButtonClose = !isInline;
2552
- if (window.innerWidth < 769 &&
2553
- LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
2554
- console.log('😎 Not show fullscreen, slider on mobile ');
2555
- return null;
2556
- }
2557
- useEffect(() => {
2558
- if (isLightBox || isFullscreen) {
2559
- document.body.classList.add('noscroll');
2560
- }
2561
- if (!window.intlTelInputUtils) {
2562
- require('intl-tel-input/build/js/utils');
2563
- }
2564
- clearCacheUsedEmailOrPhone();
2565
- }, []);
2566
- const validatingPhoneRef = useRef(false);
2567
- const validatingEmailRef = useRef(false);
2568
- const { form, validateObj } = useLeadFormConfig({
2569
- listBlockAdded,
2570
- validatingPhoneRef,
2571
- validatingEmailRef,
2572
- campaignId,
2573
- campaign_subot_id,
2574
- userInfo,
2575
- });
2576
- const middlewareOnSubmit = (e) => {
2577
- e.preventDefault();
2578
- // mark all as touched to allow validation
2579
- form.setTouched(Object.keys(validateObj).reduce((acc, cur) => {
2580
- acc[cur] = true;
2581
- return acc;
2582
- }, {}));
2583
- if (validatingEmailRef.current || validatingPhoneRef.current) {
2584
- return;
2585
- }
2586
- setTimeout(() => {
2587
- form.onSubmit((v) => {
2588
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2589
- if (Object.keys(form.errors).length)
2590
- return;
2591
- let newShowOtpPhone = null;
2592
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
2593
- // not submit yet, open otp
2594
- 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;
2595
- if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
2596
- newShowOtpPhone = {
2597
- phone: v[fieldName],
2598
- type: 'phone',
2599
- };
2600
- }
2601
- }
2602
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
2603
- // not submit yet, open otp
2604
- 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;
2605
- if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
2606
- newShowOtpPhone = {
2607
- phone: v[fieldName],
2608
- type: 'whatsapp',
2609
- };
2610
- }
2611
- }
2612
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
2613
- // not submit yet, open otp
2614
- 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;
2615
- if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
2616
- newShowOtpPhone = {
2617
- phone: v[fieldName],
2618
- type: 'zalo',
2619
- };
2620
- }
2621
- }
2622
- if (newShowOtpPhone) {
2623
- setIsSubmitLoading(true);
2624
- Service.sendSMSOtpLead(newShowOtpPhone)
2625
- .then((res) => {
2626
- var _a;
2627
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2628
- if (respMessage === 'This phone number was verified') {
2629
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2630
- return;
2631
- }
2632
- setShowOtpPhone(newShowOtpPhone);
2633
- })
2634
- .finally(() => {
2635
- setIsSubmitLoading(false);
2636
- });
2637
- return;
2638
- }
2639
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2640
- })(e);
2641
- }, 100);
2642
- };
2643
- const onOpenChange = (_open) => {
2644
- setOpen(_open);
2645
- if (!_open) {
2646
- setTimeout(() => {
2647
- onClose();
2648
- }, 250);
2649
- }
2650
- };
2651
- const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
2652
- const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
2653
- const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
2654
- const renderAfterImageSizes = imageMobileLoaded &&
2655
- imageDesktopLoaded &&
2656
- (isFullscreen ? imageBackgroundLoaded : true);
2657
- const ButtonSubmit = !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default.createElement(Button$2, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
2658
- const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
2659
- const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default.createElement(React__default.Fragment, null, LinkButtonBlock.map((item, index) => {
2660
- var _a, _b, _c;
2661
- return (React__default.createElement(Button$2, { 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: () => {
2662
- onClose === null || onClose === void 0 ? void 0 : onClose();
2663
- onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2664
- } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
2665
- })));
2666
- const PopupHeader = showHeader && (React__default.createElement("header", { className: clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default.createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default.createElement(React__default.Fragment, null,
2667
- React__default.createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
2668
- React__default.createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
2669
- const PopupEmpty = showEmpty && (React__default.createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
2670
- const PopupForm = (React__default.createElement(LeadFormProvider, { form: form },
2671
- React__default.createElement("form", { ref: formRef, className: "leadgen-form", onSubmit: middlewareOnSubmit },
2672
- React__default.createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
2673
- React__default.createElement("div", { className: "leadgen-form_inner" },
2674
- React__default.createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
2675
- const PopupOtp = showOtpPhone && (React__default.createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
2676
- setShowOtpPhone(null);
2677
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
2678
- } }));
2679
- const PopupThankYou = showThankyou && (React__default.createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
2680
- const PopupContent = (React__default.createElement("div", { className: clsx('leadgen-content', {
2681
- 'leadgen-content_small': limitFieldsLightBoxB,
2682
- }) },
2683
- !headerInsideFormContainer && PopupHeader,
2684
- !onlyHeader && (React__default.createElement("div", { className: "leadgen-inner" },
2685
- PopupThankYou,
2686
- !showThankyou && (React__default.createElement(React__default.Fragment, null,
2687
- PopupOtp,
2688
- PopupEmpty,
2689
- !(showOtpPhone || showEmpty) && PopupForm))))));
2690
- const styleOverlay = useMemo(() => {
2691
- let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
2692
- if (isMobile && imageOverlayMobile) {
2693
- styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
2694
- }
2695
- if (!isMobile && imageOverlayDesktop) {
2696
- styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
2697
- }
2698
- return styleContent;
2699
- }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
2700
- const PopupWrapper = (React__default.createElement(React__default.Fragment, null,
2701
- React__default.createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
2702
- React__default.createElement("div", { className: clsx('leadgen-wrapper', {
2703
- 'leadgen-wrapper_small': limitFieldsLightBoxB,
2704
- }) },
2705
- showButtonClose && (React__default.createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
2706
- PopupContent)));
2707
- const popupContainerClassName = clsx('leadgen', `leadgen-${currentLayout}`, {
2708
- 'leadgen-lightbox': isLightBox,
2709
- 'leadgen-inline': isInPage,
2710
- 'leadgen-slider': isSlider,
4004
+ setIsSubmitLoading(false);
2711
4005
  });
2712
- const PopupContainer = isDrawer ? (React__default.createElement(DrawerComponent, { fadeFromIndex: ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
2713
- PopupWrapper,
2714
- React__default.createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default.createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
2715
- isFullscreen ? (React__default.createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
2716
- aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
2717
- } })) : null,
2718
- PopupWrapper));
2719
- if (!renderAfterImageSizes)
2720
- return null;
2721
- if (isLightBox || isFullscreen || isSlider) {
2722
- return PopupContainer;
2723
- }
2724
- else if (isSidebar) {
2725
- return React__default.createElement(SideBarLayout, { content: PopupContainer });
2726
- }
2727
- else if (isInline) {
2728
- return (React__default.createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
2729
- }
2730
- return null;
2731
- };
2732
-
2733
- const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
2734
- const currentPath = location.pathname;
2735
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
2736
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
2737
- if (!imageMobileLoaded || !imageDesktopLoaded)
2738
- return null;
2739
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
2740
- currentLayout == 'SkinA' ? (React__default.createElement("aside", { className: "le-only-desktop" },
2741
- React__default.createElement("div", { className: "le-skin-a-desktop" },
2742
- React__default.createElement("div", { style: { position: 'relative' } },
2743
- React__default.createElement("img", { src: imageDesktop, style: {
2744
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2745
- } }),
2746
- React__default.createElement("a", { style: {
2747
- position: 'absolute',
2748
- top: '75%',
2749
- left: '50%',
2750
- transform: 'translate(-50%, -50%)',
2751
- textAlign: 'center',
2752
- width: 'calc(100% - 15px)',
2753
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2754
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
2755
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default.createElement("aside", { className: "le-only-desktop" },
2756
- React__default.createElement("div", { className: "" },
2757
- React__default.createElement("div", { style: { position: 'relative', zIndex: 10000 } },
2758
- React__default.createElement("img", { src: imageDesktop, style: {
2759
- width: '100%',
2760
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2761
- } }),
2762
- React__default.createElement("a", { style: {
2763
- position: 'absolute',
2764
- top: '75%',
2765
- left: '50%',
2766
- transform: 'translate(-50%, -50%)',
2767
- textAlign: 'center',
2768
- width: '100%',
2769
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2770
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2771
- React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
2772
- React__default.createElement("aside", { className: "le-only-mobile" },
2773
- React__default.createElement("div", { className: "le-skin-mobile" },
2774
- React__default.createElement("div", { style: { position: 'relative' } },
2775
- isVideo(imageMobile) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true },
2776
- React__default.createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default.createElement("img", { src: imageMobile, style: {
2777
- width: '100%',
2778
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
2779
- } })),
2780
- React__default.createElement("a", { style: {
2781
- position: 'absolute',
2782
- top: '82%',
2783
- left: '50%',
2784
- transform: 'translate(-50%, -50%)',
2785
- textAlign: 'center',
2786
- maxWidth: 'calc(100% - 15px)',
2787
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2788
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2789
- React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4006
+ useEffect(() => {
4007
+ setTimeout(() => {
4008
+ if (resendTimer > 0) {
4009
+ setResendTimer((r) => r - 1);
4010
+ }
4011
+ }, 1000);
4012
+ }, [resendTimer]);
4013
+ useEffect(() => {
4014
+ if (autoSendWhenOpen && !resendTimer) {
4015
+ sendOtp();
4016
+ }
4017
+ }, []);
4018
+ return (React__default.createElement("form", { onSubmit: (e) => {
4019
+ e.preventDefault();
4020
+ submitOtp();
4021
+ }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
4022
+ React__default.createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
4023
+ phone: `<strong>${displayPhone}</strong>`,
4024
+ }), footer: React__default.createElement(React__default.Fragment, null,
4025
+ React__default.createElement(Button$1, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
4026
+ React__default.createElement(Button$1, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
4027
+ sendOtp();
4028
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
4029
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
4030
+ }))) },
4031
+ React__default.createElement("div", { className: "leadgen-form_inner" },
4032
+ React__default.createElement(Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
4033
+ React__default.createElement(OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
4034
+ setIsDirty(true);
4035
+ setOtp(v.toString());
4036
+ if (isDirty && !v)
4037
+ setErrorMsg('OTP is required');
4038
+ else
4039
+ setErrorMsg(undefined);
4040
+ } }))))));
2790
4041
  };
2791
4042
 
2792
4043
  // url: imageBlocks.imageMobile.data.url
2793
4044
  // newTab: imageBlocks.imageMobile.data.newtab
2794
4045
  // image: campaignShow.image
2795
4046
  // imageDestkop: campaignShow.image_desktop
2796
- const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
2797
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
2798
- if (!imageLoaded)
2799
- return null;
2800
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
2801
- React__default.createElement("div", { className: "le-tab-popup" },
2802
- React__default.createElement("div", { style: { position: 'relative' } },
2803
- React__default.createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
2804
- React__default.createElement("img", { className: "js-popup-other-submit", src: image, style: {
2805
- aspectRatio: `${imageWidth}/${imageHeight}`,
2806
- } })),
2807
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
2808
- };
2809
-
2810
- // import mockLeadData from './mockLeadData'
2811
- const listCampaignScheduled = [];
2812
- const listCampaignScheduledToActivated = [];
2813
- const listCampaignActiveButExpired = [];
2814
- const listCampaignExcludeSonsored = [];
2815
- const listCampaignDifferentSponsor = [];
2816
- const listCampaignNotDisplayInRangeOfTime = [];
2817
- function isMobile() {
2818
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
2819
- }
2820
- const getShuffleArray = (array) => {
2821
- const newArray = [...array];
2822
- for (let i = newArray.length - 1; i > 0; i--) {
2823
- const j = Math.floor(Math.random() * (i + 1));
2824
- const temp = newArray[i];
2825
- newArray[i] = newArray[j];
2826
- newArray[j] = temp;
2827
- }
2828
- return newArray;
2829
- };
2830
- const getTimeByTimezone = (timeZone = 'UTC') => {
2831
- const date = new Date();
2832
- return new Date(date.toLocaleString('en-US', { timeZone }));
2833
- };
2834
- const parseDateByCampaignTime = (dateStr) => {
2835
- // Format like this: 2023-04-04 00:00:00
2836
- try {
2837
- const [datePart, timePart] = dateStr.split(' ');
2838
- const [year, month, day] = datePart.split('-').map(Number);
2839
- const [hours, minutes, seconds] = timePart.split(':').map(Number);
2840
- /** JavaScript counts months from 0 to 11 */
2841
- return new Date(year, month - 1, day, hours, minutes, seconds);
2842
- }
2843
- catch (err) {
2844
- return null;
2845
- }
2846
- };
2847
- const checkCampaignNowInTimeframe = (c) => {
2848
- var _a;
2849
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2850
- const startedAtStr = c.started_at;
2851
- const endedAtStr = c.ended_at;
2852
- const startedDate = parseDateByCampaignTime(startedAtStr);
2853
- const endedDate = parseDateByCampaignTime(endedAtStr);
2854
- if (!startedDate || !endedDate) {
2855
- return false;
2856
- }
2857
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
2858
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2859
- if (nowWithTimezoneMs <= endedDate.getTime() &&
2860
- nowWithTimezoneMs >= startedDate.getTime()) {
2861
- listCampaignScheduledToActivated.push(c);
2862
- return true;
2863
- }
2864
- return false;
2865
- };
2866
- function checkCampaignActiveButExpireAlready(c) {
2867
- var _a;
2868
- /** Do not setup timeframe for this campaign. No need to check */
2869
- if (c.forever === 1) {
2870
- return true;
2871
- }
2872
- const startedAtStr = c.started_at;
2873
- const endedAtStr = c.ended_at;
2874
- const startedDate = parseDateByCampaignTime(startedAtStr);
2875
- const endedDate = parseDateByCampaignTime(endedAtStr);
2876
- /** Do not setup timeframe for this campaign. No need to check */
2877
- if (!startedDate || !endedDate) {
2878
- return true;
2879
- }
2880
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2881
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
2882
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2883
- /** Check if this expire already, do not show */
2884
- if (nowWithTimezoneMs > endedDate.getTime()) {
2885
- listCampaignActiveButExpired.push(c);
2886
- return false;
2887
- }
2888
- return true;
2889
- }
2890
- function shouldNotDisplayIfExcludeAllSponsors(c) {
2891
- var _a;
2892
- const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
2893
- const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
2894
- if (isSponsored && excludeSponsored) {
2895
- listCampaignExcludeSonsored.push(c);
2896
- return true;
2897
- }
2898
- return false;
2899
- }
2900
- function shouldDisplayWithCurrentSponsor(c) {
4047
+ const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
4048
+ LEADGEN_LAYOUT.Fullscreen,
4049
+ LEADGEN_LAYOUT.Slider,
4050
+ ];
4051
+ const LEADGEN_LIMIT_LIGHTBOXB = 6;
4052
+ const LEADGEN_SHOW_HEADER = [
4053
+ 'LightBoxA',
4054
+ 'InlineA',
4055
+ LEADGEN_LAYOUT.Sidebar,
4056
+ LEADGEN_LAYOUT.Slider,
4057
+ ];
4058
+ const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2901
4059
  var _a, _b;
2902
- try {
2903
- // TODO: BE will rename `exclude_sponsored_list` later
2904
- const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
2905
- const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
2906
- const dataSponsoredId = Number((_b = document
2907
- .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
2908
- // There is no config for sponsor id and white list, should show as default
2909
- if (!dataSponsoredId ||
2910
- dataSponsoredId <= 0 ||
2911
- whiteListSponsors.length === 0) {
2912
- return true;
4060
+ const { primaryColor } = useContext(LeadGenContext$1);
4061
+ const { isMobile } = useScreenSize();
4062
+ const [open, setOpen] = useState(!!campaignId);
4063
+ const [showOtpPhone, setShowOtpPhone] = useState(null);
4064
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
4065
+ const [snap, setSnap] = useState(0.8);
4066
+ const formRef = useRef();
4067
+ const onClose = () => {
4068
+ if (showOtpPhone) {
4069
+ setShowOtpPhone(null);
2913
4070
  }
2914
- // Check the dataSponsoredId exists in the white list or not.
2915
- const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
2916
- if (isExist) {
2917
- return true;
4071
+ else {
4072
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2918
4073
  }
2919
- listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
2920
- return false;
2921
- }
2922
- catch (err) {
2923
- // Default is show
2924
- return true;
2925
- }
2926
- }
2927
- const filterFnCampaign = (c) => {
2928
- if (shouldNotDisplayIfExcludeAllSponsors(c)) {
2929
- return false;
2930
- }
2931
- else if (!shouldDisplayWithCurrentSponsor(c)) {
2932
- return false;
2933
- }
2934
- /** Active */
2935
- if (c.formatted_status === 1) {
2936
- return checkCampaignActiveButExpireAlready(c);
2937
- }
2938
- /** Schedule */
2939
- if (c.formatted_status === 0) {
2940
- listCampaignScheduled.push(c);
2941
- return checkCampaignNowInTimeframe(c);
4074
+ };
4075
+ const textBlocks = JSON.parse(extraFields.textBlocks);
4076
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
4077
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
4078
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
4079
+ const currentPath = location.pathname;
4080
+ const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
4081
+ const { align: titleAlign } = textBlocks.titleBlock.data || {};
4082
+ const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
4083
+ const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
4084
+ const isLightBox = currentLayout.includes('LightBox');
4085
+ const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
4086
+ const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
4087
+ const isInline = currentLayout.includes('Inline');
4088
+ const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
4089
+ const isInPage = isInline || isSidebar;
4090
+ const isDrawer = isLightBoxB && isMobile;
4091
+ const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
4092
+ const hasForm = isLightBoxA
4093
+ ? listBlockAdded.some((item) => LEADGEN_BLOCK_INPUT.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
4094
+ : true;
4095
+ const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
4096
+ const showHeader = !!imageMobile || !!imageDesktop;
4097
+ const onlyHeader = !title && !description;
4098
+ const showButtonClose = !isInline;
4099
+ if (window.innerWidth < 769 &&
4100
+ LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
4101
+ console.log('😎 Not show fullscreen, slider on mobile ');
4102
+ return null;
2942
4103
  }
2943
- return false;
2944
- };
2945
- const fillterApprearanceTimeCampaign = (c) => {
2946
- var _a;
2947
- try {
2948
- const isTimeInRange = (currentTime, startTime, endTime) => {
2949
- const startParts = startTime.split(':');
2950
- const endParts = endTime.split(':');
2951
- const startDate = new Date();
2952
- startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
2953
- const endDate = new Date();
2954
- endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
2955
- return currentTime >= startDate && currentTime <= endDate;
2956
- };
2957
- const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
2958
- const startTime = rulesApprValue.startTime;
2959
- const endTime = rulesApprValue.endTime || '23:59';
2960
- if (!startTime) {
2961
- return true;
4104
+ useEffect(() => {
4105
+ if (isLightBox || isFullscreen) {
4106
+ document.body.classList.add('noscroll');
2962
4107
  }
2963
- if (isTimeInRange(new Date(), startTime, endTime)) {
2964
- return true;
4108
+ if (!window.intlTelInputUtils) {
4109
+ require('intl-tel-input/build/js/utils');
2965
4110
  }
2966
- listCampaignNotDisplayInRangeOfTime.push(c);
2967
- return false;
2968
- }
2969
- catch (err) {
2970
- return true;
2971
- }
2972
- };
2973
- let timeoutRef = null;
2974
- let LEAD_SCROLL_EVENT = null;
2975
- function clearPassiveEvent() {
2976
- if (timeoutRef) {
2977
- clearTimeout(timeoutRef);
2978
- timeoutRef = null;
2979
- }
2980
- if (LEAD_SCROLL_EVENT) {
2981
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
2982
- LEAD_SCROLL_EVENT = null;
2983
- }
2984
- }
2985
- function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
2986
- // clear previous passive event, check for new condition
2987
- clearPassiveEvent();
2988
- const leadCurrentUrl = DEBUG_URL ||
2989
- ('https://' +
2990
- location.hostname +
2991
- location.pathname +
2992
- location.search).toLowerCase();
2993
- fetch(leadApi + 'api/campaign/' + leadSiteId, {
2994
- method: 'POST',
2995
- headers: {
2996
- 'Content-Type': 'application/json',
2997
- },
2998
- body: JSON.stringify({
2999
- url: leadCurrentUrl,
3000
- ga_client_id: getCookie('_ga') || null,
3001
- }),
3002
- })
3003
- .then((response) => {
3004
- return response.json();
3005
- // return mockLeadData || response.json()
3006
- })
3007
- .then((data) => {
3008
- var _a, _b, _c, _d;
3009
- LeadLog('List campagin: ', data);
3010
- LEAD_RESET_VAR();
3011
- if (data._status == 1) {
3012
- 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);
3013
- if (!getCookie('hhg-id')) {
3014
- setCookie('hhg-id', v1(), {
3015
- domain: '.' + leadDomain,
3016
- path: '/',
3017
- });
3018
- LeadLog('😍 Set HHG ID cookie');
3019
- }
3020
- // getCookie('hhg-id')
3021
- // TODO: HP-534 Filter desktop
3022
- let campaignsDevice = [];
3023
- if (isMobile()) {
3024
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
3025
- }
3026
- else {
3027
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
3028
- }
3029
- LeadLog(`👓 campaignsDevice`, campaignsDevice);
3030
- LeadLog('--listCampaignScheduled', listCampaignScheduled);
3031
- LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
3032
- LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
3033
- LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
3034
- LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
3035
- LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
3036
- // Check links
3037
- let listLinksObj = campaignsDevice
3038
- .map((i, index) => i.targets
3039
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
3040
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3041
- .flat(1);
3042
- // Check list link match current href
3043
- listLinksObj = listLinksObj.filter((i) => {
3044
- var _a;
3045
- const target = new URL(String(i.target).toLowerCase());
3046
- if (i.option == 'exact_match')
3047
- // FOR TEST LOCAL:
3048
- // return Boolean(location.pathname === target.pathname)
3049
- return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
3050
- if (i.option == 'start_with') {
3051
- // FOR TEST LOCAL:
3052
- // if (location.pathname.includes(target.pathname)) {
3053
- if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
3054
- const listExcluding = i.sub_target
3055
- .filter((i) => i.option == 'excluding')
3056
- .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
3057
- return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
3058
- }
3059
- else {
3060
- return false;
3061
- }
3062
- }
3063
- });
3064
- // Check tags
3065
- const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
3066
- const listTags = listMetaTag.map((i) => i.content);
3067
- let listCampaignHasTag = [];
3068
- let listTagsObj = [];
3069
- if (listTags && listTags.length) {
3070
- listCampaignHasTag = campaignsDevice
3071
- .map((i, index) => i.targets
3072
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
3073
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3074
- .flat(1);
3075
- listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
3076
- }
3077
- const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
3078
- const cookieKeys = document.cookie
3079
- .split('; ')
3080
- .map((i) => i.split('=')[0]);
3081
- const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
3082
- LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
3083
- const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
3084
- LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
3085
- const listCampaignSubmitedClosed = [
3086
- ...listCampaignCodeSubmited,
3087
- ...listCampaignCodeClosed,
3088
- ];
3089
- const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
3090
- const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
3091
- return !hasSubmited;
3092
- });
3093
- const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
3094
- // .sort(
3095
- // (a, b) =>
3096
- // (listCampaignValid[a.campaignIndex]?.score || 0) -
3097
- // (listCampaignValid[b.campaignIndex]?.score || 0),
3098
- // )
3099
- LeadLog('--listCampaignValid : ', listCampaignValid);
3100
- if (listCampaignValid && listCampaignValid.length) {
3101
- const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
3102
- LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
3103
- const { rules } = CAMPAIGN_SHOW;
3104
- // CHECK RULE TRIGGER POPUP
3105
- const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
3106
- LeadLog(`timeoutRule`, timeoutRule);
3107
- const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
3108
- LeadLog(`scrollRule`, scrollRule);
3109
- let impressionAction = 'TIME';
3110
- if (Number.isInteger(timeoutRule)) {
3111
- impressionAction = 'TIME';
3112
- LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
3113
- timeoutRef = setTimeout(() => {
3114
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3115
- }, timeoutRule * 1000);
4111
+ clearCacheUsedEmailOrPhone();
4112
+ }, []);
4113
+ const validatingPhoneRef = useRef(false);
4114
+ const validatingEmailRef = useRef(false);
4115
+ const { form, validateObj } = useLeadFormConfig({
4116
+ listBlockAdded,
4117
+ validatingPhoneRef,
4118
+ validatingEmailRef,
4119
+ campaignId,
4120
+ campaign_subot_id,
4121
+ userInfo,
4122
+ format: (_a = (ISO_FORMAT[locale] || ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
4123
+ });
4124
+ const onFocus = (e) => {
4125
+ const target = e.target;
4126
+ target.scrollIntoView({
4127
+ block: 'center',
4128
+ inline: 'nearest',
4129
+ behavior: 'auto',
4130
+ });
4131
+ };
4132
+ const middlewareOnSubmit = (e) => {
4133
+ e.preventDefault();
4134
+ // mark all as touched to allow validation
4135
+ const fields = Object.keys(validateObj);
4136
+ const fieldStatus = fields.reduce((acc, cur) => {
4137
+ acc[cur] = true;
4138
+ return acc;
4139
+ }, {});
4140
+ form.setTouched(fieldStatus);
4141
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
4142
+ return;
4143
+ }
4144
+ setTimeout(() => {
4145
+ form.onSubmit((v) => {
4146
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4147
+ if (Object.keys(form.errors).length)
4148
+ return;
4149
+ let newShowOtpPhone = null;
4150
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
4151
+ // not submit yet, open otp
4152
+ 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;
4153
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
4154
+ newShowOtpPhone = {
4155
+ phone: v[fieldName],
4156
+ type: 'phone',
4157
+ };
4158
+ }
3116
4159
  }
3117
- if (Number.isInteger(scrollRule)) {
3118
- impressionAction = 'SCROLL';
3119
- LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
3120
- const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
3121
- document.querySelector('body');
3122
- const pct = $p.getBoundingClientRect().top;
3123
- const pb = $p.offsetHeight;
3124
- LeadLog(`👓 Element check scroll: `, $p);
3125
- LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
3126
- const wt = window.pageYOffset || document.documentElement.scrollTop;
3127
- let percent = 0;
3128
- if (wt >= pct) {
3129
- percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
3130
- }
3131
- LeadLog('---Scroll', percent, scrollRule);
3132
- // TODO: CHECK FOOTER HEIGHT
3133
- if (percent >= scrollRule) {
3134
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3135
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
4160
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
4161
+ // not submit yet, open otp
4162
+ 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;
4163
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
4164
+ newShowOtpPhone = {
4165
+ phone: v[fieldName],
4166
+ type: 'whatsapp',
4167
+ };
4168
+ }
4169
+ }
4170
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
4171
+ // not submit yet, open otp
4172
+ 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;
4173
+ if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
4174
+ newShowOtpPhone = {
4175
+ phone: v[fieldName],
4176
+ type: 'zalo',
4177
+ };
4178
+ }
4179
+ }
4180
+ if (newShowOtpPhone) {
4181
+ setIsSubmitLoading(true);
4182
+ Service.sendSMSOtpLead(newShowOtpPhone)
4183
+ .then((res) => {
4184
+ var _a;
4185
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4186
+ if (respMessage === 'This phone number was verified') {
4187
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4188
+ return;
3136
4189
  }
3137
- };
3138
- window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
3139
- passive: true,
4190
+ setShowOtpPhone(newShowOtpPhone);
4191
+ })
4192
+ .finally(() => {
4193
+ setIsSubmitLoading(false);
3140
4194
  });
4195
+ return;
3141
4196
  }
3142
- }
3143
- else {
3144
- LeadLog('🚧 No lead campaigns on current URL, tags');
3145
- }
4197
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4198
+ })(e);
4199
+ }, 100);
4200
+ };
4201
+ const onOpenChange = (_open) => {
4202
+ setOpen(_open);
4203
+ if (!_open) {
4204
+ setTimeout(() => {
4205
+ onClose();
4206
+ }, 250);
3146
4207
  }
3147
- })
3148
- .catch((err) => {
3149
- LeadLog(`Lead error: `, err);
4208
+ };
4209
+ const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
4210
+ const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
4211
+ const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
4212
+ const renderAfterImageSizes = imageMobileLoaded &&
4213
+ imageDesktopLoaded &&
4214
+ (isFullscreen ? imageBackgroundLoaded : true);
4215
+ const ButtonSubmit = useMemo(() => {
4216
+ var _a;
4217
+ return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default.createElement(Button$1, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
4218
+ }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
4219
+ const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
4220
+ const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default.createElement(React__default.Fragment, null, LinkButtonBlock.map((item, index) => {
4221
+ var _a, _b, _c;
4222
+ return (React__default.createElement(Button$1, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
4223
+ onClose === null || onClose === void 0 ? void 0 : onClose();
4224
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
4225
+ } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
4226
+ })));
4227
+ const PopupHeader = showHeader && (React__default.createElement("header", { className: clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default.createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default.createElement(React__default.Fragment, null,
4228
+ React__default.createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
4229
+ React__default.createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
4230
+ const PopupEmpty = showEmpty && (React__default.createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
4231
+ const PopupForm = (React__default.createElement(LeadFormProvider, { form: form },
4232
+ React__default.createElement("form", { ref: formRef, className: "leadgen-form", onFocus: onFocus, onSubmit: middlewareOnSubmit },
4233
+ React__default.createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
4234
+ React__default.createElement("div", { className: "leadgen-form_inner" },
4235
+ React__default.createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
4236
+ const PopupOtp = showOtpPhone && (React__default.createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
4237
+ setShowOtpPhone(null);
4238
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
4239
+ } }));
4240
+ const PopupThankYou = showThankyou && (React__default.createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
4241
+ const PopupContent = (React__default.createElement("div", { className: clsx('leadgen-content', {
4242
+ 'leadgen-content_small': limitFieldsLightBoxB,
4243
+ }) },
4244
+ !headerInsideFormContainer && PopupHeader,
4245
+ !onlyHeader && (React__default.createElement("div", { className: "leadgen-inner" },
4246
+ PopupThankYou,
4247
+ !showThankyou && (React__default.createElement(React__default.Fragment, null,
4248
+ PopupOtp,
4249
+ PopupEmpty,
4250
+ !(showOtpPhone || showEmpty) && PopupForm))))));
4251
+ const styleOverlay = useMemo(() => {
4252
+ let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
4253
+ if (isMobile && imageOverlayMobile) {
4254
+ styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4255
+ }
4256
+ if (!isMobile && imageOverlayDesktop) {
4257
+ styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4258
+ }
4259
+ return styleContent;
4260
+ }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
4261
+ const PopupWrapper = (React__default.createElement(React__default.Fragment, null,
4262
+ React__default.createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
4263
+ React__default.createElement("div", { className: clsx('leadgen-wrapper', {
4264
+ 'leadgen-wrapper_small': limitFieldsLightBoxB,
4265
+ }) },
4266
+ showButtonClose && (React__default.createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
4267
+ PopupContent)));
4268
+ const popupContainerClassName = clsx('leadgen', `leadgen-${currentLayout}`, {
4269
+ 'leadgen-lightbox': isLightBox,
4270
+ 'leadgen-inline': isInPage,
4271
+ 'leadgen-slider': isSlider,
3150
4272
  });
3151
- }
3152
- const LeadLog = (...params) => {
3153
- if (process.env.NODE_ENV !== 'production' ||
3154
- (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
3155
- process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
3156
- (typeof localStorage !== 'undefined' &&
3157
- localStorage.getItem('hhg_debug') === 'true')) {
3158
- console.log(...params);
4273
+ const PopupContainer = isDrawer ? (React__default.createElement(DrawerComponent, { fadeFromIndex: ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
4274
+ PopupWrapper,
4275
+ React__default.createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default.createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
4276
+ isFullscreen ? (React__default.createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
4277
+ aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
4278
+ } })) : null,
4279
+ PopupWrapper));
4280
+ if (!renderAfterImageSizes)
4281
+ return null;
4282
+ if (isLightBox || isFullscreen || isSlider) {
4283
+ return PopupContainer;
4284
+ }
4285
+ else if (isSidebar) {
4286
+ return React__default.createElement(SideBarLayout, { content: PopupContainer });
4287
+ }
4288
+ else if (isInline) {
4289
+ return (React__default.createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
3159
4290
  }
4291
+ return null;
4292
+ };
4293
+
4294
+ const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
4295
+ const currentPath = location.pathname;
4296
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
4297
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
4298
+ if (!imageMobileLoaded || !imageDesktopLoaded)
4299
+ return null;
4300
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
4301
+ currentLayout == 'SkinA' ? (React__default.createElement("aside", { className: "le-only-desktop" },
4302
+ React__default.createElement("div", { className: "le-skin-a-desktop" },
4303
+ React__default.createElement("div", { style: { position: 'relative' } },
4304
+ React__default.createElement("img", { src: imageDesktop, style: {
4305
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4306
+ } }),
4307
+ React__default.createElement("a", { style: {
4308
+ position: 'absolute',
4309
+ top: '75%',
4310
+ left: '50%',
4311
+ transform: 'translate(-50%, -50%)',
4312
+ textAlign: 'center',
4313
+ width: 'calc(100% - 15px)',
4314
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4315
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
4316
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default.createElement("aside", { className: "le-only-desktop" },
4317
+ React__default.createElement("div", { className: "" },
4318
+ React__default.createElement("div", { style: { position: 'relative', zIndex: 10000 } },
4319
+ React__default.createElement("img", { src: imageDesktop, style: {
4320
+ width: '100%',
4321
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4322
+ } }),
4323
+ React__default.createElement("a", { style: {
4324
+ position: 'absolute',
4325
+ top: '75%',
4326
+ left: '50%',
4327
+ transform: 'translate(-50%, -50%)',
4328
+ textAlign: 'center',
4329
+ width: '100%',
4330
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4331
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4332
+ React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
4333
+ React__default.createElement("aside", { className: "le-only-mobile" },
4334
+ React__default.createElement("div", { className: "le-skin-mobile" },
4335
+ React__default.createElement("div", { style: { position: 'relative' } },
4336
+ isVideo(imageMobile) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true },
4337
+ React__default.createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default.createElement("img", { src: imageMobile, style: {
4338
+ width: '100%',
4339
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
4340
+ } })),
4341
+ React__default.createElement("a", { style: {
4342
+ position: 'absolute',
4343
+ top: '82%',
4344
+ left: '50%',
4345
+ transform: 'translate(-50%, -50%)',
4346
+ textAlign: 'center',
4347
+ maxWidth: 'calc(100% - 15px)',
4348
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4349
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4350
+ React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4351
+ };
4352
+
4353
+ // url: imageBlocks.imageMobile.data.url
4354
+ // newTab: imageBlocks.imageMobile.data.newtab
4355
+ // image: campaignShow.image
4356
+ // imageDestkop: campaignShow.image_desktop
4357
+ const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
4358
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
4359
+ if (!imageLoaded)
4360
+ return null;
4361
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
4362
+ React__default.createElement("div", { className: "le-tab-popup" },
4363
+ React__default.createElement("div", { style: { position: 'relative' } },
4364
+ React__default.createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
4365
+ React__default.createElement("img", { className: "js-popup-other-submit", src: image, style: {
4366
+ aspectRatio: `${imageWidth}/${imageHeight}`,
4367
+ } })),
4368
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3160
4369
  };
3161
4370
 
3162
4371
  function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
@@ -3172,7 +4381,7 @@ function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
3172
4381
  }
3173
4382
  const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, showEmpty, setShowEmpty, userInfo, }) => {
3174
4383
  var _a, _b;
3175
- const { apiUrl, siteDomain } = useContext(LeadGenContext);
4384
+ const { apiUrl, siteDomain } = useContext(LeadGenContext$1);
3176
4385
  useEffect(() => {
3177
4386
  const gaCookie = getCookie('_ga') || null;
3178
4387
  fetch(`${apiUrl}api/campaign/${code}/impression`, {
@@ -3298,7 +4507,7 @@ const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, local
3298
4507
  };
3299
4508
 
3300
4509
  // mount css
3301
- const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl, DEBUG_URL, forceCampaign, children, extraPayloadValues = [], excludeExitRulesHandler, userInfo, onClose: onCloseProps, }) => {
4510
+ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, primaryColor, apiSubotUrl, DEBUG_URL, forceCampaign, children, extraPayloadValues = [], excludeExitRulesHandler, userInfo, onClose: onCloseProps, }) => {
3302
4511
  var _a;
3303
4512
  const scrollEventHandlerRef = useRef();
3304
4513
  const leadStartTimeRef = useRef(Date.now());
@@ -3567,7 +4776,7 @@ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl,
3567
4776
  leadStartTimeRef.current = Date.now();
3568
4777
  }
3569
4778
  }, [showCampaign]);
3570
- return (React__default.createElement(LeadGenContext.Provider, { value: { apiUrl, siteDomain, siteId, locale } },
4779
+ return (React__default.createElement(LeadGenContext$1.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
3571
4780
  React__default.createElement(TranslationsContext.Provider, { value: { locale, values: getTranslations(locale) } }, children ? (React__default.createElement(Component, { campaign: showCampaign, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, setShowThankyou: setShowThankyou, locale: locale, showEmpty: showEmpty, setShowEmpty: setShowEmpty, userInfo: userInfo }, children)) : (React__default.createElement(Portal, { target: getPopupWrapperDom() },
3572
4781
  React__default.createElement(Box, { sx: { position: 'fixed', zIndex: ZINDEX_SSO - 9e6 } },
3573
4782
  React__default.createElement(Transition, { mounted: Boolean(((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1'), transition: "fade", duration: 600, timingFunction: "ease" }, (styles) => {
@@ -3587,4 +4796,4 @@ LeadGen.Thankyou = Thankyou;
3587
4796
  LeadGen.OtpForm = OtpBlock$1;
3588
4797
  LeadGen.Close = Close;
3589
4798
 
3590
- export { LeadGen };
4799
+ export { LeadGen, LeadGenSubscriptionBox };