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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (541) hide show
  1. package/build/{InputDate-8b579da2.js → InputDate-4d0f8f62.js} +3 -3
  2. package/build/{LastPeriod-64e1601a.js → LastPeriod-e7875ff0.js} +1 -1
  3. package/build/{Locale-72dce976.js → Locale-5cb9776e.js} +1 -0
  4. package/build/{MobileBottomNavigationIcon-d51ca59a.js → MobileBottomNavigationIcon-ade55d98.js} +3 -3
  5. package/build/{Spinner-883e6f71.js → Spinner-9eaad3bc.js} +1 -1
  6. package/build/{WhatsApp-52413156.js → WhatsApp-4736d161.js} +1 -1
  7. package/build/adapters.js +19 -19
  8. package/build/atoms.js +48 -48
  9. package/build/babyGrowth.js +83 -83
  10. package/build/cache.js +2 -2
  11. package/build/care.js +17 -17
  12. package/build/careBookingSearchBar.js +14 -14
  13. package/build/careBookingSearchBarV2.js +15 -15
  14. package/build/components/atoms/logo/index.d.ts +1 -1
  15. package/build/components/mantine/phone/index.d.ts +2 -0
  16. package/build/components/mantine/phoneInput/PhoneInput.d.ts +17 -0
  17. package/build/components/mantine/phoneInput/index.d.ts +1 -0
  18. package/build/components.js +97 -96
  19. package/build/{constants-4fc45016.js → constants-10fdc66a.js} +1 -1
  20. package/build/{constants-171f25c7.js → constants-df1ac0c9.js} +1 -0
  21. package/build/constants.js +3 -3
  22. package/build/constantsDomainLocales.js +3 -1
  23. package/build/constantsRiskScreener.js +2 -2
  24. package/build/constantsSite.js +2 -2
  25. package/build/{core-49c30866.js → core-2193730e.js} +1 -1
  26. package/build/{dataTransform-9fcb6f21.js → dataTransform-0bc28b35.js} +1 -1
  27. package/build/ecom.js +4 -4
  28. package/build/{editor-f38876f9.js → editor-d43056a7.js} +11 -11
  29. package/build/embeddedHeathToolCards_babyGrowth.js +23 -23
  30. package/build/embeddedHeathToolCards_babyPoop.js +19 -19
  31. package/build/embeddedHeathToolCards_babyVaccine.js +22 -22
  32. package/build/embeddedHeathToolCards_bmi_bmi.js +25 -25
  33. package/build/embeddedHeathToolCards_bmrBmr.js +25 -25
  34. package/build/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  35. package/build/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  36. package/build/embeddedHeathToolCards_pwg_pwg.js +26 -26
  37. package/build/embeddedHeathToolCards_targetHeartRate.js +27 -27
  38. package/build/esm/{InputDate-86cf8a56.js → InputDate-ae62bf9a.js} +3 -3
  39. package/build/esm/{LastPeriod-f7751d88.js → LastPeriod-ea3fdfc4.js} +1 -1
  40. package/build/esm/{Locale-3430abbb.js → Locale-6cbef683.js} +1 -0
  41. package/build/esm/{MobileBottomNavigationIcon-9c8475b0.js → MobileBottomNavigationIcon-8a422f2d.js} +3 -3
  42. package/build/esm/{Spinner-926cb3b3.js → Spinner-2b2ee80a.js} +1 -1
  43. package/build/esm/{WhatsApp-e29f71ae.js → WhatsApp-d9b6322d.js} +1 -1
  44. package/build/esm/adapters.js +19 -19
  45. package/build/esm/atoms.js +48 -48
  46. package/build/esm/babyGrowth.js +83 -83
  47. package/build/esm/cache.js +2 -2
  48. package/build/esm/care.js +17 -17
  49. package/build/esm/careBookingSearchBar.js +14 -14
  50. package/build/esm/careBookingSearchBarV2.js +15 -15
  51. package/build/esm/components/atoms/logo/index.d.ts +1 -1
  52. package/build/esm/components/mantine/phone/index.d.ts +2 -0
  53. package/build/esm/components/mantine/phoneInput/PhoneInput.d.ts +17 -0
  54. package/build/esm/components/mantine/phoneInput/index.d.ts +1 -0
  55. package/build/esm/components.js +97 -96
  56. package/build/esm/{constants-8772c2b0.js → constants-ca39f7c8.js} +1 -0
  57. package/build/esm/{constants-030b17c7.js → constants-e7d257f4.js} +1 -1
  58. package/build/esm/constants.js +3 -3
  59. package/build/esm/constantsDomainLocales.js +3 -1
  60. package/build/esm/constantsRiskScreener.js +2 -2
  61. package/build/esm/constantsSite.js +2 -2
  62. package/build/esm/{core-55455f88.js → core-b15c99fa.js} +1 -1
  63. package/build/esm/{dataTransform-a7848bdc.js → dataTransform-3e675b26.js} +1 -1
  64. package/build/esm/ecom.js +4 -4
  65. package/build/esm/{editor-377b7f2b.js → editor-c56c017c.js} +11 -11
  66. package/build/esm/embeddedHeathToolCards_babyGrowth.js +23 -23
  67. package/build/esm/embeddedHeathToolCards_babyPoop.js +19 -19
  68. package/build/esm/embeddedHeathToolCards_babyVaccine.js +22 -22
  69. package/build/esm/embeddedHeathToolCards_bmi_bmi.js +25 -25
  70. package/build/esm/embeddedHeathToolCards_bmrBmr.js +25 -25
  71. package/build/esm/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  72. package/build/esm/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  73. package/build/esm/embeddedHeathToolCards_pwg_pwg.js +26 -26
  74. package/build/esm/embeddedHeathToolCards_targetHeartRate.js +27 -27
  75. package/build/esm/footer.js +21 -21
  76. package/build/esm/gAssets.js +2 -2
  77. package/build/esm/{healthTools-6ff083fc.js → healthTools-ff0d83ac.js} +1 -1
  78. package/build/esm/healthToolsCardWrapper.js +18 -18
  79. package/build/esm/healthToolsForm.js +33 -33
  80. package/build/esm/hooks.js +13 -13
  81. package/build/esm/i18n-values/zh-CN.js +855 -0
  82. package/build/esm/i18n.js +14 -55
  83. package/build/esm/i18nV2.js +2 -2
  84. package/build/esm/{index-4dbdcc4c.js → index-0055a84b.js} +24 -24
  85. package/build/esm/{index-5ff6b134.js → index-1201d09e.js} +2 -2
  86. package/build/esm/{index-82254ae8.js → index-12e39e60.js} +25 -25
  87. package/build/esm/{index-bae2d2e9.js → index-1bea6ae1.js} +31 -31
  88. package/build/esm/{index-7b524555.js → index-1e9e7f75.js} +6 -6
  89. package/build/esm/index-22fd28bb.js +183 -0
  90. package/build/esm/{index-8e302f71.js → index-23178aa9.js} +1 -1
  91. package/build/esm/{index-5e9df0aa.js → index-2a2562dd.js} +2 -2
  92. package/build/esm/{index-35c4c26f.js → index-2b0b5ecd.js} +40 -3
  93. package/build/esm/{index-4f84ba27.js → index-2e3e0cff.js} +18 -18
  94. package/build/esm/{index-aa92750f.js → index-2f12dbba.js} +7 -7
  95. package/build/esm/{index-9506572a.js → index-355f9d5c.js} +10 -10
  96. package/build/esm/{index-94da713d.js → index-357625fc.js} +17 -17
  97. package/build/esm/{index-36da89a1.js → index-3c98ef91.js} +1 -1
  98. package/build/esm/{index-edae0b9e.js → index-3d39bdad.js} +2 -2
  99. package/build/esm/{index-c315fa6b.js → index-3ec677f5.js} +2 -2
  100. package/build/esm/{index-528169fe.js → index-3f48de19.js} +16 -16
  101. package/build/esm/{index-7f79d78c.js → index-3f57aae0.js} +2 -2
  102. package/build/esm/{index-130576cd.js → index-3f7de8cb.js} +16 -16
  103. package/build/esm/{index-f4607daa.js → index-3f972b22.js} +2 -2
  104. package/build/esm/{index-e1c1652c.js → index-458c4644.js} +3 -3
  105. package/build/esm/{index-782b32b4.js → index-4698117f.js} +3 -3
  106. package/build/esm/{index-f410871a.js → index-4d729cc4.js} +1 -1
  107. package/build/esm/{index-0f5789ca.js → index-51795464.js} +16 -16
  108. package/build/esm/{index-33c4c7ba.js → index-5301bfe9.js} +13 -13
  109. package/build/esm/{index-f5a27fa1.js → index-53b14dfd.js} +13 -13
  110. package/build/esm/{index-9d456ced.js → index-545016c2.js} +13 -13
  111. package/build/esm/{index-f437d7d3.js → index-5cd35f39.js} +22 -22
  112. package/build/esm/{index-c22c8c9f.js → index-6060489a.js} +15 -15
  113. package/build/esm/{index-109382ee.js → index-621525f8.js} +1 -1
  114. package/build/esm/{index-9a682965.js → index-6701be33.js} +1 -1
  115. package/build/esm/{index-395867d1.js → index-6a09ecad.js} +1 -1
  116. package/build/esm/{index-7f3a0d51.js → index-6e645ce9.js} +13 -13
  117. package/build/esm/{index-d25199d4.js → index-6ff57267.js} +1 -1
  118. package/build/esm/{index-fd64f3e1.js → index-7447d781.js} +18 -18
  119. package/build/esm/{index-8b71f3d7.js → index-77918ec2.js} +17 -17
  120. package/build/esm/{index-9688c45f.js → index-808718f9.js} +7 -7
  121. package/build/esm/{index-06d394fc.js → index-868eb4ba.js} +3 -3
  122. package/build/esm/{index-cd820271.js → index-86f3b263.js} +4 -4
  123. package/build/esm/{index-0ab75d88.js → index-8b58d4d5.js} +5 -5
  124. package/build/esm/{index-5024511e.js → index-8f74d63d.js} +2 -2
  125. package/build/esm/{index-e401fea0.js → index-97c7b8a6.js} +1 -1
  126. package/build/esm/{index-22f111d6.js → index-9cacc9f3.js} +3 -3
  127. package/build/esm/{index-3784dc8c.js → index-a34077dd.js} +17 -17
  128. package/build/esm/{index-7287f2a0.js → index-ad4f1aa3.js} +5 -5
  129. package/build/esm/{index-17e36457.js → index-ae8ebfbb.js} +8 -8
  130. package/build/esm/{index-44df64aa.js → index-b4398a57.js} +2 -2
  131. package/build/esm/{index-5d7077d8.js → index-b7689a43.js} +2 -2
  132. package/build/esm/{index-4bd46b7f.js → index-b92616e0.js} +2 -2
  133. package/build/esm/{index-6ab5e856.js → index-cd4c901f.js} +1 -1
  134. package/build/esm/{index-32060de3.js → index-d15062af.js} +16 -16
  135. package/build/esm/{index-4c29da01.js → index-d189b9de.js} +6 -6
  136. package/build/esm/{index-e93b1f65.js → index-d37dade0.js} +36 -27
  137. package/build/esm/{index-adf83539.js → index-d5f8e31e.js} +21 -21
  138. package/build/esm/{index-4cc74b63.js → index-d79430b6.js} +32 -32
  139. package/build/esm/{index-8885ef87.js → index-da65e1c5.js} +6 -6
  140. package/build/esm/{index-bfafe3e9.js → index-df2bbe3a.js} +17 -17
  141. package/build/esm/{index-2f124f3f.js → index-e3b526bc.js} +6 -6
  142. package/build/esm/{index-8c227289.js → index-e7f04418.js} +32 -32
  143. package/build/esm/{index-5131dc4f.js → index-f40333a0.js} +3 -3
  144. package/build/esm/{index-f9d0d6be.js → index-f44b1ab3.js} +6 -6
  145. package/build/esm/{index-cb2ab6ff.js → index-f80db4ef.js} +2 -2
  146. package/build/esm/{index-7f0089a7.js → index-fef08243.js} +3 -3
  147. package/build/esm/{index-7911d60e.js → index-ffb2f217.js} +2 -2
  148. package/build/esm/{index-8bc9ae7d.js → index-ffe4486b.js} +2 -2
  149. package/build/esm/index.js +118 -117
  150. package/build/esm/interfaces/constants/domainLocales.d.ts +2 -0
  151. package/build/esm/interfaces/constants/index.d.ts +1 -1
  152. package/build/esm/interfaces/types/Locale.d.ts +2 -1
  153. package/build/esm/interfaces/types/index.d.ts +2 -1
  154. package/build/esm/{labelSorting-ad695303.js → labelSorting-2570a1d0.js} +4 -4
  155. package/build/esm/lead/LeadGen.type.d.ts +34 -0
  156. package/build/esm/lead/LeadGenForm/LeadGenForm.d.ts +41 -0
  157. package/build/esm/lead/LeadGenForm/LeadGenForm.helpers.d.ts +2 -0
  158. package/build/esm/lead/LeadGenForm/LeadGenForm.styled.d.ts +5 -0
  159. package/build/esm/lead/LeadGenForm/LeadGenFormPhone.d.ts +17 -0
  160. package/build/esm/lead/LeadGenForm/LeadGenThankYou.d.ts +20 -0
  161. package/build/esm/lead/LeadGenForm/index.d.ts +3 -0
  162. package/build/esm/lead/LeadGenForm/textField/index.d.ts +13 -0
  163. package/build/esm/lead/LeadGenForm/textField/index.styled.d.ts +11 -0
  164. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +66 -0
  165. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +4 -0
  166. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +21 -0
  167. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +3 -0
  168. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +24 -0
  169. package/build/esm/lead/LeadGenSubscriptionBox/index.d.ts +1 -0
  170. package/build/esm/lead/LeadGenTranslationContext.d.ts +6 -0
  171. package/build/esm/lead/helpers.d.ts +56 -1
  172. package/build/esm/lead/index.d.ts +2 -1
  173. package/build/esm/lead/services/index.d.ts +21 -0
  174. package/build/esm/lead/store/index.d.ts +1 -0
  175. package/build/esm/lead.js +2422 -1232
  176. package/build/esm/{logoIcon-3352527f.js → logoIcon-f67d36b2.js} +8 -2
  177. package/build/esm/mantine.js +25 -25
  178. package/build/esm/misc.js +17 -17
  179. package/build/esm/miscGetDynamicHealthTool.js +4 -4
  180. package/build/esm/miscGetSocialList.js +8 -8
  181. package/build/esm/miscScreenSizeContext.js +1 -1
  182. package/build/esm/mobileBottomNavigation.js +5 -5
  183. package/build/esm/mobileBottomNavigationIcon.js +5 -5
  184. package/build/esm/molecules.js +74 -73
  185. package/build/esm/moleculesArticleCard.js +6 -6
  186. package/build/esm/moleculesArticleCardV2.js +16 -16
  187. package/build/esm/navigation.js +46 -45
  188. package/build/esm/navigationLogoutPopup.js +9 -9
  189. package/build/esm/navigationProfileButton.js +23 -23
  190. package/build/esm/onboardingV2.js +29 -29
  191. package/build/esm/organisms.js +50 -49
  192. package/build/esm/{post-062dce48.js → post-39c1933a.js} +2 -2
  193. package/build/esm/profileNavigation.js +19 -19
  194. package/build/esm/progressBar.js +1 -1
  195. package/build/esm/pwg.js +22 -22
  196. package/build/esm/ssoV2/api/featureFlag.d.ts +2 -1
  197. package/build/esm/ssoV2.js +53 -40
  198. package/build/esm/{store-0f9ab222.js → store-c6f45876.js} +6 -183
  199. package/build/esm/subot.js +36 -35
  200. package/build/esm/surveyOrPremiumBanner.js +33 -32
  201. package/build/esm/surveyQuestionCard.js +10 -10
  202. package/build/esm/{surveyThankyouCard-ba3a0601.js → surveyThankyouCard-95b3e6d6.js} +5 -5
  203. package/build/esm/together.js +56 -55
  204. package/build/esm/togetherApiUtils.js +4 -4
  205. package/build/esm/togetherAtoms.js +30 -30
  206. package/build/esm/togetherComponentGlobalContext.js +4 -4
  207. package/build/esm/togetherMolecules.js +51 -50
  208. package/build/esm/togetherMoleculesCardAuthor.js +28 -28
  209. package/build/esm/togetherMoleculesPostImagePreview.js +11 -11
  210. package/build/esm/togetherMoleculesProfileDetail.js +39 -38
  211. package/build/esm/togetherOrganisms.js +50 -49
  212. package/build/esm/togetherRichTextEditor.js +17 -17
  213. package/build/esm/togetherShareBox.js +10 -10
  214. package/build/esm/translationsProvider-2b2fc65d.js +55 -0
  215. package/build/esm/{treePopoverMenu-a6f7cfd7.js → treePopoverMenu-bc8ad7a8.js} +19 -19
  216. package/build/esm/{types-2e97f020.js → types-ce7ad19b.js} +2 -2
  217. package/build/esm/types.js +2 -2
  218. package/build/esm/{useCategory-a57e6557.js → useCategory-778152da.js} +18 -5
  219. package/build/esm/{useHealthToolCache-50ac5d7d.js → useHealthToolCache-89d26604.js} +1 -1
  220. package/build/esm/{useMantineLocale-ee478730.js → useMantineLocale-95434bd7.js} +8 -6
  221. package/build/esm/{usePlacesAutocomplete-119a12f3.js → usePlacesAutocomplete-ef8cc9c6.js} +1 -1
  222. package/build/esm/{useScreenSize-241e66fa.js → useScreenSize-bf03486c.js} +2 -2
  223. package/build/esm/useTogetherAuthRequiredAction.js +10 -9
  224. package/build/esm/{utils-5c250b28.js → utils-7e9b37e9.js} +3 -3
  225. package/build/esm/{utils-84d5275f.js → utils-b0412385.js} +2 -2
  226. package/build/esm/{utils-d81142cf.js → utils-dbac92d3.js} +5 -4
  227. package/build/esm/{utils-02789711.js → utils-dc1e800b.js} +2 -2
  228. package/build/esm/vaccination.js +21 -21
  229. package/build/footer.js +21 -21
  230. package/build/gAssets.js +2 -2
  231. package/build/{healthTools-257131be.js → healthTools-dbd21cb9.js} +1 -1
  232. package/build/healthToolsCardWrapper.js +18 -18
  233. package/build/healthToolsForm.js +33 -33
  234. package/build/hooks.js +13 -13
  235. package/build/i18n-values/zh-CN.js +866 -0
  236. package/build/i18n.js +16 -56
  237. package/build/i18nV2.js +1 -1
  238. package/build/{index-81db4a5e.js → index-09f99e88.js} +2 -2
  239. package/build/{index-23006a6f.js → index-0b5f4fea.js} +1 -1
  240. package/build/{index-8e6eaed0.js → index-0cc4df46.js} +22 -22
  241. package/build/{index-da1f328c.js → index-0da9204d.js} +16 -16
  242. package/build/{index-ff5393e0.js → index-143b9b21.js} +1 -1
  243. package/build/{index-9074450c.js → index-175d86a3.js} +3 -3
  244. package/build/{index-46713f6a.js → index-180ad656.js} +2 -2
  245. package/build/{index-f757576d.js → index-1b3be381.js} +1 -1
  246. package/build/{index-809fab5e.js → index-1fef978f.js} +2 -2
  247. package/build/index-21170172.js +196 -0
  248. package/build/{index-bfce43a1.js → index-268e9543.js} +17 -17
  249. package/build/{index-8298c7c0.js → index-320edae9.js} +2 -2
  250. package/build/{index-c4266bb2.js → index-321d92ae.js} +5 -5
  251. package/build/{index-1ac4d980.js → index-398fb7e9.js} +1 -1
  252. package/build/{index-d0fc83cb.js → index-39d41dec.js} +10 -10
  253. package/build/{index-da4de0f3.js → index-3ca5fb52.js} +13 -13
  254. package/build/{index-3484373a.js → index-41beb858.js} +6 -6
  255. package/build/{index-e0986c73.js → index-42d241a1.js} +13 -13
  256. package/build/{index-cc03a162.js → index-4754bb17.js} +6 -6
  257. package/build/{index-bab54ae7.js → index-4ce3e685.js} +1 -1
  258. package/build/{index-4c99f21d.js → index-4e3a681a.js} +3 -3
  259. package/build/{index-aad65709.js → index-515e1b21.js} +13 -13
  260. package/build/{index-b043d722.js → index-52daa9b7.js} +2 -2
  261. package/build/{index-d5392642.js → index-58d10dfd.js} +2 -2
  262. package/build/{index-ca0ff3c8.js → index-5e51751d.js} +13 -13
  263. package/build/{index-f30c6c68.js → index-6ef47de2.js} +17 -17
  264. package/build/{index-31c0299e.js → index-752ff392.js} +6 -6
  265. package/build/{index-9e639be2.js → index-7ae2e6e6.js} +1 -1
  266. package/build/{index-e0b64996.js → index-7af24e7a.js} +16 -16
  267. package/build/{index-d0a87c80.js → index-7b16516e.js} +1 -1
  268. package/build/{index-c1e14fd6.js → index-7c0ef7f6.js} +24 -24
  269. package/build/{index-09ddce9c.js → index-7ef2b805.js} +21 -21
  270. package/build/{index-467dfe87.js → index-861e8221.js} +1 -1
  271. package/build/{index-f8156707.js → index-86f0bdb5.js} +6 -6
  272. package/build/{index-2d635a20.js → index-87737063.js} +2 -2
  273. package/build/{index-7e3fcc69.js → index-8bdf02cd.js} +6 -6
  274. package/build/{index-78dac42f.js → index-901c1b9b.js} +36 -27
  275. package/build/{index-02e6761f.js → index-94a1298e.js} +25 -25
  276. package/build/{index-6f08804a.js → index-961dede4.js} +2 -2
  277. package/build/{index-41529ab9.js → index-9f1cd383.js} +3 -3
  278. package/build/{index-5671b247.js → index-a8695abe.js} +8 -8
  279. package/build/{index-d0da1009.js → index-ae65f00b.js} +2 -2
  280. package/build/{index-e7f3329c.js → index-b0d2b32a.js} +31 -31
  281. package/build/{index-2fc43b51.js → index-b7e2e558.js} +16 -16
  282. package/build/{index-815de854.js → index-ba06accd.js} +32 -32
  283. package/build/{index-2a96defb.js → index-c206af9c.js} +5 -5
  284. package/build/{index-9164c2ee.js → index-c69ad216.js} +3 -3
  285. package/build/{index-c3b2d3a2.js → index-c7a7dac2.js} +4 -4
  286. package/build/{index-8b1dc163.js → index-ca9e1748.js} +16 -16
  287. package/build/{index-dec3d9e5.js → index-d450263c.js} +18 -18
  288. package/build/{index-df8845e8.js → index-d99ee36c.js} +39 -2
  289. package/build/{index-a8c0fe3b.js → index-db4af610.js} +18 -18
  290. package/build/{index-0186561a.js → index-df09b828.js} +2 -2
  291. package/build/{index-e25c397c.js → index-e131b4fe.js} +3 -3
  292. package/build/{index-1c320bad.js → index-e3836fc5.js} +32 -32
  293. package/build/{index-1c3321c1.js → index-e6c8f5c7.js} +17 -17
  294. package/build/{index-5e7301a8.js → index-e73b9a01.js} +15 -15
  295. package/build/{index-b99eceae.js → index-eb7725c0.js} +1 -1
  296. package/build/{index-2edc6f4f.js → index-ecda6b9f.js} +2 -2
  297. package/build/{index-7e9b8b61.js → index-ece70484.js} +7 -7
  298. package/build/{index-d86255ae.js → index-f019a542.js} +7 -7
  299. package/build/{index-582068c8.js → index-f40878d1.js} +2 -2
  300. package/build/{index-4026f890.js → index-f79913e1.js} +2 -2
  301. package/build/{index-b3a4afc0.js → index-f8357dc8.js} +3 -3
  302. package/build/{index-de274432.js → index-f948b9c8.js} +17 -17
  303. package/build/index.js +118 -117
  304. package/build/interfaces/constants/domainLocales.d.ts +2 -0
  305. package/build/interfaces/constants/index.d.ts +1 -1
  306. package/build/interfaces/types/Locale.d.ts +2 -1
  307. package/build/interfaces/types/index.d.ts +2 -1
  308. package/build/{labelSorting-f5b88779.js → labelSorting-fb34ff85.js} +4 -4
  309. package/build/lead/LeadGen.type.d.ts +34 -0
  310. package/build/lead/LeadGenForm/LeadGenForm.d.ts +41 -0
  311. package/build/lead/LeadGenForm/LeadGenForm.helpers.d.ts +2 -0
  312. package/build/lead/LeadGenForm/LeadGenForm.styled.d.ts +5 -0
  313. package/build/lead/LeadGenForm/LeadGenFormPhone.d.ts +17 -0
  314. package/build/lead/LeadGenForm/LeadGenThankYou.d.ts +20 -0
  315. package/build/lead/LeadGenForm/index.d.ts +3 -0
  316. package/build/lead/LeadGenForm/textField/index.d.ts +13 -0
  317. package/build/lead/LeadGenForm/textField/index.styled.d.ts +11 -0
  318. package/build/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +66 -0
  319. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +4 -0
  320. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +21 -0
  321. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +3 -0
  322. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +24 -0
  323. package/build/lead/LeadGenSubscriptionBox/index.d.ts +1 -0
  324. package/build/lead/LeadGenTranslationContext.d.ts +6 -0
  325. package/build/lead/helpers.d.ts +56 -1
  326. package/build/lead/index.d.ts +2 -1
  327. package/build/lead/services/index.d.ts +21 -0
  328. package/build/lead/store/index.d.ts +1 -0
  329. package/build/lead.js +2460 -1269
  330. package/build/{logoIcon-d87f0c7c.js → logoIcon-9592951c.js} +8 -2
  331. package/build/mantine.js +22 -22
  332. package/build/misc.js +17 -17
  333. package/build/miscGetDynamicHealthTool.js +4 -4
  334. package/build/miscGetSocialList.js +8 -8
  335. package/build/miscScreenSizeContext.js +1 -1
  336. package/build/mobileBottomNavigation.js +5 -5
  337. package/build/mobileBottomNavigationIcon.js +5 -5
  338. package/build/molecules.js +74 -73
  339. package/build/moleculesArticleCard.js +6 -6
  340. package/build/moleculesArticleCardV2.js +16 -16
  341. package/build/navigation.js +46 -45
  342. package/build/navigationLogoutPopup.js +9 -9
  343. package/build/navigationProfileButton.js +23 -23
  344. package/build/onboardingV2.js +28 -28
  345. package/build/organisms.js +50 -49
  346. package/build/{post-7ad0e276.js → post-0096ba19.js} +2 -2
  347. package/build/profileNavigation.js +19 -19
  348. package/build/progressBar.js +1 -1
  349. package/build/pwg.js +22 -22
  350. package/build/ssoV2/api/featureFlag.d.ts +2 -1
  351. package/build/ssoV2.js +130 -117
  352. package/build/{store-ff958ae7.js → store-536d12ea.js} +8 -196
  353. package/build/subot.js +35 -34
  354. package/build/surveyOrPremiumBanner.js +33 -32
  355. package/build/surveyQuestionCard.js +10 -10
  356. package/build/{surveyThankyouCard-e8976fd5.js → surveyThankyouCard-7a4bcbec.js} +5 -5
  357. package/build/together.js +56 -55
  358. package/build/togetherApiUtils.js +4 -4
  359. package/build/togetherAtoms.js +30 -30
  360. package/build/togetherComponentGlobalContext.js +4 -4
  361. package/build/togetherMolecules.js +51 -50
  362. package/build/togetherMoleculesCardAuthor.js +28 -28
  363. package/build/togetherMoleculesPostImagePreview.js +11 -11
  364. package/build/togetherMoleculesProfileDetail.js +39 -38
  365. package/build/togetherOrganisms.js +50 -49
  366. package/build/togetherRichTextEditor.js +17 -17
  367. package/build/togetherShareBox.js +10 -10
  368. package/build/translationsProvider-6a0b5b3b.js +62 -0
  369. package/build/{treePopoverMenu-11d8a3c3.js → treePopoverMenu-7c10e82c.js} +19 -19
  370. package/build/{types-da86b25c.js → types-32489690.js} +2 -2
  371. package/build/types.js +2 -2
  372. package/build/{useCategory-8a7dc9fd.js → useCategory-e89e6d2f.js} +18 -5
  373. package/build/{useHealthToolCache-0d055a47.js → useHealthToolCache-480349f8.js} +1 -1
  374. package/build/{useMantineLocale-a330a7e5.js → useMantineLocale-ec6670dc.js} +8 -6
  375. package/build/{usePlacesAutocomplete-14098979.js → usePlacesAutocomplete-67b69bd8.js} +1 -1
  376. package/build/{useScreenSize-2eae68ef.js → useScreenSize-bfdacbfe.js} +2 -2
  377. package/build/useTogetherAuthRequiredAction.js +10 -9
  378. package/build/{utils-c88507b9.js → utils-0c9e01bc.js} +2 -2
  379. package/build/{utils-d104096a.js → utils-93e6845b.js} +9 -8
  380. package/build/{utils-7d98be3c.js → utils-be46cc9c.js} +2 -2
  381. package/build/{utils-192df9f4.js → utils-d08246c9.js} +3 -3
  382. package/build/vaccination.js +21 -21
  383. package/package.json +3 -3
  384. /package/build/{BMI_BOYS.percentile.monthly-179a50b1.js → BMI_BOYS.percentile.monthly-78637892.js} +0 -0
  385. /package/build/{BMI_BOYS.percentile.weekly-6e48af31.js → BMI_BOYS.percentile.weekly-b1c1f60d.js} +0 -0
  386. /package/build/{BMI_BOYS.percentile.yearly-4580e832.js → BMI_BOYS.percentile.yearly-01491d63.js} +0 -0
  387. /package/build/{BMI_BOYS.zscore.monthly-b7606779.js → BMI_BOYS.zscore.monthly-1699c10d.js} +0 -0
  388. /package/build/{BMI_BOYS.zscore.weekly-172fbecd.js → BMI_BOYS.zscore.weekly-aa0799e5.js} +0 -0
  389. /package/build/{BMI_BOYS.zscore.yearly-34a8f9cd.js → BMI_BOYS.zscore.yearly-6595bd1e.js} +0 -0
  390. /package/build/{BMI_GIRLS.percentile.monthly-5b16a621.js → BMI_GIRLS.percentile.monthly-9adfabf8.js} +0 -0
  391. /package/build/{BMI_GIRLS.percentile.weekly-a13bf779.js → BMI_GIRLS.percentile.weekly-5347c8de.js} +0 -0
  392. /package/build/{BMI_GIRLS.percentile.yearly-13973462.js → BMI_GIRLS.percentile.yearly-a5a864a9.js} +0 -0
  393. /package/build/{BMI_GIRLS.zscore.monthly-204e3d84.js → BMI_GIRLS.zscore.monthly-0351ab0c.js} +0 -0
  394. /package/build/{BMI_GIRLS.zscore.weekly-6fdd2c6a.js → BMI_GIRLS.zscore.weekly-fbe99176.js} +0 -0
  395. /package/build/{BMI_GIRLS.zscore.yearly-1cca63a0.js → BMI_GIRLS.zscore.yearly-de7359f0.js} +0 -0
  396. /package/build/{ChevronDown-666ab37d.js → ChevronDown-b3053e28.js} +0 -0
  397. /package/build/{Close-1b6e6466.js → Close-2bfa4de9.js} +0 -0
  398. /package/build/{Google-255c0f1a.js → Google-a87d9a0a.js} +0 -0
  399. /package/build/{HEAD CIRCUM_BOYS.percentile.monthly-27b74016.js → HEAD CIRCUM_BOYS.percentile.monthly-fcfa2287.js} +0 -0
  400. /package/build/{HEAD CIRCUM_BOYS.percentile.weekly-44d2ee86.js → HEAD CIRCUM_BOYS.percentile.weekly-4748fbba.js} +0 -0
  401. /package/build/{HEAD CIRCUM_BOYS.percentile.yearly-8da7f001.js → HEAD CIRCUM_BOYS.percentile.yearly-26b87f29.js} +0 -0
  402. /package/build/{HEAD CIRCUM_BOYS.zscore.monthly-61e5db90.js → HEAD CIRCUM_BOYS.zscore.monthly-d51081cd.js} +0 -0
  403. /package/build/{HEAD CIRCUM_BOYS.zscore.weekly-25d8b075.js → HEAD CIRCUM_BOYS.zscore.weekly-2c7c8d43.js} +0 -0
  404. /package/build/{HEAD CIRCUM_BOYS.zscore.yearly-1e6e1e4e.js → HEAD CIRCUM_BOYS.zscore.yearly-59038af9.js} +0 -0
  405. /package/build/{HEAD CIRCUM_GIRLS.percentile.monthly-bdd4a98b.js → HEAD CIRCUM_GIRLS.percentile.monthly-b3854633.js} +0 -0
  406. /package/build/{HEAD CIRCUM_GIRLS.percentile.weekly-c22eafb0.js → HEAD CIRCUM_GIRLS.percentile.weekly-da3cd667.js} +0 -0
  407. /package/build/{HEAD CIRCUM_GIRLS.percentile.yearly-e63f3462.js → HEAD CIRCUM_GIRLS.percentile.yearly-5ce86b08.js} +0 -0
  408. /package/build/{HEAD CIRCUM_GIRLS.zscore.monthly-ba864f1d.js → HEAD CIRCUM_GIRLS.zscore.monthly-752848a2.js} +0 -0
  409. /package/build/{HEAD CIRCUM_GIRLS.zscore.weekly-0ab88ce6.js → HEAD CIRCUM_GIRLS.zscore.weekly-d09f39b2.js} +0 -0
  410. /package/build/{HEAD CIRCUM_GIRLS.zscore.yearly-5f6cd980.js → HEAD CIRCUM_GIRLS.zscore.yearly-6e6ca083.js} +0 -0
  411. /package/build/{HEIGHT_BOYS.percentile.monthly-de94349f.js → HEIGHT_BOYS.percentile.monthly-8d7369e7.js} +0 -0
  412. /package/build/{HEIGHT_BOYS.percentile.weekly-0deb1e2e.js → HEIGHT_BOYS.percentile.weekly-f90e07a6.js} +0 -0
  413. /package/build/{HEIGHT_BOYS.percentile.yearly-de56c11c.js → HEIGHT_BOYS.percentile.yearly-06b42d06.js} +0 -0
  414. /package/build/{HEIGHT_BOYS.zscore.monthly-2ec7ba91.js → HEIGHT_BOYS.zscore.monthly-afe33d38.js} +0 -0
  415. /package/build/{HEIGHT_BOYS.zscore.weekly-ca549a20.js → HEIGHT_BOYS.zscore.weekly-41071729.js} +0 -0
  416. /package/build/{HEIGHT_BOYS.zscore.yearly-1a550c19.js → HEIGHT_BOYS.zscore.yearly-664e98c3.js} +0 -0
  417. /package/build/{HEIGHT_GIRLS.percentile.monthly-4ed4b34f.js → HEIGHT_GIRLS.percentile.monthly-b62d1af0.js} +0 -0
  418. /package/build/{HEIGHT_GIRLS.percentile.weekly-8e84201b.js → HEIGHT_GIRLS.percentile.weekly-14c524e0.js} +0 -0
  419. /package/build/{HEIGHT_GIRLS.percentile.yearly-ae554a2e.js → HEIGHT_GIRLS.percentile.yearly-5b4de05e.js} +0 -0
  420. /package/build/{HEIGHT_GIRLS.zscore.monthly-e39acd9f.js → HEIGHT_GIRLS.zscore.monthly-2d9a5528.js} +0 -0
  421. /package/build/{HEIGHT_GIRLS.zscore.weekly-c1ac2f72.js → HEIGHT_GIRLS.zscore.weekly-ac9cdb3b.js} +0 -0
  422. /package/build/{HEIGHT_GIRLS.zscore.yearly-e60e8414.js → HEIGHT_GIRLS.zscore.yearly-fdbc990a.js} +0 -0
  423. /package/build/{Visible-3c7c545a.js → Visible-20d01c26.js} +0 -0
  424. /package/build/{WEIGHT_BOYS.percentile.monthly-7907d7d8.js → WEIGHT_BOYS.percentile.monthly-08000cbd.js} +0 -0
  425. /package/build/{WEIGHT_BOYS.percentile.weekly-ffe2e09f.js → WEIGHT_BOYS.percentile.weekly-bd8ca272.js} +0 -0
  426. /package/build/{WEIGHT_BOYS.percentile.yearly-5613db72.js → WEIGHT_BOYS.percentile.yearly-578f7986.js} +0 -0
  427. /package/build/{WEIGHT_BOYS.zscore.monthly-0c71e1f1.js → WEIGHT_BOYS.zscore.monthly-9b1d5348.js} +0 -0
  428. /package/build/{WEIGHT_BOYS.zscore.weekly-551fbe61.js → WEIGHT_BOYS.zscore.weekly-379ca8a0.js} +0 -0
  429. /package/build/{WEIGHT_BOYS.zscore.yearly-faf021d6.js → WEIGHT_BOYS.zscore.yearly-9dde6f32.js} +0 -0
  430. /package/build/{WEIGHT_GIRLS.percentile.monthly-5e32962a.js → WEIGHT_GIRLS.percentile.monthly-df2b9297.js} +0 -0
  431. /package/build/{WEIGHT_GIRLS.percentile.weekly-3bf46095.js → WEIGHT_GIRLS.percentile.weekly-9fc94276.js} +0 -0
  432. /package/build/{WEIGHT_GIRLS.percentile.yearly-081bb76a.js → WEIGHT_GIRLS.percentile.yearly-bd17753b.js} +0 -0
  433. /package/build/{WEIGHT_GIRLS.zscore.monthly-278e2e2f.js → WEIGHT_GIRLS.zscore.monthly-6b0fda53.js} +0 -0
  434. /package/build/{WEIGHT_GIRLS.zscore.weekly-7b2b5cb3.js → WEIGHT_GIRLS.zscore.weekly-50dc7304.js} +0 -0
  435. /package/build/{WEIGHT_GIRLS.zscore.yearly-3f573da9.js → WEIGHT_GIRLS.zscore.yearly-acf28a4e.js} +0 -0
  436. /package/build/{animation-4a4be1d2.js → animation-5cb8a282.js} +0 -0
  437. /package/build/{constants-455c1bb4.js → constants-0c231590.js} +0 -0
  438. /package/build/{constants-a6d2ff76.js → constants-a476f276.js} +0 -0
  439. /package/build/{dataTransform-b60c06bb.js → dataTransform-fb4a13be.js} +0 -0
  440. /package/build/{doctor-1f6e5f33.js → doctor-98332328.js} +0 -0
  441. /package/build/esm/{BMI_BOYS.percentile.monthly-92d9c1f0.js → BMI_BOYS.percentile.monthly-b3d77d98.js} +0 -0
  442. /package/build/esm/{BMI_BOYS.percentile.weekly-ee2eb412.js → BMI_BOYS.percentile.weekly-e4409f30.js} +0 -0
  443. /package/build/esm/{BMI_BOYS.percentile.yearly-1633c579.js → BMI_BOYS.percentile.yearly-c2ba196b.js} +0 -0
  444. /package/build/esm/{BMI_BOYS.zscore.monthly-7cae8cf3.js → BMI_BOYS.zscore.monthly-28d2eae7.js} +0 -0
  445. /package/build/esm/{BMI_BOYS.zscore.weekly-8d5a6c27.js → BMI_BOYS.zscore.weekly-072785a9.js} +0 -0
  446. /package/build/esm/{BMI_BOYS.zscore.yearly-4385bf15.js → BMI_BOYS.zscore.yearly-b11bb01a.js} +0 -0
  447. /package/build/esm/{BMI_GIRLS.percentile.monthly-39965bce.js → BMI_GIRLS.percentile.monthly-8d2c0e92.js} +0 -0
  448. /package/build/esm/{BMI_GIRLS.percentile.weekly-04c50c49.js → BMI_GIRLS.percentile.weekly-6dd3a2df.js} +0 -0
  449. /package/build/esm/{BMI_GIRLS.percentile.yearly-c52eda5f.js → BMI_GIRLS.percentile.yearly-8c258515.js} +0 -0
  450. /package/build/esm/{BMI_GIRLS.zscore.monthly-c706b650.js → BMI_GIRLS.zscore.monthly-972ccee4.js} +0 -0
  451. /package/build/esm/{BMI_GIRLS.zscore.weekly-465b90ff.js → BMI_GIRLS.zscore.weekly-f9cb601d.js} +0 -0
  452. /package/build/esm/{BMI_GIRLS.zscore.yearly-ed0e918a.js → BMI_GIRLS.zscore.yearly-b55710e3.js} +0 -0
  453. /package/build/esm/{ChevronDown-3f8ce34e.js → ChevronDown-319bf056.js} +0 -0
  454. /package/build/esm/{Close-544c792d.js → Close-1f4384ad.js} +0 -0
  455. /package/build/esm/{Google-07add6d7.js → Google-687c736b.js} +0 -0
  456. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.monthly-36488681.js → HEAD CIRCUM_BOYS.percentile.monthly-063e77c2.js} +0 -0
  457. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.weekly-23fc9978.js → HEAD CIRCUM_BOYS.percentile.weekly-1b8aafa2.js} +0 -0
  458. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.yearly-854f13e0.js → HEAD CIRCUM_BOYS.percentile.yearly-1f1442b4.js} +0 -0
  459. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.monthly-4d4dbf90.js → HEAD CIRCUM_BOYS.zscore.monthly-401a71a1.js} +0 -0
  460. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.weekly-9f181b10.js → HEAD CIRCUM_BOYS.zscore.weekly-e66935f8.js} +0 -0
  461. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.yearly-6e8bcb7d.js → HEAD CIRCUM_BOYS.zscore.yearly-44d4a37d.js} +0 -0
  462. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.monthly-bdeb8d21.js → HEAD CIRCUM_GIRLS.percentile.monthly-e2ad3c40.js} +0 -0
  463. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.weekly-bf8d0a97.js → HEAD CIRCUM_GIRLS.percentile.weekly-be25306c.js} +0 -0
  464. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.yearly-230957db.js → HEAD CIRCUM_GIRLS.percentile.yearly-d8016c18.js} +0 -0
  465. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.monthly-20e5c1d6.js → HEAD CIRCUM_GIRLS.zscore.monthly-81d91bc2.js} +0 -0
  466. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.weekly-3993abe9.js → HEAD CIRCUM_GIRLS.zscore.weekly-06060441.js} +0 -0
  467. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.yearly-6891fbfc.js → HEAD CIRCUM_GIRLS.zscore.yearly-a176ab45.js} +0 -0
  468. /package/build/esm/{HEIGHT_BOYS.percentile.monthly-2570d419.js → HEIGHT_BOYS.percentile.monthly-c6c5bfc8.js} +0 -0
  469. /package/build/esm/{HEIGHT_BOYS.percentile.weekly-606af351.js → HEIGHT_BOYS.percentile.weekly-4fe18742.js} +0 -0
  470. /package/build/esm/{HEIGHT_BOYS.percentile.yearly-37c2dd55.js → HEIGHT_BOYS.percentile.yearly-9c591c43.js} +0 -0
  471. /package/build/esm/{HEIGHT_BOYS.zscore.monthly-81178889.js → HEIGHT_BOYS.zscore.monthly-f7d9a199.js} +0 -0
  472. /package/build/esm/{HEIGHT_BOYS.zscore.weekly-3178efa9.js → HEIGHT_BOYS.zscore.weekly-ee062e19.js} +0 -0
  473. /package/build/esm/{HEIGHT_BOYS.zscore.yearly-493f4e9a.js → HEIGHT_BOYS.zscore.yearly-5c3cef1c.js} +0 -0
  474. /package/build/esm/{HEIGHT_GIRLS.percentile.monthly-0f1f5d53.js → HEIGHT_GIRLS.percentile.monthly-ab1c4da7.js} +0 -0
  475. /package/build/esm/{HEIGHT_GIRLS.percentile.weekly-02ef3a08.js → HEIGHT_GIRLS.percentile.weekly-e7b6e8e4.js} +0 -0
  476. /package/build/esm/{HEIGHT_GIRLS.percentile.yearly-46a52ffd.js → HEIGHT_GIRLS.percentile.yearly-b7a22445.js} +0 -0
  477. /package/build/esm/{HEIGHT_GIRLS.zscore.monthly-59d32be7.js → HEIGHT_GIRLS.zscore.monthly-ed2bf049.js} +0 -0
  478. /package/build/esm/{HEIGHT_GIRLS.zscore.weekly-934f71dc.js → HEIGHT_GIRLS.zscore.weekly-03a0273c.js} +0 -0
  479. /package/build/esm/{HEIGHT_GIRLS.zscore.yearly-eeefcd63.js → HEIGHT_GIRLS.zscore.yearly-2e7f3b16.js} +0 -0
  480. /package/build/esm/{Visible-6f57a2db.js → Visible-870c370a.js} +0 -0
  481. /package/build/esm/{WEIGHT_BOYS.percentile.monthly-876f2a6d.js → WEIGHT_BOYS.percentile.monthly-10a4736f.js} +0 -0
  482. /package/build/esm/{WEIGHT_BOYS.percentile.weekly-67700803.js → WEIGHT_BOYS.percentile.weekly-0f1de588.js} +0 -0
  483. /package/build/esm/{WEIGHT_BOYS.percentile.yearly-b2adebd1.js → WEIGHT_BOYS.percentile.yearly-9b3c47b0.js} +0 -0
  484. /package/build/esm/{WEIGHT_BOYS.zscore.monthly-38e643db.js → WEIGHT_BOYS.zscore.monthly-681179fd.js} +0 -0
  485. /package/build/esm/{WEIGHT_BOYS.zscore.weekly-ed370d92.js → WEIGHT_BOYS.zscore.weekly-522a296e.js} +0 -0
  486. /package/build/esm/{WEIGHT_BOYS.zscore.yearly-158f3120.js → WEIGHT_BOYS.zscore.yearly-75f527d4.js} +0 -0
  487. /package/build/esm/{WEIGHT_GIRLS.percentile.monthly-19ed2ff2.js → WEIGHT_GIRLS.percentile.monthly-14c79e56.js} +0 -0
  488. /package/build/esm/{WEIGHT_GIRLS.percentile.weekly-c07ebd4a.js → WEIGHT_GIRLS.percentile.weekly-23326d83.js} +0 -0
  489. /package/build/esm/{WEIGHT_GIRLS.percentile.yearly-d2eb7f92.js → WEIGHT_GIRLS.percentile.yearly-111acd33.js} +0 -0
  490. /package/build/esm/{WEIGHT_GIRLS.zscore.monthly-2d39112e.js → WEIGHT_GIRLS.zscore.monthly-b902754a.js} +0 -0
  491. /package/build/esm/{WEIGHT_GIRLS.zscore.weekly-79c13caa.js → WEIGHT_GIRLS.zscore.weekly-a64bc9d2.js} +0 -0
  492. /package/build/esm/{WEIGHT_GIRLS.zscore.yearly-686b8120.js → WEIGHT_GIRLS.zscore.yearly-b2980e84.js} +0 -0
  493. /package/build/esm/{animation-f0de7fec.js → animation-c70af288.js} +0 -0
  494. /package/build/esm/{constants-67817a3e.js → constants-97ced596.js} +0 -0
  495. /package/build/esm/{constants-7a94d96a.js → constants-e9127712.js} +0 -0
  496. /package/build/esm/{dataTransform-96b33da1.js → dataTransform-a5ace7a9.js} +0 -0
  497. /package/build/esm/{doctor-ce62bcf6.js → doctor-aff6ffe0.js} +0 -0
  498. /package/build/esm/{index-0fcc7e05.js → index-0869dad7.js} +0 -0
  499. /package/build/esm/{index-d14b8ec2.js → index-39ead392.js} +0 -0
  500. /package/build/esm/{index-b814b571.js → index-48ff8880.js} +0 -0
  501. /package/build/esm/{index-20fe498c.js → index-4fc08219.js} +0 -0
  502. /package/build/esm/{index-2f816408.js → index-77e34fdf.js} +0 -0
  503. /package/build/esm/{index-a9b9cf40.js → index-b409a437.js} +0 -0
  504. /package/build/esm/{index-50922feb.js → index-ed1c9d98.js} +0 -0
  505. /package/build/esm/{index-bd1a993e.js → index-ee0d43e6.js} +0 -0
  506. /package/build/esm/{index.styles-c9d6db26.js → index.styles-9a39d828.js} +0 -0
  507. /package/build/esm/{localizeNumberFormat-91191f3b.js → localizeNumberFormat-9c2b34a7.js} +0 -0
  508. /package/build/esm/{normalizeLink-6e07e5c4.js → normalizeLink-c0dec424.js} +0 -0
  509. /package/build/esm/{number-9e7857e2.js → number-509e4127.js} +0 -0
  510. /package/build/esm/{other-7cac897b.js → other-ad977443.js} +0 -0
  511. /package/build/esm/{paths-eb036f12.js → paths-ec7f919f.js} +0 -0
  512. /package/build/esm/{translationsContext-23b5bf84.js → translationsContext-13869044.js} +0 -0
  513. /package/build/esm/{tslib.es6-eb6746ec.js → tslib.es6-34c3d3bf.js} +0 -0
  514. /package/build/esm/{types-1466329a.js → types-addbc5c7.js} +0 -0
  515. /package/build/esm/{useIsInit-58c92435.js → useIsInit-01f8095d.js} +0 -0
  516. /package/build/esm/{useOutsideClick-d1408b13.js → useOutsideClick-884ef400.js} +0 -0
  517. /package/build/esm/{useScrollbarSize-af69fd45.js → useScrollbarSize-23749c51.js} +0 -0
  518. /package/build/esm/{useUniqueId-15198ead.js → useUniqueId-bf8b1319.js} +0 -0
  519. /package/build/esm/{utils-770949fe.js → utils-f97b6496.js} +0 -0
  520. /package/build/{index-fae28861.js → index-07a1f62b.js} +0 -0
  521. /package/build/{index-fd00f1ea.js → index-68861972.js} +0 -0
  522. /package/build/{index-cd4f0240.js → index-73755798.js} +0 -0
  523. /package/build/{index-1e874626.js → index-742af7a1.js} +0 -0
  524. /package/build/{index-a5d52534.js → index-a67e4960.js} +0 -0
  525. /package/build/{index-c30aae56.js → index-ab4afcac.js} +0 -0
  526. /package/build/{index-a471322d.js → index-acf68981.js} +0 -0
  527. /package/build/{index-fce79e5f.js → index-e8db0333.js} +0 -0
  528. /package/build/{index.styles-f9818d05.js → index.styles-3160bc39.js} +0 -0
  529. /package/build/{localizeNumberFormat-ef732f37.js → localizeNumberFormat-fe015b70.js} +0 -0
  530. /package/build/{normalizeLink-65501df2.js → normalizeLink-4ea219af.js} +0 -0
  531. /package/build/{number-2ccfcc5f.js → number-8e287617.js} +0 -0
  532. /package/build/{other-4e4f19d4.js → other-7e106576.js} +0 -0
  533. /package/build/{paths-d2ea905c.js → paths-7f344af9.js} +0 -0
  534. /package/build/{translationsContext-3ac6ece2.js → translationsContext-da79cdd9.js} +0 -0
  535. /package/build/{tslib.es6-e879b440.js → tslib.es6-17e485ce.js} +0 -0
  536. /package/build/{types-2d921d78.js → types-3b12886f.js} +0 -0
  537. /package/build/{useIsInit-5cc2d405.js → useIsInit-585c0d5a.js} +0 -0
  538. /package/build/{useOutsideClick-795cda46.js → useOutsideClick-c7b9af7c.js} +0 -0
  539. /package/build/{useScrollbarSize-9fb99eed.js → useScrollbarSize-0074bb72.js} +0 -0
  540. /package/build/{useUniqueId-5f42952d.js → useUniqueId-09856594.js} +0 -0
  541. /package/build/{utils-a445506a.js → utils-a7668f82.js} +0 -0
package/build/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-17e485ce.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-21170172.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-7ae2e6e6.js');
14
+ var translationsContext = require('./translationsContext-da79cdd9.js');
15
+ var utils$1 = require('./utils-a7668f82.js');
16
+ var index$2 = require('./index-52daa9b7.js');
17
+ var index$3 = require('./index-901c1b9b.js');
18
+ var index$5 = require('./index-752ff392.js');
19
+ var index$4 = require('./index-4ce3e685.js');
20
+ require('./index.styles-3160bc39.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-ec6670dc.js');
23
+ var index$9 = require('./index-861e8221.js');
24
+ require('./index-07a1f62b.js');
25
+ var index$7 = require('./index-d99ee36c.js');
26
+ require('./other-7e106576.js');
27
+ require('./index-175d86a3.js');
28
+ var utils = require('./utils-be46cc9c.js');
29
+ var dates = require('@mantine/dates');
30
+ var usePlacesAutocomplete = require('./usePlacesAutocomplete-67b69bd8.js');
31
+ var index$6 = require('./index-f40878d1.js');
32
+ var translationsProvider = require('./translationsProvider-6a0b5b3b.js');
33
+ var Locale = require('./Locale-5cb9776e.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-d08246c9.js');
40
+ var index$8 = require('./index-ab4afcac.js');
41
+ var index$b = require('./index-f79913e1.js');
42
+ var useScreenSize = require('./useScreenSize-bfdacbfe.js');
43
+ var ReactDOM = require('react-dom');
44
+ var index$a = require('./index-1fef978f.js');
45
+ var InputDate = require('./InputDate-4d0f8f62.js');
46
+ var Close = require('./Close-2bfa4de9.js');
47
+ require('./constantsIsProduction.js');
48
+ require('./normalizeLink-4ea219af.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-09856594.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-742af7a1.js');
71
+ require('slugify');
72
+ require('string-format');
73
+ require('./togetherApiPaths.js');
74
+ require('./constants-a476f276.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,1707 @@ 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
+ ${utils$1.MediaQueries.mbUp} {
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
+ ${utils$1.MediaQueries.smbDown} {
2413
+ &[data-type='subscription_box_A'] {
2414
+ border-inline: 0;
2415
+ border-radius: 0;
2416
+ margin-inline: -16px;
2417
+ box-shadow: 0px 0px 1px 0px #0000000a/0px 0px 2px 0px #0000000f/0px 4px
2418
+ 8px 0px #0000000a;
2419
+ }
2420
+ }
2421
+ `;
2422
+ const StyledLeadGenSubscriptionBoxA = styled__default["default"].div `
2423
+ .leadgen-form_input {
2424
+ --phone-select: 45px;
2425
+ .PhoneInput {
2426
+ --phone-select: 45px;
2427
+ .PhoneInputCountry {
2428
+ margin-top: 1px;
2429
+ pointer-events: none;
2430
+ .PhoneInputCountryIconImg,
2431
+ .PhoneInputArrowContainer {
2432
+ display: none;
2433
+ }
2434
+ }
2435
+ }
2436
+ }
2437
+ `;
2438
+
2439
+ const PhoneInput = React.forwardRef((props, ref) => {
2440
+ 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"]);
2441
+ const id = idProps || uuid.v1() + name;
2442
+ 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 },
2443
+ React__default["default"].createElement("div", { className: "mantine-Input-wrapper" },
2444
+ 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" })))));
2445
+ });
2446
+
2447
+ const formatLeadGenFormValue = (values, blocks) => {
2448
+ const newValues = {};
2449
+ for (const block of blocks) {
2450
+ const { data } = block || {};
2451
+ const { value: fieldName } = data || {};
2452
+ if (fieldName in values) {
2453
+ newValues[fieldName] = values[fieldName];
2454
+ }
2455
+ }
2456
+ return newValues;
2457
+ };
2458
+
2459
+ const StyledLeadGenFormInner = styled__default["default"].div `
2460
+ display: flex;
2461
+ flex-wrap: wrap;
2462
+ gap: 8px;
2463
+ .leadgen-form_input {
2464
+ width: calc(50% - 4px);
2465
+ }
2466
+
2467
+ .leadgen-form_input_checkbox {
2468
+ width: 100%;
2469
+ }
2470
+ `;
2471
+
2472
+ const cssInputNotShrink$1 = react.css `
2473
+ height: 100% !important;
2474
+ min-height: calc(var(--container-height, 56px) * 22 / 56);
2475
+ color: ${miscTheme.theme.colors.gray800};
2476
+ font-size: var(--input, 16px);
2477
+ line-height: calc(var(--container-height, 56px) * 22 / 56);
2478
+ border: none !important;
2479
+ border-radius: 0 !important;
2480
+ outline: none !important;
2481
+ box-shadow: none !important;
2482
+ padding: 0;
2483
+ cursor: pointer;
2484
+ opacity: 0;
2485
+
2486
+ ::placeholder {
2487
+ color: ${miscTheme.theme.colors.gray400};
2488
+ }
2489
+ `;
2490
+ const cssInputShrink$1 = react.css `
2491
+ height: auto !important;
2492
+ cursor: text;
2493
+ opacity: 1;
2494
+ transition: 0.1s ease-in-out all;
2495
+ `;
2496
+ const cssLabelNotShrink$1 = react.css `
2497
+ position: absolute;
2498
+ top: calc(var(--container-height) / 2);
2499
+ left: var(--space-x, 16px);
2500
+ color: ${miscTheme.theme.colors.gray400};
2501
+ font-size: var(--label-not-shrink, 16px);
2502
+ font-weight: 400;
2503
+ line-height: calc(var(--container-height, 56px) * 18 / 56);
2504
+ margin: 0;
2505
+ z-index: 1;
2506
+ cursor: pointer;
2507
+ transform: translateY(-50%);
2508
+ transition: 0.125s ease-in all;
2509
+ `;
2510
+ const cssLabelShrink$1 = react.css `
2511
+ color: ${miscTheme.theme.colors.gray600};
2512
+ font-weight: 600;
2513
+ font-size: var(--label-shrink, 12px);
2514
+ top: calc(var(--container-height) * 7 / 56);
2515
+ transform: none;
2516
+ transition: 0.125s ease-out all;
2517
+ `;
2518
+ const cssWrapperInputNotShrink$1 = react.css `
2519
+ min-height: var(--container-height, 56px);
2520
+ display: flex;
2521
+ align-items: flex-end;
2522
+ border: 1px solid ${miscTheme.theme.colors.gray200};
2523
+ border-radius: 8px;
2524
+ background-color: #fff;
2525
+ padding-inline: var(--space-x, 16px);
2526
+ padding-block: var(--space-y-not-shrink, 16px);
2527
+ cursor: pointer;
2528
+ pointer-events: none;
2529
+
2530
+ &:has(.mantine-Input-rightSection) {
2531
+ padding-right: var(--container-height, 56px);
2532
+ }
2533
+
2534
+ .mantine-Input-icon {
2535
+ display: none;
2536
+ }
2537
+
2538
+ .mantine-NumberInput-control {
2539
+ border-color: ${miscTheme.theme.colors.gray200};
2540
+ }
2541
+ `;
2542
+ const cssWrapperInputShrink$1 = react.css `
2543
+ height: auto;
2544
+ min-height: var(--container-height, 56px);
2545
+ padding-block: var(--space-y-shrink, 7px);
2546
+ cursor: text;
2547
+ pointer-events: auto;
2548
+ `;
2549
+ const cssInputWrapperError$1 = react.css `
2550
+ color: ${miscTheme.theme.colors.red800};
2551
+ font-size: 12px;
2552
+ line-height: 1.5;
2553
+ `;
2554
+ const StyledTextFieldContainer$1 = styled__default["default"].div `
2555
+ --space-x: 16px;
2556
+ --space-y-not-shrink: 16px;
2557
+ --space-y-shrink: 7px;
2558
+ --container-height: 56px;
2559
+ --label-not-shrink: 16px;
2560
+ --label-shrink: 12px;
2561
+ --input: 16px;
2562
+
2563
+ position: relative;
2564
+ min-width: 100px;
2565
+ max-width: 100%;
2566
+ display: inline-block;
2567
+
2568
+ .textField_wrapper {
2569
+ display: inline-block;
2570
+ width: 100%;
2571
+ cursor: pointer;
2572
+ }
2573
+
2574
+ .mantine-InputWrapper-root {
2575
+ &[data-invalid='true'] {
2576
+ .mantine-Input-wrapper {
2577
+ border-color: ${miscTheme.theme.colors.red400};
2578
+ }
2579
+ }
2580
+
2581
+ .mantine-Input-wrapper {
2582
+ &:has([data-invalid]) {
2583
+ border-color: ${miscTheme.theme.colors.red400};
2584
+ }
2585
+ }
2586
+
2587
+ .mantine-InputWrapper-error {
2588
+ font-size: 12px !important;
2589
+ }
2590
+ }
2591
+
2592
+ .mantine-InputWrapper-label {
2593
+ ${cssLabelNotShrink$1}
2594
+ }
2595
+
2596
+ .mantine-Input-wrapper {
2597
+ ${cssWrapperInputNotShrink$1}
2598
+
2599
+ + .mantine-Popover-dropdown[data-position="bottom-start"] {
2600
+ left: 0 !important;
2601
+ }
2602
+ + .mantine-Popover-dropdown[data-position='top-start'] {
2603
+ top: unset !important;
2604
+ left: 0 !important;
2605
+ bottom: 100% !important;
2606
+ }
2607
+ }
2608
+
2609
+ .mantine-Input-input {
2610
+ ${cssInputNotShrink$1}
2611
+ }
2612
+
2613
+ &.textField_shrink,
2614
+ &:focus-within {
2615
+ .mantine-InputWrapper-label {
2616
+ ${cssLabelShrink$1}
2617
+ }
2618
+
2619
+ .mantine-Input-wrapper {
2620
+ ${cssWrapperInputShrink$1}
2621
+ &.mantine-Select-wrapper {
2622
+ .mantine-Select-rightSection {
2623
+ pointer-events: auto !important;
2624
+ }
2625
+ }
2626
+ }
2627
+
2628
+ .mantine-Input-input {
2629
+ ${cssInputShrink$1}
2630
+ }
2631
+
2632
+ &:has(.PhoneInput) {
2633
+ .mantine-InputWrapper-label {
2634
+ left: var(--space-x, 16px);
2635
+ }
2636
+ .PhoneInput {
2637
+ .PhoneInputInput {
2638
+ opacity: 1;
2639
+ }
2640
+ }
2641
+ }
2642
+ }
2643
+
2644
+ .PhoneInput {
2645
+ --phone-select: 75px;
2646
+ --phone-input-space-x: 8px;
2647
+ width: 100%;
2648
+ opacity: 1;
2649
+ border: none;
2650
+ .PhoneInputCountry {
2651
+ background-color: transparent;
2652
+ border: none;
2653
+ padding: 0;
2654
+ width: var(--phone-select, 75px);
2655
+ }
2656
+ .PhoneInputInput {
2657
+ flex: 1;
2658
+ min-width: 0;
2659
+ line-height: 1.5;
2660
+ outline: none !important;
2661
+ border: none;
2662
+ box-shadow: none;
2663
+ padding: 0 var(--phone-input-space-x, 8px);
2664
+ opacity: 0;
2665
+ color: ${miscTheme.theme.colors.gray800} !important;
2666
+ :focus {
2667
+ color: ${miscTheme.theme.colors.gray800} !important;
2668
+ }
2669
+ }
2670
+ }
2671
+
2672
+ &:has(.PhoneInput) {
2673
+ .mantine-InputWrapper-label {
2674
+ left: calc(
2675
+ var(--space-x, 16px) + var(--phone-select, 75px) +
2676
+ var(--phone-input-space-x, 8px)
2677
+ );
2678
+ }
2679
+ }
2680
+ `;
2681
+ const StyledChoiceFieldContainer$1 = styled__default["default"].div `
2682
+ &.leadgen-form_checkbox,
2683
+ &.leadgen-form_radio {
2684
+ width: 100%;
2685
+ }
2686
+
2687
+ &.leadgen-form_dropdown {
2688
+ width: calc(50% - 12px);
2689
+ }
2690
+
2691
+ .mantine-InputWrapper-root {
2692
+ display: block;
2693
+ .mantine-InputWrapper-error {
2694
+ font-size: 12px !important;
2695
+ }
2696
+ }
2697
+
2698
+ .mantine-InputWrapper-label {
2699
+ margin-bottom: 0.5rem;
2700
+ color: ${miscTheme.theme.colors.gray800};
2701
+ font-size: 16px;
2702
+ font-weight: 400;
2703
+ line-height: 1.5;
2704
+ }
2705
+
2706
+ .mantine-Radio-root,
2707
+ .mantine-Checkbox-root {
2708
+ gap: 8px;
2709
+ min-width: calc(50% - 4px);
2710
+
2711
+ input[type='radio'],
2712
+ input[type='checkbox'] {
2713
+ border-color: ${miscTheme.theme.colors.gray600};
2714
+ width: 18px;
2715
+ height: 18px;
2716
+ }
2717
+ input[type='checkbox'] {
2718
+ border-radius: 4px;
2719
+ }
2720
+
2721
+ &[data-checked='true'] {
2722
+ input[type='radio'],
2723
+ input[type='checkbox'] {
2724
+ border-color: ${miscTheme.theme.colors.primary600};
2725
+ + svg {
2726
+ color: ${miscTheme.theme.colors.primary600};
2727
+ }
2728
+ }
2729
+
2730
+ input[type='radio'] {
2731
+ background-color: white;
2732
+ }
2733
+ }
2734
+
2735
+ .mantine-Checkbox-input {
2736
+ &:checked {
2737
+ border-color: ${miscTheme.theme.colors.primary600};
2738
+ }
2739
+ }
2740
+ }
2741
+
2742
+ .mantine-Radio-inner,
2743
+ .mantine-Checkbox-inner {
2744
+ width: 24px;
2745
+ height: 24px;
2746
+ display: flex;
2747
+ align-items: center;
2748
+ justify-content: center;
2749
+ }
2750
+
2751
+ .mantine-Radio-body,
2752
+ .mantine-Checkbox-body {
2753
+ display: flex;
2754
+ align-items: center;
2755
+ }
2756
+
2757
+ .mantine-Radio-label,
2758
+ .mantine-Checkbox-label {
2759
+ padding-left: 8px;
2760
+ color: ${miscTheme.theme.colors.gray800};
2761
+ font-size: 14px;
2762
+ line-height: 1.4;
2763
+ letter-spacing: -0.2px;
2764
+ }
2765
+
2766
+ .leadgen-choiceContainer {
2767
+ display: flex;
2768
+ flex-wrap: wrap;
2769
+ align-items: flex-start;
2770
+ gap: 8px;
2771
+ }
2772
+
2773
+ .mantine-InputWrapper-error {
2774
+ ${cssInputWrapperError$1}
2775
+ }
2776
+ `;
2777
+
2778
+ const TextField$1 = (props) => {
2779
+ const { shrink: shrinkProps, onChangeShrink, className, children } = props, restProps = tslib_es6.__rest(props, ["shrink", "onChangeShrink", "className", "children"]);
2780
+ const containerRef = hooks.useClickOutside(() => {
2781
+ if (shrinkProps) {
2782
+ return;
2783
+ }
2784
+ setShrink(false);
2785
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(false);
2786
+ });
2787
+ const [shrink, setShrink] = React.useState(shrinkProps);
2788
+ const onClick = React.useCallback((e) => {
2789
+ setShrink(true);
2790
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(true);
2791
+ if (shrink) {
2792
+ return;
2793
+ }
2794
+ const $textEl = e.currentTarget.querySelectorAll('input:not([disabled]):not([type="submit"]),select:not([disabled]),textarea:not([disabled])');
2795
+ const $focusEl = $textEl.item($textEl.length - 1);
2796
+ if ($focusEl) {
2797
+ $focusEl.focus();
2798
+ setTimeout(() => {
2799
+ $focusEl.scrollIntoView({
2800
+ behavior: 'auto',
2801
+ block: 'center',
2802
+ inline: 'start',
2803
+ });
2804
+ }, 100);
2805
+ }
2806
+ }, [shrink]);
2807
+ React.useEffect(() => {
2808
+ setShrink(shrinkProps);
2809
+ }, [shrinkProps]);
2810
+ return (React__default["default"].createElement(StyledTextFieldContainer$1, Object.assign({ shrink: shrink, className: core.clsx(className, 'textField', { textField_shrink: !!shrink }) }, restProps),
2811
+ React__default["default"].createElement("div", { ref: containerRef, onClick: onClick, className: "textField_wrapper" }, children)));
2812
+ };
2813
+ const ChoiceField$1 = (props) => {
2814
+ const { children, className } = props, restProps = tslib_es6.__rest(props, ["children", "className"]);
2815
+ return (React__default["default"].createElement(StyledChoiceFieldContainer$1, Object.assign({ className: core.clsx(className, 'choiceField') }, restProps), children));
2816
+ };
2817
+
2818
+ const libraries = ['places'];
2819
+ const GoogleLocationBlock = (props) => {
2820
+ var _a;
2821
+ const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = tslib_es6.__rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
2822
+ const [LoadScript, setLoadScript] = React.useState(null);
2823
+ const [value, setValue] = React.useState(defaultValue || valueProps);
2824
+ 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]);
2825
+ const onChangeAutocomplete = React.useCallback((s) => {
2826
+ setValue(s);
2827
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
2828
+ }, []);
2829
+ const onClickItem = React.useCallback((item) => {
2830
+ /** For sure get value */
2831
+ setValue(item.value);
2832
+ const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
2833
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
2834
+ }, [onChangeProps, predictions]);
2835
+ React.useEffect(() => {
2836
+ setValue(valueProps);
2837
+ }, [valueProps]);
2838
+ React.useEffect(() => {
2839
+ var _a, _b, _c;
2840
+ // only load extra google script when not yet loaded
2841
+ 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) {
2842
+ Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@react-google-maps/api')); }).then((m) => {
2843
+ setLoadScript(() => m.LoadScript);
2844
+ });
2845
+ }
2846
+ }, []);
2847
+ return (React__default["default"].createElement(core.Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
2848
+ return { value: pred.description, label: pred.description };
2849
+ }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: index$7.ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
2850
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
2851
+ 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%' } })),
2852
+ children));
2853
+ } }, restProps)));
2854
+ };
2855
+
2856
+ const LeadGenForm = React.forwardRef((props, ref) => {
2857
+ const { locale, blocks, scrollToErrorField = true, form: formProps, rules: validate, initialValues, onFinish, onFinishFailed, className, style, } = props;
2858
+ const formRef = React.useRef(null);
2859
+ const form$1 = formProps || form.useForm({ initialValues, validate });
2860
+ const middlewareFinish = React.useCallback((values, event) => {
2861
+ /** Set `touched` all values for validation when submiting */
2862
+ form$1.setTouched(blocks.reduce((touched, { data }) => {
2863
+ touched[data.value] = true;
2864
+ return touched;
2865
+ }, {}));
2866
+ /** Wait for `touched` state and then submit */
2867
+ setTimeout(() => {
2868
+ const { hasErrors } = form$1.validate();
2869
+ if (hasErrors) {
2870
+ return;
2871
+ }
2872
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatLeadGenFormValue(values, blocks), event);
2873
+ }, 100);
2874
+ }, [form$1, blocks]);
2875
+ const middlewareFinishFailed = React.useCallback((errors, values, events) => {
2876
+ if (scrollToErrorField && errors) {
2877
+ const firstErrorKey = Object.keys(errors)[0];
2878
+ const firstErrorElement = document.querySelector(`[name="${firstErrorKey}"]`);
2879
+ if (firstErrorElement && (firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus)) {
2880
+ setTimeout(() => {
2881
+ firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
2882
+ firstErrorElement.scrollIntoView({
2883
+ behavior: 'auto',
2884
+ block: 'center',
2885
+ inline: 'center',
2886
+ });
2887
+ }, 100);
2888
+ }
2889
+ }
2890
+ onFinishFailed === null || onFinishFailed === void 0 ? void 0 : onFinishFailed(errors, values, events);
2891
+ }, [scrollToErrorField]);
2892
+ React.useEffect(() => {
2893
+ (() => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
2894
+ if (!window.intlTelInputUtils) {
2895
+ yield require('intl-tel-input/build/js/utils');
2896
+ }
2897
+ }))();
2898
+ }, []);
2899
+ React.useImperativeHandle(ref, () => (Object.assign(Object.assign({}, form$1), { submit: () => {
2900
+ formRef.current.requestSubmit();
2901
+ } })), [form$1, formRef]);
2902
+ if (!blocks || !blocks.length) {
2903
+ return null;
2904
+ }
2905
+ return (React__default["default"].createElement("form", { ref: formRef, onSubmit: form$1.onSubmit(middlewareFinish, middlewareFinishFailed), className: className, style: style },
2906
+ React__default["default"].createElement(StyledLeadGenFormInner, { className: "leadgen-form_inputs" }, blocks.map((block, idx) => {
2907
+ const { id, name: blockName, data } = block;
2908
+ const { placeholder, value: name, required, listQuestion, valueHTML, isSendMailChimp = false, } = data;
2909
+ const formInputProps = form$1.getInputProps(name);
2910
+ const { value, error } = formInputProps;
2911
+ const reactKey = `${id}-${idx}`;
2912
+ switch (blockName) {
2913
+ case LEADGEN_BLOCK.TextBlock: {
2914
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2915
+ 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))));
2916
+ }
2917
+ case LEADGEN_BLOCK.NumberBlock: {
2918
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2919
+ 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))));
2920
+ }
2921
+ case LEADGEN_BLOCK.EmailBlock: {
2922
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2923
+ 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))));
2924
+ }
2925
+ case LEADGEN_BLOCK.PhoneOtpBlock:
2926
+ case LEADGEN_BLOCK.WhatsappOtpBlock:
2927
+ case LEADGEN_BLOCK.ZaloOtpBlock:
2928
+ case LEADGEN_BLOCK.PhoneBlock: {
2929
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2930
+ 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))));
2931
+ }
2932
+ case LEADGEN_BLOCK.LocationBlock: {
2933
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2934
+ 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))));
2935
+ }
2936
+ case LEADGEN_BLOCK.DateBlock: {
2937
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2938
+ 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))));
2939
+ }
2940
+ case LEADGEN_BLOCK.DropdownBlock:
2941
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2942
+ React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2943
+ React__default["default"].createElement(core.Select, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, data: listQuestion.map((l) => ({
2944
+ value: l.value,
2945
+ label: l.placeholder,
2946
+ })) }, formInputProps))));
2947
+ case LEADGEN_BLOCK.CheckboxBlock: {
2948
+ const formInputCheckboxProps = form$1.getInputProps(name, {
2949
+ type: 'checkbox',
2950
+ });
2951
+ return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2952
+ isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2953
+ React__default["default"].createElement(core.Checkbox.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, sx: {
2954
+ display: 'flex',
2955
+ flexDirection: 'column',
2956
+ flexWrap: 'wrap',
2957
+ gap: 8,
2958
+ }, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2959
+ return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2960
+ } }, formInputCheckboxProps), listQuestion.map((l, _idx) => (React__default["default"].createElement(core.Checkbox, { name: name, key: _idx, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2961
+ }
2962
+ case LEADGEN_BLOCK.RadioBlock: {
2963
+ return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2964
+ isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2965
+ 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) => {
2966
+ return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2967
+ } }, formInputProps), listQuestion.map((l, _index) => (React__default["default"].createElement(core.Radio, { name: name, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2968
+ }
2969
+ case LEADGEN_BLOCK.TncBlock:
2970
+ return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2971
+ React__default["default"].createElement(core.Input.Wrapper, { error: error },
2972
+ 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)))));
2973
+ default: {
2974
+ return null;
2975
+ }
2976
+ }
2977
+ }))));
2978
+ });
2979
+
2980
+ const LEADGEN_ORDER_INPUT_WRAPPER = ['label', 'input', 'description', 'error'];
2981
+
2982
+ const LeadGenSubscriptionBoxA = (props) => {
2983
+ const { loading, image, title, submitText, locale, blocks, form, rules, onFinish, } = props;
2984
+ const formRef = React.useRef();
2985
+ const imageComp = React.useMemo(() => {
2986
+ if (!image) {
2987
+ return null;
2988
+ }
2989
+ return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeaderImage, null,
2990
+ React__default["default"].createElement("img", { src: image, alt: "" })));
2991
+ }, [image]);
2992
+ const titleComp = React.useMemo(() => {
2993
+ if (typeof title === 'string') {
2994
+ return (React__default["default"].createElement("p", { className: "leadgen-title", dangerouslySetInnerHTML: { __html: title } }));
2995
+ }
2996
+ return React__default["default"].createElement("p", { className: "leadgen-title" }, title);
2997
+ }, [title]);
2998
+ return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxA, { className: "subcription_box_A" },
2999
+ React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeader, { className: "leadgen-subscription_box_header" },
3000
+ imageComp,
3001
+ titleComp),
3002
+ React__default["default"].createElement(StyledLeadGenSubscriptionBoxBody, { className: "leadgen-subscription_box_body" },
3003
+ React__default["default"].createElement(LeadGenForm, { ref: formRef, form: form, rules: rules, blocks: blocks, locale: locale, onFinish: onFinish, className: "leadgen-subscription_box_form" }),
3004
+ React__default["default"].createElement(core.Button, { disabled: loading, loading: loading, variant: "filled", size: "lg", onClick: () => {
3005
+ formRef.current.submit();
3006
+ }, className: "leadgen-btn leadgen-btn_action", fullWidth: true }, submitText))));
3007
+ };
3008
+
3009
+ const LeadGenSubscriptionBoxWithoutMemo = ({ locale, userInfo, forceCampaign, categoryId, }) => {
3010
+ var _a, _b, _c;
3011
+ const { image, extra_fields, id: campaign_id, bot_id: campaign_subot_id = [], ThankYouBlock, } = forceCampaign || {};
3012
+ const { textBlocks, listBlockAdded, actionBlocks } = extra_fields || {};
3013
+ const { submitBlock } = actionBlocks || {};
3014
+ const { apiLeadUrl, subscriptionIcon, subscriptionTitle, submitSubscriptionBox, impression, onFinish, } = useLeadGenContext();
3015
+ const { t } = index$1.useTranslations();
3016
+ const { action: { pushNotifications }, } = React.useContext(togetherComponentGlobalContext.TogetherComponentGlobalContext);
3017
+ const refContainer = React.useRef(null);
3018
+ const [loading, setLoading] = React.useState(false);
3019
+ const [showThankyou, setShowThankyou] = React.useState(false);
3020
+ const validatingEmailRef = React.useRef(false);
3021
+ const validatingPhoneRef = React.useRef(false);
3022
+ const { form, validateObj } = useLeadFormConfig({
3023
+ listBlockAdded,
3024
+ campaignId: campaign_id,
3025
+ campaign_subot_id,
3026
+ validatingEmailRef,
3027
+ validatingPhoneRef,
3028
+ userInfo,
3029
+ });
3030
+ const subscription_title = React.useMemo(() => {
3031
+ var _a, _b;
3032
+ return subscriptionTitle ||
3033
+ ((_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) ||
3034
+ t('leadgen.message.title.default');
3035
+ }, [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]);
3036
+ const { image: thankyouImage, title: thankyouTitle, description: thankyouDescription, button: thankyouButton, } = ThankYouBlock || {};
3037
+ const intersectionObserverCallback = React.useCallback((entries) => {
3038
+ entries.forEach((entry) => {
3039
+ const { isIntersecting, target } = entry;
3040
+ if (!showThankyou &&
3041
+ isIntersecting &&
3042
+ target === refContainer.current) {
3043
+ impression();
3044
+ }
3045
+ });
3046
+ }, [impression, showThankyou]);
3047
+ const IObserver = new IntersectionObserver(intersectionObserverCallback);
3048
+ const middlewareOnSubmit = React.useCallback((values) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
3049
+ const newValues = {
3050
+ subscription_title,
3051
+ };
3052
+ const ssoValues = {
3053
+ sso_user_id: undefined,
3054
+ sso_uuid: undefined,
3055
+ sso_verified_profile: undefined,
3056
+ };
3057
+ const valueKeys = Object.keys(values);
3058
+ for (const key of valueKeys) {
3059
+ const isPhoneField = leadGenFieldNamePhone(listBlockAdded).some((k) => k === key);
3060
+ if (isPhoneField) {
3061
+ const phone = PhoneInputBase.parsePhoneNumber(values[key]);
3062
+ if (phone.isValid()) {
3063
+ /** Seperate `area_code` and `phone_number` for BE */
3064
+ newValues['area_code'] = `+${phone.countryCallingCode}`;
3065
+ newValues['phone_number'] = phone.nationalNumber;
3066
+ /** Only case login has this update */
3067
+ if ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) && (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid)) {
3068
+ const userInfoPhone = (userInfo === null || userInfo === void 0 ? void 0 : userInfo.area_code) + (userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone);
3069
+ ssoValues['sso_verified_profile'] =
3070
+ phone.number === userInfoPhone ? 1 : 0;
3071
+ ssoValues['sso_user_id'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.id;
3072
+ ssoValues['sso_uuid'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid;
3073
+ LeadLog('** LeadGen SB userInfoPhone : ', userInfoPhone);
3074
+ LeadLog('** LeadGen SB userInfoPhoneInput : ', phone.number);
3075
+ }
3076
+ }
3077
+ continue;
3078
+ }
3079
+ newValues[key] = values[key];
3080
+ }
3081
+ setLoading(true);
3082
+ try {
3083
+ const reqValues = Object.assign(Object.assign({}, newValues), ssoValues);
3084
+ const { _data } = (yield submitSubscriptionBox(reqValues)) || {};
3085
+ const { model } = _data || {};
3086
+ if (model && (model === null || model === void 0 ? void 0 : model.id)) {
3087
+ setShowThankyou(true);
3088
+ const metaValues = {
3089
+ blocks: listBlockAdded || [],
3090
+ isUpdateSso: false,
3091
+ };
3092
+ /**
3093
+ * https://hhgdev.atlassian.net/browse/EL-468
3094
+ * This feature is just using in Subscription Box
3095
+ */
3096
+ if (newValues === null || newValues === void 0 ? void 0 : newValues.name) {
3097
+ const { _data: ssoData, code: ssoErrorCode } = yield Service.postUserInfoFromLeadGen({ name: newValues === null || newValues === void 0 ? void 0 : newValues.name });
3098
+ if (ssoErrorCode && !ssoData) {
3099
+ return;
3100
+ }
3101
+ metaValues.isUpdateSso = true;
3102
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(reqValues, metaValues);
3103
+ return;
3104
+ }
3105
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(reqValues, metaValues);
3106
+ }
3107
+ }
3108
+ catch (error) {
3109
+ LeadLog('** LeadGen SubscriptionBox error : ', error);
3110
+ pushNotifications({
3111
+ message: t('leadgen.message.error.default'),
3112
+ type: 'danger',
3113
+ });
3114
+ }
3115
+ setLoading(false);
3116
+ }), [
3117
+ subscription_title,
3118
+ listBlockAdded,
3119
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
3120
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid,
3121
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone,
3122
+ ]);
3123
+ React.useEffect(() => {
3124
+ if (refContainer.current) {
3125
+ IObserver.observe(refContainer.current);
3126
+ }
3127
+ return () => {
3128
+ IObserver.disconnect();
3129
+ };
3130
+ }, [categoryId]);
3131
+ return (React__default["default"].createElement("div", { ref: refContainer },
3132
+ React__default["default"].createElement(StyledLeadGenSubscriptionBox, { "data-type": "subscription_box_A" },
3133
+ 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 })),
3134
+ !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 })))));
3135
+ };
3136
+ const LeadGenSubscriptionBox$1 = React.memo(LeadGenSubscriptionBoxWithoutMemo);
3137
+
3138
+ const Container = () => {
3139
+ const context = React.useContext(LeadGenContext);
3140
+ const { campaign_code, locale, siteId, siteDomain, userInfo, forceCampaign } = context;
3141
+ if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
3142
+ return null;
3143
+ }
3144
+ return (React__default["default"].createElement(LeadGenSubscriptionBox$1, { locale: locale, siteId: siteId, siteDomain: siteDomain, userInfo: userInfo, forceCampaign: forceCampaign, campaign_code: campaign_code }));
3145
+ };
3146
+ Container.displayName = 'LeadGenSubscriptionBox';
3147
+ const LeadGenSubscriptionBoxContainer = (props) => {
3148
+ const { apiUrl, apiSubotUrl } = props;
3149
+ return (React__default["default"].createElement(LeadGenContextProvider, Object.assign({}, props, { apiLeadUrl: apiUrl, apiSubotUrl: apiSubotUrl }),
3150
+ React__default["default"].createElement(Container, null)));
3151
+ };
3152
+ const LeadGenSubscriptionBox = LeadGenSubscriptionBoxContainer;
3153
+
3154
+ const useImageSize = (src) => {
3155
+ const [width, setWidth] = React.useState(16);
3156
+ const [height, setHeight] = React.useState(9);
3157
+ const [loaded, setLoaded] = React.useState(false);
3158
+ // load src image to get its width and height
3159
+ React.useEffect(() => {
3160
+ setLoaded(false);
3161
+ if (src) {
3162
+ const img = new Image();
3163
+ img.addEventListener('load', () => {
3164
+ setWidth(img.naturalWidth);
3165
+ setHeight(img.naturalHeight);
3166
+ setLoaded(true);
3167
+ });
3168
+ img.addEventListener('error', () => {
3169
+ setWidth(16);
3170
+ setHeight(9);
3171
+ setLoaded(true);
3172
+ });
3173
+ img.src = src;
3174
+ }
3175
+ else {
3176
+ setWidth(16);
3177
+ setHeight(9);
3178
+ setLoaded(true);
3179
+ }
3180
+ }, [src]);
3181
+ return {
3182
+ loaded,
3183
+ width,
3184
+ height,
3185
+ };
3186
+ };
3187
+
3188
+ const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default["default"].createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
3189
+ 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 },
3190
+ 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" }))));
3191
+
3192
+ // url: imageBlocks.imageMobile.data.url
3193
+ // newTab: imageBlocks.imageMobile.data.newtab
3194
+ // imageMobile: campaignShow.image
3195
+ // imageDestkop: campaignShow.image_desktop
3196
+ const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
3197
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3198
+ const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
3199
+ if (!imageMobileLoaded || !imageDestkopLoaded)
3200
+ return null;
3201
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
3202
+ React__default["default"].createElement("div", { className: "le-center-tab-popup" },
3203
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
3204
+ React__default["default"].createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
3205
+ index$8.isVideo(imageMobile) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
3206
+ React__default["default"].createElement("source", { src: imageMobile }))) : (React__default["default"].createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
3207
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3208
+ } })),
3209
+ index$8.isVideo(imageDestkop) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
3210
+ React__default["default"].createElement("source", { src: imageDestkop }))) : (React__default["default"].createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
3211
+ aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
3212
+ } }))),
3213
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3214
+ };
3215
+
3216
+ // title: titleText
3217
+ // titleAlign: textBlocks.titleBlock.data.align
3218
+ // subtitle: textBlocks.subtitleBlock.data.value
3219
+ // subtitleAlign: textBlocks.subtitleBlock.data.align
3220
+ // url: actionBlocks.linkButtonBlock.data.url
3221
+ // urlText: actionBlocks.linkButtonBlock.data.value
3222
+ // newTab: actionBlocks.linkButtonBlock.data.newtab
3223
+ // imageMobile: campaignShow.image
3224
+ // imageDesktop: campaignShow.image_desktop
3225
+ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
3226
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3227
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
3228
+ if (!imageMobileLoaded || !imageDesktopLoaded)
3229
+ return null;
3230
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
3231
+ React__default["default"].createElement("aside", { className: "le-only-desktop" },
3232
+ React__default["default"].createElement("div", { className: "le-floating-desktop" },
3233
+ React__default["default"].createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
3234
+ imageDesktop ? (React__default["default"].createElement("div", null,
3235
+ React__default["default"].createElement("img", { style: {
3236
+ maxWidth: 120,
3237
+ borderTopLeftRadius: 5,
3238
+ borderBottomLeftRadius: 5,
3239
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
3240
+ }, src: imageDesktop }))) : null,
3241
+ React__default["default"].createElement("div", { style: { padding: 20 } },
3242
+ React__default["default"].createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
3243
+ React__default["default"].createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
3244
+ React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
3245
+ React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
3246
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
3247
+ React__default["default"].createElement("aside", { className: "le-only-mobile" },
3248
+ React__default["default"].createElement("div", { className: "le-floating-mobile" },
3249
+ React__default["default"].createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
3250
+ React__default["default"].createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
3251
+ React__default["default"].createElement("div", null,
3252
+ React__default["default"].createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
3253
+ React__default["default"].createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
3254
+ imageMobile ? (React__default["default"].createElement("div", null,
3255
+ React__default["default"].createElement("img", { style: {
3256
+ marginLeft: 15,
3257
+ marginTop: 4,
3258
+ maxWidth: 100,
3259
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3260
+ }, src: imageMobile }))) : null),
3261
+ React__default["default"].createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
3262
+ React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
3263
+ React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
3264
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
3265
+ };
3266
+
3267
+ const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
3268
+ const { primaryColor } = React.useContext(LeadGenContext$1);
3269
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
3270
+ if (!imageLoaded)
3271
+ return null;
3272
+ return (React__default["default"].createElement("div", { className: "lead-modal__thank-you leadgen-inner_thankyou" },
3273
+ React__default["default"].createElement("div", { style: { width: '100%' } },
3274
+ React__default["default"].createElement("img", { src: image, style: {
3275
+ maxHeight: 162,
3276
+ objectFit: 'cover',
3277
+ aspectRatio: `${imageWidth}/${imageHeight}`,
3278
+ }, loading: "lazy" }),
3279
+ title && (React__default["default"].createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
3280
+ subtitle && (React__default["default"].createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle.split('\n').map((text, idx, list) => {
3281
+ const isShowBr = idx < list.length - 1;
3282
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
3283
+ text,
3284
+ isShowBr && React__default["default"].createElement("br", null)));
3285
+ }))),
3286
+ linkText && (React__default["default"].createElement("div", null,
3287
+ React__default["default"].createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
3288
+ React__default["default"].createElement(index$4.Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
1541
3289
  };
1542
3290
 
1543
3291
  const InlineLayout = ({ content, inlinePosition, }) => {
@@ -1650,257 +3398,41 @@ const InlineLayout = ({ content, inlinePosition, }) => {
1650
3398
  return ReactDOM.createPortal(content, target);
1651
3399
  };
1652
3400
 
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
-
3401
+ const SideBarLayout = ({ content }) => {
3402
+ const targets = React.useMemo(() => {
3403
+ const targetDoms = Array.from(document.querySelectorAll('.hc2-sidebar-with-ads,.page-main-col .right-col.f-right,.hhg-lead-sidebar'));
3404
+ targetDoms.forEach((dom) => {
3405
+ if (dom.querySelector('.sidebar-lead-modal-wrapper'))
3406
+ return;
3407
+ const wrapper = document.createElement('div');
3408
+ wrapper.classList.add('sidebar-lead-modal-wrapper');
3409
+ dom.prepend(wrapper);
3410
+ });
3411
+ return targetDoms.map((d) => d.querySelector('.sidebar-lead-modal-wrapper'));
3412
+ }, []);
3413
+ return (React__default["default"].createElement(React__default["default"].Fragment, null, targets.map((target) => ReactDOM.createPortal(content, utils$1.getWrapperDomWithSelector(target, 'sidebar-lead-modal-wrapper')))));
3414
+ };
3415
+
3416
+ const EmptyIcon = (props) => {
3417
+ const { className, style } = props;
3418
+ 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 },
3419
+ 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" }),
3420
+ 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" }),
3421
+ 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" })));
3422
+ };
3423
+
3424
+ const EmptyComponent = ({ onClose, onContinue, }) => {
3425
+ const { t } = index$1.useTranslations();
3426
+ return (React__default["default"].createElement("div", { className: "leadgen-empty" },
3427
+ React__default["default"].createElement("div", { className: "leadgen-empty_body" },
3428
+ React__default["default"].createElement("div", { className: "leadgen-empty_wrapper" },
3429
+ React__default["default"].createElement(EmptyIcon, { className: "leadgen-empty_image" }),
3430
+ React__default["default"].createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
3431
+ React__default["default"].createElement("div", { className: "leadgen-empty_footer" },
3432
+ 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')),
3433
+ 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')))));
3434
+ };
3435
+
1904
3436
  const SubtitleBlock = ({ children, align, }) => (React__default["default"].createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
1905
3437
 
1906
3438
  const cssInputNotShrink = react.css `
@@ -2227,11 +3759,13 @@ const TextField = (props) => {
2227
3759
  const $focusEl = $textEl.item($textEl.length - 1);
2228
3760
  if ($focusEl) {
2229
3761
  $focusEl.focus();
2230
- $focusEl.scrollIntoView({
2231
- behavior: 'auto',
2232
- block: 'center',
2233
- inline: 'start',
2234
- });
3762
+ setTimeout(() => {
3763
+ $focusEl.scrollIntoView({
3764
+ behavior: 'auto',
3765
+ block: 'center',
3766
+ inline: 'start',
3767
+ });
3768
+ }, 100);
2235
3769
  }
2236
3770
  }, [shrink]);
2237
3771
  React.useEffect(() => {
@@ -2248,13 +3782,13 @@ const ChoiceField = (props) => {
2248
3782
  const TitleBlock = ({ children, align, }) => (React__default["default"].createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
2249
3783
 
2250
3784
  const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, }) => {
2251
- const { t } = index.useTranslations();
3785
+ const { t } = index$1.useTranslations();
2252
3786
  const form = useLeadFormContext();
2253
3787
  const formValues = form.values;
2254
3788
  const labelTuples = React.useMemo(() => {
2255
3789
  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
3790
  .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); });
3791
+ .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
3792
  }, [locale]);
2259
3793
  return (React__default["default"].createElement(React__default["default"].Fragment, null, listBlockAdded.map((b, index) => {
2260
3794
  var _a;
@@ -2297,7 +3831,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2297
3831
  }) },
2298
3832
  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
3833
  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,
3834
+ React__default["default"].createElement(index$3.Phone, Object.assign({ className: "mantine-Input-input", name: value, spellCheck: false, type: "tel", placeholder: placeholder,
2301
3835
  // onBlur={(e) => inputOnBlur('tel', e)}
2302
3836
  id: htmlForId, defaultCountry: (locale ? utils.MAPPED_LOCALE[locale] || 'VN' : 'VN'), "data-control": "tel" }, formPhoneInputWrapper))))));
2303
3837
  }
@@ -2313,7 +3847,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2313
3847
  case 'LinkButtonBlock':
2314
3848
  return (React__default["default"].createElement("div", { key: index },
2315
3849
  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: () => {
3850
+ React__default["default"].createElement(index$a.Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
2317
3851
  onClose === null || onClose === void 0 ? void 0 : onClose();
2318
3852
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2319
3853
  } }, value))));
@@ -2322,7 +3856,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2322
3856
  isSendMailChimp && (React__default["default"].createElement("div", { style: {
2323
3857
  display: 'none',
2324
3858
  }, "data-name": value + '-mailchimp' })),
2325
- React__default["default"].createElement(index$2.Checkbox.Group, Object.assign({ withAsterisk: required,
3859
+ React__default["default"].createElement(index$3.Checkbox.Group, Object.assign({ withAsterisk: required,
2326
3860
  // className="lead-modal__form-control leadgen-form_field"
2327
3861
  label: placeholder, size: "md", sx: {
2328
3862
  display: 'flex',
@@ -2331,19 +3865,19 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2331
3865
  gap: 8,
2332
3866
  }, inputWrapperOrder: ['label', 'input', 'description', 'error'], inputContainer: (children) => {
2333
3867
  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" }))))));
3868
+ } }, 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
3869
  case 'RadioBlock':
2336
3870
  return (React__default["default"].createElement(ChoiceField, { className: "leadgen-form_radio", key: index },
2337
3871
  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,
3872
+ React__default["default"].createElement(index$3.Radio.Group, Object.assign({ withAsterisk: required,
2339
3873
  // className="lead-modal__form-control leadgen-form_field"
2340
3874
  label: placeholder, size: "md", inputWrapperOrder: ['label', 'input', 'description', 'error'], inputContainer: (children) => {
2341
3875
  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" }))))));
3876
+ } }, 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
3877
  case 'DropdownBlock':
2344
3878
  return (React__default["default"].createElement(TextField, { shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field", key: index },
2345
3879
  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
3880
+ React__default["default"].createElement(index$3.Select
2347
3881
  // className="lead-modal__form-control leadgen-form_field"
2348
3882
  , Object.assign({
2349
3883
  // className="lead-modal__form-control leadgen-form_field"
@@ -2355,7 +3889,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2355
3889
  const _d = form.getInputProps(`TNC-${id}`), { error } = _d, tncInputProps = tslib_es6.__rest(_d, ["error"]);
2356
3890
  return (React__default["default"].createElement(ChoiceField, { className: "leadgen-form_checkbox", key: id },
2357
3891
  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)))));
3892
+ 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
3893
  }
2360
3894
  return null;
2361
3895
  })));
@@ -2421,842 +3955,498 @@ const FormContainer = (_a) => {
2421
3955
  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
3956
  const HeaderContent = (React__default["default"].createElement("div", { className: "leadgen-form_header" },
2423
3957
  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 ');
3958
+ !!description && (React__default["default"].createElement("p", { title: description, className: "leadgen-description", "data-align": descriptionAlign, dangerouslySetInnerHTML: { __html: description } }))));
3959
+ if (!title && !description) {
3960
+ return null;
3961
+ }
3962
+ return (React__default["default"].createElement(StyledFormContainer, Object.assign({ className: core.clsx(className, 'leadgen-form_container'), style: style }, restProps),
3963
+ React__default["default"].createElement("div", { className: "leadgen-form_wrapper" },
3964
+ !!header && (React__default["default"].createElement("div", { className: "leadgen-form_scrollable" },
3965
+ header,
3966
+ HeaderContent,
3967
+ React__default["default"].createElement("div", { className: "leadgen-form_body" }, children))),
3968
+ !header && (React__default["default"].createElement(React__default["default"].Fragment, null,
3969
+ HeaderContent,
3970
+ React__default["default"].createElement("div", { className: "leadgen-form_body" }, children))),
3971
+ React__default["default"].createElement("div", { className: "leadgen-form_footer" }, footer))));
3972
+ };
3973
+
3974
+ const StyleHeaderImage = styled__default["default"].div `
3975
+ position: relative;
3976
+ overflow: hidden;
3977
+ width: 100%;
3978
+ height: 100%;
3979
+ padding-top: ${({ paddingTop }) => paddingTop}%;
3980
+ .leadgen-header_image_feature {
3981
+ position: absolute;
3982
+ inset: 0;
3983
+ min-width: 100%;
3984
+ min-height: 100%;
3985
+ max-width: 100%;
3986
+ max-height: 100%;
3987
+ object-fit: cover;
3988
+ object-position: center;
3989
+ }
3990
+ `;
3991
+ const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
3992
+ if (!src) {
2649
3993
  return null;
2650
3994
  }
3995
+ 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" }))));
3996
+ };
3997
+
3998
+ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
3999
+ const { primaryColor } = React.useContext(LeadGenContext$1);
4000
+ const { t } = index$1.useTranslations();
4001
+ const phone = otpData.phone;
4002
+ const otpType = otpData.type;
4003
+ const [otp, setOtp] = React.useState('');
4004
+ const [isDirty, setIsDirty] = React.useState(false);
4005
+ const [resendTimer, setResendTimer] = React.useState(autoSendWhenOpen ? 0 : 60);
4006
+ const inputRef = React.useRef(null);
4007
+ const [errorMsg, setErrorMsg] = React.useState();
4008
+ const [displayPhone, setDisplayPhone] = React.useState('');
4009
+ const formatPhoneNumberIntlRef = React.useRef();
4010
+ const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
2651
4011
  React.useEffect(() => {
2652
- if (isLightBox || isFullscreen) {
2653
- document.body.classList.add('noscroll');
4012
+ (() => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
4013
+ var _a;
4014
+ if (!formatPhoneNumberIntlRef.current) {
4015
+ const res = yield Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('react-phone-number-input')); });
4016
+ formatPhoneNumberIntlRef.current = res.formatPhoneNumberIntl;
4017
+ }
4018
+ setDisplayPhone(((_a = formatPhoneNumberIntlRef.current) === null || _a === void 0 ? void 0 : _a.call(formatPhoneNumberIntlRef, phone)) || phone);
4019
+ }))();
4020
+ }, [phone]);
4021
+ const sendOtp = () => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
4022
+ var _a;
4023
+ if (!phone) {
4024
+ return;
2654
4025
  }
2655
- if (!window.intlTelInputUtils) {
2656
- require('intl-tel-input/build/js/utils');
4026
+ const res = yield Service.sendSMSOtpLead({
4027
+ phone,
4028
+ type: otpType,
4029
+ });
4030
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4031
+ if (respMessage === 'Send sms successfully' ||
4032
+ respMessage === 'Send WhatsApp successfully' ||
4033
+ respMessage === 'Send Zalo successfully') {
4034
+ setResendTimer(60);
4035
+ setTimeout(() => {
4036
+ if (inputRef.current) {
4037
+ inputRef.current.focus();
4038
+ inputRef.current.scrollIntoView({ block: 'center' });
4039
+ }
4040
+ }, 100);
4041
+ }
4042
+ else if (respMessage === 'This phone number was verified') {
4043
+ onSuccess();
4044
+ }
4045
+ else {
4046
+ setErrorMsg(respMessage || 'Something went wrong!');
4047
+ // const defaultError = f({ id: 'notification.comment.somethingWrong' })
4048
+ // setStatusVerifyOTP('idle')
4049
+ // pushNotifications({
4050
+ // title: respMessage || defaultError,
4051
+ // message: '',
4052
+ // type: 'danger',
4053
+ // })
2657
4054
  }
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
4055
  });
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) {
4056
+ const submitOtp = () => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
4057
+ if (!phone || !otp) {
2681
4058
  return;
2682
4059
  }
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});}`;
4060
+ setIsSubmitLoading(true);
4061
+ const res = yield Service.verifyOtpLead({
4062
+ phone,
4063
+ otp,
4064
+ type: otpType,
4065
+ });
4066
+ const respMessage = res === null || res === void 0 ? void 0 : res._messages[0];
4067
+ if (respMessage === 'Verify successfully' ||
4068
+ respMessage === 'Verify WhatsApp OTP sucess' ||
4069
+ respMessage === 'Verify Zalo OTP sucess') {
4070
+ onSuccess();
2794
4071
  }
2795
- if (!isMobile && imageOverlayDesktop) {
2796
- styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4072
+ else if (respMessage === 'This phone number was verified') {
4073
+ onSuccess();
2797
4074
  }
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,
4075
+ else {
4076
+ setErrorMsg(respMessage || 'something Wrong');
4077
+ // setIsShowError(true)
4078
+ // setStatusVerifyOTP('sent')
4079
+ // pushNotifications({
4080
+ // title: res?._messages[0] || defaultError,
4081
+ // message: '',
4082
+ // type: 'danger',
4083
+ // })
4084
+ }
4085
+ setIsSubmitLoading(false);
2811
4086
  });
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 }))))));
4087
+ React.useEffect(() => {
4088
+ setTimeout(() => {
4089
+ if (resendTimer > 0) {
4090
+ setResendTimer((r) => r - 1);
4091
+ }
4092
+ }, 1000);
4093
+ }, [resendTimer]);
4094
+ React.useEffect(() => {
4095
+ if (autoSendWhenOpen && !resendTimer) {
4096
+ sendOtp();
4097
+ }
4098
+ }, []);
4099
+ return (React__default["default"].createElement("form", { onSubmit: (e) => {
4100
+ e.preventDefault();
4101
+ submitOtp();
4102
+ }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
4103
+ React__default["default"].createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
4104
+ phone: `<strong>${displayPhone}</strong>`,
4105
+ }), footer: React__default["default"].createElement(React__default["default"].Fragment, null,
4106
+ 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')),
4107
+ 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: () => {
4108
+ sendOtp();
4109
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
4110
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
4111
+ }))) },
4112
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4113
+ React__default["default"].createElement(index$3.Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
4114
+ React__default["default"].createElement(index$3.OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
4115
+ setIsDirty(true);
4116
+ setOtp(v.toString());
4117
+ if (isDirty && !v)
4118
+ setErrorMsg('OTP is required');
4119
+ else
4120
+ setErrorMsg(undefined);
4121
+ } }))))));
2890
4122
  };
2891
4123
 
2892
4124
  // url: imageBlocks.imageMobile.data.url
2893
4125
  // newTab: imageBlocks.imageMobile.data.newtab
2894
4126
  // image: campaignShow.image
2895
4127
  // 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) {
4128
+ const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
4129
+ LEADGEN_LAYOUT.Fullscreen,
4130
+ LEADGEN_LAYOUT.Slider,
4131
+ ];
4132
+ const LEADGEN_LIMIT_LIGHTBOXB = 6;
4133
+ const LEADGEN_SHOW_HEADER = [
4134
+ 'LightBoxA',
4135
+ 'InlineA',
4136
+ LEADGEN_LAYOUT.Sidebar,
4137
+ LEADGEN_LAYOUT.Slider,
4138
+ ];
4139
+ 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
4140
  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;
4141
+ const { primaryColor } = React.useContext(LeadGenContext$1);
4142
+ const { isMobile } = useScreenSize.useScreenSize();
4143
+ const [open, setOpen] = React.useState(!!campaignId);
4144
+ const [showOtpPhone, setShowOtpPhone] = React.useState(null);
4145
+ const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
4146
+ const [snap, setSnap] = React.useState(0.8);
4147
+ const formRef = React.useRef();
4148
+ const onClose = () => {
4149
+ if (showOtpPhone) {
4150
+ setShowOtpPhone(null);
3013
4151
  }
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;
4152
+ else {
4153
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
3018
4154
  }
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);
4155
+ };
4156
+ const textBlocks = JSON.parse(extraFields.textBlocks);
4157
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
4158
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
4159
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
4160
+ const currentPath = location.pathname;
4161
+ const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
4162
+ const { align: titleAlign } = textBlocks.titleBlock.data || {};
4163
+ const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
4164
+ const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
4165
+ const isLightBox = currentLayout.includes('LightBox');
4166
+ const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
4167
+ const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
4168
+ const isInline = currentLayout.includes('Inline');
4169
+ const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
4170
+ const isInPage = isInline || isSidebar;
4171
+ const isDrawer = isLightBoxB && isMobile;
4172
+ const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
4173
+ const hasForm = isLightBoxA
4174
+ ? listBlockAdded.some((item) => LEADGEN_BLOCK_INPUT.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
4175
+ : true;
4176
+ const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
4177
+ const showHeader = !!imageMobile || !!imageDesktop;
4178
+ const onlyHeader = !title && !description;
4179
+ const showButtonClose = !isInline;
4180
+ if (window.innerWidth < 769 &&
4181
+ LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
4182
+ console.log('😎 Not show fullscreen, slider on mobile ');
4183
+ return null;
3042
4184
  }
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;
4185
+ React.useEffect(() => {
4186
+ if (isLightBox || isFullscreen) {
4187
+ document.body.classList.add('noscroll');
3062
4188
  }
3063
- if (isTimeInRange(new Date(), startTime, endTime)) {
3064
- return true;
4189
+ if (!window.intlTelInputUtils) {
4190
+ require('intl-tel-input/build/js/utils');
3065
4191
  }
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);
4192
+ clearCacheUsedEmailOrPhone();
4193
+ }, []);
4194
+ const validatingPhoneRef = React.useRef(false);
4195
+ const validatingEmailRef = React.useRef(false);
4196
+ const { form, validateObj } = useLeadFormConfig({
4197
+ listBlockAdded,
4198
+ validatingPhoneRef,
4199
+ validatingEmailRef,
4200
+ campaignId,
4201
+ campaign_subot_id,
4202
+ userInfo,
4203
+ format: (_a = (index$7.ISO_FORMAT[locale] || index$7.ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
4204
+ });
4205
+ const onFocus = (e) => {
4206
+ const target = e.target;
4207
+ target.scrollIntoView({
4208
+ block: 'center',
4209
+ inline: 'nearest',
4210
+ behavior: 'auto',
4211
+ });
4212
+ };
4213
+ const middlewareOnSubmit = (e) => {
4214
+ e.preventDefault();
4215
+ // mark all as touched to allow validation
4216
+ const fields = Object.keys(validateObj);
4217
+ const fieldStatus = fields.reduce((acc, cur) => {
4218
+ acc[cur] = true;
4219
+ return acc;
4220
+ }, {});
4221
+ form.setTouched(fieldStatus);
4222
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
4223
+ return;
4224
+ }
4225
+ setTimeout(() => {
4226
+ form.onSubmit((v) => {
4227
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4228
+ if (Object.keys(form.errors).length)
4229
+ return;
4230
+ let newShowOtpPhone = null;
4231
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
4232
+ // not submit yet, open otp
4233
+ 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;
4234
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
4235
+ newShowOtpPhone = {
4236
+ phone: v[fieldName],
4237
+ type: 'phone',
4238
+ };
4239
+ }
3216
4240
  }
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);
4241
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
4242
+ // not submit yet, open otp
4243
+ 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;
4244
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
4245
+ newShowOtpPhone = {
4246
+ phone: v[fieldName],
4247
+ type: 'whatsapp',
4248
+ };
4249
+ }
4250
+ }
4251
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
4252
+ // not submit yet, open otp
4253
+ 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;
4254
+ if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
4255
+ newShowOtpPhone = {
4256
+ phone: v[fieldName],
4257
+ type: 'zalo',
4258
+ };
4259
+ }
4260
+ }
4261
+ if (newShowOtpPhone) {
4262
+ setIsSubmitLoading(true);
4263
+ Service.sendSMSOtpLead(newShowOtpPhone)
4264
+ .then((res) => {
4265
+ var _a;
4266
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4267
+ if (respMessage === 'This phone number was verified') {
4268
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4269
+ return;
3236
4270
  }
3237
- };
3238
- window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
3239
- passive: true,
4271
+ setShowOtpPhone(newShowOtpPhone);
4272
+ })
4273
+ .finally(() => {
4274
+ setIsSubmitLoading(false);
3240
4275
  });
4276
+ return;
3241
4277
  }
3242
- }
3243
- else {
3244
- LeadLog('🚧 No lead campaigns on current URL, tags');
3245
- }
4278
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4279
+ })(e);
4280
+ }, 100);
4281
+ };
4282
+ const onOpenChange = (_open) => {
4283
+ setOpen(_open);
4284
+ if (!_open) {
4285
+ setTimeout(() => {
4286
+ onClose();
4287
+ }, 250);
3246
4288
  }
3247
- })
3248
- .catch((err) => {
3249
- LeadLog(`Lead error: `, err);
4289
+ };
4290
+ const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
4291
+ const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
4292
+ const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
4293
+ const renderAfterImageSizes = imageMobileLoaded &&
4294
+ imageDesktopLoaded &&
4295
+ (isFullscreen ? imageBackgroundLoaded : true);
4296
+ const ButtonSubmit = React.useMemo(() => {
4297
+ var _a;
4298
+ 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));
4299
+ }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
4300
+ const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
4301
+ const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default["default"].createElement(React__default["default"].Fragment, null, LinkButtonBlock.map((item, index) => {
4302
+ var _a, _b, _c;
4303
+ 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: () => {
4304
+ onClose === null || onClose === void 0 ? void 0 : onClose();
4305
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
4306
+ } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
4307
+ })));
4308
+ 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,
4309
+ React__default["default"].createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
4310
+ React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
4311
+ const PopupEmpty = showEmpty && (React__default["default"].createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
4312
+ const PopupForm = (React__default["default"].createElement(LeadFormProvider, { form: form },
4313
+ React__default["default"].createElement("form", { ref: formRef, className: "leadgen-form", onFocus: onFocus, onSubmit: middlewareOnSubmit },
4314
+ React__default["default"].createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
4315
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4316
+ React__default["default"].createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
4317
+ const PopupOtp = showOtpPhone && (React__default["default"].createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
4318
+ setShowOtpPhone(null);
4319
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
4320
+ } }));
4321
+ 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 }));
4322
+ const PopupContent = (React__default["default"].createElement("div", { className: core.clsx('leadgen-content', {
4323
+ 'leadgen-content_small': limitFieldsLightBoxB,
4324
+ }) },
4325
+ !headerInsideFormContainer && PopupHeader,
4326
+ !onlyHeader && (React__default["default"].createElement("div", { className: "leadgen-inner" },
4327
+ PopupThankYou,
4328
+ !showThankyou && (React__default["default"].createElement(React__default["default"].Fragment, null,
4329
+ PopupOtp,
4330
+ PopupEmpty,
4331
+ !(showOtpPhone || showEmpty) && PopupForm))))));
4332
+ const styleOverlay = React.useMemo(() => {
4333
+ let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
4334
+ if (isMobile && imageOverlayMobile) {
4335
+ styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4336
+ }
4337
+ if (!isMobile && imageOverlayDesktop) {
4338
+ styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4339
+ }
4340
+ return styleContent;
4341
+ }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
4342
+ const PopupWrapper = (React__default["default"].createElement(React__default["default"].Fragment, null,
4343
+ React__default["default"].createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
4344
+ React__default["default"].createElement("div", { className: core.clsx('leadgen-wrapper', {
4345
+ 'leadgen-wrapper_small': limitFieldsLightBoxB,
4346
+ }) },
4347
+ showButtonClose && (React__default["default"].createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
4348
+ PopupContent)));
4349
+ const popupContainerClassName = core.clsx('leadgen', `leadgen-${currentLayout}`, {
4350
+ 'leadgen-lightbox': isLightBox,
4351
+ 'leadgen-inline': isInPage,
4352
+ 'leadgen-slider': isSlider,
3250
4353
  });
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);
4354
+ 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" },
4355
+ PopupWrapper,
4356
+ 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 },
4357
+ isFullscreen ? (React__default["default"].createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
4358
+ aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
4359
+ } })) : null,
4360
+ PopupWrapper));
4361
+ if (!renderAfterImageSizes)
4362
+ return null;
4363
+ if (isLightBox || isFullscreen || isSlider) {
4364
+ return PopupContainer;
4365
+ }
4366
+ else if (isSidebar) {
4367
+ return React__default["default"].createElement(SideBarLayout, { content: PopupContainer });
3259
4368
  }
4369
+ else if (isInline) {
4370
+ return (React__default["default"].createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
4371
+ }
4372
+ return null;
4373
+ };
4374
+
4375
+ const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
4376
+ const currentPath = location.pathname;
4377
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
4378
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
4379
+ if (!imageMobileLoaded || !imageDesktopLoaded)
4380
+ return null;
4381
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
4382
+ currentLayout == 'SkinA' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4383
+ React__default["default"].createElement("div", { className: "le-skin-a-desktop" },
4384
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
4385
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
4386
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4387
+ } }),
4388
+ React__default["default"].createElement("a", { style: {
4389
+ position: 'absolute',
4390
+ top: '75%',
4391
+ left: '50%',
4392
+ transform: 'translate(-50%, -50%)',
4393
+ textAlign: 'center',
4394
+ width: 'calc(100% - 15px)',
4395
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4396
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
4397
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4398
+ React__default["default"].createElement("div", { className: "" },
4399
+ React__default["default"].createElement("div", { style: { position: 'relative', zIndex: 10000 } },
4400
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
4401
+ width: '100%',
4402
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4403
+ } }),
4404
+ React__default["default"].createElement("a", { style: {
4405
+ position: 'absolute',
4406
+ top: '75%',
4407
+ left: '50%',
4408
+ transform: 'translate(-50%, -50%)',
4409
+ textAlign: 'center',
4410
+ width: '100%',
4411
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4412
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4413
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
4414
+ React__default["default"].createElement("aside", { className: "le-only-mobile" },
4415
+ React__default["default"].createElement("div", { className: "le-skin-mobile" },
4416
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
4417
+ index$8.isVideo(imageMobile) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true },
4418
+ React__default["default"].createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default["default"].createElement("img", { src: imageMobile, style: {
4419
+ width: '100%',
4420
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
4421
+ } })),
4422
+ React__default["default"].createElement("a", { style: {
4423
+ position: 'absolute',
4424
+ top: '82%',
4425
+ left: '50%',
4426
+ transform: 'translate(-50%, -50%)',
4427
+ textAlign: 'center',
4428
+ maxWidth: 'calc(100% - 15px)',
4429
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4430
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4431
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4432
+ };
4433
+
4434
+ // url: imageBlocks.imageMobile.data.url
4435
+ // newTab: imageBlocks.imageMobile.data.newtab
4436
+ // image: campaignShow.image
4437
+ // imageDestkop: campaignShow.image_desktop
4438
+ const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
4439
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
4440
+ if (!imageLoaded)
4441
+ return null;
4442
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
4443
+ React__default["default"].createElement("div", { className: "le-tab-popup" },
4444
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
4445
+ React__default["default"].createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
4446
+ React__default["default"].createElement("img", { className: "js-popup-other-submit", src: image, style: {
4447
+ aspectRatio: `${imageWidth}/${imageHeight}`,
4448
+ } })),
4449
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3260
4450
  };
3261
4451
 
3262
4452
  function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
@@ -3272,7 +4462,7 @@ function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
3272
4462
  }
3273
4463
  const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, showEmpty, setShowEmpty, userInfo, }) => {
3274
4464
  var _a, _b;
3275
- const { apiUrl, siteDomain } = React.useContext(LeadGenContext);
4465
+ const { apiUrl, siteDomain } = React.useContext(LeadGenContext$1);
3276
4466
  React.useEffect(() => {
3277
4467
  const gaCookie = miscCookieHelper.getCookie('_ga') || null;
3278
4468
  fetch(`${apiUrl}api/campaign/${code}/impression`, {
@@ -3667,7 +4857,7 @@ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, primaryColor
3667
4857
  leadStartTimeRef.current = Date.now();
3668
4858
  }
3669
4859
  }, [showCampaign]);
3670
- return (React__default["default"].createElement(LeadGenContext.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
4860
+ return (React__default["default"].createElement(LeadGenContext$1.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
3671
4861
  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
4862
  React__default["default"].createElement(core.Box, { sx: { position: 'fixed', zIndex: index$7.ZINDEX_SSO - 9e6 } },
3673
4863
  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 +4878,4 @@ LeadGen.OtpForm = OtpBlock$1;
3688
4878
  LeadGen.Close = Close.Close;
3689
4879
 
3690
4880
  exports.LeadGen = LeadGen;
4881
+ exports.LeadGenSubscriptionBox = LeadGenSubscriptionBox;