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

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 (531) hide show
  1. package/build/{InputDate-877c23c7.js → InputDate-9746e093.js} +3 -3
  2. package/build/{LastPeriod-dce971c7.js → LastPeriod-b3289339.js} +1 -1
  3. package/build/{MobileBottomNavigationIcon-879f9756.js → MobileBottomNavigationIcon-e1b98872.js} +3 -3
  4. package/build/{Spinner-229e09f1.js → Spinner-d314a67a.js} +1 -1
  5. package/build/{WhatsApp-5ab7c58d.js → WhatsApp-a8b76a33.js} +1 -1
  6. package/build/adapters.js +19 -19
  7. package/build/atoms.js +48 -48
  8. package/build/babyGrowth.js +83 -83
  9. package/build/cache.js +2 -2
  10. package/build/care.js +17 -17
  11. package/build/careBookingSearchBar.js +14 -14
  12. package/build/careBookingSearchBarV2.js +15 -15
  13. package/build/components/mantine/phone/index.d.ts +0 -2
  14. package/build/components.js +96 -97
  15. package/build/{constants-4aa46cbb.js → constants-6af492f0.js} +1 -1
  16. package/build/constants.js +3 -3
  17. package/build/constantsDomainLocales.js +1 -1
  18. package/build/constantsRiskScreener.js +2 -2
  19. package/build/constantsSite.js +2 -2
  20. package/build/{core-f2b87dfd.js → core-1953f8f6.js} +1 -1
  21. package/build/{dataTransform-cfc6325f.js → dataTransform-299d341e.js} +1 -1
  22. package/build/ecom.js +4 -4
  23. package/build/{editor-7954fc77.js → editor-9e5803b8.js} +11 -11
  24. package/build/embeddedHeathToolCards_babyGrowth.js +23 -23
  25. package/build/embeddedHeathToolCards_babyPoop.js +19 -19
  26. package/build/embeddedHeathToolCards_babyVaccine.js +22 -22
  27. package/build/embeddedHeathToolCards_bmi_bmi.js +25 -25
  28. package/build/embeddedHeathToolCards_bmrBmr.js +25 -25
  29. package/build/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  30. package/build/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  31. package/build/embeddedHeathToolCards_pwg_pwg.js +26 -26
  32. package/build/embeddedHeathToolCards_targetHeartRate.js +27 -27
  33. package/build/esm/{InputDate-2d1744e8.js → InputDate-c0b788ac.js} +3 -3
  34. package/build/esm/{LastPeriod-4edad391.js → LastPeriod-da33c15d.js} +1 -1
  35. package/build/esm/{MobileBottomNavigationIcon-58e04c72.js → MobileBottomNavigationIcon-12879b99.js} +3 -3
  36. package/build/esm/{Spinner-a8a10423.js → Spinner-db469081.js} +1 -1
  37. package/build/esm/{WhatsApp-1b8c1d61.js → WhatsApp-73d081fc.js} +1 -1
  38. package/build/esm/adapters.js +19 -19
  39. package/build/esm/atoms.js +48 -48
  40. package/build/esm/babyGrowth.js +83 -83
  41. package/build/esm/cache.js +2 -2
  42. package/build/esm/care.js +17 -17
  43. package/build/esm/careBookingSearchBar.js +14 -14
  44. package/build/esm/careBookingSearchBarV2.js +15 -15
  45. package/build/esm/components/mantine/phone/index.d.ts +0 -2
  46. package/build/esm/components.js +96 -97
  47. package/build/esm/{constants-b2d46ae1.js → constants-18894c10.js} +1 -1
  48. package/build/esm/constants.js +3 -3
  49. package/build/esm/constantsDomainLocales.js +1 -1
  50. package/build/esm/constantsRiskScreener.js +2 -2
  51. package/build/esm/constantsSite.js +2 -2
  52. package/build/esm/{core-cdb21f41.js → core-9f8d6b2f.js} +1 -1
  53. package/build/esm/{dataTransform-65a659b9.js → dataTransform-7a22b3a7.js} +1 -1
  54. package/build/esm/ecom.js +4 -4
  55. package/build/esm/{editor-ab9eebab.js → editor-df66b793.js} +11 -11
  56. package/build/esm/embeddedHeathToolCards_babyGrowth.js +23 -23
  57. package/build/esm/embeddedHeathToolCards_babyPoop.js +19 -19
  58. package/build/esm/embeddedHeathToolCards_babyVaccine.js +22 -22
  59. package/build/esm/embeddedHeathToolCards_bmi_bmi.js +25 -25
  60. package/build/esm/embeddedHeathToolCards_bmrBmr.js +25 -25
  61. package/build/esm/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  62. package/build/esm/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  63. package/build/esm/embeddedHeathToolCards_pwg_pwg.js +26 -26
  64. package/build/esm/embeddedHeathToolCards_targetHeartRate.js +27 -27
  65. package/build/esm/footer.js +21 -21
  66. package/build/esm/gAssets.js +2 -2
  67. package/build/esm/{healthTools-b3cf91fc.js → healthTools-f90bfa20.js} +1 -1
  68. package/build/esm/healthToolsCardWrapper.js +18 -18
  69. package/build/esm/healthToolsForm.js +33 -33
  70. package/build/esm/hooks.js +13 -13
  71. package/build/esm/i18n.js +56 -14
  72. package/build/esm/i18nV2.js +2 -2
  73. package/build/esm/{index-b0408a4c.js → index-07b81bb7.js} +27 -36
  74. package/build/esm/{index-91a9cf15.js → index-0a217701.js} +1 -1
  75. package/build/esm/{index-0dbb9857.js → index-0c735d3c.js} +17 -17
  76. package/build/esm/{index-96f04c6f.js → index-0e19d192.js} +2 -2
  77. package/build/esm/{index-7b234b2f.js → index-126572b4.js} +17 -17
  78. package/build/esm/{index-af781e76.js → index-128f0837.js} +3 -3
  79. package/build/esm/{index-4a7d9b16.js → index-13feaf1a.js} +4 -4
  80. package/build/esm/{index-1ce2f300.js → index-1a274479.js} +1 -1
  81. package/build/esm/{index-bf06cb9e.js → index-1c00c095.js} +16 -16
  82. package/build/esm/{index-dc2e59c8.js → index-1fd83190.js} +2 -2
  83. package/build/esm/{index-9fd572cf.js → index-26f91073.js} +2 -2
  84. package/build/esm/{index-29eb6825.js → index-2a6cde75.js} +2 -2
  85. package/build/esm/{index-0d13ebdc.js → index-316933cd.js} +17 -17
  86. package/build/esm/{index-2ecdf8f7.js → index-34ffb6c1.js} +16 -16
  87. package/build/esm/{index-80849ded.js → index-388b5a52.js} +3 -3
  88. package/build/esm/{index-ad7b17d1.js → index-3c763567.js} +24 -24
  89. package/build/esm/{index-24e6abe4.js → index-3e1277d2.js} +2 -2
  90. package/build/esm/{index-86f33571.js → index-46b0d30a.js} +2 -2
  91. package/build/esm/{index-bb401984.js → index-4ba59648.js} +2 -2
  92. package/build/esm/{index-6cde560e.js → index-4f0a6c84.js} +3 -3
  93. package/build/esm/{index-5dd7d058.js → index-53894be7.js} +16 -16
  94. package/build/esm/{index-a6e497c8.js → index-56b5378a.js} +15 -15
  95. package/build/esm/{index-9fb49296.js → index-57aabb5e.js} +7 -7
  96. package/build/esm/{index-34a2735d.js → index-5a7a5244.js} +31 -31
  97. package/build/esm/{index-09f6ffac.js → index-5aef6986.js} +25 -25
  98. package/build/esm/{index-1dd399ff.js → index-5d0200f0.js} +6 -6
  99. package/build/esm/{index-a7f46108.js → index-5e6dc6db.js} +3 -3
  100. package/build/esm/{index-99d4fdc5.js → index-61a111f8.js} +7 -7
  101. package/build/esm/{index-07405452.js → index-681d28d8.js} +2 -2
  102. package/build/esm/{index-29b629ba.js → index-6a5f45df.js} +1 -1
  103. package/build/esm/{index-d99d8050.js → index-6ac72472.js} +2 -2
  104. package/build/esm/{index-0b415d96.js → index-6e1ef507.js} +13 -13
  105. package/build/esm/{index-3abd9462.js → index-6fac949c.js} +2 -2
  106. package/build/esm/{index-ab98d2e6.js → index-760ba1e0.js} +10 -10
  107. package/build/esm/{index-0a373dbd.js → index-7dbb26d3.js} +6 -6
  108. package/build/esm/{index-e9ef9c5f.js → index-7e78248e.js} +6 -6
  109. package/build/esm/{index-ecc33faa.js → index-7f770fe8.js} +6 -6
  110. package/build/esm/{index-84163960.js → index-8b74f8e4.js} +1 -1
  111. package/build/esm/{index-00eec91f.js → index-8c47541d.js} +32 -32
  112. package/build/esm/{index-c12fa11f.js → index-90bb49a7.js} +18 -18
  113. package/build/esm/{index-0875a025.js → index-98cfd37b.js} +13 -13
  114. package/build/esm/{index-36e7f702.js → index-996fae38.js} +32 -32
  115. package/build/esm/{index-9024c338.js → index-99b5a528.js} +3 -3
  116. package/build/esm/{index-1da437a9.js → index-9bfc12bd.js} +21 -21
  117. package/build/esm/{index-679ad173.js → index-9fe97cf0.js} +1 -1
  118. package/build/esm/{index-396001bf.js → index-a4c8373a.js} +3 -3
  119. package/build/esm/{index-551bea97.js → index-ad8d1314.js} +1 -1
  120. package/build/esm/{index-1c12fb8b.js → index-b23acf00.js} +17 -17
  121. package/build/esm/{index-798f9e4d.js → index-c3500f4e.js} +2 -2
  122. package/build/esm/{index-dfb2ffea.js → index-cc1d1a1a.js} +2 -2
  123. package/build/esm/{index-113e360a.js → index-cd5faa30.js} +1 -1
  124. package/build/esm/{index-b7697f7b.js → index-d1038670.js} +2 -2
  125. package/build/esm/{index-39dddbb8.js → index-d2068808.js} +18 -18
  126. package/build/esm/{index-9f1abe5b.js → index-d534eff3.js} +3 -3
  127. package/build/esm/{index-b45bb27d.js → index-db312639.js} +8 -8
  128. package/build/esm/{index-1f9a2231.js → index-df5a5394.js} +5 -5
  129. package/build/esm/{index-be7ff82e.js → index-dfb047ee.js} +16 -16
  130. package/build/esm/{index-0b1e4b7f.js → index-e04827a2.js} +13 -13
  131. package/build/esm/{index-e3f57899.js → index-eeb5bd9e.js} +13 -13
  132. package/build/esm/{index-1fe0be54.js → index-ef33fd3f.js} +1 -1
  133. package/build/esm/{index-ce1be417.js → index-ef81684d.js} +6 -6
  134. package/build/esm/{index-5eb619ff.js → index-f3b8d349.js} +22 -22
  135. package/build/esm/{index-68074a37.js → index-f5f10d16.js} +1 -1
  136. package/build/esm/{index-fcf40ad6.js → index-f9f05826.js} +5 -5
  137. package/build/esm/index.js +117 -118
  138. package/build/esm/interfaces/types/index.d.ts +0 -1
  139. package/build/esm/{labelSorting-0480782a.js → labelSorting-5231682b.js} +4 -4
  140. package/build/esm/lead/helpers.d.ts +1 -56
  141. package/build/esm/lead/index.d.ts +1 -2
  142. package/build/esm/lead/services/index.d.ts +0 -21
  143. package/build/esm/lead/store/index.d.ts +0 -1
  144. package/build/esm/lead.js +986 -2162
  145. package/build/esm/{logoIcon-6aa39f66.js → logoIcon-c50c983d.js} +2 -2
  146. package/build/esm/mantine.js +25 -25
  147. package/build/esm/misc.js +17 -17
  148. package/build/esm/miscGetDynamicHealthTool.js +4 -4
  149. package/build/esm/miscGetSocialList.js +8 -8
  150. package/build/esm/miscScreenSizeContext.js +1 -1
  151. package/build/esm/mobileBottomNavigation.js +5 -5
  152. package/build/esm/mobileBottomNavigationIcon.js +5 -5
  153. package/build/esm/molecules.js +73 -74
  154. package/build/esm/moleculesArticleCard.js +6 -6
  155. package/build/esm/moleculesArticleCardV2.js +16 -16
  156. package/build/esm/navigation.js +45 -46
  157. package/build/esm/navigationLogoutPopup.js +9 -9
  158. package/build/esm/navigationProfileButton.js +23 -23
  159. package/build/esm/onboardingV2.js +29 -29
  160. package/build/esm/organisms.js +49 -50
  161. package/build/esm/{post-bd18ae33.js → post-6fd50030.js} +2 -2
  162. package/build/esm/profileNavigation.js +19 -19
  163. package/build/esm/progressBar.js +1 -1
  164. package/build/esm/pwg.js +22 -22
  165. package/build/esm/ssoV2/api/featureFlag.d.ts +1 -2
  166. package/build/esm/ssoV2.js +40 -53
  167. package/build/esm/{store-1b3563da.js → store-1c63d8b0.js} +183 -6
  168. package/build/esm/subot.js +35 -36
  169. package/build/esm/surveyOrPremiumBanner.js +32 -33
  170. package/build/esm/surveyQuestionCard.js +10 -10
  171. package/build/esm/{surveyThankyouCard-e0cb0e4f.js → surveyThankyouCard-a0c5903d.js} +5 -5
  172. package/build/esm/together.js +55 -56
  173. package/build/esm/togetherApiUtils.js +4 -4
  174. package/build/esm/togetherAtoms.js +30 -30
  175. package/build/esm/togetherComponentGlobalContext.js +4 -4
  176. package/build/esm/togetherMolecules.js +50 -51
  177. package/build/esm/togetherMoleculesCardAuthor.js +28 -28
  178. package/build/esm/togetherMoleculesPostImagePreview.js +11 -11
  179. package/build/esm/togetherMoleculesProfileDetail.js +38 -39
  180. package/build/esm/togetherOrganisms.js +49 -50
  181. package/build/esm/togetherRichTextEditor.js +17 -17
  182. package/build/esm/togetherShareBox.js +10 -10
  183. package/build/esm/{treePopoverMenu-957c961f.js → treePopoverMenu-a42b3049.js} +19 -19
  184. package/build/esm/{types-eb7bf5f2.js → types-580c541f.js} +2 -2
  185. package/build/esm/types.js +2 -2
  186. package/build/esm/{useCategory-6138ae0c.js → useCategory-b739faac.js} +5 -5
  187. package/build/esm/{useHealthToolCache-e2d184a8.js → useHealthToolCache-87091430.js} +1 -1
  188. package/build/esm/{useMantineLocale-80e1b6e8.js → useMantineLocale-27cbe6c8.js} +6 -6
  189. package/build/esm/{usePlacesAutocomplete-c4749ddc.js → usePlacesAutocomplete-b2c58eae.js} +1 -1
  190. package/build/esm/{useScreenSize-e7eac93f.js → useScreenSize-9f683ab9.js} +2 -2
  191. package/build/esm/useTogetherAuthRequiredAction.js +9 -10
  192. package/build/esm/{utils-d8da27f5.js → utils-0714a33c.js} +2 -2
  193. package/build/esm/{utils-2b1d5bd6.js → utils-c1df8b61.js} +2 -2
  194. package/build/esm/{utils-cc00d05a.js → utils-c3c90e9c.js} +4 -5
  195. package/build/esm/{utils-b919951c.js → utils-ec0a690b.js} +3 -3
  196. package/build/esm/vaccination.js +21 -21
  197. package/build/footer.js +21 -21
  198. package/build/gAssets.js +2 -2
  199. package/build/{healthTools-a016cb8d.js → healthTools-c138e13a.js} +1 -1
  200. package/build/healthToolsCardWrapper.js +18 -18
  201. package/build/healthToolsForm.js +33 -33
  202. package/build/hooks.js +13 -13
  203. package/build/i18n.js +57 -16
  204. package/build/i18nV2.js +1 -1
  205. package/build/{index-585a5bae.js → index-008eedb8.js} +7 -7
  206. package/build/{index-cb49c1bb.js → index-02e0fc3f.js} +2 -2
  207. package/build/{index-cbf55622.js → index-0649d573.js} +6 -6
  208. package/build/{index-88b43a3e.js → index-06b6f920.js} +5 -5
  209. package/build/{index-ca3c8063.js → index-06f14e03.js} +32 -32
  210. package/build/{index-0651afe0.js → index-0b4028d0.js} +2 -2
  211. package/build/{index-223317ad.js → index-1007e179.js} +2 -2
  212. package/build/{index-2878facd.js → index-11217e12.js} +4 -4
  213. package/build/{index-5cb3f50f.js → index-169f743e.js} +13 -13
  214. package/build/{index-bbfb5456.js → index-1d4f69ed.js} +1 -1
  215. package/build/{index-bb3901d9.js → index-1da24aa7.js} +16 -16
  216. package/build/{index-acd931c2.js → index-1de4bd11.js} +17 -17
  217. package/build/{index-7ba64550.js → index-201a8d71.js} +3 -3
  218. package/build/{index-4b85a78a.js → index-22387adf.js} +6 -6
  219. package/build/{index-0ba8ea71.js → index-2364e8df.js} +6 -6
  220. package/build/{index-1699773f.js → index-25bf564e.js} +25 -25
  221. package/build/{index-a105395a.js → index-2965cadb.js} +1 -1
  222. package/build/{index-228adb0f.js → index-3c5af87d.js} +2 -2
  223. package/build/{index-dd62cf24.js → index-3d563929.js} +1 -1
  224. package/build/{index-a9694d80.js → index-3f93e79e.js} +18 -18
  225. package/build/{index-d5fc7635.js → index-446beb43.js} +2 -2
  226. package/build/{index-b6a6c539.js → index-4bfd812a.js} +1 -1
  227. package/build/{index-0a5e6408.js → index-50426772.js} +27 -36
  228. package/build/{index-05035d2b.js → index-5387bc40.js} +5 -5
  229. package/build/{index-3b093a8b.js → index-59d5c076.js} +16 -16
  230. package/build/{index-a0064d3e.js → index-5d8490cb.js} +1 -1
  231. package/build/{index-2f099fb7.js → index-6568d0d4.js} +7 -7
  232. package/build/{index-f2b654c4.js → index-6937ab6f.js} +17 -17
  233. package/build/{index-af6f003e.js → index-72db33ac.js} +2 -2
  234. package/build/{index-18565e54.js → index-7306bd8c.js} +18 -18
  235. package/build/{index-220172c4.js → index-7cc099d8.js} +3 -3
  236. package/build/{index-a2de13bb.js → index-8a3b8367.js} +2 -2
  237. package/build/{index-3d227b95.js → index-92e68ec9.js} +13 -13
  238. package/build/{index-a6738c7d.js → index-98b8aa1a.js} +3 -3
  239. package/build/{index-752817df.js → index-99272d11.js} +16 -16
  240. package/build/{index-7b7b50dc.js → index-9b9e59a2.js} +1 -1
  241. package/build/{index-5005ce85.js → index-a09cd67f.js} +1 -1
  242. package/build/{index-eab7c34b.js → index-a2637997.js} +13 -13
  243. package/build/{index-d30c98c8.js → index-a62351d2.js} +22 -22
  244. package/build/{index-a734e870.js → index-aa5a595c.js} +8 -8
  245. package/build/{index-934b8ae0.js → index-aa749e85.js} +17 -17
  246. package/build/{index-d6a16d97.js → index-ad7933f9.js} +1 -1
  247. package/build/{index-39ff1669.js → index-af21979d.js} +17 -17
  248. package/build/{index-ffa642f4.js → index-b81a335e.js} +2 -2
  249. package/build/{index-cc2888bb.js → index-bd129201.js} +1 -1
  250. package/build/{index-50d7ebaa.js → index-bf1efdbb.js} +6 -6
  251. package/build/{index-253ec2d9.js → index-c034f39c.js} +2 -2
  252. package/build/{index-6851924c.js → index-c60ecec1.js} +16 -16
  253. package/build/{index-72d32bf1.js → index-c926a6a3.js} +6 -6
  254. package/build/{index-db6611f1.js → index-ca8ec47e.js} +3 -3
  255. package/build/{index-85a69b52.js → index-d15413c2.js} +24 -24
  256. package/build/{index-817d411d.js → index-d1da0386.js} +32 -32
  257. package/build/{index-06f80018.js → index-d4caff5b.js} +2 -2
  258. package/build/{index-0084363f.js → index-dd83dbad.js} +10 -10
  259. package/build/{index-9b773d37.js → index-dda0b9d1.js} +3 -3
  260. package/build/{index-79a16c97.js → index-e5f20367.js} +2 -2
  261. package/build/{index-bca93346.js → index-e6660745.js} +2 -2
  262. package/build/{index-d99a6332.js → index-e7f07eca.js} +31 -31
  263. package/build/{index-c58f317f.js → index-e81dd9db.js} +13 -13
  264. package/build/{index-69a5e880.js → index-e98b6385.js} +2 -2
  265. package/build/{index-c81cfcf9.js → index-ecc24c2c.js} +3 -3
  266. package/build/{index-a33a5b8c.js → index-f05dc08c.js} +2 -2
  267. package/build/{index-ce4cd7f0.js → index-f90e1c8e.js} +21 -21
  268. package/build/{index-36e65c85.js → index-fe1b090f.js} +15 -15
  269. package/build/index.js +117 -118
  270. package/build/interfaces/types/index.d.ts +0 -1
  271. package/build/{labelSorting-cfeffd52.js → labelSorting-b5d28c8b.js} +4 -4
  272. package/build/lead/helpers.d.ts +1 -56
  273. package/build/lead/index.d.ts +1 -2
  274. package/build/lead/services/index.d.ts +0 -21
  275. package/build/lead/store/index.d.ts +0 -1
  276. package/build/lead.js +1034 -2211
  277. package/build/{logoIcon-0269990f.js → logoIcon-5c2ba163.js} +2 -2
  278. package/build/mantine.js +22 -22
  279. package/build/misc.js +17 -17
  280. package/build/miscGetDynamicHealthTool.js +4 -4
  281. package/build/miscGetSocialList.js +8 -8
  282. package/build/miscScreenSizeContext.js +1 -1
  283. package/build/mobileBottomNavigation.js +5 -5
  284. package/build/mobileBottomNavigationIcon.js +5 -5
  285. package/build/molecules.js +73 -74
  286. package/build/moleculesArticleCard.js +6 -6
  287. package/build/moleculesArticleCardV2.js +16 -16
  288. package/build/navigation.js +45 -46
  289. package/build/navigationLogoutPopup.js +9 -9
  290. package/build/navigationProfileButton.js +23 -23
  291. package/build/onboardingV2.js +28 -28
  292. package/build/organisms.js +49 -50
  293. package/build/{post-954dd984.js → post-34bb441f.js} +2 -2
  294. package/build/profileNavigation.js +19 -19
  295. package/build/progressBar.js +1 -1
  296. package/build/pwg.js +22 -22
  297. package/build/ssoV2/api/featureFlag.d.ts +1 -2
  298. package/build/ssoV2.js +117 -130
  299. package/build/{store-f8263e4e.js → store-1ddbc453.js} +196 -8
  300. package/build/subot.js +34 -35
  301. package/build/surveyOrPremiumBanner.js +32 -33
  302. package/build/surveyQuestionCard.js +10 -10
  303. package/build/{surveyThankyouCard-bb3a138d.js → surveyThankyouCard-ac96d4b4.js} +5 -5
  304. package/build/together.js +55 -56
  305. package/build/togetherApiUtils.js +4 -4
  306. package/build/togetherAtoms.js +30 -30
  307. package/build/togetherComponentGlobalContext.js +4 -4
  308. package/build/togetherMolecules.js +50 -51
  309. package/build/togetherMoleculesCardAuthor.js +28 -28
  310. package/build/togetherMoleculesPostImagePreview.js +11 -11
  311. package/build/togetherMoleculesProfileDetail.js +38 -39
  312. package/build/togetherOrganisms.js +49 -50
  313. package/build/togetherRichTextEditor.js +17 -17
  314. package/build/togetherShareBox.js +10 -10
  315. package/build/{treePopoverMenu-6e79ee16.js → treePopoverMenu-faee82ba.js} +19 -19
  316. package/build/{types-33c0756b.js → types-6a849d0f.js} +2 -2
  317. package/build/types.js +2 -2
  318. package/build/{useCategory-49d6eb99.js → useCategory-457cf1c5.js} +5 -5
  319. package/build/{useHealthToolCache-111b486d.js → useHealthToolCache-8246efd1.js} +1 -1
  320. package/build/{useMantineLocale-89cc8207.js → useMantineLocale-70ce0f42.js} +6 -6
  321. package/build/{usePlacesAutocomplete-951ae89e.js → usePlacesAutocomplete-c1253ff8.js} +1 -1
  322. package/build/{useScreenSize-f2c19a70.js → useScreenSize-0d50d147.js} +2 -2
  323. package/build/useTogetherAuthRequiredAction.js +9 -10
  324. package/build/{utils-2de3e40a.js → utils-0a02bd15.js} +2 -2
  325. package/build/{utils-91d25828.js → utils-47903e31.js} +3 -3
  326. package/build/{utils-dd3a3402.js → utils-4c8af11f.js} +2 -2
  327. package/build/{utils-b64f9207.js → utils-e1a9bf2b.js} +8 -9
  328. package/build/vaccination.js +21 -21
  329. package/package.json +3 -3
  330. package/build/components/mantine/phoneInput/PhoneInput.d.ts +0 -17
  331. package/build/components/mantine/phoneInput/index.d.ts +0 -1
  332. package/build/esm/components/mantine/phoneInput/PhoneInput.d.ts +0 -17
  333. package/build/esm/components/mantine/phoneInput/index.d.ts +0 -1
  334. package/build/esm/index-2688ff72.js +0 -183
  335. package/build/esm/lead/LeadGen.type.d.ts +0 -34
  336. package/build/esm/lead/LeadGenForm/LeadGenForm.d.ts +0 -41
  337. package/build/esm/lead/LeadGenForm/LeadGenForm.helpers.d.ts +0 -2
  338. package/build/esm/lead/LeadGenForm/LeadGenForm.styled.d.ts +0 -5
  339. package/build/esm/lead/LeadGenForm/LeadGenFormPhone.d.ts +0 -17
  340. package/build/esm/lead/LeadGenForm/LeadGenThankYou.d.ts +0 -20
  341. package/build/esm/lead/LeadGenForm/index.d.ts +0 -3
  342. package/build/esm/lead/LeadGenForm/textField/index.d.ts +0 -13
  343. package/build/esm/lead/LeadGenForm/textField/index.styled.d.ts +0 -11
  344. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +0 -66
  345. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +0 -4
  346. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +0 -21
  347. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +0 -3
  348. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +0 -24
  349. package/build/esm/lead/LeadGenSubscriptionBox/index.d.ts +0 -1
  350. package/build/esm/lead/LeadGenTranslationContext.d.ts +0 -6
  351. package/build/esm/translationsProvider-dac81da4.js +0 -55
  352. package/build/index-c69ba434.js +0 -196
  353. package/build/lead/LeadGen.type.d.ts +0 -34
  354. package/build/lead/LeadGenForm/LeadGenForm.d.ts +0 -41
  355. package/build/lead/LeadGenForm/LeadGenForm.helpers.d.ts +0 -2
  356. package/build/lead/LeadGenForm/LeadGenForm.styled.d.ts +0 -5
  357. package/build/lead/LeadGenForm/LeadGenFormPhone.d.ts +0 -17
  358. package/build/lead/LeadGenForm/LeadGenThankYou.d.ts +0 -20
  359. package/build/lead/LeadGenForm/index.d.ts +0 -3
  360. package/build/lead/LeadGenForm/textField/index.d.ts +0 -13
  361. package/build/lead/LeadGenForm/textField/index.styled.d.ts +0 -11
  362. package/build/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +0 -66
  363. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +0 -4
  364. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +0 -21
  365. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +0 -3
  366. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +0 -24
  367. package/build/lead/LeadGenSubscriptionBox/index.d.ts +0 -1
  368. package/build/lead/LeadGenTranslationContext.d.ts +0 -6
  369. package/build/translationsProvider-681225a2.js +0 -62
  370. /package/build/{BMI_BOYS.percentile.monthly-405a630a.js → BMI_BOYS.percentile.monthly-df2482bd.js} +0 -0
  371. /package/build/{BMI_BOYS.percentile.weekly-07b1b016.js → BMI_BOYS.percentile.weekly-035eb626.js} +0 -0
  372. /package/build/{BMI_BOYS.percentile.yearly-a40fb757.js → BMI_BOYS.percentile.yearly-5fe8b43f.js} +0 -0
  373. /package/build/{BMI_BOYS.zscore.monthly-c7e09504.js → BMI_BOYS.zscore.monthly-324ae79e.js} +0 -0
  374. /package/build/{BMI_BOYS.zscore.weekly-376d05a8.js → BMI_BOYS.zscore.weekly-0f5f08fc.js} +0 -0
  375. /package/build/{BMI_BOYS.zscore.yearly-b7f75a2e.js → BMI_BOYS.zscore.yearly-83add2b5.js} +0 -0
  376. /package/build/{BMI_GIRLS.percentile.monthly-d3a0643a.js → BMI_GIRLS.percentile.monthly-19bcd66d.js} +0 -0
  377. /package/build/{BMI_GIRLS.percentile.weekly-ce5d4cdb.js → BMI_GIRLS.percentile.weekly-3f7c8830.js} +0 -0
  378. /package/build/{BMI_GIRLS.percentile.yearly-1f97a795.js → BMI_GIRLS.percentile.yearly-032b7aa7.js} +0 -0
  379. /package/build/{BMI_GIRLS.zscore.monthly-077489ec.js → BMI_GIRLS.zscore.monthly-345313ae.js} +0 -0
  380. /package/build/{BMI_GIRLS.zscore.weekly-e50841f6.js → BMI_GIRLS.zscore.weekly-4bff215b.js} +0 -0
  381. /package/build/{BMI_GIRLS.zscore.yearly-8aca994b.js → BMI_GIRLS.zscore.yearly-b090beec.js} +0 -0
  382. /package/build/{ChevronDown-bc69de3a.js → ChevronDown-41194899.js} +0 -0
  383. /package/build/{Close-390f3c2d.js → Close-2add3da2.js} +0 -0
  384. /package/build/{Google-2265b4b5.js → Google-39a84f2a.js} +0 -0
  385. /package/build/{HEAD CIRCUM_BOYS.percentile.monthly-ca597e32.js → HEAD CIRCUM_BOYS.percentile.monthly-c2fab73c.js} +0 -0
  386. /package/build/{HEAD CIRCUM_BOYS.percentile.weekly-50eec743.js → HEAD CIRCUM_BOYS.percentile.weekly-166966e5.js} +0 -0
  387. /package/build/{HEAD CIRCUM_BOYS.percentile.yearly-848e6544.js → HEAD CIRCUM_BOYS.percentile.yearly-f779680b.js} +0 -0
  388. /package/build/{HEAD CIRCUM_BOYS.zscore.monthly-d58e5439.js → HEAD CIRCUM_BOYS.zscore.monthly-e2ded6bc.js} +0 -0
  389. /package/build/{HEAD CIRCUM_BOYS.zscore.weekly-bbd82265.js → HEAD CIRCUM_BOYS.zscore.weekly-beb5c911.js} +0 -0
  390. /package/build/{HEAD CIRCUM_BOYS.zscore.yearly-7db39b45.js → HEAD CIRCUM_BOYS.zscore.yearly-b85cf0d6.js} +0 -0
  391. /package/build/{HEAD CIRCUM_GIRLS.percentile.monthly-0a97ff9e.js → HEAD CIRCUM_GIRLS.percentile.monthly-d681a0ee.js} +0 -0
  392. /package/build/{HEAD CIRCUM_GIRLS.percentile.weekly-c78bc5c5.js → HEAD CIRCUM_GIRLS.percentile.weekly-9e4cb570.js} +0 -0
  393. /package/build/{HEAD CIRCUM_GIRLS.percentile.yearly-cda42a30.js → HEAD CIRCUM_GIRLS.percentile.yearly-23f33f5d.js} +0 -0
  394. /package/build/{HEAD CIRCUM_GIRLS.zscore.monthly-51674c76.js → HEAD CIRCUM_GIRLS.zscore.monthly-2bae97cf.js} +0 -0
  395. /package/build/{HEAD CIRCUM_GIRLS.zscore.weekly-65eda1af.js → HEAD CIRCUM_GIRLS.zscore.weekly-999a9564.js} +0 -0
  396. /package/build/{HEAD CIRCUM_GIRLS.zscore.yearly-d5af3abf.js → HEAD CIRCUM_GIRLS.zscore.yearly-c5ee4f98.js} +0 -0
  397. /package/build/{HEIGHT_BOYS.percentile.monthly-70ea2220.js → HEIGHT_BOYS.percentile.monthly-af1bbd51.js} +0 -0
  398. /package/build/{HEIGHT_BOYS.percentile.weekly-3fc2233e.js → HEIGHT_BOYS.percentile.weekly-dc4597cf.js} +0 -0
  399. /package/build/{HEIGHT_BOYS.percentile.yearly-02bbd1ea.js → HEIGHT_BOYS.percentile.yearly-226b11ca.js} +0 -0
  400. /package/build/{HEIGHT_BOYS.zscore.monthly-476f71f1.js → HEIGHT_BOYS.zscore.monthly-2ce0c9c1.js} +0 -0
  401. /package/build/{HEIGHT_BOYS.zscore.weekly-5229b9be.js → HEIGHT_BOYS.zscore.weekly-3cbf2c2a.js} +0 -0
  402. /package/build/{HEIGHT_BOYS.zscore.yearly-5046fb8e.js → HEIGHT_BOYS.zscore.yearly-1c8a3c1d.js} +0 -0
  403. /package/build/{HEIGHT_GIRLS.percentile.monthly-36db0ab0.js → HEIGHT_GIRLS.percentile.monthly-c8266607.js} +0 -0
  404. /package/build/{HEIGHT_GIRLS.percentile.weekly-c7667e72.js → HEIGHT_GIRLS.percentile.weekly-db44a8d4.js} +0 -0
  405. /package/build/{HEIGHT_GIRLS.percentile.yearly-8614198b.js → HEIGHT_GIRLS.percentile.yearly-a85b0b4d.js} +0 -0
  406. /package/build/{HEIGHT_GIRLS.zscore.monthly-0cab9bf4.js → HEIGHT_GIRLS.zscore.monthly-7893ef51.js} +0 -0
  407. /package/build/{HEIGHT_GIRLS.zscore.weekly-077d6997.js → HEIGHT_GIRLS.zscore.weekly-b40844c5.js} +0 -0
  408. /package/build/{HEIGHT_GIRLS.zscore.yearly-ff1ea86f.js → HEIGHT_GIRLS.zscore.yearly-9f26867c.js} +0 -0
  409. /package/build/{Locale-608d8aa7.js → Locale-836a0da1.js} +0 -0
  410. /package/build/{Visible-60bb588d.js → Visible-51d5d954.js} +0 -0
  411. /package/build/{WEIGHT_BOYS.percentile.monthly-d1a868a3.js → WEIGHT_BOYS.percentile.monthly-e075c1a3.js} +0 -0
  412. /package/build/{WEIGHT_BOYS.percentile.weekly-07187b39.js → WEIGHT_BOYS.percentile.weekly-b8a78276.js} +0 -0
  413. /package/build/{WEIGHT_BOYS.percentile.yearly-eef61209.js → WEIGHT_BOYS.percentile.yearly-f2d9c7c9.js} +0 -0
  414. /package/build/{WEIGHT_BOYS.zscore.monthly-11a57778.js → WEIGHT_BOYS.zscore.monthly-0c7c819f.js} +0 -0
  415. /package/build/{WEIGHT_BOYS.zscore.weekly-3fe2b4d2.js → WEIGHT_BOYS.zscore.weekly-b19ddebe.js} +0 -0
  416. /package/build/{WEIGHT_BOYS.zscore.yearly-37eba4a4.js → WEIGHT_BOYS.zscore.yearly-0c6b12a8.js} +0 -0
  417. /package/build/{WEIGHT_GIRLS.percentile.monthly-db6cef50.js → WEIGHT_GIRLS.percentile.monthly-c8002622.js} +0 -0
  418. /package/build/{WEIGHT_GIRLS.percentile.weekly-3b49590f.js → WEIGHT_GIRLS.percentile.weekly-bfc763f2.js} +0 -0
  419. /package/build/{WEIGHT_GIRLS.percentile.yearly-d86b6625.js → WEIGHT_GIRLS.percentile.yearly-88606367.js} +0 -0
  420. /package/build/{WEIGHT_GIRLS.zscore.monthly-b8a2d43b.js → WEIGHT_GIRLS.zscore.monthly-8ac01726.js} +0 -0
  421. /package/build/{WEIGHT_GIRLS.zscore.weekly-51f15303.js → WEIGHT_GIRLS.zscore.weekly-bda518a0.js} +0 -0
  422. /package/build/{WEIGHT_GIRLS.zscore.yearly-415922de.js → WEIGHT_GIRLS.zscore.yearly-c8521c02.js} +0 -0
  423. /package/build/{animation-1dff46f2.js → animation-953a4127.js} +0 -0
  424. /package/build/{constants-fcc28c66.js → constants-1416f348.js} +0 -0
  425. /package/build/{constants-a59bae5a.js → constants-32022ceb.js} +0 -0
  426. /package/build/{constants-1459a83e.js → constants-49711f56.js} +0 -0
  427. /package/build/{dataTransform-e813ed6a.js → dataTransform-4de10d58.js} +0 -0
  428. /package/build/{doctor-cb7a7cfc.js → doctor-3bc8f39e.js} +0 -0
  429. /package/build/esm/{BMI_BOYS.percentile.monthly-f3c22ef1.js → BMI_BOYS.percentile.monthly-01cdb562.js} +0 -0
  430. /package/build/esm/{BMI_BOYS.percentile.weekly-318e11ef.js → BMI_BOYS.percentile.weekly-8893dd3e.js} +0 -0
  431. /package/build/esm/{BMI_BOYS.percentile.yearly-d8aa6920.js → BMI_BOYS.percentile.yearly-9d4b69c9.js} +0 -0
  432. /package/build/esm/{BMI_BOYS.zscore.monthly-fa3be4d9.js → BMI_BOYS.zscore.monthly-c6671ee4.js} +0 -0
  433. /package/build/esm/{BMI_BOYS.zscore.weekly-9606a55c.js → BMI_BOYS.zscore.weekly-92e1d131.js} +0 -0
  434. /package/build/esm/{BMI_BOYS.zscore.yearly-4779c33b.js → BMI_BOYS.zscore.yearly-05bbdd7b.js} +0 -0
  435. /package/build/esm/{BMI_GIRLS.percentile.monthly-8d7bff9c.js → BMI_GIRLS.percentile.monthly-ec51639e.js} +0 -0
  436. /package/build/esm/{BMI_GIRLS.percentile.weekly-04fe9074.js → BMI_GIRLS.percentile.weekly-7c0c8b4a.js} +0 -0
  437. /package/build/esm/{BMI_GIRLS.percentile.yearly-815d739d.js → BMI_GIRLS.percentile.yearly-6cc143f2.js} +0 -0
  438. /package/build/esm/{BMI_GIRLS.zscore.monthly-893015d6.js → BMI_GIRLS.zscore.monthly-1f018468.js} +0 -0
  439. /package/build/esm/{BMI_GIRLS.zscore.weekly-cc80e658.js → BMI_GIRLS.zscore.weekly-af5a4b2b.js} +0 -0
  440. /package/build/esm/{BMI_GIRLS.zscore.yearly-6a80cde6.js → BMI_GIRLS.zscore.yearly-c7a07f25.js} +0 -0
  441. /package/build/esm/{ChevronDown-948cd754.js → ChevronDown-42f671e1.js} +0 -0
  442. /package/build/esm/{Close-79f9c8c5.js → Close-5e54b2d5.js} +0 -0
  443. /package/build/esm/{Google-04b6682f.js → Google-6652e3bc.js} +0 -0
  444. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.monthly-9d0248e5.js → HEAD CIRCUM_BOYS.percentile.monthly-7e66fc3a.js} +0 -0
  445. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.weekly-a776948c.js → HEAD CIRCUM_BOYS.percentile.weekly-64473467.js} +0 -0
  446. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.yearly-c99a242d.js → HEAD CIRCUM_BOYS.percentile.yearly-08606ae2.js} +0 -0
  447. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.monthly-c94643ef.js → HEAD CIRCUM_BOYS.zscore.monthly-4e140e3f.js} +0 -0
  448. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.weekly-cdf1ea50.js → HEAD CIRCUM_BOYS.zscore.weekly-4e1b5770.js} +0 -0
  449. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.yearly-9f4d04da.js → HEAD CIRCUM_BOYS.zscore.yearly-0dec10da.js} +0 -0
  450. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.monthly-d0b2ff79.js → HEAD CIRCUM_GIRLS.percentile.monthly-d18303ca.js} +0 -0
  451. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.weekly-4f6856df.js → HEAD CIRCUM_GIRLS.percentile.weekly-55770071.js} +0 -0
  452. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.yearly-936dabd2.js → HEAD CIRCUM_GIRLS.percentile.yearly-25e4a2c9.js} +0 -0
  453. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.monthly-f503bf4f.js → HEAD CIRCUM_GIRLS.zscore.monthly-d33b6246.js} +0 -0
  454. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.weekly-a9355b2d.js → HEAD CIRCUM_GIRLS.zscore.weekly-abef6f22.js} +0 -0
  455. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.yearly-795bffd6.js → HEAD CIRCUM_GIRLS.zscore.yearly-444bc2b4.js} +0 -0
  456. /package/build/esm/{HEIGHT_BOYS.percentile.monthly-693d85ff.js → HEIGHT_BOYS.percentile.monthly-dc5d6faf.js} +0 -0
  457. /package/build/esm/{HEIGHT_BOYS.percentile.weekly-a778d94d.js → HEIGHT_BOYS.percentile.weekly-75b1b9f1.js} +0 -0
  458. /package/build/esm/{HEIGHT_BOYS.percentile.yearly-9cf0eb3b.js → HEIGHT_BOYS.percentile.yearly-bc5c7a34.js} +0 -0
  459. /package/build/esm/{HEIGHT_BOYS.zscore.monthly-7a32dbec.js → HEIGHT_BOYS.zscore.monthly-bbad4abb.js} +0 -0
  460. /package/build/esm/{HEIGHT_BOYS.zscore.weekly-01d778a3.js → HEIGHT_BOYS.zscore.weekly-736c87b3.js} +0 -0
  461. /package/build/esm/{HEIGHT_BOYS.zscore.yearly-f9c8fc3e.js → HEIGHT_BOYS.zscore.yearly-31f0f935.js} +0 -0
  462. /package/build/esm/{HEIGHT_GIRLS.percentile.monthly-9966ef76.js → HEIGHT_GIRLS.percentile.monthly-95c5c1fc.js} +0 -0
  463. /package/build/esm/{HEIGHT_GIRLS.percentile.weekly-94548ffe.js → HEIGHT_GIRLS.percentile.weekly-12d97ac4.js} +0 -0
  464. /package/build/esm/{HEIGHT_GIRLS.percentile.yearly-a03dc269.js → HEIGHT_GIRLS.percentile.yearly-c188d8d7.js} +0 -0
  465. /package/build/esm/{HEIGHT_GIRLS.zscore.monthly-557a853d.js → HEIGHT_GIRLS.zscore.monthly-2885a84f.js} +0 -0
  466. /package/build/esm/{HEIGHT_GIRLS.zscore.weekly-bfad8a41.js → HEIGHT_GIRLS.zscore.weekly-4623c6b8.js} +0 -0
  467. /package/build/esm/{HEIGHT_GIRLS.zscore.yearly-82208285.js → HEIGHT_GIRLS.zscore.yearly-0f241320.js} +0 -0
  468. /package/build/esm/{Locale-645224b1.js → Locale-cd9c33a3.js} +0 -0
  469. /package/build/esm/{Visible-6b232e0c.js → Visible-4b6153b5.js} +0 -0
  470. /package/build/esm/{WEIGHT_BOYS.percentile.monthly-c2ba61f3.js → WEIGHT_BOYS.percentile.monthly-52cbd675.js} +0 -0
  471. /package/build/esm/{WEIGHT_BOYS.percentile.weekly-a2227777.js → WEIGHT_BOYS.percentile.weekly-d9aebf61.js} +0 -0
  472. /package/build/esm/{WEIGHT_BOYS.percentile.yearly-aadf37bd.js → WEIGHT_BOYS.percentile.yearly-2f93ab0a.js} +0 -0
  473. /package/build/esm/{WEIGHT_BOYS.zscore.monthly-626abe60.js → WEIGHT_BOYS.zscore.monthly-249fcf8d.js} +0 -0
  474. /package/build/esm/{WEIGHT_BOYS.zscore.weekly-90f9c427.js → WEIGHT_BOYS.zscore.weekly-293fb368.js} +0 -0
  475. /package/build/esm/{WEIGHT_BOYS.zscore.yearly-5437ef19.js → WEIGHT_BOYS.zscore.yearly-ba2bba37.js} +0 -0
  476. /package/build/esm/{WEIGHT_GIRLS.percentile.monthly-8162ecc6.js → WEIGHT_GIRLS.percentile.monthly-db69de41.js} +0 -0
  477. /package/build/esm/{WEIGHT_GIRLS.percentile.weekly-487bcb64.js → WEIGHT_GIRLS.percentile.weekly-fb7303bc.js} +0 -0
  478. /package/build/esm/{WEIGHT_GIRLS.percentile.yearly-faba19c1.js → WEIGHT_GIRLS.percentile.yearly-7604d8f5.js} +0 -0
  479. /package/build/esm/{WEIGHT_GIRLS.zscore.monthly-c07f1793.js → WEIGHT_GIRLS.zscore.monthly-998a69bf.js} +0 -0
  480. /package/build/esm/{WEIGHT_GIRLS.zscore.weekly-4bbce9e7.js → WEIGHT_GIRLS.zscore.weekly-468c577f.js} +0 -0
  481. /package/build/esm/{WEIGHT_GIRLS.zscore.yearly-681a5574.js → WEIGHT_GIRLS.zscore.yearly-0f83301c.js} +0 -0
  482. /package/build/esm/{animation-2d0f4aa0.js → animation-3b7fbeb8.js} +0 -0
  483. /package/build/esm/{constants-d2a882e1.js → constants-56418598.js} +0 -0
  484. /package/build/esm/{constants-6036c3b5.js → constants-8550ea4b.js} +0 -0
  485. /package/build/esm/{constants-14911af0.js → constants-936d56a3.js} +0 -0
  486. /package/build/esm/{dataTransform-1e40a135.js → dataTransform-1365e4e2.js} +0 -0
  487. /package/build/esm/{doctor-72a2c028.js → doctor-933f26b5.js} +0 -0
  488. /package/build/esm/{index-8de8f7f0.js → index-0db4da34.js} +0 -0
  489. /package/build/esm/{index-f148865f.js → index-243908c8.js} +0 -0
  490. /package/build/esm/{index-83d3a9a2.js → index-578f4600.js} +0 -0
  491. /package/build/esm/{index-c3a24335.js → index-610d69af.js} +0 -0
  492. /package/build/esm/{index-ed07bb88.js → index-66938a55.js} +0 -0
  493. /package/build/esm/{index-7f8c17be.js → index-a318c025.js} +0 -0
  494. /package/build/esm/{index-558cb332.js → index-cb171154.js} +0 -0
  495. /package/build/esm/{index-3c4f726d.js → index-f44c62ca.js} +0 -0
  496. /package/build/esm/{index.styles-0dbdf2b4.js → index.styles-4a412578.js} +0 -0
  497. /package/build/esm/{localizeNumberFormat-59a95171.js → localizeNumberFormat-79aefc62.js} +0 -0
  498. /package/build/esm/{normalizeLink-ced8b6a3.js → normalizeLink-69a06b00.js} +0 -0
  499. /package/build/esm/{number-4eedb3fc.js → number-7472b20c.js} +0 -0
  500. /package/build/esm/{other-68ac8404.js → other-756a8244.js} +0 -0
  501. /package/build/esm/{paths-193824df.js → paths-f75a5925.js} +0 -0
  502. /package/build/esm/{translationsContext-dccf2103.js → translationsContext-1df74fcc.js} +0 -0
  503. /package/build/esm/{tslib.es6-ae8d1850.js → tslib.es6-6b8750ce.js} +0 -0
  504. /package/build/esm/{types-32c72a0c.js → types-160c2989.js} +0 -0
  505. /package/build/esm/{useIsInit-f2ba6b67.js → useIsInit-9df1e8e2.js} +0 -0
  506. /package/build/esm/{useOutsideClick-9ce3c0f0.js → useOutsideClick-1023869e.js} +0 -0
  507. /package/build/esm/{useScrollbarSize-4c4c3eaa.js → useScrollbarSize-0adaf38c.js} +0 -0
  508. /package/build/esm/{useUniqueId-f1f0c8a8.js → useUniqueId-0d0b484a.js} +0 -0
  509. /package/build/esm/{utils-6ab4908f.js → utils-ee78bcad.js} +0 -0
  510. /package/build/{index-86c58f8b.js → index-215c8c86.js} +0 -0
  511. /package/build/{index-e6b1775d.js → index-39692ed5.js} +0 -0
  512. /package/build/{index-4ea44e96.js → index-51127a60.js} +0 -0
  513. /package/build/{index-4520c363.js → index-6602fed3.js} +0 -0
  514. /package/build/{index-f6aa6d45.js → index-6b6c86d5.js} +0 -0
  515. /package/build/{index-560b56b1.js → index-7155ed17.js} +0 -0
  516. /package/build/{index-8497154e.js → index-e80a72b8.js} +0 -0
  517. /package/build/{index-da3e2cd5.js → index-f73f06bf.js} +0 -0
  518. /package/build/{index.styles-330e816a.js → index.styles-01d7e5fb.js} +0 -0
  519. /package/build/{localizeNumberFormat-5db51302.js → localizeNumberFormat-18110dda.js} +0 -0
  520. /package/build/{normalizeLink-733224f2.js → normalizeLink-b8d7fe5a.js} +0 -0
  521. /package/build/{number-2aa5b606.js → number-94987413.js} +0 -0
  522. /package/build/{other-000eae02.js → other-23c85ba5.js} +0 -0
  523. /package/build/{paths-48b12f16.js → paths-2de4f842.js} +0 -0
  524. /package/build/{translationsContext-ac71e4c7.js → translationsContext-55646101.js} +0 -0
  525. /package/build/{tslib.es6-217a5733.js → tslib.es6-a4e6f6fe.js} +0 -0
  526. /package/build/{types-4a912ba2.js → types-a7667594.js} +0 -0
  527. /package/build/{useIsInit-09ae2cfc.js → useIsInit-407bd907.js} +0 -0
  528. /package/build/{useOutsideClick-c405fe35.js → useOutsideClick-205a8b3e.js} +0 -0
  529. /package/build/{useScrollbarSize-979f36e2.js → useScrollbarSize-ff4a550a.js} +0 -0
  530. /package/build/{useUniqueId-391fa11f.js → useUniqueId-188a010a.js} +0 -0
  531. /package/build/{utils-3b6801b1.js → utils-eb50a5d6.js} +0 -0
package/build/lead.js CHANGED
@@ -2,76 +2,55 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('./tslib.es6-217a5733.js');
5
+ var tslib_es6 = require('./tslib.es6-a4e6f6fe.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-c69ba434.js');
11
+ var index = require('./index-3d563929.js');
12
+ var translationsContext = require('./translationsContext-55646101.js');
12
13
  var miscCookieHelper = require('./miscCookieHelper.js');
13
- var index$1 = require('./index-dd62cf24.js');
14
- var translationsContext = require('./translationsContext-ac71e4c7.js');
15
- var utils$1 = require('./utils-3b6801b1.js');
16
- var index$2 = require('./index-253ec2d9.js');
17
- var index$3 = require('./index-0a5e6408.js');
18
- var index$5 = require('./index-0ba8ea71.js');
19
- var index$4 = require('./index-7b7b50dc.js');
20
- require('./index.styles-330e816a.js');
14
+ var utils$1 = require('./utils-eb50a5d6.js');
15
+ var index$1 = require('./index-c034f39c.js');
16
+ var index$2 = require('./index-50426772.js');
17
+ var index$4 = require('./index-2364e8df.js');
18
+ var index$3 = require('./index-9b9e59a2.js');
19
+ require('./index.styles-01d7e5fb.js');
21
20
  var hooks = require('@mantine/hooks');
22
- require('./useMantineLocale-89cc8207.js');
23
- var index$9 = require('./index-bbfb5456.js');
24
- require('./index-da3e2cd5.js');
25
- var index$7 = require('./index-af6f003e.js');
26
- require('./other-000eae02.js');
27
- require('./index-220172c4.js');
28
- var utils = require('./utils-2de3e40a.js');
29
- var dates = require('@mantine/dates');
30
- var usePlacesAutocomplete = require('./usePlacesAutocomplete-951ae89e.js');
31
- var index$6 = require('./index-223317ad.js');
32
- var translationsProvider = require('./translationsProvider-681225a2.js');
33
- var Locale = require('./Locale-608d8aa7.js');
21
+ require('./useMantineLocale-70ce0f42.js');
22
+ var index$8 = require('./index-1d4f69ed.js');
23
+ require('./index-f73f06bf.js');
24
+ var index$7 = require('./index-72db33ac.js');
25
+ require('./other-23c85ba5.js');
26
+ require('./index-7cc099d8.js');
27
+ var utils = require('./utils-0a02bd15.js');
28
+ require('@mantine/dates');
29
+ var usePlacesAutocomplete = require('./usePlacesAutocomplete-c1253ff8.js');
30
+ var index$5 = require('./index-1007e179.js');
34
31
  var uuid = require('uuid');
35
- var PhoneInputBase = require('react-phone-number-input');
32
+ var index$6 = require('./index-6602fed3.js');
33
+ var index$a = require('./index-e6660745.js');
34
+ var useScreenSize = require('./useScreenSize-0d50d147.js');
35
+ var ReactDOM = require('react-dom');
36
+ var react = require('@emotion/react');
36
37
  var styled = require('@emotion/styled');
37
38
  var miscTheme = require('./miscTheme.js');
38
- var react = require('@emotion/react');
39
- var togetherComponentGlobalContext = require('./utils-91d25828.js');
40
- var index$8 = require('./index-4520c363.js');
41
- var index$b = require('./index-bca93346.js');
42
- var useScreenSize = require('./useScreenSize-f2c19a70.js');
43
- var ReactDOM = require('react-dom');
44
- var index$a = require('./index-ffa642f4.js');
45
- var InputDate = require('./InputDate-877c23c7.js');
46
- var Close = require('./Close-390f3c2d.js');
47
- require('./constantsIsProduction.js');
48
- require('./normalizeLink-733224f2.js');
49
- require('./constantsDomainLocales.js');
39
+ var index$9 = require('./index-b81a335e.js');
40
+ var InputDate = require('./InputDate-9746e093.js');
41
+ var Close = require('./Close-2add3da2.js');
50
42
  require('@hhgtech/icons/other');
51
43
  require('@mantine/carousel');
44
+ require('./Locale-836a0da1.js');
52
45
  require('classnames');
53
- require('./useUniqueId-391fa11f.js');
46
+ require('./useUniqueId-188a010a.js');
54
47
  require('./constantsSite.js');
55
48
  require('@hhgtech/icons/core');
56
49
  require('@mantine/notifications');
50
+ require('./constantsDomainLocales.js');
51
+ require('./constantsIsProduction.js');
57
52
  require('date-fns/locale');
58
53
  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-f6aa6d45.js');
71
- require('slugify');
72
- require('string-format');
73
- require('./togetherApiPaths.js');
74
- require('./constants-1459a83e.js');
75
54
  require('vaul');
76
55
 
77
56
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -123,7 +102,7 @@ if (sessionStorage.getItem('insider_object')) {
123
102
  }
124
103
  const docLang = document.documentElement.lang;
125
104
  // TODO: country code
126
- const LEAD_LOCALE_DATA$1 = {
105
+ const LEAD_LOCALE_DATA = {
127
106
  'vi-VN': {
128
107
  popupLang: 'vi',
129
108
  countryCode: 'vn',
@@ -165,7 +144,7 @@ const LEAD_LOCALE_DATA$1 = {
165
144
  countryCodeNumber: 91,
166
145
  },
167
146
  };
168
- const LEAD_LOCALE = LEAD_LOCALE_DATA$1[docLang] || LEAD_LOCALE_DATA$1['vi-VN'];
147
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
169
148
  function LEAD_RESET_VAR() {
170
149
  // LEAD_CURRENT_URL = location.href.toLowerCase();
171
150
  LEAD_CURRENT_URL =
@@ -186,11 +165,6 @@ const LEAD_TIMEZONE_DATA = {
186
165
  9: 'Asia/Manila', // Philippines / Filipinos Site
187
166
  };
188
167
 
189
- const LEADGEN_ACTIONS = {
190
- SHOW: 'SHOW',
191
- SCROLL: 'SCROLL',
192
- TIME: 'TIME',
193
- };
194
168
  const LEADGEN_LAYOUT = {
195
169
  LightBoxA: 'LightBoxA',
196
170
  LightBoxB: 'LightBoxB',
@@ -220,10 +194,8 @@ const LEADGEN_BLOCK = {
220
194
  DropdownBlock: 'DropdownBlock',
221
195
  CheckboxBlock: 'CheckboxBlock',
222
196
  TncBlock: 'TncBlock',
223
- TitleBlock: 'TitleBlock',
224
- SubtitleBlock: 'SubtitleBlock',
225
197
  };
226
- const LEADGEN_BLOCK_INPUT = [
198
+ const LEADGEN_BLOCK_IN_FORM = [
227
199
  LEADGEN_BLOCK.TextBlock,
228
200
  LEADGEN_BLOCK.NumberBlock,
229
201
  LEADGEN_BLOCK.DateBlock,
@@ -238,59 +210,7 @@ const LEADGEN_BLOCK_INPUT = [
238
210
  LEADGEN_BLOCK.CheckboxBlock,
239
211
  LEADGEN_BLOCK.TncBlock,
240
212
  ];
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
- };
251
213
  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
- };
294
214
  const mappingSSOToLead = (userInfoProps) => {
295
215
  var _a, _b;
296
216
  try {
@@ -306,7 +226,7 @@ const mappingSSOToLead = (userInfoProps) => {
306
226
  if (ssoKey === 'birthday') {
307
227
  const dob = dayjs__default["default"](initValue, 'YYYY-MM-DD', true);
308
228
  if (dob.isValid()) {
309
- user.birthday = dob.toDate();
229
+ user.birthday = dob;
310
230
  }
311
231
  }
312
232
  else if (ssoKey === 'gender') {
@@ -329,83 +249,16 @@ const mappingSSOToLead = (userInfoProps) => {
329
249
  catch (error) {
330
250
  return;
331
251
  }
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
- }
372
252
  };
373
253
 
374
254
  class Store {
375
255
  constructor() {
376
- this.apiSsoUrl = 'https://staging-id.hellobacsi.com/';
377
256
  this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
378
257
  this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
379
258
  }
380
259
  }
381
260
  const leadStore = new Store();
382
261
 
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
- };
409
262
  const leadApi = {
410
263
  call(_a) {
411
264
  var { url, data = undefined } = _a, config = tslib_es6.__rest(_a, ["url", "data"]);
@@ -509,54 +362,8 @@ const verifyOtpLead = ({ phone, otp, type, }) => {
509
362
  },
510
363
  });
511
364
  };
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
- };
553
365
  const Service = {
554
366
  campaignGetById,
555
- getCampaignByCode,
556
- getSubscriptionBoxInfo,
557
- postSubscriptionBoxLead,
558
- postUserInfoFromLeadGen,
559
- campaignPostImpression,
560
367
  validateEmailOrPhoneOnSubot,
561
368
  validateEmailOrPhoneOnLeadGen,
562
369
  validatePhoneNumberOnLeadGen,
@@ -663,7 +470,7 @@ const clearCacheUsedEmailOrPhone = () => {
663
470
  // You can give context variables any name
664
471
  const [LeadFormProvider$1, useLeadFormContext$1, useLeadForm$1] = form.createFormContext();
665
472
  const useLeadFormConfig$1 = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, }) => {
666
- const { t } = index$1.useTranslations();
473
+ const { t } = index.useTranslations();
667
474
  const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
668
475
  React.useEffect(() => {
669
476
  if (!window.intlTelInputUtils) {
@@ -893,10 +700,10 @@ const Component = ({ campaign, onClose: onCloseProp, onOtherSubmit, onSubmit, sh
893
700
  const Description = (_a) => {
894
701
  var rest = tslib_es6.__rest(_a, []);
895
702
  const { description } = React.useContext(LeadGenComponentContext);
896
- return description ? (React__default["default"].createElement(index$2.Text, Object.assign({ size: "p3" }, rest), description)) : null;
703
+ return description ? (React__default["default"].createElement(index$1.Text, Object.assign({ size: "p3" }, rest), description)) : null;
897
704
  };
898
705
 
899
- const LeadGenContext$1 = React.createContext({});
706
+ const LeadGenContext = React.createContext({});
900
707
 
901
708
  var useStyles$2 = core.createStyles(() => {
902
709
  return {
@@ -949,7 +756,7 @@ const LocationBlock = ({ name, placeholder, locale, required = true, }) => {
949
756
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
950
757
  LoadScript && (React__default["default"].createElement(LoadScript, { googleMapsApiKey: usePlacesAutocomplete.GOOGLE_API_KEY, libraries: libraries$1, loadingElement: React__default["default"].createElement(React__default["default"].Fragment, null) })),
951
758
  React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": name, "data-control": 'text' }),
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) => {
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) => {
953
760
  setSearchValue(query);
954
761
  }, 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" },
955
762
  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)))));
@@ -960,7 +767,7 @@ const SubtitleBlock$1 = ({ children, align, }) => (React__default["default"].cre
960
767
  const TitleBlock$1 = ({ children, align, }) => (React__default["default"].createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
961
768
 
962
769
  const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, popoverProps, }) => {
963
- const { primaryColor } = React.useContext(LeadGenContext$1);
770
+ const { primaryColor } = React.useContext(LeadGenContext);
964
771
  const { classes, cx } = useStyles$2(undefined, {
965
772
  name: 'LeadGen__Field',
966
773
  styles,
@@ -978,15 +785,15 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
978
785
  case 'SubtitleBlock':
979
786
  return (React__default["default"].createElement(SubtitleBlock$1, { key: index, align: align }, value));
980
787
  case 'TextBlock':
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),
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),
982
789
  // onChangeRaw={(e) => inputOnChange('text', e)}
983
790
  label: placeholder, "data-control": "text", name: value }, form.getInputProps(value))));
984
791
  case 'NumberBlock':
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),
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),
986
793
  // onChange={(e) => inputOnChange('number', e)}
987
794
  label: placeholder, "data-control": "number", name: value }, form.getInputProps(value))));
988
795
  case 'EmailBlock':
989
- return (React__default["default"].createElement(index$3.Input, Object.assign({ key: index, withAsterisk: required, spellCheck: false,
796
+ return (React__default["default"].createElement(index$2.Input, Object.assign({ key: index, withAsterisk: required, spellCheck: false,
990
797
  // type="email"
991
798
  placeholder: placeholder, className: cx('leadgen-control', classes.control), label: placeholder, "data-control": "email", name: value }, form.getInputProps(value))));
992
799
  case 'PhoneOtpBlock':
@@ -994,12 +801,12 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
994
801
  case 'ZaloOtpBlock':
995
802
  case 'PhoneBlock': {
996
803
  const id = popupId + '-' + value + '-' + index;
997
- return (React__default["default"].createElement(index$3.Input.Wrapper, Object.assign({ size: "md", withAsterisk: required, key: index, label: placeholder,
804
+ return (React__default["default"].createElement(index$2.Input.Wrapper, Object.assign({ size: "md", withAsterisk: required, key: index, label: placeholder,
998
805
  // error={errorField.phone}
999
806
  className: cx('leadgen-control', classes.control), labelProps: {
1000
807
  htmlFor: id,
1001
808
  } }, form.getInputProps(value)),
1002
- React__default["default"].createElement(index$3.Phone, { name: value, spellCheck: false, type: "tel", placeholder: placeholder, value: form.getInputProps(value).value, onChange: (v) => {
809
+ React__default["default"].createElement(index$2.Phone, { name: value, spellCheck: false, type: "tel", placeholder: placeholder, value: form.getInputProps(value).value, onChange: (v) => {
1003
810
  form.setFieldValue(value, v);
1004
811
  },
1005
812
  // onBlur={(e) => inputOnBlur('tel', e)}
@@ -1010,12 +817,12 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
1010
817
  }
1011
818
  case 'DateBlock':
1012
819
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
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))),
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))),
1014
821
  React__default["default"].createElement("input", { type: "hidden", name: value, "data-control": "date" })));
1015
822
  case 'LinkButtonBlock':
1016
823
  return (React__default["default"].createElement("div", { key: index },
1017
824
  React__default["default"].createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
1018
- React__default["default"].createElement(index$4.Button, { type: "button", size: "md", color: primaryColor, className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
825
+ React__default["default"].createElement(index$3.Button, { type: "button", size: "md", color: primaryColor, className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
1019
826
  onClose === null || onClose === void 0 ? void 0 : onClose();
1020
827
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
1021
828
  } }, value))));
@@ -1024,26 +831,26 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
1024
831
  isSendMailChimp && (React__default["default"].createElement("div", { style: {
1025
832
  display: 'none',
1026
833
  }, "data-name": value + '-mailchimp' })),
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: {
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: {
1028
835
  display: 'flex',
1029
836
  flexDirection: 'column',
1030
837
  gap: 8,
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" }))))));
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" }))))));
1032
839
  case 'RadioBlock':
1033
840
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
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" }))))));
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" }))))));
1036
843
  case 'DropdownBlock':
1037
844
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
1038
845
  React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
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) => ({
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) => ({
1040
847
  value: l.value,
1041
848
  label: l.placeholder,
1042
849
  })) }, form.getInputProps(value)))));
1043
850
  case 'TncBlock':
1044
851
  const tncInputProps = form.getInputProps('TNC-' + b.id);
1045
852
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
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 }))));
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 }))));
1047
854
  }
1048
855
  return null;
1049
856
  })));
@@ -1070,12 +877,12 @@ var useStyles$1 = core.createStyles((theme) => {
1070
877
  const Heading = (_a) => {
1071
878
  var rest = tslib_es6.__rest(_a, []);
1072
879
  const { heading } = React.useContext(LeadGenComponentContext);
1073
- return heading ? (React__default["default"].createElement(index$2.Text, Object.assign({ size: "h3" }, rest), heading)) : null;
880
+ return heading ? (React__default["default"].createElement(index$1.Text, Object.assign({ size: "h3" }, rest), heading)) : null;
1074
881
  };
1075
882
 
1076
883
  const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps, submitProps, }) => {
1077
884
  var _a;
1078
- const { primaryColor } = React.useContext(LeadGenContext$1);
885
+ const { primaryColor } = React.useContext(LeadGenContext);
1079
886
  const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, setFormRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = React.useContext(LeadGenComponentContext);
1080
887
  const { classes, cx } = useStyles$1(undefined, {
1081
888
  name: 'LeadGen__FormComponent',
@@ -1164,7 +971,7 @@ const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps,
1164
971
  control: classes.control,
1165
972
  }, listBlockAdded: listBlockAdded, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit, popoverProps: popoverProps })),
1166
973
  ((_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 },
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))))));
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))))));
1168
975
  };
1169
976
  const Form = (props) => {
1170
977
  const { showOtpPhone, showThankyou } = React.useContext(LeadGenComponentContext);
@@ -1185,7 +992,7 @@ var useStyles = core.createStyles(() => {
1185
992
  });
1186
993
 
1187
994
  const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, styles, classNames, }) => {
1188
- const { t } = index$1.useTranslations();
995
+ const { t } = index.useTranslations();
1189
996
  const phone = otpData.phone;
1190
997
  const otpType = otpData.type;
1191
998
  const [otp, setOtp] = React.useState('');
@@ -1295,9 +1102,9 @@ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, st
1295
1102
  submitOtp();
1296
1103
  }, className: cx(classes.root, className) },
1297
1104
  React__default["default"].createElement("div", { className: classes.header },
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) => {
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) => {
1301
1108
  setIsDirty(true);
1302
1109
  setOtp(v);
1303
1110
  if (isDirty && !v)
@@ -1306,10 +1113,10 @@ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, st
1306
1113
  setErrorMsg(undefined);
1307
1114
  }, error: isDirty ? errorMsg : undefined }),
1308
1115
  React__default["default"].createElement("div", { className: classes.actions },
1309
- React__default["default"].createElement(index$4.Button, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1116
+ React__default["default"].createElement(index$3.Button, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1310
1117
  // onClick={() => submitOtp()}
1311
1118
  disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
1312
- React__default["default"].createElement(index$4.Button, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1119
+ React__default["default"].createElement(index$3.Button, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1313
1120
  sendOtp();
1314
1121
  }, disabled: !!resendTimer }, t('lead.otp.resend', {
1315
1122
  timer: resendTimer ? ` (${resendTimer}s)` : '',
@@ -1590,1610 +1397,69 @@ const translationsMap = {
1590
1397
  'tl-PH': enPH,
1591
1398
  };
1592
1399
  const getTranslations = (locale) => {
1593
- const translations = Object.assign(Object.assign({}, translationsProvider.translationsMap[locale]), translationsMap[locale]);
1400
+ const translations = translationsMap[locale];
1594
1401
  if (translations) {
1595
1402
  return translations;
1596
1403
  }
1597
1404
  return translationsMap['en-PH'];
1598
1405
  };
1599
1406
 
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));
1407
+ const useImageSize = (src) => {
1408
+ const [width, setWidth] = React.useState(16);
1409
+ const [height, setHeight] = React.useState(9);
1410
+ const [loaded, setLoaded] = React.useState(false);
1411
+ // load src image to get its width and height
1412
+ React.useEffect(() => {
1413
+ setLoaded(false);
1414
+ if (src) {
1415
+ const img = new Image();
1416
+ img.addEventListener('load', () => {
1417
+ setWidth(img.naturalWidth);
1418
+ setHeight(img.naturalHeight);
1419
+ setLoaded(true);
1420
+ });
1421
+ img.addEventListener('error', () => {
1422
+ setWidth(16);
1423
+ setHeight(9);
1424
+ setLoaded(true);
1425
+ });
1426
+ img.src = src;
1427
+ }
1428
+ else {
1429
+ setWidth(16);
1430
+ setHeight(9);
1431
+ setLoaded(true);
1432
+ }
1433
+ }, [src]);
1434
+ return {
1435
+ loaded,
1436
+ width,
1437
+ height,
1438
+ };
1604
1439
  };
1605
1440
 
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) {
1640
- return null;
1641
- }
1642
- };
1643
- const checkCampaignNowInTimeframe = (c) => {
1644
- var _a;
1645
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1646
- const startedAtStr = c.started_at;
1647
- const endedAtStr = c.ended_at;
1648
- const startedDate = parseDateByCampaignTime(startedAtStr);
1649
- const endedDate = parseDateByCampaignTime(endedAtStr);
1650
- if (!startedDate || !endedDate) {
1651
- return false;
1652
- }
1653
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
1654
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1655
- if (nowWithTimezoneMs <= endedDate.getTime() &&
1656
- nowWithTimezoneMs >= startedDate.getTime()) {
1657
- listCampaignScheduledToActivated.push(c);
1658
- return true;
1659
- }
1660
- return false;
1661
- };
1662
- function checkCampaignActiveButExpireAlready(c) {
1663
- var _a;
1664
- /** Do not setup timeframe for this campaign. No need to check */
1665
- if (c.forever === 1) {
1666
- return true;
1667
- }
1668
- const startedAtStr = c.started_at;
1669
- const endedAtStr = c.ended_at;
1670
- const startedDate = parseDateByCampaignTime(startedAtStr);
1671
- const endedDate = parseDateByCampaignTime(endedAtStr);
1672
- /** Do not setup timeframe for this campaign. No need to check */
1673
- if (!startedDate || !endedDate) {
1674
- return true;
1675
- }
1676
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1677
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
1678
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1679
- /** Check if this expire already, do not show */
1680
- if (nowWithTimezoneMs > endedDate.getTime()) {
1681
- listCampaignActiveButExpired.push(c);
1682
- return false;
1683
- }
1684
- return true;
1685
- }
1686
- function shouldNotDisplayIfExcludeAllSponsors(c) {
1687
- var _a;
1688
- const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
1689
- const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
1690
- if (isSponsored && excludeSponsored) {
1691
- listCampaignExcludeSonsored.push(c);
1692
- return true;
1693
- }
1694
- return false;
1695
- }
1696
- function shouldDisplayWithCurrentSponsor(c) {
1697
- var _a, _b;
1698
- try {
1699
- // TODO: BE will rename `exclude_sponsored_list` later
1700
- const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
1701
- const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
1702
- const dataSponsoredId = Number((_b = document
1703
- .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
1704
- // There is no config for sponsor id and white list, should show as default
1705
- if (!dataSponsoredId ||
1706
- dataSponsoredId <= 0 ||
1707
- whiteListSponsors.length === 0) {
1708
- return true;
1709
- }
1710
- // Check the dataSponsoredId exists in the white list or not.
1711
- const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
1712
- if (isExist) {
1713
- return true;
1714
- }
1715
- listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
1716
- return false;
1717
- }
1718
- catch (err) {
1719
- // Default is show
1720
- return true;
1721
- }
1722
- }
1723
- const filterFnCampaign = (c) => {
1724
- if (shouldNotDisplayIfExcludeAllSponsors(c)) {
1725
- return false;
1726
- }
1727
- else if (!shouldDisplayWithCurrentSponsor(c)) {
1728
- return false;
1729
- }
1730
- /** Active */
1731
- if (c.formatted_status === 1) {
1732
- return checkCampaignActiveButExpireAlready(c);
1733
- }
1734
- /** Schedule */
1735
- if (c.formatted_status === 0) {
1736
- listCampaignScheduled.push(c);
1737
- return checkCampaignNowInTimeframe(c);
1738
- }
1739
- return false;
1740
- };
1741
- const fillterApprearanceTimeCampaign = (c) => {
1742
- var _a;
1743
- try {
1744
- const isTimeInRange = (currentTime, startTime, endTime) => {
1745
- const startParts = startTime.split(':');
1746
- const endParts = endTime.split(':');
1747
- const startDate = new Date();
1748
- startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
1749
- const endDate = new Date();
1750
- endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
1751
- return currentTime >= startDate && currentTime <= endDate;
1752
- };
1753
- const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
1754
- const startTime = rulesApprValue.startTime;
1755
- const endTime = rulesApprValue.endTime || '23:59';
1756
- if (!startTime) {
1757
- return true;
1758
- }
1759
- if (isTimeInRange(new Date(), startTime, endTime)) {
1760
- return true;
1761
- }
1762
- listCampaignNotDisplayInRangeOfTime.push(c);
1763
- return false;
1764
- }
1765
- catch (err) {
1766
- return true;
1767
- }
1768
- };
1769
- let timeoutRef = null;
1770
- let LEAD_SCROLL_EVENT = null;
1771
- function clearPassiveEvent() {
1772
- if (timeoutRef) {
1773
- clearTimeout(timeoutRef);
1774
- timeoutRef = null;
1775
- }
1776
- if (LEAD_SCROLL_EVENT) {
1777
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1778
- LEAD_SCROLL_EVENT = null;
1779
- }
1780
- }
1781
- function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
1782
- // clear previous passive event, check for new condition
1783
- clearPassiveEvent();
1784
- const leadCurrentUrl = DEBUG_URL ||
1785
- ('https://' +
1786
- location.hostname +
1787
- location.pathname +
1788
- location.search).toLowerCase();
1789
- fetch(leadApi + 'api/campaign/' + leadSiteId, {
1790
- method: 'POST',
1791
- headers: {
1792
- 'Content-Type': 'application/json',
1793
- },
1794
- body: JSON.stringify({
1795
- url: leadCurrentUrl,
1796
- ga_client_id: miscCookieHelper.getCookie('_ga') || null,
1797
- }),
1798
- })
1799
- .then((response) => {
1800
- return response.json();
1801
- // return mockLeadData || response.json()
1802
- })
1803
- .then((data) => {
1804
- var _a, _b, _c, _d;
1805
- LeadLog('List campagin: ', data);
1806
- LEAD_RESET_VAR();
1807
- if (data._status == 1) {
1808
- const campaigns = (((_b = (_a = data._data) === null || _a === void 0 ? void 0 : _a.campaigns) === null || _b === void 0 ? void 0 : _b.filter(filterFnCampaign)) || []).filter(fillterApprearanceTimeCampaign);
1809
- if (!miscCookieHelper.getCookie('hhg-id')) {
1810
- miscCookieHelper.setCookie('hhg-id', uuid.v1(), {
1811
- domain: '.' + leadDomain,
1812
- path: '/',
1813
- });
1814
- LeadLog('😍 Set HHG ID cookie');
1815
- }
1816
- // getCookie('hhg-id')
1817
- // TODO: HP-534 Filter desktop
1818
- let campaignsDevice = [];
1819
- if (isMobile()) {
1820
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
1821
- }
1822
- else {
1823
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
1824
- }
1825
- LeadLog(`👓 campaignsDevice`, campaignsDevice);
1826
- LeadLog('--listCampaignScheduled', listCampaignScheduled);
1827
- LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
1828
- LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
1829
- LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
1830
- LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
1831
- LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
1832
- // Check links
1833
- let listLinksObj = campaignsDevice
1834
- .map((i, index) => i.targets
1835
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
1836
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1837
- .flat(1);
1838
- // Check list link match current href
1839
- listLinksObj = listLinksObj.filter((i) => {
1840
- var _a;
1841
- const target = new URL(String(i.target).toLowerCase());
1842
- if (i.option == 'exact_match')
1843
- // FOR TEST LOCAL:
1844
- // return Boolean(location.pathname === target.pathname)
1845
- return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
1846
- if (i.option == 'start_with') {
1847
- // FOR TEST LOCAL:
1848
- // if (location.pathname.includes(target.pathname)) {
1849
- if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
1850
- const listExcluding = i.sub_target
1851
- .filter((i) => i.option == 'excluding')
1852
- .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
1853
- return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
1854
- }
1855
- else {
1856
- return false;
1857
- }
1858
- }
1859
- });
1860
- // Check tags
1861
- const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
1862
- const listTags = listMetaTag.map((i) => i.content);
1863
- let listCampaignHasTag = [];
1864
- let listTagsObj = [];
1865
- if (listTags && listTags.length) {
1866
- listCampaignHasTag = campaignsDevice
1867
- .map((i, index) => i.targets
1868
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
1869
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1870
- .flat(1);
1871
- listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
1872
- }
1873
- const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
1874
- const cookieKeys = document.cookie
1875
- .split('; ')
1876
- .map((i) => i.split('=')[0]);
1877
- const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
1878
- LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
1879
- const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
1880
- LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
1881
- const listCampaignSubmitedClosed = [
1882
- ...listCampaignCodeSubmited,
1883
- ...listCampaignCodeClosed,
1884
- ];
1885
- const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
1886
- const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
1887
- return !hasSubmited;
1888
- });
1889
- const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
1890
- // .sort(
1891
- // (a, b) =>
1892
- // (listCampaignValid[a.campaignIndex]?.score || 0) -
1893
- // (listCampaignValid[b.campaignIndex]?.score || 0),
1894
- // )
1895
- LeadLog('--listCampaignValid : ', listCampaignValid);
1896
- if (listCampaignValid && listCampaignValid.length) {
1897
- const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
1898
- LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
1899
- const { rules } = CAMPAIGN_SHOW;
1900
- // CHECK RULE TRIGGER POPUP
1901
- const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
1902
- LeadLog(`timeoutRule`, timeoutRule);
1903
- const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
1904
- LeadLog(`scrollRule`, scrollRule);
1905
- let impressionAction = 'TIME';
1906
- if (Number.isInteger(timeoutRule)) {
1907
- impressionAction = 'TIME';
1908
- LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
1909
- timeoutRef = setTimeout(() => {
1910
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1911
- }, timeoutRule * 1000);
1912
- }
1913
- if (Number.isInteger(scrollRule)) {
1914
- impressionAction = 'SCROLL';
1915
- LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
1916
- const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
1917
- document.querySelector('body');
1918
- const pct = $p.getBoundingClientRect().top;
1919
- const pb = $p.offsetHeight;
1920
- LeadLog(`👓 Element check scroll: `, $p);
1921
- LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
1922
- const wt = window.pageYOffset || document.documentElement.scrollTop;
1923
- let percent = 0;
1924
- if (wt >= pct) {
1925
- percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
1926
- }
1927
- LeadLog('---Scroll', percent, scrollRule);
1928
- // TODO: CHECK FOOTER HEIGHT
1929
- if (percent >= scrollRule) {
1930
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1931
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1932
- }
1933
- };
1934
- window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
1935
- passive: true,
1936
- });
1937
- }
1938
- }
1939
- else {
1940
- LeadLog('🚧 No lead campaigns on current URL, tags');
1941
- }
1942
- }
1943
- })
1944
- .catch((err) => {
1945
- LeadLog(`Lead error: `, err);
1946
- });
1947
- }
1948
- const LeadLog = (...params) => {
1949
- if (process.env.NODE_ENV !== 'production' ||
1950
- (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
1951
- process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
1952
- (typeof localStorage !== 'undefined' &&
1953
- localStorage.getItem('hhg_debug') === 'true')) {
1954
- console.log(...params);
1955
- }
1956
- };
1957
-
1958
- const LeadGenContext = React.createContext({
1959
- submit(value) {
1960
- /** Init for FAKING function */
1961
- LeadLog('** LeadGen Submit : ', value);
1962
- return Promise.reject(value);
1963
- },
1964
- submitSubscriptionBox(value) {
1965
- /** Init for FAKING function */
1966
- LeadLog('** LeadGen SubmitSubscriptionBox : ', value);
1967
- return Promise.reject(value);
1968
- },
1969
- impression(value) {
1970
- /** Init for FAKING function */
1971
- LeadLog('** LeadGen Impression : ', value);
1972
- return Promise.reject(value);
1973
- },
1974
- /** For Subscription Box */
1975
- subscriptionIcon: '',
1976
- subscriptionTitle: '',
1977
- });
1978
- const LeadGenContextProvider = (props) => {
1979
- const { campaign_code: campaignCodeProps, apiSsoUrl, apiLeadUrl, apiSubotUrl, locale: localeProps, forceCampaign: forceCampaignProps, extraValues, articleId = 1, categoryId = 1, siteDomain: site_domain, children, } = props;
1980
- const [forceCampaign, setForceCampaign] = React.useState(forceCampaignProps);
1981
- const [subscriptionInfo, setSubscriptionInfo] = React.useState({
1982
- subscriptionIcon: '',
1983
- subscriptionTitle: '',
1984
- });
1985
- const locale = React.useMemo(() => {
1986
- return localeProps || Locale.LOCALE['PhilippinesEnglish'];
1987
- }, [localeProps]);
1988
- const leadGenContextValue = React.useMemo(() => (Object.assign(Object.assign({}, props), { forceCampaign })), [...Object.values(props), forceCampaign]);
1989
- const { url, campaign_id, campaign_code, cookie_id, ga_client_id, category_id, article_id, article_title, } = React.useMemo(() => ({
1990
- url: location.href.toLowerCase() || '',
1991
- cookie_id: miscCookieHelper.getCookie('hhg-id') || null,
1992
- ga_client_id: miscCookieHelper.getCookie('_ga'),
1993
- campaign_id: forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id,
1994
- campaign_code: campaignCodeProps || (forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.code),
1995
- category_id: categoryId,
1996
- article_id: articleId,
1997
- article_title: document.title || '',
1998
- }), [campaignCodeProps, articleId, categoryId, forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id]);
1999
- const fetchCampaign = React.useCallback((campaign_code) => {
2000
- Service.getCampaignByCode(campaign_code).then((res) => {
2001
- const { _data } = res || {};
2002
- const { campaigns } = _data || {};
2003
- LeadLog('** LeadGen Campaign : ', campaigns);
2004
- setForceCampaign(formatCampaignDetail(campaigns));
2005
- });
2006
- }, [campaignCodeProps]);
2007
- // TODO : Update form for LeadGen
2008
- const submit = React.useCallback((data) => {
2009
- return Service.postSubscriptionBoxLead({ data });
2010
- }, []);
2011
- const submitSubscriptionBox = React.useCallback((value) => {
2012
- const data = Object.assign(Object.assign(Object.assign(Object.assign({}, value), { campaign_id,
2013
- site_domain, url: (value === null || value === void 0 ? void 0 : value.url) || url, ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id }), extraValues), { article_id,
2014
- category_id, article_title: (extraValues === null || extraValues === void 0 ? void 0 : extraValues.article_title) || article_title });
2015
- return Service.postSubscriptionBoxLead({ data });
2016
- }, [
2017
- extraValues,
2018
- site_domain,
2019
- campaign_id,
2020
- article_id,
2021
- article_title,
2022
- category_id,
2023
- url,
2024
- ga_client_id,
2025
- ]);
2026
- const impression = React.useCallback((value) => {
2027
- return Service.campaignPostImpression({
2028
- url: (value === null || value === void 0 ? void 0 : value.url) || url,
2029
- action: (value === null || value === void 0 ? void 0 : value.action) || LEADGEN_ACTIONS.SCROLL,
2030
- code: (value === null || value === void 0 ? void 0 : value.code) || campaign_code,
2031
- title_article: (value === null || value === void 0 ? void 0 : value.title_article) || article_title,
2032
- cookie_id: (value === null || value === void 0 ? void 0 : value.cookie_id) || cookie_id,
2033
- ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id,
2034
- extra: (value === null || value === void 0 ? void 0 : value.extra) || Object.assign({ cookie_id,
2035
- article_id, subscription_title: subscriptionInfo.subscriptionTitle }, extraValues),
2036
- referrer: value === null || value === void 0 ? void 0 : value.referrer,
2037
- });
2038
- }, [
2039
- extraValues,
2040
- campaign_id,
2041
- url,
2042
- campaign_code,
2043
- article_title,
2044
- cookie_id,
2045
- ga_client_id,
2046
- article_id,
2047
- subscriptionInfo.subscriptionTitle,
2048
- ]);
2049
- React.useEffect(() => {
2050
- if (forceCampaignProps) {
2051
- setForceCampaign(forceCampaignProps);
2052
- return;
2053
- }
2054
- /** For Subscription Box */
2055
- if (categoryId) {
2056
- Service.getSubscriptionBoxInfo({
2057
- category: categoryId,
2058
- site: site_domain,
2059
- }).then((res) => {
2060
- const { _data } = res || {};
2061
- const { item, campaign_code } = _data || {};
2062
- const { icon, content } = item || {};
2063
- LeadLog('** LeadGen SubscriptionBox campaign_code : ', campaign_code);
2064
- LeadLog('** LeadGen SubscriptionBox subscription_icon : ', icon);
2065
- LeadLog('** LeadGen SubscriptionBox subscription_title : ', content);
2066
- setSubscriptionInfo({
2067
- subscriptionIcon: icon,
2068
- subscriptionTitle: content,
2069
- });
2070
- if (campaign_code) {
2071
- fetchCampaign(campaign_code);
2072
- }
2073
- });
2074
- return;
2075
- }
2076
- if (campaignCodeProps) {
2077
- fetchCampaign(campaignCodeProps);
2078
- }
2079
- }, [campaignCodeProps, categoryId]);
2080
- React.useEffect(() => {
2081
- leadStore.apiSsoUrl = apiSsoUrl;
2082
- leadStore.apiLeadUrl = apiLeadUrl;
2083
- leadStore.apiSubotUrl = apiSubotUrl;
2084
- }, [apiLeadUrl, apiSubotUrl, apiSsoUrl]);
2085
- if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
2086
- return null;
2087
- }
2088
- return (React__default["default"].createElement(LeadGenContext.Provider, { value: Object.assign(Object.assign(Object.assign({}, leadGenContextValue), subscriptionInfo), { submit,
2089
- submitSubscriptionBox,
2090
- impression }) },
2091
- React__default["default"].createElement(LeadGenTranslationProvider, { locale: locale }, children)));
2092
- };
2093
- const useLeadGenContext = () => {
2094
- const context = React.useContext(LeadGenContext);
2095
- return Object.assign(Object.assign({}, context), { apiLeadUrl: context.apiLeadUrl || leadStore.apiLeadUrl, apiSubotUrl: context.apiSubotUrl || leadStore.apiSubotUrl });
2096
- };
2097
-
2098
- // eslint-disable-next-line @typescript-eslint/no-var-requires
2099
- const customParseFormat = require('dayjs/plugin/customParseFormat');
2100
- dayjs__default["default"].extend(customParseFormat);
2101
- // You can give context variables any name
2102
- const [LeadFormProvider, useLeadFormContext, useLeadForm] = form.createFormContext();
2103
- const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
2104
- var _a;
2105
- const { t } = index$1.useTranslations();
2106
- const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
2107
- const LEAD_LOCALE = LEAD_LOCALE_DATA[(_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.lang] ||
2108
- LEAD_LOCALE_DATA['vi-VN'];
2109
- const validateObj = React.useMemo(() => {
2110
- const InputBlocks = [
2111
- 'TextBlock',
2112
- 'NumberBlock',
2113
- 'EmailBlock',
2114
- 'PhoneBlock',
2115
- 'DateBlock',
2116
- 'CheckboxBlock',
2117
- 'RadioBlock',
2118
- 'DropdownBlock',
2119
- 'PhoneOtpBlock',
2120
- 'WhatsappOtpBlock',
2121
- 'ZaloOtpBlock',
2122
- 'LocationBlock',
2123
- 'TncBlock',
2124
- ];
2125
- // ALL are required and can skip if not touched yet
2126
- const withSharedCheck = (name, cb,
2127
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2128
- block) => {
2129
- return (value) => {
2130
- var _a;
2131
- const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
2132
- if (!formRef.current.isTouched(name))
2133
- return;
2134
- if ((typeof value === 'string' && value.trim() === '') ||
2135
- typeof value === 'undefined' ||
2136
- (Array.isArray(value) && value.length === 0)) {
2137
- return isBLockRequired
2138
- ? t('validator.required')
2139
- : cb === null || cb === void 0 ? void 0 : cb(value);
2140
- }
2141
- return cb === null || cb === void 0 ? void 0 : cb(value);
2142
- };
2143
- };
2144
- return listBlockAdded
2145
- .filter((b) => InputBlocks.includes(b.name))
2146
- .reduce((r, b) => {
2147
- const { name: fieldType, data } = b || {};
2148
- const { value: fieldName, required } = data || {};
2149
- const isRequired = required !== null && required !== void 0 ? required : true;
2150
- if (fieldType === 'NumberBlock') {
2151
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2152
- if (value && isNaN(Number(value))) {
2153
- return t('validator.number');
2154
- }
2155
- }, b) });
2156
- }
2157
- else if (fieldType === 'EmailBlock') {
2158
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2159
- if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
2160
- return t('validator.email');
2161
- }
2162
- if (!value)
2163
- return;
2164
- validatingEmailRef.current = true;
2165
- setTimeout(() => {
2166
- formRef.current.setFieldError(fieldName, 'Validating...');
2167
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2168
- email: value,
2169
- })
2170
- .then((tKey) => {
2171
- if (tKey) {
2172
- formRef.current.setFieldError(fieldName, t(tKey));
2173
- }
2174
- else {
2175
- formRef.current.clearFieldError(fieldName);
2176
- }
2177
- validatingEmailRef.current = false;
2178
- })
2179
- .catch((e) => {
2180
- console.error(e);
2181
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2182
- validatingEmailRef.current = false;
2183
- });
2184
- }, 200);
2185
- }, b) });
2186
- }
2187
- else if (fieldType === 'PhoneBlock' ||
2188
- fieldType === 'PhoneOtpBlock' ||
2189
- fieldType === 'ZaloOtpBlock' ||
2190
- fieldType === 'WhatsappOtpBlock') {
2191
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2192
- if (value &&
2193
- window.intlTelInputUtils &&
2194
- !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
2195
- return t('validator.phone');
2196
- }
2197
- if (!value)
2198
- return;
2199
- validatingPhoneRef.current = true;
2200
- setTimeout(() => {
2201
- formRef.current.setFieldError(fieldName, 'Validating...');
2202
- if (b.data.singleSubmission) {
2203
- checkUsedPhoneOnlyWithCache(campaignId, value)
2204
- .then((tKey) => {
2205
- if (tKey) {
2206
- formRef.current.setFieldError(fieldName, t(tKey));
2207
- }
2208
- else {
2209
- formRef.current.clearFieldError(fieldName);
2210
- }
2211
- validatingPhoneRef.current = false;
2212
- })
2213
- .catch((err) => {
2214
- console.error(err);
2215
- formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
2216
- validatingPhoneRef.current = false;
2217
- });
2218
- }
2219
- else {
2220
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2221
- phone: value,
2222
- })
2223
- .then((tKey) => {
2224
- if (tKey) {
2225
- formRef.current.setFieldError(fieldName, t(tKey));
2226
- }
2227
- else {
2228
- formRef.current.clearFieldError(fieldName);
2229
- }
2230
- validatingPhoneRef.current = false;
2231
- })
2232
- .catch((e) => {
2233
- console.error(e);
2234
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2235
- validatingPhoneRef.current = false;
2236
- });
2237
- }
2238
- }, 200);
2239
- }, b) });
2240
- }
2241
- else if (fieldType === 'DateBlock') {
2242
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2243
- if (!isRequired && !value) {
2244
- return;
2245
- }
2246
- const errMsg = t('validator.dateInvalid');
2247
- const dayInJS = typeof value === 'string'
2248
- ? dayjs__default["default"](value, format, true)
2249
- : dayjs__default["default"](value);
2250
- if (!dayInJS.isValid()) {
2251
- return errMsg;
2252
- }
2253
- }, b) });
2254
- }
2255
- else if (fieldType === 'TncBlock') {
2256
- return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
2257
- if (isRequired && !value) {
2258
- return t('validator.required');
2259
- }
2260
- }, b) });
2261
- }
2262
- else {
2263
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
2264
- }
2265
- }, {});
2266
- }, [listBlockAdded.map((b) => b.name).join(','), format]);
2267
- const form = useLeadForm({
2268
- validateInputOnChange: true,
2269
- validateInputOnBlur: true,
2270
- clearInputErrorOnChange: true,
2271
- validate: validateObj,
2272
- initialValues,
2273
- });
2274
- const formRef = React.useRef(form);
2275
- formRef.current = form;
2276
- return { form, validateObj };
2277
- };
2278
-
2279
- const StyledLeadGenThankYou = styled__default["default"].div `
2280
- display: flex;
2281
- gap: 8px;
2282
- flex-direction: column;
2283
- padding-block: 24px;
2284
-
2285
- .leadgen-image {
2286
- width: 120px;
2287
- height: 120px;
2288
- margin-inline: auto;
2289
- object-fit: contain;
2290
- object-position: center;
2291
- text-align: center;
2292
- }
2293
-
2294
- .leadgen-title {
2295
- margin-block: 0;
2296
- color: ${miscTheme.theme.colors.gray900};
2297
- font-weight: 700;
2298
- font-size: 18px;
2299
- line-height: 28px;
2300
- letter-spacing: -0.2px;
2301
- }
2302
-
2303
- .leadgen-description {
2304
- margin-block: 0;
2305
- color: ${miscTheme.theme.colors.gray600};
2306
- font-weight: 400;
2307
- font-size: 14px;
2308
- line-height: 22px;
2309
- letter-spacing: -0.2px;
2310
- text-align: center;
2311
- }
2312
-
2313
- > [data-align] {
2314
- &[data-align='right'] {
2315
- text-align: right;
2316
- }
2317
- &[data-align='center'] {
2318
- text-align: center;
2319
- }
2320
- }
2321
- `;
2322
- const LeadGenThankYou = ({ image, title, description, showButton = false, button, className, style, }) => {
2323
- const { src } = image;
2324
- const { htmlText: titleText, align: titleAlign } = title;
2325
- const { htmlText: descriptionText, align: descriptionAlign } = description;
2326
- const { htmlText: buttonText, newtab, url, onClick } = button;
2327
- return (React__default["default"].createElement(StyledLeadGenThankYou, { className: className, style: style },
2328
- React__default["default"].createElement("img", { src: src, alt: "", className: "leadgen-thankyou_image leadgen-image" }),
2329
- React__default["default"].createElement("p", { className: "leadgen-thankyou_title leadgen-title", "data-align": titleAlign }, titleText),
2330
- React__default["default"].createElement("p", { className: "leadgen-thankyou_description leadgen-description", "data-align": descriptionAlign }, descriptionText),
2331
- !!buttonText && showButton && (React__default["default"].createElement(core.Button, { component: url ? 'a' : 'button', target: newtab ? '_blank' : undefined, href: url, size: "lg", variant: "filled", className: "leadgen-thankyoue_btn leadgen-btn", onClick: onClick }, buttonText))));
2332
- };
2333
-
2334
- const StyledLeadGenSubscriptionBoxBody = styled__default["default"].div `
2335
- margin-top: 16px;
2336
- .leadgen-btn {
2337
- margin-top: 16px;
2338
- }
2339
- `;
2340
- const StyledLeadGenSubscriptionBoxHeaderImage = styled__default["default"].div `
2341
- margin-top: 3px;
2342
- margin-right: 20px;
2343
- width: 44px;
2344
- height: 44px;
2345
-
2346
- img {
2347
- width: 100%;
2348
- height: 100%;
2349
- object-fix: contain;
2350
- onject-position: center;
2351
- }
2352
-
2353
- :has(img[src='']) {
2354
- display: none;
2355
- }
2356
- `;
2357
- const StyledLeadGenSubscriptionBoxHeader = styled__default["default"].div `
2358
- display: flex;
2359
- align-items: center;
2360
- margin-bottom: 16px;
2361
- .leadgen-title {
2362
- margin-bottom: 0;
2363
- flex: 1;
2364
- min-width: 0;
2365
- color: ${miscTheme.theme.colors.gray900};
2366
- font-size: 18px;
2367
- font-weight: 400;
2368
- line-height: 1.4;
2369
- letter-spacing: -0.8px;
2370
- }
2371
- `;
2372
- const StyledLeadGenSubscriptionBox = styled__default["default"].div `
2373
- padding: 16px;
2374
- border: 1px solid ${miscTheme.theme.colors.neutral100};
2375
- border-radius: 12px;
2376
- margin-inline: auto;
2377
- .leadgen-form_inputs {
2378
- .leadgen-form_input {
2379
- width: 100%;
2380
- }
2381
- }
2382
-
2383
- .leadgen-form_input {
2384
- .mantine-Input-wrapper {
2385
- max-height: 56px;
2386
- }
2387
- }
2388
-
2389
- @media screen and (min-width: 768px) {
2390
- .leadgen-subscription_box_body {
2391
- display: flex;
2392
- > form {
2393
- flex: 1;
2394
- min-width: 0;
2395
-
2396
- .leadgen-form_inputs {
2397
- .leadgen-form_input {
2398
- width: calc(50% - 4px);
2399
- }
2400
- }
2401
- }
2402
-
2403
- .leadgen-btn {
2404
- margin-top: 0;
2405
- margin-left: 8px;
2406
- width: auto;
2407
- min-height: 56px;
2408
- }
2409
- }
2410
- }
2411
- `;
2412
- const StyledLeadGenSubscriptionBoxA = styled__default["default"].div `
2413
- .leadgen-form_input {
2414
- --phone-select: 45px;
2415
- .PhoneInput {
2416
- --phone-select: 45px;
2417
- .PhoneInputCountry {
2418
- margin-top: 1px;
2419
- pointer-events: none;
2420
- .PhoneInputCountryIconImg,
2421
- .PhoneInputArrowContainer {
2422
- display: none;
2423
- }
2424
- }
2425
- }
2426
- }
2427
- `;
2428
-
2429
- const PhoneInput = React.forwardRef((props, ref) => {
2430
- const { defaultCountry, id: idProps, name, placeholder, label, labelElement, labelProps, description, descriptionProps, withAsterisk, inputMode, inputContainer, inputWrapperOrder, error, className, classNames, style, styles } = props, restProps = tslib_es6.__rest(props, ["defaultCountry", "id", "name", "placeholder", "label", "labelElement", "labelProps", "description", "descriptionProps", "withAsterisk", "inputMode", "inputContainer", "inputWrapperOrder", "error", "className", "classNames", "style", "styles"]);
2431
- const id = idProps || uuid.v1() + name;
2432
- return (React__default["default"].createElement(core.Input.Wrapper, { size: "md", label: label, labelElement: labelElement, labelProps: Object.assign({ htmlFor: id }, labelProps), description: description, descriptionProps: descriptionProps, withAsterisk: withAsterisk, inputMode: inputMode, inputContainer: inputContainer, inputWrapperOrder: inputWrapperOrder, error: error, "data-invalid": !!error, className: className, classNames: classNames, style: style, styles: styles },
2433
- React__default["default"].createElement("div", { className: "mantine-Input-wrapper" },
2434
- React__default["default"].createElement(index$3.Phone, Object.assign({}, restProps, { id: id, ref: ref, name: name, spellCheck: false, placeholder: placeholder, defaultCountry: defaultCountry, className: "mantine-Input-input", type: "tel", "data-control": "tel" })))));
2435
- });
2436
-
2437
- const formatLeadGenFormValue = (values, blocks) => {
2438
- const newValues = {};
2439
- for (const block of blocks) {
2440
- const { data } = block || {};
2441
- const { value: fieldName } = data || {};
2442
- if (fieldName in values) {
2443
- newValues[fieldName] = values[fieldName];
2444
- }
2445
- }
2446
- return newValues;
2447
- };
2448
-
2449
- const StyledLeadGenFormInner = styled__default["default"].div `
2450
- display: flex;
2451
- flex-wrap: wrap;
2452
- gap: 8px;
2453
- .leadgen-form_input {
2454
- width: calc(50% - 4px);
2455
- }
2456
-
2457
- .leadgen-form_input_checkbox {
2458
- width: 100%;
2459
- }
2460
- `;
2461
-
2462
- const cssInputNotShrink$1 = react.css `
2463
- height: 100% !important;
2464
- min-height: calc(var(--container-height, 56px) * 22 / 56);
2465
- color: ${miscTheme.theme.colors.gray800};
2466
- font-size: var(--input, 16px);
2467
- line-height: calc(var(--container-height, 56px) * 22 / 56);
2468
- border: none !important;
2469
- border-radius: 0 !important;
2470
- outline: none !important;
2471
- box-shadow: none !important;
2472
- padding: 0;
2473
- cursor: pointer;
2474
- opacity: 0;
2475
-
2476
- ::placeholder {
2477
- color: ${miscTheme.theme.colors.gray400};
2478
- }
2479
- `;
2480
- const cssInputShrink$1 = react.css `
2481
- height: auto !important;
2482
- cursor: text;
2483
- opacity: 1;
2484
- transition: 0.1s ease-in-out all;
2485
- `;
2486
- const cssLabelNotShrink$1 = react.css `
2487
- position: absolute;
2488
- top: calc(var(--container-height) / 2);
2489
- left: var(--space-x, 16px);
2490
- color: ${miscTheme.theme.colors.gray400};
2491
- font-size: var(--label-not-shrink, 16px);
2492
- font-weight: 400;
2493
- line-height: calc(var(--container-height, 56px) * 18 / 56);
2494
- margin: 0;
2495
- z-index: 1;
2496
- cursor: pointer;
2497
- transform: translateY(-50%);
2498
- transition: 0.125s ease-in all;
2499
- `;
2500
- const cssLabelShrink$1 = react.css `
2501
- color: ${miscTheme.theme.colors.gray600};
2502
- font-weight: 600;
2503
- font-size: var(--label-shrink, 12px);
2504
- top: calc(var(--container-height) * 7 / 56);
2505
- transform: none;
2506
- transition: 0.125s ease-out all;
2507
- `;
2508
- const cssWrapperInputNotShrink$1 = react.css `
2509
- min-height: var(--container-height, 56px);
2510
- display: flex;
2511
- align-items: flex-end;
2512
- border: 1px solid ${miscTheme.theme.colors.gray200};
2513
- border-radius: 8px;
2514
- background-color: #fff;
2515
- padding-inline: var(--space-x, 16px);
2516
- padding-block: var(--space-y-not-shrink, 16px);
2517
- cursor: pointer;
2518
- pointer-events: none;
2519
-
2520
- &:has(.mantine-Input-rightSection) {
2521
- padding-right: var(--container-height, 56px);
2522
- }
2523
-
2524
- .mantine-Input-icon {
2525
- display: none;
2526
- }
2527
-
2528
- .mantine-NumberInput-control {
2529
- border-color: ${miscTheme.theme.colors.gray200};
2530
- }
2531
- `;
2532
- const cssWrapperInputShrink$1 = react.css `
2533
- height: auto;
2534
- min-height: var(--container-height, 56px);
2535
- padding-block: var(--space-y-shrink, 7px);
2536
- cursor: text;
2537
- pointer-events: auto;
2538
- `;
2539
- const cssInputWrapperError$1 = react.css `
2540
- color: ${miscTheme.theme.colors.red800};
2541
- font-size: 12px;
2542
- line-height: 1.5;
2543
- `;
2544
- const StyledTextFieldContainer$1 = styled__default["default"].div `
2545
- --space-x: 16px;
2546
- --space-y-not-shrink: 16px;
2547
- --space-y-shrink: 7px;
2548
- --container-height: 56px;
2549
- --label-not-shrink: 16px;
2550
- --label-shrink: 12px;
2551
- --input: 16px;
2552
-
2553
- position: relative;
2554
- min-width: 100px;
2555
- max-width: 100%;
2556
- display: inline-block;
2557
-
2558
- .textField_wrapper {
2559
- display: inline-block;
2560
- width: 100%;
2561
- cursor: pointer;
2562
- }
2563
-
2564
- .mantine-InputWrapper-root {
2565
- &[data-invalid='true'] {
2566
- .mantine-Input-wrapper {
2567
- border-color: ${miscTheme.theme.colors.red400};
2568
- }
2569
- }
2570
-
2571
- .mantine-Input-wrapper {
2572
- &:has([data-invalid]) {
2573
- border-color: ${miscTheme.theme.colors.red400};
2574
- }
2575
- }
2576
-
2577
- .mantine-InputWrapper-error {
2578
- font-size: 12px !important;
2579
- }
2580
- }
2581
-
2582
- .mantine-InputWrapper-label {
2583
- ${cssLabelNotShrink$1}
2584
- }
2585
-
2586
- .mantine-Input-wrapper {
2587
- ${cssWrapperInputNotShrink$1}
2588
-
2589
- + .mantine-Popover-dropdown[data-position="bottom-start"] {
2590
- left: 0 !important;
2591
- }
2592
- + .mantine-Popover-dropdown[data-position='top-start'] {
2593
- top: unset !important;
2594
- left: 0 !important;
2595
- bottom: 100% !important;
2596
- }
2597
- }
2598
-
2599
- .mantine-Input-input {
2600
- ${cssInputNotShrink$1}
2601
- }
2602
-
2603
- &.textField_shrink,
2604
- &:focus-within {
2605
- .mantine-InputWrapper-label {
2606
- ${cssLabelShrink$1}
2607
- }
2608
-
2609
- .mantine-Input-wrapper {
2610
- ${cssWrapperInputShrink$1}
2611
- &.mantine-Select-wrapper {
2612
- .mantine-Select-rightSection {
2613
- pointer-events: auto !important;
2614
- }
2615
- }
2616
- }
2617
-
2618
- .mantine-Input-input {
2619
- ${cssInputShrink$1}
2620
- }
2621
-
2622
- &:has(.PhoneInput) {
2623
- .mantine-InputWrapper-label {
2624
- left: var(--space-x, 16px);
2625
- }
2626
- .PhoneInput {
2627
- .PhoneInputInput {
2628
- opacity: 1;
2629
- }
2630
- }
2631
- }
2632
- }
2633
-
2634
- .PhoneInput {
2635
- --phone-select: 75px;
2636
- --phone-input-space-x: 8px;
2637
- width: 100%;
2638
- opacity: 1;
2639
- border: none;
2640
- .PhoneInputCountry {
2641
- background-color: transparent;
2642
- border: none;
2643
- padding: 0;
2644
- width: var(--phone-select, 75px);
2645
- }
2646
- .PhoneInputInput {
2647
- flex: 1;
2648
- min-width: 0;
2649
- line-height: 1.5;
2650
- outline: none !important;
2651
- border: none;
2652
- box-shadow: none;
2653
- padding: 0 var(--phone-input-space-x, 8px);
2654
- opacity: 0;
2655
- color: ${miscTheme.theme.colors.gray800} !important;
2656
- :focus {
2657
- color: ${miscTheme.theme.colors.gray800} !important;
2658
- }
2659
- }
2660
- }
2661
-
2662
- &:has(.PhoneInput) {
2663
- .mantine-InputWrapper-label {
2664
- left: calc(
2665
- var(--space-x, 16px) + var(--phone-select, 75px) +
2666
- var(--phone-input-space-x, 8px)
2667
- );
2668
- }
2669
- }
2670
- `;
2671
- const StyledChoiceFieldContainer$1 = styled__default["default"].div `
2672
- &.leadgen-form_checkbox,
2673
- &.leadgen-form_radio {
2674
- width: 100%;
2675
- }
2676
-
2677
- &.leadgen-form_dropdown {
2678
- width: calc(50% - 12px);
2679
- }
2680
-
2681
- .mantine-InputWrapper-root {
2682
- display: block;
2683
- .mantine-InputWrapper-error {
2684
- font-size: 12px !important;
2685
- }
2686
- }
2687
-
2688
- .mantine-InputWrapper-label {
2689
- margin-bottom: 0.5rem;
2690
- color: ${miscTheme.theme.colors.gray800};
2691
- font-size: 16px;
2692
- font-weight: 400;
2693
- line-height: 1.5;
2694
- }
2695
-
2696
- .mantine-Radio-root,
2697
- .mantine-Checkbox-root {
2698
- gap: 8px;
2699
- min-width: calc(50% - 4px);
2700
-
2701
- input[type='radio'],
2702
- input[type='checkbox'] {
2703
- border-color: ${miscTheme.theme.colors.gray600};
2704
- width: 18px;
2705
- height: 18px;
2706
- }
2707
- input[type='checkbox'] {
2708
- border-radius: 4px;
2709
- }
2710
-
2711
- &[data-checked='true'] {
2712
- input[type='radio'],
2713
- input[type='checkbox'] {
2714
- border-color: ${miscTheme.theme.colors.primary600};
2715
- + svg {
2716
- color: ${miscTheme.theme.colors.primary600};
2717
- }
2718
- }
2719
-
2720
- input[type='radio'] {
2721
- background-color: white;
2722
- }
2723
- }
2724
-
2725
- .mantine-Checkbox-input {
2726
- &:checked {
2727
- border-color: ${miscTheme.theme.colors.primary600};
2728
- }
2729
- }
2730
- }
2731
-
2732
- .mantine-Radio-inner,
2733
- .mantine-Checkbox-inner {
2734
- width: 24px;
2735
- height: 24px;
2736
- display: flex;
2737
- align-items: center;
2738
- justify-content: center;
2739
- }
2740
-
2741
- .mantine-Radio-body,
2742
- .mantine-Checkbox-body {
2743
- display: flex;
2744
- align-items: center;
2745
- }
2746
-
2747
- .mantine-Radio-label,
2748
- .mantine-Checkbox-label {
2749
- padding-left: 8px;
2750
- color: ${miscTheme.theme.colors.gray800};
2751
- font-size: 14px;
2752
- line-height: 1.4;
2753
- letter-spacing: -0.2px;
2754
- }
2755
-
2756
- .leadgen-choiceContainer {
2757
- display: flex;
2758
- flex-wrap: wrap;
2759
- align-items: flex-start;
2760
- gap: 8px;
2761
- }
2762
-
2763
- .mantine-InputWrapper-error {
2764
- ${cssInputWrapperError$1}
2765
- }
2766
- `;
2767
-
2768
- const TextField$1 = (props) => {
2769
- const { shrink: shrinkProps, onChangeShrink, className, children } = props, restProps = tslib_es6.__rest(props, ["shrink", "onChangeShrink", "className", "children"]);
2770
- const containerRef = hooks.useClickOutside(() => {
2771
- if (shrinkProps) {
2772
- return;
2773
- }
2774
- setShrink(false);
2775
- onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(false);
2776
- });
2777
- const [shrink, setShrink] = React.useState(shrinkProps);
2778
- const onClick = React.useCallback((e) => {
2779
- setShrink(true);
2780
- onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(true);
2781
- if (shrink) {
2782
- return;
2783
- }
2784
- const $textEl = e.currentTarget.querySelectorAll('input:not([disabled]):not([type="submit"]),select:not([disabled]),textarea:not([disabled])');
2785
- const $focusEl = $textEl.item($textEl.length - 1);
2786
- if ($focusEl) {
2787
- $focusEl.focus();
2788
- setTimeout(() => {
2789
- $focusEl.scrollIntoView({
2790
- behavior: 'auto',
2791
- block: 'center',
2792
- inline: 'start',
2793
- });
2794
- }, 100);
2795
- }
2796
- }, [shrink]);
2797
- React.useEffect(() => {
2798
- setShrink(shrinkProps);
2799
- }, [shrinkProps]);
2800
- return (React__default["default"].createElement(StyledTextFieldContainer$1, Object.assign({ shrink: shrink, className: core.clsx(className, 'textField', { textField_shrink: !!shrink }) }, restProps),
2801
- React__default["default"].createElement("div", { ref: containerRef, onClick: onClick, className: "textField_wrapper" }, children)));
2802
- };
2803
- const ChoiceField$1 = (props) => {
2804
- const { children, className } = props, restProps = tslib_es6.__rest(props, ["children", "className"]);
2805
- return (React__default["default"].createElement(StyledChoiceFieldContainer$1, Object.assign({ className: core.clsx(className, 'choiceField') }, restProps), children));
2806
- };
2807
-
2808
- const libraries = ['places'];
2809
- const GoogleLocationBlock = (props) => {
2810
- var _a;
2811
- const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = tslib_es6.__rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
2812
- const [LoadScript, setLoadScript] = React.useState(null);
2813
- const [value, setValue] = React.useState(defaultValue || valueProps);
2814
- const { predictions } = usePlacesAutocomplete.usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
2815
- const onChangeAutocomplete = React.useCallback((s) => {
2816
- setValue(s);
2817
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
2818
- }, []);
2819
- const onClickItem = React.useCallback((item) => {
2820
- /** For sure get value */
2821
- setValue(item.value);
2822
- const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
2823
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
2824
- }, [onChangeProps, predictions]);
2825
- React.useEffect(() => {
2826
- setValue(valueProps);
2827
- }, [valueProps]);
2828
- React.useEffect(() => {
2829
- var _a, _b, _c;
2830
- // only load extra google script when not yet loaded
2831
- if (!((_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.places) === null || _c === void 0 ? void 0 : _c.AutocompleteService) && !LoadScript) {
2832
- Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@react-google-maps/api')); }).then((m) => {
2833
- setLoadScript(() => m.LoadScript);
2834
- });
2835
- }
2836
- }, []);
2837
- return (React__default["default"].createElement(core.Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
2838
- return { value: pred.description, label: pred.description };
2839
- }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: index$7.ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
2840
- return (React__default["default"].createElement(React__default["default"].Fragment, null,
2841
- LoadScript && (React__default["default"].createElement(LoadScript, { googleMapsApiKey: usePlacesAutocomplete.GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default["default"].createElement(React__default["default"].Fragment, null), style: { width: '100%' } })),
2842
- children));
2843
- } }, restProps)));
2844
- };
2845
-
2846
- const LeadGenForm = React.forwardRef((props, ref) => {
2847
- const { locale, blocks, scrollToErrorField = true, form: formProps, rules: validate, initialValues, onFinish, onFinishFailed, className, style, } = props;
2848
- const formRef = React.useRef(null);
2849
- const form$1 = formProps || form.useForm({ initialValues, validate });
2850
- const middlewareFinish = React.useCallback((values, event) => {
2851
- /** Set `touched` all values for validation when submiting */
2852
- form$1.setTouched(blocks.reduce((touched, { data }) => {
2853
- touched[data.value] = true;
2854
- return touched;
2855
- }, {}));
2856
- /** Wait for `touched` state and then submit */
2857
- setTimeout(() => {
2858
- const { hasErrors } = form$1.validate();
2859
- if (hasErrors) {
2860
- return;
2861
- }
2862
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatLeadGenFormValue(values, blocks), event);
2863
- }, 100);
2864
- }, [form$1, blocks]);
2865
- const middlewareFinishFailed = React.useCallback((errors, values, events) => {
2866
- if (scrollToErrorField && errors) {
2867
- const firstErrorKey = Object.keys(errors)[0];
2868
- const firstErrorElement = document.querySelector(`[name="${firstErrorKey}"]`);
2869
- if (firstErrorElement && (firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus)) {
2870
- setTimeout(() => {
2871
- firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
2872
- firstErrorElement.scrollIntoView({
2873
- behavior: 'auto',
2874
- block: 'center',
2875
- inline: 'center',
2876
- });
2877
- }, 100);
2878
- }
2879
- }
2880
- onFinishFailed === null || onFinishFailed === void 0 ? void 0 : onFinishFailed(errors, values, events);
2881
- }, [scrollToErrorField]);
2882
- React.useEffect(() => {
2883
- (() => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
2884
- if (!window.intlTelInputUtils) {
2885
- yield require('intl-tel-input/build/js/utils');
2886
- }
2887
- }))();
2888
- }, []);
2889
- React.useImperativeHandle(ref, () => (Object.assign(Object.assign({}, form$1), { submit: () => {
2890
- formRef.current.requestSubmit();
2891
- } })), [form$1, formRef]);
2892
- if (!blocks || !blocks.length) {
2893
- return null;
2894
- }
2895
- return (React__default["default"].createElement("form", { ref: formRef, onSubmit: form$1.onSubmit(middlewareFinish, middlewareFinishFailed), className: className, style: style },
2896
- React__default["default"].createElement(StyledLeadGenFormInner, { className: "leadgen-form_inputs" }, blocks.map((block, idx) => {
2897
- const { id, name: blockName, data } = block;
2898
- const { placeholder, value: name, required, listQuestion, valueHTML, isSendMailChimp = false, } = data;
2899
- const formInputProps = form$1.getInputProps(name);
2900
- const { value, error } = formInputProps;
2901
- const reactKey = `${id}-${idx}`;
2902
- switch (blockName) {
2903
- case LEADGEN_BLOCK.TextBlock: {
2904
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2905
- React__default["default"].createElement(core.TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "text", "data-control": "text" }, formInputProps))));
2906
- }
2907
- case LEADGEN_BLOCK.NumberBlock: {
2908
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2909
- React__default["default"].createElement(core.NumberInput, Object.assign({ name: value, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "number", "data-control": "number" }, formInputProps))));
2910
- }
2911
- case LEADGEN_BLOCK.EmailBlock: {
2912
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2913
- React__default["default"].createElement(core.TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, "data-control": "email" }, formInputProps))));
2914
- }
2915
- case LEADGEN_BLOCK.PhoneOtpBlock:
2916
- case LEADGEN_BLOCK.WhatsappOtpBlock:
2917
- case LEADGEN_BLOCK.ZaloOtpBlock:
2918
- case LEADGEN_BLOCK.PhoneBlock: {
2919
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2920
- React__default["default"].createElement(PhoneInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, defaultCountry: (locale ? utils.MAPPED_LOCALE[locale] || 'VN' : 'VN'), type: "text", "data-control": "text" }, formInputProps))));
2921
- }
2922
- case LEADGEN_BLOCK.LocationBlock: {
2923
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2924
- React__default["default"].createElement(GoogleLocationBlock, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, locale: locale, "data-control": "text" }, formInputProps))));
2925
- }
2926
- case LEADGEN_BLOCK.DateBlock: {
2927
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2928
- React__default["default"].createElement(dates.DateInput, Object.assign({ locale: (utils.MAPPED_LOCALE === null || utils.MAPPED_LOCALE === void 0 ? void 0 : utils.MAPPED_LOCALE[locale]) || utils.MAPPED_LOCALE['vi-VN'], valueFormat: "DD/MM/YYYY", name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "default", "data-control": "date" }, formInputProps))));
2929
- }
2930
- case LEADGEN_BLOCK.DropdownBlock:
2931
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2932
- React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2933
- React__default["default"].createElement(core.Select, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, data: listQuestion.map((l) => ({
2934
- value: l.value,
2935
- label: l.placeholder,
2936
- })) }, formInputProps))));
2937
- case LEADGEN_BLOCK.CheckboxBlock: {
2938
- const formInputCheckboxProps = form$1.getInputProps(name, {
2939
- type: 'checkbox',
2940
- });
2941
- return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2942
- isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2943
- React__default["default"].createElement(core.Checkbox.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, sx: {
2944
- display: 'flex',
2945
- flexDirection: 'column',
2946
- flexWrap: 'wrap',
2947
- gap: 8,
2948
- }, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2949
- return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2950
- } }, formInputCheckboxProps), listQuestion.map((l, _idx) => (React__default["default"].createElement(core.Checkbox, { name: name, key: _idx, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2951
- }
2952
- case LEADGEN_BLOCK.RadioBlock: {
2953
- return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2954
- isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2955
- React__default["default"].createElement(core.Radio.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, spellCheck: true, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2956
- return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2957
- } }, formInputProps), listQuestion.map((l, _index) => (React__default["default"].createElement(core.Radio, { name: name, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2958
- }
2959
- case LEADGEN_BLOCK.TncBlock:
2960
- return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2961
- React__default["default"].createElement(core.Input.Wrapper, { error: error },
2962
- React__default["default"].createElement(core.Checkbox, Object.assign({ value: value, name: 'TNC-' + id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, formInputProps)))));
2963
- default: {
2964
- return null;
2965
- }
2966
- }
2967
- }))));
2968
- });
2969
-
2970
- const LEADGEN_ORDER_INPUT_WRAPPER = ['label', 'input', 'description', 'error'];
2971
-
2972
- const LeadGenSubscriptionBoxA = (props) => {
2973
- const { loading, image, title, submitText, locale, blocks, form, rules, onFinish, } = props;
2974
- const formRef = React.useRef();
2975
- const imageComp = React.useMemo(() => {
2976
- if (!image) {
2977
- return null;
2978
- }
2979
- return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeaderImage, null,
2980
- React__default["default"].createElement("img", { src: image, alt: "" })));
2981
- }, [image]);
2982
- const titleComp = React.useMemo(() => {
2983
- if (typeof title === 'string') {
2984
- return (React__default["default"].createElement("p", { className: "leadgen-title", dangerouslySetInnerHTML: { __html: title } }));
2985
- }
2986
- return React__default["default"].createElement("p", { className: "leadgen-title" }, title);
2987
- }, [title]);
2988
- return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxA, { className: "subcription_box_A" },
2989
- React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeader, { className: "leadgen-subscription_box_header" },
2990
- imageComp,
2991
- titleComp),
2992
- React__default["default"].createElement(StyledLeadGenSubscriptionBoxBody, { className: "leadgen-subscription_box_body" },
2993
- React__default["default"].createElement(LeadGenForm, { ref: formRef, form: form, rules: rules, blocks: blocks, locale: locale, onFinish: onFinish, className: "leadgen-subscription_box_form" }),
2994
- React__default["default"].createElement(core.Button, { disabled: loading, loading: loading, variant: "filled", size: "lg", onClick: () => {
2995
- formRef.current.submit();
2996
- }, className: "leadgen-btn leadgen-btn_action", fullWidth: true }, submitText))));
2997
- };
2998
-
2999
- const LeadGenSubscriptionBoxWithoutMemo = ({ locale, userInfo, forceCampaign, categoryId, }) => {
3000
- var _a, _b, _c;
3001
- const { image, extra_fields, id: campaign_id, bot_id: campaign_subot_id = [], ThankYouBlock, } = forceCampaign || {};
3002
- const { textBlocks, listBlockAdded, actionBlocks } = extra_fields || {};
3003
- const { submitBlock } = actionBlocks || {};
3004
- const { apiLeadUrl, subscriptionIcon, subscriptionTitle, submitSubscriptionBox, impression, onFinish, } = useLeadGenContext();
3005
- const { t } = index$1.useTranslations();
3006
- const { action: { pushNotifications }, } = React.useContext(togetherComponentGlobalContext.TogetherComponentGlobalContext);
3007
- const refContainer = React.useRef(null);
3008
- const [loading, setLoading] = React.useState(false);
3009
- const [showThankyou, setShowThankyou] = React.useState(false);
3010
- const validatingEmailRef = React.useRef(false);
3011
- const validatingPhoneRef = React.useRef(false);
3012
- const { form, validateObj } = useLeadFormConfig({
3013
- listBlockAdded,
3014
- campaignId: campaign_id,
3015
- campaign_subot_id,
3016
- validatingEmailRef,
3017
- validatingPhoneRef,
3018
- userInfo,
3019
- });
3020
- const subscription_title = React.useMemo(() => {
3021
- var _a, _b;
3022
- return subscriptionTitle ||
3023
- ((_b = (_a = textBlocks === null || textBlocks === void 0 ? void 0 : textBlocks.titleBlock) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value) ||
3024
- t('leadgen.message.title.default');
3025
- }, [subscriptionTitle, (_b = (_a = textBlocks === null || textBlocks === void 0 ? void 0 : textBlocks.titleBlock) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value]);
3026
- const { image: thankyouImage, title: thankyouTitle, description: thankyouDescription, button: thankyouButton, } = ThankYouBlock || {};
3027
- const intersectionObserverCallback = React.useCallback((entries) => {
3028
- entries.forEach((entry) => {
3029
- const { isIntersecting, target } = entry;
3030
- if (!showThankyou &&
3031
- isIntersecting &&
3032
- target === refContainer.current) {
3033
- impression();
3034
- }
3035
- });
3036
- }, [impression, showThankyou]);
3037
- const IObserver = new IntersectionObserver(intersectionObserverCallback);
3038
- const middlewareOnSubmit = React.useCallback((values) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
3039
- const newValues = {
3040
- subscription_title,
3041
- };
3042
- const ssoValues = {
3043
- sso_user_id: undefined,
3044
- sso_uuid: undefined,
3045
- sso_verified_profile: undefined,
3046
- };
3047
- const valueKeys = Object.keys(values);
3048
- for (const key of valueKeys) {
3049
- const isPhoneField = leadGenFieldNamePhone(listBlockAdded).some((k) => k === key);
3050
- if (isPhoneField) {
3051
- const phone = PhoneInputBase.parsePhoneNumber(values[key]);
3052
- if (phone.isValid()) {
3053
- /** Seperate `area_code` and `phone_number` for BE */
3054
- newValues['area_code'] = `+${phone.countryCallingCode}`;
3055
- newValues['phone_number'] = phone.nationalNumber;
3056
- /** Only case login has this update */
3057
- if ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) && (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid)) {
3058
- ssoValues['sso_verified_profile'] =
3059
- phone.number === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone) ? 1 : 0;
3060
- ssoValues['sso_user_id'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.id;
3061
- ssoValues['sso_uuid'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid;
3062
- }
3063
- }
3064
- continue;
3065
- }
3066
- newValues[key] = values[key];
3067
- }
3068
- setLoading(true);
3069
- try {
3070
- const reqValues = Object.assign(Object.assign({}, newValues), ssoValues);
3071
- const { _data } = (yield submitSubscriptionBox(reqValues)) || {};
3072
- const { model } = _data || {};
3073
- if (model && (model === null || model === void 0 ? void 0 : model.id)) {
3074
- setShowThankyou(true);
3075
- const metaValues = {
3076
- blocks: listBlockAdded || [],
3077
- isUpdateSso: false,
3078
- };
3079
- /**
3080
- * https://hhgdev.atlassian.net/browse/EL-468
3081
- * This feature is just using in Subscription Box
3082
- */
3083
- if (newValues === null || newValues === void 0 ? void 0 : newValues.name) {
3084
- const { _data: ssoData, code: ssoErrorCode } = yield Service.postUserInfoFromLeadGen({ name: newValues === null || newValues === void 0 ? void 0 : newValues.name });
3085
- if (ssoErrorCode && !ssoData) {
3086
- return;
3087
- }
3088
- metaValues.isUpdateSso = true;
3089
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(reqValues, metaValues);
3090
- return;
3091
- }
3092
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(reqValues, metaValues);
3093
- }
3094
- }
3095
- catch (error) {
3096
- LeadLog('** LeadGen SubscriptionBox error : ', error);
3097
- pushNotifications({
3098
- message: t('leadgen.message.error.default'),
3099
- type: 'danger',
3100
- });
3101
- }
3102
- setLoading(false);
3103
- }), [
3104
- subscription_title,
3105
- listBlockAdded,
3106
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
3107
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid,
3108
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone,
3109
- ]);
3110
- React.useEffect(() => {
3111
- if (refContainer.current) {
3112
- IObserver.observe(refContainer.current);
3113
- }
3114
- return () => {
3115
- IObserver.disconnect();
3116
- };
3117
- }, [categoryId]);
3118
- return (React__default["default"].createElement("div", { ref: refContainer },
3119
- React__default["default"].createElement(StyledLeadGenSubscriptionBox, null,
3120
- showThankyou && (React__default["default"].createElement(LeadGenThankYou, { image: Object.assign(Object.assign({}, thankyouImage), { src: thankyouImage.src || `${apiLeadUrl}admin/img/thanksyou.png` }), title: thankyouTitle, description: thankyouDescription, button: thankyouButton })),
3121
- !showThankyou && (React__default["default"].createElement(LeadGenSubscriptionBoxA, { loading: loading, image: subscriptionIcon || image, title: subscription_title, submitText: (_c = submitBlock === null || submitBlock === void 0 ? void 0 : submitBlock.data) === null || _c === void 0 ? void 0 : _c.value, blocks: listBlockAdded, locale: locale, form: form, rules: validateObj, onFinish: middlewareOnSubmit })))));
3122
- };
3123
- const LeadGenSubscriptionBox$1 = React.memo(LeadGenSubscriptionBoxWithoutMemo);
3124
-
3125
- const Container = () => {
3126
- const context = React.useContext(LeadGenContext);
3127
- const { campaign_code, locale, siteId, siteDomain, userInfo, forceCampaign } = context;
3128
- if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
3129
- return null;
3130
- }
3131
- return (React__default["default"].createElement(LeadGenSubscriptionBox$1, { locale: locale, siteId: siteId, siteDomain: siteDomain, userInfo: userInfo, forceCampaign: forceCampaign, campaign_code: campaign_code }));
3132
- };
3133
- Container.displayName = 'LeadGenSubscriptionBox';
3134
- const LeadGenSubscriptionBoxContainer = (props) => {
3135
- const { apiUrl, apiSubotUrl } = props;
3136
- return (React__default["default"].createElement(LeadGenContextProvider, Object.assign({}, props, { apiLeadUrl: apiUrl, apiSubotUrl: apiSubotUrl }),
3137
- React__default["default"].createElement(Container, null)));
3138
- };
3139
- const LeadGenSubscriptionBox = LeadGenSubscriptionBoxContainer;
3140
-
3141
- const useImageSize = (src) => {
3142
- const [width, setWidth] = React.useState(16);
3143
- const [height, setHeight] = React.useState(9);
3144
- const [loaded, setLoaded] = React.useState(false);
3145
- // load src image to get its width and height
3146
- React.useEffect(() => {
3147
- setLoaded(false);
3148
- if (src) {
3149
- const img = new Image();
3150
- img.addEventListener('load', () => {
3151
- setWidth(img.naturalWidth);
3152
- setHeight(img.naturalHeight);
3153
- setLoaded(true);
3154
- });
3155
- img.addEventListener('error', () => {
3156
- setWidth(16);
3157
- setHeight(9);
3158
- setLoaded(true);
3159
- });
3160
- img.src = src;
3161
- }
3162
- else {
3163
- setWidth(16);
3164
- setHeight(9);
3165
- setLoaded(true);
3166
- }
3167
- }, [src]);
3168
- return {
3169
- loaded,
3170
- width,
3171
- height,
3172
- };
3173
- };
3174
-
3175
- const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default["default"].createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
3176
- React__default["default"].createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
3177
- React__default["default"].createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
3178
-
3179
- // url: imageBlocks.imageMobile.data.url
3180
- // newTab: imageBlocks.imageMobile.data.newtab
3181
- // imageMobile: campaignShow.image
3182
- // imageDestkop: campaignShow.image_desktop
3183
- const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
3184
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3185
- const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
3186
- if (!imageMobileLoaded || !imageDestkopLoaded)
1441
+ const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default["default"].createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
1442
+ 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 },
1443
+ 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" }))));
1444
+
1445
+ // url: imageBlocks.imageMobile.data.url
1446
+ // newTab: imageBlocks.imageMobile.data.newtab
1447
+ // imageMobile: campaignShow.image
1448
+ // imageDestkop: campaignShow.image_desktop
1449
+ const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
1450
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1451
+ const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
1452
+ if (!imageMobileLoaded || !imageDestkopLoaded)
3187
1453
  return null;
3188
1454
  return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
3189
1455
  React__default["default"].createElement("div", { className: "le-center-tab-popup" },
3190
1456
  React__default["default"].createElement("div", { style: { position: 'relative' } },
3191
1457
  React__default["default"].createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
3192
- index$8.isVideo(imageMobile) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
1458
+ index$6.isVideo(imageMobile) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
3193
1459
  React__default["default"].createElement("source", { src: imageMobile }))) : (React__default["default"].createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
3194
1460
  aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3195
1461
  } })),
3196
- index$8.isVideo(imageDestkop) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
1462
+ index$6.isVideo(imageDestkop) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
3197
1463
  React__default["default"].createElement("source", { src: imageDestkop }))) : (React__default["default"].createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
3198
1464
  aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
3199
1465
  } }))),
@@ -3252,7 +1518,7 @@ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, su
3252
1518
  };
3253
1519
 
3254
1520
  const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
3255
- const { primaryColor } = React.useContext(LeadGenContext$1);
1521
+ const { primaryColor } = React.useContext(LeadGenContext);
3256
1522
  const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
3257
1523
  if (!imageLoaded)
3258
1524
  return null;
@@ -3272,7 +1538,7 @@ const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkN
3272
1538
  }))),
3273
1539
  linkText && (React__default["default"].createElement("div", null,
3274
1540
  React__default["default"].createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
3275
- React__default["default"].createElement(index$4.Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
1541
+ React__default["default"].createElement(index$3.Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
3276
1542
  };
3277
1543
 
3278
1544
  const InlineLayout = ({ content, inlinePosition, }) => {
@@ -3409,7 +1675,7 @@ const EmptyIcon = (props) => {
3409
1675
  };
3410
1676
 
3411
1677
  const EmptyComponent = ({ onClose, onContinue, }) => {
3412
- const { t } = index$1.useTranslations();
1678
+ const { t } = index.useTranslations();
3413
1679
  return (React__default["default"].createElement("div", { className: "leadgen-empty" },
3414
1680
  React__default["default"].createElement("div", { className: "leadgen-empty_body" },
3415
1681
  React__default["default"].createElement("div", { className: "leadgen-empty_wrapper" },
@@ -3420,6 +1686,222 @@ const EmptyComponent = ({ onClose, onContinue, }) => {
3420
1686
  React__default["default"].createElement(core.Button, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
3421
1687
  };
3422
1688
 
1689
+ const libraries = ['places'];
1690
+ const GoogleLocationBlock = (props) => {
1691
+ var _a;
1692
+ const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = tslib_es6.__rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
1693
+ const [LoadScript, setLoadScript] = React.useState(null);
1694
+ const [value, setValue] = React.useState(defaultValue || valueProps);
1695
+ 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]);
1696
+ const onChangeAutocomplete = React.useCallback((s) => {
1697
+ setValue(s);
1698
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
1699
+ }, []);
1700
+ const onClickItem = React.useCallback((item) => {
1701
+ /** For sure get value */
1702
+ setValue(item.value);
1703
+ const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
1704
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
1705
+ }, [onChangeProps, predictions]);
1706
+ React.useEffect(() => {
1707
+ setValue(valueProps);
1708
+ }, [valueProps]);
1709
+ React.useEffect(() => {
1710
+ var _a, _b, _c;
1711
+ // only load extra google script when not yet loaded
1712
+ 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) {
1713
+ Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@react-google-maps/api')); }).then((m) => {
1714
+ setLoadScript(() => m.LoadScript);
1715
+ });
1716
+ }
1717
+ }, []);
1718
+ return (React__default["default"].createElement(core.Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
1719
+ return { value: pred.description, label: pred.description };
1720
+ }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: index$7.ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
1721
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
1722
+ 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%' } })),
1723
+ children));
1724
+ } }, restProps)));
1725
+ };
1726
+
1727
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
1728
+ const customParseFormat = require('dayjs/plugin/customParseFormat');
1729
+ dayjs__default["default"].extend(customParseFormat);
1730
+ // You can give context variables any name
1731
+ const [LeadFormProvider, useLeadFormContext, useLeadForm] = form.createFormContext();
1732
+ const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
1733
+ const { t } = index.useTranslations();
1734
+ const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
1735
+ const validateObj = React.useMemo(() => {
1736
+ const InputBlocks = [
1737
+ 'TextBlock',
1738
+ 'NumberBlock',
1739
+ 'EmailBlock',
1740
+ 'PhoneBlock',
1741
+ 'DateBlock',
1742
+ 'CheckboxBlock',
1743
+ 'RadioBlock',
1744
+ 'DropdownBlock',
1745
+ 'PhoneOtpBlock',
1746
+ 'WhatsappOtpBlock',
1747
+ 'ZaloOtpBlock',
1748
+ 'LocationBlock',
1749
+ 'TncBlock',
1750
+ ];
1751
+ // ALL are required and can skip if not touched yet
1752
+ const withSharedCheck = (name, cb,
1753
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1754
+ block) => {
1755
+ return (value) => {
1756
+ var _a;
1757
+ const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
1758
+ if (!formRef.current.isTouched(name))
1759
+ return;
1760
+ if ((typeof value === 'string' && value.trim() === '') ||
1761
+ typeof value === 'undefined' ||
1762
+ (Array.isArray(value) && value.length === 0)) {
1763
+ return isBLockRequired
1764
+ ? t('validator.required')
1765
+ : cb === null || cb === void 0 ? void 0 : cb(value);
1766
+ }
1767
+ return cb === null || cb === void 0 ? void 0 : cb(value);
1768
+ };
1769
+ };
1770
+ return listBlockAdded
1771
+ .filter((b) => InputBlocks.includes(b.name))
1772
+ .reduce((r, b) => {
1773
+ const { name: fieldType, data } = b || {};
1774
+ const { value: fieldName, required } = data || {};
1775
+ const isRequired = required !== null && required !== void 0 ? required : true;
1776
+ if (fieldType === 'NumberBlock') {
1777
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1778
+ if (value && isNaN(Number(value))) {
1779
+ return t('validator.number');
1780
+ }
1781
+ }, b) });
1782
+ }
1783
+ else if (fieldType === 'EmailBlock') {
1784
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1785
+ if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
1786
+ return t('validator.email');
1787
+ }
1788
+ if (!value)
1789
+ return;
1790
+ validatingEmailRef.current = true;
1791
+ setTimeout(() => {
1792
+ formRef.current.setFieldError(fieldName, 'Validating...');
1793
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1794
+ email: value,
1795
+ })
1796
+ .then((tKey) => {
1797
+ if (tKey) {
1798
+ formRef.current.setFieldError(fieldName, t(tKey));
1799
+ }
1800
+ else {
1801
+ formRef.current.clearFieldError(fieldName);
1802
+ }
1803
+ validatingEmailRef.current = false;
1804
+ })
1805
+ .catch((e) => {
1806
+ console.error(e);
1807
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
1808
+ validatingEmailRef.current = false;
1809
+ });
1810
+ }, 200);
1811
+ }, b) });
1812
+ }
1813
+ else if (fieldType === 'PhoneBlock' ||
1814
+ fieldType === 'PhoneOtpBlock' ||
1815
+ fieldType === 'ZaloOtpBlock' ||
1816
+ fieldType === 'WhatsappOtpBlock') {
1817
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1818
+ if (value &&
1819
+ window.intlTelInputUtils &&
1820
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
1821
+ return t('validator.phone');
1822
+ }
1823
+ if (!value)
1824
+ return;
1825
+ validatingPhoneRef.current = true;
1826
+ setTimeout(() => {
1827
+ formRef.current.setFieldError(fieldName, 'Validating...');
1828
+ if (b.data.singleSubmission) {
1829
+ checkUsedPhoneOnlyWithCache(campaignId, value)
1830
+ .then((tKey) => {
1831
+ if (tKey) {
1832
+ formRef.current.setFieldError(fieldName, t(tKey));
1833
+ }
1834
+ else {
1835
+ formRef.current.clearFieldError(fieldName);
1836
+ }
1837
+ validatingPhoneRef.current = false;
1838
+ })
1839
+ .catch((err) => {
1840
+ console.error(err);
1841
+ formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
1842
+ validatingPhoneRef.current = false;
1843
+ });
1844
+ }
1845
+ else {
1846
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1847
+ phone: value,
1848
+ })
1849
+ .then((tKey) => {
1850
+ if (tKey) {
1851
+ formRef.current.setFieldError(fieldName, t(tKey));
1852
+ }
1853
+ else {
1854
+ formRef.current.clearFieldError(fieldName);
1855
+ }
1856
+ validatingPhoneRef.current = false;
1857
+ })
1858
+ .catch((e) => {
1859
+ console.error(e);
1860
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
1861
+ validatingPhoneRef.current = false;
1862
+ });
1863
+ }
1864
+ }, 200);
1865
+ }, b) });
1866
+ }
1867
+ else if (fieldType === 'DateBlock') {
1868
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1869
+ if (!isRequired && !value) {
1870
+ return;
1871
+ }
1872
+ const errMsg = t('validator.dateInvalid');
1873
+ const dayInJS = typeof value === 'string'
1874
+ ? dayjs__default["default"](value, format, true)
1875
+ : dayjs__default["default"](value);
1876
+ if (!dayInJS.isValid()) {
1877
+ return errMsg;
1878
+ }
1879
+ }, b) });
1880
+ }
1881
+ else if (fieldType === 'TncBlock') {
1882
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
1883
+ if (isRequired && !value) {
1884
+ return t('validator.required');
1885
+ }
1886
+ }, b) });
1887
+ }
1888
+ else {
1889
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
1890
+ }
1891
+ }, {});
1892
+ }, [listBlockAdded.map((b) => b.name).join(','), format]);
1893
+ const form = useLeadForm({
1894
+ validateInputOnChange: true,
1895
+ validateInputOnBlur: true,
1896
+ clearInputErrorOnChange: true,
1897
+ validate: validateObj,
1898
+ initialValues,
1899
+ });
1900
+ const formRef = React.useRef(form);
1901
+ formRef.current = form;
1902
+ return { form, validateObj };
1903
+ };
1904
+
3423
1905
  const SubtitleBlock = ({ children, align, }) => (React__default["default"].createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
3424
1906
 
3425
1907
  const cssInputNotShrink = react.css `
@@ -3746,13 +2228,11 @@ const TextField = (props) => {
3746
2228
  const $focusEl = $textEl.item($textEl.length - 1);
3747
2229
  if ($focusEl) {
3748
2230
  $focusEl.focus();
3749
- setTimeout(() => {
3750
- $focusEl.scrollIntoView({
3751
- behavior: 'auto',
3752
- block: 'center',
3753
- inline: 'start',
3754
- });
3755
- }, 100);
2231
+ $focusEl.scrollIntoView({
2232
+ behavior: 'auto',
2233
+ block: 'center',
2234
+ inline: 'start',
2235
+ });
3756
2236
  }
3757
2237
  }, [shrink]);
3758
2238
  React.useEffect(() => {
@@ -3769,13 +2249,13 @@ const ChoiceField = (props) => {
3769
2249
  const TitleBlock = ({ children, align, }) => (React__default["default"].createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
3770
2250
 
3771
2251
  const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, }) => {
3772
- const { t } = index$1.useTranslations();
2252
+ const { t } = index.useTranslations();
3773
2253
  const form = useLeadFormContext();
3774
2254
  const formValues = form.values;
3775
2255
  const labelTuples = React.useMemo(() => {
3776
2256
  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
3777
2257
  .split('/')
3778
- .map((key) => { var _a; return t((_a = index$9.COMMON_DATE_TRANSLATE_KEY === null || index$9.COMMON_DATE_TRANSLATE_KEY === void 0 ? void 0 : index$9.COMMON_DATE_TRANSLATE_KEY[key]) === null || _a === void 0 ? void 0 : _a.id); });
2258
+ .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); });
3779
2259
  }, [locale]);
3780
2260
  return (React__default["default"].createElement(React__default["default"].Fragment, null, listBlockAdded.map((b, index) => {
3781
2261
  var _a;
@@ -3818,7 +2298,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
3818
2298
  }) },
3819
2299
  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 },
3820
2300
  React__default["default"].createElement("div", { className: "mantine-Input-wrapper" },
3821
- React__default["default"].createElement(index$3.Phone, Object.assign({ className: "mantine-Input-input", name: value, spellCheck: false, type: "tel", placeholder: placeholder,
2301
+ React__default["default"].createElement(index$2.Phone, Object.assign({ className: "mantine-Input-input", name: value, spellCheck: false, type: "tel", placeholder: placeholder,
3822
2302
  // onBlur={(e) => inputOnBlur('tel', e)}
3823
2303
  id: htmlForId, defaultCountry: (locale ? utils.MAPPED_LOCALE[locale] || 'VN' : 'VN'), "data-control": "tel" }, formPhoneInputWrapper))))));
3824
2304
  }
@@ -3834,7 +2314,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
3834
2314
  case 'LinkButtonBlock':
3835
2315
  return (React__default["default"].createElement("div", { key: index },
3836
2316
  React__default["default"].createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
3837
- React__default["default"].createElement(index$a.Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
2317
+ React__default["default"].createElement(index$9.Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
3838
2318
  onClose === null || onClose === void 0 ? void 0 : onClose();
3839
2319
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
3840
2320
  } }, value))));
@@ -3843,7 +2323,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
3843
2323
  isSendMailChimp && (React__default["default"].createElement("div", { style: {
3844
2324
  display: 'none',
3845
2325
  }, "data-name": value + '-mailchimp' })),
3846
- React__default["default"].createElement(index$3.Checkbox.Group, Object.assign({ withAsterisk: required,
2326
+ React__default["default"].createElement(index$2.Checkbox.Group, Object.assign({ withAsterisk: required,
3847
2327
  // className="lead-modal__form-control leadgen-form_field"
3848
2328
  label: placeholder, size: "md", sx: {
3849
2329
  display: 'flex',
@@ -3852,19 +2332,19 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
3852
2332
  gap: 8,
3853
2333
  }, inputWrapperOrder: ['label', 'input', 'description', 'error'], inputContainer: (children) => {
3854
2334
  return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
3855
- } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$3.Checkbox, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2335
+ } }, 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" }))))));
3856
2336
  case 'RadioBlock':
3857
2337
  return (React__default["default"].createElement(ChoiceField, { className: "leadgen-form_radio", key: index },
3858
2338
  isSendMailChimp && (React__default["default"].createElement(core.Input, { type: "hidden", name: value + '-mailchimp', value: isSendMailChimp })),
3859
- React__default["default"].createElement(index$3.Radio.Group, Object.assign({ withAsterisk: required,
2339
+ React__default["default"].createElement(index$2.Radio.Group, Object.assign({ withAsterisk: required,
3860
2340
  // className="lead-modal__form-control leadgen-form_field"
3861
2341
  label: placeholder, size: "md", inputWrapperOrder: ['label', 'input', 'description', 'error'], inputContainer: (children) => {
3862
2342
  return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
3863
- } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$3.Radio, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2343
+ } }, 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" }))))));
3864
2344
  case 'DropdownBlock':
3865
2345
  return (React__default["default"].createElement(TextField, { shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field", key: index },
3866
2346
  React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
3867
- React__default["default"].createElement(index$3.Select
2347
+ React__default["default"].createElement(index$2.Select
3868
2348
  // className="lead-modal__form-control leadgen-form_field"
3869
2349
  , Object.assign({
3870
2350
  // className="lead-modal__form-control leadgen-form_field"
@@ -3876,7 +2356,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
3876
2356
  const _d = form.getInputProps(`TNC-${id}`), { error } = _d, tncInputProps = tslib_es6.__rest(_d, ["error"]);
3877
2357
  return (React__default["default"].createElement(ChoiceField, { className: "leadgen-form_checkbox", key: id },
3878
2358
  React__default["default"].createElement(core.Input.Wrapper, { error: error },
3879
- React__default["default"].createElement(index$3.Checkbox, Object.assign({ name: 'TNC-' + id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps)))));
2359
+ 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)))));
3880
2360
  }
3881
2361
  return null;
3882
2362
  })));
@@ -3979,12 +2459,12 @@ const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
3979
2459
  if (!src) {
3980
2460
  return null;
3981
2461
  }
3982
- return (React__default["default"].createElement(StyleHeaderImage, { paddingTop: (1 / ratio) * 100, className: core.clsx(className, 'leadgen-header_image'), style: style }, index$8.isVideo(src) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true, className: "leadgen-header_image_feature leadgen-header_image_video", src: src })) : (React__default["default"].createElement("img", { src: src, draggable: "false", alt: "", className: "leadgen-header_image_feature leadgen-header_image_image" }))));
2462
+ 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" }))));
3983
2463
  };
3984
2464
 
3985
2465
  const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
3986
- const { primaryColor } = React.useContext(LeadGenContext$1);
3987
- const { t } = index$1.useTranslations();
2466
+ const { primaryColor } = React.useContext(LeadGenContext);
2467
+ const { t } = index.useTranslations();
3988
2468
  const phone = otpData.phone;
3989
2469
  const otpType = otpData.type;
3990
2470
  const [otp, setOtp] = React.useState('');
@@ -4069,371 +2549,715 @@ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
4069
2549
  // type: 'danger',
4070
2550
  // })
4071
2551
  }
4072
- setIsSubmitLoading(false);
2552
+ setIsSubmitLoading(false);
2553
+ });
2554
+ React.useEffect(() => {
2555
+ setTimeout(() => {
2556
+ if (resendTimer > 0) {
2557
+ setResendTimer((r) => r - 1);
2558
+ }
2559
+ }, 1000);
2560
+ }, [resendTimer]);
2561
+ React.useEffect(() => {
2562
+ if (autoSendWhenOpen && !resendTimer) {
2563
+ sendOtp();
2564
+ }
2565
+ }, []);
2566
+ return (React__default["default"].createElement("form", { onSubmit: (e) => {
2567
+ e.preventDefault();
2568
+ submitOtp();
2569
+ }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
2570
+ React__default["default"].createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
2571
+ phone: `<strong>${displayPhone}</strong>`,
2572
+ }), footer: React__default["default"].createElement(React__default["default"].Fragment, null,
2573
+ 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')),
2574
+ 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: () => {
2575
+ sendOtp();
2576
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
2577
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
2578
+ }))) },
2579
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
2580
+ React__default["default"].createElement(index$2.Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
2581
+ React__default["default"].createElement(index$2.OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
2582
+ setIsDirty(true);
2583
+ setOtp(v.toString());
2584
+ if (isDirty && !v)
2585
+ setErrorMsg('OTP is required');
2586
+ else
2587
+ setErrorMsg(undefined);
2588
+ } }))))));
2589
+ };
2590
+
2591
+ // url: imageBlocks.imageMobile.data.url
2592
+ // newTab: imageBlocks.imageMobile.data.newtab
2593
+ // image: campaignShow.image
2594
+ // imageDestkop: campaignShow.image_desktop
2595
+ const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
2596
+ LEADGEN_LAYOUT.Fullscreen,
2597
+ LEADGEN_LAYOUT.Slider,
2598
+ ];
2599
+ const LEADGEN_LIMIT_LIGHTBOXB = 6;
2600
+ const LEADGEN_SHOW_HEADER = [
2601
+ 'LightBoxA',
2602
+ 'InlineA',
2603
+ LEADGEN_LAYOUT.Sidebar,
2604
+ LEADGEN_LAYOUT.Slider,
2605
+ ];
2606
+ const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2607
+ var _a, _b;
2608
+ const { primaryColor } = React.useContext(LeadGenContext);
2609
+ const { isMobile } = useScreenSize.useScreenSize();
2610
+ const [open, setOpen] = React.useState(!!campaignId);
2611
+ const [showOtpPhone, setShowOtpPhone] = React.useState(null);
2612
+ const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
2613
+ const [snap, setSnap] = React.useState(0.8);
2614
+ const formRef = React.useRef();
2615
+ const onClose = () => {
2616
+ if (showOtpPhone) {
2617
+ setShowOtpPhone(null);
2618
+ }
2619
+ else {
2620
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2621
+ }
2622
+ };
2623
+ const textBlocks = JSON.parse(extraFields.textBlocks);
2624
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
2625
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
2626
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
2627
+ const currentPath = location.pathname;
2628
+ const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
2629
+ const { align: titleAlign } = textBlocks.titleBlock.data || {};
2630
+ const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
2631
+ const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
2632
+ const isLightBox = currentLayout.includes('LightBox');
2633
+ const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
2634
+ const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
2635
+ const isInline = currentLayout.includes('Inline');
2636
+ const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
2637
+ const isInPage = isInline || isSidebar;
2638
+ const isDrawer = isLightBoxB && isMobile;
2639
+ const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
2640
+ const hasForm = isLightBoxA
2641
+ ? listBlockAdded.some((item) => LEADGEN_BLOCK_IN_FORM.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
2642
+ : true;
2643
+ const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
2644
+ const showHeader = !!imageMobile || !!imageDesktop;
2645
+ const onlyHeader = !title && !description;
2646
+ const showButtonClose = !isInline;
2647
+ if (window.innerWidth < 769 &&
2648
+ LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
2649
+ console.log('😎 Not show fullscreen, slider on mobile ');
2650
+ return null;
2651
+ }
2652
+ React.useEffect(() => {
2653
+ if (isLightBox || isFullscreen) {
2654
+ document.body.classList.add('noscroll');
2655
+ }
2656
+ if (!window.intlTelInputUtils) {
2657
+ require('intl-tel-input/build/js/utils');
2658
+ }
2659
+ clearCacheUsedEmailOrPhone();
2660
+ }, []);
2661
+ const validatingPhoneRef = React.useRef(false);
2662
+ const validatingEmailRef = React.useRef(false);
2663
+ const { form, validateObj } = useLeadFormConfig({
2664
+ listBlockAdded,
2665
+ validatingPhoneRef,
2666
+ validatingEmailRef,
2667
+ campaignId,
2668
+ campaign_subot_id,
2669
+ userInfo,
2670
+ format: (_a = (index$7.ISO_FORMAT[locale] || index$7.ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
2671
+ });
2672
+ const middlewareOnSubmit = (e) => {
2673
+ e.preventDefault();
2674
+ // mark all as touched to allow validation
2675
+ const fields = Object.keys(validateObj);
2676
+ const fieldStatus = fields.reduce((acc, cur) => {
2677
+ acc[cur] = true;
2678
+ return acc;
2679
+ }, {});
2680
+ form.setTouched(fieldStatus);
2681
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
2682
+ return;
2683
+ }
2684
+ setTimeout(() => {
2685
+ form.onSubmit((v) => {
2686
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2687
+ if (Object.keys(form.errors).length)
2688
+ return;
2689
+ let newShowOtpPhone = null;
2690
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
2691
+ // not submit yet, open otp
2692
+ 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;
2693
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
2694
+ newShowOtpPhone = {
2695
+ phone: v[fieldName],
2696
+ type: 'phone',
2697
+ };
2698
+ }
2699
+ }
2700
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
2701
+ // not submit yet, open otp
2702
+ 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;
2703
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
2704
+ newShowOtpPhone = {
2705
+ phone: v[fieldName],
2706
+ type: 'whatsapp',
2707
+ };
2708
+ }
2709
+ }
2710
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
2711
+ // not submit yet, open otp
2712
+ 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;
2713
+ if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
2714
+ newShowOtpPhone = {
2715
+ phone: v[fieldName],
2716
+ type: 'zalo',
2717
+ };
2718
+ }
2719
+ }
2720
+ if (newShowOtpPhone) {
2721
+ setIsSubmitLoading(true);
2722
+ Service.sendSMSOtpLead(newShowOtpPhone)
2723
+ .then((res) => {
2724
+ var _a;
2725
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2726
+ if (respMessage === 'This phone number was verified') {
2727
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2728
+ return;
2729
+ }
2730
+ setShowOtpPhone(newShowOtpPhone);
2731
+ })
2732
+ .finally(() => {
2733
+ setIsSubmitLoading(false);
2734
+ });
2735
+ return;
2736
+ }
2737
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2738
+ })(e);
2739
+ }, 100);
2740
+ };
2741
+ const onOpenChange = (_open) => {
2742
+ setOpen(_open);
2743
+ if (!_open) {
2744
+ setTimeout(() => {
2745
+ onClose();
2746
+ }, 250);
2747
+ }
2748
+ };
2749
+ const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
2750
+ const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
2751
+ const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
2752
+ const renderAfterImageSizes = imageMobileLoaded &&
2753
+ imageDesktopLoaded &&
2754
+ (isFullscreen ? imageBackgroundLoaded : true);
2755
+ const ButtonSubmit = React.useMemo(() => {
2756
+ var _a;
2757
+ 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));
2758
+ }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
2759
+ const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
2760
+ const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default["default"].createElement(React__default["default"].Fragment, null, LinkButtonBlock.map((item, index) => {
2761
+ var _a, _b, _c;
2762
+ 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: () => {
2763
+ onClose === null || onClose === void 0 ? void 0 : onClose();
2764
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2765
+ } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
2766
+ })));
2767
+ 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,
2768
+ React__default["default"].createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
2769
+ React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
2770
+ const PopupEmpty = showEmpty && (React__default["default"].createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
2771
+ const PopupForm = (React__default["default"].createElement(LeadFormProvider, { form: form },
2772
+ React__default["default"].createElement("form", { ref: formRef, className: "leadgen-form", onSubmit: middlewareOnSubmit },
2773
+ React__default["default"].createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
2774
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
2775
+ React__default["default"].createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
2776
+ const PopupOtp = showOtpPhone && (React__default["default"].createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
2777
+ setShowOtpPhone(null);
2778
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
2779
+ } }));
2780
+ 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 }));
2781
+ const PopupContent = (React__default["default"].createElement("div", { className: core.clsx('leadgen-content', {
2782
+ 'leadgen-content_small': limitFieldsLightBoxB,
2783
+ }) },
2784
+ !headerInsideFormContainer && PopupHeader,
2785
+ !onlyHeader && (React__default["default"].createElement("div", { className: "leadgen-inner" },
2786
+ PopupThankYou,
2787
+ !showThankyou && (React__default["default"].createElement(React__default["default"].Fragment, null,
2788
+ PopupOtp,
2789
+ PopupEmpty,
2790
+ !(showOtpPhone || showEmpty) && PopupForm))))));
2791
+ const styleOverlay = React.useMemo(() => {
2792
+ let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
2793
+ if (isMobile && imageOverlayMobile) {
2794
+ styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
2795
+ }
2796
+ if (!isMobile && imageOverlayDesktop) {
2797
+ styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
2798
+ }
2799
+ return styleContent;
2800
+ }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
2801
+ const PopupWrapper = (React__default["default"].createElement(React__default["default"].Fragment, null,
2802
+ React__default["default"].createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
2803
+ React__default["default"].createElement("div", { className: core.clsx('leadgen-wrapper', {
2804
+ 'leadgen-wrapper_small': limitFieldsLightBoxB,
2805
+ }) },
2806
+ showButtonClose && (React__default["default"].createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
2807
+ PopupContent)));
2808
+ const popupContainerClassName = core.clsx('leadgen', `leadgen-${currentLayout}`, {
2809
+ 'leadgen-lightbox': isLightBox,
2810
+ 'leadgen-inline': isInPage,
2811
+ 'leadgen-slider': isSlider,
4073
2812
  });
4074
- React.useEffect(() => {
4075
- setTimeout(() => {
4076
- if (resendTimer > 0) {
4077
- setResendTimer((r) => r - 1);
4078
- }
4079
- }, 1000);
4080
- }, [resendTimer]);
4081
- React.useEffect(() => {
4082
- if (autoSendWhenOpen && !resendTimer) {
4083
- sendOtp();
4084
- }
4085
- }, []);
4086
- return (React__default["default"].createElement("form", { onSubmit: (e) => {
4087
- e.preventDefault();
4088
- submitOtp();
4089
- }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
4090
- React__default["default"].createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
4091
- phone: `<strong>${displayPhone}</strong>`,
4092
- }), footer: React__default["default"].createElement(React__default["default"].Fragment, null,
4093
- React__default["default"].createElement(core.Button, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
4094
- React__default["default"].createElement(core.Button, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
4095
- sendOtp();
4096
- }, disabled: !!resendTimer }, t('lead.otp.resend', {
4097
- timer: resendTimer ? ` (${resendTimer}s)` : '',
4098
- }))) },
4099
- React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4100
- React__default["default"].createElement(index$3.Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
4101
- React__default["default"].createElement(index$3.OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
4102
- setIsDirty(true);
4103
- setOtp(v.toString());
4104
- if (isDirty && !v)
4105
- setErrorMsg('OTP is required');
4106
- else
4107
- setErrorMsg(undefined);
4108
- } }))))));
2813
+ 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" },
2814
+ PopupWrapper,
2815
+ 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 },
2816
+ isFullscreen ? (React__default["default"].createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
2817
+ aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
2818
+ } })) : null,
2819
+ PopupWrapper));
2820
+ if (!renderAfterImageSizes)
2821
+ return null;
2822
+ if (isLightBox || isFullscreen || isSlider) {
2823
+ return PopupContainer;
2824
+ }
2825
+ else if (isSidebar) {
2826
+ return React__default["default"].createElement(SideBarLayout, { content: PopupContainer });
2827
+ }
2828
+ else if (isInline) {
2829
+ return (React__default["default"].createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
2830
+ }
2831
+ return null;
2832
+ };
2833
+
2834
+ const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
2835
+ const currentPath = location.pathname;
2836
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
2837
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
2838
+ if (!imageMobileLoaded || !imageDesktopLoaded)
2839
+ return null;
2840
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
2841
+ currentLayout == 'SkinA' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
2842
+ React__default["default"].createElement("div", { className: "le-skin-a-desktop" },
2843
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
2844
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
2845
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2846
+ } }),
2847
+ React__default["default"].createElement("a", { style: {
2848
+ position: 'absolute',
2849
+ top: '75%',
2850
+ left: '50%',
2851
+ transform: 'translate(-50%, -50%)',
2852
+ textAlign: 'center',
2853
+ width: 'calc(100% - 15px)',
2854
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2855
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
2856
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
2857
+ React__default["default"].createElement("div", { className: "" },
2858
+ React__default["default"].createElement("div", { style: { position: 'relative', zIndex: 10000 } },
2859
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
2860
+ width: '100%',
2861
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2862
+ } }),
2863
+ React__default["default"].createElement("a", { style: {
2864
+ position: 'absolute',
2865
+ top: '75%',
2866
+ left: '50%',
2867
+ transform: 'translate(-50%, -50%)',
2868
+ textAlign: 'center',
2869
+ width: '100%',
2870
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2871
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2872
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
2873
+ React__default["default"].createElement("aside", { className: "le-only-mobile" },
2874
+ React__default["default"].createElement("div", { className: "le-skin-mobile" },
2875
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
2876
+ index$6.isVideo(imageMobile) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true },
2877
+ React__default["default"].createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default["default"].createElement("img", { src: imageMobile, style: {
2878
+ width: '100%',
2879
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
2880
+ } })),
2881
+ React__default["default"].createElement("a", { style: {
2882
+ position: 'absolute',
2883
+ top: '82%',
2884
+ left: '50%',
2885
+ transform: 'translate(-50%, -50%)',
2886
+ textAlign: 'center',
2887
+ maxWidth: 'calc(100% - 15px)',
2888
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2889
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2890
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4109
2891
  };
4110
2892
 
4111
2893
  // url: imageBlocks.imageMobile.data.url
4112
2894
  // newTab: imageBlocks.imageMobile.data.newtab
4113
2895
  // image: campaignShow.image
4114
2896
  // imageDestkop: campaignShow.image_desktop
4115
- const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
4116
- LEADGEN_LAYOUT.Fullscreen,
4117
- LEADGEN_LAYOUT.Slider,
4118
- ];
4119
- const LEADGEN_LIMIT_LIGHTBOXB = 6;
4120
- const LEADGEN_SHOW_HEADER = [
4121
- 'LightBoxA',
4122
- 'InlineA',
4123
- LEADGEN_LAYOUT.Sidebar,
4124
- LEADGEN_LAYOUT.Slider,
4125
- ];
4126
- const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2897
+ const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
2898
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
2899
+ if (!imageLoaded)
2900
+ return null;
2901
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
2902
+ React__default["default"].createElement("div", { className: "le-tab-popup" },
2903
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
2904
+ React__default["default"].createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
2905
+ React__default["default"].createElement("img", { className: "js-popup-other-submit", src: image, style: {
2906
+ aspectRatio: `${imageWidth}/${imageHeight}`,
2907
+ } })),
2908
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
2909
+ };
2910
+
2911
+ // import mockLeadData from './mockLeadData'
2912
+ const listCampaignScheduled = [];
2913
+ const listCampaignScheduledToActivated = [];
2914
+ const listCampaignActiveButExpired = [];
2915
+ const listCampaignExcludeSonsored = [];
2916
+ const listCampaignDifferentSponsor = [];
2917
+ const listCampaignNotDisplayInRangeOfTime = [];
2918
+ function isMobile() {
2919
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
2920
+ }
2921
+ const getShuffleArray = (array) => {
2922
+ const newArray = [...array];
2923
+ for (let i = newArray.length - 1; i > 0; i--) {
2924
+ const j = Math.floor(Math.random() * (i + 1));
2925
+ const temp = newArray[i];
2926
+ newArray[i] = newArray[j];
2927
+ newArray[j] = temp;
2928
+ }
2929
+ return newArray;
2930
+ };
2931
+ const getTimeByTimezone = (timeZone = 'UTC') => {
2932
+ const date = new Date();
2933
+ return new Date(date.toLocaleString('en-US', { timeZone }));
2934
+ };
2935
+ const parseDateByCampaignTime = (dateStr) => {
2936
+ // Format like this: 2023-04-04 00:00:00
2937
+ try {
2938
+ const [datePart, timePart] = dateStr.split(' ');
2939
+ const [year, month, day] = datePart.split('-').map(Number);
2940
+ const [hours, minutes, seconds] = timePart.split(':').map(Number);
2941
+ /** JavaScript counts months from 0 to 11 */
2942
+ return new Date(year, month - 1, day, hours, minutes, seconds);
2943
+ }
2944
+ catch (err) {
2945
+ return null;
2946
+ }
2947
+ };
2948
+ const checkCampaignNowInTimeframe = (c) => {
2949
+ var _a;
2950
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2951
+ const startedAtStr = c.started_at;
2952
+ const endedAtStr = c.ended_at;
2953
+ const startedDate = parseDateByCampaignTime(startedAtStr);
2954
+ const endedDate = parseDateByCampaignTime(endedAtStr);
2955
+ if (!startedDate || !endedDate) {
2956
+ return false;
2957
+ }
2958
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
2959
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2960
+ if (nowWithTimezoneMs <= endedDate.getTime() &&
2961
+ nowWithTimezoneMs >= startedDate.getTime()) {
2962
+ listCampaignScheduledToActivated.push(c);
2963
+ return true;
2964
+ }
2965
+ return false;
2966
+ };
2967
+ function checkCampaignActiveButExpireAlready(c) {
2968
+ var _a;
2969
+ /** Do not setup timeframe for this campaign. No need to check */
2970
+ if (c.forever === 1) {
2971
+ return true;
2972
+ }
2973
+ const startedAtStr = c.started_at;
2974
+ const endedAtStr = c.ended_at;
2975
+ const startedDate = parseDateByCampaignTime(startedAtStr);
2976
+ const endedDate = parseDateByCampaignTime(endedAtStr);
2977
+ /** Do not setup timeframe for this campaign. No need to check */
2978
+ if (!startedDate || !endedDate) {
2979
+ return true;
2980
+ }
2981
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2982
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
2983
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2984
+ /** Check if this expire already, do not show */
2985
+ if (nowWithTimezoneMs > endedDate.getTime()) {
2986
+ listCampaignActiveButExpired.push(c);
2987
+ return false;
2988
+ }
2989
+ return true;
2990
+ }
2991
+ function shouldNotDisplayIfExcludeAllSponsors(c) {
2992
+ var _a;
2993
+ const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
2994
+ const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
2995
+ if (isSponsored && excludeSponsored) {
2996
+ listCampaignExcludeSonsored.push(c);
2997
+ return true;
2998
+ }
2999
+ return false;
3000
+ }
3001
+ function shouldDisplayWithCurrentSponsor(c) {
4127
3002
  var _a, _b;
4128
- const { primaryColor } = React.useContext(LeadGenContext$1);
4129
- const { isMobile } = useScreenSize.useScreenSize();
4130
- const [open, setOpen] = React.useState(!!campaignId);
4131
- const [showOtpPhone, setShowOtpPhone] = React.useState(null);
4132
- const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
4133
- const [snap, setSnap] = React.useState(0.8);
4134
- const formRef = React.useRef();
4135
- const onClose = () => {
4136
- if (showOtpPhone) {
4137
- setShowOtpPhone(null);
3003
+ try {
3004
+ // TODO: BE will rename `exclude_sponsored_list` later
3005
+ const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
3006
+ const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
3007
+ const dataSponsoredId = Number((_b = document
3008
+ .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
3009
+ // There is no config for sponsor id and white list, should show as default
3010
+ if (!dataSponsoredId ||
3011
+ dataSponsoredId <= 0 ||
3012
+ whiteListSponsors.length === 0) {
3013
+ return true;
4138
3014
  }
4139
- else {
4140
- onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
3015
+ // Check the dataSponsoredId exists in the white list or not.
3016
+ const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
3017
+ if (isExist) {
3018
+ return true;
4141
3019
  }
4142
- };
4143
- const textBlocks = JSON.parse(extraFields.textBlocks);
4144
- const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
4145
- const actionBlocks = JSON.parse(extraFields.actionBlocks);
4146
- const popUpSubmitText = actionBlocks.submitBlock.data.value;
4147
- const currentPath = location.pathname;
4148
- const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
4149
- const { align: titleAlign } = textBlocks.titleBlock.data || {};
4150
- const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
4151
- const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
4152
- const isLightBox = currentLayout.includes('LightBox');
4153
- const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
4154
- const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
4155
- const isInline = currentLayout.includes('Inline');
4156
- const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
4157
- const isInPage = isInline || isSidebar;
4158
- const isDrawer = isLightBoxB && isMobile;
4159
- const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
4160
- const hasForm = isLightBoxA
4161
- ? listBlockAdded.some((item) => LEADGEN_BLOCK_INPUT.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
4162
- : true;
4163
- const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
4164
- const showHeader = !!imageMobile || !!imageDesktop;
4165
- const onlyHeader = !title && !description;
4166
- const showButtonClose = !isInline;
4167
- if (window.innerWidth < 769 &&
4168
- LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
4169
- console.log('😎 Not show fullscreen, slider on mobile ');
4170
- return null;
3020
+ listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
3021
+ return false;
4171
3022
  }
4172
- React.useEffect(() => {
4173
- if (isLightBox || isFullscreen) {
4174
- document.body.classList.add('noscroll');
4175
- }
4176
- if (!window.intlTelInputUtils) {
4177
- require('intl-tel-input/build/js/utils');
3023
+ catch (err) {
3024
+ // Default is show
3025
+ return true;
3026
+ }
3027
+ }
3028
+ const filterFnCampaign = (c) => {
3029
+ if (shouldNotDisplayIfExcludeAllSponsors(c)) {
3030
+ return false;
3031
+ }
3032
+ else if (!shouldDisplayWithCurrentSponsor(c)) {
3033
+ return false;
3034
+ }
3035
+ /** Active */
3036
+ if (c.formatted_status === 1) {
3037
+ return checkCampaignActiveButExpireAlready(c);
3038
+ }
3039
+ /** Schedule */
3040
+ if (c.formatted_status === 0) {
3041
+ listCampaignScheduled.push(c);
3042
+ return checkCampaignNowInTimeframe(c);
3043
+ }
3044
+ return false;
3045
+ };
3046
+ const fillterApprearanceTimeCampaign = (c) => {
3047
+ var _a;
3048
+ try {
3049
+ const isTimeInRange = (currentTime, startTime, endTime) => {
3050
+ const startParts = startTime.split(':');
3051
+ const endParts = endTime.split(':');
3052
+ const startDate = new Date();
3053
+ startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
3054
+ const endDate = new Date();
3055
+ endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
3056
+ return currentTime >= startDate && currentTime <= endDate;
3057
+ };
3058
+ const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
3059
+ const startTime = rulesApprValue.startTime;
3060
+ const endTime = rulesApprValue.endTime || '23:59';
3061
+ if (!startTime) {
3062
+ return true;
4178
3063
  }
4179
- clearCacheUsedEmailOrPhone();
4180
- }, []);
4181
- const validatingPhoneRef = React.useRef(false);
4182
- const validatingEmailRef = React.useRef(false);
4183
- const { form, validateObj } = useLeadFormConfig({
4184
- listBlockAdded,
4185
- validatingPhoneRef,
4186
- validatingEmailRef,
4187
- campaignId,
4188
- campaign_subot_id,
4189
- userInfo,
4190
- format: (_a = (index$7.ISO_FORMAT[locale] || index$7.ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
4191
- });
4192
- const onFocus = (e) => {
4193
- const target = e.target;
4194
- target.scrollIntoView({
4195
- block: 'center',
4196
- inline: 'nearest',
4197
- behavior: 'auto',
4198
- });
4199
- };
4200
- const middlewareOnSubmit = (e) => {
4201
- e.preventDefault();
4202
- // mark all as touched to allow validation
4203
- const fields = Object.keys(validateObj);
4204
- const fieldStatus = fields.reduce((acc, cur) => {
4205
- acc[cur] = true;
4206
- return acc;
4207
- }, {});
4208
- form.setTouched(fieldStatus);
4209
- if (validatingEmailRef.current || validatingPhoneRef.current) {
4210
- return;
3064
+ if (isTimeInRange(new Date(), startTime, endTime)) {
3065
+ return true;
4211
3066
  }
4212
- setTimeout(() => {
4213
- form.onSubmit((v) => {
4214
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4215
- if (Object.keys(form.errors).length)
4216
- return;
4217
- let newShowOtpPhone = null;
4218
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
4219
- // not submit yet, open otp
4220
- const fieldName = (_b = (_a = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock)) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value;
4221
- if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
4222
- newShowOtpPhone = {
4223
- phone: v[fieldName],
4224
- type: 'phone',
4225
- };
3067
+ listCampaignNotDisplayInRangeOfTime.push(c);
3068
+ return false;
3069
+ }
3070
+ catch (err) {
3071
+ return true;
3072
+ }
3073
+ };
3074
+ let timeoutRef = null;
3075
+ let LEAD_SCROLL_EVENT = null;
3076
+ function clearPassiveEvent() {
3077
+ if (timeoutRef) {
3078
+ clearTimeout(timeoutRef);
3079
+ timeoutRef = null;
3080
+ }
3081
+ if (LEAD_SCROLL_EVENT) {
3082
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3083
+ LEAD_SCROLL_EVENT = null;
3084
+ }
3085
+ }
3086
+ function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
3087
+ // clear previous passive event, check for new condition
3088
+ clearPassiveEvent();
3089
+ const leadCurrentUrl = DEBUG_URL ||
3090
+ ('https://' +
3091
+ location.hostname +
3092
+ location.pathname +
3093
+ location.search).toLowerCase();
3094
+ fetch(leadApi + 'api/campaign/' + leadSiteId, {
3095
+ method: 'POST',
3096
+ headers: {
3097
+ 'Content-Type': 'application/json',
3098
+ },
3099
+ body: JSON.stringify({
3100
+ url: leadCurrentUrl,
3101
+ ga_client_id: miscCookieHelper.getCookie('_ga') || null,
3102
+ }),
3103
+ })
3104
+ .then((response) => {
3105
+ return response.json();
3106
+ // return mockLeadData || response.json()
3107
+ })
3108
+ .then((data) => {
3109
+ var _a, _b, _c, _d;
3110
+ LeadLog('List campagin: ', data);
3111
+ LEAD_RESET_VAR();
3112
+ if (data._status == 1) {
3113
+ 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);
3114
+ if (!miscCookieHelper.getCookie('hhg-id')) {
3115
+ miscCookieHelper.setCookie('hhg-id', uuid.v1(), {
3116
+ domain: '.' + leadDomain,
3117
+ path: '/',
3118
+ });
3119
+ LeadLog('😍 Set HHG ID cookie');
3120
+ }
3121
+ // getCookie('hhg-id')
3122
+ // TODO: HP-534 Filter desktop
3123
+ let campaignsDevice = [];
3124
+ if (isMobile()) {
3125
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
3126
+ }
3127
+ else {
3128
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
3129
+ }
3130
+ LeadLog(`👓 campaignsDevice`, campaignsDevice);
3131
+ LeadLog('--listCampaignScheduled', listCampaignScheduled);
3132
+ LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
3133
+ LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
3134
+ LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
3135
+ LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
3136
+ LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
3137
+ // Check links
3138
+ let listLinksObj = campaignsDevice
3139
+ .map((i, index) => i.targets
3140
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
3141
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3142
+ .flat(1);
3143
+ // Check list link match current href
3144
+ listLinksObj = listLinksObj.filter((i) => {
3145
+ var _a;
3146
+ const target = new URL(String(i.target).toLowerCase());
3147
+ if (i.option == 'exact_match')
3148
+ // FOR TEST LOCAL:
3149
+ // return Boolean(location.pathname === target.pathname)
3150
+ return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
3151
+ if (i.option == 'start_with') {
3152
+ // FOR TEST LOCAL:
3153
+ // if (location.pathname.includes(target.pathname)) {
3154
+ if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
3155
+ const listExcluding = i.sub_target
3156
+ .filter((i) => i.option == 'excluding')
3157
+ .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
3158
+ return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
4226
3159
  }
4227
- }
4228
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
4229
- // not submit yet, open otp
4230
- const fieldName = (_e = (_d = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock)) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.value;
4231
- if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
4232
- newShowOtpPhone = {
4233
- phone: v[fieldName],
4234
- type: 'whatsapp',
4235
- };
3160
+ else {
3161
+ return false;
4236
3162
  }
4237
3163
  }
4238
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
4239
- // not submit yet, open otp
4240
- const fieldName = (_h = (_g = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock)) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.value;
4241
- if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
4242
- newShowOtpPhone = {
4243
- phone: v[fieldName],
4244
- type: 'zalo',
4245
- };
4246
- }
3164
+ });
3165
+ // Check tags
3166
+ const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
3167
+ const listTags = listMetaTag.map((i) => i.content);
3168
+ let listCampaignHasTag = [];
3169
+ let listTagsObj = [];
3170
+ if (listTags && listTags.length) {
3171
+ listCampaignHasTag = campaignsDevice
3172
+ .map((i, index) => i.targets
3173
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
3174
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3175
+ .flat(1);
3176
+ listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
3177
+ }
3178
+ const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
3179
+ const cookieKeys = document.cookie
3180
+ .split('; ')
3181
+ .map((i) => i.split('=')[0]);
3182
+ const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
3183
+ LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
3184
+ const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
3185
+ LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
3186
+ const listCampaignSubmitedClosed = [
3187
+ ...listCampaignCodeSubmited,
3188
+ ...listCampaignCodeClosed,
3189
+ ];
3190
+ const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
3191
+ const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
3192
+ return !hasSubmited;
3193
+ });
3194
+ const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
3195
+ // .sort(
3196
+ // (a, b) =>
3197
+ // (listCampaignValid[a.campaignIndex]?.score || 0) -
3198
+ // (listCampaignValid[b.campaignIndex]?.score || 0),
3199
+ // )
3200
+ LeadLog('--listCampaignValid : ', listCampaignValid);
3201
+ if (listCampaignValid && listCampaignValid.length) {
3202
+ const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
3203
+ LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
3204
+ const { rules } = CAMPAIGN_SHOW;
3205
+ // CHECK RULE TRIGGER POPUP
3206
+ const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
3207
+ LeadLog(`timeoutRule`, timeoutRule);
3208
+ const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
3209
+ LeadLog(`scrollRule`, scrollRule);
3210
+ let impressionAction = 'TIME';
3211
+ if (Number.isInteger(timeoutRule)) {
3212
+ impressionAction = 'TIME';
3213
+ LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
3214
+ timeoutRef = setTimeout(() => {
3215
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3216
+ }, timeoutRule * 1000);
4247
3217
  }
4248
- if (newShowOtpPhone) {
4249
- setIsSubmitLoading(true);
4250
- Service.sendSMSOtpLead(newShowOtpPhone)
4251
- .then((res) => {
4252
- var _a;
4253
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4254
- if (respMessage === 'This phone number was verified') {
4255
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4256
- return;
3218
+ if (Number.isInteger(scrollRule)) {
3219
+ impressionAction = 'SCROLL';
3220
+ LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
3221
+ const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
3222
+ document.querySelector('body');
3223
+ const pct = $p.getBoundingClientRect().top;
3224
+ const pb = $p.offsetHeight;
3225
+ LeadLog(`👓 Element check scroll: `, $p);
3226
+ LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
3227
+ const wt = window.pageYOffset || document.documentElement.scrollTop;
3228
+ let percent = 0;
3229
+ if (wt >= pct) {
3230
+ percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
4257
3231
  }
4258
- setShowOtpPhone(newShowOtpPhone);
4259
- })
4260
- .finally(() => {
4261
- setIsSubmitLoading(false);
3232
+ LeadLog('---Scroll', percent, scrollRule);
3233
+ // TODO: CHECK FOOTER HEIGHT
3234
+ if (percent >= scrollRule) {
3235
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3236
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3237
+ }
3238
+ };
3239
+ window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
3240
+ passive: true,
4262
3241
  });
4263
- return;
4264
3242
  }
4265
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4266
- })(e);
4267
- }, 100);
4268
- };
4269
- const onOpenChange = (_open) => {
4270
- setOpen(_open);
4271
- if (!_open) {
4272
- setTimeout(() => {
4273
- onClose();
4274
- }, 250);
4275
- }
4276
- };
4277
- const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
4278
- const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
4279
- const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
4280
- const renderAfterImageSizes = imageMobileLoaded &&
4281
- imageDesktopLoaded &&
4282
- (isFullscreen ? imageBackgroundLoaded : true);
4283
- const ButtonSubmit = React.useMemo(() => {
4284
- var _a;
4285
- return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default["default"].createElement(core.Button, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
4286
- }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
4287
- const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
4288
- const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default["default"].createElement(React__default["default"].Fragment, null, LinkButtonBlock.map((item, index) => {
4289
- var _a, _b, _c;
4290
- return (React__default["default"].createElement(core.Button, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
4291
- onClose === null || onClose === void 0 ? void 0 : onClose();
4292
- onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
4293
- } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
4294
- })));
4295
- const PopupHeader = showHeader && (React__default["default"].createElement("header", { className: core.clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default["default"].createElement(React__default["default"].Fragment, null,
4296
- React__default["default"].createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
4297
- React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
4298
- const PopupEmpty = showEmpty && (React__default["default"].createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
4299
- const PopupForm = (React__default["default"].createElement(LeadFormProvider, { form: form },
4300
- React__default["default"].createElement("form", { ref: formRef, className: "leadgen-form", onFocus: onFocus, onSubmit: middlewareOnSubmit },
4301
- React__default["default"].createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
4302
- React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4303
- React__default["default"].createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
4304
- const PopupOtp = showOtpPhone && (React__default["default"].createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
4305
- setShowOtpPhone(null);
4306
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
4307
- } }));
4308
- const PopupThankYou = showThankyou && (React__default["default"].createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
4309
- const PopupContent = (React__default["default"].createElement("div", { className: core.clsx('leadgen-content', {
4310
- 'leadgen-content_small': limitFieldsLightBoxB,
4311
- }) },
4312
- !headerInsideFormContainer && PopupHeader,
4313
- !onlyHeader && (React__default["default"].createElement("div", { className: "leadgen-inner" },
4314
- PopupThankYou,
4315
- !showThankyou && (React__default["default"].createElement(React__default["default"].Fragment, null,
4316
- PopupOtp,
4317
- PopupEmpty,
4318
- !(showOtpPhone || showEmpty) && PopupForm))))));
4319
- const styleOverlay = React.useMemo(() => {
4320
- let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
4321
- if (isMobile && imageOverlayMobile) {
4322
- styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4323
- }
4324
- if (!isMobile && imageOverlayDesktop) {
4325
- styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
3243
+ }
3244
+ else {
3245
+ LeadLog('🚧 No lead campaigns on current URL, tags');
3246
+ }
4326
3247
  }
4327
- return styleContent;
4328
- }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
4329
- const PopupWrapper = (React__default["default"].createElement(React__default["default"].Fragment, null,
4330
- React__default["default"].createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
4331
- React__default["default"].createElement("div", { className: core.clsx('leadgen-wrapper', {
4332
- 'leadgen-wrapper_small': limitFieldsLightBoxB,
4333
- }) },
4334
- showButtonClose && (React__default["default"].createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
4335
- PopupContent)));
4336
- const popupContainerClassName = core.clsx('leadgen', `leadgen-${currentLayout}`, {
4337
- 'leadgen-lightbox': isLightBox,
4338
- 'leadgen-inline': isInPage,
4339
- 'leadgen-slider': isSlider,
3248
+ })
3249
+ .catch((err) => {
3250
+ LeadLog(`Lead error: `, err);
4340
3251
  });
4341
- const PopupContainer = isDrawer ? (React__default["default"].createElement(index$b.DrawerComponent, { fadeFromIndex: index$7.ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
4342
- PopupWrapper,
4343
- React__default["default"].createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default["default"].createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
4344
- isFullscreen ? (React__default["default"].createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
4345
- aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
4346
- } })) : null,
4347
- PopupWrapper));
4348
- if (!renderAfterImageSizes)
4349
- return null;
4350
- if (isLightBox || isFullscreen || isSlider) {
4351
- return PopupContainer;
4352
- }
4353
- else if (isSidebar) {
4354
- return React__default["default"].createElement(SideBarLayout, { content: PopupContainer });
4355
- }
4356
- else if (isInline) {
4357
- return (React__default["default"].createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
3252
+ }
3253
+ const LeadLog = (...params) => {
3254
+ if (process.env.NODE_ENV !== 'production' ||
3255
+ (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
3256
+ process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
3257
+ (typeof localStorage !== 'undefined' &&
3258
+ localStorage.getItem('hhg_debug') === 'true')) {
3259
+ console.log(...params);
4358
3260
  }
4359
- return null;
4360
- };
4361
-
4362
- const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
4363
- const currentPath = location.pathname;
4364
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
4365
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
4366
- if (!imageMobileLoaded || !imageDesktopLoaded)
4367
- return null;
4368
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
4369
- currentLayout == 'SkinA' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4370
- React__default["default"].createElement("div", { className: "le-skin-a-desktop" },
4371
- React__default["default"].createElement("div", { style: { position: 'relative' } },
4372
- React__default["default"].createElement("img", { src: imageDesktop, style: {
4373
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4374
- } }),
4375
- React__default["default"].createElement("a", { style: {
4376
- position: 'absolute',
4377
- top: '75%',
4378
- left: '50%',
4379
- transform: 'translate(-50%, -50%)',
4380
- textAlign: 'center',
4381
- width: 'calc(100% - 15px)',
4382
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4383
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
4384
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4385
- React__default["default"].createElement("div", { className: "" },
4386
- React__default["default"].createElement("div", { style: { position: 'relative', zIndex: 10000 } },
4387
- React__default["default"].createElement("img", { src: imageDesktop, style: {
4388
- width: '100%',
4389
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4390
- } }),
4391
- React__default["default"].createElement("a", { style: {
4392
- position: 'absolute',
4393
- top: '75%',
4394
- left: '50%',
4395
- transform: 'translate(-50%, -50%)',
4396
- textAlign: 'center',
4397
- width: '100%',
4398
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4399
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4400
- React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
4401
- React__default["default"].createElement("aside", { className: "le-only-mobile" },
4402
- React__default["default"].createElement("div", { className: "le-skin-mobile" },
4403
- React__default["default"].createElement("div", { style: { position: 'relative' } },
4404
- index$8.isVideo(imageMobile) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true },
4405
- React__default["default"].createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default["default"].createElement("img", { src: imageMobile, style: {
4406
- width: '100%',
4407
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
4408
- } })),
4409
- React__default["default"].createElement("a", { style: {
4410
- position: 'absolute',
4411
- top: '82%',
4412
- left: '50%',
4413
- transform: 'translate(-50%, -50%)',
4414
- textAlign: 'center',
4415
- maxWidth: 'calc(100% - 15px)',
4416
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4417
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4418
- React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4419
- };
4420
-
4421
- // url: imageBlocks.imageMobile.data.url
4422
- // newTab: imageBlocks.imageMobile.data.newtab
4423
- // image: campaignShow.image
4424
- // imageDestkop: campaignShow.image_desktop
4425
- const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
4426
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
4427
- if (!imageLoaded)
4428
- return null;
4429
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
4430
- React__default["default"].createElement("div", { className: "le-tab-popup" },
4431
- React__default["default"].createElement("div", { style: { position: 'relative' } },
4432
- React__default["default"].createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
4433
- React__default["default"].createElement("img", { className: "js-popup-other-submit", src: image, style: {
4434
- aspectRatio: `${imageWidth}/${imageHeight}`,
4435
- } })),
4436
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
4437
3261
  };
4438
3262
 
4439
3263
  function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
@@ -4449,7 +3273,7 @@ function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
4449
3273
  }
4450
3274
  const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, showEmpty, setShowEmpty, userInfo, }) => {
4451
3275
  var _a, _b;
4452
- const { apiUrl, siteDomain } = React.useContext(LeadGenContext$1);
3276
+ const { apiUrl, siteDomain } = React.useContext(LeadGenContext);
4453
3277
  React.useEffect(() => {
4454
3278
  const gaCookie = miscCookieHelper.getCookie('_ga') || null;
4455
3279
  fetch(`${apiUrl}api/campaign/${code}/impression`, {
@@ -4844,7 +3668,7 @@ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, primaryColor
4844
3668
  leadStartTimeRef.current = Date.now();
4845
3669
  }
4846
3670
  }, [showCampaign]);
4847
- return (React__default["default"].createElement(LeadGenContext$1.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
3671
+ return (React__default["default"].createElement(LeadGenContext.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
4848
3672
  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() },
4849
3673
  React__default["default"].createElement(core.Box, { sx: { position: 'fixed', zIndex: index$7.ZINDEX_SSO - 9e6 } },
4850
3674
  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) => {
@@ -4865,4 +3689,3 @@ LeadGen.OtpForm = OtpBlock$1;
4865
3689
  LeadGen.Close = Close.Close;
4866
3690
 
4867
3691
  exports.LeadGen = LeadGen;
4868
- exports.LeadGenSubscriptionBox = LeadGenSubscriptionBox;