@hhgtech/hhg-components 1.29.374-beta-1 → 1.29.374

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 (539) hide show
  1. package/build/{InputDate-27f75a17.js → InputDate-8b579da2.js} +3 -3
  2. package/build/{LastPeriod-9df97187.js → LastPeriod-64e1601a.js} +1 -1
  3. package/build/{Locale-ab6a6ba4.js → Locale-72dce976.js} +0 -1
  4. package/build/{MobileBottomNavigationIcon-96a68780.js → MobileBottomNavigationIcon-d51ca59a.js} +3 -3
  5. package/build/{Spinner-aa4dd99c.js → Spinner-883e6f71.js} +1 -1
  6. package/build/{WhatsApp-9903ef96.js → WhatsApp-52413156.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-0bcb9891.js → constants-171f25c7.js} +0 -1
  18. package/build/{constants-7f234d99.js → constants-4fc45016.js} +1 -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-c24db88c.js → core-49c30866.js} +1 -1
  24. package/build/{dataTransform-049d8098.js → dataTransform-9fcb6f21.js} +1 -1
  25. package/build/ecom.js +4 -4
  26. package/build/{editor-6fe7a5a0.js → editor-f38876f9.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-53408741.js → InputDate-86cf8a56.js} +3 -3
  37. package/build/esm/{LastPeriod-7572677e.js → LastPeriod-f7751d88.js} +1 -1
  38. package/build/esm/{Locale-2def755e.js → Locale-3430abbb.js} +0 -1
  39. package/build/esm/{MobileBottomNavigationIcon-3333d468.js → MobileBottomNavigationIcon-9c8475b0.js} +3 -3
  40. package/build/esm/{Spinner-2e9210e6.js → Spinner-926cb3b3.js} +1 -1
  41. package/build/esm/{WhatsApp-be4e850b.js → WhatsApp-e29f71ae.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-42ff2492.js → constants-030b17c7.js} +1 -1
  53. package/build/esm/{constants-c405c24a.js → constants-8772c2b0.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-dc68adaf.js → core-55455f88.js} +1 -1
  59. package/build/esm/{dataTransform-183320e7.js → dataTransform-a7848bdc.js} +1 -1
  60. package/build/esm/ecom.js +4 -4
  61. package/build/esm/{editor-d1af996e.js → editor-377b7f2b.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-3d480046.js → healthTools-6ff083fc.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-56d4c7d5.js → index-06d394fc.js} +3 -3
  80. package/build/esm/{index-8fe7951c.js → index-0ab75d88.js} +5 -5
  81. package/build/esm/{index-0e386ca4.js → index-0f5789ca.js} +16 -16
  82. package/build/esm/{index-410551f4.js → index-109382ee.js} +1 -1
  83. package/build/esm/{index-b01bed06.js → index-130576cd.js} +16 -16
  84. package/build/esm/{index-8d30046e.js → index-17e36457.js} +8 -8
  85. package/build/esm/{index-224abae7.js → index-22f111d6.js} +3 -3
  86. package/build/esm/{index-de4012d5.js → index-2f124f3f.js} +6 -6
  87. package/build/esm/{index-b472c383.js → index-32060de3.js} +16 -16
  88. package/build/esm/{index-bd6288c0.js → index-33c4c7ba.js} +13 -13
  89. package/build/esm/{index-54de0535.js → index-35c4c26f.js} +2 -39
  90. package/build/esm/{index-d8aea1c6.js → index-36da89a1.js} +1 -1
  91. package/build/esm/{index-510b91b2.js → index-3784dc8c.js} +17 -17
  92. package/build/esm/{index-bedd68c7.js → index-395867d1.js} +1 -1
  93. package/build/esm/{index-d5dfbc30.js → index-44df64aa.js} +2 -2
  94. package/build/esm/{index-1b7e37bd.js → index-4bd46b7f.js} +2 -2
  95. package/build/esm/{index-0e17355b.js → index-4c29da01.js} +6 -6
  96. package/build/esm/{index-eb330fed.js → index-4cc74b63.js} +32 -32
  97. package/build/esm/{index-060e9629.js → index-4dbdcc4c.js} +24 -24
  98. package/build/esm/{index-1bd62005.js → index-4f84ba27.js} +18 -18
  99. package/build/esm/{index-53e72c1e.js → index-5024511e.js} +2 -2
  100. package/build/esm/{index-4d7b2bc3.js → index-5131dc4f.js} +3 -3
  101. package/build/esm/{index-5535a0d5.js → index-528169fe.js} +16 -16
  102. package/build/esm/{index-6c64fa7c.js → index-5d7077d8.js} +2 -2
  103. package/build/esm/{index-1b46ae3f.js → index-5e9df0aa.js} +2 -2
  104. package/build/esm/{index-eea13537.js → index-5ff6b134.js} +2 -2
  105. package/build/esm/{index-0d9a1b8c.js → index-6ab5e856.js} +1 -1
  106. package/build/esm/{index-dbed3a12.js → index-7287f2a0.js} +5 -5
  107. package/build/esm/{index-ccd54316.js → index-782b32b4.js} +3 -3
  108. package/build/esm/{index-5afaa486.js → index-7911d60e.js} +2 -2
  109. package/build/esm/{index-5ab20a03.js → index-7b524555.js} +6 -6
  110. package/build/esm/{index-67bb06d6.js → index-7f0089a7.js} +3 -3
  111. package/build/esm/{index-ac1dc7b5.js → index-7f3a0d51.js} +13 -13
  112. package/build/esm/{index-56f8b83d.js → index-7f79d78c.js} +2 -2
  113. package/build/esm/{index-e2520675.js → index-82254ae8.js} +25 -25
  114. package/build/esm/{index-16fae63d.js → index-8885ef87.js} +6 -6
  115. package/build/esm/{index-fbe17b79.js → index-8b71f3d7.js} +17 -17
  116. package/build/esm/{index-d30ed987.js → index-8bc9ae7d.js} +2 -2
  117. package/build/esm/{index-2c1db9ad.js → index-8c227289.js} +32 -32
  118. package/build/esm/{index-9ce105df.js → index-8e302f71.js} +1 -1
  119. package/build/esm/{index-2794e74a.js → index-94da713d.js} +17 -17
  120. package/build/esm/{index-15cbeea2.js → index-9506572a.js} +10 -10
  121. package/build/esm/{index-4665f512.js → index-9688c45f.js} +7 -7
  122. package/build/esm/{index-4e2139dc.js → index-9a682965.js} +1 -1
  123. package/build/esm/{index-55d4a57f.js → index-9d456ced.js} +13 -13
  124. package/build/esm/{index-7f282951.js → index-aa92750f.js} +7 -7
  125. package/build/esm/{index-27730dc3.js → index-adf83539.js} +21 -21
  126. package/build/esm/{index-17165c22.js → index-bae2d2e9.js} +31 -31
  127. package/build/esm/{index-f0fbcf39.js → index-bfafe3e9.js} +17 -17
  128. package/build/esm/{index-b78bcf84.js → index-c22c8c9f.js} +15 -15
  129. package/build/esm/{index-1603823c.js → index-c315fa6b.js} +2 -2
  130. package/build/esm/{index-a7b5b3da.js → index-cb2ab6ff.js} +2 -2
  131. package/build/esm/{index-1f21ae1e.js → index-cd820271.js} +4 -4
  132. package/build/esm/{index-adc4f674.js → index-d25199d4.js} +1 -1
  133. package/build/esm/{index-921553c7.js → index-e1c1652c.js} +3 -3
  134. package/build/esm/{index-94c7ee4b.js → index-e401fea0.js} +1 -1
  135. package/build/esm/{index-a1ae0a50.js → index-e93b1f65.js} +27 -36
  136. package/build/esm/{index-10620223.js → index-edae0b9e.js} +2 -2
  137. package/build/esm/{index-adf2bd5f.js → index-f410871a.js} +1 -1
  138. package/build/esm/{index-e274fd81.js → index-f437d7d3.js} +22 -22
  139. package/build/esm/{index-202a8ced.js → index-f4607daa.js} +2 -2
  140. package/build/esm/{index-3ed1535e.js → index-f5a27fa1.js} +13 -13
  141. package/build/esm/{index-0abc03cd.js → index-f9d0d6be.js} +6 -6
  142. package/build/esm/{index-d5affca6.js → index-fd64f3e1.js} +18 -18
  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-903c9ace.js → labelSorting-ad695303.js} +4 -4
  149. package/build/esm/lead/helpers.d.ts +1 -56
  150. package/build/esm/lead/index.d.ts +1 -2
  151. package/build/esm/lead/services/index.d.ts +0 -19
  152. package/build/esm/lead/store/index.d.ts +0 -1
  153. package/build/esm/lead.js +984 -2120
  154. package/build/esm/{logoIcon-fdb7619c.js → logoIcon-3352527f.js} +2 -8
  155. package/build/esm/mantine.js +25 -25
  156. package/build/esm/misc.js +17 -17
  157. package/build/esm/miscGetDynamicHealthTool.js +4 -4
  158. package/build/esm/miscGetSocialList.js +8 -8
  159. package/build/esm/miscScreenSizeContext.js +1 -1
  160. package/build/esm/mobileBottomNavigation.js +5 -5
  161. package/build/esm/mobileBottomNavigationIcon.js +5 -5
  162. package/build/esm/molecules.js +73 -73
  163. package/build/esm/moleculesArticleCard.js +6 -6
  164. package/build/esm/moleculesArticleCardV2.js +16 -16
  165. package/build/esm/navigation.js +45 -45
  166. package/build/esm/navigationLogoutPopup.js +9 -9
  167. package/build/esm/navigationProfileButton.js +23 -23
  168. package/build/esm/onboardingV2.js +29 -29
  169. package/build/esm/organisms.js +49 -49
  170. package/build/esm/{post-d812dde9.js → post-062dce48.js} +2 -2
  171. package/build/esm/profileNavigation.js +19 -19
  172. package/build/esm/progressBar.js +1 -1
  173. package/build/esm/pwg.js +22 -22
  174. package/build/esm/ssoV2/api/featureFlag.d.ts +1 -2
  175. package/build/esm/ssoV2.js +39 -51
  176. package/build/esm/{store-ffd867c4.js → store-0f9ab222.js} +4 -4
  177. package/build/esm/subot.js +35 -35
  178. package/build/esm/surveyOrPremiumBanner.js +32 -32
  179. package/build/esm/surveyQuestionCard.js +10 -10
  180. package/build/esm/{surveyThankyouCard-6362dc3c.js → surveyThankyouCard-ba3a0601.js} +5 -5
  181. package/build/esm/together.js +55 -55
  182. package/build/esm/togetherApiUtils.js +4 -4
  183. package/build/esm/togetherAtoms.js +30 -30
  184. package/build/esm/togetherComponentGlobalContext.js +4 -4
  185. package/build/esm/togetherMolecules.js +50 -50
  186. package/build/esm/togetherMoleculesCardAuthor.js +28 -28
  187. package/build/esm/togetherMoleculesPostImagePreview.js +11 -11
  188. package/build/esm/togetherMoleculesProfileDetail.js +38 -38
  189. package/build/esm/togetherOrganisms.js +49 -49
  190. package/build/esm/togetherRichTextEditor.js +17 -17
  191. package/build/esm/togetherShareBox.js +10 -10
  192. package/build/esm/{treePopoverMenu-03480736.js → treePopoverMenu-a6f7cfd7.js} +19 -19
  193. package/build/esm/{types-4b072730.js → types-2e97f020.js} +2 -2
  194. package/build/esm/types.js +2 -2
  195. package/build/esm/{useCategory-1d58b7de.js → useCategory-a57e6557.js} +5 -18
  196. package/build/esm/{useHealthToolCache-8e65e4cc.js → useHealthToolCache-50ac5d7d.js} +1 -1
  197. package/build/esm/{useMantineLocale-2ddd0d66.js → useMantineLocale-ee478730.js} +6 -8
  198. package/build/esm/{usePlacesAutocomplete-1451c491.js → usePlacesAutocomplete-119a12f3.js} +1 -1
  199. package/build/esm/{useScreenSize-b097bc99.js → useScreenSize-241e66fa.js} +2 -2
  200. package/build/esm/useTogetherAuthRequiredAction.js +9 -9
  201. package/build/esm/{utils-837a98c2.js → utils-02789711.js} +2 -2
  202. package/build/esm/{utils-a6705915.js → utils-5c250b28.js} +3 -3
  203. package/build/esm/{utils-3ff75edd.js → utils-84d5275f.js} +2 -2
  204. package/build/esm/{utils-9d061cb4.js → utils-d81142cf.js} +4 -4
  205. package/build/esm/vaccination.js +21 -21
  206. package/build/footer.js +21 -21
  207. package/build/gAssets.js +2 -2
  208. package/build/{healthTools-5675769e.js → healthTools-257131be.js} +1 -1
  209. package/build/healthToolsCardWrapper.js +18 -18
  210. package/build/healthToolsForm.js +33 -33
  211. package/build/hooks.js +13 -13
  212. package/build/i18n.js +56 -16
  213. package/build/i18nV2.js +1 -1
  214. package/build/{index-56574883.js → index-0186561a.js} +2 -2
  215. package/build/{index-517f6f16.js → index-02e6761f.js} +25 -25
  216. package/build/{index-c7b52682.js → index-09ddce9c.js} +21 -21
  217. package/build/{index-b755d36a.js → index-1ac4d980.js} +1 -1
  218. package/build/{index-d68d726d.js → index-1c320bad.js} +32 -32
  219. package/build/{index-8cc5aaf4.js → index-1c3321c1.js} +17 -17
  220. package/build/{index-a9122b6e.js → index-23006a6f.js} +1 -1
  221. package/build/{index-8e928040.js → index-2a96defb.js} +5 -5
  222. package/build/{index-4ba367d3.js → index-2d635a20.js} +2 -2
  223. package/build/{index-1cbd6748.js → index-2edc6f4f.js} +2 -2
  224. package/build/{index-8807a628.js → index-2fc43b51.js} +16 -16
  225. package/build/{index-706cdb42.js → index-31c0299e.js} +6 -6
  226. package/build/{index-c0efb13b.js → index-3484373a.js} +6 -6
  227. package/build/{index-3f648346.js → index-4026f890.js} +2 -2
  228. package/build/{index-5978843f.js → index-41529ab9.js} +3 -3
  229. package/build/{index-23e996bf.js → index-46713f6a.js} +2 -2
  230. package/build/{index-5c38e2bd.js → index-467dfe87.js} +1 -1
  231. package/build/{index-f68b6b94.js → index-4c99f21d.js} +3 -3
  232. package/build/{index-67fb3969.js → index-5671b247.js} +8 -8
  233. package/build/{index-737372f7.js → index-582068c8.js} +2 -2
  234. package/build/{index-8721dda0.js → index-5e7301a8.js} +15 -15
  235. package/build/{index-3e668daf.js → index-6f08804a.js} +2 -2
  236. package/build/{index-d0820aeb.js → index-78dac42f.js} +27 -36
  237. package/build/{index-0a1ac489.js → index-7e3fcc69.js} +6 -6
  238. package/build/{index-90c35133.js → index-7e9b8b61.js} +7 -7
  239. package/build/{index-2644ecd5.js → index-809fab5e.js} +2 -2
  240. package/build/{index-68ca2ec6.js → index-815de854.js} +32 -32
  241. package/build/{index-d74b605a.js → index-81db4a5e.js} +2 -2
  242. package/build/{index-42af3733.js → index-8298c7c0.js} +2 -2
  243. package/build/{index-ee1dd2b5.js → index-8b1dc163.js} +16 -16
  244. package/build/{index-058de55a.js → index-8e6eaed0.js} +22 -22
  245. package/build/{index-a10c0c62.js → index-9074450c.js} +3 -3
  246. package/build/{index-d4b12903.js → index-9164c2ee.js} +3 -3
  247. package/build/{index-729572c2.js → index-9e639be2.js} +1 -1
  248. package/build/{index-b5cf12ac.js → index-a8c0fe3b.js} +18 -18
  249. package/build/{index-2fd62012.js → index-aad65709.js} +13 -13
  250. package/build/{index-fe818695.js → index-b043d722.js} +2 -2
  251. package/build/{index-4ca26ec6.js → index-b3a4afc0.js} +3 -3
  252. package/build/{index-f425dec1.js → index-b99eceae.js} +1 -1
  253. package/build/{index-4ec0821f.js → index-bab54ae7.js} +1 -1
  254. package/build/{index-7523372e.js → index-bfce43a1.js} +17 -17
  255. package/build/{index-9ab7ef60.js → index-c1e14fd6.js} +24 -24
  256. package/build/{index-64618042.js → index-c3b2d3a2.js} +4 -4
  257. package/build/{index-965b5561.js → index-c4266bb2.js} +5 -5
  258. package/build/{index-01f31cb8.js → index-ca0ff3c8.js} +13 -13
  259. package/build/{index-e7218beb.js → index-cc03a162.js} +6 -6
  260. package/build/{index-e1a7b1ce.js → index-d0a87c80.js} +1 -1
  261. package/build/{index-84b1400f.js → index-d0da1009.js} +2 -2
  262. package/build/{index-3278247e.js → index-d0fc83cb.js} +10 -10
  263. package/build/{index-8e3127cf.js → index-d5392642.js} +2 -2
  264. package/build/{index-131cf2b6.js → index-d86255ae.js} +7 -7
  265. package/build/{index-0b32faf6.js → index-da1f328c.js} +16 -16
  266. package/build/{index-9783335b.js → index-da4de0f3.js} +13 -13
  267. package/build/{index-2a3051c7.js → index-de274432.js} +17 -17
  268. package/build/{index-702577b3.js → index-dec3d9e5.js} +18 -18
  269. package/build/{index-523e7e4d.js → index-df8845e8.js} +2 -39
  270. package/build/{index-ebe2c303.js → index-e0986c73.js} +13 -13
  271. package/build/{index-6d0d6307.js → index-e0b64996.js} +16 -16
  272. package/build/{index-424296a4.js → index-e25c397c.js} +3 -3
  273. package/build/{index-23f5de35.js → index-e7f3329c.js} +31 -31
  274. package/build/{index-734405be.js → index-f30c6c68.js} +17 -17
  275. package/build/{index-2555df32.js → index-f757576d.js} +1 -1
  276. package/build/{index-1d84b42c.js → index-f8156707.js} +6 -6
  277. package/build/{index-01674c9d.js → index-ff5393e0.js} +1 -1
  278. package/build/index.js +117 -117
  279. package/build/interfaces/constants/domainLocales.d.ts +0 -2
  280. package/build/interfaces/constants/index.d.ts +1 -1
  281. package/build/interfaces/types/Locale.d.ts +1 -2
  282. package/build/interfaces/types/index.d.ts +1 -2
  283. package/build/{labelSorting-1c7cee93.js → labelSorting-f5b88779.js} +4 -4
  284. package/build/lead/helpers.d.ts +1 -56
  285. package/build/lead/index.d.ts +1 -2
  286. package/build/lead/services/index.d.ts +0 -19
  287. package/build/lead/store/index.d.ts +0 -1
  288. package/build/lead.js +997 -2134
  289. package/build/{logoIcon-0adc172c.js → logoIcon-d87f0c7c.js} +2 -8
  290. package/build/mantine.js +22 -22
  291. package/build/misc.js +17 -17
  292. package/build/miscGetDynamicHealthTool.js +4 -4
  293. package/build/miscGetSocialList.js +8 -8
  294. package/build/miscScreenSizeContext.js +1 -1
  295. package/build/mobileBottomNavigation.js +5 -5
  296. package/build/mobileBottomNavigationIcon.js +5 -5
  297. package/build/molecules.js +73 -73
  298. package/build/moleculesArticleCard.js +6 -6
  299. package/build/moleculesArticleCardV2.js +16 -16
  300. package/build/navigation.js +45 -45
  301. package/build/navigationLogoutPopup.js +9 -9
  302. package/build/navigationProfileButton.js +23 -23
  303. package/build/onboardingV2.js +28 -28
  304. package/build/organisms.js +49 -49
  305. package/build/{post-9e59e11b.js → post-7ad0e276.js} +2 -2
  306. package/build/profileNavigation.js +19 -19
  307. package/build/progressBar.js +1 -1
  308. package/build/pwg.js +22 -22
  309. package/build/ssoV2/api/featureFlag.d.ts +1 -2
  310. package/build/ssoV2.js +37 -49
  311. package/build/{store-f6379c86.js → store-ff958ae7.js} +4 -4
  312. package/build/subot.js +34 -34
  313. package/build/surveyOrPremiumBanner.js +32 -32
  314. package/build/surveyQuestionCard.js +10 -10
  315. package/build/{surveyThankyouCard-24135968.js → surveyThankyouCard-e8976fd5.js} +5 -5
  316. package/build/together.js +55 -55
  317. package/build/togetherApiUtils.js +4 -4
  318. package/build/togetherAtoms.js +30 -30
  319. package/build/togetherComponentGlobalContext.js +4 -4
  320. package/build/togetherMolecules.js +50 -50
  321. package/build/togetherMoleculesCardAuthor.js +28 -28
  322. package/build/togetherMoleculesPostImagePreview.js +11 -11
  323. package/build/togetherMoleculesProfileDetail.js +38 -38
  324. package/build/togetherOrganisms.js +49 -49
  325. package/build/togetherRichTextEditor.js +17 -17
  326. package/build/togetherShareBox.js +10 -10
  327. package/build/{treePopoverMenu-d6e8372b.js → treePopoverMenu-11d8a3c3.js} +19 -19
  328. package/build/{types-26ce9ce5.js → types-da86b25c.js} +2 -2
  329. package/build/types.js +2 -2
  330. package/build/{useCategory-941ff45e.js → useCategory-8a7dc9fd.js} +5 -18
  331. package/build/{useHealthToolCache-068e5649.js → useHealthToolCache-0d055a47.js} +1 -1
  332. package/build/{useMantineLocale-d74729a8.js → useMantineLocale-a330a7e5.js} +6 -8
  333. package/build/{usePlacesAutocomplete-c3a05472.js → usePlacesAutocomplete-14098979.js} +1 -1
  334. package/build/{useScreenSize-805ef787.js → useScreenSize-2eae68ef.js} +2 -2
  335. package/build/useTogetherAuthRequiredAction.js +9 -9
  336. package/build/{utils-a70ced06.js → utils-192df9f4.js} +3 -3
  337. package/build/{utils-2d4e6ea6.js → utils-7d98be3c.js} +2 -2
  338. package/build/{utils-914af569.js → utils-c88507b9.js} +2 -2
  339. package/build/{utils-22163cc9.js → utils-d104096a.js} +4 -4
  340. package/build/vaccination.js +21 -21
  341. package/package.json +3 -3
  342. package/build/components/mantine/phoneInput/PhoneInput.d.ts +0 -17
  343. package/build/components/mantine/phoneInput/index.d.ts +0 -1
  344. package/build/esm/components/mantine/phoneInput/PhoneInput.d.ts +0 -17
  345. package/build/esm/components/mantine/phoneInput/index.d.ts +0 -1
  346. package/build/esm/i18n-values/zh-CN.js +0 -855
  347. package/build/esm/lead/LeadGen.type.d.ts +0 -31
  348. package/build/esm/lead/LeadGenForm/LeadGenForm.d.ts +0 -41
  349. package/build/esm/lead/LeadGenForm/LeadGenForm.helpers.d.ts +0 -2
  350. package/build/esm/lead/LeadGenForm/LeadGenForm.styled.d.ts +0 -5
  351. package/build/esm/lead/LeadGenForm/LeadGenFormPhone.d.ts +0 -17
  352. package/build/esm/lead/LeadGenForm/LeadGenThankYou.d.ts +0 -20
  353. package/build/esm/lead/LeadGenForm/index.d.ts +0 -3
  354. package/build/esm/lead/LeadGenForm/textField/index.d.ts +0 -13
  355. package/build/esm/lead/LeadGenForm/textField/index.styled.d.ts +0 -11
  356. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +0 -63
  357. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +0 -4
  358. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +0 -21
  359. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +0 -3
  360. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +0 -23
  361. package/build/esm/lead/LeadGenSubscriptionBox/index.d.ts +0 -1
  362. package/build/esm/lead/LeadGenTranslationContext.d.ts +0 -6
  363. package/build/esm/translationsProvider-75b93b92.js +0 -55
  364. package/build/i18n-values/zh-CN.js +0 -866
  365. package/build/lead/LeadGen.type.d.ts +0 -31
  366. package/build/lead/LeadGenForm/LeadGenForm.d.ts +0 -41
  367. package/build/lead/LeadGenForm/LeadGenForm.helpers.d.ts +0 -2
  368. package/build/lead/LeadGenForm/LeadGenForm.styled.d.ts +0 -5
  369. package/build/lead/LeadGenForm/LeadGenFormPhone.d.ts +0 -17
  370. package/build/lead/LeadGenForm/LeadGenThankYou.d.ts +0 -20
  371. package/build/lead/LeadGenForm/index.d.ts +0 -3
  372. package/build/lead/LeadGenForm/textField/index.d.ts +0 -13
  373. package/build/lead/LeadGenForm/textField/index.styled.d.ts +0 -11
  374. package/build/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +0 -63
  375. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +0 -4
  376. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +0 -21
  377. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +0 -3
  378. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +0 -23
  379. package/build/lead/LeadGenSubscriptionBox/index.d.ts +0 -1
  380. package/build/lead/LeadGenTranslationContext.d.ts +0 -6
  381. package/build/translationsProvider-0f5d2303.js +0 -62
  382. /package/build/{BMI_BOYS.percentile.monthly-f4daed0d.js → BMI_BOYS.percentile.monthly-179a50b1.js} +0 -0
  383. /package/build/{BMI_BOYS.percentile.weekly-1de7f0e1.js → BMI_BOYS.percentile.weekly-6e48af31.js} +0 -0
  384. /package/build/{BMI_BOYS.percentile.yearly-0222daae.js → BMI_BOYS.percentile.yearly-4580e832.js} +0 -0
  385. /package/build/{BMI_BOYS.zscore.monthly-1bd85a5e.js → BMI_BOYS.zscore.monthly-b7606779.js} +0 -0
  386. /package/build/{BMI_BOYS.zscore.weekly-65f9be2b.js → BMI_BOYS.zscore.weekly-172fbecd.js} +0 -0
  387. /package/build/{BMI_BOYS.zscore.yearly-c9a6b727.js → BMI_BOYS.zscore.yearly-34a8f9cd.js} +0 -0
  388. /package/build/{BMI_GIRLS.percentile.monthly-220ef448.js → BMI_GIRLS.percentile.monthly-5b16a621.js} +0 -0
  389. /package/build/{BMI_GIRLS.percentile.weekly-7a5096e3.js → BMI_GIRLS.percentile.weekly-a13bf779.js} +0 -0
  390. /package/build/{BMI_GIRLS.percentile.yearly-53ed80a2.js → BMI_GIRLS.percentile.yearly-13973462.js} +0 -0
  391. /package/build/{BMI_GIRLS.zscore.monthly-5df375ff.js → BMI_GIRLS.zscore.monthly-204e3d84.js} +0 -0
  392. /package/build/{BMI_GIRLS.zscore.weekly-9503c924.js → BMI_GIRLS.zscore.weekly-6fdd2c6a.js} +0 -0
  393. /package/build/{BMI_GIRLS.zscore.yearly-f8c55dfc.js → BMI_GIRLS.zscore.yearly-1cca63a0.js} +0 -0
  394. /package/build/{ChevronDown-5813f17e.js → ChevronDown-666ab37d.js} +0 -0
  395. /package/build/{Close-4893c3ca.js → Close-1b6e6466.js} +0 -0
  396. /package/build/{Google-391b9a03.js → Google-255c0f1a.js} +0 -0
  397. /package/build/{HEAD CIRCUM_BOYS.percentile.monthly-4d8f3e60.js → HEAD CIRCUM_BOYS.percentile.monthly-27b74016.js} +0 -0
  398. /package/build/{HEAD CIRCUM_BOYS.percentile.weekly-1819f9c6.js → HEAD CIRCUM_BOYS.percentile.weekly-44d2ee86.js} +0 -0
  399. /package/build/{HEAD CIRCUM_BOYS.percentile.yearly-020cb98a.js → HEAD CIRCUM_BOYS.percentile.yearly-8da7f001.js} +0 -0
  400. /package/build/{HEAD CIRCUM_BOYS.zscore.monthly-feeff1b8.js → HEAD CIRCUM_BOYS.zscore.monthly-61e5db90.js} +0 -0
  401. /package/build/{HEAD CIRCUM_BOYS.zscore.weekly-e8427518.js → HEAD CIRCUM_BOYS.zscore.weekly-25d8b075.js} +0 -0
  402. /package/build/{HEAD CIRCUM_BOYS.zscore.yearly-0d9f4ede.js → HEAD CIRCUM_BOYS.zscore.yearly-1e6e1e4e.js} +0 -0
  403. /package/build/{HEAD CIRCUM_GIRLS.percentile.monthly-a058e780.js → HEAD CIRCUM_GIRLS.percentile.monthly-bdd4a98b.js} +0 -0
  404. /package/build/{HEAD CIRCUM_GIRLS.percentile.weekly-121b74bc.js → HEAD CIRCUM_GIRLS.percentile.weekly-c22eafb0.js} +0 -0
  405. /package/build/{HEAD CIRCUM_GIRLS.percentile.yearly-7729a5ed.js → HEAD CIRCUM_GIRLS.percentile.yearly-e63f3462.js} +0 -0
  406. /package/build/{HEAD CIRCUM_GIRLS.zscore.monthly-5a6747cd.js → HEAD CIRCUM_GIRLS.zscore.monthly-ba864f1d.js} +0 -0
  407. /package/build/{HEAD CIRCUM_GIRLS.zscore.weekly-5f4cb404.js → HEAD CIRCUM_GIRLS.zscore.weekly-0ab88ce6.js} +0 -0
  408. /package/build/{HEAD CIRCUM_GIRLS.zscore.yearly-db75ac45.js → HEAD CIRCUM_GIRLS.zscore.yearly-5f6cd980.js} +0 -0
  409. /package/build/{HEIGHT_BOYS.percentile.monthly-9979a4bf.js → HEIGHT_BOYS.percentile.monthly-de94349f.js} +0 -0
  410. /package/build/{HEIGHT_BOYS.percentile.weekly-ebcdeaa8.js → HEIGHT_BOYS.percentile.weekly-0deb1e2e.js} +0 -0
  411. /package/build/{HEIGHT_BOYS.percentile.yearly-6f6fc978.js → HEIGHT_BOYS.percentile.yearly-de56c11c.js} +0 -0
  412. /package/build/{HEIGHT_BOYS.zscore.monthly-c4d5a63c.js → HEIGHT_BOYS.zscore.monthly-2ec7ba91.js} +0 -0
  413. /package/build/{HEIGHT_BOYS.zscore.weekly-ac833d64.js → HEIGHT_BOYS.zscore.weekly-ca549a20.js} +0 -0
  414. /package/build/{HEIGHT_BOYS.zscore.yearly-ff3f71f9.js → HEIGHT_BOYS.zscore.yearly-1a550c19.js} +0 -0
  415. /package/build/{HEIGHT_GIRLS.percentile.monthly-eb3712f6.js → HEIGHT_GIRLS.percentile.monthly-4ed4b34f.js} +0 -0
  416. /package/build/{HEIGHT_GIRLS.percentile.weekly-f9e21b4d.js → HEIGHT_GIRLS.percentile.weekly-8e84201b.js} +0 -0
  417. /package/build/{HEIGHT_GIRLS.percentile.yearly-3b69d6bd.js → HEIGHT_GIRLS.percentile.yearly-ae554a2e.js} +0 -0
  418. /package/build/{HEIGHT_GIRLS.zscore.monthly-812e3b24.js → HEIGHT_GIRLS.zscore.monthly-e39acd9f.js} +0 -0
  419. /package/build/{HEIGHT_GIRLS.zscore.weekly-0450e9dd.js → HEIGHT_GIRLS.zscore.weekly-c1ac2f72.js} +0 -0
  420. /package/build/{HEIGHT_GIRLS.zscore.yearly-3e9be766.js → HEIGHT_GIRLS.zscore.yearly-e60e8414.js} +0 -0
  421. /package/build/{Visible-6c80b7ef.js → Visible-3c7c545a.js} +0 -0
  422. /package/build/{WEIGHT_BOYS.percentile.monthly-15304941.js → WEIGHT_BOYS.percentile.monthly-7907d7d8.js} +0 -0
  423. /package/build/{WEIGHT_BOYS.percentile.weekly-7f6893d6.js → WEIGHT_BOYS.percentile.weekly-ffe2e09f.js} +0 -0
  424. /package/build/{WEIGHT_BOYS.percentile.yearly-9de9bd0e.js → WEIGHT_BOYS.percentile.yearly-5613db72.js} +0 -0
  425. /package/build/{WEIGHT_BOYS.zscore.monthly-44b508be.js → WEIGHT_BOYS.zscore.monthly-0c71e1f1.js} +0 -0
  426. /package/build/{WEIGHT_BOYS.zscore.weekly-fb670db8.js → WEIGHT_BOYS.zscore.weekly-551fbe61.js} +0 -0
  427. /package/build/{WEIGHT_BOYS.zscore.yearly-d23350c0.js → WEIGHT_BOYS.zscore.yearly-faf021d6.js} +0 -0
  428. /package/build/{WEIGHT_GIRLS.percentile.monthly-09784264.js → WEIGHT_GIRLS.percentile.monthly-5e32962a.js} +0 -0
  429. /package/build/{WEIGHT_GIRLS.percentile.weekly-ad7ef81e.js → WEIGHT_GIRLS.percentile.weekly-3bf46095.js} +0 -0
  430. /package/build/{WEIGHT_GIRLS.percentile.yearly-55c9d4e9.js → WEIGHT_GIRLS.percentile.yearly-081bb76a.js} +0 -0
  431. /package/build/{WEIGHT_GIRLS.zscore.monthly-abd26afa.js → WEIGHT_GIRLS.zscore.monthly-278e2e2f.js} +0 -0
  432. /package/build/{WEIGHT_GIRLS.zscore.weekly-370b7aa6.js → WEIGHT_GIRLS.zscore.weekly-7b2b5cb3.js} +0 -0
  433. /package/build/{WEIGHT_GIRLS.zscore.yearly-b07eecee.js → WEIGHT_GIRLS.zscore.yearly-3f573da9.js} +0 -0
  434. /package/build/{animation-5ca47bb9.js → animation-4a4be1d2.js} +0 -0
  435. /package/build/{constants-57c5ae20.js → constants-455c1bb4.js} +0 -0
  436. /package/build/{constants-8c977f49.js → constants-a6d2ff76.js} +0 -0
  437. /package/build/{dataTransform-1061941e.js → dataTransform-b60c06bb.js} +0 -0
  438. /package/build/{doctor-479ad363.js → doctor-1f6e5f33.js} +0 -0
  439. /package/build/esm/{BMI_BOYS.percentile.monthly-f7827037.js → BMI_BOYS.percentile.monthly-92d9c1f0.js} +0 -0
  440. /package/build/esm/{BMI_BOYS.percentile.weekly-565ddccf.js → BMI_BOYS.percentile.weekly-ee2eb412.js} +0 -0
  441. /package/build/esm/{BMI_BOYS.percentile.yearly-e5813395.js → BMI_BOYS.percentile.yearly-1633c579.js} +0 -0
  442. /package/build/esm/{BMI_BOYS.zscore.monthly-896b5548.js → BMI_BOYS.zscore.monthly-7cae8cf3.js} +0 -0
  443. /package/build/esm/{BMI_BOYS.zscore.weekly-72d8f1d4.js → BMI_BOYS.zscore.weekly-8d5a6c27.js} +0 -0
  444. /package/build/esm/{BMI_BOYS.zscore.yearly-5cdbc608.js → BMI_BOYS.zscore.yearly-4385bf15.js} +0 -0
  445. /package/build/esm/{BMI_GIRLS.percentile.monthly-4689d010.js → BMI_GIRLS.percentile.monthly-39965bce.js} +0 -0
  446. /package/build/esm/{BMI_GIRLS.percentile.weekly-8095cdb1.js → BMI_GIRLS.percentile.weekly-04c50c49.js} +0 -0
  447. /package/build/esm/{BMI_GIRLS.percentile.yearly-e420d4b6.js → BMI_GIRLS.percentile.yearly-c52eda5f.js} +0 -0
  448. /package/build/esm/{BMI_GIRLS.zscore.monthly-96744fcf.js → BMI_GIRLS.zscore.monthly-c706b650.js} +0 -0
  449. /package/build/esm/{BMI_GIRLS.zscore.weekly-108cd0c1.js → BMI_GIRLS.zscore.weekly-465b90ff.js} +0 -0
  450. /package/build/esm/{BMI_GIRLS.zscore.yearly-ddc29cbb.js → BMI_GIRLS.zscore.yearly-ed0e918a.js} +0 -0
  451. /package/build/esm/{ChevronDown-6c5ab56c.js → ChevronDown-3f8ce34e.js} +0 -0
  452. /package/build/esm/{Close-bed66153.js → Close-544c792d.js} +0 -0
  453. /package/build/esm/{Google-0d0deb6c.js → Google-07add6d7.js} +0 -0
  454. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.monthly-3f49b594.js → HEAD CIRCUM_BOYS.percentile.monthly-36488681.js} +0 -0
  455. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.weekly-189d3b0d.js → HEAD CIRCUM_BOYS.percentile.weekly-23fc9978.js} +0 -0
  456. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.yearly-a36b8cc0.js → HEAD CIRCUM_BOYS.percentile.yearly-854f13e0.js} +0 -0
  457. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.monthly-adbdbe9b.js → HEAD CIRCUM_BOYS.zscore.monthly-4d4dbf90.js} +0 -0
  458. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.weekly-389bcd18.js → HEAD CIRCUM_BOYS.zscore.weekly-9f181b10.js} +0 -0
  459. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.yearly-93f5c48a.js → HEAD CIRCUM_BOYS.zscore.yearly-6e8bcb7d.js} +0 -0
  460. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.monthly-d6d60aa3.js → HEAD CIRCUM_GIRLS.percentile.monthly-bdeb8d21.js} +0 -0
  461. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.weekly-fce1c0a4.js → HEAD CIRCUM_GIRLS.percentile.weekly-bf8d0a97.js} +0 -0
  462. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.yearly-8b9b0963.js → HEAD CIRCUM_GIRLS.percentile.yearly-230957db.js} +0 -0
  463. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.monthly-a384e6b8.js → HEAD CIRCUM_GIRLS.zscore.monthly-20e5c1d6.js} +0 -0
  464. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.weekly-2b323528.js → HEAD CIRCUM_GIRLS.zscore.weekly-3993abe9.js} +0 -0
  465. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.yearly-49dcd33e.js → HEAD CIRCUM_GIRLS.zscore.yearly-6891fbfc.js} +0 -0
  466. /package/build/esm/{HEIGHT_BOYS.percentile.monthly-f199288a.js → HEIGHT_BOYS.percentile.monthly-2570d419.js} +0 -0
  467. /package/build/esm/{HEIGHT_BOYS.percentile.weekly-a343b1bb.js → HEIGHT_BOYS.percentile.weekly-606af351.js} +0 -0
  468. /package/build/esm/{HEIGHT_BOYS.percentile.yearly-e4055e79.js → HEIGHT_BOYS.percentile.yearly-37c2dd55.js} +0 -0
  469. /package/build/esm/{HEIGHT_BOYS.zscore.monthly-f3b712b0.js → HEIGHT_BOYS.zscore.monthly-81178889.js} +0 -0
  470. /package/build/esm/{HEIGHT_BOYS.zscore.weekly-bb857bea.js → HEIGHT_BOYS.zscore.weekly-3178efa9.js} +0 -0
  471. /package/build/esm/{HEIGHT_BOYS.zscore.yearly-711d5437.js → HEIGHT_BOYS.zscore.yearly-493f4e9a.js} +0 -0
  472. /package/build/esm/{HEIGHT_GIRLS.percentile.monthly-328501ed.js → HEIGHT_GIRLS.percentile.monthly-0f1f5d53.js} +0 -0
  473. /package/build/esm/{HEIGHT_GIRLS.percentile.weekly-0851701a.js → HEIGHT_GIRLS.percentile.weekly-02ef3a08.js} +0 -0
  474. /package/build/esm/{HEIGHT_GIRLS.percentile.yearly-ccc2206e.js → HEIGHT_GIRLS.percentile.yearly-46a52ffd.js} +0 -0
  475. /package/build/esm/{HEIGHT_GIRLS.zscore.monthly-eda10451.js → HEIGHT_GIRLS.zscore.monthly-59d32be7.js} +0 -0
  476. /package/build/esm/{HEIGHT_GIRLS.zscore.weekly-58d86605.js → HEIGHT_GIRLS.zscore.weekly-934f71dc.js} +0 -0
  477. /package/build/esm/{HEIGHT_GIRLS.zscore.yearly-ccb8497b.js → HEIGHT_GIRLS.zscore.yearly-eeefcd63.js} +0 -0
  478. /package/build/esm/{Visible-c5e6e4e6.js → Visible-6f57a2db.js} +0 -0
  479. /package/build/esm/{WEIGHT_BOYS.percentile.monthly-33449fab.js → WEIGHT_BOYS.percentile.monthly-876f2a6d.js} +0 -0
  480. /package/build/esm/{WEIGHT_BOYS.percentile.weekly-48943538.js → WEIGHT_BOYS.percentile.weekly-67700803.js} +0 -0
  481. /package/build/esm/{WEIGHT_BOYS.percentile.yearly-4c2f88f2.js → WEIGHT_BOYS.percentile.yearly-b2adebd1.js} +0 -0
  482. /package/build/esm/{WEIGHT_BOYS.zscore.monthly-0f42bc26.js → WEIGHT_BOYS.zscore.monthly-38e643db.js} +0 -0
  483. /package/build/esm/{WEIGHT_BOYS.zscore.weekly-677a0765.js → WEIGHT_BOYS.zscore.weekly-ed370d92.js} +0 -0
  484. /package/build/esm/{WEIGHT_BOYS.zscore.yearly-580b0b33.js → WEIGHT_BOYS.zscore.yearly-158f3120.js} +0 -0
  485. /package/build/esm/{WEIGHT_GIRLS.percentile.monthly-be676e3d.js → WEIGHT_GIRLS.percentile.monthly-19ed2ff2.js} +0 -0
  486. /package/build/esm/{WEIGHT_GIRLS.percentile.weekly-c35d4786.js → WEIGHT_GIRLS.percentile.weekly-c07ebd4a.js} +0 -0
  487. /package/build/esm/{WEIGHT_GIRLS.percentile.yearly-fbba1129.js → WEIGHT_GIRLS.percentile.yearly-d2eb7f92.js} +0 -0
  488. /package/build/esm/{WEIGHT_GIRLS.zscore.monthly-8d62df68.js → WEIGHT_GIRLS.zscore.monthly-2d39112e.js} +0 -0
  489. /package/build/esm/{WEIGHT_GIRLS.zscore.weekly-d48fbc5a.js → WEIGHT_GIRLS.zscore.weekly-79c13caa.js} +0 -0
  490. /package/build/esm/{WEIGHT_GIRLS.zscore.yearly-5a9af915.js → WEIGHT_GIRLS.zscore.yearly-686b8120.js} +0 -0
  491. /package/build/esm/{animation-d5589e8b.js → animation-f0de7fec.js} +0 -0
  492. /package/build/esm/{constants-86b4a845.js → constants-67817a3e.js} +0 -0
  493. /package/build/esm/{constants-341374a3.js → constants-7a94d96a.js} +0 -0
  494. /package/build/esm/{dataTransform-51f00ef8.js → dataTransform-96b33da1.js} +0 -0
  495. /package/build/esm/{doctor-9dd59807.js → doctor-ce62bcf6.js} +0 -0
  496. /package/build/esm/{index-cd80d854.js → index-0fcc7e05.js} +0 -0
  497. /package/build/esm/{index-758957ae.js → index-20fe498c.js} +0 -0
  498. /package/build/esm/{index-094d7d78.js → index-2f816408.js} +0 -0
  499. /package/build/esm/{index-fd8e30de.js → index-50922feb.js} +0 -0
  500. /package/build/esm/{index-c23c9f7e.js → index-a9b9cf40.js} +0 -0
  501. /package/build/esm/{index-a26c1eda.js → index-b814b571.js} +0 -0
  502. /package/build/esm/{index-f3b6ab45.js → index-bd1a993e.js} +0 -0
  503. /package/build/esm/{index-4afb0581.js → index-d14b8ec2.js} +0 -0
  504. /package/build/esm/{index.styles-f8978237.js → index.styles-c9d6db26.js} +0 -0
  505. /package/build/esm/{localizeNumberFormat-2199ec15.js → localizeNumberFormat-91191f3b.js} +0 -0
  506. /package/build/esm/{normalizeLink-827f4e69.js → normalizeLink-6e07e5c4.js} +0 -0
  507. /package/build/esm/{number-0139958f.js → number-9e7857e2.js} +0 -0
  508. /package/build/esm/{other-a974982d.js → other-7cac897b.js} +0 -0
  509. /package/build/esm/{paths-053bd382.js → paths-eb036f12.js} +0 -0
  510. /package/build/esm/{translationsContext-4ea92c46.js → translationsContext-23b5bf84.js} +0 -0
  511. /package/build/esm/{tslib.es6-1073e423.js → tslib.es6-eb6746ec.js} +0 -0
  512. /package/build/esm/{types-c83c742e.js → types-1466329a.js} +0 -0
  513. /package/build/esm/{useIsInit-a00426ab.js → useIsInit-58c92435.js} +0 -0
  514. /package/build/esm/{useOutsideClick-dd8680ce.js → useOutsideClick-d1408b13.js} +0 -0
  515. /package/build/esm/{useScrollbarSize-7bd945f2.js → useScrollbarSize-af69fd45.js} +0 -0
  516. /package/build/esm/{useUniqueId-fa696ba6.js → useUniqueId-15198ead.js} +0 -0
  517. /package/build/esm/{utils-f530e069.js → utils-770949fe.js} +0 -0
  518. /package/build/{index-62ecd981.js → index-1e874626.js} +0 -0
  519. /package/build/{index-72924c47.js → index-a471322d.js} +0 -0
  520. /package/build/{index-1f0ffa62.js → index-a5d52534.js} +0 -0
  521. /package/build/{index-54146416.js → index-c30aae56.js} +0 -0
  522. /package/build/{index-75f7316f.js → index-cd4f0240.js} +0 -0
  523. /package/build/{index-adfb7062.js → index-fae28861.js} +0 -0
  524. /package/build/{index-66cbcf0b.js → index-fce79e5f.js} +0 -0
  525. /package/build/{index-64f3f9cd.js → index-fd00f1ea.js} +0 -0
  526. /package/build/{index.styles-65606527.js → index.styles-f9818d05.js} +0 -0
  527. /package/build/{localizeNumberFormat-95af1367.js → localizeNumberFormat-ef732f37.js} +0 -0
  528. /package/build/{normalizeLink-325ec7cc.js → normalizeLink-65501df2.js} +0 -0
  529. /package/build/{number-04e9f091.js → number-2ccfcc5f.js} +0 -0
  530. /package/build/{other-7cb22946.js → other-4e4f19d4.js} +0 -0
  531. /package/build/{paths-ad2e821c.js → paths-d2ea905c.js} +0 -0
  532. /package/build/{translationsContext-824f5c5d.js → translationsContext-3ac6ece2.js} +0 -0
  533. /package/build/{tslib.es6-751dcc64.js → tslib.es6-e879b440.js} +0 -0
  534. /package/build/{types-d9723642.js → types-2d921d78.js} +0 -0
  535. /package/build/{useIsInit-c869bcde.js → useIsInit-5cc2d405.js} +0 -0
  536. /package/build/{useOutsideClick-57926422.js → useOutsideClick-795cda46.js} +0 -0
  537. /package/build/{useScrollbarSize-972b58b9.js → useScrollbarSize-9fb99eed.js} +0 -0
  538. /package/build/{useUniqueId-1e0d5636.js → useUniqueId-5f42952d.js} +0 -0
  539. /package/build/{utils-0a56df4b.js → utils-a445506a.js} +0 -0
package/build/lead.js CHANGED
@@ -2,51 +2,48 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('./tslib.es6-751dcc64.js');
5
+ var tslib_es6 = require('./tslib.es6-e879b440.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-729572c2.js');
12
- var translationsContext = require('./translationsContext-824f5c5d.js');
11
+ var index = require('./index-9e639be2.js');
12
+ var translationsContext = require('./translationsContext-3ac6ece2.js');
13
13
  var miscCookieHelper = require('./miscCookieHelper.js');
14
- var utils$1 = require('./utils-0a56df4b.js');
15
- var index$1 = require('./index-fe818695.js');
16
- var index$2 = require('./index-d0820aeb.js');
17
- var index$4 = require('./index-706cdb42.js');
18
- var index$3 = require('./index-4ec0821f.js');
19
- require('./index.styles-65606527.js');
14
+ var utils$1 = require('./utils-a445506a.js');
15
+ var index$1 = require('./index-b043d722.js');
16
+ var index$2 = require('./index-78dac42f.js');
17
+ var index$4 = require('./index-31c0299e.js');
18
+ var index$3 = require('./index-bab54ae7.js');
19
+ require('./index.styles-f9818d05.js');
20
20
  var hooks = require('@mantine/hooks');
21
- require('./useMantineLocale-d74729a8.js');
22
- var index$8 = require('./index-5c38e2bd.js');
23
- require('./index-adfb7062.js');
24
- var index$6 = require('./index-523e7e4d.js');
25
- require('./other-7cb22946.js');
26
- require('./index-a10c0c62.js');
27
- var utils = require('./utils-2d4e6ea6.js');
28
- var dates = require('@mantine/dates');
29
- var usePlacesAutocomplete = require('./usePlacesAutocomplete-c3a05472.js');
30
- var index$5 = require('./index-737372f7.js');
31
- var translationsProvider = require('./translationsProvider-0f5d2303.js');
32
- var Locale = require('./Locale-ab6a6ba4.js');
21
+ require('./useMantineLocale-a330a7e5.js');
22
+ var index$8 = require('./index-467dfe87.js');
23
+ require('./index-fae28861.js');
24
+ var index$7 = require('./index-df8845e8.js');
25
+ require('./other-4e4f19d4.js');
26
+ require('./index-9074450c.js');
27
+ var utils = require('./utils-7d98be3c.js');
28
+ require('@mantine/dates');
29
+ var usePlacesAutocomplete = require('./usePlacesAutocomplete-14098979.js');
30
+ var index$5 = require('./index-582068c8.js');
33
31
  var uuid = require('uuid');
34
- var PhoneInputBase = require('react-phone-number-input');
32
+ var index$6 = require('./index-c30aae56.js');
33
+ var index$a = require('./index-4026f890.js');
34
+ var useScreenSize = require('./useScreenSize-2eae68ef.js');
35
+ var ReactDOM = require('react-dom');
36
+ var react = require('@emotion/react');
35
37
  var styled = require('@emotion/styled');
36
38
  var miscTheme = require('./miscTheme.js');
37
- var react = require('@emotion/react');
38
- var togetherComponentGlobalContext = require('./utils-a70ced06.js');
39
- var index$7 = require('./index-54146416.js');
40
- var index$a = require('./index-3f648346.js');
41
- var useScreenSize = require('./useScreenSize-805ef787.js');
42
- var ReactDOM = require('react-dom');
43
- var index$9 = require('./index-2644ecd5.js');
44
- var InputDate = require('./InputDate-27f75a17.js');
45
- var Close = require('./Close-4893c3ca.js');
39
+ var index$9 = require('./index-809fab5e.js');
40
+ var InputDate = require('./InputDate-8b579da2.js');
41
+ var Close = require('./Close-1b6e6466.js');
46
42
  require('@hhgtech/icons/other');
47
43
  require('@mantine/carousel');
44
+ require('./Locale-72dce976.js');
48
45
  require('classnames');
49
- require('./useUniqueId-1e0d5636.js');
46
+ require('./useUniqueId-5f42952d.js');
50
47
  require('./constantsSite.js');
51
48
  require('@hhgtech/icons/core');
52
49
  require('@mantine/notifications');
@@ -54,22 +51,6 @@ require('./constantsDomainLocales.js');
54
51
  require('./constantsIsProduction.js');
55
52
  require('date-fns/locale');
56
53
  require('./constantsRiskScreener.js');
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-62ecd981.js');
69
- require('slugify');
70
- require('string-format');
71
- require('./togetherApiPaths.js');
72
- require('./constants-8c977f49.js');
73
54
  require('vaul');
74
55
 
75
56
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -121,7 +102,7 @@ if (sessionStorage.getItem('insider_object')) {
121
102
  }
122
103
  const docLang = document.documentElement.lang;
123
104
  // TODO: country code
124
- const LEAD_LOCALE_DATA$1 = {
105
+ const LEAD_LOCALE_DATA = {
125
106
  'vi-VN': {
126
107
  popupLang: 'vi',
127
108
  countryCode: 'vn',
@@ -163,7 +144,7 @@ const LEAD_LOCALE_DATA$1 = {
163
144
  countryCodeNumber: 91,
164
145
  },
165
146
  };
166
- const LEAD_LOCALE = LEAD_LOCALE_DATA$1[docLang] || LEAD_LOCALE_DATA$1['vi-VN'];
147
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
167
148
  function LEAD_RESET_VAR() {
168
149
  // LEAD_CURRENT_URL = location.href.toLowerCase();
169
150
  LEAD_CURRENT_URL =
@@ -184,11 +165,6 @@ const LEAD_TIMEZONE_DATA = {
184
165
  9: 'Asia/Manila', // Philippines / Filipinos Site
185
166
  };
186
167
 
187
- const LEADGEN_ACTIONS = {
188
- SHOW: 'SHOW',
189
- SCROLL: 'SCROLL',
190
- TIME: 'TIME',
191
- };
192
168
  const LEADGEN_LAYOUT = {
193
169
  LightBoxA: 'LightBoxA',
194
170
  LightBoxB: 'LightBoxB',
@@ -218,10 +194,8 @@ const LEADGEN_BLOCK = {
218
194
  DropdownBlock: 'DropdownBlock',
219
195
  CheckboxBlock: 'CheckboxBlock',
220
196
  TncBlock: 'TncBlock',
221
- TitleBlock: 'TitleBlock',
222
- SubtitleBlock: 'SubtitleBlock',
223
197
  };
224
- const LEADGEN_BLOCK_INPUT = [
198
+ const LEADGEN_BLOCK_IN_FORM = [
225
199
  LEADGEN_BLOCK.TextBlock,
226
200
  LEADGEN_BLOCK.NumberBlock,
227
201
  LEADGEN_BLOCK.DateBlock,
@@ -236,59 +210,7 @@ const LEADGEN_BLOCK_INPUT = [
236
210
  LEADGEN_BLOCK.CheckboxBlock,
237
211
  LEADGEN_BLOCK.TncBlock,
238
212
  ];
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
213
  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
214
  const mappingSSOToLead = (userInfoProps) => {
293
215
  var _a, _b;
294
216
  try {
@@ -304,7 +226,7 @@ const mappingSSOToLead = (userInfoProps) => {
304
226
  if (ssoKey === 'birthday') {
305
227
  const dob = dayjs__default["default"](initValue, 'YYYY-MM-DD', true);
306
228
  if (dob.isValid()) {
307
- user.birthday = dob.toDate();
229
+ user.birthday = dob;
308
230
  }
309
231
  }
310
232
  else if (ssoKey === 'gender') {
@@ -327,66 +249,16 @@ const mappingSSOToLead = (userInfoProps) => {
327
249
  catch (error) {
328
250
  return;
329
251
  }
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
252
  };
371
253
 
372
254
  class Store {
373
255
  constructor() {
374
- this.apiSsoUrl = 'https://staging-id.hellobacsi.com/';
375
256
  this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
376
257
  this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
377
258
  }
378
259
  }
379
260
  const leadStore = new Store();
380
261
 
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
262
  const leadApi = {
391
263
  call(_a) {
392
264
  var { url, data = undefined } = _a, config = tslib_es6.__rest(_a, ["url", "data"]);
@@ -490,50 +362,8 @@ const verifyOtpLead = ({ phone, otp, type, }) => {
490
362
  },
491
363
  });
492
364
  };
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
365
  const Service = {
531
366
  campaignGetById,
532
- getCampaignByCode,
533
- getSubscriptionBoxInfo,
534
- postSubscriptionBoxLead,
535
- postUserInfoFromLeadGen,
536
- campaignPostImpression,
537
367
  validateEmailOrPhoneOnSubot,
538
368
  validateEmailOrPhoneOnLeadGen,
539
369
  validatePhoneNumberOnLeadGen,
@@ -873,7 +703,7 @@ const Description = (_a) => {
873
703
  return description ? (React__default["default"].createElement(index$1.Text, Object.assign({ size: "p3" }, rest), description)) : null;
874
704
  };
875
705
 
876
- const LeadGenContext$1 = React.createContext({});
706
+ const LeadGenContext = React.createContext({});
877
707
 
878
708
  var useStyles$2 = core.createStyles(() => {
879
709
  return {
@@ -937,7 +767,7 @@ const SubtitleBlock$1 = ({ children, align, }) => (React__default["default"].cre
937
767
  const TitleBlock$1 = ({ children, align, }) => (React__default["default"].createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
938
768
 
939
769
  const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, popoverProps, }) => {
940
- const { primaryColor } = React.useContext(LeadGenContext$1);
770
+ const { primaryColor } = React.useContext(LeadGenContext);
941
771
  const { classes, cx } = useStyles$2(undefined, {
942
772
  name: 'LeadGen__Field',
943
773
  styles,
@@ -1052,7 +882,7 @@ const Heading = (_a) => {
1052
882
 
1053
883
  const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps, submitProps, }) => {
1054
884
  var _a;
1055
- const { primaryColor } = React.useContext(LeadGenContext$1);
885
+ const { primaryColor } = React.useContext(LeadGenContext);
1056
886
  const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, setFormRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = React.useContext(LeadGenComponentContext);
1057
887
  const { classes, cx } = useStyles$1(undefined, {
1058
888
  name: 'LeadGen__FormComponent',
@@ -1562,1597 +1392,73 @@ const translationsMap = {
1562
1392
  'my-MM': myMM,
1563
1393
  'km-KH': kmKH,
1564
1394
  'zh-TW': zhTW,
1565
- 'zh-CN': zhTW,
1566
1395
  'th-TH': thTH,
1567
1396
  'tl-PH': enPH,
1568
1397
  };
1569
1398
  const getTranslations = (locale) => {
1570
- const translations = Object.assign(Object.assign({}, translationsProvider.translationsMap[locale]), translationsMap[locale]);
1399
+ const translations = translationsMap[locale];
1571
1400
  if (translations) {
1572
1401
  return translations;
1573
1402
  }
1574
1403
  return translationsMap['en-PH'];
1575
1404
  };
1576
1405
 
1577
- const LeadGenTranslationProvider = (props) => {
1578
- const { locale, children } = props;
1579
- const translationContextValue = React.useMemo(() => ({ locale, values: getTranslations(locale) }), [locale]);
1580
- return (React__default["default"].createElement(translationsContext.TranslationsContext.Provider, { value: translationContextValue }, children));
1406
+ const useImageSize = (src) => {
1407
+ const [width, setWidth] = React.useState(16);
1408
+ const [height, setHeight] = React.useState(9);
1409
+ const [loaded, setLoaded] = React.useState(false);
1410
+ // load src image to get its width and height
1411
+ React.useEffect(() => {
1412
+ setLoaded(false);
1413
+ if (src) {
1414
+ const img = new Image();
1415
+ img.addEventListener('load', () => {
1416
+ setWidth(img.naturalWidth);
1417
+ setHeight(img.naturalHeight);
1418
+ setLoaded(true);
1419
+ });
1420
+ img.addEventListener('error', () => {
1421
+ setWidth(16);
1422
+ setHeight(9);
1423
+ setLoaded(true);
1424
+ });
1425
+ img.src = src;
1426
+ }
1427
+ else {
1428
+ setWidth(16);
1429
+ setHeight(9);
1430
+ setLoaded(true);
1431
+ }
1432
+ }, [src]);
1433
+ return {
1434
+ loaded,
1435
+ width,
1436
+ height,
1437
+ };
1581
1438
  };
1582
1439
 
1583
- // import mockLeadData from './mockLeadData'
1584
- const listCampaignScheduled = [];
1585
- const listCampaignScheduledToActivated = [];
1586
- const listCampaignActiveButExpired = [];
1587
- const listCampaignExcludeSonsored = [];
1588
- const listCampaignDifferentSponsor = [];
1589
- const listCampaignNotDisplayInRangeOfTime = [];
1590
- function isMobile() {
1591
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
1592
- }
1593
- const getShuffleArray = (array) => {
1594
- const newArray = [...array];
1595
- for (let i = newArray.length - 1; i > 0; i--) {
1596
- const j = Math.floor(Math.random() * (i + 1));
1597
- const temp = newArray[i];
1598
- newArray[i] = newArray[j];
1599
- newArray[j] = temp;
1600
- }
1601
- return newArray;
1602
- };
1603
- const getTimeByTimezone = (timeZone = 'UTC') => {
1604
- const date = new Date();
1605
- return new Date(date.toLocaleString('en-US', { timeZone }));
1606
- };
1607
- const parseDateByCampaignTime = (dateStr) => {
1608
- // Format like this: 2023-04-04 00:00:00
1609
- try {
1610
- const [datePart, timePart] = dateStr.split(' ');
1611
- const [year, month, day] = datePart.split('-').map(Number);
1612
- const [hours, minutes, seconds] = timePart.split(':').map(Number);
1613
- /** JavaScript counts months from 0 to 11 */
1614
- return new Date(year, month - 1, day, hours, minutes, seconds);
1615
- }
1616
- catch (err) {
1617
- return null;
1618
- }
1619
- };
1620
- const checkCampaignNowInTimeframe = (c) => {
1621
- var _a;
1622
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1623
- const startedAtStr = c.started_at;
1624
- const endedAtStr = c.ended_at;
1625
- const startedDate = parseDateByCampaignTime(startedAtStr);
1626
- const endedDate = parseDateByCampaignTime(endedAtStr);
1627
- if (!startedDate || !endedDate) {
1628
- return false;
1629
- }
1630
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
1631
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1632
- if (nowWithTimezoneMs <= endedDate.getTime() &&
1633
- nowWithTimezoneMs >= startedDate.getTime()) {
1634
- listCampaignScheduledToActivated.push(c);
1635
- return true;
1636
- }
1637
- return false;
1638
- };
1639
- function checkCampaignActiveButExpireAlready(c) {
1640
- var _a;
1641
- /** Do not setup timeframe for this campaign. No need to check */
1642
- if (c.forever === 1) {
1643
- return true;
1644
- }
1645
- const startedAtStr = c.started_at;
1646
- const endedAtStr = c.ended_at;
1647
- const startedDate = parseDateByCampaignTime(startedAtStr);
1648
- const endedDate = parseDateByCampaignTime(endedAtStr);
1649
- /** Do not setup timeframe for this campaign. No need to check */
1650
- if (!startedDate || !endedDate) {
1651
- return true;
1652
- }
1653
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1654
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
1655
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1656
- /** Check if this expire already, do not show */
1657
- if (nowWithTimezoneMs > endedDate.getTime()) {
1658
- listCampaignActiveButExpired.push(c);
1659
- return false;
1660
- }
1661
- return true;
1662
- }
1663
- function shouldNotDisplayIfExcludeAllSponsors(c) {
1664
- var _a;
1665
- const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
1666
- const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
1667
- if (isSponsored && excludeSponsored) {
1668
- listCampaignExcludeSonsored.push(c);
1669
- return true;
1670
- }
1671
- return false;
1672
- }
1673
- function shouldDisplayWithCurrentSponsor(c) {
1674
- var _a, _b;
1675
- try {
1676
- // TODO: BE will rename `exclude_sponsored_list` later
1677
- const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
1678
- const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
1679
- const dataSponsoredId = Number((_b = document
1680
- .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
1681
- // There is no config for sponsor id and white list, should show as default
1682
- if (!dataSponsoredId ||
1683
- dataSponsoredId <= 0 ||
1684
- whiteListSponsors.length === 0) {
1685
- return true;
1686
- }
1687
- // Check the dataSponsoredId exists in the white list or not.
1688
- const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
1689
- if (isExist) {
1690
- return true;
1691
- }
1692
- listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
1693
- return false;
1694
- }
1695
- catch (err) {
1696
- // Default is show
1697
- return true;
1698
- }
1699
- }
1700
- const filterFnCampaign = (c) => {
1701
- if (shouldNotDisplayIfExcludeAllSponsors(c)) {
1702
- return false;
1703
- }
1704
- else if (!shouldDisplayWithCurrentSponsor(c)) {
1705
- return false;
1706
- }
1707
- /** Active */
1708
- if (c.formatted_status === 1) {
1709
- return checkCampaignActiveButExpireAlready(c);
1710
- }
1711
- /** Schedule */
1712
- if (c.formatted_status === 0) {
1713
- listCampaignScheduled.push(c);
1714
- return checkCampaignNowInTimeframe(c);
1715
- }
1716
- return false;
1717
- };
1718
- const fillterApprearanceTimeCampaign = (c) => {
1719
- var _a;
1720
- try {
1721
- const isTimeInRange = (currentTime, startTime, endTime) => {
1722
- const startParts = startTime.split(':');
1723
- const endParts = endTime.split(':');
1724
- const startDate = new Date();
1725
- startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
1726
- const endDate = new Date();
1727
- endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
1728
- return currentTime >= startDate && currentTime <= endDate;
1729
- };
1730
- const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
1731
- const startTime = rulesApprValue.startTime;
1732
- const endTime = rulesApprValue.endTime || '23:59';
1733
- if (!startTime) {
1734
- return true;
1735
- }
1736
- if (isTimeInRange(new Date(), startTime, endTime)) {
1737
- return true;
1738
- }
1739
- listCampaignNotDisplayInRangeOfTime.push(c);
1740
- return false;
1741
- }
1742
- catch (err) {
1743
- return true;
1744
- }
1745
- };
1746
- let timeoutRef = null;
1747
- let LEAD_SCROLL_EVENT = null;
1748
- function clearPassiveEvent() {
1749
- if (timeoutRef) {
1750
- clearTimeout(timeoutRef);
1751
- timeoutRef = null;
1752
- }
1753
- if (LEAD_SCROLL_EVENT) {
1754
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1755
- LEAD_SCROLL_EVENT = null;
1756
- }
1757
- }
1758
- function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
1759
- // clear previous passive event, check for new condition
1760
- clearPassiveEvent();
1761
- const leadCurrentUrl = DEBUG_URL ||
1762
- ('https://' +
1763
- location.hostname +
1764
- location.pathname +
1765
- location.search).toLowerCase();
1766
- fetch(leadApi + 'api/campaign/' + leadSiteId, {
1767
- method: 'POST',
1768
- headers: {
1769
- 'Content-Type': 'application/json',
1770
- },
1771
- body: JSON.stringify({
1772
- url: leadCurrentUrl,
1773
- ga_client_id: miscCookieHelper.getCookie('_ga') || null,
1774
- }),
1775
- })
1776
- .then((response) => {
1777
- return response.json();
1778
- // return mockLeadData || response.json()
1779
- })
1780
- .then((data) => {
1781
- var _a, _b, _c, _d;
1782
- LeadLog('List campagin: ', data);
1783
- LEAD_RESET_VAR();
1784
- if (data._status == 1) {
1785
- 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);
1786
- if (!miscCookieHelper.getCookie('hhg-id')) {
1787
- miscCookieHelper.setCookie('hhg-id', uuid.v1(), {
1788
- domain: '.' + leadDomain,
1789
- path: '/',
1790
- });
1791
- LeadLog('😍 Set HHG ID cookie');
1792
- }
1793
- // getCookie('hhg-id')
1794
- // TODO: HP-534 Filter desktop
1795
- let campaignsDevice = [];
1796
- if (isMobile()) {
1797
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
1798
- }
1799
- else {
1800
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
1801
- }
1802
- LeadLog(`👓 campaignsDevice`, campaignsDevice);
1803
- LeadLog('--listCampaignScheduled', listCampaignScheduled);
1804
- LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
1805
- LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
1806
- LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
1807
- LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
1808
- LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
1809
- // Check links
1810
- let listLinksObj = campaignsDevice
1811
- .map((i, index) => i.targets
1812
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
1813
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1814
- .flat(1);
1815
- // Check list link match current href
1816
- listLinksObj = listLinksObj.filter((i) => {
1817
- var _a;
1818
- const target = new URL(String(i.target).toLowerCase());
1819
- if (i.option == 'exact_match')
1820
- // FOR TEST LOCAL:
1821
- // return Boolean(location.pathname === target.pathname)
1822
- return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
1823
- if (i.option == 'start_with') {
1824
- // FOR TEST LOCAL:
1825
- // if (location.pathname.includes(target.pathname)) {
1826
- if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
1827
- const listExcluding = i.sub_target
1828
- .filter((i) => i.option == 'excluding')
1829
- .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
1830
- return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
1831
- }
1832
- else {
1833
- return false;
1834
- }
1835
- }
1836
- });
1837
- // Check tags
1838
- const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
1839
- const listTags = listMetaTag.map((i) => i.content);
1840
- let listCampaignHasTag = [];
1841
- let listTagsObj = [];
1842
- if (listTags && listTags.length) {
1843
- listCampaignHasTag = campaignsDevice
1844
- .map((i, index) => i.targets
1845
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
1846
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1847
- .flat(1);
1848
- listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
1849
- }
1850
- const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
1851
- const cookieKeys = document.cookie
1852
- .split('; ')
1853
- .map((i) => i.split('=')[0]);
1854
- const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
1855
- LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
1856
- const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
1857
- LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
1858
- const listCampaignSubmitedClosed = [
1859
- ...listCampaignCodeSubmited,
1860
- ...listCampaignCodeClosed,
1861
- ];
1862
- const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
1863
- const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
1864
- return !hasSubmited;
1865
- });
1866
- const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
1867
- // .sort(
1868
- // (a, b) =>
1869
- // (listCampaignValid[a.campaignIndex]?.score || 0) -
1870
- // (listCampaignValid[b.campaignIndex]?.score || 0),
1871
- // )
1872
- LeadLog('--listCampaignValid : ', listCampaignValid);
1873
- if (listCampaignValid && listCampaignValid.length) {
1874
- const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
1875
- LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
1876
- const { rules } = CAMPAIGN_SHOW;
1877
- // CHECK RULE TRIGGER POPUP
1878
- const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
1879
- LeadLog(`timeoutRule`, timeoutRule);
1880
- const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
1881
- LeadLog(`scrollRule`, scrollRule);
1882
- let impressionAction = 'TIME';
1883
- if (Number.isInteger(timeoutRule)) {
1884
- impressionAction = 'TIME';
1885
- LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
1886
- timeoutRef = setTimeout(() => {
1887
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1888
- }, timeoutRule * 1000);
1889
- }
1890
- if (Number.isInteger(scrollRule)) {
1891
- impressionAction = 'SCROLL';
1892
- LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
1893
- const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
1894
- document.querySelector('body');
1895
- const pct = $p.getBoundingClientRect().top;
1896
- const pb = $p.offsetHeight;
1897
- LeadLog(`👓 Element check scroll: `, $p);
1898
- LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
1899
- const wt = window.pageYOffset || document.documentElement.scrollTop;
1900
- let percent = 0;
1901
- if (wt >= pct) {
1902
- percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
1903
- }
1904
- LeadLog('---Scroll', percent, scrollRule);
1905
- // TODO: CHECK FOOTER HEIGHT
1906
- if (percent >= scrollRule) {
1907
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1908
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1909
- }
1910
- };
1911
- window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
1912
- passive: true,
1913
- });
1914
- }
1915
- }
1916
- else {
1917
- LeadLog('🚧 No lead campaigns on current URL, tags');
1918
- }
1919
- }
1920
- })
1921
- .catch((err) => {
1922
- LeadLog(`Lead error: `, err);
1923
- });
1924
- }
1925
- const LeadLog = (...params) => {
1926
- if (process.env.NODE_ENV !== 'production' ||
1927
- (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
1928
- process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
1929
- (typeof localStorage !== 'undefined' &&
1930
- localStorage.getItem('hhg_debug') === 'true')) {
1931
- console.log(...params);
1932
- }
1933
- };
1934
-
1935
- const LeadGenContext = React.createContext({
1936
- submit(value) {
1937
- /** Init for FAKING function */
1938
- LeadLog('** LeadGen Submit : ', value);
1939
- return Promise.reject(value);
1940
- },
1941
- submitSubscriptionBox(value) {
1942
- /** Init for FAKING function */
1943
- LeadLog('** LeadGen SubmitSubscriptionBox : ', value);
1944
- return Promise.reject(value);
1945
- },
1946
- impression(value) {
1947
- /** Init for FAKING function */
1948
- LeadLog('** LeadGen Impression : ', value);
1949
- return Promise.reject(value);
1950
- },
1951
- /** For Subscription Box */
1952
- subscriptionIcon: '',
1953
- subscriptionTitle: '',
1954
- });
1955
- const LeadGenContextProvider = (props) => {
1956
- const { campaign_code: campaignCodeProps, apiSsoUrl, apiLeadUrl, apiSubotUrl, locale: localeProps, forceCampaign: forceCampaignProps, extraValues, articleId = 1, categoryId = 1, siteDomain: site_domain, children, } = props;
1957
- const [forceCampaign, setForceCampaign] = React.useState(forceCampaignProps);
1958
- const [subscriptionInfo, setSubscriptionInfo] = React.useState({
1959
- subscriptionIcon: '',
1960
- subscriptionTitle: '',
1961
- });
1962
- const locale = React.useMemo(() => {
1963
- return localeProps || Locale.LOCALE['PhilippinesEnglish'];
1964
- }, [localeProps]);
1965
- const leadGenContextValue = React.useMemo(() => (Object.assign(Object.assign({}, props), { forceCampaign })), [...Object.values(props), forceCampaign]);
1966
- const { url, campaign_id, campaign_code, cookie_id, ga_client_id, category_id, article_id, article_title, } = React.useMemo(() => ({
1967
- url: location.href.toLowerCase() || '',
1968
- cookie_id: miscCookieHelper.getCookie('hhg-id') || null,
1969
- ga_client_id: miscCookieHelper.getCookie('_ga'),
1970
- campaign_id: forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id,
1971
- campaign_code: campaignCodeProps || (forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.code),
1972
- category_id: categoryId,
1973
- article_id: articleId,
1974
- article_title: document.title || '',
1975
- }), [campaignCodeProps, articleId, categoryId, forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id]);
1976
- const fetchCampaign = React.useCallback((campaign_code) => {
1977
- Service.getCampaignByCode(campaign_code).then((res) => {
1978
- const { _data } = res || {};
1979
- const { campaigns } = _data || {};
1980
- LeadLog('** LeadGen Campaign : ', campaigns);
1981
- setForceCampaign(formatCampaignDetail(campaigns));
1982
- });
1983
- }, [campaignCodeProps]);
1984
- // TODO : Update form for LeadGen
1985
- const submit = React.useCallback((data) => {
1986
- return Service.postSubscriptionBoxLead({ data });
1987
- }, []);
1988
- const submitSubscriptionBox = React.useCallback((value) => {
1989
- const data = Object.assign(Object.assign(Object.assign(Object.assign({}, value), { campaign_id,
1990
- 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,
1991
- category_id, article_title: (extraValues === null || extraValues === void 0 ? void 0 : extraValues.article_title) || article_title });
1992
- return Service.postSubscriptionBoxLead({ data });
1993
- }, [
1994
- extraValues,
1995
- site_domain,
1996
- campaign_id,
1997
- article_id,
1998
- article_title,
1999
- category_id,
2000
- url,
2001
- ga_client_id,
2002
- ]);
2003
- const impression = React.useCallback((value) => {
2004
- return Service.campaignPostImpression({
2005
- url: (value === null || value === void 0 ? void 0 : value.url) || url,
2006
- action: (value === null || value === void 0 ? void 0 : value.action) || LEADGEN_ACTIONS.SCROLL,
2007
- code: (value === null || value === void 0 ? void 0 : value.code) || campaign_code,
2008
- title_article: (value === null || value === void 0 ? void 0 : value.title_article) || article_title,
2009
- cookie_id: (value === null || value === void 0 ? void 0 : value.cookie_id) || cookie_id,
2010
- ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id,
2011
- extra: (value === null || value === void 0 ? void 0 : value.extra) || Object.assign({ cookie_id,
2012
- article_id, subscription_title: subscriptionInfo.subscriptionTitle }, extraValues),
2013
- referrer: value === null || value === void 0 ? void 0 : value.referrer,
2014
- });
2015
- }, [
2016
- extraValues,
2017
- campaign_id,
2018
- url,
2019
- campaign_code,
2020
- article_title,
2021
- cookie_id,
2022
- ga_client_id,
2023
- article_id,
2024
- subscriptionInfo.subscriptionTitle,
2025
- ]);
2026
- React.useEffect(() => {
2027
- if (forceCampaignProps) {
2028
- setForceCampaign(forceCampaignProps);
2029
- return;
2030
- }
2031
- /** For Subscription Box */
2032
- if (categoryId) {
2033
- Service.getSubscriptionBoxInfo({
2034
- category: categoryId,
2035
- site: site_domain,
2036
- }).then((res) => {
2037
- const { _data } = res || {};
2038
- const { item, campaign_code } = _data || {};
2039
- const { icon, content } = item || {};
2040
- LeadLog('** LeadGen SubscriptionBox campaign_code : ', campaign_code);
2041
- LeadLog('** LeadGen SubscriptionBox subscription_icon : ', icon);
2042
- LeadLog('** LeadGen SubscriptionBox subscription_title : ', content);
2043
- setSubscriptionInfo({
2044
- subscriptionIcon: icon,
2045
- subscriptionTitle: content,
2046
- });
2047
- if (campaign_code) {
2048
- fetchCampaign(campaign_code);
2049
- }
2050
- });
2051
- return;
2052
- }
2053
- if (campaignCodeProps) {
2054
- fetchCampaign(campaignCodeProps);
2055
- }
2056
- }, [campaignCodeProps, categoryId]);
2057
- React.useEffect(() => {
2058
- leadStore.apiSsoUrl = apiSsoUrl;
2059
- leadStore.apiLeadUrl = apiLeadUrl;
2060
- leadStore.apiSubotUrl = apiSubotUrl;
2061
- }, [apiLeadUrl, apiSubotUrl, apiSsoUrl]);
2062
- if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
2063
- return null;
2064
- }
2065
- return (React__default["default"].createElement(LeadGenContext.Provider, { value: Object.assign(Object.assign(Object.assign({}, leadGenContextValue), subscriptionInfo), { submit,
2066
- submitSubscriptionBox,
2067
- impression }) },
2068
- React__default["default"].createElement(LeadGenTranslationProvider, { locale: locale }, children)));
2069
- };
2070
- const useLeadGenContext = () => {
2071
- const context = React.useContext(LeadGenContext);
2072
- return Object.assign(Object.assign({}, context), { apiLeadUrl: context.apiLeadUrl || leadStore.apiLeadUrl, apiSubotUrl: context.apiSubotUrl || leadStore.apiSubotUrl });
2073
- };
2074
-
2075
- // eslint-disable-next-line @typescript-eslint/no-var-requires
2076
- const customParseFormat = require('dayjs/plugin/customParseFormat');
2077
- dayjs__default["default"].extend(customParseFormat);
2078
- // You can give context variables any name
2079
- const [LeadFormProvider, useLeadFormContext, useLeadForm] = form.createFormContext();
2080
- const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
2081
- var _a;
2082
- const { t } = index.useTranslations();
2083
- const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
2084
- const LEAD_LOCALE = LEAD_LOCALE_DATA[(_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.lang] ||
2085
- LEAD_LOCALE_DATA['vi-VN'];
2086
- const validateObj = React.useMemo(() => {
2087
- const InputBlocks = [
2088
- 'TextBlock',
2089
- 'NumberBlock',
2090
- 'EmailBlock',
2091
- 'PhoneBlock',
2092
- 'DateBlock',
2093
- 'CheckboxBlock',
2094
- 'RadioBlock',
2095
- 'DropdownBlock',
2096
- 'PhoneOtpBlock',
2097
- 'WhatsappOtpBlock',
2098
- 'ZaloOtpBlock',
2099
- 'LocationBlock',
2100
- 'TncBlock',
2101
- ];
2102
- // ALL are required and can skip if not touched yet
2103
- const withSharedCheck = (name, cb,
2104
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2105
- block) => {
2106
- return (value) => {
2107
- var _a;
2108
- const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
2109
- if (!formRef.current.isTouched(name))
2110
- return;
2111
- if ((typeof value === 'string' && value.trim() === '') ||
2112
- typeof value === 'undefined' ||
2113
- (Array.isArray(value) && value.length === 0)) {
2114
- return isBLockRequired
2115
- ? t('validator.required')
2116
- : cb === null || cb === void 0 ? void 0 : cb(value);
2117
- }
2118
- return cb === null || cb === void 0 ? void 0 : cb(value);
2119
- };
2120
- };
2121
- return listBlockAdded
2122
- .filter((b) => InputBlocks.includes(b.name))
2123
- .reduce((r, b) => {
2124
- const { name: fieldType, data } = b || {};
2125
- const { value: fieldName, required } = data || {};
2126
- const isRequired = required !== null && required !== void 0 ? required : true;
2127
- if (fieldType === 'NumberBlock') {
2128
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2129
- if (value && isNaN(Number(value))) {
2130
- return t('validator.number');
2131
- }
2132
- }, b) });
2133
- }
2134
- else if (fieldType === 'EmailBlock') {
2135
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2136
- if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
2137
- return t('validator.email');
2138
- }
2139
- if (!value)
2140
- return;
2141
- validatingEmailRef.current = true;
2142
- setTimeout(() => {
2143
- formRef.current.setFieldError(fieldName, 'Validating...');
2144
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2145
- email: value,
2146
- })
2147
- .then((tKey) => {
2148
- if (tKey) {
2149
- formRef.current.setFieldError(fieldName, t(tKey));
2150
- }
2151
- else {
2152
- formRef.current.clearFieldError(fieldName);
2153
- }
2154
- validatingEmailRef.current = false;
2155
- })
2156
- .catch((e) => {
2157
- console.error(e);
2158
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2159
- validatingEmailRef.current = false;
2160
- });
2161
- }, 200);
2162
- }, b) });
2163
- }
2164
- else if (fieldType === 'PhoneBlock' ||
2165
- fieldType === 'PhoneOtpBlock' ||
2166
- fieldType === 'ZaloOtpBlock' ||
2167
- fieldType === 'WhatsappOtpBlock') {
2168
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2169
- if (value &&
2170
- window.intlTelInputUtils &&
2171
- !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
2172
- return t('validator.phone');
2173
- }
2174
- if (!value)
2175
- return;
2176
- validatingPhoneRef.current = true;
2177
- setTimeout(() => {
2178
- formRef.current.setFieldError(fieldName, 'Validating...');
2179
- if (b.data.singleSubmission) {
2180
- checkUsedPhoneOnlyWithCache(campaignId, value)
2181
- .then((tKey) => {
2182
- if (tKey) {
2183
- formRef.current.setFieldError(fieldName, t(tKey));
2184
- }
2185
- else {
2186
- formRef.current.clearFieldError(fieldName);
2187
- }
2188
- validatingPhoneRef.current = false;
2189
- })
2190
- .catch((err) => {
2191
- console.error(err);
2192
- formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
2193
- validatingPhoneRef.current = false;
2194
- });
2195
- }
2196
- else {
2197
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2198
- phone: value,
2199
- })
2200
- .then((tKey) => {
2201
- if (tKey) {
2202
- formRef.current.setFieldError(fieldName, t(tKey));
2203
- }
2204
- else {
2205
- formRef.current.clearFieldError(fieldName);
2206
- }
2207
- validatingPhoneRef.current = false;
2208
- })
2209
- .catch((e) => {
2210
- console.error(e);
2211
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2212
- validatingPhoneRef.current = false;
2213
- });
2214
- }
2215
- }, 200);
2216
- }, b) });
2217
- }
2218
- else if (fieldType === 'DateBlock') {
2219
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2220
- if (!isRequired && !value) {
2221
- return;
2222
- }
2223
- const errMsg = t('validator.dateInvalid');
2224
- const dayInJS = typeof value === 'string'
2225
- ? dayjs__default["default"](value, format, true)
2226
- : dayjs__default["default"](value);
2227
- if (!dayInJS.isValid()) {
2228
- return errMsg;
2229
- }
2230
- }, b) });
2231
- }
2232
- else if (fieldType === 'TncBlock') {
2233
- return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
2234
- if (isRequired && !value) {
2235
- return t('validator.required');
2236
- }
2237
- }, b) });
2238
- }
2239
- else {
2240
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
2241
- }
2242
- }, {});
2243
- }, [listBlockAdded.map((b) => b.name).join(','), format]);
2244
- const form = useLeadForm({
2245
- validateInputOnChange: true,
2246
- validateInputOnBlur: true,
2247
- clearInputErrorOnChange: true,
2248
- validate: validateObj,
2249
- initialValues,
2250
- });
2251
- const formRef = React.useRef(form);
2252
- formRef.current = form;
2253
- return { form, validateObj };
2254
- };
2255
-
2256
- const StyledLeadGenThankYou = styled__default["default"].div `
2257
- display: flex;
2258
- gap: 8px;
2259
- flex-direction: column;
2260
- padding-block: 24px;
2261
-
2262
- .leadgen-image {
2263
- width: 120px;
2264
- height: 120px;
2265
- margin-inline: auto;
2266
- object-fit: contain;
2267
- object-position: center;
2268
- text-align: center;
2269
- }
2270
-
2271
- .leadgen-title {
2272
- margin-block: 0;
2273
- color: ${miscTheme.theme.colors.gray900};
2274
- font-weight: 700;
2275
- font-size: 18px;
2276
- line-height: 28px;
2277
- letter-spacing: -0.2px;
2278
- }
2279
-
2280
- .leadgen-description {
2281
- margin-block: 0;
2282
- color: ${miscTheme.theme.colors.gray600};
2283
- font-weight: 400;
2284
- font-size: 14px;
2285
- line-height: 22px;
2286
- letter-spacing: -0.2px;
2287
- text-align: center;
2288
- }
2289
-
2290
- > [data-align] {
2291
- &[data-align='right'] {
2292
- text-align: right;
2293
- }
2294
- &[data-align='center'] {
2295
- text-align: center;
2296
- }
2297
- }
2298
- `;
2299
- const LeadGenThankYou = ({ image, title, description, showButton = false, button, className, style, }) => {
2300
- const { src } = image;
2301
- const { htmlText: titleText, align: titleAlign } = title;
2302
- const { htmlText: descriptionText, align: descriptionAlign } = description;
2303
- const { htmlText: buttonText, newtab, url, onClick } = button;
2304
- return (React__default["default"].createElement(StyledLeadGenThankYou, { className: className, style: style },
2305
- React__default["default"].createElement("img", { src: src, alt: "", className: "leadgen-thankyou_image leadgen-image" }),
2306
- React__default["default"].createElement("p", { className: "leadgen-thankyou_title leadgen-title", "data-align": titleAlign }, titleText),
2307
- React__default["default"].createElement("p", { className: "leadgen-thankyou_description leadgen-description", "data-align": descriptionAlign }, descriptionText),
2308
- !!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))));
2309
- };
2310
-
2311
- const StyledLeadGenSubscriptionBoxBody = styled__default["default"].div `
2312
- margin-top: 16px;
2313
- .leadgen-btn {
2314
- margin-top: 16px;
2315
- }
2316
- `;
2317
- const StyledLeadGenSubscriptionBoxHeaderImage = styled__default["default"].div `
2318
- margin-top: 3px;
2319
- margin-right: 20px;
2320
- width: 44px;
2321
- height: 44px;
2322
-
2323
- img {
2324
- width: 100%;
2325
- height: 100%;
2326
- object-fix: contain;
2327
- onject-position: center;
2328
- }
2329
-
2330
- :has(img[src='']) {
2331
- display: none;
2332
- }
2333
- `;
2334
- const StyledLeadGenSubscriptionBoxHeader = styled__default["default"].div `
2335
- display: flex;
2336
- align-items: center;
2337
- margin-bottom: 16px;
2338
- .leadgen-title {
2339
- margin-bottom: 0;
2340
- flex: 1;
2341
- min-width: 0;
2342
- color: ${miscTheme.theme.colors.gray900};
2343
- font-size: 18px;
2344
- font-weight: 400;
2345
- line-height: 1.4;
2346
- letter-spacing: -0.8px;
2347
- }
2348
- `;
2349
- const StyledLeadGenSubscriptionBox = styled__default["default"].div `
2350
- padding: 16px;
2351
- border: 1px solid ${miscTheme.theme.colors.neutral100};
2352
- border-radius: 12px;
2353
- margin-inline: auto;
2354
- .leadgen-form_inputs {
2355
- .leadgen-form_input {
2356
- width: 100%;
2357
- }
2358
- }
2359
-
2360
- .leadgen-form_input {
2361
- .mantine-Input-wrapper {
2362
- max-height: 56px;
2363
- }
2364
- }
2365
-
2366
- @media screen and (min-width: 768px) {
2367
- .leadgen-subscription_box_body {
2368
- display: flex;
2369
- > form {
2370
- flex: 1;
2371
- min-width: 0;
2372
-
2373
- .leadgen-form_inputs {
2374
- .leadgen-form_input {
2375
- width: calc(50% - 4px);
2376
- }
2377
- }
2378
- }
2379
-
2380
- .leadgen-btn {
2381
- margin-top: 0;
2382
- margin-left: 8px;
2383
- width: auto;
2384
- min-height: 56px;
2385
- }
2386
- }
2387
- }
2388
- `;
2389
- const StyledLeadGenSubscriptionBoxA = styled__default["default"].div `
2390
- .leadgen-form_input {
2391
- --phone-select: 45px;
2392
- .PhoneInput {
2393
- --phone-select: 45px;
2394
- .PhoneInputCountry {
2395
- margin-top: 1px;
2396
- pointer-events: none;
2397
- .PhoneInputCountryIconImg,
2398
- .PhoneInputArrowContainer {
2399
- display: none;
2400
- }
2401
- }
2402
- }
2403
- }
2404
- `;
2405
-
2406
- const PhoneInput = React.forwardRef((props, ref) => {
2407
- 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"]);
2408
- const id = idProps || uuid.v1() + name;
2409
- 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 },
2410
- React__default["default"].createElement("div", { className: "mantine-Input-wrapper" },
2411
- 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" })))));
2412
- });
2413
-
2414
- const formatLeadGenFormValue = (values, blocks) => {
2415
- const newValues = {};
2416
- for (const block of blocks) {
2417
- const { data } = block || {};
2418
- const { value: fieldName } = data || {};
2419
- if (fieldName in values) {
2420
- newValues[fieldName] = values[fieldName];
2421
- }
2422
- }
2423
- return newValues;
2424
- };
2425
-
2426
- const StyledLeadGenFormInner = styled__default["default"].div `
2427
- display: flex;
2428
- flex-wrap: wrap;
2429
- gap: 8px;
2430
- .leadgen-form_input {
2431
- width: calc(50% - 4px);
2432
- }
2433
-
2434
- .leadgen-form_input_checkbox {
2435
- width: 100%;
2436
- }
2437
- `;
2438
-
2439
- const cssInputNotShrink$1 = react.css `
2440
- height: 100% !important;
2441
- min-height: calc(var(--container-height, 56px) * 22 / 56);
2442
- color: ${miscTheme.theme.colors.gray800};
2443
- font-size: var(--input, 16px);
2444
- line-height: calc(var(--container-height, 56px) * 22 / 56);
2445
- border: none !important;
2446
- border-radius: 0 !important;
2447
- outline: none !important;
2448
- box-shadow: none !important;
2449
- padding: 0;
2450
- cursor: pointer;
2451
- opacity: 0;
2452
-
2453
- ::placeholder {
2454
- color: ${miscTheme.theme.colors.gray400};
2455
- }
2456
- `;
2457
- const cssInputShrink$1 = react.css `
2458
- height: auto !important;
2459
- cursor: text;
2460
- opacity: 1;
2461
- transition: 0.1s ease-in-out all;
2462
- `;
2463
- const cssLabelNotShrink$1 = react.css `
2464
- position: absolute;
2465
- top: calc(var(--container-height) / 2);
2466
- left: var(--space-x, 16px);
2467
- color: ${miscTheme.theme.colors.gray400};
2468
- font-size: var(--label-not-shrink, 16px);
2469
- font-weight: 400;
2470
- line-height: calc(var(--container-height, 56px) * 18 / 56);
2471
- margin: 0;
2472
- z-index: 1;
2473
- cursor: pointer;
2474
- transform: translateY(-50%);
2475
- transition: 0.125s ease-in all;
2476
- `;
2477
- const cssLabelShrink$1 = react.css `
2478
- color: ${miscTheme.theme.colors.gray600};
2479
- font-weight: 600;
2480
- font-size: var(--label-shrink, 12px);
2481
- top: calc(var(--container-height) * 7 / 56);
2482
- transform: none;
2483
- transition: 0.125s ease-out all;
2484
- `;
2485
- const cssWrapperInputNotShrink$1 = react.css `
2486
- min-height: var(--container-height, 56px);
2487
- display: flex;
2488
- align-items: flex-end;
2489
- border: 1px solid ${miscTheme.theme.colors.gray200};
2490
- border-radius: 8px;
2491
- background-color: #fff;
2492
- padding-inline: var(--space-x, 16px);
2493
- padding-block: var(--space-y-not-shrink, 16px);
2494
- cursor: pointer;
2495
- pointer-events: none;
2496
-
2497
- &:has(.mantine-Input-rightSection) {
2498
- padding-right: var(--container-height, 56px);
2499
- }
2500
-
2501
- .mantine-Input-icon {
2502
- display: none;
2503
- }
2504
-
2505
- .mantine-NumberInput-control {
2506
- border-color: ${miscTheme.theme.colors.gray200};
2507
- }
2508
- `;
2509
- const cssWrapperInputShrink$1 = react.css `
2510
- height: auto;
2511
- min-height: var(--container-height, 56px);
2512
- padding-block: var(--space-y-shrink, 7px);
2513
- cursor: text;
2514
- pointer-events: auto;
2515
- `;
2516
- const cssInputWrapperError$1 = react.css `
2517
- color: ${miscTheme.theme.colors.red800};
2518
- font-size: 12px;
2519
- line-height: 1.5;
2520
- `;
2521
- const StyledTextFieldContainer$1 = styled__default["default"].div `
2522
- --space-x: 16px;
2523
- --space-y-not-shrink: 16px;
2524
- --space-y-shrink: 7px;
2525
- --container-height: 56px;
2526
- --label-not-shrink: 16px;
2527
- --label-shrink: 12px;
2528
- --input: 16px;
2529
-
2530
- position: relative;
2531
- min-width: 100px;
2532
- max-width: 100%;
2533
- display: inline-block;
2534
-
2535
- .textField_wrapper {
2536
- display: inline-block;
2537
- width: 100%;
2538
- cursor: pointer;
2539
- }
2540
-
2541
- .mantine-InputWrapper-root {
2542
- &[data-invalid='true'] {
2543
- .mantine-Input-wrapper {
2544
- border-color: ${miscTheme.theme.colors.red400};
2545
- }
2546
- }
2547
-
2548
- .mantine-Input-wrapper {
2549
- &:has([data-invalid]) {
2550
- border-color: ${miscTheme.theme.colors.red400};
2551
- }
2552
- }
2553
-
2554
- .mantine-InputWrapper-error {
2555
- font-size: 12px !important;
2556
- }
2557
- }
2558
-
2559
- .mantine-InputWrapper-label {
2560
- ${cssLabelNotShrink$1}
2561
- }
2562
-
2563
- .mantine-Input-wrapper {
2564
- ${cssWrapperInputNotShrink$1}
2565
-
2566
- + .mantine-Popover-dropdown[data-position="bottom-start"] {
2567
- left: 0 !important;
2568
- }
2569
- + .mantine-Popover-dropdown[data-position='top-start'] {
2570
- top: unset !important;
2571
- left: 0 !important;
2572
- bottom: 100% !important;
2573
- }
2574
- }
2575
-
2576
- .mantine-Input-input {
2577
- ${cssInputNotShrink$1}
2578
- }
2579
-
2580
- &.textField_shrink,
2581
- &:focus-within {
2582
- .mantine-InputWrapper-label {
2583
- ${cssLabelShrink$1}
2584
- }
2585
-
2586
- .mantine-Input-wrapper {
2587
- ${cssWrapperInputShrink$1}
2588
- &.mantine-Select-wrapper {
2589
- .mantine-Select-rightSection {
2590
- pointer-events: auto !important;
2591
- }
2592
- }
2593
- }
2594
-
2595
- .mantine-Input-input {
2596
- ${cssInputShrink$1}
2597
- }
2598
-
2599
- &:has(.PhoneInput) {
2600
- .mantine-InputWrapper-label {
2601
- left: var(--space-x, 16px);
2602
- }
2603
- .PhoneInput {
2604
- .PhoneInputInput {
2605
- opacity: 1;
2606
- }
2607
- }
2608
- }
2609
- }
2610
-
2611
- .PhoneInput {
2612
- --phone-select: 75px;
2613
- --phone-input-space-x: 8px;
2614
- width: 100%;
2615
- opacity: 1;
2616
- border: none;
2617
- .PhoneInputCountry {
2618
- background-color: transparent;
2619
- border: none;
2620
- padding: 0;
2621
- width: var(--phone-select, 75px);
2622
- }
2623
- .PhoneInputInput {
2624
- flex: 1;
2625
- min-width: 0;
2626
- line-height: 1.5;
2627
- outline: none !important;
2628
- border: none;
2629
- box-shadow: none;
2630
- padding: 0 var(--phone-input-space-x, 8px);
2631
- opacity: 0;
2632
- color: ${miscTheme.theme.colors.gray800} !important;
2633
- :focus {
2634
- color: ${miscTheme.theme.colors.gray800} !important;
2635
- }
2636
- }
2637
- }
2638
-
2639
- &:has(.PhoneInput) {
2640
- .mantine-InputWrapper-label {
2641
- left: calc(
2642
- var(--space-x, 16px) + var(--phone-select, 75px) +
2643
- var(--phone-input-space-x, 8px)
2644
- );
2645
- }
2646
- }
2647
- `;
2648
- const StyledChoiceFieldContainer$1 = styled__default["default"].div `
2649
- &.leadgen-form_checkbox,
2650
- &.leadgen-form_radio {
2651
- width: 100%;
2652
- }
2653
-
2654
- &.leadgen-form_dropdown {
2655
- width: calc(50% - 12px);
2656
- }
2657
-
2658
- .mantine-InputWrapper-root {
2659
- display: block;
2660
- .mantine-InputWrapper-error {
2661
- font-size: 12px !important;
2662
- }
2663
- }
2664
-
2665
- .mantine-InputWrapper-label {
2666
- margin-bottom: 0.5rem;
2667
- color: ${miscTheme.theme.colors.gray800};
2668
- font-size: 16px;
2669
- font-weight: 400;
2670
- line-height: 1.5;
2671
- }
2672
-
2673
- .mantine-Radio-root,
2674
- .mantine-Checkbox-root {
2675
- gap: 8px;
2676
- min-width: calc(50% - 4px);
2677
-
2678
- input[type='radio'],
2679
- input[type='checkbox'] {
2680
- border-color: ${miscTheme.theme.colors.gray600};
2681
- width: 18px;
2682
- height: 18px;
2683
- }
2684
- input[type='checkbox'] {
2685
- border-radius: 4px;
2686
- }
2687
-
2688
- &[data-checked='true'] {
2689
- input[type='radio'],
2690
- input[type='checkbox'] {
2691
- border-color: ${miscTheme.theme.colors.primary600};
2692
- + svg {
2693
- color: ${miscTheme.theme.colors.primary600};
2694
- }
2695
- }
2696
-
2697
- input[type='radio'] {
2698
- background-color: white;
2699
- }
2700
- }
2701
-
2702
- .mantine-Checkbox-input {
2703
- &:checked {
2704
- border-color: ${miscTheme.theme.colors.primary600};
2705
- }
2706
- }
2707
- }
2708
-
2709
- .mantine-Radio-inner,
2710
- .mantine-Checkbox-inner {
2711
- width: 24px;
2712
- height: 24px;
2713
- display: flex;
2714
- align-items: center;
2715
- justify-content: center;
2716
- }
2717
-
2718
- .mantine-Radio-body,
2719
- .mantine-Checkbox-body {
2720
- display: flex;
2721
- align-items: center;
2722
- }
2723
-
2724
- .mantine-Radio-label,
2725
- .mantine-Checkbox-label {
2726
- padding-left: 8px;
2727
- color: ${miscTheme.theme.colors.gray800};
2728
- font-size: 14px;
2729
- line-height: 1.4;
2730
- letter-spacing: -0.2px;
2731
- }
2732
-
2733
- .leadgen-choiceContainer {
2734
- display: flex;
2735
- flex-wrap: wrap;
2736
- align-items: flex-start;
2737
- gap: 8px;
2738
- }
2739
-
2740
- .mantine-InputWrapper-error {
2741
- ${cssInputWrapperError$1}
2742
- }
2743
- `;
2744
-
2745
- const TextField$1 = (props) => {
2746
- const { shrink: shrinkProps, onChangeShrink, className, children } = props, restProps = tslib_es6.__rest(props, ["shrink", "onChangeShrink", "className", "children"]);
2747
- const containerRef = hooks.useClickOutside(() => {
2748
- if (shrinkProps) {
2749
- return;
2750
- }
2751
- setShrink(false);
2752
- onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(false);
2753
- });
2754
- const [shrink, setShrink] = React.useState(shrinkProps);
2755
- const onClick = React.useCallback((e) => {
2756
- setShrink(true);
2757
- onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(true);
2758
- if (shrink) {
2759
- return;
2760
- }
2761
- const $textEl = e.currentTarget.querySelectorAll('input:not([disabled]):not([type="submit"]),select:not([disabled]),textarea:not([disabled])');
2762
- const $focusEl = $textEl.item($textEl.length - 1);
2763
- if ($focusEl) {
2764
- $focusEl.focus();
2765
- setTimeout(() => {
2766
- $focusEl.scrollIntoView({
2767
- behavior: 'auto',
2768
- block: 'center',
2769
- inline: 'start',
2770
- });
2771
- }, 100);
2772
- }
2773
- }, [shrink]);
2774
- React.useEffect(() => {
2775
- setShrink(shrinkProps);
2776
- }, [shrinkProps]);
2777
- return (React__default["default"].createElement(StyledTextFieldContainer$1, Object.assign({ shrink: shrink, className: core.clsx(className, 'textField', { textField_shrink: !!shrink }) }, restProps),
2778
- React__default["default"].createElement("div", { ref: containerRef, onClick: onClick, className: "textField_wrapper" }, children)));
2779
- };
2780
- const ChoiceField$1 = (props) => {
2781
- const { children, className } = props, restProps = tslib_es6.__rest(props, ["children", "className"]);
2782
- return (React__default["default"].createElement(StyledChoiceFieldContainer$1, Object.assign({ className: core.clsx(className, 'choiceField') }, restProps), children));
2783
- };
2784
-
2785
- const libraries = ['places'];
2786
- const GoogleLocationBlock = (props) => {
2787
- var _a;
2788
- const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = tslib_es6.__rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
2789
- const [LoadScript, setLoadScript] = React.useState(null);
2790
- const [value, setValue] = React.useState(defaultValue || valueProps);
2791
- 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]);
2792
- const onChangeAutocomplete = React.useCallback((s) => {
2793
- setValue(s);
2794
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
2795
- }, []);
2796
- const onClickItem = React.useCallback((item) => {
2797
- /** For sure get value */
2798
- setValue(item.value);
2799
- const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
2800
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
2801
- }, [onChangeProps, predictions]);
2802
- React.useEffect(() => {
2803
- setValue(valueProps);
2804
- }, [valueProps]);
2805
- React.useEffect(() => {
2806
- var _a, _b, _c;
2807
- // only load extra google script when not yet loaded
2808
- 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) {
2809
- Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@react-google-maps/api')); }).then((m) => {
2810
- setLoadScript(() => m.LoadScript);
2811
- });
2812
- }
2813
- }, []);
2814
- return (React__default["default"].createElement(core.Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
2815
- return { value: pred.description, label: pred.description };
2816
- }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: index$6.ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
2817
- return (React__default["default"].createElement(React__default["default"].Fragment, null,
2818
- 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%' } })),
2819
- children));
2820
- } }, restProps)));
2821
- };
2822
-
2823
- const LeadGenForm = React.forwardRef((props, ref) => {
2824
- const { locale, blocks, scrollToErrorField = true, form: formProps, rules: validate, initialValues, onFinish, onFinishFailed, className, style, } = props;
2825
- const formRef = React.useRef(null);
2826
- const form$1 = formProps || form.useForm({ initialValues, validate });
2827
- const middlewareFinish = React.useCallback((values, event) => {
2828
- /** Set `touched` all values for validation when submiting */
2829
- form$1.setTouched(blocks.reduce((touched, { data }) => {
2830
- touched[data.value] = true;
2831
- return touched;
2832
- }, {}));
2833
- /** Wait for `touched` state and then submit */
2834
- setTimeout(() => {
2835
- const { hasErrors } = form$1.validate();
2836
- if (hasErrors) {
2837
- return;
2838
- }
2839
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatLeadGenFormValue(values, blocks), event);
2840
- }, 100);
2841
- }, [form$1, blocks]);
2842
- const middlewareFinishFailed = React.useCallback((errors, values, events) => {
2843
- if (scrollToErrorField && errors) {
2844
- const firstErrorKey = Object.keys(errors)[0];
2845
- const firstErrorElement = document.querySelector(`[name="${firstErrorKey}"]`);
2846
- if (firstErrorElement && (firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus)) {
2847
- setTimeout(() => {
2848
- firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
2849
- firstErrorElement.scrollIntoView({
2850
- behavior: 'auto',
2851
- block: 'center',
2852
- inline: 'center',
2853
- });
2854
- }, 100);
2855
- }
2856
- }
2857
- onFinishFailed === null || onFinishFailed === void 0 ? void 0 : onFinishFailed(errors, values, events);
2858
- }, [scrollToErrorField]);
2859
- React.useEffect(() => {
2860
- (() => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
2861
- if (!window.intlTelInputUtils) {
2862
- yield require('intl-tel-input/build/js/utils');
2863
- }
2864
- }))();
2865
- }, []);
2866
- React.useImperativeHandle(ref, () => (Object.assign(Object.assign({}, form$1), { submit: () => {
2867
- formRef.current.requestSubmit();
2868
- } })), [form$1, formRef]);
2869
- if (!blocks || !blocks.length) {
2870
- return null;
2871
- }
2872
- return (React__default["default"].createElement("form", { ref: formRef, onSubmit: form$1.onSubmit(middlewareFinish, middlewareFinishFailed), className: className, style: style },
2873
- React__default["default"].createElement(StyledLeadGenFormInner, { className: "leadgen-form_inputs" }, blocks.map((block, idx) => {
2874
- const { id, name: blockName, data } = block;
2875
- const { placeholder, value: name, required, listQuestion, valueHTML, isSendMailChimp = false, } = data;
2876
- const formInputProps = form$1.getInputProps(name);
2877
- const { value, error } = formInputProps;
2878
- const reactKey = `${id}-${idx}`;
2879
- switch (blockName) {
2880
- case LEADGEN_BLOCK.TextBlock: {
2881
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2882
- 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))));
2883
- }
2884
- case LEADGEN_BLOCK.NumberBlock: {
2885
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2886
- 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))));
2887
- }
2888
- case LEADGEN_BLOCK.EmailBlock: {
2889
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2890
- 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))));
2891
- }
2892
- case LEADGEN_BLOCK.PhoneOtpBlock:
2893
- case LEADGEN_BLOCK.WhatsappOtpBlock:
2894
- case LEADGEN_BLOCK.ZaloOtpBlock:
2895
- case LEADGEN_BLOCK.PhoneBlock: {
2896
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2897
- 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))));
2898
- }
2899
- case LEADGEN_BLOCK.LocationBlock: {
2900
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2901
- 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))));
2902
- }
2903
- case LEADGEN_BLOCK.DateBlock: {
2904
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2905
- 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))));
2906
- }
2907
- case LEADGEN_BLOCK.DropdownBlock:
2908
- return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2909
- React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2910
- React__default["default"].createElement(core.Select, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, data: listQuestion.map((l) => ({
2911
- value: l.value,
2912
- label: l.placeholder,
2913
- })) }, formInputProps))));
2914
- case LEADGEN_BLOCK.CheckboxBlock: {
2915
- const formInputCheckboxProps = form$1.getInputProps(name, {
2916
- type: 'checkbox',
2917
- });
2918
- return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2919
- isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2920
- React__default["default"].createElement(core.Checkbox.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, sx: {
2921
- display: 'flex',
2922
- flexDirection: 'column',
2923
- flexWrap: 'wrap',
2924
- gap: 8,
2925
- }, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2926
- return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2927
- } }, formInputCheckboxProps), listQuestion.map((l, _idx) => (React__default["default"].createElement(core.Checkbox, { name: name, key: _idx, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2928
- }
2929
- case LEADGEN_BLOCK.RadioBlock: {
2930
- return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2931
- isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2932
- 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) => {
2933
- return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2934
- } }, formInputProps), listQuestion.map((l, _index) => (React__default["default"].createElement(core.Radio, { name: name, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2935
- }
2936
- case LEADGEN_BLOCK.TncBlock:
2937
- return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2938
- React__default["default"].createElement(core.Input.Wrapper, { error: error },
2939
- 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)))));
2940
- default: {
2941
- return null;
2942
- }
2943
- }
2944
- }))));
2945
- });
2946
-
2947
- const LEADGEN_ORDER_INPUT_WRAPPER = ['label', 'input', 'description', 'error'];
2948
-
2949
- const LeadGenSubscriptionBoxA = (props) => {
2950
- const { loading, image, title, submitText, locale, blocks, form, rules, onFinish, } = props;
2951
- const formRef = React.useRef();
2952
- const imageComp = React.useMemo(() => {
2953
- if (!image) {
2954
- return null;
2955
- }
2956
- return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeaderImage, null,
2957
- React__default["default"].createElement("img", { src: image, alt: "" })));
2958
- }, [image]);
2959
- const titleComp = React.useMemo(() => {
2960
- if (typeof title === 'string') {
2961
- return (React__default["default"].createElement("p", { className: "leadgen-title", dangerouslySetInnerHTML: { __html: title } }));
2962
- }
2963
- return React__default["default"].createElement("p", { className: "leadgen-title" }, title);
2964
- }, [title]);
2965
- return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxA, { className: "subcription_box_A" },
2966
- React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeader, { className: "leadgen-subscription_box_header" },
2967
- imageComp,
2968
- titleComp),
2969
- React__default["default"].createElement(StyledLeadGenSubscriptionBoxBody, { className: "leadgen-subscription_box_body" },
2970
- React__default["default"].createElement(LeadGenForm, { ref: formRef, form: form, rules: rules, blocks: blocks, locale: locale, onFinish: onFinish, className: "leadgen-subscription_box_form" }),
2971
- React__default["default"].createElement(core.Button, { disabled: loading, loading: loading, variant: "filled", size: "lg", onClick: () => {
2972
- formRef.current.submit();
2973
- }, className: "leadgen-btn leadgen-btn_action", fullWidth: true }, submitText))));
2974
- };
2975
-
2976
- const LeadGenSubscriptionBoxWithoutMemo = ({ locale, userInfo, forceCampaign, categoryId, }) => {
2977
- var _a, _b, _c;
2978
- const { image, extra_fields, id: campaign_id, bot_id: campaign_subot_id = [], ThankYouBlock, } = forceCampaign || {};
2979
- const { textBlocks, listBlockAdded, actionBlocks } = extra_fields || {};
2980
- const { submitBlock } = actionBlocks || {};
2981
- const { apiLeadUrl, subscriptionIcon, subscriptionTitle, submitSubscriptionBox, impression, onFinish, } = useLeadGenContext();
2982
- const { t } = index.useTranslations();
2983
- const { action: { pushNotifications }, } = React.useContext(togetherComponentGlobalContext.TogetherComponentGlobalContext);
2984
- const refContainer = React.useRef(null);
2985
- const [loading, setLoading] = React.useState(false);
2986
- const [showThankyou, setShowThankyou] = React.useState(false);
2987
- const validatingEmailRef = React.useRef(false);
2988
- const validatingPhoneRef = React.useRef(false);
2989
- const { form, validateObj } = useLeadFormConfig({
2990
- listBlockAdded,
2991
- campaignId: campaign_id,
2992
- campaign_subot_id,
2993
- validatingEmailRef,
2994
- validatingPhoneRef,
2995
- userInfo,
2996
- });
2997
- const subscription_title = React.useMemo(() => {
2998
- var _a, _b;
2999
- return subscriptionTitle ||
3000
- ((_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
- t('leadgen.message.title.default');
3002
- }, [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]);
3003
- const { image: thankyouImage, title: thankyouTitle, description: thankyouDescription, button: thankyouButton, } = ThankYouBlock || {};
3004
- const intersectionObserverCallback = React.useCallback((entries) => {
3005
- entries.forEach((entry) => {
3006
- const { isIntersecting, target } = entry;
3007
- if (!showThankyou &&
3008
- isIntersecting &&
3009
- target === refContainer.current) {
3010
- impression();
3011
- }
3012
- });
3013
- }, [impression, showThankyou]);
3014
- const IObserver = new IntersectionObserver(intersectionObserverCallback);
3015
- const middlewareOnSubmit = React.useCallback((values) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
3016
- const newValues = {
3017
- subscription_title,
3018
- };
3019
- const ssoValues = {
3020
- sso_user_id: undefined,
3021
- sso_uuid: undefined,
3022
- sso_verified_profile: undefined,
3023
- };
3024
- const valueKeys = Object.keys(values);
3025
- for (const key of valueKeys) {
3026
- const isPhoneField = leadGenFieldNamePhone(listBlockAdded).some((k) => k === key);
3027
- if (isPhoneField) {
3028
- const phone = PhoneInputBase.parsePhoneNumber(values[key]);
3029
- if (phone.isValid()) {
3030
- /** Seperate `area_code` and `phone_number` for BE */
3031
- newValues['area_code'] = `+${phone.countryCallingCode}`;
3032
- newValues['phone_number'] = phone.nationalNumber;
3033
- /** Only case login has this update */
3034
- if ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) && (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid)) {
3035
- ssoValues['sso_verified_profile'] =
3036
- phone.number === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone) ? 1 : 0;
3037
- ssoValues['sso_user_id'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.id;
3038
- ssoValues['sso_uuid'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid;
3039
- }
3040
- }
3041
- continue;
3042
- }
3043
- newValues[key] = values[key];
3044
- }
3045
- setLoading(true);
3046
- try {
3047
- const { _data } = (yield submitSubscriptionBox(Object.assign(Object.assign({}, newValues), ssoValues))) || {};
3048
- const { model } = _data || {};
3049
- if (model && (model === null || model === void 0 ? void 0 : model.id)) {
3050
- setShowThankyou(true);
3051
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(Object.assign(Object.assign({}, newValues), ssoValues), listBlockAdded || []);
3052
- }
3053
- }
3054
- catch (error) {
3055
- LeadLog('** LeadGen SubscriptionBox error : ', error);
3056
- pushNotifications({
3057
- message: t('leadgen.message.error.default'),
3058
- type: 'danger',
3059
- });
3060
- }
3061
- setLoading(false);
3062
- }), [
3063
- subscription_title,
3064
- listBlockAdded,
3065
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
3066
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid,
3067
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone,
3068
- ]);
3069
- React.useEffect(() => {
3070
- if (refContainer.current) {
3071
- IObserver.observe(refContainer.current);
3072
- }
3073
- return () => {
3074
- IObserver.disconnect();
3075
- };
3076
- }, [categoryId]);
3077
- return (React__default["default"].createElement("div", { ref: refContainer },
3078
- React__default["default"].createElement(StyledLeadGenSubscriptionBox, null,
3079
- 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 })),
3080
- !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 })))));
3081
- };
3082
- const LeadGenSubscriptionBox$1 = React.memo(LeadGenSubscriptionBoxWithoutMemo);
3083
-
3084
- const Container = () => {
3085
- const context = React.useContext(LeadGenContext);
3086
- const { campaign_code, locale, siteId, siteDomain, userInfo, forceCampaign } = context;
3087
- if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
3088
- return null;
3089
- }
3090
- return (React__default["default"].createElement(LeadGenSubscriptionBox$1, { locale: locale, siteId: siteId, siteDomain: siteDomain, userInfo: userInfo, forceCampaign: forceCampaign, campaign_code: campaign_code }));
3091
- };
3092
- Container.displayName = 'LeadGenSubscriptionBox';
3093
- const LeadGenSubscriptionBoxContainer = (props) => {
3094
- const { apiUrl, apiSubotUrl } = props;
3095
- return (React__default["default"].createElement(LeadGenContextProvider, Object.assign({}, props, { apiLeadUrl: apiUrl, apiSubotUrl: apiSubotUrl }),
3096
- React__default["default"].createElement(Container, null)));
3097
- };
3098
- const LeadGenSubscriptionBox = LeadGenSubscriptionBoxContainer;
3099
-
3100
- const useImageSize = (src) => {
3101
- const [width, setWidth] = React.useState(16);
3102
- const [height, setHeight] = React.useState(9);
3103
- const [loaded, setLoaded] = React.useState(false);
3104
- // load src image to get its width and height
3105
- React.useEffect(() => {
3106
- setLoaded(false);
3107
- if (src) {
3108
- const img = new Image();
3109
- img.addEventListener('load', () => {
3110
- setWidth(img.naturalWidth);
3111
- setHeight(img.naturalHeight);
3112
- setLoaded(true);
3113
- });
3114
- img.addEventListener('error', () => {
3115
- setWidth(16);
3116
- setHeight(9);
3117
- setLoaded(true);
3118
- });
3119
- img.src = src;
3120
- }
3121
- else {
3122
- setWidth(16);
3123
- setHeight(9);
3124
- setLoaded(true);
3125
- }
3126
- }, [src]);
3127
- return {
3128
- loaded,
3129
- width,
3130
- height,
3131
- };
3132
- };
3133
-
3134
- const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default["default"].createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
3135
- 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 },
3136
- 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" }))));
3137
-
3138
- // url: imageBlocks.imageMobile.data.url
3139
- // newTab: imageBlocks.imageMobile.data.newtab
3140
- // imageMobile: campaignShow.image
3141
- // imageDestkop: campaignShow.image_desktop
3142
- const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
3143
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3144
- const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
3145
- if (!imageMobileLoaded || !imageDestkopLoaded)
1440
+ const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default["default"].createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
1441
+ React__default["default"].createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
1442
+ React__default["default"].createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
1443
+
1444
+ // url: imageBlocks.imageMobile.data.url
1445
+ // newTab: imageBlocks.imageMobile.data.newtab
1446
+ // imageMobile: campaignShow.image
1447
+ // imageDestkop: campaignShow.image_desktop
1448
+ const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
1449
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1450
+ const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
1451
+ if (!imageMobileLoaded || !imageDestkopLoaded)
3146
1452
  return null;
3147
1453
  return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
3148
1454
  React__default["default"].createElement("div", { className: "le-center-tab-popup" },
3149
1455
  React__default["default"].createElement("div", { style: { position: 'relative' } },
3150
1456
  React__default["default"].createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
3151
- index$7.isVideo(imageMobile) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
1457
+ index$6.isVideo(imageMobile) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
3152
1458
  React__default["default"].createElement("source", { src: imageMobile }))) : (React__default["default"].createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
3153
1459
  aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3154
1460
  } })),
3155
- index$7.isVideo(imageDestkop) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
1461
+ index$6.isVideo(imageDestkop) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
3156
1462
  React__default["default"].createElement("source", { src: imageDestkop }))) : (React__default["default"].createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
3157
1463
  aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
3158
1464
  } }))),
@@ -3211,7 +1517,7 @@ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, su
3211
1517
  };
3212
1518
 
3213
1519
  const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
3214
- const { primaryColor } = React.useContext(LeadGenContext$1);
1520
+ const { primaryColor } = React.useContext(LeadGenContext);
3215
1521
  const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
3216
1522
  if (!imageLoaded)
3217
1523
  return null;
@@ -3379,6 +1685,222 @@ const EmptyComponent = ({ onClose, onContinue, }) => {
3379
1685
  React__default["default"].createElement(core.Button, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
3380
1686
  };
3381
1687
 
1688
+ const libraries = ['places'];
1689
+ const GoogleLocationBlock = (props) => {
1690
+ var _a;
1691
+ const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = tslib_es6.__rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
1692
+ const [LoadScript, setLoadScript] = React.useState(null);
1693
+ const [value, setValue] = React.useState(defaultValue || valueProps);
1694
+ const { predictions } = usePlacesAutocomplete.usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
1695
+ const onChangeAutocomplete = React.useCallback((s) => {
1696
+ setValue(s);
1697
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
1698
+ }, []);
1699
+ const onClickItem = React.useCallback((item) => {
1700
+ /** For sure get value */
1701
+ setValue(item.value);
1702
+ const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
1703
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
1704
+ }, [onChangeProps, predictions]);
1705
+ React.useEffect(() => {
1706
+ setValue(valueProps);
1707
+ }, [valueProps]);
1708
+ React.useEffect(() => {
1709
+ var _a, _b, _c;
1710
+ // only load extra google script when not yet loaded
1711
+ if (!((_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.places) === null || _c === void 0 ? void 0 : _c.AutocompleteService) && !LoadScript) {
1712
+ Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@react-google-maps/api')); }).then((m) => {
1713
+ setLoadScript(() => m.LoadScript);
1714
+ });
1715
+ }
1716
+ }, []);
1717
+ return (React__default["default"].createElement(core.Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
1718
+ return { value: pred.description, label: pred.description };
1719
+ }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: index$7.ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
1720
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
1721
+ LoadScript && (React__default["default"].createElement(LoadScript, { googleMapsApiKey: usePlacesAutocomplete.GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default["default"].createElement(React__default["default"].Fragment, null), style: { width: '100%' } })),
1722
+ children));
1723
+ } }, restProps)));
1724
+ };
1725
+
1726
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
1727
+ const customParseFormat = require('dayjs/plugin/customParseFormat');
1728
+ dayjs__default["default"].extend(customParseFormat);
1729
+ // You can give context variables any name
1730
+ const [LeadFormProvider, useLeadFormContext, useLeadForm] = form.createFormContext();
1731
+ const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
1732
+ const { t } = index.useTranslations();
1733
+ const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
1734
+ const validateObj = React.useMemo(() => {
1735
+ const InputBlocks = [
1736
+ 'TextBlock',
1737
+ 'NumberBlock',
1738
+ 'EmailBlock',
1739
+ 'PhoneBlock',
1740
+ 'DateBlock',
1741
+ 'CheckboxBlock',
1742
+ 'RadioBlock',
1743
+ 'DropdownBlock',
1744
+ 'PhoneOtpBlock',
1745
+ 'WhatsappOtpBlock',
1746
+ 'ZaloOtpBlock',
1747
+ 'LocationBlock',
1748
+ 'TncBlock',
1749
+ ];
1750
+ // ALL are required and can skip if not touched yet
1751
+ const withSharedCheck = (name, cb,
1752
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1753
+ block) => {
1754
+ return (value) => {
1755
+ var _a;
1756
+ const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
1757
+ if (!formRef.current.isTouched(name))
1758
+ return;
1759
+ if ((typeof value === 'string' && value.trim() === '') ||
1760
+ typeof value === 'undefined' ||
1761
+ (Array.isArray(value) && value.length === 0)) {
1762
+ return isBLockRequired
1763
+ ? t('validator.required')
1764
+ : cb === null || cb === void 0 ? void 0 : cb(value);
1765
+ }
1766
+ return cb === null || cb === void 0 ? void 0 : cb(value);
1767
+ };
1768
+ };
1769
+ return listBlockAdded
1770
+ .filter((b) => InputBlocks.includes(b.name))
1771
+ .reduce((r, b) => {
1772
+ const { name: fieldType, data } = b || {};
1773
+ const { value: fieldName, required } = data || {};
1774
+ const isRequired = required !== null && required !== void 0 ? required : true;
1775
+ if (fieldType === 'NumberBlock') {
1776
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1777
+ if (value && isNaN(Number(value))) {
1778
+ return t('validator.number');
1779
+ }
1780
+ }, b) });
1781
+ }
1782
+ else if (fieldType === 'EmailBlock') {
1783
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1784
+ if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
1785
+ return t('validator.email');
1786
+ }
1787
+ if (!value)
1788
+ return;
1789
+ validatingEmailRef.current = true;
1790
+ setTimeout(() => {
1791
+ formRef.current.setFieldError(fieldName, 'Validating...');
1792
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1793
+ email: value,
1794
+ })
1795
+ .then((tKey) => {
1796
+ if (tKey) {
1797
+ formRef.current.setFieldError(fieldName, t(tKey));
1798
+ }
1799
+ else {
1800
+ formRef.current.clearFieldError(fieldName);
1801
+ }
1802
+ validatingEmailRef.current = false;
1803
+ })
1804
+ .catch((e) => {
1805
+ console.error(e);
1806
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
1807
+ validatingEmailRef.current = false;
1808
+ });
1809
+ }, 200);
1810
+ }, b) });
1811
+ }
1812
+ else if (fieldType === 'PhoneBlock' ||
1813
+ fieldType === 'PhoneOtpBlock' ||
1814
+ fieldType === 'ZaloOtpBlock' ||
1815
+ fieldType === 'WhatsappOtpBlock') {
1816
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1817
+ if (value &&
1818
+ window.intlTelInputUtils &&
1819
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
1820
+ return t('validator.phone');
1821
+ }
1822
+ if (!value)
1823
+ return;
1824
+ validatingPhoneRef.current = true;
1825
+ setTimeout(() => {
1826
+ formRef.current.setFieldError(fieldName, 'Validating...');
1827
+ if (b.data.singleSubmission) {
1828
+ checkUsedPhoneOnlyWithCache(campaignId, value)
1829
+ .then((tKey) => {
1830
+ if (tKey) {
1831
+ formRef.current.setFieldError(fieldName, t(tKey));
1832
+ }
1833
+ else {
1834
+ formRef.current.clearFieldError(fieldName);
1835
+ }
1836
+ validatingPhoneRef.current = false;
1837
+ })
1838
+ .catch((err) => {
1839
+ console.error(err);
1840
+ formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
1841
+ validatingPhoneRef.current = false;
1842
+ });
1843
+ }
1844
+ else {
1845
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1846
+ phone: value,
1847
+ })
1848
+ .then((tKey) => {
1849
+ if (tKey) {
1850
+ formRef.current.setFieldError(fieldName, t(tKey));
1851
+ }
1852
+ else {
1853
+ formRef.current.clearFieldError(fieldName);
1854
+ }
1855
+ validatingPhoneRef.current = false;
1856
+ })
1857
+ .catch((e) => {
1858
+ console.error(e);
1859
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
1860
+ validatingPhoneRef.current = false;
1861
+ });
1862
+ }
1863
+ }, 200);
1864
+ }, b) });
1865
+ }
1866
+ else if (fieldType === 'DateBlock') {
1867
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1868
+ if (!isRequired && !value) {
1869
+ return;
1870
+ }
1871
+ const errMsg = t('validator.dateInvalid');
1872
+ const dayInJS = typeof value === 'string'
1873
+ ? dayjs__default["default"](value, format, true)
1874
+ : dayjs__default["default"](value);
1875
+ if (!dayInJS.isValid()) {
1876
+ return errMsg;
1877
+ }
1878
+ }, b) });
1879
+ }
1880
+ else if (fieldType === 'TncBlock') {
1881
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
1882
+ if (isRequired && !value) {
1883
+ return t('validator.required');
1884
+ }
1885
+ }, b) });
1886
+ }
1887
+ else {
1888
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
1889
+ }
1890
+ }, {});
1891
+ }, [listBlockAdded.map((b) => b.name).join(','), format]);
1892
+ const form = useLeadForm({
1893
+ validateInputOnChange: true,
1894
+ validateInputOnBlur: true,
1895
+ clearInputErrorOnChange: true,
1896
+ validate: validateObj,
1897
+ initialValues,
1898
+ });
1899
+ const formRef = React.useRef(form);
1900
+ formRef.current = form;
1901
+ return { form, validateObj };
1902
+ };
1903
+
3382
1904
  const SubtitleBlock = ({ children, align, }) => (React__default["default"].createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
3383
1905
 
3384
1906
  const cssInputNotShrink = react.css `
@@ -3705,13 +2227,11 @@ const TextField = (props) => {
3705
2227
  const $focusEl = $textEl.item($textEl.length - 1);
3706
2228
  if ($focusEl) {
3707
2229
  $focusEl.focus();
3708
- setTimeout(() => {
3709
- $focusEl.scrollIntoView({
3710
- behavior: 'auto',
3711
- block: 'center',
3712
- inline: 'start',
3713
- });
3714
- }, 100);
2230
+ $focusEl.scrollIntoView({
2231
+ behavior: 'auto',
2232
+ block: 'center',
2233
+ inline: 'start',
2234
+ });
3715
2235
  }
3716
2236
  }, [shrink]);
3717
2237
  React.useEffect(() => {
@@ -3732,7 +2252,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
3732
2252
  const form = useLeadFormContext();
3733
2253
  const formValues = form.values;
3734
2254
  const labelTuples = React.useMemo(() => {
3735
- return ((index$6.ISO_FORMAT === null || index$6.ISO_FORMAT === void 0 ? void 0 : index$6.ISO_FORMAT[locale]) || index$6.ISO_FORMAT['vi-VN']).dateFormat
2255
+ 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
3736
2256
  .split('/')
3737
2257
  .map((key) => { var _a; return t((_a = index$8.COMMON_DATE_TRANSLATE_KEY === null || index$8.COMMON_DATE_TRANSLATE_KEY === void 0 ? void 0 : index$8.COMMON_DATE_TRANSLATE_KEY[key]) === null || _a === void 0 ? void 0 : _a.id); });
3738
2258
  }, [locale]);
@@ -3938,11 +2458,11 @@ const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
3938
2458
  if (!src) {
3939
2459
  return null;
3940
2460
  }
3941
- return (React__default["default"].createElement(StyleHeaderImage, { paddingTop: (1 / ratio) * 100, className: core.clsx(className, 'leadgen-header_image'), style: style }, index$7.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" }))));
2461
+ return (React__default["default"].createElement(StyleHeaderImage, { paddingTop: (1 / ratio) * 100, className: core.clsx(className, 'leadgen-header_image'), style: style }, index$6.isVideo(src) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true, className: "leadgen-header_image_feature leadgen-header_image_video", src: src })) : (React__default["default"].createElement("img", { src: src, draggable: "false", alt: "", className: "leadgen-header_image_feature leadgen-header_image_image" }))));
3942
2462
  };
3943
2463
 
3944
2464
  const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
3945
- const { primaryColor } = React.useContext(LeadGenContext$1);
2465
+ const { primaryColor } = React.useContext(LeadGenContext);
3946
2466
  const { t } = index.useTranslations();
3947
2467
  const phone = otpData.phone;
3948
2468
  const otpType = otpData.type;
@@ -4028,371 +2548,715 @@ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
4028
2548
  // type: 'danger',
4029
2549
  // })
4030
2550
  }
4031
- setIsSubmitLoading(false);
2551
+ setIsSubmitLoading(false);
2552
+ });
2553
+ React.useEffect(() => {
2554
+ setTimeout(() => {
2555
+ if (resendTimer > 0) {
2556
+ setResendTimer((r) => r - 1);
2557
+ }
2558
+ }, 1000);
2559
+ }, [resendTimer]);
2560
+ React.useEffect(() => {
2561
+ if (autoSendWhenOpen && !resendTimer) {
2562
+ sendOtp();
2563
+ }
2564
+ }, []);
2565
+ return (React__default["default"].createElement("form", { onSubmit: (e) => {
2566
+ e.preventDefault();
2567
+ submitOtp();
2568
+ }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
2569
+ React__default["default"].createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
2570
+ phone: `<strong>${displayPhone}</strong>`,
2571
+ }), footer: React__default["default"].createElement(React__default["default"].Fragment, null,
2572
+ React__default["default"].createElement(core.Button, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
2573
+ React__default["default"].createElement(core.Button, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
2574
+ sendOtp();
2575
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
2576
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
2577
+ }))) },
2578
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
2579
+ React__default["default"].createElement(index$2.Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
2580
+ React__default["default"].createElement(index$2.OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
2581
+ setIsDirty(true);
2582
+ setOtp(v.toString());
2583
+ if (isDirty && !v)
2584
+ setErrorMsg('OTP is required');
2585
+ else
2586
+ setErrorMsg(undefined);
2587
+ } }))))));
2588
+ };
2589
+
2590
+ // url: imageBlocks.imageMobile.data.url
2591
+ // newTab: imageBlocks.imageMobile.data.newtab
2592
+ // image: campaignShow.image
2593
+ // imageDestkop: campaignShow.image_desktop
2594
+ const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
2595
+ LEADGEN_LAYOUT.Fullscreen,
2596
+ LEADGEN_LAYOUT.Slider,
2597
+ ];
2598
+ const LEADGEN_LIMIT_LIGHTBOXB = 6;
2599
+ const LEADGEN_SHOW_HEADER = [
2600
+ 'LightBoxA',
2601
+ 'InlineA',
2602
+ LEADGEN_LAYOUT.Sidebar,
2603
+ LEADGEN_LAYOUT.Slider,
2604
+ ];
2605
+ const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2606
+ var _a, _b;
2607
+ const { primaryColor } = React.useContext(LeadGenContext);
2608
+ const { isMobile } = useScreenSize.useScreenSize();
2609
+ const [open, setOpen] = React.useState(!!campaignId);
2610
+ const [showOtpPhone, setShowOtpPhone] = React.useState(null);
2611
+ const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
2612
+ const [snap, setSnap] = React.useState(0.8);
2613
+ const formRef = React.useRef();
2614
+ const onClose = () => {
2615
+ if (showOtpPhone) {
2616
+ setShowOtpPhone(null);
2617
+ }
2618
+ else {
2619
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2620
+ }
2621
+ };
2622
+ const textBlocks = JSON.parse(extraFields.textBlocks);
2623
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
2624
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
2625
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
2626
+ const currentPath = location.pathname;
2627
+ const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
2628
+ const { align: titleAlign } = textBlocks.titleBlock.data || {};
2629
+ const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
2630
+ const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
2631
+ const isLightBox = currentLayout.includes('LightBox');
2632
+ const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
2633
+ const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
2634
+ const isInline = currentLayout.includes('Inline');
2635
+ const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
2636
+ const isInPage = isInline || isSidebar;
2637
+ const isDrawer = isLightBoxB && isMobile;
2638
+ const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
2639
+ const hasForm = isLightBoxA
2640
+ ? listBlockAdded.some((item) => LEADGEN_BLOCK_IN_FORM.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
2641
+ : true;
2642
+ const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
2643
+ const showHeader = !!imageMobile || !!imageDesktop;
2644
+ const onlyHeader = !title && !description;
2645
+ const showButtonClose = !isInline;
2646
+ if (window.innerWidth < 769 &&
2647
+ LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
2648
+ console.log('😎 Not show fullscreen, slider on mobile ');
2649
+ return null;
2650
+ }
2651
+ React.useEffect(() => {
2652
+ if (isLightBox || isFullscreen) {
2653
+ document.body.classList.add('noscroll');
2654
+ }
2655
+ if (!window.intlTelInputUtils) {
2656
+ require('intl-tel-input/build/js/utils');
2657
+ }
2658
+ clearCacheUsedEmailOrPhone();
2659
+ }, []);
2660
+ const validatingPhoneRef = React.useRef(false);
2661
+ const validatingEmailRef = React.useRef(false);
2662
+ const { form, validateObj } = useLeadFormConfig({
2663
+ listBlockAdded,
2664
+ validatingPhoneRef,
2665
+ validatingEmailRef,
2666
+ campaignId,
2667
+ campaign_subot_id,
2668
+ userInfo,
2669
+ format: (_a = (index$7.ISO_FORMAT[locale] || index$7.ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
2670
+ });
2671
+ const middlewareOnSubmit = (e) => {
2672
+ e.preventDefault();
2673
+ // mark all as touched to allow validation
2674
+ const fields = Object.keys(validateObj);
2675
+ const fieldStatus = fields.reduce((acc, cur) => {
2676
+ acc[cur] = true;
2677
+ return acc;
2678
+ }, {});
2679
+ form.setTouched(fieldStatus);
2680
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
2681
+ return;
2682
+ }
2683
+ setTimeout(() => {
2684
+ form.onSubmit((v) => {
2685
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2686
+ if (Object.keys(form.errors).length)
2687
+ return;
2688
+ let newShowOtpPhone = null;
2689
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
2690
+ // not submit yet, open otp
2691
+ const fieldName = (_b = (_a = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock)) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value;
2692
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
2693
+ newShowOtpPhone = {
2694
+ phone: v[fieldName],
2695
+ type: 'phone',
2696
+ };
2697
+ }
2698
+ }
2699
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
2700
+ // not submit yet, open otp
2701
+ const fieldName = (_e = (_d = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock)) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.value;
2702
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
2703
+ newShowOtpPhone = {
2704
+ phone: v[fieldName],
2705
+ type: 'whatsapp',
2706
+ };
2707
+ }
2708
+ }
2709
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
2710
+ // not submit yet, open otp
2711
+ const fieldName = (_h = (_g = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock)) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.value;
2712
+ if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
2713
+ newShowOtpPhone = {
2714
+ phone: v[fieldName],
2715
+ type: 'zalo',
2716
+ };
2717
+ }
2718
+ }
2719
+ if (newShowOtpPhone) {
2720
+ setIsSubmitLoading(true);
2721
+ Service.sendSMSOtpLead(newShowOtpPhone)
2722
+ .then((res) => {
2723
+ var _a;
2724
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2725
+ if (respMessage === 'This phone number was verified') {
2726
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2727
+ return;
2728
+ }
2729
+ setShowOtpPhone(newShowOtpPhone);
2730
+ })
2731
+ .finally(() => {
2732
+ setIsSubmitLoading(false);
2733
+ });
2734
+ return;
2735
+ }
2736
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2737
+ })(e);
2738
+ }, 100);
2739
+ };
2740
+ const onOpenChange = (_open) => {
2741
+ setOpen(_open);
2742
+ if (!_open) {
2743
+ setTimeout(() => {
2744
+ onClose();
2745
+ }, 250);
2746
+ }
2747
+ };
2748
+ const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
2749
+ const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
2750
+ const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
2751
+ const renderAfterImageSizes = imageMobileLoaded &&
2752
+ imageDesktopLoaded &&
2753
+ (isFullscreen ? imageBackgroundLoaded : true);
2754
+ const ButtonSubmit = React.useMemo(() => {
2755
+ var _a;
2756
+ return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default["default"].createElement(core.Button, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
2757
+ }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
2758
+ const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
2759
+ const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default["default"].createElement(React__default["default"].Fragment, null, LinkButtonBlock.map((item, index) => {
2760
+ var _a, _b, _c;
2761
+ return (React__default["default"].createElement(core.Button, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
2762
+ onClose === null || onClose === void 0 ? void 0 : onClose();
2763
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2764
+ } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
2765
+ })));
2766
+ const PopupHeader = showHeader && (React__default["default"].createElement("header", { className: core.clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default["default"].createElement(React__default["default"].Fragment, null,
2767
+ React__default["default"].createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
2768
+ React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
2769
+ const PopupEmpty = showEmpty && (React__default["default"].createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
2770
+ const PopupForm = (React__default["default"].createElement(LeadFormProvider, { form: form },
2771
+ React__default["default"].createElement("form", { ref: formRef, className: "leadgen-form", onSubmit: middlewareOnSubmit },
2772
+ React__default["default"].createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
2773
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
2774
+ React__default["default"].createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
2775
+ const PopupOtp = showOtpPhone && (React__default["default"].createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
2776
+ setShowOtpPhone(null);
2777
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
2778
+ } }));
2779
+ const PopupThankYou = showThankyou && (React__default["default"].createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
2780
+ const PopupContent = (React__default["default"].createElement("div", { className: core.clsx('leadgen-content', {
2781
+ 'leadgen-content_small': limitFieldsLightBoxB,
2782
+ }) },
2783
+ !headerInsideFormContainer && PopupHeader,
2784
+ !onlyHeader && (React__default["default"].createElement("div", { className: "leadgen-inner" },
2785
+ PopupThankYou,
2786
+ !showThankyou && (React__default["default"].createElement(React__default["default"].Fragment, null,
2787
+ PopupOtp,
2788
+ PopupEmpty,
2789
+ !(showOtpPhone || showEmpty) && PopupForm))))));
2790
+ const styleOverlay = React.useMemo(() => {
2791
+ let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
2792
+ if (isMobile && imageOverlayMobile) {
2793
+ styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
2794
+ }
2795
+ if (!isMobile && imageOverlayDesktop) {
2796
+ styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
2797
+ }
2798
+ return styleContent;
2799
+ }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
2800
+ const PopupWrapper = (React__default["default"].createElement(React__default["default"].Fragment, null,
2801
+ React__default["default"].createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
2802
+ React__default["default"].createElement("div", { className: core.clsx('leadgen-wrapper', {
2803
+ 'leadgen-wrapper_small': limitFieldsLightBoxB,
2804
+ }) },
2805
+ showButtonClose && (React__default["default"].createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
2806
+ PopupContent)));
2807
+ const popupContainerClassName = core.clsx('leadgen', `leadgen-${currentLayout}`, {
2808
+ 'leadgen-lightbox': isLightBox,
2809
+ 'leadgen-inline': isInPage,
2810
+ 'leadgen-slider': isSlider,
4032
2811
  });
4033
- React.useEffect(() => {
4034
- setTimeout(() => {
4035
- if (resendTimer > 0) {
4036
- setResendTimer((r) => r - 1);
4037
- }
4038
- }, 1000);
4039
- }, [resendTimer]);
4040
- React.useEffect(() => {
4041
- if (autoSendWhenOpen && !resendTimer) {
4042
- sendOtp();
4043
- }
4044
- }, []);
4045
- return (React__default["default"].createElement("form", { onSubmit: (e) => {
4046
- e.preventDefault();
4047
- submitOtp();
4048
- }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
4049
- React__default["default"].createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
4050
- phone: `<strong>${displayPhone}</strong>`,
4051
- }), footer: React__default["default"].createElement(React__default["default"].Fragment, null,
4052
- 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')),
4053
- 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: () => {
4054
- sendOtp();
4055
- }, disabled: !!resendTimer }, t('lead.otp.resend', {
4056
- timer: resendTimer ? ` (${resendTimer}s)` : '',
4057
- }))) },
4058
- React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4059
- React__default["default"].createElement(index$2.Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
4060
- React__default["default"].createElement(index$2.OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
4061
- setIsDirty(true);
4062
- setOtp(v.toString());
4063
- if (isDirty && !v)
4064
- setErrorMsg('OTP is required');
4065
- else
4066
- setErrorMsg(undefined);
4067
- } }))))));
2812
+ const PopupContainer = isDrawer ? (React__default["default"].createElement(index$a.DrawerComponent, { fadeFromIndex: index$7.ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
2813
+ PopupWrapper,
2814
+ React__default["default"].createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default["default"].createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
2815
+ isFullscreen ? (React__default["default"].createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
2816
+ aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
2817
+ } })) : null,
2818
+ PopupWrapper));
2819
+ if (!renderAfterImageSizes)
2820
+ return null;
2821
+ if (isLightBox || isFullscreen || isSlider) {
2822
+ return PopupContainer;
2823
+ }
2824
+ else if (isSidebar) {
2825
+ return React__default["default"].createElement(SideBarLayout, { content: PopupContainer });
2826
+ }
2827
+ else if (isInline) {
2828
+ return (React__default["default"].createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
2829
+ }
2830
+ return null;
2831
+ };
2832
+
2833
+ const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
2834
+ const currentPath = location.pathname;
2835
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
2836
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
2837
+ if (!imageMobileLoaded || !imageDesktopLoaded)
2838
+ return null;
2839
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
2840
+ currentLayout == 'SkinA' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
2841
+ React__default["default"].createElement("div", { className: "le-skin-a-desktop" },
2842
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
2843
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
2844
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2845
+ } }),
2846
+ React__default["default"].createElement("a", { style: {
2847
+ position: 'absolute',
2848
+ top: '75%',
2849
+ left: '50%',
2850
+ transform: 'translate(-50%, -50%)',
2851
+ textAlign: 'center',
2852
+ width: 'calc(100% - 15px)',
2853
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2854
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
2855
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
2856
+ React__default["default"].createElement("div", { className: "" },
2857
+ React__default["default"].createElement("div", { style: { position: 'relative', zIndex: 10000 } },
2858
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
2859
+ width: '100%',
2860
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2861
+ } }),
2862
+ React__default["default"].createElement("a", { style: {
2863
+ position: 'absolute',
2864
+ top: '75%',
2865
+ left: '50%',
2866
+ transform: 'translate(-50%, -50%)',
2867
+ textAlign: 'center',
2868
+ width: '100%',
2869
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2870
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2871
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
2872
+ React__default["default"].createElement("aside", { className: "le-only-mobile" },
2873
+ React__default["default"].createElement("div", { className: "le-skin-mobile" },
2874
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
2875
+ index$6.isVideo(imageMobile) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true },
2876
+ React__default["default"].createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default["default"].createElement("img", { src: imageMobile, style: {
2877
+ width: '100%',
2878
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
2879
+ } })),
2880
+ React__default["default"].createElement("a", { style: {
2881
+ position: 'absolute',
2882
+ top: '82%',
2883
+ left: '50%',
2884
+ transform: 'translate(-50%, -50%)',
2885
+ textAlign: 'center',
2886
+ maxWidth: 'calc(100% - 15px)',
2887
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2888
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2889
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4068
2890
  };
4069
2891
 
4070
2892
  // url: imageBlocks.imageMobile.data.url
4071
2893
  // newTab: imageBlocks.imageMobile.data.newtab
4072
2894
  // image: campaignShow.image
4073
2895
  // imageDestkop: campaignShow.image_desktop
4074
- const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
4075
- LEADGEN_LAYOUT.Fullscreen,
4076
- LEADGEN_LAYOUT.Slider,
4077
- ];
4078
- const LEADGEN_LIMIT_LIGHTBOXB = 6;
4079
- const LEADGEN_SHOW_HEADER = [
4080
- 'LightBoxA',
4081
- 'InlineA',
4082
- LEADGEN_LAYOUT.Sidebar,
4083
- LEADGEN_LAYOUT.Slider,
4084
- ];
4085
- const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2896
+ const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
2897
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
2898
+ if (!imageLoaded)
2899
+ return null;
2900
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
2901
+ React__default["default"].createElement("div", { className: "le-tab-popup" },
2902
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
2903
+ React__default["default"].createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
2904
+ React__default["default"].createElement("img", { className: "js-popup-other-submit", src: image, style: {
2905
+ aspectRatio: `${imageWidth}/${imageHeight}`,
2906
+ } })),
2907
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
2908
+ };
2909
+
2910
+ // import mockLeadData from './mockLeadData'
2911
+ const listCampaignScheduled = [];
2912
+ const listCampaignScheduledToActivated = [];
2913
+ const listCampaignActiveButExpired = [];
2914
+ const listCampaignExcludeSonsored = [];
2915
+ const listCampaignDifferentSponsor = [];
2916
+ const listCampaignNotDisplayInRangeOfTime = [];
2917
+ function isMobile() {
2918
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
2919
+ }
2920
+ const getShuffleArray = (array) => {
2921
+ const newArray = [...array];
2922
+ for (let i = newArray.length - 1; i > 0; i--) {
2923
+ const j = Math.floor(Math.random() * (i + 1));
2924
+ const temp = newArray[i];
2925
+ newArray[i] = newArray[j];
2926
+ newArray[j] = temp;
2927
+ }
2928
+ return newArray;
2929
+ };
2930
+ const getTimeByTimezone = (timeZone = 'UTC') => {
2931
+ const date = new Date();
2932
+ return new Date(date.toLocaleString('en-US', { timeZone }));
2933
+ };
2934
+ const parseDateByCampaignTime = (dateStr) => {
2935
+ // Format like this: 2023-04-04 00:00:00
2936
+ try {
2937
+ const [datePart, timePart] = dateStr.split(' ');
2938
+ const [year, month, day] = datePart.split('-').map(Number);
2939
+ const [hours, minutes, seconds] = timePart.split(':').map(Number);
2940
+ /** JavaScript counts months from 0 to 11 */
2941
+ return new Date(year, month - 1, day, hours, minutes, seconds);
2942
+ }
2943
+ catch (err) {
2944
+ return null;
2945
+ }
2946
+ };
2947
+ const checkCampaignNowInTimeframe = (c) => {
2948
+ var _a;
2949
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2950
+ const startedAtStr = c.started_at;
2951
+ const endedAtStr = c.ended_at;
2952
+ const startedDate = parseDateByCampaignTime(startedAtStr);
2953
+ const endedDate = parseDateByCampaignTime(endedAtStr);
2954
+ if (!startedDate || !endedDate) {
2955
+ return false;
2956
+ }
2957
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
2958
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2959
+ if (nowWithTimezoneMs <= endedDate.getTime() &&
2960
+ nowWithTimezoneMs >= startedDate.getTime()) {
2961
+ listCampaignScheduledToActivated.push(c);
2962
+ return true;
2963
+ }
2964
+ return false;
2965
+ };
2966
+ function checkCampaignActiveButExpireAlready(c) {
2967
+ var _a;
2968
+ /** Do not setup timeframe for this campaign. No need to check */
2969
+ if (c.forever === 1) {
2970
+ return true;
2971
+ }
2972
+ const startedAtStr = c.started_at;
2973
+ const endedAtStr = c.ended_at;
2974
+ const startedDate = parseDateByCampaignTime(startedAtStr);
2975
+ const endedDate = parseDateByCampaignTime(endedAtStr);
2976
+ /** Do not setup timeframe for this campaign. No need to check */
2977
+ if (!startedDate || !endedDate) {
2978
+ return true;
2979
+ }
2980
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2981
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
2982
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2983
+ /** Check if this expire already, do not show */
2984
+ if (nowWithTimezoneMs > endedDate.getTime()) {
2985
+ listCampaignActiveButExpired.push(c);
2986
+ return false;
2987
+ }
2988
+ return true;
2989
+ }
2990
+ function shouldNotDisplayIfExcludeAllSponsors(c) {
2991
+ var _a;
2992
+ const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
2993
+ const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
2994
+ if (isSponsored && excludeSponsored) {
2995
+ listCampaignExcludeSonsored.push(c);
2996
+ return true;
2997
+ }
2998
+ return false;
2999
+ }
3000
+ function shouldDisplayWithCurrentSponsor(c) {
4086
3001
  var _a, _b;
4087
- const { primaryColor } = React.useContext(LeadGenContext$1);
4088
- const { isMobile } = useScreenSize.useScreenSize();
4089
- const [open, setOpen] = React.useState(!!campaignId);
4090
- const [showOtpPhone, setShowOtpPhone] = React.useState(null);
4091
- const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
4092
- const [snap, setSnap] = React.useState(0.8);
4093
- const formRef = React.useRef();
4094
- const onClose = () => {
4095
- if (showOtpPhone) {
4096
- setShowOtpPhone(null);
3002
+ try {
3003
+ // TODO: BE will rename `exclude_sponsored_list` later
3004
+ const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
3005
+ const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
3006
+ const dataSponsoredId = Number((_b = document
3007
+ .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
3008
+ // There is no config for sponsor id and white list, should show as default
3009
+ if (!dataSponsoredId ||
3010
+ dataSponsoredId <= 0 ||
3011
+ whiteListSponsors.length === 0) {
3012
+ return true;
4097
3013
  }
4098
- else {
4099
- onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
3014
+ // Check the dataSponsoredId exists in the white list or not.
3015
+ const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
3016
+ if (isExist) {
3017
+ return true;
4100
3018
  }
4101
- };
4102
- const textBlocks = JSON.parse(extraFields.textBlocks);
4103
- const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
4104
- const actionBlocks = JSON.parse(extraFields.actionBlocks);
4105
- const popUpSubmitText = actionBlocks.submitBlock.data.value;
4106
- const currentPath = location.pathname;
4107
- const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
4108
- const { align: titleAlign } = textBlocks.titleBlock.data || {};
4109
- const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
4110
- const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
4111
- const isLightBox = currentLayout.includes('LightBox');
4112
- const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
4113
- const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
4114
- const isInline = currentLayout.includes('Inline');
4115
- const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
4116
- const isInPage = isInline || isSidebar;
4117
- const isDrawer = isLightBoxB && isMobile;
4118
- const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
4119
- const hasForm = isLightBoxA
4120
- ? listBlockAdded.some((item) => LEADGEN_BLOCK_INPUT.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
4121
- : true;
4122
- const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
4123
- const showHeader = !!imageMobile || !!imageDesktop;
4124
- const onlyHeader = !title && !description;
4125
- const showButtonClose = !isInline;
4126
- if (window.innerWidth < 769 &&
4127
- LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
4128
- console.log('😎 Not show fullscreen, slider on mobile ');
4129
- return null;
3019
+ listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
3020
+ return false;
4130
3021
  }
4131
- React.useEffect(() => {
4132
- if (isLightBox || isFullscreen) {
4133
- document.body.classList.add('noscroll');
4134
- }
4135
- if (!window.intlTelInputUtils) {
4136
- require('intl-tel-input/build/js/utils');
3022
+ catch (err) {
3023
+ // Default is show
3024
+ return true;
3025
+ }
3026
+ }
3027
+ const filterFnCampaign = (c) => {
3028
+ if (shouldNotDisplayIfExcludeAllSponsors(c)) {
3029
+ return false;
3030
+ }
3031
+ else if (!shouldDisplayWithCurrentSponsor(c)) {
3032
+ return false;
3033
+ }
3034
+ /** Active */
3035
+ if (c.formatted_status === 1) {
3036
+ return checkCampaignActiveButExpireAlready(c);
3037
+ }
3038
+ /** Schedule */
3039
+ if (c.formatted_status === 0) {
3040
+ listCampaignScheduled.push(c);
3041
+ return checkCampaignNowInTimeframe(c);
3042
+ }
3043
+ return false;
3044
+ };
3045
+ const fillterApprearanceTimeCampaign = (c) => {
3046
+ var _a;
3047
+ try {
3048
+ const isTimeInRange = (currentTime, startTime, endTime) => {
3049
+ const startParts = startTime.split(':');
3050
+ const endParts = endTime.split(':');
3051
+ const startDate = new Date();
3052
+ startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
3053
+ const endDate = new Date();
3054
+ endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
3055
+ return currentTime >= startDate && currentTime <= endDate;
3056
+ };
3057
+ const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
3058
+ const startTime = rulesApprValue.startTime;
3059
+ const endTime = rulesApprValue.endTime || '23:59';
3060
+ if (!startTime) {
3061
+ return true;
4137
3062
  }
4138
- clearCacheUsedEmailOrPhone();
4139
- }, []);
4140
- const validatingPhoneRef = React.useRef(false);
4141
- const validatingEmailRef = React.useRef(false);
4142
- const { form, validateObj } = useLeadFormConfig({
4143
- listBlockAdded,
4144
- validatingPhoneRef,
4145
- validatingEmailRef,
4146
- campaignId,
4147
- campaign_subot_id,
4148
- userInfo,
4149
- format: (_a = (index$6.ISO_FORMAT[locale] || index$6.ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
4150
- });
4151
- const onFocus = (e) => {
4152
- const target = e.target;
4153
- target.scrollIntoView({
4154
- block: 'center',
4155
- inline: 'nearest',
4156
- behavior: 'auto',
4157
- });
4158
- };
4159
- const middlewareOnSubmit = (e) => {
4160
- e.preventDefault();
4161
- // mark all as touched to allow validation
4162
- const fields = Object.keys(validateObj);
4163
- const fieldStatus = fields.reduce((acc, cur) => {
4164
- acc[cur] = true;
4165
- return acc;
4166
- }, {});
4167
- form.setTouched(fieldStatus);
4168
- if (validatingEmailRef.current || validatingPhoneRef.current) {
4169
- return;
3063
+ if (isTimeInRange(new Date(), startTime, endTime)) {
3064
+ return true;
4170
3065
  }
4171
- setTimeout(() => {
4172
- form.onSubmit((v) => {
4173
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4174
- if (Object.keys(form.errors).length)
4175
- return;
4176
- let newShowOtpPhone = null;
4177
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
4178
- // not submit yet, open otp
4179
- 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;
4180
- if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
4181
- newShowOtpPhone = {
4182
- phone: v[fieldName],
4183
- type: 'phone',
4184
- };
3066
+ listCampaignNotDisplayInRangeOfTime.push(c);
3067
+ return false;
3068
+ }
3069
+ catch (err) {
3070
+ return true;
3071
+ }
3072
+ };
3073
+ let timeoutRef = null;
3074
+ let LEAD_SCROLL_EVENT = null;
3075
+ function clearPassiveEvent() {
3076
+ if (timeoutRef) {
3077
+ clearTimeout(timeoutRef);
3078
+ timeoutRef = null;
3079
+ }
3080
+ if (LEAD_SCROLL_EVENT) {
3081
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3082
+ LEAD_SCROLL_EVENT = null;
3083
+ }
3084
+ }
3085
+ function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
3086
+ // clear previous passive event, check for new condition
3087
+ clearPassiveEvent();
3088
+ const leadCurrentUrl = DEBUG_URL ||
3089
+ ('https://' +
3090
+ location.hostname +
3091
+ location.pathname +
3092
+ location.search).toLowerCase();
3093
+ fetch(leadApi + 'api/campaign/' + leadSiteId, {
3094
+ method: 'POST',
3095
+ headers: {
3096
+ 'Content-Type': 'application/json',
3097
+ },
3098
+ body: JSON.stringify({
3099
+ url: leadCurrentUrl,
3100
+ ga_client_id: miscCookieHelper.getCookie('_ga') || null,
3101
+ }),
3102
+ })
3103
+ .then((response) => {
3104
+ return response.json();
3105
+ // return mockLeadData || response.json()
3106
+ })
3107
+ .then((data) => {
3108
+ var _a, _b, _c, _d;
3109
+ LeadLog('List campagin: ', data);
3110
+ LEAD_RESET_VAR();
3111
+ if (data._status == 1) {
3112
+ const campaigns = (((_b = (_a = data._data) === null || _a === void 0 ? void 0 : _a.campaigns) === null || _b === void 0 ? void 0 : _b.filter(filterFnCampaign)) || []).filter(fillterApprearanceTimeCampaign);
3113
+ if (!miscCookieHelper.getCookie('hhg-id')) {
3114
+ miscCookieHelper.setCookie('hhg-id', uuid.v1(), {
3115
+ domain: '.' + leadDomain,
3116
+ path: '/',
3117
+ });
3118
+ LeadLog('😍 Set HHG ID cookie');
3119
+ }
3120
+ // getCookie('hhg-id')
3121
+ // TODO: HP-534 Filter desktop
3122
+ let campaignsDevice = [];
3123
+ if (isMobile()) {
3124
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
3125
+ }
3126
+ else {
3127
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
3128
+ }
3129
+ LeadLog(`👓 campaignsDevice`, campaignsDevice);
3130
+ LeadLog('--listCampaignScheduled', listCampaignScheduled);
3131
+ LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
3132
+ LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
3133
+ LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
3134
+ LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
3135
+ LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
3136
+ // Check links
3137
+ let listLinksObj = campaignsDevice
3138
+ .map((i, index) => i.targets
3139
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
3140
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3141
+ .flat(1);
3142
+ // Check list link match current href
3143
+ listLinksObj = listLinksObj.filter((i) => {
3144
+ var _a;
3145
+ const target = new URL(String(i.target).toLowerCase());
3146
+ if (i.option == 'exact_match')
3147
+ // FOR TEST LOCAL:
3148
+ // return Boolean(location.pathname === target.pathname)
3149
+ return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
3150
+ if (i.option == 'start_with') {
3151
+ // FOR TEST LOCAL:
3152
+ // if (location.pathname.includes(target.pathname)) {
3153
+ if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
3154
+ const listExcluding = i.sub_target
3155
+ .filter((i) => i.option == 'excluding')
3156
+ .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
3157
+ return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
4185
3158
  }
4186
- }
4187
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
4188
- // not submit yet, open otp
4189
- 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;
4190
- if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
4191
- newShowOtpPhone = {
4192
- phone: v[fieldName],
4193
- type: 'whatsapp',
4194
- };
3159
+ else {
3160
+ return false;
4195
3161
  }
4196
3162
  }
4197
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
4198
- // not submit yet, open otp
4199
- 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;
4200
- if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
4201
- newShowOtpPhone = {
4202
- phone: v[fieldName],
4203
- type: 'zalo',
4204
- };
4205
- }
3163
+ });
3164
+ // Check tags
3165
+ const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
3166
+ const listTags = listMetaTag.map((i) => i.content);
3167
+ let listCampaignHasTag = [];
3168
+ let listTagsObj = [];
3169
+ if (listTags && listTags.length) {
3170
+ listCampaignHasTag = campaignsDevice
3171
+ .map((i, index) => i.targets
3172
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
3173
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3174
+ .flat(1);
3175
+ listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
3176
+ }
3177
+ const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
3178
+ const cookieKeys = document.cookie
3179
+ .split('; ')
3180
+ .map((i) => i.split('=')[0]);
3181
+ const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
3182
+ LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
3183
+ const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
3184
+ LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
3185
+ const listCampaignSubmitedClosed = [
3186
+ ...listCampaignCodeSubmited,
3187
+ ...listCampaignCodeClosed,
3188
+ ];
3189
+ const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
3190
+ const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
3191
+ return !hasSubmited;
3192
+ });
3193
+ const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
3194
+ // .sort(
3195
+ // (a, b) =>
3196
+ // (listCampaignValid[a.campaignIndex]?.score || 0) -
3197
+ // (listCampaignValid[b.campaignIndex]?.score || 0),
3198
+ // )
3199
+ LeadLog('--listCampaignValid : ', listCampaignValid);
3200
+ if (listCampaignValid && listCampaignValid.length) {
3201
+ const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
3202
+ LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
3203
+ const { rules } = CAMPAIGN_SHOW;
3204
+ // CHECK RULE TRIGGER POPUP
3205
+ const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
3206
+ LeadLog(`timeoutRule`, timeoutRule);
3207
+ const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
3208
+ LeadLog(`scrollRule`, scrollRule);
3209
+ let impressionAction = 'TIME';
3210
+ if (Number.isInteger(timeoutRule)) {
3211
+ impressionAction = 'TIME';
3212
+ LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
3213
+ timeoutRef = setTimeout(() => {
3214
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3215
+ }, timeoutRule * 1000);
4206
3216
  }
4207
- if (newShowOtpPhone) {
4208
- setIsSubmitLoading(true);
4209
- Service.sendSMSOtpLead(newShowOtpPhone)
4210
- .then((res) => {
4211
- var _a;
4212
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4213
- if (respMessage === 'This phone number was verified') {
4214
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4215
- return;
3217
+ if (Number.isInteger(scrollRule)) {
3218
+ impressionAction = 'SCROLL';
3219
+ LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
3220
+ const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
3221
+ document.querySelector('body');
3222
+ const pct = $p.getBoundingClientRect().top;
3223
+ const pb = $p.offsetHeight;
3224
+ LeadLog(`👓 Element check scroll: `, $p);
3225
+ LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
3226
+ const wt = window.pageYOffset || document.documentElement.scrollTop;
3227
+ let percent = 0;
3228
+ if (wt >= pct) {
3229
+ percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
4216
3230
  }
4217
- setShowOtpPhone(newShowOtpPhone);
4218
- })
4219
- .finally(() => {
4220
- setIsSubmitLoading(false);
3231
+ LeadLog('---Scroll', percent, scrollRule);
3232
+ // TODO: CHECK FOOTER HEIGHT
3233
+ if (percent >= scrollRule) {
3234
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3235
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3236
+ }
3237
+ };
3238
+ window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
3239
+ passive: true,
4221
3240
  });
4222
- return;
4223
3241
  }
4224
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4225
- })(e);
4226
- }, 100);
4227
- };
4228
- const onOpenChange = (_open) => {
4229
- setOpen(_open);
4230
- if (!_open) {
4231
- setTimeout(() => {
4232
- onClose();
4233
- }, 250);
4234
- }
4235
- };
4236
- const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
4237
- const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
4238
- const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
4239
- const renderAfterImageSizes = imageMobileLoaded &&
4240
- imageDesktopLoaded &&
4241
- (isFullscreen ? imageBackgroundLoaded : true);
4242
- const ButtonSubmit = React.useMemo(() => {
4243
- var _a;
4244
- 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));
4245
- }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
4246
- const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
4247
- const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default["default"].createElement(React__default["default"].Fragment, null, LinkButtonBlock.map((item, index) => {
4248
- var _a, _b, _c;
4249
- 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: () => {
4250
- onClose === null || onClose === void 0 ? void 0 : onClose();
4251
- onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
4252
- } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
4253
- })));
4254
- 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,
4255
- React__default["default"].createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
4256
- React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
4257
- const PopupEmpty = showEmpty && (React__default["default"].createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
4258
- const PopupForm = (React__default["default"].createElement(LeadFormProvider, { form: form },
4259
- React__default["default"].createElement("form", { ref: formRef, className: "leadgen-form", onFocus: onFocus, onSubmit: middlewareOnSubmit },
4260
- React__default["default"].createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
4261
- React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4262
- React__default["default"].createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
4263
- const PopupOtp = showOtpPhone && (React__default["default"].createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
4264
- setShowOtpPhone(null);
4265
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
4266
- } }));
4267
- 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 }));
4268
- const PopupContent = (React__default["default"].createElement("div", { className: core.clsx('leadgen-content', {
4269
- 'leadgen-content_small': limitFieldsLightBoxB,
4270
- }) },
4271
- !headerInsideFormContainer && PopupHeader,
4272
- !onlyHeader && (React__default["default"].createElement("div", { className: "leadgen-inner" },
4273
- PopupThankYou,
4274
- !showThankyou && (React__default["default"].createElement(React__default["default"].Fragment, null,
4275
- PopupOtp,
4276
- PopupEmpty,
4277
- !(showOtpPhone || showEmpty) && PopupForm))))));
4278
- const styleOverlay = React.useMemo(() => {
4279
- let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
4280
- if (isMobile && imageOverlayMobile) {
4281
- styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4282
- }
4283
- if (!isMobile && imageOverlayDesktop) {
4284
- styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
3242
+ }
3243
+ else {
3244
+ LeadLog('🚧 No lead campaigns on current URL, tags');
3245
+ }
4285
3246
  }
4286
- return styleContent;
4287
- }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
4288
- const PopupWrapper = (React__default["default"].createElement(React__default["default"].Fragment, null,
4289
- React__default["default"].createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
4290
- React__default["default"].createElement("div", { className: core.clsx('leadgen-wrapper', {
4291
- 'leadgen-wrapper_small': limitFieldsLightBoxB,
4292
- }) },
4293
- showButtonClose && (React__default["default"].createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
4294
- PopupContent)));
4295
- const popupContainerClassName = core.clsx('leadgen', `leadgen-${currentLayout}`, {
4296
- 'leadgen-lightbox': isLightBox,
4297
- 'leadgen-inline': isInPage,
4298
- 'leadgen-slider': isSlider,
3247
+ })
3248
+ .catch((err) => {
3249
+ LeadLog(`Lead error: `, err);
4299
3250
  });
4300
- const PopupContainer = isDrawer ? (React__default["default"].createElement(index$a.DrawerComponent, { fadeFromIndex: index$6.ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
4301
- PopupWrapper,
4302
- 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 },
4303
- isFullscreen ? (React__default["default"].createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
4304
- aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
4305
- } })) : null,
4306
- PopupWrapper));
4307
- if (!renderAfterImageSizes)
4308
- return null;
4309
- if (isLightBox || isFullscreen || isSlider) {
4310
- return PopupContainer;
4311
- }
4312
- else if (isSidebar) {
4313
- return React__default["default"].createElement(SideBarLayout, { content: PopupContainer });
4314
- }
4315
- else if (isInline) {
4316
- return (React__default["default"].createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
3251
+ }
3252
+ const LeadLog = (...params) => {
3253
+ if (process.env.NODE_ENV !== 'production' ||
3254
+ (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
3255
+ process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
3256
+ (typeof localStorage !== 'undefined' &&
3257
+ localStorage.getItem('hhg_debug') === 'true')) {
3258
+ console.log(...params);
4317
3259
  }
4318
- return null;
4319
- };
4320
-
4321
- const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
4322
- const currentPath = location.pathname;
4323
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
4324
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
4325
- if (!imageMobileLoaded || !imageDesktopLoaded)
4326
- return null;
4327
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
4328
- currentLayout == 'SkinA' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4329
- React__default["default"].createElement("div", { className: "le-skin-a-desktop" },
4330
- React__default["default"].createElement("div", { style: { position: 'relative' } },
4331
- React__default["default"].createElement("img", { src: imageDesktop, style: {
4332
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4333
- } }),
4334
- React__default["default"].createElement("a", { style: {
4335
- position: 'absolute',
4336
- top: '75%',
4337
- left: '50%',
4338
- transform: 'translate(-50%, -50%)',
4339
- textAlign: 'center',
4340
- width: 'calc(100% - 15px)',
4341
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4342
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
4343
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4344
- React__default["default"].createElement("div", { className: "" },
4345
- React__default["default"].createElement("div", { style: { position: 'relative', zIndex: 10000 } },
4346
- React__default["default"].createElement("img", { src: imageDesktop, style: {
4347
- width: '100%',
4348
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4349
- } }),
4350
- React__default["default"].createElement("a", { style: {
4351
- position: 'absolute',
4352
- top: '75%',
4353
- left: '50%',
4354
- transform: 'translate(-50%, -50%)',
4355
- textAlign: 'center',
4356
- width: '100%',
4357
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4358
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4359
- React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
4360
- React__default["default"].createElement("aside", { className: "le-only-mobile" },
4361
- React__default["default"].createElement("div", { className: "le-skin-mobile" },
4362
- React__default["default"].createElement("div", { style: { position: 'relative' } },
4363
- index$7.isVideo(imageMobile) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true },
4364
- React__default["default"].createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default["default"].createElement("img", { src: imageMobile, style: {
4365
- width: '100%',
4366
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
4367
- } })),
4368
- React__default["default"].createElement("a", { style: {
4369
- position: 'absolute',
4370
- top: '82%',
4371
- left: '50%',
4372
- transform: 'translate(-50%, -50%)',
4373
- textAlign: 'center',
4374
- maxWidth: 'calc(100% - 15px)',
4375
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4376
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4377
- React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4378
- };
4379
-
4380
- // url: imageBlocks.imageMobile.data.url
4381
- // newTab: imageBlocks.imageMobile.data.newtab
4382
- // image: campaignShow.image
4383
- // imageDestkop: campaignShow.image_desktop
4384
- const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
4385
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
4386
- if (!imageLoaded)
4387
- return null;
4388
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
4389
- React__default["default"].createElement("div", { className: "le-tab-popup" },
4390
- React__default["default"].createElement("div", { style: { position: 'relative' } },
4391
- React__default["default"].createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
4392
- React__default["default"].createElement("img", { className: "js-popup-other-submit", src: image, style: {
4393
- aspectRatio: `${imageWidth}/${imageHeight}`,
4394
- } })),
4395
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
4396
3260
  };
4397
3261
 
4398
3262
  function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
@@ -4408,7 +3272,7 @@ function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
4408
3272
  }
4409
3273
  const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, showEmpty, setShowEmpty, userInfo, }) => {
4410
3274
  var _a, _b;
4411
- const { apiUrl, siteDomain } = React.useContext(LeadGenContext$1);
3275
+ const { apiUrl, siteDomain } = React.useContext(LeadGenContext);
4412
3276
  React.useEffect(() => {
4413
3277
  const gaCookie = miscCookieHelper.getCookie('_ga') || null;
4414
3278
  fetch(`${apiUrl}api/campaign/${code}/impression`, {
@@ -4803,9 +3667,9 @@ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, primaryColor
4803
3667
  leadStartTimeRef.current = Date.now();
4804
3668
  }
4805
3669
  }, [showCampaign]);
4806
- return (React__default["default"].createElement(LeadGenContext$1.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
3670
+ return (React__default["default"].createElement(LeadGenContext.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
4807
3671
  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() },
4808
- React__default["default"].createElement(core.Box, { sx: { position: 'fixed', zIndex: index$6.ZINDEX_SSO - 9e6 } },
3672
+ React__default["default"].createElement(core.Box, { sx: { position: 'fixed', zIndex: index$7.ZINDEX_SSO - 9e6 } },
4809
3673
  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) => {
4810
3674
  var _a;
4811
3675
  return (React__default["default"].createElement(core.Box, { style: styles }, ((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1' && (React__default["default"].createElement(React__default["default"].Fragment, null,
@@ -4824,4 +3688,3 @@ LeadGen.OtpForm = OtpBlock$1;
4824
3688
  LeadGen.Close = Close.Close;
4825
3689
 
4826
3690
  exports.LeadGen = LeadGen;
4827
- exports.LeadGenSubscriptionBox = LeadGenSubscriptionBox;