@hhgtech/hhg-components 1.29.371-beta-3 → 1.29.372

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 (545) hide show
  1. package/build/{InputDate-61e9c5a1.js → InputDate-084af3b7.js} +20 -20
  2. package/build/{LastPeriod-37f9ad03.js → LastPeriod-7920d16e.js} +1 -1
  3. package/build/{Locale-7ef9bbac.js → Locale-a034e717.js} +0 -1
  4. package/build/{MobileBottomNavigationIcon-2504f04b.js → MobileBottomNavigationIcon-ae480710.js} +3 -3
  5. package/build/{Spinner-4a73038c.js → Spinner-9bf08d65.js} +1 -1
  6. package/build/{WhatsApp-48e231e9.js → WhatsApp-73c563dc.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-0773fc84.js → constants-3c232ac7.js} +1 -1
  18. package/build/{constants-ef70697a.js → constants-f0954264.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-b94eb05a.js → core-35ae537b.js} +1 -1
  24. package/build/{dataTransform-866f83fb.js → dataTransform-90facc7b.js} +1 -1
  25. package/build/ecom.js +4 -4
  26. package/build/{editor-67f37f06.js → editor-b1b9b19c.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-7205d5bf.js → InputDate-544d7517.js} +20 -20
  37. package/build/esm/{LastPeriod-8fb1da89.js → LastPeriod-64debefd.js} +1 -1
  38. package/build/esm/{Locale-08f0c7dd.js → Locale-3e2786ee.js} +0 -1
  39. package/build/esm/{MobileBottomNavigationIcon-46d840d7.js → MobileBottomNavigationIcon-57dcd2d5.js} +3 -3
  40. package/build/esm/{Spinner-90f339db.js → Spinner-a2b03942.js} +1 -1
  41. package/build/esm/{WhatsApp-60d6e215.js → WhatsApp-4bd22594.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-5c8f80dc.js → constants-46a13b0b.js} +1 -1
  53. package/build/esm/{constants-39b9db20.js → constants-5e4d9287.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-e470839e.js → core-b8fa3e33.js} +1 -1
  59. package/build/esm/{dataTransform-bf484109.js → dataTransform-1ad95d27.js} +1 -1
  60. package/build/esm/ecom.js +4 -4
  61. package/build/esm/{editor-0f2f16c6.js → editor-8213370a.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-3f8017a5.js → healthTools-84758186.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-631ed8f0.js → index-008fb6f5.js} +13 -13
  80. package/build/esm/{index-48aacda8.js → index-02c659dd.js} +1 -1
  81. package/build/esm/{index-f8b4f0b3.js → index-08134aa1.js} +18 -18
  82. package/build/esm/{index-22f4a880.js → index-0823f05f.js} +2 -2
  83. package/build/esm/{index-c0789666.js → index-0b7e5368.js} +17 -17
  84. package/build/esm/{index-ab6306df.js → index-0ece29aa.js} +2 -2
  85. package/build/esm/{index-fcfb5e03.js → index-15dc7ed3.js} +32 -32
  86. package/build/esm/{index-dba3c9f8.js → index-1992432a.js} +1 -1
  87. package/build/esm/{index-0042746f.js → index-2050b8fa.js} +17 -17
  88. package/build/esm/{index-463a4ac6.js → index-22e09b92.js} +16 -16
  89. package/build/esm/{index-462f2716.js → index-260a6cef.js} +16 -16
  90. package/build/esm/{index-c2757163.js → index-3283d034.js} +8 -8
  91. package/build/esm/{index-b448c622.js → index-34f81557.js} +2 -2
  92. package/build/esm/{index-ed5e4009.js → index-371d0a77.js} +2 -2
  93. package/build/esm/{index-5bfbb25e.js → index-37f46909.js} +17 -17
  94. package/build/esm/{index-a88963d3.js → index-3c7bade1.js} +2 -2
  95. package/build/esm/{index-64e7b9c3.js → index-3e33fe3d.js} +10 -10
  96. package/build/esm/{index-dc733b8a.js → index-3fe07695.js} +27 -36
  97. package/build/esm/{index-cc9c8870.js → index-40542814.js} +5 -5
  98. package/build/esm/{index-b194318f.js → index-4320a963.js} +15 -15
  99. package/build/esm/{index-5094d18a.js → index-49767cf6.js} +5 -5
  100. package/build/esm/{index-234cb2cc.js → index-49c4b81e.js} +2 -2
  101. package/build/esm/{index-2ea81f95.js → index-59b7c65e.js} +2 -2
  102. package/build/esm/{index-1f4d454e.js → index-5b5f2d0c.js} +22 -22
  103. package/build/esm/{index-e0adcb3b.js → index-6223f41c.js} +3 -3
  104. package/build/esm/{index-3a3f8652.js → index-6491bd17.js} +1 -1
  105. package/build/esm/{index-2cbac092.js → index-6e796974.js} +1 -1
  106. package/build/esm/{index-34ba8787.js → index-722df7e6.js} +4 -4
  107. package/build/esm/{index-e6c329bb.js → index-773c6e02.js} +6 -6
  108. package/build/esm/{index-2413498d.js → index-799ebe61.js} +13 -13
  109. package/build/esm/{index-c9594e55.js → index-7cdf73e7.js} +6 -6
  110. package/build/esm/{index-77220ada.js → index-83afe17a.js} +17 -17
  111. package/build/esm/{index-56ec762e.js → index-84fabe77.js} +16 -16
  112. package/build/esm/{index-e5173b05.js → index-8590aa43.js} +1 -1
  113. package/build/esm/{index-9ebcb339.js → index-87283fad.js} +13 -13
  114. package/build/esm/{index-9865e182.js → index-88a60434.js} +13 -13
  115. package/build/esm/{index-b51ea106.js → index-8a062d3b.js} +3 -3
  116. package/build/esm/{index-d854a351.js → index-9792c9b6.js} +18 -18
  117. package/build/esm/{index-857de40f.js → index-b0a09330.js} +2 -2
  118. package/build/esm/{index-603469cf.js → index-b0f6139c.js} +31 -31
  119. package/build/esm/{index-3b4d798b.js → index-b1702546.js} +2 -39
  120. package/build/esm/{index-1ad4b807.js → index-b41d6d8a.js} +21 -21
  121. package/build/esm/{index-40ab3b03.js → index-b42c9f25.js} +32 -32
  122. package/build/esm/{index-e3789b8b.js → index-b52e228a.js} +16 -16
  123. package/build/esm/{index-6eed224f.js → index-c07eed8e.js} +24 -24
  124. package/build/esm/{index-864f7b5b.js → index-c229b5b7.js} +1 -1
  125. package/build/esm/{index-e3c73f61.js → index-c85f2927.js} +2 -2
  126. package/build/esm/{index-27e79f70.js → index-cc5dd802.js} +7 -7
  127. package/build/esm/{index-7b648cab.js → index-d2bdab8c.js} +6 -6
  128. package/build/esm/{index-cfd3b8dd.js → index-d303f24d.js} +7 -7
  129. package/build/esm/{index-0978cfdd.js → index-d46d72e5.js} +2 -2
  130. package/build/esm/{index-f74a8323.js → index-d6b1760f.js} +25 -25
  131. package/build/esm/{index-c2617513.js → index-ddb8b5f9.js} +3 -3
  132. package/build/esm/{index-6cbb85ce.js → index-e00ea5ce.js} +1 -1
  133. package/build/esm/{index-652d6c84.js → index-e2f4897f.js} +3 -3
  134. package/build/esm/{index-a8c524a9.js → index-e3522239.js} +1 -1
  135. package/build/esm/{index-d77e0c23.js → index-e3abcd93.js} +1 -1
  136. package/build/esm/{index-64a61d3e.js → index-e5ebf355.js} +6 -6
  137. package/build/esm/{index-cfe7c4a6.js → index-eb34db89.js} +2 -2
  138. package/build/esm/{index-8f0d901b.js → index-f12cf95a.js} +6 -6
  139. package/build/esm/{index-07beb988.js → index-f18301b6.js} +3 -3
  140. package/build/esm/{index-44404be2.js → index-f1dfe73b.js} +3 -3
  141. package/build/esm/{index-49cbae4a.js → index-f20e08f2.js} +2 -2
  142. package/build/esm/{index-fcbbfa4b.js → index-febe5b0b.js} +2 -2
  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-9cf83f21.js → labelSorting-4590af02.js} +4 -4
  149. package/build/esm/lead/helpers.d.ts +1 -56
  150. package/build/esm/lead/index.d.ts +2 -2
  151. package/build/esm/lead/layouts/lightbox/formContext.d.ts +1 -2
  152. package/build/esm/lead/leadGenContext.d.ts +1 -0
  153. package/build/esm/lead/services/index.d.ts +0 -19
  154. package/build/esm/lead/store/index.d.ts +0 -1
  155. package/build/esm/lead.css +1 -1
  156. package/build/esm/lead.js +1037 -2234
  157. package/build/esm/{logoIcon-cb8e0653.js → logoIcon-8a63b46b.js} +2 -8
  158. package/build/esm/mantine.js +25 -25
  159. package/build/esm/misc.js +17 -17
  160. package/build/esm/miscGetDynamicHealthTool.js +4 -4
  161. package/build/esm/miscGetSocialList.js +8 -8
  162. package/build/esm/miscScreenSizeContext.js +1 -1
  163. package/build/esm/mobileBottomNavigation.js +5 -5
  164. package/build/esm/mobileBottomNavigationIcon.js +5 -5
  165. package/build/esm/molecules.js +73 -73
  166. package/build/esm/moleculesArticleCard.js +6 -6
  167. package/build/esm/moleculesArticleCardV2.js +16 -16
  168. package/build/esm/navigation.js +45 -45
  169. package/build/esm/navigationLogoutPopup.js +9 -9
  170. package/build/esm/navigationProfileButton.js +23 -23
  171. package/build/esm/onboardingV2.js +29 -29
  172. package/build/esm/organisms.js +49 -49
  173. package/build/esm/{post-ed72f334.js → post-a4e3b00b.js} +2 -2
  174. package/build/esm/profileNavigation.js +19 -19
  175. package/build/esm/progressBar.js +1 -1
  176. package/build/esm/pwg.js +22 -22
  177. package/build/esm/ssoV2/api/featureFlag.d.ts +1 -2
  178. package/build/esm/ssoV2.js +39 -51
  179. package/build/esm/{store-8c2e40e8.js → store-a9c2a3c4.js} +4 -4
  180. package/build/esm/subot.js +35 -35
  181. package/build/esm/surveyOrPremiumBanner.js +32 -32
  182. package/build/esm/surveyQuestionCard.js +10 -10
  183. package/build/esm/{surveyThankyouCard-df288b5b.js → surveyThankyouCard-f1e71ef9.js} +5 -5
  184. package/build/esm/together.js +55 -55
  185. package/build/esm/togetherApiUtils.js +4 -4
  186. package/build/esm/togetherAtoms.js +30 -30
  187. package/build/esm/togetherComponentGlobalContext.js +4 -4
  188. package/build/esm/togetherMolecules.js +50 -50
  189. package/build/esm/togetherMoleculesCardAuthor.js +28 -28
  190. package/build/esm/togetherMoleculesPostImagePreview.js +11 -11
  191. package/build/esm/togetherMoleculesProfileDetail.js +38 -38
  192. package/build/esm/togetherOrganisms.js +49 -49
  193. package/build/esm/togetherRichTextEditor.js +17 -17
  194. package/build/esm/togetherShareBox.js +10 -10
  195. package/build/esm/{treePopoverMenu-f55ffb06.js → treePopoverMenu-2b4a0ce7.js} +19 -19
  196. package/build/esm/{types-fe17cb13.js → types-00647e82.js} +2 -2
  197. package/build/esm/types.js +2 -2
  198. package/build/esm/{useCategory-485df8ce.js → useCategory-b156220e.js} +5 -18
  199. package/build/esm/{useHealthToolCache-21c2c43e.js → useHealthToolCache-83bc2007.js} +1 -1
  200. package/build/esm/{useMantineLocale-6f10e30e.js → useMantineLocale-75d3a92b.js} +6 -8
  201. package/build/esm/{usePlacesAutocomplete-1043aded.js → usePlacesAutocomplete-be5196d7.js} +1 -1
  202. package/build/esm/{useScreenSize-caf0dd66.js → useScreenSize-9091e971.js} +2 -2
  203. package/build/esm/useTogetherAuthRequiredAction.js +9 -9
  204. package/build/esm/{utils-608e1033.js → utils-0d32cd95.js} +4 -4
  205. package/build/esm/{utils-0cb064a5.js → utils-654cc220.js} +2 -2
  206. package/build/esm/{utils-4d4e79bb.js → utils-c6d483d6.js} +3 -3
  207. package/build/esm/{utils-be2c60b0.js → utils-d3607ebf.js} +2 -2
  208. package/build/esm/vaccination.js +21 -21
  209. package/build/footer.js +21 -21
  210. package/build/gAssets.js +2 -2
  211. package/build/{healthTools-6a9f073b.js → healthTools-5d43fdba.js} +1 -1
  212. package/build/healthToolsCardWrapper.js +18 -18
  213. package/build/healthToolsForm.js +33 -33
  214. package/build/hooks.js +13 -13
  215. package/build/i18n.js +56 -16
  216. package/build/i18nV2.js +1 -1
  217. package/build/{index-a3e1ea36.js → index-015decac.js} +13 -13
  218. package/build/{index-05aa2361.js → index-022360ea.js} +2 -2
  219. package/build/{index-2c675ca4.js → index-04336ab9.js} +1 -1
  220. package/build/{index-3be634dd.js → index-04fded65.js} +1 -1
  221. package/build/{index-d4eecf33.js → index-064c06f3.js} +5 -5
  222. package/build/{index-f40aef22.js → index-0b1b3404.js} +3 -3
  223. package/build/{index-07842b92.js → index-0ccd6ab4.js} +18 -18
  224. package/build/{index-2c5ea2c0.js → index-109bc0ba.js} +16 -16
  225. package/build/{index-0c52d734.js → index-153b215b.js} +16 -16
  226. package/build/{index-4de45eec.js → index-1832c923.js} +1 -1
  227. package/build/{index-d3e5cfef.js → index-1dca06d3.js} +31 -31
  228. package/build/{index-6748439e.js → index-1e3ef673.js} +8 -8
  229. package/build/{index-9df0ac34.js → index-1e5869a0.js} +1 -1
  230. package/build/{index-770e2eb7.js → index-1ffd87e6.js} +6 -6
  231. package/build/{index-6d5de17c.js → index-2aa39a80.js} +15 -15
  232. package/build/{index-4c0627ae.js → index-312f141b.js} +3 -3
  233. package/build/{index-347b5bb1.js → index-32d56013.js} +2 -2
  234. package/build/{index-c2596ec2.js → index-33c24fd1.js} +13 -13
  235. package/build/{index-81637606.js → index-349d4ad5.js} +3 -3
  236. package/build/{index-54b96999.js → index-3acf4291.js} +1 -1
  237. package/build/{index-bfa8f8e1.js → index-3b559014.js} +6 -6
  238. package/build/{index-080b0aaf.js → index-3c9b6c14.js} +1 -1
  239. package/build/{index-b0be7fa8.js → index-3d0f0804.js} +2 -2
  240. package/build/{index-fdc1ccc3.js → index-3d49b533.js} +17 -17
  241. package/build/{index-2dde1f98.js → index-4f50c9a6.js} +4 -4
  242. package/build/{index-f651a751.js → index-576a7b83.js} +32 -32
  243. package/build/{index-ebd7b720.js → index-578b7adc.js} +2 -2
  244. package/build/{index-cd6ddf39.js → index-5874eb30.js} +7 -7
  245. package/build/{index-c5c2105e.js → index-6427efb3.js} +32 -32
  246. package/build/{index-5f6ebc77.js → index-6433425b.js} +6 -6
  247. package/build/{index-81a96c8d.js → index-669549a2.js} +2 -2
  248. package/build/{index-87d3b911.js → index-6e1d6d78.js} +2 -2
  249. package/build/{index-2e482c2e.js → index-73816dbf.js} +16 -16
  250. package/build/{index-79296333.js → index-7a0bbb05.js} +2 -39
  251. package/build/{index-b3c66e75.js → index-7d70d6d9.js} +2 -2
  252. package/build/{index-61cd7af4.js → index-7fc6a742.js} +3 -3
  253. package/build/{index-5b0db148.js → index-86e1489b.js} +3 -3
  254. package/build/{index-13879fc8.js → index-892e05e3.js} +13 -13
  255. package/build/{index-78e2cb65.js → index-8a505064.js} +17 -17
  256. package/build/{index-e0bdefdd.js → index-90c3bd51.js} +2 -2
  257. package/build/{index-7013062e.js → index-95d0866e.js} +22 -22
  258. package/build/{index-93bc0075.js → index-964bebd5.js} +2 -2
  259. package/build/{index-696ae54c.js → index-9e545145.js} +17 -17
  260. package/build/{index-9f0bcaee.js → index-9ed8f15e.js} +6 -6
  261. package/build/{index-47c560a5.js → index-a67e5b8c.js} +2 -2
  262. package/build/{index-a90113f4.js → index-b15cd09e.js} +2 -2
  263. package/build/{index-ffaf8d8a.js → index-b7e2e5d7.js} +2 -2
  264. package/build/{index-565a5e20.js → index-b98ed131.js} +13 -13
  265. package/build/{index-9cf6031b.js → index-bcf83833.js} +17 -17
  266. package/build/{index-178544eb.js → index-bcffdc4e.js} +3 -3
  267. package/build/{index-56f422b6.js → index-c234311f.js} +16 -16
  268. package/build/{index-0e998580.js → index-c349ac59.js} +18 -18
  269. package/build/{index-6ec9d3b4.js → index-c4fdcb5d.js} +25 -25
  270. package/build/{index-4dda9970.js → index-c6c79524.js} +5 -5
  271. package/build/{index-1ec480a4.js → index-d59daad9.js} +21 -21
  272. package/build/{index-00e0387f.js → index-d93867ea.js} +1 -1
  273. package/build/{index-f6fe92be.js → index-dc9d63cb.js} +10 -10
  274. package/build/{index-c721c3c3.js → index-e6d89d93.js} +7 -7
  275. package/build/{index-8860da28.js → index-e7f91600.js} +1 -1
  276. package/build/{index-0739a213.js → index-f0871b13.js} +2 -2
  277. package/build/{index-56dd9661.js → index-f1240784.js} +6 -6
  278. package/build/{index-686b3e59.js → index-fa0f1dec.js} +1 -1
  279. package/build/{index-caea14e2.js → index-ff7f8fd0.js} +24 -24
  280. package/build/{index-125f65cd.js → index-ffa29b44.js} +27 -36
  281. package/build/index.js +117 -117
  282. package/build/interfaces/constants/domainLocales.d.ts +0 -2
  283. package/build/interfaces/constants/index.d.ts +1 -1
  284. package/build/interfaces/types/Locale.d.ts +1 -2
  285. package/build/interfaces/types/index.d.ts +1 -2
  286. package/build/{labelSorting-ddd1f2ce.js → labelSorting-7570276e.js} +4 -4
  287. package/build/lead/helpers.d.ts +1 -56
  288. package/build/lead/index.d.ts +2 -2
  289. package/build/lead/layouts/lightbox/formContext.d.ts +1 -2
  290. package/build/lead/leadGenContext.d.ts +1 -0
  291. package/build/lead/services/index.d.ts +0 -19
  292. package/build/lead/store/index.d.ts +0 -1
  293. package/build/lead.css +1 -1
  294. package/build/lead.js +1033 -2231
  295. package/build/{logoIcon-10d4c2c7.js → logoIcon-a0093830.js} +2 -8
  296. package/build/mantine.js +22 -22
  297. package/build/misc.js +17 -17
  298. package/build/miscGetDynamicHealthTool.js +4 -4
  299. package/build/miscGetSocialList.js +8 -8
  300. package/build/miscScreenSizeContext.js +1 -1
  301. package/build/mobileBottomNavigation.js +5 -5
  302. package/build/mobileBottomNavigationIcon.js +5 -5
  303. package/build/molecules.js +73 -73
  304. package/build/moleculesArticleCard.js +6 -6
  305. package/build/moleculesArticleCardV2.js +16 -16
  306. package/build/navigation.js +45 -45
  307. package/build/navigationLogoutPopup.js +9 -9
  308. package/build/navigationProfileButton.js +23 -23
  309. package/build/onboardingV2.js +28 -28
  310. package/build/organisms.js +49 -49
  311. package/build/{post-71dba53e.js → post-8b3ec323.js} +2 -2
  312. package/build/profileNavigation.js +19 -19
  313. package/build/progressBar.js +1 -1
  314. package/build/pwg.js +22 -22
  315. package/build/ssoV2/api/featureFlag.d.ts +1 -2
  316. package/build/ssoV2.js +37 -49
  317. package/build/{store-162831bf.js → store-3bb34d08.js} +4 -4
  318. package/build/subot.js +34 -34
  319. package/build/surveyOrPremiumBanner.js +32 -32
  320. package/build/surveyQuestionCard.js +10 -10
  321. package/build/{surveyThankyouCard-04e30b65.js → surveyThankyouCard-40fde7aa.js} +5 -5
  322. package/build/together.js +55 -55
  323. package/build/togetherApiUtils.js +4 -4
  324. package/build/togetherAtoms.js +30 -30
  325. package/build/togetherComponentGlobalContext.js +4 -4
  326. package/build/togetherMolecules.js +50 -50
  327. package/build/togetherMoleculesCardAuthor.js +28 -28
  328. package/build/togetherMoleculesPostImagePreview.js +11 -11
  329. package/build/togetherMoleculesProfileDetail.js +38 -38
  330. package/build/togetherOrganisms.js +49 -49
  331. package/build/togetherRichTextEditor.js +17 -17
  332. package/build/togetherShareBox.js +10 -10
  333. package/build/{treePopoverMenu-102e209a.js → treePopoverMenu-9f4d0f7d.js} +19 -19
  334. package/build/{types-8648a9f6.js → types-709ee706.js} +2 -2
  335. package/build/types.js +2 -2
  336. package/build/{useCategory-edc47b24.js → useCategory-889d8b9e.js} +5 -18
  337. package/build/{useHealthToolCache-7ac7bc8b.js → useHealthToolCache-dd27ba92.js} +1 -1
  338. package/build/{useMantineLocale-cbfcee76.js → useMantineLocale-aa4e4cdc.js} +6 -8
  339. package/build/{usePlacesAutocomplete-d9c9d190.js → usePlacesAutocomplete-60f0a6d0.js} +1 -1
  340. package/build/{useScreenSize-5edbf21b.js → useScreenSize-013494cb.js} +2 -2
  341. package/build/useTogetherAuthRequiredAction.js +9 -9
  342. package/build/{utils-b86dfeef.js → utils-0a036093.js} +3 -3
  343. package/build/{utils-55566c6a.js → utils-bb4ffbb8.js} +2 -2
  344. package/build/{utils-b9463401.js → utils-c3214203.js} +4 -4
  345. package/build/{utils-ed4bc922.js → utils-cfbfcd70.js} +2 -2
  346. package/build/vaccination.js +21 -21
  347. package/package.json +3 -3
  348. package/build/components/mantine/phoneInput/PhoneInput.d.ts +0 -17
  349. package/build/components/mantine/phoneInput/index.d.ts +0 -1
  350. package/build/esm/components/mantine/phoneInput/PhoneInput.d.ts +0 -17
  351. package/build/esm/components/mantine/phoneInput/index.d.ts +0 -1
  352. package/build/esm/i18n-values/zh-CN.js +0 -855
  353. package/build/esm/lead/LeadGen.type.d.ts +0 -31
  354. package/build/esm/lead/LeadGenForm/LeadGenForm.d.ts +0 -41
  355. package/build/esm/lead/LeadGenForm/LeadGenForm.helpers.d.ts +0 -2
  356. package/build/esm/lead/LeadGenForm/LeadGenForm.styled.d.ts +0 -5
  357. package/build/esm/lead/LeadGenForm/LeadGenFormPhone.d.ts +0 -17
  358. package/build/esm/lead/LeadGenForm/LeadGenThankYou.d.ts +0 -20
  359. package/build/esm/lead/LeadGenForm/index.d.ts +0 -3
  360. package/build/esm/lead/LeadGenForm/textField/index.d.ts +0 -13
  361. package/build/esm/lead/LeadGenForm/textField/index.styled.d.ts +0 -11
  362. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +0 -63
  363. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +0 -4
  364. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +0 -21
  365. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +0 -3
  366. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +0 -23
  367. package/build/esm/lead/LeadGenSubscriptionBox/index.d.ts +0 -1
  368. package/build/esm/lead/LeadGenTranslationContext.d.ts +0 -6
  369. package/build/esm/translationsProvider-598fb4c6.js +0 -55
  370. package/build/i18n-values/zh-CN.js +0 -866
  371. package/build/lead/LeadGen.type.d.ts +0 -31
  372. package/build/lead/LeadGenForm/LeadGenForm.d.ts +0 -41
  373. package/build/lead/LeadGenForm/LeadGenForm.helpers.d.ts +0 -2
  374. package/build/lead/LeadGenForm/LeadGenForm.styled.d.ts +0 -5
  375. package/build/lead/LeadGenForm/LeadGenFormPhone.d.ts +0 -17
  376. package/build/lead/LeadGenForm/LeadGenThankYou.d.ts +0 -20
  377. package/build/lead/LeadGenForm/index.d.ts +0 -3
  378. package/build/lead/LeadGenForm/textField/index.d.ts +0 -13
  379. package/build/lead/LeadGenForm/textField/index.styled.d.ts +0 -11
  380. package/build/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +0 -63
  381. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +0 -4
  382. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +0 -21
  383. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +0 -3
  384. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +0 -23
  385. package/build/lead/LeadGenSubscriptionBox/index.d.ts +0 -1
  386. package/build/lead/LeadGenTranslationContext.d.ts +0 -6
  387. package/build/translationsProvider-b383e3b6.js +0 -62
  388. /package/build/{BMI_BOYS.percentile.monthly-35aa5ebe.js → BMI_BOYS.percentile.monthly-f5295f7f.js} +0 -0
  389. /package/build/{BMI_BOYS.percentile.weekly-06d286f6.js → BMI_BOYS.percentile.weekly-e89f6859.js} +0 -0
  390. /package/build/{BMI_BOYS.percentile.yearly-d68cbaef.js → BMI_BOYS.percentile.yearly-206f392e.js} +0 -0
  391. /package/build/{BMI_BOYS.zscore.monthly-d778ca5f.js → BMI_BOYS.zscore.monthly-62cfeba2.js} +0 -0
  392. /package/build/{BMI_BOYS.zscore.weekly-d40d219b.js → BMI_BOYS.zscore.weekly-aa9c8d30.js} +0 -0
  393. /package/build/{BMI_BOYS.zscore.yearly-b6efcc79.js → BMI_BOYS.zscore.yearly-40a612b4.js} +0 -0
  394. /package/build/{BMI_GIRLS.percentile.monthly-0d426264.js → BMI_GIRLS.percentile.monthly-81b1a5b7.js} +0 -0
  395. /package/build/{BMI_GIRLS.percentile.weekly-936b386f.js → BMI_GIRLS.percentile.weekly-b90e7d68.js} +0 -0
  396. /package/build/{BMI_GIRLS.percentile.yearly-af29294d.js → BMI_GIRLS.percentile.yearly-78565dff.js} +0 -0
  397. /package/build/{BMI_GIRLS.zscore.monthly-d9f1c7b0.js → BMI_GIRLS.zscore.monthly-bf3313da.js} +0 -0
  398. /package/build/{BMI_GIRLS.zscore.weekly-23490287.js → BMI_GIRLS.zscore.weekly-76c59850.js} +0 -0
  399. /package/build/{BMI_GIRLS.zscore.yearly-a846aa7d.js → BMI_GIRLS.zscore.yearly-b45db558.js} +0 -0
  400. /package/build/{ChevronDown-5961731d.js → ChevronDown-4d7e527c.js} +0 -0
  401. /package/build/{Close-74cf47e8.js → Close-88109e78.js} +0 -0
  402. /package/build/{Google-d0c35b20.js → Google-18b395b8.js} +0 -0
  403. /package/build/{HEAD CIRCUM_BOYS.percentile.monthly-77226b6c.js → HEAD CIRCUM_BOYS.percentile.monthly-c5365f78.js} +0 -0
  404. /package/build/{HEAD CIRCUM_BOYS.percentile.weekly-72e7afe1.js → HEAD CIRCUM_BOYS.percentile.weekly-ba1be07f.js} +0 -0
  405. /package/build/{HEAD CIRCUM_BOYS.percentile.yearly-98efbbf7.js → HEAD CIRCUM_BOYS.percentile.yearly-0d9ff7de.js} +0 -0
  406. /package/build/{HEAD CIRCUM_BOYS.zscore.monthly-3af2a621.js → HEAD CIRCUM_BOYS.zscore.monthly-293579ed.js} +0 -0
  407. /package/build/{HEAD CIRCUM_BOYS.zscore.weekly-747e6068.js → HEAD CIRCUM_BOYS.zscore.weekly-d4476f55.js} +0 -0
  408. /package/build/{HEAD CIRCUM_BOYS.zscore.yearly-c0e7f52b.js → HEAD CIRCUM_BOYS.zscore.yearly-b7f64416.js} +0 -0
  409. /package/build/{HEAD CIRCUM_GIRLS.percentile.monthly-d7461423.js → HEAD CIRCUM_GIRLS.percentile.monthly-30829c3b.js} +0 -0
  410. /package/build/{HEAD CIRCUM_GIRLS.percentile.weekly-efc23b48.js → HEAD CIRCUM_GIRLS.percentile.weekly-2f227a0a.js} +0 -0
  411. /package/build/{HEAD CIRCUM_GIRLS.percentile.yearly-eed57f44.js → HEAD CIRCUM_GIRLS.percentile.yearly-ab05fba4.js} +0 -0
  412. /package/build/{HEAD CIRCUM_GIRLS.zscore.monthly-46108e64.js → HEAD CIRCUM_GIRLS.zscore.monthly-9e41bb48.js} +0 -0
  413. /package/build/{HEAD CIRCUM_GIRLS.zscore.weekly-c8b69243.js → HEAD CIRCUM_GIRLS.zscore.weekly-07fdf8b4.js} +0 -0
  414. /package/build/{HEAD CIRCUM_GIRLS.zscore.yearly-aa19583f.js → HEAD CIRCUM_GIRLS.zscore.yearly-3d09a791.js} +0 -0
  415. /package/build/{HEIGHT_BOYS.percentile.monthly-1ce70df3.js → HEIGHT_BOYS.percentile.monthly-58875bdd.js} +0 -0
  416. /package/build/{HEIGHT_BOYS.percentile.weekly-f2bb70b7.js → HEIGHT_BOYS.percentile.weekly-0614ac80.js} +0 -0
  417. /package/build/{HEIGHT_BOYS.percentile.yearly-e4d04b02.js → HEIGHT_BOYS.percentile.yearly-b992897c.js} +0 -0
  418. /package/build/{HEIGHT_BOYS.zscore.monthly-c2bbcded.js → HEIGHT_BOYS.zscore.monthly-4b1bcf27.js} +0 -0
  419. /package/build/{HEIGHT_BOYS.zscore.weekly-0f41d68c.js → HEIGHT_BOYS.zscore.weekly-77c0776c.js} +0 -0
  420. /package/build/{HEIGHT_BOYS.zscore.yearly-a99fec6a.js → HEIGHT_BOYS.zscore.yearly-5dc8e6a1.js} +0 -0
  421. /package/build/{HEIGHT_GIRLS.percentile.monthly-ebbb538b.js → HEIGHT_GIRLS.percentile.monthly-cc99017e.js} +0 -0
  422. /package/build/{HEIGHT_GIRLS.percentile.weekly-1fd31eca.js → HEIGHT_GIRLS.percentile.weekly-fae4e9f9.js} +0 -0
  423. /package/build/{HEIGHT_GIRLS.percentile.yearly-f732d518.js → HEIGHT_GIRLS.percentile.yearly-bc7c5e30.js} +0 -0
  424. /package/build/{HEIGHT_GIRLS.zscore.monthly-a9088cff.js → HEIGHT_GIRLS.zscore.monthly-2a6220ef.js} +0 -0
  425. /package/build/{HEIGHT_GIRLS.zscore.weekly-3af9512e.js → HEIGHT_GIRLS.zscore.weekly-c676eacf.js} +0 -0
  426. /package/build/{HEIGHT_GIRLS.zscore.yearly-60b3eab0.js → HEIGHT_GIRLS.zscore.yearly-eec4124e.js} +0 -0
  427. /package/build/{Visible-24f4ae37.js → Visible-49e0cc9d.js} +0 -0
  428. /package/build/{WEIGHT_BOYS.percentile.monthly-937f229b.js → WEIGHT_BOYS.percentile.monthly-14105231.js} +0 -0
  429. /package/build/{WEIGHT_BOYS.percentile.weekly-573412d4.js → WEIGHT_BOYS.percentile.weekly-7bb55772.js} +0 -0
  430. /package/build/{WEIGHT_BOYS.percentile.yearly-8b8ad9fe.js → WEIGHT_BOYS.percentile.yearly-d5d911a6.js} +0 -0
  431. /package/build/{WEIGHT_BOYS.zscore.monthly-c20b7ddc.js → WEIGHT_BOYS.zscore.monthly-67f28812.js} +0 -0
  432. /package/build/{WEIGHT_BOYS.zscore.weekly-17ff91ca.js → WEIGHT_BOYS.zscore.weekly-c5749492.js} +0 -0
  433. /package/build/{WEIGHT_BOYS.zscore.yearly-bf2e850b.js → WEIGHT_BOYS.zscore.yearly-f9dfc214.js} +0 -0
  434. /package/build/{WEIGHT_GIRLS.percentile.monthly-6deb23bc.js → WEIGHT_GIRLS.percentile.monthly-863b5e58.js} +0 -0
  435. /package/build/{WEIGHT_GIRLS.percentile.weekly-603d00e9.js → WEIGHT_GIRLS.percentile.weekly-97e5da17.js} +0 -0
  436. /package/build/{WEIGHT_GIRLS.percentile.yearly-60cdc8d1.js → WEIGHT_GIRLS.percentile.yearly-540af1d1.js} +0 -0
  437. /package/build/{WEIGHT_GIRLS.zscore.monthly-14c20f6f.js → WEIGHT_GIRLS.zscore.monthly-79fe6b74.js} +0 -0
  438. /package/build/{WEIGHT_GIRLS.zscore.weekly-394bbf62.js → WEIGHT_GIRLS.zscore.weekly-0ec74845.js} +0 -0
  439. /package/build/{WEIGHT_GIRLS.zscore.yearly-04c5803f.js → WEIGHT_GIRLS.zscore.yearly-7e811cf4.js} +0 -0
  440. /package/build/{animation-98f0f673.js → animation-13c1efd7.js} +0 -0
  441. /package/build/{constants-c84c0a84.js → constants-0dc7ef32.js} +0 -0
  442. /package/build/{constants-15fd8e3c.js → constants-4b2fea40.js} +0 -0
  443. /package/build/{dataTransform-466b2cef.js → dataTransform-ed106647.js} +0 -0
  444. /package/build/{doctor-e368b391.js → doctor-b018f684.js} +0 -0
  445. /package/build/esm/{BMI_BOYS.percentile.monthly-d847cb51.js → BMI_BOYS.percentile.monthly-eca08d1b.js} +0 -0
  446. /package/build/esm/{BMI_BOYS.percentile.weekly-28f99e79.js → BMI_BOYS.percentile.weekly-0f36c0a5.js} +0 -0
  447. /package/build/esm/{BMI_BOYS.percentile.yearly-e17cdcd7.js → BMI_BOYS.percentile.yearly-de605740.js} +0 -0
  448. /package/build/esm/{BMI_BOYS.zscore.monthly-c1bcc29a.js → BMI_BOYS.zscore.monthly-871240d7.js} +0 -0
  449. /package/build/esm/{BMI_BOYS.zscore.weekly-87c39d2a.js → BMI_BOYS.zscore.weekly-53e9361f.js} +0 -0
  450. /package/build/esm/{BMI_BOYS.zscore.yearly-c34d70cd.js → BMI_BOYS.zscore.yearly-693c5ba7.js} +0 -0
  451. /package/build/esm/{BMI_GIRLS.percentile.monthly-9b3d44a4.js → BMI_GIRLS.percentile.monthly-af445923.js} +0 -0
  452. /package/build/esm/{BMI_GIRLS.percentile.weekly-1bd0fd46.js → BMI_GIRLS.percentile.weekly-038c1d84.js} +0 -0
  453. /package/build/esm/{BMI_GIRLS.percentile.yearly-914d5a00.js → BMI_GIRLS.percentile.yearly-ad96c33e.js} +0 -0
  454. /package/build/esm/{BMI_GIRLS.zscore.monthly-ec794401.js → BMI_GIRLS.zscore.monthly-d1463624.js} +0 -0
  455. /package/build/esm/{BMI_GIRLS.zscore.weekly-97f06d42.js → BMI_GIRLS.zscore.weekly-7d60db22.js} +0 -0
  456. /package/build/esm/{BMI_GIRLS.zscore.yearly-54289d04.js → BMI_GIRLS.zscore.yearly-df88448a.js} +0 -0
  457. /package/build/esm/{ChevronDown-a4cf7631.js → ChevronDown-47446788.js} +0 -0
  458. /package/build/esm/{Close-a61d81c6.js → Close-c3a49880.js} +0 -0
  459. /package/build/esm/{Google-658e601e.js → Google-4613f559.js} +0 -0
  460. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.monthly-2504b72e.js → HEAD CIRCUM_BOYS.percentile.monthly-60e25ec5.js} +0 -0
  461. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.weekly-945555ab.js → HEAD CIRCUM_BOYS.percentile.weekly-3c3343ae.js} +0 -0
  462. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.yearly-0ecdf4fa.js → HEAD CIRCUM_BOYS.percentile.yearly-be196089.js} +0 -0
  463. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.monthly-a415c706.js → HEAD CIRCUM_BOYS.zscore.monthly-29ff8370.js} +0 -0
  464. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.weekly-4301d02a.js → HEAD CIRCUM_BOYS.zscore.weekly-92e4b27a.js} +0 -0
  465. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.yearly-db5d50e4.js → HEAD CIRCUM_BOYS.zscore.yearly-2e6a5016.js} +0 -0
  466. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.monthly-20107e97.js → HEAD CIRCUM_GIRLS.percentile.monthly-b9290e16.js} +0 -0
  467. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.weekly-f7dc82dd.js → HEAD CIRCUM_GIRLS.percentile.weekly-8062ea4d.js} +0 -0
  468. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.yearly-1593553b.js → HEAD CIRCUM_GIRLS.percentile.yearly-b164ccc6.js} +0 -0
  469. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.monthly-bc248172.js → HEAD CIRCUM_GIRLS.zscore.monthly-d9e6f3eb.js} +0 -0
  470. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.weekly-307991f7.js → HEAD CIRCUM_GIRLS.zscore.weekly-4fd80615.js} +0 -0
  471. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.yearly-61b0290d.js → HEAD CIRCUM_GIRLS.zscore.yearly-f28609a2.js} +0 -0
  472. /package/build/esm/{HEIGHT_BOYS.percentile.monthly-9113922c.js → HEIGHT_BOYS.percentile.monthly-15a0bc4d.js} +0 -0
  473. /package/build/esm/{HEIGHT_BOYS.percentile.weekly-1f3bcc5f.js → HEIGHT_BOYS.percentile.weekly-102b50e3.js} +0 -0
  474. /package/build/esm/{HEIGHT_BOYS.percentile.yearly-267121e2.js → HEIGHT_BOYS.percentile.yearly-cf42e15a.js} +0 -0
  475. /package/build/esm/{HEIGHT_BOYS.zscore.monthly-48d404ae.js → HEIGHT_BOYS.zscore.monthly-8f455cc9.js} +0 -0
  476. /package/build/esm/{HEIGHT_BOYS.zscore.weekly-6993438a.js → HEIGHT_BOYS.zscore.weekly-f2c852bd.js} +0 -0
  477. /package/build/esm/{HEIGHT_BOYS.zscore.yearly-4bf4d1e6.js → HEIGHT_BOYS.zscore.yearly-0ebca637.js} +0 -0
  478. /package/build/esm/{HEIGHT_GIRLS.percentile.monthly-daa0663f.js → HEIGHT_GIRLS.percentile.monthly-790caf2c.js} +0 -0
  479. /package/build/esm/{HEIGHT_GIRLS.percentile.weekly-813f5fd7.js → HEIGHT_GIRLS.percentile.weekly-18f018dd.js} +0 -0
  480. /package/build/esm/{HEIGHT_GIRLS.percentile.yearly-eff8bf30.js → HEIGHT_GIRLS.percentile.yearly-5b3a5c7e.js} +0 -0
  481. /package/build/esm/{HEIGHT_GIRLS.zscore.monthly-30a32b50.js → HEIGHT_GIRLS.zscore.monthly-5a259243.js} +0 -0
  482. /package/build/esm/{HEIGHT_GIRLS.zscore.weekly-694139b8.js → HEIGHT_GIRLS.zscore.weekly-7dcf65e7.js} +0 -0
  483. /package/build/esm/{HEIGHT_GIRLS.zscore.yearly-fd93c8ea.js → HEIGHT_GIRLS.zscore.yearly-1f427d14.js} +0 -0
  484. /package/build/esm/{Visible-2bab58e1.js → Visible-c0ca5ff5.js} +0 -0
  485. /package/build/esm/{WEIGHT_BOYS.percentile.monthly-ff9ff248.js → WEIGHT_BOYS.percentile.monthly-1cb736bc.js} +0 -0
  486. /package/build/esm/{WEIGHT_BOYS.percentile.weekly-329cab06.js → WEIGHT_BOYS.percentile.weekly-cd49dbad.js} +0 -0
  487. /package/build/esm/{WEIGHT_BOYS.percentile.yearly-7febf596.js → WEIGHT_BOYS.percentile.yearly-73dbe0a9.js} +0 -0
  488. /package/build/esm/{WEIGHT_BOYS.zscore.monthly-45594801.js → WEIGHT_BOYS.zscore.monthly-cf13f60b.js} +0 -0
  489. /package/build/esm/{WEIGHT_BOYS.zscore.weekly-9530978c.js → WEIGHT_BOYS.zscore.weekly-5cb0f54e.js} +0 -0
  490. /package/build/esm/{WEIGHT_BOYS.zscore.yearly-eb72e975.js → WEIGHT_BOYS.zscore.yearly-f8920ebb.js} +0 -0
  491. /package/build/esm/{WEIGHT_GIRLS.percentile.monthly-05775d79.js → WEIGHT_GIRLS.percentile.monthly-d05adf8a.js} +0 -0
  492. /package/build/esm/{WEIGHT_GIRLS.percentile.weekly-8d9f769e.js → WEIGHT_GIRLS.percentile.weekly-8bfcc146.js} +0 -0
  493. /package/build/esm/{WEIGHT_GIRLS.percentile.yearly-30144bae.js → WEIGHT_GIRLS.percentile.yearly-b8972989.js} +0 -0
  494. /package/build/esm/{WEIGHT_GIRLS.zscore.monthly-cf07d175.js → WEIGHT_GIRLS.zscore.monthly-fb98e36d.js} +0 -0
  495. /package/build/esm/{WEIGHT_GIRLS.zscore.weekly-33e0d835.js → WEIGHT_GIRLS.zscore.weekly-69079f9a.js} +0 -0
  496. /package/build/esm/{WEIGHT_GIRLS.zscore.yearly-d608073f.js → WEIGHT_GIRLS.zscore.yearly-22e982d8.js} +0 -0
  497. /package/build/esm/{animation-936439f3.js → animation-8f44fc6c.js} +0 -0
  498. /package/build/esm/{constants-dec93ad8.js → constants-6d3e6bd2.js} +0 -0
  499. /package/build/esm/{constants-3525e3f2.js → constants-dbb68f45.js} +0 -0
  500. /package/build/esm/{dataTransform-3d760b9f.js → dataTransform-0688712b.js} +0 -0
  501. /package/build/esm/{doctor-76b1e3a5.js → doctor-23714c67.js} +0 -0
  502. /package/build/esm/{index-f99e0243.js → index-388c355e.js} +0 -0
  503. /package/build/esm/{index-b9fd9fcf.js → index-530d9459.js} +0 -0
  504. /package/build/esm/{index-b0b1e4dc.js → index-577a8f9b.js} +0 -0
  505. /package/build/esm/{index-649372bd.js → index-658ef77b.js} +0 -0
  506. /package/build/esm/{index-5a380bf2.js → index-72875897.js} +0 -0
  507. /package/build/esm/{index-b2f2ef05.js → index-a96ad622.js} +0 -0
  508. /package/build/esm/{index-037ec766.js → index-d1e7bea2.js} +0 -0
  509. /package/build/esm/{index-8227d187.js → index-f6ae34df.js} +0 -0
  510. /package/build/esm/{index.styles-24493eed.js → index.styles-e7a84f91.js} +0 -0
  511. /package/build/esm/{localizeNumberFormat-5ee70bdb.js → localizeNumberFormat-e8ce7c0c.js} +0 -0
  512. /package/build/esm/{normalizeLink-70222b22.js → normalizeLink-a6fff3b6.js} +0 -0
  513. /package/build/esm/{number-6c0361f0.js → number-9db85954.js} +0 -0
  514. /package/build/esm/{other-04096300.js → other-39c7ba92.js} +0 -0
  515. /package/build/esm/{paths-50ad35fc.js → paths-73406cfb.js} +0 -0
  516. /package/build/esm/{translationsContext-1d64cf04.js → translationsContext-db44a804.js} +0 -0
  517. /package/build/esm/{tslib.es6-b06892b6.js → tslib.es6-def645e9.js} +0 -0
  518. /package/build/esm/{types-6b50d489.js → types-d2b218e1.js} +0 -0
  519. /package/build/esm/{useIsInit-09563c77.js → useIsInit-e1c4cbbb.js} +0 -0
  520. /package/build/esm/{useOutsideClick-461af3f1.js → useOutsideClick-c5c0416e.js} +0 -0
  521. /package/build/esm/{useScrollbarSize-ea155b73.js → useScrollbarSize-cdca65c3.js} +0 -0
  522. /package/build/esm/{useUniqueId-879e70af.js → useUniqueId-5ba39dd0.js} +0 -0
  523. /package/build/esm/{utils-f4fc54ed.js → utils-ad366429.js} +0 -0
  524. /package/build/{index-2e09584a.js → index-020412a7.js} +0 -0
  525. /package/build/{index-af135972.js → index-0630bc54.js} +0 -0
  526. /package/build/{index-312d7d65.js → index-439ed166.js} +0 -0
  527. /package/build/{index-1262dfcb.js → index-5ecc8dcf.js} +0 -0
  528. /package/build/{index-cc3c4d6d.js → index-6d25977a.js} +0 -0
  529. /package/build/{index-69afccff.js → index-71123b1e.js} +0 -0
  530. /package/build/{index-8b8d709b.js → index-a18c5ff1.js} +0 -0
  531. /package/build/{index-5aac0dc2.js → index-ec78675c.js} +0 -0
  532. /package/build/{index.styles-33ccc931.js → index.styles-1c27538c.js} +0 -0
  533. /package/build/{localizeNumberFormat-cf37a5eb.js → localizeNumberFormat-3fa00932.js} +0 -0
  534. /package/build/{normalizeLink-79d4e277.js → normalizeLink-cdde0b93.js} +0 -0
  535. /package/build/{number-87c5f3a1.js → number-d95061a1.js} +0 -0
  536. /package/build/{other-81af4989.js → other-4710bd77.js} +0 -0
  537. /package/build/{paths-31b6c759.js → paths-264a6504.js} +0 -0
  538. /package/build/{translationsContext-32ff79c3.js → translationsContext-02291cc2.js} +0 -0
  539. /package/build/{tslib.es6-a8bff8b8.js → tslib.es6-0c296361.js} +0 -0
  540. /package/build/{types-40d5f385.js → types-124cdc28.js} +0 -0
  541. /package/build/{useIsInit-1dd7e2ba.js → useIsInit-1962c185.js} +0 -0
  542. /package/build/{useOutsideClick-009d5b2b.js → useOutsideClick-99f10750.js} +0 -0
  543. /package/build/{useScrollbarSize-499a8e08.js → useScrollbarSize-3663cbc4.js} +0 -0
  544. /package/build/{useUniqueId-cf03a9e2.js → useUniqueId-5d17e7af.js} +0 -0
  545. /package/build/{utils-77ed117f.js → utils-e42c732c.js} +0 -0
package/build/lead.js CHANGED
@@ -2,74 +2,54 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('./tslib.es6-a8bff8b8.js');
5
+ var tslib_es6 = require('./tslib.es6-0c296361.js');
6
6
  var React = require('react');
7
7
  var core = require('@mantine/core');
8
8
  var dayjs = require('dayjs');
9
9
  var debounce = require('lodash/debounce');
10
10
  var form = require('@mantine/form');
11
- var index = require('./index-4de45eec.js');
12
- var translationsContext = require('./translationsContext-32ff79c3.js');
11
+ var index = require('./index-1832c923.js');
12
+ var translationsContext = require('./translationsContext-02291cc2.js');
13
13
  var miscCookieHelper = require('./miscCookieHelper.js');
14
- var utils$1 = require('./utils-77ed117f.js');
15
- var index$1 = require('./index-87d3b911.js');
16
- var index$2 = require('./index-125f65cd.js');
17
- var index$4 = require('./index-9f0bcaee.js');
18
- var utils = require('./utils-ed4bc922.js');
19
- var dates = require('@mantine/dates');
20
- var index$7 = require('./index-79296333.js');
21
- var index$9 = require('./index-080b0aaf.js');
22
- require('./index-5aac0dc2.js');
23
- require('./useMantineLocale-cbfcee76.js');
24
- var index$5 = require('./index-2c675ca4.js');
25
- require('./index.styles-33ccc931.js');
14
+ var utils$1 = require('./utils-e42c732c.js');
15
+ var index$1 = require('./index-6e1d6d78.js');
16
+ var index$2 = require('./index-ffa29b44.js');
17
+ var index$4 = require('./index-9ed8f15e.js');
18
+ var index$3 = require('./index-04336ab9.js');
19
+ require('./index.styles-1c27538c.js');
26
20
  var hooks = require('@mantine/hooks');
27
- require('./other-81af4989.js');
28
- require('./index-f40aef22.js');
29
- var usePlacesAutocomplete = require('./usePlacesAutocomplete-d9c9d190.js');
30
- var index$3 = require('./index-b3c66e75.js');
31
- var index$6 = require('./index-b0be7fa8.js');
32
- var translationsProvider = require('./translationsProvider-b383e3b6.js');
33
- var Locale = require('./Locale-7ef9bbac.js');
21
+ require('./useMantineLocale-aa4e4cdc.js');
22
+ require('./index-3c9b6c14.js');
23
+ require('./index-ec78675c.js');
24
+ var index$7 = require('./index-7a0bbb05.js');
25
+ require('./other-4710bd77.js');
26
+ require('./index-0b1b3404.js');
27
+ var utils = require('./utils-cfbfcd70.js');
28
+ require('@mantine/dates');
29
+ var usePlacesAutocomplete = require('./usePlacesAutocomplete-60f0a6d0.js');
30
+ var index$5 = require('./index-3d0f0804.js');
34
31
  var uuid = require('uuid');
35
- var PhoneInputBase = require('react-phone-number-input');
32
+ var index$6 = require('./index-71123b1e.js');
33
+ var index$9 = require('./index-964bebd5.js');
34
+ var useScreenSize = require('./useScreenSize-013494cb.js');
35
+ var ReactDOM = require('react-dom');
36
+ var react = require('@emotion/react');
36
37
  var styled = require('@emotion/styled');
37
38
  var miscTheme = require('./miscTheme.js');
38
- var react = require('@emotion/react');
39
- var togetherComponentGlobalContext = require('./utils-b86dfeef.js');
40
- var index$8 = require('./index-69afccff.js');
41
- var index$a = require('./index-93bc0075.js');
42
- var useScreenSize = require('./useScreenSize-5edbf21b.js');
43
- var ReactDOM = require('react-dom');
44
- var InputDate = require('./InputDate-61e9c5a1.js');
45
- var Close = require('./Close-74cf47e8.js');
39
+ var index$8 = require('./index-7d70d6d9.js');
40
+ var Close = require('./Close-88109e78.js');
46
41
  require('@hhgtech/icons/other');
47
42
  require('@mantine/carousel');
43
+ require('./Locale-a034e717.js');
48
44
  require('classnames');
49
- require('./useUniqueId-cf03a9e2.js');
45
+ require('./useUniqueId-5d17e7af.js');
50
46
  require('./constantsSite.js');
51
47
  require('@hhgtech/icons/core');
52
- require('date-fns/locale');
48
+ require('@mantine/notifications');
53
49
  require('./constantsDomainLocales.js');
54
- require('./constantsRiskScreener.js');
55
50
  require('./constantsIsProduction.js');
56
- require('@mantine/notifications');
57
- require('./i18n-values/en-PH.js');
58
- require('./i18n-values/hi-IN.js');
59
- require('./i18n-values/id-ID.js');
60
- require('./i18n-values/km-KH.js');
61
- require('./i18n-values/ms-MY.js');
62
- require('./i18n-values/my-MM.js');
63
- require('./i18n-values/th-TH.js');
64
- require('./i18n-values/tl-PH.js');
65
- require('./i18n-values/vi-VN.js');
66
- require('./i18n-values/vi-VN_MB.js');
67
- require('./i18n-values/zh-TW.js');
68
- require('./index-1262dfcb.js');
69
- require('slugify');
70
- require('string-format');
71
- require('./togetherApiPaths.js');
72
- require('./constants-15fd8e3c.js');
51
+ require('date-fns/locale');
52
+ require('./constantsRiskScreener.js');
73
53
  require('vaul');
74
54
 
75
55
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -121,7 +101,7 @@ if (sessionStorage.getItem('insider_object')) {
121
101
  }
122
102
  const docLang = document.documentElement.lang;
123
103
  // TODO: country code
124
- const LEAD_LOCALE_DATA$1 = {
104
+ const LEAD_LOCALE_DATA = {
125
105
  'vi-VN': {
126
106
  popupLang: 'vi',
127
107
  countryCode: 'vn',
@@ -163,7 +143,7 @@ const LEAD_LOCALE_DATA$1 = {
163
143
  countryCodeNumber: 91,
164
144
  },
165
145
  };
166
- const LEAD_LOCALE = LEAD_LOCALE_DATA$1[docLang] || LEAD_LOCALE_DATA$1['vi-VN'];
146
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
167
147
  function LEAD_RESET_VAR() {
168
148
  // LEAD_CURRENT_URL = location.href.toLowerCase();
169
149
  LEAD_CURRENT_URL =
@@ -184,11 +164,6 @@ const LEAD_TIMEZONE_DATA = {
184
164
  9: 'Asia/Manila', // Philippines / Filipinos Site
185
165
  };
186
166
 
187
- const LEADGEN_ACTIONS = {
188
- SHOW: 'SHOW',
189
- SCROLL: 'SCROLL',
190
- TIME: 'TIME',
191
- };
192
167
  const LEADGEN_LAYOUT = {
193
168
  LightBoxA: 'LightBoxA',
194
169
  LightBoxB: 'LightBoxB',
@@ -218,10 +193,8 @@ const LEADGEN_BLOCK = {
218
193
  DropdownBlock: 'DropdownBlock',
219
194
  CheckboxBlock: 'CheckboxBlock',
220
195
  TncBlock: 'TncBlock',
221
- TitleBlock: 'TitleBlock',
222
- SubtitleBlock: 'SubtitleBlock',
223
196
  };
224
- const LEADGEN_BLOCK_INPUT = [
197
+ const LEADGEN_BLOCK_IN_FORM = [
225
198
  LEADGEN_BLOCK.TextBlock,
226
199
  LEADGEN_BLOCK.NumberBlock,
227
200
  LEADGEN_BLOCK.DateBlock,
@@ -236,59 +209,7 @@ const LEADGEN_BLOCK_INPUT = [
236
209
  LEADGEN_BLOCK.CheckboxBlock,
237
210
  LEADGEN_BLOCK.TncBlock,
238
211
  ];
239
- const leadGenFieldNamePhone = (listBlockAdded) => {
240
- return listBlockAdded
241
- .filter(({ name }) => [
242
- LEADGEN_BLOCK.PhoneBlock,
243
- LEADGEN_BLOCK.PhoneOtpBlock,
244
- LEADGEN_BLOCK.WhatsappOtpBlock,
245
- LEADGEN_BLOCK.ZaloOtpBlock,
246
- ].includes(name))
247
- .map(({ data }) => data.value);
248
- };
249
212
  const SSO_MAP_LEAD = ['name', 'email', 'birthday', 'phone', 'gender'];
250
- const LEAD_LOCALE_DATA = {
251
- 'vi-VN': {
252
- popupLang: 'vi',
253
- countryCode: 'vn',
254
- countryCodeNumber: 84,
255
- },
256
- 'id-ID': {
257
- popupLang: 'id',
258
- countryCode: 'id',
259
- countryCodeNumber: 62,
260
- },
261
- 'th-TH': {
262
- popupLang: 'th',
263
- countryCode: 'th',
264
- countryCodeNumber: 66,
265
- },
266
- 'ms-MY': {
267
- popupLang: 'ms',
268
- countryCode: 'my',
269
- countryCodeNumber: 60,
270
- },
271
- 'zh-TW': {
272
- popupLang: 'zh',
273
- countryCode: 'tw',
274
- countryCodeNumber: 886,
275
- },
276
- 'km-KH': {
277
- popupLang: 'km',
278
- countryCode: 'kh',
279
- countryCodeNumber: 855,
280
- },
281
- 'my-MM': {
282
- popupLang: 'my',
283
- countryCode: 'mm',
284
- countryCodeNumber: 95,
285
- },
286
- 'hi-IN': {
287
- popupLang: 'hi',
288
- countryCode: 'in',
289
- countryCodeNumber: 91,
290
- },
291
- };
292
213
  const mappingSSOToLead = (userInfoProps) => {
293
214
  var _a, _b;
294
215
  try {
@@ -304,7 +225,7 @@ const mappingSSOToLead = (userInfoProps) => {
304
225
  if (ssoKey === 'birthday') {
305
226
  const dob = dayjs__default["default"](initValue, 'YYYY-MM-DD', true);
306
227
  if (dob.isValid()) {
307
- user.birthday = dob.toDate();
228
+ user.birthday = dob;
308
229
  }
309
230
  }
310
231
  else if (ssoKey === 'gender') {
@@ -327,66 +248,16 @@ const mappingSSOToLead = (userInfoProps) => {
327
248
  catch (error) {
328
249
  return;
329
250
  }
330
- };
331
- const formatCampaignDetail = (campaign) => {
332
- if (!campaign) {
333
- return {};
334
- }
335
- try {
336
- const { extra_fields, thank_you_image } = campaign || {};
337
- const { textBlocks: exTextBlocks, imageBlocks: exImageBlocks, listBlockAdded: exListBlockAdded, listBlockThankyou: exListBlockThankyou, actionBlocks: exActionBlocks, } = extra_fields;
338
- const textBlocks = JSON.parse(exTextBlocks);
339
- const imageBlocks = JSON.parse(exImageBlocks);
340
- const listBlockAdded = JSON.parse(exListBlockAdded);
341
- const listBlockThankyou = JSON.parse(exListBlockThankyou);
342
- const actionBlocks = JSON.parse(exActionBlocks);
343
- const ThankYouBlock = {
344
- image: { src: thank_you_image },
345
- };
346
- listBlockThankyou.forEach((block) => {
347
- const { name, data } = block || {};
348
- const { value: htmlText, align, newtab, url } = data || {};
349
- switch (name) {
350
- case LEADGEN_BLOCK.TitleBlock: {
351
- ThankYouBlock.title = { htmlText, align };
352
- }
353
- case LEADGEN_BLOCK.SubtitleBlock: {
354
- ThankYouBlock.description = { htmlText, align };
355
- }
356
- case LEADGEN_BLOCK.LinkButtonBlock: {
357
- ThankYouBlock.button = { htmlText, newtab, url };
358
- }
359
- }
360
- });
361
- return Object.assign(Object.assign({}, campaign), { extra_fields: Object.assign(Object.assign({}, extra_fields), { textBlocks,
362
- imageBlocks,
363
- listBlockAdded,
364
- listBlockThankyou,
365
- actionBlocks }), ThankYouBlock });
366
- }
367
- catch (error) {
368
- return {};
369
- }
370
251
  };
371
252
 
372
253
  class Store {
373
254
  constructor() {
374
- this.apiSsoUrl = 'https://staging-id.hellobacsi.com/';
375
255
  this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
376
256
  this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
377
257
  }
378
258
  }
379
259
  const leadStore = new Store();
380
260
 
381
- const LEADGEN_API_METHOD = {
382
- GET: 'get',
383
- POST: 'POST',
384
- };
385
- const LEADGEN_API_PATH = {
386
- V2_CAMPAIGN: 'api/v2/campaign',
387
- V2_SUBSCRIPTION_LEAD: 'api/v2/subscription-box',
388
- V2_SUBSCRIPTION_INFO: 'api/campaign/get-title',
389
- };
390
261
  const leadApi = {
391
262
  call(_a) {
392
263
  var { url, data = undefined } = _a, config = tslib_es6.__rest(_a, ["url", "data"]);
@@ -490,50 +361,8 @@ const verifyOtpLead = ({ phone, otp, type, }) => {
490
361
  },
491
362
  });
492
363
  };
493
- const getCampaignByCode = (campaign_code) => {
494
- return leadApi.call({
495
- url: `${LEADGEN_API_PATH.V2_CAMPAIGN}/${campaign_code}`,
496
- method: LEADGEN_API_METHOD.GET,
497
- });
498
- };
499
- const getSubscriptionBoxInfo = ({ category, site, }) => {
500
- return leadApi.call({
501
- url: `${LEADGEN_API_PATH.V2_SUBSCRIPTION_INFO}?category=${category}&site=${site}`,
502
- method: LEADGEN_API_METHOD.GET,
503
- });
504
- };
505
- const postSubscriptionBoxLead = ({ data }) => {
506
- return leadApi.call({
507
- url: LEADGEN_API_PATH.V2_SUBSCRIPTION_LEAD,
508
- method: LEADGEN_API_METHOD.POST,
509
- data,
510
- });
511
- };
512
- const postUserInfoFromLeadGen = ({}) => {
513
- return;
514
- };
515
- const campaignPostImpression = ({ code, action, title_article, ga_client_id, cookie_id, extra, url, referrer, }) => {
516
- return leadApi.call({
517
- url: `api/campaign/${code}/impression`,
518
- method: LEADGEN_API_METHOD.POST,
519
- data: {
520
- action,
521
- title_article,
522
- cookie_id,
523
- ga_client_id,
524
- url,
525
- extra,
526
- referrer,
527
- },
528
- });
529
- };
530
364
  const Service = {
531
365
  campaignGetById,
532
- getCampaignByCode,
533
- getSubscriptionBoxInfo,
534
- postSubscriptionBoxLead,
535
- postUserInfoFromLeadGen,
536
- campaignPostImpression,
537
366
  validateEmailOrPhoneOnSubot,
538
367
  validateEmailOrPhoneOnLeadGen,
539
368
  validatePhoneNumberOnLeadGen,
@@ -873,6 +702,8 @@ const Description = (_a) => {
873
702
  return description ? (React__default["default"].createElement(index$1.Text, Object.assign({ size: "p3" }, rest), description)) : null;
874
703
  };
875
704
 
705
+ const LeadGenContext = React.createContext({});
706
+
876
707
  var useStyles$2 = core.createStyles(() => {
877
708
  return {
878
709
  control: {},
@@ -935,6 +766,7 @@ const SubtitleBlock$1 = ({ children, align, }) => (React__default["default"].cre
935
766
  const TitleBlock$1 = ({ children, align, }) => (React__default["default"].createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
936
767
 
937
768
  const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, popoverProps, }) => {
769
+ const { primaryColor } = React.useContext(LeadGenContext);
938
770
  const { classes, cx } = useStyles$2(undefined, {
939
771
  name: 'LeadGen__Field',
940
772
  styles,
@@ -989,7 +821,7 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
989
821
  case 'LinkButtonBlock':
990
822
  return (React__default["default"].createElement("div", { key: index },
991
823
  React__default["default"].createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
992
- React__default["default"].createElement(index$3.Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
824
+ React__default["default"].createElement(index$3.Button, { type: "button", size: "md", color: primaryColor, className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
993
825
  onClose === null || onClose === void 0 ? void 0 : onClose();
994
826
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
995
827
  } }, value))));
@@ -1049,6 +881,7 @@ const Heading = (_a) => {
1049
881
 
1050
882
  const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps, submitProps, }) => {
1051
883
  var _a;
884
+ const { primaryColor } = React.useContext(LeadGenContext);
1052
885
  const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, setFormRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = React.useContext(LeadGenComponentContext);
1053
886
  const { classes, cx } = useStyles$1(undefined, {
1054
887
  name: 'LeadGen__FormComponent',
@@ -1137,7 +970,7 @@ const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps,
1137
970
  control: classes.control,
1138
971
  }, listBlockAdded: listBlockAdded, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit, popoverProps: popoverProps })),
1139
972
  ((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) ? null : (React__default["default"].createElement("div", { className: classes.submitBtnWrapper },
1140
- React__default["default"].createElement(index$5.Button, Object.assign({ size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, loading: isSubmitLoading }, submitProps), popUpSubmitText))))));
973
+ React__default["default"].createElement(index$3.Button, Object.assign({ size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, loading: isSubmitLoading, color: primaryColor }, submitProps), popUpSubmitText))))));
1141
974
  };
1142
975
  const Form = (props) => {
1143
976
  const { showOtpPhone, showThankyou } = React.useContext(LeadGenComponentContext);
@@ -1268,7 +1101,7 @@ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, st
1268
1101
  submitOtp();
1269
1102
  }, className: cx(classes.root, className) },
1270
1103
  React__default["default"].createElement("div", { className: classes.header },
1271
- React__default["default"].createElement(index$6.Heading, { tag: "h3", className: classes.heading }, t('lead.otp.title')),
1104
+ React__default["default"].createElement(index$5.Heading, { tag: "h3", className: classes.heading }, t('lead.otp.title')),
1272
1105
  React__default["default"].createElement(index$1.Text, { size: "p3", className: classes.description }, t('lead.otp.desc', { phone: displayPhone }))),
1273
1106
  React__default["default"].createElement(index$2.Input, { ref: inputRef, name: '_' + name + '-otp', spellCheck: false, type: "number", placeholder: t('lead.otp.phonePlaceholder'), className: classes.control, label: t('lead.otp.phoneLabel'), "data-control": "otp", withAsterisk: true, pattern: "[0-9]*", value: otp, maxLength: 6, onChange: (v) => {
1274
1107
  setIsDirty(true);
@@ -1279,10 +1112,10 @@ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, st
1279
1112
  setErrorMsg(undefined);
1280
1113
  }, error: isDirty ? errorMsg : undefined }),
1281
1114
  React__default["default"].createElement("div", { className: classes.actions },
1282
- React__default["default"].createElement(index$5.Button, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1115
+ React__default["default"].createElement(index$3.Button, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1283
1116
  // onClick={() => submitOtp()}
1284
1117
  disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
1285
- React__default["default"].createElement(index$5.Button, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1118
+ React__default["default"].createElement(index$3.Button, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1286
1119
  sendOtp();
1287
1120
  }, disabled: !!resendTimer }, t('lead.otp.resend', {
1288
1121
  timer: resendTimer ? ` (${resendTimer}s)` : '',
@@ -1325,7 +1158,6 @@ var enPH = {
1325
1158
  "validator.min": "jQuery.validator.format('Please enter a value greater than or equal to {0}.",
1326
1159
  "validator.emailUsed": "Email already in use for this campaign.",
1327
1160
  "validator.phoneUsed": "Your phone number already in use for this campaign.",
1328
- "validator.dateInvalid": "This date is not valid, please update.",
1329
1161
  "lead.otp.title": "Enter OTP",
1330
1162
  "lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
1331
1163
  "lead.otp.verify": "Verify",
@@ -1334,10 +1166,7 @@ var enPH = {
1334
1166
  "lead.otp.phonePlaceholder": "Enter OTP",
1335
1167
  "lead.empty.title": "Oops, seem your information is empty, do you want to submit the information again?",
1336
1168
  "lead.empty.cancel": "Cancel",
1337
- "lead.empty.submitAgain": "Submit again",
1338
- "common.day": "Day",
1339
- "common.month": "Month",
1340
- "common.year": "Year"
1169
+ "lead.empty.submitAgain": "Submit again"
1341
1170
  };
1342
1171
 
1343
1172
  var hiIN = {
@@ -1348,7 +1177,6 @@ var hiIN = {
1348
1177
  "validator.maxlength": "कृपया {0} अक्षर से अधिक दर्ज न करें",
1349
1178
  "validator.minlength": "कृपया कम से कम {0} अक्षर दर्ज करें",
1350
1179
  "validator.phone": "कृपया एक वैध संख्या दर्ज करें",
1351
- "validator.dateInvalid": "यह तिथि मान्य नहीं है, कृपया अपडेट करें।",
1352
1180
  "validator.emailUsed": "Email already in use for this campaign.",
1353
1181
  "validator.phoneUsed": "Your phone number already in use for this campaign.",
1354
1182
  "lead.otp.title": "Enter OTP",
@@ -1357,10 +1185,7 @@ var hiIN = {
1357
1185
  "lead.otp.resend": "Resend OTP{timer}",
1358
1186
  "lead.empty.title": "ऊप्स! लगता है आपकी जानकारी खाली है। क्या आप जानकारी फिर से सबमिट करना चाहते हैं?",
1359
1187
  "lead.empty.cancel": "रद्द करें",
1360
- "lead.empty.submitAgain": "फिर से सबमिट करें",
1361
- "common.day": "साल",
1362
- "common.month": "महीना",
1363
- "common.year": ""
1188
+ "lead.empty.submitAgain": "फिर से सबमिट करें"
1364
1189
  };
1365
1190
 
1366
1191
  var idID = {
@@ -1373,7 +1198,6 @@ var idID = {
1373
1198
  "validator.phone": "Tolong daftarkan nomor telepon yang valid",
1374
1199
  "validator.emailUsed": "Email sudah digunakan untuk kampanye ini.",
1375
1200
  "validator.phoneUsed": "Nomor telepon Anda sudah digunakan untuk kampanye ini.",
1376
- "validator.dateInvalid": "Tanggal ini tidak valid, silakan perbarui",
1377
1201
  "lead.otp.title": "Masukkan OTP",
1378
1202
  "lead.otp.desc": "Kami telah mengirimkan OTP ke nomor ponsel Anda {phone}",
1379
1203
  "lead.otp.verify": "Verifikasi",
@@ -1382,10 +1206,7 @@ var idID = {
1382
1206
  "lead.otp.phonePlaceholder": "Masukkan OTP",
1383
1207
  "lead.empty.title": "Oops, sepertinya informasi Anda kosong. Apakah Anda ingin mengirimkan informasi lagi?",
1384
1208
  "lead.empty.cancel": "Batal",
1385
- "lead.empty.submitAgain": "Kirim lagi",
1386
- "common.day": "Hari",
1387
- "common.month": "Bulan",
1388
- "common.year": "Tahun"
1209
+ "lead.empty.submitAgain": "Kirim lagi"
1389
1210
  };
1390
1211
 
1391
1212
  var kmKH = {
@@ -1398,7 +1219,6 @@ var kmKH = {
1398
1219
  "validator.phone": "សូម​វាយបញ្ចូល​លេខ​ឲ្យ​បាន​ត្រឹមត្រូវ",
1399
1220
  "validator.emailUsed": "អ៊ីមែលត្រូវបានប្រើប្រាស់សម្រាប់យុទ្ធនាការនេះរួចហើយ។",
1400
1221
  "validator.phoneUsed": "លេខទូរស័ព្ទរបស់អ្នកត្រូវបានប្រើប្រាស់សម្រាប់យុទ្ធនាការនេះរួចហើយ។",
1401
- "validator.dateInvalid": "កាលបរិច្ឆេទនេះមិនត្រឹមត្រូវទេ សូមធ្វើបច្ចុប្បន្នភាព។",
1402
1222
  "lead.otp.title": "បញ្ចូល OTP",
1403
1223
  "lead.otp.desc": "យើងបានផ្ញើ OTP ទៅកាន់លេខទូរសព្ទរបស់អ្នក {phone}",
1404
1224
  "lead.otp.verify": "ផ្ទៀងផ្ទាត់",
@@ -1407,10 +1227,7 @@ var kmKH = {
1407
1227
  "lead.otp.phonePlaceholder": "បញ្ចូល OTP",
1408
1228
  "lead.empty.title": "អូុបស! ហាក់ដូចជាព័ត៌មានរបស់អ្នកទទេ។ តើអ្នកចង់ដាក់ស្នើព័ត៌មានម្តងទៀតទេ?",
1409
1229
  "lead.empty.cancel": "លុប​ចោល",
1410
- "lead.empty.submitAgain": "ដាក់ស្នើម្ដងទៀត",
1411
- "common.day": "ឆ្នាំ",
1412
- "common.month": "ខែ",
1413
- "common.year": "ថ្ងៃ"
1230
+ "lead.empty.submitAgain": "ដាក់ស្នើម្ដងទៀត"
1414
1231
  };
1415
1232
 
1416
1233
  var msMY = {
@@ -1423,7 +1240,6 @@ var msMY = {
1423
1240
  "validator.phone": "Sila masukkan no telefon yang sah.",
1424
1241
  "validator.emailUsed": "Emel sudah digunakan untuk kempen ini.",
1425
1242
  "validator.phoneUsed": "Nombor telefon anda sudah digunakan untuk kempen ini.",
1426
- "validator.dateInvalid": "Tarikh ini tidak sah, sila kemas kini",
1427
1243
  "lead.otp.title": "Masukkan OTP",
1428
1244
  "lead.otp.desc": "Kami telah menghantar OTP ke nombor telefon bimbit anda {phone}",
1429
1245
  "lead.otp.verify": "Sahkan",
@@ -1432,10 +1248,7 @@ var msMY = {
1432
1248
  "lead.otp.phonePlaceholder": "Masukkan OTP",
1433
1249
  "lead.empty.title": "Oops, nampaknya maklumat anda kosong. Adakah anda ingin menghantar maklumat semula?",
1434
1250
  "lead.empty.cancel": "Batal",
1435
- "lead.empty.submitAgain": "Hantar semula",
1436
- "common.day": "Hari",
1437
- "common.month": "Bulan",
1438
- "common.year": "Tahun"
1251
+ "lead.empty.submitAgain": "Hantar semula"
1439
1252
  };
1440
1253
 
1441
1254
  var myMM = {
@@ -1448,7 +1261,6 @@ var myMM = {
1448
1261
  "validator.phone": "မှန်ကန်သော ဖုန်းနံပါတ်ထည့်သွင်းပါ",
1449
1262
  "validator.emailUsed": "ဤအေကာင့်အတွက် အီးမေးလ်ကို အသုံးပြုပြီးဖြစ်ပါသည်။",
1450
1263
  "validator.phoneUsed": "ဤအေကာင့်အတွက် သင့်ဖုန်းနံပါတ်ကို အသုံးပြုပြီးဖြစ်ပါသည်။",
1451
- "validator.dateInvalid": "ယနေ့စွဲမှားနေသည်၊ ကျေးဇူးပြု၍ ပြင်ဆင်ပါ။",
1452
1264
  "lead.otp.title": "OTP ကိုထည့်ပါ",
1453
1265
  "lead.otp.desc": "ကျွန်ုပ်တို့သည် OTP ကိုသင့်ဖုန်းနံပါတ် {phone} သို့ပို့ခဲ့သည်",
1454
1266
  "lead.otp.verify": "အတည်ပြုပါ",
@@ -1457,10 +1269,7 @@ var myMM = {
1457
1269
  "lead.otp.phonePlaceholder": "OTP ကိုထည့်ပါ",
1458
1270
  "lead.empty.title": "အုပ်စ်! သင့်အချက်အလက်သည် ဗလာဖြစ်နေသလိုဖြစ်သည်။ ထပ်မံတင်သွင်းလိုပါသလား?",
1459
1271
  "lead.empty.cancel": "မလုပ်ဆောင်ပါ",
1460
- "lead.empty.submitAgain": "ထပ်မံတင်သွင်းပါ",
1461
- "common.day": "ရက်",
1462
- "common.month": "လ",
1463
- "common.year": "နှစ်"
1272
+ "lead.empty.submitAgain": "ထပ်မံတင်သွင်းပါ"
1464
1273
  };
1465
1274
 
1466
1275
  var thTH = {
@@ -1473,7 +1282,6 @@ var thTH = {
1473
1282
  "validator.phone": "กรุณาใส่ตัวเลขที่ถูกต้อง",
1474
1283
  "validator.emailUsed": "อีเมลนี้ถูกใช้สำหรับแคมเปญนี้แล้ว",
1475
1284
  "validator.phoneUsed": "หมายเลขโทรศัพท์ของคุณถูกใช้สำหรับแคมเปญนี้แล้ว",
1476
- "validator.dateInvalid": "วันที่นี้ไม่ถูกต้อง โปรดอัปเดต",
1477
1285
  "lead.otp.title": "ป้อน OTP",
1478
1286
  "lead.otp.desc": "เราได้ส่ง OTP ไปยังหมายเลขโทรศัพท์มือถือของคุณ {phone}",
1479
1287
  "lead.otp.verify": "ยืนยัน",
@@ -1482,10 +1290,7 @@ var thTH = {
1482
1290
  "lead.otp.phonePlaceholder": "ป้อน OTP",
1483
1291
  "lead.empty.title": "อุ๊ปส์! ดูเหมือนว่าข้อมูลของคุณว่างเปล่า คุณต้องการส่งข้อมูลอีกครั้งหรือไม่?",
1484
1292
  "lead.empty.cancel": "ยกเลิก",
1485
- "lead.empty.submitAgain": "ส่งอีกครั้ง",
1486
- "common.day": "วัน",
1487
- "common.month": "เดือน",
1488
- "common.year": "ปี"
1293
+ "lead.empty.submitAgain": "ส่งอีกครั้ง"
1489
1294
  };
1490
1295
 
1491
1296
  var viVN = {
@@ -1509,7 +1314,6 @@ var viVN = {
1509
1314
  "validator.phone": "Nhập đúng định dạng số điện thoại",
1510
1315
  "validator.emailUsed": "Email này đã được sử dụng.",
1511
1316
  "validator.phoneUsed": "Số điện thoại này đã được sử dụng.",
1512
- "validator.dateInvalid": "Ngày này không hợp lệ, vui lòng cập nhật.",
1513
1317
  "lead.otp.title": "Nhập OTP",
1514
1318
  "lead.otp.desc": "Chúng tôi đã gửi OTP đến số điện thoại của bạn {phone}",
1515
1319
  "lead.otp.verify": "Xác minh",
@@ -1518,10 +1322,7 @@ var viVN = {
1518
1322
  "lead.otp.phonePlaceholder": "Nhập OTP",
1519
1323
  "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?",
1520
1324
  "lead.empty.cancel": "Hủy",
1521
- "lead.empty.submitAgain": "Gửi lại",
1522
- "common.day": "Ngày",
1523
- "common.month": "Tháng",
1524
- "common.year": "Năm"
1325
+ "lead.empty.submitAgain": "Gửi lại"
1525
1326
  };
1526
1327
 
1527
1328
  var zhTW = {
@@ -1534,7 +1335,6 @@ var zhTW = {
1534
1335
  "validator.phone": "請填入有效的電話號碼",
1535
1336
  "validator.emailUsed": "此電子郵件已被使用於此活動。",
1536
1337
  "validator.phoneUsed": "您的手機號碼已被使用於此活動。",
1537
- "validator.dateInvalid": "此日期無效,請更新.",
1538
1338
  "lead.otp.title": "輸入 OTP",
1539
1339
  "lead.otp.desc": "我們已將 OTP 發送到您的手機號碼 {phone}",
1540
1340
  "lead.otp.verify": "驗證",
@@ -1543,10 +1343,7 @@ var zhTW = {
1543
1343
  "lead.otp.phonePlaceholder": "輸入 OTP",
1544
1344
  "lead.empty.title": "哎呀,您的資訊似乎是空的,您想要重新提交資訊嗎?",
1545
1345
  "lead.empty.cancel": "取消",
1546
- "lead.empty.submitAgain": "重新提交",
1547
- "common.day": "日",
1548
- "common.month": "月",
1549
- "common.year": "年"
1346
+ "lead.empty.submitAgain": "重新提交"
1550
1347
  };
1551
1348
 
1552
1349
  const translationsMap = {
@@ -1558,1618 +1355,92 @@ const translationsMap = {
1558
1355
  'my-MM': myMM,
1559
1356
  'km-KH': kmKH,
1560
1357
  'zh-TW': zhTW,
1561
- 'zh-CN': zhTW,
1562
1358
  'th-TH': thTH,
1563
1359
  'tl-PH': enPH,
1564
1360
  };
1565
1361
  const getTranslations = (locale) => {
1566
- const translations = Object.assign(Object.assign({}, translationsProvider.translationsMap[locale]), translationsMap[locale]);
1362
+ const translations = translationsMap[locale];
1567
1363
  if (translations) {
1568
1364
  return translations;
1569
1365
  }
1570
1366
  return translationsMap['en-PH'];
1571
1367
  };
1572
1368
 
1573
- const LeadGenContext$1 = React.createContext({});
1369
+ const useImageSize = (src) => {
1370
+ const [width, setWidth] = React.useState(16);
1371
+ const [height, setHeight] = React.useState(9);
1372
+ const [loaded, setLoaded] = React.useState(false);
1373
+ // load src image to get its width and height
1374
+ React.useEffect(() => {
1375
+ setLoaded(false);
1376
+ if (src) {
1377
+ const img = new Image();
1378
+ img.addEventListener('load', () => {
1379
+ setWidth(img.naturalWidth);
1380
+ setHeight(img.naturalHeight);
1381
+ setLoaded(true);
1382
+ });
1383
+ img.addEventListener('error', () => {
1384
+ setWidth(16);
1385
+ setHeight(9);
1386
+ setLoaded(true);
1387
+ });
1388
+ img.src = src;
1389
+ }
1390
+ else {
1391
+ setWidth(16);
1392
+ setHeight(9);
1393
+ setLoaded(true);
1394
+ }
1395
+ }, [src]);
1396
+ return {
1397
+ loaded,
1398
+ width,
1399
+ height,
1400
+ };
1401
+ };
1402
+
1403
+ const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default["default"].createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
1404
+ React__default["default"].createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
1405
+ React__default["default"].createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
1574
1406
 
1575
- const LeadGenTranslationProvider = (props) => {
1576
- const { locale, children } = props;
1577
- const translationContextValue = React.useMemo(() => ({ locale, values: getTranslations(locale) }), [locale]);
1578
- return (React__default["default"].createElement(translationsContext.TranslationsContext.Provider, { value: translationContextValue }, children));
1407
+ // url: imageBlocks.imageMobile.data.url
1408
+ // newTab: imageBlocks.imageMobile.data.newtab
1409
+ // imageMobile: campaignShow.image
1410
+ // imageDestkop: campaignShow.image_desktop
1411
+ const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
1412
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1413
+ const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
1414
+ if (!imageMobileLoaded || !imageDestkopLoaded)
1415
+ return null;
1416
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
1417
+ React__default["default"].createElement("div", { className: "le-center-tab-popup" },
1418
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
1419
+ React__default["default"].createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
1420
+ index$6.isVideo(imageMobile) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
1421
+ React__default["default"].createElement("source", { src: imageMobile }))) : (React__default["default"].createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
1422
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1423
+ } })),
1424
+ index$6.isVideo(imageDestkop) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
1425
+ React__default["default"].createElement("source", { src: imageDestkop }))) : (React__default["default"].createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
1426
+ aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
1427
+ } }))),
1428
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
1579
1429
  };
1580
1430
 
1581
- // import mockLeadData from './mockLeadData'
1582
- const listCampaignScheduled = [];
1583
- const listCampaignScheduledToActivated = [];
1584
- const listCampaignActiveButExpired = [];
1585
- const listCampaignExcludeSonsored = [];
1586
- const listCampaignDifferentSponsor = [];
1587
- const listCampaignNotDisplayInRangeOfTime = [];
1588
- function isMobile() {
1589
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
1590
- }
1591
- const getShuffleArray = (array) => {
1592
- const newArray = [...array];
1593
- for (let i = newArray.length - 1; i > 0; i--) {
1594
- const j = Math.floor(Math.random() * (i + 1));
1595
- const temp = newArray[i];
1596
- newArray[i] = newArray[j];
1597
- newArray[j] = temp;
1598
- }
1599
- return newArray;
1600
- };
1601
- const getTimeByTimezone = (timeZone = 'UTC') => {
1602
- const date = new Date();
1603
- return new Date(date.toLocaleString('en-US', { timeZone }));
1604
- };
1605
- const parseDateByCampaignTime = (dateStr) => {
1606
- // Format like this: 2023-04-04 00:00:00
1607
- try {
1608
- const [datePart, timePart] = dateStr.split(' ');
1609
- const [year, month, day] = datePart.split('-').map(Number);
1610
- const [hours, minutes, seconds] = timePart.split(':').map(Number);
1611
- /** JavaScript counts months from 0 to 11 */
1612
- return new Date(year, month - 1, day, hours, minutes, seconds);
1613
- }
1614
- catch (err) {
1615
- return null;
1616
- }
1617
- };
1618
- const checkCampaignNowInTimeframe = (c) => {
1619
- var _a;
1620
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1621
- const startedAtStr = c.started_at;
1622
- const endedAtStr = c.ended_at;
1623
- const startedDate = parseDateByCampaignTime(startedAtStr);
1624
- const endedDate = parseDateByCampaignTime(endedAtStr);
1625
- if (!startedDate || !endedDate) {
1626
- return false;
1627
- }
1628
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
1629
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1630
- if (nowWithTimezoneMs <= endedDate.getTime() &&
1631
- nowWithTimezoneMs >= startedDate.getTime()) {
1632
- listCampaignScheduledToActivated.push(c);
1633
- return true;
1634
- }
1635
- return false;
1636
- };
1637
- function checkCampaignActiveButExpireAlready(c) {
1638
- var _a;
1639
- /** Do not setup timeframe for this campaign. No need to check */
1640
- if (c.forever === 1) {
1641
- return true;
1642
- }
1643
- const startedAtStr = c.started_at;
1644
- const endedAtStr = c.ended_at;
1645
- const startedDate = parseDateByCampaignTime(startedAtStr);
1646
- const endedDate = parseDateByCampaignTime(endedAtStr);
1647
- /** Do not setup timeframe for this campaign. No need to check */
1648
- if (!startedDate || !endedDate) {
1649
- return true;
1650
- }
1651
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1652
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
1653
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1654
- /** Check if this expire already, do not show */
1655
- if (nowWithTimezoneMs > endedDate.getTime()) {
1656
- listCampaignActiveButExpired.push(c);
1657
- return false;
1658
- }
1659
- return true;
1660
- }
1661
- function shouldNotDisplayIfExcludeAllSponsors(c) {
1662
- var _a;
1663
- const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
1664
- const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
1665
- if (isSponsored && excludeSponsored) {
1666
- listCampaignExcludeSonsored.push(c);
1667
- return true;
1668
- }
1669
- return false;
1670
- }
1671
- function shouldDisplayWithCurrentSponsor(c) {
1672
- var _a, _b;
1673
- try {
1674
- // TODO: BE will rename `exclude_sponsored_list` later
1675
- const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
1676
- const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
1677
- const dataSponsoredId = Number((_b = document
1678
- .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
1679
- // There is no config for sponsor id and white list, should show as default
1680
- if (!dataSponsoredId ||
1681
- dataSponsoredId <= 0 ||
1682
- whiteListSponsors.length === 0) {
1683
- return true;
1684
- }
1685
- // Check the dataSponsoredId exists in the white list or not.
1686
- const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
1687
- if (isExist) {
1688
- return true;
1689
- }
1690
- listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
1691
- return false;
1692
- }
1693
- catch (err) {
1694
- // Default is show
1695
- return true;
1696
- }
1697
- }
1698
- const filterFnCampaign = (c) => {
1699
- if (shouldNotDisplayIfExcludeAllSponsors(c)) {
1700
- return false;
1701
- }
1702
- else if (!shouldDisplayWithCurrentSponsor(c)) {
1703
- return false;
1704
- }
1705
- /** Active */
1706
- if (c.formatted_status === 1) {
1707
- return checkCampaignActiveButExpireAlready(c);
1708
- }
1709
- /** Schedule */
1710
- if (c.formatted_status === 0) {
1711
- listCampaignScheduled.push(c);
1712
- return checkCampaignNowInTimeframe(c);
1713
- }
1714
- return false;
1715
- };
1716
- const fillterApprearanceTimeCampaign = (c) => {
1717
- var _a;
1718
- try {
1719
- const isTimeInRange = (currentTime, startTime, endTime) => {
1720
- const startParts = startTime.split(':');
1721
- const endParts = endTime.split(':');
1722
- const startDate = new Date();
1723
- startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
1724
- const endDate = new Date();
1725
- endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
1726
- return currentTime >= startDate && currentTime <= endDate;
1727
- };
1728
- const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
1729
- const startTime = rulesApprValue.startTime;
1730
- const endTime = rulesApprValue.endTime || '23:59';
1731
- if (!startTime) {
1732
- return true;
1733
- }
1734
- if (isTimeInRange(new Date(), startTime, endTime)) {
1735
- return true;
1736
- }
1737
- listCampaignNotDisplayInRangeOfTime.push(c);
1738
- return false;
1739
- }
1740
- catch (err) {
1741
- return true;
1742
- }
1743
- };
1744
- let timeoutRef = null;
1745
- let LEAD_SCROLL_EVENT = null;
1746
- function clearPassiveEvent() {
1747
- if (timeoutRef) {
1748
- clearTimeout(timeoutRef);
1749
- timeoutRef = null;
1750
- }
1751
- if (LEAD_SCROLL_EVENT) {
1752
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1753
- LEAD_SCROLL_EVENT = null;
1754
- }
1755
- }
1756
- function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
1757
- // clear previous passive event, check for new condition
1758
- clearPassiveEvent();
1759
- const leadCurrentUrl = DEBUG_URL ||
1760
- ('https://' +
1761
- location.hostname +
1762
- location.pathname +
1763
- location.search).toLowerCase();
1764
- fetch(leadApi + 'api/campaign/' + leadSiteId, {
1765
- method: 'POST',
1766
- headers: {
1767
- 'Content-Type': 'application/json',
1768
- },
1769
- body: JSON.stringify({
1770
- url: leadCurrentUrl,
1771
- ga_client_id: miscCookieHelper.getCookie('_ga') || null,
1772
- }),
1773
- })
1774
- .then((response) => {
1775
- return response.json();
1776
- // return mockLeadData || response.json()
1777
- })
1778
- .then((data) => {
1779
- var _a, _b, _c, _d;
1780
- LeadLog('List campagin: ', data);
1781
- LEAD_RESET_VAR();
1782
- if (data._status == 1) {
1783
- 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);
1784
- if (!miscCookieHelper.getCookie('hhg-id')) {
1785
- miscCookieHelper.setCookie('hhg-id', uuid.v1(), {
1786
- domain: '.' + leadDomain,
1787
- path: '/',
1788
- });
1789
- LeadLog('😍 Set HHG ID cookie');
1790
- }
1791
- // getCookie('hhg-id')
1792
- // TODO: HP-534 Filter desktop
1793
- let campaignsDevice = [];
1794
- if (isMobile()) {
1795
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
1796
- }
1797
- else {
1798
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
1799
- }
1800
- LeadLog(`👓 campaignsDevice`, campaignsDevice);
1801
- LeadLog('--listCampaignScheduled', listCampaignScheduled);
1802
- LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
1803
- LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
1804
- LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
1805
- LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
1806
- LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
1807
- // Check links
1808
- let listLinksObj = campaignsDevice
1809
- .map((i, index) => i.targets
1810
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
1811
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1812
- .flat(1);
1813
- // Check list link match current href
1814
- listLinksObj = listLinksObj.filter((i) => {
1815
- var _a;
1816
- const target = new URL(String(i.target).toLowerCase());
1817
- if (i.option == 'exact_match')
1818
- // FOR TEST LOCAL:
1819
- // return Boolean(location.pathname === target.pathname)
1820
- return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
1821
- if (i.option == 'start_with') {
1822
- // FOR TEST LOCAL:
1823
- // if (location.pathname.includes(target.pathname)) {
1824
- if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
1825
- const listExcluding = i.sub_target
1826
- .filter((i) => i.option == 'excluding')
1827
- .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
1828
- return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
1829
- }
1830
- else {
1831
- return false;
1832
- }
1833
- }
1834
- });
1835
- // Check tags
1836
- const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
1837
- const listTags = listMetaTag.map((i) => i.content);
1838
- let listCampaignHasTag = [];
1839
- let listTagsObj = [];
1840
- if (listTags && listTags.length) {
1841
- listCampaignHasTag = campaignsDevice
1842
- .map((i, index) => i.targets
1843
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
1844
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1845
- .flat(1);
1846
- listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
1847
- }
1848
- const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
1849
- const cookieKeys = document.cookie
1850
- .split('; ')
1851
- .map((i) => i.split('=')[0]);
1852
- const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
1853
- LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
1854
- const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
1855
- LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
1856
- const listCampaignSubmitedClosed = [
1857
- ...listCampaignCodeSubmited,
1858
- ...listCampaignCodeClosed,
1859
- ];
1860
- const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
1861
- const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
1862
- return !hasSubmited;
1863
- });
1864
- const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
1865
- // .sort(
1866
- // (a, b) =>
1867
- // (listCampaignValid[a.campaignIndex]?.score || 0) -
1868
- // (listCampaignValid[b.campaignIndex]?.score || 0),
1869
- // )
1870
- LeadLog('--listCampaignValid : ', listCampaignValid);
1871
- if (listCampaignValid && listCampaignValid.length) {
1872
- const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
1873
- LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
1874
- const { rules } = CAMPAIGN_SHOW;
1875
- // CHECK RULE TRIGGER POPUP
1876
- const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
1877
- LeadLog(`timeoutRule`, timeoutRule);
1878
- const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
1879
- LeadLog(`scrollRule`, scrollRule);
1880
- let impressionAction = 'TIME';
1881
- if (Number.isInteger(timeoutRule)) {
1882
- impressionAction = 'TIME';
1883
- LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
1884
- timeoutRef = setTimeout(() => {
1885
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1886
- }, timeoutRule * 1000);
1887
- }
1888
- if (Number.isInteger(scrollRule)) {
1889
- impressionAction = 'SCROLL';
1890
- LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
1891
- const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
1892
- document.querySelector('body');
1893
- const pct = $p.getBoundingClientRect().top;
1894
- const pb = $p.offsetHeight;
1895
- LeadLog(`👓 Element check scroll: `, $p);
1896
- LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
1897
- const wt = window.pageYOffset || document.documentElement.scrollTop;
1898
- let percent = 0;
1899
- if (wt >= pct) {
1900
- percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
1901
- }
1902
- LeadLog('---Scroll', percent, scrollRule);
1903
- // TODO: CHECK FOOTER HEIGHT
1904
- if (percent >= scrollRule) {
1905
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1906
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1907
- }
1908
- };
1909
- window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
1910
- passive: true,
1911
- });
1912
- }
1913
- }
1914
- else {
1915
- LeadLog('🚧 No lead campaigns on current URL, tags');
1916
- }
1917
- }
1918
- })
1919
- .catch((err) => {
1920
- LeadLog(`Lead error: `, err);
1921
- });
1922
- }
1923
- const LeadLog = (...params) => {
1924
- if (process.env.NODE_ENV !== 'production' ||
1925
- (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
1926
- process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
1927
- (typeof localStorage !== 'undefined' &&
1928
- localStorage.getItem('hhg_debug') === 'true')) {
1929
- console.log(...params);
1930
- }
1931
- };
1932
-
1933
- const LeadGenContext = React.createContext({
1934
- submit(value) {
1935
- /** Init for FAKING function */
1936
- LeadLog('** LeadGen Submit : ', value);
1937
- return Promise.reject(value);
1938
- },
1939
- submitSubscriptionBox(value) {
1940
- /** Init for FAKING function */
1941
- LeadLog('** LeadGen SubmitSubscriptionBox : ', value);
1942
- return Promise.reject(value);
1943
- },
1944
- impression(value) {
1945
- /** Init for FAKING function */
1946
- LeadLog('** LeadGen Impression : ', value);
1947
- return Promise.reject(value);
1948
- },
1949
- /** For Subscription Box */
1950
- subscriptionIcon: '',
1951
- subscriptionTitle: '',
1952
- });
1953
- const LeadGenContextProvider = (props) => {
1954
- const { campaign_code: campaignCodeProps, apiSsoUrl, apiLeadUrl, apiSubotUrl, locale: localeProps, forceCampaign: forceCampaignProps, extraValues, articleId = 1, categoryId = 1, siteDomain: site_domain, children, } = props;
1955
- const [forceCampaign, setForceCampaign] = React.useState(forceCampaignProps);
1956
- const [subscriptionInfo, setSubscriptionInfo] = React.useState({
1957
- subscriptionIcon: '',
1958
- subscriptionTitle: '',
1959
- });
1960
- const locale = React.useMemo(() => {
1961
- return localeProps || Locale.LOCALE['PhilippinesEnglish'];
1962
- }, [localeProps]);
1963
- const leadGenContextValue = React.useMemo(() => (Object.assign(Object.assign({}, props), { forceCampaign })), [...Object.values(props), forceCampaign]);
1964
- const { url, campaign_id, campaign_code, cookie_id, ga_client_id, category_id, article_id, article_title, } = React.useMemo(() => ({
1965
- url: location.href.toLowerCase() || '',
1966
- cookie_id: miscCookieHelper.getCookie('hhg-id') || null,
1967
- ga_client_id: miscCookieHelper.getCookie('_ga'),
1968
- campaign_id: forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id,
1969
- campaign_code: campaignCodeProps || (forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.code),
1970
- category_id: categoryId,
1971
- article_id: articleId,
1972
- article_title: document.title || '',
1973
- }), [campaignCodeProps, articleId, categoryId, forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id]);
1974
- const fetchCampaign = React.useCallback((campaign_code) => {
1975
- Service.getCampaignByCode(campaign_code).then((res) => {
1976
- const { _data } = res || {};
1977
- const { campaigns } = _data || {};
1978
- LeadLog('** LeadGen Campaign : ', campaigns);
1979
- setForceCampaign(formatCampaignDetail(campaigns));
1980
- });
1981
- }, [campaignCodeProps]);
1982
- // TODO : Update form for LeadGen
1983
- const submit = React.useCallback((data) => {
1984
- return Service.postSubscriptionBoxLead({ data });
1985
- }, []);
1986
- const submitSubscriptionBox = React.useCallback((value) => {
1987
- const data = Object.assign(Object.assign(Object.assign(Object.assign({}, value), { campaign_id,
1988
- 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,
1989
- category_id, article_title: (extraValues === null || extraValues === void 0 ? void 0 : extraValues.article_title) || article_title });
1990
- return Service.postSubscriptionBoxLead({ data });
1991
- }, [
1992
- extraValues,
1993
- site_domain,
1994
- campaign_id,
1995
- article_id,
1996
- article_title,
1997
- category_id,
1998
- url,
1999
- ga_client_id,
2000
- ]);
2001
- const impression = React.useCallback((value) => {
2002
- return Service.campaignPostImpression({
2003
- url: (value === null || value === void 0 ? void 0 : value.url) || url,
2004
- action: (value === null || value === void 0 ? void 0 : value.action) || LEADGEN_ACTIONS.SCROLL,
2005
- code: (value === null || value === void 0 ? void 0 : value.code) || campaign_code,
2006
- title_article: (value === null || value === void 0 ? void 0 : value.title_article) || article_title,
2007
- cookie_id: (value === null || value === void 0 ? void 0 : value.cookie_id) || cookie_id,
2008
- ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id,
2009
- extra: (value === null || value === void 0 ? void 0 : value.extra) || Object.assign({ cookie_id,
2010
- article_id, subscription_title: subscriptionInfo.subscriptionTitle }, extraValues),
2011
- referrer: value === null || value === void 0 ? void 0 : value.referrer,
2012
- });
2013
- }, [
2014
- extraValues,
2015
- campaign_id,
2016
- url,
2017
- campaign_code,
2018
- article_title,
2019
- cookie_id,
2020
- ga_client_id,
2021
- article_id,
2022
- subscriptionInfo.subscriptionTitle,
2023
- ]);
2024
- React.useEffect(() => {
2025
- if (forceCampaignProps) {
2026
- setForceCampaign(forceCampaignProps);
2027
- return;
2028
- }
2029
- /** For Subscription Box */
2030
- if (categoryId) {
2031
- Service.getSubscriptionBoxInfo({
2032
- category: categoryId,
2033
- site: site_domain,
2034
- }).then((res) => {
2035
- const { _data } = res || {};
2036
- const { item, campaign_code } = _data || {};
2037
- const { icon, content } = item;
2038
- LeadLog('** LeadGen SubscriptionBox campaign_code : ', campaign_code);
2039
- LeadLog('** LeadGen SubscriptionBox subscription_icon : ', icon);
2040
- LeadLog('** LeadGen SubscriptionBox subscription_title : ', content);
2041
- if (icon && content) {
2042
- setSubscriptionInfo({
2043
- subscriptionIcon: icon,
2044
- subscriptionTitle: content,
2045
- });
2046
- }
2047
- fetchCampaign(campaign_code);
2048
- });
2049
- return;
2050
- }
2051
- if (campaignCodeProps) {
2052
- fetchCampaign(campaignCodeProps);
2053
- }
2054
- }, [campaignCodeProps, categoryId]);
2055
- React.useEffect(() => {
2056
- leadStore.apiSsoUrl = apiSsoUrl;
2057
- leadStore.apiLeadUrl = apiLeadUrl;
2058
- leadStore.apiSubotUrl = apiSubotUrl;
2059
- }, [apiLeadUrl, apiSubotUrl, apiSsoUrl]);
2060
- if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
2061
- return null;
2062
- }
2063
- return (React__default["default"].createElement(LeadGenContext.Provider, { value: Object.assign(Object.assign(Object.assign({}, leadGenContextValue), subscriptionInfo), { submit,
2064
- submitSubscriptionBox,
2065
- impression }) },
2066
- React__default["default"].createElement(LeadGenTranslationProvider, { locale: locale }, children)));
2067
- };
2068
- const useLeadGenContext = () => {
2069
- const context = React.useContext(LeadGenContext);
2070
- return Object.assign(Object.assign({}, context), { apiLeadUrl: context.apiLeadUrl || leadStore.apiLeadUrl, apiSubotUrl: context.apiSubotUrl || leadStore.apiSubotUrl });
2071
- };
2072
-
2073
- // eslint-disable-next-line @typescript-eslint/no-var-requires
2074
- const customParseFormat = require('dayjs/plugin/customParseFormat');
2075
- dayjs__default["default"].extend(customParseFormat);
2076
- // You can give context variables any name
2077
- const [LeadFormProvider, useLeadFormContext, useLeadForm] = form.createFormContext();
2078
- const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
2079
- var _a;
2080
- const { t } = index.useTranslations();
2081
- const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
2082
- const LEAD_LOCALE = LEAD_LOCALE_DATA[(_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.lang] ||
2083
- LEAD_LOCALE_DATA['vi-VN'];
2084
- const validateObj = React.useMemo(() => {
2085
- const InputBlocks = [
2086
- 'TextBlock',
2087
- 'NumberBlock',
2088
- 'EmailBlock',
2089
- 'PhoneBlock',
2090
- 'DateBlock',
2091
- 'CheckboxBlock',
2092
- 'RadioBlock',
2093
- 'DropdownBlock',
2094
- 'PhoneOtpBlock',
2095
- 'WhatsappOtpBlock',
2096
- 'ZaloOtpBlock',
2097
- 'LocationBlock',
2098
- 'TncBlock',
2099
- ];
2100
- // ALL are required and can skip if not touched yet
2101
- const withSharedCheck = (name, cb,
2102
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2103
- block) => {
2104
- return (value) => {
2105
- var _a;
2106
- const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
2107
- if (!formRef.current.isTouched(name))
2108
- return;
2109
- if ((typeof value === 'string' && value.trim() === '') ||
2110
- typeof value === 'undefined' ||
2111
- (Array.isArray(value) && value.length === 0)) {
2112
- return isBLockRequired
2113
- ? t('validator.required')
2114
- : cb === null || cb === void 0 ? void 0 : cb(value);
2115
- }
2116
- return cb === null || cb === void 0 ? void 0 : cb(value);
2117
- };
2118
- };
2119
- return listBlockAdded
2120
- .filter((b) => InputBlocks.includes(b.name))
2121
- .reduce((r, b) => {
2122
- const { name: fieldType, data } = b || {};
2123
- const { value: fieldName, required } = data || {};
2124
- const isRequired = required !== null && required !== void 0 ? required : true;
2125
- if (fieldType === 'NumberBlock') {
2126
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2127
- if (value && isNaN(Number(value))) {
2128
- return t('validator.number');
2129
- }
2130
- }, b) });
2131
- }
2132
- else if (fieldType === 'EmailBlock') {
2133
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2134
- if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
2135
- return t('validator.email');
2136
- }
2137
- if (!value)
2138
- return;
2139
- validatingEmailRef.current = true;
2140
- setTimeout(() => {
2141
- formRef.current.setFieldError(fieldName, 'Validating...');
2142
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2143
- email: value,
2144
- })
2145
- .then((tKey) => {
2146
- if (tKey) {
2147
- formRef.current.setFieldError(fieldName, t(tKey));
2148
- }
2149
- else {
2150
- formRef.current.clearFieldError(fieldName);
2151
- }
2152
- validatingEmailRef.current = false;
2153
- })
2154
- .catch((e) => {
2155
- console.error(e);
2156
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2157
- validatingEmailRef.current = false;
2158
- });
2159
- }, 200);
2160
- }, b) });
2161
- }
2162
- else if (fieldType === 'PhoneBlock' ||
2163
- fieldType === 'PhoneOtpBlock' ||
2164
- fieldType === 'ZaloOtpBlock' ||
2165
- fieldType === 'WhatsappOtpBlock') {
2166
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2167
- if (value &&
2168
- window.intlTelInputUtils &&
2169
- !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
2170
- return t('validator.phone');
2171
- }
2172
- if (!value)
2173
- return;
2174
- validatingPhoneRef.current = true;
2175
- setTimeout(() => {
2176
- formRef.current.setFieldError(fieldName, 'Validating...');
2177
- if (b.data.singleSubmission) {
2178
- checkUsedPhoneOnlyWithCache(campaignId, value)
2179
- .then((tKey) => {
2180
- if (tKey) {
2181
- formRef.current.setFieldError(fieldName, t(tKey));
2182
- }
2183
- else {
2184
- formRef.current.clearFieldError(fieldName);
2185
- }
2186
- validatingPhoneRef.current = false;
2187
- })
2188
- .catch((err) => {
2189
- console.error(err);
2190
- formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
2191
- validatingPhoneRef.current = false;
2192
- });
2193
- }
2194
- else {
2195
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2196
- phone: value,
2197
- })
2198
- .then((tKey) => {
2199
- if (tKey) {
2200
- formRef.current.setFieldError(fieldName, t(tKey));
2201
- }
2202
- else {
2203
- formRef.current.clearFieldError(fieldName);
2204
- }
2205
- validatingPhoneRef.current = false;
2206
- })
2207
- .catch((e) => {
2208
- console.error(e);
2209
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2210
- validatingPhoneRef.current = false;
2211
- });
2212
- }
2213
- }, 200);
2214
- }, b) });
2215
- }
2216
- else if (fieldType === 'DateBlock') {
2217
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2218
- if (!isRequired && !value) {
2219
- return;
2220
- }
2221
- const errMsg = t('validator.dateInvalid');
2222
- const dayInJS = typeof value === 'string'
2223
- ? dayjs__default["default"](value, format, true)
2224
- : dayjs__default["default"](value);
2225
- if (!dayInJS.isValid()) {
2226
- return errMsg;
2227
- }
2228
- }, b) });
2229
- }
2230
- else if (fieldType === 'TncBlock') {
2231
- return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
2232
- if (isRequired && !value) {
2233
- return t('validator.required');
2234
- }
2235
- }, b) });
2236
- }
2237
- else {
2238
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
2239
- }
2240
- }, {});
2241
- }, [listBlockAdded.map((b) => b.name).join(','), format]);
2242
- const form = useLeadForm({
2243
- validateInputOnChange: true,
2244
- validateInputOnBlur: true,
2245
- clearInputErrorOnChange: true,
2246
- validate: validateObj,
2247
- initialValues,
2248
- });
2249
- const formRef = React.useRef(form);
2250
- formRef.current = form;
2251
- return { form, validateObj };
2252
- };
2253
-
2254
- const StyledLeadGenThankYou = styled__default["default"].div `
2255
- display: flex;
2256
- gap: 8px;
2257
- flex-direction: column;
2258
- padding-block: 24px;
2259
-
2260
- .leadgen-image {
2261
- width: 120px;
2262
- height: 120px;
2263
- margin-inline: auto;
2264
- object-fit: contain;
2265
- object-position: center;
2266
- text-align: center;
2267
- }
2268
-
2269
- .leadgen-title {
2270
- margin-block: 0;
2271
- color: ${miscTheme.theme.colors.gray900};
2272
- font-weight: 700;
2273
- font-size: 18px;
2274
- line-height: 28px;
2275
- letter-spacing: -0.2px;
2276
- }
2277
-
2278
- .leadgen-description {
2279
- margin-block: 0;
2280
- color: ${miscTheme.theme.colors.gray600};
2281
- font-weight: 400;
2282
- font-size: 14px;
2283
- line-height: 22px;
2284
- letter-spacing: -0.2px;
2285
- text-align: center;
2286
- }
2287
-
2288
- > [data-align] {
2289
- &[data-align='right'] {
2290
- text-align: right;
2291
- }
2292
- &[data-align='center'] {
2293
- text-align: center;
2294
- }
2295
- }
2296
- `;
2297
- const LeadGenThankYou = ({ image, title, description, showButton = false, button, className, style, }) => {
2298
- const { src } = image;
2299
- const { htmlText: titleText, align: titleAlign } = title;
2300
- const { htmlText: descriptionText, align: descriptionAlign } = description;
2301
- const { htmlText: buttonText, newtab, url, onClick } = button;
2302
- return (React__default["default"].createElement(StyledLeadGenThankYou, { className: className, style: style },
2303
- React__default["default"].createElement("img", { src: src, alt: "", className: "leadgen-thankyou_image leadgen-image" }),
2304
- React__default["default"].createElement("p", { className: "leadgen-thankyou_title leadgen-title", "data-align": titleAlign }, titleText),
2305
- React__default["default"].createElement("p", { className: "leadgen-thankyou_description leadgen-description", "data-align": descriptionAlign }, descriptionText),
2306
- !!buttonText && showButton && (React__default["default"].createElement(core.Button, { component: url ? 'a' : 'button', target: newtab ? '_blank' : undefined, href: url, size: "lg", variant: "filled", className: "leadgen-thankyoue_btn leadgen-btn", onClick: onClick }, buttonText))));
2307
- };
2308
-
2309
- const StyledLeadGenSubscriptionBoxBody = styled__default["default"].div `
2310
- margin-top: 16px;
2311
- .leadgen-btn {
2312
- margin-top: 16px;
2313
- }
2314
- `;
2315
- const StyledLeadGenSubscriptionBoxHeaderImage = styled__default["default"].div `
2316
- margin-top: 3px;
2317
- margin-right: 20px;
2318
- width: 44px;
2319
- height: 44px;
2320
-
2321
- img {
2322
- width: 100%;
2323
- height: 100%;
2324
- object-fix: contain;
2325
- onject-position: center;
2326
- }
2327
-
2328
- :has(img[src='']) {
2329
- display: none;
2330
- }
2331
- `;
2332
- const StyledLeadGenSubscriptionBoxHeader = styled__default["default"].div `
2333
- display: flex;
2334
- align-items: center;
2335
- margin-bottom: 16px;
2336
- .leadgen-title {
2337
- margin-bottom: 0;
2338
- flex: 1;
2339
- min-width: 0;
2340
- color: ${miscTheme.theme.colors.gray900};
2341
- font-size: 18px;
2342
- font-weight: 400;
2343
- line-height: 1.4;
2344
- letter-spacing: -0.8px;
2345
- }
2346
- `;
2347
- const StyledLeadGenSubscriptionBox = styled__default["default"].div `
2348
- padding: 16px;
2349
- border: 1px solid ${miscTheme.theme.colors.neutral100};
2350
- border-radius: 12px;
2351
- margin-inline: auto;
2352
- .leadgen-form_inputs {
2353
- .leadgen-form_input {
2354
- width: 100%;
2355
- }
2356
- }
2357
-
2358
- .leadgen-form_input {
2359
- .mantine-Input-wrapper {
2360
- max-height: 56px;
2361
- }
2362
- }
2363
-
2364
- @media screen and (min-width: 768px) {
2365
- .leadgen-subscription_box_body {
2366
- display: flex;
2367
- > form {
2368
- flex: 1;
2369
- min-width: 0;
2370
-
2371
- .leadgen-form_inputs {
2372
- .leadgen-form_input {
2373
- width: calc(50% - 4px);
2374
- }
2375
- }
2376
- }
2377
-
2378
- .leadgen-btn {
2379
- margin-top: 0;
2380
- margin-left: 8px;
2381
- width: auto;
2382
- min-height: 56px;
2383
- }
2384
- }
2385
- }
2386
- `;
2387
- const StyledLeadGenSubscriptionBoxA = styled__default["default"].div `
2388
- .leadgen-form_input {
2389
- --phone-select: 45px;
2390
- .PhoneInput {
2391
- --phone-select: 45px;
2392
- .PhoneInputCountry {
2393
- margin-top: 1px;
2394
- pointer-events: none;
2395
- .PhoneInputCountryIconImg,
2396
- .PhoneInputArrowContainer {
2397
- display: none;
2398
- }
2399
- }
2400
- }
2401
- }
2402
- `;
2403
-
2404
- const PhoneInput = React.forwardRef((props, ref) => {
2405
- const { defaultCountry, id: idProps, name, placeholder, label, labelElement, labelProps, description, descriptionProps, withAsterisk, inputMode, inputContainer, inputWrapperOrder, error, className, classNames, style, styles } = props, restProps = tslib_es6.__rest(props, ["defaultCountry", "id", "name", "placeholder", "label", "labelElement", "labelProps", "description", "descriptionProps", "withAsterisk", "inputMode", "inputContainer", "inputWrapperOrder", "error", "className", "classNames", "style", "styles"]);
2406
- const id = idProps || uuid.v1() + name;
2407
- return (React__default["default"].createElement(core.Input.Wrapper, { size: "md", label: label, labelElement: labelElement, labelProps: Object.assign({ htmlFor: id }, labelProps), description: description, descriptionProps: descriptionProps, withAsterisk: withAsterisk, inputMode: inputMode, inputContainer: inputContainer, inputWrapperOrder: inputWrapperOrder, error: error, "data-invalid": !!error, className: className, classNames: classNames, style: style, styles: styles },
2408
- React__default["default"].createElement("div", { className: "mantine-Input-wrapper" },
2409
- React__default["default"].createElement(index$2.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" })))));
2410
- });
2411
-
2412
- const formatLeadGenFormValue = (values, blocks) => {
2413
- const newValues = {};
2414
- for (const block of blocks) {
2415
- const { data } = block || {};
2416
- const { value: fieldName } = data || {};
2417
- if (fieldName in values) {
2418
- newValues[fieldName] = values[fieldName];
2419
- }
2420
- }
2421
- return newValues;
2422
- };
2423
-
2424
- const StyledLeadGenFormInner = styled__default["default"].div `
2425
- display: flex;
2426
- flex-wrap: wrap;
2427
- gap: 8px;
2428
- .leadgen-form_input {
2429
- width: calc(50% - 4px);
2430
- }
2431
-
2432
- .leadgen-form_input_checkbox {
2433
- width: 100%;
2434
- }
2435
- `;
2436
-
2437
- const cssInputNotShrink$1 = react.css `
2438
- height: 100% !important;
2439
- min-height: calc(var(--container-height, 56px) * 22 / 56);
2440
- color: ${miscTheme.theme.colors.gray800};
2441
- font-size: var(--input, 16px);
2442
- line-height: calc(var(--container-height, 56px) * 22 / 56);
2443
- border: none !important;
2444
- border-radius: 0 !important;
2445
- outline: none !important;
2446
- box-shadow: none !important;
2447
- padding: 0;
2448
- cursor: pointer;
2449
- opacity: 0;
2450
-
2451
- ::placeholder {
2452
- color: ${miscTheme.theme.colors.gray400};
2453
- }
2454
- `;
2455
- const cssInputShrink$1 = react.css `
2456
- height: auto !important;
2457
- cursor: text;
2458
- opacity: 1;
2459
- transition: 0.1s ease-in-out all;
2460
- `;
2461
- const cssLabelNotShrink$1 = react.css `
2462
- position: absolute;
2463
- top: calc(var(--container-height) / 2);
2464
- left: var(--space-x, 16px);
2465
- color: ${miscTheme.theme.colors.gray400};
2466
- font-size: var(--label-not-shrink, 16px);
2467
- font-weight: 400;
2468
- line-height: calc(var(--container-height, 56px) * 18 / 56);
2469
- margin: 0;
2470
- z-index: 1;
2471
- cursor: pointer;
2472
- transform: translateY(-50%);
2473
- transition: 0.125s ease-in all;
2474
- `;
2475
- const cssLabelShrink$1 = react.css `
2476
- color: ${miscTheme.theme.colors.gray600};
2477
- font-weight: 600;
2478
- font-size: var(--label-shrink, 12px);
2479
- top: calc(var(--container-height) * 7 / 56);
2480
- transform: none;
2481
- transition: 0.125s ease-out all;
2482
- `;
2483
- const cssWrapperInputNotShrink$1 = react.css `
2484
- min-height: var(--container-height, 56px);
2485
- display: flex;
2486
- align-items: flex-end;
2487
- border: 1px solid ${miscTheme.theme.colors.gray200};
2488
- border-radius: 8px;
2489
- background-color: #fff;
2490
- padding-inline: var(--space-x, 16px);
2491
- padding-block: var(--space-y-not-shrink, 16px);
2492
- cursor: pointer;
2493
- pointer-events: none;
2494
-
2495
- &:has(.mantine-Input-rightSection) {
2496
- padding-right: var(--container-height, 56px);
2497
- }
2498
-
2499
- .mantine-Input-icon {
2500
- display: none;
2501
- }
2502
-
2503
- .mantine-NumberInput-control {
2504
- border-color: ${miscTheme.theme.colors.gray200};
2505
- }
2506
- `;
2507
- const cssWrapperInputShrink$1 = react.css `
2508
- height: auto;
2509
- min-height: var(--container-height, 56px);
2510
- padding-block: var(--space-y-shrink, 7px);
2511
- cursor: text;
2512
- pointer-events: auto;
2513
- `;
2514
- const cssInputWrapperError$1 = react.css `
2515
- color: ${miscTheme.theme.colors.red800};
2516
- font-size: 12px;
2517
- line-height: 1.5;
2518
- `;
2519
- const StyledTextFieldContainer$1 = styled__default["default"].div `
2520
- --space-x: 16px;
2521
- --space-y-not-shrink: 16px;
2522
- --space-y-shrink: 7px;
2523
- --container-height: 56px;
2524
- --label-not-shrink: 16px;
2525
- --label-shrink: 12px;
2526
- --input: 16px;
2527
-
2528
- position: relative;
2529
- min-width: 100px;
2530
- max-width: 100%;
2531
- display: inline-block;
2532
-
2533
- .textField_wrapper {
2534
- display: inline-block;
2535
- width: 100%;
2536
- cursor: pointer;
2537
- }
2538
-
2539
- .mantine-InputWrapper-root {
2540
- &[data-invalid='true'] {
2541
- .mantine-Input-wrapper {
2542
- border-color: ${miscTheme.theme.colors.red400};
2543
- }
2544
- }
2545
-
2546
- .mantine-Input-wrapper {
2547
- &:has([data-invalid]) {
2548
- border-color: ${miscTheme.theme.colors.red400};
2549
- }
2550
- }
2551
-
2552
- .mantine-InputWrapper-error {
2553
- font-size: 12px !important;
2554
- }
2555
- }
2556
-
2557
- .mantine-InputWrapper-label {
2558
- ${cssLabelNotShrink$1}
2559
- }
2560
-
2561
- .mantine-Input-wrapper {
2562
- ${cssWrapperInputNotShrink$1}
2563
-
2564
- + .mantine-Popover-dropdown[data-position="bottom-start"] {
2565
- left: 0 !important;
2566
- }
2567
- + .mantine-Popover-dropdown[data-position='top-start'] {
2568
- top: unset !important;
2569
- left: 0 !important;
2570
- bottom: 100% !important;
2571
- }
2572
- }
2573
-
2574
- .mantine-Input-input {
2575
- ${cssInputNotShrink$1}
2576
- }
2577
-
2578
- &.textField_shrink,
2579
- &:focus-within {
2580
- .mantine-InputWrapper-label {
2581
- ${cssLabelShrink$1}
2582
- }
2583
-
2584
- .mantine-Input-wrapper {
2585
- ${cssWrapperInputShrink$1}
2586
- &.mantine-Select-wrapper {
2587
- .mantine-Select-rightSection {
2588
- pointer-events: auto !important;
2589
- }
2590
- }
2591
- }
2592
-
2593
- .mantine-Input-input {
2594
- ${cssInputShrink$1}
2595
- }
2596
-
2597
- &:has(.PhoneInput) {
2598
- .mantine-InputWrapper-label {
2599
- left: var(--space-x, 16px);
2600
- }
2601
- .PhoneInput {
2602
- .PhoneInputInput {
2603
- opacity: 1;
2604
- }
2605
- }
2606
- }
2607
- }
2608
-
2609
- .PhoneInput {
2610
- --phone-select: 75px;
2611
- --phone-input-space-x: 8px;
2612
- width: 100%;
2613
- opacity: 1;
2614
- border: none;
2615
- .PhoneInputCountry {
2616
- background-color: transparent;
2617
- border: none;
2618
- padding: 0;
2619
- width: var(--phone-select, 75px);
2620
- }
2621
- .PhoneInputInput {
2622
- flex: 1;
2623
- min-width: 0;
2624
- line-height: 1.5;
2625
- outline: none !important;
2626
- border: none;
2627
- box-shadow: none;
2628
- padding: 0 var(--phone-input-space-x, 8px);
2629
- opacity: 0;
2630
- color: ${miscTheme.theme.colors.gray800} !important;
2631
- :focus {
2632
- color: ${miscTheme.theme.colors.gray800} !important;
2633
- }
2634
- }
2635
- }
2636
-
2637
- &:has(.PhoneInput) {
2638
- .mantine-InputWrapper-label {
2639
- left: calc(
2640
- var(--space-x, 16px) + var(--phone-select, 75px) +
2641
- var(--phone-input-space-x, 8px)
2642
- );
2643
- }
2644
- }
2645
- `;
2646
- const StyledChoiceFieldContainer$1 = styled__default["default"].div `
2647
- &.leadgen-form_checkbox,
2648
- &.leadgen-form_radio {
2649
- width: 100%;
2650
- }
2651
-
2652
- &.leadgen-form_dropdown {
2653
- width: calc(50% - 12px);
2654
- }
2655
-
2656
- .mantine-InputWrapper-root {
2657
- display: block;
2658
- .mantine-InputWrapper-error {
2659
- font-size: 12px !important;
2660
- }
2661
- }
2662
-
2663
- .mantine-InputWrapper-label {
2664
- margin-bottom: 0.5rem;
2665
- color: ${miscTheme.theme.colors.gray800};
2666
- font-size: 16px;
2667
- font-weight: 400;
2668
- line-height: 1.5;
2669
- }
2670
-
2671
- .mantine-Radio-root,
2672
- .mantine-Checkbox-root {
2673
- gap: 8px;
2674
- min-width: calc(50% - 4px);
2675
-
2676
- input[type='radio'],
2677
- input[type='checkbox'] {
2678
- border-color: ${miscTheme.theme.colors.gray600};
2679
- width: 18px;
2680
- height: 18px;
2681
- }
2682
- input[type='checkbox'] {
2683
- border-radius: 4px;
2684
- }
2685
-
2686
- &[data-checked='true'] {
2687
- input[type='radio'],
2688
- input[type='checkbox'] {
2689
- border-color: ${miscTheme.theme.colors.primary600};
2690
- + svg {
2691
- color: ${miscTheme.theme.colors.primary600};
2692
- }
2693
- }
2694
-
2695
- input[type='radio'] {
2696
- background-color: white;
2697
- }
2698
- }
2699
-
2700
- .mantine-Checkbox-input {
2701
- &:checked {
2702
- border-color: ${miscTheme.theme.colors.primary600};
2703
- }
2704
- }
2705
- }
2706
-
2707
- .mantine-Radio-inner,
2708
- .mantine-Checkbox-inner {
2709
- width: 24px;
2710
- height: 24px;
2711
- display: flex;
2712
- align-items: center;
2713
- justify-content: center;
2714
- }
2715
-
2716
- .mantine-Radio-body,
2717
- .mantine-Checkbox-body {
2718
- display: flex;
2719
- align-items: center;
2720
- }
2721
-
2722
- .mantine-Radio-label,
2723
- .mantine-Checkbox-label {
2724
- padding-left: 8px;
2725
- color: ${miscTheme.theme.colors.gray800};
2726
- font-size: 14px;
2727
- line-height: 1.4;
2728
- letter-spacing: -0.2px;
2729
- }
2730
-
2731
- .leadgen-choiceContainer {
2732
- display: flex;
2733
- flex-wrap: wrap;
2734
- align-items: flex-start;
2735
- gap: 8px;
2736
- }
2737
-
2738
- .mantine-InputWrapper-error {
2739
- ${cssInputWrapperError$1}
2740
- }
2741
- `;
2742
-
2743
- const TextField$1 = (props) => {
2744
- const { shrink: shrinkProps, onChangeShrink, className, children } = props, restProps = tslib_es6.__rest(props, ["shrink", "onChangeShrink", "className", "children"]);
2745
- const containerRef = hooks.useClickOutside(() => {
2746
- if (shrinkProps) {
2747
- return;
2748
- }
2749
- setShrink(false);
2750
- onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(false);
2751
- });
2752
- const [shrink, setShrink] = React.useState(shrinkProps);
2753
- const onClick = React.useCallback((e) => {
2754
- setShrink(true);
2755
- onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(true);
2756
- if (shrink) {
2757
- return;
2758
- }
2759
- const $textEl = e.currentTarget.querySelectorAll('input:not([disabled]):not([type="submit"]),select:not([disabled]),textarea:not([disabled])');
2760
- const $focusEl = $textEl.item($textEl.length - 1);
2761
- if ($focusEl) {
2762
- $focusEl.focus();
2763
- setTimeout(() => {
2764
- $focusEl.scrollIntoView({
2765
- behavior: 'auto',
2766
- block: 'center',
2767
- inline: 'start',
2768
- });
2769
- }, 100);
2770
- }
2771
- }, [shrink]);
2772
- React.useEffect(() => {
2773
- setShrink(shrinkProps);
2774
- }, [shrinkProps]);
2775
- return (React__default["default"].createElement(StyledTextFieldContainer$1, Object.assign({ shrink: shrink, className: core.clsx(className, 'textField', { textField_shrink: !!shrink }) }, restProps),
2776
- React__default["default"].createElement("div", { ref: containerRef, onClick: onClick, className: "textField_wrapper" }, children)));
2777
- };
2778
- const ChoiceField$1 = (props) => {
2779
- const { children, className } = props, restProps = tslib_es6.__rest(props, ["children", "className"]);
2780
- return (React__default["default"].createElement(StyledChoiceFieldContainer$1, Object.assign({ className: core.clsx(className, 'choiceField') }, restProps), children));
2781
- };
2782
-
2783
- const libraries = ['places'];
2784
- const GoogleLocationBlock = (props) => {
2785
- var _a;
2786
- const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = tslib_es6.__rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
2787
- const [LoadScript, setLoadScript] = React.useState(null);
2788
- const [value, setValue] = React.useState(defaultValue || valueProps);
2789
- const { predictions } = usePlacesAutocomplete.usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
2790
- const onChangeAutocomplete = React.useCallback((s) => {
2791
- setValue(s);
2792
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
2793
- }, []);
2794
- const onClickItem = React.useCallback((item) => {
2795
- /** For sure get value */
2796
- setValue(item.value);
2797
- const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
2798
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
2799
- }, [onChangeProps, predictions]);
2800
- React.useEffect(() => {
2801
- setValue(valueProps);
2802
- }, [valueProps]);
2803
- React.useEffect(() => {
2804
- var _a, _b, _c;
2805
- // only load extra google script when not yet loaded
2806
- 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) {
2807
- Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@react-google-maps/api')); }).then((m) => {
2808
- setLoadScript(() => m.LoadScript);
2809
- });
2810
- }
2811
- }, []);
2812
- return (React__default["default"].createElement(core.Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
2813
- return { value: pred.description, label: pred.description };
2814
- }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: index$7.ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
2815
- return (React__default["default"].createElement(React__default["default"].Fragment, null,
2816
- LoadScript && (React__default["default"].createElement(LoadScript, { googleMapsApiKey: usePlacesAutocomplete.GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default["default"].createElement(React__default["default"].Fragment, null), style: { width: '100%' } })),
2817
- children));
2818
- } }, restProps)));
2819
- };
2820
-
2821
- const LeadGenForm = React.forwardRef((props, ref) => {
2822
- const { locale, blocks, scrollToErrorField = true, form: formProps, rules: validate, initialValues, onFinish, onFinishFailed, className, style, } = props;
2823
- const formRef = React.useRef(null);
2824
- const form$1 = formProps || form.useForm({ initialValues, validate });
2825
- const middlewareFinish = React.useCallback((values, event) => {
2826
- /** Set `touched` all values for validation when submiting */
2827
- form$1.setTouched(blocks.reduce((touched, { data }) => {
2828
- touched[data.value] = true;
2829
- return touched;
2830
- }, {}));
2831
- /** Wait for `touched` state and then submit */
2832
- setTimeout(() => {
2833
- const { hasErrors } = form$1.validate();
2834
- if (hasErrors) {
2835
- return;
2836
- }
2837
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatLeadGenFormValue(values, blocks), event);
2838
- }, 100);
2839
- }, [form$1, blocks]);
2840
- const middlewareFinishFailed = React.useCallback((errors, values, events) => {
2841
- if (scrollToErrorField && errors) {
2842
- const firstErrorKey = Object.keys(errors)[0];
2843
- const firstErrorElement = document.querySelector(`[name="${firstErrorKey}"]`);
2844
- if (firstErrorElement && (firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus)) {
2845
- setTimeout(() => {
2846
- firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
2847
- firstErrorElement.scrollIntoView({
2848
- behavior: 'auto',
2849
- block: 'center',
2850
- inline: 'center',
2851
- });
2852
- }, 100);
2853
- }
2854
- }
2855
- onFinishFailed === null || onFinishFailed === void 0 ? void 0 : onFinishFailed(errors, values, events);
2856
- }, [scrollToErrorField]);
2857
- React.useEffect(() => {
2858
- (() => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
2859
- if (!window.intlTelInputUtils) {
2860
- yield require('intl-tel-input/build/js/utils');
2861
- }
2862
- }))();
2863
- }, []);
2864
- React.useImperativeHandle(ref, () => (Object.assign(Object.assign({}, form$1), { submit: () => {
2865
- formRef.current.requestSubmit();
2866
- } })), [form$1, formRef]);
2867
- if (!blocks || !blocks.length) {
2868
- return null;
2869
- }
2870
- return (React__default["default"].createElement("form", { ref: formRef, onSubmit: form$1.onSubmit(middlewareFinish, middlewareFinishFailed), className: className, style: style },
2871
- React__default["default"].createElement(StyledLeadGenFormInner, { className: "leadgen-form_inputs" }, blocks.map((block, idx) => {
2872
- const { id, name: blockName, data } = block;
2873
- const { placeholder, value: name, required, listQuestion, valueHTML, isSendMailChimp = false, } = data;
2874
- const formInputProps = form$1.getInputProps(name);
2875
- const { value, error } = formInputProps;
2876
- const reactKey = `${id}-${idx}`;
2877
- switch (blockName) {
2878
- case LEADGEN_BLOCK.TextBlock: {
2879
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2880
- React__default["default"].createElement(core.TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "text", "data-control": "text" }, formInputProps))));
2881
- }
2882
- case LEADGEN_BLOCK.NumberBlock: {
2883
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2884
- React__default["default"].createElement(core.NumberInput, Object.assign({ name: value, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "number", "data-control": "number" }, formInputProps))));
2885
- }
2886
- case LEADGEN_BLOCK.EmailBlock: {
2887
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2888
- React__default["default"].createElement(core.TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, "data-control": "email" }, formInputProps))));
2889
- }
2890
- case LEADGEN_BLOCK.PhoneOtpBlock:
2891
- case LEADGEN_BLOCK.WhatsappOtpBlock:
2892
- case LEADGEN_BLOCK.ZaloOtpBlock:
2893
- case LEADGEN_BLOCK.PhoneBlock: {
2894
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2895
- React__default["default"].createElement(PhoneInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, defaultCountry: (locale ? utils.MAPPED_LOCALE[locale] || 'VN' : 'VN'), type: "text", "data-control": "text" }, formInputProps))));
2896
- }
2897
- case LEADGEN_BLOCK.LocationBlock: {
2898
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2899
- React__default["default"].createElement(GoogleLocationBlock, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, locale: locale, "data-control": "text" }, formInputProps))));
2900
- }
2901
- case LEADGEN_BLOCK.DateBlock: {
2902
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2903
- React__default["default"].createElement(dates.DateInput, Object.assign({ locale: (utils.MAPPED_LOCALE === null || utils.MAPPED_LOCALE === void 0 ? void 0 : utils.MAPPED_LOCALE[locale]) || utils.MAPPED_LOCALE['vi-VN'], valueFormat: "DD/MM/YYYY", name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "default", "data-control": "date" }, formInputProps))));
2904
- }
2905
- case LEADGEN_BLOCK.DropdownBlock:
2906
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2907
- React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2908
- React__default["default"].createElement(core.Select, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, data: listQuestion.map((l) => ({
2909
- value: l.value,
2910
- label: l.placeholder,
2911
- })) }, formInputProps))));
2912
- case LEADGEN_BLOCK.CheckboxBlock: {
2913
- const formInputCheckboxProps = form$1.getInputProps(name, {
2914
- type: 'checkbox',
2915
- });
2916
- return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2917
- isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2918
- React__default["default"].createElement(core.Checkbox.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, sx: {
2919
- display: 'flex',
2920
- flexDirection: 'column',
2921
- flexWrap: 'wrap',
2922
- gap: 8,
2923
- }, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2924
- return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2925
- } }, formInputCheckboxProps), listQuestion.map((l, _idx) => (React__default["default"].createElement(core.Checkbox, { name: name, key: _idx, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2926
- }
2927
- case LEADGEN_BLOCK.RadioBlock: {
2928
- return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2929
- isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2930
- React__default["default"].createElement(core.Radio.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, spellCheck: true, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2931
- return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2932
- } }, formInputProps), listQuestion.map((l, _index) => (React__default["default"].createElement(core.Radio, { name: name, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2933
- }
2934
- case LEADGEN_BLOCK.TncBlock:
2935
- return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2936
- React__default["default"].createElement(core.Input.Wrapper, { error: error },
2937
- React__default["default"].createElement(core.Checkbox, Object.assign({ value: value, name: 'TNC-' + id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, formInputProps)))));
2938
- default: {
2939
- return null;
2940
- }
2941
- }
2942
- }))));
2943
- });
2944
-
2945
- const LEADGEN_ORDER_INPUT_WRAPPER = ['label', 'input', 'description', 'error'];
2946
-
2947
- const LeadGenSubscriptionBoxA = (props) => {
2948
- const { loading, image, title, submitText, locale, blocks, form, rules, onFinish, } = props;
2949
- const formRef = React.useRef();
2950
- const imageComp = React.useMemo(() => {
2951
- if (!image) {
2952
- return null;
2953
- }
2954
- return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeaderImage, null,
2955
- React__default["default"].createElement("img", { src: image, alt: "" })));
2956
- }, [image]);
2957
- const titleComp = React.useMemo(() => {
2958
- if (typeof title === 'string') {
2959
- return (React__default["default"].createElement("p", { className: "leadgen-title", dangerouslySetInnerHTML: { __html: title } }));
2960
- }
2961
- return React__default["default"].createElement("p", { className: "leadgen-title" }, title);
2962
- }, [title]);
2963
- return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxA, { className: "subcription_box_A" },
2964
- React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeader, { className: "leadgen-subscription_box_header" },
2965
- imageComp,
2966
- titleComp),
2967
- React__default["default"].createElement(StyledLeadGenSubscriptionBoxBody, { className: "leadgen-subscription_box_body" },
2968
- React__default["default"].createElement(LeadGenForm, { ref: formRef, form: form, rules: rules, blocks: blocks, locale: locale, onFinish: onFinish, className: "leadgen-subscription_box_form" }),
2969
- React__default["default"].createElement(core.Button, { disabled: loading, loading: loading, variant: "filled", size: "lg", onClick: () => {
2970
- formRef.current.submit();
2971
- }, className: "leadgen-btn leadgen-btn_action", fullWidth: true }, submitText))));
2972
- };
2973
-
2974
- const LeadGenSubscriptionBoxWithoutMemo = ({ locale, userInfo, forceCampaign, categoryId, }) => {
2975
- var _a, _b, _c;
2976
- const { image, extra_fields, id: campaign_id, bot_id: campaign_subot_id = [], ThankYouBlock, } = forceCampaign || {};
2977
- const { textBlocks, listBlockAdded, actionBlocks } = extra_fields || {};
2978
- const { submitBlock } = actionBlocks || {};
2979
- const { apiLeadUrl, subscriptionIcon, subscriptionTitle, submitSubscriptionBox, impression, onFinish, } = useLeadGenContext();
2980
- const { t } = index.useTranslations();
2981
- const { action: { pushNotifications }, } = React.useContext(togetherComponentGlobalContext.TogetherComponentGlobalContext);
2982
- const refContainer = React.useRef(null);
2983
- const [loading, setLoading] = React.useState(false);
2984
- const [showThankyou, setShowThankyou] = React.useState(false);
2985
- const validatingEmailRef = React.useRef(false);
2986
- const validatingPhoneRef = React.useRef(false);
2987
- const { form, validateObj } = useLeadFormConfig({
2988
- listBlockAdded,
2989
- campaignId: campaign_id,
2990
- campaign_subot_id,
2991
- validatingEmailRef,
2992
- validatingPhoneRef,
2993
- userInfo,
2994
- });
2995
- const subscription_title = React.useMemo(() => {
2996
- var _a, _b;
2997
- return subscriptionTitle ||
2998
- ((_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) ||
2999
- t('leadgen.message.title.default');
3000
- }, [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]);
3001
- const { image: thankyouImage, title: thankyouTitle, description: thankyouDescription, button: thankyouButton, } = ThankYouBlock || {};
3002
- const intersectionObserverCallback = React.useCallback((entries) => {
3003
- entries.forEach((entry) => {
3004
- const { isIntersecting, target } = entry;
3005
- if (!showThankyou &&
3006
- isIntersecting &&
3007
- target === refContainer.current) {
3008
- impression();
3009
- }
3010
- });
3011
- }, [impression, showThankyou]);
3012
- const IObserver = new IntersectionObserver(intersectionObserverCallback);
3013
- const middlewareOnSubmit = React.useCallback((values) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
3014
- const newValues = {
3015
- subscription_title,
3016
- };
3017
- const ssoValues = {
3018
- sso_user_id: undefined,
3019
- sso_uuid: undefined,
3020
- sso_verified_profile: undefined,
3021
- };
3022
- const valueKeys = Object.keys(values);
3023
- for (const key of valueKeys) {
3024
- const isPhoneField = leadGenFieldNamePhone(listBlockAdded).some((k) => k === key);
3025
- if (isPhoneField) {
3026
- const phone = PhoneInputBase.parsePhoneNumber(values[key]);
3027
- if (phone.isValid()) {
3028
- /** Seperate `area_code` and `phone_number` for BE */
3029
- newValues['area_code'] = `+${phone.countryCallingCode}`;
3030
- newValues['phone_number'] = phone.nationalNumber;
3031
- /** Only case login has this update */
3032
- if ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) && (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid)) {
3033
- ssoValues['sso_verified_profile'] =
3034
- phone.number === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone) ? 1 : 0;
3035
- ssoValues['sso_user_id'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.id;
3036
- ssoValues['sso_uuid'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid;
3037
- }
3038
- }
3039
- continue;
3040
- }
3041
- newValues[key] = values[key];
3042
- }
3043
- setLoading(true);
3044
- try {
3045
- const { _data } = (yield submitSubscriptionBox(Object.assign(Object.assign({}, newValues), ssoValues))) || {};
3046
- const { model } = _data || {};
3047
- if (model && (model === null || model === void 0 ? void 0 : model.id)) {
3048
- setShowThankyou(true);
3049
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(Object.assign(Object.assign({}, newValues), ssoValues), listBlockAdded || []);
3050
- }
3051
- }
3052
- catch (error) {
3053
- LeadLog('** LeadGen SubscriptionBox error : ', error);
3054
- pushNotifications({
3055
- message: t('leadgen.message.error.default'),
3056
- type: 'danger',
3057
- });
3058
- }
3059
- setLoading(false);
3060
- }), [
3061
- subscription_title,
3062
- listBlockAdded,
3063
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
3064
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid,
3065
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone,
3066
- ]);
3067
- React.useEffect(() => {
3068
- if (refContainer.current) {
3069
- IObserver.observe(refContainer.current);
3070
- }
3071
- return () => {
3072
- IObserver.disconnect();
3073
- };
3074
- }, [categoryId]);
3075
- return (React__default["default"].createElement("div", { ref: refContainer },
3076
- React__default["default"].createElement(StyledLeadGenSubscriptionBox, null,
3077
- showThankyou && (React__default["default"].createElement(LeadGenThankYou, { image: Object.assign(Object.assign({}, thankyouImage), { src: thankyouImage.src || `${apiLeadUrl}admin/img/thanksyou.png` }), title: thankyouTitle, description: thankyouDescription, button: thankyouButton })),
3078
- !showThankyou && (React__default["default"].createElement(LeadGenSubscriptionBoxA, { loading: loading, image: subscriptionIcon || image, title: subscription_title, submitText: (_c = submitBlock === null || submitBlock === void 0 ? void 0 : submitBlock.data) === null || _c === void 0 ? void 0 : _c.value, blocks: listBlockAdded, locale: locale, form: form, rules: validateObj, onFinish: middlewareOnSubmit })))));
3079
- };
3080
- const LeadGenSubscriptionBox$1 = React.memo(LeadGenSubscriptionBoxWithoutMemo);
3081
-
3082
- const Container = () => {
3083
- const context = React.useContext(LeadGenContext);
3084
- const { campaign_code, locale, siteId, siteDomain, userInfo, forceCampaign } = context;
3085
- if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
3086
- return null;
3087
- }
3088
- return (React__default["default"].createElement(LeadGenSubscriptionBox$1, { locale: locale, siteId: siteId, siteDomain: siteDomain, userInfo: userInfo, forceCampaign: forceCampaign, campaign_code: campaign_code }));
3089
- };
3090
- Container.displayName = 'LeadGenSubscriptionBox';
3091
- const LeadGenSubscriptionBoxContainer = (props) => {
3092
- const { apiUrl, apiSubotUrl } = props;
3093
- return (React__default["default"].createElement(LeadGenContextProvider, Object.assign({}, props, { apiLeadUrl: apiUrl, apiSubotUrl: apiSubotUrl }),
3094
- React__default["default"].createElement(Container, null)));
3095
- };
3096
- const LeadGenSubscriptionBox = LeadGenSubscriptionBoxContainer;
3097
-
3098
- const useImageSize = (src) => {
3099
- const [width, setWidth] = React.useState(16);
3100
- const [height, setHeight] = React.useState(9);
3101
- const [loaded, setLoaded] = React.useState(false);
3102
- // load src image to get its width and height
3103
- React.useEffect(() => {
3104
- setLoaded(false);
3105
- if (src) {
3106
- const img = new Image();
3107
- img.addEventListener('load', () => {
3108
- setWidth(img.naturalWidth);
3109
- setHeight(img.naturalHeight);
3110
- setLoaded(true);
3111
- });
3112
- img.addEventListener('error', () => {
3113
- setWidth(16);
3114
- setHeight(9);
3115
- setLoaded(true);
3116
- });
3117
- img.src = src;
3118
- }
3119
- else {
3120
- setWidth(16);
3121
- setHeight(9);
3122
- setLoaded(true);
3123
- }
3124
- }, [src]);
3125
- return {
3126
- loaded,
3127
- width,
3128
- height,
3129
- };
3130
- };
3131
-
3132
- const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default["default"].createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
3133
- React__default["default"].createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
3134
- React__default["default"].createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
3135
-
3136
- // url: imageBlocks.imageMobile.data.url
3137
- // newTab: imageBlocks.imageMobile.data.newtab
3138
- // imageMobile: campaignShow.image
3139
- // imageDestkop: campaignShow.image_desktop
3140
- const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
3141
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3142
- const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
3143
- if (!imageMobileLoaded || !imageDestkopLoaded)
3144
- return null;
3145
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
3146
- React__default["default"].createElement("div", { className: "le-center-tab-popup" },
3147
- React__default["default"].createElement("div", { style: { position: 'relative' } },
3148
- React__default["default"].createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
3149
- index$8.isVideo(imageMobile) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
3150
- React__default["default"].createElement("source", { src: imageMobile }))) : (React__default["default"].createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
3151
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3152
- } })),
3153
- index$8.isVideo(imageDestkop) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
3154
- React__default["default"].createElement("source", { src: imageDestkop }))) : (React__default["default"].createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
3155
- aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
3156
- } }))),
3157
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3158
- };
3159
-
3160
- // title: titleText
3161
- // titleAlign: textBlocks.titleBlock.data.align
3162
- // subtitle: textBlocks.subtitleBlock.data.value
3163
- // subtitleAlign: textBlocks.subtitleBlock.data.align
3164
- // url: actionBlocks.linkButtonBlock.data.url
3165
- // urlText: actionBlocks.linkButtonBlock.data.value
3166
- // newTab: actionBlocks.linkButtonBlock.data.newtab
3167
- // imageMobile: campaignShow.image
3168
- // imageDesktop: campaignShow.image_desktop
3169
- const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
3170
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3171
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
3172
- if (!imageMobileLoaded || !imageDesktopLoaded)
1431
+ // title: titleText
1432
+ // titleAlign: textBlocks.titleBlock.data.align
1433
+ // subtitle: textBlocks.subtitleBlock.data.value
1434
+ // subtitleAlign: textBlocks.subtitleBlock.data.align
1435
+ // url: actionBlocks.linkButtonBlock.data.url
1436
+ // urlText: actionBlocks.linkButtonBlock.data.value
1437
+ // newTab: actionBlocks.linkButtonBlock.data.newtab
1438
+ // imageMobile: campaignShow.image
1439
+ // imageDesktop: campaignShow.image_desktop
1440
+ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
1441
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1442
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
1443
+ if (!imageMobileLoaded || !imageDesktopLoaded)
3173
1444
  return null;
3174
1445
  return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
3175
1446
  React__default["default"].createElement("aside", { className: "le-only-desktop" },
@@ -3209,6 +1480,7 @@ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, su
3209
1480
  };
3210
1481
 
3211
1482
  const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
1483
+ const { primaryColor } = React.useContext(LeadGenContext);
3212
1484
  const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
3213
1485
  if (!imageLoaded)
3214
1486
  return null;
@@ -3228,7 +1500,7 @@ const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkN
3228
1500
  }))),
3229
1501
  linkText && (React__default["default"].createElement("div", null,
3230
1502
  React__default["default"].createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
3231
- React__default["default"].createElement("button", { className: `lead-modal__btn ${LEAD_CLASS}` }, linkText)))))));
1503
+ React__default["default"].createElement(index$3.Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
3232
1504
  };
3233
1505
 
3234
1506
  const InlineLayout = ({ content, inlinePosition, }) => {
@@ -3376,6 +1648,211 @@ const EmptyComponent = ({ onClose, onContinue, }) => {
3376
1648
  React__default["default"].createElement(core.Button, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
3377
1649
  };
3378
1650
 
1651
+ const libraries = ['places'];
1652
+ const GoogleLocationBlock = (props) => {
1653
+ var _a;
1654
+ const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = tslib_es6.__rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
1655
+ const [LoadScript, setLoadScript] = React.useState(null);
1656
+ const [value, setValue] = React.useState(defaultValue || valueProps);
1657
+ const { predictions } = usePlacesAutocomplete.usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
1658
+ const onChangeAutocomplete = React.useCallback((s) => {
1659
+ setValue(s);
1660
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
1661
+ }, []);
1662
+ const onClickItem = React.useCallback((item) => {
1663
+ /** For sure get value */
1664
+ setValue(item.value);
1665
+ const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
1666
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
1667
+ }, [onChangeProps, predictions]);
1668
+ React.useEffect(() => {
1669
+ setValue(valueProps);
1670
+ }, [valueProps]);
1671
+ React.useEffect(() => {
1672
+ var _a, _b, _c;
1673
+ // only load extra google script when not yet loaded
1674
+ 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) {
1675
+ Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@react-google-maps/api')); }).then((m) => {
1676
+ setLoadScript(() => m.LoadScript);
1677
+ });
1678
+ }
1679
+ }, []);
1680
+ return (React__default["default"].createElement(core.Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
1681
+ return { value: pred.description, label: pred.description };
1682
+ }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: index$7.ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
1683
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
1684
+ LoadScript && (React__default["default"].createElement(LoadScript, { googleMapsApiKey: usePlacesAutocomplete.GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default["default"].createElement(React__default["default"].Fragment, null), style: { width: '100%' } })),
1685
+ children));
1686
+ } }, restProps)));
1687
+ };
1688
+
1689
+ // You can give context variables any name
1690
+ const [LeadFormProvider, useLeadFormContext, useLeadForm] = form.createFormContext();
1691
+ const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, }) => {
1692
+ const { t } = index.useTranslations();
1693
+ const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
1694
+ const validateObj = React.useMemo(() => {
1695
+ const InputBlocks = [
1696
+ 'TextBlock',
1697
+ 'NumberBlock',
1698
+ 'EmailBlock',
1699
+ 'PhoneBlock',
1700
+ 'DateBlock',
1701
+ 'CheckboxBlock',
1702
+ 'RadioBlock',
1703
+ 'DropdownBlock',
1704
+ 'PhoneOtpBlock',
1705
+ 'WhatsappOtpBlock',
1706
+ 'ZaloOtpBlock',
1707
+ 'LocationBlock',
1708
+ 'TncBlock',
1709
+ ];
1710
+ // ALL are required and can skip if not touched yet
1711
+ const withSharedCheck = (name, cb,
1712
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1713
+ block) => {
1714
+ return (value) => {
1715
+ var _a;
1716
+ const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
1717
+ if (!formRef.current.isTouched(name))
1718
+ return;
1719
+ if ((typeof value === 'string' && value.replace(' ', '') === '') ||
1720
+ typeof value === 'undefined' ||
1721
+ value === '' ||
1722
+ (Array.isArray(value) && value.length === 0)) {
1723
+ return isBLockRequired
1724
+ ? t('validator.required')
1725
+ : cb === null || cb === void 0 ? void 0 : cb(value);
1726
+ }
1727
+ return cb === null || cb === void 0 ? void 0 : cb(value);
1728
+ };
1729
+ };
1730
+ return listBlockAdded
1731
+ .filter((b) => InputBlocks.includes(b.name))
1732
+ .reduce((r, b) => {
1733
+ var _a;
1734
+ const isRequired = (_a = b.data.required) !== null && _a !== void 0 ? _a : true;
1735
+ if (b.name === 'NumberBlock') {
1736
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1737
+ if (value && isNaN(Number(value))) {
1738
+ return t('validator.number');
1739
+ }
1740
+ }, b) });
1741
+ }
1742
+ else if (b.name === 'EmailBlock') {
1743
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1744
+ if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
1745
+ return t('validator.email');
1746
+ }
1747
+ if (!value)
1748
+ return;
1749
+ validatingEmailRef.current = true;
1750
+ setTimeout(() => {
1751
+ formRef.current.setFieldError(b.data.value, 'Validating...');
1752
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1753
+ email: value,
1754
+ })
1755
+ .then((tKey) => {
1756
+ if (tKey) {
1757
+ formRef.current.setFieldError(b.data.value, t(tKey));
1758
+ }
1759
+ else {
1760
+ formRef.current.clearFieldError(b.data.value);
1761
+ }
1762
+ validatingEmailRef.current = false;
1763
+ })
1764
+ .catch((e) => {
1765
+ console.error(e);
1766
+ formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
1767
+ validatingEmailRef.current = false;
1768
+ });
1769
+ }, 200);
1770
+ }, b) });
1771
+ }
1772
+ else if (b.name === 'PhoneBlock' ||
1773
+ b.name === 'PhoneOtpBlock' ||
1774
+ b.name === 'ZaloOtpBlock' ||
1775
+ b.name === 'WhatsappOtpBlock') {
1776
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1777
+ if (value &&
1778
+ window.intlTelInputUtils &&
1779
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
1780
+ return t('validator.phone');
1781
+ }
1782
+ if (!value)
1783
+ return;
1784
+ validatingPhoneRef.current = true;
1785
+ setTimeout(() => {
1786
+ formRef.current.setFieldError(b.data.value, 'Validating...');
1787
+ if (b.data.singleSubmission) {
1788
+ checkUsedPhoneOnlyWithCache(campaignId, value)
1789
+ .then((tKey) => {
1790
+ if (tKey) {
1791
+ formRef.current.setFieldError(b.data.value, t(tKey));
1792
+ }
1793
+ else {
1794
+ formRef.current.clearFieldError(b.data.value);
1795
+ }
1796
+ validatingPhoneRef.current = false;
1797
+ })
1798
+ .catch((err) => {
1799
+ console.error(err);
1800
+ formRef.current.setFieldError(b.data.value, err.message || 'Something went wrong');
1801
+ validatingPhoneRef.current = false;
1802
+ });
1803
+ }
1804
+ else {
1805
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1806
+ phone: value,
1807
+ })
1808
+ .then((tKey) => {
1809
+ if (tKey) {
1810
+ formRef.current.setFieldError(b.data.value, t(tKey));
1811
+ }
1812
+ else {
1813
+ formRef.current.clearFieldError(b.data.value);
1814
+ }
1815
+ validatingPhoneRef.current = false;
1816
+ })
1817
+ .catch((e) => {
1818
+ console.error(e);
1819
+ formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
1820
+ validatingPhoneRef.current = false;
1821
+ });
1822
+ }
1823
+ }, 200);
1824
+ }, b) });
1825
+ }
1826
+ else if (b.name === 'DateBlock') {
1827
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1828
+ if (value && isNaN(Date.parse(value))) {
1829
+ return t('validator.date');
1830
+ }
1831
+ }, b) });
1832
+ }
1833
+ else if (b.name === 'TncBlock') {
1834
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
1835
+ if (isRequired && !value) {
1836
+ return t('validator.required');
1837
+ }
1838
+ }, b) });
1839
+ }
1840
+ else {
1841
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, undefined, b) });
1842
+ }
1843
+ }, {});
1844
+ }, [listBlockAdded.map((b) => b.name).join(',')]);
1845
+ const form = useLeadForm({
1846
+ validateInputOnChange: true,
1847
+ clearInputErrorOnChange: true,
1848
+ validate: validateObj,
1849
+ initialValues,
1850
+ });
1851
+ const formRef = React.useRef(form);
1852
+ formRef.current = form;
1853
+ return { form, validateObj };
1854
+ };
1855
+
3379
1856
  const SubtitleBlock = ({ children, align, }) => (React__default["default"].createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
3380
1857
 
3381
1858
  const cssInputNotShrink = react.css `
@@ -3546,14 +2023,6 @@ const StyledTextFieldContainer = styled__default["default"].div `
3546
2023
  }
3547
2024
  }
3548
2025
 
3549
- &:focus-within {
3550
- .mantine-Input-wrapper {
3551
- transition: 0.25s linear border;
3552
- border-color: ${miscTheme.theme.colors.primary600};
3553
- box-shadow: 0 0 4px ${miscTheme.theme.colors.primary200};
3554
- }
3555
- }
3556
-
3557
2026
  .PhoneInput {
3558
2027
  --phone-select: 75px;
3559
2028
  --phone-input-space-x: 8px;
@@ -3702,13 +2171,11 @@ const TextField = (props) => {
3702
2171
  const $focusEl = $textEl.item($textEl.length - 1);
3703
2172
  if ($focusEl) {
3704
2173
  $focusEl.focus();
3705
- setTimeout(() => {
3706
- $focusEl.scrollIntoView({
3707
- behavior: 'auto',
3708
- block: 'center',
3709
- inline: 'start',
3710
- });
3711
- }, 100);
2174
+ $focusEl.scrollIntoView({
2175
+ behavior: 'auto',
2176
+ block: 'center',
2177
+ inline: 'start',
2178
+ });
3712
2179
  }
3713
2180
  }, [shrink]);
3714
2181
  React.useEffect(() => {
@@ -3725,14 +2192,8 @@ const ChoiceField = (props) => {
3725
2192
  const TitleBlock = ({ children, align, }) => (React__default["default"].createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
3726
2193
 
3727
2194
  const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, }) => {
3728
- const { t } = index.useTranslations();
3729
2195
  const form = useLeadFormContext();
3730
2196
  const formValues = form.values;
3731
- const labelTuples = React.useMemo(() => {
3732
- return ((index$7.ISO_FORMAT === null || index$7.ISO_FORMAT === void 0 ? void 0 : index$7.ISO_FORMAT[locale]) || index$7.ISO_FORMAT['vi-VN']).dateFormat
3733
- .split('/')
3734
- .map((key) => { var _a; return t((_a = index$9.COMMON_DATE_TRANSLATE_KEY === null || index$9.COMMON_DATE_TRANSLATE_KEY === void 0 ? void 0 : index$9.COMMON_DATE_TRANSLATE_KEY[key]) === null || _a === void 0 ? void 0 : _a.id); });
3735
- }, [locale]);
3736
2197
  return (React__default["default"].createElement(React__default["default"].Fragment, null, listBlockAdded.map((b, index) => {
3737
2198
  var _a;
3738
2199
  const { name = '', data = {}, id } = b || {};
@@ -3782,15 +2243,17 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
3782
2243
  return (React__default["default"].createElement(TextField, { key: index, shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field" },
3783
2244
  React__default["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)))));
3784
2245
  }
3785
- case 'DateBlock': {
3786
- const _c = form.getInputProps(value), { error } = _c, formInputProps = tslib_es6.__rest(_c, ["error"]);
3787
- return (React__default["default"].createElement(core.Input.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" },
3788
- React__default["default"].createElement(InputDate.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))));
3789
- }
2246
+ case 'DateBlock':
2247
+ return (React__default["default"].createElement(TextField, { key: index, shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field" },
2248
+ React__default["default"].createElement(index$4.DatePicker, Object.assign({ clearable: true, withAsterisk: required, type: "default", name: value, placeholder: placeholder, label: placeholder, inputWrapperOrder: ['label', 'input', 'description', 'error'], inputContainer: (children) => {
2249
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
2250
+ children,
2251
+ React__default["default"].createElement("input", { type: "hidden", "data-control": "date", name: value, value: formValue })));
2252
+ } }, form.getInputProps(value)))));
3790
2253
  case 'LinkButtonBlock':
3791
2254
  return (React__default["default"].createElement("div", { key: index },
3792
2255
  React__default["default"].createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
3793
- React__default["default"].createElement(index$3.Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
2256
+ React__default["default"].createElement(index$8.Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
3794
2257
  onClose === null || onClose === void 0 ? void 0 : onClose();
3795
2258
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
3796
2259
  } }, value))));
@@ -3829,7 +2292,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
3829
2292
  label: l.placeholder,
3830
2293
  })) }, form.getInputProps(value)))));
3831
2294
  case 'TncBlock':
3832
- const _d = form.getInputProps(`TNC-${id}`), { error } = _d, tncInputProps = tslib_es6.__rest(_d, ["error"]);
2295
+ const _c = form.getInputProps(`TNC-${id}`), { error } = _c, tncInputProps = tslib_es6.__rest(_c, ["error"]);
3833
2296
  return (React__default["default"].createElement(ChoiceField, { className: "leadgen-form_checkbox", key: id },
3834
2297
  React__default["default"].createElement(core.Input.Wrapper, { error: error },
3835
2298
  React__default["default"].createElement(index$2.Checkbox, Object.assign({ name: 'TNC-' + id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps)))));
@@ -3935,10 +2398,11 @@ const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
3935
2398
  if (!src) {
3936
2399
  return null;
3937
2400
  }
3938
- return (React__default["default"].createElement(StyleHeaderImage, { paddingTop: (1 / ratio) * 100, className: core.clsx(className, 'leadgen-header_image'), style: style }, index$8.isVideo(src) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true, className: "leadgen-header_image_feature leadgen-header_image_video", src: src })) : (React__default["default"].createElement("img", { src: src, draggable: "false", alt: "", className: "leadgen-header_image_feature leadgen-header_image_image" }))));
2401
+ return (React__default["default"].createElement(StyleHeaderImage, { paddingTop: (1 / ratio) * 100, className: core.clsx(className, 'leadgen-header_image'), style: style }, index$6.isVideo(src) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true, className: "leadgen-header_image_feature leadgen-header_image_video", src: src })) : (React__default["default"].createElement("img", { src: src, draggable: "false", alt: "", className: "leadgen-header_image_feature leadgen-header_image_image" }))));
3939
2402
  };
3940
2403
 
3941
2404
  const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
2405
+ const { primaryColor } = React.useContext(LeadGenContext);
3942
2406
  const { t } = index.useTranslations();
3943
2407
  const phone = otpData.phone;
3944
2408
  const otpType = otpData.type;
@@ -4024,370 +2488,709 @@ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
4024
2488
  // type: 'danger',
4025
2489
  // })
4026
2490
  }
4027
- setIsSubmitLoading(false);
4028
- });
4029
- React.useEffect(() => {
4030
- setTimeout(() => {
4031
- if (resendTimer > 0) {
4032
- setResendTimer((r) => r - 1);
4033
- }
4034
- }, 1000);
4035
- }, [resendTimer]);
4036
- React.useEffect(() => {
4037
- if (autoSendWhenOpen && !resendTimer) {
4038
- sendOtp();
2491
+ setIsSubmitLoading(false);
2492
+ });
2493
+ React.useEffect(() => {
2494
+ setTimeout(() => {
2495
+ if (resendTimer > 0) {
2496
+ setResendTimer((r) => r - 1);
2497
+ }
2498
+ }, 1000);
2499
+ }, [resendTimer]);
2500
+ React.useEffect(() => {
2501
+ if (autoSendWhenOpen && !resendTimer) {
2502
+ sendOtp();
2503
+ }
2504
+ }, []);
2505
+ return (React__default["default"].createElement("form", { onSubmit: (e) => {
2506
+ e.preventDefault();
2507
+ submitOtp();
2508
+ }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
2509
+ React__default["default"].createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
2510
+ phone: `<strong>${displayPhone}</strong>`,
2511
+ }), footer: React__default["default"].createElement(React__default["default"].Fragment, null,
2512
+ React__default["default"].createElement(core.Button, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
2513
+ React__default["default"].createElement(core.Button, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
2514
+ sendOtp();
2515
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
2516
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
2517
+ }))) },
2518
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
2519
+ React__default["default"].createElement(index$2.Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
2520
+ React__default["default"].createElement(index$2.OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
2521
+ setIsDirty(true);
2522
+ setOtp(v.toString());
2523
+ if (isDirty && !v)
2524
+ setErrorMsg('OTP is required');
2525
+ else
2526
+ setErrorMsg(undefined);
2527
+ } }))))));
2528
+ };
2529
+
2530
+ // url: imageBlocks.imageMobile.data.url
2531
+ // newTab: imageBlocks.imageMobile.data.newtab
2532
+ // image: campaignShow.image
2533
+ // imageDestkop: campaignShow.image_desktop
2534
+ const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
2535
+ LEADGEN_LAYOUT.Fullscreen,
2536
+ LEADGEN_LAYOUT.Slider,
2537
+ ];
2538
+ const LEADGEN_LIMIT_LIGHTBOXB = 6;
2539
+ const LEADGEN_SHOW_HEADER = [
2540
+ 'LightBoxA',
2541
+ 'InlineA',
2542
+ LEADGEN_LAYOUT.Sidebar,
2543
+ LEADGEN_LAYOUT.Slider,
2544
+ ];
2545
+ const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2546
+ var _a;
2547
+ const { primaryColor } = React.useContext(LeadGenContext);
2548
+ const { isMobile } = useScreenSize.useScreenSize();
2549
+ const [open, setOpen] = React.useState(!!campaignId);
2550
+ const [showOtpPhone, setShowOtpPhone] = React.useState(null);
2551
+ const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
2552
+ const [snap, setSnap] = React.useState(0.8);
2553
+ const formRef = React.useRef();
2554
+ const onClose = () => {
2555
+ if (showOtpPhone) {
2556
+ setShowOtpPhone(null);
2557
+ }
2558
+ else {
2559
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2560
+ }
2561
+ };
2562
+ const textBlocks = JSON.parse(extraFields.textBlocks);
2563
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
2564
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
2565
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
2566
+ const currentPath = location.pathname;
2567
+ const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
2568
+ const { align: titleAlign } = textBlocks.titleBlock.data || {};
2569
+ const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
2570
+ const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
2571
+ const isLightBox = currentLayout.includes('LightBox');
2572
+ const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
2573
+ const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
2574
+ const isInline = currentLayout.includes('Inline');
2575
+ const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
2576
+ const isInPage = isInline || isSidebar;
2577
+ const isDrawer = isLightBoxB && isMobile;
2578
+ const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
2579
+ const hasForm = isLightBoxA
2580
+ ? listBlockAdded.some((item) => LEADGEN_BLOCK_IN_FORM.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
2581
+ : true;
2582
+ const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
2583
+ const showHeader = !!imageMobile || !!imageDesktop;
2584
+ const onlyHeader = !title && !description;
2585
+ const showButtonClose = !isInline;
2586
+ if (window.innerWidth < 769 &&
2587
+ LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
2588
+ console.log('😎 Not show fullscreen, slider on mobile ');
2589
+ return null;
2590
+ }
2591
+ React.useEffect(() => {
2592
+ if (isLightBox || isFullscreen) {
2593
+ document.body.classList.add('noscroll');
2594
+ }
2595
+ if (!window.intlTelInputUtils) {
2596
+ require('intl-tel-input/build/js/utils');
2597
+ }
2598
+ clearCacheUsedEmailOrPhone();
2599
+ }, []);
2600
+ const validatingPhoneRef = React.useRef(false);
2601
+ const validatingEmailRef = React.useRef(false);
2602
+ const { form, validateObj } = useLeadFormConfig({
2603
+ listBlockAdded,
2604
+ validatingPhoneRef,
2605
+ validatingEmailRef,
2606
+ campaignId,
2607
+ campaign_subot_id,
2608
+ userInfo,
2609
+ });
2610
+ const middlewareOnSubmit = (e) => {
2611
+ e.preventDefault();
2612
+ // mark all as touched to allow validation
2613
+ form.setTouched(Object.keys(validateObj).reduce((acc, cur) => {
2614
+ acc[cur] = true;
2615
+ return acc;
2616
+ }, {}));
2617
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
2618
+ return;
2619
+ }
2620
+ setTimeout(() => {
2621
+ form.onSubmit((v) => {
2622
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2623
+ if (Object.keys(form.errors).length)
2624
+ return;
2625
+ let newShowOtpPhone = null;
2626
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
2627
+ // not submit yet, open otp
2628
+ 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;
2629
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
2630
+ newShowOtpPhone = {
2631
+ phone: v[fieldName],
2632
+ type: 'phone',
2633
+ };
2634
+ }
2635
+ }
2636
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
2637
+ // not submit yet, open otp
2638
+ 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;
2639
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
2640
+ newShowOtpPhone = {
2641
+ phone: v[fieldName],
2642
+ type: 'whatsapp',
2643
+ };
2644
+ }
2645
+ }
2646
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
2647
+ // not submit yet, open otp
2648
+ 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;
2649
+ if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
2650
+ newShowOtpPhone = {
2651
+ phone: v[fieldName],
2652
+ type: 'zalo',
2653
+ };
2654
+ }
2655
+ }
2656
+ if (newShowOtpPhone) {
2657
+ setIsSubmitLoading(true);
2658
+ Service.sendSMSOtpLead(newShowOtpPhone)
2659
+ .then((res) => {
2660
+ var _a;
2661
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2662
+ if (respMessage === 'This phone number was verified') {
2663
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2664
+ return;
2665
+ }
2666
+ setShowOtpPhone(newShowOtpPhone);
2667
+ })
2668
+ .finally(() => {
2669
+ setIsSubmitLoading(false);
2670
+ });
2671
+ return;
2672
+ }
2673
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2674
+ })(e);
2675
+ }, 100);
2676
+ };
2677
+ const onOpenChange = (_open) => {
2678
+ setOpen(_open);
2679
+ if (!_open) {
2680
+ setTimeout(() => {
2681
+ onClose();
2682
+ }, 250);
2683
+ }
2684
+ };
2685
+ const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
2686
+ const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
2687
+ const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
2688
+ const renderAfterImageSizes = imageMobileLoaded &&
2689
+ imageDesktopLoaded &&
2690
+ (isFullscreen ? imageBackgroundLoaded : true);
2691
+ const ButtonSubmit = !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default["default"].createElement(core.Button, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, loading: isSubmitLoading }, popUpSubmitText));
2692
+ const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
2693
+ const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default["default"].createElement(React__default["default"].Fragment, null, LinkButtonBlock.map((item, index) => {
2694
+ var _a, _b, _c;
2695
+ return (React__default["default"].createElement(core.Button, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
2696
+ onClose === null || onClose === void 0 ? void 0 : onClose();
2697
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2698
+ } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
2699
+ })));
2700
+ const PopupHeader = showHeader && (React__default["default"].createElement("header", { className: core.clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default["default"].createElement(React__default["default"].Fragment, null,
2701
+ React__default["default"].createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
2702
+ React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
2703
+ const PopupEmpty = showEmpty && (React__default["default"].createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
2704
+ const PopupForm = (React__default["default"].createElement(LeadFormProvider, { form: form },
2705
+ React__default["default"].createElement("form", { ref: formRef, className: "leadgen-form", onSubmit: middlewareOnSubmit },
2706
+ React__default["default"].createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
2707
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
2708
+ React__default["default"].createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
2709
+ const PopupOtp = showOtpPhone && (React__default["default"].createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
2710
+ setShowOtpPhone(null);
2711
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
2712
+ } }));
2713
+ const PopupThankYou = showThankyou && (React__default["default"].createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
2714
+ const PopupContent = (React__default["default"].createElement("div", { className: core.clsx('leadgen-content', {
2715
+ 'leadgen-content_small': limitFieldsLightBoxB,
2716
+ }) },
2717
+ !headerInsideFormContainer && PopupHeader,
2718
+ !onlyHeader && (React__default["default"].createElement("div", { className: "leadgen-inner" },
2719
+ PopupThankYou,
2720
+ !showThankyou && (React__default["default"].createElement(React__default["default"].Fragment, null,
2721
+ PopupOtp,
2722
+ PopupEmpty,
2723
+ !(showOtpPhone || showEmpty) && PopupForm))))));
2724
+ const styleOverlay = React.useMemo(() => {
2725
+ let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
2726
+ if (isMobile && imageOverlayMobile) {
2727
+ styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
2728
+ }
2729
+ if (!isMobile && imageOverlayDesktop) {
2730
+ styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4039
2731
  }
4040
- }, []);
4041
- return (React__default["default"].createElement("form", { onSubmit: (e) => {
4042
- e.preventDefault();
4043
- submitOtp();
4044
- }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
4045
- React__default["default"].createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
4046
- phone: `<strong>${displayPhone}</strong>`,
4047
- }), footer: React__default["default"].createElement(React__default["default"].Fragment, null,
4048
- React__default["default"].createElement(core.Button, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
4049
- React__default["default"].createElement(core.Button, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, onClick: () => {
4050
- sendOtp();
4051
- }, disabled: !!resendTimer }, t('lead.otp.resend', {
4052
- timer: resendTimer ? ` (${resendTimer}s)` : '',
4053
- }))) },
4054
- React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4055
- React__default["default"].createElement(index$2.Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
4056
- React__default["default"].createElement(index$2.OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
4057
- setIsDirty(true);
4058
- setOtp(v.toString());
4059
- if (isDirty && !v)
4060
- setErrorMsg('OTP is required');
4061
- else
4062
- setErrorMsg(undefined);
4063
- } }))))));
2732
+ return styleContent;
2733
+ }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
2734
+ const PopupWrapper = (React__default["default"].createElement(React__default["default"].Fragment, null,
2735
+ React__default["default"].createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
2736
+ React__default["default"].createElement("div", { className: core.clsx('leadgen-wrapper', {
2737
+ 'leadgen-wrapper_small': limitFieldsLightBoxB,
2738
+ }) },
2739
+ showButtonClose && (React__default["default"].createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
2740
+ PopupContent)));
2741
+ const popupContainerClassName = core.clsx('leadgen', `leadgen-${currentLayout}`, {
2742
+ 'leadgen-lightbox': isLightBox,
2743
+ 'leadgen-inline': isInPage,
2744
+ 'leadgen-slider': isSlider,
2745
+ });
2746
+ const PopupContainer = isDrawer ? (React__default["default"].createElement(index$9.DrawerComponent, { fadeFromIndex: index$7.ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
2747
+ PopupWrapper,
2748
+ React__default["default"].createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default["default"].createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
2749
+ isFullscreen ? (React__default["default"].createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
2750
+ aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
2751
+ } })) : null,
2752
+ PopupWrapper));
2753
+ if (!renderAfterImageSizes)
2754
+ return null;
2755
+ if (isLightBox || isFullscreen || isSlider) {
2756
+ return PopupContainer;
2757
+ }
2758
+ else if (isSidebar) {
2759
+ return React__default["default"].createElement(SideBarLayout, { content: PopupContainer });
2760
+ }
2761
+ else if (isInline) {
2762
+ return (React__default["default"].createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
2763
+ }
2764
+ return null;
2765
+ };
2766
+
2767
+ const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
2768
+ const currentPath = location.pathname;
2769
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
2770
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
2771
+ if (!imageMobileLoaded || !imageDesktopLoaded)
2772
+ return null;
2773
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
2774
+ currentLayout == 'SkinA' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
2775
+ React__default["default"].createElement("div", { className: "le-skin-a-desktop" },
2776
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
2777
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
2778
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2779
+ } }),
2780
+ React__default["default"].createElement("a", { style: {
2781
+ position: 'absolute',
2782
+ top: '75%',
2783
+ left: '50%',
2784
+ transform: 'translate(-50%, -50%)',
2785
+ textAlign: 'center',
2786
+ width: 'calc(100% - 15px)',
2787
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2788
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
2789
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
2790
+ React__default["default"].createElement("div", { className: "" },
2791
+ React__default["default"].createElement("div", { style: { position: 'relative', zIndex: 10000 } },
2792
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
2793
+ width: '100%',
2794
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2795
+ } }),
2796
+ React__default["default"].createElement("a", { style: {
2797
+ position: 'absolute',
2798
+ top: '75%',
2799
+ left: '50%',
2800
+ transform: 'translate(-50%, -50%)',
2801
+ textAlign: 'center',
2802
+ width: '100%',
2803
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2804
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2805
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
2806
+ React__default["default"].createElement("aside", { className: "le-only-mobile" },
2807
+ React__default["default"].createElement("div", { className: "le-skin-mobile" },
2808
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
2809
+ index$6.isVideo(imageMobile) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true },
2810
+ React__default["default"].createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default["default"].createElement("img", { src: imageMobile, style: {
2811
+ width: '100%',
2812
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
2813
+ } })),
2814
+ React__default["default"].createElement("a", { style: {
2815
+ position: 'absolute',
2816
+ top: '82%',
2817
+ left: '50%',
2818
+ transform: 'translate(-50%, -50%)',
2819
+ textAlign: 'center',
2820
+ maxWidth: 'calc(100% - 15px)',
2821
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2822
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2823
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4064
2824
  };
4065
2825
 
4066
2826
  // url: imageBlocks.imageMobile.data.url
4067
2827
  // newTab: imageBlocks.imageMobile.data.newtab
4068
2828
  // image: campaignShow.image
4069
2829
  // imageDestkop: campaignShow.image_desktop
4070
- const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
4071
- LEADGEN_LAYOUT.Fullscreen,
4072
- LEADGEN_LAYOUT.Slider,
4073
- ];
4074
- const LEADGEN_LIMIT_LIGHTBOXB = 6;
4075
- const LEADGEN_SHOW_HEADER = [
4076
- 'LightBoxA',
4077
- 'InlineA',
4078
- LEADGEN_LAYOUT.Sidebar,
4079
- LEADGEN_LAYOUT.Slider,
4080
- ];
4081
- const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
4082
- var _a, _b;
4083
- const { isMobile } = useScreenSize.useScreenSize();
4084
- const [open, setOpen] = React.useState(!!campaignId);
4085
- const [showOtpPhone, setShowOtpPhone] = React.useState(null);
4086
- const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
4087
- const [snap, setSnap] = React.useState(0.8);
4088
- const formRef = React.useRef();
4089
- const onClose = () => {
4090
- if (showOtpPhone) {
4091
- setShowOtpPhone(null);
2830
+ const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
2831
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
2832
+ if (!imageLoaded)
2833
+ return null;
2834
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
2835
+ React__default["default"].createElement("div", { className: "le-tab-popup" },
2836
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
2837
+ React__default["default"].createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
2838
+ React__default["default"].createElement("img", { className: "js-popup-other-submit", src: image, style: {
2839
+ aspectRatio: `${imageWidth}/${imageHeight}`,
2840
+ } })),
2841
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
2842
+ };
2843
+
2844
+ // import mockLeadData from './mockLeadData'
2845
+ const listCampaignScheduled = [];
2846
+ const listCampaignScheduledToActivated = [];
2847
+ const listCampaignActiveButExpired = [];
2848
+ const listCampaignExcludeSonsored = [];
2849
+ const listCampaignDifferentSponsor = [];
2850
+ const listCampaignNotDisplayInRangeOfTime = [];
2851
+ function isMobile() {
2852
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
2853
+ }
2854
+ const getShuffleArray = (array) => {
2855
+ const newArray = [...array];
2856
+ for (let i = newArray.length - 1; i > 0; i--) {
2857
+ const j = Math.floor(Math.random() * (i + 1));
2858
+ const temp = newArray[i];
2859
+ newArray[i] = newArray[j];
2860
+ newArray[j] = temp;
2861
+ }
2862
+ return newArray;
2863
+ };
2864
+ const getTimeByTimezone = (timeZone = 'UTC') => {
2865
+ const date = new Date();
2866
+ return new Date(date.toLocaleString('en-US', { timeZone }));
2867
+ };
2868
+ const parseDateByCampaignTime = (dateStr) => {
2869
+ // Format like this: 2023-04-04 00:00:00
2870
+ try {
2871
+ const [datePart, timePart] = dateStr.split(' ');
2872
+ const [year, month, day] = datePart.split('-').map(Number);
2873
+ const [hours, minutes, seconds] = timePart.split(':').map(Number);
2874
+ /** JavaScript counts months from 0 to 11 */
2875
+ return new Date(year, month - 1, day, hours, minutes, seconds);
2876
+ }
2877
+ catch (err) {
2878
+ return null;
2879
+ }
2880
+ };
2881
+ const checkCampaignNowInTimeframe = (c) => {
2882
+ var _a;
2883
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2884
+ const startedAtStr = c.started_at;
2885
+ const endedAtStr = c.ended_at;
2886
+ const startedDate = parseDateByCampaignTime(startedAtStr);
2887
+ const endedDate = parseDateByCampaignTime(endedAtStr);
2888
+ if (!startedDate || !endedDate) {
2889
+ return false;
2890
+ }
2891
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
2892
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2893
+ if (nowWithTimezoneMs <= endedDate.getTime() &&
2894
+ nowWithTimezoneMs >= startedDate.getTime()) {
2895
+ listCampaignScheduledToActivated.push(c);
2896
+ return true;
2897
+ }
2898
+ return false;
2899
+ };
2900
+ function checkCampaignActiveButExpireAlready(c) {
2901
+ var _a;
2902
+ /** Do not setup timeframe for this campaign. No need to check */
2903
+ if (c.forever === 1) {
2904
+ return true;
2905
+ }
2906
+ const startedAtStr = c.started_at;
2907
+ const endedAtStr = c.ended_at;
2908
+ const startedDate = parseDateByCampaignTime(startedAtStr);
2909
+ const endedDate = parseDateByCampaignTime(endedAtStr);
2910
+ /** Do not setup timeframe for this campaign. No need to check */
2911
+ if (!startedDate || !endedDate) {
2912
+ return true;
2913
+ }
2914
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2915
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
2916
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2917
+ /** Check if this expire already, do not show */
2918
+ if (nowWithTimezoneMs > endedDate.getTime()) {
2919
+ listCampaignActiveButExpired.push(c);
2920
+ return false;
2921
+ }
2922
+ return true;
2923
+ }
2924
+ function shouldNotDisplayIfExcludeAllSponsors(c) {
2925
+ var _a;
2926
+ const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
2927
+ const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
2928
+ if (isSponsored && excludeSponsored) {
2929
+ listCampaignExcludeSonsored.push(c);
2930
+ return true;
2931
+ }
2932
+ return false;
2933
+ }
2934
+ function shouldDisplayWithCurrentSponsor(c) {
2935
+ var _a, _b;
2936
+ try {
2937
+ // TODO: BE will rename `exclude_sponsored_list` later
2938
+ const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
2939
+ const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
2940
+ const dataSponsoredId = Number((_b = document
2941
+ .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
2942
+ // There is no config for sponsor id and white list, should show as default
2943
+ if (!dataSponsoredId ||
2944
+ dataSponsoredId <= 0 ||
2945
+ whiteListSponsors.length === 0) {
2946
+ return true;
4092
2947
  }
4093
- else {
4094
- onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2948
+ // Check the dataSponsoredId exists in the white list or not.
2949
+ const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
2950
+ if (isExist) {
2951
+ return true;
4095
2952
  }
4096
- };
4097
- const textBlocks = JSON.parse(extraFields.textBlocks);
4098
- const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
4099
- const actionBlocks = JSON.parse(extraFields.actionBlocks);
4100
- const popUpSubmitText = actionBlocks.submitBlock.data.value;
4101
- const currentPath = location.pathname;
4102
- const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
4103
- const { align: titleAlign } = textBlocks.titleBlock.data || {};
4104
- const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
4105
- const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
4106
- const isLightBox = currentLayout.includes('LightBox');
4107
- const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
4108
- const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
4109
- const isInline = currentLayout.includes('Inline');
4110
- const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
4111
- const isInPage = isInline || isSidebar;
4112
- const isDrawer = isLightBoxB && isMobile;
4113
- const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
4114
- const hasForm = isLightBoxA
4115
- ? listBlockAdded.some((item) => LEADGEN_BLOCK_INPUT.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
4116
- : true;
4117
- const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
4118
- const showHeader = !!imageMobile || !!imageDesktop;
4119
- const onlyHeader = !title && !description;
4120
- const showButtonClose = !isInline;
4121
- if (window.innerWidth < 769 &&
4122
- LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
4123
- console.log('😎 Not show fullscreen, slider on mobile ');
4124
- return null;
2953
+ listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
2954
+ return false;
4125
2955
  }
4126
- React.useEffect(() => {
4127
- if (isLightBox || isFullscreen) {
4128
- document.body.classList.add('noscroll');
4129
- }
4130
- if (!window.intlTelInputUtils) {
4131
- require('intl-tel-input/build/js/utils');
2956
+ catch (err) {
2957
+ // Default is show
2958
+ return true;
2959
+ }
2960
+ }
2961
+ const filterFnCampaign = (c) => {
2962
+ if (shouldNotDisplayIfExcludeAllSponsors(c)) {
2963
+ return false;
2964
+ }
2965
+ else if (!shouldDisplayWithCurrentSponsor(c)) {
2966
+ return false;
2967
+ }
2968
+ /** Active */
2969
+ if (c.formatted_status === 1) {
2970
+ return checkCampaignActiveButExpireAlready(c);
2971
+ }
2972
+ /** Schedule */
2973
+ if (c.formatted_status === 0) {
2974
+ listCampaignScheduled.push(c);
2975
+ return checkCampaignNowInTimeframe(c);
2976
+ }
2977
+ return false;
2978
+ };
2979
+ const fillterApprearanceTimeCampaign = (c) => {
2980
+ var _a;
2981
+ try {
2982
+ const isTimeInRange = (currentTime, startTime, endTime) => {
2983
+ const startParts = startTime.split(':');
2984
+ const endParts = endTime.split(':');
2985
+ const startDate = new Date();
2986
+ startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
2987
+ const endDate = new Date();
2988
+ endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
2989
+ return currentTime >= startDate && currentTime <= endDate;
2990
+ };
2991
+ const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
2992
+ const startTime = rulesApprValue.startTime;
2993
+ const endTime = rulesApprValue.endTime || '23:59';
2994
+ if (!startTime) {
2995
+ return true;
4132
2996
  }
4133
- clearCacheUsedEmailOrPhone();
4134
- }, []);
4135
- const validatingPhoneRef = React.useRef(false);
4136
- const validatingEmailRef = React.useRef(false);
4137
- const { form, validateObj } = useLeadFormConfig({
4138
- listBlockAdded,
4139
- validatingPhoneRef,
4140
- validatingEmailRef,
4141
- campaignId,
4142
- campaign_subot_id,
4143
- userInfo,
4144
- format: (_a = (index$7.ISO_FORMAT[locale] || index$7.ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
4145
- });
4146
- const onFocus = (e) => {
4147
- const target = e.target;
4148
- target.scrollIntoView({
4149
- block: 'center',
4150
- inline: 'nearest',
4151
- behavior: 'auto',
4152
- });
4153
- };
4154
- const middlewareOnSubmit = (e) => {
4155
- e.preventDefault();
4156
- // mark all as touched to allow validation
4157
- const fields = Object.keys(validateObj);
4158
- const fieldStatus = fields.reduce((acc, cur) => {
4159
- acc[cur] = true;
4160
- return acc;
4161
- }, {});
4162
- form.setTouched(fieldStatus);
4163
- if (validatingEmailRef.current || validatingPhoneRef.current) {
4164
- return;
2997
+ if (isTimeInRange(new Date(), startTime, endTime)) {
2998
+ return true;
4165
2999
  }
4166
- setTimeout(() => {
4167
- form.onSubmit((v) => {
4168
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4169
- if (Object.keys(form.errors).length)
4170
- return;
4171
- let newShowOtpPhone = null;
4172
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
4173
- // not submit yet, open otp
4174
- 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;
4175
- if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
4176
- newShowOtpPhone = {
4177
- phone: v[fieldName],
4178
- type: 'phone',
4179
- };
3000
+ listCampaignNotDisplayInRangeOfTime.push(c);
3001
+ return false;
3002
+ }
3003
+ catch (err) {
3004
+ return true;
3005
+ }
3006
+ };
3007
+ let timeoutRef = null;
3008
+ let LEAD_SCROLL_EVENT = null;
3009
+ function clearPassiveEvent() {
3010
+ if (timeoutRef) {
3011
+ clearTimeout(timeoutRef);
3012
+ timeoutRef = null;
3013
+ }
3014
+ if (LEAD_SCROLL_EVENT) {
3015
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3016
+ LEAD_SCROLL_EVENT = null;
3017
+ }
3018
+ }
3019
+ function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
3020
+ // clear previous passive event, check for new condition
3021
+ clearPassiveEvent();
3022
+ const leadCurrentUrl = DEBUG_URL ||
3023
+ ('https://' +
3024
+ location.hostname +
3025
+ location.pathname +
3026
+ location.search).toLowerCase();
3027
+ fetch(leadApi + 'api/campaign/' + leadSiteId, {
3028
+ method: 'POST',
3029
+ headers: {
3030
+ 'Content-Type': 'application/json',
3031
+ },
3032
+ body: JSON.stringify({
3033
+ url: leadCurrentUrl,
3034
+ ga_client_id: miscCookieHelper.getCookie('_ga') || null,
3035
+ }),
3036
+ })
3037
+ .then((response) => {
3038
+ return response.json();
3039
+ // return mockLeadData || response.json()
3040
+ })
3041
+ .then((data) => {
3042
+ var _a, _b, _c, _d;
3043
+ LeadLog('List campagin: ', data);
3044
+ LEAD_RESET_VAR();
3045
+ if (data._status == 1) {
3046
+ 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);
3047
+ if (!miscCookieHelper.getCookie('hhg-id')) {
3048
+ miscCookieHelper.setCookie('hhg-id', uuid.v1(), {
3049
+ domain: '.' + leadDomain,
3050
+ path: '/',
3051
+ });
3052
+ LeadLog('😍 Set HHG ID cookie');
3053
+ }
3054
+ // getCookie('hhg-id')
3055
+ // TODO: HP-534 Filter desktop
3056
+ let campaignsDevice = [];
3057
+ if (isMobile()) {
3058
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
3059
+ }
3060
+ else {
3061
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
3062
+ }
3063
+ LeadLog(`👓 campaignsDevice`, campaignsDevice);
3064
+ LeadLog('--listCampaignScheduled', listCampaignScheduled);
3065
+ LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
3066
+ LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
3067
+ LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
3068
+ LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
3069
+ LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
3070
+ // Check links
3071
+ let listLinksObj = campaignsDevice
3072
+ .map((i, index) => i.targets
3073
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
3074
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3075
+ .flat(1);
3076
+ // Check list link match current href
3077
+ listLinksObj = listLinksObj.filter((i) => {
3078
+ var _a;
3079
+ const target = new URL(String(i.target).toLowerCase());
3080
+ if (i.option == 'exact_match')
3081
+ // FOR TEST LOCAL:
3082
+ // return Boolean(location.pathname === target.pathname)
3083
+ return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
3084
+ if (i.option == 'start_with') {
3085
+ // FOR TEST LOCAL:
3086
+ // if (location.pathname.includes(target.pathname)) {
3087
+ if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
3088
+ const listExcluding = i.sub_target
3089
+ .filter((i) => i.option == 'excluding')
3090
+ .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
3091
+ return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
4180
3092
  }
4181
- }
4182
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
4183
- // not submit yet, open otp
4184
- 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;
4185
- if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
4186
- newShowOtpPhone = {
4187
- phone: v[fieldName],
4188
- type: 'whatsapp',
4189
- };
3093
+ else {
3094
+ return false;
4190
3095
  }
4191
3096
  }
4192
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
4193
- // not submit yet, open otp
4194
- 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;
4195
- if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
4196
- newShowOtpPhone = {
4197
- phone: v[fieldName],
4198
- type: 'zalo',
4199
- };
4200
- }
3097
+ });
3098
+ // Check tags
3099
+ const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
3100
+ const listTags = listMetaTag.map((i) => i.content);
3101
+ let listCampaignHasTag = [];
3102
+ let listTagsObj = [];
3103
+ if (listTags && listTags.length) {
3104
+ listCampaignHasTag = campaignsDevice
3105
+ .map((i, index) => i.targets
3106
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
3107
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3108
+ .flat(1);
3109
+ listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
3110
+ }
3111
+ const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
3112
+ const cookieKeys = document.cookie
3113
+ .split('; ')
3114
+ .map((i) => i.split('=')[0]);
3115
+ const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
3116
+ LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
3117
+ const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
3118
+ LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
3119
+ const listCampaignSubmitedClosed = [
3120
+ ...listCampaignCodeSubmited,
3121
+ ...listCampaignCodeClosed,
3122
+ ];
3123
+ const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
3124
+ const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
3125
+ return !hasSubmited;
3126
+ });
3127
+ const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
3128
+ // .sort(
3129
+ // (a, b) =>
3130
+ // (listCampaignValid[a.campaignIndex]?.score || 0) -
3131
+ // (listCampaignValid[b.campaignIndex]?.score || 0),
3132
+ // )
3133
+ LeadLog('--listCampaignValid : ', listCampaignValid);
3134
+ if (listCampaignValid && listCampaignValid.length) {
3135
+ const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
3136
+ LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
3137
+ const { rules } = CAMPAIGN_SHOW;
3138
+ // CHECK RULE TRIGGER POPUP
3139
+ const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
3140
+ LeadLog(`timeoutRule`, timeoutRule);
3141
+ const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
3142
+ LeadLog(`scrollRule`, scrollRule);
3143
+ let impressionAction = 'TIME';
3144
+ if (Number.isInteger(timeoutRule)) {
3145
+ impressionAction = 'TIME';
3146
+ LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
3147
+ timeoutRef = setTimeout(() => {
3148
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3149
+ }, timeoutRule * 1000);
4201
3150
  }
4202
- if (newShowOtpPhone) {
4203
- setIsSubmitLoading(true);
4204
- Service.sendSMSOtpLead(newShowOtpPhone)
4205
- .then((res) => {
4206
- var _a;
4207
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4208
- if (respMessage === 'This phone number was verified') {
4209
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4210
- return;
3151
+ if (Number.isInteger(scrollRule)) {
3152
+ impressionAction = 'SCROLL';
3153
+ LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
3154
+ const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
3155
+ document.querySelector('body');
3156
+ const pct = $p.getBoundingClientRect().top;
3157
+ const pb = $p.offsetHeight;
3158
+ LeadLog(`👓 Element check scroll: `, $p);
3159
+ LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
3160
+ const wt = window.pageYOffset || document.documentElement.scrollTop;
3161
+ let percent = 0;
3162
+ if (wt >= pct) {
3163
+ percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
4211
3164
  }
4212
- setShowOtpPhone(newShowOtpPhone);
4213
- })
4214
- .finally(() => {
4215
- setIsSubmitLoading(false);
3165
+ LeadLog('---Scroll', percent, scrollRule);
3166
+ // TODO: CHECK FOOTER HEIGHT
3167
+ if (percent >= scrollRule) {
3168
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3169
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3170
+ }
3171
+ };
3172
+ window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
3173
+ passive: true,
4216
3174
  });
4217
- return;
4218
3175
  }
4219
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4220
- })(e);
4221
- }, 100);
4222
- };
4223
- const onOpenChange = (_open) => {
4224
- setOpen(_open);
4225
- if (!_open) {
4226
- setTimeout(() => {
4227
- onClose();
4228
- }, 250);
4229
- }
4230
- };
4231
- const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
4232
- const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
4233
- const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
4234
- const renderAfterImageSizes = imageMobileLoaded &&
4235
- imageDesktopLoaded &&
4236
- (isFullscreen ? imageBackgroundLoaded : true);
4237
- const ButtonSubmit = React.useMemo(() => {
4238
- var _a;
4239
- return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default["default"].createElement(core.Button, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
4240
- }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
4241
- const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
4242
- const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default["default"].createElement(React__default["default"].Fragment, null, LinkButtonBlock.map((item, index) => {
4243
- var _a, _b, _c;
4244
- return (React__default["default"].createElement(core.Button, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", onClick: () => {
4245
- onClose === null || onClose === void 0 ? void 0 : onClose();
4246
- onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
4247
- } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
4248
- })));
4249
- const PopupHeader = showHeader && (React__default["default"].createElement("header", { className: core.clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default["default"].createElement(React__default["default"].Fragment, null,
4250
- React__default["default"].createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
4251
- React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
4252
- const PopupEmpty = showEmpty && (React__default["default"].createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
4253
- const PopupForm = (React__default["default"].createElement(LeadFormProvider, { form: form },
4254
- React__default["default"].createElement("form", { ref: formRef, className: "leadgen-form", onFocus: onFocus, onSubmit: middlewareOnSubmit },
4255
- React__default["default"].createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
4256
- React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4257
- React__default["default"].createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
4258
- const PopupOtp = showOtpPhone && (React__default["default"].createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
4259
- setShowOtpPhone(null);
4260
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
4261
- } }));
4262
- const PopupThankYou = showThankyou && (React__default["default"].createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
4263
- const PopupContent = (React__default["default"].createElement("div", { className: core.clsx('leadgen-content', {
4264
- 'leadgen-content_small': limitFieldsLightBoxB,
4265
- }) },
4266
- !headerInsideFormContainer && PopupHeader,
4267
- !onlyHeader && (React__default["default"].createElement("div", { className: "leadgen-inner" },
4268
- PopupThankYou,
4269
- !showThankyou && (React__default["default"].createElement(React__default["default"].Fragment, null,
4270
- PopupOtp,
4271
- PopupEmpty,
4272
- !(showOtpPhone || showEmpty) && PopupForm))))));
4273
- const styleOverlay = React.useMemo(() => {
4274
- let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
4275
- if (isMobile && imageOverlayMobile) {
4276
- styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4277
- }
4278
- if (!isMobile && imageOverlayDesktop) {
4279
- styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
3176
+ }
3177
+ else {
3178
+ LeadLog('🚧 No lead campaigns on current URL, tags');
3179
+ }
4280
3180
  }
4281
- return styleContent;
4282
- }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
4283
- const PopupWrapper = (React__default["default"].createElement(React__default["default"].Fragment, null,
4284
- React__default["default"].createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
4285
- React__default["default"].createElement("div", { className: core.clsx('leadgen-wrapper', {
4286
- 'leadgen-wrapper_small': limitFieldsLightBoxB,
4287
- }) },
4288
- showButtonClose && (React__default["default"].createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
4289
- PopupContent)));
4290
- const popupContainerClassName = core.clsx('leadgen', `leadgen-${currentLayout}`, {
4291
- 'leadgen-lightbox': isLightBox,
4292
- 'leadgen-inline': isInPage,
4293
- 'leadgen-slider': isSlider,
3181
+ })
3182
+ .catch((err) => {
3183
+ LeadLog(`Lead error: `, err);
4294
3184
  });
4295
- const PopupContainer = isDrawer ? (React__default["default"].createElement(index$a.DrawerComponent, { fadeFromIndex: index$7.ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
4296
- PopupWrapper,
4297
- React__default["default"].createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default["default"].createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
4298
- isFullscreen ? (React__default["default"].createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
4299
- aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
4300
- } })) : null,
4301
- PopupWrapper));
4302
- if (!renderAfterImageSizes)
4303
- return null;
4304
- if (isLightBox || isFullscreen || isSlider) {
4305
- return PopupContainer;
4306
- }
4307
- else if (isSidebar) {
4308
- return React__default["default"].createElement(SideBarLayout, { content: PopupContainer });
4309
- }
4310
- else if (isInline) {
4311
- return (React__default["default"].createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
3185
+ }
3186
+ const LeadLog = (...params) => {
3187
+ if (process.env.NODE_ENV !== 'production' ||
3188
+ (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
3189
+ process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
3190
+ (typeof localStorage !== 'undefined' &&
3191
+ localStorage.getItem('hhg_debug') === 'true')) {
3192
+ console.log(...params);
4312
3193
  }
4313
- return null;
4314
- };
4315
-
4316
- const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
4317
- const currentPath = location.pathname;
4318
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
4319
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
4320
- if (!imageMobileLoaded || !imageDesktopLoaded)
4321
- return null;
4322
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
4323
- currentLayout == 'SkinA' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4324
- React__default["default"].createElement("div", { className: "le-skin-a-desktop" },
4325
- React__default["default"].createElement("div", { style: { position: 'relative' } },
4326
- React__default["default"].createElement("img", { src: imageDesktop, style: {
4327
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4328
- } }),
4329
- React__default["default"].createElement("a", { style: {
4330
- position: 'absolute',
4331
- top: '75%',
4332
- left: '50%',
4333
- transform: 'translate(-50%, -50%)',
4334
- textAlign: 'center',
4335
- width: 'calc(100% - 15px)',
4336
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4337
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
4338
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4339
- React__default["default"].createElement("div", { className: "" },
4340
- React__default["default"].createElement("div", { style: { position: 'relative', zIndex: 10000 } },
4341
- React__default["default"].createElement("img", { src: imageDesktop, style: {
4342
- width: '100%',
4343
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4344
- } }),
4345
- React__default["default"].createElement("a", { style: {
4346
- position: 'absolute',
4347
- top: '75%',
4348
- left: '50%',
4349
- transform: 'translate(-50%, -50%)',
4350
- textAlign: 'center',
4351
- width: '100%',
4352
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4353
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4354
- React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
4355
- React__default["default"].createElement("aside", { className: "le-only-mobile" },
4356
- React__default["default"].createElement("div", { className: "le-skin-mobile" },
4357
- React__default["default"].createElement("div", { style: { position: 'relative' } },
4358
- index$8.isVideo(imageMobile) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true },
4359
- React__default["default"].createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default["default"].createElement("img", { src: imageMobile, style: {
4360
- width: '100%',
4361
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
4362
- } })),
4363
- React__default["default"].createElement("a", { style: {
4364
- position: 'absolute',
4365
- top: '82%',
4366
- left: '50%',
4367
- transform: 'translate(-50%, -50%)',
4368
- textAlign: 'center',
4369
- maxWidth: 'calc(100% - 15px)',
4370
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4371
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4372
- React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4373
- };
4374
-
4375
- // url: imageBlocks.imageMobile.data.url
4376
- // newTab: imageBlocks.imageMobile.data.newtab
4377
- // image: campaignShow.image
4378
- // imageDestkop: campaignShow.image_desktop
4379
- const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
4380
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
4381
- if (!imageLoaded)
4382
- return null;
4383
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
4384
- React__default["default"].createElement("div", { className: "le-tab-popup" },
4385
- React__default["default"].createElement("div", { style: { position: 'relative' } },
4386
- React__default["default"].createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
4387
- React__default["default"].createElement("img", { className: "js-popup-other-submit", src: image, style: {
4388
- aspectRatio: `${imageWidth}/${imageHeight}`,
4389
- } })),
4390
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
4391
3194
  };
4392
3195
 
4393
3196
  function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
@@ -4403,7 +3206,7 @@ function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
4403
3206
  }
4404
3207
  const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, showEmpty, setShowEmpty, userInfo, }) => {
4405
3208
  var _a, _b;
4406
- const { apiUrl, siteDomain } = React.useContext(LeadGenContext$1);
3209
+ const { apiUrl, siteDomain } = React.useContext(LeadGenContext);
4407
3210
  React.useEffect(() => {
4408
3211
  const gaCookie = miscCookieHelper.getCookie('_ga') || null;
4409
3212
  fetch(`${apiUrl}api/campaign/${code}/impression`, {
@@ -4529,7 +3332,7 @@ const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, local
4529
3332
  };
4530
3333
 
4531
3334
  // mount css
4532
- const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl, DEBUG_URL, forceCampaign, children, extraPayloadValues = [], excludeExitRulesHandler, userInfo, onClose: onCloseProps, }) => {
3335
+ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, primaryColor, apiSubotUrl, DEBUG_URL, forceCampaign, children, extraPayloadValues = [], excludeExitRulesHandler, userInfo, onClose: onCloseProps, }) => {
4533
3336
  var _a;
4534
3337
  const scrollEventHandlerRef = React.useRef();
4535
3338
  const leadStartTimeRef = React.useRef(Date.now());
@@ -4798,7 +3601,7 @@ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl,
4798
3601
  leadStartTimeRef.current = Date.now();
4799
3602
  }
4800
3603
  }, [showCampaign]);
4801
- return (React__default["default"].createElement(LeadGenContext$1.Provider, { value: { apiUrl, siteDomain, siteId, locale } },
3604
+ return (React__default["default"].createElement(LeadGenContext.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
4802
3605
  React__default["default"].createElement(translationsContext.TranslationsContext.Provider, { value: { locale, values: getTranslations(locale) } }, children ? (React__default["default"].createElement(Component, { campaign: showCampaign, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, setShowThankyou: setShowThankyou, locale: locale, showEmpty: showEmpty, setShowEmpty: setShowEmpty, userInfo: userInfo }, children)) : (React__default["default"].createElement(core.Portal, { target: utils$1.getPopupWrapperDom() },
4803
3606
  React__default["default"].createElement(core.Box, { sx: { position: 'fixed', zIndex: index$7.ZINDEX_SSO - 9e6 } },
4804
3607
  React__default["default"].createElement(core.Transition, { mounted: Boolean(((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1'), transition: "fade", duration: 600, timingFunction: "ease" }, (styles) => {
@@ -4819,4 +3622,3 @@ LeadGen.OtpForm = OtpBlock$1;
4819
3622
  LeadGen.Close = Close.Close;
4820
3623
 
4821
3624
  exports.LeadGen = LeadGen;
4822
- exports.LeadGenSubscriptionBox = LeadGenSubscriptionBox;