@hhgtech/hhg-components 1.29.372-beta-2 → 1.29.373

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (543) hide show
  1. package/build/{InputDate-53510fc6.js → InputDate-39bd6171.js} +20 -20
  2. package/build/{LastPeriod-97a41212.js → LastPeriod-277f41c6.js} +1 -1
  3. package/build/{Locale-a6cfbd0c.js → Locale-2723c28f.js} +0 -1
  4. package/build/{MobileBottomNavigationIcon-adde2568.js → MobileBottomNavigationIcon-663adc1f.js} +3 -3
  5. package/build/{Spinner-8aadaea4.js → Spinner-b867278e.js} +1 -1
  6. package/build/{WhatsApp-d1ecfc43.js → WhatsApp-3745791a.js} +1 -1
  7. package/build/adapters.js +19 -19
  8. package/build/atoms.js +48 -48
  9. package/build/babyGrowth.js +83 -83
  10. package/build/cache.js +2 -2
  11. package/build/care.js +17 -17
  12. package/build/careBookingSearchBar.js +14 -14
  13. package/build/careBookingSearchBarV2.js +15 -15
  14. package/build/components/atoms/logo/index.d.ts +1 -1
  15. package/build/components/mantine/phone/index.d.ts +0 -2
  16. package/build/components.js +96 -96
  17. package/build/{constants-e794cab6.js → constants-979354be.js} +1 -1
  18. package/build/{constants-1d734061.js → constants-f818e265.js} +0 -1
  19. package/build/constants.js +3 -3
  20. package/build/constantsDomainLocales.js +1 -3
  21. package/build/constantsRiskScreener.js +2 -2
  22. package/build/constantsSite.js +2 -2
  23. package/build/{core-752b36de.js → core-0bfb3bf0.js} +1 -1
  24. package/build/{dataTransform-0a5fe360.js → dataTransform-60ef068f.js} +1 -1
  25. package/build/ecom.js +4 -4
  26. package/build/{editor-63f2487a.js → editor-6b13b33c.js} +11 -11
  27. package/build/embeddedHeathToolCards_babyGrowth.js +23 -23
  28. package/build/embeddedHeathToolCards_babyPoop.js +19 -19
  29. package/build/embeddedHeathToolCards_babyVaccine.js +22 -22
  30. package/build/embeddedHeathToolCards_bmi_bmi.js +25 -25
  31. package/build/embeddedHeathToolCards_bmrBmr.js +25 -25
  32. package/build/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  33. package/build/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  34. package/build/embeddedHeathToolCards_pwg_pwg.js +26 -26
  35. package/build/embeddedHeathToolCards_targetHeartRate.js +27 -27
  36. package/build/esm/{InputDate-fc760765.js → InputDate-d47f4a01.js} +20 -20
  37. package/build/esm/{LastPeriod-0553ce0c.js → LastPeriod-5036dd88.js} +1 -1
  38. package/build/esm/{Locale-dd2625fa.js → Locale-07134c93.js} +0 -1
  39. package/build/esm/{MobileBottomNavigationIcon-25af9080.js → MobileBottomNavigationIcon-9a6febe7.js} +3 -3
  40. package/build/esm/{Spinner-ea23fbfb.js → Spinner-a41322b5.js} +1 -1
  41. package/build/esm/{WhatsApp-72789740.js → WhatsApp-e19fd45d.js} +1 -1
  42. package/build/esm/adapters.js +19 -19
  43. package/build/esm/atoms.js +48 -48
  44. package/build/esm/babyGrowth.js +83 -83
  45. package/build/esm/cache.js +2 -2
  46. package/build/esm/care.js +17 -17
  47. package/build/esm/careBookingSearchBar.js +14 -14
  48. package/build/esm/careBookingSearchBarV2.js +15 -15
  49. package/build/esm/components/atoms/logo/index.d.ts +1 -1
  50. package/build/esm/components/mantine/phone/index.d.ts +0 -2
  51. package/build/esm/components.js +96 -96
  52. package/build/esm/{constants-0f0116ef.js → constants-1e234074.js} +1 -1
  53. package/build/esm/{constants-3523c601.js → constants-20c3d5eb.js} +0 -1
  54. package/build/esm/constants.js +3 -3
  55. package/build/esm/constantsDomainLocales.js +1 -3
  56. package/build/esm/constantsRiskScreener.js +2 -2
  57. package/build/esm/constantsSite.js +2 -2
  58. package/build/esm/{core-c99557e1.js → core-2e1d801d.js} +1 -1
  59. package/build/esm/{dataTransform-6e4cf75a.js → dataTransform-674194af.js} +1 -1
  60. package/build/esm/ecom.js +4 -4
  61. package/build/esm/{editor-9a8b3577.js → editor-1c141e18.js} +11 -11
  62. package/build/esm/embeddedHeathToolCards_babyGrowth.js +23 -23
  63. package/build/esm/embeddedHeathToolCards_babyPoop.js +19 -19
  64. package/build/esm/embeddedHeathToolCards_babyVaccine.js +22 -22
  65. package/build/esm/embeddedHeathToolCards_bmi_bmi.js +25 -25
  66. package/build/esm/embeddedHeathToolCards_bmrBmr.js +25 -25
  67. package/build/esm/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  68. package/build/esm/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  69. package/build/esm/embeddedHeathToolCards_pwg_pwg.js +26 -26
  70. package/build/esm/embeddedHeathToolCards_targetHeartRate.js +27 -27
  71. package/build/esm/footer.js +21 -21
  72. package/build/esm/gAssets.js +2 -2
  73. package/build/esm/{healthTools-e923053c.js → healthTools-369c0656.js} +1 -1
  74. package/build/esm/healthToolsCardWrapper.js +18 -18
  75. package/build/esm/healthToolsForm.js +33 -33
  76. package/build/esm/hooks.js +13 -13
  77. package/build/esm/i18n.js +55 -14
  78. package/build/esm/i18nV2.js +2 -2
  79. package/build/esm/{index-346818d6.js → index-00d1d057.js} +6 -6
  80. package/build/esm/{index-c3841e4d.js → index-01a293ec.js} +27 -36
  81. package/build/esm/{index-af35b428.js → index-03684b81.js} +3 -3
  82. package/build/esm/{index-f824c0e2.js → index-043873f3.js} +16 -16
  83. package/build/esm/{index-70296026.js → index-0c71a30f.js} +17 -17
  84. package/build/esm/{index-6888dffa.js → index-10e9d1b7.js} +17 -17
  85. package/build/esm/{index-c07f5c07.js → index-11ac8aea.js} +1 -1
  86. package/build/esm/{index-1f0f5aca.js → index-1366b5aa.js} +10 -10
  87. package/build/esm/{index-d4520e91.js → index-1a1ccc71.js} +8 -8
  88. package/build/esm/{index-4ff7c62a.js → index-1b71077d.js} +2 -2
  89. package/build/esm/{index-e1426133.js → index-1d8bd28b.js} +22 -22
  90. package/build/esm/{index-a4e6b5ce.js → index-1e07e28a.js} +2 -2
  91. package/build/esm/{index-96704673.js → index-2146fe51.js} +1 -1
  92. package/build/esm/{index-8c90983b.js → index-279897da.js} +1 -1
  93. package/build/esm/{index-5466e357.js → index-292cce89.js} +1 -1
  94. package/build/esm/{index-9530557d.js → index-321f7852.js} +17 -17
  95. package/build/esm/{index-4ed57f85.js → index-380b8316.js} +2 -2
  96. package/build/esm/{index-871051cf.js → index-38aca112.js} +3 -3
  97. package/build/esm/{index-0423b372.js → index-39835a89.js} +2 -2
  98. package/build/esm/{index-fd855849.js → index-3a1495d6.js} +5 -5
  99. package/build/esm/{index-37a63220.js → index-44ac19ab.js} +7 -7
  100. package/build/esm/{index-c3ce6157.js → index-45add692.js} +6 -6
  101. package/build/esm/{index-e40243b0.js → index-45c7be3c.js} +3 -3
  102. package/build/esm/{index-a9feb783.js → index-4bcc31a6.js} +32 -32
  103. package/build/esm/{index-370af621.js → index-52accd51.js} +2 -39
  104. package/build/esm/{index-3e1814c1.js → index-53f5e323.js} +1 -1
  105. package/build/esm/{index-45505f2c.js → index-5b0fec76.js} +2 -2
  106. package/build/esm/{index-f34dad0c.js → index-6cff42a5.js} +16 -16
  107. package/build/esm/{index-f47da5bb.js → index-6d9a63ae.js} +13 -13
  108. package/build/esm/{index-f4b25e8f.js → index-6e8d0eb7.js} +13 -13
  109. package/build/esm/{index-96e04fc8.js → index-6ed2eaa5.js} +16 -16
  110. package/build/esm/{index-08b9a262.js → index-745cdca5.js} +16 -16
  111. package/build/esm/{index-8f8bc043.js → index-82a1b9c3.js} +15 -15
  112. package/build/esm/{index-1881a822.js → index-843a933c.js} +2 -2
  113. package/build/esm/{index-cf6b6574.js → index-84a9daf8.js} +18 -18
  114. package/build/esm/{index-12b37e1d.js → index-85550d91.js} +6 -6
  115. package/build/esm/{index-65f141c1.js → index-87fc69f5.js} +1 -1
  116. package/build/esm/{index-1096cc1a.js → index-94453b7b.js} +3 -3
  117. package/build/esm/{index-2d19a560.js → index-9ab17c42.js} +31 -31
  118. package/build/esm/{index-5b650465.js → index-9f09262e.js} +1 -1
  119. package/build/esm/{index-1b73eed5.js → index-a0a5dbea.js} +4 -4
  120. package/build/esm/{index-3bc6ddd1.js → index-a34096b4.js} +17 -17
  121. package/build/esm/{index-3b1703aa.js → index-a4866cef.js} +13 -13
  122. package/build/esm/{index-4cc9b880.js → index-a4f611de.js} +1 -1
  123. package/build/esm/{index-23d3743e.js → index-a7eee506.js} +2 -2
  124. package/build/esm/{index-e388493a.js → index-acbcda8e.js} +18 -18
  125. package/build/esm/{index-290638a8.js → index-b20b637a.js} +2 -2
  126. package/build/esm/{index-81ccb624.js → index-b520cbab.js} +2 -2
  127. package/build/esm/{index-3222872e.js → index-bb64b141.js} +25 -25
  128. package/build/esm/{index-5b0939a8.js → index-c89611db.js} +3 -3
  129. package/build/esm/{index-dd664bf5.js → index-d41d469d.js} +3 -3
  130. package/build/esm/{index-a369d413.js → index-d972356e.js} +5 -5
  131. package/build/esm/{index-a7927623.js → index-d9a5e563.js} +2 -2
  132. package/build/esm/{index-6a2e5610.js → index-dd6a1724.js} +21 -21
  133. package/build/esm/{index-d3eb4e0d.js → index-de9e0ceb.js} +2 -2
  134. package/build/esm/{index-97ca081d.js → index-dfc48cf4.js} +2 -2
  135. package/build/esm/{index-4f0f3097.js → index-e13e7f89.js} +24 -24
  136. package/build/esm/{index-6f990758.js → index-e1a8672b.js} +6 -6
  137. package/build/esm/{index-17f4cc07.js → index-e447e9fc.js} +6 -6
  138. package/build/esm/{index-9b8d4fd0.js → index-e86fb7af.js} +1 -1
  139. package/build/esm/{index-b35d49d4.js → index-eb9376f6.js} +32 -32
  140. package/build/esm/{index-79890213.js → index-f0928248.js} +2 -2
  141. package/build/esm/{index-19b02397.js → index-fbc9646e.js} +7 -7
  142. package/build/esm/{index-8d9fbcc3.js → index-fd247adc.js} +13 -13
  143. package/build/esm/index.js +117 -117
  144. package/build/esm/interfaces/constants/domainLocales.d.ts +0 -2
  145. package/build/esm/interfaces/constants/index.d.ts +1 -1
  146. package/build/esm/interfaces/types/Locale.d.ts +1 -2
  147. package/build/esm/interfaces/types/index.d.ts +1 -2
  148. package/build/esm/{labelSorting-af5bf1b1.js → labelSorting-2e2b4521.js} +4 -4
  149. package/build/esm/lead/helpers.d.ts +1 -56
  150. package/build/esm/lead/index.d.ts +1 -2
  151. package/build/esm/lead/layouts/lightbox/formContext.d.ts +1 -2
  152. package/build/esm/lead/services/index.d.ts +0 -19
  153. package/build/esm/lead/store/index.d.ts +0 -1
  154. package/build/esm/lead.css +1 -1
  155. package/build/esm/lead.js +995 -2191
  156. package/build/esm/{logoIcon-48572541.js → logoIcon-82673d69.js} +2 -8
  157. package/build/esm/mantine.js +25 -25
  158. package/build/esm/misc.js +17 -17
  159. package/build/esm/miscGetDynamicHealthTool.js +4 -4
  160. package/build/esm/miscGetSocialList.js +8 -8
  161. package/build/esm/miscScreenSizeContext.js +1 -1
  162. package/build/esm/mobileBottomNavigation.js +5 -5
  163. package/build/esm/mobileBottomNavigationIcon.js +5 -5
  164. package/build/esm/molecules.js +73 -73
  165. package/build/esm/moleculesArticleCard.js +6 -6
  166. package/build/esm/moleculesArticleCardV2.js +16 -16
  167. package/build/esm/navigation.js +45 -45
  168. package/build/esm/navigationLogoutPopup.js +9 -9
  169. package/build/esm/navigationProfileButton.js +23 -23
  170. package/build/esm/onboardingV2.js +29 -29
  171. package/build/esm/organisms.js +49 -49
  172. package/build/esm/{post-5ecb65c5.js → post-b303aabc.js} +2 -2
  173. package/build/esm/profileNavigation.js +19 -19
  174. package/build/esm/progressBar.js +1 -1
  175. package/build/esm/pwg.js +22 -22
  176. package/build/esm/ssoV2/api/featureFlag.d.ts +1 -2
  177. package/build/esm/ssoV2.js +39 -51
  178. package/build/esm/{store-18fd61ec.js → store-906da6e3.js} +4 -4
  179. package/build/esm/subot.js +35 -35
  180. package/build/esm/surveyOrPremiumBanner.js +32 -32
  181. package/build/esm/surveyQuestionCard.js +10 -10
  182. package/build/esm/{surveyThankyouCard-6c4ba9c3.js → surveyThankyouCard-d56a88b7.js} +5 -5
  183. package/build/esm/together.js +55 -55
  184. package/build/esm/togetherApiUtils.js +4 -4
  185. package/build/esm/togetherAtoms.js +30 -30
  186. package/build/esm/togetherComponentGlobalContext.js +4 -4
  187. package/build/esm/togetherMolecules.js +50 -50
  188. package/build/esm/togetherMoleculesCardAuthor.js +28 -28
  189. package/build/esm/togetherMoleculesPostImagePreview.js +11 -11
  190. package/build/esm/togetherMoleculesProfileDetail.js +38 -38
  191. package/build/esm/togetherOrganisms.js +49 -49
  192. package/build/esm/togetherRichTextEditor.js +17 -17
  193. package/build/esm/togetherShareBox.js +10 -10
  194. package/build/esm/{treePopoverMenu-d2e708d8.js → treePopoverMenu-a764e8b3.js} +19 -19
  195. package/build/esm/{types-2c7ea5b1.js → types-1732e205.js} +2 -2
  196. package/build/esm/types.js +2 -2
  197. package/build/esm/{useCategory-98903303.js → useCategory-f344e24b.js} +5 -18
  198. package/build/esm/{useHealthToolCache-c0de2d5a.js → useHealthToolCache-611a21f2.js} +1 -1
  199. package/build/esm/{useMantineLocale-3dcc1724.js → useMantineLocale-2648ca03.js} +6 -8
  200. package/build/esm/{usePlacesAutocomplete-bfb0db64.js → usePlacesAutocomplete-e6a27296.js} +1 -1
  201. package/build/esm/{useScreenSize-cc7d6c7a.js → useScreenSize-34cbd783.js} +2 -2
  202. package/build/esm/useTogetherAuthRequiredAction.js +9 -9
  203. package/build/esm/{utils-fd471902.js → utils-0b69d7c1.js} +2 -2
  204. package/build/esm/{utils-6e5d68e8.js → utils-786037e3.js} +2 -2
  205. package/build/esm/{utils-064598a5.js → utils-b4cfd8d0.js} +3 -3
  206. package/build/esm/{utils-cedbce5b.js → utils-bd8204f1.js} +4 -4
  207. package/build/esm/vaccination.js +21 -21
  208. package/build/footer.js +21 -21
  209. package/build/gAssets.js +2 -2
  210. package/build/{healthTools-0dc6a117.js → healthTools-ea6e9b1a.js} +1 -1
  211. package/build/healthToolsCardWrapper.js +18 -18
  212. package/build/healthToolsForm.js +33 -33
  213. package/build/hooks.js +13 -13
  214. package/build/i18n.js +56 -16
  215. package/build/i18nV2.js +1 -1
  216. package/build/{index-4aef88ff.js → index-02ec2ce8.js} +1 -1
  217. package/build/{index-f519625e.js → index-03843c98.js} +27 -36
  218. package/build/{index-d4cc55d5.js → index-0569146b.js} +2 -2
  219. package/build/{index-04498acf.js → index-05d7e388.js} +16 -16
  220. package/build/{index-0f337c0c.js → index-09a4fdcc.js} +2 -2
  221. package/build/{index-e4c4a47e.js → index-0d7e63f1.js} +2 -2
  222. package/build/{index-5367382b.js → index-0f3397db.js} +24 -24
  223. package/build/{index-1badbcf0.js → index-1126e8c3.js} +13 -13
  224. package/build/{index-9f76eff8.js → index-1daa798a.js} +2 -2
  225. package/build/{index-920ce764.js → index-1f1f0c5c.js} +6 -6
  226. package/build/{index-51226aea.js → index-1f2581dc.js} +16 -16
  227. package/build/{index-7280eafc.js → index-211155ad.js} +7 -7
  228. package/build/{index-ad640b16.js → index-2ac06f25.js} +1 -1
  229. package/build/{index-9a3f589b.js → index-2d183ddd.js} +21 -21
  230. package/build/{index-956f121c.js → index-30445f01.js} +3 -3
  231. package/build/{index-8ad0770c.js → index-313986f8.js} +2 -39
  232. package/build/{index-b30545be.js → index-3521b764.js} +2 -2
  233. package/build/{index-3a2dcdb1.js → index-3802f7d1.js} +2 -2
  234. package/build/{index-ca360d1b.js → index-3879b270.js} +32 -32
  235. package/build/{index-5dcab081.js → index-3a00a873.js} +6 -6
  236. package/build/{index-22677d6f.js → index-3a860bc9.js} +18 -18
  237. package/build/{index-477103d5.js → index-3b36be31.js} +17 -17
  238. package/build/{index-103b6d52.js → index-3d634a4e.js} +15 -15
  239. package/build/{index-01925084.js → index-45b7f806.js} +13 -13
  240. package/build/{index-4f9a53eb.js → index-46410bb9.js} +25 -25
  241. package/build/{index-d766b652.js → index-465c24d5.js} +3 -3
  242. package/build/{index-f7b562d7.js → index-4a9a2c03.js} +5 -5
  243. package/build/{index-588763ca.js → index-53923d20.js} +2 -2
  244. package/build/{index-6ae674be.js → index-54823cfb.js} +13 -13
  245. package/build/{index-e06e527b.js → index-5ce573da.js} +10 -10
  246. package/build/{index-7021af67.js → index-674c1e8f.js} +6 -6
  247. package/build/{index-a5b6bf95.js → index-6929b526.js} +6 -6
  248. package/build/{index-1ec23a8c.js → index-6b4e8c24.js} +1 -1
  249. package/build/{index-704521de.js → index-780b89ca.js} +2 -2
  250. package/build/{index-c88eca7a.js → index-781d5c05.js} +2 -2
  251. package/build/{index-379d705c.js → index-8249ac09.js} +1 -1
  252. package/build/{index-09051bb1.js → index-82f50b82.js} +13 -13
  253. package/build/{index-25405264.js → index-862151dc.js} +3 -3
  254. package/build/{index-e37e8c94.js → index-872cfb2b.js} +2 -2
  255. package/build/{index-549d3920.js → index-88e57242.js} +3 -3
  256. package/build/{index-ba2f1673.js → index-9311a66a.js} +3 -3
  257. package/build/{index-2bea9f69.js → index-9aaa0051.js} +1 -1
  258. package/build/{index-5ef55da1.js → index-9bbc1cc0.js} +2 -2
  259. package/build/{index-c5193758.js → index-9cfb6f01.js} +1 -1
  260. package/build/{index-c7b180a8.js → index-9ffc892e.js} +32 -32
  261. package/build/{index-d9db5903.js → index-ac236671.js} +1 -1
  262. package/build/{index-e76a2d6b.js → index-ad3fac95.js} +17 -17
  263. package/build/{index-8f7e7733.js → index-ad7af6c9.js} +2 -2
  264. package/build/{index-1c224e52.js → index-b1ff851d.js} +6 -6
  265. package/build/{index-1e7383be.js → index-b5b2f96c.js} +1 -1
  266. package/build/{index-da72b1e4.js → index-b6cf7572.js} +5 -5
  267. package/build/{index-f7a352ec.js → index-b7230632.js} +16 -16
  268. package/build/{index-3424b721.js → index-c001a050.js} +1 -1
  269. package/build/{index-5d752841.js → index-c880f609.js} +17 -17
  270. package/build/{index-e90fd8b1.js → index-ced4a459.js} +2 -2
  271. package/build/{index-abf4568e.js → index-d3458e6c.js} +18 -18
  272. package/build/{index-50f21f67.js → index-d47f22b8.js} +22 -22
  273. package/build/{index-03dd0804.js → index-d54c5bff.js} +31 -31
  274. package/build/{index-ce264aab.js → index-e7bb57be.js} +4 -4
  275. package/build/{index-5eab3cf1.js → index-eb122fd8.js} +8 -8
  276. package/build/{index-695380e6.js → index-ecb288e0.js} +3 -3
  277. package/build/{index-8b3c6bb6.js → index-eea151e5.js} +17 -17
  278. package/build/{index-c03d5b05.js → index-f1cc4236.js} +7 -7
  279. package/build/{index-d3aa7ac9.js → index-f8b6c1a4.js} +16 -16
  280. package/build/index.js +117 -117
  281. package/build/interfaces/constants/domainLocales.d.ts +0 -2
  282. package/build/interfaces/constants/index.d.ts +1 -1
  283. package/build/interfaces/types/Locale.d.ts +1 -2
  284. package/build/interfaces/types/index.d.ts +1 -2
  285. package/build/{labelSorting-f0a2b329.js → labelSorting-91e042b2.js} +4 -4
  286. package/build/lead/helpers.d.ts +1 -56
  287. package/build/lead/index.d.ts +1 -2
  288. package/build/lead/layouts/lightbox/formContext.d.ts +1 -2
  289. package/build/lead/services/index.d.ts +0 -19
  290. package/build/lead/store/index.d.ts +0 -1
  291. package/build/lead.css +1 -1
  292. package/build/lead.js +997 -2194
  293. package/build/{logoIcon-abf47ead.js → logoIcon-0d6bf2cb.js} +2 -8
  294. package/build/mantine.js +22 -22
  295. package/build/misc.js +17 -17
  296. package/build/miscGetDynamicHealthTool.js +4 -4
  297. package/build/miscGetSocialList.js +8 -8
  298. package/build/miscScreenSizeContext.js +1 -1
  299. package/build/mobileBottomNavigation.js +5 -5
  300. package/build/mobileBottomNavigationIcon.js +5 -5
  301. package/build/molecules.js +73 -73
  302. package/build/moleculesArticleCard.js +6 -6
  303. package/build/moleculesArticleCardV2.js +16 -16
  304. package/build/navigation.js +45 -45
  305. package/build/navigationLogoutPopup.js +9 -9
  306. package/build/navigationProfileButton.js +23 -23
  307. package/build/onboardingV2.js +28 -28
  308. package/build/organisms.js +49 -49
  309. package/build/{post-e39c948f.js → post-0a654de4.js} +2 -2
  310. package/build/profileNavigation.js +19 -19
  311. package/build/progressBar.js +1 -1
  312. package/build/pwg.js +22 -22
  313. package/build/ssoV2/api/featureFlag.d.ts +1 -2
  314. package/build/ssoV2.js +37 -49
  315. package/build/{store-19496022.js → store-4f2a5549.js} +4 -4
  316. package/build/subot.js +34 -34
  317. package/build/surveyOrPremiumBanner.js +32 -32
  318. package/build/surveyQuestionCard.js +10 -10
  319. package/build/{surveyThankyouCard-c4a46538.js → surveyThankyouCard-df7eca0d.js} +5 -5
  320. package/build/together.js +55 -55
  321. package/build/togetherApiUtils.js +4 -4
  322. package/build/togetherAtoms.js +30 -30
  323. package/build/togetherComponentGlobalContext.js +4 -4
  324. package/build/togetherMolecules.js +50 -50
  325. package/build/togetherMoleculesCardAuthor.js +28 -28
  326. package/build/togetherMoleculesPostImagePreview.js +11 -11
  327. package/build/togetherMoleculesProfileDetail.js +38 -38
  328. package/build/togetherOrganisms.js +49 -49
  329. package/build/togetherRichTextEditor.js +17 -17
  330. package/build/togetherShareBox.js +10 -10
  331. package/build/{treePopoverMenu-452d5155.js → treePopoverMenu-6d84be70.js} +19 -19
  332. package/build/{types-2aa2c266.js → types-25f74bad.js} +2 -2
  333. package/build/types.js +2 -2
  334. package/build/{useCategory-4efd9a6a.js → useCategory-45d025d3.js} +5 -18
  335. package/build/{useHealthToolCache-e5fe0a19.js → useHealthToolCache-45e11da8.js} +1 -1
  336. package/build/{useMantineLocale-481b8a13.js → useMantineLocale-641ac8c6.js} +6 -8
  337. package/build/{usePlacesAutocomplete-26f79d1c.js → usePlacesAutocomplete-8554270f.js} +1 -1
  338. package/build/{useScreenSize-03cd2dde.js → useScreenSize-f2c93dfe.js} +2 -2
  339. package/build/useTogetherAuthRequiredAction.js +9 -9
  340. package/build/{utils-be9f0bd7.js → utils-0204d947.js} +2 -2
  341. package/build/{utils-abfdf38e.js → utils-55730e46.js} +4 -4
  342. package/build/{utils-4addbbdb.js → utils-7a0cd70f.js} +2 -2
  343. package/build/{utils-10a24a63.js → utils-c7cc1f19.js} +3 -3
  344. package/build/vaccination.js +21 -21
  345. package/package.json +3 -3
  346. package/build/components/mantine/phoneInput/PhoneInput.d.ts +0 -17
  347. package/build/components/mantine/phoneInput/index.d.ts +0 -1
  348. package/build/esm/components/mantine/phoneInput/PhoneInput.d.ts +0 -17
  349. package/build/esm/components/mantine/phoneInput/index.d.ts +0 -1
  350. package/build/esm/i18n-values/zh-CN.js +0 -855
  351. package/build/esm/lead/LeadGen.type.d.ts +0 -31
  352. package/build/esm/lead/LeadGenForm/LeadGenForm.d.ts +0 -41
  353. package/build/esm/lead/LeadGenForm/LeadGenForm.helpers.d.ts +0 -2
  354. package/build/esm/lead/LeadGenForm/LeadGenForm.styled.d.ts +0 -5
  355. package/build/esm/lead/LeadGenForm/LeadGenFormPhone.d.ts +0 -17
  356. package/build/esm/lead/LeadGenForm/LeadGenThankYou.d.ts +0 -20
  357. package/build/esm/lead/LeadGenForm/index.d.ts +0 -3
  358. package/build/esm/lead/LeadGenForm/textField/index.d.ts +0 -13
  359. package/build/esm/lead/LeadGenForm/textField/index.styled.d.ts +0 -11
  360. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +0 -63
  361. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +0 -4
  362. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +0 -21
  363. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +0 -3
  364. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +0 -23
  365. package/build/esm/lead/LeadGenSubscriptionBox/index.d.ts +0 -1
  366. package/build/esm/lead/LeadGenTranslationContext.d.ts +0 -6
  367. package/build/esm/translationsProvider-058aa9f4.js +0 -55
  368. package/build/i18n-values/zh-CN.js +0 -866
  369. package/build/lead/LeadGen.type.d.ts +0 -31
  370. package/build/lead/LeadGenForm/LeadGenForm.d.ts +0 -41
  371. package/build/lead/LeadGenForm/LeadGenForm.helpers.d.ts +0 -2
  372. package/build/lead/LeadGenForm/LeadGenForm.styled.d.ts +0 -5
  373. package/build/lead/LeadGenForm/LeadGenFormPhone.d.ts +0 -17
  374. package/build/lead/LeadGenForm/LeadGenThankYou.d.ts +0 -20
  375. package/build/lead/LeadGenForm/index.d.ts +0 -3
  376. package/build/lead/LeadGenForm/textField/index.d.ts +0 -13
  377. package/build/lead/LeadGenForm/textField/index.styled.d.ts +0 -11
  378. package/build/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +0 -63
  379. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +0 -4
  380. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +0 -21
  381. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +0 -3
  382. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +0 -23
  383. package/build/lead/LeadGenSubscriptionBox/index.d.ts +0 -1
  384. package/build/lead/LeadGenTranslationContext.d.ts +0 -6
  385. package/build/translationsProvider-2988368b.js +0 -62
  386. /package/build/{BMI_BOYS.percentile.monthly-a94ca606.js → BMI_BOYS.percentile.monthly-8657c76a.js} +0 -0
  387. /package/build/{BMI_BOYS.percentile.weekly-836a362e.js → BMI_BOYS.percentile.weekly-f4dc0c4d.js} +0 -0
  388. /package/build/{BMI_BOYS.percentile.yearly-2da80d18.js → BMI_BOYS.percentile.yearly-3ca55467.js} +0 -0
  389. /package/build/{BMI_BOYS.zscore.monthly-ddabfd0d.js → BMI_BOYS.zscore.monthly-005bd4d2.js} +0 -0
  390. /package/build/{BMI_BOYS.zscore.weekly-44db2028.js → BMI_BOYS.zscore.weekly-8dc3f934.js} +0 -0
  391. /package/build/{BMI_BOYS.zscore.yearly-34644dac.js → BMI_BOYS.zscore.yearly-f3aa27f6.js} +0 -0
  392. /package/build/{BMI_GIRLS.percentile.monthly-e049696d.js → BMI_GIRLS.percentile.monthly-f0d63ea0.js} +0 -0
  393. /package/build/{BMI_GIRLS.percentile.weekly-17bc9a3f.js → BMI_GIRLS.percentile.weekly-89550f05.js} +0 -0
  394. /package/build/{BMI_GIRLS.percentile.yearly-8f603d39.js → BMI_GIRLS.percentile.yearly-fbdf6f62.js} +0 -0
  395. /package/build/{BMI_GIRLS.zscore.monthly-59affc15.js → BMI_GIRLS.zscore.monthly-ebcb1b0c.js} +0 -0
  396. /package/build/{BMI_GIRLS.zscore.weekly-6fcf7879.js → BMI_GIRLS.zscore.weekly-05b95ccc.js} +0 -0
  397. /package/build/{BMI_GIRLS.zscore.yearly-adf6fe1d.js → BMI_GIRLS.zscore.yearly-f1019188.js} +0 -0
  398. /package/build/{ChevronDown-c3f711b6.js → ChevronDown-8a456bfa.js} +0 -0
  399. /package/build/{Close-af38b8d8.js → Close-f5683b6c.js} +0 -0
  400. /package/build/{Google-89d9d352.js → Google-d8fbb79c.js} +0 -0
  401. /package/build/{HEAD CIRCUM_BOYS.percentile.monthly-41afcfce.js → HEAD CIRCUM_BOYS.percentile.monthly-0dabbe9a.js} +0 -0
  402. /package/build/{HEAD CIRCUM_BOYS.percentile.weekly-57391036.js → HEAD CIRCUM_BOYS.percentile.weekly-c8802a77.js} +0 -0
  403. /package/build/{HEAD CIRCUM_BOYS.percentile.yearly-c3f58e37.js → HEAD CIRCUM_BOYS.percentile.yearly-4a875ed6.js} +0 -0
  404. /package/build/{HEAD CIRCUM_BOYS.zscore.monthly-1e58b0be.js → HEAD CIRCUM_BOYS.zscore.monthly-985b1e26.js} +0 -0
  405. /package/build/{HEAD CIRCUM_BOYS.zscore.weekly-1cab9188.js → HEAD CIRCUM_BOYS.zscore.weekly-fce154c7.js} +0 -0
  406. /package/build/{HEAD CIRCUM_BOYS.zscore.yearly-c10f93fe.js → HEAD CIRCUM_BOYS.zscore.yearly-bb11148b.js} +0 -0
  407. /package/build/{HEAD CIRCUM_GIRLS.percentile.monthly-f3d4a5d0.js → HEAD CIRCUM_GIRLS.percentile.monthly-a2cfdbf7.js} +0 -0
  408. /package/build/{HEAD CIRCUM_GIRLS.percentile.weekly-13024b99.js → HEAD CIRCUM_GIRLS.percentile.weekly-8a05f050.js} +0 -0
  409. /package/build/{HEAD CIRCUM_GIRLS.percentile.yearly-31bd2df8.js → HEAD CIRCUM_GIRLS.percentile.yearly-654300c6.js} +0 -0
  410. /package/build/{HEAD CIRCUM_GIRLS.zscore.monthly-62c93cbe.js → HEAD CIRCUM_GIRLS.zscore.monthly-efc688a5.js} +0 -0
  411. /package/build/{HEAD CIRCUM_GIRLS.zscore.weekly-48764d7e.js → HEAD CIRCUM_GIRLS.zscore.weekly-c2a93f80.js} +0 -0
  412. /package/build/{HEAD CIRCUM_GIRLS.zscore.yearly-6ee35298.js → HEAD CIRCUM_GIRLS.zscore.yearly-a4cebc93.js} +0 -0
  413. /package/build/{HEIGHT_BOYS.percentile.monthly-cedda272.js → HEIGHT_BOYS.percentile.monthly-5ef11f01.js} +0 -0
  414. /package/build/{HEIGHT_BOYS.percentile.weekly-a7d3426e.js → HEIGHT_BOYS.percentile.weekly-8ed943db.js} +0 -0
  415. /package/build/{HEIGHT_BOYS.percentile.yearly-af32bacb.js → HEIGHT_BOYS.percentile.yearly-6978da52.js} +0 -0
  416. /package/build/{HEIGHT_BOYS.zscore.monthly-c1ec0f1a.js → HEIGHT_BOYS.zscore.monthly-fe7f2a83.js} +0 -0
  417. /package/build/{HEIGHT_BOYS.zscore.weekly-a99cd461.js → HEIGHT_BOYS.zscore.weekly-56770ae4.js} +0 -0
  418. /package/build/{HEIGHT_BOYS.zscore.yearly-65531c25.js → HEIGHT_BOYS.zscore.yearly-7f747c0d.js} +0 -0
  419. /package/build/{HEIGHT_GIRLS.percentile.monthly-c3c68ff1.js → HEIGHT_GIRLS.percentile.monthly-11ef591b.js} +0 -0
  420. /package/build/{HEIGHT_GIRLS.percentile.weekly-7789077e.js → HEIGHT_GIRLS.percentile.weekly-d5f902bd.js} +0 -0
  421. /package/build/{HEIGHT_GIRLS.percentile.yearly-c552b2cd.js → HEIGHT_GIRLS.percentile.yearly-b29fcf3f.js} +0 -0
  422. /package/build/{HEIGHT_GIRLS.zscore.monthly-f5c30e44.js → HEIGHT_GIRLS.zscore.monthly-c2b950c6.js} +0 -0
  423. /package/build/{HEIGHT_GIRLS.zscore.weekly-aa7359b8.js → HEIGHT_GIRLS.zscore.weekly-fafb77e5.js} +0 -0
  424. /package/build/{HEIGHT_GIRLS.zscore.yearly-a3121654.js → HEIGHT_GIRLS.zscore.yearly-51e2ac88.js} +0 -0
  425. /package/build/{Visible-c0e317b6.js → Visible-e68ad984.js} +0 -0
  426. /package/build/{WEIGHT_BOYS.percentile.monthly-546f7888.js → WEIGHT_BOYS.percentile.monthly-95579d1b.js} +0 -0
  427. /package/build/{WEIGHT_BOYS.percentile.weekly-38af0491.js → WEIGHT_BOYS.percentile.weekly-0d85437f.js} +0 -0
  428. /package/build/{WEIGHT_BOYS.percentile.yearly-f008340d.js → WEIGHT_BOYS.percentile.yearly-a68e7946.js} +0 -0
  429. /package/build/{WEIGHT_BOYS.zscore.monthly-e8802481.js → WEIGHT_BOYS.zscore.monthly-e2ab176e.js} +0 -0
  430. /package/build/{WEIGHT_BOYS.zscore.weekly-409ed8cf.js → WEIGHT_BOYS.zscore.weekly-ed00829a.js} +0 -0
  431. /package/build/{WEIGHT_BOYS.zscore.yearly-df392705.js → WEIGHT_BOYS.zscore.yearly-6c5f3d8d.js} +0 -0
  432. /package/build/{WEIGHT_GIRLS.percentile.monthly-524fe0d4.js → WEIGHT_GIRLS.percentile.monthly-a81b7004.js} +0 -0
  433. /package/build/{WEIGHT_GIRLS.percentile.weekly-81a69fd3.js → WEIGHT_GIRLS.percentile.weekly-927efb7f.js} +0 -0
  434. /package/build/{WEIGHT_GIRLS.percentile.yearly-020535af.js → WEIGHT_GIRLS.percentile.yearly-2e15c4ad.js} +0 -0
  435. /package/build/{WEIGHT_GIRLS.zscore.monthly-14b4e77b.js → WEIGHT_GIRLS.zscore.monthly-5ff1be24.js} +0 -0
  436. /package/build/{WEIGHT_GIRLS.zscore.weekly-5520f50e.js → WEIGHT_GIRLS.zscore.weekly-8e9d9fa1.js} +0 -0
  437. /package/build/{WEIGHT_GIRLS.zscore.yearly-25e801fa.js → WEIGHT_GIRLS.zscore.yearly-0711078f.js} +0 -0
  438. /package/build/{animation-ffcf687b.js → animation-f1d48882.js} +0 -0
  439. /package/build/{constants-459aab55.js → constants-26168815.js} +0 -0
  440. /package/build/{constants-75af6d16.js → constants-ec1dc828.js} +0 -0
  441. /package/build/{dataTransform-8d6c3c6f.js → dataTransform-795c88ab.js} +0 -0
  442. /package/build/{doctor-0c5af8d7.js → doctor-bd84be05.js} +0 -0
  443. /package/build/esm/{BMI_BOYS.percentile.monthly-98b80b28.js → BMI_BOYS.percentile.monthly-f87c0cec.js} +0 -0
  444. /package/build/esm/{BMI_BOYS.percentile.weekly-2fe6652f.js → BMI_BOYS.percentile.weekly-df88fe6a.js} +0 -0
  445. /package/build/esm/{BMI_BOYS.percentile.yearly-08013b35.js → BMI_BOYS.percentile.yearly-efab1e50.js} +0 -0
  446. /package/build/esm/{BMI_BOYS.zscore.monthly-98cafee7.js → BMI_BOYS.zscore.monthly-bca64885.js} +0 -0
  447. /package/build/esm/{BMI_BOYS.zscore.weekly-a2873e74.js → BMI_BOYS.zscore.weekly-c6b2fe02.js} +0 -0
  448. /package/build/esm/{BMI_BOYS.zscore.yearly-4f3248cd.js → BMI_BOYS.zscore.yearly-6e275a3f.js} +0 -0
  449. /package/build/esm/{BMI_GIRLS.percentile.monthly-e3a3a60e.js → BMI_GIRLS.percentile.monthly-e0af8146.js} +0 -0
  450. /package/build/esm/{BMI_GIRLS.percentile.weekly-67a60ae0.js → BMI_GIRLS.percentile.weekly-ab0faec2.js} +0 -0
  451. /package/build/esm/{BMI_GIRLS.percentile.yearly-f5289f0a.js → BMI_GIRLS.percentile.yearly-067f0d6e.js} +0 -0
  452. /package/build/esm/{BMI_GIRLS.zscore.monthly-ea2c6c7d.js → BMI_GIRLS.zscore.monthly-a9bd5e5b.js} +0 -0
  453. /package/build/esm/{BMI_GIRLS.zscore.weekly-31ebf715.js → BMI_GIRLS.zscore.weekly-a50beb6f.js} +0 -0
  454. /package/build/esm/{BMI_GIRLS.zscore.yearly-0f5cd13e.js → BMI_GIRLS.zscore.yearly-47a98d22.js} +0 -0
  455. /package/build/esm/{ChevronDown-d4216c49.js → ChevronDown-05754bcf.js} +0 -0
  456. /package/build/esm/{Close-a1570e5a.js → Close-9039a072.js} +0 -0
  457. /package/build/esm/{Google-836ba7ee.js → Google-c488a1bf.js} +0 -0
  458. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.monthly-c5b52221.js → HEAD CIRCUM_BOYS.percentile.monthly-5864cf59.js} +0 -0
  459. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.weekly-5939b5e3.js → HEAD CIRCUM_BOYS.percentile.weekly-48c99d09.js} +0 -0
  460. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.yearly-287b382c.js → HEAD CIRCUM_BOYS.percentile.yearly-c0c2b01a.js} +0 -0
  461. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.monthly-82522fd4.js → HEAD CIRCUM_BOYS.zscore.monthly-1fbdc3b5.js} +0 -0
  462. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.weekly-f888f299.js → HEAD CIRCUM_BOYS.zscore.weekly-12617919.js} +0 -0
  463. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.yearly-4fd9b4f0.js → HEAD CIRCUM_BOYS.zscore.yearly-2d4773af.js} +0 -0
  464. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.monthly-accd234c.js → HEAD CIRCUM_GIRLS.percentile.monthly-7eaf5b74.js} +0 -0
  465. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.weekly-11df9b57.js → HEAD CIRCUM_GIRLS.percentile.weekly-07718321.js} +0 -0
  466. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.yearly-832d6d96.js → HEAD CIRCUM_GIRLS.percentile.yearly-5c40e3ef.js} +0 -0
  467. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.monthly-d796cff8.js → HEAD CIRCUM_GIRLS.zscore.monthly-bbc744a0.js} +0 -0
  468. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.weekly-dbdfd713.js → HEAD CIRCUM_GIRLS.zscore.weekly-71c3530d.js} +0 -0
  469. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.yearly-bbd50143.js → HEAD CIRCUM_GIRLS.zscore.yearly-562448de.js} +0 -0
  470. /package/build/esm/{HEIGHT_BOYS.percentile.monthly-13bf1524.js → HEIGHT_BOYS.percentile.monthly-f229f4c1.js} +0 -0
  471. /package/build/esm/{HEIGHT_BOYS.percentile.weekly-ee262d0f.js → HEIGHT_BOYS.percentile.weekly-6372f64c.js} +0 -0
  472. /package/build/esm/{HEIGHT_BOYS.percentile.yearly-878b6fed.js → HEIGHT_BOYS.percentile.yearly-79b5c4cd.js} +0 -0
  473. /package/build/esm/{HEIGHT_BOYS.zscore.monthly-86a939d1.js → HEIGHT_BOYS.zscore.monthly-c25e6418.js} +0 -0
  474. /package/build/esm/{HEIGHT_BOYS.zscore.weekly-2314a0c1.js → HEIGHT_BOYS.zscore.weekly-c6164b2d.js} +0 -0
  475. /package/build/esm/{HEIGHT_BOYS.zscore.yearly-9c94c8e1.js → HEIGHT_BOYS.zscore.yearly-1ac79b25.js} +0 -0
  476. /package/build/esm/{HEIGHT_GIRLS.percentile.monthly-7590684f.js → HEIGHT_GIRLS.percentile.monthly-57be4fe7.js} +0 -0
  477. /package/build/esm/{HEIGHT_GIRLS.percentile.weekly-680b838e.js → HEIGHT_GIRLS.percentile.weekly-3bd60cda.js} +0 -0
  478. /package/build/esm/{HEIGHT_GIRLS.percentile.yearly-798c4744.js → HEIGHT_GIRLS.percentile.yearly-2392717d.js} +0 -0
  479. /package/build/esm/{HEIGHT_GIRLS.zscore.monthly-3e584eb1.js → HEIGHT_GIRLS.zscore.monthly-e4da0130.js} +0 -0
  480. /package/build/esm/{HEIGHT_GIRLS.zscore.weekly-e5d7976a.js → HEIGHT_GIRLS.zscore.weekly-398cab51.js} +0 -0
  481. /package/build/esm/{HEIGHT_GIRLS.zscore.yearly-494e461f.js → HEIGHT_GIRLS.zscore.yearly-0aa6db35.js} +0 -0
  482. /package/build/esm/{Visible-af1dbd44.js → Visible-fe1a671b.js} +0 -0
  483. /package/build/esm/{WEIGHT_BOYS.percentile.monthly-1ae7df4c.js → WEIGHT_BOYS.percentile.monthly-4fe46448.js} +0 -0
  484. /package/build/esm/{WEIGHT_BOYS.percentile.weekly-8c22f2be.js → WEIGHT_BOYS.percentile.weekly-61cd4679.js} +0 -0
  485. /package/build/esm/{WEIGHT_BOYS.percentile.yearly-becb5697.js → WEIGHT_BOYS.percentile.yearly-175962e7.js} +0 -0
  486. /package/build/esm/{WEIGHT_BOYS.zscore.monthly-0a194058.js → WEIGHT_BOYS.zscore.monthly-5b48638d.js} +0 -0
  487. /package/build/esm/{WEIGHT_BOYS.zscore.weekly-9145c833.js → WEIGHT_BOYS.zscore.weekly-f765de66.js} +0 -0
  488. /package/build/esm/{WEIGHT_BOYS.zscore.yearly-4fb5c591.js → WEIGHT_BOYS.zscore.yearly-2810ea3a.js} +0 -0
  489. /package/build/esm/{WEIGHT_GIRLS.percentile.monthly-2e282f8b.js → WEIGHT_GIRLS.percentile.monthly-edd22d58.js} +0 -0
  490. /package/build/esm/{WEIGHT_GIRLS.percentile.weekly-e69f82dc.js → WEIGHT_GIRLS.percentile.weekly-16b503c8.js} +0 -0
  491. /package/build/esm/{WEIGHT_GIRLS.percentile.yearly-c463294f.js → WEIGHT_GIRLS.percentile.yearly-b0f7b0e3.js} +0 -0
  492. /package/build/esm/{WEIGHT_GIRLS.zscore.monthly-e9990c7e.js → WEIGHT_GIRLS.zscore.monthly-bafd7336.js} +0 -0
  493. /package/build/esm/{WEIGHT_GIRLS.zscore.weekly-64fe359e.js → WEIGHT_GIRLS.zscore.weekly-13e3b15d.js} +0 -0
  494. /package/build/esm/{WEIGHT_GIRLS.zscore.yearly-299f776b.js → WEIGHT_GIRLS.zscore.yearly-cb2c7ca0.js} +0 -0
  495. /package/build/esm/{animation-de92eac9.js → animation-4e68b089.js} +0 -0
  496. /package/build/esm/{constants-f5042816.js → constants-8fa39e2b.js} +0 -0
  497. /package/build/esm/{constants-347788b2.js → constants-fbf3481e.js} +0 -0
  498. /package/build/esm/{dataTransform-50fd6ddf.js → dataTransform-0d67f5f8.js} +0 -0
  499. /package/build/esm/{doctor-11fffc6e.js → doctor-391af6d0.js} +0 -0
  500. /package/build/esm/{index-45e1c9a1.js → index-2795fa56.js} +0 -0
  501. /package/build/esm/{index-89498cd6.js → index-2e6714c4.js} +0 -0
  502. /package/build/esm/{index-664497df.js → index-348e7549.js} +0 -0
  503. /package/build/esm/{index-db6cad26.js → index-5400fc7b.js} +0 -0
  504. /package/build/esm/{index-06e4ca77.js → index-6cc7eff8.js} +0 -0
  505. /package/build/esm/{index-b8e1ece4.js → index-7320bb4e.js} +0 -0
  506. /package/build/esm/{index-2a8894e6.js → index-832b09c0.js} +0 -0
  507. /package/build/esm/{index-e7737ff7.js → index-c6c69fc7.js} +0 -0
  508. /package/build/esm/{index.styles-a1185717.js → index.styles-74d4cd9a.js} +0 -0
  509. /package/build/esm/{localizeNumberFormat-1fdb8aa8.js → localizeNumberFormat-5dadff83.js} +0 -0
  510. /package/build/esm/{normalizeLink-321e9bca.js → normalizeLink-9ad88b8a.js} +0 -0
  511. /package/build/esm/{number-1d1c965d.js → number-4874a84c.js} +0 -0
  512. /package/build/esm/{other-2483b757.js → other-c1d47dbe.js} +0 -0
  513. /package/build/esm/{paths-4600a9c1.js → paths-d493ff83.js} +0 -0
  514. /package/build/esm/{translationsContext-8c982b59.js → translationsContext-6860109f.js} +0 -0
  515. /package/build/esm/{tslib.es6-5338c038.js → tslib.es6-37ac3f80.js} +0 -0
  516. /package/build/esm/{types-d9ab84a2.js → types-bafec1d0.js} +0 -0
  517. /package/build/esm/{useIsInit-a4da83cb.js → useIsInit-a50d4693.js} +0 -0
  518. /package/build/esm/{useOutsideClick-cd806f77.js → useOutsideClick-6c8cc9bd.js} +0 -0
  519. /package/build/esm/{useScrollbarSize-abd71947.js → useScrollbarSize-10b6c5db.js} +0 -0
  520. /package/build/esm/{useUniqueId-58e62fe5.js → useUniqueId-add5ca42.js} +0 -0
  521. /package/build/esm/{utils-bad138ab.js → utils-fd0077ec.js} +0 -0
  522. /package/build/{index-ffba7b3c.js → index-3cfbcf67.js} +0 -0
  523. /package/build/{index-857c287a.js → index-4e5503ea.js} +0 -0
  524. /package/build/{index-e0e69a8c.js → index-6fa267ee.js} +0 -0
  525. /package/build/{index-0baf46a9.js → index-7a99b28f.js} +0 -0
  526. /package/build/{index-88d9a33b.js → index-a2652f78.js} +0 -0
  527. /package/build/{index-10d959d5.js → index-ab45e0ad.js} +0 -0
  528. /package/build/{index-222ea420.js → index-b9a8d994.js} +0 -0
  529. /package/build/{index-5a53d685.js → index-f3df447c.js} +0 -0
  530. /package/build/{index.styles-cdfc2015.js → index.styles-98bdc2ef.js} +0 -0
  531. /package/build/{localizeNumberFormat-bd72b6e3.js → localizeNumberFormat-6a6886ee.js} +0 -0
  532. /package/build/{normalizeLink-4f6ec0e4.js → normalizeLink-b31bd775.js} +0 -0
  533. /package/build/{number-75eec17b.js → number-144eafe9.js} +0 -0
  534. /package/build/{other-c454606b.js → other-bf9b4bcf.js} +0 -0
  535. /package/build/{paths-4d6918f2.js → paths-e9fc7b80.js} +0 -0
  536. /package/build/{translationsContext-03c93e26.js → translationsContext-a085d37d.js} +0 -0
  537. /package/build/{tslib.es6-5d29380d.js → tslib.es6-6a38b123.js} +0 -0
  538. /package/build/{types-cafd9617.js → types-33611582.js} +0 -0
  539. /package/build/{useIsInit-0773f875.js → useIsInit-330b1f95.js} +0 -0
  540. /package/build/{useOutsideClick-398b0bb1.js → useOutsideClick-e79b1002.js} +0 -0
  541. /package/build/{useScrollbarSize-1b60cab4.js → useScrollbarSize-1e7e0424.js} +0 -0
  542. /package/build/{useUniqueId-c9bbb0bd.js → useUniqueId-8da5848c.js} +0 -0
  543. /package/build/{utils-ce39dcb2.js → utils-80ddfe39.js} +0 -0
package/build/esm/lead.js CHANGED
@@ -1,48 +1,44 @@
1
- import { _ as __rest, a as __awaiter } from './tslib.es6-5338c038.js';
2
- import React__default, { createContext, useMemo, useEffect, useRef, useState, useContext, useCallback, forwardRef, useImperativeHandle, memo } from 'react';
3
- import { createStyles, Box, Button as Button$1, Input as Input$1, clsx, Autocomplete, Checkbox as Checkbox$1, Radio as Radio$1, Select as Select$1, TextInput, NumberInput as NumberInput$1, Portal, Transition, Overlay } from '@mantine/core';
1
+ import { _ as __rest, a as __awaiter } from './tslib.es6-37ac3f80.js';
2
+ import React__default, { createContext, useMemo, useEffect, useRef, useState, useContext, useCallback } from 'react';
3
+ import { createStyles, Box, Button as Button$1, Autocomplete, clsx, Input as Input$1, TextInput, NumberInput as NumberInput$1, Portal, Transition, Overlay } from '@mantine/core';
4
4
  import dayjs from 'dayjs';
5
5
  import debounce from 'lodash/debounce';
6
- import { createFormContext, useForm } from '@mantine/form';
7
- import { u as useTranslations } from './index-5b650465.js';
8
- import { T as TranslationsContext } from './translationsContext-8c982b59.js';
6
+ import { createFormContext } from '@mantine/form';
7
+ import { u as useTranslations } from './index-9f09262e.js';
8
+ import { T as TranslationsContext } from './translationsContext-6860109f.js';
9
9
  import { getCookie, setCookie } from './miscCookieHelper.js';
10
- import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-bad138ab.js';
11
- import { T as Text } from './index-0423b372.js';
12
- import { S as Select, d as Checkbox, I as Input, R as Radio, P as Phone, N as NumberInput, O as OTP } from './index-c3841e4d.js';
13
- import { D as DatePicker } from './index-6f990758.js';
14
- import { B as Button } from './index-8c90983b.js';
15
- import './index.styles-a1185717.js';
10
+ import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-fd0077ec.js';
11
+ import { T as Text } from './index-39835a89.js';
12
+ import { S as Select, d as Checkbox, I as Input, R as Radio, P as Phone, N as NumberInput, O as OTP } from './index-01a293ec.js';
13
+ import { D as DatePicker } from './index-e1a8672b.js';
14
+ import { B as Button } from './index-279897da.js';
15
+ import './index.styles-74d4cd9a.js';
16
16
  import { useClickOutside } from '@mantine/hooks';
17
- import './useMantineLocale-3dcc1724.js';
18
- import { C as COMMON_DATE_TRANSLATE_KEY } from './index-65f141c1.js';
19
- import './index-2a8894e6.js';
20
- import { Z as ZINDEX_SSO, I as ISO_FORMAT } from './index-370af621.js';
21
- import './other-2483b757.js';
22
- import './index-e40243b0.js';
23
- import { M as MAPPED_LOCALE } from './utils-fd471902.js';
24
- import { DateInput } from '@mantine/dates';
25
- import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-bfb0db64.js';
26
- import { H as Heading$1 } from './index-81ccb624.js';
27
- import { t as translationsMap$1 } from './translationsProvider-058aa9f4.js';
28
- import { L as LOCALE } from './Locale-dd2625fa.js';
17
+ import './useMantineLocale-2648ca03.js';
18
+ import './index-87fc69f5.js';
19
+ import './index-832b09c0.js';
20
+ import { Z as ZINDEX_SSO } from './index-52accd51.js';
21
+ import './other-c1d47dbe.js';
22
+ import './index-45c7be3c.js';
23
+ import { M as MAPPED_LOCALE } from './utils-0b69d7c1.js';
24
+ import '@mantine/dates';
25
+ import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-e6a27296.js';
26
+ import { H as Heading$1 } from './index-b520cbab.js';
29
27
  import { v1 } from 'uuid';
30
- import { parsePhoneNumber } from 'react-phone-number-input';
28
+ import { i as isVideo } from './index-2795fa56.js';
29
+ import { D as DrawerComponent } from './index-d9a5e563.js';
30
+ import { u as useScreenSize } from './useScreenSize-34cbd783.js';
31
+ import { createPortal } from 'react-dom';
32
+ import { css } from '@emotion/react';
31
33
  import styled from '@emotion/styled';
32
34
  import { theme } from './miscTheme.js';
33
- import { css } from '@emotion/react';
34
- import { T as TogetherComponentGlobalContext } from './utils-064598a5.js';
35
- import { i as isVideo } from './index-45e1c9a1.js';
36
- import { D as DrawerComponent } from './index-a7927623.js';
37
- import { u as useScreenSize } from './useScreenSize-cc7d6c7a.js';
38
- import { createPortal } from 'react-dom';
39
- import { B as Button$2 } from './index-97ca081d.js';
40
- import { I as InputDate } from './InputDate-fc760765.js';
41
- import { C as Close } from './Close-a1570e5a.js';
35
+ import { B as Button$2 } from './index-dfc48cf4.js';
36
+ import { C as Close } from './Close-9039a072.js';
42
37
  import '@hhgtech/icons/other';
43
38
  import '@mantine/carousel';
39
+ import './Locale-07134c93.js';
44
40
  import 'classnames';
45
- import './useUniqueId-58e62fe5.js';
41
+ import './useUniqueId-add5ca42.js';
46
42
  import './constantsSite.js';
47
43
  import '@hhgtech/icons/core';
48
44
  import '@mantine/notifications';
@@ -50,22 +46,6 @@ import './constantsDomainLocales.js';
50
46
  import './constantsIsProduction.js';
51
47
  import 'date-fns/locale';
52
48
  import './constantsRiskScreener.js';
53
- import './i18n-values/en-PH.js';
54
- import './i18n-values/hi-IN.js';
55
- import './i18n-values/id-ID.js';
56
- import './i18n-values/km-KH.js';
57
- import './i18n-values/ms-MY.js';
58
- import './i18n-values/my-MM.js';
59
- import './i18n-values/th-TH.js';
60
- import './i18n-values/tl-PH.js';
61
- import './i18n-values/vi-VN.js';
62
- import './i18n-values/vi-VN_MB.js';
63
- import './i18n-values/zh-TW.js';
64
- import './index-db6cad26.js';
65
- import 'slugify';
66
- import 'string-format';
67
- import './togetherApiPaths.js';
68
- import './constants-f5042816.js';
69
49
  import 'vaul';
70
50
 
71
51
  const LeadGenComponentContext = createContext({});
@@ -92,7 +72,7 @@ if (sessionStorage.getItem('insider_object')) {
92
72
  }
93
73
  const docLang = document.documentElement.lang;
94
74
  // TODO: country code
95
- const LEAD_LOCALE_DATA$1 = {
75
+ const LEAD_LOCALE_DATA = {
96
76
  'vi-VN': {
97
77
  popupLang: 'vi',
98
78
  countryCode: 'vn',
@@ -134,7 +114,7 @@ const LEAD_LOCALE_DATA$1 = {
134
114
  countryCodeNumber: 91,
135
115
  },
136
116
  };
137
- const LEAD_LOCALE = LEAD_LOCALE_DATA$1[docLang] || LEAD_LOCALE_DATA$1['vi-VN'];
117
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
138
118
  function LEAD_RESET_VAR() {
139
119
  // LEAD_CURRENT_URL = location.href.toLowerCase();
140
120
  LEAD_CURRENT_URL =
@@ -155,11 +135,6 @@ const LEAD_TIMEZONE_DATA = {
155
135
  9: 'Asia/Manila', // Philippines / Filipinos Site
156
136
  };
157
137
 
158
- const LEADGEN_ACTIONS = {
159
- SHOW: 'SHOW',
160
- SCROLL: 'SCROLL',
161
- TIME: 'TIME',
162
- };
163
138
  const LEADGEN_LAYOUT = {
164
139
  LightBoxA: 'LightBoxA',
165
140
  LightBoxB: 'LightBoxB',
@@ -189,10 +164,8 @@ const LEADGEN_BLOCK = {
189
164
  DropdownBlock: 'DropdownBlock',
190
165
  CheckboxBlock: 'CheckboxBlock',
191
166
  TncBlock: 'TncBlock',
192
- TitleBlock: 'TitleBlock',
193
- SubtitleBlock: 'SubtitleBlock',
194
167
  };
195
- const LEADGEN_BLOCK_INPUT = [
168
+ const LEADGEN_BLOCK_IN_FORM = [
196
169
  LEADGEN_BLOCK.TextBlock,
197
170
  LEADGEN_BLOCK.NumberBlock,
198
171
  LEADGEN_BLOCK.DateBlock,
@@ -207,59 +180,7 @@ const LEADGEN_BLOCK_INPUT = [
207
180
  LEADGEN_BLOCK.CheckboxBlock,
208
181
  LEADGEN_BLOCK.TncBlock,
209
182
  ];
210
- const leadGenFieldNamePhone = (listBlockAdded) => {
211
- return listBlockAdded
212
- .filter(({ name }) => [
213
- LEADGEN_BLOCK.PhoneBlock,
214
- LEADGEN_BLOCK.PhoneOtpBlock,
215
- LEADGEN_BLOCK.WhatsappOtpBlock,
216
- LEADGEN_BLOCK.ZaloOtpBlock,
217
- ].includes(name))
218
- .map(({ data }) => data.value);
219
- };
220
183
  const SSO_MAP_LEAD = ['name', 'email', 'birthday', 'phone', 'gender'];
221
- const LEAD_LOCALE_DATA = {
222
- 'vi-VN': {
223
- popupLang: 'vi',
224
- countryCode: 'vn',
225
- countryCodeNumber: 84,
226
- },
227
- 'id-ID': {
228
- popupLang: 'id',
229
- countryCode: 'id',
230
- countryCodeNumber: 62,
231
- },
232
- 'th-TH': {
233
- popupLang: 'th',
234
- countryCode: 'th',
235
- countryCodeNumber: 66,
236
- },
237
- 'ms-MY': {
238
- popupLang: 'ms',
239
- countryCode: 'my',
240
- countryCodeNumber: 60,
241
- },
242
- 'zh-TW': {
243
- popupLang: 'zh',
244
- countryCode: 'tw',
245
- countryCodeNumber: 886,
246
- },
247
- 'km-KH': {
248
- popupLang: 'km',
249
- countryCode: 'kh',
250
- countryCodeNumber: 855,
251
- },
252
- 'my-MM': {
253
- popupLang: 'my',
254
- countryCode: 'mm',
255
- countryCodeNumber: 95,
256
- },
257
- 'hi-IN': {
258
- popupLang: 'hi',
259
- countryCode: 'in',
260
- countryCodeNumber: 91,
261
- },
262
- };
263
184
  const mappingSSOToLead = (userInfoProps) => {
264
185
  var _a, _b;
265
186
  try {
@@ -275,7 +196,7 @@ const mappingSSOToLead = (userInfoProps) => {
275
196
  if (ssoKey === 'birthday') {
276
197
  const dob = dayjs(initValue, 'YYYY-MM-DD', true);
277
198
  if (dob.isValid()) {
278
- user.birthday = dob.toDate();
199
+ user.birthday = dob;
279
200
  }
280
201
  }
281
202
  else if (ssoKey === 'gender') {
@@ -298,66 +219,16 @@ const mappingSSOToLead = (userInfoProps) => {
298
219
  catch (error) {
299
220
  return;
300
221
  }
301
- };
302
- const formatCampaignDetail = (campaign) => {
303
- if (!campaign) {
304
- return {};
305
- }
306
- try {
307
- const { extra_fields, thank_you_image } = campaign || {};
308
- const { textBlocks: exTextBlocks, imageBlocks: exImageBlocks, listBlockAdded: exListBlockAdded, listBlockThankyou: exListBlockThankyou, actionBlocks: exActionBlocks, } = extra_fields;
309
- const textBlocks = JSON.parse(exTextBlocks);
310
- const imageBlocks = JSON.parse(exImageBlocks);
311
- const listBlockAdded = JSON.parse(exListBlockAdded);
312
- const listBlockThankyou = JSON.parse(exListBlockThankyou);
313
- const actionBlocks = JSON.parse(exActionBlocks);
314
- const ThankYouBlock = {
315
- image: { src: thank_you_image },
316
- };
317
- listBlockThankyou.forEach((block) => {
318
- const { name, data } = block || {};
319
- const { value: htmlText, align, newtab, url } = data || {};
320
- switch (name) {
321
- case LEADGEN_BLOCK.TitleBlock: {
322
- ThankYouBlock.title = { htmlText, align };
323
- }
324
- case LEADGEN_BLOCK.SubtitleBlock: {
325
- ThankYouBlock.description = { htmlText, align };
326
- }
327
- case LEADGEN_BLOCK.LinkButtonBlock: {
328
- ThankYouBlock.button = { htmlText, newtab, url };
329
- }
330
- }
331
- });
332
- return Object.assign(Object.assign({}, campaign), { extra_fields: Object.assign(Object.assign({}, extra_fields), { textBlocks,
333
- imageBlocks,
334
- listBlockAdded,
335
- listBlockThankyou,
336
- actionBlocks }), ThankYouBlock });
337
- }
338
- catch (error) {
339
- return {};
340
- }
341
222
  };
342
223
 
343
224
  class Store {
344
225
  constructor() {
345
- this.apiSsoUrl = 'https://staging-id.hellobacsi.com/';
346
226
  this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
347
227
  this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
348
228
  }
349
229
  }
350
230
  const leadStore = new Store();
351
231
 
352
- const LEADGEN_API_METHOD = {
353
- GET: 'get',
354
- POST: 'POST',
355
- };
356
- const LEADGEN_API_PATH = {
357
- V2_CAMPAIGN: 'api/v2/campaign',
358
- V2_SUBSCRIPTION_LEAD: 'api/v2/subscription-box',
359
- V2_SUBSCRIPTION_INFO: 'api/campaign/get-title',
360
- };
361
232
  const leadApi = {
362
233
  call(_a) {
363
234
  var { url, data = undefined } = _a, config = __rest(_a, ["url", "data"]);
@@ -461,50 +332,8 @@ const verifyOtpLead = ({ phone, otp, type, }) => {
461
332
  },
462
333
  });
463
334
  };
464
- const getCampaignByCode = (campaign_code) => {
465
- return leadApi.call({
466
- url: `${LEADGEN_API_PATH.V2_CAMPAIGN}/${campaign_code}`,
467
- method: LEADGEN_API_METHOD.GET,
468
- });
469
- };
470
- const getSubscriptionBoxInfo = ({ category, site, }) => {
471
- return leadApi.call({
472
- url: `${LEADGEN_API_PATH.V2_SUBSCRIPTION_INFO}?category=${category}&site=${site}`,
473
- method: LEADGEN_API_METHOD.GET,
474
- });
475
- };
476
- const postSubscriptionBoxLead = ({ data }) => {
477
- return leadApi.call({
478
- url: LEADGEN_API_PATH.V2_SUBSCRIPTION_LEAD,
479
- method: LEADGEN_API_METHOD.POST,
480
- data,
481
- });
482
- };
483
- const postUserInfoFromLeadGen = ({}) => {
484
- return;
485
- };
486
- const campaignPostImpression = ({ code, action, title_article, ga_client_id, cookie_id, extra, url, referrer, }) => {
487
- return leadApi.call({
488
- url: `api/campaign/${code}/impression`,
489
- method: LEADGEN_API_METHOD.POST,
490
- data: {
491
- action,
492
- title_article,
493
- cookie_id,
494
- ga_client_id,
495
- url,
496
- extra,
497
- referrer,
498
- },
499
- });
500
- };
501
335
  const Service = {
502
336
  campaignGetById,
503
- getCampaignByCode,
504
- getSubscriptionBoxInfo,
505
- postSubscriptionBoxLead,
506
- postUserInfoFromLeadGen,
507
- campaignPostImpression,
508
337
  validateEmailOrPhoneOnSubot,
509
338
  validateEmailOrPhoneOnLeadGen,
510
339
  validatePhoneNumberOnLeadGen,
@@ -844,7 +673,7 @@ const Description = (_a) => {
844
673
  return description ? (React__default.createElement(Text, Object.assign({ size: "p3" }, rest), description)) : null;
845
674
  };
846
675
 
847
- const LeadGenContext$1 = createContext({});
676
+ const LeadGenContext = createContext({});
848
677
 
849
678
  var useStyles$2 = createStyles(() => {
850
679
  return {
@@ -908,7 +737,7 @@ const SubtitleBlock$1 = ({ children, align, }) => (React__default.createElement(
908
737
  const TitleBlock$1 = ({ children, align, }) => (React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
909
738
 
910
739
  const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, popoverProps, }) => {
911
- const { primaryColor } = useContext(LeadGenContext$1);
740
+ const { primaryColor } = useContext(LeadGenContext);
912
741
  const { classes, cx } = useStyles$2(undefined, {
913
742
  name: 'LeadGen__Field',
914
743
  styles,
@@ -1023,7 +852,7 @@ const Heading = (_a) => {
1023
852
 
1024
853
  const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps, submitProps, }) => {
1025
854
  var _a;
1026
- const { primaryColor } = useContext(LeadGenContext$1);
855
+ const { primaryColor } = useContext(LeadGenContext);
1027
856
  const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, setFormRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = useContext(LeadGenComponentContext);
1028
857
  const { classes, cx } = useStyles$1(undefined, {
1029
858
  name: 'LeadGen__FormComponent',
@@ -1300,7 +1129,6 @@ var enPH = {
1300
1129
  "validator.min": "jQuery.validator.format('Please enter a value greater than or equal to {0}.",
1301
1130
  "validator.emailUsed": "Email already in use for this campaign.",
1302
1131
  "validator.phoneUsed": "Your phone number already in use for this campaign.",
1303
- "validator.dateInvalid": "This date is not valid, please update.",
1304
1132
  "lead.otp.title": "Enter OTP",
1305
1133
  "lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
1306
1134
  "lead.otp.verify": "Verify",
@@ -1309,10 +1137,7 @@ var enPH = {
1309
1137
  "lead.otp.phonePlaceholder": "Enter OTP",
1310
1138
  "lead.empty.title": "Oops, seem your information is empty, do you want to submit the information again?",
1311
1139
  "lead.empty.cancel": "Cancel",
1312
- "lead.empty.submitAgain": "Submit again",
1313
- "common.day": "Day",
1314
- "common.month": "Month",
1315
- "common.year": "Year"
1140
+ "lead.empty.submitAgain": "Submit again"
1316
1141
  };
1317
1142
 
1318
1143
  var hiIN = {
@@ -1323,7 +1148,6 @@ var hiIN = {
1323
1148
  "validator.maxlength": "कृपया {0} अक्षर से अधिक दर्ज न करें",
1324
1149
  "validator.minlength": "कृपया कम से कम {0} अक्षर दर्ज करें",
1325
1150
  "validator.phone": "कृपया एक वैध संख्या दर्ज करें",
1326
- "validator.dateInvalid": "यह तिथि मान्य नहीं है, कृपया अपडेट करें।",
1327
1151
  "validator.emailUsed": "Email already in use for this campaign.",
1328
1152
  "validator.phoneUsed": "Your phone number already in use for this campaign.",
1329
1153
  "lead.otp.title": "Enter OTP",
@@ -1332,10 +1156,7 @@ var hiIN = {
1332
1156
  "lead.otp.resend": "Resend OTP{timer}",
1333
1157
  "lead.empty.title": "ऊप्स! लगता है आपकी जानकारी खाली है। क्या आप जानकारी फिर से सबमिट करना चाहते हैं?",
1334
1158
  "lead.empty.cancel": "रद्द करें",
1335
- "lead.empty.submitAgain": "फिर से सबमिट करें",
1336
- "common.day": "साल",
1337
- "common.month": "महीना",
1338
- "common.year": ""
1159
+ "lead.empty.submitAgain": "फिर से सबमिट करें"
1339
1160
  };
1340
1161
 
1341
1162
  var idID = {
@@ -1348,7 +1169,6 @@ var idID = {
1348
1169
  "validator.phone": "Tolong daftarkan nomor telepon yang valid",
1349
1170
  "validator.emailUsed": "Email sudah digunakan untuk kampanye ini.",
1350
1171
  "validator.phoneUsed": "Nomor telepon Anda sudah digunakan untuk kampanye ini.",
1351
- "validator.dateInvalid": "Tanggal ini tidak valid, silakan perbarui",
1352
1172
  "lead.otp.title": "Masukkan OTP",
1353
1173
  "lead.otp.desc": "Kami telah mengirimkan OTP ke nomor ponsel Anda {phone}",
1354
1174
  "lead.otp.verify": "Verifikasi",
@@ -1357,10 +1177,7 @@ var idID = {
1357
1177
  "lead.otp.phonePlaceholder": "Masukkan OTP",
1358
1178
  "lead.empty.title": "Oops, sepertinya informasi Anda kosong. Apakah Anda ingin mengirimkan informasi lagi?",
1359
1179
  "lead.empty.cancel": "Batal",
1360
- "lead.empty.submitAgain": "Kirim lagi",
1361
- "common.day": "Hari",
1362
- "common.month": "Bulan",
1363
- "common.year": "Tahun"
1180
+ "lead.empty.submitAgain": "Kirim lagi"
1364
1181
  };
1365
1182
 
1366
1183
  var kmKH = {
@@ -1373,7 +1190,6 @@ var kmKH = {
1373
1190
  "validator.phone": "សូម​វាយបញ្ចូល​លេខ​ឲ្យ​បាន​ត្រឹមត្រូវ",
1374
1191
  "validator.emailUsed": "អ៊ីមែលត្រូវបានប្រើប្រាស់សម្រាប់យុទ្ធនាការនេះរួចហើយ។",
1375
1192
  "validator.phoneUsed": "លេខទូរស័ព្ទរបស់អ្នកត្រូវបានប្រើប្រាស់សម្រាប់យុទ្ធនាការនេះរួចហើយ។",
1376
- "validator.dateInvalid": "កាលបរិច្ឆេទនេះមិនត្រឹមត្រូវទេ សូមធ្វើបច្ចុប្បន្នភាព។",
1377
1193
  "lead.otp.title": "បញ្ចូល OTP",
1378
1194
  "lead.otp.desc": "យើងបានផ្ញើ OTP ទៅកាន់លេខទូរសព្ទរបស់អ្នក {phone}",
1379
1195
  "lead.otp.verify": "ផ្ទៀងផ្ទាត់",
@@ -1382,10 +1198,7 @@ var kmKH = {
1382
1198
  "lead.otp.phonePlaceholder": "បញ្ចូល OTP",
1383
1199
  "lead.empty.title": "អូុបស! ហាក់ដូចជាព័ត៌មានរបស់អ្នកទទេ។ តើអ្នកចង់ដាក់ស្នើព័ត៌មានម្តងទៀតទេ?",
1384
1200
  "lead.empty.cancel": "លុប​ចោល",
1385
- "lead.empty.submitAgain": "ដាក់ស្នើម្ដងទៀត",
1386
- "common.day": "ឆ្នាំ",
1387
- "common.month": "ខែ",
1388
- "common.year": "ថ្ងៃ"
1201
+ "lead.empty.submitAgain": "ដាក់ស្នើម្ដងទៀត"
1389
1202
  };
1390
1203
 
1391
1204
  var msMY = {
@@ -1398,7 +1211,6 @@ var msMY = {
1398
1211
  "validator.phone": "Sila masukkan no telefon yang sah.",
1399
1212
  "validator.emailUsed": "Emel sudah digunakan untuk kempen ini.",
1400
1213
  "validator.phoneUsed": "Nombor telefon anda sudah digunakan untuk kempen ini.",
1401
- "validator.dateInvalid": "Tarikh ini tidak sah, sila kemas kini",
1402
1214
  "lead.otp.title": "Masukkan OTP",
1403
1215
  "lead.otp.desc": "Kami telah menghantar OTP ke nombor telefon bimbit anda {phone}",
1404
1216
  "lead.otp.verify": "Sahkan",
@@ -1407,10 +1219,7 @@ var msMY = {
1407
1219
  "lead.otp.phonePlaceholder": "Masukkan OTP",
1408
1220
  "lead.empty.title": "Oops, nampaknya maklumat anda kosong. Adakah anda ingin menghantar maklumat semula?",
1409
1221
  "lead.empty.cancel": "Batal",
1410
- "lead.empty.submitAgain": "Hantar semula",
1411
- "common.day": "Hari",
1412
- "common.month": "Bulan",
1413
- "common.year": "Tahun"
1222
+ "lead.empty.submitAgain": "Hantar semula"
1414
1223
  };
1415
1224
 
1416
1225
  var myMM = {
@@ -1423,7 +1232,6 @@ var myMM = {
1423
1232
  "validator.phone": "မှန်ကန်သော ဖုန်းနံပါတ်ထည့်သွင်းပါ",
1424
1233
  "validator.emailUsed": "ဤအေကာင့်အတွက် အီးမေးလ်ကို အသုံးပြုပြီးဖြစ်ပါသည်။",
1425
1234
  "validator.phoneUsed": "ဤအေကာင့်အတွက် သင့်ဖုန်းနံပါတ်ကို အသုံးပြုပြီးဖြစ်ပါသည်။",
1426
- "validator.dateInvalid": "ယနေ့စွဲမှားနေသည်၊ ကျေးဇူးပြု၍ ပြင်ဆင်ပါ။",
1427
1235
  "lead.otp.title": "OTP ကိုထည့်ပါ",
1428
1236
  "lead.otp.desc": "ကျွန်ုပ်တို့သည် OTP ကိုသင့်ဖုန်းနံပါတ် {phone} သို့ပို့ခဲ့သည်",
1429
1237
  "lead.otp.verify": "အတည်ပြုပါ",
@@ -1432,10 +1240,7 @@ var myMM = {
1432
1240
  "lead.otp.phonePlaceholder": "OTP ကိုထည့်ပါ",
1433
1241
  "lead.empty.title": "အုပ်စ်! သင့်အချက်အလက်သည် ဗလာဖြစ်နေသလိုဖြစ်သည်။ ထပ်မံတင်သွင်းလိုပါသလား?",
1434
1242
  "lead.empty.cancel": "မလုပ်ဆောင်ပါ",
1435
- "lead.empty.submitAgain": "ထပ်မံတင်သွင်းပါ",
1436
- "common.day": "ရက်",
1437
- "common.month": "လ",
1438
- "common.year": "နှစ်"
1243
+ "lead.empty.submitAgain": "ထပ်မံတင်သွင်းပါ"
1439
1244
  };
1440
1245
 
1441
1246
  var thTH = {
@@ -1448,7 +1253,6 @@ var thTH = {
1448
1253
  "validator.phone": "กรุณาใส่ตัวเลขที่ถูกต้อง",
1449
1254
  "validator.emailUsed": "อีเมลนี้ถูกใช้สำหรับแคมเปญนี้แล้ว",
1450
1255
  "validator.phoneUsed": "หมายเลขโทรศัพท์ของคุณถูกใช้สำหรับแคมเปญนี้แล้ว",
1451
- "validator.dateInvalid": "วันที่นี้ไม่ถูกต้อง โปรดอัปเดต",
1452
1256
  "lead.otp.title": "ป้อน OTP",
1453
1257
  "lead.otp.desc": "เราได้ส่ง OTP ไปยังหมายเลขโทรศัพท์มือถือของคุณ {phone}",
1454
1258
  "lead.otp.verify": "ยืนยัน",
@@ -1457,10 +1261,7 @@ var thTH = {
1457
1261
  "lead.otp.phonePlaceholder": "ป้อน OTP",
1458
1262
  "lead.empty.title": "อุ๊ปส์! ดูเหมือนว่าข้อมูลของคุณว่างเปล่า คุณต้องการส่งข้อมูลอีกครั้งหรือไม่?",
1459
1263
  "lead.empty.cancel": "ยกเลิก",
1460
- "lead.empty.submitAgain": "ส่งอีกครั้ง",
1461
- "common.day": "วัน",
1462
- "common.month": "เดือน",
1463
- "common.year": "ปี"
1264
+ "lead.empty.submitAgain": "ส่งอีกครั้ง"
1464
1265
  };
1465
1266
 
1466
1267
  var viVN = {
@@ -1484,7 +1285,6 @@ var viVN = {
1484
1285
  "validator.phone": "Nhập đúng định dạng số điện thoại",
1485
1286
  "validator.emailUsed": "Email này đã được sử dụng.",
1486
1287
  "validator.phoneUsed": "Số điện thoại này đã được sử dụng.",
1487
- "validator.dateInvalid": "Ngày này không hợp lệ, vui lòng cập nhật.",
1488
1288
  "lead.otp.title": "Nhập OTP",
1489
1289
  "lead.otp.desc": "Chúng tôi đã gửi OTP đến số điện thoại của bạn {phone}",
1490
1290
  "lead.otp.verify": "Xác minh",
@@ -1493,10 +1293,7 @@ var viVN = {
1493
1293
  "lead.otp.phonePlaceholder": "Nhập OTP",
1494
1294
  "lead.empty.title": "Oops, có vẻ như thông tin của bạn đang trống. Bạn có muốn gửi lại thông tin không?",
1495
1295
  "lead.empty.cancel": "Hủy",
1496
- "lead.empty.submitAgain": "Gửi lại",
1497
- "common.day": "Ngày",
1498
- "common.month": "Tháng",
1499
- "common.year": "Năm"
1296
+ "lead.empty.submitAgain": "Gửi lại"
1500
1297
  };
1501
1298
 
1502
1299
  var zhTW = {
@@ -1509,7 +1306,6 @@ var zhTW = {
1509
1306
  "validator.phone": "請填入有效的電話號碼",
1510
1307
  "validator.emailUsed": "此電子郵件已被使用於此活動。",
1511
1308
  "validator.phoneUsed": "您的手機號碼已被使用於此活動。",
1512
- "validator.dateInvalid": "此日期無效,請更新.",
1513
1309
  "lead.otp.title": "輸入 OTP",
1514
1310
  "lead.otp.desc": "我們已將 OTP 發送到您的手機號碼 {phone}",
1515
1311
  "lead.otp.verify": "驗證",
@@ -1518,10 +1314,7 @@ var zhTW = {
1518
1314
  "lead.otp.phonePlaceholder": "輸入 OTP",
1519
1315
  "lead.empty.title": "哎呀,您的資訊似乎是空的,您想要重新提交資訊嗎?",
1520
1316
  "lead.empty.cancel": "取消",
1521
- "lead.empty.submitAgain": "重新提交",
1522
- "common.day": "日",
1523
- "common.month": "月",
1524
- "common.year": "年"
1317
+ "lead.empty.submitAgain": "重新提交"
1525
1318
  };
1526
1319
 
1527
1320
  const translationsMap = {
@@ -1533,1589 +1326,63 @@ const translationsMap = {
1533
1326
  'my-MM': myMM,
1534
1327
  'km-KH': kmKH,
1535
1328
  'zh-TW': zhTW,
1536
- 'zh-CN': zhTW,
1537
1329
  'th-TH': thTH,
1538
1330
  'tl-PH': enPH,
1539
1331
  };
1540
1332
  const getTranslations = (locale) => {
1541
- const translations = Object.assign(Object.assign({}, translationsMap$1[locale]), translationsMap[locale]);
1333
+ const translations = translationsMap[locale];
1542
1334
  if (translations) {
1543
1335
  return translations;
1544
1336
  }
1545
1337
  return translationsMap['en-PH'];
1546
1338
  };
1547
1339
 
1548
- const LeadGenTranslationProvider = (props) => {
1549
- const { locale, children } = props;
1550
- const translationContextValue = useMemo(() => ({ locale, values: getTranslations(locale) }), [locale]);
1551
- return (React__default.createElement(TranslationsContext.Provider, { value: translationContextValue }, children));
1340
+ const useImageSize = (src) => {
1341
+ const [width, setWidth] = useState(16);
1342
+ const [height, setHeight] = useState(9);
1343
+ const [loaded, setLoaded] = useState(false);
1344
+ // load src image to get its width and height
1345
+ useEffect(() => {
1346
+ setLoaded(false);
1347
+ if (src) {
1348
+ const img = new Image();
1349
+ img.addEventListener('load', () => {
1350
+ setWidth(img.naturalWidth);
1351
+ setHeight(img.naturalHeight);
1352
+ setLoaded(true);
1353
+ });
1354
+ img.addEventListener('error', () => {
1355
+ setWidth(16);
1356
+ setHeight(9);
1357
+ setLoaded(true);
1358
+ });
1359
+ img.src = src;
1360
+ }
1361
+ else {
1362
+ setWidth(16);
1363
+ setHeight(9);
1364
+ setLoaded(true);
1365
+ }
1366
+ }, [src]);
1367
+ return {
1368
+ loaded,
1369
+ width,
1370
+ height,
1371
+ };
1552
1372
  };
1553
1373
 
1554
- // import mockLeadData from './mockLeadData'
1555
- const listCampaignScheduled = [];
1556
- const listCampaignScheduledToActivated = [];
1557
- const listCampaignActiveButExpired = [];
1558
- const listCampaignExcludeSonsored = [];
1559
- const listCampaignDifferentSponsor = [];
1560
- const listCampaignNotDisplayInRangeOfTime = [];
1561
- function isMobile() {
1562
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
1563
- }
1564
- const getShuffleArray = (array) => {
1565
- const newArray = [...array];
1566
- for (let i = newArray.length - 1; i > 0; i--) {
1567
- const j = Math.floor(Math.random() * (i + 1));
1568
- const temp = newArray[i];
1569
- newArray[i] = newArray[j];
1570
- newArray[j] = temp;
1571
- }
1572
- return newArray;
1573
- };
1574
- const getTimeByTimezone = (timeZone = 'UTC') => {
1575
- const date = new Date();
1576
- return new Date(date.toLocaleString('en-US', { timeZone }));
1577
- };
1578
- const parseDateByCampaignTime = (dateStr) => {
1579
- // Format like this: 2023-04-04 00:00:00
1580
- try {
1581
- const [datePart, timePart] = dateStr.split(' ');
1582
- const [year, month, day] = datePart.split('-').map(Number);
1583
- const [hours, minutes, seconds] = timePart.split(':').map(Number);
1584
- /** JavaScript counts months from 0 to 11 */
1585
- return new Date(year, month - 1, day, hours, minutes, seconds);
1586
- }
1587
- catch (err) {
1588
- return null;
1589
- }
1590
- };
1591
- const checkCampaignNowInTimeframe = (c) => {
1592
- var _a;
1593
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1594
- const startedAtStr = c.started_at;
1595
- const endedAtStr = c.ended_at;
1596
- const startedDate = parseDateByCampaignTime(startedAtStr);
1597
- const endedDate = parseDateByCampaignTime(endedAtStr);
1598
- if (!startedDate || !endedDate) {
1599
- return false;
1600
- }
1601
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
1602
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1603
- if (nowWithTimezoneMs <= endedDate.getTime() &&
1604
- nowWithTimezoneMs >= startedDate.getTime()) {
1605
- listCampaignScheduledToActivated.push(c);
1606
- return true;
1607
- }
1608
- return false;
1609
- };
1610
- function checkCampaignActiveButExpireAlready(c) {
1611
- var _a;
1612
- /** Do not setup timeframe for this campaign. No need to check */
1613
- if (c.forever === 1) {
1614
- return true;
1615
- }
1616
- const startedAtStr = c.started_at;
1617
- const endedAtStr = c.ended_at;
1618
- const startedDate = parseDateByCampaignTime(startedAtStr);
1619
- const endedDate = parseDateByCampaignTime(endedAtStr);
1620
- /** Do not setup timeframe for this campaign. No need to check */
1621
- if (!startedDate || !endedDate) {
1622
- return true;
1623
- }
1624
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1625
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
1626
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1627
- /** Check if this expire already, do not show */
1628
- if (nowWithTimezoneMs > endedDate.getTime()) {
1629
- listCampaignActiveButExpired.push(c);
1630
- return false;
1631
- }
1632
- return true;
1633
- }
1634
- function shouldNotDisplayIfExcludeAllSponsors(c) {
1635
- var _a;
1636
- const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
1637
- const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
1638
- if (isSponsored && excludeSponsored) {
1639
- listCampaignExcludeSonsored.push(c);
1640
- return true;
1641
- }
1642
- return false;
1643
- }
1644
- function shouldDisplayWithCurrentSponsor(c) {
1645
- var _a, _b;
1646
- try {
1647
- // TODO: BE will rename `exclude_sponsored_list` later
1648
- const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
1649
- const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
1650
- const dataSponsoredId = Number((_b = document
1651
- .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
1652
- // There is no config for sponsor id and white list, should show as default
1653
- if (!dataSponsoredId ||
1654
- dataSponsoredId <= 0 ||
1655
- whiteListSponsors.length === 0) {
1656
- return true;
1657
- }
1658
- // Check the dataSponsoredId exists in the white list or not.
1659
- const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
1660
- if (isExist) {
1661
- return true;
1662
- }
1663
- listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
1664
- return false;
1665
- }
1666
- catch (err) {
1667
- // Default is show
1668
- return true;
1669
- }
1670
- }
1671
- const filterFnCampaign = (c) => {
1672
- if (shouldNotDisplayIfExcludeAllSponsors(c)) {
1673
- return false;
1674
- }
1675
- else if (!shouldDisplayWithCurrentSponsor(c)) {
1676
- return false;
1677
- }
1678
- /** Active */
1679
- if (c.formatted_status === 1) {
1680
- return checkCampaignActiveButExpireAlready(c);
1681
- }
1682
- /** Schedule */
1683
- if (c.formatted_status === 0) {
1684
- listCampaignScheduled.push(c);
1685
- return checkCampaignNowInTimeframe(c);
1686
- }
1687
- return false;
1688
- };
1689
- const fillterApprearanceTimeCampaign = (c) => {
1690
- var _a;
1691
- try {
1692
- const isTimeInRange = (currentTime, startTime, endTime) => {
1693
- const startParts = startTime.split(':');
1694
- const endParts = endTime.split(':');
1695
- const startDate = new Date();
1696
- startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
1697
- const endDate = new Date();
1698
- endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
1699
- return currentTime >= startDate && currentTime <= endDate;
1700
- };
1701
- const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
1702
- const startTime = rulesApprValue.startTime;
1703
- const endTime = rulesApprValue.endTime || '23:59';
1704
- if (!startTime) {
1705
- return true;
1706
- }
1707
- if (isTimeInRange(new Date(), startTime, endTime)) {
1708
- return true;
1709
- }
1710
- listCampaignNotDisplayInRangeOfTime.push(c);
1711
- return false;
1712
- }
1713
- catch (err) {
1714
- return true;
1715
- }
1716
- };
1717
- let timeoutRef = null;
1718
- let LEAD_SCROLL_EVENT = null;
1719
- function clearPassiveEvent() {
1720
- if (timeoutRef) {
1721
- clearTimeout(timeoutRef);
1722
- timeoutRef = null;
1723
- }
1724
- if (LEAD_SCROLL_EVENT) {
1725
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1726
- LEAD_SCROLL_EVENT = null;
1727
- }
1728
- }
1729
- function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
1730
- // clear previous passive event, check for new condition
1731
- clearPassiveEvent();
1732
- const leadCurrentUrl = DEBUG_URL ||
1733
- ('https://' +
1734
- location.hostname +
1735
- location.pathname +
1736
- location.search).toLowerCase();
1737
- fetch(leadApi + 'api/campaign/' + leadSiteId, {
1738
- method: 'POST',
1739
- headers: {
1740
- 'Content-Type': 'application/json',
1741
- },
1742
- body: JSON.stringify({
1743
- url: leadCurrentUrl,
1744
- ga_client_id: getCookie('_ga') || null,
1745
- }),
1746
- })
1747
- .then((response) => {
1748
- return response.json();
1749
- // return mockLeadData || response.json()
1750
- })
1751
- .then((data) => {
1752
- var _a, _b, _c, _d;
1753
- LeadLog('List campagin: ', data);
1754
- LEAD_RESET_VAR();
1755
- if (data._status == 1) {
1756
- const campaigns = (((_b = (_a = data._data) === null || _a === void 0 ? void 0 : _a.campaigns) === null || _b === void 0 ? void 0 : _b.filter(filterFnCampaign)) || []).filter(fillterApprearanceTimeCampaign);
1757
- if (!getCookie('hhg-id')) {
1758
- setCookie('hhg-id', v1(), {
1759
- domain: '.' + leadDomain,
1760
- path: '/',
1761
- });
1762
- LeadLog('😍 Set HHG ID cookie');
1763
- }
1764
- // getCookie('hhg-id')
1765
- // TODO: HP-534 Filter desktop
1766
- let campaignsDevice = [];
1767
- if (isMobile()) {
1768
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
1769
- }
1770
- else {
1771
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
1772
- }
1773
- LeadLog(`👓 campaignsDevice`, campaignsDevice);
1774
- LeadLog('--listCampaignScheduled', listCampaignScheduled);
1775
- LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
1776
- LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
1777
- LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
1778
- LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
1779
- LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
1780
- // Check links
1781
- let listLinksObj = campaignsDevice
1782
- .map((i, index) => i.targets
1783
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
1784
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1785
- .flat(1);
1786
- // Check list link match current href
1787
- listLinksObj = listLinksObj.filter((i) => {
1788
- var _a;
1789
- const target = new URL(String(i.target).toLowerCase());
1790
- if (i.option == 'exact_match')
1791
- // FOR TEST LOCAL:
1792
- // return Boolean(location.pathname === target.pathname)
1793
- return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
1794
- if (i.option == 'start_with') {
1795
- // FOR TEST LOCAL:
1796
- // if (location.pathname.includes(target.pathname)) {
1797
- if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
1798
- const listExcluding = i.sub_target
1799
- .filter((i) => i.option == 'excluding')
1800
- .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
1801
- return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
1802
- }
1803
- else {
1804
- return false;
1805
- }
1806
- }
1807
- });
1808
- // Check tags
1809
- const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
1810
- const listTags = listMetaTag.map((i) => i.content);
1811
- let listCampaignHasTag = [];
1812
- let listTagsObj = [];
1813
- if (listTags && listTags.length) {
1814
- listCampaignHasTag = campaignsDevice
1815
- .map((i, index) => i.targets
1816
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
1817
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1818
- .flat(1);
1819
- listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
1820
- }
1821
- const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
1822
- const cookieKeys = document.cookie
1823
- .split('; ')
1824
- .map((i) => i.split('=')[0]);
1825
- const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
1826
- LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
1827
- const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
1828
- LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
1829
- const listCampaignSubmitedClosed = [
1830
- ...listCampaignCodeSubmited,
1831
- ...listCampaignCodeClosed,
1832
- ];
1833
- const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
1834
- const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
1835
- return !hasSubmited;
1836
- });
1837
- const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
1838
- // .sort(
1839
- // (a, b) =>
1840
- // (listCampaignValid[a.campaignIndex]?.score || 0) -
1841
- // (listCampaignValid[b.campaignIndex]?.score || 0),
1842
- // )
1843
- LeadLog('--listCampaignValid : ', listCampaignValid);
1844
- if (listCampaignValid && listCampaignValid.length) {
1845
- const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
1846
- LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
1847
- const { rules } = CAMPAIGN_SHOW;
1848
- // CHECK RULE TRIGGER POPUP
1849
- const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
1850
- LeadLog(`timeoutRule`, timeoutRule);
1851
- const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
1852
- LeadLog(`scrollRule`, scrollRule);
1853
- let impressionAction = 'TIME';
1854
- if (Number.isInteger(timeoutRule)) {
1855
- impressionAction = 'TIME';
1856
- LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
1857
- timeoutRef = setTimeout(() => {
1858
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1859
- }, timeoutRule * 1000);
1860
- }
1861
- if (Number.isInteger(scrollRule)) {
1862
- impressionAction = 'SCROLL';
1863
- LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
1864
- const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
1865
- document.querySelector('body');
1866
- const pct = $p.getBoundingClientRect().top;
1867
- const pb = $p.offsetHeight;
1868
- LeadLog(`👓 Element check scroll: `, $p);
1869
- LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
1870
- const wt = window.pageYOffset || document.documentElement.scrollTop;
1871
- let percent = 0;
1872
- if (wt >= pct) {
1873
- percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
1874
- }
1875
- LeadLog('---Scroll', percent, scrollRule);
1876
- // TODO: CHECK FOOTER HEIGHT
1877
- if (percent >= scrollRule) {
1878
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1879
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1880
- }
1881
- };
1882
- window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
1883
- passive: true,
1884
- });
1885
- }
1886
- }
1887
- else {
1888
- LeadLog('🚧 No lead campaigns on current URL, tags');
1889
- }
1890
- }
1891
- })
1892
- .catch((err) => {
1893
- LeadLog(`Lead error: `, err);
1894
- });
1895
- }
1896
- const LeadLog = (...params) => {
1897
- if (process.env.NODE_ENV !== 'production' ||
1898
- (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
1899
- process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
1900
- (typeof localStorage !== 'undefined' &&
1901
- localStorage.getItem('hhg_debug') === 'true')) {
1902
- console.log(...params);
1903
- }
1904
- };
1905
-
1906
- const LeadGenContext = createContext({
1907
- submit(value) {
1908
- /** Init for FAKING function */
1909
- LeadLog('** LeadGen Submit : ', value);
1910
- return Promise.reject(value);
1911
- },
1912
- submitSubscriptionBox(value) {
1913
- /** Init for FAKING function */
1914
- LeadLog('** LeadGen SubmitSubscriptionBox : ', value);
1915
- return Promise.reject(value);
1916
- },
1917
- impression(value) {
1918
- /** Init for FAKING function */
1919
- LeadLog('** LeadGen Impression : ', value);
1920
- return Promise.reject(value);
1921
- },
1922
- /** For Subscription Box */
1923
- subscriptionIcon: '',
1924
- subscriptionTitle: '',
1925
- });
1926
- const LeadGenContextProvider = (props) => {
1927
- const { campaign_code: campaignCodeProps, apiSsoUrl, apiLeadUrl, apiSubotUrl, locale: localeProps, forceCampaign: forceCampaignProps, extraValues, articleId = 1, categoryId = 1, siteDomain: site_domain, children, } = props;
1928
- const [forceCampaign, setForceCampaign] = useState(forceCampaignProps);
1929
- const [subscriptionInfo, setSubscriptionInfo] = useState({
1930
- subscriptionIcon: '',
1931
- subscriptionTitle: '',
1932
- });
1933
- const locale = useMemo(() => {
1934
- return localeProps || LOCALE['PhilippinesEnglish'];
1935
- }, [localeProps]);
1936
- const leadGenContextValue = useMemo(() => (Object.assign(Object.assign({}, props), { forceCampaign })), [...Object.values(props), forceCampaign]);
1937
- const { url, campaign_id, campaign_code, cookie_id, ga_client_id, category_id, article_id, article_title, } = useMemo(() => ({
1938
- url: location.href.toLowerCase() || '',
1939
- cookie_id: getCookie('hhg-id') || null,
1940
- ga_client_id: getCookie('_ga'),
1941
- campaign_id: forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id,
1942
- campaign_code: campaignCodeProps || (forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.code),
1943
- category_id: categoryId,
1944
- article_id: articleId,
1945
- article_title: document.title || '',
1946
- }), [campaignCodeProps, articleId, categoryId, forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id]);
1947
- const fetchCampaign = useCallback((campaign_code) => {
1948
- Service.getCampaignByCode(campaign_code).then((res) => {
1949
- const { _data } = res || {};
1950
- const { campaigns } = _data || {};
1951
- LeadLog('** LeadGen Campaign : ', campaigns);
1952
- setForceCampaign(formatCampaignDetail(campaigns));
1953
- });
1954
- }, [campaignCodeProps]);
1955
- // TODO : Update form for LeadGen
1956
- const submit = useCallback((data) => {
1957
- return Service.postSubscriptionBoxLead({ data });
1958
- }, []);
1959
- const submitSubscriptionBox = useCallback((value) => {
1960
- const data = Object.assign(Object.assign(Object.assign(Object.assign({}, value), { campaign_id,
1961
- site_domain, url: (value === null || value === void 0 ? void 0 : value.url) || url, ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id }), extraValues), { article_id,
1962
- category_id, article_title: (extraValues === null || extraValues === void 0 ? void 0 : extraValues.article_title) || article_title });
1963
- return Service.postSubscriptionBoxLead({ data });
1964
- }, [
1965
- extraValues,
1966
- site_domain,
1967
- campaign_id,
1968
- article_id,
1969
- article_title,
1970
- category_id,
1971
- url,
1972
- ga_client_id,
1973
- ]);
1974
- const impression = useCallback((value) => {
1975
- return Service.campaignPostImpression({
1976
- url: (value === null || value === void 0 ? void 0 : value.url) || url,
1977
- action: (value === null || value === void 0 ? void 0 : value.action) || LEADGEN_ACTIONS.SCROLL,
1978
- code: (value === null || value === void 0 ? void 0 : value.code) || campaign_code,
1979
- title_article: (value === null || value === void 0 ? void 0 : value.title_article) || article_title,
1980
- cookie_id: (value === null || value === void 0 ? void 0 : value.cookie_id) || cookie_id,
1981
- ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id,
1982
- extra: (value === null || value === void 0 ? void 0 : value.extra) || Object.assign({ cookie_id,
1983
- article_id, subscription_title: subscriptionInfo.subscriptionTitle }, extraValues),
1984
- referrer: value === null || value === void 0 ? void 0 : value.referrer,
1985
- });
1986
- }, [
1987
- extraValues,
1988
- campaign_id,
1989
- url,
1990
- campaign_code,
1991
- article_title,
1992
- cookie_id,
1993
- ga_client_id,
1994
- article_id,
1995
- subscriptionInfo.subscriptionTitle,
1996
- ]);
1997
- useEffect(() => {
1998
- if (forceCampaignProps) {
1999
- setForceCampaign(forceCampaignProps);
2000
- return;
2001
- }
2002
- /** For Subscription Box */
2003
- if (categoryId) {
2004
- Service.getSubscriptionBoxInfo({
2005
- category: categoryId,
2006
- site: site_domain,
2007
- }).then((res) => {
2008
- const { _data } = res || {};
2009
- const { item, campaign_code } = _data || {};
2010
- const { icon, content } = item || {};
2011
- LeadLog('** LeadGen SubscriptionBox campaign_code : ', campaign_code);
2012
- LeadLog('** LeadGen SubscriptionBox subscription_icon : ', icon);
2013
- LeadLog('** LeadGen SubscriptionBox subscription_title : ', content);
2014
- if (icon && content) {
2015
- setSubscriptionInfo({
2016
- subscriptionIcon: icon,
2017
- subscriptionTitle: content,
2018
- });
2019
- }
2020
- if (campaign_code) {
2021
- fetchCampaign(campaign_code);
2022
- }
2023
- });
2024
- return;
2025
- }
2026
- if (campaignCodeProps) {
2027
- fetchCampaign(campaignCodeProps);
2028
- }
2029
- }, [campaignCodeProps, categoryId]);
2030
- useEffect(() => {
2031
- leadStore.apiSsoUrl = apiSsoUrl;
2032
- leadStore.apiLeadUrl = apiLeadUrl;
2033
- leadStore.apiSubotUrl = apiSubotUrl;
2034
- }, [apiLeadUrl, apiSubotUrl, apiSsoUrl]);
2035
- if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
2036
- return null;
2037
- }
2038
- return (React__default.createElement(LeadGenContext.Provider, { value: Object.assign(Object.assign(Object.assign({}, leadGenContextValue), subscriptionInfo), { submit,
2039
- submitSubscriptionBox,
2040
- impression }) },
2041
- React__default.createElement(LeadGenTranslationProvider, { locale: locale }, children)));
2042
- };
2043
- const useLeadGenContext = () => {
2044
- const context = useContext(LeadGenContext);
2045
- return Object.assign(Object.assign({}, context), { apiLeadUrl: context.apiLeadUrl || leadStore.apiLeadUrl, apiSubotUrl: context.apiSubotUrl || leadStore.apiSubotUrl });
2046
- };
2047
-
2048
- // eslint-disable-next-line @typescript-eslint/no-var-requires
2049
- const customParseFormat = require('dayjs/plugin/customParseFormat');
2050
- dayjs.extend(customParseFormat);
2051
- // You can give context variables any name
2052
- const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
2053
- const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
2054
- var _a;
2055
- const { t } = useTranslations();
2056
- const initialValues = useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
2057
- const LEAD_LOCALE = LEAD_LOCALE_DATA[(_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.lang] ||
2058
- LEAD_LOCALE_DATA['vi-VN'];
2059
- const validateObj = useMemo(() => {
2060
- const InputBlocks = [
2061
- 'TextBlock',
2062
- 'NumberBlock',
2063
- 'EmailBlock',
2064
- 'PhoneBlock',
2065
- 'DateBlock',
2066
- 'CheckboxBlock',
2067
- 'RadioBlock',
2068
- 'DropdownBlock',
2069
- 'PhoneOtpBlock',
2070
- 'WhatsappOtpBlock',
2071
- 'ZaloOtpBlock',
2072
- 'LocationBlock',
2073
- 'TncBlock',
2074
- ];
2075
- // ALL are required and can skip if not touched yet
2076
- const withSharedCheck = (name, cb,
2077
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2078
- block) => {
2079
- return (value) => {
2080
- var _a;
2081
- const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
2082
- if (!formRef.current.isTouched(name))
2083
- return;
2084
- if ((typeof value === 'string' && value.trim() === '') ||
2085
- typeof value === 'undefined' ||
2086
- (Array.isArray(value) && value.length === 0)) {
2087
- return isBLockRequired
2088
- ? t('validator.required')
2089
- : cb === null || cb === void 0 ? void 0 : cb(value);
2090
- }
2091
- return cb === null || cb === void 0 ? void 0 : cb(value);
2092
- };
2093
- };
2094
- return listBlockAdded
2095
- .filter((b) => InputBlocks.includes(b.name))
2096
- .reduce((r, b) => {
2097
- const { name: fieldType, data } = b || {};
2098
- const { value: fieldName, required } = data || {};
2099
- const isRequired = required !== null && required !== void 0 ? required : true;
2100
- if (fieldType === 'NumberBlock') {
2101
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2102
- if (value && isNaN(Number(value))) {
2103
- return t('validator.number');
2104
- }
2105
- }, b) });
2106
- }
2107
- else if (fieldType === 'EmailBlock') {
2108
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2109
- if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
2110
- return t('validator.email');
2111
- }
2112
- if (!value)
2113
- return;
2114
- validatingEmailRef.current = true;
2115
- setTimeout(() => {
2116
- formRef.current.setFieldError(fieldName, 'Validating...');
2117
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2118
- email: value,
2119
- })
2120
- .then((tKey) => {
2121
- if (tKey) {
2122
- formRef.current.setFieldError(fieldName, t(tKey));
2123
- }
2124
- else {
2125
- formRef.current.clearFieldError(fieldName);
2126
- }
2127
- validatingEmailRef.current = false;
2128
- })
2129
- .catch((e) => {
2130
- console.error(e);
2131
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2132
- validatingEmailRef.current = false;
2133
- });
2134
- }, 200);
2135
- }, b) });
2136
- }
2137
- else if (fieldType === 'PhoneBlock' ||
2138
- fieldType === 'PhoneOtpBlock' ||
2139
- fieldType === 'ZaloOtpBlock' ||
2140
- fieldType === 'WhatsappOtpBlock') {
2141
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2142
- if (value &&
2143
- window.intlTelInputUtils &&
2144
- !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
2145
- return t('validator.phone');
2146
- }
2147
- if (!value)
2148
- return;
2149
- validatingPhoneRef.current = true;
2150
- setTimeout(() => {
2151
- formRef.current.setFieldError(fieldName, 'Validating...');
2152
- if (b.data.singleSubmission) {
2153
- checkUsedPhoneOnlyWithCache(campaignId, value)
2154
- .then((tKey) => {
2155
- if (tKey) {
2156
- formRef.current.setFieldError(fieldName, t(tKey));
2157
- }
2158
- else {
2159
- formRef.current.clearFieldError(fieldName);
2160
- }
2161
- validatingPhoneRef.current = false;
2162
- })
2163
- .catch((err) => {
2164
- console.error(err);
2165
- formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
2166
- validatingPhoneRef.current = false;
2167
- });
2168
- }
2169
- else {
2170
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2171
- phone: value,
2172
- })
2173
- .then((tKey) => {
2174
- if (tKey) {
2175
- formRef.current.setFieldError(fieldName, t(tKey));
2176
- }
2177
- else {
2178
- formRef.current.clearFieldError(fieldName);
2179
- }
2180
- validatingPhoneRef.current = false;
2181
- })
2182
- .catch((e) => {
2183
- console.error(e);
2184
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2185
- validatingPhoneRef.current = false;
2186
- });
2187
- }
2188
- }, 200);
2189
- }, b) });
2190
- }
2191
- else if (fieldType === 'DateBlock') {
2192
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2193
- if (!isRequired && !value) {
2194
- return;
2195
- }
2196
- const errMsg = t('validator.dateInvalid');
2197
- const dayInJS = typeof value === 'string'
2198
- ? dayjs(value, format, true)
2199
- : dayjs(value);
2200
- if (!dayInJS.isValid()) {
2201
- return errMsg;
2202
- }
2203
- }, b) });
2204
- }
2205
- else if (fieldType === 'TncBlock') {
2206
- return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
2207
- if (isRequired && !value) {
2208
- return t('validator.required');
2209
- }
2210
- }, b) });
2211
- }
2212
- else {
2213
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
2214
- }
2215
- }, {});
2216
- }, [listBlockAdded.map((b) => b.name).join(','), format]);
2217
- const form = useLeadForm({
2218
- validateInputOnChange: true,
2219
- validateInputOnBlur: true,
2220
- clearInputErrorOnChange: true,
2221
- validate: validateObj,
2222
- initialValues,
2223
- });
2224
- const formRef = useRef(form);
2225
- formRef.current = form;
2226
- return { form, validateObj };
2227
- };
2228
-
2229
- const StyledLeadGenThankYou = styled.div `
2230
- display: flex;
2231
- gap: 8px;
2232
- flex-direction: column;
2233
- padding-block: 24px;
2234
-
2235
- .leadgen-image {
2236
- width: 120px;
2237
- height: 120px;
2238
- margin-inline: auto;
2239
- object-fit: contain;
2240
- object-position: center;
2241
- text-align: center;
2242
- }
2243
-
2244
- .leadgen-title {
2245
- margin-block: 0;
2246
- color: ${theme.colors.gray900};
2247
- font-weight: 700;
2248
- font-size: 18px;
2249
- line-height: 28px;
2250
- letter-spacing: -0.2px;
2251
- }
2252
-
2253
- .leadgen-description {
2254
- margin-block: 0;
2255
- color: ${theme.colors.gray600};
2256
- font-weight: 400;
2257
- font-size: 14px;
2258
- line-height: 22px;
2259
- letter-spacing: -0.2px;
2260
- text-align: center;
2261
- }
2262
-
2263
- > [data-align] {
2264
- &[data-align='right'] {
2265
- text-align: right;
2266
- }
2267
- &[data-align='center'] {
2268
- text-align: center;
2269
- }
2270
- }
2271
- `;
2272
- const LeadGenThankYou = ({ image, title, description, showButton = false, button, className, style, }) => {
2273
- const { src } = image;
2274
- const { htmlText: titleText, align: titleAlign } = title;
2275
- const { htmlText: descriptionText, align: descriptionAlign } = description;
2276
- const { htmlText: buttonText, newtab, url, onClick } = button;
2277
- return (React__default.createElement(StyledLeadGenThankYou, { className: className, style: style },
2278
- React__default.createElement("img", { src: src, alt: "", className: "leadgen-thankyou_image leadgen-image" }),
2279
- React__default.createElement("p", { className: "leadgen-thankyou_title leadgen-title", "data-align": titleAlign }, titleText),
2280
- React__default.createElement("p", { className: "leadgen-thankyou_description leadgen-description", "data-align": descriptionAlign }, descriptionText),
2281
- !!buttonText && showButton && (React__default.createElement(Button$1, { component: url ? 'a' : 'button', target: newtab ? '_blank' : undefined, href: url, size: "lg", variant: "filled", className: "leadgen-thankyoue_btn leadgen-btn", onClick: onClick }, buttonText))));
2282
- };
2283
-
2284
- const StyledLeadGenSubscriptionBoxBody = styled.div `
2285
- margin-top: 16px;
2286
- .leadgen-btn {
2287
- margin-top: 16px;
2288
- }
2289
- `;
2290
- const StyledLeadGenSubscriptionBoxHeaderImage = styled.div `
2291
- margin-top: 3px;
2292
- margin-right: 20px;
2293
- width: 44px;
2294
- height: 44px;
2295
-
2296
- img {
2297
- width: 100%;
2298
- height: 100%;
2299
- object-fix: contain;
2300
- onject-position: center;
2301
- }
2302
-
2303
- :has(img[src='']) {
2304
- display: none;
2305
- }
2306
- `;
2307
- const StyledLeadGenSubscriptionBoxHeader = styled.div `
2308
- display: flex;
2309
- align-items: center;
2310
- margin-bottom: 16px;
2311
- .leadgen-title {
2312
- margin-bottom: 0;
2313
- flex: 1;
2314
- min-width: 0;
2315
- color: ${theme.colors.gray900};
2316
- font-size: 18px;
2317
- font-weight: 400;
2318
- line-height: 1.4;
2319
- letter-spacing: -0.8px;
2320
- }
2321
- `;
2322
- const StyledLeadGenSubscriptionBox = styled.div `
2323
- padding: 16px;
2324
- border: 1px solid ${theme.colors.neutral100};
2325
- border-radius: 12px;
2326
- margin-inline: auto;
2327
- .leadgen-form_inputs {
2328
- .leadgen-form_input {
2329
- width: 100%;
2330
- }
2331
- }
2332
-
2333
- .leadgen-form_input {
2334
- .mantine-Input-wrapper {
2335
- max-height: 56px;
2336
- }
2337
- }
2338
-
2339
- @media screen and (min-width: 768px) {
2340
- .leadgen-subscription_box_body {
2341
- display: flex;
2342
- > form {
2343
- flex: 1;
2344
- min-width: 0;
2345
-
2346
- .leadgen-form_inputs {
2347
- .leadgen-form_input {
2348
- width: calc(50% - 4px);
2349
- }
2350
- }
2351
- }
2352
-
2353
- .leadgen-btn {
2354
- margin-top: 0;
2355
- margin-left: 8px;
2356
- width: auto;
2357
- min-height: 56px;
2358
- }
2359
- }
2360
- }
2361
- `;
2362
- const StyledLeadGenSubscriptionBoxA = styled.div `
2363
- .leadgen-form_input {
2364
- --phone-select: 45px;
2365
- .PhoneInput {
2366
- --phone-select: 45px;
2367
- .PhoneInputCountry {
2368
- margin-top: 1px;
2369
- pointer-events: none;
2370
- .PhoneInputCountryIconImg,
2371
- .PhoneInputArrowContainer {
2372
- display: none;
2373
- }
2374
- }
2375
- }
2376
- }
2377
- `;
2378
-
2379
- const PhoneInput = forwardRef((props, ref) => {
2380
- const { defaultCountry, id: idProps, name, placeholder, label, labelElement, labelProps, description, descriptionProps, withAsterisk, inputMode, inputContainer, inputWrapperOrder, error, className, classNames, style, styles } = props, restProps = __rest(props, ["defaultCountry", "id", "name", "placeholder", "label", "labelElement", "labelProps", "description", "descriptionProps", "withAsterisk", "inputMode", "inputContainer", "inputWrapperOrder", "error", "className", "classNames", "style", "styles"]);
2381
- const id = idProps || v1() + name;
2382
- return (React__default.createElement(Input$1.Wrapper, { size: "md", label: label, labelElement: labelElement, labelProps: Object.assign({ htmlFor: id }, labelProps), description: description, descriptionProps: descriptionProps, withAsterisk: withAsterisk, inputMode: inputMode, inputContainer: inputContainer, inputWrapperOrder: inputWrapperOrder, error: error, "data-invalid": !!error, className: className, classNames: classNames, style: style, styles: styles },
2383
- React__default.createElement("div", { className: "mantine-Input-wrapper" },
2384
- React__default.createElement(Phone, Object.assign({}, restProps, { id: id, ref: ref, name: name, spellCheck: false, placeholder: placeholder, defaultCountry: defaultCountry, className: "mantine-Input-input", type: "tel", "data-control": "tel" })))));
2385
- });
2386
-
2387
- const formatLeadGenFormValue = (values, blocks) => {
2388
- const newValues = {};
2389
- for (const block of blocks) {
2390
- const { data } = block || {};
2391
- const { value: fieldName } = data || {};
2392
- if (fieldName in values) {
2393
- newValues[fieldName] = values[fieldName];
2394
- }
2395
- }
2396
- return newValues;
2397
- };
2398
-
2399
- const StyledLeadGenFormInner = styled.div `
2400
- display: flex;
2401
- flex-wrap: wrap;
2402
- gap: 8px;
2403
- .leadgen-form_input {
2404
- width: calc(50% - 4px);
2405
- }
2406
-
2407
- .leadgen-form_input_checkbox {
2408
- width: 100%;
2409
- }
2410
- `;
2411
-
2412
- const cssInputNotShrink$1 = css `
2413
- height: 100% !important;
2414
- min-height: calc(var(--container-height, 56px) * 22 / 56);
2415
- color: ${theme.colors.gray800};
2416
- font-size: var(--input, 16px);
2417
- line-height: calc(var(--container-height, 56px) * 22 / 56);
2418
- border: none !important;
2419
- border-radius: 0 !important;
2420
- outline: none !important;
2421
- box-shadow: none !important;
2422
- padding: 0;
2423
- cursor: pointer;
2424
- opacity: 0;
2425
-
2426
- ::placeholder {
2427
- color: ${theme.colors.gray400};
2428
- }
2429
- `;
2430
- const cssInputShrink$1 = css `
2431
- height: auto !important;
2432
- cursor: text;
2433
- opacity: 1;
2434
- transition: 0.1s ease-in-out all;
2435
- `;
2436
- const cssLabelNotShrink$1 = css `
2437
- position: absolute;
2438
- top: calc(var(--container-height) / 2);
2439
- left: var(--space-x, 16px);
2440
- color: ${theme.colors.gray400};
2441
- font-size: var(--label-not-shrink, 16px);
2442
- font-weight: 400;
2443
- line-height: calc(var(--container-height, 56px) * 18 / 56);
2444
- margin: 0;
2445
- z-index: 1;
2446
- cursor: pointer;
2447
- transform: translateY(-50%);
2448
- transition: 0.125s ease-in all;
2449
- `;
2450
- const cssLabelShrink$1 = css `
2451
- color: ${theme.colors.gray600};
2452
- font-weight: 600;
2453
- font-size: var(--label-shrink, 12px);
2454
- top: calc(var(--container-height) * 7 / 56);
2455
- transform: none;
2456
- transition: 0.125s ease-out all;
2457
- `;
2458
- const cssWrapperInputNotShrink$1 = css `
2459
- min-height: var(--container-height, 56px);
2460
- display: flex;
2461
- align-items: flex-end;
2462
- border: 1px solid ${theme.colors.gray200};
2463
- border-radius: 8px;
2464
- background-color: #fff;
2465
- padding-inline: var(--space-x, 16px);
2466
- padding-block: var(--space-y-not-shrink, 16px);
2467
- cursor: pointer;
2468
- pointer-events: none;
2469
-
2470
- &:has(.mantine-Input-rightSection) {
2471
- padding-right: var(--container-height, 56px);
2472
- }
2473
-
2474
- .mantine-Input-icon {
2475
- display: none;
2476
- }
2477
-
2478
- .mantine-NumberInput-control {
2479
- border-color: ${theme.colors.gray200};
2480
- }
2481
- `;
2482
- const cssWrapperInputShrink$1 = css `
2483
- height: auto;
2484
- min-height: var(--container-height, 56px);
2485
- padding-block: var(--space-y-shrink, 7px);
2486
- cursor: text;
2487
- pointer-events: auto;
2488
- `;
2489
- const cssInputWrapperError$1 = css `
2490
- color: ${theme.colors.red800};
2491
- font-size: 12px;
2492
- line-height: 1.5;
2493
- `;
2494
- const StyledTextFieldContainer$1 = styled.div `
2495
- --space-x: 16px;
2496
- --space-y-not-shrink: 16px;
2497
- --space-y-shrink: 7px;
2498
- --container-height: 56px;
2499
- --label-not-shrink: 16px;
2500
- --label-shrink: 12px;
2501
- --input: 16px;
2502
-
2503
- position: relative;
2504
- min-width: 100px;
2505
- max-width: 100%;
2506
- display: inline-block;
2507
-
2508
- .textField_wrapper {
2509
- display: inline-block;
2510
- width: 100%;
2511
- cursor: pointer;
2512
- }
2513
-
2514
- .mantine-InputWrapper-root {
2515
- &[data-invalid='true'] {
2516
- .mantine-Input-wrapper {
2517
- border-color: ${theme.colors.red400};
2518
- }
2519
- }
2520
-
2521
- .mantine-Input-wrapper {
2522
- &:has([data-invalid]) {
2523
- border-color: ${theme.colors.red400};
2524
- }
2525
- }
2526
-
2527
- .mantine-InputWrapper-error {
2528
- font-size: 12px !important;
2529
- }
2530
- }
2531
-
2532
- .mantine-InputWrapper-label {
2533
- ${cssLabelNotShrink$1}
2534
- }
2535
-
2536
- .mantine-Input-wrapper {
2537
- ${cssWrapperInputNotShrink$1}
2538
-
2539
- + .mantine-Popover-dropdown[data-position="bottom-start"] {
2540
- left: 0 !important;
2541
- }
2542
- + .mantine-Popover-dropdown[data-position='top-start'] {
2543
- top: unset !important;
2544
- left: 0 !important;
2545
- bottom: 100% !important;
2546
- }
2547
- }
2548
-
2549
- .mantine-Input-input {
2550
- ${cssInputNotShrink$1}
2551
- }
2552
-
2553
- &.textField_shrink,
2554
- &:focus-within {
2555
- .mantine-InputWrapper-label {
2556
- ${cssLabelShrink$1}
2557
- }
2558
-
2559
- .mantine-Input-wrapper {
2560
- ${cssWrapperInputShrink$1}
2561
- &.mantine-Select-wrapper {
2562
- .mantine-Select-rightSection {
2563
- pointer-events: auto !important;
2564
- }
2565
- }
2566
- }
2567
-
2568
- .mantine-Input-input {
2569
- ${cssInputShrink$1}
2570
- }
2571
-
2572
- &:has(.PhoneInput) {
2573
- .mantine-InputWrapper-label {
2574
- left: var(--space-x, 16px);
2575
- }
2576
- .PhoneInput {
2577
- .PhoneInputInput {
2578
- opacity: 1;
2579
- }
2580
- }
2581
- }
2582
- }
2583
-
2584
- .PhoneInput {
2585
- --phone-select: 75px;
2586
- --phone-input-space-x: 8px;
2587
- width: 100%;
2588
- opacity: 1;
2589
- border: none;
2590
- .PhoneInputCountry {
2591
- background-color: transparent;
2592
- border: none;
2593
- padding: 0;
2594
- width: var(--phone-select, 75px);
2595
- }
2596
- .PhoneInputInput {
2597
- flex: 1;
2598
- min-width: 0;
2599
- line-height: 1.5;
2600
- outline: none !important;
2601
- border: none;
2602
- box-shadow: none;
2603
- padding: 0 var(--phone-input-space-x, 8px);
2604
- opacity: 0;
2605
- color: ${theme.colors.gray800} !important;
2606
- :focus {
2607
- color: ${theme.colors.gray800} !important;
2608
- }
2609
- }
2610
- }
2611
-
2612
- &:has(.PhoneInput) {
2613
- .mantine-InputWrapper-label {
2614
- left: calc(
2615
- var(--space-x, 16px) + var(--phone-select, 75px) +
2616
- var(--phone-input-space-x, 8px)
2617
- );
2618
- }
2619
- }
2620
- `;
2621
- const StyledChoiceFieldContainer$1 = styled.div `
2622
- &.leadgen-form_checkbox,
2623
- &.leadgen-form_radio {
2624
- width: 100%;
2625
- }
2626
-
2627
- &.leadgen-form_dropdown {
2628
- width: calc(50% - 12px);
2629
- }
2630
-
2631
- .mantine-InputWrapper-root {
2632
- display: block;
2633
- .mantine-InputWrapper-error {
2634
- font-size: 12px !important;
2635
- }
2636
- }
2637
-
2638
- .mantine-InputWrapper-label {
2639
- margin-bottom: 0.5rem;
2640
- color: ${theme.colors.gray800};
2641
- font-size: 16px;
2642
- font-weight: 400;
2643
- line-height: 1.5;
2644
- }
2645
-
2646
- .mantine-Radio-root,
2647
- .mantine-Checkbox-root {
2648
- gap: 8px;
2649
- min-width: calc(50% - 4px);
2650
-
2651
- input[type='radio'],
2652
- input[type='checkbox'] {
2653
- border-color: ${theme.colors.gray600};
2654
- width: 18px;
2655
- height: 18px;
2656
- }
2657
- input[type='checkbox'] {
2658
- border-radius: 4px;
2659
- }
2660
-
2661
- &[data-checked='true'] {
2662
- input[type='radio'],
2663
- input[type='checkbox'] {
2664
- border-color: ${theme.colors.primary600};
2665
- + svg {
2666
- color: ${theme.colors.primary600};
2667
- }
2668
- }
2669
-
2670
- input[type='radio'] {
2671
- background-color: white;
2672
- }
2673
- }
2674
-
2675
- .mantine-Checkbox-input {
2676
- &:checked {
2677
- border-color: ${theme.colors.primary600};
2678
- }
2679
- }
2680
- }
2681
-
2682
- .mantine-Radio-inner,
2683
- .mantine-Checkbox-inner {
2684
- width: 24px;
2685
- height: 24px;
2686
- display: flex;
2687
- align-items: center;
2688
- justify-content: center;
2689
- }
2690
-
2691
- .mantine-Radio-body,
2692
- .mantine-Checkbox-body {
2693
- display: flex;
2694
- align-items: center;
2695
- }
2696
-
2697
- .mantine-Radio-label,
2698
- .mantine-Checkbox-label {
2699
- padding-left: 8px;
2700
- color: ${theme.colors.gray800};
2701
- font-size: 14px;
2702
- line-height: 1.4;
2703
- letter-spacing: -0.2px;
2704
- }
2705
-
2706
- .leadgen-choiceContainer {
2707
- display: flex;
2708
- flex-wrap: wrap;
2709
- align-items: flex-start;
2710
- gap: 8px;
2711
- }
2712
-
2713
- .mantine-InputWrapper-error {
2714
- ${cssInputWrapperError$1}
2715
- }
2716
- `;
2717
-
2718
- const TextField$1 = (props) => {
2719
- const { shrink: shrinkProps, onChangeShrink, className, children } = props, restProps = __rest(props, ["shrink", "onChangeShrink", "className", "children"]);
2720
- const containerRef = useClickOutside(() => {
2721
- if (shrinkProps) {
2722
- return;
2723
- }
2724
- setShrink(false);
2725
- onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(false);
2726
- });
2727
- const [shrink, setShrink] = useState(shrinkProps);
2728
- const onClick = useCallback((e) => {
2729
- setShrink(true);
2730
- onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(true);
2731
- if (shrink) {
2732
- return;
2733
- }
2734
- const $textEl = e.currentTarget.querySelectorAll('input:not([disabled]):not([type="submit"]),select:not([disabled]),textarea:not([disabled])');
2735
- const $focusEl = $textEl.item($textEl.length - 1);
2736
- if ($focusEl) {
2737
- $focusEl.focus();
2738
- setTimeout(() => {
2739
- $focusEl.scrollIntoView({
2740
- behavior: 'auto',
2741
- block: 'center',
2742
- inline: 'start',
2743
- });
2744
- }, 100);
2745
- }
2746
- }, [shrink]);
2747
- useEffect(() => {
2748
- setShrink(shrinkProps);
2749
- }, [shrinkProps]);
2750
- return (React__default.createElement(StyledTextFieldContainer$1, Object.assign({ shrink: shrink, className: clsx(className, 'textField', { textField_shrink: !!shrink }) }, restProps),
2751
- React__default.createElement("div", { ref: containerRef, onClick: onClick, className: "textField_wrapper" }, children)));
2752
- };
2753
- const ChoiceField$1 = (props) => {
2754
- const { children, className } = props, restProps = __rest(props, ["children", "className"]);
2755
- return (React__default.createElement(StyledChoiceFieldContainer$1, Object.assign({ className: clsx(className, 'choiceField') }, restProps), children));
2756
- };
2757
-
2758
- const libraries = ['places'];
2759
- const GoogleLocationBlock = (props) => {
2760
- var _a;
2761
- const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = __rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
2762
- const [LoadScript, setLoadScript] = useState(null);
2763
- const [value, setValue] = useState(defaultValue || valueProps);
2764
- const { predictions } = usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
2765
- const onChangeAutocomplete = useCallback((s) => {
2766
- setValue(s);
2767
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
2768
- }, []);
2769
- const onClickItem = useCallback((item) => {
2770
- /** For sure get value */
2771
- setValue(item.value);
2772
- const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
2773
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
2774
- }, [onChangeProps, predictions]);
2775
- useEffect(() => {
2776
- setValue(valueProps);
2777
- }, [valueProps]);
2778
- useEffect(() => {
2779
- var _a, _b, _c;
2780
- // only load extra google script when not yet loaded
2781
- if (!((_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.places) === null || _c === void 0 ? void 0 : _c.AutocompleteService) && !LoadScript) {
2782
- import('@react-google-maps/api').then((m) => {
2783
- setLoadScript(() => m.LoadScript);
2784
- });
2785
- }
2786
- }, []);
2787
- return (React__default.createElement(Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
2788
- return { value: pred.description, label: pred.description };
2789
- }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
2790
- return (React__default.createElement(React__default.Fragment, null,
2791
- LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default.createElement(React__default.Fragment, null), style: { width: '100%' } })),
2792
- children));
2793
- } }, restProps)));
2794
- };
2795
-
2796
- const LeadGenForm = forwardRef((props, ref) => {
2797
- const { locale, blocks, scrollToErrorField = true, form: formProps, rules: validate, initialValues, onFinish, onFinishFailed, className, style, } = props;
2798
- const formRef = useRef(null);
2799
- const form = formProps || useForm({ initialValues, validate });
2800
- const middlewareFinish = useCallback((values, event) => {
2801
- /** Set `touched` all values for validation when submiting */
2802
- form.setTouched(blocks.reduce((touched, { data }) => {
2803
- touched[data.value] = true;
2804
- return touched;
2805
- }, {}));
2806
- /** Wait for `touched` state and then submit */
2807
- setTimeout(() => {
2808
- const { hasErrors } = form.validate();
2809
- if (hasErrors) {
2810
- return;
2811
- }
2812
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatLeadGenFormValue(values, blocks), event);
2813
- }, 100);
2814
- }, [form, blocks]);
2815
- const middlewareFinishFailed = useCallback((errors, values, events) => {
2816
- if (scrollToErrorField && errors) {
2817
- const firstErrorKey = Object.keys(errors)[0];
2818
- const firstErrorElement = document.querySelector(`[name="${firstErrorKey}"]`);
2819
- if (firstErrorElement && (firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus)) {
2820
- setTimeout(() => {
2821
- firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
2822
- firstErrorElement.scrollIntoView({
2823
- behavior: 'auto',
2824
- block: 'center',
2825
- inline: 'center',
2826
- });
2827
- }, 100);
2828
- }
2829
- }
2830
- onFinishFailed === null || onFinishFailed === void 0 ? void 0 : onFinishFailed(errors, values, events);
2831
- }, [scrollToErrorField]);
2832
- useEffect(() => {
2833
- (() => __awaiter(void 0, void 0, void 0, function* () {
2834
- if (!window.intlTelInputUtils) {
2835
- yield require('intl-tel-input/build/js/utils');
2836
- }
2837
- }))();
2838
- }, []);
2839
- useImperativeHandle(ref, () => (Object.assign(Object.assign({}, form), { submit: () => {
2840
- formRef.current.requestSubmit();
2841
- } })), [form, formRef]);
2842
- if (!blocks || !blocks.length) {
2843
- return null;
2844
- }
2845
- return (React__default.createElement("form", { ref: formRef, onSubmit: form.onSubmit(middlewareFinish, middlewareFinishFailed), className: className, style: style },
2846
- React__default.createElement(StyledLeadGenFormInner, { className: "leadgen-form_inputs" }, blocks.map((block, idx) => {
2847
- const { id, name: blockName, data } = block;
2848
- const { placeholder, value: name, required, listQuestion, valueHTML, isSendMailChimp = false, } = data;
2849
- const formInputProps = form.getInputProps(name);
2850
- const { value, error } = formInputProps;
2851
- const reactKey = `${id}-${idx}`;
2852
- switch (blockName) {
2853
- case LEADGEN_BLOCK.TextBlock: {
2854
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2855
- React__default.createElement(TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "text", "data-control": "text" }, formInputProps))));
2856
- }
2857
- case LEADGEN_BLOCK.NumberBlock: {
2858
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2859
- React__default.createElement(NumberInput$1, Object.assign({ name: value, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "number", "data-control": "number" }, formInputProps))));
2860
- }
2861
- case LEADGEN_BLOCK.EmailBlock: {
2862
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2863
- React__default.createElement(TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, "data-control": "email" }, formInputProps))));
2864
- }
2865
- case LEADGEN_BLOCK.PhoneOtpBlock:
2866
- case LEADGEN_BLOCK.WhatsappOtpBlock:
2867
- case LEADGEN_BLOCK.ZaloOtpBlock:
2868
- case LEADGEN_BLOCK.PhoneBlock: {
2869
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2870
- React__default.createElement(PhoneInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, defaultCountry: (locale ? MAPPED_LOCALE[locale] || 'VN' : 'VN'), type: "text", "data-control": "text" }, formInputProps))));
2871
- }
2872
- case LEADGEN_BLOCK.LocationBlock: {
2873
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2874
- React__default.createElement(GoogleLocationBlock, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, locale: locale, "data-control": "text" }, formInputProps))));
2875
- }
2876
- case LEADGEN_BLOCK.DateBlock: {
2877
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2878
- React__default.createElement(DateInput, Object.assign({ locale: (MAPPED_LOCALE === null || MAPPED_LOCALE === void 0 ? void 0 : MAPPED_LOCALE[locale]) || MAPPED_LOCALE['vi-VN'], valueFormat: "DD/MM/YYYY", name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "default", "data-control": "date" }, formInputProps))));
2879
- }
2880
- case LEADGEN_BLOCK.DropdownBlock:
2881
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2882
- React__default.createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2883
- React__default.createElement(Select$1, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, data: listQuestion.map((l) => ({
2884
- value: l.value,
2885
- label: l.placeholder,
2886
- })) }, formInputProps))));
2887
- case LEADGEN_BLOCK.CheckboxBlock: {
2888
- const formInputCheckboxProps = form.getInputProps(name, {
2889
- type: 'checkbox',
2890
- });
2891
- return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2892
- isSendMailChimp && (React__default.createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2893
- React__default.createElement(Checkbox$1.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, sx: {
2894
- display: 'flex',
2895
- flexDirection: 'column',
2896
- flexWrap: 'wrap',
2897
- gap: 8,
2898
- }, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2899
- return (React__default.createElement("div", { className: "leadgen-choiceContainer" }, children));
2900
- } }, formInputCheckboxProps), listQuestion.map((l, _idx) => (React__default.createElement(Checkbox$1, { name: name, key: _idx, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2901
- }
2902
- case LEADGEN_BLOCK.RadioBlock: {
2903
- return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2904
- isSendMailChimp && (React__default.createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2905
- React__default.createElement(Radio$1.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, spellCheck: true, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2906
- return (React__default.createElement("div", { className: "leadgen-choiceContainer" }, children));
2907
- } }, formInputProps), listQuestion.map((l, _index) => (React__default.createElement(Radio$1, { name: name, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2908
- }
2909
- case LEADGEN_BLOCK.TncBlock:
2910
- return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2911
- React__default.createElement(Input$1.Wrapper, { error: error },
2912
- React__default.createElement(Checkbox$1, Object.assign({ value: value, name: 'TNC-' + id, label: React__default.createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, formInputProps)))));
2913
- default: {
2914
- return null;
2915
- }
2916
- }
2917
- }))));
2918
- });
2919
-
2920
- const LEADGEN_ORDER_INPUT_WRAPPER = ['label', 'input', 'description', 'error'];
2921
-
2922
- const LeadGenSubscriptionBoxA = (props) => {
2923
- const { loading, image, title, submitText, locale, blocks, form, rules, onFinish, } = props;
2924
- const formRef = useRef();
2925
- const imageComp = useMemo(() => {
2926
- if (!image) {
2927
- return null;
2928
- }
2929
- return (React__default.createElement(StyledLeadGenSubscriptionBoxHeaderImage, null,
2930
- React__default.createElement("img", { src: image, alt: "" })));
2931
- }, [image]);
2932
- const titleComp = useMemo(() => {
2933
- if (typeof title === 'string') {
2934
- return (React__default.createElement("p", { className: "leadgen-title", dangerouslySetInnerHTML: { __html: title } }));
2935
- }
2936
- return React__default.createElement("p", { className: "leadgen-title" }, title);
2937
- }, [title]);
2938
- return (React__default.createElement(StyledLeadGenSubscriptionBoxA, { className: "subcription_box_A" },
2939
- React__default.createElement(StyledLeadGenSubscriptionBoxHeader, { className: "leadgen-subscription_box_header" },
2940
- imageComp,
2941
- titleComp),
2942
- React__default.createElement(StyledLeadGenSubscriptionBoxBody, { className: "leadgen-subscription_box_body" },
2943
- React__default.createElement(LeadGenForm, { ref: formRef, form: form, rules: rules, blocks: blocks, locale: locale, onFinish: onFinish, className: "leadgen-subscription_box_form" }),
2944
- React__default.createElement(Button$1, { disabled: loading, loading: loading, variant: "filled", size: "lg", onClick: () => {
2945
- formRef.current.submit();
2946
- }, className: "leadgen-btn leadgen-btn_action", fullWidth: true }, submitText))));
2947
- };
2948
-
2949
- const LeadGenSubscriptionBoxWithoutMemo = ({ locale, userInfo, forceCampaign, categoryId, }) => {
2950
- var _a, _b, _c;
2951
- const { image, extra_fields, id: campaign_id, bot_id: campaign_subot_id = [], ThankYouBlock, } = forceCampaign || {};
2952
- const { textBlocks, listBlockAdded, actionBlocks } = extra_fields || {};
2953
- const { submitBlock } = actionBlocks || {};
2954
- const { apiLeadUrl, subscriptionIcon, subscriptionTitle, submitSubscriptionBox, impression, onFinish, } = useLeadGenContext();
2955
- const { t } = useTranslations();
2956
- const { action: { pushNotifications }, } = useContext(TogetherComponentGlobalContext);
2957
- const refContainer = useRef(null);
2958
- const [loading, setLoading] = useState(false);
2959
- const [showThankyou, setShowThankyou] = useState(false);
2960
- const validatingEmailRef = useRef(false);
2961
- const validatingPhoneRef = useRef(false);
2962
- const { form, validateObj } = useLeadFormConfig({
2963
- listBlockAdded,
2964
- campaignId: campaign_id,
2965
- campaign_subot_id,
2966
- validatingEmailRef,
2967
- validatingPhoneRef,
2968
- userInfo,
2969
- });
2970
- const subscription_title = useMemo(() => {
2971
- var _a, _b;
2972
- return subscriptionTitle ||
2973
- ((_b = (_a = textBlocks === null || textBlocks === void 0 ? void 0 : textBlocks.titleBlock) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value) ||
2974
- t('leadgen.message.title.default');
2975
- }, [subscriptionTitle, (_b = (_a = textBlocks === null || textBlocks === void 0 ? void 0 : textBlocks.titleBlock) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value]);
2976
- const { image: thankyouImage, title: thankyouTitle, description: thankyouDescription, button: thankyouButton, } = ThankYouBlock || {};
2977
- const intersectionObserverCallback = useCallback((entries) => {
2978
- entries.forEach((entry) => {
2979
- const { isIntersecting, target } = entry;
2980
- if (!showThankyou &&
2981
- isIntersecting &&
2982
- target === refContainer.current) {
2983
- impression();
2984
- }
2985
- });
2986
- }, [impression, showThankyou]);
2987
- const IObserver = new IntersectionObserver(intersectionObserverCallback);
2988
- const middlewareOnSubmit = useCallback((values) => __awaiter(void 0, void 0, void 0, function* () {
2989
- const newValues = {
2990
- subscription_title,
2991
- };
2992
- const ssoValues = {
2993
- sso_user_id: undefined,
2994
- sso_uuid: undefined,
2995
- sso_verified_profile: undefined,
2996
- };
2997
- const valueKeys = Object.keys(values);
2998
- for (const key of valueKeys) {
2999
- const isPhoneField = leadGenFieldNamePhone(listBlockAdded).some((k) => k === key);
3000
- if (isPhoneField) {
3001
- const phone = parsePhoneNumber(values[key]);
3002
- if (phone.isValid()) {
3003
- /** Seperate `area_code` and `phone_number` for BE */
3004
- newValues['area_code'] = `+${phone.countryCallingCode}`;
3005
- newValues['phone_number'] = phone.nationalNumber;
3006
- /** Only case login has this update */
3007
- if ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) && (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid)) {
3008
- ssoValues['sso_verified_profile'] =
3009
- phone.number === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone) ? 1 : 0;
3010
- ssoValues['sso_user_id'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.id;
3011
- ssoValues['sso_uuid'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid;
3012
- }
3013
- }
3014
- continue;
3015
- }
3016
- newValues[key] = values[key];
3017
- }
3018
- setLoading(true);
3019
- try {
3020
- const { _data } = (yield submitSubscriptionBox(Object.assign(Object.assign({}, newValues), ssoValues))) || {};
3021
- const { model } = _data || {};
3022
- if (model && (model === null || model === void 0 ? void 0 : model.id)) {
3023
- setShowThankyou(true);
3024
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(Object.assign(Object.assign({}, newValues), ssoValues), listBlockAdded || []);
3025
- }
3026
- }
3027
- catch (error) {
3028
- LeadLog('** LeadGen SubscriptionBox error : ', error);
3029
- pushNotifications({
3030
- message: t('leadgen.message.error.default'),
3031
- type: 'danger',
3032
- });
3033
- }
3034
- setLoading(false);
3035
- }), [
3036
- subscription_title,
3037
- listBlockAdded,
3038
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
3039
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid,
3040
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone,
3041
- ]);
3042
- useEffect(() => {
3043
- if (refContainer.current) {
3044
- IObserver.observe(refContainer.current);
3045
- }
3046
- return () => {
3047
- IObserver.disconnect();
3048
- };
3049
- }, [categoryId]);
3050
- return (React__default.createElement("div", { ref: refContainer },
3051
- React__default.createElement(StyledLeadGenSubscriptionBox, null,
3052
- showThankyou && (React__default.createElement(LeadGenThankYou, { image: Object.assign(Object.assign({}, thankyouImage), { src: thankyouImage.src || `${apiLeadUrl}admin/img/thanksyou.png` }), title: thankyouTitle, description: thankyouDescription, button: thankyouButton })),
3053
- !showThankyou && (React__default.createElement(LeadGenSubscriptionBoxA, { loading: loading, image: subscriptionIcon || image, title: subscription_title, submitText: (_c = submitBlock === null || submitBlock === void 0 ? void 0 : submitBlock.data) === null || _c === void 0 ? void 0 : _c.value, blocks: listBlockAdded, locale: locale, form: form, rules: validateObj, onFinish: middlewareOnSubmit })))));
3054
- };
3055
- const LeadGenSubscriptionBox$1 = memo(LeadGenSubscriptionBoxWithoutMemo);
3056
-
3057
- const Container = () => {
3058
- const context = useContext(LeadGenContext);
3059
- const { campaign_code, locale, siteId, siteDomain, userInfo, forceCampaign } = context;
3060
- if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
3061
- return null;
3062
- }
3063
- return (React__default.createElement(LeadGenSubscriptionBox$1, { locale: locale, siteId: siteId, siteDomain: siteDomain, userInfo: userInfo, forceCampaign: forceCampaign, campaign_code: campaign_code }));
3064
- };
3065
- Container.displayName = 'LeadGenSubscriptionBox';
3066
- const LeadGenSubscriptionBoxContainer = (props) => {
3067
- const { apiUrl, apiSubotUrl } = props;
3068
- return (React__default.createElement(LeadGenContextProvider, Object.assign({}, props, { apiLeadUrl: apiUrl, apiSubotUrl: apiSubotUrl }),
3069
- React__default.createElement(Container, null)));
3070
- };
3071
- const LeadGenSubscriptionBox = LeadGenSubscriptionBoxContainer;
3072
-
3073
- const useImageSize = (src) => {
3074
- const [width, setWidth] = useState(16);
3075
- const [height, setHeight] = useState(9);
3076
- const [loaded, setLoaded] = useState(false);
3077
- // load src image to get its width and height
3078
- useEffect(() => {
3079
- setLoaded(false);
3080
- if (src) {
3081
- const img = new Image();
3082
- img.addEventListener('load', () => {
3083
- setWidth(img.naturalWidth);
3084
- setHeight(img.naturalHeight);
3085
- setLoaded(true);
3086
- });
3087
- img.addEventListener('error', () => {
3088
- setWidth(16);
3089
- setHeight(9);
3090
- setLoaded(true);
3091
- });
3092
- img.src = src;
3093
- }
3094
- else {
3095
- setWidth(16);
3096
- setHeight(9);
3097
- setLoaded(true);
3098
- }
3099
- }, [src]);
3100
- return {
3101
- loaded,
3102
- width,
3103
- height,
3104
- };
3105
- };
3106
-
3107
- const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default.createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
3108
- React__default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
3109
- React__default.createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
3110
-
3111
- // url: imageBlocks.imageMobile.data.url
3112
- // newTab: imageBlocks.imageMobile.data.newtab
3113
- // imageMobile: campaignShow.image
3114
- // imageDestkop: campaignShow.image_desktop
3115
- const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
3116
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3117
- const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
3118
- if (!imageMobileLoaded || !imageDestkopLoaded)
1374
+ const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default.createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
1375
+ React__default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
1376
+ React__default.createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
1377
+
1378
+ // url: imageBlocks.imageMobile.data.url
1379
+ // newTab: imageBlocks.imageMobile.data.newtab
1380
+ // imageMobile: campaignShow.image
1381
+ // imageDestkop: campaignShow.image_desktop
1382
+ const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
1383
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1384
+ const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
1385
+ if (!imageMobileLoaded || !imageDestkopLoaded)
3119
1386
  return null;
3120
1387
  return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
3121
1388
  React__default.createElement("div", { className: "le-center-tab-popup" },
@@ -3184,7 +1451,7 @@ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, su
3184
1451
  };
3185
1452
 
3186
1453
  const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
3187
- const { primaryColor } = useContext(LeadGenContext$1);
1454
+ const { primaryColor } = useContext(LeadGenContext);
3188
1455
  const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
3189
1456
  if (!imageLoaded)
3190
1457
  return null;
@@ -3352,6 +1619,211 @@ const EmptyComponent = ({ onClose, onContinue, }) => {
3352
1619
  React__default.createElement(Button$1, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
3353
1620
  };
3354
1621
 
1622
+ const libraries = ['places'];
1623
+ const GoogleLocationBlock = (props) => {
1624
+ var _a;
1625
+ const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = __rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
1626
+ const [LoadScript, setLoadScript] = useState(null);
1627
+ const [value, setValue] = useState(defaultValue || valueProps);
1628
+ const { predictions } = usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
1629
+ const onChangeAutocomplete = useCallback((s) => {
1630
+ setValue(s);
1631
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
1632
+ }, []);
1633
+ const onClickItem = useCallback((item) => {
1634
+ /** For sure get value */
1635
+ setValue(item.value);
1636
+ const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
1637
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
1638
+ }, [onChangeProps, predictions]);
1639
+ useEffect(() => {
1640
+ setValue(valueProps);
1641
+ }, [valueProps]);
1642
+ useEffect(() => {
1643
+ var _a, _b, _c;
1644
+ // only load extra google script when not yet loaded
1645
+ if (!((_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.places) === null || _c === void 0 ? void 0 : _c.AutocompleteService) && !LoadScript) {
1646
+ import('@react-google-maps/api').then((m) => {
1647
+ setLoadScript(() => m.LoadScript);
1648
+ });
1649
+ }
1650
+ }, []);
1651
+ return (React__default.createElement(Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
1652
+ return { value: pred.description, label: pred.description };
1653
+ }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
1654
+ return (React__default.createElement(React__default.Fragment, null,
1655
+ LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default.createElement(React__default.Fragment, null), style: { width: '100%' } })),
1656
+ children));
1657
+ } }, restProps)));
1658
+ };
1659
+
1660
+ // You can give context variables any name
1661
+ const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
1662
+ const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, }) => {
1663
+ const { t } = useTranslations();
1664
+ const initialValues = useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
1665
+ const validateObj = useMemo(() => {
1666
+ const InputBlocks = [
1667
+ 'TextBlock',
1668
+ 'NumberBlock',
1669
+ 'EmailBlock',
1670
+ 'PhoneBlock',
1671
+ 'DateBlock',
1672
+ 'CheckboxBlock',
1673
+ 'RadioBlock',
1674
+ 'DropdownBlock',
1675
+ 'PhoneOtpBlock',
1676
+ 'WhatsappOtpBlock',
1677
+ 'ZaloOtpBlock',
1678
+ 'LocationBlock',
1679
+ 'TncBlock',
1680
+ ];
1681
+ // ALL are required and can skip if not touched yet
1682
+ const withSharedCheck = (name, cb,
1683
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1684
+ block) => {
1685
+ return (value) => {
1686
+ var _a;
1687
+ const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
1688
+ if (!formRef.current.isTouched(name))
1689
+ return;
1690
+ if ((typeof value === 'string' && value.replace(' ', '') === '') ||
1691
+ typeof value === 'undefined' ||
1692
+ value === '' ||
1693
+ (Array.isArray(value) && value.length === 0)) {
1694
+ return isBLockRequired
1695
+ ? t('validator.required')
1696
+ : cb === null || cb === void 0 ? void 0 : cb(value);
1697
+ }
1698
+ return cb === null || cb === void 0 ? void 0 : cb(value);
1699
+ };
1700
+ };
1701
+ return listBlockAdded
1702
+ .filter((b) => InputBlocks.includes(b.name))
1703
+ .reduce((r, b) => {
1704
+ var _a;
1705
+ const isRequired = (_a = b.data.required) !== null && _a !== void 0 ? _a : true;
1706
+ if (b.name === 'NumberBlock') {
1707
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1708
+ if (value && isNaN(Number(value))) {
1709
+ return t('validator.number');
1710
+ }
1711
+ }, b) });
1712
+ }
1713
+ else if (b.name === 'EmailBlock') {
1714
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1715
+ if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
1716
+ return t('validator.email');
1717
+ }
1718
+ if (!value)
1719
+ return;
1720
+ validatingEmailRef.current = true;
1721
+ setTimeout(() => {
1722
+ formRef.current.setFieldError(b.data.value, 'Validating...');
1723
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1724
+ email: value,
1725
+ })
1726
+ .then((tKey) => {
1727
+ if (tKey) {
1728
+ formRef.current.setFieldError(b.data.value, t(tKey));
1729
+ }
1730
+ else {
1731
+ formRef.current.clearFieldError(b.data.value);
1732
+ }
1733
+ validatingEmailRef.current = false;
1734
+ })
1735
+ .catch((e) => {
1736
+ console.error(e);
1737
+ formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
1738
+ validatingEmailRef.current = false;
1739
+ });
1740
+ }, 200);
1741
+ }, b) });
1742
+ }
1743
+ else if (b.name === 'PhoneBlock' ||
1744
+ b.name === 'PhoneOtpBlock' ||
1745
+ b.name === 'ZaloOtpBlock' ||
1746
+ b.name === 'WhatsappOtpBlock') {
1747
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1748
+ if (value &&
1749
+ window.intlTelInputUtils &&
1750
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
1751
+ return t('validator.phone');
1752
+ }
1753
+ if (!value)
1754
+ return;
1755
+ validatingPhoneRef.current = true;
1756
+ setTimeout(() => {
1757
+ formRef.current.setFieldError(b.data.value, 'Validating...');
1758
+ if (b.data.singleSubmission) {
1759
+ checkUsedPhoneOnlyWithCache(campaignId, value)
1760
+ .then((tKey) => {
1761
+ if (tKey) {
1762
+ formRef.current.setFieldError(b.data.value, t(tKey));
1763
+ }
1764
+ else {
1765
+ formRef.current.clearFieldError(b.data.value);
1766
+ }
1767
+ validatingPhoneRef.current = false;
1768
+ })
1769
+ .catch((err) => {
1770
+ console.error(err);
1771
+ formRef.current.setFieldError(b.data.value, err.message || 'Something went wrong');
1772
+ validatingPhoneRef.current = false;
1773
+ });
1774
+ }
1775
+ else {
1776
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1777
+ phone: value,
1778
+ })
1779
+ .then((tKey) => {
1780
+ if (tKey) {
1781
+ formRef.current.setFieldError(b.data.value, t(tKey));
1782
+ }
1783
+ else {
1784
+ formRef.current.clearFieldError(b.data.value);
1785
+ }
1786
+ validatingPhoneRef.current = false;
1787
+ })
1788
+ .catch((e) => {
1789
+ console.error(e);
1790
+ formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
1791
+ validatingPhoneRef.current = false;
1792
+ });
1793
+ }
1794
+ }, 200);
1795
+ }, b) });
1796
+ }
1797
+ else if (b.name === 'DateBlock') {
1798
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1799
+ if (value && isNaN(Date.parse(value))) {
1800
+ return t('validator.date');
1801
+ }
1802
+ }, b) });
1803
+ }
1804
+ else if (b.name === 'TncBlock') {
1805
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
1806
+ if (isRequired && !value) {
1807
+ return t('validator.required');
1808
+ }
1809
+ }, b) });
1810
+ }
1811
+ else {
1812
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, undefined, b) });
1813
+ }
1814
+ }, {});
1815
+ }, [listBlockAdded.map((b) => b.name).join(',')]);
1816
+ const form = useLeadForm({
1817
+ validateInputOnChange: true,
1818
+ clearInputErrorOnChange: true,
1819
+ validate: validateObj,
1820
+ initialValues,
1821
+ });
1822
+ const formRef = useRef(form);
1823
+ formRef.current = form;
1824
+ return { form, validateObj };
1825
+ };
1826
+
3355
1827
  const SubtitleBlock = ({ children, align, }) => (React__default.createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
3356
1828
 
3357
1829
  const cssInputNotShrink = css `
@@ -3678,13 +2150,11 @@ const TextField = (props) => {
3678
2150
  const $focusEl = $textEl.item($textEl.length - 1);
3679
2151
  if ($focusEl) {
3680
2152
  $focusEl.focus();
3681
- setTimeout(() => {
3682
- $focusEl.scrollIntoView({
3683
- behavior: 'auto',
3684
- block: 'center',
3685
- inline: 'start',
3686
- });
3687
- }, 100);
2153
+ $focusEl.scrollIntoView({
2154
+ behavior: 'auto',
2155
+ block: 'center',
2156
+ inline: 'start',
2157
+ });
3688
2158
  }
3689
2159
  }, [shrink]);
3690
2160
  useEffect(() => {
@@ -3701,14 +2171,8 @@ const ChoiceField = (props) => {
3701
2171
  const TitleBlock = ({ children, align, }) => (React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
3702
2172
 
3703
2173
  const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, }) => {
3704
- const { t } = useTranslations();
3705
2174
  const form = useLeadFormContext();
3706
2175
  const formValues = form.values;
3707
- const labelTuples = useMemo(() => {
3708
- return ((ISO_FORMAT === null || ISO_FORMAT === void 0 ? void 0 : ISO_FORMAT[locale]) || ISO_FORMAT['vi-VN']).dateFormat
3709
- .split('/')
3710
- .map((key) => { var _a; return t((_a = COMMON_DATE_TRANSLATE_KEY === null || COMMON_DATE_TRANSLATE_KEY === void 0 ? void 0 : COMMON_DATE_TRANSLATE_KEY[key]) === null || _a === void 0 ? void 0 : _a.id); });
3711
- }, [locale]);
3712
2176
  return (React__default.createElement(React__default.Fragment, null, listBlockAdded.map((b, index) => {
3713
2177
  var _a;
3714
2178
  const { name = '', data = {}, id } = b || {};
@@ -3758,11 +2222,13 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
3758
2222
  return (React__default.createElement(TextField, { key: index, shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field" },
3759
2223
  React__default.createElement(GoogleLocationBlock, Object.assign({ withAsterisk: required, name: value, placeholder: placeholder, label: placeholder, "data-control": "text", locale: locale, inputWrapperOrder: ['label', 'input', 'description', 'error'] }, form.getInputProps(value)))));
3760
2224
  }
3761
- case 'DateBlock': {
3762
- const _c = form.getInputProps(value), { error } = _c, formInputProps = __rest(_c, ["error"]);
3763
- return (React__default.createElement(Input$1.Wrapper, { key: index, size: "md", withAsterisk: required, label: placeholder, "data-invalid": !!error, inputWrapperOrder: ['label', 'input', 'description', 'error'], error: error, className: "lead-modal__form-control leadgen-form_field" },
3764
- React__default.createElement(InputDate, Object.assign({ name: value, error: Boolean(error), locale: locale, "data-extra": true, "data-name": value, "data-control": "date", className: "leadgen-form_field_date", labelTuples: labelTuples }, formInputProps))));
3765
- }
2225
+ case 'DateBlock':
2226
+ return (React__default.createElement(TextField, { key: index, shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field" },
2227
+ React__default.createElement(DatePicker, Object.assign({ clearable: true, withAsterisk: required, type: "default", name: value, placeholder: placeholder, label: placeholder, inputWrapperOrder: ['label', 'input', 'description', 'error'], inputContainer: (children) => {
2228
+ return (React__default.createElement(React__default.Fragment, null,
2229
+ children,
2230
+ React__default.createElement("input", { type: "hidden", "data-control": "date", name: value, value: formValue })));
2231
+ } }, form.getInputProps(value)))));
3766
2232
  case 'LinkButtonBlock':
3767
2233
  return (React__default.createElement("div", { key: index },
3768
2234
  React__default.createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
@@ -3805,7 +2271,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
3805
2271
  label: l.placeholder,
3806
2272
  })) }, form.getInputProps(value)))));
3807
2273
  case 'TncBlock':
3808
- const _d = form.getInputProps(`TNC-${id}`), { error } = _d, tncInputProps = __rest(_d, ["error"]);
2274
+ const _c = form.getInputProps(`TNC-${id}`), { error } = _c, tncInputProps = __rest(_c, ["error"]);
3809
2275
  return (React__default.createElement(ChoiceField, { className: "leadgen-form_checkbox", key: id },
3810
2276
  React__default.createElement(Input$1.Wrapper, { error: error },
3811
2277
  React__default.createElement(Checkbox, Object.assign({ name: 'TNC-' + id, label: React__default.createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps)))));
@@ -3915,7 +2381,7 @@ const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
3915
2381
  };
3916
2382
 
3917
2383
  const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
3918
- const { primaryColor } = useContext(LeadGenContext$1);
2384
+ const { primaryColor } = useContext(LeadGenContext);
3919
2385
  const { t } = useTranslations();
3920
2386
  const phone = otpData.phone;
3921
2387
  const otpType = otpData.type;
@@ -4001,371 +2467,709 @@ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
4001
2467
  // type: 'danger',
4002
2468
  // })
4003
2469
  }
4004
- setIsSubmitLoading(false);
4005
- });
4006
- useEffect(() => {
4007
- setTimeout(() => {
4008
- if (resendTimer > 0) {
4009
- setResendTimer((r) => r - 1);
4010
- }
4011
- }, 1000);
4012
- }, [resendTimer]);
4013
- useEffect(() => {
4014
- if (autoSendWhenOpen && !resendTimer) {
4015
- sendOtp();
2470
+ setIsSubmitLoading(false);
2471
+ });
2472
+ useEffect(() => {
2473
+ setTimeout(() => {
2474
+ if (resendTimer > 0) {
2475
+ setResendTimer((r) => r - 1);
2476
+ }
2477
+ }, 1000);
2478
+ }, [resendTimer]);
2479
+ useEffect(() => {
2480
+ if (autoSendWhenOpen && !resendTimer) {
2481
+ sendOtp();
2482
+ }
2483
+ }, []);
2484
+ return (React__default.createElement("form", { onSubmit: (e) => {
2485
+ e.preventDefault();
2486
+ submitOtp();
2487
+ }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
2488
+ React__default.createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
2489
+ phone: `<strong>${displayPhone}</strong>`,
2490
+ }), footer: React__default.createElement(React__default.Fragment, null,
2491
+ React__default.createElement(Button$1, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
2492
+ React__default.createElement(Button$1, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
2493
+ sendOtp();
2494
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
2495
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
2496
+ }))) },
2497
+ React__default.createElement("div", { className: "leadgen-form_inner" },
2498
+ React__default.createElement(Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
2499
+ React__default.createElement(OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
2500
+ setIsDirty(true);
2501
+ setOtp(v.toString());
2502
+ if (isDirty && !v)
2503
+ setErrorMsg('OTP is required');
2504
+ else
2505
+ setErrorMsg(undefined);
2506
+ } }))))));
2507
+ };
2508
+
2509
+ // url: imageBlocks.imageMobile.data.url
2510
+ // newTab: imageBlocks.imageMobile.data.newtab
2511
+ // image: campaignShow.image
2512
+ // imageDestkop: campaignShow.image_desktop
2513
+ const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
2514
+ LEADGEN_LAYOUT.Fullscreen,
2515
+ LEADGEN_LAYOUT.Slider,
2516
+ ];
2517
+ const LEADGEN_LIMIT_LIGHTBOXB = 6;
2518
+ const LEADGEN_SHOW_HEADER = [
2519
+ 'LightBoxA',
2520
+ 'InlineA',
2521
+ LEADGEN_LAYOUT.Sidebar,
2522
+ LEADGEN_LAYOUT.Slider,
2523
+ ];
2524
+ const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2525
+ var _a;
2526
+ const { primaryColor } = useContext(LeadGenContext);
2527
+ const { isMobile } = useScreenSize();
2528
+ const [open, setOpen] = useState(!!campaignId);
2529
+ const [showOtpPhone, setShowOtpPhone] = useState(null);
2530
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
2531
+ const [snap, setSnap] = useState(0.8);
2532
+ const formRef = useRef();
2533
+ const onClose = () => {
2534
+ if (showOtpPhone) {
2535
+ setShowOtpPhone(null);
2536
+ }
2537
+ else {
2538
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2539
+ }
2540
+ };
2541
+ const textBlocks = JSON.parse(extraFields.textBlocks);
2542
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
2543
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
2544
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
2545
+ const currentPath = location.pathname;
2546
+ const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
2547
+ const { align: titleAlign } = textBlocks.titleBlock.data || {};
2548
+ const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
2549
+ const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
2550
+ const isLightBox = currentLayout.includes('LightBox');
2551
+ const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
2552
+ const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
2553
+ const isInline = currentLayout.includes('Inline');
2554
+ const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
2555
+ const isInPage = isInline || isSidebar;
2556
+ const isDrawer = isLightBoxB && isMobile;
2557
+ const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
2558
+ const hasForm = isLightBoxA
2559
+ ? listBlockAdded.some((item) => LEADGEN_BLOCK_IN_FORM.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
2560
+ : true;
2561
+ const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
2562
+ const showHeader = !!imageMobile || !!imageDesktop;
2563
+ const onlyHeader = !title && !description;
2564
+ const showButtonClose = !isInline;
2565
+ if (window.innerWidth < 769 &&
2566
+ LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
2567
+ console.log('😎 Not show fullscreen, slider on mobile ');
2568
+ return null;
2569
+ }
2570
+ useEffect(() => {
2571
+ if (isLightBox || isFullscreen) {
2572
+ document.body.classList.add('noscroll');
2573
+ }
2574
+ if (!window.intlTelInputUtils) {
2575
+ require('intl-tel-input/build/js/utils');
2576
+ }
2577
+ clearCacheUsedEmailOrPhone();
2578
+ }, []);
2579
+ const validatingPhoneRef = useRef(false);
2580
+ const validatingEmailRef = useRef(false);
2581
+ const { form, validateObj } = useLeadFormConfig({
2582
+ listBlockAdded,
2583
+ validatingPhoneRef,
2584
+ validatingEmailRef,
2585
+ campaignId,
2586
+ campaign_subot_id,
2587
+ userInfo,
2588
+ });
2589
+ const middlewareOnSubmit = (e) => {
2590
+ e.preventDefault();
2591
+ // mark all as touched to allow validation
2592
+ form.setTouched(Object.keys(validateObj).reduce((acc, cur) => {
2593
+ acc[cur] = true;
2594
+ return acc;
2595
+ }, {}));
2596
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
2597
+ return;
2598
+ }
2599
+ setTimeout(() => {
2600
+ form.onSubmit((v) => {
2601
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2602
+ if (Object.keys(form.errors).length)
2603
+ return;
2604
+ let newShowOtpPhone = null;
2605
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
2606
+ // not submit yet, open otp
2607
+ 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;
2608
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
2609
+ newShowOtpPhone = {
2610
+ phone: v[fieldName],
2611
+ type: 'phone',
2612
+ };
2613
+ }
2614
+ }
2615
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
2616
+ // not submit yet, open otp
2617
+ 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;
2618
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
2619
+ newShowOtpPhone = {
2620
+ phone: v[fieldName],
2621
+ type: 'whatsapp',
2622
+ };
2623
+ }
2624
+ }
2625
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
2626
+ // not submit yet, open otp
2627
+ 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;
2628
+ if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
2629
+ newShowOtpPhone = {
2630
+ phone: v[fieldName],
2631
+ type: 'zalo',
2632
+ };
2633
+ }
2634
+ }
2635
+ if (newShowOtpPhone) {
2636
+ setIsSubmitLoading(true);
2637
+ Service.sendSMSOtpLead(newShowOtpPhone)
2638
+ .then((res) => {
2639
+ var _a;
2640
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2641
+ if (respMessage === 'This phone number was verified') {
2642
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2643
+ return;
2644
+ }
2645
+ setShowOtpPhone(newShowOtpPhone);
2646
+ })
2647
+ .finally(() => {
2648
+ setIsSubmitLoading(false);
2649
+ });
2650
+ return;
2651
+ }
2652
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2653
+ })(e);
2654
+ }, 100);
2655
+ };
2656
+ const onOpenChange = (_open) => {
2657
+ setOpen(_open);
2658
+ if (!_open) {
2659
+ setTimeout(() => {
2660
+ onClose();
2661
+ }, 250);
2662
+ }
2663
+ };
2664
+ const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
2665
+ const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
2666
+ const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
2667
+ const renderAfterImageSizes = imageMobileLoaded &&
2668
+ imageDesktopLoaded &&
2669
+ (isFullscreen ? imageBackgroundLoaded : true);
2670
+ const ButtonSubmit = !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default.createElement(Button$1, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, loading: isSubmitLoading }, popUpSubmitText));
2671
+ const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
2672
+ const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default.createElement(React__default.Fragment, null, LinkButtonBlock.map((item, index) => {
2673
+ var _a, _b, _c;
2674
+ return (React__default.createElement(Button$1, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
2675
+ onClose === null || onClose === void 0 ? void 0 : onClose();
2676
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2677
+ } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
2678
+ })));
2679
+ const PopupHeader = showHeader && (React__default.createElement("header", { className: clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default.createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default.createElement(React__default.Fragment, null,
2680
+ React__default.createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
2681
+ React__default.createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
2682
+ const PopupEmpty = showEmpty && (React__default.createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
2683
+ const PopupForm = (React__default.createElement(LeadFormProvider, { form: form },
2684
+ React__default.createElement("form", { ref: formRef, className: "leadgen-form", onSubmit: middlewareOnSubmit },
2685
+ React__default.createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
2686
+ React__default.createElement("div", { className: "leadgen-form_inner" },
2687
+ React__default.createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
2688
+ const PopupOtp = showOtpPhone && (React__default.createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
2689
+ setShowOtpPhone(null);
2690
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
2691
+ } }));
2692
+ const PopupThankYou = showThankyou && (React__default.createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
2693
+ const PopupContent = (React__default.createElement("div", { className: clsx('leadgen-content', {
2694
+ 'leadgen-content_small': limitFieldsLightBoxB,
2695
+ }) },
2696
+ !headerInsideFormContainer && PopupHeader,
2697
+ !onlyHeader && (React__default.createElement("div", { className: "leadgen-inner" },
2698
+ PopupThankYou,
2699
+ !showThankyou && (React__default.createElement(React__default.Fragment, null,
2700
+ PopupOtp,
2701
+ PopupEmpty,
2702
+ !(showOtpPhone || showEmpty) && PopupForm))))));
2703
+ const styleOverlay = useMemo(() => {
2704
+ let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
2705
+ if (isMobile && imageOverlayMobile) {
2706
+ styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
2707
+ }
2708
+ if (!isMobile && imageOverlayDesktop) {
2709
+ styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4016
2710
  }
4017
- }, []);
4018
- return (React__default.createElement("form", { onSubmit: (e) => {
4019
- e.preventDefault();
4020
- submitOtp();
4021
- }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
4022
- React__default.createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
4023
- phone: `<strong>${displayPhone}</strong>`,
4024
- }), footer: React__default.createElement(React__default.Fragment, null,
4025
- React__default.createElement(Button$1, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
4026
- React__default.createElement(Button$1, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
4027
- sendOtp();
4028
- }, disabled: !!resendTimer }, t('lead.otp.resend', {
4029
- timer: resendTimer ? ` (${resendTimer}s)` : '',
4030
- }))) },
4031
- React__default.createElement("div", { className: "leadgen-form_inner" },
4032
- React__default.createElement(Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
4033
- React__default.createElement(OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
4034
- setIsDirty(true);
4035
- setOtp(v.toString());
4036
- if (isDirty && !v)
4037
- setErrorMsg('OTP is required');
4038
- else
4039
- setErrorMsg(undefined);
4040
- } }))))));
2711
+ return styleContent;
2712
+ }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
2713
+ const PopupWrapper = (React__default.createElement(React__default.Fragment, null,
2714
+ React__default.createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
2715
+ React__default.createElement("div", { className: clsx('leadgen-wrapper', {
2716
+ 'leadgen-wrapper_small': limitFieldsLightBoxB,
2717
+ }) },
2718
+ showButtonClose && (React__default.createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
2719
+ PopupContent)));
2720
+ const popupContainerClassName = clsx('leadgen', `leadgen-${currentLayout}`, {
2721
+ 'leadgen-lightbox': isLightBox,
2722
+ 'leadgen-inline': isInPage,
2723
+ 'leadgen-slider': isSlider,
2724
+ });
2725
+ const PopupContainer = isDrawer ? (React__default.createElement(DrawerComponent, { fadeFromIndex: ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
2726
+ PopupWrapper,
2727
+ React__default.createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default.createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
2728
+ isFullscreen ? (React__default.createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
2729
+ aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
2730
+ } })) : null,
2731
+ PopupWrapper));
2732
+ if (!renderAfterImageSizes)
2733
+ return null;
2734
+ if (isLightBox || isFullscreen || isSlider) {
2735
+ return PopupContainer;
2736
+ }
2737
+ else if (isSidebar) {
2738
+ return React__default.createElement(SideBarLayout, { content: PopupContainer });
2739
+ }
2740
+ else if (isInline) {
2741
+ return (React__default.createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
2742
+ }
2743
+ return null;
2744
+ };
2745
+
2746
+ const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
2747
+ const currentPath = location.pathname;
2748
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
2749
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
2750
+ if (!imageMobileLoaded || !imageDesktopLoaded)
2751
+ return null;
2752
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
2753
+ currentLayout == 'SkinA' ? (React__default.createElement("aside", { className: "le-only-desktop" },
2754
+ React__default.createElement("div", { className: "le-skin-a-desktop" },
2755
+ React__default.createElement("div", { style: { position: 'relative' } },
2756
+ React__default.createElement("img", { src: imageDesktop, style: {
2757
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2758
+ } }),
2759
+ React__default.createElement("a", { style: {
2760
+ position: 'absolute',
2761
+ top: '75%',
2762
+ left: '50%',
2763
+ transform: 'translate(-50%, -50%)',
2764
+ textAlign: 'center',
2765
+ width: 'calc(100% - 15px)',
2766
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2767
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
2768
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default.createElement("aside", { className: "le-only-desktop" },
2769
+ React__default.createElement("div", { className: "" },
2770
+ React__default.createElement("div", { style: { position: 'relative', zIndex: 10000 } },
2771
+ React__default.createElement("img", { src: imageDesktop, style: {
2772
+ width: '100%',
2773
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2774
+ } }),
2775
+ React__default.createElement("a", { style: {
2776
+ position: 'absolute',
2777
+ top: '75%',
2778
+ left: '50%',
2779
+ transform: 'translate(-50%, -50%)',
2780
+ textAlign: 'center',
2781
+ width: '100%',
2782
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2783
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2784
+ React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
2785
+ React__default.createElement("aside", { className: "le-only-mobile" },
2786
+ React__default.createElement("div", { className: "le-skin-mobile" },
2787
+ React__default.createElement("div", { style: { position: 'relative' } },
2788
+ isVideo(imageMobile) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true },
2789
+ React__default.createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default.createElement("img", { src: imageMobile, style: {
2790
+ width: '100%',
2791
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
2792
+ } })),
2793
+ React__default.createElement("a", { style: {
2794
+ position: 'absolute',
2795
+ top: '82%',
2796
+ left: '50%',
2797
+ transform: 'translate(-50%, -50%)',
2798
+ textAlign: 'center',
2799
+ maxWidth: 'calc(100% - 15px)',
2800
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2801
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2802
+ React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4041
2803
  };
4042
2804
 
4043
2805
  // url: imageBlocks.imageMobile.data.url
4044
2806
  // newTab: imageBlocks.imageMobile.data.newtab
4045
2807
  // image: campaignShow.image
4046
2808
  // imageDestkop: campaignShow.image_desktop
4047
- const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
4048
- LEADGEN_LAYOUT.Fullscreen,
4049
- LEADGEN_LAYOUT.Slider,
4050
- ];
4051
- const LEADGEN_LIMIT_LIGHTBOXB = 6;
4052
- const LEADGEN_SHOW_HEADER = [
4053
- 'LightBoxA',
4054
- 'InlineA',
4055
- LEADGEN_LAYOUT.Sidebar,
4056
- LEADGEN_LAYOUT.Slider,
4057
- ];
4058
- const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2809
+ const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
2810
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
2811
+ if (!imageLoaded)
2812
+ return null;
2813
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
2814
+ React__default.createElement("div", { className: "le-tab-popup" },
2815
+ React__default.createElement("div", { style: { position: 'relative' } },
2816
+ React__default.createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
2817
+ React__default.createElement("img", { className: "js-popup-other-submit", src: image, style: {
2818
+ aspectRatio: `${imageWidth}/${imageHeight}`,
2819
+ } })),
2820
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
2821
+ };
2822
+
2823
+ // import mockLeadData from './mockLeadData'
2824
+ const listCampaignScheduled = [];
2825
+ const listCampaignScheduledToActivated = [];
2826
+ const listCampaignActiveButExpired = [];
2827
+ const listCampaignExcludeSonsored = [];
2828
+ const listCampaignDifferentSponsor = [];
2829
+ const listCampaignNotDisplayInRangeOfTime = [];
2830
+ function isMobile() {
2831
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
2832
+ }
2833
+ const getShuffleArray = (array) => {
2834
+ const newArray = [...array];
2835
+ for (let i = newArray.length - 1; i > 0; i--) {
2836
+ const j = Math.floor(Math.random() * (i + 1));
2837
+ const temp = newArray[i];
2838
+ newArray[i] = newArray[j];
2839
+ newArray[j] = temp;
2840
+ }
2841
+ return newArray;
2842
+ };
2843
+ const getTimeByTimezone = (timeZone = 'UTC') => {
2844
+ const date = new Date();
2845
+ return new Date(date.toLocaleString('en-US', { timeZone }));
2846
+ };
2847
+ const parseDateByCampaignTime = (dateStr) => {
2848
+ // Format like this: 2023-04-04 00:00:00
2849
+ try {
2850
+ const [datePart, timePart] = dateStr.split(' ');
2851
+ const [year, month, day] = datePart.split('-').map(Number);
2852
+ const [hours, minutes, seconds] = timePart.split(':').map(Number);
2853
+ /** JavaScript counts months from 0 to 11 */
2854
+ return new Date(year, month - 1, day, hours, minutes, seconds);
2855
+ }
2856
+ catch (err) {
2857
+ return null;
2858
+ }
2859
+ };
2860
+ const checkCampaignNowInTimeframe = (c) => {
2861
+ var _a;
2862
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2863
+ const startedAtStr = c.started_at;
2864
+ const endedAtStr = c.ended_at;
2865
+ const startedDate = parseDateByCampaignTime(startedAtStr);
2866
+ const endedDate = parseDateByCampaignTime(endedAtStr);
2867
+ if (!startedDate || !endedDate) {
2868
+ return false;
2869
+ }
2870
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
2871
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2872
+ if (nowWithTimezoneMs <= endedDate.getTime() &&
2873
+ nowWithTimezoneMs >= startedDate.getTime()) {
2874
+ listCampaignScheduledToActivated.push(c);
2875
+ return true;
2876
+ }
2877
+ return false;
2878
+ };
2879
+ function checkCampaignActiveButExpireAlready(c) {
2880
+ var _a;
2881
+ /** Do not setup timeframe for this campaign. No need to check */
2882
+ if (c.forever === 1) {
2883
+ return true;
2884
+ }
2885
+ const startedAtStr = c.started_at;
2886
+ const endedAtStr = c.ended_at;
2887
+ const startedDate = parseDateByCampaignTime(startedAtStr);
2888
+ const endedDate = parseDateByCampaignTime(endedAtStr);
2889
+ /** Do not setup timeframe for this campaign. No need to check */
2890
+ if (!startedDate || !endedDate) {
2891
+ return true;
2892
+ }
2893
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2894
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
2895
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2896
+ /** Check if this expire already, do not show */
2897
+ if (nowWithTimezoneMs > endedDate.getTime()) {
2898
+ listCampaignActiveButExpired.push(c);
2899
+ return false;
2900
+ }
2901
+ return true;
2902
+ }
2903
+ function shouldNotDisplayIfExcludeAllSponsors(c) {
2904
+ var _a;
2905
+ const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
2906
+ const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
2907
+ if (isSponsored && excludeSponsored) {
2908
+ listCampaignExcludeSonsored.push(c);
2909
+ return true;
2910
+ }
2911
+ return false;
2912
+ }
2913
+ function shouldDisplayWithCurrentSponsor(c) {
4059
2914
  var _a, _b;
4060
- const { primaryColor } = useContext(LeadGenContext$1);
4061
- const { isMobile } = useScreenSize();
4062
- const [open, setOpen] = useState(!!campaignId);
4063
- const [showOtpPhone, setShowOtpPhone] = useState(null);
4064
- const [isSubmitLoading, setIsSubmitLoading] = useState(false);
4065
- const [snap, setSnap] = useState(0.8);
4066
- const formRef = useRef();
4067
- const onClose = () => {
4068
- if (showOtpPhone) {
4069
- setShowOtpPhone(null);
2915
+ try {
2916
+ // TODO: BE will rename `exclude_sponsored_list` later
2917
+ const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
2918
+ const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
2919
+ const dataSponsoredId = Number((_b = document
2920
+ .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
2921
+ // There is no config for sponsor id and white list, should show as default
2922
+ if (!dataSponsoredId ||
2923
+ dataSponsoredId <= 0 ||
2924
+ whiteListSponsors.length === 0) {
2925
+ return true;
4070
2926
  }
4071
- else {
4072
- onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2927
+ // Check the dataSponsoredId exists in the white list or not.
2928
+ const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
2929
+ if (isExist) {
2930
+ return true;
4073
2931
  }
4074
- };
4075
- const textBlocks = JSON.parse(extraFields.textBlocks);
4076
- const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
4077
- const actionBlocks = JSON.parse(extraFields.actionBlocks);
4078
- const popUpSubmitText = actionBlocks.submitBlock.data.value;
4079
- const currentPath = location.pathname;
4080
- const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
4081
- const { align: titleAlign } = textBlocks.titleBlock.data || {};
4082
- const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
4083
- const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
4084
- const isLightBox = currentLayout.includes('LightBox');
4085
- const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
4086
- const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
4087
- const isInline = currentLayout.includes('Inline');
4088
- const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
4089
- const isInPage = isInline || isSidebar;
4090
- const isDrawer = isLightBoxB && isMobile;
4091
- const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
4092
- const hasForm = isLightBoxA
4093
- ? listBlockAdded.some((item) => LEADGEN_BLOCK_INPUT.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
4094
- : true;
4095
- const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
4096
- const showHeader = !!imageMobile || !!imageDesktop;
4097
- const onlyHeader = !title && !description;
4098
- const showButtonClose = !isInline;
4099
- if (window.innerWidth < 769 &&
4100
- LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
4101
- console.log('😎 Not show fullscreen, slider on mobile ');
4102
- return null;
2932
+ listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
2933
+ return false;
4103
2934
  }
4104
- useEffect(() => {
4105
- if (isLightBox || isFullscreen) {
4106
- document.body.classList.add('noscroll');
4107
- }
4108
- if (!window.intlTelInputUtils) {
4109
- require('intl-tel-input/build/js/utils');
2935
+ catch (err) {
2936
+ // Default is show
2937
+ return true;
2938
+ }
2939
+ }
2940
+ const filterFnCampaign = (c) => {
2941
+ if (shouldNotDisplayIfExcludeAllSponsors(c)) {
2942
+ return false;
2943
+ }
2944
+ else if (!shouldDisplayWithCurrentSponsor(c)) {
2945
+ return false;
2946
+ }
2947
+ /** Active */
2948
+ if (c.formatted_status === 1) {
2949
+ return checkCampaignActiveButExpireAlready(c);
2950
+ }
2951
+ /** Schedule */
2952
+ if (c.formatted_status === 0) {
2953
+ listCampaignScheduled.push(c);
2954
+ return checkCampaignNowInTimeframe(c);
2955
+ }
2956
+ return false;
2957
+ };
2958
+ const fillterApprearanceTimeCampaign = (c) => {
2959
+ var _a;
2960
+ try {
2961
+ const isTimeInRange = (currentTime, startTime, endTime) => {
2962
+ const startParts = startTime.split(':');
2963
+ const endParts = endTime.split(':');
2964
+ const startDate = new Date();
2965
+ startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
2966
+ const endDate = new Date();
2967
+ endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
2968
+ return currentTime >= startDate && currentTime <= endDate;
2969
+ };
2970
+ const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
2971
+ const startTime = rulesApprValue.startTime;
2972
+ const endTime = rulesApprValue.endTime || '23:59';
2973
+ if (!startTime) {
2974
+ return true;
4110
2975
  }
4111
- clearCacheUsedEmailOrPhone();
4112
- }, []);
4113
- const validatingPhoneRef = useRef(false);
4114
- const validatingEmailRef = useRef(false);
4115
- const { form, validateObj } = useLeadFormConfig({
4116
- listBlockAdded,
4117
- validatingPhoneRef,
4118
- validatingEmailRef,
4119
- campaignId,
4120
- campaign_subot_id,
4121
- userInfo,
4122
- format: (_a = (ISO_FORMAT[locale] || ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
4123
- });
4124
- const onFocus = (e) => {
4125
- const target = e.target;
4126
- target.scrollIntoView({
4127
- block: 'center',
4128
- inline: 'nearest',
4129
- behavior: 'auto',
4130
- });
4131
- };
4132
- const middlewareOnSubmit = (e) => {
4133
- e.preventDefault();
4134
- // mark all as touched to allow validation
4135
- const fields = Object.keys(validateObj);
4136
- const fieldStatus = fields.reduce((acc, cur) => {
4137
- acc[cur] = true;
4138
- return acc;
4139
- }, {});
4140
- form.setTouched(fieldStatus);
4141
- if (validatingEmailRef.current || validatingPhoneRef.current) {
4142
- return;
2976
+ if (isTimeInRange(new Date(), startTime, endTime)) {
2977
+ return true;
4143
2978
  }
4144
- setTimeout(() => {
4145
- form.onSubmit((v) => {
4146
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4147
- if (Object.keys(form.errors).length)
4148
- return;
4149
- let newShowOtpPhone = null;
4150
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
4151
- // not submit yet, open otp
4152
- const fieldName = (_b = (_a = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock)) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value;
4153
- if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
4154
- newShowOtpPhone = {
4155
- phone: v[fieldName],
4156
- type: 'phone',
4157
- };
2979
+ listCampaignNotDisplayInRangeOfTime.push(c);
2980
+ return false;
2981
+ }
2982
+ catch (err) {
2983
+ return true;
2984
+ }
2985
+ };
2986
+ let timeoutRef = null;
2987
+ let LEAD_SCROLL_EVENT = null;
2988
+ function clearPassiveEvent() {
2989
+ if (timeoutRef) {
2990
+ clearTimeout(timeoutRef);
2991
+ timeoutRef = null;
2992
+ }
2993
+ if (LEAD_SCROLL_EVENT) {
2994
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
2995
+ LEAD_SCROLL_EVENT = null;
2996
+ }
2997
+ }
2998
+ function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
2999
+ // clear previous passive event, check for new condition
3000
+ clearPassiveEvent();
3001
+ const leadCurrentUrl = DEBUG_URL ||
3002
+ ('https://' +
3003
+ location.hostname +
3004
+ location.pathname +
3005
+ location.search).toLowerCase();
3006
+ fetch(leadApi + 'api/campaign/' + leadSiteId, {
3007
+ method: 'POST',
3008
+ headers: {
3009
+ 'Content-Type': 'application/json',
3010
+ },
3011
+ body: JSON.stringify({
3012
+ url: leadCurrentUrl,
3013
+ ga_client_id: getCookie('_ga') || null,
3014
+ }),
3015
+ })
3016
+ .then((response) => {
3017
+ return response.json();
3018
+ // return mockLeadData || response.json()
3019
+ })
3020
+ .then((data) => {
3021
+ var _a, _b, _c, _d;
3022
+ LeadLog('List campagin: ', data);
3023
+ LEAD_RESET_VAR();
3024
+ if (data._status == 1) {
3025
+ 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);
3026
+ if (!getCookie('hhg-id')) {
3027
+ setCookie('hhg-id', v1(), {
3028
+ domain: '.' + leadDomain,
3029
+ path: '/',
3030
+ });
3031
+ LeadLog('😍 Set HHG ID cookie');
3032
+ }
3033
+ // getCookie('hhg-id')
3034
+ // TODO: HP-534 Filter desktop
3035
+ let campaignsDevice = [];
3036
+ if (isMobile()) {
3037
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
3038
+ }
3039
+ else {
3040
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
3041
+ }
3042
+ LeadLog(`👓 campaignsDevice`, campaignsDevice);
3043
+ LeadLog('--listCampaignScheduled', listCampaignScheduled);
3044
+ LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
3045
+ LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
3046
+ LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
3047
+ LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
3048
+ LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
3049
+ // Check links
3050
+ let listLinksObj = campaignsDevice
3051
+ .map((i, index) => i.targets
3052
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
3053
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3054
+ .flat(1);
3055
+ // Check list link match current href
3056
+ listLinksObj = listLinksObj.filter((i) => {
3057
+ var _a;
3058
+ const target = new URL(String(i.target).toLowerCase());
3059
+ if (i.option == 'exact_match')
3060
+ // FOR TEST LOCAL:
3061
+ // return Boolean(location.pathname === target.pathname)
3062
+ return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
3063
+ if (i.option == 'start_with') {
3064
+ // FOR TEST LOCAL:
3065
+ // if (location.pathname.includes(target.pathname)) {
3066
+ if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
3067
+ const listExcluding = i.sub_target
3068
+ .filter((i) => i.option == 'excluding')
3069
+ .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
3070
+ return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
4158
3071
  }
4159
- }
4160
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
4161
- // not submit yet, open otp
4162
- const fieldName = (_e = (_d = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock)) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.value;
4163
- if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
4164
- newShowOtpPhone = {
4165
- phone: v[fieldName],
4166
- type: 'whatsapp',
4167
- };
3072
+ else {
3073
+ return false;
4168
3074
  }
4169
3075
  }
4170
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
4171
- // not submit yet, open otp
4172
- const fieldName = (_h = (_g = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock)) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.value;
4173
- if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
4174
- newShowOtpPhone = {
4175
- phone: v[fieldName],
4176
- type: 'zalo',
4177
- };
4178
- }
3076
+ });
3077
+ // Check tags
3078
+ const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
3079
+ const listTags = listMetaTag.map((i) => i.content);
3080
+ let listCampaignHasTag = [];
3081
+ let listTagsObj = [];
3082
+ if (listTags && listTags.length) {
3083
+ listCampaignHasTag = campaignsDevice
3084
+ .map((i, index) => i.targets
3085
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
3086
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3087
+ .flat(1);
3088
+ listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
3089
+ }
3090
+ const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
3091
+ const cookieKeys = document.cookie
3092
+ .split('; ')
3093
+ .map((i) => i.split('=')[0]);
3094
+ const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
3095
+ LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
3096
+ const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
3097
+ LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
3098
+ const listCampaignSubmitedClosed = [
3099
+ ...listCampaignCodeSubmited,
3100
+ ...listCampaignCodeClosed,
3101
+ ];
3102
+ const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
3103
+ const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
3104
+ return !hasSubmited;
3105
+ });
3106
+ const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
3107
+ // .sort(
3108
+ // (a, b) =>
3109
+ // (listCampaignValid[a.campaignIndex]?.score || 0) -
3110
+ // (listCampaignValid[b.campaignIndex]?.score || 0),
3111
+ // )
3112
+ LeadLog('--listCampaignValid : ', listCampaignValid);
3113
+ if (listCampaignValid && listCampaignValid.length) {
3114
+ const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
3115
+ LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
3116
+ const { rules } = CAMPAIGN_SHOW;
3117
+ // CHECK RULE TRIGGER POPUP
3118
+ const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
3119
+ LeadLog(`timeoutRule`, timeoutRule);
3120
+ const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
3121
+ LeadLog(`scrollRule`, scrollRule);
3122
+ let impressionAction = 'TIME';
3123
+ if (Number.isInteger(timeoutRule)) {
3124
+ impressionAction = 'TIME';
3125
+ LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
3126
+ timeoutRef = setTimeout(() => {
3127
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3128
+ }, timeoutRule * 1000);
4179
3129
  }
4180
- if (newShowOtpPhone) {
4181
- setIsSubmitLoading(true);
4182
- Service.sendSMSOtpLead(newShowOtpPhone)
4183
- .then((res) => {
4184
- var _a;
4185
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4186
- if (respMessage === 'This phone number was verified') {
4187
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4188
- return;
3130
+ if (Number.isInteger(scrollRule)) {
3131
+ impressionAction = 'SCROLL';
3132
+ LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
3133
+ const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
3134
+ document.querySelector('body');
3135
+ const pct = $p.getBoundingClientRect().top;
3136
+ const pb = $p.offsetHeight;
3137
+ LeadLog(`👓 Element check scroll: `, $p);
3138
+ LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
3139
+ const wt = window.pageYOffset || document.documentElement.scrollTop;
3140
+ let percent = 0;
3141
+ if (wt >= pct) {
3142
+ percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
4189
3143
  }
4190
- setShowOtpPhone(newShowOtpPhone);
4191
- })
4192
- .finally(() => {
4193
- setIsSubmitLoading(false);
3144
+ LeadLog('---Scroll', percent, scrollRule);
3145
+ // TODO: CHECK FOOTER HEIGHT
3146
+ if (percent >= scrollRule) {
3147
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3148
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3149
+ }
3150
+ };
3151
+ window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
3152
+ passive: true,
4194
3153
  });
4195
- return;
4196
3154
  }
4197
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4198
- })(e);
4199
- }, 100);
4200
- };
4201
- const onOpenChange = (_open) => {
4202
- setOpen(_open);
4203
- if (!_open) {
4204
- setTimeout(() => {
4205
- onClose();
4206
- }, 250);
4207
- }
4208
- };
4209
- const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
4210
- const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
4211
- const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
4212
- const renderAfterImageSizes = imageMobileLoaded &&
4213
- imageDesktopLoaded &&
4214
- (isFullscreen ? imageBackgroundLoaded : true);
4215
- const ButtonSubmit = useMemo(() => {
4216
- var _a;
4217
- return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default.createElement(Button$1, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
4218
- }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
4219
- const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
4220
- const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default.createElement(React__default.Fragment, null, LinkButtonBlock.map((item, index) => {
4221
- var _a, _b, _c;
4222
- return (React__default.createElement(Button$1, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
4223
- onClose === null || onClose === void 0 ? void 0 : onClose();
4224
- onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
4225
- } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
4226
- })));
4227
- const PopupHeader = showHeader && (React__default.createElement("header", { className: clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default.createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default.createElement(React__default.Fragment, null,
4228
- React__default.createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
4229
- React__default.createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
4230
- const PopupEmpty = showEmpty && (React__default.createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
4231
- const PopupForm = (React__default.createElement(LeadFormProvider, { form: form },
4232
- React__default.createElement("form", { ref: formRef, className: "leadgen-form", onFocus: onFocus, onSubmit: middlewareOnSubmit },
4233
- React__default.createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
4234
- React__default.createElement("div", { className: "leadgen-form_inner" },
4235
- React__default.createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
4236
- const PopupOtp = showOtpPhone && (React__default.createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
4237
- setShowOtpPhone(null);
4238
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
4239
- } }));
4240
- const PopupThankYou = showThankyou && (React__default.createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
4241
- const PopupContent = (React__default.createElement("div", { className: clsx('leadgen-content', {
4242
- 'leadgen-content_small': limitFieldsLightBoxB,
4243
- }) },
4244
- !headerInsideFormContainer && PopupHeader,
4245
- !onlyHeader && (React__default.createElement("div", { className: "leadgen-inner" },
4246
- PopupThankYou,
4247
- !showThankyou && (React__default.createElement(React__default.Fragment, null,
4248
- PopupOtp,
4249
- PopupEmpty,
4250
- !(showOtpPhone || showEmpty) && PopupForm))))));
4251
- const styleOverlay = useMemo(() => {
4252
- let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
4253
- if (isMobile && imageOverlayMobile) {
4254
- styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4255
- }
4256
- if (!isMobile && imageOverlayDesktop) {
4257
- styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
3155
+ }
3156
+ else {
3157
+ LeadLog('🚧 No lead campaigns on current URL, tags');
3158
+ }
4258
3159
  }
4259
- return styleContent;
4260
- }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
4261
- const PopupWrapper = (React__default.createElement(React__default.Fragment, null,
4262
- React__default.createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
4263
- React__default.createElement("div", { className: clsx('leadgen-wrapper', {
4264
- 'leadgen-wrapper_small': limitFieldsLightBoxB,
4265
- }) },
4266
- showButtonClose && (React__default.createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
4267
- PopupContent)));
4268
- const popupContainerClassName = clsx('leadgen', `leadgen-${currentLayout}`, {
4269
- 'leadgen-lightbox': isLightBox,
4270
- 'leadgen-inline': isInPage,
4271
- 'leadgen-slider': isSlider,
3160
+ })
3161
+ .catch((err) => {
3162
+ LeadLog(`Lead error: `, err);
4272
3163
  });
4273
- const PopupContainer = isDrawer ? (React__default.createElement(DrawerComponent, { fadeFromIndex: ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
4274
- PopupWrapper,
4275
- React__default.createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default.createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
4276
- isFullscreen ? (React__default.createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
4277
- aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
4278
- } })) : null,
4279
- PopupWrapper));
4280
- if (!renderAfterImageSizes)
4281
- return null;
4282
- if (isLightBox || isFullscreen || isSlider) {
4283
- return PopupContainer;
4284
- }
4285
- else if (isSidebar) {
4286
- return React__default.createElement(SideBarLayout, { content: PopupContainer });
4287
- }
4288
- else if (isInline) {
4289
- return (React__default.createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
3164
+ }
3165
+ const LeadLog = (...params) => {
3166
+ if (process.env.NODE_ENV !== 'production' ||
3167
+ (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
3168
+ process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
3169
+ (typeof localStorage !== 'undefined' &&
3170
+ localStorage.getItem('hhg_debug') === 'true')) {
3171
+ console.log(...params);
4290
3172
  }
4291
- return null;
4292
- };
4293
-
4294
- const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
4295
- const currentPath = location.pathname;
4296
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
4297
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
4298
- if (!imageMobileLoaded || !imageDesktopLoaded)
4299
- return null;
4300
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
4301
- currentLayout == 'SkinA' ? (React__default.createElement("aside", { className: "le-only-desktop" },
4302
- React__default.createElement("div", { className: "le-skin-a-desktop" },
4303
- React__default.createElement("div", { style: { position: 'relative' } },
4304
- React__default.createElement("img", { src: imageDesktop, style: {
4305
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4306
- } }),
4307
- React__default.createElement("a", { style: {
4308
- position: 'absolute',
4309
- top: '75%',
4310
- left: '50%',
4311
- transform: 'translate(-50%, -50%)',
4312
- textAlign: 'center',
4313
- width: 'calc(100% - 15px)',
4314
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4315
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
4316
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default.createElement("aside", { className: "le-only-desktop" },
4317
- React__default.createElement("div", { className: "" },
4318
- React__default.createElement("div", { style: { position: 'relative', zIndex: 10000 } },
4319
- React__default.createElement("img", { src: imageDesktop, style: {
4320
- width: '100%',
4321
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4322
- } }),
4323
- React__default.createElement("a", { style: {
4324
- position: 'absolute',
4325
- top: '75%',
4326
- left: '50%',
4327
- transform: 'translate(-50%, -50%)',
4328
- textAlign: 'center',
4329
- width: '100%',
4330
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4331
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4332
- React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
4333
- React__default.createElement("aside", { className: "le-only-mobile" },
4334
- React__default.createElement("div", { className: "le-skin-mobile" },
4335
- React__default.createElement("div", { style: { position: 'relative' } },
4336
- isVideo(imageMobile) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true },
4337
- React__default.createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default.createElement("img", { src: imageMobile, style: {
4338
- width: '100%',
4339
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
4340
- } })),
4341
- React__default.createElement("a", { style: {
4342
- position: 'absolute',
4343
- top: '82%',
4344
- left: '50%',
4345
- transform: 'translate(-50%, -50%)',
4346
- textAlign: 'center',
4347
- maxWidth: 'calc(100% - 15px)',
4348
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4349
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4350
- React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4351
- };
4352
-
4353
- // url: imageBlocks.imageMobile.data.url
4354
- // newTab: imageBlocks.imageMobile.data.newtab
4355
- // image: campaignShow.image
4356
- // imageDestkop: campaignShow.image_desktop
4357
- const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
4358
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
4359
- if (!imageLoaded)
4360
- return null;
4361
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
4362
- React__default.createElement("div", { className: "le-tab-popup" },
4363
- React__default.createElement("div", { style: { position: 'relative' } },
4364
- React__default.createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
4365
- React__default.createElement("img", { className: "js-popup-other-submit", src: image, style: {
4366
- aspectRatio: `${imageWidth}/${imageHeight}`,
4367
- } })),
4368
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
4369
3173
  };
4370
3174
 
4371
3175
  function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
@@ -4381,7 +3185,7 @@ function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
4381
3185
  }
4382
3186
  const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, showEmpty, setShowEmpty, userInfo, }) => {
4383
3187
  var _a, _b;
4384
- const { apiUrl, siteDomain } = useContext(LeadGenContext$1);
3188
+ const { apiUrl, siteDomain } = useContext(LeadGenContext);
4385
3189
  useEffect(() => {
4386
3190
  const gaCookie = getCookie('_ga') || null;
4387
3191
  fetch(`${apiUrl}api/campaign/${code}/impression`, {
@@ -4776,7 +3580,7 @@ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, primaryColor
4776
3580
  leadStartTimeRef.current = Date.now();
4777
3581
  }
4778
3582
  }, [showCampaign]);
4779
- return (React__default.createElement(LeadGenContext$1.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
3583
+ return (React__default.createElement(LeadGenContext.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
4780
3584
  React__default.createElement(TranslationsContext.Provider, { value: { locale, values: getTranslations(locale) } }, children ? (React__default.createElement(Component, { campaign: showCampaign, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, setShowThankyou: setShowThankyou, locale: locale, showEmpty: showEmpty, setShowEmpty: setShowEmpty, userInfo: userInfo }, children)) : (React__default.createElement(Portal, { target: getPopupWrapperDom() },
4781
3585
  React__default.createElement(Box, { sx: { position: 'fixed', zIndex: ZINDEX_SSO - 9e6 } },
4782
3586
  React__default.createElement(Transition, { mounted: Boolean(((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1'), transition: "fade", duration: 600, timingFunction: "ease" }, (styles) => {
@@ -4796,4 +3600,4 @@ LeadGen.Thankyou = Thankyou;
4796
3600
  LeadGen.OtpForm = OtpBlock$1;
4797
3601
  LeadGen.Close = Close;
4798
3602
 
4799
- export { LeadGen, LeadGenSubscriptionBox };
3603
+ export { LeadGen };