@hhgtech/hhg-components 1.29.372 → 1.29.374-beta-1

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 (543) hide show
  1. package/build/{InputDate-084af3b7.js → InputDate-27f75a17.js} +20 -20
  2. package/build/{LastPeriod-7920d16e.js → LastPeriod-9df97187.js} +1 -1
  3. package/build/{Locale-a034e717.js → Locale-ab6a6ba4.js} +1 -0
  4. package/build/{MobileBottomNavigationIcon-ae480710.js → MobileBottomNavigationIcon-96a68780.js} +3 -3
  5. package/build/{Spinner-9bf08d65.js → Spinner-aa4dd99c.js} +1 -1
  6. package/build/{WhatsApp-73c563dc.js → WhatsApp-9903ef96.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-f0954264.js → constants-0bcb9891.js} +1 -0
  20. package/build/{constants-3c232ac7.js → constants-7f234d99.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-35ae537b.js → core-c24db88c.js} +1 -1
  26. package/build/{dataTransform-90facc7b.js → dataTransform-049d8098.js} +1 -1
  27. package/build/ecom.js +4 -4
  28. package/build/{editor-b1b9b19c.js → editor-6fe7a5a0.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-544d7517.js → InputDate-53408741.js} +20 -20
  39. package/build/esm/{LastPeriod-64debefd.js → LastPeriod-7572677e.js} +1 -1
  40. package/build/esm/{Locale-3e2786ee.js → Locale-2def755e.js} +1 -0
  41. package/build/esm/{MobileBottomNavigationIcon-57dcd2d5.js → MobileBottomNavigationIcon-3333d468.js} +3 -3
  42. package/build/esm/{Spinner-a2b03942.js → Spinner-2e9210e6.js} +1 -1
  43. package/build/esm/{WhatsApp-4bd22594.js → WhatsApp-be4e850b.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-46a13b0b.js → constants-42ff2492.js} +1 -1
  57. package/build/esm/{constants-5e4d9287.js → constants-c405c24a.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-b8fa3e33.js → core-dc68adaf.js} +1 -1
  63. package/build/esm/{dataTransform-1ad95d27.js → dataTransform-183320e7.js} +1 -1
  64. package/build/esm/ecom.js +4 -4
  65. package/build/esm/{editor-8213370a.js → editor-d1af996e.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-84758186.js → healthTools-3d480046.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-c07eed8e.js → index-060e9629.js} +24 -24
  85. package/build/esm/{index-7cdf73e7.js → index-0abc03cd.js} +6 -6
  86. package/build/esm/{index-02c659dd.js → index-0d9a1b8c.js} +1 -1
  87. package/build/esm/{index-f12cf95a.js → index-0e17355b.js} +6 -6
  88. package/build/esm/{index-260a6cef.js → index-0e386ca4.js} +16 -16
  89. package/build/esm/{index-49c4b81e.js → index-10620223.js} +2 -2
  90. package/build/esm/{index-3e33fe3d.js → index-15cbeea2.js} +10 -10
  91. package/build/esm/{index-371d0a77.js → index-1603823c.js} +2 -2
  92. package/build/esm/{index-773c6e02.js → index-16fae63d.js} +6 -6
  93. package/build/esm/{index-b0f6139c.js → index-17165c22.js} +31 -31
  94. package/build/esm/{index-eb34db89.js → index-1b46ae3f.js} +2 -2
  95. package/build/esm/{index-0ece29aa.js → index-1b7e37bd.js} +2 -2
  96. package/build/esm/{index-9792c9b6.js → index-1bd62005.js} +18 -18
  97. package/build/esm/{index-722df7e6.js → index-1f21ae1e.js} +4 -4
  98. package/build/esm/{index-0823f05f.js → index-202a8ced.js} +2 -2
  99. package/build/esm/{index-8a062d3b.js → index-224abae7.js} +3 -3
  100. package/build/esm/{index-b41d6d8a.js → index-27730dc3.js} +21 -21
  101. package/build/esm/{index-83afe17a.js → index-2794e74a.js} +17 -17
  102. package/build/esm/{index-15dc7ed3.js → index-2c1db9ad.js} +32 -32
  103. package/build/esm/{index-008fb6f5.js → index-3ed1535e.js} +13 -13
  104. package/build/esm/{index-e3abcd93.js → index-410551f4.js} +1 -1
  105. package/build/esm/{index-d303f24d.js → index-4665f512.js} +7 -7
  106. package/build/esm/{index-6223f41c.js → index-4d7b2bc3.js} +3 -3
  107. package/build/esm/{index-c229b5b7.js → index-4e2139dc.js} +1 -1
  108. package/build/esm/{index-2050b8fa.js → index-510b91b2.js} +17 -17
  109. package/build/esm/{index-d46d72e5.js → index-53e72c1e.js} +2 -2
  110. package/build/esm/{index-b1702546.js → index-54de0535.js} +39 -2
  111. package/build/esm/{index-84fabe77.js → index-5535a0d5.js} +16 -16
  112. package/build/esm/{index-799ebe61.js → index-55d4a57f.js} +13 -13
  113. package/build/esm/{index-e2f4897f.js → index-56d4c7d5.js} +3 -3
  114. package/build/esm/{index-b0a09330.js → index-56f8b83d.js} +2 -2
  115. package/build/esm/{index-d2bdab8c.js → index-5ab20a03.js} +6 -6
  116. package/build/esm/{index-59b7c65e.js → index-5afaa486.js} +2 -2
  117. package/build/esm/{index-f18301b6.js → index-67bb06d6.js} +3 -3
  118. package/build/esm/{index-34f81557.js → index-6c64fa7c.js} +2 -2
  119. package/build/esm/{index-cc5dd802.js → index-7f282951.js} +7 -7
  120. package/build/esm/{index-3283d034.js → index-8d30046e.js} +8 -8
  121. package/build/esm/{index-40542814.js → index-8fe7951c.js} +5 -5
  122. package/build/esm/{index-f1dfe73b.js → index-921553c7.js} +3 -3
  123. package/build/esm/{index-e3522239.js → index-94c7ee4b.js} +1 -1
  124. package/build/esm/{index-e00ea5ce.js → index-9ce105df.js} +1 -1
  125. package/build/esm/{index-3fe07695.js → index-a1ae0a50.js} +36 -27
  126. package/build/esm/{index-f20e08f2.js → index-a7b5b3da.js} +2 -2
  127. package/build/esm/{index-88a60434.js → index-ac1dc7b5.js} +13 -13
  128. package/build/esm/{index-8590aa43.js → index-adc4f674.js} +1 -1
  129. package/build/esm/{index-1992432a.js → index-adf2bd5f.js} +1 -1
  130. package/build/esm/{index-22e09b92.js → index-b01bed06.js} +16 -16
  131. package/build/esm/{index-b52e228a.js → index-b472c383.js} +16 -16
  132. package/build/esm/{index-4320a963.js → index-b78bcf84.js} +15 -15
  133. package/build/esm/{index-87283fad.js → index-bd6288c0.js} +13 -13
  134. package/build/esm/{index-6e796974.js → index-bedd68c7.js} +1 -1
  135. package/build/esm/{index-ddb8b5f9.js → index-ccd54316.js} +3 -3
  136. package/build/esm/{index-febe5b0b.js → index-d30ed987.js} +2 -2
  137. package/build/esm/{index-08134aa1.js → index-d5affca6.js} +18 -18
  138. package/build/esm/{index-3c7bade1.js → index-d5dfbc30.js} +2 -2
  139. package/build/esm/{index-6491bd17.js → index-d8aea1c6.js} +1 -1
  140. package/build/esm/{index-49767cf6.js → index-dbed3a12.js} +5 -5
  141. package/build/esm/{index-e5ebf355.js → index-de4012d5.js} +6 -6
  142. package/build/esm/{index-d6b1760f.js → index-e2520675.js} +25 -25
  143. package/build/esm/{index-5b5f2d0c.js → index-e274fd81.js} +22 -22
  144. package/build/esm/{index-b42c9f25.js → index-eb330fed.js} +32 -32
  145. package/build/esm/{index-c85f2927.js → index-eea13537.js} +2 -2
  146. package/build/esm/{index-0b7e5368.js → index-f0fbcf39.js} +17 -17
  147. package/build/esm/{index-37f46909.js → index-fbe17b79.js} +17 -17
  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-4590af02.js → labelSorting-903c9ace.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 +2 -1
  172. package/build/esm/lead/layouts/lightbox/formContext.d.ts +2 -1
  173. package/build/esm/lead/services/index.d.ts +19 -0
  174. package/build/esm/lead/store/index.d.ts +1 -0
  175. package/build/esm/lead.css +1 -1
  176. package/build/esm/lead.js +2437 -1235
  177. package/build/esm/{logoIcon-8a63b46b.js → logoIcon-fdb7619c.js} +8 -2
  178. package/build/esm/mantine.js +25 -25
  179. package/build/esm/misc.js +17 -17
  180. package/build/esm/miscGetDynamicHealthTool.js +4 -4
  181. package/build/esm/miscGetSocialList.js +8 -8
  182. package/build/esm/miscScreenSizeContext.js +1 -1
  183. package/build/esm/mobileBottomNavigation.js +5 -5
  184. package/build/esm/mobileBottomNavigationIcon.js +5 -5
  185. package/build/esm/molecules.js +73 -73
  186. package/build/esm/moleculesArticleCard.js +6 -6
  187. package/build/esm/moleculesArticleCardV2.js +16 -16
  188. package/build/esm/navigation.js +45 -45
  189. package/build/esm/navigationLogoutPopup.js +9 -9
  190. package/build/esm/navigationProfileButton.js +23 -23
  191. package/build/esm/onboardingV2.js +29 -29
  192. package/build/esm/organisms.js +49 -49
  193. package/build/esm/{post-a4e3b00b.js → post-d812dde9.js} +2 -2
  194. package/build/esm/profileNavigation.js +19 -19
  195. package/build/esm/progressBar.js +1 -1
  196. package/build/esm/pwg.js +22 -22
  197. package/build/esm/ssoV2/api/featureFlag.d.ts +2 -1
  198. package/build/esm/ssoV2.js +51 -39
  199. package/build/esm/{store-a9c2a3c4.js → store-ffd867c4.js} +4 -4
  200. package/build/esm/subot.js +35 -35
  201. package/build/esm/surveyOrPremiumBanner.js +32 -32
  202. package/build/esm/surveyQuestionCard.js +10 -10
  203. package/build/esm/{surveyThankyouCard-f1e71ef9.js → surveyThankyouCard-6362dc3c.js} +5 -5
  204. package/build/esm/together.js +55 -55
  205. package/build/esm/togetherApiUtils.js +4 -4
  206. package/build/esm/togetherAtoms.js +30 -30
  207. package/build/esm/togetherComponentGlobalContext.js +4 -4
  208. package/build/esm/togetherMolecules.js +50 -50
  209. package/build/esm/togetherMoleculesCardAuthor.js +28 -28
  210. package/build/esm/togetherMoleculesPostImagePreview.js +11 -11
  211. package/build/esm/togetherMoleculesProfileDetail.js +38 -38
  212. package/build/esm/togetherOrganisms.js +49 -49
  213. package/build/esm/togetherRichTextEditor.js +17 -17
  214. package/build/esm/togetherShareBox.js +10 -10
  215. package/build/esm/translationsProvider-75b93b92.js +55 -0
  216. package/build/esm/{treePopoverMenu-2b4a0ce7.js → treePopoverMenu-03480736.js} +19 -19
  217. package/build/esm/{types-00647e82.js → types-4b072730.js} +2 -2
  218. package/build/esm/types.js +2 -2
  219. package/build/esm/{useCategory-b156220e.js → useCategory-1d58b7de.js} +18 -5
  220. package/build/esm/{useHealthToolCache-83bc2007.js → useHealthToolCache-8e65e4cc.js} +1 -1
  221. package/build/esm/{useMantineLocale-75d3a92b.js → useMantineLocale-2ddd0d66.js} +8 -6
  222. package/build/esm/{usePlacesAutocomplete-be5196d7.js → usePlacesAutocomplete-1451c491.js} +1 -1
  223. package/build/esm/{useScreenSize-9091e971.js → useScreenSize-b097bc99.js} +2 -2
  224. package/build/esm/useTogetherAuthRequiredAction.js +9 -9
  225. package/build/esm/{utils-654cc220.js → utils-3ff75edd.js} +2 -2
  226. package/build/esm/{utils-d3607ebf.js → utils-837a98c2.js} +2 -2
  227. package/build/esm/{utils-0d32cd95.js → utils-9d061cb4.js} +4 -4
  228. package/build/esm/{utils-c6d483d6.js → utils-a6705915.js} +3 -3
  229. package/build/esm/vaccination.js +21 -21
  230. package/build/footer.js +21 -21
  231. package/build/gAssets.js +2 -2
  232. package/build/{healthTools-5d43fdba.js → healthTools-5675769e.js} +1 -1
  233. package/build/healthToolsCardWrapper.js +18 -18
  234. package/build/healthToolsForm.js +33 -33
  235. package/build/hooks.js +13 -13
  236. package/build/i18n-values/zh-CN.js +866 -0
  237. package/build/i18n.js +16 -56
  238. package/build/i18nV2.js +1 -1
  239. package/build/{index-1e5869a0.js → index-01674c9d.js} +1 -1
  240. package/build/{index-015decac.js → index-01f31cb8.js} +13 -13
  241. package/build/{index-95d0866e.js → index-058de55a.js} +22 -22
  242. package/build/{index-f1240784.js → index-0a1ac489.js} +6 -6
  243. package/build/{index-153b215b.js → index-0b32faf6.js} +16 -16
  244. package/build/{index-e6d89d93.js → index-131cf2b6.js} +7 -7
  245. package/build/{index-b15cd09e.js → index-1cbd6748.js} +2 -2
  246. package/build/{index-3b559014.js → index-1d84b42c.js} +6 -6
  247. package/build/{index-90c3bd51.js → index-23e996bf.js} +2 -2
  248. package/build/{index-1dca06d3.js → index-23f5de35.js} +31 -31
  249. package/build/{index-fa0f1dec.js → index-2555df32.js} +1 -1
  250. package/build/{index-7d70d6d9.js → index-2644ecd5.js} +2 -2
  251. package/build/{index-3d49b533.js → index-2a3051c7.js} +17 -17
  252. package/build/{index-892e05e3.js → index-2fd62012.js} +13 -13
  253. package/build/{index-dc9d63cb.js → index-3278247e.js} +10 -10
  254. package/build/{index-a67e5b8c.js → index-3e668daf.js} +2 -2
  255. package/build/{index-964bebd5.js → index-3f648346.js} +2 -2
  256. package/build/{index-349d4ad5.js → index-424296a4.js} +3 -3
  257. package/build/{index-578b7adc.js → index-42af3733.js} +2 -2
  258. package/build/{index-f0871b13.js → index-4ba367d3.js} +2 -2
  259. package/build/{index-312f141b.js → index-4ca26ec6.js} +3 -3
  260. package/build/{index-04336ab9.js → index-4ec0821f.js} +1 -1
  261. package/build/{index-c4fdcb5d.js → index-517f6f16.js} +25 -25
  262. package/build/{index-7a0bbb05.js → index-523e7e4d.js} +39 -2
  263. package/build/{index-b7e2e5d7.js → index-56574883.js} +2 -2
  264. package/build/{index-86e1489b.js → index-5978843f.js} +3 -3
  265. package/build/{index-3c9b6c14.js → index-5c38e2bd.js} +1 -1
  266. package/build/{index-4f50c9a6.js → index-64618042.js} +4 -4
  267. package/build/{index-1e3ef673.js → index-67fb3969.js} +8 -8
  268. package/build/{index-6427efb3.js → index-68ca2ec6.js} +32 -32
  269. package/build/{index-109bc0ba.js → index-6d0d6307.js} +16 -16
  270. package/build/{index-0ccd6ab4.js → index-702577b3.js} +18 -18
  271. package/build/{index-9ed8f15e.js → index-706cdb42.js} +6 -6
  272. package/build/{index-1832c923.js → index-729572c2.js} +1 -1
  273. package/build/{index-9e545145.js → index-734405be.js} +17 -17
  274. package/build/{index-3d0f0804.js → index-737372f7.js} +2 -2
  275. package/build/{index-bcf83833.js → index-7523372e.js} +17 -17
  276. package/build/{index-669549a2.js → index-84b1400f.js} +2 -2
  277. package/build/{index-2aa39a80.js → index-8721dda0.js} +15 -15
  278. package/build/{index-73816dbf.js → index-8807a628.js} +16 -16
  279. package/build/{index-8a505064.js → index-8cc5aaf4.js} +17 -17
  280. package/build/{index-32d56013.js → index-8e3127cf.js} +2 -2
  281. package/build/{index-c6c79524.js → index-8e928040.js} +5 -5
  282. package/build/{index-5874eb30.js → index-90c35133.js} +7 -7
  283. package/build/{index-064c06f3.js → index-965b5561.js} +5 -5
  284. package/build/{index-b98ed131.js → index-9783335b.js} +13 -13
  285. package/build/{index-ff7f8fd0.js → index-9ab7ef60.js} +24 -24
  286. package/build/{index-0b1b3404.js → index-a10c0c62.js} +3 -3
  287. package/build/{index-3acf4291.js → index-a9122b6e.js} +1 -1
  288. package/build/{index-c349ac59.js → index-b5cf12ac.js} +18 -18
  289. package/build/{index-d93867ea.js → index-b755d36a.js} +1 -1
  290. package/build/{index-1ffd87e6.js → index-c0efb13b.js} +6 -6
  291. package/build/{index-d59daad9.js → index-c7b52682.js} +21 -21
  292. package/build/{index-ffa29b44.js → index-d0820aeb.js} +36 -27
  293. package/build/{index-7fc6a742.js → index-d4b12903.js} +3 -3
  294. package/build/{index-576a7b83.js → index-d68d726d.js} +32 -32
  295. package/build/{index-022360ea.js → index-d74b605a.js} +2 -2
  296. package/build/{index-04fded65.js → index-e1a7b1ce.js} +1 -1
  297. package/build/{index-6433425b.js → index-e7218beb.js} +6 -6
  298. package/build/{index-33c24fd1.js → index-ebe2c303.js} +13 -13
  299. package/build/{index-c234311f.js → index-ee1dd2b5.js} +16 -16
  300. package/build/{index-e7f91600.js → index-f425dec1.js} +1 -1
  301. package/build/{index-bcffdc4e.js → index-f68b6b94.js} +3 -3
  302. package/build/{index-6e1d6d78.js → index-fe818695.js} +2 -2
  303. package/build/index.js +117 -117
  304. package/build/interfaces/constants/domainLocales.d.ts +2 -0
  305. package/build/interfaces/constants/index.d.ts +1 -1
  306. package/build/interfaces/types/Locale.d.ts +2 -1
  307. package/build/interfaces/types/index.d.ts +2 -1
  308. package/build/{labelSorting-7570276e.js → labelSorting-1c7cee93.js} +4 -4
  309. package/build/lead/LeadGen.type.d.ts +31 -0
  310. package/build/lead/LeadGenForm/LeadGenForm.d.ts +41 -0
  311. package/build/lead/LeadGenForm/LeadGenForm.helpers.d.ts +2 -0
  312. package/build/lead/LeadGenForm/LeadGenForm.styled.d.ts +5 -0
  313. package/build/lead/LeadGenForm/LeadGenFormPhone.d.ts +17 -0
  314. package/build/lead/LeadGenForm/LeadGenThankYou.d.ts +20 -0
  315. package/build/lead/LeadGenForm/index.d.ts +3 -0
  316. package/build/lead/LeadGenForm/textField/index.d.ts +13 -0
  317. package/build/lead/LeadGenForm/textField/index.styled.d.ts +11 -0
  318. package/build/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +63 -0
  319. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +4 -0
  320. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +21 -0
  321. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +3 -0
  322. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +23 -0
  323. package/build/lead/LeadGenSubscriptionBox/index.d.ts +1 -0
  324. package/build/lead/LeadGenTranslationContext.d.ts +6 -0
  325. package/build/lead/helpers.d.ts +56 -1
  326. package/build/lead/index.d.ts +2 -1
  327. package/build/lead/layouts/lightbox/formContext.d.ts +2 -1
  328. package/build/lead/services/index.d.ts +19 -0
  329. package/build/lead/store/index.d.ts +1 -0
  330. package/build/lead.css +1 -1
  331. package/build/lead.js +2308 -1105
  332. package/build/{logoIcon-a0093830.js → logoIcon-0adc172c.js} +8 -2
  333. package/build/mantine.js +22 -22
  334. package/build/misc.js +17 -17
  335. package/build/miscGetDynamicHealthTool.js +4 -4
  336. package/build/miscGetSocialList.js +8 -8
  337. package/build/miscScreenSizeContext.js +1 -1
  338. package/build/mobileBottomNavigation.js +5 -5
  339. package/build/mobileBottomNavigationIcon.js +5 -5
  340. package/build/molecules.js +73 -73
  341. package/build/moleculesArticleCard.js +6 -6
  342. package/build/moleculesArticleCardV2.js +16 -16
  343. package/build/navigation.js +45 -45
  344. package/build/navigationLogoutPopup.js +9 -9
  345. package/build/navigationProfileButton.js +23 -23
  346. package/build/onboardingV2.js +28 -28
  347. package/build/organisms.js +49 -49
  348. package/build/{post-8b3ec323.js → post-9e59e11b.js} +2 -2
  349. package/build/profileNavigation.js +19 -19
  350. package/build/progressBar.js +1 -1
  351. package/build/pwg.js +22 -22
  352. package/build/ssoV2/api/featureFlag.d.ts +2 -1
  353. package/build/ssoV2.js +49 -37
  354. package/build/{store-3bb34d08.js → store-f6379c86.js} +4 -4
  355. package/build/subot.js +34 -34
  356. package/build/surveyOrPremiumBanner.js +32 -32
  357. package/build/surveyQuestionCard.js +10 -10
  358. package/build/{surveyThankyouCard-40fde7aa.js → surveyThankyouCard-24135968.js} +5 -5
  359. package/build/together.js +55 -55
  360. package/build/togetherApiUtils.js +4 -4
  361. package/build/togetherAtoms.js +30 -30
  362. package/build/togetherComponentGlobalContext.js +4 -4
  363. package/build/togetherMolecules.js +50 -50
  364. package/build/togetherMoleculesCardAuthor.js +28 -28
  365. package/build/togetherMoleculesPostImagePreview.js +11 -11
  366. package/build/togetherMoleculesProfileDetail.js +38 -38
  367. package/build/togetherOrganisms.js +49 -49
  368. package/build/togetherRichTextEditor.js +17 -17
  369. package/build/togetherShareBox.js +10 -10
  370. package/build/translationsProvider-0f5d2303.js +62 -0
  371. package/build/{treePopoverMenu-9f4d0f7d.js → treePopoverMenu-d6e8372b.js} +19 -19
  372. package/build/{types-709ee706.js → types-26ce9ce5.js} +2 -2
  373. package/build/types.js +2 -2
  374. package/build/{useCategory-889d8b9e.js → useCategory-941ff45e.js} +18 -5
  375. package/build/{useHealthToolCache-dd27ba92.js → useHealthToolCache-068e5649.js} +1 -1
  376. package/build/{useMantineLocale-aa4e4cdc.js → useMantineLocale-d74729a8.js} +8 -6
  377. package/build/{usePlacesAutocomplete-60f0a6d0.js → usePlacesAutocomplete-c3a05472.js} +1 -1
  378. package/build/{useScreenSize-013494cb.js → useScreenSize-805ef787.js} +2 -2
  379. package/build/useTogetherAuthRequiredAction.js +9 -9
  380. package/build/{utils-c3214203.js → utils-22163cc9.js} +4 -4
  381. package/build/{utils-cfbfcd70.js → utils-2d4e6ea6.js} +2 -2
  382. package/build/{utils-bb4ffbb8.js → utils-914af569.js} +2 -2
  383. package/build/{utils-0a036093.js → utils-a70ced06.js} +3 -3
  384. package/build/vaccination.js +21 -21
  385. package/package.json +3 -3
  386. /package/build/{BMI_BOYS.percentile.monthly-f5295f7f.js → BMI_BOYS.percentile.monthly-f4daed0d.js} +0 -0
  387. /package/build/{BMI_BOYS.percentile.weekly-e89f6859.js → BMI_BOYS.percentile.weekly-1de7f0e1.js} +0 -0
  388. /package/build/{BMI_BOYS.percentile.yearly-206f392e.js → BMI_BOYS.percentile.yearly-0222daae.js} +0 -0
  389. /package/build/{BMI_BOYS.zscore.monthly-62cfeba2.js → BMI_BOYS.zscore.monthly-1bd85a5e.js} +0 -0
  390. /package/build/{BMI_BOYS.zscore.weekly-aa9c8d30.js → BMI_BOYS.zscore.weekly-65f9be2b.js} +0 -0
  391. /package/build/{BMI_BOYS.zscore.yearly-40a612b4.js → BMI_BOYS.zscore.yearly-c9a6b727.js} +0 -0
  392. /package/build/{BMI_GIRLS.percentile.monthly-81b1a5b7.js → BMI_GIRLS.percentile.monthly-220ef448.js} +0 -0
  393. /package/build/{BMI_GIRLS.percentile.weekly-b90e7d68.js → BMI_GIRLS.percentile.weekly-7a5096e3.js} +0 -0
  394. /package/build/{BMI_GIRLS.percentile.yearly-78565dff.js → BMI_GIRLS.percentile.yearly-53ed80a2.js} +0 -0
  395. /package/build/{BMI_GIRLS.zscore.monthly-bf3313da.js → BMI_GIRLS.zscore.monthly-5df375ff.js} +0 -0
  396. /package/build/{BMI_GIRLS.zscore.weekly-76c59850.js → BMI_GIRLS.zscore.weekly-9503c924.js} +0 -0
  397. /package/build/{BMI_GIRLS.zscore.yearly-b45db558.js → BMI_GIRLS.zscore.yearly-f8c55dfc.js} +0 -0
  398. /package/build/{ChevronDown-4d7e527c.js → ChevronDown-5813f17e.js} +0 -0
  399. /package/build/{Close-88109e78.js → Close-4893c3ca.js} +0 -0
  400. /package/build/{Google-18b395b8.js → Google-391b9a03.js} +0 -0
  401. /package/build/{HEAD CIRCUM_BOYS.percentile.monthly-c5365f78.js → HEAD CIRCUM_BOYS.percentile.monthly-4d8f3e60.js} +0 -0
  402. /package/build/{HEAD CIRCUM_BOYS.percentile.weekly-ba1be07f.js → HEAD CIRCUM_BOYS.percentile.weekly-1819f9c6.js} +0 -0
  403. /package/build/{HEAD CIRCUM_BOYS.percentile.yearly-0d9ff7de.js → HEAD CIRCUM_BOYS.percentile.yearly-020cb98a.js} +0 -0
  404. /package/build/{HEAD CIRCUM_BOYS.zscore.monthly-293579ed.js → HEAD CIRCUM_BOYS.zscore.monthly-feeff1b8.js} +0 -0
  405. /package/build/{HEAD CIRCUM_BOYS.zscore.weekly-d4476f55.js → HEAD CIRCUM_BOYS.zscore.weekly-e8427518.js} +0 -0
  406. /package/build/{HEAD CIRCUM_BOYS.zscore.yearly-b7f64416.js → HEAD CIRCUM_BOYS.zscore.yearly-0d9f4ede.js} +0 -0
  407. /package/build/{HEAD CIRCUM_GIRLS.percentile.monthly-30829c3b.js → HEAD CIRCUM_GIRLS.percentile.monthly-a058e780.js} +0 -0
  408. /package/build/{HEAD CIRCUM_GIRLS.percentile.weekly-2f227a0a.js → HEAD CIRCUM_GIRLS.percentile.weekly-121b74bc.js} +0 -0
  409. /package/build/{HEAD CIRCUM_GIRLS.percentile.yearly-ab05fba4.js → HEAD CIRCUM_GIRLS.percentile.yearly-7729a5ed.js} +0 -0
  410. /package/build/{HEAD CIRCUM_GIRLS.zscore.monthly-9e41bb48.js → HEAD CIRCUM_GIRLS.zscore.monthly-5a6747cd.js} +0 -0
  411. /package/build/{HEAD CIRCUM_GIRLS.zscore.weekly-07fdf8b4.js → HEAD CIRCUM_GIRLS.zscore.weekly-5f4cb404.js} +0 -0
  412. /package/build/{HEAD CIRCUM_GIRLS.zscore.yearly-3d09a791.js → HEAD CIRCUM_GIRLS.zscore.yearly-db75ac45.js} +0 -0
  413. /package/build/{HEIGHT_BOYS.percentile.monthly-58875bdd.js → HEIGHT_BOYS.percentile.monthly-9979a4bf.js} +0 -0
  414. /package/build/{HEIGHT_BOYS.percentile.weekly-0614ac80.js → HEIGHT_BOYS.percentile.weekly-ebcdeaa8.js} +0 -0
  415. /package/build/{HEIGHT_BOYS.percentile.yearly-b992897c.js → HEIGHT_BOYS.percentile.yearly-6f6fc978.js} +0 -0
  416. /package/build/{HEIGHT_BOYS.zscore.monthly-4b1bcf27.js → HEIGHT_BOYS.zscore.monthly-c4d5a63c.js} +0 -0
  417. /package/build/{HEIGHT_BOYS.zscore.weekly-77c0776c.js → HEIGHT_BOYS.zscore.weekly-ac833d64.js} +0 -0
  418. /package/build/{HEIGHT_BOYS.zscore.yearly-5dc8e6a1.js → HEIGHT_BOYS.zscore.yearly-ff3f71f9.js} +0 -0
  419. /package/build/{HEIGHT_GIRLS.percentile.monthly-cc99017e.js → HEIGHT_GIRLS.percentile.monthly-eb3712f6.js} +0 -0
  420. /package/build/{HEIGHT_GIRLS.percentile.weekly-fae4e9f9.js → HEIGHT_GIRLS.percentile.weekly-f9e21b4d.js} +0 -0
  421. /package/build/{HEIGHT_GIRLS.percentile.yearly-bc7c5e30.js → HEIGHT_GIRLS.percentile.yearly-3b69d6bd.js} +0 -0
  422. /package/build/{HEIGHT_GIRLS.zscore.monthly-2a6220ef.js → HEIGHT_GIRLS.zscore.monthly-812e3b24.js} +0 -0
  423. /package/build/{HEIGHT_GIRLS.zscore.weekly-c676eacf.js → HEIGHT_GIRLS.zscore.weekly-0450e9dd.js} +0 -0
  424. /package/build/{HEIGHT_GIRLS.zscore.yearly-eec4124e.js → HEIGHT_GIRLS.zscore.yearly-3e9be766.js} +0 -0
  425. /package/build/{Visible-49e0cc9d.js → Visible-6c80b7ef.js} +0 -0
  426. /package/build/{WEIGHT_BOYS.percentile.monthly-14105231.js → WEIGHT_BOYS.percentile.monthly-15304941.js} +0 -0
  427. /package/build/{WEIGHT_BOYS.percentile.weekly-7bb55772.js → WEIGHT_BOYS.percentile.weekly-7f6893d6.js} +0 -0
  428. /package/build/{WEIGHT_BOYS.percentile.yearly-d5d911a6.js → WEIGHT_BOYS.percentile.yearly-9de9bd0e.js} +0 -0
  429. /package/build/{WEIGHT_BOYS.zscore.monthly-67f28812.js → WEIGHT_BOYS.zscore.monthly-44b508be.js} +0 -0
  430. /package/build/{WEIGHT_BOYS.zscore.weekly-c5749492.js → WEIGHT_BOYS.zscore.weekly-fb670db8.js} +0 -0
  431. /package/build/{WEIGHT_BOYS.zscore.yearly-f9dfc214.js → WEIGHT_BOYS.zscore.yearly-d23350c0.js} +0 -0
  432. /package/build/{WEIGHT_GIRLS.percentile.monthly-863b5e58.js → WEIGHT_GIRLS.percentile.monthly-09784264.js} +0 -0
  433. /package/build/{WEIGHT_GIRLS.percentile.weekly-97e5da17.js → WEIGHT_GIRLS.percentile.weekly-ad7ef81e.js} +0 -0
  434. /package/build/{WEIGHT_GIRLS.percentile.yearly-540af1d1.js → WEIGHT_GIRLS.percentile.yearly-55c9d4e9.js} +0 -0
  435. /package/build/{WEIGHT_GIRLS.zscore.monthly-79fe6b74.js → WEIGHT_GIRLS.zscore.monthly-abd26afa.js} +0 -0
  436. /package/build/{WEIGHT_GIRLS.zscore.weekly-0ec74845.js → WEIGHT_GIRLS.zscore.weekly-370b7aa6.js} +0 -0
  437. /package/build/{WEIGHT_GIRLS.zscore.yearly-7e811cf4.js → WEIGHT_GIRLS.zscore.yearly-b07eecee.js} +0 -0
  438. /package/build/{animation-13c1efd7.js → animation-5ca47bb9.js} +0 -0
  439. /package/build/{constants-0dc7ef32.js → constants-57c5ae20.js} +0 -0
  440. /package/build/{constants-4b2fea40.js → constants-8c977f49.js} +0 -0
  441. /package/build/{dataTransform-ed106647.js → dataTransform-1061941e.js} +0 -0
  442. /package/build/{doctor-b018f684.js → doctor-479ad363.js} +0 -0
  443. /package/build/esm/{BMI_BOYS.percentile.monthly-eca08d1b.js → BMI_BOYS.percentile.monthly-f7827037.js} +0 -0
  444. /package/build/esm/{BMI_BOYS.percentile.weekly-0f36c0a5.js → BMI_BOYS.percentile.weekly-565ddccf.js} +0 -0
  445. /package/build/esm/{BMI_BOYS.percentile.yearly-de605740.js → BMI_BOYS.percentile.yearly-e5813395.js} +0 -0
  446. /package/build/esm/{BMI_BOYS.zscore.monthly-871240d7.js → BMI_BOYS.zscore.monthly-896b5548.js} +0 -0
  447. /package/build/esm/{BMI_BOYS.zscore.weekly-53e9361f.js → BMI_BOYS.zscore.weekly-72d8f1d4.js} +0 -0
  448. /package/build/esm/{BMI_BOYS.zscore.yearly-693c5ba7.js → BMI_BOYS.zscore.yearly-5cdbc608.js} +0 -0
  449. /package/build/esm/{BMI_GIRLS.percentile.monthly-af445923.js → BMI_GIRLS.percentile.monthly-4689d010.js} +0 -0
  450. /package/build/esm/{BMI_GIRLS.percentile.weekly-038c1d84.js → BMI_GIRLS.percentile.weekly-8095cdb1.js} +0 -0
  451. /package/build/esm/{BMI_GIRLS.percentile.yearly-ad96c33e.js → BMI_GIRLS.percentile.yearly-e420d4b6.js} +0 -0
  452. /package/build/esm/{BMI_GIRLS.zscore.monthly-d1463624.js → BMI_GIRLS.zscore.monthly-96744fcf.js} +0 -0
  453. /package/build/esm/{BMI_GIRLS.zscore.weekly-7d60db22.js → BMI_GIRLS.zscore.weekly-108cd0c1.js} +0 -0
  454. /package/build/esm/{BMI_GIRLS.zscore.yearly-df88448a.js → BMI_GIRLS.zscore.yearly-ddc29cbb.js} +0 -0
  455. /package/build/esm/{ChevronDown-47446788.js → ChevronDown-6c5ab56c.js} +0 -0
  456. /package/build/esm/{Close-c3a49880.js → Close-bed66153.js} +0 -0
  457. /package/build/esm/{Google-4613f559.js → Google-0d0deb6c.js} +0 -0
  458. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.monthly-60e25ec5.js → HEAD CIRCUM_BOYS.percentile.monthly-3f49b594.js} +0 -0
  459. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.weekly-3c3343ae.js → HEAD CIRCUM_BOYS.percentile.weekly-189d3b0d.js} +0 -0
  460. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.yearly-be196089.js → HEAD CIRCUM_BOYS.percentile.yearly-a36b8cc0.js} +0 -0
  461. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.monthly-29ff8370.js → HEAD CIRCUM_BOYS.zscore.monthly-adbdbe9b.js} +0 -0
  462. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.weekly-92e4b27a.js → HEAD CIRCUM_BOYS.zscore.weekly-389bcd18.js} +0 -0
  463. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.yearly-2e6a5016.js → HEAD CIRCUM_BOYS.zscore.yearly-93f5c48a.js} +0 -0
  464. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.monthly-b9290e16.js → HEAD CIRCUM_GIRLS.percentile.monthly-d6d60aa3.js} +0 -0
  465. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.weekly-8062ea4d.js → HEAD CIRCUM_GIRLS.percentile.weekly-fce1c0a4.js} +0 -0
  466. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.yearly-b164ccc6.js → HEAD CIRCUM_GIRLS.percentile.yearly-8b9b0963.js} +0 -0
  467. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.monthly-d9e6f3eb.js → HEAD CIRCUM_GIRLS.zscore.monthly-a384e6b8.js} +0 -0
  468. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.weekly-4fd80615.js → HEAD CIRCUM_GIRLS.zscore.weekly-2b323528.js} +0 -0
  469. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.yearly-f28609a2.js → HEAD CIRCUM_GIRLS.zscore.yearly-49dcd33e.js} +0 -0
  470. /package/build/esm/{HEIGHT_BOYS.percentile.monthly-15a0bc4d.js → HEIGHT_BOYS.percentile.monthly-f199288a.js} +0 -0
  471. /package/build/esm/{HEIGHT_BOYS.percentile.weekly-102b50e3.js → HEIGHT_BOYS.percentile.weekly-a343b1bb.js} +0 -0
  472. /package/build/esm/{HEIGHT_BOYS.percentile.yearly-cf42e15a.js → HEIGHT_BOYS.percentile.yearly-e4055e79.js} +0 -0
  473. /package/build/esm/{HEIGHT_BOYS.zscore.monthly-8f455cc9.js → HEIGHT_BOYS.zscore.monthly-f3b712b0.js} +0 -0
  474. /package/build/esm/{HEIGHT_BOYS.zscore.weekly-f2c852bd.js → HEIGHT_BOYS.zscore.weekly-bb857bea.js} +0 -0
  475. /package/build/esm/{HEIGHT_BOYS.zscore.yearly-0ebca637.js → HEIGHT_BOYS.zscore.yearly-711d5437.js} +0 -0
  476. /package/build/esm/{HEIGHT_GIRLS.percentile.monthly-790caf2c.js → HEIGHT_GIRLS.percentile.monthly-328501ed.js} +0 -0
  477. /package/build/esm/{HEIGHT_GIRLS.percentile.weekly-18f018dd.js → HEIGHT_GIRLS.percentile.weekly-0851701a.js} +0 -0
  478. /package/build/esm/{HEIGHT_GIRLS.percentile.yearly-5b3a5c7e.js → HEIGHT_GIRLS.percentile.yearly-ccc2206e.js} +0 -0
  479. /package/build/esm/{HEIGHT_GIRLS.zscore.monthly-5a259243.js → HEIGHT_GIRLS.zscore.monthly-eda10451.js} +0 -0
  480. /package/build/esm/{HEIGHT_GIRLS.zscore.weekly-7dcf65e7.js → HEIGHT_GIRLS.zscore.weekly-58d86605.js} +0 -0
  481. /package/build/esm/{HEIGHT_GIRLS.zscore.yearly-1f427d14.js → HEIGHT_GIRLS.zscore.yearly-ccb8497b.js} +0 -0
  482. /package/build/esm/{Visible-c0ca5ff5.js → Visible-c5e6e4e6.js} +0 -0
  483. /package/build/esm/{WEIGHT_BOYS.percentile.monthly-1cb736bc.js → WEIGHT_BOYS.percentile.monthly-33449fab.js} +0 -0
  484. /package/build/esm/{WEIGHT_BOYS.percentile.weekly-cd49dbad.js → WEIGHT_BOYS.percentile.weekly-48943538.js} +0 -0
  485. /package/build/esm/{WEIGHT_BOYS.percentile.yearly-73dbe0a9.js → WEIGHT_BOYS.percentile.yearly-4c2f88f2.js} +0 -0
  486. /package/build/esm/{WEIGHT_BOYS.zscore.monthly-cf13f60b.js → WEIGHT_BOYS.zscore.monthly-0f42bc26.js} +0 -0
  487. /package/build/esm/{WEIGHT_BOYS.zscore.weekly-5cb0f54e.js → WEIGHT_BOYS.zscore.weekly-677a0765.js} +0 -0
  488. /package/build/esm/{WEIGHT_BOYS.zscore.yearly-f8920ebb.js → WEIGHT_BOYS.zscore.yearly-580b0b33.js} +0 -0
  489. /package/build/esm/{WEIGHT_GIRLS.percentile.monthly-d05adf8a.js → WEIGHT_GIRLS.percentile.monthly-be676e3d.js} +0 -0
  490. /package/build/esm/{WEIGHT_GIRLS.percentile.weekly-8bfcc146.js → WEIGHT_GIRLS.percentile.weekly-c35d4786.js} +0 -0
  491. /package/build/esm/{WEIGHT_GIRLS.percentile.yearly-b8972989.js → WEIGHT_GIRLS.percentile.yearly-fbba1129.js} +0 -0
  492. /package/build/esm/{WEIGHT_GIRLS.zscore.monthly-fb98e36d.js → WEIGHT_GIRLS.zscore.monthly-8d62df68.js} +0 -0
  493. /package/build/esm/{WEIGHT_GIRLS.zscore.weekly-69079f9a.js → WEIGHT_GIRLS.zscore.weekly-d48fbc5a.js} +0 -0
  494. /package/build/esm/{WEIGHT_GIRLS.zscore.yearly-22e982d8.js → WEIGHT_GIRLS.zscore.yearly-5a9af915.js} +0 -0
  495. /package/build/esm/{animation-8f44fc6c.js → animation-d5589e8b.js} +0 -0
  496. /package/build/esm/{constants-6d3e6bd2.js → constants-341374a3.js} +0 -0
  497. /package/build/esm/{constants-dbb68f45.js → constants-86b4a845.js} +0 -0
  498. /package/build/esm/{dataTransform-0688712b.js → dataTransform-51f00ef8.js} +0 -0
  499. /package/build/esm/{doctor-23714c67.js → doctor-9dd59807.js} +0 -0
  500. /package/build/esm/{index-388c355e.js → index-094d7d78.js} +0 -0
  501. /package/build/esm/{index-72875897.js → index-4afb0581.js} +0 -0
  502. /package/build/esm/{index-658ef77b.js → index-758957ae.js} +0 -0
  503. /package/build/esm/{index-577a8f9b.js → index-a26c1eda.js} +0 -0
  504. /package/build/esm/{index-a96ad622.js → index-c23c9f7e.js} +0 -0
  505. /package/build/esm/{index-d1e7bea2.js → index-cd80d854.js} +0 -0
  506. /package/build/esm/{index-f6ae34df.js → index-f3b6ab45.js} +0 -0
  507. /package/build/esm/{index-530d9459.js → index-fd8e30de.js} +0 -0
  508. /package/build/esm/{index.styles-e7a84f91.js → index.styles-f8978237.js} +0 -0
  509. /package/build/esm/{localizeNumberFormat-e8ce7c0c.js → localizeNumberFormat-2199ec15.js} +0 -0
  510. /package/build/esm/{normalizeLink-a6fff3b6.js → normalizeLink-827f4e69.js} +0 -0
  511. /package/build/esm/{number-9db85954.js → number-0139958f.js} +0 -0
  512. /package/build/esm/{other-39c7ba92.js → other-a974982d.js} +0 -0
  513. /package/build/esm/{paths-73406cfb.js → paths-053bd382.js} +0 -0
  514. /package/build/esm/{translationsContext-db44a804.js → translationsContext-4ea92c46.js} +0 -0
  515. /package/build/esm/{tslib.es6-def645e9.js → tslib.es6-1073e423.js} +0 -0
  516. /package/build/esm/{types-d2b218e1.js → types-c83c742e.js} +0 -0
  517. /package/build/esm/{useIsInit-e1c4cbbb.js → useIsInit-a00426ab.js} +0 -0
  518. /package/build/esm/{useOutsideClick-c5c0416e.js → useOutsideClick-dd8680ce.js} +0 -0
  519. /package/build/esm/{useScrollbarSize-cdca65c3.js → useScrollbarSize-7bd945f2.js} +0 -0
  520. /package/build/esm/{useUniqueId-5ba39dd0.js → useUniqueId-fa696ba6.js} +0 -0
  521. /package/build/esm/{utils-ad366429.js → utils-f530e069.js} +0 -0
  522. /package/build/{index-439ed166.js → index-1f0ffa62.js} +0 -0
  523. /package/build/{index-71123b1e.js → index-54146416.js} +0 -0
  524. /package/build/{index-5ecc8dcf.js → index-62ecd981.js} +0 -0
  525. /package/build/{index-0630bc54.js → index-64f3f9cd.js} +0 -0
  526. /package/build/{index-6d25977a.js → index-66cbcf0b.js} +0 -0
  527. /package/build/{index-a18c5ff1.js → index-72924c47.js} +0 -0
  528. /package/build/{index-020412a7.js → index-75f7316f.js} +0 -0
  529. /package/build/{index-ec78675c.js → index-adfb7062.js} +0 -0
  530. /package/build/{index.styles-1c27538c.js → index.styles-65606527.js} +0 -0
  531. /package/build/{localizeNumberFormat-3fa00932.js → localizeNumberFormat-95af1367.js} +0 -0
  532. /package/build/{normalizeLink-cdde0b93.js → normalizeLink-325ec7cc.js} +0 -0
  533. /package/build/{number-d95061a1.js → number-04e9f091.js} +0 -0
  534. /package/build/{other-4710bd77.js → other-7cb22946.js} +0 -0
  535. /package/build/{paths-264a6504.js → paths-ad2e821c.js} +0 -0
  536. /package/build/{translationsContext-02291cc2.js → translationsContext-824f5c5d.js} +0 -0
  537. /package/build/{tslib.es6-0c296361.js → tslib.es6-751dcc64.js} +0 -0
  538. /package/build/{types-124cdc28.js → types-d9723642.js} +0 -0
  539. /package/build/{useIsInit-1962c185.js → useIsInit-c869bcde.js} +0 -0
  540. /package/build/{useOutsideClick-99f10750.js → useOutsideClick-57926422.js} +0 -0
  541. /package/build/{useScrollbarSize-3663cbc4.js → useScrollbarSize-972b58b9.js} +0 -0
  542. /package/build/{useUniqueId-5d17e7af.js → useUniqueId-1e0d5636.js} +0 -0
  543. /package/build/{utils-e42c732c.js → utils-0a56df4b.js} +0 -0
package/build/esm/lead.js CHANGED
@@ -1,44 +1,48 @@
1
- import { _ as __rest, a as __awaiter } from './tslib.es6-def645e9.js';
2
- import React__default, { createContext, useMemo, useEffect, useRef, useState, useContext, useCallback } from 'react';
3
- import { createStyles, Box, Button as Button$1, Autocomplete, clsx, Input as Input$1, TextInput, NumberInput as NumberInput$1, Portal, Transition, Overlay } from '@mantine/core';
1
+ import { _ as __rest, a as __awaiter } from './tslib.es6-1073e423.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-e3522239.js';
8
- import { T as TranslationsContext } from './translationsContext-db44a804.js';
6
+ import { createFormContext, useForm } from '@mantine/form';
7
+ import { u as useTranslations } from './index-94c7ee4b.js';
8
+ import { T as TranslationsContext } from './translationsContext-4ea92c46.js';
9
9
  import { getCookie, setCookie } from './miscCookieHelper.js';
10
- import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-ad366429.js';
11
- import { T as Text } from './index-d46d72e5.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-3fe07695.js';
13
- import { D as DatePicker } from './index-773c6e02.js';
14
- import { B as Button } from './index-02c659dd.js';
15
- import './index.styles-e7a84f91.js';
10
+ import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-f530e069.js';
11
+ import { T as Text } from './index-53e72c1e.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-a1ae0a50.js';
13
+ import { D as DatePicker } from './index-16fae63d.js';
14
+ import { B as Button } from './index-0d9a1b8c.js';
15
+ import './index.styles-f8978237.js';
16
16
  import { useClickOutside } from '@mantine/hooks';
17
- import './useMantineLocale-75d3a92b.js';
18
- import './index-6e796974.js';
19
- import './index-f6ae34df.js';
20
- import { Z as ZINDEX_SSO } from './index-b1702546.js';
21
- import './other-39c7ba92.js';
22
- import './index-f18301b6.js';
23
- import { M as MAPPED_LOCALE } from './utils-654cc220.js';
24
- import '@mantine/dates';
25
- import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-be5196d7.js';
26
- import { H as Heading$1 } from './index-c85f2927.js';
17
+ import './useMantineLocale-2ddd0d66.js';
18
+ import { C as COMMON_DATE_TRANSLATE_KEY } from './index-bedd68c7.js';
19
+ import './index-f3b6ab45.js';
20
+ import { Z as ZINDEX_SSO, I as ISO_FORMAT } from './index-54de0535.js';
21
+ import './other-a974982d.js';
22
+ import './index-67bb06d6.js';
23
+ import { M as MAPPED_LOCALE } from './utils-3ff75edd.js';
24
+ import { DateInput } from '@mantine/dates';
25
+ import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-1451c491.js';
26
+ import { H as Heading$1 } from './index-eea13537.js';
27
+ import { t as translationsMap$1 } from './translationsProvider-75b93b92.js';
28
+ import { L as LOCALE } from './Locale-2def755e.js';
27
29
  import { v1 } from 'uuid';
28
- import { i as isVideo } from './index-72875897.js';
29
- import { D as DrawerComponent } from './index-3c7bade1.js';
30
- import { u as useScreenSize } from './useScreenSize-9091e971.js';
31
- import { createPortal } from 'react-dom';
32
- import { css } from '@emotion/react';
30
+ import { parsePhoneNumber } from 'react-phone-number-input';
33
31
  import styled from '@emotion/styled';
34
32
  import { theme } from './miscTheme.js';
35
- import { B as Button$2 } from './index-0823f05f.js';
36
- import { C as Close } from './Close-c3a49880.js';
33
+ import { css } from '@emotion/react';
34
+ import { T as TogetherComponentGlobalContext } from './utils-a6705915.js';
35
+ import { i as isVideo } from './index-4afb0581.js';
36
+ import { D as DrawerComponent } from './index-d5dfbc30.js';
37
+ import { u as useScreenSize } from './useScreenSize-b097bc99.js';
38
+ import { createPortal } from 'react-dom';
39
+ import { B as Button$2 } from './index-202a8ced.js';
40
+ import { I as InputDate } from './InputDate-53408741.js';
41
+ import { C as Close } from './Close-bed66153.js';
37
42
  import '@hhgtech/icons/other';
38
43
  import '@mantine/carousel';
39
- import './Locale-3e2786ee.js';
40
44
  import 'classnames';
41
- import './useUniqueId-5ba39dd0.js';
45
+ import './useUniqueId-fa696ba6.js';
42
46
  import './constantsSite.js';
43
47
  import '@hhgtech/icons/core';
44
48
  import '@mantine/notifications';
@@ -46,6 +50,22 @@ import './constantsDomainLocales.js';
46
50
  import './constantsIsProduction.js';
47
51
  import 'date-fns/locale';
48
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-cd80d854.js';
65
+ import 'slugify';
66
+ import 'string-format';
67
+ import './togetherApiPaths.js';
68
+ import './constants-341374a3.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,7 +844,7 @@ const Description = (_a) => {
673
844
  return description ? (React__default.createElement(Text, Object.assign({ size: "p3" }, rest), description)) : null;
674
845
  };
675
846
 
676
- const LeadGenContext = createContext({});
847
+ const LeadGenContext$1 = createContext({});
677
848
 
678
849
  var useStyles$2 = createStyles(() => {
679
850
  return {
@@ -737,7 +908,7 @@ const SubtitleBlock$1 = ({ children, align, }) => (React__default.createElement(
737
908
  const TitleBlock$1 = ({ children, align, }) => (React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
738
909
 
739
910
  const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, popoverProps, }) => {
740
- const { primaryColor } = useContext(LeadGenContext);
911
+ const { primaryColor } = useContext(LeadGenContext$1);
741
912
  const { classes, cx } = useStyles$2(undefined, {
742
913
  name: 'LeadGen__Field',
743
914
  styles,
@@ -852,7 +1023,7 @@ const Heading = (_a) => {
852
1023
 
853
1024
  const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps, submitProps, }) => {
854
1025
  var _a;
855
- const { primaryColor } = useContext(LeadGenContext);
1026
+ const { primaryColor } = useContext(LeadGenContext$1);
856
1027
  const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, setFormRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = useContext(LeadGenComponentContext);
857
1028
  const { classes, cx } = useStyles$1(undefined, {
858
1029
  name: 'LeadGen__FormComponent',
@@ -1129,6 +1300,7 @@ var enPH = {
1129
1300
  "validator.min": "jQuery.validator.format('Please enter a value greater than or equal to {0}.",
1130
1301
  "validator.emailUsed": "Email already in use for this campaign.",
1131
1302
  "validator.phoneUsed": "Your phone number already in use for this campaign.",
1303
+ "validator.dateInvalid": "This date is not valid, please update.",
1132
1304
  "lead.otp.title": "Enter OTP",
1133
1305
  "lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
1134
1306
  "lead.otp.verify": "Verify",
@@ -1137,7 +1309,10 @@ var enPH = {
1137
1309
  "lead.otp.phonePlaceholder": "Enter OTP",
1138
1310
  "lead.empty.title": "Oops, seem your information is empty, do you want to submit the information again?",
1139
1311
  "lead.empty.cancel": "Cancel",
1140
- "lead.empty.submitAgain": "Submit again"
1312
+ "lead.empty.submitAgain": "Submit again",
1313
+ "common.day": "Day",
1314
+ "common.month": "Month",
1315
+ "common.year": "Year"
1141
1316
  };
1142
1317
 
1143
1318
  var hiIN = {
@@ -1148,6 +1323,7 @@ var hiIN = {
1148
1323
  "validator.maxlength": "कृपया {0} अक्षर से अधिक दर्ज न करें",
1149
1324
  "validator.minlength": "कृपया कम से कम {0} अक्षर दर्ज करें",
1150
1325
  "validator.phone": "कृपया एक वैध संख्या दर्ज करें",
1326
+ "validator.dateInvalid": "यह तिथि मान्य नहीं है, कृपया अपडेट करें।",
1151
1327
  "validator.emailUsed": "Email already in use for this campaign.",
1152
1328
  "validator.phoneUsed": "Your phone number already in use for this campaign.",
1153
1329
  "lead.otp.title": "Enter OTP",
@@ -1156,7 +1332,10 @@ var hiIN = {
1156
1332
  "lead.otp.resend": "Resend OTP{timer}",
1157
1333
  "lead.empty.title": "ऊप्स! लगता है आपकी जानकारी खाली है। क्या आप जानकारी फिर से सबमिट करना चाहते हैं?",
1158
1334
  "lead.empty.cancel": "रद्द करें",
1159
- "lead.empty.submitAgain": "फिर से सबमिट करें"
1335
+ "lead.empty.submitAgain": "फिर से सबमिट करें",
1336
+ "common.day": "साल",
1337
+ "common.month": "महीना",
1338
+ "common.year": ""
1160
1339
  };
1161
1340
 
1162
1341
  var idID = {
@@ -1169,6 +1348,7 @@ var idID = {
1169
1348
  "validator.phone": "Tolong daftarkan nomor telepon yang valid",
1170
1349
  "validator.emailUsed": "Email sudah digunakan untuk kampanye ini.",
1171
1350
  "validator.phoneUsed": "Nomor telepon Anda sudah digunakan untuk kampanye ini.",
1351
+ "validator.dateInvalid": "Tanggal ini tidak valid, silakan perbarui",
1172
1352
  "lead.otp.title": "Masukkan OTP",
1173
1353
  "lead.otp.desc": "Kami telah mengirimkan OTP ke nomor ponsel Anda {phone}",
1174
1354
  "lead.otp.verify": "Verifikasi",
@@ -1177,7 +1357,10 @@ var idID = {
1177
1357
  "lead.otp.phonePlaceholder": "Masukkan OTP",
1178
1358
  "lead.empty.title": "Oops, sepertinya informasi Anda kosong. Apakah Anda ingin mengirimkan informasi lagi?",
1179
1359
  "lead.empty.cancel": "Batal",
1180
- "lead.empty.submitAgain": "Kirim lagi"
1360
+ "lead.empty.submitAgain": "Kirim lagi",
1361
+ "common.day": "Hari",
1362
+ "common.month": "Bulan",
1363
+ "common.year": "Tahun"
1181
1364
  };
1182
1365
 
1183
1366
  var kmKH = {
@@ -1190,6 +1373,7 @@ var kmKH = {
1190
1373
  "validator.phone": "សូម​វាយបញ្ចូល​លេខ​ឲ្យ​បាន​ត្រឹមត្រូវ",
1191
1374
  "validator.emailUsed": "អ៊ីមែលត្រូវបានប្រើប្រាស់សម្រាប់យុទ្ធនាការនេះរួចហើយ។",
1192
1375
  "validator.phoneUsed": "លេខទូរស័ព្ទរបស់អ្នកត្រូវបានប្រើប្រាស់សម្រាប់យុទ្ធនាការនេះរួចហើយ។",
1376
+ "validator.dateInvalid": "កាលបរិច្ឆេទនេះមិនត្រឹមត្រូវទេ សូមធ្វើបច្ចុប្បន្នភាព។",
1193
1377
  "lead.otp.title": "បញ្ចូល OTP",
1194
1378
  "lead.otp.desc": "យើងបានផ្ញើ OTP ទៅកាន់លេខទូរសព្ទរបស់អ្នក {phone}",
1195
1379
  "lead.otp.verify": "ផ្ទៀងផ្ទាត់",
@@ -1198,7 +1382,10 @@ var kmKH = {
1198
1382
  "lead.otp.phonePlaceholder": "បញ្ចូល OTP",
1199
1383
  "lead.empty.title": "អូុបស! ហាក់ដូចជាព័ត៌មានរបស់អ្នកទទេ។ តើអ្នកចង់ដាក់ស្នើព័ត៌មានម្តងទៀតទេ?",
1200
1384
  "lead.empty.cancel": "លុប​ចោល",
1201
- "lead.empty.submitAgain": "ដាក់ស្នើម្ដងទៀត"
1385
+ "lead.empty.submitAgain": "ដាក់ស្នើម្ដងទៀត",
1386
+ "common.day": "ឆ្នាំ",
1387
+ "common.month": "ខែ",
1388
+ "common.year": "ថ្ងៃ"
1202
1389
  };
1203
1390
 
1204
1391
  var msMY = {
@@ -1211,6 +1398,7 @@ var msMY = {
1211
1398
  "validator.phone": "Sila masukkan no telefon yang sah.",
1212
1399
  "validator.emailUsed": "Emel sudah digunakan untuk kempen ini.",
1213
1400
  "validator.phoneUsed": "Nombor telefon anda sudah digunakan untuk kempen ini.",
1401
+ "validator.dateInvalid": "Tarikh ini tidak sah, sila kemas kini",
1214
1402
  "lead.otp.title": "Masukkan OTP",
1215
1403
  "lead.otp.desc": "Kami telah menghantar OTP ke nombor telefon bimbit anda {phone}",
1216
1404
  "lead.otp.verify": "Sahkan",
@@ -1219,7 +1407,10 @@ var msMY = {
1219
1407
  "lead.otp.phonePlaceholder": "Masukkan OTP",
1220
1408
  "lead.empty.title": "Oops, nampaknya maklumat anda kosong. Adakah anda ingin menghantar maklumat semula?",
1221
1409
  "lead.empty.cancel": "Batal",
1222
- "lead.empty.submitAgain": "Hantar semula"
1410
+ "lead.empty.submitAgain": "Hantar semula",
1411
+ "common.day": "Hari",
1412
+ "common.month": "Bulan",
1413
+ "common.year": "Tahun"
1223
1414
  };
1224
1415
 
1225
1416
  var myMM = {
@@ -1232,6 +1423,7 @@ var myMM = {
1232
1423
  "validator.phone": "မှန်ကန်သော ဖုန်းနံပါတ်ထည့်သွင်းပါ",
1233
1424
  "validator.emailUsed": "ဤအေကာင့်အတွက် အီးမေးလ်ကို အသုံးပြုပြီးဖြစ်ပါသည်။",
1234
1425
  "validator.phoneUsed": "ဤအေကာင့်အတွက် သင့်ဖုန်းနံပါတ်ကို အသုံးပြုပြီးဖြစ်ပါသည်။",
1426
+ "validator.dateInvalid": "ယနေ့စွဲမှားနေသည်၊ ကျေးဇူးပြု၍ ပြင်ဆင်ပါ။",
1235
1427
  "lead.otp.title": "OTP ကိုထည့်ပါ",
1236
1428
  "lead.otp.desc": "ကျွန်ုပ်တို့သည် OTP ကိုသင့်ဖုန်းနံပါတ် {phone} သို့ပို့ခဲ့သည်",
1237
1429
  "lead.otp.verify": "အတည်ပြုပါ",
@@ -1240,7 +1432,10 @@ var myMM = {
1240
1432
  "lead.otp.phonePlaceholder": "OTP ကိုထည့်ပါ",
1241
1433
  "lead.empty.title": "အုပ်စ်! သင့်အချက်အလက်သည် ဗလာဖြစ်နေသလိုဖြစ်သည်။ ထပ်မံတင်သွင်းလိုပါသလား?",
1242
1434
  "lead.empty.cancel": "မလုပ်ဆောင်ပါ",
1243
- "lead.empty.submitAgain": "ထပ်မံတင်သွင်းပါ"
1435
+ "lead.empty.submitAgain": "ထပ်မံတင်သွင်းပါ",
1436
+ "common.day": "ရက်",
1437
+ "common.month": "လ",
1438
+ "common.year": "နှစ်"
1244
1439
  };
1245
1440
 
1246
1441
  var thTH = {
@@ -1253,6 +1448,7 @@ var thTH = {
1253
1448
  "validator.phone": "กรุณาใส่ตัวเลขที่ถูกต้อง",
1254
1449
  "validator.emailUsed": "อีเมลนี้ถูกใช้สำหรับแคมเปญนี้แล้ว",
1255
1450
  "validator.phoneUsed": "หมายเลขโทรศัพท์ของคุณถูกใช้สำหรับแคมเปญนี้แล้ว",
1451
+ "validator.dateInvalid": "วันที่นี้ไม่ถูกต้อง โปรดอัปเดต",
1256
1452
  "lead.otp.title": "ป้อน OTP",
1257
1453
  "lead.otp.desc": "เราได้ส่ง OTP ไปยังหมายเลขโทรศัพท์มือถือของคุณ {phone}",
1258
1454
  "lead.otp.verify": "ยืนยัน",
@@ -1261,7 +1457,10 @@ var thTH = {
1261
1457
  "lead.otp.phonePlaceholder": "ป้อน OTP",
1262
1458
  "lead.empty.title": "อุ๊ปส์! ดูเหมือนว่าข้อมูลของคุณว่างเปล่า คุณต้องการส่งข้อมูลอีกครั้งหรือไม่?",
1263
1459
  "lead.empty.cancel": "ยกเลิก",
1264
- "lead.empty.submitAgain": "ส่งอีกครั้ง"
1460
+ "lead.empty.submitAgain": "ส่งอีกครั้ง",
1461
+ "common.day": "วัน",
1462
+ "common.month": "เดือน",
1463
+ "common.year": "ปี"
1265
1464
  };
1266
1465
 
1267
1466
  var viVN = {
@@ -1285,6 +1484,7 @@ var viVN = {
1285
1484
  "validator.phone": "Nhập đúng định dạng số điện thoại",
1286
1485
  "validator.emailUsed": "Email này đã được sử dụng.",
1287
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.",
1288
1488
  "lead.otp.title": "Nhập OTP",
1289
1489
  "lead.otp.desc": "Chúng tôi đã gửi OTP đến số điện thoại của bạn {phone}",
1290
1490
  "lead.otp.verify": "Xác minh",
@@ -1293,7 +1493,10 @@ var viVN = {
1293
1493
  "lead.otp.phonePlaceholder": "Nhập OTP",
1294
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?",
1295
1495
  "lead.empty.cancel": "Hủy",
1296
- "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"
1297
1500
  };
1298
1501
 
1299
1502
  var zhTW = {
@@ -1306,6 +1509,7 @@ var zhTW = {
1306
1509
  "validator.phone": "請填入有效的電話號碼",
1307
1510
  "validator.emailUsed": "此電子郵件已被使用於此活動。",
1308
1511
  "validator.phoneUsed": "您的手機號碼已被使用於此活動。",
1512
+ "validator.dateInvalid": "此日期無效,請更新.",
1309
1513
  "lead.otp.title": "輸入 OTP",
1310
1514
  "lead.otp.desc": "我們已將 OTP 發送到您的手機號碼 {phone}",
1311
1515
  "lead.otp.verify": "驗證",
@@ -1314,7 +1518,10 @@ var zhTW = {
1314
1518
  "lead.otp.phonePlaceholder": "輸入 OTP",
1315
1519
  "lead.empty.title": "哎呀,您的資訊似乎是空的,您想要重新提交資訊嗎?",
1316
1520
  "lead.empty.cancel": "取消",
1317
- "lead.empty.submitAgain": "重新提交"
1521
+ "lead.empty.submitAgain": "重新提交",
1522
+ "common.day": "日",
1523
+ "common.month": "月",
1524
+ "common.year": "年"
1318
1525
  };
1319
1526
 
1320
1527
  const translationsMap = {
@@ -1326,165 +1533,1689 @@ const translationsMap = {
1326
1533
  'my-MM': myMM,
1327
1534
  'km-KH': kmKH,
1328
1535
  'zh-TW': zhTW,
1536
+ 'zh-CN': zhTW,
1329
1537
  'th-TH': thTH,
1330
1538
  'tl-PH': enPH,
1331
1539
  };
1332
1540
  const getTranslations = (locale) => {
1333
- const translations = translationsMap[locale];
1541
+ const translations = Object.assign(Object.assign({}, translationsMap$1[locale]), translationsMap[locale]);
1334
1542
  if (translations) {
1335
1543
  return translations;
1336
1544
  }
1337
1545
  return translationsMap['en-PH'];
1338
1546
  };
1339
1547
 
1340
- const useImageSize = (src) => {
1341
- const [width, setWidth] = useState(16);
1342
- const [height, setHeight] = useState(9);
1343
- const [loaded, setLoaded] = useState(false);
1344
- // load src image to get its width and height
1345
- useEffect(() => {
1346
- setLoaded(false);
1347
- if (src) {
1348
- const img = new Image();
1349
- img.addEventListener('load', () => {
1350
- setWidth(img.naturalWidth);
1351
- setHeight(img.naturalHeight);
1352
- setLoaded(true);
1353
- });
1354
- img.addEventListener('error', () => {
1355
- setWidth(16);
1356
- setHeight(9);
1357
- setLoaded(true);
1358
- });
1359
- img.src = src;
1360
- }
1361
- else {
1362
- setWidth(16);
1363
- setHeight(9);
1364
- setLoaded(true);
1365
- }
1366
- }, [src]);
1367
- return {
1368
- loaded,
1369
- width,
1370
- height,
1371
- };
1372
- };
1373
-
1374
- const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default.createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
1375
- React__default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
1376
- 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" }))));
1377
-
1378
- // url: imageBlocks.imageMobile.data.url
1379
- // newTab: imageBlocks.imageMobile.data.newtab
1380
- // imageMobile: campaignShow.image
1381
- // imageDestkop: campaignShow.image_desktop
1382
- const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
1383
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1384
- const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
1385
- if (!imageMobileLoaded || !imageDestkopLoaded)
1386
- return null;
1387
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
1388
- React__default.createElement("div", { className: "le-center-tab-popup" },
1389
- React__default.createElement("div", { style: { position: 'relative' } },
1390
- React__default.createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
1391
- isVideo(imageMobile) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
1392
- React__default.createElement("source", { src: imageMobile }))) : (React__default.createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
1393
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1394
- } })),
1395
- isVideo(imageDestkop) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
1396
- React__default.createElement("source", { src: imageDestkop }))) : (React__default.createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
1397
- aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
1398
- } }))),
1399
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
1400
- };
1401
-
1402
- // title: titleText
1403
- // titleAlign: textBlocks.titleBlock.data.align
1404
- // subtitle: textBlocks.subtitleBlock.data.value
1405
- // subtitleAlign: textBlocks.subtitleBlock.data.align
1406
- // url: actionBlocks.linkButtonBlock.data.url
1407
- // urlText: actionBlocks.linkButtonBlock.data.value
1408
- // newTab: actionBlocks.linkButtonBlock.data.newtab
1409
- // imageMobile: campaignShow.image
1410
- // imageDesktop: campaignShow.image_desktop
1411
- const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
1412
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1413
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
1414
- if (!imageMobileLoaded || !imageDesktopLoaded)
1415
- return null;
1416
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
1417
- React__default.createElement("aside", { className: "le-only-desktop" },
1418
- React__default.createElement("div", { className: "le-floating-desktop" },
1419
- React__default.createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
1420
- imageDesktop ? (React__default.createElement("div", null,
1421
- React__default.createElement("img", { style: {
1422
- maxWidth: 120,
1423
- borderTopLeftRadius: 5,
1424
- borderBottomLeftRadius: 5,
1425
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
1426
- }, src: imageDesktop }))) : null,
1427
- React__default.createElement("div", { style: { padding: 20 } },
1428
- React__default.createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
1429
- React__default.createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
1430
- React__default.createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
1431
- React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
1432
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
1433
- React__default.createElement("aside", { className: "le-only-mobile" },
1434
- React__default.createElement("div", { className: "le-floating-mobile" },
1435
- React__default.createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
1436
- React__default.createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
1437
- React__default.createElement("div", null,
1438
- React__default.createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
1439
- React__default.createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
1440
- imageMobile ? (React__default.createElement("div", null,
1441
- React__default.createElement("img", { style: {
1442
- marginLeft: 15,
1443
- marginTop: 4,
1444
- maxWidth: 100,
1445
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1446
- }, src: imageMobile }))) : null),
1447
- React__default.createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
1448
- React__default.createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
1449
- React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
1450
- 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));
1451
1552
  };
1452
1553
 
1453
- const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
1454
- const { primaryColor } = useContext(LeadGenContext);
1455
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
1456
- 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) {
1457
1588
  return null;
1458
- return (React__default.createElement("div", { className: "lead-modal__thank-you leadgen-inner_thankyou" },
1459
- React__default.createElement("div", { style: { width: '100%' } },
1460
- React__default.createElement("img", { src: image, style: {
1461
- maxHeight: 162,
1462
- objectFit: 'cover',
1463
- aspectRatio: `${imageWidth}/${imageHeight}`,
1464
- }, loading: "lazy" }),
1465
- title && (React__default.createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
1466
- subtitle && (React__default.createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle.split('\n').map((text, idx, list) => {
1467
- const isShowBr = idx < list.length - 1;
1468
- return (React__default.createElement(React__default.Fragment, null,
1469
- text,
1470
- isShowBr && React__default.createElement("br", null)));
1471
- }))),
1472
- linkText && (React__default.createElement("div", null,
1473
- React__default.createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
1474
- React__default.createElement(Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
1475
- };
1476
-
1477
- const InlineLayout = ({ content, inlinePosition, }) => {
1478
- const target = useMemo(() => {
1479
- if (!inlinePosition)
1480
- return null;
1481
- const parents = document.querySelectorAll(`[data-url="${location.pathname}"] .body-content`);
1482
- const allChildren = Array.from(parents).reduce((r, p) => {
1483
- return [...r, ...Array.from(p.children)];
1484
- }, []);
1485
- if (allChildren === null || allChildren === void 0 ? void 0 : allChildren.length) {
1486
- // find the third p tag in the body content, some other tags might mix in between
1487
- const allPTags = allChildren.filter((c) => c.nodeName === 'P');
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
+ setSubscriptionInfo({
2015
+ subscriptionIcon: icon,
2016
+ subscriptionTitle: content,
2017
+ });
2018
+ if (campaign_code) {
2019
+ fetchCampaign(campaign_code);
2020
+ }
2021
+ });
2022
+ return;
2023
+ }
2024
+ if (campaignCodeProps) {
2025
+ fetchCampaign(campaignCodeProps);
2026
+ }
2027
+ }, [campaignCodeProps, categoryId]);
2028
+ useEffect(() => {
2029
+ leadStore.apiSsoUrl = apiSsoUrl;
2030
+ leadStore.apiLeadUrl = apiLeadUrl;
2031
+ leadStore.apiSubotUrl = apiSubotUrl;
2032
+ }, [apiLeadUrl, apiSubotUrl, apiSsoUrl]);
2033
+ if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
2034
+ return null;
2035
+ }
2036
+ return (React__default.createElement(LeadGenContext.Provider, { value: Object.assign(Object.assign(Object.assign({}, leadGenContextValue), subscriptionInfo), { submit,
2037
+ submitSubscriptionBox,
2038
+ impression }) },
2039
+ React__default.createElement(LeadGenTranslationProvider, { locale: locale }, children)));
2040
+ };
2041
+ const useLeadGenContext = () => {
2042
+ const context = useContext(LeadGenContext);
2043
+ return Object.assign(Object.assign({}, context), { apiLeadUrl: context.apiLeadUrl || leadStore.apiLeadUrl, apiSubotUrl: context.apiSubotUrl || leadStore.apiSubotUrl });
2044
+ };
2045
+
2046
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
2047
+ const customParseFormat = require('dayjs/plugin/customParseFormat');
2048
+ dayjs.extend(customParseFormat);
2049
+ // You can give context variables any name
2050
+ const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
2051
+ const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
2052
+ var _a;
2053
+ const { t } = useTranslations();
2054
+ const initialValues = useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
2055
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[(_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.lang] ||
2056
+ LEAD_LOCALE_DATA['vi-VN'];
2057
+ const validateObj = useMemo(() => {
2058
+ const InputBlocks = [
2059
+ 'TextBlock',
2060
+ 'NumberBlock',
2061
+ 'EmailBlock',
2062
+ 'PhoneBlock',
2063
+ 'DateBlock',
2064
+ 'CheckboxBlock',
2065
+ 'RadioBlock',
2066
+ 'DropdownBlock',
2067
+ 'PhoneOtpBlock',
2068
+ 'WhatsappOtpBlock',
2069
+ 'ZaloOtpBlock',
2070
+ 'LocationBlock',
2071
+ 'TncBlock',
2072
+ ];
2073
+ // ALL are required and can skip if not touched yet
2074
+ const withSharedCheck = (name, cb,
2075
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2076
+ block) => {
2077
+ return (value) => {
2078
+ var _a;
2079
+ const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
2080
+ if (!formRef.current.isTouched(name))
2081
+ return;
2082
+ if ((typeof value === 'string' && value.trim() === '') ||
2083
+ typeof value === 'undefined' ||
2084
+ (Array.isArray(value) && value.length === 0)) {
2085
+ return isBLockRequired
2086
+ ? t('validator.required')
2087
+ : cb === null || cb === void 0 ? void 0 : cb(value);
2088
+ }
2089
+ return cb === null || cb === void 0 ? void 0 : cb(value);
2090
+ };
2091
+ };
2092
+ return listBlockAdded
2093
+ .filter((b) => InputBlocks.includes(b.name))
2094
+ .reduce((r, b) => {
2095
+ const { name: fieldType, data } = b || {};
2096
+ const { value: fieldName, required } = data || {};
2097
+ const isRequired = required !== null && required !== void 0 ? required : true;
2098
+ if (fieldType === 'NumberBlock') {
2099
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2100
+ if (value && isNaN(Number(value))) {
2101
+ return t('validator.number');
2102
+ }
2103
+ }, b) });
2104
+ }
2105
+ else if (fieldType === 'EmailBlock') {
2106
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2107
+ if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
2108
+ return t('validator.email');
2109
+ }
2110
+ if (!value)
2111
+ return;
2112
+ validatingEmailRef.current = true;
2113
+ setTimeout(() => {
2114
+ formRef.current.setFieldError(fieldName, 'Validating...');
2115
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2116
+ email: value,
2117
+ })
2118
+ .then((tKey) => {
2119
+ if (tKey) {
2120
+ formRef.current.setFieldError(fieldName, t(tKey));
2121
+ }
2122
+ else {
2123
+ formRef.current.clearFieldError(fieldName);
2124
+ }
2125
+ validatingEmailRef.current = false;
2126
+ })
2127
+ .catch((e) => {
2128
+ console.error(e);
2129
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2130
+ validatingEmailRef.current = false;
2131
+ });
2132
+ }, 200);
2133
+ }, b) });
2134
+ }
2135
+ else if (fieldType === 'PhoneBlock' ||
2136
+ fieldType === 'PhoneOtpBlock' ||
2137
+ fieldType === 'ZaloOtpBlock' ||
2138
+ fieldType === 'WhatsappOtpBlock') {
2139
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2140
+ if (value &&
2141
+ window.intlTelInputUtils &&
2142
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
2143
+ return t('validator.phone');
2144
+ }
2145
+ if (!value)
2146
+ return;
2147
+ validatingPhoneRef.current = true;
2148
+ setTimeout(() => {
2149
+ formRef.current.setFieldError(fieldName, 'Validating...');
2150
+ if (b.data.singleSubmission) {
2151
+ checkUsedPhoneOnlyWithCache(campaignId, value)
2152
+ .then((tKey) => {
2153
+ if (tKey) {
2154
+ formRef.current.setFieldError(fieldName, t(tKey));
2155
+ }
2156
+ else {
2157
+ formRef.current.clearFieldError(fieldName);
2158
+ }
2159
+ validatingPhoneRef.current = false;
2160
+ })
2161
+ .catch((err) => {
2162
+ console.error(err);
2163
+ formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
2164
+ validatingPhoneRef.current = false;
2165
+ });
2166
+ }
2167
+ else {
2168
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2169
+ phone: value,
2170
+ })
2171
+ .then((tKey) => {
2172
+ if (tKey) {
2173
+ formRef.current.setFieldError(fieldName, t(tKey));
2174
+ }
2175
+ else {
2176
+ formRef.current.clearFieldError(fieldName);
2177
+ }
2178
+ validatingPhoneRef.current = false;
2179
+ })
2180
+ .catch((e) => {
2181
+ console.error(e);
2182
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2183
+ validatingPhoneRef.current = false;
2184
+ });
2185
+ }
2186
+ }, 200);
2187
+ }, b) });
2188
+ }
2189
+ else if (fieldType === 'DateBlock') {
2190
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2191
+ if (!isRequired && !value) {
2192
+ return;
2193
+ }
2194
+ const errMsg = t('validator.dateInvalid');
2195
+ const dayInJS = typeof value === 'string'
2196
+ ? dayjs(value, format, true)
2197
+ : dayjs(value);
2198
+ if (!dayInJS.isValid()) {
2199
+ return errMsg;
2200
+ }
2201
+ }, b) });
2202
+ }
2203
+ else if (fieldType === 'TncBlock') {
2204
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
2205
+ if (isRequired && !value) {
2206
+ return t('validator.required');
2207
+ }
2208
+ }, b) });
2209
+ }
2210
+ else {
2211
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
2212
+ }
2213
+ }, {});
2214
+ }, [listBlockAdded.map((b) => b.name).join(','), format]);
2215
+ const form = useLeadForm({
2216
+ validateInputOnChange: true,
2217
+ validateInputOnBlur: true,
2218
+ clearInputErrorOnChange: true,
2219
+ validate: validateObj,
2220
+ initialValues,
2221
+ });
2222
+ const formRef = useRef(form);
2223
+ formRef.current = form;
2224
+ return { form, validateObj };
2225
+ };
2226
+
2227
+ const StyledLeadGenThankYou = styled.div `
2228
+ display: flex;
2229
+ gap: 8px;
2230
+ flex-direction: column;
2231
+ padding-block: 24px;
2232
+
2233
+ .leadgen-image {
2234
+ width: 120px;
2235
+ height: 120px;
2236
+ margin-inline: auto;
2237
+ object-fit: contain;
2238
+ object-position: center;
2239
+ text-align: center;
2240
+ }
2241
+
2242
+ .leadgen-title {
2243
+ margin-block: 0;
2244
+ color: ${theme.colors.gray900};
2245
+ font-weight: 700;
2246
+ font-size: 18px;
2247
+ line-height: 28px;
2248
+ letter-spacing: -0.2px;
2249
+ }
2250
+
2251
+ .leadgen-description {
2252
+ margin-block: 0;
2253
+ color: ${theme.colors.gray600};
2254
+ font-weight: 400;
2255
+ font-size: 14px;
2256
+ line-height: 22px;
2257
+ letter-spacing: -0.2px;
2258
+ text-align: center;
2259
+ }
2260
+
2261
+ > [data-align] {
2262
+ &[data-align='right'] {
2263
+ text-align: right;
2264
+ }
2265
+ &[data-align='center'] {
2266
+ text-align: center;
2267
+ }
2268
+ }
2269
+ `;
2270
+ const LeadGenThankYou = ({ image, title, description, showButton = false, button, className, style, }) => {
2271
+ const { src } = image;
2272
+ const { htmlText: titleText, align: titleAlign } = title;
2273
+ const { htmlText: descriptionText, align: descriptionAlign } = description;
2274
+ const { htmlText: buttonText, newtab, url, onClick } = button;
2275
+ return (React__default.createElement(StyledLeadGenThankYou, { className: className, style: style },
2276
+ React__default.createElement("img", { src: src, alt: "", className: "leadgen-thankyou_image leadgen-image" }),
2277
+ React__default.createElement("p", { className: "leadgen-thankyou_title leadgen-title", "data-align": titleAlign }, titleText),
2278
+ React__default.createElement("p", { className: "leadgen-thankyou_description leadgen-description", "data-align": descriptionAlign }, descriptionText),
2279
+ !!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))));
2280
+ };
2281
+
2282
+ const StyledLeadGenSubscriptionBoxBody = styled.div `
2283
+ margin-top: 16px;
2284
+ .leadgen-btn {
2285
+ margin-top: 16px;
2286
+ }
2287
+ `;
2288
+ const StyledLeadGenSubscriptionBoxHeaderImage = styled.div `
2289
+ margin-top: 3px;
2290
+ margin-right: 20px;
2291
+ width: 44px;
2292
+ height: 44px;
2293
+
2294
+ img {
2295
+ width: 100%;
2296
+ height: 100%;
2297
+ object-fix: contain;
2298
+ onject-position: center;
2299
+ }
2300
+
2301
+ :has(img[src='']) {
2302
+ display: none;
2303
+ }
2304
+ `;
2305
+ const StyledLeadGenSubscriptionBoxHeader = styled.div `
2306
+ display: flex;
2307
+ align-items: center;
2308
+ margin-bottom: 16px;
2309
+ .leadgen-title {
2310
+ margin-bottom: 0;
2311
+ flex: 1;
2312
+ min-width: 0;
2313
+ color: ${theme.colors.gray900};
2314
+ font-size: 18px;
2315
+ font-weight: 400;
2316
+ line-height: 1.4;
2317
+ letter-spacing: -0.8px;
2318
+ }
2319
+ `;
2320
+ const StyledLeadGenSubscriptionBox = styled.div `
2321
+ padding: 16px;
2322
+ border: 1px solid ${theme.colors.neutral100};
2323
+ border-radius: 12px;
2324
+ margin-inline: auto;
2325
+ .leadgen-form_inputs {
2326
+ .leadgen-form_input {
2327
+ width: 100%;
2328
+ }
2329
+ }
2330
+
2331
+ .leadgen-form_input {
2332
+ .mantine-Input-wrapper {
2333
+ max-height: 56px;
2334
+ }
2335
+ }
2336
+
2337
+ @media screen and (min-width: 768px) {
2338
+ .leadgen-subscription_box_body {
2339
+ display: flex;
2340
+ > form {
2341
+ flex: 1;
2342
+ min-width: 0;
2343
+
2344
+ .leadgen-form_inputs {
2345
+ .leadgen-form_input {
2346
+ width: calc(50% - 4px);
2347
+ }
2348
+ }
2349
+ }
2350
+
2351
+ .leadgen-btn {
2352
+ margin-top: 0;
2353
+ margin-left: 8px;
2354
+ width: auto;
2355
+ min-height: 56px;
2356
+ }
2357
+ }
2358
+ }
2359
+ `;
2360
+ const StyledLeadGenSubscriptionBoxA = styled.div `
2361
+ .leadgen-form_input {
2362
+ --phone-select: 45px;
2363
+ .PhoneInput {
2364
+ --phone-select: 45px;
2365
+ .PhoneInputCountry {
2366
+ margin-top: 1px;
2367
+ pointer-events: none;
2368
+ .PhoneInputCountryIconImg,
2369
+ .PhoneInputArrowContainer {
2370
+ display: none;
2371
+ }
2372
+ }
2373
+ }
2374
+ }
2375
+ `;
2376
+
2377
+ const PhoneInput = forwardRef((props, ref) => {
2378
+ 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"]);
2379
+ const id = idProps || v1() + name;
2380
+ 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 },
2381
+ React__default.createElement("div", { className: "mantine-Input-wrapper" },
2382
+ 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" })))));
2383
+ });
2384
+
2385
+ const formatLeadGenFormValue = (values, blocks) => {
2386
+ const newValues = {};
2387
+ for (const block of blocks) {
2388
+ const { data } = block || {};
2389
+ const { value: fieldName } = data || {};
2390
+ if (fieldName in values) {
2391
+ newValues[fieldName] = values[fieldName];
2392
+ }
2393
+ }
2394
+ return newValues;
2395
+ };
2396
+
2397
+ const StyledLeadGenFormInner = styled.div `
2398
+ display: flex;
2399
+ flex-wrap: wrap;
2400
+ gap: 8px;
2401
+ .leadgen-form_input {
2402
+ width: calc(50% - 4px);
2403
+ }
2404
+
2405
+ .leadgen-form_input_checkbox {
2406
+ width: 100%;
2407
+ }
2408
+ `;
2409
+
2410
+ const cssInputNotShrink$1 = css `
2411
+ height: 100% !important;
2412
+ min-height: calc(var(--container-height, 56px) * 22 / 56);
2413
+ color: ${theme.colors.gray800};
2414
+ font-size: var(--input, 16px);
2415
+ line-height: calc(var(--container-height, 56px) * 22 / 56);
2416
+ border: none !important;
2417
+ border-radius: 0 !important;
2418
+ outline: none !important;
2419
+ box-shadow: none !important;
2420
+ padding: 0;
2421
+ cursor: pointer;
2422
+ opacity: 0;
2423
+
2424
+ ::placeholder {
2425
+ color: ${theme.colors.gray400};
2426
+ }
2427
+ `;
2428
+ const cssInputShrink$1 = css `
2429
+ height: auto !important;
2430
+ cursor: text;
2431
+ opacity: 1;
2432
+ transition: 0.1s ease-in-out all;
2433
+ `;
2434
+ const cssLabelNotShrink$1 = css `
2435
+ position: absolute;
2436
+ top: calc(var(--container-height) / 2);
2437
+ left: var(--space-x, 16px);
2438
+ color: ${theme.colors.gray400};
2439
+ font-size: var(--label-not-shrink, 16px);
2440
+ font-weight: 400;
2441
+ line-height: calc(var(--container-height, 56px) * 18 / 56);
2442
+ margin: 0;
2443
+ z-index: 1;
2444
+ cursor: pointer;
2445
+ transform: translateY(-50%);
2446
+ transition: 0.125s ease-in all;
2447
+ `;
2448
+ const cssLabelShrink$1 = css `
2449
+ color: ${theme.colors.gray600};
2450
+ font-weight: 600;
2451
+ font-size: var(--label-shrink, 12px);
2452
+ top: calc(var(--container-height) * 7 / 56);
2453
+ transform: none;
2454
+ transition: 0.125s ease-out all;
2455
+ `;
2456
+ const cssWrapperInputNotShrink$1 = css `
2457
+ min-height: var(--container-height, 56px);
2458
+ display: flex;
2459
+ align-items: flex-end;
2460
+ border: 1px solid ${theme.colors.gray200};
2461
+ border-radius: 8px;
2462
+ background-color: #fff;
2463
+ padding-inline: var(--space-x, 16px);
2464
+ padding-block: var(--space-y-not-shrink, 16px);
2465
+ cursor: pointer;
2466
+ pointer-events: none;
2467
+
2468
+ &:has(.mantine-Input-rightSection) {
2469
+ padding-right: var(--container-height, 56px);
2470
+ }
2471
+
2472
+ .mantine-Input-icon {
2473
+ display: none;
2474
+ }
2475
+
2476
+ .mantine-NumberInput-control {
2477
+ border-color: ${theme.colors.gray200};
2478
+ }
2479
+ `;
2480
+ const cssWrapperInputShrink$1 = css `
2481
+ height: auto;
2482
+ min-height: var(--container-height, 56px);
2483
+ padding-block: var(--space-y-shrink, 7px);
2484
+ cursor: text;
2485
+ pointer-events: auto;
2486
+ `;
2487
+ const cssInputWrapperError$1 = css `
2488
+ color: ${theme.colors.red800};
2489
+ font-size: 12px;
2490
+ line-height: 1.5;
2491
+ `;
2492
+ const StyledTextFieldContainer$1 = styled.div `
2493
+ --space-x: 16px;
2494
+ --space-y-not-shrink: 16px;
2495
+ --space-y-shrink: 7px;
2496
+ --container-height: 56px;
2497
+ --label-not-shrink: 16px;
2498
+ --label-shrink: 12px;
2499
+ --input: 16px;
2500
+
2501
+ position: relative;
2502
+ min-width: 100px;
2503
+ max-width: 100%;
2504
+ display: inline-block;
2505
+
2506
+ .textField_wrapper {
2507
+ display: inline-block;
2508
+ width: 100%;
2509
+ cursor: pointer;
2510
+ }
2511
+
2512
+ .mantine-InputWrapper-root {
2513
+ &[data-invalid='true'] {
2514
+ .mantine-Input-wrapper {
2515
+ border-color: ${theme.colors.red400};
2516
+ }
2517
+ }
2518
+
2519
+ .mantine-Input-wrapper {
2520
+ &:has([data-invalid]) {
2521
+ border-color: ${theme.colors.red400};
2522
+ }
2523
+ }
2524
+
2525
+ .mantine-InputWrapper-error {
2526
+ font-size: 12px !important;
2527
+ }
2528
+ }
2529
+
2530
+ .mantine-InputWrapper-label {
2531
+ ${cssLabelNotShrink$1}
2532
+ }
2533
+
2534
+ .mantine-Input-wrapper {
2535
+ ${cssWrapperInputNotShrink$1}
2536
+
2537
+ + .mantine-Popover-dropdown[data-position="bottom-start"] {
2538
+ left: 0 !important;
2539
+ }
2540
+ + .mantine-Popover-dropdown[data-position='top-start'] {
2541
+ top: unset !important;
2542
+ left: 0 !important;
2543
+ bottom: 100% !important;
2544
+ }
2545
+ }
2546
+
2547
+ .mantine-Input-input {
2548
+ ${cssInputNotShrink$1}
2549
+ }
2550
+
2551
+ &.textField_shrink,
2552
+ &:focus-within {
2553
+ .mantine-InputWrapper-label {
2554
+ ${cssLabelShrink$1}
2555
+ }
2556
+
2557
+ .mantine-Input-wrapper {
2558
+ ${cssWrapperInputShrink$1}
2559
+ &.mantine-Select-wrapper {
2560
+ .mantine-Select-rightSection {
2561
+ pointer-events: auto !important;
2562
+ }
2563
+ }
2564
+ }
2565
+
2566
+ .mantine-Input-input {
2567
+ ${cssInputShrink$1}
2568
+ }
2569
+
2570
+ &:has(.PhoneInput) {
2571
+ .mantine-InputWrapper-label {
2572
+ left: var(--space-x, 16px);
2573
+ }
2574
+ .PhoneInput {
2575
+ .PhoneInputInput {
2576
+ opacity: 1;
2577
+ }
2578
+ }
2579
+ }
2580
+ }
2581
+
2582
+ .PhoneInput {
2583
+ --phone-select: 75px;
2584
+ --phone-input-space-x: 8px;
2585
+ width: 100%;
2586
+ opacity: 1;
2587
+ border: none;
2588
+ .PhoneInputCountry {
2589
+ background-color: transparent;
2590
+ border: none;
2591
+ padding: 0;
2592
+ width: var(--phone-select, 75px);
2593
+ }
2594
+ .PhoneInputInput {
2595
+ flex: 1;
2596
+ min-width: 0;
2597
+ line-height: 1.5;
2598
+ outline: none !important;
2599
+ border: none;
2600
+ box-shadow: none;
2601
+ padding: 0 var(--phone-input-space-x, 8px);
2602
+ opacity: 0;
2603
+ color: ${theme.colors.gray800} !important;
2604
+ :focus {
2605
+ color: ${theme.colors.gray800} !important;
2606
+ }
2607
+ }
2608
+ }
2609
+
2610
+ &:has(.PhoneInput) {
2611
+ .mantine-InputWrapper-label {
2612
+ left: calc(
2613
+ var(--space-x, 16px) + var(--phone-select, 75px) +
2614
+ var(--phone-input-space-x, 8px)
2615
+ );
2616
+ }
2617
+ }
2618
+ `;
2619
+ const StyledChoiceFieldContainer$1 = styled.div `
2620
+ &.leadgen-form_checkbox,
2621
+ &.leadgen-form_radio {
2622
+ width: 100%;
2623
+ }
2624
+
2625
+ &.leadgen-form_dropdown {
2626
+ width: calc(50% - 12px);
2627
+ }
2628
+
2629
+ .mantine-InputWrapper-root {
2630
+ display: block;
2631
+ .mantine-InputWrapper-error {
2632
+ font-size: 12px !important;
2633
+ }
2634
+ }
2635
+
2636
+ .mantine-InputWrapper-label {
2637
+ margin-bottom: 0.5rem;
2638
+ color: ${theme.colors.gray800};
2639
+ font-size: 16px;
2640
+ font-weight: 400;
2641
+ line-height: 1.5;
2642
+ }
2643
+
2644
+ .mantine-Radio-root,
2645
+ .mantine-Checkbox-root {
2646
+ gap: 8px;
2647
+ min-width: calc(50% - 4px);
2648
+
2649
+ input[type='radio'],
2650
+ input[type='checkbox'] {
2651
+ border-color: ${theme.colors.gray600};
2652
+ width: 18px;
2653
+ height: 18px;
2654
+ }
2655
+ input[type='checkbox'] {
2656
+ border-radius: 4px;
2657
+ }
2658
+
2659
+ &[data-checked='true'] {
2660
+ input[type='radio'],
2661
+ input[type='checkbox'] {
2662
+ border-color: ${theme.colors.primary600};
2663
+ + svg {
2664
+ color: ${theme.colors.primary600};
2665
+ }
2666
+ }
2667
+
2668
+ input[type='radio'] {
2669
+ background-color: white;
2670
+ }
2671
+ }
2672
+
2673
+ .mantine-Checkbox-input {
2674
+ &:checked {
2675
+ border-color: ${theme.colors.primary600};
2676
+ }
2677
+ }
2678
+ }
2679
+
2680
+ .mantine-Radio-inner,
2681
+ .mantine-Checkbox-inner {
2682
+ width: 24px;
2683
+ height: 24px;
2684
+ display: flex;
2685
+ align-items: center;
2686
+ justify-content: center;
2687
+ }
2688
+
2689
+ .mantine-Radio-body,
2690
+ .mantine-Checkbox-body {
2691
+ display: flex;
2692
+ align-items: center;
2693
+ }
2694
+
2695
+ .mantine-Radio-label,
2696
+ .mantine-Checkbox-label {
2697
+ padding-left: 8px;
2698
+ color: ${theme.colors.gray800};
2699
+ font-size: 14px;
2700
+ line-height: 1.4;
2701
+ letter-spacing: -0.2px;
2702
+ }
2703
+
2704
+ .leadgen-choiceContainer {
2705
+ display: flex;
2706
+ flex-wrap: wrap;
2707
+ align-items: flex-start;
2708
+ gap: 8px;
2709
+ }
2710
+
2711
+ .mantine-InputWrapper-error {
2712
+ ${cssInputWrapperError$1}
2713
+ }
2714
+ `;
2715
+
2716
+ const TextField$1 = (props) => {
2717
+ const { shrink: shrinkProps, onChangeShrink, className, children } = props, restProps = __rest(props, ["shrink", "onChangeShrink", "className", "children"]);
2718
+ const containerRef = useClickOutside(() => {
2719
+ if (shrinkProps) {
2720
+ return;
2721
+ }
2722
+ setShrink(false);
2723
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(false);
2724
+ });
2725
+ const [shrink, setShrink] = useState(shrinkProps);
2726
+ const onClick = useCallback((e) => {
2727
+ setShrink(true);
2728
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(true);
2729
+ if (shrink) {
2730
+ return;
2731
+ }
2732
+ const $textEl = e.currentTarget.querySelectorAll('input:not([disabled]):not([type="submit"]),select:not([disabled]),textarea:not([disabled])');
2733
+ const $focusEl = $textEl.item($textEl.length - 1);
2734
+ if ($focusEl) {
2735
+ $focusEl.focus();
2736
+ setTimeout(() => {
2737
+ $focusEl.scrollIntoView({
2738
+ behavior: 'auto',
2739
+ block: 'center',
2740
+ inline: 'start',
2741
+ });
2742
+ }, 100);
2743
+ }
2744
+ }, [shrink]);
2745
+ useEffect(() => {
2746
+ setShrink(shrinkProps);
2747
+ }, [shrinkProps]);
2748
+ return (React__default.createElement(StyledTextFieldContainer$1, Object.assign({ shrink: shrink, className: clsx(className, 'textField', { textField_shrink: !!shrink }) }, restProps),
2749
+ React__default.createElement("div", { ref: containerRef, onClick: onClick, className: "textField_wrapper" }, children)));
2750
+ };
2751
+ const ChoiceField$1 = (props) => {
2752
+ const { children, className } = props, restProps = __rest(props, ["children", "className"]);
2753
+ return (React__default.createElement(StyledChoiceFieldContainer$1, Object.assign({ className: clsx(className, 'choiceField') }, restProps), children));
2754
+ };
2755
+
2756
+ const libraries = ['places'];
2757
+ const GoogleLocationBlock = (props) => {
2758
+ var _a;
2759
+ const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = __rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
2760
+ const [LoadScript, setLoadScript] = useState(null);
2761
+ const [value, setValue] = useState(defaultValue || valueProps);
2762
+ 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]);
2763
+ const onChangeAutocomplete = useCallback((s) => {
2764
+ setValue(s);
2765
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
2766
+ }, []);
2767
+ const onClickItem = useCallback((item) => {
2768
+ /** For sure get value */
2769
+ setValue(item.value);
2770
+ const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
2771
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
2772
+ }, [onChangeProps, predictions]);
2773
+ useEffect(() => {
2774
+ setValue(valueProps);
2775
+ }, [valueProps]);
2776
+ useEffect(() => {
2777
+ var _a, _b, _c;
2778
+ // only load extra google script when not yet loaded
2779
+ 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) {
2780
+ import('@react-google-maps/api').then((m) => {
2781
+ setLoadScript(() => m.LoadScript);
2782
+ });
2783
+ }
2784
+ }, []);
2785
+ return (React__default.createElement(Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
2786
+ return { value: pred.description, label: pred.description };
2787
+ }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
2788
+ return (React__default.createElement(React__default.Fragment, null,
2789
+ LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default.createElement(React__default.Fragment, null), style: { width: '100%' } })),
2790
+ children));
2791
+ } }, restProps)));
2792
+ };
2793
+
2794
+ const LeadGenForm = forwardRef((props, ref) => {
2795
+ const { locale, blocks, scrollToErrorField = true, form: formProps, rules: validate, initialValues, onFinish, onFinishFailed, className, style, } = props;
2796
+ const formRef = useRef(null);
2797
+ const form = formProps || useForm({ initialValues, validate });
2798
+ const middlewareFinish = useCallback((values, event) => {
2799
+ /** Set `touched` all values for validation when submiting */
2800
+ form.setTouched(blocks.reduce((touched, { data }) => {
2801
+ touched[data.value] = true;
2802
+ return touched;
2803
+ }, {}));
2804
+ /** Wait for `touched` state and then submit */
2805
+ setTimeout(() => {
2806
+ const { hasErrors } = form.validate();
2807
+ if (hasErrors) {
2808
+ return;
2809
+ }
2810
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatLeadGenFormValue(values, blocks), event);
2811
+ }, 100);
2812
+ }, [form, blocks]);
2813
+ const middlewareFinishFailed = useCallback((errors, values, events) => {
2814
+ if (scrollToErrorField && errors) {
2815
+ const firstErrorKey = Object.keys(errors)[0];
2816
+ const firstErrorElement = document.querySelector(`[name="${firstErrorKey}"]`);
2817
+ if (firstErrorElement && (firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus)) {
2818
+ setTimeout(() => {
2819
+ firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
2820
+ firstErrorElement.scrollIntoView({
2821
+ behavior: 'auto',
2822
+ block: 'center',
2823
+ inline: 'center',
2824
+ });
2825
+ }, 100);
2826
+ }
2827
+ }
2828
+ onFinishFailed === null || onFinishFailed === void 0 ? void 0 : onFinishFailed(errors, values, events);
2829
+ }, [scrollToErrorField]);
2830
+ useEffect(() => {
2831
+ (() => __awaiter(void 0, void 0, void 0, function* () {
2832
+ if (!window.intlTelInputUtils) {
2833
+ yield require('intl-tel-input/build/js/utils');
2834
+ }
2835
+ }))();
2836
+ }, []);
2837
+ useImperativeHandle(ref, () => (Object.assign(Object.assign({}, form), { submit: () => {
2838
+ formRef.current.requestSubmit();
2839
+ } })), [form, formRef]);
2840
+ if (!blocks || !blocks.length) {
2841
+ return null;
2842
+ }
2843
+ return (React__default.createElement("form", { ref: formRef, onSubmit: form.onSubmit(middlewareFinish, middlewareFinishFailed), className: className, style: style },
2844
+ React__default.createElement(StyledLeadGenFormInner, { className: "leadgen-form_inputs" }, blocks.map((block, idx) => {
2845
+ const { id, name: blockName, data } = block;
2846
+ const { placeholder, value: name, required, listQuestion, valueHTML, isSendMailChimp = false, } = data;
2847
+ const formInputProps = form.getInputProps(name);
2848
+ const { value, error } = formInputProps;
2849
+ const reactKey = `${id}-${idx}`;
2850
+ switch (blockName) {
2851
+ case LEADGEN_BLOCK.TextBlock: {
2852
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2853
+ 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))));
2854
+ }
2855
+ case LEADGEN_BLOCK.NumberBlock: {
2856
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2857
+ 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))));
2858
+ }
2859
+ case LEADGEN_BLOCK.EmailBlock: {
2860
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2861
+ 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))));
2862
+ }
2863
+ case LEADGEN_BLOCK.PhoneOtpBlock:
2864
+ case LEADGEN_BLOCK.WhatsappOtpBlock:
2865
+ case LEADGEN_BLOCK.ZaloOtpBlock:
2866
+ case LEADGEN_BLOCK.PhoneBlock: {
2867
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2868
+ 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))));
2869
+ }
2870
+ case LEADGEN_BLOCK.LocationBlock: {
2871
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2872
+ 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))));
2873
+ }
2874
+ case LEADGEN_BLOCK.DateBlock: {
2875
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2876
+ 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))));
2877
+ }
2878
+ case LEADGEN_BLOCK.DropdownBlock:
2879
+ return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2880
+ React__default.createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2881
+ React__default.createElement(Select$1, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, data: listQuestion.map((l) => ({
2882
+ value: l.value,
2883
+ label: l.placeholder,
2884
+ })) }, formInputProps))));
2885
+ case LEADGEN_BLOCK.CheckboxBlock: {
2886
+ const formInputCheckboxProps = form.getInputProps(name, {
2887
+ type: 'checkbox',
2888
+ });
2889
+ return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2890
+ isSendMailChimp && (React__default.createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2891
+ React__default.createElement(Checkbox$1.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, sx: {
2892
+ display: 'flex',
2893
+ flexDirection: 'column',
2894
+ flexWrap: 'wrap',
2895
+ gap: 8,
2896
+ }, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2897
+ return (React__default.createElement("div", { className: "leadgen-choiceContainer" }, children));
2898
+ } }, formInputCheckboxProps), listQuestion.map((l, _idx) => (React__default.createElement(Checkbox$1, { name: name, key: _idx, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2899
+ }
2900
+ case LEADGEN_BLOCK.RadioBlock: {
2901
+ return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2902
+ isSendMailChimp && (React__default.createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2903
+ 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) => {
2904
+ return (React__default.createElement("div", { className: "leadgen-choiceContainer" }, children));
2905
+ } }, formInputProps), listQuestion.map((l, _index) => (React__default.createElement(Radio$1, { name: name, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2906
+ }
2907
+ case LEADGEN_BLOCK.TncBlock:
2908
+ return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2909
+ React__default.createElement(Input$1.Wrapper, { error: error },
2910
+ 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)))));
2911
+ default: {
2912
+ return null;
2913
+ }
2914
+ }
2915
+ }))));
2916
+ });
2917
+
2918
+ const LEADGEN_ORDER_INPUT_WRAPPER = ['label', 'input', 'description', 'error'];
2919
+
2920
+ const LeadGenSubscriptionBoxA = (props) => {
2921
+ const { loading, image, title, submitText, locale, blocks, form, rules, onFinish, } = props;
2922
+ const formRef = useRef();
2923
+ const imageComp = useMemo(() => {
2924
+ if (!image) {
2925
+ return null;
2926
+ }
2927
+ return (React__default.createElement(StyledLeadGenSubscriptionBoxHeaderImage, null,
2928
+ React__default.createElement("img", { src: image, alt: "" })));
2929
+ }, [image]);
2930
+ const titleComp = useMemo(() => {
2931
+ if (typeof title === 'string') {
2932
+ return (React__default.createElement("p", { className: "leadgen-title", dangerouslySetInnerHTML: { __html: title } }));
2933
+ }
2934
+ return React__default.createElement("p", { className: "leadgen-title" }, title);
2935
+ }, [title]);
2936
+ return (React__default.createElement(StyledLeadGenSubscriptionBoxA, { className: "subcription_box_A" },
2937
+ React__default.createElement(StyledLeadGenSubscriptionBoxHeader, { className: "leadgen-subscription_box_header" },
2938
+ imageComp,
2939
+ titleComp),
2940
+ React__default.createElement(StyledLeadGenSubscriptionBoxBody, { className: "leadgen-subscription_box_body" },
2941
+ React__default.createElement(LeadGenForm, { ref: formRef, form: form, rules: rules, blocks: blocks, locale: locale, onFinish: onFinish, className: "leadgen-subscription_box_form" }),
2942
+ React__default.createElement(Button$1, { disabled: loading, loading: loading, variant: "filled", size: "lg", onClick: () => {
2943
+ formRef.current.submit();
2944
+ }, className: "leadgen-btn leadgen-btn_action", fullWidth: true }, submitText))));
2945
+ };
2946
+
2947
+ const LeadGenSubscriptionBoxWithoutMemo = ({ locale, userInfo, forceCampaign, categoryId, }) => {
2948
+ var _a, _b, _c;
2949
+ const { image, extra_fields, id: campaign_id, bot_id: campaign_subot_id = [], ThankYouBlock, } = forceCampaign || {};
2950
+ const { textBlocks, listBlockAdded, actionBlocks } = extra_fields || {};
2951
+ const { submitBlock } = actionBlocks || {};
2952
+ const { apiLeadUrl, subscriptionIcon, subscriptionTitle, submitSubscriptionBox, impression, onFinish, } = useLeadGenContext();
2953
+ const { t } = useTranslations();
2954
+ const { action: { pushNotifications }, } = useContext(TogetherComponentGlobalContext);
2955
+ const refContainer = useRef(null);
2956
+ const [loading, setLoading] = useState(false);
2957
+ const [showThankyou, setShowThankyou] = useState(false);
2958
+ const validatingEmailRef = useRef(false);
2959
+ const validatingPhoneRef = useRef(false);
2960
+ const { form, validateObj } = useLeadFormConfig({
2961
+ listBlockAdded,
2962
+ campaignId: campaign_id,
2963
+ campaign_subot_id,
2964
+ validatingEmailRef,
2965
+ validatingPhoneRef,
2966
+ userInfo,
2967
+ });
2968
+ const subscription_title = useMemo(() => {
2969
+ var _a, _b;
2970
+ return subscriptionTitle ||
2971
+ ((_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) ||
2972
+ t('leadgen.message.title.default');
2973
+ }, [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]);
2974
+ const { image: thankyouImage, title: thankyouTitle, description: thankyouDescription, button: thankyouButton, } = ThankYouBlock || {};
2975
+ const intersectionObserverCallback = useCallback((entries) => {
2976
+ entries.forEach((entry) => {
2977
+ const { isIntersecting, target } = entry;
2978
+ if (!showThankyou &&
2979
+ isIntersecting &&
2980
+ target === refContainer.current) {
2981
+ impression();
2982
+ }
2983
+ });
2984
+ }, [impression, showThankyou]);
2985
+ const IObserver = new IntersectionObserver(intersectionObserverCallback);
2986
+ const middlewareOnSubmit = useCallback((values) => __awaiter(void 0, void 0, void 0, function* () {
2987
+ const newValues = {
2988
+ subscription_title,
2989
+ };
2990
+ const ssoValues = {
2991
+ sso_user_id: undefined,
2992
+ sso_uuid: undefined,
2993
+ sso_verified_profile: undefined,
2994
+ };
2995
+ const valueKeys = Object.keys(values);
2996
+ for (const key of valueKeys) {
2997
+ const isPhoneField = leadGenFieldNamePhone(listBlockAdded).some((k) => k === key);
2998
+ if (isPhoneField) {
2999
+ const phone = parsePhoneNumber(values[key]);
3000
+ if (phone.isValid()) {
3001
+ /** Seperate `area_code` and `phone_number` for BE */
3002
+ newValues['area_code'] = `+${phone.countryCallingCode}`;
3003
+ newValues['phone_number'] = phone.nationalNumber;
3004
+ /** Only case login has this update */
3005
+ if ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) && (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid)) {
3006
+ ssoValues['sso_verified_profile'] =
3007
+ phone.number === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone) ? 1 : 0;
3008
+ ssoValues['sso_user_id'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.id;
3009
+ ssoValues['sso_uuid'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid;
3010
+ }
3011
+ }
3012
+ continue;
3013
+ }
3014
+ newValues[key] = values[key];
3015
+ }
3016
+ setLoading(true);
3017
+ try {
3018
+ const { _data } = (yield submitSubscriptionBox(Object.assign(Object.assign({}, newValues), ssoValues))) || {};
3019
+ const { model } = _data || {};
3020
+ if (model && (model === null || model === void 0 ? void 0 : model.id)) {
3021
+ setShowThankyou(true);
3022
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(Object.assign(Object.assign({}, newValues), ssoValues), listBlockAdded || []);
3023
+ }
3024
+ }
3025
+ catch (error) {
3026
+ LeadLog('** LeadGen SubscriptionBox error : ', error);
3027
+ pushNotifications({
3028
+ message: t('leadgen.message.error.default'),
3029
+ type: 'danger',
3030
+ });
3031
+ }
3032
+ setLoading(false);
3033
+ }), [
3034
+ subscription_title,
3035
+ listBlockAdded,
3036
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
3037
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid,
3038
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone,
3039
+ ]);
3040
+ useEffect(() => {
3041
+ if (refContainer.current) {
3042
+ IObserver.observe(refContainer.current);
3043
+ }
3044
+ return () => {
3045
+ IObserver.disconnect();
3046
+ };
3047
+ }, [categoryId]);
3048
+ return (React__default.createElement("div", { ref: refContainer },
3049
+ React__default.createElement(StyledLeadGenSubscriptionBox, null,
3050
+ 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 })),
3051
+ !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 })))));
3052
+ };
3053
+ const LeadGenSubscriptionBox$1 = memo(LeadGenSubscriptionBoxWithoutMemo);
3054
+
3055
+ const Container = () => {
3056
+ const context = useContext(LeadGenContext);
3057
+ const { campaign_code, locale, siteId, siteDomain, userInfo, forceCampaign } = context;
3058
+ if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
3059
+ return null;
3060
+ }
3061
+ return (React__default.createElement(LeadGenSubscriptionBox$1, { locale: locale, siteId: siteId, siteDomain: siteDomain, userInfo: userInfo, forceCampaign: forceCampaign, campaign_code: campaign_code }));
3062
+ };
3063
+ Container.displayName = 'LeadGenSubscriptionBox';
3064
+ const LeadGenSubscriptionBoxContainer = (props) => {
3065
+ const { apiUrl, apiSubotUrl } = props;
3066
+ return (React__default.createElement(LeadGenContextProvider, Object.assign({}, props, { apiLeadUrl: apiUrl, apiSubotUrl: apiSubotUrl }),
3067
+ React__default.createElement(Container, null)));
3068
+ };
3069
+ const LeadGenSubscriptionBox = LeadGenSubscriptionBoxContainer;
3070
+
3071
+ const useImageSize = (src) => {
3072
+ const [width, setWidth] = useState(16);
3073
+ const [height, setHeight] = useState(9);
3074
+ const [loaded, setLoaded] = useState(false);
3075
+ // load src image to get its width and height
3076
+ useEffect(() => {
3077
+ setLoaded(false);
3078
+ if (src) {
3079
+ const img = new Image();
3080
+ img.addEventListener('load', () => {
3081
+ setWidth(img.naturalWidth);
3082
+ setHeight(img.naturalHeight);
3083
+ setLoaded(true);
3084
+ });
3085
+ img.addEventListener('error', () => {
3086
+ setWidth(16);
3087
+ setHeight(9);
3088
+ setLoaded(true);
3089
+ });
3090
+ img.src = src;
3091
+ }
3092
+ else {
3093
+ setWidth(16);
3094
+ setHeight(9);
3095
+ setLoaded(true);
3096
+ }
3097
+ }, [src]);
3098
+ return {
3099
+ loaded,
3100
+ width,
3101
+ height,
3102
+ };
3103
+ };
3104
+
3105
+ const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default.createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
3106
+ React__default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
3107
+ 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" }))));
3108
+
3109
+ // url: imageBlocks.imageMobile.data.url
3110
+ // newTab: imageBlocks.imageMobile.data.newtab
3111
+ // imageMobile: campaignShow.image
3112
+ // imageDestkop: campaignShow.image_desktop
3113
+ const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
3114
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3115
+ const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
3116
+ if (!imageMobileLoaded || !imageDestkopLoaded)
3117
+ return null;
3118
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
3119
+ React__default.createElement("div", { className: "le-center-tab-popup" },
3120
+ React__default.createElement("div", { style: { position: 'relative' } },
3121
+ React__default.createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
3122
+ isVideo(imageMobile) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
3123
+ React__default.createElement("source", { src: imageMobile }))) : (React__default.createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
3124
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3125
+ } })),
3126
+ isVideo(imageDestkop) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
3127
+ React__default.createElement("source", { src: imageDestkop }))) : (React__default.createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
3128
+ aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
3129
+ } }))),
3130
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3131
+ };
3132
+
3133
+ // title: titleText
3134
+ // titleAlign: textBlocks.titleBlock.data.align
3135
+ // subtitle: textBlocks.subtitleBlock.data.value
3136
+ // subtitleAlign: textBlocks.subtitleBlock.data.align
3137
+ // url: actionBlocks.linkButtonBlock.data.url
3138
+ // urlText: actionBlocks.linkButtonBlock.data.value
3139
+ // newTab: actionBlocks.linkButtonBlock.data.newtab
3140
+ // imageMobile: campaignShow.image
3141
+ // imageDesktop: campaignShow.image_desktop
3142
+ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
3143
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3144
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
3145
+ if (!imageMobileLoaded || !imageDesktopLoaded)
3146
+ return null;
3147
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
3148
+ React__default.createElement("aside", { className: "le-only-desktop" },
3149
+ React__default.createElement("div", { className: "le-floating-desktop" },
3150
+ React__default.createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
3151
+ imageDesktop ? (React__default.createElement("div", null,
3152
+ React__default.createElement("img", { style: {
3153
+ maxWidth: 120,
3154
+ borderTopLeftRadius: 5,
3155
+ borderBottomLeftRadius: 5,
3156
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
3157
+ }, src: imageDesktop }))) : null,
3158
+ React__default.createElement("div", { style: { padding: 20 } },
3159
+ React__default.createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
3160
+ React__default.createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
3161
+ React__default.createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
3162
+ React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
3163
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
3164
+ React__default.createElement("aside", { className: "le-only-mobile" },
3165
+ React__default.createElement("div", { className: "le-floating-mobile" },
3166
+ React__default.createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
3167
+ React__default.createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
3168
+ React__default.createElement("div", null,
3169
+ React__default.createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
3170
+ React__default.createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
3171
+ imageMobile ? (React__default.createElement("div", null,
3172
+ React__default.createElement("img", { style: {
3173
+ marginLeft: 15,
3174
+ marginTop: 4,
3175
+ maxWidth: 100,
3176
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3177
+ }, src: imageMobile }))) : null),
3178
+ React__default.createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
3179
+ React__default.createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
3180
+ React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
3181
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
3182
+ };
3183
+
3184
+ const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
3185
+ const { primaryColor } = useContext(LeadGenContext$1);
3186
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
3187
+ if (!imageLoaded)
3188
+ return null;
3189
+ return (React__default.createElement("div", { className: "lead-modal__thank-you leadgen-inner_thankyou" },
3190
+ React__default.createElement("div", { style: { width: '100%' } },
3191
+ React__default.createElement("img", { src: image, style: {
3192
+ maxHeight: 162,
3193
+ objectFit: 'cover',
3194
+ aspectRatio: `${imageWidth}/${imageHeight}`,
3195
+ }, loading: "lazy" }),
3196
+ title && (React__default.createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
3197
+ subtitle && (React__default.createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle.split('\n').map((text, idx, list) => {
3198
+ const isShowBr = idx < list.length - 1;
3199
+ return (React__default.createElement(React__default.Fragment, null,
3200
+ text,
3201
+ isShowBr && React__default.createElement("br", null)));
3202
+ }))),
3203
+ linkText && (React__default.createElement("div", null,
3204
+ React__default.createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
3205
+ React__default.createElement(Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
3206
+ };
3207
+
3208
+ const InlineLayout = ({ content, inlinePosition, }) => {
3209
+ const target = useMemo(() => {
3210
+ if (!inlinePosition)
3211
+ return null;
3212
+ const parents = document.querySelectorAll(`[data-url="${location.pathname}"] .body-content`);
3213
+ const allChildren = Array.from(parents).reduce((r, p) => {
3214
+ return [...r, ...Array.from(p.children)];
3215
+ }, []);
3216
+ if (allChildren === null || allChildren === void 0 ? void 0 : allChildren.length) {
3217
+ // find the third p tag in the body content, some other tags might mix in between
3218
+ const allPTags = allChildren.filter((c) => c.nodeName === 'P');
1488
3219
  const allH2Tags = allChildren.filter((c) => c.nodeName === 'H2');
1489
3220
  let target = null;
1490
3221
  switch (inlinePosition) {
@@ -1602,226 +3333,21 @@ const SideBarLayout = ({ content }) => {
1602
3333
  const EmptyIcon = (props) => {
1603
3334
  const { className, style } = props;
1604
3335
  return (React__default.createElement("svg", { width: "160", height: "160", viewBox: "0 0 160 160", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, style: style },
1605
- React__default.createElement("path", { d: "M79.9974 113.333C98.4069 113.333 113.331 98.4096 113.331 80.0001C113.331 61.5906 98.4069 46.6667 79.9974 46.6667C61.5879 46.6667 46.6641 61.5906 46.6641 80.0001C46.6641 98.4096 61.5879 113.333 79.9974 113.333Z", fill: "#F44D2C" }),
1606
- 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" }),
1607
- 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" })));
1608
- };
1609
-
1610
- const EmptyComponent = ({ onClose, onContinue, }) => {
1611
- const { t } = useTranslations();
1612
- return (React__default.createElement("div", { className: "leadgen-empty" },
1613
- React__default.createElement("div", { className: "leadgen-empty_body" },
1614
- React__default.createElement("div", { className: "leadgen-empty_wrapper" },
1615
- React__default.createElement(EmptyIcon, { className: "leadgen-empty_image" }),
1616
- React__default.createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
1617
- React__default.createElement("div", { className: "leadgen-empty_footer" },
1618
- React__default.createElement(Button$1, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
1619
- React__default.createElement(Button$1, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
1620
- };
1621
-
1622
- const libraries = ['places'];
1623
- const GoogleLocationBlock = (props) => {
1624
- var _a;
1625
- const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = __rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
1626
- const [LoadScript, setLoadScript] = useState(null);
1627
- const [value, setValue] = useState(defaultValue || valueProps);
1628
- 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]);
1629
- const onChangeAutocomplete = useCallback((s) => {
1630
- setValue(s);
1631
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
1632
- }, []);
1633
- const onClickItem = useCallback((item) => {
1634
- /** For sure get value */
1635
- setValue(item.value);
1636
- const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
1637
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
1638
- }, [onChangeProps, predictions]);
1639
- useEffect(() => {
1640
- setValue(valueProps);
1641
- }, [valueProps]);
1642
- useEffect(() => {
1643
- var _a, _b, _c;
1644
- // only load extra google script when not yet loaded
1645
- 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) {
1646
- import('@react-google-maps/api').then((m) => {
1647
- setLoadScript(() => m.LoadScript);
1648
- });
1649
- }
1650
- }, []);
1651
- return (React__default.createElement(Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
1652
- return { value: pred.description, label: pred.description };
1653
- }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
1654
- return (React__default.createElement(React__default.Fragment, null,
1655
- LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default.createElement(React__default.Fragment, null), style: { width: '100%' } })),
1656
- children));
1657
- } }, restProps)));
1658
- };
1659
-
1660
- // You can give context variables any name
1661
- const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
1662
- const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, }) => {
1663
- const { t } = useTranslations();
1664
- const initialValues = useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
1665
- const validateObj = useMemo(() => {
1666
- const InputBlocks = [
1667
- 'TextBlock',
1668
- 'NumberBlock',
1669
- 'EmailBlock',
1670
- 'PhoneBlock',
1671
- 'DateBlock',
1672
- 'CheckboxBlock',
1673
- 'RadioBlock',
1674
- 'DropdownBlock',
1675
- 'PhoneOtpBlock',
1676
- 'WhatsappOtpBlock',
1677
- 'ZaloOtpBlock',
1678
- 'LocationBlock',
1679
- 'TncBlock',
1680
- ];
1681
- // ALL are required and can skip if not touched yet
1682
- const withSharedCheck = (name, cb,
1683
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1684
- block) => {
1685
- return (value) => {
1686
- var _a;
1687
- const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
1688
- if (!formRef.current.isTouched(name))
1689
- return;
1690
- if ((typeof value === 'string' && value.replace(' ', '') === '') ||
1691
- typeof value === 'undefined' ||
1692
- value === '' ||
1693
- (Array.isArray(value) && value.length === 0)) {
1694
- return isBLockRequired
1695
- ? t('validator.required')
1696
- : cb === null || cb === void 0 ? void 0 : cb(value);
1697
- }
1698
- return cb === null || cb === void 0 ? void 0 : cb(value);
1699
- };
1700
- };
1701
- return listBlockAdded
1702
- .filter((b) => InputBlocks.includes(b.name))
1703
- .reduce((r, b) => {
1704
- var _a;
1705
- const isRequired = (_a = b.data.required) !== null && _a !== void 0 ? _a : true;
1706
- if (b.name === 'NumberBlock') {
1707
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1708
- if (value && isNaN(Number(value))) {
1709
- return t('validator.number');
1710
- }
1711
- }, b) });
1712
- }
1713
- else if (b.name === 'EmailBlock') {
1714
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1715
- if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
1716
- return t('validator.email');
1717
- }
1718
- if (!value)
1719
- return;
1720
- validatingEmailRef.current = true;
1721
- setTimeout(() => {
1722
- formRef.current.setFieldError(b.data.value, 'Validating...');
1723
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1724
- email: value,
1725
- })
1726
- .then((tKey) => {
1727
- if (tKey) {
1728
- formRef.current.setFieldError(b.data.value, t(tKey));
1729
- }
1730
- else {
1731
- formRef.current.clearFieldError(b.data.value);
1732
- }
1733
- validatingEmailRef.current = false;
1734
- })
1735
- .catch((e) => {
1736
- console.error(e);
1737
- formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
1738
- validatingEmailRef.current = false;
1739
- });
1740
- }, 200);
1741
- }, b) });
1742
- }
1743
- else if (b.name === 'PhoneBlock' ||
1744
- b.name === 'PhoneOtpBlock' ||
1745
- b.name === 'ZaloOtpBlock' ||
1746
- b.name === 'WhatsappOtpBlock') {
1747
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1748
- if (value &&
1749
- window.intlTelInputUtils &&
1750
- !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
1751
- return t('validator.phone');
1752
- }
1753
- if (!value)
1754
- return;
1755
- validatingPhoneRef.current = true;
1756
- setTimeout(() => {
1757
- formRef.current.setFieldError(b.data.value, 'Validating...');
1758
- if (b.data.singleSubmission) {
1759
- checkUsedPhoneOnlyWithCache(campaignId, value)
1760
- .then((tKey) => {
1761
- if (tKey) {
1762
- formRef.current.setFieldError(b.data.value, t(tKey));
1763
- }
1764
- else {
1765
- formRef.current.clearFieldError(b.data.value);
1766
- }
1767
- validatingPhoneRef.current = false;
1768
- })
1769
- .catch((err) => {
1770
- console.error(err);
1771
- formRef.current.setFieldError(b.data.value, err.message || 'Something went wrong');
1772
- validatingPhoneRef.current = false;
1773
- });
1774
- }
1775
- else {
1776
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1777
- phone: value,
1778
- })
1779
- .then((tKey) => {
1780
- if (tKey) {
1781
- formRef.current.setFieldError(b.data.value, t(tKey));
1782
- }
1783
- else {
1784
- formRef.current.clearFieldError(b.data.value);
1785
- }
1786
- validatingPhoneRef.current = false;
1787
- })
1788
- .catch((e) => {
1789
- console.error(e);
1790
- formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
1791
- validatingPhoneRef.current = false;
1792
- });
1793
- }
1794
- }, 200);
1795
- }, b) });
1796
- }
1797
- else if (b.name === 'DateBlock') {
1798
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1799
- if (value && isNaN(Date.parse(value))) {
1800
- return t('validator.date');
1801
- }
1802
- }, b) });
1803
- }
1804
- else if (b.name === 'TncBlock') {
1805
- return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
1806
- if (isRequired && !value) {
1807
- return t('validator.required');
1808
- }
1809
- }, b) });
1810
- }
1811
- else {
1812
- return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, undefined, b) });
1813
- }
1814
- }, {});
1815
- }, [listBlockAdded.map((b) => b.name).join(',')]);
1816
- const form = useLeadForm({
1817
- validateInputOnChange: true,
1818
- clearInputErrorOnChange: true,
1819
- validate: validateObj,
1820
- initialValues,
1821
- });
1822
- const formRef = useRef(form);
1823
- formRef.current = form;
1824
- return { form, validateObj };
3336
+ React__default.createElement("path", { d: "M79.9974 113.333C98.4069 113.333 113.331 98.4096 113.331 80.0001C113.331 61.5906 98.4069 46.6667 79.9974 46.6667C61.5879 46.6667 46.6641 61.5906 46.6641 80.0001C46.6641 98.4096 61.5879 113.333 79.9974 113.333Z", fill: "#F44D2C" }),
3337
+ 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" }),
3338
+ 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" })));
3339
+ };
3340
+
3341
+ const EmptyComponent = ({ onClose, onContinue, }) => {
3342
+ const { t } = useTranslations();
3343
+ return (React__default.createElement("div", { className: "leadgen-empty" },
3344
+ React__default.createElement("div", { className: "leadgen-empty_body" },
3345
+ React__default.createElement("div", { className: "leadgen-empty_wrapper" },
3346
+ React__default.createElement(EmptyIcon, { className: "leadgen-empty_image" }),
3347
+ React__default.createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
3348
+ React__default.createElement("div", { className: "leadgen-empty_footer" },
3349
+ React__default.createElement(Button$1, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
3350
+ React__default.createElement(Button$1, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
1825
3351
  };
1826
3352
 
1827
3353
  const SubtitleBlock = ({ children, align, }) => (React__default.createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
@@ -1994,6 +3520,14 @@ const StyledTextFieldContainer = styled.div `
1994
3520
  }
1995
3521
  }
1996
3522
 
3523
+ &:focus-within {
3524
+ .mantine-Input-wrapper {
3525
+ transition: 0.25s linear border;
3526
+ border-color: ${theme.colors.primary600};
3527
+ box-shadow: 0 0 4px ${theme.colors.primary200};
3528
+ }
3529
+ }
3530
+
1997
3531
  .PhoneInput {
1998
3532
  --phone-select: 75px;
1999
3533
  --phone-input-space-x: 8px;
@@ -2142,11 +3676,13 @@ const TextField = (props) => {
2142
3676
  const $focusEl = $textEl.item($textEl.length - 1);
2143
3677
  if ($focusEl) {
2144
3678
  $focusEl.focus();
2145
- $focusEl.scrollIntoView({
2146
- behavior: 'auto',
2147
- block: 'center',
2148
- inline: 'start',
2149
- });
3679
+ setTimeout(() => {
3680
+ $focusEl.scrollIntoView({
3681
+ behavior: 'auto',
3682
+ block: 'center',
3683
+ inline: 'start',
3684
+ });
3685
+ }, 100);
2150
3686
  }
2151
3687
  }, [shrink]);
2152
3688
  useEffect(() => {
@@ -2163,8 +3699,14 @@ const ChoiceField = (props) => {
2163
3699
  const TitleBlock = ({ children, align, }) => (React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
2164
3700
 
2165
3701
  const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, }) => {
3702
+ const { t } = useTranslations();
2166
3703
  const form = useLeadFormContext();
2167
3704
  const formValues = form.values;
3705
+ const labelTuples = useMemo(() => {
3706
+ return ((ISO_FORMAT === null || ISO_FORMAT === void 0 ? void 0 : ISO_FORMAT[locale]) || ISO_FORMAT['vi-VN']).dateFormat
3707
+ .split('/')
3708
+ .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); });
3709
+ }, [locale]);
2168
3710
  return (React__default.createElement(React__default.Fragment, null, listBlockAdded.map((b, index) => {
2169
3711
  var _a;
2170
3712
  const { name = '', data = {}, id } = b || {};
@@ -2214,13 +3756,11 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2214
3756
  return (React__default.createElement(TextField, { key: index, shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field" },
2215
3757
  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)))));
2216
3758
  }
2217
- case 'DateBlock':
2218
- return (React__default.createElement(TextField, { key: index, shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field" },
2219
- 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) => {
2220
- return (React__default.createElement(React__default.Fragment, null,
2221
- children,
2222
- React__default.createElement("input", { type: "hidden", "data-control": "date", name: value, value: formValue })));
2223
- } }, form.getInputProps(value)))));
3759
+ case 'DateBlock': {
3760
+ const _c = form.getInputProps(value), { error } = _c, formInputProps = __rest(_c, ["error"]);
3761
+ 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" },
3762
+ 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))));
3763
+ }
2224
3764
  case 'LinkButtonBlock':
2225
3765
  return (React__default.createElement("div", { key: index },
2226
3766
  React__default.createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
@@ -2263,7 +3803,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2263
3803
  label: l.placeholder,
2264
3804
  })) }, form.getInputProps(value)))));
2265
3805
  case 'TncBlock':
2266
- const _c = form.getInputProps(`TNC-${id}`), { error } = _c, tncInputProps = __rest(_c, ["error"]);
3806
+ const _d = form.getInputProps(`TNC-${id}`), { error } = _d, tncInputProps = __rest(_d, ["error"]);
2267
3807
  return (React__default.createElement(ChoiceField, { className: "leadgen-form_checkbox", key: id },
2268
3808
  React__default.createElement(Input$1.Wrapper, { error: error },
2269
3809
  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)))));
@@ -2326,842 +3866,504 @@ const StyledFormContainer = styled.div `
2326
3866
  /**
2327
3867
  *
2328
3868
  * Use this component inside <form></form> tag
2329
- *
2330
- */
2331
- const FormContainer = (_a) => {
2332
- var { title, titleAlign, description, descriptionAlign, className, style, children, header, footer } = _a, restProps = __rest(_a, ["title", "titleAlign", "description", "descriptionAlign", "className", "style", "children", "header", "footer"]);
2333
- const HeaderContent = (React__default.createElement("div", { className: "leadgen-form_header" },
2334
- React__default.createElement("h2", { title: title, className: "leadgen-title", "data-align": titleAlign }, title),
2335
- !!description && (React__default.createElement("p", { title: description, className: "leadgen-description", "data-align": descriptionAlign, dangerouslySetInnerHTML: { __html: description } }))));
2336
- if (!title && !description) {
2337
- return null;
2338
- }
2339
- return (React__default.createElement(StyledFormContainer, Object.assign({ className: clsx(className, 'leadgen-form_container'), style: style }, restProps),
2340
- React__default.createElement("div", { className: "leadgen-form_wrapper" },
2341
- !!header && (React__default.createElement("div", { className: "leadgen-form_scrollable" },
2342
- header,
2343
- HeaderContent,
2344
- React__default.createElement("div", { className: "leadgen-form_body" }, children))),
2345
- !header && (React__default.createElement(React__default.Fragment, null,
2346
- HeaderContent,
2347
- React__default.createElement("div", { className: "leadgen-form_body" }, children))),
2348
- React__default.createElement("div", { className: "leadgen-form_footer" }, footer))));
2349
- };
2350
-
2351
- const StyleHeaderImage = styled.div `
2352
- position: relative;
2353
- overflow: hidden;
2354
- width: 100%;
2355
- height: 100%;
2356
- padding-top: ${({ paddingTop }) => paddingTop}%;
2357
- .leadgen-header_image_feature {
2358
- position: absolute;
2359
- inset: 0;
2360
- min-width: 100%;
2361
- min-height: 100%;
2362
- max-width: 100%;
2363
- max-height: 100%;
2364
- object-fit: cover;
2365
- object-position: center;
2366
- }
2367
- `;
2368
- const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
2369
- if (!src) {
2370
- return null;
2371
- }
2372
- return (React__default.createElement(StyleHeaderImage, { paddingTop: (1 / ratio) * 100, className: clsx(className, 'leadgen-header_image'), style: style }, isVideo(src) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true, className: "leadgen-header_image_feature leadgen-header_image_video", src: src })) : (React__default.createElement("img", { src: src, draggable: "false", alt: "", className: "leadgen-header_image_feature leadgen-header_image_image" }))));
2373
- };
2374
-
2375
- const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
2376
- const { primaryColor } = useContext(LeadGenContext);
2377
- const { t } = useTranslations();
2378
- const phone = otpData.phone;
2379
- const otpType = otpData.type;
2380
- const [otp, setOtp] = useState('');
2381
- const [isDirty, setIsDirty] = useState(false);
2382
- const [resendTimer, setResendTimer] = useState(autoSendWhenOpen ? 0 : 60);
2383
- const inputRef = useRef(null);
2384
- const [errorMsg, setErrorMsg] = useState();
2385
- const [displayPhone, setDisplayPhone] = useState('');
2386
- const formatPhoneNumberIntlRef = useRef();
2387
- const [isSubmitLoading, setIsSubmitLoading] = useState(false);
2388
- useEffect(() => {
2389
- (() => __awaiter(void 0, void 0, void 0, function* () {
2390
- var _a;
2391
- if (!formatPhoneNumberIntlRef.current) {
2392
- const res = yield import('react-phone-number-input');
2393
- formatPhoneNumberIntlRef.current = res.formatPhoneNumberIntl;
2394
- }
2395
- setDisplayPhone(((_a = formatPhoneNumberIntlRef.current) === null || _a === void 0 ? void 0 : _a.call(formatPhoneNumberIntlRef, phone)) || phone);
2396
- }))();
2397
- }, [phone]);
2398
- const sendOtp = () => __awaiter(void 0, void 0, void 0, function* () {
2399
- var _a;
2400
- if (!phone) {
2401
- return;
2402
- }
2403
- const res = yield Service.sendSMSOtpLead({
2404
- phone,
2405
- type: otpType,
2406
- });
2407
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2408
- if (respMessage === 'Send sms successfully' ||
2409
- respMessage === 'Send WhatsApp successfully' ||
2410
- respMessage === 'Send Zalo successfully') {
2411
- setResendTimer(60);
2412
- setTimeout(() => {
2413
- if (inputRef.current) {
2414
- inputRef.current.focus();
2415
- inputRef.current.scrollIntoView({ block: 'center' });
2416
- }
2417
- }, 100);
2418
- }
2419
- else if (respMessage === 'This phone number was verified') {
2420
- onSuccess();
2421
- }
2422
- else {
2423
- setErrorMsg(respMessage || 'Something went wrong!');
2424
- // const defaultError = f({ id: 'notification.comment.somethingWrong' })
2425
- // setStatusVerifyOTP('idle')
2426
- // pushNotifications({
2427
- // title: respMessage || defaultError,
2428
- // message: '',
2429
- // type: 'danger',
2430
- // })
2431
- }
2432
- });
2433
- const submitOtp = () => __awaiter(void 0, void 0, void 0, function* () {
2434
- if (!phone || !otp) {
2435
- return;
2436
- }
2437
- setIsSubmitLoading(true);
2438
- const res = yield Service.verifyOtpLead({
2439
- phone,
2440
- otp,
2441
- type: otpType,
2442
- });
2443
- const respMessage = res === null || res === void 0 ? void 0 : res._messages[0];
2444
- if (respMessage === 'Verify successfully' ||
2445
- respMessage === 'Verify WhatsApp OTP sucess' ||
2446
- respMessage === 'Verify Zalo OTP sucess') {
2447
- onSuccess();
2448
- }
2449
- else if (respMessage === 'This phone number was verified') {
2450
- onSuccess();
2451
- }
2452
- else {
2453
- setErrorMsg(respMessage || 'something Wrong');
2454
- // setIsShowError(true)
2455
- // setStatusVerifyOTP('sent')
2456
- // pushNotifications({
2457
- // title: res?._messages[0] || defaultError,
2458
- // message: '',
2459
- // type: 'danger',
2460
- // })
2461
- }
2462
- setIsSubmitLoading(false);
2463
- });
2464
- useEffect(() => {
2465
- setTimeout(() => {
2466
- if (resendTimer > 0) {
2467
- setResendTimer((r) => r - 1);
2468
- }
2469
- }, 1000);
2470
- }, [resendTimer]);
2471
- useEffect(() => {
2472
- if (autoSendWhenOpen && !resendTimer) {
2473
- sendOtp();
2474
- }
2475
- }, []);
2476
- return (React__default.createElement("form", { onSubmit: (e) => {
2477
- e.preventDefault();
2478
- submitOtp();
2479
- }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
2480
- React__default.createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
2481
- phone: `<strong>${displayPhone}</strong>`,
2482
- }), footer: React__default.createElement(React__default.Fragment, null,
2483
- 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')),
2484
- 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: () => {
2485
- sendOtp();
2486
- }, disabled: !!resendTimer }, t('lead.otp.resend', {
2487
- timer: resendTimer ? ` (${resendTimer}s)` : '',
2488
- }))) },
2489
- React__default.createElement("div", { className: "leadgen-form_inner" },
2490
- React__default.createElement(Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
2491
- React__default.createElement(OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
2492
- setIsDirty(true);
2493
- setOtp(v.toString());
2494
- if (isDirty && !v)
2495
- setErrorMsg('OTP is required');
2496
- else
2497
- setErrorMsg(undefined);
2498
- } }))))));
2499
- };
2500
-
2501
- // url: imageBlocks.imageMobile.data.url
2502
- // newTab: imageBlocks.imageMobile.data.newtab
2503
- // image: campaignShow.image
2504
- // imageDestkop: campaignShow.image_desktop
2505
- const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
2506
- LEADGEN_LAYOUT.Fullscreen,
2507
- LEADGEN_LAYOUT.Slider,
2508
- ];
2509
- const LEADGEN_LIMIT_LIGHTBOXB = 6;
2510
- const LEADGEN_SHOW_HEADER = [
2511
- 'LightBoxA',
2512
- 'InlineA',
2513
- LEADGEN_LAYOUT.Sidebar,
2514
- LEADGEN_LAYOUT.Slider,
2515
- ];
2516
- const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2517
- var _a;
2518
- const { primaryColor } = useContext(LeadGenContext);
2519
- const { isMobile } = useScreenSize();
2520
- const [open, setOpen] = useState(!!campaignId);
2521
- const [showOtpPhone, setShowOtpPhone] = useState(null);
2522
- const [isSubmitLoading, setIsSubmitLoading] = useState(false);
2523
- const [snap, setSnap] = useState(0.8);
2524
- const formRef = useRef();
2525
- const onClose = () => {
2526
- if (showOtpPhone) {
2527
- setShowOtpPhone(null);
2528
- }
2529
- else {
2530
- onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2531
- }
2532
- };
2533
- const textBlocks = JSON.parse(extraFields.textBlocks);
2534
- const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
2535
- const actionBlocks = JSON.parse(extraFields.actionBlocks);
2536
- const popUpSubmitText = actionBlocks.submitBlock.data.value;
2537
- const currentPath = location.pathname;
2538
- const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
2539
- const { align: titleAlign } = textBlocks.titleBlock.data || {};
2540
- const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
2541
- const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
2542
- const isLightBox = currentLayout.includes('LightBox');
2543
- const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
2544
- const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
2545
- const isInline = currentLayout.includes('Inline');
2546
- const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
2547
- const isInPage = isInline || isSidebar;
2548
- const isDrawer = isLightBoxB && isMobile;
2549
- const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
2550
- const hasForm = isLightBoxA
2551
- ? listBlockAdded.some((item) => LEADGEN_BLOCK_IN_FORM.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
2552
- : true;
2553
- const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
2554
- const showHeader = !!imageMobile || !!imageDesktop;
2555
- const onlyHeader = !title && !description;
2556
- const showButtonClose = !isInline;
2557
- if (window.innerWidth < 769 &&
2558
- LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
2559
- console.log('😎 Not show fullscreen, slider on mobile ');
3869
+ *
3870
+ */
3871
+ const FormContainer = (_a) => {
3872
+ var { title, titleAlign, description, descriptionAlign, className, style, children, header, footer } = _a, restProps = __rest(_a, ["title", "titleAlign", "description", "descriptionAlign", "className", "style", "children", "header", "footer"]);
3873
+ const HeaderContent = (React__default.createElement("div", { className: "leadgen-form_header" },
3874
+ React__default.createElement("h2", { title: title, className: "leadgen-title", "data-align": titleAlign }, title),
3875
+ !!description && (React__default.createElement("p", { title: description, className: "leadgen-description", "data-align": descriptionAlign, dangerouslySetInnerHTML: { __html: description } }))));
3876
+ if (!title && !description) {
3877
+ return null;
3878
+ }
3879
+ return (React__default.createElement(StyledFormContainer, Object.assign({ className: clsx(className, 'leadgen-form_container'), style: style }, restProps),
3880
+ React__default.createElement("div", { className: "leadgen-form_wrapper" },
3881
+ !!header && (React__default.createElement("div", { className: "leadgen-form_scrollable" },
3882
+ header,
3883
+ HeaderContent,
3884
+ React__default.createElement("div", { className: "leadgen-form_body" }, children))),
3885
+ !header && (React__default.createElement(React__default.Fragment, null,
3886
+ HeaderContent,
3887
+ React__default.createElement("div", { className: "leadgen-form_body" }, children))),
3888
+ React__default.createElement("div", { className: "leadgen-form_footer" }, footer))));
3889
+ };
3890
+
3891
+ const StyleHeaderImage = styled.div `
3892
+ position: relative;
3893
+ overflow: hidden;
3894
+ width: 100%;
3895
+ height: 100%;
3896
+ padding-top: ${({ paddingTop }) => paddingTop}%;
3897
+ .leadgen-header_image_feature {
3898
+ position: absolute;
3899
+ inset: 0;
3900
+ min-width: 100%;
3901
+ min-height: 100%;
3902
+ max-width: 100%;
3903
+ max-height: 100%;
3904
+ object-fit: cover;
3905
+ object-position: center;
3906
+ }
3907
+ `;
3908
+ const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
3909
+ if (!src) {
2560
3910
  return null;
2561
3911
  }
3912
+ return (React__default.createElement(StyleHeaderImage, { paddingTop: (1 / ratio) * 100, className: clsx(className, 'leadgen-header_image'), style: style }, isVideo(src) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true, className: "leadgen-header_image_feature leadgen-header_image_video", src: src })) : (React__default.createElement("img", { src: src, draggable: "false", alt: "", className: "leadgen-header_image_feature leadgen-header_image_image" }))));
3913
+ };
3914
+
3915
+ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
3916
+ const { primaryColor } = useContext(LeadGenContext$1);
3917
+ const { t } = useTranslations();
3918
+ const phone = otpData.phone;
3919
+ const otpType = otpData.type;
3920
+ const [otp, setOtp] = useState('');
3921
+ const [isDirty, setIsDirty] = useState(false);
3922
+ const [resendTimer, setResendTimer] = useState(autoSendWhenOpen ? 0 : 60);
3923
+ const inputRef = useRef(null);
3924
+ const [errorMsg, setErrorMsg] = useState();
3925
+ const [displayPhone, setDisplayPhone] = useState('');
3926
+ const formatPhoneNumberIntlRef = useRef();
3927
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
2562
3928
  useEffect(() => {
2563
- if (isLightBox || isFullscreen) {
2564
- document.body.classList.add('noscroll');
3929
+ (() => __awaiter(void 0, void 0, void 0, function* () {
3930
+ var _a;
3931
+ if (!formatPhoneNumberIntlRef.current) {
3932
+ const res = yield import('react-phone-number-input');
3933
+ formatPhoneNumberIntlRef.current = res.formatPhoneNumberIntl;
3934
+ }
3935
+ setDisplayPhone(((_a = formatPhoneNumberIntlRef.current) === null || _a === void 0 ? void 0 : _a.call(formatPhoneNumberIntlRef, phone)) || phone);
3936
+ }))();
3937
+ }, [phone]);
3938
+ const sendOtp = () => __awaiter(void 0, void 0, void 0, function* () {
3939
+ var _a;
3940
+ if (!phone) {
3941
+ return;
2565
3942
  }
2566
- if (!window.intlTelInputUtils) {
2567
- require('intl-tel-input/build/js/utils');
3943
+ const res = yield Service.sendSMSOtpLead({
3944
+ phone,
3945
+ type: otpType,
3946
+ });
3947
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
3948
+ if (respMessage === 'Send sms successfully' ||
3949
+ respMessage === 'Send WhatsApp successfully' ||
3950
+ respMessage === 'Send Zalo successfully') {
3951
+ setResendTimer(60);
3952
+ setTimeout(() => {
3953
+ if (inputRef.current) {
3954
+ inputRef.current.focus();
3955
+ inputRef.current.scrollIntoView({ block: 'center' });
3956
+ }
3957
+ }, 100);
3958
+ }
3959
+ else if (respMessage === 'This phone number was verified') {
3960
+ onSuccess();
3961
+ }
3962
+ else {
3963
+ setErrorMsg(respMessage || 'Something went wrong!');
3964
+ // const defaultError = f({ id: 'notification.comment.somethingWrong' })
3965
+ // setStatusVerifyOTP('idle')
3966
+ // pushNotifications({
3967
+ // title: respMessage || defaultError,
3968
+ // message: '',
3969
+ // type: 'danger',
3970
+ // })
2568
3971
  }
2569
- clearCacheUsedEmailOrPhone();
2570
- }, []);
2571
- const validatingPhoneRef = useRef(false);
2572
- const validatingEmailRef = useRef(false);
2573
- const { form, validateObj } = useLeadFormConfig({
2574
- listBlockAdded,
2575
- validatingPhoneRef,
2576
- validatingEmailRef,
2577
- campaignId,
2578
- campaign_subot_id,
2579
- userInfo,
2580
3972
  });
2581
- const middlewareOnSubmit = (e) => {
2582
- e.preventDefault();
2583
- // mark all as touched to allow validation
2584
- form.setTouched(Object.keys(validateObj).reduce((acc, cur) => {
2585
- acc[cur] = true;
2586
- return acc;
2587
- }, {}));
2588
- if (validatingEmailRef.current || validatingPhoneRef.current) {
3973
+ const submitOtp = () => __awaiter(void 0, void 0, void 0, function* () {
3974
+ if (!phone || !otp) {
2589
3975
  return;
2590
3976
  }
2591
- setTimeout(() => {
2592
- form.onSubmit((v) => {
2593
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2594
- if (Object.keys(form.errors).length)
2595
- return;
2596
- let newShowOtpPhone = null;
2597
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
2598
- // not submit yet, open otp
2599
- 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;
2600
- if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
2601
- newShowOtpPhone = {
2602
- phone: v[fieldName],
2603
- type: 'phone',
2604
- };
2605
- }
2606
- }
2607
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
2608
- // not submit yet, open otp
2609
- 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;
2610
- if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
2611
- newShowOtpPhone = {
2612
- phone: v[fieldName],
2613
- type: 'whatsapp',
2614
- };
2615
- }
2616
- }
2617
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
2618
- // not submit yet, open otp
2619
- 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;
2620
- if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
2621
- newShowOtpPhone = {
2622
- phone: v[fieldName],
2623
- type: 'zalo',
2624
- };
2625
- }
2626
- }
2627
- if (newShowOtpPhone) {
2628
- setIsSubmitLoading(true);
2629
- Service.sendSMSOtpLead(newShowOtpPhone)
2630
- .then((res) => {
2631
- var _a;
2632
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2633
- if (respMessage === 'This phone number was verified') {
2634
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2635
- return;
2636
- }
2637
- setShowOtpPhone(newShowOtpPhone);
2638
- })
2639
- .finally(() => {
2640
- setIsSubmitLoading(false);
2641
- });
2642
- return;
2643
- }
2644
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2645
- })(e);
2646
- }, 100);
2647
- };
2648
- const onOpenChange = (_open) => {
2649
- setOpen(_open);
2650
- if (!_open) {
2651
- setTimeout(() => {
2652
- onClose();
2653
- }, 250);
2654
- }
2655
- };
2656
- const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
2657
- const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
2658
- const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
2659
- const renderAfterImageSizes = imageMobileLoaded &&
2660
- imageDesktopLoaded &&
2661
- (isFullscreen ? imageBackgroundLoaded : true);
2662
- const ButtonSubmit = !((_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", color: primaryColor, loading: isSubmitLoading }, popUpSubmitText));
2663
- const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
2664
- const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default.createElement(React__default.Fragment, null, LinkButtonBlock.map((item, index) => {
2665
- var _a, _b, _c;
2666
- 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: () => {
2667
- onClose === null || onClose === void 0 ? void 0 : onClose();
2668
- onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2669
- } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
2670
- })));
2671
- 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,
2672
- React__default.createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
2673
- React__default.createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
2674
- const PopupEmpty = showEmpty && (React__default.createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
2675
- const PopupForm = (React__default.createElement(LeadFormProvider, { form: form },
2676
- React__default.createElement("form", { ref: formRef, className: "leadgen-form", onSubmit: middlewareOnSubmit },
2677
- React__default.createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
2678
- React__default.createElement("div", { className: "leadgen-form_inner" },
2679
- React__default.createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
2680
- const PopupOtp = showOtpPhone && (React__default.createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
2681
- setShowOtpPhone(null);
2682
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
2683
- } }));
2684
- 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 }));
2685
- const PopupContent = (React__default.createElement("div", { className: clsx('leadgen-content', {
2686
- 'leadgen-content_small': limitFieldsLightBoxB,
2687
- }) },
2688
- !headerInsideFormContainer && PopupHeader,
2689
- !onlyHeader && (React__default.createElement("div", { className: "leadgen-inner" },
2690
- PopupThankYou,
2691
- !showThankyou && (React__default.createElement(React__default.Fragment, null,
2692
- PopupOtp,
2693
- PopupEmpty,
2694
- !(showOtpPhone || showEmpty) && PopupForm))))));
2695
- const styleOverlay = useMemo(() => {
2696
- let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
2697
- if (isMobile && imageOverlayMobile) {
2698
- styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
3977
+ setIsSubmitLoading(true);
3978
+ const res = yield Service.verifyOtpLead({
3979
+ phone,
3980
+ otp,
3981
+ type: otpType,
3982
+ });
3983
+ const respMessage = res === null || res === void 0 ? void 0 : res._messages[0];
3984
+ if (respMessage === 'Verify successfully' ||
3985
+ respMessage === 'Verify WhatsApp OTP sucess' ||
3986
+ respMessage === 'Verify Zalo OTP sucess') {
3987
+ onSuccess();
2699
3988
  }
2700
- if (!isMobile && imageOverlayDesktop) {
2701
- styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
3989
+ else if (respMessage === 'This phone number was verified') {
3990
+ onSuccess();
2702
3991
  }
2703
- return styleContent;
2704
- }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
2705
- const PopupWrapper = (React__default.createElement(React__default.Fragment, null,
2706
- React__default.createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
2707
- React__default.createElement("div", { className: clsx('leadgen-wrapper', {
2708
- 'leadgen-wrapper_small': limitFieldsLightBoxB,
2709
- }) },
2710
- showButtonClose && (React__default.createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
2711
- PopupContent)));
2712
- const popupContainerClassName = clsx('leadgen', `leadgen-${currentLayout}`, {
2713
- 'leadgen-lightbox': isLightBox,
2714
- 'leadgen-inline': isInPage,
2715
- 'leadgen-slider': isSlider,
3992
+ else {
3993
+ setErrorMsg(respMessage || 'something Wrong');
3994
+ // setIsShowError(true)
3995
+ // setStatusVerifyOTP('sent')
3996
+ // pushNotifications({
3997
+ // title: res?._messages[0] || defaultError,
3998
+ // message: '',
3999
+ // type: 'danger',
4000
+ // })
4001
+ }
4002
+ setIsSubmitLoading(false);
2716
4003
  });
2717
- 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" },
2718
- PopupWrapper,
2719
- 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 },
2720
- isFullscreen ? (React__default.createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
2721
- aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
2722
- } })) : null,
2723
- PopupWrapper));
2724
- if (!renderAfterImageSizes)
2725
- return null;
2726
- if (isLightBox || isFullscreen || isSlider) {
2727
- return PopupContainer;
2728
- }
2729
- else if (isSidebar) {
2730
- return React__default.createElement(SideBarLayout, { content: PopupContainer });
2731
- }
2732
- else if (isInline) {
2733
- return (React__default.createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
2734
- }
2735
- return null;
2736
- };
2737
-
2738
- const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
2739
- const currentPath = location.pathname;
2740
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
2741
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
2742
- if (!imageMobileLoaded || !imageDesktopLoaded)
2743
- return null;
2744
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
2745
- currentLayout == 'SkinA' ? (React__default.createElement("aside", { className: "le-only-desktop" },
2746
- React__default.createElement("div", { className: "le-skin-a-desktop" },
2747
- React__default.createElement("div", { style: { position: 'relative' } },
2748
- React__default.createElement("img", { src: imageDesktop, style: {
2749
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2750
- } }),
2751
- React__default.createElement("a", { style: {
2752
- position: 'absolute',
2753
- top: '75%',
2754
- left: '50%',
2755
- transform: 'translate(-50%, -50%)',
2756
- textAlign: 'center',
2757
- width: 'calc(100% - 15px)',
2758
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2759
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
2760
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default.createElement("aside", { className: "le-only-desktop" },
2761
- React__default.createElement("div", { className: "" },
2762
- React__default.createElement("div", { style: { position: 'relative', zIndex: 10000 } },
2763
- React__default.createElement("img", { src: imageDesktop, style: {
2764
- width: '100%',
2765
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2766
- } }),
2767
- React__default.createElement("a", { style: {
2768
- position: 'absolute',
2769
- top: '75%',
2770
- left: '50%',
2771
- transform: 'translate(-50%, -50%)',
2772
- textAlign: 'center',
2773
- width: '100%',
2774
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2775
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2776
- React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
2777
- React__default.createElement("aside", { className: "le-only-mobile" },
2778
- React__default.createElement("div", { className: "le-skin-mobile" },
2779
- React__default.createElement("div", { style: { position: 'relative' } },
2780
- isVideo(imageMobile) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true },
2781
- React__default.createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default.createElement("img", { src: imageMobile, style: {
2782
- width: '100%',
2783
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
2784
- } })),
2785
- React__default.createElement("a", { style: {
2786
- position: 'absolute',
2787
- top: '82%',
2788
- left: '50%',
2789
- transform: 'translate(-50%, -50%)',
2790
- textAlign: 'center',
2791
- maxWidth: 'calc(100% - 15px)',
2792
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2793
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2794
- React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4004
+ useEffect(() => {
4005
+ setTimeout(() => {
4006
+ if (resendTimer > 0) {
4007
+ setResendTimer((r) => r - 1);
4008
+ }
4009
+ }, 1000);
4010
+ }, [resendTimer]);
4011
+ useEffect(() => {
4012
+ if (autoSendWhenOpen && !resendTimer) {
4013
+ sendOtp();
4014
+ }
4015
+ }, []);
4016
+ return (React__default.createElement("form", { onSubmit: (e) => {
4017
+ e.preventDefault();
4018
+ submitOtp();
4019
+ }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
4020
+ React__default.createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
4021
+ phone: `<strong>${displayPhone}</strong>`,
4022
+ }), footer: React__default.createElement(React__default.Fragment, null,
4023
+ 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')),
4024
+ 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: () => {
4025
+ sendOtp();
4026
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
4027
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
4028
+ }))) },
4029
+ React__default.createElement("div", { className: "leadgen-form_inner" },
4030
+ React__default.createElement(Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
4031
+ React__default.createElement(OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
4032
+ setIsDirty(true);
4033
+ setOtp(v.toString());
4034
+ if (isDirty && !v)
4035
+ setErrorMsg('OTP is required');
4036
+ else
4037
+ setErrorMsg(undefined);
4038
+ } }))))));
2795
4039
  };
2796
4040
 
2797
4041
  // url: imageBlocks.imageMobile.data.url
2798
4042
  // newTab: imageBlocks.imageMobile.data.newtab
2799
4043
  // image: campaignShow.image
2800
4044
  // imageDestkop: campaignShow.image_desktop
2801
- const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
2802
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
2803
- if (!imageLoaded)
2804
- return null;
2805
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
2806
- React__default.createElement("div", { className: "le-tab-popup" },
2807
- React__default.createElement("div", { style: { position: 'relative' } },
2808
- React__default.createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
2809
- React__default.createElement("img", { className: "js-popup-other-submit", src: image, style: {
2810
- aspectRatio: `${imageWidth}/${imageHeight}`,
2811
- } })),
2812
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
2813
- };
2814
-
2815
- // import mockLeadData from './mockLeadData'
2816
- const listCampaignScheduled = [];
2817
- const listCampaignScheduledToActivated = [];
2818
- const listCampaignActiveButExpired = [];
2819
- const listCampaignExcludeSonsored = [];
2820
- const listCampaignDifferentSponsor = [];
2821
- const listCampaignNotDisplayInRangeOfTime = [];
2822
- function isMobile() {
2823
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
2824
- }
2825
- const getShuffleArray = (array) => {
2826
- const newArray = [...array];
2827
- for (let i = newArray.length - 1; i > 0; i--) {
2828
- const j = Math.floor(Math.random() * (i + 1));
2829
- const temp = newArray[i];
2830
- newArray[i] = newArray[j];
2831
- newArray[j] = temp;
2832
- }
2833
- return newArray;
2834
- };
2835
- const getTimeByTimezone = (timeZone = 'UTC') => {
2836
- const date = new Date();
2837
- return new Date(date.toLocaleString('en-US', { timeZone }));
2838
- };
2839
- const parseDateByCampaignTime = (dateStr) => {
2840
- // Format like this: 2023-04-04 00:00:00
2841
- try {
2842
- const [datePart, timePart] = dateStr.split(' ');
2843
- const [year, month, day] = datePart.split('-').map(Number);
2844
- const [hours, minutes, seconds] = timePart.split(':').map(Number);
2845
- /** JavaScript counts months from 0 to 11 */
2846
- return new Date(year, month - 1, day, hours, minutes, seconds);
2847
- }
2848
- catch (err) {
2849
- return null;
2850
- }
2851
- };
2852
- const checkCampaignNowInTimeframe = (c) => {
2853
- var _a;
2854
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2855
- const startedAtStr = c.started_at;
2856
- const endedAtStr = c.ended_at;
2857
- const startedDate = parseDateByCampaignTime(startedAtStr);
2858
- const endedDate = parseDateByCampaignTime(endedAtStr);
2859
- if (!startedDate || !endedDate) {
2860
- return false;
2861
- }
2862
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
2863
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2864
- if (nowWithTimezoneMs <= endedDate.getTime() &&
2865
- nowWithTimezoneMs >= startedDate.getTime()) {
2866
- listCampaignScheduledToActivated.push(c);
2867
- return true;
2868
- }
2869
- return false;
2870
- };
2871
- function checkCampaignActiveButExpireAlready(c) {
2872
- var _a;
2873
- /** Do not setup timeframe for this campaign. No need to check */
2874
- if (c.forever === 1) {
2875
- return true;
2876
- }
2877
- const startedAtStr = c.started_at;
2878
- const endedAtStr = c.ended_at;
2879
- const startedDate = parseDateByCampaignTime(startedAtStr);
2880
- const endedDate = parseDateByCampaignTime(endedAtStr);
2881
- /** Do not setup timeframe for this campaign. No need to check */
2882
- if (!startedDate || !endedDate) {
2883
- return true;
2884
- }
2885
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2886
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
2887
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2888
- /** Check if this expire already, do not show */
2889
- if (nowWithTimezoneMs > endedDate.getTime()) {
2890
- listCampaignActiveButExpired.push(c);
2891
- return false;
2892
- }
2893
- return true;
2894
- }
2895
- function shouldNotDisplayIfExcludeAllSponsors(c) {
2896
- var _a;
2897
- const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
2898
- const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
2899
- if (isSponsored && excludeSponsored) {
2900
- listCampaignExcludeSonsored.push(c);
2901
- return true;
2902
- }
2903
- return false;
2904
- }
2905
- function shouldDisplayWithCurrentSponsor(c) {
4045
+ const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
4046
+ LEADGEN_LAYOUT.Fullscreen,
4047
+ LEADGEN_LAYOUT.Slider,
4048
+ ];
4049
+ const LEADGEN_LIMIT_LIGHTBOXB = 6;
4050
+ const LEADGEN_SHOW_HEADER = [
4051
+ 'LightBoxA',
4052
+ 'InlineA',
4053
+ LEADGEN_LAYOUT.Sidebar,
4054
+ LEADGEN_LAYOUT.Slider,
4055
+ ];
4056
+ const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2906
4057
  var _a, _b;
2907
- try {
2908
- // TODO: BE will rename `exclude_sponsored_list` later
2909
- const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
2910
- const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
2911
- const dataSponsoredId = Number((_b = document
2912
- .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
2913
- // There is no config for sponsor id and white list, should show as default
2914
- if (!dataSponsoredId ||
2915
- dataSponsoredId <= 0 ||
2916
- whiteListSponsors.length === 0) {
2917
- return true;
4058
+ const { primaryColor } = useContext(LeadGenContext$1);
4059
+ const { isMobile } = useScreenSize();
4060
+ const [open, setOpen] = useState(!!campaignId);
4061
+ const [showOtpPhone, setShowOtpPhone] = useState(null);
4062
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
4063
+ const [snap, setSnap] = useState(0.8);
4064
+ const formRef = useRef();
4065
+ const onClose = () => {
4066
+ if (showOtpPhone) {
4067
+ setShowOtpPhone(null);
2918
4068
  }
2919
- // Check the dataSponsoredId exists in the white list or not.
2920
- const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
2921
- if (isExist) {
2922
- return true;
4069
+ else {
4070
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2923
4071
  }
2924
- listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
2925
- return false;
2926
- }
2927
- catch (err) {
2928
- // Default is show
2929
- return true;
2930
- }
2931
- }
2932
- const filterFnCampaign = (c) => {
2933
- if (shouldNotDisplayIfExcludeAllSponsors(c)) {
2934
- return false;
2935
- }
2936
- else if (!shouldDisplayWithCurrentSponsor(c)) {
2937
- return false;
2938
- }
2939
- /** Active */
2940
- if (c.formatted_status === 1) {
2941
- return checkCampaignActiveButExpireAlready(c);
2942
- }
2943
- /** Schedule */
2944
- if (c.formatted_status === 0) {
2945
- listCampaignScheduled.push(c);
2946
- return checkCampaignNowInTimeframe(c);
4072
+ };
4073
+ const textBlocks = JSON.parse(extraFields.textBlocks);
4074
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
4075
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
4076
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
4077
+ const currentPath = location.pathname;
4078
+ const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
4079
+ const { align: titleAlign } = textBlocks.titleBlock.data || {};
4080
+ const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
4081
+ const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
4082
+ const isLightBox = currentLayout.includes('LightBox');
4083
+ const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
4084
+ const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
4085
+ const isInline = currentLayout.includes('Inline');
4086
+ const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
4087
+ const isInPage = isInline || isSidebar;
4088
+ const isDrawer = isLightBoxB && isMobile;
4089
+ const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
4090
+ const hasForm = isLightBoxA
4091
+ ? listBlockAdded.some((item) => LEADGEN_BLOCK_INPUT.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
4092
+ : true;
4093
+ const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
4094
+ const showHeader = !!imageMobile || !!imageDesktop;
4095
+ const onlyHeader = !title && !description;
4096
+ const showButtonClose = !isInline;
4097
+ if (window.innerWidth < 769 &&
4098
+ LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
4099
+ console.log('😎 Not show fullscreen, slider on mobile ');
4100
+ return null;
2947
4101
  }
2948
- return false;
2949
- };
2950
- const fillterApprearanceTimeCampaign = (c) => {
2951
- var _a;
2952
- try {
2953
- const isTimeInRange = (currentTime, startTime, endTime) => {
2954
- const startParts = startTime.split(':');
2955
- const endParts = endTime.split(':');
2956
- const startDate = new Date();
2957
- startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
2958
- const endDate = new Date();
2959
- endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
2960
- return currentTime >= startDate && currentTime <= endDate;
2961
- };
2962
- const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
2963
- const startTime = rulesApprValue.startTime;
2964
- const endTime = rulesApprValue.endTime || '23:59';
2965
- if (!startTime) {
2966
- return true;
4102
+ useEffect(() => {
4103
+ if (isLightBox || isFullscreen) {
4104
+ document.body.classList.add('noscroll');
2967
4105
  }
2968
- if (isTimeInRange(new Date(), startTime, endTime)) {
2969
- return true;
4106
+ if (!window.intlTelInputUtils) {
4107
+ require('intl-tel-input/build/js/utils');
2970
4108
  }
2971
- listCampaignNotDisplayInRangeOfTime.push(c);
2972
- return false;
2973
- }
2974
- catch (err) {
2975
- return true;
2976
- }
2977
- };
2978
- let timeoutRef = null;
2979
- let LEAD_SCROLL_EVENT = null;
2980
- function clearPassiveEvent() {
2981
- if (timeoutRef) {
2982
- clearTimeout(timeoutRef);
2983
- timeoutRef = null;
2984
- }
2985
- if (LEAD_SCROLL_EVENT) {
2986
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
2987
- LEAD_SCROLL_EVENT = null;
2988
- }
2989
- }
2990
- function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
2991
- // clear previous passive event, check for new condition
2992
- clearPassiveEvent();
2993
- const leadCurrentUrl = DEBUG_URL ||
2994
- ('https://' +
2995
- location.hostname +
2996
- location.pathname +
2997
- location.search).toLowerCase();
2998
- fetch(leadApi + 'api/campaign/' + leadSiteId, {
2999
- method: 'POST',
3000
- headers: {
3001
- 'Content-Type': 'application/json',
3002
- },
3003
- body: JSON.stringify({
3004
- url: leadCurrentUrl,
3005
- ga_client_id: getCookie('_ga') || null,
3006
- }),
3007
- })
3008
- .then((response) => {
3009
- return response.json();
3010
- // return mockLeadData || response.json()
3011
- })
3012
- .then((data) => {
3013
- var _a, _b, _c, _d;
3014
- LeadLog('List campagin: ', data);
3015
- LEAD_RESET_VAR();
3016
- if (data._status == 1) {
3017
- 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);
3018
- if (!getCookie('hhg-id')) {
3019
- setCookie('hhg-id', v1(), {
3020
- domain: '.' + leadDomain,
3021
- path: '/',
3022
- });
3023
- LeadLog('😍 Set HHG ID cookie');
3024
- }
3025
- // getCookie('hhg-id')
3026
- // TODO: HP-534 Filter desktop
3027
- let campaignsDevice = [];
3028
- if (isMobile()) {
3029
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
3030
- }
3031
- else {
3032
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
3033
- }
3034
- LeadLog(`👓 campaignsDevice`, campaignsDevice);
3035
- LeadLog('--listCampaignScheduled', listCampaignScheduled);
3036
- LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
3037
- LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
3038
- LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
3039
- LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
3040
- LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
3041
- // Check links
3042
- let listLinksObj = campaignsDevice
3043
- .map((i, index) => i.targets
3044
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
3045
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3046
- .flat(1);
3047
- // Check list link match current href
3048
- listLinksObj = listLinksObj.filter((i) => {
3049
- var _a;
3050
- const target = new URL(String(i.target).toLowerCase());
3051
- if (i.option == 'exact_match')
3052
- // FOR TEST LOCAL:
3053
- // return Boolean(location.pathname === target.pathname)
3054
- return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
3055
- if (i.option == 'start_with') {
3056
- // FOR TEST LOCAL:
3057
- // if (location.pathname.includes(target.pathname)) {
3058
- if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
3059
- const listExcluding = i.sub_target
3060
- .filter((i) => i.option == 'excluding')
3061
- .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
3062
- return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
3063
- }
3064
- else {
3065
- return false;
3066
- }
3067
- }
3068
- });
3069
- // Check tags
3070
- const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
3071
- const listTags = listMetaTag.map((i) => i.content);
3072
- let listCampaignHasTag = [];
3073
- let listTagsObj = [];
3074
- if (listTags && listTags.length) {
3075
- listCampaignHasTag = campaignsDevice
3076
- .map((i, index) => i.targets
3077
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
3078
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3079
- .flat(1);
3080
- listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
3081
- }
3082
- const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
3083
- const cookieKeys = document.cookie
3084
- .split('; ')
3085
- .map((i) => i.split('=')[0]);
3086
- const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
3087
- LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
3088
- const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
3089
- LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
3090
- const listCampaignSubmitedClosed = [
3091
- ...listCampaignCodeSubmited,
3092
- ...listCampaignCodeClosed,
3093
- ];
3094
- const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
3095
- const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
3096
- return !hasSubmited;
3097
- });
3098
- const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
3099
- // .sort(
3100
- // (a, b) =>
3101
- // (listCampaignValid[a.campaignIndex]?.score || 0) -
3102
- // (listCampaignValid[b.campaignIndex]?.score || 0),
3103
- // )
3104
- LeadLog('--listCampaignValid : ', listCampaignValid);
3105
- if (listCampaignValid && listCampaignValid.length) {
3106
- const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
3107
- LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
3108
- const { rules } = CAMPAIGN_SHOW;
3109
- // CHECK RULE TRIGGER POPUP
3110
- const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
3111
- LeadLog(`timeoutRule`, timeoutRule);
3112
- const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
3113
- LeadLog(`scrollRule`, scrollRule);
3114
- let impressionAction = 'TIME';
3115
- if (Number.isInteger(timeoutRule)) {
3116
- impressionAction = 'TIME';
3117
- LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
3118
- timeoutRef = setTimeout(() => {
3119
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3120
- }, timeoutRule * 1000);
4109
+ clearCacheUsedEmailOrPhone();
4110
+ }, []);
4111
+ const validatingPhoneRef = useRef(false);
4112
+ const validatingEmailRef = useRef(false);
4113
+ const { form, validateObj } = useLeadFormConfig({
4114
+ listBlockAdded,
4115
+ validatingPhoneRef,
4116
+ validatingEmailRef,
4117
+ campaignId,
4118
+ campaign_subot_id,
4119
+ userInfo,
4120
+ format: (_a = (ISO_FORMAT[locale] || ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
4121
+ });
4122
+ const onFocus = (e) => {
4123
+ const target = e.target;
4124
+ target.scrollIntoView({
4125
+ block: 'center',
4126
+ inline: 'nearest',
4127
+ behavior: 'auto',
4128
+ });
4129
+ };
4130
+ const middlewareOnSubmit = (e) => {
4131
+ e.preventDefault();
4132
+ // mark all as touched to allow validation
4133
+ const fields = Object.keys(validateObj);
4134
+ const fieldStatus = fields.reduce((acc, cur) => {
4135
+ acc[cur] = true;
4136
+ return acc;
4137
+ }, {});
4138
+ form.setTouched(fieldStatus);
4139
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
4140
+ return;
4141
+ }
4142
+ setTimeout(() => {
4143
+ form.onSubmit((v) => {
4144
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4145
+ if (Object.keys(form.errors).length)
4146
+ return;
4147
+ let newShowOtpPhone = null;
4148
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
4149
+ // not submit yet, open otp
4150
+ 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;
4151
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
4152
+ newShowOtpPhone = {
4153
+ phone: v[fieldName],
4154
+ type: 'phone',
4155
+ };
4156
+ }
3121
4157
  }
3122
- if (Number.isInteger(scrollRule)) {
3123
- impressionAction = 'SCROLL';
3124
- LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
3125
- const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
3126
- document.querySelector('body');
3127
- const pct = $p.getBoundingClientRect().top;
3128
- const pb = $p.offsetHeight;
3129
- LeadLog(`👓 Element check scroll: `, $p);
3130
- LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
3131
- const wt = window.pageYOffset || document.documentElement.scrollTop;
3132
- let percent = 0;
3133
- if (wt >= pct) {
3134
- percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
3135
- }
3136
- LeadLog('---Scroll', percent, scrollRule);
3137
- // TODO: CHECK FOOTER HEIGHT
3138
- if (percent >= scrollRule) {
3139
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3140
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
4158
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
4159
+ // not submit yet, open otp
4160
+ 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;
4161
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
4162
+ newShowOtpPhone = {
4163
+ phone: v[fieldName],
4164
+ type: 'whatsapp',
4165
+ };
4166
+ }
4167
+ }
4168
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
4169
+ // not submit yet, open otp
4170
+ 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;
4171
+ if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
4172
+ newShowOtpPhone = {
4173
+ phone: v[fieldName],
4174
+ type: 'zalo',
4175
+ };
4176
+ }
4177
+ }
4178
+ if (newShowOtpPhone) {
4179
+ setIsSubmitLoading(true);
4180
+ Service.sendSMSOtpLead(newShowOtpPhone)
4181
+ .then((res) => {
4182
+ var _a;
4183
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4184
+ if (respMessage === 'This phone number was verified') {
4185
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4186
+ return;
3141
4187
  }
3142
- };
3143
- window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
3144
- passive: true,
4188
+ setShowOtpPhone(newShowOtpPhone);
4189
+ })
4190
+ .finally(() => {
4191
+ setIsSubmitLoading(false);
3145
4192
  });
4193
+ return;
3146
4194
  }
3147
- }
3148
- else {
3149
- LeadLog('🚧 No lead campaigns on current URL, tags');
3150
- }
4195
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4196
+ })(e);
4197
+ }, 100);
4198
+ };
4199
+ const onOpenChange = (_open) => {
4200
+ setOpen(_open);
4201
+ if (!_open) {
4202
+ setTimeout(() => {
4203
+ onClose();
4204
+ }, 250);
3151
4205
  }
3152
- })
3153
- .catch((err) => {
3154
- LeadLog(`Lead error: `, err);
4206
+ };
4207
+ const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
4208
+ const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
4209
+ const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
4210
+ const renderAfterImageSizes = imageMobileLoaded &&
4211
+ imageDesktopLoaded &&
4212
+ (isFullscreen ? imageBackgroundLoaded : true);
4213
+ const ButtonSubmit = useMemo(() => {
4214
+ var _a;
4215
+ 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));
4216
+ }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
4217
+ const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
4218
+ const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default.createElement(React__default.Fragment, null, LinkButtonBlock.map((item, index) => {
4219
+ var _a, _b, _c;
4220
+ 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: () => {
4221
+ onClose === null || onClose === void 0 ? void 0 : onClose();
4222
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
4223
+ } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
4224
+ })));
4225
+ 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,
4226
+ React__default.createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
4227
+ React__default.createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
4228
+ const PopupEmpty = showEmpty && (React__default.createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
4229
+ const PopupForm = (React__default.createElement(LeadFormProvider, { form: form },
4230
+ React__default.createElement("form", { ref: formRef, className: "leadgen-form", onFocus: onFocus, onSubmit: middlewareOnSubmit },
4231
+ React__default.createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
4232
+ React__default.createElement("div", { className: "leadgen-form_inner" },
4233
+ React__default.createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
4234
+ const PopupOtp = showOtpPhone && (React__default.createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
4235
+ setShowOtpPhone(null);
4236
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
4237
+ } }));
4238
+ 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 }));
4239
+ const PopupContent = (React__default.createElement("div", { className: clsx('leadgen-content', {
4240
+ 'leadgen-content_small': limitFieldsLightBoxB,
4241
+ }) },
4242
+ !headerInsideFormContainer && PopupHeader,
4243
+ !onlyHeader && (React__default.createElement("div", { className: "leadgen-inner" },
4244
+ PopupThankYou,
4245
+ !showThankyou && (React__default.createElement(React__default.Fragment, null,
4246
+ PopupOtp,
4247
+ PopupEmpty,
4248
+ !(showOtpPhone || showEmpty) && PopupForm))))));
4249
+ const styleOverlay = useMemo(() => {
4250
+ let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
4251
+ if (isMobile && imageOverlayMobile) {
4252
+ styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4253
+ }
4254
+ if (!isMobile && imageOverlayDesktop) {
4255
+ styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4256
+ }
4257
+ return styleContent;
4258
+ }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
4259
+ const PopupWrapper = (React__default.createElement(React__default.Fragment, null,
4260
+ React__default.createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
4261
+ React__default.createElement("div", { className: clsx('leadgen-wrapper', {
4262
+ 'leadgen-wrapper_small': limitFieldsLightBoxB,
4263
+ }) },
4264
+ showButtonClose && (React__default.createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
4265
+ PopupContent)));
4266
+ const popupContainerClassName = clsx('leadgen', `leadgen-${currentLayout}`, {
4267
+ 'leadgen-lightbox': isLightBox,
4268
+ 'leadgen-inline': isInPage,
4269
+ 'leadgen-slider': isSlider,
3155
4270
  });
3156
- }
3157
- const LeadLog = (...params) => {
3158
- if (process.env.NODE_ENV !== 'production' ||
3159
- (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
3160
- process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
3161
- (typeof localStorage !== 'undefined' &&
3162
- localStorage.getItem('hhg_debug') === 'true')) {
3163
- console.log(...params);
4271
+ 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" },
4272
+ PopupWrapper,
4273
+ 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 },
4274
+ isFullscreen ? (React__default.createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
4275
+ aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
4276
+ } })) : null,
4277
+ PopupWrapper));
4278
+ if (!renderAfterImageSizes)
4279
+ return null;
4280
+ if (isLightBox || isFullscreen || isSlider) {
4281
+ return PopupContainer;
4282
+ }
4283
+ else if (isSidebar) {
4284
+ return React__default.createElement(SideBarLayout, { content: PopupContainer });
4285
+ }
4286
+ else if (isInline) {
4287
+ return (React__default.createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
3164
4288
  }
4289
+ return null;
4290
+ };
4291
+
4292
+ const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
4293
+ const currentPath = location.pathname;
4294
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
4295
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
4296
+ if (!imageMobileLoaded || !imageDesktopLoaded)
4297
+ return null;
4298
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
4299
+ currentLayout == 'SkinA' ? (React__default.createElement("aside", { className: "le-only-desktop" },
4300
+ React__default.createElement("div", { className: "le-skin-a-desktop" },
4301
+ React__default.createElement("div", { style: { position: 'relative' } },
4302
+ React__default.createElement("img", { src: imageDesktop, style: {
4303
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4304
+ } }),
4305
+ React__default.createElement("a", { style: {
4306
+ position: 'absolute',
4307
+ top: '75%',
4308
+ left: '50%',
4309
+ transform: 'translate(-50%, -50%)',
4310
+ textAlign: 'center',
4311
+ width: 'calc(100% - 15px)',
4312
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4313
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
4314
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default.createElement("aside", { className: "le-only-desktop" },
4315
+ React__default.createElement("div", { className: "" },
4316
+ React__default.createElement("div", { style: { position: 'relative', zIndex: 10000 } },
4317
+ React__default.createElement("img", { src: imageDesktop, style: {
4318
+ width: '100%',
4319
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4320
+ } }),
4321
+ React__default.createElement("a", { style: {
4322
+ position: 'absolute',
4323
+ top: '75%',
4324
+ left: '50%',
4325
+ transform: 'translate(-50%, -50%)',
4326
+ textAlign: 'center',
4327
+ width: '100%',
4328
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4329
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4330
+ React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
4331
+ React__default.createElement("aside", { className: "le-only-mobile" },
4332
+ React__default.createElement("div", { className: "le-skin-mobile" },
4333
+ React__default.createElement("div", { style: { position: 'relative' } },
4334
+ isVideo(imageMobile) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true },
4335
+ React__default.createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default.createElement("img", { src: imageMobile, style: {
4336
+ width: '100%',
4337
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
4338
+ } })),
4339
+ React__default.createElement("a", { style: {
4340
+ position: 'absolute',
4341
+ top: '82%',
4342
+ left: '50%',
4343
+ transform: 'translate(-50%, -50%)',
4344
+ textAlign: 'center',
4345
+ maxWidth: 'calc(100% - 15px)',
4346
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4347
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4348
+ React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4349
+ };
4350
+
4351
+ // url: imageBlocks.imageMobile.data.url
4352
+ // newTab: imageBlocks.imageMobile.data.newtab
4353
+ // image: campaignShow.image
4354
+ // imageDestkop: campaignShow.image_desktop
4355
+ const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
4356
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
4357
+ if (!imageLoaded)
4358
+ return null;
4359
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
4360
+ React__default.createElement("div", { className: "le-tab-popup" },
4361
+ React__default.createElement("div", { style: { position: 'relative' } },
4362
+ React__default.createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
4363
+ React__default.createElement("img", { className: "js-popup-other-submit", src: image, style: {
4364
+ aspectRatio: `${imageWidth}/${imageHeight}`,
4365
+ } })),
4366
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3165
4367
  };
3166
4368
 
3167
4369
  function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
@@ -3177,7 +4379,7 @@ function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
3177
4379
  }
3178
4380
  const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, showEmpty, setShowEmpty, userInfo, }) => {
3179
4381
  var _a, _b;
3180
- const { apiUrl, siteDomain } = useContext(LeadGenContext);
4382
+ const { apiUrl, siteDomain } = useContext(LeadGenContext$1);
3181
4383
  useEffect(() => {
3182
4384
  const gaCookie = getCookie('_ga') || null;
3183
4385
  fetch(`${apiUrl}api/campaign/${code}/impression`, {
@@ -3572,7 +4774,7 @@ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, primaryColor
3572
4774
  leadStartTimeRef.current = Date.now();
3573
4775
  }
3574
4776
  }, [showCampaign]);
3575
- return (React__default.createElement(LeadGenContext.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
4777
+ return (React__default.createElement(LeadGenContext$1.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
3576
4778
  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() },
3577
4779
  React__default.createElement(Box, { sx: { position: 'fixed', zIndex: ZINDEX_SSO - 9e6 } },
3578
4780
  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) => {
@@ -3592,4 +4794,4 @@ LeadGen.Thankyou = Thankyou;
3592
4794
  LeadGen.OtpForm = OtpBlock$1;
3593
4795
  LeadGen.Close = Close;
3594
4796
 
3595
- export { LeadGen };
4797
+ export { LeadGen, LeadGenSubscriptionBox };