@hhgtech/hhg-components 1.29.374 → 1.29.375-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 (541) hide show
  1. package/build/{InputDate-8b579da2.js → InputDate-20926325.js} +3 -3
  2. package/build/{LastPeriod-64e1601a.js → LastPeriod-51fd8dbe.js} +1 -1
  3. package/build/{Locale-72dce976.js → Locale-8ad13864.js} +1 -0
  4. package/build/{MobileBottomNavigationIcon-d51ca59a.js → MobileBottomNavigationIcon-a0a94f1d.js} +3 -3
  5. package/build/{Spinner-883e6f71.js → Spinner-0497cae7.js} +1 -1
  6. package/build/{WhatsApp-52413156.js → WhatsApp-0e3e2817.js} +1 -1
  7. package/build/adapters.js +19 -19
  8. package/build/atoms.js +48 -48
  9. package/build/babyGrowth.js +83 -83
  10. package/build/cache.js +2 -2
  11. package/build/care.js +17 -17
  12. package/build/careBookingSearchBar.js +14 -14
  13. package/build/careBookingSearchBarV2.js +15 -15
  14. package/build/components/atoms/logo/index.d.ts +1 -1
  15. package/build/components/mantine/phone/index.d.ts +2 -0
  16. package/build/components/mantine/phoneInput/PhoneInput.d.ts +17 -0
  17. package/build/components/mantine/phoneInput/index.d.ts +1 -0
  18. package/build/components.js +97 -96
  19. package/build/{constants-171f25c7.js → constants-0c329810.js} +1 -0
  20. package/build/{constants-4fc45016.js → constants-cd5a73f8.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-49c30866.js → core-047019ba.js} +1 -1
  26. package/build/{dataTransform-9fcb6f21.js → dataTransform-f3eb573f.js} +1 -1
  27. package/build/ecom.js +4 -4
  28. package/build/{editor-f38876f9.js → editor-93875927.js} +11 -11
  29. package/build/embeddedHeathToolCards_babyGrowth.js +23 -23
  30. package/build/embeddedHeathToolCards_babyPoop.js +19 -19
  31. package/build/embeddedHeathToolCards_babyVaccine.js +22 -22
  32. package/build/embeddedHeathToolCards_bmi_bmi.js +25 -25
  33. package/build/embeddedHeathToolCards_bmrBmr.js +25 -25
  34. package/build/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  35. package/build/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  36. package/build/embeddedHeathToolCards_pwg_pwg.js +26 -26
  37. package/build/embeddedHeathToolCards_targetHeartRate.js +27 -27
  38. package/build/esm/{InputDate-86cf8a56.js → InputDate-cb433d87.js} +3 -3
  39. package/build/esm/{LastPeriod-f7751d88.js → LastPeriod-e4189fa8.js} +1 -1
  40. package/build/esm/{Locale-3430abbb.js → Locale-100fdeac.js} +1 -0
  41. package/build/esm/{MobileBottomNavigationIcon-9c8475b0.js → MobileBottomNavigationIcon-f45959d0.js} +3 -3
  42. package/build/esm/{Spinner-926cb3b3.js → Spinner-c1b37824.js} +1 -1
  43. package/build/esm/{WhatsApp-e29f71ae.js → WhatsApp-694d812e.js} +1 -1
  44. package/build/esm/adapters.js +19 -19
  45. package/build/esm/atoms.js +48 -48
  46. package/build/esm/babyGrowth.js +83 -83
  47. package/build/esm/cache.js +2 -2
  48. package/build/esm/care.js +17 -17
  49. package/build/esm/careBookingSearchBar.js +14 -14
  50. package/build/esm/careBookingSearchBarV2.js +15 -15
  51. package/build/esm/components/atoms/logo/index.d.ts +1 -1
  52. package/build/esm/components/mantine/phone/index.d.ts +2 -0
  53. package/build/esm/components/mantine/phoneInput/PhoneInput.d.ts +17 -0
  54. package/build/esm/components/mantine/phoneInput/index.d.ts +1 -0
  55. package/build/esm/components.js +97 -96
  56. package/build/esm/{constants-030b17c7.js → constants-875acddc.js} +1 -1
  57. package/build/esm/{constants-8772c2b0.js → constants-bdee8ee2.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-55455f88.js → core-53be81d9.js} +1 -1
  63. package/build/esm/{dataTransform-a7848bdc.js → dataTransform-0b64a127.js} +1 -1
  64. package/build/esm/ecom.js +4 -4
  65. package/build/esm/{editor-377b7f2b.js → editor-382b94f1.js} +11 -11
  66. package/build/esm/embeddedHeathToolCards_babyGrowth.js +23 -23
  67. package/build/esm/embeddedHeathToolCards_babyPoop.js +19 -19
  68. package/build/esm/embeddedHeathToolCards_babyVaccine.js +22 -22
  69. package/build/esm/embeddedHeathToolCards_bmi_bmi.js +25 -25
  70. package/build/esm/embeddedHeathToolCards_bmrBmr.js +25 -25
  71. package/build/esm/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  72. package/build/esm/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  73. package/build/esm/embeddedHeathToolCards_pwg_pwg.js +26 -26
  74. package/build/esm/embeddedHeathToolCards_targetHeartRate.js +27 -27
  75. package/build/esm/footer.js +21 -21
  76. package/build/esm/gAssets.js +2 -2
  77. package/build/esm/{healthTools-6ff083fc.js → healthTools-e1a6ef1e.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-130576cd.js → index-02d42621.js} +16 -16
  85. package/build/esm/{index-9d456ced.js → index-02f47b31.js} +13 -13
  86. package/build/esm/{index-5131dc4f.js → index-0c58a126.js} +3 -3
  87. package/build/esm/{index-f410871a.js → index-0d1f9a50.js} +1 -1
  88. package/build/esm/{index-8885ef87.js → index-0e78532d.js} +6 -6
  89. package/build/esm/{index-0ab75d88.js → index-1c8b6280.js} +5 -5
  90. package/build/esm/{index-395867d1.js → index-1e3c6089.js} +1 -1
  91. package/build/esm/{index-e401fea0.js → index-294036ac.js} +1 -1
  92. package/build/esm/{index-8b71f3d7.js → index-2b4b6af2.js} +17 -17
  93. package/build/esm/{index-9a682965.js → index-2b893c79.js} +1 -1
  94. package/build/esm/{index-782b32b4.js → index-341d2f3b.js} +3 -3
  95. package/build/esm/{index-7f3a0d51.js → index-3842de95.js} +13 -13
  96. package/build/esm/{index-4cc74b63.js → index-39b43b9e.js} +32 -32
  97. package/build/esm/{index-8e302f71.js → index-3f4943bc.js} +1 -1
  98. package/build/esm/{index-f4607daa.js → index-3fbaa18d.js} +2 -2
  99. package/build/esm/{index-5d7077d8.js → index-41290d4b.js} +2 -2
  100. package/build/esm/{index-5024511e.js → index-415966ff.js} +2 -2
  101. package/build/esm/{index-8c227289.js → index-43f087d8.js} +32 -32
  102. package/build/esm/{index-fd64f3e1.js → index-45e85a8c.js} +18 -18
  103. package/build/esm/{index-33c4c7ba.js → index-4e75b39f.js} +13 -13
  104. package/build/esm/{index-82254ae8.js → index-501608d0.js} +25 -25
  105. package/build/esm/{index-9688c45f.js → index-5192d2d0.js} +7 -7
  106. package/build/esm/{index-e93b1f65.js → index-547896ee.js} +36 -27
  107. package/build/esm/{index-17e36457.js → index-5579e38e.js} +8 -8
  108. package/build/esm/{index-cd820271.js → index-5b533ca3.js} +4 -4
  109. package/build/esm/{index-4c29da01.js → index-6500ae67.js} +6 -6
  110. package/build/esm/{index-d25199d4.js → index-650a49cd.js} +1 -1
  111. package/build/esm/{index-adf83539.js → index-6872bac6.js} +21 -21
  112. package/build/esm/{index-8bc9ae7d.js → index-6a2f5018.js} +2 -2
  113. package/build/esm/{index-7911d60e.js → index-784cfa7f.js} +2 -2
  114. package/build/esm/{index-f9d0d6be.js → index-7a8a5be4.js} +6 -6
  115. package/build/esm/index-7b052b20.js +183 -0
  116. package/build/esm/{index-7f79d78c.js → index-7d8800af.js} +2 -2
  117. package/build/esm/{index-2f124f3f.js → index-82388c38.js} +6 -6
  118. package/build/esm/{index-bfafe3e9.js → index-82b32d0e.js} +17 -17
  119. package/build/esm/{index-3784dc8c.js → index-84a54d97.js} +17 -17
  120. package/build/esm/{index-94da713d.js → index-84dc26fd.js} +17 -17
  121. package/build/esm/{index-22f111d6.js → index-86937bce.js} +3 -3
  122. package/build/esm/{index-5e9df0aa.js → index-876a9add.js} +2 -2
  123. package/build/esm/{index-32060de3.js → index-892b0b9b.js} +16 -16
  124. package/build/esm/{index-7f0089a7.js → index-8c6ab6db.js} +3 -3
  125. package/build/esm/{index-5ff6b134.js → index-909c59e1.js} +2 -2
  126. package/build/esm/{index-9506572a.js → index-93b74def.js} +10 -10
  127. package/build/esm/{index-c315fa6b.js → index-96518dbc.js} +2 -2
  128. package/build/esm/{index-e1c1652c.js → index-970fd008.js} +3 -3
  129. package/build/esm/{index-edae0b9e.js → index-a0cf14b5.js} +2 -2
  130. package/build/esm/{index-44df64aa.js → index-a2959147.js} +2 -2
  131. package/build/esm/{index-cb2ab6ff.js → index-a5439b1f.js} +2 -2
  132. package/build/esm/{index-35c4c26f.js → index-ab4a3bf8.js} +40 -3
  133. package/build/esm/{index-0f5789ca.js → index-abd48358.js} +16 -16
  134. package/build/esm/{index-4f84ba27.js → index-afb4a537.js} +18 -18
  135. package/build/esm/{index-f437d7d3.js → index-b65d442e.js} +22 -22
  136. package/build/esm/{index-109382ee.js → index-b6c3d59e.js} +1 -1
  137. package/build/esm/{index-7b524555.js → index-bcbf4377.js} +6 -6
  138. package/build/esm/{index-aa92750f.js → index-cac726a1.js} +7 -7
  139. package/build/esm/{index-4bd46b7f.js → index-d1f4bf2b.js} +2 -2
  140. package/build/esm/{index-7287f2a0.js → index-d4c04671.js} +5 -5
  141. package/build/esm/{index-6ab5e856.js → index-dd5350a4.js} +1 -1
  142. package/build/esm/{index-4dbdcc4c.js → index-df556ccd.js} +24 -24
  143. package/build/esm/{index-c22c8c9f.js → index-ebcdc410.js} +15 -15
  144. package/build/esm/{index-f5a27fa1.js → index-ec463e2e.js} +13 -13
  145. package/build/esm/{index-528169fe.js → index-ed86669b.js} +16 -16
  146. package/build/esm/{index-36da89a1.js → index-edc96538.js} +1 -1
  147. package/build/esm/{index-bae2d2e9.js → index-f2eff1ea.js} +31 -31
  148. package/build/esm/{index-06d394fc.js → index-fc8946f6.js} +3 -3
  149. package/build/esm/index.js +118 -117
  150. package/build/esm/interfaces/constants/domainLocales.d.ts +2 -0
  151. package/build/esm/interfaces/constants/index.d.ts +1 -1
  152. package/build/esm/interfaces/types/Locale.d.ts +2 -1
  153. package/build/esm/interfaces/types/index.d.ts +2 -1
  154. package/build/esm/{labelSorting-ad695303.js → labelSorting-ea5f093e.js} +4 -4
  155. package/build/esm/lead/LeadGen.type.d.ts +34 -0
  156. package/build/esm/lead/LeadGenForm/LeadGenForm.d.ts +41 -0
  157. package/build/esm/lead/LeadGenForm/LeadGenForm.helpers.d.ts +2 -0
  158. package/build/esm/lead/LeadGenForm/LeadGenForm.styled.d.ts +5 -0
  159. package/build/esm/lead/LeadGenForm/LeadGenFormPhone.d.ts +17 -0
  160. package/build/esm/lead/LeadGenForm/LeadGenThankYou.d.ts +20 -0
  161. package/build/esm/lead/LeadGenForm/index.d.ts +3 -0
  162. package/build/esm/lead/LeadGenForm/textField/index.d.ts +13 -0
  163. package/build/esm/lead/LeadGenForm/textField/index.styled.d.ts +11 -0
  164. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +66 -0
  165. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +4 -0
  166. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +21 -0
  167. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +3 -0
  168. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +24 -0
  169. package/build/esm/lead/LeadGenSubscriptionBox/index.d.ts +1 -0
  170. package/build/esm/lead/LeadGenTranslationContext.d.ts +6 -0
  171. package/build/esm/lead/helpers.d.ts +56 -1
  172. package/build/esm/lead/index.d.ts +2 -1
  173. package/build/esm/lead/services/index.d.ts +21 -0
  174. package/build/esm/lead/store/index.d.ts +1 -0
  175. package/build/esm/lead.js +2409 -1232
  176. package/build/esm/{logoIcon-3352527f.js → logoIcon-bc9a0a3b.js} +8 -2
  177. package/build/esm/mantine.js +25 -25
  178. package/build/esm/misc.js +17 -17
  179. package/build/esm/miscGetDynamicHealthTool.js +4 -4
  180. package/build/esm/miscGetSocialList.js +8 -8
  181. package/build/esm/miscScreenSizeContext.js +1 -1
  182. package/build/esm/mobileBottomNavigation.js +5 -5
  183. package/build/esm/mobileBottomNavigationIcon.js +5 -5
  184. package/build/esm/molecules.js +74 -73
  185. package/build/esm/moleculesArticleCard.js +6 -6
  186. package/build/esm/moleculesArticleCardV2.js +16 -16
  187. package/build/esm/navigation.js +46 -45
  188. package/build/esm/navigationLogoutPopup.js +9 -9
  189. package/build/esm/navigationProfileButton.js +23 -23
  190. package/build/esm/onboardingV2.js +29 -29
  191. package/build/esm/organisms.js +50 -49
  192. package/build/esm/{post-062dce48.js → post-564356b1.js} +2 -2
  193. package/build/esm/profileNavigation.js +19 -19
  194. package/build/esm/progressBar.js +1 -1
  195. package/build/esm/pwg.js +22 -22
  196. package/build/esm/ssoV2/api/featureFlag.d.ts +2 -1
  197. package/build/esm/ssoV2.js +53 -40
  198. package/build/esm/{store-0f9ab222.js → store-67ecda4a.js} +6 -183
  199. package/build/esm/subot.js +36 -35
  200. package/build/esm/surveyOrPremiumBanner.js +33 -32
  201. package/build/esm/surveyQuestionCard.js +10 -10
  202. package/build/esm/{surveyThankyouCard-ba3a0601.js → surveyThankyouCard-bf7ecb4e.js} +5 -5
  203. package/build/esm/together.js +56 -55
  204. package/build/esm/togetherApiUtils.js +4 -4
  205. package/build/esm/togetherAtoms.js +30 -30
  206. package/build/esm/togetherComponentGlobalContext.js +4 -4
  207. package/build/esm/togetherMolecules.js +51 -50
  208. package/build/esm/togetherMoleculesCardAuthor.js +28 -28
  209. package/build/esm/togetherMoleculesPostImagePreview.js +11 -11
  210. package/build/esm/togetherMoleculesProfileDetail.js +39 -38
  211. package/build/esm/togetherOrganisms.js +50 -49
  212. package/build/esm/togetherRichTextEditor.js +17 -17
  213. package/build/esm/togetherShareBox.js +10 -10
  214. package/build/esm/translationsProvider-0d1b782f.js +55 -0
  215. package/build/esm/{treePopoverMenu-a6f7cfd7.js → treePopoverMenu-caee92ec.js} +19 -19
  216. package/build/esm/{types-2e97f020.js → types-72e9785a.js} +2 -2
  217. package/build/esm/types.js +2 -2
  218. package/build/esm/{useCategory-a57e6557.js → useCategory-228ee512.js} +18 -5
  219. package/build/esm/{useHealthToolCache-50ac5d7d.js → useHealthToolCache-f6f38a54.js} +1 -1
  220. package/build/esm/{useMantineLocale-ee478730.js → useMantineLocale-1f75dde1.js} +8 -6
  221. package/build/esm/{usePlacesAutocomplete-119a12f3.js → usePlacesAutocomplete-214eb8ef.js} +1 -1
  222. package/build/esm/{useScreenSize-241e66fa.js → useScreenSize-e743e40e.js} +2 -2
  223. package/build/esm/useTogetherAuthRequiredAction.js +10 -9
  224. package/build/esm/{utils-5c250b28.js → utils-3e7eec95.js} +3 -3
  225. package/build/esm/{utils-84d5275f.js → utils-7d3a93fd.js} +2 -2
  226. package/build/esm/{utils-02789711.js → utils-88d6ad8f.js} +2 -2
  227. package/build/esm/{utils-d81142cf.js → utils-c3f5e7e1.js} +5 -4
  228. package/build/esm/vaccination.js +21 -21
  229. package/build/footer.js +21 -21
  230. package/build/gAssets.js +2 -2
  231. package/build/{healthTools-257131be.js → healthTools-bfe1daf9.js} +1 -1
  232. package/build/healthToolsCardWrapper.js +18 -18
  233. package/build/healthToolsForm.js +33 -33
  234. package/build/hooks.js +13 -13
  235. package/build/i18n-values/zh-CN.js +866 -0
  236. package/build/i18n.js +16 -56
  237. package/build/i18nV2.js +1 -1
  238. package/build/{index-d86255ae.js → index-00084392.js} +7 -7
  239. package/build/{index-78dac42f.js → index-027c8e83.js} +36 -27
  240. package/build/{index-8298c7c0.js → index-04f13410.js} +2 -2
  241. package/build/{index-e0b64996.js → index-12826402.js} +16 -16
  242. package/build/{index-b99eceae.js → index-198d5b63.js} +1 -1
  243. package/build/{index-4c99f21d.js → index-1a12b233.js} +3 -3
  244. package/build/{index-1ac4d980.js → index-1df65119.js} +1 -1
  245. package/build/{index-41529ab9.js → index-213caca9.js} +3 -3
  246. package/build/{index-9164c2ee.js → index-214cf40a.js} +3 -3
  247. package/build/{index-815de854.js → index-2428e5a1.js} +32 -32
  248. package/build/{index-d0fc83cb.js → index-24d43979.js} +10 -10
  249. package/build/{index-f8156707.js → index-281768ff.js} +6 -6
  250. package/build/{index-8e6eaed0.js → index-29f1fb01.js} +22 -22
  251. package/build/{index-31c0299e.js → index-2d59b16f.js} +6 -6
  252. package/build/{index-2edc6f4f.js → index-300d6b51.js} +2 -2
  253. package/build/{index-e25c397c.js → index-3177db87.js} +3 -3
  254. package/build/{index-e0986c73.js → index-33ec0fe8.js} +13 -13
  255. package/build/{index-809fab5e.js → index-37454604.js} +2 -2
  256. package/build/{index-81db4a5e.js → index-37a22329.js} +2 -2
  257. package/build/{index-dec3d9e5.js → index-3dabf5a2.js} +18 -18
  258. package/build/{index-582068c8.js → index-40475f23.js} +2 -2
  259. package/build/{index-da1f328c.js → index-4386d767.js} +16 -16
  260. package/build/{index-c4266bb2.js → index-469d5c71.js} +5 -5
  261. package/build/{index-2fc43b51.js → index-4ddd8819.js} +16 -16
  262. package/build/{index-7e9b8b61.js → index-4e1609e3.js} +7 -7
  263. package/build/{index-bab54ae7.js → index-4fb80c7b.js} +1 -1
  264. package/build/{index-8b1dc163.js → index-5851c1d9.js} +16 -16
  265. package/build/{index-1c3321c1.js → index-5acf3129.js} +17 -17
  266. package/build/{index-c1e14fd6.js → index-5b63a320.js} +24 -24
  267. package/build/{index-e7f3329c.js → index-5e98810a.js} +31 -31
  268. package/build/{index-5671b247.js → index-734f15a6.js} +8 -8
  269. package/build/{index-a8c0fe3b.js → index-737baed2.js} +18 -18
  270. package/build/{index-ca0ff3c8.js → index-74e562ee.js} +13 -13
  271. package/build/{index-f757576d.js → index-78a563f0.js} +1 -1
  272. package/build/{index-d0a87c80.js → index-7a6225e4.js} +1 -1
  273. package/build/{index-2d635a20.js → index-80ee4b68.js} +2 -2
  274. package/build/{index-6f08804a.js → index-857b4c50.js} +2 -2
  275. package/build/{index-02e6761f.js → index-898016f9.js} +25 -25
  276. package/build/index-8c87abc1.js +196 -0
  277. package/build/{index-b043d722.js → index-8dbf70d2.js} +2 -2
  278. package/build/{index-23006a6f.js → index-97a8165b.js} +1 -1
  279. package/build/{index-c3b2d3a2.js → index-a16033c5.js} +4 -4
  280. package/build/{index-d5392642.js → index-aaffe3de.js} +2 -2
  281. package/build/{index-ff5393e0.js → index-ac1ffa0e.js} +1 -1
  282. package/build/{index-df8845e8.js → index-adf52869.js} +39 -2
  283. package/build/{index-5e7301a8.js → index-af930c80.js} +15 -15
  284. package/build/{index-1c320bad.js → index-b193b2ac.js} +32 -32
  285. package/build/{index-9e639be2.js → index-b1996baf.js} +1 -1
  286. package/build/{index-cc03a162.js → index-b722ae58.js} +6 -6
  287. package/build/{index-f30c6c68.js → index-b8c7e6e3.js} +17 -17
  288. package/build/{index-da4de0f3.js → index-c7bc565a.js} +13 -13
  289. package/build/{index-467dfe87.js → index-c7c3ef88.js} +1 -1
  290. package/build/{index-b3a4afc0.js → index-ccb6403f.js} +3 -3
  291. package/build/{index-d0da1009.js → index-cfafbf67.js} +2 -2
  292. package/build/{index-3484373a.js → index-d43e0af1.js} +6 -6
  293. package/build/{index-4026f890.js → index-ddc24215.js} +2 -2
  294. package/build/{index-46713f6a.js → index-de4ff5cc.js} +2 -2
  295. package/build/{index-aad65709.js → index-e0c49c17.js} +13 -13
  296. package/build/{index-bfce43a1.js → index-e6055d15.js} +17 -17
  297. package/build/{index-09ddce9c.js → index-e72559bd.js} +21 -21
  298. package/build/{index-9074450c.js → index-e7cb4126.js} +3 -3
  299. package/build/{index-2a96defb.js → index-effcbb0f.js} +5 -5
  300. package/build/{index-0186561a.js → index-f5c25137.js} +2 -2
  301. package/build/{index-7e3fcc69.js → index-f5ca7a8d.js} +6 -6
  302. package/build/{index-de274432.js → index-f84792b7.js} +17 -17
  303. package/build/index.js +118 -117
  304. package/build/interfaces/constants/domainLocales.d.ts +2 -0
  305. package/build/interfaces/constants/index.d.ts +1 -1
  306. package/build/interfaces/types/Locale.d.ts +2 -1
  307. package/build/interfaces/types/index.d.ts +2 -1
  308. package/build/{labelSorting-f5b88779.js → labelSorting-eeba8f8f.js} +4 -4
  309. package/build/lead/LeadGen.type.d.ts +34 -0
  310. package/build/lead/LeadGenForm/LeadGenForm.d.ts +41 -0
  311. package/build/lead/LeadGenForm/LeadGenForm.helpers.d.ts +2 -0
  312. package/build/lead/LeadGenForm/LeadGenForm.styled.d.ts +5 -0
  313. package/build/lead/LeadGenForm/LeadGenFormPhone.d.ts +17 -0
  314. package/build/lead/LeadGenForm/LeadGenThankYou.d.ts +20 -0
  315. package/build/lead/LeadGenForm/index.d.ts +3 -0
  316. package/build/lead/LeadGenForm/textField/index.d.ts +13 -0
  317. package/build/lead/LeadGenForm/textField/index.styled.d.ts +11 -0
  318. package/build/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +66 -0
  319. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +4 -0
  320. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +21 -0
  321. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +3 -0
  322. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +24 -0
  323. package/build/lead/LeadGenSubscriptionBox/index.d.ts +1 -0
  324. package/build/lead/LeadGenTranslationContext.d.ts +6 -0
  325. package/build/lead/helpers.d.ts +56 -1
  326. package/build/lead/index.d.ts +2 -1
  327. package/build/lead/services/index.d.ts +21 -0
  328. package/build/lead/store/index.d.ts +1 -0
  329. package/build/lead.js +2447 -1269
  330. package/build/{logoIcon-d87f0c7c.js → logoIcon-f1052b32.js} +8 -2
  331. package/build/mantine.js +22 -22
  332. package/build/misc.js +17 -17
  333. package/build/miscGetDynamicHealthTool.js +4 -4
  334. package/build/miscGetSocialList.js +8 -8
  335. package/build/miscScreenSizeContext.js +1 -1
  336. package/build/mobileBottomNavigation.js +5 -5
  337. package/build/mobileBottomNavigationIcon.js +5 -5
  338. package/build/molecules.js +74 -73
  339. package/build/moleculesArticleCard.js +6 -6
  340. package/build/moleculesArticleCardV2.js +16 -16
  341. package/build/navigation.js +46 -45
  342. package/build/navigationLogoutPopup.js +9 -9
  343. package/build/navigationProfileButton.js +23 -23
  344. package/build/onboardingV2.js +28 -28
  345. package/build/organisms.js +50 -49
  346. package/build/{post-7ad0e276.js → post-914fed2f.js} +2 -2
  347. package/build/profileNavigation.js +19 -19
  348. package/build/progressBar.js +1 -1
  349. package/build/pwg.js +22 -22
  350. package/build/ssoV2/api/featureFlag.d.ts +2 -1
  351. package/build/ssoV2.js +130 -117
  352. package/build/{store-ff958ae7.js → store-1b258086.js} +8 -196
  353. package/build/subot.js +35 -34
  354. package/build/surveyOrPremiumBanner.js +33 -32
  355. package/build/surveyQuestionCard.js +10 -10
  356. package/build/{surveyThankyouCard-e8976fd5.js → surveyThankyouCard-03c28230.js} +5 -5
  357. package/build/together.js +56 -55
  358. package/build/togetherApiUtils.js +4 -4
  359. package/build/togetherAtoms.js +30 -30
  360. package/build/togetherComponentGlobalContext.js +4 -4
  361. package/build/togetherMolecules.js +51 -50
  362. package/build/togetherMoleculesCardAuthor.js +28 -28
  363. package/build/togetherMoleculesPostImagePreview.js +11 -11
  364. package/build/togetherMoleculesProfileDetail.js +39 -38
  365. package/build/togetherOrganisms.js +50 -49
  366. package/build/togetherRichTextEditor.js +17 -17
  367. package/build/togetherShareBox.js +10 -10
  368. package/build/translationsProvider-7f2122ba.js +62 -0
  369. package/build/{treePopoverMenu-11d8a3c3.js → treePopoverMenu-7c9ee6e6.js} +19 -19
  370. package/build/{types-da86b25c.js → types-7fbe86d7.js} +2 -2
  371. package/build/types.js +2 -2
  372. package/build/{useCategory-8a7dc9fd.js → useCategory-f4dd8e5b.js} +18 -5
  373. package/build/{useHealthToolCache-0d055a47.js → useHealthToolCache-2cd5a460.js} +1 -1
  374. package/build/{useMantineLocale-a330a7e5.js → useMantineLocale-bda94d46.js} +8 -6
  375. package/build/{usePlacesAutocomplete-14098979.js → usePlacesAutocomplete-907a23f0.js} +1 -1
  376. package/build/{useScreenSize-2eae68ef.js → useScreenSize-ce7bda9a.js} +2 -2
  377. package/build/useTogetherAuthRequiredAction.js +10 -9
  378. package/build/{utils-7d98be3c.js → utils-1899de95.js} +2 -2
  379. package/build/{utils-d104096a.js → utils-a2f21483.js} +9 -8
  380. package/build/{utils-c88507b9.js → utils-e42414a8.js} +2 -2
  381. package/build/{utils-192df9f4.js → utils-f115ca74.js} +3 -3
  382. package/build/vaccination.js +21 -21
  383. package/package.json +3 -3
  384. /package/build/{BMI_BOYS.percentile.monthly-179a50b1.js → BMI_BOYS.percentile.monthly-4c341249.js} +0 -0
  385. /package/build/{BMI_BOYS.percentile.weekly-6e48af31.js → BMI_BOYS.percentile.weekly-81b78623.js} +0 -0
  386. /package/build/{BMI_BOYS.percentile.yearly-4580e832.js → BMI_BOYS.percentile.yearly-655aaee9.js} +0 -0
  387. /package/build/{BMI_BOYS.zscore.monthly-b7606779.js → BMI_BOYS.zscore.monthly-6f1ac991.js} +0 -0
  388. /package/build/{BMI_BOYS.zscore.weekly-172fbecd.js → BMI_BOYS.zscore.weekly-e130784e.js} +0 -0
  389. /package/build/{BMI_BOYS.zscore.yearly-34a8f9cd.js → BMI_BOYS.zscore.yearly-5e964cd9.js} +0 -0
  390. /package/build/{BMI_GIRLS.percentile.monthly-5b16a621.js → BMI_GIRLS.percentile.monthly-0a7110ee.js} +0 -0
  391. /package/build/{BMI_GIRLS.percentile.weekly-a13bf779.js → BMI_GIRLS.percentile.weekly-d5a76196.js} +0 -0
  392. /package/build/{BMI_GIRLS.percentile.yearly-13973462.js → BMI_GIRLS.percentile.yearly-57b39938.js} +0 -0
  393. /package/build/{BMI_GIRLS.zscore.monthly-204e3d84.js → BMI_GIRLS.zscore.monthly-8e154e0d.js} +0 -0
  394. /package/build/{BMI_GIRLS.zscore.weekly-6fdd2c6a.js → BMI_GIRLS.zscore.weekly-0cf719c6.js} +0 -0
  395. /package/build/{BMI_GIRLS.zscore.yearly-1cca63a0.js → BMI_GIRLS.zscore.yearly-26148bc0.js} +0 -0
  396. /package/build/{ChevronDown-666ab37d.js → ChevronDown-29c47ec7.js} +0 -0
  397. /package/build/{Close-1b6e6466.js → Close-4eff7e72.js} +0 -0
  398. /package/build/{Google-255c0f1a.js → Google-60ff715c.js} +0 -0
  399. /package/build/{HEAD CIRCUM_BOYS.percentile.monthly-27b74016.js → HEAD CIRCUM_BOYS.percentile.monthly-f89a14f7.js} +0 -0
  400. /package/build/{HEAD CIRCUM_BOYS.percentile.weekly-44d2ee86.js → HEAD CIRCUM_BOYS.percentile.weekly-643e3e77.js} +0 -0
  401. /package/build/{HEAD CIRCUM_BOYS.percentile.yearly-8da7f001.js → HEAD CIRCUM_BOYS.percentile.yearly-d153f0f7.js} +0 -0
  402. /package/build/{HEAD CIRCUM_BOYS.zscore.monthly-61e5db90.js → HEAD CIRCUM_BOYS.zscore.monthly-d8a6e27e.js} +0 -0
  403. /package/build/{HEAD CIRCUM_BOYS.zscore.weekly-25d8b075.js → HEAD CIRCUM_BOYS.zscore.weekly-c776576a.js} +0 -0
  404. /package/build/{HEAD CIRCUM_BOYS.zscore.yearly-1e6e1e4e.js → HEAD CIRCUM_BOYS.zscore.yearly-d608021d.js} +0 -0
  405. /package/build/{HEAD CIRCUM_GIRLS.percentile.monthly-bdd4a98b.js → HEAD CIRCUM_GIRLS.percentile.monthly-9c3747ca.js} +0 -0
  406. /package/build/{HEAD CIRCUM_GIRLS.percentile.weekly-c22eafb0.js → HEAD CIRCUM_GIRLS.percentile.weekly-20d7efdb.js} +0 -0
  407. /package/build/{HEAD CIRCUM_GIRLS.percentile.yearly-e63f3462.js → HEAD CIRCUM_GIRLS.percentile.yearly-80b10103.js} +0 -0
  408. /package/build/{HEAD CIRCUM_GIRLS.zscore.monthly-ba864f1d.js → HEAD CIRCUM_GIRLS.zscore.monthly-e41f56b6.js} +0 -0
  409. /package/build/{HEAD CIRCUM_GIRLS.zscore.weekly-0ab88ce6.js → HEAD CIRCUM_GIRLS.zscore.weekly-18698ce2.js} +0 -0
  410. /package/build/{HEAD CIRCUM_GIRLS.zscore.yearly-5f6cd980.js → HEAD CIRCUM_GIRLS.zscore.yearly-ff2e529c.js} +0 -0
  411. /package/build/{HEIGHT_BOYS.percentile.monthly-de94349f.js → HEIGHT_BOYS.percentile.monthly-b7d476b6.js} +0 -0
  412. /package/build/{HEIGHT_BOYS.percentile.weekly-0deb1e2e.js → HEIGHT_BOYS.percentile.weekly-3ca3aeee.js} +0 -0
  413. /package/build/{HEIGHT_BOYS.percentile.yearly-de56c11c.js → HEIGHT_BOYS.percentile.yearly-afa9241c.js} +0 -0
  414. /package/build/{HEIGHT_BOYS.zscore.monthly-2ec7ba91.js → HEIGHT_BOYS.zscore.monthly-33cf1b01.js} +0 -0
  415. /package/build/{HEIGHT_BOYS.zscore.weekly-ca549a20.js → HEIGHT_BOYS.zscore.weekly-0d28b82a.js} +0 -0
  416. /package/build/{HEIGHT_BOYS.zscore.yearly-1a550c19.js → HEIGHT_BOYS.zscore.yearly-1490b739.js} +0 -0
  417. /package/build/{HEIGHT_GIRLS.percentile.monthly-4ed4b34f.js → HEIGHT_GIRLS.percentile.monthly-a82daac8.js} +0 -0
  418. /package/build/{HEIGHT_GIRLS.percentile.weekly-8e84201b.js → HEIGHT_GIRLS.percentile.weekly-ba4c7c12.js} +0 -0
  419. /package/build/{HEIGHT_GIRLS.percentile.yearly-ae554a2e.js → HEIGHT_GIRLS.percentile.yearly-149b1a8c.js} +0 -0
  420. /package/build/{HEIGHT_GIRLS.zscore.monthly-e39acd9f.js → HEIGHT_GIRLS.zscore.monthly-e82b3511.js} +0 -0
  421. /package/build/{HEIGHT_GIRLS.zscore.weekly-c1ac2f72.js → HEIGHT_GIRLS.zscore.weekly-bd712cbf.js} +0 -0
  422. /package/build/{HEIGHT_GIRLS.zscore.yearly-e60e8414.js → HEIGHT_GIRLS.zscore.yearly-c6d16dd1.js} +0 -0
  423. /package/build/{Visible-3c7c545a.js → Visible-97d0ae65.js} +0 -0
  424. /package/build/{WEIGHT_BOYS.percentile.monthly-7907d7d8.js → WEIGHT_BOYS.percentile.monthly-78a01ef9.js} +0 -0
  425. /package/build/{WEIGHT_BOYS.percentile.weekly-ffe2e09f.js → WEIGHT_BOYS.percentile.weekly-ad581b41.js} +0 -0
  426. /package/build/{WEIGHT_BOYS.percentile.yearly-5613db72.js → WEIGHT_BOYS.percentile.yearly-dea5e8fe.js} +0 -0
  427. /package/build/{WEIGHT_BOYS.zscore.monthly-0c71e1f1.js → WEIGHT_BOYS.zscore.monthly-6e022993.js} +0 -0
  428. /package/build/{WEIGHT_BOYS.zscore.weekly-551fbe61.js → WEIGHT_BOYS.zscore.weekly-423d084d.js} +0 -0
  429. /package/build/{WEIGHT_BOYS.zscore.yearly-faf021d6.js → WEIGHT_BOYS.zscore.yearly-f0010d58.js} +0 -0
  430. /package/build/{WEIGHT_GIRLS.percentile.monthly-5e32962a.js → WEIGHT_GIRLS.percentile.monthly-486aa7a0.js} +0 -0
  431. /package/build/{WEIGHT_GIRLS.percentile.weekly-3bf46095.js → WEIGHT_GIRLS.percentile.weekly-702afb08.js} +0 -0
  432. /package/build/{WEIGHT_GIRLS.percentile.yearly-081bb76a.js → WEIGHT_GIRLS.percentile.yearly-27ae4f9b.js} +0 -0
  433. /package/build/{WEIGHT_GIRLS.zscore.monthly-278e2e2f.js → WEIGHT_GIRLS.zscore.monthly-ee349b1d.js} +0 -0
  434. /package/build/{WEIGHT_GIRLS.zscore.weekly-7b2b5cb3.js → WEIGHT_GIRLS.zscore.weekly-e6dca16d.js} +0 -0
  435. /package/build/{WEIGHT_GIRLS.zscore.yearly-3f573da9.js → WEIGHT_GIRLS.zscore.yearly-b704dcca.js} +0 -0
  436. /package/build/{animation-4a4be1d2.js → animation-8b1ea68b.js} +0 -0
  437. /package/build/{constants-455c1bb4.js → constants-188b108c.js} +0 -0
  438. /package/build/{constants-a6d2ff76.js → constants-fdd86b6a.js} +0 -0
  439. /package/build/{dataTransform-b60c06bb.js → dataTransform-7dfbaa1d.js} +0 -0
  440. /package/build/{doctor-1f6e5f33.js → doctor-03c4ddb3.js} +0 -0
  441. /package/build/esm/{BMI_BOYS.percentile.monthly-92d9c1f0.js → BMI_BOYS.percentile.monthly-134ce0a7.js} +0 -0
  442. /package/build/esm/{BMI_BOYS.percentile.weekly-ee2eb412.js → BMI_BOYS.percentile.weekly-8c36c8e6.js} +0 -0
  443. /package/build/esm/{BMI_BOYS.percentile.yearly-1633c579.js → BMI_BOYS.percentile.yearly-7d764924.js} +0 -0
  444. /package/build/esm/{BMI_BOYS.zscore.monthly-7cae8cf3.js → BMI_BOYS.zscore.monthly-e6e6acb4.js} +0 -0
  445. /package/build/esm/{BMI_BOYS.zscore.weekly-8d5a6c27.js → BMI_BOYS.zscore.weekly-5626ff35.js} +0 -0
  446. /package/build/esm/{BMI_BOYS.zscore.yearly-4385bf15.js → BMI_BOYS.zscore.yearly-28c69fdf.js} +0 -0
  447. /package/build/esm/{BMI_GIRLS.percentile.monthly-39965bce.js → BMI_GIRLS.percentile.monthly-175cebb2.js} +0 -0
  448. /package/build/esm/{BMI_GIRLS.percentile.weekly-04c50c49.js → BMI_GIRLS.percentile.weekly-b0c6d326.js} +0 -0
  449. /package/build/esm/{BMI_GIRLS.percentile.yearly-c52eda5f.js → BMI_GIRLS.percentile.yearly-2f5777cb.js} +0 -0
  450. /package/build/esm/{BMI_GIRLS.zscore.monthly-c706b650.js → BMI_GIRLS.zscore.monthly-1a0f8c00.js} +0 -0
  451. /package/build/esm/{BMI_GIRLS.zscore.weekly-465b90ff.js → BMI_GIRLS.zscore.weekly-dc6907d1.js} +0 -0
  452. /package/build/esm/{BMI_GIRLS.zscore.yearly-ed0e918a.js → BMI_GIRLS.zscore.yearly-f7d97963.js} +0 -0
  453. /package/build/esm/{ChevronDown-3f8ce34e.js → ChevronDown-791818f1.js} +0 -0
  454. /package/build/esm/{Close-544c792d.js → Close-709afe4d.js} +0 -0
  455. /package/build/esm/{Google-07add6d7.js → Google-6f70ea7f.js} +0 -0
  456. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.monthly-36488681.js → HEAD CIRCUM_BOYS.percentile.monthly-af03ff8a.js} +0 -0
  457. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.weekly-23fc9978.js → HEAD CIRCUM_BOYS.percentile.weekly-51a883eb.js} +0 -0
  458. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.yearly-854f13e0.js → HEAD CIRCUM_BOYS.percentile.yearly-251103a5.js} +0 -0
  459. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.monthly-4d4dbf90.js → HEAD CIRCUM_BOYS.zscore.monthly-453d8ce4.js} +0 -0
  460. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.weekly-9f181b10.js → HEAD CIRCUM_BOYS.zscore.weekly-93e3e6a6.js} +0 -0
  461. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.yearly-6e8bcb7d.js → HEAD CIRCUM_BOYS.zscore.yearly-21358492.js} +0 -0
  462. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.monthly-bdeb8d21.js → HEAD CIRCUM_GIRLS.percentile.monthly-78f16816.js} +0 -0
  463. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.weekly-bf8d0a97.js → HEAD CIRCUM_GIRLS.percentile.weekly-f6babb53.js} +0 -0
  464. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.yearly-230957db.js → HEAD CIRCUM_GIRLS.percentile.yearly-30dfa5c0.js} +0 -0
  465. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.monthly-20e5c1d6.js → HEAD CIRCUM_GIRLS.zscore.monthly-ff2a5735.js} +0 -0
  466. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.weekly-3993abe9.js → HEAD CIRCUM_GIRLS.zscore.weekly-ca7a26a8.js} +0 -0
  467. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.yearly-6891fbfc.js → HEAD CIRCUM_GIRLS.zscore.yearly-68964768.js} +0 -0
  468. /package/build/esm/{HEIGHT_BOYS.percentile.monthly-2570d419.js → HEIGHT_BOYS.percentile.monthly-e8ae596e.js} +0 -0
  469. /package/build/esm/{HEIGHT_BOYS.percentile.weekly-606af351.js → HEIGHT_BOYS.percentile.weekly-b52da75b.js} +0 -0
  470. /package/build/esm/{HEIGHT_BOYS.percentile.yearly-37c2dd55.js → HEIGHT_BOYS.percentile.yearly-598fbeaa.js} +0 -0
  471. /package/build/esm/{HEIGHT_BOYS.zscore.monthly-81178889.js → HEIGHT_BOYS.zscore.monthly-c58a8e18.js} +0 -0
  472. /package/build/esm/{HEIGHT_BOYS.zscore.weekly-3178efa9.js → HEIGHT_BOYS.zscore.weekly-2ddecd9c.js} +0 -0
  473. /package/build/esm/{HEIGHT_BOYS.zscore.yearly-493f4e9a.js → HEIGHT_BOYS.zscore.yearly-ece37a33.js} +0 -0
  474. /package/build/esm/{HEIGHT_GIRLS.percentile.monthly-0f1f5d53.js → HEIGHT_GIRLS.percentile.monthly-5823bad8.js} +0 -0
  475. /package/build/esm/{HEIGHT_GIRLS.percentile.weekly-02ef3a08.js → HEIGHT_GIRLS.percentile.weekly-17a2e5ba.js} +0 -0
  476. /package/build/esm/{HEIGHT_GIRLS.percentile.yearly-46a52ffd.js → HEIGHT_GIRLS.percentile.yearly-9ae2595b.js} +0 -0
  477. /package/build/esm/{HEIGHT_GIRLS.zscore.monthly-59d32be7.js → HEIGHT_GIRLS.zscore.monthly-a98d7bc0.js} +0 -0
  478. /package/build/esm/{HEIGHT_GIRLS.zscore.weekly-934f71dc.js → HEIGHT_GIRLS.zscore.weekly-7295b313.js} +0 -0
  479. /package/build/esm/{HEIGHT_GIRLS.zscore.yearly-eeefcd63.js → HEIGHT_GIRLS.zscore.yearly-e20eb029.js} +0 -0
  480. /package/build/esm/{Visible-6f57a2db.js → Visible-7c80278e.js} +0 -0
  481. /package/build/esm/{WEIGHT_BOYS.percentile.monthly-876f2a6d.js → WEIGHT_BOYS.percentile.monthly-034de158.js} +0 -0
  482. /package/build/esm/{WEIGHT_BOYS.percentile.weekly-67700803.js → WEIGHT_BOYS.percentile.weekly-d7fa48b3.js} +0 -0
  483. /package/build/esm/{WEIGHT_BOYS.percentile.yearly-b2adebd1.js → WEIGHT_BOYS.percentile.yearly-a26cb2f3.js} +0 -0
  484. /package/build/esm/{WEIGHT_BOYS.zscore.monthly-38e643db.js → WEIGHT_BOYS.zscore.monthly-07dc70be.js} +0 -0
  485. /package/build/esm/{WEIGHT_BOYS.zscore.weekly-ed370d92.js → WEIGHT_BOYS.zscore.weekly-0152f11a.js} +0 -0
  486. /package/build/esm/{WEIGHT_BOYS.zscore.yearly-158f3120.js → WEIGHT_BOYS.zscore.yearly-7dc3323f.js} +0 -0
  487. /package/build/esm/{WEIGHT_GIRLS.percentile.monthly-19ed2ff2.js → WEIGHT_GIRLS.percentile.monthly-72f452ce.js} +0 -0
  488. /package/build/esm/{WEIGHT_GIRLS.percentile.weekly-c07ebd4a.js → WEIGHT_GIRLS.percentile.weekly-d657a0c8.js} +0 -0
  489. /package/build/esm/{WEIGHT_GIRLS.percentile.yearly-d2eb7f92.js → WEIGHT_GIRLS.percentile.yearly-aced1ff4.js} +0 -0
  490. /package/build/esm/{WEIGHT_GIRLS.zscore.monthly-2d39112e.js → WEIGHT_GIRLS.zscore.monthly-560dc4b0.js} +0 -0
  491. /package/build/esm/{WEIGHT_GIRLS.zscore.weekly-79c13caa.js → WEIGHT_GIRLS.zscore.weekly-c2f4ba9b.js} +0 -0
  492. /package/build/esm/{WEIGHT_GIRLS.zscore.yearly-686b8120.js → WEIGHT_GIRLS.zscore.yearly-12a669b6.js} +0 -0
  493. /package/build/esm/{animation-f0de7fec.js → animation-2d9550bf.js} +0 -0
  494. /package/build/esm/{constants-67817a3e.js → constants-44282e2b.js} +0 -0
  495. /package/build/esm/{constants-7a94d96a.js → constants-b37d9aab.js} +0 -0
  496. /package/build/esm/{dataTransform-96b33da1.js → dataTransform-94579960.js} +0 -0
  497. /package/build/esm/{doctor-ce62bcf6.js → doctor-7a110178.js} +0 -0
  498. /package/build/esm/{index-50922feb.js → index-051ea88c.js} +0 -0
  499. /package/build/esm/{index-b814b571.js → index-27150fa7.js} +0 -0
  500. /package/build/esm/{index-bd1a993e.js → index-65bf95fa.js} +0 -0
  501. /package/build/esm/{index-2f816408.js → index-9851237f.js} +0 -0
  502. /package/build/esm/{index-a9b9cf40.js → index-b9e1eb78.js} +0 -0
  503. /package/build/esm/{index-d14b8ec2.js → index-d2212d3b.js} +0 -0
  504. /package/build/esm/{index-20fe498c.js → index-d2ce3850.js} +0 -0
  505. /package/build/esm/{index-0fcc7e05.js → index-fef5945b.js} +0 -0
  506. /package/build/esm/{index.styles-c9d6db26.js → index.styles-90e570fc.js} +0 -0
  507. /package/build/esm/{localizeNumberFormat-91191f3b.js → localizeNumberFormat-e015e68b.js} +0 -0
  508. /package/build/esm/{normalizeLink-6e07e5c4.js → normalizeLink-88ac1114.js} +0 -0
  509. /package/build/esm/{number-9e7857e2.js → number-cec527f6.js} +0 -0
  510. /package/build/esm/{other-7cac897b.js → other-9578648a.js} +0 -0
  511. /package/build/esm/{paths-eb036f12.js → paths-51ce1e3b.js} +0 -0
  512. /package/build/esm/{translationsContext-23b5bf84.js → translationsContext-ff52e07d.js} +0 -0
  513. /package/build/esm/{tslib.es6-eb6746ec.js → tslib.es6-106e94f9.js} +0 -0
  514. /package/build/esm/{types-1466329a.js → types-dfc04905.js} +0 -0
  515. /package/build/esm/{useIsInit-58c92435.js → useIsInit-61b10be8.js} +0 -0
  516. /package/build/esm/{useOutsideClick-d1408b13.js → useOutsideClick-037a7230.js} +0 -0
  517. /package/build/esm/{useScrollbarSize-af69fd45.js → useScrollbarSize-c560eaa0.js} +0 -0
  518. /package/build/esm/{useUniqueId-15198ead.js → useUniqueId-cdbcbe28.js} +0 -0
  519. /package/build/esm/{utils-770949fe.js → utils-53449c9d.js} +0 -0
  520. /package/build/{index-c30aae56.js → index-0fb792ac.js} +0 -0
  521. /package/build/{index-a471322d.js → index-3e924baa.js} +0 -0
  522. /package/build/{index-fae28861.js → index-46e740d6.js} +0 -0
  523. /package/build/{index-fce79e5f.js → index-47abef43.js} +0 -0
  524. /package/build/{index-a5d52534.js → index-7ee90ed7.js} +0 -0
  525. /package/build/{index-fd00f1ea.js → index-8211621c.js} +0 -0
  526. /package/build/{index-1e874626.js → index-8ae8e326.js} +0 -0
  527. /package/build/{index-cd4f0240.js → index-f6f53b00.js} +0 -0
  528. /package/build/{index.styles-f9818d05.js → index.styles-6e20a8c5.js} +0 -0
  529. /package/build/{localizeNumberFormat-ef732f37.js → localizeNumberFormat-c67beac0.js} +0 -0
  530. /package/build/{normalizeLink-65501df2.js → normalizeLink-bbc22991.js} +0 -0
  531. /package/build/{number-2ccfcc5f.js → number-fc9ed546.js} +0 -0
  532. /package/build/{other-4e4f19d4.js → other-9f8453c8.js} +0 -0
  533. /package/build/{paths-d2ea905c.js → paths-70a3a73e.js} +0 -0
  534. /package/build/{translationsContext-3ac6ece2.js → translationsContext-c26d1113.js} +0 -0
  535. /package/build/{tslib.es6-e879b440.js → tslib.es6-2e2a9190.js} +0 -0
  536. /package/build/{types-2d921d78.js → types-606ce3c2.js} +0 -0
  537. /package/build/{useIsInit-5cc2d405.js → useIsInit-b0a30842.js} +0 -0
  538. /package/build/{useOutsideClick-795cda46.js → useOutsideClick-77e9679b.js} +0 -0
  539. /package/build/{useScrollbarSize-9fb99eed.js → useScrollbarSize-d414c6da.js} +0 -0
  540. /package/build/{useUniqueId-5f42952d.js → useUniqueId-71a9e721.js} +0 -0
  541. /package/build/{utils-a445506a.js → utils-5a0561f4.js} +0 -0
package/build/lead.js CHANGED
@@ -2,55 +2,76 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('./tslib.es6-e879b440.js');
5
+ var tslib_es6 = require('./tslib.es6-2e2a9190.js');
6
6
  var React = require('react');
7
7
  var core = require('@mantine/core');
8
8
  var dayjs = require('dayjs');
9
9
  var debounce = require('lodash/debounce');
10
10
  var form = require('@mantine/form');
11
- var index = require('./index-9e639be2.js');
12
- var translationsContext = require('./translationsContext-3ac6ece2.js');
11
+ var index = require('./index-8c87abc1.js');
13
12
  var miscCookieHelper = require('./miscCookieHelper.js');
14
- var utils$1 = require('./utils-a445506a.js');
15
- var index$1 = require('./index-b043d722.js');
16
- var index$2 = require('./index-78dac42f.js');
17
- var index$4 = require('./index-31c0299e.js');
18
- var index$3 = require('./index-bab54ae7.js');
19
- require('./index.styles-f9818d05.js');
13
+ var index$1 = require('./index-b1996baf.js');
14
+ var translationsContext = require('./translationsContext-c26d1113.js');
15
+ var utils$1 = require('./utils-5a0561f4.js');
16
+ var index$2 = require('./index-8dbf70d2.js');
17
+ var index$3 = require('./index-027c8e83.js');
18
+ var index$5 = require('./index-2d59b16f.js');
19
+ var index$4 = require('./index-4fb80c7b.js');
20
+ require('./index.styles-6e20a8c5.js');
20
21
  var hooks = require('@mantine/hooks');
21
- require('./useMantineLocale-a330a7e5.js');
22
- var index$8 = require('./index-467dfe87.js');
23
- require('./index-fae28861.js');
24
- var index$7 = require('./index-df8845e8.js');
25
- require('./other-4e4f19d4.js');
26
- require('./index-9074450c.js');
27
- var utils = require('./utils-7d98be3c.js');
28
- require('@mantine/dates');
29
- var usePlacesAutocomplete = require('./usePlacesAutocomplete-14098979.js');
30
- var index$5 = require('./index-582068c8.js');
22
+ require('./useMantineLocale-bda94d46.js');
23
+ var index$9 = require('./index-c7c3ef88.js');
24
+ require('./index-46e740d6.js');
25
+ var index$7 = require('./index-adf52869.js');
26
+ require('./other-9f8453c8.js');
27
+ require('./index-e7cb4126.js');
28
+ var utils = require('./utils-1899de95.js');
29
+ var dates = require('@mantine/dates');
30
+ var usePlacesAutocomplete = require('./usePlacesAutocomplete-907a23f0.js');
31
+ var index$6 = require('./index-40475f23.js');
32
+ var translationsProvider = require('./translationsProvider-7f2122ba.js');
33
+ var Locale = require('./Locale-8ad13864.js');
31
34
  var uuid = require('uuid');
32
- var index$6 = require('./index-c30aae56.js');
33
- var index$a = require('./index-4026f890.js');
34
- var useScreenSize = require('./useScreenSize-2eae68ef.js');
35
- var ReactDOM = require('react-dom');
36
- var react = require('@emotion/react');
35
+ var PhoneInputBase = require('react-phone-number-input');
37
36
  var styled = require('@emotion/styled');
38
37
  var miscTheme = require('./miscTheme.js');
39
- var index$9 = require('./index-809fab5e.js');
40
- var InputDate = require('./InputDate-8b579da2.js');
41
- var Close = require('./Close-1b6e6466.js');
38
+ var react = require('@emotion/react');
39
+ var togetherComponentGlobalContext = require('./utils-f115ca74.js');
40
+ var index$8 = require('./index-0fb792ac.js');
41
+ var index$b = require('./index-ddc24215.js');
42
+ var useScreenSize = require('./useScreenSize-ce7bda9a.js');
43
+ var ReactDOM = require('react-dom');
44
+ var index$a = require('./index-37454604.js');
45
+ var InputDate = require('./InputDate-20926325.js');
46
+ var Close = require('./Close-4eff7e72.js');
47
+ require('./constantsIsProduction.js');
48
+ require('./normalizeLink-bbc22991.js');
49
+ require('./constantsDomainLocales.js');
42
50
  require('@hhgtech/icons/other');
43
51
  require('@mantine/carousel');
44
- require('./Locale-72dce976.js');
45
52
  require('classnames');
46
- require('./useUniqueId-5f42952d.js');
53
+ require('./useUniqueId-71a9e721.js');
47
54
  require('./constantsSite.js');
48
55
  require('@hhgtech/icons/core');
49
56
  require('@mantine/notifications');
50
- require('./constantsDomainLocales.js');
51
- require('./constantsIsProduction.js');
52
57
  require('date-fns/locale');
53
58
  require('./constantsRiskScreener.js');
59
+ require('./i18n-values/en-PH.js');
60
+ require('./i18n-values/hi-IN.js');
61
+ require('./i18n-values/id-ID.js');
62
+ require('./i18n-values/km-KH.js');
63
+ require('./i18n-values/ms-MY.js');
64
+ require('./i18n-values/my-MM.js');
65
+ require('./i18n-values/th-TH.js');
66
+ require('./i18n-values/tl-PH.js');
67
+ require('./i18n-values/vi-VN.js');
68
+ require('./i18n-values/vi-VN_MB.js');
69
+ require('./i18n-values/zh-TW.js');
70
+ require('./index-8ae8e326.js');
71
+ require('slugify');
72
+ require('string-format');
73
+ require('./togetherApiPaths.js');
74
+ require('./constants-fdd86b6a.js');
54
75
  require('vaul');
55
76
 
56
77
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -102,7 +123,7 @@ if (sessionStorage.getItem('insider_object')) {
102
123
  }
103
124
  const docLang = document.documentElement.lang;
104
125
  // TODO: country code
105
- const LEAD_LOCALE_DATA = {
126
+ const LEAD_LOCALE_DATA$1 = {
106
127
  'vi-VN': {
107
128
  popupLang: 'vi',
108
129
  countryCode: 'vn',
@@ -144,7 +165,7 @@ const LEAD_LOCALE_DATA = {
144
165
  countryCodeNumber: 91,
145
166
  },
146
167
  };
147
- const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
168
+ const LEAD_LOCALE = LEAD_LOCALE_DATA$1[docLang] || LEAD_LOCALE_DATA$1['vi-VN'];
148
169
  function LEAD_RESET_VAR() {
149
170
  // LEAD_CURRENT_URL = location.href.toLowerCase();
150
171
  LEAD_CURRENT_URL =
@@ -165,6 +186,11 @@ const LEAD_TIMEZONE_DATA = {
165
186
  9: 'Asia/Manila', // Philippines / Filipinos Site
166
187
  };
167
188
 
189
+ const LEADGEN_ACTIONS = {
190
+ SHOW: 'SHOW',
191
+ SCROLL: 'SCROLL',
192
+ TIME: 'TIME',
193
+ };
168
194
  const LEADGEN_LAYOUT = {
169
195
  LightBoxA: 'LightBoxA',
170
196
  LightBoxB: 'LightBoxB',
@@ -194,8 +220,10 @@ const LEADGEN_BLOCK = {
194
220
  DropdownBlock: 'DropdownBlock',
195
221
  CheckboxBlock: 'CheckboxBlock',
196
222
  TncBlock: 'TncBlock',
223
+ TitleBlock: 'TitleBlock',
224
+ SubtitleBlock: 'SubtitleBlock',
197
225
  };
198
- const LEADGEN_BLOCK_IN_FORM = [
226
+ const LEADGEN_BLOCK_INPUT = [
199
227
  LEADGEN_BLOCK.TextBlock,
200
228
  LEADGEN_BLOCK.NumberBlock,
201
229
  LEADGEN_BLOCK.DateBlock,
@@ -210,7 +238,59 @@ const LEADGEN_BLOCK_IN_FORM = [
210
238
  LEADGEN_BLOCK.CheckboxBlock,
211
239
  LEADGEN_BLOCK.TncBlock,
212
240
  ];
241
+ const leadGenFieldNamePhone = (listBlockAdded) => {
242
+ return listBlockAdded
243
+ .filter(({ name }) => [
244
+ LEADGEN_BLOCK.PhoneBlock,
245
+ LEADGEN_BLOCK.PhoneOtpBlock,
246
+ LEADGEN_BLOCK.WhatsappOtpBlock,
247
+ LEADGEN_BLOCK.ZaloOtpBlock,
248
+ ].includes(name))
249
+ .map(({ data }) => data.value);
250
+ };
213
251
  const SSO_MAP_LEAD = ['name', 'email', 'birthday', 'phone', 'gender'];
252
+ const LEAD_LOCALE_DATA = {
253
+ 'vi-VN': {
254
+ popupLang: 'vi',
255
+ countryCode: 'vn',
256
+ countryCodeNumber: 84,
257
+ },
258
+ 'id-ID': {
259
+ popupLang: 'id',
260
+ countryCode: 'id',
261
+ countryCodeNumber: 62,
262
+ },
263
+ 'th-TH': {
264
+ popupLang: 'th',
265
+ countryCode: 'th',
266
+ countryCodeNumber: 66,
267
+ },
268
+ 'ms-MY': {
269
+ popupLang: 'ms',
270
+ countryCode: 'my',
271
+ countryCodeNumber: 60,
272
+ },
273
+ 'zh-TW': {
274
+ popupLang: 'zh',
275
+ countryCode: 'tw',
276
+ countryCodeNumber: 886,
277
+ },
278
+ 'km-KH': {
279
+ popupLang: 'km',
280
+ countryCode: 'kh',
281
+ countryCodeNumber: 855,
282
+ },
283
+ 'my-MM': {
284
+ popupLang: 'my',
285
+ countryCode: 'mm',
286
+ countryCodeNumber: 95,
287
+ },
288
+ 'hi-IN': {
289
+ popupLang: 'hi',
290
+ countryCode: 'in',
291
+ countryCodeNumber: 91,
292
+ },
293
+ };
214
294
  const mappingSSOToLead = (userInfoProps) => {
215
295
  var _a, _b;
216
296
  try {
@@ -226,7 +306,7 @@ const mappingSSOToLead = (userInfoProps) => {
226
306
  if (ssoKey === 'birthday') {
227
307
  const dob = dayjs__default["default"](initValue, 'YYYY-MM-DD', true);
228
308
  if (dob.isValid()) {
229
- user.birthday = dob;
309
+ user.birthday = dob.toDate();
230
310
  }
231
311
  }
232
312
  else if (ssoKey === 'gender') {
@@ -249,16 +329,83 @@ const mappingSSOToLead = (userInfoProps) => {
249
329
  catch (error) {
250
330
  return;
251
331
  }
332
+ };
333
+ const formatCampaignDetail = (campaign) => {
334
+ if (!campaign) {
335
+ return {};
336
+ }
337
+ try {
338
+ const { extra_fields, thank_you_image } = campaign || {};
339
+ const { textBlocks: exTextBlocks, imageBlocks: exImageBlocks, listBlockAdded: exListBlockAdded, listBlockThankyou: exListBlockThankyou, actionBlocks: exActionBlocks, } = extra_fields;
340
+ const textBlocks = JSON.parse(exTextBlocks);
341
+ const imageBlocks = JSON.parse(exImageBlocks);
342
+ const listBlockAdded = JSON.parse(exListBlockAdded);
343
+ const listBlockThankyou = JSON.parse(exListBlockThankyou);
344
+ const actionBlocks = JSON.parse(exActionBlocks);
345
+ const ThankYouBlock = {
346
+ image: { src: thank_you_image },
347
+ };
348
+ listBlockThankyou.forEach((block) => {
349
+ const { name, data } = block || {};
350
+ const { value: htmlText, align, newtab, url } = data || {};
351
+ switch (name) {
352
+ case LEADGEN_BLOCK.TitleBlock: {
353
+ ThankYouBlock.title = { htmlText, align };
354
+ }
355
+ case LEADGEN_BLOCK.SubtitleBlock: {
356
+ ThankYouBlock.description = { htmlText, align };
357
+ }
358
+ case LEADGEN_BLOCK.LinkButtonBlock: {
359
+ ThankYouBlock.button = { htmlText, newtab, url };
360
+ }
361
+ }
362
+ });
363
+ return Object.assign(Object.assign({}, campaign), { extra_fields: Object.assign(Object.assign({}, extra_fields), { textBlocks,
364
+ imageBlocks,
365
+ listBlockAdded,
366
+ listBlockThankyou,
367
+ actionBlocks }), ThankYouBlock });
368
+ }
369
+ catch (error) {
370
+ return {};
371
+ }
252
372
  };
253
373
 
254
374
  class Store {
255
375
  constructor() {
376
+ this.apiSsoUrl = 'https://staging-id.hellobacsi.com/';
256
377
  this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
257
378
  this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
258
379
  }
259
380
  }
260
381
  const leadStore = new Store();
261
382
 
383
+ const METHOD = {
384
+ GET: 'get',
385
+ POST: 'POST',
386
+ };
387
+ const LEADGEN_API_PATH = {
388
+ V2_CAMPAIGN: 'api/v2/campaign',
389
+ V2_SUBSCRIPTION_LEAD: 'api/v2/subscription-box',
390
+ V2_SUBSCRIPTION_INFO: 'api/campaign/get-title',
391
+ };
392
+ const SSO_API_PATH = {
393
+ USER_UPDATE: 'api/user/update',
394
+ };
395
+ const ssoApi = {
396
+ call(_a) {
397
+ var { url, data } = _a, config = tslib_es6.__rest(_a, ["url", "data"]);
398
+ const token = miscCookieHelper.getCookie(index.BEARER_TOKEN_COOKIE);
399
+ config.body = JSON.stringify(data);
400
+ config.headers = {
401
+ 'Content-Type': 'application/json',
402
+ Authorization: `Bearer ${token}`,
403
+ };
404
+ return fetch(`${leadStore.apiSsoUrl}${url}`, config)
405
+ .then((res) => res.json())
406
+ .catch(() => ({}));
407
+ },
408
+ };
262
409
  const leadApi = {
263
410
  call(_a) {
264
411
  var { url, data = undefined } = _a, config = tslib_es6.__rest(_a, ["url", "data"]);
@@ -362,8 +509,54 @@ const verifyOtpLead = ({ phone, otp, type, }) => {
362
509
  },
363
510
  });
364
511
  };
512
+ const getCampaignByCode = (campaign_code) => {
513
+ return leadApi.call({
514
+ url: `${LEADGEN_API_PATH.V2_CAMPAIGN}/${campaign_code}`,
515
+ method: METHOD.GET,
516
+ });
517
+ };
518
+ const getSubscriptionBoxInfo = ({ category, site, }) => {
519
+ return leadApi.call({
520
+ url: `${LEADGEN_API_PATH.V2_SUBSCRIPTION_INFO}?category=${category}&site=${site}`,
521
+ method: METHOD.GET,
522
+ });
523
+ };
524
+ const postSubscriptionBoxLead = ({ data }) => {
525
+ return leadApi.call({
526
+ url: LEADGEN_API_PATH.V2_SUBSCRIPTION_LEAD,
527
+ method: METHOD.POST,
528
+ data,
529
+ });
530
+ };
531
+ const postUserInfoFromLeadGen = ({ name }) => {
532
+ return ssoApi.call({
533
+ url: SSO_API_PATH.USER_UPDATE,
534
+ method: METHOD.POST,
535
+ data: { name },
536
+ });
537
+ };
538
+ const campaignPostImpression = ({ code, action, title_article, ga_client_id, cookie_id, extra, url, referrer, }) => {
539
+ return leadApi.call({
540
+ url: `api/campaign/${code}/impression`,
541
+ method: METHOD.POST,
542
+ data: {
543
+ action,
544
+ title_article,
545
+ cookie_id,
546
+ ga_client_id,
547
+ url,
548
+ extra,
549
+ referrer,
550
+ },
551
+ });
552
+ };
365
553
  const Service = {
366
554
  campaignGetById,
555
+ getCampaignByCode,
556
+ getSubscriptionBoxInfo,
557
+ postSubscriptionBoxLead,
558
+ postUserInfoFromLeadGen,
559
+ campaignPostImpression,
367
560
  validateEmailOrPhoneOnSubot,
368
561
  validateEmailOrPhoneOnLeadGen,
369
562
  validatePhoneNumberOnLeadGen,
@@ -470,7 +663,7 @@ const clearCacheUsedEmailOrPhone = () => {
470
663
  // You can give context variables any name
471
664
  const [LeadFormProvider$1, useLeadFormContext$1, useLeadForm$1] = form.createFormContext();
472
665
  const useLeadFormConfig$1 = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, }) => {
473
- const { t } = index.useTranslations();
666
+ const { t } = index$1.useTranslations();
474
667
  const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
475
668
  React.useEffect(() => {
476
669
  if (!window.intlTelInputUtils) {
@@ -700,10 +893,10 @@ const Component = ({ campaign, onClose: onCloseProp, onOtherSubmit, onSubmit, sh
700
893
  const Description = (_a) => {
701
894
  var rest = tslib_es6.__rest(_a, []);
702
895
  const { description } = React.useContext(LeadGenComponentContext);
703
- return description ? (React__default["default"].createElement(index$1.Text, Object.assign({ size: "p3" }, rest), description)) : null;
896
+ return description ? (React__default["default"].createElement(index$2.Text, Object.assign({ size: "p3" }, rest), description)) : null;
704
897
  };
705
898
 
706
- const LeadGenContext = React.createContext({});
899
+ const LeadGenContext$1 = React.createContext({});
707
900
 
708
901
  var useStyles$2 = core.createStyles(() => {
709
902
  return {
@@ -756,7 +949,7 @@ const LocationBlock = ({ name, placeholder, locale, required = true, }) => {
756
949
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
757
950
  LoadScript && (React__default["default"].createElement(LoadScript, { googleMapsApiKey: usePlacesAutocomplete.GOOGLE_API_KEY, libraries: libraries$1, loadingElement: React__default["default"].createElement(React__default["default"].Fragment, null) })),
758
951
  React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": name, "data-control": 'text' }),
759
- React__default["default"].createElement(index$2.Select, Object.assign({ className: "lead-modal__form-control", label: placeholder, placeholder: placeholder, withAsterisk: required, name: name, data: options, searchValue: searchValue, onSearchChange: (query) => {
952
+ React__default["default"].createElement(index$3.Select, Object.assign({ className: "lead-modal__form-control", label: placeholder, placeholder: placeholder, withAsterisk: required, name: name, data: options, searchValue: searchValue, onSearchChange: (query) => {
760
953
  setSearchValue(query);
761
954
  }, filter: () => true, clearable: true, searchable: true, onChange: (val) => setAddress(val || ''), icon: React__default["default"].createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" },
762
955
  React__default["default"].createElement("path", { d: "M10 9.792q.605 0 1.032-.427.426-.428.426-1.032 0-.603-.426-1.031A1.4 1.4 0 0 0 10 6.875q-.604 0-1.032.427a1.4 1.4 0 0 0-.426 1.031q0 .604.426 1.032.428.426 1.032.427m0 8.083q-.145 0-.292-.042a.7.7 0 0 1-.27-.145Q6.478 15 5.01 12.708 3.54 10.418 3.54 8.5q0-3.021 1.949-4.823T10 1.875t4.51 1.802q1.95 1.802 1.949 4.823 0 1.917-1.468 4.208-1.47 2.292-4.427 4.98a.7.7 0 0 1-.271.145 1 1 0 0 1-.292.042", fill: "#8C8C8C" })), autoComplete: 'no-auto-complete-' + randRef.current, rightSection: React__default["default"].createElement(React__default["default"].Fragment, null) }, form.getInputProps(name)))));
@@ -767,7 +960,7 @@ const SubtitleBlock$1 = ({ children, align, }) => (React__default["default"].cre
767
960
  const TitleBlock$1 = ({ children, align, }) => (React__default["default"].createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
768
961
 
769
962
  const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, popoverProps, }) => {
770
- const { primaryColor } = React.useContext(LeadGenContext);
963
+ const { primaryColor } = React.useContext(LeadGenContext$1);
771
964
  const { classes, cx } = useStyles$2(undefined, {
772
965
  name: 'LeadGen__Field',
773
966
  styles,
@@ -785,15 +978,15 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
785
978
  case 'SubtitleBlock':
786
979
  return (React__default["default"].createElement(SubtitleBlock$1, { key: index, align: align }, value));
787
980
  case 'TextBlock':
788
- return (React__default["default"].createElement(index$2.Input, Object.assign({ key: index, withAsterisk: required, spellCheck: false, type: "text", placeholder: placeholder, className: cx('leadgen-control', classes.control),
981
+ return (React__default["default"].createElement(index$3.Input, Object.assign({ key: index, withAsterisk: required, spellCheck: false, type: "text", placeholder: placeholder, className: cx('leadgen-control', classes.control),
789
982
  // onChangeRaw={(e) => inputOnChange('text', e)}
790
983
  label: placeholder, "data-control": "text", name: value }, form.getInputProps(value))));
791
984
  case 'NumberBlock':
792
- return (React__default["default"].createElement(index$2.NumberInput, Object.assign({ key: index, withAsterisk: required, spellCheck: false, type: "number", placeholder: placeholder, className: cx('leadgen-control', classes.control),
985
+ return (React__default["default"].createElement(index$3.NumberInput, Object.assign({ key: index, withAsterisk: required, spellCheck: false, type: "number", placeholder: placeholder, className: cx('leadgen-control', classes.control),
793
986
  // onChange={(e) => inputOnChange('number', e)}
794
987
  label: placeholder, "data-control": "number", name: value }, form.getInputProps(value))));
795
988
  case 'EmailBlock':
796
- return (React__default["default"].createElement(index$2.Input, Object.assign({ key: index, withAsterisk: required, spellCheck: false,
989
+ return (React__default["default"].createElement(index$3.Input, Object.assign({ key: index, withAsterisk: required, spellCheck: false,
797
990
  // type="email"
798
991
  placeholder: placeholder, className: cx('leadgen-control', classes.control), label: placeholder, "data-control": "email", name: value }, form.getInputProps(value))));
799
992
  case 'PhoneOtpBlock':
@@ -801,12 +994,12 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
801
994
  case 'ZaloOtpBlock':
802
995
  case 'PhoneBlock': {
803
996
  const id = popupId + '-' + value + '-' + index;
804
- return (React__default["default"].createElement(index$2.Input.Wrapper, Object.assign({ size: "md", withAsterisk: required, key: index, label: placeholder,
997
+ return (React__default["default"].createElement(index$3.Input.Wrapper, Object.assign({ size: "md", withAsterisk: required, key: index, label: placeholder,
805
998
  // error={errorField.phone}
806
999
  className: cx('leadgen-control', classes.control), labelProps: {
807
1000
  htmlFor: id,
808
1001
  } }, form.getInputProps(value)),
809
- React__default["default"].createElement(index$2.Phone, { name: value, spellCheck: false, type: "tel", placeholder: placeholder, value: form.getInputProps(value).value, onChange: (v) => {
1002
+ React__default["default"].createElement(index$3.Phone, { name: value, spellCheck: false, type: "tel", placeholder: placeholder, value: form.getInputProps(value).value, onChange: (v) => {
810
1003
  form.setFieldValue(value, v);
811
1004
  },
812
1005
  // onBlur={(e) => inputOnBlur('tel', e)}
@@ -817,12 +1010,12 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
817
1010
  }
818
1011
  case 'DateBlock':
819
1012
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
820
- React__default["default"].createElement(index$4.DatePicker, Object.assign({ withAsterisk: required, key: index, type: "default", name: value, placeholder: placeholder, className: cx('leadgen-control', classes.control), label: placeholder, "data-control": "date", popoverProps: popoverProps }, form.getInputProps(value))),
1013
+ React__default["default"].createElement(index$5.DatePicker, Object.assign({ withAsterisk: required, key: index, type: "default", name: value, placeholder: placeholder, className: cx('leadgen-control', classes.control), label: placeholder, "data-control": "date", popoverProps: popoverProps }, form.getInputProps(value))),
821
1014
  React__default["default"].createElement("input", { type: "hidden", name: value, "data-control": "date" })));
822
1015
  case 'LinkButtonBlock':
823
1016
  return (React__default["default"].createElement("div", { key: index },
824
1017
  React__default["default"].createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
825
- React__default["default"].createElement(index$3.Button, { type: "button", size: "md", color: primaryColor, className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
1018
+ React__default["default"].createElement(index$4.Button, { type: "button", size: "md", color: primaryColor, className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
826
1019
  onClose === null || onClose === void 0 ? void 0 : onClose();
827
1020
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
828
1021
  } }, value))));
@@ -831,26 +1024,26 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
831
1024
  isSendMailChimp && (React__default["default"].createElement("div", { style: {
832
1025
  display: 'none',
833
1026
  }, "data-name": value + '-mailchimp' })),
834
- React__default["default"].createElement(index$2.Checkbox.Group, Object.assign({ withAsterisk: required, className: cx('leadgen-control', classes.control), key: index, label: placeholder, size: "md", sx: {
1027
+ React__default["default"].createElement(index$3.Checkbox.Group, Object.assign({ withAsterisk: required, className: cx('leadgen-control', classes.control), key: index, label: placeholder, size: "md", sx: {
835
1028
  display: 'flex',
836
1029
  flexDirection: 'column',
837
1030
  gap: 8,
838
- } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$2.Checkbox, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
1031
+ } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$3.Checkbox, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
839
1032
  case 'RadioBlock':
840
1033
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
841
- isSendMailChimp && (React__default["default"].createElement(index$2.Input, { type: "hidden", name: value + '-mailchimp', value: isSendMailChimp })),
842
- React__default["default"].createElement(index$2.Radio.Group, Object.assign({ withAsterisk: required, className: cx('leadgen-control', classes.control), key: index, label: placeholder, size: "md" }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$2.Radio, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
1034
+ isSendMailChimp && (React__default["default"].createElement(index$3.Input, { type: "hidden", name: value + '-mailchimp', value: isSendMailChimp })),
1035
+ React__default["default"].createElement(index$3.Radio.Group, Object.assign({ withAsterisk: required, className: cx('leadgen-control', classes.control), key: index, label: placeholder, size: "md" }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$3.Radio, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
843
1036
  case 'DropdownBlock':
844
1037
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
845
1038
  React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
846
- React__default["default"].createElement(index$2.Select, Object.assign({ key: index, className: cx('leadgen-control', classes.control), label: placeholder, withAsterisk: required, name: value, data: listQuestion.map((l) => ({
1039
+ React__default["default"].createElement(index$3.Select, Object.assign({ key: index, className: cx('leadgen-control', classes.control), label: placeholder, withAsterisk: required, name: value, data: listQuestion.map((l) => ({
847
1040
  value: l.value,
848
1041
  label: l.placeholder,
849
1042
  })) }, form.getInputProps(value)))));
850
1043
  case 'TncBlock':
851
1044
  const tncInputProps = form.getInputProps('TNC-' + b.id);
852
1045
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
853
- React__default["default"].createElement(index$2.Checkbox, Object.assign({ name: 'TNC-' + b.id, key: b.id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps, { error: tncInputProps.error ? tncInputProps.error : undefined }))));
1046
+ React__default["default"].createElement(index$3.Checkbox, Object.assign({ name: 'TNC-' + b.id, key: b.id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps, { error: tncInputProps.error ? tncInputProps.error : undefined }))));
854
1047
  }
855
1048
  return null;
856
1049
  })));
@@ -877,12 +1070,12 @@ var useStyles$1 = core.createStyles((theme) => {
877
1070
  const Heading = (_a) => {
878
1071
  var rest = tslib_es6.__rest(_a, []);
879
1072
  const { heading } = React.useContext(LeadGenComponentContext);
880
- return heading ? (React__default["default"].createElement(index$1.Text, Object.assign({ size: "h3" }, rest), heading)) : null;
1073
+ return heading ? (React__default["default"].createElement(index$2.Text, Object.assign({ size: "h3" }, rest), heading)) : null;
881
1074
  };
882
1075
 
883
1076
  const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps, submitProps, }) => {
884
1077
  var _a;
885
- const { primaryColor } = React.useContext(LeadGenContext);
1078
+ const { primaryColor } = React.useContext(LeadGenContext$1);
886
1079
  const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, setFormRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = React.useContext(LeadGenComponentContext);
887
1080
  const { classes, cx } = useStyles$1(undefined, {
888
1081
  name: 'LeadGen__FormComponent',
@@ -971,7 +1164,7 @@ const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps,
971
1164
  control: classes.control,
972
1165
  }, listBlockAdded: listBlockAdded, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit, popoverProps: popoverProps })),
973
1166
  ((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) ? null : (React__default["default"].createElement("div", { className: classes.submitBtnWrapper },
974
- React__default["default"].createElement(index$3.Button, Object.assign({ size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, loading: isSubmitLoading, color: primaryColor }, submitProps), popUpSubmitText))))));
1167
+ React__default["default"].createElement(index$4.Button, Object.assign({ size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, loading: isSubmitLoading, color: primaryColor }, submitProps), popUpSubmitText))))));
975
1168
  };
976
1169
  const Form = (props) => {
977
1170
  const { showOtpPhone, showThankyou } = React.useContext(LeadGenComponentContext);
@@ -992,7 +1185,7 @@ var useStyles = core.createStyles(() => {
992
1185
  });
993
1186
 
994
1187
  const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, styles, classNames, }) => {
995
- const { t } = index.useTranslations();
1188
+ const { t } = index$1.useTranslations();
996
1189
  const phone = otpData.phone;
997
1190
  const otpType = otpData.type;
998
1191
  const [otp, setOtp] = React.useState('');
@@ -1102,9 +1295,9 @@ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, st
1102
1295
  submitOtp();
1103
1296
  }, className: cx(classes.root, className) },
1104
1297
  React__default["default"].createElement("div", { className: classes.header },
1105
- React__default["default"].createElement(index$5.Heading, { tag: "h3", className: classes.heading }, t('lead.otp.title')),
1106
- React__default["default"].createElement(index$1.Text, { size: "p3", className: classes.description }, t('lead.otp.desc', { phone: displayPhone }))),
1107
- React__default["default"].createElement(index$2.Input, { ref: inputRef, name: '_' + name + '-otp', spellCheck: false, type: "number", placeholder: t('lead.otp.phonePlaceholder'), className: classes.control, label: t('lead.otp.phoneLabel'), "data-control": "otp", withAsterisk: true, pattern: "[0-9]*", value: otp, maxLength: 6, onChange: (v) => {
1298
+ React__default["default"].createElement(index$6.Heading, { tag: "h3", className: classes.heading }, t('lead.otp.title')),
1299
+ React__default["default"].createElement(index$2.Text, { size: "p3", className: classes.description }, t('lead.otp.desc', { phone: displayPhone }))),
1300
+ React__default["default"].createElement(index$3.Input, { ref: inputRef, name: '_' + name + '-otp', spellCheck: false, type: "number", placeholder: t('lead.otp.phonePlaceholder'), className: classes.control, label: t('lead.otp.phoneLabel'), "data-control": "otp", withAsterisk: true, pattern: "[0-9]*", value: otp, maxLength: 6, onChange: (v) => {
1108
1301
  setIsDirty(true);
1109
1302
  setOtp(v);
1110
1303
  if (isDirty && !v)
@@ -1113,10 +1306,10 @@ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, st
1113
1306
  setErrorMsg(undefined);
1114
1307
  }, error: isDirty ? errorMsg : undefined }),
1115
1308
  React__default["default"].createElement("div", { className: classes.actions },
1116
- React__default["default"].createElement(index$3.Button, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1309
+ React__default["default"].createElement(index$4.Button, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1117
1310
  // onClick={() => submitOtp()}
1118
1311
  disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
1119
- React__default["default"].createElement(index$3.Button, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1312
+ React__default["default"].createElement(index$4.Button, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1120
1313
  sendOtp();
1121
1314
  }, disabled: !!resendTimer }, t('lead.otp.resend', {
1122
1315
  timer: resendTimer ? ` (${resendTimer}s)` : '',
@@ -1392,152 +1585,1694 @@ const translationsMap = {
1392
1585
  'my-MM': myMM,
1393
1586
  'km-KH': kmKH,
1394
1587
  'zh-TW': zhTW,
1588
+ 'zh-CN': zhTW,
1395
1589
  'th-TH': thTH,
1396
1590
  'tl-PH': enPH,
1397
1591
  };
1398
1592
  const getTranslations = (locale) => {
1399
- const translations = translationsMap[locale];
1593
+ const translations = Object.assign(Object.assign({}, translationsProvider.translationsMap[locale]), translationsMap[locale]);
1400
1594
  if (translations) {
1401
1595
  return translations;
1402
1596
  }
1403
1597
  return translationsMap['en-PH'];
1404
1598
  };
1405
1599
 
1406
- const useImageSize = (src) => {
1407
- const [width, setWidth] = React.useState(16);
1408
- const [height, setHeight] = React.useState(9);
1409
- const [loaded, setLoaded] = React.useState(false);
1410
- // load src image to get its width and height
1411
- React.useEffect(() => {
1412
- setLoaded(false);
1413
- if (src) {
1414
- const img = new Image();
1415
- img.addEventListener('load', () => {
1416
- setWidth(img.naturalWidth);
1417
- setHeight(img.naturalHeight);
1418
- setLoaded(true);
1419
- });
1420
- img.addEventListener('error', () => {
1421
- setWidth(16);
1422
- setHeight(9);
1423
- setLoaded(true);
1424
- });
1425
- img.src = src;
1426
- }
1427
- else {
1428
- setWidth(16);
1429
- setHeight(9);
1430
- setLoaded(true);
1431
- }
1432
- }, [src]);
1433
- return {
1434
- loaded,
1435
- width,
1436
- height,
1437
- };
1438
- };
1439
-
1440
- const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default["default"].createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
1441
- React__default["default"].createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
1442
- React__default["default"].createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
1443
-
1444
- // url: imageBlocks.imageMobile.data.url
1445
- // newTab: imageBlocks.imageMobile.data.newtab
1446
- // imageMobile: campaignShow.image
1447
- // imageDestkop: campaignShow.image_desktop
1448
- const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
1449
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1450
- const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
1451
- if (!imageMobileLoaded || !imageDestkopLoaded)
1452
- return null;
1453
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
1454
- React__default["default"].createElement("div", { className: "le-center-tab-popup" },
1455
- React__default["default"].createElement("div", { style: { position: 'relative' } },
1456
- React__default["default"].createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
1457
- index$6.isVideo(imageMobile) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
1458
- React__default["default"].createElement("source", { src: imageMobile }))) : (React__default["default"].createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
1459
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1460
- } })),
1461
- index$6.isVideo(imageDestkop) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
1462
- React__default["default"].createElement("source", { src: imageDestkop }))) : (React__default["default"].createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
1463
- aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
1464
- } }))),
1465
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
1466
- };
1467
-
1468
- // title: titleText
1469
- // titleAlign: textBlocks.titleBlock.data.align
1470
- // subtitle: textBlocks.subtitleBlock.data.value
1471
- // subtitleAlign: textBlocks.subtitleBlock.data.align
1472
- // url: actionBlocks.linkButtonBlock.data.url
1473
- // urlText: actionBlocks.linkButtonBlock.data.value
1474
- // newTab: actionBlocks.linkButtonBlock.data.newtab
1475
- // imageMobile: campaignShow.image
1476
- // imageDesktop: campaignShow.image_desktop
1477
- const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
1478
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1479
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
1480
- if (!imageMobileLoaded || !imageDesktopLoaded)
1481
- return null;
1482
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
1483
- React__default["default"].createElement("aside", { className: "le-only-desktop" },
1484
- React__default["default"].createElement("div", { className: "le-floating-desktop" },
1485
- React__default["default"].createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
1486
- imageDesktop ? (React__default["default"].createElement("div", null,
1487
- React__default["default"].createElement("img", { style: {
1488
- maxWidth: 120,
1489
- borderTopLeftRadius: 5,
1490
- borderBottomLeftRadius: 5,
1491
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
1492
- }, src: imageDesktop }))) : null,
1493
- React__default["default"].createElement("div", { style: { padding: 20 } },
1494
- React__default["default"].createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
1495
- React__default["default"].createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
1496
- React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
1497
- React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
1498
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
1499
- React__default["default"].createElement("aside", { className: "le-only-mobile" },
1500
- React__default["default"].createElement("div", { className: "le-floating-mobile" },
1501
- React__default["default"].createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
1502
- React__default["default"].createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
1503
- React__default["default"].createElement("div", null,
1504
- React__default["default"].createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
1505
- React__default["default"].createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
1506
- imageMobile ? (React__default["default"].createElement("div", null,
1507
- React__default["default"].createElement("img", { style: {
1508
- marginLeft: 15,
1509
- marginTop: 4,
1510
- maxWidth: 100,
1511
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1512
- }, src: imageMobile }))) : null),
1513
- React__default["default"].createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
1514
- React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
1515
- React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
1516
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
1600
+ const LeadGenTranslationProvider = (props) => {
1601
+ const { locale, children } = props;
1602
+ const translationContextValue = React.useMemo(() => ({ locale, values: getTranslations(locale) }), [locale]);
1603
+ return (React__default["default"].createElement(translationsContext.TranslationsContext.Provider, { value: translationContextValue }, children));
1517
1604
  };
1518
1605
 
1519
- const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
1520
- const { primaryColor } = React.useContext(LeadGenContext);
1521
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
1522
- if (!imageLoaded)
1606
+ // import mockLeadData from './mockLeadData'
1607
+ const listCampaignScheduled = [];
1608
+ const listCampaignScheduledToActivated = [];
1609
+ const listCampaignActiveButExpired = [];
1610
+ const listCampaignExcludeSonsored = [];
1611
+ const listCampaignDifferentSponsor = [];
1612
+ const listCampaignNotDisplayInRangeOfTime = [];
1613
+ function isMobile() {
1614
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
1615
+ }
1616
+ const getShuffleArray = (array) => {
1617
+ const newArray = [...array];
1618
+ for (let i = newArray.length - 1; i > 0; i--) {
1619
+ const j = Math.floor(Math.random() * (i + 1));
1620
+ const temp = newArray[i];
1621
+ newArray[i] = newArray[j];
1622
+ newArray[j] = temp;
1623
+ }
1624
+ return newArray;
1625
+ };
1626
+ const getTimeByTimezone = (timeZone = 'UTC') => {
1627
+ const date = new Date();
1628
+ return new Date(date.toLocaleString('en-US', { timeZone }));
1629
+ };
1630
+ const parseDateByCampaignTime = (dateStr) => {
1631
+ // Format like this: 2023-04-04 00:00:00
1632
+ try {
1633
+ const [datePart, timePart] = dateStr.split(' ');
1634
+ const [year, month, day] = datePart.split('-').map(Number);
1635
+ const [hours, minutes, seconds] = timePart.split(':').map(Number);
1636
+ /** JavaScript counts months from 0 to 11 */
1637
+ return new Date(year, month - 1, day, hours, minutes, seconds);
1638
+ }
1639
+ catch (err) {
1523
1640
  return null;
1524
- return (React__default["default"].createElement("div", { className: "lead-modal__thank-you leadgen-inner_thankyou" },
1525
- React__default["default"].createElement("div", { style: { width: '100%' } },
1526
- React__default["default"].createElement("img", { src: image, style: {
1527
- maxHeight: 162,
1528
- objectFit: 'cover',
1529
- aspectRatio: `${imageWidth}/${imageHeight}`,
1530
- }, loading: "lazy" }),
1531
- title && (React__default["default"].createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
1532
- subtitle && (React__default["default"].createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle.split('\n').map((text, idx, list) => {
1533
- const isShowBr = idx < list.length - 1;
1534
- return (React__default["default"].createElement(React__default["default"].Fragment, null,
1535
- text,
1536
- isShowBr && React__default["default"].createElement("br", null)));
1537
- }))),
1538
- linkText && (React__default["default"].createElement("div", null,
1539
- React__default["default"].createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
1540
- React__default["default"].createElement(index$3.Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
1641
+ }
1642
+ };
1643
+ const checkCampaignNowInTimeframe = (c) => {
1644
+ var _a;
1645
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1646
+ const startedAtStr = c.started_at;
1647
+ const endedAtStr = c.ended_at;
1648
+ const startedDate = parseDateByCampaignTime(startedAtStr);
1649
+ const endedDate = parseDateByCampaignTime(endedAtStr);
1650
+ if (!startedDate || !endedDate) {
1651
+ return false;
1652
+ }
1653
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
1654
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1655
+ if (nowWithTimezoneMs <= endedDate.getTime() &&
1656
+ nowWithTimezoneMs >= startedDate.getTime()) {
1657
+ listCampaignScheduledToActivated.push(c);
1658
+ return true;
1659
+ }
1660
+ return false;
1661
+ };
1662
+ function checkCampaignActiveButExpireAlready(c) {
1663
+ var _a;
1664
+ /** Do not setup timeframe for this campaign. No need to check */
1665
+ if (c.forever === 1) {
1666
+ return true;
1667
+ }
1668
+ const startedAtStr = c.started_at;
1669
+ const endedAtStr = c.ended_at;
1670
+ const startedDate = parseDateByCampaignTime(startedAtStr);
1671
+ const endedDate = parseDateByCampaignTime(endedAtStr);
1672
+ /** Do not setup timeframe for this campaign. No need to check */
1673
+ if (!startedDate || !endedDate) {
1674
+ return true;
1675
+ }
1676
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1677
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
1678
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1679
+ /** Check if this expire already, do not show */
1680
+ if (nowWithTimezoneMs > endedDate.getTime()) {
1681
+ listCampaignActiveButExpired.push(c);
1682
+ return false;
1683
+ }
1684
+ return true;
1685
+ }
1686
+ function shouldNotDisplayIfExcludeAllSponsors(c) {
1687
+ var _a;
1688
+ const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
1689
+ const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
1690
+ if (isSponsored && excludeSponsored) {
1691
+ listCampaignExcludeSonsored.push(c);
1692
+ return true;
1693
+ }
1694
+ return false;
1695
+ }
1696
+ function shouldDisplayWithCurrentSponsor(c) {
1697
+ var _a, _b;
1698
+ try {
1699
+ // TODO: BE will rename `exclude_sponsored_list` later
1700
+ const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
1701
+ const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
1702
+ const dataSponsoredId = Number((_b = document
1703
+ .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
1704
+ // There is no config for sponsor id and white list, should show as default
1705
+ if (!dataSponsoredId ||
1706
+ dataSponsoredId <= 0 ||
1707
+ whiteListSponsors.length === 0) {
1708
+ return true;
1709
+ }
1710
+ // Check the dataSponsoredId exists in the white list or not.
1711
+ const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
1712
+ if (isExist) {
1713
+ return true;
1714
+ }
1715
+ listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
1716
+ return false;
1717
+ }
1718
+ catch (err) {
1719
+ // Default is show
1720
+ return true;
1721
+ }
1722
+ }
1723
+ const filterFnCampaign = (c) => {
1724
+ if (shouldNotDisplayIfExcludeAllSponsors(c)) {
1725
+ return false;
1726
+ }
1727
+ else if (!shouldDisplayWithCurrentSponsor(c)) {
1728
+ return false;
1729
+ }
1730
+ /** Active */
1731
+ if (c.formatted_status === 1) {
1732
+ return checkCampaignActiveButExpireAlready(c);
1733
+ }
1734
+ /** Schedule */
1735
+ if (c.formatted_status === 0) {
1736
+ listCampaignScheduled.push(c);
1737
+ return checkCampaignNowInTimeframe(c);
1738
+ }
1739
+ return false;
1740
+ };
1741
+ const fillterApprearanceTimeCampaign = (c) => {
1742
+ var _a;
1743
+ try {
1744
+ const isTimeInRange = (currentTime, startTime, endTime) => {
1745
+ const startParts = startTime.split(':');
1746
+ const endParts = endTime.split(':');
1747
+ const startDate = new Date();
1748
+ startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
1749
+ const endDate = new Date();
1750
+ endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
1751
+ return currentTime >= startDate && currentTime <= endDate;
1752
+ };
1753
+ const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
1754
+ const startTime = rulesApprValue.startTime;
1755
+ const endTime = rulesApprValue.endTime || '23:59';
1756
+ if (!startTime) {
1757
+ return true;
1758
+ }
1759
+ if (isTimeInRange(new Date(), startTime, endTime)) {
1760
+ return true;
1761
+ }
1762
+ listCampaignNotDisplayInRangeOfTime.push(c);
1763
+ return false;
1764
+ }
1765
+ catch (err) {
1766
+ return true;
1767
+ }
1768
+ };
1769
+ let timeoutRef = null;
1770
+ let LEAD_SCROLL_EVENT = null;
1771
+ function clearPassiveEvent() {
1772
+ if (timeoutRef) {
1773
+ clearTimeout(timeoutRef);
1774
+ timeoutRef = null;
1775
+ }
1776
+ if (LEAD_SCROLL_EVENT) {
1777
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1778
+ LEAD_SCROLL_EVENT = null;
1779
+ }
1780
+ }
1781
+ function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
1782
+ // clear previous passive event, check for new condition
1783
+ clearPassiveEvent();
1784
+ const leadCurrentUrl = DEBUG_URL ||
1785
+ ('https://' +
1786
+ location.hostname +
1787
+ location.pathname +
1788
+ location.search).toLowerCase();
1789
+ fetch(leadApi + 'api/campaign/' + leadSiteId, {
1790
+ method: 'POST',
1791
+ headers: {
1792
+ 'Content-Type': 'application/json',
1793
+ },
1794
+ body: JSON.stringify({
1795
+ url: leadCurrentUrl,
1796
+ ga_client_id: miscCookieHelper.getCookie('_ga') || null,
1797
+ }),
1798
+ })
1799
+ .then((response) => {
1800
+ return response.json();
1801
+ // return mockLeadData || response.json()
1802
+ })
1803
+ .then((data) => {
1804
+ var _a, _b, _c, _d;
1805
+ LeadLog('List campagin: ', data);
1806
+ LEAD_RESET_VAR();
1807
+ if (data._status == 1) {
1808
+ 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);
1809
+ if (!miscCookieHelper.getCookie('hhg-id')) {
1810
+ miscCookieHelper.setCookie('hhg-id', uuid.v1(), {
1811
+ domain: '.' + leadDomain,
1812
+ path: '/',
1813
+ });
1814
+ LeadLog('😍 Set HHG ID cookie');
1815
+ }
1816
+ // getCookie('hhg-id')
1817
+ // TODO: HP-534 Filter desktop
1818
+ let campaignsDevice = [];
1819
+ if (isMobile()) {
1820
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
1821
+ }
1822
+ else {
1823
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
1824
+ }
1825
+ LeadLog(`👓 campaignsDevice`, campaignsDevice);
1826
+ LeadLog('--listCampaignScheduled', listCampaignScheduled);
1827
+ LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
1828
+ LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
1829
+ LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
1830
+ LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
1831
+ LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
1832
+ // Check links
1833
+ let listLinksObj = campaignsDevice
1834
+ .map((i, index) => i.targets
1835
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
1836
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1837
+ .flat(1);
1838
+ // Check list link match current href
1839
+ listLinksObj = listLinksObj.filter((i) => {
1840
+ var _a;
1841
+ const target = new URL(String(i.target).toLowerCase());
1842
+ if (i.option == 'exact_match')
1843
+ // FOR TEST LOCAL:
1844
+ // return Boolean(location.pathname === target.pathname)
1845
+ return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
1846
+ if (i.option == 'start_with') {
1847
+ // FOR TEST LOCAL:
1848
+ // if (location.pathname.includes(target.pathname)) {
1849
+ if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
1850
+ const listExcluding = i.sub_target
1851
+ .filter((i) => i.option == 'excluding')
1852
+ .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
1853
+ return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
1854
+ }
1855
+ else {
1856
+ return false;
1857
+ }
1858
+ }
1859
+ });
1860
+ // Check tags
1861
+ const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
1862
+ const listTags = listMetaTag.map((i) => i.content);
1863
+ let listCampaignHasTag = [];
1864
+ let listTagsObj = [];
1865
+ if (listTags && listTags.length) {
1866
+ listCampaignHasTag = campaignsDevice
1867
+ .map((i, index) => i.targets
1868
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
1869
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1870
+ .flat(1);
1871
+ listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
1872
+ }
1873
+ const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
1874
+ const cookieKeys = document.cookie
1875
+ .split('; ')
1876
+ .map((i) => i.split('=')[0]);
1877
+ const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
1878
+ LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
1879
+ const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
1880
+ LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
1881
+ const listCampaignSubmitedClosed = [
1882
+ ...listCampaignCodeSubmited,
1883
+ ...listCampaignCodeClosed,
1884
+ ];
1885
+ const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
1886
+ const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
1887
+ return !hasSubmited;
1888
+ });
1889
+ const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
1890
+ // .sort(
1891
+ // (a, b) =>
1892
+ // (listCampaignValid[a.campaignIndex]?.score || 0) -
1893
+ // (listCampaignValid[b.campaignIndex]?.score || 0),
1894
+ // )
1895
+ LeadLog('--listCampaignValid : ', listCampaignValid);
1896
+ if (listCampaignValid && listCampaignValid.length) {
1897
+ const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
1898
+ LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
1899
+ const { rules } = CAMPAIGN_SHOW;
1900
+ // CHECK RULE TRIGGER POPUP
1901
+ const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
1902
+ LeadLog(`timeoutRule`, timeoutRule);
1903
+ const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
1904
+ LeadLog(`scrollRule`, scrollRule);
1905
+ let impressionAction = 'TIME';
1906
+ if (Number.isInteger(timeoutRule)) {
1907
+ impressionAction = 'TIME';
1908
+ LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
1909
+ timeoutRef = setTimeout(() => {
1910
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1911
+ }, timeoutRule * 1000);
1912
+ }
1913
+ if (Number.isInteger(scrollRule)) {
1914
+ impressionAction = 'SCROLL';
1915
+ LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
1916
+ const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
1917
+ document.querySelector('body');
1918
+ const pct = $p.getBoundingClientRect().top;
1919
+ const pb = $p.offsetHeight;
1920
+ LeadLog(`👓 Element check scroll: `, $p);
1921
+ LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
1922
+ const wt = window.pageYOffset || document.documentElement.scrollTop;
1923
+ let percent = 0;
1924
+ if (wt >= pct) {
1925
+ percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
1926
+ }
1927
+ LeadLog('---Scroll', percent, scrollRule);
1928
+ // TODO: CHECK FOOTER HEIGHT
1929
+ if (percent >= scrollRule) {
1930
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1931
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1932
+ }
1933
+ };
1934
+ window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
1935
+ passive: true,
1936
+ });
1937
+ }
1938
+ }
1939
+ else {
1940
+ LeadLog('🚧 No lead campaigns on current URL, tags');
1941
+ }
1942
+ }
1943
+ })
1944
+ .catch((err) => {
1945
+ LeadLog(`Lead error: `, err);
1946
+ });
1947
+ }
1948
+ const LeadLog = (...params) => {
1949
+ if (process.env.NODE_ENV !== 'production' ||
1950
+ (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
1951
+ process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
1952
+ (typeof localStorage !== 'undefined' &&
1953
+ localStorage.getItem('hhg_debug') === 'true')) {
1954
+ console.log(...params);
1955
+ }
1956
+ };
1957
+
1958
+ const LeadGenContext = React.createContext({
1959
+ submit(value) {
1960
+ /** Init for FAKING function */
1961
+ LeadLog('** LeadGen Submit : ', value);
1962
+ return Promise.reject(value);
1963
+ },
1964
+ submitSubscriptionBox(value) {
1965
+ /** Init for FAKING function */
1966
+ LeadLog('** LeadGen SubmitSubscriptionBox : ', value);
1967
+ return Promise.reject(value);
1968
+ },
1969
+ impression(value) {
1970
+ /** Init for FAKING function */
1971
+ LeadLog('** LeadGen Impression : ', value);
1972
+ return Promise.reject(value);
1973
+ },
1974
+ /** For Subscription Box */
1975
+ subscriptionIcon: '',
1976
+ subscriptionTitle: '',
1977
+ });
1978
+ const LeadGenContextProvider = (props) => {
1979
+ const { campaign_code: campaignCodeProps, apiSsoUrl, apiLeadUrl, apiSubotUrl, locale: localeProps, forceCampaign: forceCampaignProps, extraValues, articleId = 1, categoryId = 1, siteDomain: site_domain, children, } = props;
1980
+ const [forceCampaign, setForceCampaign] = React.useState(forceCampaignProps);
1981
+ const [subscriptionInfo, setSubscriptionInfo] = React.useState({
1982
+ subscriptionIcon: '',
1983
+ subscriptionTitle: '',
1984
+ });
1985
+ const locale = React.useMemo(() => {
1986
+ return localeProps || Locale.LOCALE['PhilippinesEnglish'];
1987
+ }, [localeProps]);
1988
+ const leadGenContextValue = React.useMemo(() => (Object.assign(Object.assign({}, props), { forceCampaign })), [...Object.values(props), forceCampaign]);
1989
+ const { url, campaign_id, campaign_code, cookie_id, ga_client_id, category_id, article_id, article_title, } = React.useMemo(() => ({
1990
+ url: location.href.toLowerCase() || '',
1991
+ cookie_id: miscCookieHelper.getCookie('hhg-id') || null,
1992
+ ga_client_id: miscCookieHelper.getCookie('_ga'),
1993
+ campaign_id: forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id,
1994
+ campaign_code: campaignCodeProps || (forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.code),
1995
+ category_id: categoryId,
1996
+ article_id: articleId,
1997
+ article_title: document.title || '',
1998
+ }), [campaignCodeProps, articleId, categoryId, forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id]);
1999
+ const fetchCampaign = React.useCallback((campaign_code) => {
2000
+ Service.getCampaignByCode(campaign_code).then((res) => {
2001
+ const { _data } = res || {};
2002
+ const { campaigns } = _data || {};
2003
+ LeadLog('** LeadGen Campaign : ', campaigns);
2004
+ setForceCampaign(formatCampaignDetail(campaigns));
2005
+ });
2006
+ }, [campaignCodeProps]);
2007
+ // TODO : Update form for LeadGen
2008
+ const submit = React.useCallback((data) => {
2009
+ return Service.postSubscriptionBoxLead({ data });
2010
+ }, []);
2011
+ const submitSubscriptionBox = React.useCallback((value) => {
2012
+ const data = Object.assign(Object.assign(Object.assign(Object.assign({}, value), { campaign_id,
2013
+ 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,
2014
+ category_id, article_title: (extraValues === null || extraValues === void 0 ? void 0 : extraValues.article_title) || article_title });
2015
+ return Service.postSubscriptionBoxLead({ data });
2016
+ }, [
2017
+ extraValues,
2018
+ site_domain,
2019
+ campaign_id,
2020
+ article_id,
2021
+ article_title,
2022
+ category_id,
2023
+ url,
2024
+ ga_client_id,
2025
+ ]);
2026
+ const impression = React.useCallback((value) => {
2027
+ return Service.campaignPostImpression({
2028
+ url: (value === null || value === void 0 ? void 0 : value.url) || url,
2029
+ action: (value === null || value === void 0 ? void 0 : value.action) || LEADGEN_ACTIONS.SCROLL,
2030
+ code: (value === null || value === void 0 ? void 0 : value.code) || campaign_code,
2031
+ title_article: (value === null || value === void 0 ? void 0 : value.title_article) || article_title,
2032
+ cookie_id: (value === null || value === void 0 ? void 0 : value.cookie_id) || cookie_id,
2033
+ ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id,
2034
+ extra: (value === null || value === void 0 ? void 0 : value.extra) || Object.assign({ cookie_id,
2035
+ article_id, subscription_title: subscriptionInfo.subscriptionTitle }, extraValues),
2036
+ referrer: value === null || value === void 0 ? void 0 : value.referrer,
2037
+ });
2038
+ }, [
2039
+ extraValues,
2040
+ campaign_id,
2041
+ url,
2042
+ campaign_code,
2043
+ article_title,
2044
+ cookie_id,
2045
+ ga_client_id,
2046
+ article_id,
2047
+ subscriptionInfo.subscriptionTitle,
2048
+ ]);
2049
+ React.useEffect(() => {
2050
+ if (forceCampaignProps) {
2051
+ setForceCampaign(forceCampaignProps);
2052
+ return;
2053
+ }
2054
+ /** For Subscription Box */
2055
+ if (categoryId) {
2056
+ Service.getSubscriptionBoxInfo({
2057
+ category: categoryId,
2058
+ site: site_domain,
2059
+ }).then((res) => {
2060
+ const { _data } = res || {};
2061
+ const { item, campaign_code } = _data || {};
2062
+ const { icon, content } = item || {};
2063
+ LeadLog('** LeadGen SubscriptionBox campaign_code : ', campaign_code);
2064
+ LeadLog('** LeadGen SubscriptionBox subscription_icon : ', icon);
2065
+ LeadLog('** LeadGen SubscriptionBox subscription_title : ', content);
2066
+ setSubscriptionInfo({
2067
+ subscriptionIcon: icon,
2068
+ subscriptionTitle: content,
2069
+ });
2070
+ if (campaign_code) {
2071
+ fetchCampaign(campaign_code);
2072
+ }
2073
+ });
2074
+ return;
2075
+ }
2076
+ if (campaignCodeProps) {
2077
+ fetchCampaign(campaignCodeProps);
2078
+ }
2079
+ }, [campaignCodeProps, categoryId]);
2080
+ React.useEffect(() => {
2081
+ leadStore.apiSsoUrl = apiSsoUrl;
2082
+ leadStore.apiLeadUrl = apiLeadUrl;
2083
+ leadStore.apiSubotUrl = apiSubotUrl;
2084
+ }, [apiLeadUrl, apiSubotUrl, apiSsoUrl]);
2085
+ if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
2086
+ return null;
2087
+ }
2088
+ return (React__default["default"].createElement(LeadGenContext.Provider, { value: Object.assign(Object.assign(Object.assign({}, leadGenContextValue), subscriptionInfo), { submit,
2089
+ submitSubscriptionBox,
2090
+ impression }) },
2091
+ React__default["default"].createElement(LeadGenTranslationProvider, { locale: locale }, children)));
2092
+ };
2093
+ const useLeadGenContext = () => {
2094
+ const context = React.useContext(LeadGenContext);
2095
+ return Object.assign(Object.assign({}, context), { apiLeadUrl: context.apiLeadUrl || leadStore.apiLeadUrl, apiSubotUrl: context.apiSubotUrl || leadStore.apiSubotUrl });
2096
+ };
2097
+
2098
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
2099
+ const customParseFormat = require('dayjs/plugin/customParseFormat');
2100
+ dayjs__default["default"].extend(customParseFormat);
2101
+ // You can give context variables any name
2102
+ const [LeadFormProvider, useLeadFormContext, useLeadForm] = form.createFormContext();
2103
+ const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
2104
+ var _a;
2105
+ const { t } = index$1.useTranslations();
2106
+ const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
2107
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[(_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.lang] ||
2108
+ LEAD_LOCALE_DATA['vi-VN'];
2109
+ const validateObj = React.useMemo(() => {
2110
+ const InputBlocks = [
2111
+ 'TextBlock',
2112
+ 'NumberBlock',
2113
+ 'EmailBlock',
2114
+ 'PhoneBlock',
2115
+ 'DateBlock',
2116
+ 'CheckboxBlock',
2117
+ 'RadioBlock',
2118
+ 'DropdownBlock',
2119
+ 'PhoneOtpBlock',
2120
+ 'WhatsappOtpBlock',
2121
+ 'ZaloOtpBlock',
2122
+ 'LocationBlock',
2123
+ 'TncBlock',
2124
+ ];
2125
+ // ALL are required and can skip if not touched yet
2126
+ const withSharedCheck = (name, cb,
2127
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2128
+ block) => {
2129
+ return (value) => {
2130
+ var _a;
2131
+ const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
2132
+ if (!formRef.current.isTouched(name))
2133
+ return;
2134
+ if ((typeof value === 'string' && value.trim() === '') ||
2135
+ typeof value === 'undefined' ||
2136
+ (Array.isArray(value) && value.length === 0)) {
2137
+ return isBLockRequired
2138
+ ? t('validator.required')
2139
+ : cb === null || cb === void 0 ? void 0 : cb(value);
2140
+ }
2141
+ return cb === null || cb === void 0 ? void 0 : cb(value);
2142
+ };
2143
+ };
2144
+ return listBlockAdded
2145
+ .filter((b) => InputBlocks.includes(b.name))
2146
+ .reduce((r, b) => {
2147
+ const { name: fieldType, data } = b || {};
2148
+ const { value: fieldName, required } = data || {};
2149
+ const isRequired = required !== null && required !== void 0 ? required : true;
2150
+ if (fieldType === 'NumberBlock') {
2151
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2152
+ if (value && isNaN(Number(value))) {
2153
+ return t('validator.number');
2154
+ }
2155
+ }, b) });
2156
+ }
2157
+ else if (fieldType === 'EmailBlock') {
2158
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2159
+ if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
2160
+ return t('validator.email');
2161
+ }
2162
+ if (!value)
2163
+ return;
2164
+ validatingEmailRef.current = true;
2165
+ setTimeout(() => {
2166
+ formRef.current.setFieldError(fieldName, 'Validating...');
2167
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2168
+ email: value,
2169
+ })
2170
+ .then((tKey) => {
2171
+ if (tKey) {
2172
+ formRef.current.setFieldError(fieldName, t(tKey));
2173
+ }
2174
+ else {
2175
+ formRef.current.clearFieldError(fieldName);
2176
+ }
2177
+ validatingEmailRef.current = false;
2178
+ })
2179
+ .catch((e) => {
2180
+ console.error(e);
2181
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2182
+ validatingEmailRef.current = false;
2183
+ });
2184
+ }, 200);
2185
+ }, b) });
2186
+ }
2187
+ else if (fieldType === 'PhoneBlock' ||
2188
+ fieldType === 'PhoneOtpBlock' ||
2189
+ fieldType === 'ZaloOtpBlock' ||
2190
+ fieldType === 'WhatsappOtpBlock') {
2191
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2192
+ if (value &&
2193
+ window.intlTelInputUtils &&
2194
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
2195
+ return t('validator.phone');
2196
+ }
2197
+ if (!value)
2198
+ return;
2199
+ validatingPhoneRef.current = true;
2200
+ setTimeout(() => {
2201
+ formRef.current.setFieldError(fieldName, 'Validating...');
2202
+ if (b.data.singleSubmission) {
2203
+ checkUsedPhoneOnlyWithCache(campaignId, value)
2204
+ .then((tKey) => {
2205
+ if (tKey) {
2206
+ formRef.current.setFieldError(fieldName, t(tKey));
2207
+ }
2208
+ else {
2209
+ formRef.current.clearFieldError(fieldName);
2210
+ }
2211
+ validatingPhoneRef.current = false;
2212
+ })
2213
+ .catch((err) => {
2214
+ console.error(err);
2215
+ formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
2216
+ validatingPhoneRef.current = false;
2217
+ });
2218
+ }
2219
+ else {
2220
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2221
+ phone: value,
2222
+ })
2223
+ .then((tKey) => {
2224
+ if (tKey) {
2225
+ formRef.current.setFieldError(fieldName, t(tKey));
2226
+ }
2227
+ else {
2228
+ formRef.current.clearFieldError(fieldName);
2229
+ }
2230
+ validatingPhoneRef.current = false;
2231
+ })
2232
+ .catch((e) => {
2233
+ console.error(e);
2234
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2235
+ validatingPhoneRef.current = false;
2236
+ });
2237
+ }
2238
+ }, 200);
2239
+ }, b) });
2240
+ }
2241
+ else if (fieldType === 'DateBlock') {
2242
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2243
+ if (!isRequired && !value) {
2244
+ return;
2245
+ }
2246
+ const errMsg = t('validator.dateInvalid');
2247
+ const dayInJS = typeof value === 'string'
2248
+ ? dayjs__default["default"](value, format, true)
2249
+ : dayjs__default["default"](value);
2250
+ if (!dayInJS.isValid()) {
2251
+ return errMsg;
2252
+ }
2253
+ }, b) });
2254
+ }
2255
+ else if (fieldType === 'TncBlock') {
2256
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
2257
+ if (isRequired && !value) {
2258
+ return t('validator.required');
2259
+ }
2260
+ }, b) });
2261
+ }
2262
+ else {
2263
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
2264
+ }
2265
+ }, {});
2266
+ }, [listBlockAdded.map((b) => b.name).join(','), format]);
2267
+ const form = useLeadForm({
2268
+ validateInputOnChange: true,
2269
+ validateInputOnBlur: true,
2270
+ clearInputErrorOnChange: true,
2271
+ validate: validateObj,
2272
+ initialValues,
2273
+ });
2274
+ const formRef = React.useRef(form);
2275
+ formRef.current = form;
2276
+ return { form, validateObj };
2277
+ };
2278
+
2279
+ const StyledLeadGenThankYou = styled__default["default"].div `
2280
+ display: flex;
2281
+ gap: 8px;
2282
+ flex-direction: column;
2283
+ padding-block: 24px;
2284
+
2285
+ .leadgen-image {
2286
+ width: 120px;
2287
+ height: 120px;
2288
+ margin-inline: auto;
2289
+ object-fit: contain;
2290
+ object-position: center;
2291
+ text-align: center;
2292
+ }
2293
+
2294
+ .leadgen-title {
2295
+ margin-block: 0;
2296
+ color: ${miscTheme.theme.colors.gray900};
2297
+ font-weight: 700;
2298
+ font-size: 18px;
2299
+ line-height: 28px;
2300
+ letter-spacing: -0.2px;
2301
+ }
2302
+
2303
+ .leadgen-description {
2304
+ margin-block: 0;
2305
+ color: ${miscTheme.theme.colors.gray600};
2306
+ font-weight: 400;
2307
+ font-size: 14px;
2308
+ line-height: 22px;
2309
+ letter-spacing: -0.2px;
2310
+ text-align: center;
2311
+ }
2312
+
2313
+ > [data-align] {
2314
+ &[data-align='right'] {
2315
+ text-align: right;
2316
+ }
2317
+ &[data-align='center'] {
2318
+ text-align: center;
2319
+ }
2320
+ }
2321
+ `;
2322
+ const LeadGenThankYou = ({ image, title, description, showButton = false, button, className, style, }) => {
2323
+ const { src } = image;
2324
+ const { htmlText: titleText, align: titleAlign } = title;
2325
+ const { htmlText: descriptionText, align: descriptionAlign } = description;
2326
+ const { htmlText: buttonText, newtab, url, onClick } = button;
2327
+ return (React__default["default"].createElement(StyledLeadGenThankYou, { className: className, style: style },
2328
+ React__default["default"].createElement("img", { src: src, alt: "", className: "leadgen-thankyou_image leadgen-image" }),
2329
+ React__default["default"].createElement("p", { className: "leadgen-thankyou_title leadgen-title", "data-align": titleAlign }, titleText),
2330
+ React__default["default"].createElement("p", { className: "leadgen-thankyou_description leadgen-description", "data-align": descriptionAlign }, descriptionText),
2331
+ !!buttonText && showButton && (React__default["default"].createElement(core.Button, { component: url ? 'a' : 'button', target: newtab ? '_blank' : undefined, href: url, size: "lg", variant: "filled", className: "leadgen-thankyoue_btn leadgen-btn", onClick: onClick }, buttonText))));
2332
+ };
2333
+
2334
+ const StyledLeadGenSubscriptionBoxBody = styled__default["default"].div `
2335
+ margin-top: 16px;
2336
+ .leadgen-btn {
2337
+ margin-top: 16px;
2338
+ }
2339
+ `;
2340
+ const StyledLeadGenSubscriptionBoxHeaderImage = styled__default["default"].div `
2341
+ margin-top: 3px;
2342
+ margin-right: 20px;
2343
+ width: 44px;
2344
+ height: 44px;
2345
+
2346
+ img {
2347
+ width: 100%;
2348
+ height: 100%;
2349
+ object-fix: contain;
2350
+ onject-position: center;
2351
+ }
2352
+
2353
+ :has(img[src='']) {
2354
+ display: none;
2355
+ }
2356
+ `;
2357
+ const StyledLeadGenSubscriptionBoxHeader = styled__default["default"].div `
2358
+ display: flex;
2359
+ align-items: center;
2360
+ margin-bottom: 16px;
2361
+ .leadgen-title {
2362
+ margin-bottom: 0;
2363
+ flex: 1;
2364
+ min-width: 0;
2365
+ color: ${miscTheme.theme.colors.gray900};
2366
+ font-size: 18px;
2367
+ font-weight: 400;
2368
+ line-height: 1.4;
2369
+ letter-spacing: -0.8px;
2370
+ }
2371
+ `;
2372
+ const StyledLeadGenSubscriptionBox = styled__default["default"].div `
2373
+ padding: 16px;
2374
+ border: 1px solid ${miscTheme.theme.colors.neutral100};
2375
+ border-radius: 12px;
2376
+ margin-inline: auto;
2377
+ .leadgen-form_inputs {
2378
+ .leadgen-form_input {
2379
+ width: 100%;
2380
+ }
2381
+ }
2382
+
2383
+ .leadgen-form_input {
2384
+ .mantine-Input-wrapper {
2385
+ max-height: 56px;
2386
+ }
2387
+ }
2388
+
2389
+ @media screen and (min-width: 768px) {
2390
+ .leadgen-subscription_box_body {
2391
+ display: flex;
2392
+ > form {
2393
+ flex: 1;
2394
+ min-width: 0;
2395
+
2396
+ .leadgen-form_inputs {
2397
+ .leadgen-form_input {
2398
+ width: calc(50% - 4px);
2399
+ }
2400
+ }
2401
+ }
2402
+
2403
+ .leadgen-btn {
2404
+ margin-top: 0;
2405
+ margin-left: 8px;
2406
+ width: auto;
2407
+ min-height: 56px;
2408
+ }
2409
+ }
2410
+ }
2411
+ `;
2412
+ const StyledLeadGenSubscriptionBoxA = styled__default["default"].div `
2413
+ .leadgen-form_input {
2414
+ --phone-select: 45px;
2415
+ .PhoneInput {
2416
+ --phone-select: 45px;
2417
+ .PhoneInputCountry {
2418
+ margin-top: 1px;
2419
+ pointer-events: none;
2420
+ .PhoneInputCountryIconImg,
2421
+ .PhoneInputArrowContainer {
2422
+ display: none;
2423
+ }
2424
+ }
2425
+ }
2426
+ }
2427
+ `;
2428
+
2429
+ const PhoneInput = React.forwardRef((props, ref) => {
2430
+ const { defaultCountry, id: idProps, name, placeholder, label, labelElement, labelProps, description, descriptionProps, withAsterisk, inputMode, inputContainer, inputWrapperOrder, error, className, classNames, style, styles } = props, restProps = tslib_es6.__rest(props, ["defaultCountry", "id", "name", "placeholder", "label", "labelElement", "labelProps", "description", "descriptionProps", "withAsterisk", "inputMode", "inputContainer", "inputWrapperOrder", "error", "className", "classNames", "style", "styles"]);
2431
+ const id = idProps || uuid.v1() + name;
2432
+ return (React__default["default"].createElement(core.Input.Wrapper, { size: "md", label: label, labelElement: labelElement, labelProps: Object.assign({ htmlFor: id }, labelProps), description: description, descriptionProps: descriptionProps, withAsterisk: withAsterisk, inputMode: inputMode, inputContainer: inputContainer, inputWrapperOrder: inputWrapperOrder, error: error, "data-invalid": !!error, className: className, classNames: classNames, style: style, styles: styles },
2433
+ React__default["default"].createElement("div", { className: "mantine-Input-wrapper" },
2434
+ React__default["default"].createElement(index$3.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" })))));
2435
+ });
2436
+
2437
+ const formatLeadGenFormValue = (values, blocks) => {
2438
+ const newValues = {};
2439
+ for (const block of blocks) {
2440
+ const { data } = block || {};
2441
+ const { value: fieldName } = data || {};
2442
+ if (fieldName in values) {
2443
+ newValues[fieldName] = values[fieldName];
2444
+ }
2445
+ }
2446
+ return newValues;
2447
+ };
2448
+
2449
+ const StyledLeadGenFormInner = styled__default["default"].div `
2450
+ display: flex;
2451
+ flex-wrap: wrap;
2452
+ gap: 8px;
2453
+ .leadgen-form_input {
2454
+ width: calc(50% - 4px);
2455
+ }
2456
+
2457
+ .leadgen-form_input_checkbox {
2458
+ width: 100%;
2459
+ }
2460
+ `;
2461
+
2462
+ const cssInputNotShrink$1 = react.css `
2463
+ height: 100% !important;
2464
+ min-height: calc(var(--container-height, 56px) * 22 / 56);
2465
+ color: ${miscTheme.theme.colors.gray800};
2466
+ font-size: var(--input, 16px);
2467
+ line-height: calc(var(--container-height, 56px) * 22 / 56);
2468
+ border: none !important;
2469
+ border-radius: 0 !important;
2470
+ outline: none !important;
2471
+ box-shadow: none !important;
2472
+ padding: 0;
2473
+ cursor: pointer;
2474
+ opacity: 0;
2475
+
2476
+ ::placeholder {
2477
+ color: ${miscTheme.theme.colors.gray400};
2478
+ }
2479
+ `;
2480
+ const cssInputShrink$1 = react.css `
2481
+ height: auto !important;
2482
+ cursor: text;
2483
+ opacity: 1;
2484
+ transition: 0.1s ease-in-out all;
2485
+ `;
2486
+ const cssLabelNotShrink$1 = react.css `
2487
+ position: absolute;
2488
+ top: calc(var(--container-height) / 2);
2489
+ left: var(--space-x, 16px);
2490
+ color: ${miscTheme.theme.colors.gray400};
2491
+ font-size: var(--label-not-shrink, 16px);
2492
+ font-weight: 400;
2493
+ line-height: calc(var(--container-height, 56px) * 18 / 56);
2494
+ margin: 0;
2495
+ z-index: 1;
2496
+ cursor: pointer;
2497
+ transform: translateY(-50%);
2498
+ transition: 0.125s ease-in all;
2499
+ `;
2500
+ const cssLabelShrink$1 = react.css `
2501
+ color: ${miscTheme.theme.colors.gray600};
2502
+ font-weight: 600;
2503
+ font-size: var(--label-shrink, 12px);
2504
+ top: calc(var(--container-height) * 7 / 56);
2505
+ transform: none;
2506
+ transition: 0.125s ease-out all;
2507
+ `;
2508
+ const cssWrapperInputNotShrink$1 = react.css `
2509
+ min-height: var(--container-height, 56px);
2510
+ display: flex;
2511
+ align-items: flex-end;
2512
+ border: 1px solid ${miscTheme.theme.colors.gray200};
2513
+ border-radius: 8px;
2514
+ background-color: #fff;
2515
+ padding-inline: var(--space-x, 16px);
2516
+ padding-block: var(--space-y-not-shrink, 16px);
2517
+ cursor: pointer;
2518
+ pointer-events: none;
2519
+
2520
+ &:has(.mantine-Input-rightSection) {
2521
+ padding-right: var(--container-height, 56px);
2522
+ }
2523
+
2524
+ .mantine-Input-icon {
2525
+ display: none;
2526
+ }
2527
+
2528
+ .mantine-NumberInput-control {
2529
+ border-color: ${miscTheme.theme.colors.gray200};
2530
+ }
2531
+ `;
2532
+ const cssWrapperInputShrink$1 = react.css `
2533
+ height: auto;
2534
+ min-height: var(--container-height, 56px);
2535
+ padding-block: var(--space-y-shrink, 7px);
2536
+ cursor: text;
2537
+ pointer-events: auto;
2538
+ `;
2539
+ const cssInputWrapperError$1 = react.css `
2540
+ color: ${miscTheme.theme.colors.red800};
2541
+ font-size: 12px;
2542
+ line-height: 1.5;
2543
+ `;
2544
+ const StyledTextFieldContainer$1 = styled__default["default"].div `
2545
+ --space-x: 16px;
2546
+ --space-y-not-shrink: 16px;
2547
+ --space-y-shrink: 7px;
2548
+ --container-height: 56px;
2549
+ --label-not-shrink: 16px;
2550
+ --label-shrink: 12px;
2551
+ --input: 16px;
2552
+
2553
+ position: relative;
2554
+ min-width: 100px;
2555
+ max-width: 100%;
2556
+ display: inline-block;
2557
+
2558
+ .textField_wrapper {
2559
+ display: inline-block;
2560
+ width: 100%;
2561
+ cursor: pointer;
2562
+ }
2563
+
2564
+ .mantine-InputWrapper-root {
2565
+ &[data-invalid='true'] {
2566
+ .mantine-Input-wrapper {
2567
+ border-color: ${miscTheme.theme.colors.red400};
2568
+ }
2569
+ }
2570
+
2571
+ .mantine-Input-wrapper {
2572
+ &:has([data-invalid]) {
2573
+ border-color: ${miscTheme.theme.colors.red400};
2574
+ }
2575
+ }
2576
+
2577
+ .mantine-InputWrapper-error {
2578
+ font-size: 12px !important;
2579
+ }
2580
+ }
2581
+
2582
+ .mantine-InputWrapper-label {
2583
+ ${cssLabelNotShrink$1}
2584
+ }
2585
+
2586
+ .mantine-Input-wrapper {
2587
+ ${cssWrapperInputNotShrink$1}
2588
+
2589
+ + .mantine-Popover-dropdown[data-position="bottom-start"] {
2590
+ left: 0 !important;
2591
+ }
2592
+ + .mantine-Popover-dropdown[data-position='top-start'] {
2593
+ top: unset !important;
2594
+ left: 0 !important;
2595
+ bottom: 100% !important;
2596
+ }
2597
+ }
2598
+
2599
+ .mantine-Input-input {
2600
+ ${cssInputNotShrink$1}
2601
+ }
2602
+
2603
+ &.textField_shrink,
2604
+ &:focus-within {
2605
+ .mantine-InputWrapper-label {
2606
+ ${cssLabelShrink$1}
2607
+ }
2608
+
2609
+ .mantine-Input-wrapper {
2610
+ ${cssWrapperInputShrink$1}
2611
+ &.mantine-Select-wrapper {
2612
+ .mantine-Select-rightSection {
2613
+ pointer-events: auto !important;
2614
+ }
2615
+ }
2616
+ }
2617
+
2618
+ .mantine-Input-input {
2619
+ ${cssInputShrink$1}
2620
+ }
2621
+
2622
+ &:has(.PhoneInput) {
2623
+ .mantine-InputWrapper-label {
2624
+ left: var(--space-x, 16px);
2625
+ }
2626
+ .PhoneInput {
2627
+ .PhoneInputInput {
2628
+ opacity: 1;
2629
+ }
2630
+ }
2631
+ }
2632
+ }
2633
+
2634
+ .PhoneInput {
2635
+ --phone-select: 75px;
2636
+ --phone-input-space-x: 8px;
2637
+ width: 100%;
2638
+ opacity: 1;
2639
+ border: none;
2640
+ .PhoneInputCountry {
2641
+ background-color: transparent;
2642
+ border: none;
2643
+ padding: 0;
2644
+ width: var(--phone-select, 75px);
2645
+ }
2646
+ .PhoneInputInput {
2647
+ flex: 1;
2648
+ min-width: 0;
2649
+ line-height: 1.5;
2650
+ outline: none !important;
2651
+ border: none;
2652
+ box-shadow: none;
2653
+ padding: 0 var(--phone-input-space-x, 8px);
2654
+ opacity: 0;
2655
+ color: ${miscTheme.theme.colors.gray800} !important;
2656
+ :focus {
2657
+ color: ${miscTheme.theme.colors.gray800} !important;
2658
+ }
2659
+ }
2660
+ }
2661
+
2662
+ &:has(.PhoneInput) {
2663
+ .mantine-InputWrapper-label {
2664
+ left: calc(
2665
+ var(--space-x, 16px) + var(--phone-select, 75px) +
2666
+ var(--phone-input-space-x, 8px)
2667
+ );
2668
+ }
2669
+ }
2670
+ `;
2671
+ const StyledChoiceFieldContainer$1 = styled__default["default"].div `
2672
+ &.leadgen-form_checkbox,
2673
+ &.leadgen-form_radio {
2674
+ width: 100%;
2675
+ }
2676
+
2677
+ &.leadgen-form_dropdown {
2678
+ width: calc(50% - 12px);
2679
+ }
2680
+
2681
+ .mantine-InputWrapper-root {
2682
+ display: block;
2683
+ .mantine-InputWrapper-error {
2684
+ font-size: 12px !important;
2685
+ }
2686
+ }
2687
+
2688
+ .mantine-InputWrapper-label {
2689
+ margin-bottom: 0.5rem;
2690
+ color: ${miscTheme.theme.colors.gray800};
2691
+ font-size: 16px;
2692
+ font-weight: 400;
2693
+ line-height: 1.5;
2694
+ }
2695
+
2696
+ .mantine-Radio-root,
2697
+ .mantine-Checkbox-root {
2698
+ gap: 8px;
2699
+ min-width: calc(50% - 4px);
2700
+
2701
+ input[type='radio'],
2702
+ input[type='checkbox'] {
2703
+ border-color: ${miscTheme.theme.colors.gray600};
2704
+ width: 18px;
2705
+ height: 18px;
2706
+ }
2707
+ input[type='checkbox'] {
2708
+ border-radius: 4px;
2709
+ }
2710
+
2711
+ &[data-checked='true'] {
2712
+ input[type='radio'],
2713
+ input[type='checkbox'] {
2714
+ border-color: ${miscTheme.theme.colors.primary600};
2715
+ + svg {
2716
+ color: ${miscTheme.theme.colors.primary600};
2717
+ }
2718
+ }
2719
+
2720
+ input[type='radio'] {
2721
+ background-color: white;
2722
+ }
2723
+ }
2724
+
2725
+ .mantine-Checkbox-input {
2726
+ &:checked {
2727
+ border-color: ${miscTheme.theme.colors.primary600};
2728
+ }
2729
+ }
2730
+ }
2731
+
2732
+ .mantine-Radio-inner,
2733
+ .mantine-Checkbox-inner {
2734
+ width: 24px;
2735
+ height: 24px;
2736
+ display: flex;
2737
+ align-items: center;
2738
+ justify-content: center;
2739
+ }
2740
+
2741
+ .mantine-Radio-body,
2742
+ .mantine-Checkbox-body {
2743
+ display: flex;
2744
+ align-items: center;
2745
+ }
2746
+
2747
+ .mantine-Radio-label,
2748
+ .mantine-Checkbox-label {
2749
+ padding-left: 8px;
2750
+ color: ${miscTheme.theme.colors.gray800};
2751
+ font-size: 14px;
2752
+ line-height: 1.4;
2753
+ letter-spacing: -0.2px;
2754
+ }
2755
+
2756
+ .leadgen-choiceContainer {
2757
+ display: flex;
2758
+ flex-wrap: wrap;
2759
+ align-items: flex-start;
2760
+ gap: 8px;
2761
+ }
2762
+
2763
+ .mantine-InputWrapper-error {
2764
+ ${cssInputWrapperError$1}
2765
+ }
2766
+ `;
2767
+
2768
+ const TextField$1 = (props) => {
2769
+ const { shrink: shrinkProps, onChangeShrink, className, children } = props, restProps = tslib_es6.__rest(props, ["shrink", "onChangeShrink", "className", "children"]);
2770
+ const containerRef = hooks.useClickOutside(() => {
2771
+ if (shrinkProps) {
2772
+ return;
2773
+ }
2774
+ setShrink(false);
2775
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(false);
2776
+ });
2777
+ const [shrink, setShrink] = React.useState(shrinkProps);
2778
+ const onClick = React.useCallback((e) => {
2779
+ setShrink(true);
2780
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(true);
2781
+ if (shrink) {
2782
+ return;
2783
+ }
2784
+ const $textEl = e.currentTarget.querySelectorAll('input:not([disabled]):not([type="submit"]),select:not([disabled]),textarea:not([disabled])');
2785
+ const $focusEl = $textEl.item($textEl.length - 1);
2786
+ if ($focusEl) {
2787
+ $focusEl.focus();
2788
+ setTimeout(() => {
2789
+ $focusEl.scrollIntoView({
2790
+ behavior: 'auto',
2791
+ block: 'center',
2792
+ inline: 'start',
2793
+ });
2794
+ }, 100);
2795
+ }
2796
+ }, [shrink]);
2797
+ React.useEffect(() => {
2798
+ setShrink(shrinkProps);
2799
+ }, [shrinkProps]);
2800
+ return (React__default["default"].createElement(StyledTextFieldContainer$1, Object.assign({ shrink: shrink, className: core.clsx(className, 'textField', { textField_shrink: !!shrink }) }, restProps),
2801
+ React__default["default"].createElement("div", { ref: containerRef, onClick: onClick, className: "textField_wrapper" }, children)));
2802
+ };
2803
+ const ChoiceField$1 = (props) => {
2804
+ const { children, className } = props, restProps = tslib_es6.__rest(props, ["children", "className"]);
2805
+ return (React__default["default"].createElement(StyledChoiceFieldContainer$1, Object.assign({ className: core.clsx(className, 'choiceField') }, restProps), children));
2806
+ };
2807
+
2808
+ const libraries = ['places'];
2809
+ const GoogleLocationBlock = (props) => {
2810
+ var _a;
2811
+ const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = tslib_es6.__rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
2812
+ const [LoadScript, setLoadScript] = React.useState(null);
2813
+ const [value, setValue] = React.useState(defaultValue || valueProps);
2814
+ const { predictions } = usePlacesAutocomplete.usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
2815
+ const onChangeAutocomplete = React.useCallback((s) => {
2816
+ setValue(s);
2817
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
2818
+ }, []);
2819
+ const onClickItem = React.useCallback((item) => {
2820
+ /** For sure get value */
2821
+ setValue(item.value);
2822
+ const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
2823
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
2824
+ }, [onChangeProps, predictions]);
2825
+ React.useEffect(() => {
2826
+ setValue(valueProps);
2827
+ }, [valueProps]);
2828
+ React.useEffect(() => {
2829
+ var _a, _b, _c;
2830
+ // only load extra google script when not yet loaded
2831
+ 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) {
2832
+ Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@react-google-maps/api')); }).then((m) => {
2833
+ setLoadScript(() => m.LoadScript);
2834
+ });
2835
+ }
2836
+ }, []);
2837
+ return (React__default["default"].createElement(core.Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
2838
+ return { value: pred.description, label: pred.description };
2839
+ }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: index$7.ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
2840
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
2841
+ LoadScript && (React__default["default"].createElement(LoadScript, { googleMapsApiKey: usePlacesAutocomplete.GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default["default"].createElement(React__default["default"].Fragment, null), style: { width: '100%' } })),
2842
+ children));
2843
+ } }, restProps)));
2844
+ };
2845
+
2846
+ const LeadGenForm = React.forwardRef((props, ref) => {
2847
+ const { locale, blocks, scrollToErrorField = true, form: formProps, rules: validate, initialValues, onFinish, onFinishFailed, className, style, } = props;
2848
+ const formRef = React.useRef(null);
2849
+ const form$1 = formProps || form.useForm({ initialValues, validate });
2850
+ const middlewareFinish = React.useCallback((values, event) => {
2851
+ /** Set `touched` all values for validation when submiting */
2852
+ form$1.setTouched(blocks.reduce((touched, { data }) => {
2853
+ touched[data.value] = true;
2854
+ return touched;
2855
+ }, {}));
2856
+ /** Wait for `touched` state and then submit */
2857
+ setTimeout(() => {
2858
+ const { hasErrors } = form$1.validate();
2859
+ if (hasErrors) {
2860
+ return;
2861
+ }
2862
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatLeadGenFormValue(values, blocks), event);
2863
+ }, 100);
2864
+ }, [form$1, blocks]);
2865
+ const middlewareFinishFailed = React.useCallback((errors, values, events) => {
2866
+ if (scrollToErrorField && errors) {
2867
+ const firstErrorKey = Object.keys(errors)[0];
2868
+ const firstErrorElement = document.querySelector(`[name="${firstErrorKey}"]`);
2869
+ if (firstErrorElement && (firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus)) {
2870
+ setTimeout(() => {
2871
+ firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
2872
+ firstErrorElement.scrollIntoView({
2873
+ behavior: 'auto',
2874
+ block: 'center',
2875
+ inline: 'center',
2876
+ });
2877
+ }, 100);
2878
+ }
2879
+ }
2880
+ onFinishFailed === null || onFinishFailed === void 0 ? void 0 : onFinishFailed(errors, values, events);
2881
+ }, [scrollToErrorField]);
2882
+ React.useEffect(() => {
2883
+ (() => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
2884
+ if (!window.intlTelInputUtils) {
2885
+ yield require('intl-tel-input/build/js/utils');
2886
+ }
2887
+ }))();
2888
+ }, []);
2889
+ React.useImperativeHandle(ref, () => (Object.assign(Object.assign({}, form$1), { submit: () => {
2890
+ formRef.current.requestSubmit();
2891
+ } })), [form$1, formRef]);
2892
+ if (!blocks || !blocks.length) {
2893
+ return null;
2894
+ }
2895
+ return (React__default["default"].createElement("form", { ref: formRef, onSubmit: form$1.onSubmit(middlewareFinish, middlewareFinishFailed), className: className, style: style },
2896
+ React__default["default"].createElement(StyledLeadGenFormInner, { className: "leadgen-form_inputs" }, blocks.map((block, idx) => {
2897
+ const { id, name: blockName, data } = block;
2898
+ const { placeholder, value: name, required, listQuestion, valueHTML, isSendMailChimp = false, } = data;
2899
+ const formInputProps = form$1.getInputProps(name);
2900
+ const { value, error } = formInputProps;
2901
+ const reactKey = `${id}-${idx}`;
2902
+ switch (blockName) {
2903
+ case LEADGEN_BLOCK.TextBlock: {
2904
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2905
+ React__default["default"].createElement(core.TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "text", "data-control": "text" }, formInputProps))));
2906
+ }
2907
+ case LEADGEN_BLOCK.NumberBlock: {
2908
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2909
+ React__default["default"].createElement(core.NumberInput, Object.assign({ name: value, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "number", "data-control": "number" }, formInputProps))));
2910
+ }
2911
+ case LEADGEN_BLOCK.EmailBlock: {
2912
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2913
+ React__default["default"].createElement(core.TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, "data-control": "email" }, formInputProps))));
2914
+ }
2915
+ case LEADGEN_BLOCK.PhoneOtpBlock:
2916
+ case LEADGEN_BLOCK.WhatsappOtpBlock:
2917
+ case LEADGEN_BLOCK.ZaloOtpBlock:
2918
+ case LEADGEN_BLOCK.PhoneBlock: {
2919
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2920
+ React__default["default"].createElement(PhoneInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, defaultCountry: (locale ? utils.MAPPED_LOCALE[locale] || 'VN' : 'VN'), type: "text", "data-control": "text" }, formInputProps))));
2921
+ }
2922
+ case LEADGEN_BLOCK.LocationBlock: {
2923
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2924
+ React__default["default"].createElement(GoogleLocationBlock, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, locale: locale, "data-control": "text" }, formInputProps))));
2925
+ }
2926
+ case LEADGEN_BLOCK.DateBlock: {
2927
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2928
+ React__default["default"].createElement(dates.DateInput, Object.assign({ locale: (utils.MAPPED_LOCALE === null || utils.MAPPED_LOCALE === void 0 ? void 0 : utils.MAPPED_LOCALE[locale]) || utils.MAPPED_LOCALE['vi-VN'], valueFormat: "DD/MM/YYYY", name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "default", "data-control": "date" }, formInputProps))));
2929
+ }
2930
+ case LEADGEN_BLOCK.DropdownBlock:
2931
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2932
+ React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2933
+ React__default["default"].createElement(core.Select, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, data: listQuestion.map((l) => ({
2934
+ value: l.value,
2935
+ label: l.placeholder,
2936
+ })) }, formInputProps))));
2937
+ case LEADGEN_BLOCK.CheckboxBlock: {
2938
+ const formInputCheckboxProps = form$1.getInputProps(name, {
2939
+ type: 'checkbox',
2940
+ });
2941
+ return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2942
+ isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2943
+ React__default["default"].createElement(core.Checkbox.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, sx: {
2944
+ display: 'flex',
2945
+ flexDirection: 'column',
2946
+ flexWrap: 'wrap',
2947
+ gap: 8,
2948
+ }, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2949
+ return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2950
+ } }, formInputCheckboxProps), listQuestion.map((l, _idx) => (React__default["default"].createElement(core.Checkbox, { name: name, key: _idx, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2951
+ }
2952
+ case LEADGEN_BLOCK.RadioBlock: {
2953
+ return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2954
+ isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2955
+ React__default["default"].createElement(core.Radio.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, spellCheck: true, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2956
+ return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2957
+ } }, formInputProps), listQuestion.map((l, _index) => (React__default["default"].createElement(core.Radio, { name: name, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2958
+ }
2959
+ case LEADGEN_BLOCK.TncBlock:
2960
+ return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2961
+ React__default["default"].createElement(core.Input.Wrapper, { error: error },
2962
+ React__default["default"].createElement(core.Checkbox, Object.assign({ value: value, name: 'TNC-' + id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, formInputProps)))));
2963
+ default: {
2964
+ return null;
2965
+ }
2966
+ }
2967
+ }))));
2968
+ });
2969
+
2970
+ const LEADGEN_ORDER_INPUT_WRAPPER = ['label', 'input', 'description', 'error'];
2971
+
2972
+ const LeadGenSubscriptionBoxA = (props) => {
2973
+ const { loading, image, title, submitText, locale, blocks, form, rules, onFinish, } = props;
2974
+ const formRef = React.useRef();
2975
+ const imageComp = React.useMemo(() => {
2976
+ if (!image) {
2977
+ return null;
2978
+ }
2979
+ return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeaderImage, null,
2980
+ React__default["default"].createElement("img", { src: image, alt: "" })));
2981
+ }, [image]);
2982
+ const titleComp = React.useMemo(() => {
2983
+ if (typeof title === 'string') {
2984
+ return (React__default["default"].createElement("p", { className: "leadgen-title", dangerouslySetInnerHTML: { __html: title } }));
2985
+ }
2986
+ return React__default["default"].createElement("p", { className: "leadgen-title" }, title);
2987
+ }, [title]);
2988
+ return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxA, { className: "subcription_box_A" },
2989
+ React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeader, { className: "leadgen-subscription_box_header" },
2990
+ imageComp,
2991
+ titleComp),
2992
+ React__default["default"].createElement(StyledLeadGenSubscriptionBoxBody, { className: "leadgen-subscription_box_body" },
2993
+ React__default["default"].createElement(LeadGenForm, { ref: formRef, form: form, rules: rules, blocks: blocks, locale: locale, onFinish: onFinish, className: "leadgen-subscription_box_form" }),
2994
+ React__default["default"].createElement(core.Button, { disabled: loading, loading: loading, variant: "filled", size: "lg", onClick: () => {
2995
+ formRef.current.submit();
2996
+ }, className: "leadgen-btn leadgen-btn_action", fullWidth: true }, submitText))));
2997
+ };
2998
+
2999
+ const LeadGenSubscriptionBoxWithoutMemo = ({ locale, userInfo, forceCampaign, categoryId, }) => {
3000
+ var _a, _b, _c;
3001
+ const { image, extra_fields, id: campaign_id, bot_id: campaign_subot_id = [], ThankYouBlock, } = forceCampaign || {};
3002
+ const { textBlocks, listBlockAdded, actionBlocks } = extra_fields || {};
3003
+ const { submitBlock } = actionBlocks || {};
3004
+ const { apiLeadUrl, subscriptionIcon, subscriptionTitle, submitSubscriptionBox, impression, onFinish, } = useLeadGenContext();
3005
+ const { t } = index$1.useTranslations();
3006
+ const { action: { pushNotifications }, } = React.useContext(togetherComponentGlobalContext.TogetherComponentGlobalContext);
3007
+ const refContainer = React.useRef(null);
3008
+ const [loading, setLoading] = React.useState(false);
3009
+ const [showThankyou, setShowThankyou] = React.useState(false);
3010
+ const validatingEmailRef = React.useRef(false);
3011
+ const validatingPhoneRef = React.useRef(false);
3012
+ const { form, validateObj } = useLeadFormConfig({
3013
+ listBlockAdded,
3014
+ campaignId: campaign_id,
3015
+ campaign_subot_id,
3016
+ validatingEmailRef,
3017
+ validatingPhoneRef,
3018
+ userInfo,
3019
+ });
3020
+ const subscription_title = React.useMemo(() => {
3021
+ var _a, _b;
3022
+ return subscriptionTitle ||
3023
+ ((_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) ||
3024
+ t('leadgen.message.title.default');
3025
+ }, [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]);
3026
+ const { image: thankyouImage, title: thankyouTitle, description: thankyouDescription, button: thankyouButton, } = ThankYouBlock || {};
3027
+ const intersectionObserverCallback = React.useCallback((entries) => {
3028
+ entries.forEach((entry) => {
3029
+ const { isIntersecting, target } = entry;
3030
+ if (!showThankyou &&
3031
+ isIntersecting &&
3032
+ target === refContainer.current) {
3033
+ impression();
3034
+ }
3035
+ });
3036
+ }, [impression, showThankyou]);
3037
+ const IObserver = new IntersectionObserver(intersectionObserverCallback);
3038
+ const middlewareOnSubmit = React.useCallback((values) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
3039
+ const newValues = {
3040
+ subscription_title,
3041
+ };
3042
+ const ssoValues = {
3043
+ sso_user_id: undefined,
3044
+ sso_uuid: undefined,
3045
+ sso_verified_profile: undefined,
3046
+ };
3047
+ const valueKeys = Object.keys(values);
3048
+ for (const key of valueKeys) {
3049
+ const isPhoneField = leadGenFieldNamePhone(listBlockAdded).some((k) => k === key);
3050
+ if (isPhoneField) {
3051
+ const phone = PhoneInputBase.parsePhoneNumber(values[key]);
3052
+ if (phone.isValid()) {
3053
+ /** Seperate `area_code` and `phone_number` for BE */
3054
+ newValues['area_code'] = `+${phone.countryCallingCode}`;
3055
+ newValues['phone_number'] = phone.nationalNumber;
3056
+ /** Only case login has this update */
3057
+ if ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) && (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid)) {
3058
+ ssoValues['sso_verified_profile'] =
3059
+ phone.number === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone) ? 1 : 0;
3060
+ ssoValues['sso_user_id'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.id;
3061
+ ssoValues['sso_uuid'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid;
3062
+ }
3063
+ }
3064
+ continue;
3065
+ }
3066
+ newValues[key] = values[key];
3067
+ }
3068
+ setLoading(true);
3069
+ try {
3070
+ const reqValues = Object.assign(Object.assign({}, newValues), ssoValues);
3071
+ const { _data } = (yield submitSubscriptionBox(reqValues)) || {};
3072
+ const { model } = _data || {};
3073
+ if (model && (model === null || model === void 0 ? void 0 : model.id)) {
3074
+ setShowThankyou(true);
3075
+ const metaValues = {
3076
+ blocks: listBlockAdded || [],
3077
+ isUpdateSso: false,
3078
+ };
3079
+ /**
3080
+ * https://hhgdev.atlassian.net/browse/EL-468
3081
+ * This feature is just using in Subscription Box
3082
+ */
3083
+ if (newValues === null || newValues === void 0 ? void 0 : newValues.name) {
3084
+ const { _data: ssoData, code: ssoErrorCode } = yield Service.postUserInfoFromLeadGen({ name: newValues === null || newValues === void 0 ? void 0 : newValues.name });
3085
+ if (ssoErrorCode && !ssoData) {
3086
+ return;
3087
+ }
3088
+ metaValues.isUpdateSso = true;
3089
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(reqValues, metaValues);
3090
+ return;
3091
+ }
3092
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(reqValues, metaValues);
3093
+ }
3094
+ }
3095
+ catch (error) {
3096
+ LeadLog('** LeadGen SubscriptionBox error : ', error);
3097
+ pushNotifications({
3098
+ message: t('leadgen.message.error.default'),
3099
+ type: 'danger',
3100
+ });
3101
+ }
3102
+ setLoading(false);
3103
+ }), [
3104
+ subscription_title,
3105
+ listBlockAdded,
3106
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
3107
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid,
3108
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone,
3109
+ ]);
3110
+ React.useEffect(() => {
3111
+ if (refContainer.current) {
3112
+ IObserver.observe(refContainer.current);
3113
+ }
3114
+ return () => {
3115
+ IObserver.disconnect();
3116
+ };
3117
+ }, [categoryId]);
3118
+ return (React__default["default"].createElement("div", { ref: refContainer },
3119
+ React__default["default"].createElement(StyledLeadGenSubscriptionBox, null,
3120
+ showThankyou && (React__default["default"].createElement(LeadGenThankYou, { image: Object.assign(Object.assign({}, thankyouImage), { src: thankyouImage.src || `${apiLeadUrl}admin/img/thanksyou.png` }), title: thankyouTitle, description: thankyouDescription, button: thankyouButton })),
3121
+ !showThankyou && (React__default["default"].createElement(LeadGenSubscriptionBoxA, { loading: loading, image: subscriptionIcon || image, title: subscription_title, submitText: (_c = submitBlock === null || submitBlock === void 0 ? void 0 : submitBlock.data) === null || _c === void 0 ? void 0 : _c.value, blocks: listBlockAdded, locale: locale, form: form, rules: validateObj, onFinish: middlewareOnSubmit })))));
3122
+ };
3123
+ const LeadGenSubscriptionBox$1 = React.memo(LeadGenSubscriptionBoxWithoutMemo);
3124
+
3125
+ const Container = () => {
3126
+ const context = React.useContext(LeadGenContext);
3127
+ const { campaign_code, locale, siteId, siteDomain, userInfo, forceCampaign } = context;
3128
+ if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
3129
+ return null;
3130
+ }
3131
+ return (React__default["default"].createElement(LeadGenSubscriptionBox$1, { locale: locale, siteId: siteId, siteDomain: siteDomain, userInfo: userInfo, forceCampaign: forceCampaign, campaign_code: campaign_code }));
3132
+ };
3133
+ Container.displayName = 'LeadGenSubscriptionBox';
3134
+ const LeadGenSubscriptionBoxContainer = (props) => {
3135
+ const { apiUrl, apiSubotUrl } = props;
3136
+ return (React__default["default"].createElement(LeadGenContextProvider, Object.assign({}, props, { apiLeadUrl: apiUrl, apiSubotUrl: apiSubotUrl }),
3137
+ React__default["default"].createElement(Container, null)));
3138
+ };
3139
+ const LeadGenSubscriptionBox = LeadGenSubscriptionBoxContainer;
3140
+
3141
+ const useImageSize = (src) => {
3142
+ const [width, setWidth] = React.useState(16);
3143
+ const [height, setHeight] = React.useState(9);
3144
+ const [loaded, setLoaded] = React.useState(false);
3145
+ // load src image to get its width and height
3146
+ React.useEffect(() => {
3147
+ setLoaded(false);
3148
+ if (src) {
3149
+ const img = new Image();
3150
+ img.addEventListener('load', () => {
3151
+ setWidth(img.naturalWidth);
3152
+ setHeight(img.naturalHeight);
3153
+ setLoaded(true);
3154
+ });
3155
+ img.addEventListener('error', () => {
3156
+ setWidth(16);
3157
+ setHeight(9);
3158
+ setLoaded(true);
3159
+ });
3160
+ img.src = src;
3161
+ }
3162
+ else {
3163
+ setWidth(16);
3164
+ setHeight(9);
3165
+ setLoaded(true);
3166
+ }
3167
+ }, [src]);
3168
+ return {
3169
+ loaded,
3170
+ width,
3171
+ height,
3172
+ };
3173
+ };
3174
+
3175
+ const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default["default"].createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
3176
+ React__default["default"].createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
3177
+ React__default["default"].createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
3178
+
3179
+ // url: imageBlocks.imageMobile.data.url
3180
+ // newTab: imageBlocks.imageMobile.data.newtab
3181
+ // imageMobile: campaignShow.image
3182
+ // imageDestkop: campaignShow.image_desktop
3183
+ const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
3184
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3185
+ const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
3186
+ if (!imageMobileLoaded || !imageDestkopLoaded)
3187
+ return null;
3188
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
3189
+ React__default["default"].createElement("div", { className: "le-center-tab-popup" },
3190
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
3191
+ React__default["default"].createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
3192
+ index$8.isVideo(imageMobile) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
3193
+ React__default["default"].createElement("source", { src: imageMobile }))) : (React__default["default"].createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
3194
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3195
+ } })),
3196
+ index$8.isVideo(imageDestkop) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
3197
+ React__default["default"].createElement("source", { src: imageDestkop }))) : (React__default["default"].createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
3198
+ aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
3199
+ } }))),
3200
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3201
+ };
3202
+
3203
+ // title: titleText
3204
+ // titleAlign: textBlocks.titleBlock.data.align
3205
+ // subtitle: textBlocks.subtitleBlock.data.value
3206
+ // subtitleAlign: textBlocks.subtitleBlock.data.align
3207
+ // url: actionBlocks.linkButtonBlock.data.url
3208
+ // urlText: actionBlocks.linkButtonBlock.data.value
3209
+ // newTab: actionBlocks.linkButtonBlock.data.newtab
3210
+ // imageMobile: campaignShow.image
3211
+ // imageDesktop: campaignShow.image_desktop
3212
+ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
3213
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3214
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
3215
+ if (!imageMobileLoaded || !imageDesktopLoaded)
3216
+ return null;
3217
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
3218
+ React__default["default"].createElement("aside", { className: "le-only-desktop" },
3219
+ React__default["default"].createElement("div", { className: "le-floating-desktop" },
3220
+ React__default["default"].createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
3221
+ imageDesktop ? (React__default["default"].createElement("div", null,
3222
+ React__default["default"].createElement("img", { style: {
3223
+ maxWidth: 120,
3224
+ borderTopLeftRadius: 5,
3225
+ borderBottomLeftRadius: 5,
3226
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
3227
+ }, src: imageDesktop }))) : null,
3228
+ React__default["default"].createElement("div", { style: { padding: 20 } },
3229
+ React__default["default"].createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
3230
+ React__default["default"].createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
3231
+ React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
3232
+ React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
3233
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
3234
+ React__default["default"].createElement("aside", { className: "le-only-mobile" },
3235
+ React__default["default"].createElement("div", { className: "le-floating-mobile" },
3236
+ React__default["default"].createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
3237
+ React__default["default"].createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
3238
+ React__default["default"].createElement("div", null,
3239
+ React__default["default"].createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
3240
+ React__default["default"].createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
3241
+ imageMobile ? (React__default["default"].createElement("div", null,
3242
+ React__default["default"].createElement("img", { style: {
3243
+ marginLeft: 15,
3244
+ marginTop: 4,
3245
+ maxWidth: 100,
3246
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3247
+ }, src: imageMobile }))) : null),
3248
+ React__default["default"].createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
3249
+ React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
3250
+ React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
3251
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
3252
+ };
3253
+
3254
+ const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
3255
+ const { primaryColor } = React.useContext(LeadGenContext$1);
3256
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
3257
+ if (!imageLoaded)
3258
+ return null;
3259
+ return (React__default["default"].createElement("div", { className: "lead-modal__thank-you leadgen-inner_thankyou" },
3260
+ React__default["default"].createElement("div", { style: { width: '100%' } },
3261
+ React__default["default"].createElement("img", { src: image, style: {
3262
+ maxHeight: 162,
3263
+ objectFit: 'cover',
3264
+ aspectRatio: `${imageWidth}/${imageHeight}`,
3265
+ }, loading: "lazy" }),
3266
+ title && (React__default["default"].createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
3267
+ subtitle && (React__default["default"].createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle.split('\n').map((text, idx, list) => {
3268
+ const isShowBr = idx < list.length - 1;
3269
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
3270
+ text,
3271
+ isShowBr && React__default["default"].createElement("br", null)));
3272
+ }))),
3273
+ linkText && (React__default["default"].createElement("div", null,
3274
+ React__default["default"].createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
3275
+ React__default["default"].createElement(index$4.Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
1541
3276
  };
1542
3277
 
1543
3278
  const InlineLayout = ({ content, inlinePosition, }) => {
@@ -1650,257 +3385,41 @@ const InlineLayout = ({ content, inlinePosition, }) => {
1650
3385
  return ReactDOM.createPortal(content, target);
1651
3386
  };
1652
3387
 
1653
- const SideBarLayout = ({ content }) => {
1654
- const targets = React.useMemo(() => {
1655
- const targetDoms = Array.from(document.querySelectorAll('.hc2-sidebar-with-ads,.page-main-col .right-col.f-right,.hhg-lead-sidebar'));
1656
- targetDoms.forEach((dom) => {
1657
- if (dom.querySelector('.sidebar-lead-modal-wrapper'))
1658
- return;
1659
- const wrapper = document.createElement('div');
1660
- wrapper.classList.add('sidebar-lead-modal-wrapper');
1661
- dom.prepend(wrapper);
1662
- });
1663
- return targetDoms.map((d) => d.querySelector('.sidebar-lead-modal-wrapper'));
1664
- }, []);
1665
- return (React__default["default"].createElement(React__default["default"].Fragment, null, targets.map((target) => ReactDOM.createPortal(content, utils$1.getWrapperDomWithSelector(target, 'sidebar-lead-modal-wrapper')))));
1666
- };
1667
-
1668
- const EmptyIcon = (props) => {
1669
- const { className, style } = props;
1670
- return (React__default["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 },
1671
- React__default["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" }),
1672
- React__default["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" }),
1673
- React__default["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" })));
1674
- };
1675
-
1676
- const EmptyComponent = ({ onClose, onContinue, }) => {
1677
- const { t } = index.useTranslations();
1678
- return (React__default["default"].createElement("div", { className: "leadgen-empty" },
1679
- React__default["default"].createElement("div", { className: "leadgen-empty_body" },
1680
- React__default["default"].createElement("div", { className: "leadgen-empty_wrapper" },
1681
- React__default["default"].createElement(EmptyIcon, { className: "leadgen-empty_image" }),
1682
- React__default["default"].createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
1683
- React__default["default"].createElement("div", { className: "leadgen-empty_footer" },
1684
- React__default["default"].createElement(core.Button, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
1685
- React__default["default"].createElement(core.Button, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
1686
- };
1687
-
1688
- const libraries = ['places'];
1689
- const GoogleLocationBlock = (props) => {
1690
- var _a;
1691
- const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = tslib_es6.__rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
1692
- const [LoadScript, setLoadScript] = React.useState(null);
1693
- const [value, setValue] = React.useState(defaultValue || valueProps);
1694
- const { predictions } = usePlacesAutocomplete.usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
1695
- const onChangeAutocomplete = React.useCallback((s) => {
1696
- setValue(s);
1697
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
1698
- }, []);
1699
- const onClickItem = React.useCallback((item) => {
1700
- /** For sure get value */
1701
- setValue(item.value);
1702
- const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
1703
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
1704
- }, [onChangeProps, predictions]);
1705
- React.useEffect(() => {
1706
- setValue(valueProps);
1707
- }, [valueProps]);
1708
- React.useEffect(() => {
1709
- var _a, _b, _c;
1710
- // only load extra google script when not yet loaded
1711
- 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) {
1712
- Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@react-google-maps/api')); }).then((m) => {
1713
- setLoadScript(() => m.LoadScript);
1714
- });
1715
- }
1716
- }, []);
1717
- return (React__default["default"].createElement(core.Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
1718
- return { value: pred.description, label: pred.description };
1719
- }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: index$7.ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
1720
- return (React__default["default"].createElement(React__default["default"].Fragment, null,
1721
- LoadScript && (React__default["default"].createElement(LoadScript, { googleMapsApiKey: usePlacesAutocomplete.GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default["default"].createElement(React__default["default"].Fragment, null), style: { width: '100%' } })),
1722
- children));
1723
- } }, restProps)));
1724
- };
1725
-
1726
- // eslint-disable-next-line @typescript-eslint/no-var-requires
1727
- const customParseFormat = require('dayjs/plugin/customParseFormat');
1728
- dayjs__default["default"].extend(customParseFormat);
1729
- // You can give context variables any name
1730
- const [LeadFormProvider, useLeadFormContext, useLeadForm] = form.createFormContext();
1731
- const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
1732
- const { t } = index.useTranslations();
1733
- const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
1734
- const validateObj = React.useMemo(() => {
1735
- const InputBlocks = [
1736
- 'TextBlock',
1737
- 'NumberBlock',
1738
- 'EmailBlock',
1739
- 'PhoneBlock',
1740
- 'DateBlock',
1741
- 'CheckboxBlock',
1742
- 'RadioBlock',
1743
- 'DropdownBlock',
1744
- 'PhoneOtpBlock',
1745
- 'WhatsappOtpBlock',
1746
- 'ZaloOtpBlock',
1747
- 'LocationBlock',
1748
- 'TncBlock',
1749
- ];
1750
- // ALL are required and can skip if not touched yet
1751
- const withSharedCheck = (name, cb,
1752
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1753
- block) => {
1754
- return (value) => {
1755
- var _a;
1756
- const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
1757
- if (!formRef.current.isTouched(name))
1758
- return;
1759
- if ((typeof value === 'string' && value.trim() === '') ||
1760
- typeof value === 'undefined' ||
1761
- (Array.isArray(value) && value.length === 0)) {
1762
- return isBLockRequired
1763
- ? t('validator.required')
1764
- : cb === null || cb === void 0 ? void 0 : cb(value);
1765
- }
1766
- return cb === null || cb === void 0 ? void 0 : cb(value);
1767
- };
1768
- };
1769
- return listBlockAdded
1770
- .filter((b) => InputBlocks.includes(b.name))
1771
- .reduce((r, b) => {
1772
- const { name: fieldType, data } = b || {};
1773
- const { value: fieldName, required } = data || {};
1774
- const isRequired = required !== null && required !== void 0 ? required : true;
1775
- if (fieldType === 'NumberBlock') {
1776
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1777
- if (value && isNaN(Number(value))) {
1778
- return t('validator.number');
1779
- }
1780
- }, b) });
1781
- }
1782
- else if (fieldType === 'EmailBlock') {
1783
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1784
- if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
1785
- return t('validator.email');
1786
- }
1787
- if (!value)
1788
- return;
1789
- validatingEmailRef.current = true;
1790
- setTimeout(() => {
1791
- formRef.current.setFieldError(fieldName, 'Validating...');
1792
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1793
- email: value,
1794
- })
1795
- .then((tKey) => {
1796
- if (tKey) {
1797
- formRef.current.setFieldError(fieldName, t(tKey));
1798
- }
1799
- else {
1800
- formRef.current.clearFieldError(fieldName);
1801
- }
1802
- validatingEmailRef.current = false;
1803
- })
1804
- .catch((e) => {
1805
- console.error(e);
1806
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
1807
- validatingEmailRef.current = false;
1808
- });
1809
- }, 200);
1810
- }, b) });
1811
- }
1812
- else if (fieldType === 'PhoneBlock' ||
1813
- fieldType === 'PhoneOtpBlock' ||
1814
- fieldType === 'ZaloOtpBlock' ||
1815
- fieldType === 'WhatsappOtpBlock') {
1816
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1817
- if (value &&
1818
- window.intlTelInputUtils &&
1819
- !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
1820
- return t('validator.phone');
1821
- }
1822
- if (!value)
1823
- return;
1824
- validatingPhoneRef.current = true;
1825
- setTimeout(() => {
1826
- formRef.current.setFieldError(fieldName, 'Validating...');
1827
- if (b.data.singleSubmission) {
1828
- checkUsedPhoneOnlyWithCache(campaignId, value)
1829
- .then((tKey) => {
1830
- if (tKey) {
1831
- formRef.current.setFieldError(fieldName, t(tKey));
1832
- }
1833
- else {
1834
- formRef.current.clearFieldError(fieldName);
1835
- }
1836
- validatingPhoneRef.current = false;
1837
- })
1838
- .catch((err) => {
1839
- console.error(err);
1840
- formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
1841
- validatingPhoneRef.current = false;
1842
- });
1843
- }
1844
- else {
1845
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1846
- phone: value,
1847
- })
1848
- .then((tKey) => {
1849
- if (tKey) {
1850
- formRef.current.setFieldError(fieldName, t(tKey));
1851
- }
1852
- else {
1853
- formRef.current.clearFieldError(fieldName);
1854
- }
1855
- validatingPhoneRef.current = false;
1856
- })
1857
- .catch((e) => {
1858
- console.error(e);
1859
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
1860
- validatingPhoneRef.current = false;
1861
- });
1862
- }
1863
- }, 200);
1864
- }, b) });
1865
- }
1866
- else if (fieldType === 'DateBlock') {
1867
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1868
- if (!isRequired && !value) {
1869
- return;
1870
- }
1871
- const errMsg = t('validator.dateInvalid');
1872
- const dayInJS = typeof value === 'string'
1873
- ? dayjs__default["default"](value, format, true)
1874
- : dayjs__default["default"](value);
1875
- if (!dayInJS.isValid()) {
1876
- return errMsg;
1877
- }
1878
- }, b) });
1879
- }
1880
- else if (fieldType === 'TncBlock') {
1881
- return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
1882
- if (isRequired && !value) {
1883
- return t('validator.required');
1884
- }
1885
- }, b) });
1886
- }
1887
- else {
1888
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
1889
- }
1890
- }, {});
1891
- }, [listBlockAdded.map((b) => b.name).join(','), format]);
1892
- const form = useLeadForm({
1893
- validateInputOnChange: true,
1894
- validateInputOnBlur: true,
1895
- clearInputErrorOnChange: true,
1896
- validate: validateObj,
1897
- initialValues,
1898
- });
1899
- const formRef = React.useRef(form);
1900
- formRef.current = form;
1901
- return { form, validateObj };
1902
- };
1903
-
3388
+ const SideBarLayout = ({ content }) => {
3389
+ const targets = React.useMemo(() => {
3390
+ const targetDoms = Array.from(document.querySelectorAll('.hc2-sidebar-with-ads,.page-main-col .right-col.f-right,.hhg-lead-sidebar'));
3391
+ targetDoms.forEach((dom) => {
3392
+ if (dom.querySelector('.sidebar-lead-modal-wrapper'))
3393
+ return;
3394
+ const wrapper = document.createElement('div');
3395
+ wrapper.classList.add('sidebar-lead-modal-wrapper');
3396
+ dom.prepend(wrapper);
3397
+ });
3398
+ return targetDoms.map((d) => d.querySelector('.sidebar-lead-modal-wrapper'));
3399
+ }, []);
3400
+ return (React__default["default"].createElement(React__default["default"].Fragment, null, targets.map((target) => ReactDOM.createPortal(content, utils$1.getWrapperDomWithSelector(target, 'sidebar-lead-modal-wrapper')))));
3401
+ };
3402
+
3403
+ const EmptyIcon = (props) => {
3404
+ const { className, style } = props;
3405
+ return (React__default["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 },
3406
+ React__default["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" }),
3407
+ React__default["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" }),
3408
+ React__default["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" })));
3409
+ };
3410
+
3411
+ const EmptyComponent = ({ onClose, onContinue, }) => {
3412
+ const { t } = index$1.useTranslations();
3413
+ return (React__default["default"].createElement("div", { className: "leadgen-empty" },
3414
+ React__default["default"].createElement("div", { className: "leadgen-empty_body" },
3415
+ React__default["default"].createElement("div", { className: "leadgen-empty_wrapper" },
3416
+ React__default["default"].createElement(EmptyIcon, { className: "leadgen-empty_image" }),
3417
+ React__default["default"].createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
3418
+ React__default["default"].createElement("div", { className: "leadgen-empty_footer" },
3419
+ React__default["default"].createElement(core.Button, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
3420
+ React__default["default"].createElement(core.Button, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
3421
+ };
3422
+
1904
3423
  const SubtitleBlock = ({ children, align, }) => (React__default["default"].createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
1905
3424
 
1906
3425
  const cssInputNotShrink = react.css `
@@ -2227,11 +3746,13 @@ const TextField = (props) => {
2227
3746
  const $focusEl = $textEl.item($textEl.length - 1);
2228
3747
  if ($focusEl) {
2229
3748
  $focusEl.focus();
2230
- $focusEl.scrollIntoView({
2231
- behavior: 'auto',
2232
- block: 'center',
2233
- inline: 'start',
2234
- });
3749
+ setTimeout(() => {
3750
+ $focusEl.scrollIntoView({
3751
+ behavior: 'auto',
3752
+ block: 'center',
3753
+ inline: 'start',
3754
+ });
3755
+ }, 100);
2235
3756
  }
2236
3757
  }, [shrink]);
2237
3758
  React.useEffect(() => {
@@ -2248,13 +3769,13 @@ const ChoiceField = (props) => {
2248
3769
  const TitleBlock = ({ children, align, }) => (React__default["default"].createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
2249
3770
 
2250
3771
  const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, }) => {
2251
- const { t } = index.useTranslations();
3772
+ const { t } = index$1.useTranslations();
2252
3773
  const form = useLeadFormContext();
2253
3774
  const formValues = form.values;
2254
3775
  const labelTuples = React.useMemo(() => {
2255
3776
  return ((index$7.ISO_FORMAT === null || index$7.ISO_FORMAT === void 0 ? void 0 : index$7.ISO_FORMAT[locale]) || index$7.ISO_FORMAT['vi-VN']).dateFormat
2256
3777
  .split('/')
2257
- .map((key) => { var _a; return t((_a = index$8.COMMON_DATE_TRANSLATE_KEY === null || index$8.COMMON_DATE_TRANSLATE_KEY === void 0 ? void 0 : index$8.COMMON_DATE_TRANSLATE_KEY[key]) === null || _a === void 0 ? void 0 : _a.id); });
3778
+ .map((key) => { var _a; return t((_a = index$9.COMMON_DATE_TRANSLATE_KEY === null || index$9.COMMON_DATE_TRANSLATE_KEY === void 0 ? void 0 : index$9.COMMON_DATE_TRANSLATE_KEY[key]) === null || _a === void 0 ? void 0 : _a.id); });
2258
3779
  }, [locale]);
2259
3780
  return (React__default["default"].createElement(React__default["default"].Fragment, null, listBlockAdded.map((b, index) => {
2260
3781
  var _a;
@@ -2297,7 +3818,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2297
3818
  }) },
2298
3819
  React__default["default"].createElement(core.Input.Wrapper, { size: "md", withAsterisk: required, label: placeholder, "data-invalid": !!error, labelProps: { htmlFor: htmlForId }, inputWrapperOrder: ['label', 'input', 'description', 'error'], error: error },
2299
3820
  React__default["default"].createElement("div", { className: "mantine-Input-wrapper" },
2300
- React__default["default"].createElement(index$2.Phone, Object.assign({ className: "mantine-Input-input", name: value, spellCheck: false, type: "tel", placeholder: placeholder,
3821
+ React__default["default"].createElement(index$3.Phone, Object.assign({ className: "mantine-Input-input", name: value, spellCheck: false, type: "tel", placeholder: placeholder,
2301
3822
  // onBlur={(e) => inputOnBlur('tel', e)}
2302
3823
  id: htmlForId, defaultCountry: (locale ? utils.MAPPED_LOCALE[locale] || 'VN' : 'VN'), "data-control": "tel" }, formPhoneInputWrapper))))));
2303
3824
  }
@@ -2313,7 +3834,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2313
3834
  case 'LinkButtonBlock':
2314
3835
  return (React__default["default"].createElement("div", { key: index },
2315
3836
  React__default["default"].createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
2316
- React__default["default"].createElement(index$9.Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
3837
+ React__default["default"].createElement(index$a.Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
2317
3838
  onClose === null || onClose === void 0 ? void 0 : onClose();
2318
3839
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2319
3840
  } }, value))));
@@ -2322,7 +3843,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2322
3843
  isSendMailChimp && (React__default["default"].createElement("div", { style: {
2323
3844
  display: 'none',
2324
3845
  }, "data-name": value + '-mailchimp' })),
2325
- React__default["default"].createElement(index$2.Checkbox.Group, Object.assign({ withAsterisk: required,
3846
+ React__default["default"].createElement(index$3.Checkbox.Group, Object.assign({ withAsterisk: required,
2326
3847
  // className="lead-modal__form-control leadgen-form_field"
2327
3848
  label: placeholder, size: "md", sx: {
2328
3849
  display: 'flex',
@@ -2331,19 +3852,19 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2331
3852
  gap: 8,
2332
3853
  }, inputWrapperOrder: ['label', 'input', 'description', 'error'], inputContainer: (children) => {
2333
3854
  return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2334
- } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$2.Checkbox, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
3855
+ } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$3.Checkbox, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2335
3856
  case 'RadioBlock':
2336
3857
  return (React__default["default"].createElement(ChoiceField, { className: "leadgen-form_radio", key: index },
2337
3858
  isSendMailChimp && (React__default["default"].createElement(core.Input, { type: "hidden", name: value + '-mailchimp', value: isSendMailChimp })),
2338
- React__default["default"].createElement(index$2.Radio.Group, Object.assign({ withAsterisk: required,
3859
+ React__default["default"].createElement(index$3.Radio.Group, Object.assign({ withAsterisk: required,
2339
3860
  // className="lead-modal__form-control leadgen-form_field"
2340
3861
  label: placeholder, size: "md", inputWrapperOrder: ['label', 'input', 'description', 'error'], inputContainer: (children) => {
2341
3862
  return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2342
- } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$2.Radio, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
3863
+ } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$3.Radio, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2343
3864
  case 'DropdownBlock':
2344
3865
  return (React__default["default"].createElement(TextField, { shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field", key: index },
2345
3866
  React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2346
- React__default["default"].createElement(index$2.Select
3867
+ React__default["default"].createElement(index$3.Select
2347
3868
  // className="lead-modal__form-control leadgen-form_field"
2348
3869
  , Object.assign({
2349
3870
  // className="lead-modal__form-control leadgen-form_field"
@@ -2355,7 +3876,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2355
3876
  const _d = form.getInputProps(`TNC-${id}`), { error } = _d, tncInputProps = tslib_es6.__rest(_d, ["error"]);
2356
3877
  return (React__default["default"].createElement(ChoiceField, { className: "leadgen-form_checkbox", key: id },
2357
3878
  React__default["default"].createElement(core.Input.Wrapper, { error: error },
2358
- React__default["default"].createElement(index$2.Checkbox, Object.assign({ name: 'TNC-' + id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps)))));
3879
+ React__default["default"].createElement(index$3.Checkbox, Object.assign({ name: 'TNC-' + id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps)))));
2359
3880
  }
2360
3881
  return null;
2361
3882
  })));
@@ -2421,842 +3942,498 @@ const FormContainer = (_a) => {
2421
3942
  var { title, titleAlign, description, descriptionAlign, className, style, children, header, footer } = _a, restProps = tslib_es6.__rest(_a, ["title", "titleAlign", "description", "descriptionAlign", "className", "style", "children", "header", "footer"]);
2422
3943
  const HeaderContent = (React__default["default"].createElement("div", { className: "leadgen-form_header" },
2423
3944
  React__default["default"].createElement("h2", { title: title, className: "leadgen-title", "data-align": titleAlign }, title),
2424
- !!description && (React__default["default"].createElement("p", { title: description, className: "leadgen-description", "data-align": descriptionAlign, dangerouslySetInnerHTML: { __html: description } }))));
2425
- if (!title && !description) {
2426
- return null;
2427
- }
2428
- return (React__default["default"].createElement(StyledFormContainer, Object.assign({ className: core.clsx(className, 'leadgen-form_container'), style: style }, restProps),
2429
- React__default["default"].createElement("div", { className: "leadgen-form_wrapper" },
2430
- !!header && (React__default["default"].createElement("div", { className: "leadgen-form_scrollable" },
2431
- header,
2432
- HeaderContent,
2433
- React__default["default"].createElement("div", { className: "leadgen-form_body" }, children))),
2434
- !header && (React__default["default"].createElement(React__default["default"].Fragment, null,
2435
- HeaderContent,
2436
- React__default["default"].createElement("div", { className: "leadgen-form_body" }, children))),
2437
- React__default["default"].createElement("div", { className: "leadgen-form_footer" }, footer))));
2438
- };
2439
-
2440
- const StyleHeaderImage = styled__default["default"].div `
2441
- position: relative;
2442
- overflow: hidden;
2443
- width: 100%;
2444
- height: 100%;
2445
- padding-top: ${({ paddingTop }) => paddingTop}%;
2446
- .leadgen-header_image_feature {
2447
- position: absolute;
2448
- inset: 0;
2449
- min-width: 100%;
2450
- min-height: 100%;
2451
- max-width: 100%;
2452
- max-height: 100%;
2453
- object-fit: cover;
2454
- object-position: center;
2455
- }
2456
- `;
2457
- const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
2458
- if (!src) {
2459
- return null;
2460
- }
2461
- return (React__default["default"].createElement(StyleHeaderImage, { paddingTop: (1 / ratio) * 100, className: core.clsx(className, 'leadgen-header_image'), style: style }, index$6.isVideo(src) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true, className: "leadgen-header_image_feature leadgen-header_image_video", src: src })) : (React__default["default"].createElement("img", { src: src, draggable: "false", alt: "", className: "leadgen-header_image_feature leadgen-header_image_image" }))));
2462
- };
2463
-
2464
- const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
2465
- const { primaryColor } = React.useContext(LeadGenContext);
2466
- const { t } = index.useTranslations();
2467
- const phone = otpData.phone;
2468
- const otpType = otpData.type;
2469
- const [otp, setOtp] = React.useState('');
2470
- const [isDirty, setIsDirty] = React.useState(false);
2471
- const [resendTimer, setResendTimer] = React.useState(autoSendWhenOpen ? 0 : 60);
2472
- const inputRef = React.useRef(null);
2473
- const [errorMsg, setErrorMsg] = React.useState();
2474
- const [displayPhone, setDisplayPhone] = React.useState('');
2475
- const formatPhoneNumberIntlRef = React.useRef();
2476
- const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
2477
- React.useEffect(() => {
2478
- (() => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
2479
- var _a;
2480
- if (!formatPhoneNumberIntlRef.current) {
2481
- const res = yield Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('react-phone-number-input')); });
2482
- formatPhoneNumberIntlRef.current = res.formatPhoneNumberIntl;
2483
- }
2484
- setDisplayPhone(((_a = formatPhoneNumberIntlRef.current) === null || _a === void 0 ? void 0 : _a.call(formatPhoneNumberIntlRef, phone)) || phone);
2485
- }))();
2486
- }, [phone]);
2487
- const sendOtp = () => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
2488
- var _a;
2489
- if (!phone) {
2490
- return;
2491
- }
2492
- const res = yield Service.sendSMSOtpLead({
2493
- phone,
2494
- type: otpType,
2495
- });
2496
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2497
- if (respMessage === 'Send sms successfully' ||
2498
- respMessage === 'Send WhatsApp successfully' ||
2499
- respMessage === 'Send Zalo successfully') {
2500
- setResendTimer(60);
2501
- setTimeout(() => {
2502
- if (inputRef.current) {
2503
- inputRef.current.focus();
2504
- inputRef.current.scrollIntoView({ block: 'center' });
2505
- }
2506
- }, 100);
2507
- }
2508
- else if (respMessage === 'This phone number was verified') {
2509
- onSuccess();
2510
- }
2511
- else {
2512
- setErrorMsg(respMessage || 'Something went wrong!');
2513
- // const defaultError = f({ id: 'notification.comment.somethingWrong' })
2514
- // setStatusVerifyOTP('idle')
2515
- // pushNotifications({
2516
- // title: respMessage || defaultError,
2517
- // message: '',
2518
- // type: 'danger',
2519
- // })
2520
- }
2521
- });
2522
- const submitOtp = () => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
2523
- if (!phone || !otp) {
2524
- return;
2525
- }
2526
- setIsSubmitLoading(true);
2527
- const res = yield Service.verifyOtpLead({
2528
- phone,
2529
- otp,
2530
- type: otpType,
2531
- });
2532
- const respMessage = res === null || res === void 0 ? void 0 : res._messages[0];
2533
- if (respMessage === 'Verify successfully' ||
2534
- respMessage === 'Verify WhatsApp OTP sucess' ||
2535
- respMessage === 'Verify Zalo OTP sucess') {
2536
- onSuccess();
2537
- }
2538
- else if (respMessage === 'This phone number was verified') {
2539
- onSuccess();
2540
- }
2541
- else {
2542
- setErrorMsg(respMessage || 'something Wrong');
2543
- // setIsShowError(true)
2544
- // setStatusVerifyOTP('sent')
2545
- // pushNotifications({
2546
- // title: res?._messages[0] || defaultError,
2547
- // message: '',
2548
- // type: 'danger',
2549
- // })
2550
- }
2551
- setIsSubmitLoading(false);
2552
- });
2553
- React.useEffect(() => {
2554
- setTimeout(() => {
2555
- if (resendTimer > 0) {
2556
- setResendTimer((r) => r - 1);
2557
- }
2558
- }, 1000);
2559
- }, [resendTimer]);
2560
- React.useEffect(() => {
2561
- if (autoSendWhenOpen && !resendTimer) {
2562
- sendOtp();
2563
- }
2564
- }, []);
2565
- return (React__default["default"].createElement("form", { onSubmit: (e) => {
2566
- e.preventDefault();
2567
- submitOtp();
2568
- }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
2569
- React__default["default"].createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
2570
- phone: `<strong>${displayPhone}</strong>`,
2571
- }), footer: React__default["default"].createElement(React__default["default"].Fragment, null,
2572
- React__default["default"].createElement(core.Button, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
2573
- React__default["default"].createElement(core.Button, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
2574
- sendOtp();
2575
- }, disabled: !!resendTimer }, t('lead.otp.resend', {
2576
- timer: resendTimer ? ` (${resendTimer}s)` : '',
2577
- }))) },
2578
- React__default["default"].createElement("div", { className: "leadgen-form_inner" },
2579
- React__default["default"].createElement(index$2.Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
2580
- React__default["default"].createElement(index$2.OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
2581
- setIsDirty(true);
2582
- setOtp(v.toString());
2583
- if (isDirty && !v)
2584
- setErrorMsg('OTP is required');
2585
- else
2586
- setErrorMsg(undefined);
2587
- } }))))));
2588
- };
2589
-
2590
- // url: imageBlocks.imageMobile.data.url
2591
- // newTab: imageBlocks.imageMobile.data.newtab
2592
- // image: campaignShow.image
2593
- // imageDestkop: campaignShow.image_desktop
2594
- const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
2595
- LEADGEN_LAYOUT.Fullscreen,
2596
- LEADGEN_LAYOUT.Slider,
2597
- ];
2598
- const LEADGEN_LIMIT_LIGHTBOXB = 6;
2599
- const LEADGEN_SHOW_HEADER = [
2600
- 'LightBoxA',
2601
- 'InlineA',
2602
- LEADGEN_LAYOUT.Sidebar,
2603
- LEADGEN_LAYOUT.Slider,
2604
- ];
2605
- const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2606
- var _a, _b;
2607
- const { primaryColor } = React.useContext(LeadGenContext);
2608
- const { isMobile } = useScreenSize.useScreenSize();
2609
- const [open, setOpen] = React.useState(!!campaignId);
2610
- const [showOtpPhone, setShowOtpPhone] = React.useState(null);
2611
- const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
2612
- const [snap, setSnap] = React.useState(0.8);
2613
- const formRef = React.useRef();
2614
- const onClose = () => {
2615
- if (showOtpPhone) {
2616
- setShowOtpPhone(null);
2617
- }
2618
- else {
2619
- onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2620
- }
2621
- };
2622
- const textBlocks = JSON.parse(extraFields.textBlocks);
2623
- const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
2624
- const actionBlocks = JSON.parse(extraFields.actionBlocks);
2625
- const popUpSubmitText = actionBlocks.submitBlock.data.value;
2626
- const currentPath = location.pathname;
2627
- const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
2628
- const { align: titleAlign } = textBlocks.titleBlock.data || {};
2629
- const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
2630
- const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
2631
- const isLightBox = currentLayout.includes('LightBox');
2632
- const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
2633
- const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
2634
- const isInline = currentLayout.includes('Inline');
2635
- const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
2636
- const isInPage = isInline || isSidebar;
2637
- const isDrawer = isLightBoxB && isMobile;
2638
- const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
2639
- const hasForm = isLightBoxA
2640
- ? listBlockAdded.some((item) => LEADGEN_BLOCK_IN_FORM.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
2641
- : true;
2642
- const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
2643
- const showHeader = !!imageMobile || !!imageDesktop;
2644
- const onlyHeader = !title && !description;
2645
- const showButtonClose = !isInline;
2646
- if (window.innerWidth < 769 &&
2647
- LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
2648
- console.log('😎 Not show fullscreen, slider on mobile ');
3945
+ !!description && (React__default["default"].createElement("p", { title: description, className: "leadgen-description", "data-align": descriptionAlign, dangerouslySetInnerHTML: { __html: description } }))));
3946
+ if (!title && !description) {
3947
+ return null;
3948
+ }
3949
+ return (React__default["default"].createElement(StyledFormContainer, Object.assign({ className: core.clsx(className, 'leadgen-form_container'), style: style }, restProps),
3950
+ React__default["default"].createElement("div", { className: "leadgen-form_wrapper" },
3951
+ !!header && (React__default["default"].createElement("div", { className: "leadgen-form_scrollable" },
3952
+ header,
3953
+ HeaderContent,
3954
+ React__default["default"].createElement("div", { className: "leadgen-form_body" }, children))),
3955
+ !header && (React__default["default"].createElement(React__default["default"].Fragment, null,
3956
+ HeaderContent,
3957
+ React__default["default"].createElement("div", { className: "leadgen-form_body" }, children))),
3958
+ React__default["default"].createElement("div", { className: "leadgen-form_footer" }, footer))));
3959
+ };
3960
+
3961
+ const StyleHeaderImage = styled__default["default"].div `
3962
+ position: relative;
3963
+ overflow: hidden;
3964
+ width: 100%;
3965
+ height: 100%;
3966
+ padding-top: ${({ paddingTop }) => paddingTop}%;
3967
+ .leadgen-header_image_feature {
3968
+ position: absolute;
3969
+ inset: 0;
3970
+ min-width: 100%;
3971
+ min-height: 100%;
3972
+ max-width: 100%;
3973
+ max-height: 100%;
3974
+ object-fit: cover;
3975
+ object-position: center;
3976
+ }
3977
+ `;
3978
+ const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
3979
+ if (!src) {
2649
3980
  return null;
2650
3981
  }
3982
+ return (React__default["default"].createElement(StyleHeaderImage, { paddingTop: (1 / ratio) * 100, className: core.clsx(className, 'leadgen-header_image'), style: style }, index$8.isVideo(src) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true, className: "leadgen-header_image_feature leadgen-header_image_video", src: src })) : (React__default["default"].createElement("img", { src: src, draggable: "false", alt: "", className: "leadgen-header_image_feature leadgen-header_image_image" }))));
3983
+ };
3984
+
3985
+ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
3986
+ const { primaryColor } = React.useContext(LeadGenContext$1);
3987
+ const { t } = index$1.useTranslations();
3988
+ const phone = otpData.phone;
3989
+ const otpType = otpData.type;
3990
+ const [otp, setOtp] = React.useState('');
3991
+ const [isDirty, setIsDirty] = React.useState(false);
3992
+ const [resendTimer, setResendTimer] = React.useState(autoSendWhenOpen ? 0 : 60);
3993
+ const inputRef = React.useRef(null);
3994
+ const [errorMsg, setErrorMsg] = React.useState();
3995
+ const [displayPhone, setDisplayPhone] = React.useState('');
3996
+ const formatPhoneNumberIntlRef = React.useRef();
3997
+ const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
2651
3998
  React.useEffect(() => {
2652
- if (isLightBox || isFullscreen) {
2653
- document.body.classList.add('noscroll');
3999
+ (() => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
4000
+ var _a;
4001
+ if (!formatPhoneNumberIntlRef.current) {
4002
+ const res = yield Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('react-phone-number-input')); });
4003
+ formatPhoneNumberIntlRef.current = res.formatPhoneNumberIntl;
4004
+ }
4005
+ setDisplayPhone(((_a = formatPhoneNumberIntlRef.current) === null || _a === void 0 ? void 0 : _a.call(formatPhoneNumberIntlRef, phone)) || phone);
4006
+ }))();
4007
+ }, [phone]);
4008
+ const sendOtp = () => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
4009
+ var _a;
4010
+ if (!phone) {
4011
+ return;
2654
4012
  }
2655
- if (!window.intlTelInputUtils) {
2656
- require('intl-tel-input/build/js/utils');
4013
+ const res = yield Service.sendSMSOtpLead({
4014
+ phone,
4015
+ type: otpType,
4016
+ });
4017
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4018
+ if (respMessage === 'Send sms successfully' ||
4019
+ respMessage === 'Send WhatsApp successfully' ||
4020
+ respMessage === 'Send Zalo successfully') {
4021
+ setResendTimer(60);
4022
+ setTimeout(() => {
4023
+ if (inputRef.current) {
4024
+ inputRef.current.focus();
4025
+ inputRef.current.scrollIntoView({ block: 'center' });
4026
+ }
4027
+ }, 100);
4028
+ }
4029
+ else if (respMessage === 'This phone number was verified') {
4030
+ onSuccess();
4031
+ }
4032
+ else {
4033
+ setErrorMsg(respMessage || 'Something went wrong!');
4034
+ // const defaultError = f({ id: 'notification.comment.somethingWrong' })
4035
+ // setStatusVerifyOTP('idle')
4036
+ // pushNotifications({
4037
+ // title: respMessage || defaultError,
4038
+ // message: '',
4039
+ // type: 'danger',
4040
+ // })
2657
4041
  }
2658
- clearCacheUsedEmailOrPhone();
2659
- }, []);
2660
- const validatingPhoneRef = React.useRef(false);
2661
- const validatingEmailRef = React.useRef(false);
2662
- const { form, validateObj } = useLeadFormConfig({
2663
- listBlockAdded,
2664
- validatingPhoneRef,
2665
- validatingEmailRef,
2666
- campaignId,
2667
- campaign_subot_id,
2668
- userInfo,
2669
- format: (_a = (index$7.ISO_FORMAT[locale] || index$7.ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
2670
4042
  });
2671
- const middlewareOnSubmit = (e) => {
2672
- e.preventDefault();
2673
- // mark all as touched to allow validation
2674
- const fields = Object.keys(validateObj);
2675
- const fieldStatus = fields.reduce((acc, cur) => {
2676
- acc[cur] = true;
2677
- return acc;
2678
- }, {});
2679
- form.setTouched(fieldStatus);
2680
- if (validatingEmailRef.current || validatingPhoneRef.current) {
4043
+ const submitOtp = () => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
4044
+ if (!phone || !otp) {
2681
4045
  return;
2682
4046
  }
2683
- setTimeout(() => {
2684
- form.onSubmit((v) => {
2685
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2686
- if (Object.keys(form.errors).length)
2687
- return;
2688
- let newShowOtpPhone = null;
2689
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
2690
- // not submit yet, open otp
2691
- 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;
2692
- if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
2693
- newShowOtpPhone = {
2694
- phone: v[fieldName],
2695
- type: 'phone',
2696
- };
2697
- }
2698
- }
2699
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
2700
- // not submit yet, open otp
2701
- 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;
2702
- if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
2703
- newShowOtpPhone = {
2704
- phone: v[fieldName],
2705
- type: 'whatsapp',
2706
- };
2707
- }
2708
- }
2709
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
2710
- // not submit yet, open otp
2711
- 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;
2712
- if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
2713
- newShowOtpPhone = {
2714
- phone: v[fieldName],
2715
- type: 'zalo',
2716
- };
2717
- }
2718
- }
2719
- if (newShowOtpPhone) {
2720
- setIsSubmitLoading(true);
2721
- Service.sendSMSOtpLead(newShowOtpPhone)
2722
- .then((res) => {
2723
- var _a;
2724
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2725
- if (respMessage === 'This phone number was verified') {
2726
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2727
- return;
2728
- }
2729
- setShowOtpPhone(newShowOtpPhone);
2730
- })
2731
- .finally(() => {
2732
- setIsSubmitLoading(false);
2733
- });
2734
- return;
2735
- }
2736
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2737
- })(e);
2738
- }, 100);
2739
- };
2740
- const onOpenChange = (_open) => {
2741
- setOpen(_open);
2742
- if (!_open) {
2743
- setTimeout(() => {
2744
- onClose();
2745
- }, 250);
2746
- }
2747
- };
2748
- const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
2749
- const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
2750
- const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
2751
- const renderAfterImageSizes = imageMobileLoaded &&
2752
- imageDesktopLoaded &&
2753
- (isFullscreen ? imageBackgroundLoaded : true);
2754
- const ButtonSubmit = React.useMemo(() => {
2755
- var _a;
2756
- return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default["default"].createElement(core.Button, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
2757
- }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
2758
- const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
2759
- const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default["default"].createElement(React__default["default"].Fragment, null, LinkButtonBlock.map((item, index) => {
2760
- var _a, _b, _c;
2761
- return (React__default["default"].createElement(core.Button, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
2762
- onClose === null || onClose === void 0 ? void 0 : onClose();
2763
- onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2764
- } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
2765
- })));
2766
- const PopupHeader = showHeader && (React__default["default"].createElement("header", { className: core.clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default["default"].createElement(React__default["default"].Fragment, null,
2767
- React__default["default"].createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
2768
- React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
2769
- const PopupEmpty = showEmpty && (React__default["default"].createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
2770
- const PopupForm = (React__default["default"].createElement(LeadFormProvider, { form: form },
2771
- React__default["default"].createElement("form", { ref: formRef, className: "leadgen-form", onSubmit: middlewareOnSubmit },
2772
- React__default["default"].createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
2773
- React__default["default"].createElement("div", { className: "leadgen-form_inner" },
2774
- React__default["default"].createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
2775
- const PopupOtp = showOtpPhone && (React__default["default"].createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
2776
- setShowOtpPhone(null);
2777
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
2778
- } }));
2779
- const PopupThankYou = showThankyou && (React__default["default"].createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
2780
- const PopupContent = (React__default["default"].createElement("div", { className: core.clsx('leadgen-content', {
2781
- 'leadgen-content_small': limitFieldsLightBoxB,
2782
- }) },
2783
- !headerInsideFormContainer && PopupHeader,
2784
- !onlyHeader && (React__default["default"].createElement("div", { className: "leadgen-inner" },
2785
- PopupThankYou,
2786
- !showThankyou && (React__default["default"].createElement(React__default["default"].Fragment, null,
2787
- PopupOtp,
2788
- PopupEmpty,
2789
- !(showOtpPhone || showEmpty) && PopupForm))))));
2790
- const styleOverlay = React.useMemo(() => {
2791
- let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
2792
- if (isMobile && imageOverlayMobile) {
2793
- styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4047
+ setIsSubmitLoading(true);
4048
+ const res = yield Service.verifyOtpLead({
4049
+ phone,
4050
+ otp,
4051
+ type: otpType,
4052
+ });
4053
+ const respMessage = res === null || res === void 0 ? void 0 : res._messages[0];
4054
+ if (respMessage === 'Verify successfully' ||
4055
+ respMessage === 'Verify WhatsApp OTP sucess' ||
4056
+ respMessage === 'Verify Zalo OTP sucess') {
4057
+ onSuccess();
2794
4058
  }
2795
- if (!isMobile && imageOverlayDesktop) {
2796
- styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4059
+ else if (respMessage === 'This phone number was verified') {
4060
+ onSuccess();
2797
4061
  }
2798
- return styleContent;
2799
- }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
2800
- const PopupWrapper = (React__default["default"].createElement(React__default["default"].Fragment, null,
2801
- React__default["default"].createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
2802
- React__default["default"].createElement("div", { className: core.clsx('leadgen-wrapper', {
2803
- 'leadgen-wrapper_small': limitFieldsLightBoxB,
2804
- }) },
2805
- showButtonClose && (React__default["default"].createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
2806
- PopupContent)));
2807
- const popupContainerClassName = core.clsx('leadgen', `leadgen-${currentLayout}`, {
2808
- 'leadgen-lightbox': isLightBox,
2809
- 'leadgen-inline': isInPage,
2810
- 'leadgen-slider': isSlider,
4062
+ else {
4063
+ setErrorMsg(respMessage || 'something Wrong');
4064
+ // setIsShowError(true)
4065
+ // setStatusVerifyOTP('sent')
4066
+ // pushNotifications({
4067
+ // title: res?._messages[0] || defaultError,
4068
+ // message: '',
4069
+ // type: 'danger',
4070
+ // })
4071
+ }
4072
+ setIsSubmitLoading(false);
2811
4073
  });
2812
- const PopupContainer = isDrawer ? (React__default["default"].createElement(index$a.DrawerComponent, { fadeFromIndex: index$7.ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
2813
- PopupWrapper,
2814
- React__default["default"].createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default["default"].createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
2815
- isFullscreen ? (React__default["default"].createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
2816
- aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
2817
- } })) : null,
2818
- PopupWrapper));
2819
- if (!renderAfterImageSizes)
2820
- return null;
2821
- if (isLightBox || isFullscreen || isSlider) {
2822
- return PopupContainer;
2823
- }
2824
- else if (isSidebar) {
2825
- return React__default["default"].createElement(SideBarLayout, { content: PopupContainer });
2826
- }
2827
- else if (isInline) {
2828
- return (React__default["default"].createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
2829
- }
2830
- return null;
2831
- };
2832
-
2833
- const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
2834
- const currentPath = location.pathname;
2835
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
2836
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
2837
- if (!imageMobileLoaded || !imageDesktopLoaded)
2838
- return null;
2839
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
2840
- currentLayout == 'SkinA' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
2841
- React__default["default"].createElement("div", { className: "le-skin-a-desktop" },
2842
- React__default["default"].createElement("div", { style: { position: 'relative' } },
2843
- React__default["default"].createElement("img", { src: imageDesktop, style: {
2844
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2845
- } }),
2846
- React__default["default"].createElement("a", { style: {
2847
- position: 'absolute',
2848
- top: '75%',
2849
- left: '50%',
2850
- transform: 'translate(-50%, -50%)',
2851
- textAlign: 'center',
2852
- width: 'calc(100% - 15px)',
2853
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2854
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
2855
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
2856
- React__default["default"].createElement("div", { className: "" },
2857
- React__default["default"].createElement("div", { style: { position: 'relative', zIndex: 10000 } },
2858
- React__default["default"].createElement("img", { src: imageDesktop, style: {
2859
- width: '100%',
2860
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2861
- } }),
2862
- React__default["default"].createElement("a", { style: {
2863
- position: 'absolute',
2864
- top: '75%',
2865
- left: '50%',
2866
- transform: 'translate(-50%, -50%)',
2867
- textAlign: 'center',
2868
- width: '100%',
2869
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2870
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2871
- React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
2872
- React__default["default"].createElement("aside", { className: "le-only-mobile" },
2873
- React__default["default"].createElement("div", { className: "le-skin-mobile" },
2874
- React__default["default"].createElement("div", { style: { position: 'relative' } },
2875
- index$6.isVideo(imageMobile) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true },
2876
- React__default["default"].createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default["default"].createElement("img", { src: imageMobile, style: {
2877
- width: '100%',
2878
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
2879
- } })),
2880
- React__default["default"].createElement("a", { style: {
2881
- position: 'absolute',
2882
- top: '82%',
2883
- left: '50%',
2884
- transform: 'translate(-50%, -50%)',
2885
- textAlign: 'center',
2886
- maxWidth: 'calc(100% - 15px)',
2887
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2888
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2889
- React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4074
+ React.useEffect(() => {
4075
+ setTimeout(() => {
4076
+ if (resendTimer > 0) {
4077
+ setResendTimer((r) => r - 1);
4078
+ }
4079
+ }, 1000);
4080
+ }, [resendTimer]);
4081
+ React.useEffect(() => {
4082
+ if (autoSendWhenOpen && !resendTimer) {
4083
+ sendOtp();
4084
+ }
4085
+ }, []);
4086
+ return (React__default["default"].createElement("form", { onSubmit: (e) => {
4087
+ e.preventDefault();
4088
+ submitOtp();
4089
+ }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
4090
+ React__default["default"].createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
4091
+ phone: `<strong>${displayPhone}</strong>`,
4092
+ }), footer: React__default["default"].createElement(React__default["default"].Fragment, null,
4093
+ React__default["default"].createElement(core.Button, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
4094
+ React__default["default"].createElement(core.Button, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
4095
+ sendOtp();
4096
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
4097
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
4098
+ }))) },
4099
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4100
+ React__default["default"].createElement(index$3.Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
4101
+ React__default["default"].createElement(index$3.OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
4102
+ setIsDirty(true);
4103
+ setOtp(v.toString());
4104
+ if (isDirty && !v)
4105
+ setErrorMsg('OTP is required');
4106
+ else
4107
+ setErrorMsg(undefined);
4108
+ } }))))));
2890
4109
  };
2891
4110
 
2892
4111
  // url: imageBlocks.imageMobile.data.url
2893
4112
  // newTab: imageBlocks.imageMobile.data.newtab
2894
4113
  // image: campaignShow.image
2895
4114
  // imageDestkop: campaignShow.image_desktop
2896
- const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
2897
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
2898
- if (!imageLoaded)
2899
- return null;
2900
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
2901
- React__default["default"].createElement("div", { className: "le-tab-popup" },
2902
- React__default["default"].createElement("div", { style: { position: 'relative' } },
2903
- React__default["default"].createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
2904
- React__default["default"].createElement("img", { className: "js-popup-other-submit", src: image, style: {
2905
- aspectRatio: `${imageWidth}/${imageHeight}`,
2906
- } })),
2907
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
2908
- };
2909
-
2910
- // import mockLeadData from './mockLeadData'
2911
- const listCampaignScheduled = [];
2912
- const listCampaignScheduledToActivated = [];
2913
- const listCampaignActiveButExpired = [];
2914
- const listCampaignExcludeSonsored = [];
2915
- const listCampaignDifferentSponsor = [];
2916
- const listCampaignNotDisplayInRangeOfTime = [];
2917
- function isMobile() {
2918
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
2919
- }
2920
- const getShuffleArray = (array) => {
2921
- const newArray = [...array];
2922
- for (let i = newArray.length - 1; i > 0; i--) {
2923
- const j = Math.floor(Math.random() * (i + 1));
2924
- const temp = newArray[i];
2925
- newArray[i] = newArray[j];
2926
- newArray[j] = temp;
2927
- }
2928
- return newArray;
2929
- };
2930
- const getTimeByTimezone = (timeZone = 'UTC') => {
2931
- const date = new Date();
2932
- return new Date(date.toLocaleString('en-US', { timeZone }));
2933
- };
2934
- const parseDateByCampaignTime = (dateStr) => {
2935
- // Format like this: 2023-04-04 00:00:00
2936
- try {
2937
- const [datePart, timePart] = dateStr.split(' ');
2938
- const [year, month, day] = datePart.split('-').map(Number);
2939
- const [hours, minutes, seconds] = timePart.split(':').map(Number);
2940
- /** JavaScript counts months from 0 to 11 */
2941
- return new Date(year, month - 1, day, hours, minutes, seconds);
2942
- }
2943
- catch (err) {
2944
- return null;
2945
- }
2946
- };
2947
- const checkCampaignNowInTimeframe = (c) => {
2948
- var _a;
2949
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2950
- const startedAtStr = c.started_at;
2951
- const endedAtStr = c.ended_at;
2952
- const startedDate = parseDateByCampaignTime(startedAtStr);
2953
- const endedDate = parseDateByCampaignTime(endedAtStr);
2954
- if (!startedDate || !endedDate) {
2955
- return false;
2956
- }
2957
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
2958
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2959
- if (nowWithTimezoneMs <= endedDate.getTime() &&
2960
- nowWithTimezoneMs >= startedDate.getTime()) {
2961
- listCampaignScheduledToActivated.push(c);
2962
- return true;
2963
- }
2964
- return false;
2965
- };
2966
- function checkCampaignActiveButExpireAlready(c) {
2967
- var _a;
2968
- /** Do not setup timeframe for this campaign. No need to check */
2969
- if (c.forever === 1) {
2970
- return true;
2971
- }
2972
- const startedAtStr = c.started_at;
2973
- const endedAtStr = c.ended_at;
2974
- const startedDate = parseDateByCampaignTime(startedAtStr);
2975
- const endedDate = parseDateByCampaignTime(endedAtStr);
2976
- /** Do not setup timeframe for this campaign. No need to check */
2977
- if (!startedDate || !endedDate) {
2978
- return true;
2979
- }
2980
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2981
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
2982
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2983
- /** Check if this expire already, do not show */
2984
- if (nowWithTimezoneMs > endedDate.getTime()) {
2985
- listCampaignActiveButExpired.push(c);
2986
- return false;
2987
- }
2988
- return true;
2989
- }
2990
- function shouldNotDisplayIfExcludeAllSponsors(c) {
2991
- var _a;
2992
- const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
2993
- const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
2994
- if (isSponsored && excludeSponsored) {
2995
- listCampaignExcludeSonsored.push(c);
2996
- return true;
2997
- }
2998
- return false;
2999
- }
3000
- function shouldDisplayWithCurrentSponsor(c) {
4115
+ const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
4116
+ LEADGEN_LAYOUT.Fullscreen,
4117
+ LEADGEN_LAYOUT.Slider,
4118
+ ];
4119
+ const LEADGEN_LIMIT_LIGHTBOXB = 6;
4120
+ const LEADGEN_SHOW_HEADER = [
4121
+ 'LightBoxA',
4122
+ 'InlineA',
4123
+ LEADGEN_LAYOUT.Sidebar,
4124
+ LEADGEN_LAYOUT.Slider,
4125
+ ];
4126
+ const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
3001
4127
  var _a, _b;
3002
- try {
3003
- // TODO: BE will rename `exclude_sponsored_list` later
3004
- const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
3005
- const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
3006
- const dataSponsoredId = Number((_b = document
3007
- .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
3008
- // There is no config for sponsor id and white list, should show as default
3009
- if (!dataSponsoredId ||
3010
- dataSponsoredId <= 0 ||
3011
- whiteListSponsors.length === 0) {
3012
- return true;
4128
+ const { primaryColor } = React.useContext(LeadGenContext$1);
4129
+ const { isMobile } = useScreenSize.useScreenSize();
4130
+ const [open, setOpen] = React.useState(!!campaignId);
4131
+ const [showOtpPhone, setShowOtpPhone] = React.useState(null);
4132
+ const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
4133
+ const [snap, setSnap] = React.useState(0.8);
4134
+ const formRef = React.useRef();
4135
+ const onClose = () => {
4136
+ if (showOtpPhone) {
4137
+ setShowOtpPhone(null);
3013
4138
  }
3014
- // Check the dataSponsoredId exists in the white list or not.
3015
- const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
3016
- if (isExist) {
3017
- return true;
4139
+ else {
4140
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
3018
4141
  }
3019
- listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
3020
- return false;
3021
- }
3022
- catch (err) {
3023
- // Default is show
3024
- return true;
3025
- }
3026
- }
3027
- const filterFnCampaign = (c) => {
3028
- if (shouldNotDisplayIfExcludeAllSponsors(c)) {
3029
- return false;
3030
- }
3031
- else if (!shouldDisplayWithCurrentSponsor(c)) {
3032
- return false;
3033
- }
3034
- /** Active */
3035
- if (c.formatted_status === 1) {
3036
- return checkCampaignActiveButExpireAlready(c);
3037
- }
3038
- /** Schedule */
3039
- if (c.formatted_status === 0) {
3040
- listCampaignScheduled.push(c);
3041
- return checkCampaignNowInTimeframe(c);
4142
+ };
4143
+ const textBlocks = JSON.parse(extraFields.textBlocks);
4144
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
4145
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
4146
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
4147
+ const currentPath = location.pathname;
4148
+ const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
4149
+ const { align: titleAlign } = textBlocks.titleBlock.data || {};
4150
+ const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
4151
+ const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
4152
+ const isLightBox = currentLayout.includes('LightBox');
4153
+ const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
4154
+ const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
4155
+ const isInline = currentLayout.includes('Inline');
4156
+ const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
4157
+ const isInPage = isInline || isSidebar;
4158
+ const isDrawer = isLightBoxB && isMobile;
4159
+ const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
4160
+ const hasForm = isLightBoxA
4161
+ ? listBlockAdded.some((item) => LEADGEN_BLOCK_INPUT.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
4162
+ : true;
4163
+ const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
4164
+ const showHeader = !!imageMobile || !!imageDesktop;
4165
+ const onlyHeader = !title && !description;
4166
+ const showButtonClose = !isInline;
4167
+ if (window.innerWidth < 769 &&
4168
+ LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
4169
+ console.log('😎 Not show fullscreen, slider on mobile ');
4170
+ return null;
3042
4171
  }
3043
- return false;
3044
- };
3045
- const fillterApprearanceTimeCampaign = (c) => {
3046
- var _a;
3047
- try {
3048
- const isTimeInRange = (currentTime, startTime, endTime) => {
3049
- const startParts = startTime.split(':');
3050
- const endParts = endTime.split(':');
3051
- const startDate = new Date();
3052
- startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
3053
- const endDate = new Date();
3054
- endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
3055
- return currentTime >= startDate && currentTime <= endDate;
3056
- };
3057
- const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
3058
- const startTime = rulesApprValue.startTime;
3059
- const endTime = rulesApprValue.endTime || '23:59';
3060
- if (!startTime) {
3061
- return true;
4172
+ React.useEffect(() => {
4173
+ if (isLightBox || isFullscreen) {
4174
+ document.body.classList.add('noscroll');
3062
4175
  }
3063
- if (isTimeInRange(new Date(), startTime, endTime)) {
3064
- return true;
4176
+ if (!window.intlTelInputUtils) {
4177
+ require('intl-tel-input/build/js/utils');
3065
4178
  }
3066
- listCampaignNotDisplayInRangeOfTime.push(c);
3067
- return false;
3068
- }
3069
- catch (err) {
3070
- return true;
3071
- }
3072
- };
3073
- let timeoutRef = null;
3074
- let LEAD_SCROLL_EVENT = null;
3075
- function clearPassiveEvent() {
3076
- if (timeoutRef) {
3077
- clearTimeout(timeoutRef);
3078
- timeoutRef = null;
3079
- }
3080
- if (LEAD_SCROLL_EVENT) {
3081
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3082
- LEAD_SCROLL_EVENT = null;
3083
- }
3084
- }
3085
- function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
3086
- // clear previous passive event, check for new condition
3087
- clearPassiveEvent();
3088
- const leadCurrentUrl = DEBUG_URL ||
3089
- ('https://' +
3090
- location.hostname +
3091
- location.pathname +
3092
- location.search).toLowerCase();
3093
- fetch(leadApi + 'api/campaign/' + leadSiteId, {
3094
- method: 'POST',
3095
- headers: {
3096
- 'Content-Type': 'application/json',
3097
- },
3098
- body: JSON.stringify({
3099
- url: leadCurrentUrl,
3100
- ga_client_id: miscCookieHelper.getCookie('_ga') || null,
3101
- }),
3102
- })
3103
- .then((response) => {
3104
- return response.json();
3105
- // return mockLeadData || response.json()
3106
- })
3107
- .then((data) => {
3108
- var _a, _b, _c, _d;
3109
- LeadLog('List campagin: ', data);
3110
- LEAD_RESET_VAR();
3111
- if (data._status == 1) {
3112
- 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);
3113
- if (!miscCookieHelper.getCookie('hhg-id')) {
3114
- miscCookieHelper.setCookie('hhg-id', uuid.v1(), {
3115
- domain: '.' + leadDomain,
3116
- path: '/',
3117
- });
3118
- LeadLog('😍 Set HHG ID cookie');
3119
- }
3120
- // getCookie('hhg-id')
3121
- // TODO: HP-534 Filter desktop
3122
- let campaignsDevice = [];
3123
- if (isMobile()) {
3124
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
3125
- }
3126
- else {
3127
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
3128
- }
3129
- LeadLog(`👓 campaignsDevice`, campaignsDevice);
3130
- LeadLog('--listCampaignScheduled', listCampaignScheduled);
3131
- LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
3132
- LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
3133
- LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
3134
- LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
3135
- LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
3136
- // Check links
3137
- let listLinksObj = campaignsDevice
3138
- .map((i, index) => i.targets
3139
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
3140
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3141
- .flat(1);
3142
- // Check list link match current href
3143
- listLinksObj = listLinksObj.filter((i) => {
3144
- var _a;
3145
- const target = new URL(String(i.target).toLowerCase());
3146
- if (i.option == 'exact_match')
3147
- // FOR TEST LOCAL:
3148
- // return Boolean(location.pathname === target.pathname)
3149
- return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
3150
- if (i.option == 'start_with') {
3151
- // FOR TEST LOCAL:
3152
- // if (location.pathname.includes(target.pathname)) {
3153
- if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
3154
- const listExcluding = i.sub_target
3155
- .filter((i) => i.option == 'excluding')
3156
- .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
3157
- return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
3158
- }
3159
- else {
3160
- return false;
3161
- }
3162
- }
3163
- });
3164
- // Check tags
3165
- const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
3166
- const listTags = listMetaTag.map((i) => i.content);
3167
- let listCampaignHasTag = [];
3168
- let listTagsObj = [];
3169
- if (listTags && listTags.length) {
3170
- listCampaignHasTag = campaignsDevice
3171
- .map((i, index) => i.targets
3172
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
3173
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3174
- .flat(1);
3175
- listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
3176
- }
3177
- const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
3178
- const cookieKeys = document.cookie
3179
- .split('; ')
3180
- .map((i) => i.split('=')[0]);
3181
- const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
3182
- LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
3183
- const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
3184
- LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
3185
- const listCampaignSubmitedClosed = [
3186
- ...listCampaignCodeSubmited,
3187
- ...listCampaignCodeClosed,
3188
- ];
3189
- const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
3190
- const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
3191
- return !hasSubmited;
3192
- });
3193
- const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
3194
- // .sort(
3195
- // (a, b) =>
3196
- // (listCampaignValid[a.campaignIndex]?.score || 0) -
3197
- // (listCampaignValid[b.campaignIndex]?.score || 0),
3198
- // )
3199
- LeadLog('--listCampaignValid : ', listCampaignValid);
3200
- if (listCampaignValid && listCampaignValid.length) {
3201
- const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
3202
- LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
3203
- const { rules } = CAMPAIGN_SHOW;
3204
- // CHECK RULE TRIGGER POPUP
3205
- const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
3206
- LeadLog(`timeoutRule`, timeoutRule);
3207
- const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
3208
- LeadLog(`scrollRule`, scrollRule);
3209
- let impressionAction = 'TIME';
3210
- if (Number.isInteger(timeoutRule)) {
3211
- impressionAction = 'TIME';
3212
- LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
3213
- timeoutRef = setTimeout(() => {
3214
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3215
- }, timeoutRule * 1000);
4179
+ clearCacheUsedEmailOrPhone();
4180
+ }, []);
4181
+ const validatingPhoneRef = React.useRef(false);
4182
+ const validatingEmailRef = React.useRef(false);
4183
+ const { form, validateObj } = useLeadFormConfig({
4184
+ listBlockAdded,
4185
+ validatingPhoneRef,
4186
+ validatingEmailRef,
4187
+ campaignId,
4188
+ campaign_subot_id,
4189
+ userInfo,
4190
+ format: (_a = (index$7.ISO_FORMAT[locale] || index$7.ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
4191
+ });
4192
+ const onFocus = (e) => {
4193
+ const target = e.target;
4194
+ target.scrollIntoView({
4195
+ block: 'center',
4196
+ inline: 'nearest',
4197
+ behavior: 'auto',
4198
+ });
4199
+ };
4200
+ const middlewareOnSubmit = (e) => {
4201
+ e.preventDefault();
4202
+ // mark all as touched to allow validation
4203
+ const fields = Object.keys(validateObj);
4204
+ const fieldStatus = fields.reduce((acc, cur) => {
4205
+ acc[cur] = true;
4206
+ return acc;
4207
+ }, {});
4208
+ form.setTouched(fieldStatus);
4209
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
4210
+ return;
4211
+ }
4212
+ setTimeout(() => {
4213
+ form.onSubmit((v) => {
4214
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4215
+ if (Object.keys(form.errors).length)
4216
+ return;
4217
+ let newShowOtpPhone = null;
4218
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
4219
+ // not submit yet, open otp
4220
+ 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;
4221
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
4222
+ newShowOtpPhone = {
4223
+ phone: v[fieldName],
4224
+ type: 'phone',
4225
+ };
4226
+ }
3216
4227
  }
3217
- if (Number.isInteger(scrollRule)) {
3218
- impressionAction = 'SCROLL';
3219
- LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
3220
- const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
3221
- document.querySelector('body');
3222
- const pct = $p.getBoundingClientRect().top;
3223
- const pb = $p.offsetHeight;
3224
- LeadLog(`👓 Element check scroll: `, $p);
3225
- LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
3226
- const wt = window.pageYOffset || document.documentElement.scrollTop;
3227
- let percent = 0;
3228
- if (wt >= pct) {
3229
- percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
3230
- }
3231
- LeadLog('---Scroll', percent, scrollRule);
3232
- // TODO: CHECK FOOTER HEIGHT
3233
- if (percent >= scrollRule) {
3234
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3235
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
4228
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
4229
+ // not submit yet, open otp
4230
+ 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;
4231
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
4232
+ newShowOtpPhone = {
4233
+ phone: v[fieldName],
4234
+ type: 'whatsapp',
4235
+ };
4236
+ }
4237
+ }
4238
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
4239
+ // not submit yet, open otp
4240
+ 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;
4241
+ if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
4242
+ newShowOtpPhone = {
4243
+ phone: v[fieldName],
4244
+ type: 'zalo',
4245
+ };
4246
+ }
4247
+ }
4248
+ if (newShowOtpPhone) {
4249
+ setIsSubmitLoading(true);
4250
+ Service.sendSMSOtpLead(newShowOtpPhone)
4251
+ .then((res) => {
4252
+ var _a;
4253
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4254
+ if (respMessage === 'This phone number was verified') {
4255
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4256
+ return;
3236
4257
  }
3237
- };
3238
- window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
3239
- passive: true,
4258
+ setShowOtpPhone(newShowOtpPhone);
4259
+ })
4260
+ .finally(() => {
4261
+ setIsSubmitLoading(false);
3240
4262
  });
4263
+ return;
3241
4264
  }
3242
- }
3243
- else {
3244
- LeadLog('🚧 No lead campaigns on current URL, tags');
3245
- }
4265
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4266
+ })(e);
4267
+ }, 100);
4268
+ };
4269
+ const onOpenChange = (_open) => {
4270
+ setOpen(_open);
4271
+ if (!_open) {
4272
+ setTimeout(() => {
4273
+ onClose();
4274
+ }, 250);
3246
4275
  }
3247
- })
3248
- .catch((err) => {
3249
- LeadLog(`Lead error: `, err);
4276
+ };
4277
+ const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
4278
+ const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
4279
+ const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
4280
+ const renderAfterImageSizes = imageMobileLoaded &&
4281
+ imageDesktopLoaded &&
4282
+ (isFullscreen ? imageBackgroundLoaded : true);
4283
+ const ButtonSubmit = React.useMemo(() => {
4284
+ var _a;
4285
+ return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default["default"].createElement(core.Button, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
4286
+ }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
4287
+ const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
4288
+ const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default["default"].createElement(React__default["default"].Fragment, null, LinkButtonBlock.map((item, index) => {
4289
+ var _a, _b, _c;
4290
+ return (React__default["default"].createElement(core.Button, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
4291
+ onClose === null || onClose === void 0 ? void 0 : onClose();
4292
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
4293
+ } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
4294
+ })));
4295
+ const PopupHeader = showHeader && (React__default["default"].createElement("header", { className: core.clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default["default"].createElement(React__default["default"].Fragment, null,
4296
+ React__default["default"].createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
4297
+ React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
4298
+ const PopupEmpty = showEmpty && (React__default["default"].createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
4299
+ const PopupForm = (React__default["default"].createElement(LeadFormProvider, { form: form },
4300
+ React__default["default"].createElement("form", { ref: formRef, className: "leadgen-form", onFocus: onFocus, onSubmit: middlewareOnSubmit },
4301
+ React__default["default"].createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
4302
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4303
+ React__default["default"].createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
4304
+ const PopupOtp = showOtpPhone && (React__default["default"].createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
4305
+ setShowOtpPhone(null);
4306
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
4307
+ } }));
4308
+ const PopupThankYou = showThankyou && (React__default["default"].createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
4309
+ const PopupContent = (React__default["default"].createElement("div", { className: core.clsx('leadgen-content', {
4310
+ 'leadgen-content_small': limitFieldsLightBoxB,
4311
+ }) },
4312
+ !headerInsideFormContainer && PopupHeader,
4313
+ !onlyHeader && (React__default["default"].createElement("div", { className: "leadgen-inner" },
4314
+ PopupThankYou,
4315
+ !showThankyou && (React__default["default"].createElement(React__default["default"].Fragment, null,
4316
+ PopupOtp,
4317
+ PopupEmpty,
4318
+ !(showOtpPhone || showEmpty) && PopupForm))))));
4319
+ const styleOverlay = React.useMemo(() => {
4320
+ let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
4321
+ if (isMobile && imageOverlayMobile) {
4322
+ styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4323
+ }
4324
+ if (!isMobile && imageOverlayDesktop) {
4325
+ styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4326
+ }
4327
+ return styleContent;
4328
+ }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
4329
+ const PopupWrapper = (React__default["default"].createElement(React__default["default"].Fragment, null,
4330
+ React__default["default"].createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
4331
+ React__default["default"].createElement("div", { className: core.clsx('leadgen-wrapper', {
4332
+ 'leadgen-wrapper_small': limitFieldsLightBoxB,
4333
+ }) },
4334
+ showButtonClose && (React__default["default"].createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
4335
+ PopupContent)));
4336
+ const popupContainerClassName = core.clsx('leadgen', `leadgen-${currentLayout}`, {
4337
+ 'leadgen-lightbox': isLightBox,
4338
+ 'leadgen-inline': isInPage,
4339
+ 'leadgen-slider': isSlider,
3250
4340
  });
3251
- }
3252
- const LeadLog = (...params) => {
3253
- if (process.env.NODE_ENV !== 'production' ||
3254
- (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
3255
- process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
3256
- (typeof localStorage !== 'undefined' &&
3257
- localStorage.getItem('hhg_debug') === 'true')) {
3258
- console.log(...params);
4341
+ const PopupContainer = isDrawer ? (React__default["default"].createElement(index$b.DrawerComponent, { fadeFromIndex: index$7.ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
4342
+ PopupWrapper,
4343
+ React__default["default"].createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default["default"].createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
4344
+ isFullscreen ? (React__default["default"].createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
4345
+ aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
4346
+ } })) : null,
4347
+ PopupWrapper));
4348
+ if (!renderAfterImageSizes)
4349
+ return null;
4350
+ if (isLightBox || isFullscreen || isSlider) {
4351
+ return PopupContainer;
4352
+ }
4353
+ else if (isSidebar) {
4354
+ return React__default["default"].createElement(SideBarLayout, { content: PopupContainer });
3259
4355
  }
4356
+ else if (isInline) {
4357
+ return (React__default["default"].createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
4358
+ }
4359
+ return null;
4360
+ };
4361
+
4362
+ const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
4363
+ const currentPath = location.pathname;
4364
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
4365
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
4366
+ if (!imageMobileLoaded || !imageDesktopLoaded)
4367
+ return null;
4368
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
4369
+ currentLayout == 'SkinA' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4370
+ React__default["default"].createElement("div", { className: "le-skin-a-desktop" },
4371
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
4372
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
4373
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4374
+ } }),
4375
+ React__default["default"].createElement("a", { style: {
4376
+ position: 'absolute',
4377
+ top: '75%',
4378
+ left: '50%',
4379
+ transform: 'translate(-50%, -50%)',
4380
+ textAlign: 'center',
4381
+ width: 'calc(100% - 15px)',
4382
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4383
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
4384
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4385
+ React__default["default"].createElement("div", { className: "" },
4386
+ React__default["default"].createElement("div", { style: { position: 'relative', zIndex: 10000 } },
4387
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
4388
+ width: '100%',
4389
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4390
+ } }),
4391
+ React__default["default"].createElement("a", { style: {
4392
+ position: 'absolute',
4393
+ top: '75%',
4394
+ left: '50%',
4395
+ transform: 'translate(-50%, -50%)',
4396
+ textAlign: 'center',
4397
+ width: '100%',
4398
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4399
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4400
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
4401
+ React__default["default"].createElement("aside", { className: "le-only-mobile" },
4402
+ React__default["default"].createElement("div", { className: "le-skin-mobile" },
4403
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
4404
+ index$8.isVideo(imageMobile) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true },
4405
+ React__default["default"].createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default["default"].createElement("img", { src: imageMobile, style: {
4406
+ width: '100%',
4407
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
4408
+ } })),
4409
+ React__default["default"].createElement("a", { style: {
4410
+ position: 'absolute',
4411
+ top: '82%',
4412
+ left: '50%',
4413
+ transform: 'translate(-50%, -50%)',
4414
+ textAlign: 'center',
4415
+ maxWidth: 'calc(100% - 15px)',
4416
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4417
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4418
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4419
+ };
4420
+
4421
+ // url: imageBlocks.imageMobile.data.url
4422
+ // newTab: imageBlocks.imageMobile.data.newtab
4423
+ // image: campaignShow.image
4424
+ // imageDestkop: campaignShow.image_desktop
4425
+ const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
4426
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
4427
+ if (!imageLoaded)
4428
+ return null;
4429
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
4430
+ React__default["default"].createElement("div", { className: "le-tab-popup" },
4431
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
4432
+ React__default["default"].createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
4433
+ React__default["default"].createElement("img", { className: "js-popup-other-submit", src: image, style: {
4434
+ aspectRatio: `${imageWidth}/${imageHeight}`,
4435
+ } })),
4436
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3260
4437
  };
3261
4438
 
3262
4439
  function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
@@ -3272,7 +4449,7 @@ function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
3272
4449
  }
3273
4450
  const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, showEmpty, setShowEmpty, userInfo, }) => {
3274
4451
  var _a, _b;
3275
- const { apiUrl, siteDomain } = React.useContext(LeadGenContext);
4452
+ const { apiUrl, siteDomain } = React.useContext(LeadGenContext$1);
3276
4453
  React.useEffect(() => {
3277
4454
  const gaCookie = miscCookieHelper.getCookie('_ga') || null;
3278
4455
  fetch(`${apiUrl}api/campaign/${code}/impression`, {
@@ -3667,7 +4844,7 @@ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, primaryColor
3667
4844
  leadStartTimeRef.current = Date.now();
3668
4845
  }
3669
4846
  }, [showCampaign]);
3670
- return (React__default["default"].createElement(LeadGenContext.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
4847
+ return (React__default["default"].createElement(LeadGenContext$1.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
3671
4848
  React__default["default"].createElement(translationsContext.TranslationsContext.Provider, { value: { locale, values: getTranslations(locale) } }, children ? (React__default["default"].createElement(Component, { campaign: showCampaign, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, setShowThankyou: setShowThankyou, locale: locale, showEmpty: showEmpty, setShowEmpty: setShowEmpty, userInfo: userInfo }, children)) : (React__default["default"].createElement(core.Portal, { target: utils$1.getPopupWrapperDom() },
3672
4849
  React__default["default"].createElement(core.Box, { sx: { position: 'fixed', zIndex: index$7.ZINDEX_SSO - 9e6 } },
3673
4850
  React__default["default"].createElement(core.Transition, { mounted: Boolean(((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1'), transition: "fade", duration: 600, timingFunction: "ease" }, (styles) => {
@@ -3688,3 +4865,4 @@ LeadGen.OtpForm = OtpBlock$1;
3688
4865
  LeadGen.Close = Close.Close;
3689
4866
 
3690
4867
  exports.LeadGen = LeadGen;
4868
+ exports.LeadGenSubscriptionBox = LeadGenSubscriptionBox;