@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/esm/lead.js CHANGED
@@ -1,48 +1,45 @@
1
- import { _ as __rest, a as __awaiter } from './tslib.es6-1073e423.js';
2
- import React__default, { createContext, useMemo, useEffect, useRef, useState, useContext, useCallback, forwardRef, useImperativeHandle, memo } from 'react';
3
- import { createStyles, Box, Button as Button$1, Input as Input$1, clsx, Autocomplete, Checkbox as Checkbox$1, Radio as Radio$1, Select as Select$1, TextInput, NumberInput as NumberInput$1, Portal, Transition, Overlay } from '@mantine/core';
1
+ import { _ as __rest, a as __awaiter } from './tslib.es6-eb6746ec.js';
2
+ import React__default, { createContext, useMemo, useEffect, useRef, useState, useContext, useCallback } from 'react';
3
+ import { createStyles, Box, Button as Button$1, Autocomplete, clsx, Input as Input$1, TextInput, NumberInput as NumberInput$1, Portal, Transition, Overlay } from '@mantine/core';
4
4
  import dayjs from 'dayjs';
5
5
  import debounce from 'lodash/debounce';
6
- import { createFormContext, useForm } from '@mantine/form';
7
- import { u as useTranslations } from './index-94c7ee4b.js';
8
- import { T as TranslationsContext } from './translationsContext-4ea92c46.js';
6
+ import { createFormContext } from '@mantine/form';
7
+ import { u as useTranslations } from './index-e401fea0.js';
8
+ import { T as TranslationsContext } from './translationsContext-23b5bf84.js';
9
9
  import { getCookie, setCookie } from './miscCookieHelper.js';
10
- import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-f530e069.js';
11
- import { T as Text } from './index-53e72c1e.js';
12
- import { S as Select, d as Checkbox, I as Input, R as Radio, P as Phone, N as NumberInput, O as OTP } from './index-a1ae0a50.js';
13
- import { D as DatePicker } from './index-16fae63d.js';
14
- import { B as Button } from './index-0d9a1b8c.js';
15
- import './index.styles-f8978237.js';
10
+ import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-770949fe.js';
11
+ import { T as Text } from './index-5024511e.js';
12
+ import { S as Select, d as Checkbox, I as Input, R as Radio, P as Phone, N as NumberInput, O as OTP } from './index-e93b1f65.js';
13
+ import { D as DatePicker } from './index-8885ef87.js';
14
+ import { B as Button } from './index-6ab5e856.js';
15
+ import './index.styles-c9d6db26.js';
16
16
  import { useClickOutside } from '@mantine/hooks';
17
- import './useMantineLocale-2ddd0d66.js';
18
- import { C as COMMON_DATE_TRANSLATE_KEY } from './index-bedd68c7.js';
19
- import './index-f3b6ab45.js';
20
- import { Z as ZINDEX_SSO, I as ISO_FORMAT } from './index-54de0535.js';
21
- import './other-a974982d.js';
22
- import './index-67bb06d6.js';
23
- import { M as MAPPED_LOCALE } from './utils-3ff75edd.js';
24
- import { DateInput } from '@mantine/dates';
25
- import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-1451c491.js';
26
- import { H as Heading$1 } from './index-eea13537.js';
27
- import { t as translationsMap$1 } from './translationsProvider-75b93b92.js';
28
- import { L as LOCALE } from './Locale-2def755e.js';
17
+ import './useMantineLocale-ee478730.js';
18
+ import { C as COMMON_DATE_TRANSLATE_KEY } from './index-395867d1.js';
19
+ import './index-bd1a993e.js';
20
+ import { Z as ZINDEX_SSO, I as ISO_FORMAT } from './index-35c4c26f.js';
21
+ import './other-7cac897b.js';
22
+ import './index-7f0089a7.js';
23
+ import { M as MAPPED_LOCALE } from './utils-84d5275f.js';
24
+ import '@mantine/dates';
25
+ import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-119a12f3.js';
26
+ import { H as Heading$1 } from './index-5ff6b134.js';
29
27
  import { v1 } from 'uuid';
30
- import { parsePhoneNumber } from 'react-phone-number-input';
28
+ import { i as isVideo } from './index-d14b8ec2.js';
29
+ import { D as DrawerComponent } from './index-44df64aa.js';
30
+ import { u as useScreenSize } from './useScreenSize-241e66fa.js';
31
+ import { createPortal } from 'react-dom';
32
+ import { css } from '@emotion/react';
31
33
  import styled from '@emotion/styled';
32
34
  import { theme } from './miscTheme.js';
33
- import { css } from '@emotion/react';
34
- import { T as TogetherComponentGlobalContext } from './utils-a6705915.js';
35
- import { i as isVideo } from './index-4afb0581.js';
36
- import { D as DrawerComponent } from './index-d5dfbc30.js';
37
- import { u as useScreenSize } from './useScreenSize-b097bc99.js';
38
- import { createPortal } from 'react-dom';
39
- import { B as Button$2 } from './index-202a8ced.js';
40
- import { I as InputDate } from './InputDate-53408741.js';
41
- import { C as Close } from './Close-bed66153.js';
35
+ import { B as Button$2 } from './index-f4607daa.js';
36
+ import { I as InputDate } from './InputDate-86cf8a56.js';
37
+ import { C as Close } from './Close-544c792d.js';
42
38
  import '@hhgtech/icons/other';
43
39
  import '@mantine/carousel';
40
+ import './Locale-3430abbb.js';
44
41
  import 'classnames';
45
- import './useUniqueId-fa696ba6.js';
42
+ import './useUniqueId-15198ead.js';
46
43
  import './constantsSite.js';
47
44
  import '@hhgtech/icons/core';
48
45
  import '@mantine/notifications';
@@ -50,22 +47,6 @@ import './constantsDomainLocales.js';
50
47
  import './constantsIsProduction.js';
51
48
  import 'date-fns/locale';
52
49
  import './constantsRiskScreener.js';
53
- import './i18n-values/en-PH.js';
54
- import './i18n-values/hi-IN.js';
55
- import './i18n-values/id-ID.js';
56
- import './i18n-values/km-KH.js';
57
- import './i18n-values/ms-MY.js';
58
- import './i18n-values/my-MM.js';
59
- import './i18n-values/th-TH.js';
60
- import './i18n-values/tl-PH.js';
61
- import './i18n-values/vi-VN.js';
62
- import './i18n-values/vi-VN_MB.js';
63
- import './i18n-values/zh-TW.js';
64
- import './index-cd80d854.js';
65
- import 'slugify';
66
- import 'string-format';
67
- import './togetherApiPaths.js';
68
- import './constants-341374a3.js';
69
50
  import 'vaul';
70
51
 
71
52
  const LeadGenComponentContext = createContext({});
@@ -92,7 +73,7 @@ if (sessionStorage.getItem('insider_object')) {
92
73
  }
93
74
  const docLang = document.documentElement.lang;
94
75
  // TODO: country code
95
- const LEAD_LOCALE_DATA$1 = {
76
+ const LEAD_LOCALE_DATA = {
96
77
  'vi-VN': {
97
78
  popupLang: 'vi',
98
79
  countryCode: 'vn',
@@ -134,7 +115,7 @@ const LEAD_LOCALE_DATA$1 = {
134
115
  countryCodeNumber: 91,
135
116
  },
136
117
  };
137
- const LEAD_LOCALE = LEAD_LOCALE_DATA$1[docLang] || LEAD_LOCALE_DATA$1['vi-VN'];
118
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
138
119
  function LEAD_RESET_VAR() {
139
120
  // LEAD_CURRENT_URL = location.href.toLowerCase();
140
121
  LEAD_CURRENT_URL =
@@ -155,11 +136,6 @@ const LEAD_TIMEZONE_DATA = {
155
136
  9: 'Asia/Manila', // Philippines / Filipinos Site
156
137
  };
157
138
 
158
- const LEADGEN_ACTIONS = {
159
- SHOW: 'SHOW',
160
- SCROLL: 'SCROLL',
161
- TIME: 'TIME',
162
- };
163
139
  const LEADGEN_LAYOUT = {
164
140
  LightBoxA: 'LightBoxA',
165
141
  LightBoxB: 'LightBoxB',
@@ -189,10 +165,8 @@ const LEADGEN_BLOCK = {
189
165
  DropdownBlock: 'DropdownBlock',
190
166
  CheckboxBlock: 'CheckboxBlock',
191
167
  TncBlock: 'TncBlock',
192
- TitleBlock: 'TitleBlock',
193
- SubtitleBlock: 'SubtitleBlock',
194
168
  };
195
- const LEADGEN_BLOCK_INPUT = [
169
+ const LEADGEN_BLOCK_IN_FORM = [
196
170
  LEADGEN_BLOCK.TextBlock,
197
171
  LEADGEN_BLOCK.NumberBlock,
198
172
  LEADGEN_BLOCK.DateBlock,
@@ -207,59 +181,7 @@ const LEADGEN_BLOCK_INPUT = [
207
181
  LEADGEN_BLOCK.CheckboxBlock,
208
182
  LEADGEN_BLOCK.TncBlock,
209
183
  ];
210
- const leadGenFieldNamePhone = (listBlockAdded) => {
211
- return listBlockAdded
212
- .filter(({ name }) => [
213
- LEADGEN_BLOCK.PhoneBlock,
214
- LEADGEN_BLOCK.PhoneOtpBlock,
215
- LEADGEN_BLOCK.WhatsappOtpBlock,
216
- LEADGEN_BLOCK.ZaloOtpBlock,
217
- ].includes(name))
218
- .map(({ data }) => data.value);
219
- };
220
184
  const SSO_MAP_LEAD = ['name', 'email', 'birthday', 'phone', 'gender'];
221
- const LEAD_LOCALE_DATA = {
222
- 'vi-VN': {
223
- popupLang: 'vi',
224
- countryCode: 'vn',
225
- countryCodeNumber: 84,
226
- },
227
- 'id-ID': {
228
- popupLang: 'id',
229
- countryCode: 'id',
230
- countryCodeNumber: 62,
231
- },
232
- 'th-TH': {
233
- popupLang: 'th',
234
- countryCode: 'th',
235
- countryCodeNumber: 66,
236
- },
237
- 'ms-MY': {
238
- popupLang: 'ms',
239
- countryCode: 'my',
240
- countryCodeNumber: 60,
241
- },
242
- 'zh-TW': {
243
- popupLang: 'zh',
244
- countryCode: 'tw',
245
- countryCodeNumber: 886,
246
- },
247
- 'km-KH': {
248
- popupLang: 'km',
249
- countryCode: 'kh',
250
- countryCodeNumber: 855,
251
- },
252
- 'my-MM': {
253
- popupLang: 'my',
254
- countryCode: 'mm',
255
- countryCodeNumber: 95,
256
- },
257
- 'hi-IN': {
258
- popupLang: 'hi',
259
- countryCode: 'in',
260
- countryCodeNumber: 91,
261
- },
262
- };
263
185
  const mappingSSOToLead = (userInfoProps) => {
264
186
  var _a, _b;
265
187
  try {
@@ -275,7 +197,7 @@ const mappingSSOToLead = (userInfoProps) => {
275
197
  if (ssoKey === 'birthday') {
276
198
  const dob = dayjs(initValue, 'YYYY-MM-DD', true);
277
199
  if (dob.isValid()) {
278
- user.birthday = dob.toDate();
200
+ user.birthday = dob;
279
201
  }
280
202
  }
281
203
  else if (ssoKey === 'gender') {
@@ -298,66 +220,16 @@ const mappingSSOToLead = (userInfoProps) => {
298
220
  catch (error) {
299
221
  return;
300
222
  }
301
- };
302
- const formatCampaignDetail = (campaign) => {
303
- if (!campaign) {
304
- return {};
305
- }
306
- try {
307
- const { extra_fields, thank_you_image } = campaign || {};
308
- const { textBlocks: exTextBlocks, imageBlocks: exImageBlocks, listBlockAdded: exListBlockAdded, listBlockThankyou: exListBlockThankyou, actionBlocks: exActionBlocks, } = extra_fields;
309
- const textBlocks = JSON.parse(exTextBlocks);
310
- const imageBlocks = JSON.parse(exImageBlocks);
311
- const listBlockAdded = JSON.parse(exListBlockAdded);
312
- const listBlockThankyou = JSON.parse(exListBlockThankyou);
313
- const actionBlocks = JSON.parse(exActionBlocks);
314
- const ThankYouBlock = {
315
- image: { src: thank_you_image },
316
- };
317
- listBlockThankyou.forEach((block) => {
318
- const { name, data } = block || {};
319
- const { value: htmlText, align, newtab, url } = data || {};
320
- switch (name) {
321
- case LEADGEN_BLOCK.TitleBlock: {
322
- ThankYouBlock.title = { htmlText, align };
323
- }
324
- case LEADGEN_BLOCK.SubtitleBlock: {
325
- ThankYouBlock.description = { htmlText, align };
326
- }
327
- case LEADGEN_BLOCK.LinkButtonBlock: {
328
- ThankYouBlock.button = { htmlText, newtab, url };
329
- }
330
- }
331
- });
332
- return Object.assign(Object.assign({}, campaign), { extra_fields: Object.assign(Object.assign({}, extra_fields), { textBlocks,
333
- imageBlocks,
334
- listBlockAdded,
335
- listBlockThankyou,
336
- actionBlocks }), ThankYouBlock });
337
- }
338
- catch (error) {
339
- return {};
340
- }
341
223
  };
342
224
 
343
225
  class Store {
344
226
  constructor() {
345
- this.apiSsoUrl = 'https://staging-id.hellobacsi.com/';
346
227
  this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
347
228
  this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
348
229
  }
349
230
  }
350
231
  const leadStore = new Store();
351
232
 
352
- const LEADGEN_API_METHOD = {
353
- GET: 'get',
354
- POST: 'POST',
355
- };
356
- const LEADGEN_API_PATH = {
357
- V2_CAMPAIGN: 'api/v2/campaign',
358
- V2_SUBSCRIPTION_LEAD: 'api/v2/subscription-box',
359
- V2_SUBSCRIPTION_INFO: 'api/campaign/get-title',
360
- };
361
233
  const leadApi = {
362
234
  call(_a) {
363
235
  var { url, data = undefined } = _a, config = __rest(_a, ["url", "data"]);
@@ -461,50 +333,8 @@ const verifyOtpLead = ({ phone, otp, type, }) => {
461
333
  },
462
334
  });
463
335
  };
464
- const getCampaignByCode = (campaign_code) => {
465
- return leadApi.call({
466
- url: `${LEADGEN_API_PATH.V2_CAMPAIGN}/${campaign_code}`,
467
- method: LEADGEN_API_METHOD.GET,
468
- });
469
- };
470
- const getSubscriptionBoxInfo = ({ category, site, }) => {
471
- return leadApi.call({
472
- url: `${LEADGEN_API_PATH.V2_SUBSCRIPTION_INFO}?category=${category}&site=${site}`,
473
- method: LEADGEN_API_METHOD.GET,
474
- });
475
- };
476
- const postSubscriptionBoxLead = ({ data }) => {
477
- return leadApi.call({
478
- url: LEADGEN_API_PATH.V2_SUBSCRIPTION_LEAD,
479
- method: LEADGEN_API_METHOD.POST,
480
- data,
481
- });
482
- };
483
- const postUserInfoFromLeadGen = ({}) => {
484
- return;
485
- };
486
- const campaignPostImpression = ({ code, action, title_article, ga_client_id, cookie_id, extra, url, referrer, }) => {
487
- return leadApi.call({
488
- url: `api/campaign/${code}/impression`,
489
- method: LEADGEN_API_METHOD.POST,
490
- data: {
491
- action,
492
- title_article,
493
- cookie_id,
494
- ga_client_id,
495
- url,
496
- extra,
497
- referrer,
498
- },
499
- });
500
- };
501
336
  const Service = {
502
337
  campaignGetById,
503
- getCampaignByCode,
504
- getSubscriptionBoxInfo,
505
- postSubscriptionBoxLead,
506
- postUserInfoFromLeadGen,
507
- campaignPostImpression,
508
338
  validateEmailOrPhoneOnSubot,
509
339
  validateEmailOrPhoneOnLeadGen,
510
340
  validatePhoneNumberOnLeadGen,
@@ -844,7 +674,7 @@ const Description = (_a) => {
844
674
  return description ? (React__default.createElement(Text, Object.assign({ size: "p3" }, rest), description)) : null;
845
675
  };
846
676
 
847
- const LeadGenContext$1 = createContext({});
677
+ const LeadGenContext = createContext({});
848
678
 
849
679
  var useStyles$2 = createStyles(() => {
850
680
  return {
@@ -908,7 +738,7 @@ const SubtitleBlock$1 = ({ children, align, }) => (React__default.createElement(
908
738
  const TitleBlock$1 = ({ children, align, }) => (React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
909
739
 
910
740
  const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, popoverProps, }) => {
911
- const { primaryColor } = useContext(LeadGenContext$1);
741
+ const { primaryColor } = useContext(LeadGenContext);
912
742
  const { classes, cx } = useStyles$2(undefined, {
913
743
  name: 'LeadGen__Field',
914
744
  styles,
@@ -1023,7 +853,7 @@ const Heading = (_a) => {
1023
853
 
1024
854
  const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps, submitProps, }) => {
1025
855
  var _a;
1026
- const { primaryColor } = useContext(LeadGenContext$1);
856
+ const { primaryColor } = useContext(LeadGenContext);
1027
857
  const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, setFormRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = useContext(LeadGenComponentContext);
1028
858
  const { classes, cx } = useStyles$1(undefined, {
1029
859
  name: 'LeadGen__FormComponent',
@@ -1533,1587 +1363,63 @@ const translationsMap = {
1533
1363
  'my-MM': myMM,
1534
1364
  'km-KH': kmKH,
1535
1365
  'zh-TW': zhTW,
1536
- 'zh-CN': zhTW,
1537
1366
  'th-TH': thTH,
1538
1367
  'tl-PH': enPH,
1539
1368
  };
1540
1369
  const getTranslations = (locale) => {
1541
- const translations = Object.assign(Object.assign({}, translationsMap$1[locale]), translationsMap[locale]);
1370
+ const translations = translationsMap[locale];
1542
1371
  if (translations) {
1543
1372
  return translations;
1544
1373
  }
1545
1374
  return translationsMap['en-PH'];
1546
1375
  };
1547
1376
 
1548
- const LeadGenTranslationProvider = (props) => {
1549
- const { locale, children } = props;
1550
- const translationContextValue = useMemo(() => ({ locale, values: getTranslations(locale) }), [locale]);
1551
- return (React__default.createElement(TranslationsContext.Provider, { value: translationContextValue }, children));
1377
+ const useImageSize = (src) => {
1378
+ const [width, setWidth] = useState(16);
1379
+ const [height, setHeight] = useState(9);
1380
+ const [loaded, setLoaded] = useState(false);
1381
+ // load src image to get its width and height
1382
+ useEffect(() => {
1383
+ setLoaded(false);
1384
+ if (src) {
1385
+ const img = new Image();
1386
+ img.addEventListener('load', () => {
1387
+ setWidth(img.naturalWidth);
1388
+ setHeight(img.naturalHeight);
1389
+ setLoaded(true);
1390
+ });
1391
+ img.addEventListener('error', () => {
1392
+ setWidth(16);
1393
+ setHeight(9);
1394
+ setLoaded(true);
1395
+ });
1396
+ img.src = src;
1397
+ }
1398
+ else {
1399
+ setWidth(16);
1400
+ setHeight(9);
1401
+ setLoaded(true);
1402
+ }
1403
+ }, [src]);
1404
+ return {
1405
+ loaded,
1406
+ width,
1407
+ height,
1408
+ };
1552
1409
  };
1553
1410
 
1554
- // import mockLeadData from './mockLeadData'
1555
- const listCampaignScheduled = [];
1556
- const listCampaignScheduledToActivated = [];
1557
- const listCampaignActiveButExpired = [];
1558
- const listCampaignExcludeSonsored = [];
1559
- const listCampaignDifferentSponsor = [];
1560
- const listCampaignNotDisplayInRangeOfTime = [];
1561
- function isMobile() {
1562
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
1563
- }
1564
- const getShuffleArray = (array) => {
1565
- const newArray = [...array];
1566
- for (let i = newArray.length - 1; i > 0; i--) {
1567
- const j = Math.floor(Math.random() * (i + 1));
1568
- const temp = newArray[i];
1569
- newArray[i] = newArray[j];
1570
- newArray[j] = temp;
1571
- }
1572
- return newArray;
1573
- };
1574
- const getTimeByTimezone = (timeZone = 'UTC') => {
1575
- const date = new Date();
1576
- return new Date(date.toLocaleString('en-US', { timeZone }));
1577
- };
1578
- const parseDateByCampaignTime = (dateStr) => {
1579
- // Format like this: 2023-04-04 00:00:00
1580
- try {
1581
- const [datePart, timePart] = dateStr.split(' ');
1582
- const [year, month, day] = datePart.split('-').map(Number);
1583
- const [hours, minutes, seconds] = timePart.split(':').map(Number);
1584
- /** JavaScript counts months from 0 to 11 */
1585
- return new Date(year, month - 1, day, hours, minutes, seconds);
1586
- }
1587
- catch (err) {
1588
- return null;
1589
- }
1590
- };
1591
- const checkCampaignNowInTimeframe = (c) => {
1592
- var _a;
1593
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1594
- const startedAtStr = c.started_at;
1595
- const endedAtStr = c.ended_at;
1596
- const startedDate = parseDateByCampaignTime(startedAtStr);
1597
- const endedDate = parseDateByCampaignTime(endedAtStr);
1598
- if (!startedDate || !endedDate) {
1599
- return false;
1600
- }
1601
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
1602
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1603
- if (nowWithTimezoneMs <= endedDate.getTime() &&
1604
- nowWithTimezoneMs >= startedDate.getTime()) {
1605
- listCampaignScheduledToActivated.push(c);
1606
- return true;
1607
- }
1608
- return false;
1609
- };
1610
- function checkCampaignActiveButExpireAlready(c) {
1611
- var _a;
1612
- /** Do not setup timeframe for this campaign. No need to check */
1613
- if (c.forever === 1) {
1614
- return true;
1615
- }
1616
- const startedAtStr = c.started_at;
1617
- const endedAtStr = c.ended_at;
1618
- const startedDate = parseDateByCampaignTime(startedAtStr);
1619
- const endedDate = parseDateByCampaignTime(endedAtStr);
1620
- /** Do not setup timeframe for this campaign. No need to check */
1621
- if (!startedDate || !endedDate) {
1622
- return true;
1623
- }
1624
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1625
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
1626
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1627
- /** Check if this expire already, do not show */
1628
- if (nowWithTimezoneMs > endedDate.getTime()) {
1629
- listCampaignActiveButExpired.push(c);
1630
- return false;
1631
- }
1632
- return true;
1633
- }
1634
- function shouldNotDisplayIfExcludeAllSponsors(c) {
1635
- var _a;
1636
- const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
1637
- const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
1638
- if (isSponsored && excludeSponsored) {
1639
- listCampaignExcludeSonsored.push(c);
1640
- return true;
1641
- }
1642
- return false;
1643
- }
1644
- function shouldDisplayWithCurrentSponsor(c) {
1645
- var _a, _b;
1646
- try {
1647
- // TODO: BE will rename `exclude_sponsored_list` later
1648
- const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
1649
- const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
1650
- const dataSponsoredId = Number((_b = document
1651
- .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
1652
- // There is no config for sponsor id and white list, should show as default
1653
- if (!dataSponsoredId ||
1654
- dataSponsoredId <= 0 ||
1655
- whiteListSponsors.length === 0) {
1656
- return true;
1657
- }
1658
- // Check the dataSponsoredId exists in the white list or not.
1659
- const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
1660
- if (isExist) {
1661
- return true;
1662
- }
1663
- listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
1664
- return false;
1665
- }
1666
- catch (err) {
1667
- // Default is show
1668
- return true;
1669
- }
1670
- }
1671
- const filterFnCampaign = (c) => {
1672
- if (shouldNotDisplayIfExcludeAllSponsors(c)) {
1673
- return false;
1674
- }
1675
- else if (!shouldDisplayWithCurrentSponsor(c)) {
1676
- return false;
1677
- }
1678
- /** Active */
1679
- if (c.formatted_status === 1) {
1680
- return checkCampaignActiveButExpireAlready(c);
1681
- }
1682
- /** Schedule */
1683
- if (c.formatted_status === 0) {
1684
- listCampaignScheduled.push(c);
1685
- return checkCampaignNowInTimeframe(c);
1686
- }
1687
- return false;
1688
- };
1689
- const fillterApprearanceTimeCampaign = (c) => {
1690
- var _a;
1691
- try {
1692
- const isTimeInRange = (currentTime, startTime, endTime) => {
1693
- const startParts = startTime.split(':');
1694
- const endParts = endTime.split(':');
1695
- const startDate = new Date();
1696
- startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
1697
- const endDate = new Date();
1698
- endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
1699
- return currentTime >= startDate && currentTime <= endDate;
1700
- };
1701
- const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
1702
- const startTime = rulesApprValue.startTime;
1703
- const endTime = rulesApprValue.endTime || '23:59';
1704
- if (!startTime) {
1705
- return true;
1706
- }
1707
- if (isTimeInRange(new Date(), startTime, endTime)) {
1708
- return true;
1709
- }
1710
- listCampaignNotDisplayInRangeOfTime.push(c);
1711
- return false;
1712
- }
1713
- catch (err) {
1714
- return true;
1715
- }
1716
- };
1717
- let timeoutRef = null;
1718
- let LEAD_SCROLL_EVENT = null;
1719
- function clearPassiveEvent() {
1720
- if (timeoutRef) {
1721
- clearTimeout(timeoutRef);
1722
- timeoutRef = null;
1723
- }
1724
- if (LEAD_SCROLL_EVENT) {
1725
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1726
- LEAD_SCROLL_EVENT = null;
1727
- }
1728
- }
1729
- function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
1730
- // clear previous passive event, check for new condition
1731
- clearPassiveEvent();
1732
- const leadCurrentUrl = DEBUG_URL ||
1733
- ('https://' +
1734
- location.hostname +
1735
- location.pathname +
1736
- location.search).toLowerCase();
1737
- fetch(leadApi + 'api/campaign/' + leadSiteId, {
1738
- method: 'POST',
1739
- headers: {
1740
- 'Content-Type': 'application/json',
1741
- },
1742
- body: JSON.stringify({
1743
- url: leadCurrentUrl,
1744
- ga_client_id: getCookie('_ga') || null,
1745
- }),
1746
- })
1747
- .then((response) => {
1748
- return response.json();
1749
- // return mockLeadData || response.json()
1750
- })
1751
- .then((data) => {
1752
- var _a, _b, _c, _d;
1753
- LeadLog('List campagin: ', data);
1754
- LEAD_RESET_VAR();
1755
- if (data._status == 1) {
1756
- const campaigns = (((_b = (_a = data._data) === null || _a === void 0 ? void 0 : _a.campaigns) === null || _b === void 0 ? void 0 : _b.filter(filterFnCampaign)) || []).filter(fillterApprearanceTimeCampaign);
1757
- if (!getCookie('hhg-id')) {
1758
- setCookie('hhg-id', v1(), {
1759
- domain: '.' + leadDomain,
1760
- path: '/',
1761
- });
1762
- LeadLog('😍 Set HHG ID cookie');
1763
- }
1764
- // getCookie('hhg-id')
1765
- // TODO: HP-534 Filter desktop
1766
- let campaignsDevice = [];
1767
- if (isMobile()) {
1768
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
1769
- }
1770
- else {
1771
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
1772
- }
1773
- LeadLog(`👓 campaignsDevice`, campaignsDevice);
1774
- LeadLog('--listCampaignScheduled', listCampaignScheduled);
1775
- LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
1776
- LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
1777
- LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
1778
- LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
1779
- LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
1780
- // Check links
1781
- let listLinksObj = campaignsDevice
1782
- .map((i, index) => i.targets
1783
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
1784
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1785
- .flat(1);
1786
- // Check list link match current href
1787
- listLinksObj = listLinksObj.filter((i) => {
1788
- var _a;
1789
- const target = new URL(String(i.target).toLowerCase());
1790
- if (i.option == 'exact_match')
1791
- // FOR TEST LOCAL:
1792
- // return Boolean(location.pathname === target.pathname)
1793
- return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
1794
- if (i.option == 'start_with') {
1795
- // FOR TEST LOCAL:
1796
- // if (location.pathname.includes(target.pathname)) {
1797
- if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
1798
- const listExcluding = i.sub_target
1799
- .filter((i) => i.option == 'excluding')
1800
- .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
1801
- return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
1802
- }
1803
- else {
1804
- return false;
1805
- }
1806
- }
1807
- });
1808
- // Check tags
1809
- const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
1810
- const listTags = listMetaTag.map((i) => i.content);
1811
- let listCampaignHasTag = [];
1812
- let listTagsObj = [];
1813
- if (listTags && listTags.length) {
1814
- listCampaignHasTag = campaignsDevice
1815
- .map((i, index) => i.targets
1816
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
1817
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1818
- .flat(1);
1819
- listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
1820
- }
1821
- const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
1822
- const cookieKeys = document.cookie
1823
- .split('; ')
1824
- .map((i) => i.split('=')[0]);
1825
- const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
1826
- LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
1827
- const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
1828
- LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
1829
- const listCampaignSubmitedClosed = [
1830
- ...listCampaignCodeSubmited,
1831
- ...listCampaignCodeClosed,
1832
- ];
1833
- const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
1834
- const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
1835
- return !hasSubmited;
1836
- });
1837
- const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
1838
- // .sort(
1839
- // (a, b) =>
1840
- // (listCampaignValid[a.campaignIndex]?.score || 0) -
1841
- // (listCampaignValid[b.campaignIndex]?.score || 0),
1842
- // )
1843
- LeadLog('--listCampaignValid : ', listCampaignValid);
1844
- if (listCampaignValid && listCampaignValid.length) {
1845
- const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
1846
- LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
1847
- const { rules } = CAMPAIGN_SHOW;
1848
- // CHECK RULE TRIGGER POPUP
1849
- const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
1850
- LeadLog(`timeoutRule`, timeoutRule);
1851
- const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
1852
- LeadLog(`scrollRule`, scrollRule);
1853
- let impressionAction = 'TIME';
1854
- if (Number.isInteger(timeoutRule)) {
1855
- impressionAction = 'TIME';
1856
- LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
1857
- timeoutRef = setTimeout(() => {
1858
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1859
- }, timeoutRule * 1000);
1860
- }
1861
- if (Number.isInteger(scrollRule)) {
1862
- impressionAction = 'SCROLL';
1863
- LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
1864
- const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
1865
- document.querySelector('body');
1866
- const pct = $p.getBoundingClientRect().top;
1867
- const pb = $p.offsetHeight;
1868
- LeadLog(`👓 Element check scroll: `, $p);
1869
- LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
1870
- const wt = window.pageYOffset || document.documentElement.scrollTop;
1871
- let percent = 0;
1872
- if (wt >= pct) {
1873
- percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
1874
- }
1875
- LeadLog('---Scroll', percent, scrollRule);
1876
- // TODO: CHECK FOOTER HEIGHT
1877
- if (percent >= scrollRule) {
1878
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1879
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1880
- }
1881
- };
1882
- window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
1883
- passive: true,
1884
- });
1885
- }
1886
- }
1887
- else {
1888
- LeadLog('🚧 No lead campaigns on current URL, tags');
1889
- }
1890
- }
1891
- })
1892
- .catch((err) => {
1893
- LeadLog(`Lead error: `, err);
1894
- });
1895
- }
1896
- const LeadLog = (...params) => {
1897
- if (process.env.NODE_ENV !== 'production' ||
1898
- (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
1899
- process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
1900
- (typeof localStorage !== 'undefined' &&
1901
- localStorage.getItem('hhg_debug') === 'true')) {
1902
- console.log(...params);
1903
- }
1904
- };
1905
-
1906
- const LeadGenContext = createContext({
1907
- submit(value) {
1908
- /** Init for FAKING function */
1909
- LeadLog('** LeadGen Submit : ', value);
1910
- return Promise.reject(value);
1911
- },
1912
- submitSubscriptionBox(value) {
1913
- /** Init for FAKING function */
1914
- LeadLog('** LeadGen SubmitSubscriptionBox : ', value);
1915
- return Promise.reject(value);
1916
- },
1917
- impression(value) {
1918
- /** Init for FAKING function */
1919
- LeadLog('** LeadGen Impression : ', value);
1920
- return Promise.reject(value);
1921
- },
1922
- /** For Subscription Box */
1923
- subscriptionIcon: '',
1924
- subscriptionTitle: '',
1925
- });
1926
- const LeadGenContextProvider = (props) => {
1927
- const { campaign_code: campaignCodeProps, apiSsoUrl, apiLeadUrl, apiSubotUrl, locale: localeProps, forceCampaign: forceCampaignProps, extraValues, articleId = 1, categoryId = 1, siteDomain: site_domain, children, } = props;
1928
- const [forceCampaign, setForceCampaign] = useState(forceCampaignProps);
1929
- const [subscriptionInfo, setSubscriptionInfo] = useState({
1930
- subscriptionIcon: '',
1931
- subscriptionTitle: '',
1932
- });
1933
- const locale = useMemo(() => {
1934
- return localeProps || LOCALE['PhilippinesEnglish'];
1935
- }, [localeProps]);
1936
- const leadGenContextValue = useMemo(() => (Object.assign(Object.assign({}, props), { forceCampaign })), [...Object.values(props), forceCampaign]);
1937
- const { url, campaign_id, campaign_code, cookie_id, ga_client_id, category_id, article_id, article_title, } = useMemo(() => ({
1938
- url: location.href.toLowerCase() || '',
1939
- cookie_id: getCookie('hhg-id') || null,
1940
- ga_client_id: getCookie('_ga'),
1941
- campaign_id: forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id,
1942
- campaign_code: campaignCodeProps || (forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.code),
1943
- category_id: categoryId,
1944
- article_id: articleId,
1945
- article_title: document.title || '',
1946
- }), [campaignCodeProps, articleId, categoryId, forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id]);
1947
- const fetchCampaign = useCallback((campaign_code) => {
1948
- Service.getCampaignByCode(campaign_code).then((res) => {
1949
- const { _data } = res || {};
1950
- const { campaigns } = _data || {};
1951
- LeadLog('** LeadGen Campaign : ', campaigns);
1952
- setForceCampaign(formatCampaignDetail(campaigns));
1953
- });
1954
- }, [campaignCodeProps]);
1955
- // TODO : Update form for LeadGen
1956
- const submit = useCallback((data) => {
1957
- return Service.postSubscriptionBoxLead({ data });
1958
- }, []);
1959
- const submitSubscriptionBox = useCallback((value) => {
1960
- const data = Object.assign(Object.assign(Object.assign(Object.assign({}, value), { campaign_id,
1961
- site_domain, url: (value === null || value === void 0 ? void 0 : value.url) || url, ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id }), extraValues), { article_id,
1962
- category_id, article_title: (extraValues === null || extraValues === void 0 ? void 0 : extraValues.article_title) || article_title });
1963
- return Service.postSubscriptionBoxLead({ data });
1964
- }, [
1965
- extraValues,
1966
- site_domain,
1967
- campaign_id,
1968
- article_id,
1969
- article_title,
1970
- category_id,
1971
- url,
1972
- ga_client_id,
1973
- ]);
1974
- const impression = useCallback((value) => {
1975
- return Service.campaignPostImpression({
1976
- url: (value === null || value === void 0 ? void 0 : value.url) || url,
1977
- action: (value === null || value === void 0 ? void 0 : value.action) || LEADGEN_ACTIONS.SCROLL,
1978
- code: (value === null || value === void 0 ? void 0 : value.code) || campaign_code,
1979
- title_article: (value === null || value === void 0 ? void 0 : value.title_article) || article_title,
1980
- cookie_id: (value === null || value === void 0 ? void 0 : value.cookie_id) || cookie_id,
1981
- ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id,
1982
- extra: (value === null || value === void 0 ? void 0 : value.extra) || Object.assign({ cookie_id,
1983
- article_id, subscription_title: subscriptionInfo.subscriptionTitle }, extraValues),
1984
- referrer: value === null || value === void 0 ? void 0 : value.referrer,
1985
- });
1986
- }, [
1987
- extraValues,
1988
- campaign_id,
1989
- url,
1990
- campaign_code,
1991
- article_title,
1992
- cookie_id,
1993
- ga_client_id,
1994
- article_id,
1995
- subscriptionInfo.subscriptionTitle,
1996
- ]);
1997
- useEffect(() => {
1998
- if (forceCampaignProps) {
1999
- setForceCampaign(forceCampaignProps);
2000
- return;
2001
- }
2002
- /** For Subscription Box */
2003
- if (categoryId) {
2004
- Service.getSubscriptionBoxInfo({
2005
- category: categoryId,
2006
- site: site_domain,
2007
- }).then((res) => {
2008
- const { _data } = res || {};
2009
- const { item, campaign_code } = _data || {};
2010
- const { icon, content } = item || {};
2011
- LeadLog('** LeadGen SubscriptionBox campaign_code : ', campaign_code);
2012
- LeadLog('** LeadGen SubscriptionBox subscription_icon : ', icon);
2013
- LeadLog('** LeadGen SubscriptionBox subscription_title : ', content);
2014
- setSubscriptionInfo({
2015
- subscriptionIcon: icon,
2016
- subscriptionTitle: content,
2017
- });
2018
- if (campaign_code) {
2019
- fetchCampaign(campaign_code);
2020
- }
2021
- });
2022
- return;
2023
- }
2024
- if (campaignCodeProps) {
2025
- fetchCampaign(campaignCodeProps);
2026
- }
2027
- }, [campaignCodeProps, categoryId]);
2028
- useEffect(() => {
2029
- leadStore.apiSsoUrl = apiSsoUrl;
2030
- leadStore.apiLeadUrl = apiLeadUrl;
2031
- leadStore.apiSubotUrl = apiSubotUrl;
2032
- }, [apiLeadUrl, apiSubotUrl, apiSsoUrl]);
2033
- if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
2034
- return null;
2035
- }
2036
- return (React__default.createElement(LeadGenContext.Provider, { value: Object.assign(Object.assign(Object.assign({}, leadGenContextValue), subscriptionInfo), { submit,
2037
- submitSubscriptionBox,
2038
- impression }) },
2039
- React__default.createElement(LeadGenTranslationProvider, { locale: locale }, children)));
2040
- };
2041
- const useLeadGenContext = () => {
2042
- const context = useContext(LeadGenContext);
2043
- return Object.assign(Object.assign({}, context), { apiLeadUrl: context.apiLeadUrl || leadStore.apiLeadUrl, apiSubotUrl: context.apiSubotUrl || leadStore.apiSubotUrl });
2044
- };
2045
-
2046
- // eslint-disable-next-line @typescript-eslint/no-var-requires
2047
- const customParseFormat = require('dayjs/plugin/customParseFormat');
2048
- dayjs.extend(customParseFormat);
2049
- // You can give context variables any name
2050
- const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
2051
- const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
2052
- var _a;
2053
- const { t } = useTranslations();
2054
- const initialValues = useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
2055
- const LEAD_LOCALE = LEAD_LOCALE_DATA[(_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.lang] ||
2056
- LEAD_LOCALE_DATA['vi-VN'];
2057
- const validateObj = useMemo(() => {
2058
- const InputBlocks = [
2059
- 'TextBlock',
2060
- 'NumberBlock',
2061
- 'EmailBlock',
2062
- 'PhoneBlock',
2063
- 'DateBlock',
2064
- 'CheckboxBlock',
2065
- 'RadioBlock',
2066
- 'DropdownBlock',
2067
- 'PhoneOtpBlock',
2068
- 'WhatsappOtpBlock',
2069
- 'ZaloOtpBlock',
2070
- 'LocationBlock',
2071
- 'TncBlock',
2072
- ];
2073
- // ALL are required and can skip if not touched yet
2074
- const withSharedCheck = (name, cb,
2075
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2076
- block) => {
2077
- return (value) => {
2078
- var _a;
2079
- const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
2080
- if (!formRef.current.isTouched(name))
2081
- return;
2082
- if ((typeof value === 'string' && value.trim() === '') ||
2083
- typeof value === 'undefined' ||
2084
- (Array.isArray(value) && value.length === 0)) {
2085
- return isBLockRequired
2086
- ? t('validator.required')
2087
- : cb === null || cb === void 0 ? void 0 : cb(value);
2088
- }
2089
- return cb === null || cb === void 0 ? void 0 : cb(value);
2090
- };
2091
- };
2092
- return listBlockAdded
2093
- .filter((b) => InputBlocks.includes(b.name))
2094
- .reduce((r, b) => {
2095
- const { name: fieldType, data } = b || {};
2096
- const { value: fieldName, required } = data || {};
2097
- const isRequired = required !== null && required !== void 0 ? required : true;
2098
- if (fieldType === 'NumberBlock') {
2099
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2100
- if (value && isNaN(Number(value))) {
2101
- return t('validator.number');
2102
- }
2103
- }, b) });
2104
- }
2105
- else if (fieldType === 'EmailBlock') {
2106
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2107
- if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
2108
- return t('validator.email');
2109
- }
2110
- if (!value)
2111
- return;
2112
- validatingEmailRef.current = true;
2113
- setTimeout(() => {
2114
- formRef.current.setFieldError(fieldName, 'Validating...');
2115
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2116
- email: value,
2117
- })
2118
- .then((tKey) => {
2119
- if (tKey) {
2120
- formRef.current.setFieldError(fieldName, t(tKey));
2121
- }
2122
- else {
2123
- formRef.current.clearFieldError(fieldName);
2124
- }
2125
- validatingEmailRef.current = false;
2126
- })
2127
- .catch((e) => {
2128
- console.error(e);
2129
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2130
- validatingEmailRef.current = false;
2131
- });
2132
- }, 200);
2133
- }, b) });
2134
- }
2135
- else if (fieldType === 'PhoneBlock' ||
2136
- fieldType === 'PhoneOtpBlock' ||
2137
- fieldType === 'ZaloOtpBlock' ||
2138
- fieldType === 'WhatsappOtpBlock') {
2139
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2140
- if (value &&
2141
- window.intlTelInputUtils &&
2142
- !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
2143
- return t('validator.phone');
2144
- }
2145
- if (!value)
2146
- return;
2147
- validatingPhoneRef.current = true;
2148
- setTimeout(() => {
2149
- formRef.current.setFieldError(fieldName, 'Validating...');
2150
- if (b.data.singleSubmission) {
2151
- checkUsedPhoneOnlyWithCache(campaignId, value)
2152
- .then((tKey) => {
2153
- if (tKey) {
2154
- formRef.current.setFieldError(fieldName, t(tKey));
2155
- }
2156
- else {
2157
- formRef.current.clearFieldError(fieldName);
2158
- }
2159
- validatingPhoneRef.current = false;
2160
- })
2161
- .catch((err) => {
2162
- console.error(err);
2163
- formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
2164
- validatingPhoneRef.current = false;
2165
- });
2166
- }
2167
- else {
2168
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2169
- phone: value,
2170
- })
2171
- .then((tKey) => {
2172
- if (tKey) {
2173
- formRef.current.setFieldError(fieldName, t(tKey));
2174
- }
2175
- else {
2176
- formRef.current.clearFieldError(fieldName);
2177
- }
2178
- validatingPhoneRef.current = false;
2179
- })
2180
- .catch((e) => {
2181
- console.error(e);
2182
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2183
- validatingPhoneRef.current = false;
2184
- });
2185
- }
2186
- }, 200);
2187
- }, b) });
2188
- }
2189
- else if (fieldType === 'DateBlock') {
2190
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2191
- if (!isRequired && !value) {
2192
- return;
2193
- }
2194
- const errMsg = t('validator.dateInvalid');
2195
- const dayInJS = typeof value === 'string'
2196
- ? dayjs(value, format, true)
2197
- : dayjs(value);
2198
- if (!dayInJS.isValid()) {
2199
- return errMsg;
2200
- }
2201
- }, b) });
2202
- }
2203
- else if (fieldType === 'TncBlock') {
2204
- return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
2205
- if (isRequired && !value) {
2206
- return t('validator.required');
2207
- }
2208
- }, b) });
2209
- }
2210
- else {
2211
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
2212
- }
2213
- }, {});
2214
- }, [listBlockAdded.map((b) => b.name).join(','), format]);
2215
- const form = useLeadForm({
2216
- validateInputOnChange: true,
2217
- validateInputOnBlur: true,
2218
- clearInputErrorOnChange: true,
2219
- validate: validateObj,
2220
- initialValues,
2221
- });
2222
- const formRef = useRef(form);
2223
- formRef.current = form;
2224
- return { form, validateObj };
2225
- };
2226
-
2227
- const StyledLeadGenThankYou = styled.div `
2228
- display: flex;
2229
- gap: 8px;
2230
- flex-direction: column;
2231
- padding-block: 24px;
2232
-
2233
- .leadgen-image {
2234
- width: 120px;
2235
- height: 120px;
2236
- margin-inline: auto;
2237
- object-fit: contain;
2238
- object-position: center;
2239
- text-align: center;
2240
- }
2241
-
2242
- .leadgen-title {
2243
- margin-block: 0;
2244
- color: ${theme.colors.gray900};
2245
- font-weight: 700;
2246
- font-size: 18px;
2247
- line-height: 28px;
2248
- letter-spacing: -0.2px;
2249
- }
2250
-
2251
- .leadgen-description {
2252
- margin-block: 0;
2253
- color: ${theme.colors.gray600};
2254
- font-weight: 400;
2255
- font-size: 14px;
2256
- line-height: 22px;
2257
- letter-spacing: -0.2px;
2258
- text-align: center;
2259
- }
2260
-
2261
- > [data-align] {
2262
- &[data-align='right'] {
2263
- text-align: right;
2264
- }
2265
- &[data-align='center'] {
2266
- text-align: center;
2267
- }
2268
- }
2269
- `;
2270
- const LeadGenThankYou = ({ image, title, description, showButton = false, button, className, style, }) => {
2271
- const { src } = image;
2272
- const { htmlText: titleText, align: titleAlign } = title;
2273
- const { htmlText: descriptionText, align: descriptionAlign } = description;
2274
- const { htmlText: buttonText, newtab, url, onClick } = button;
2275
- return (React__default.createElement(StyledLeadGenThankYou, { className: className, style: style },
2276
- React__default.createElement("img", { src: src, alt: "", className: "leadgen-thankyou_image leadgen-image" }),
2277
- React__default.createElement("p", { className: "leadgen-thankyou_title leadgen-title", "data-align": titleAlign }, titleText),
2278
- React__default.createElement("p", { className: "leadgen-thankyou_description leadgen-description", "data-align": descriptionAlign }, descriptionText),
2279
- !!buttonText && showButton && (React__default.createElement(Button$1, { component: url ? 'a' : 'button', target: newtab ? '_blank' : undefined, href: url, size: "lg", variant: "filled", className: "leadgen-thankyoue_btn leadgen-btn", onClick: onClick }, buttonText))));
2280
- };
2281
-
2282
- const StyledLeadGenSubscriptionBoxBody = styled.div `
2283
- margin-top: 16px;
2284
- .leadgen-btn {
2285
- margin-top: 16px;
2286
- }
2287
- `;
2288
- const StyledLeadGenSubscriptionBoxHeaderImage = styled.div `
2289
- margin-top: 3px;
2290
- margin-right: 20px;
2291
- width: 44px;
2292
- height: 44px;
2293
-
2294
- img {
2295
- width: 100%;
2296
- height: 100%;
2297
- object-fix: contain;
2298
- onject-position: center;
2299
- }
2300
-
2301
- :has(img[src='']) {
2302
- display: none;
2303
- }
2304
- `;
2305
- const StyledLeadGenSubscriptionBoxHeader = styled.div `
2306
- display: flex;
2307
- align-items: center;
2308
- margin-bottom: 16px;
2309
- .leadgen-title {
2310
- margin-bottom: 0;
2311
- flex: 1;
2312
- min-width: 0;
2313
- color: ${theme.colors.gray900};
2314
- font-size: 18px;
2315
- font-weight: 400;
2316
- line-height: 1.4;
2317
- letter-spacing: -0.8px;
2318
- }
2319
- `;
2320
- const StyledLeadGenSubscriptionBox = styled.div `
2321
- padding: 16px;
2322
- border: 1px solid ${theme.colors.neutral100};
2323
- border-radius: 12px;
2324
- margin-inline: auto;
2325
- .leadgen-form_inputs {
2326
- .leadgen-form_input {
2327
- width: 100%;
2328
- }
2329
- }
2330
-
2331
- .leadgen-form_input {
2332
- .mantine-Input-wrapper {
2333
- max-height: 56px;
2334
- }
2335
- }
2336
-
2337
- @media screen and (min-width: 768px) {
2338
- .leadgen-subscription_box_body {
2339
- display: flex;
2340
- > form {
2341
- flex: 1;
2342
- min-width: 0;
2343
-
2344
- .leadgen-form_inputs {
2345
- .leadgen-form_input {
2346
- width: calc(50% - 4px);
2347
- }
2348
- }
2349
- }
2350
-
2351
- .leadgen-btn {
2352
- margin-top: 0;
2353
- margin-left: 8px;
2354
- width: auto;
2355
- min-height: 56px;
2356
- }
2357
- }
2358
- }
2359
- `;
2360
- const StyledLeadGenSubscriptionBoxA = styled.div `
2361
- .leadgen-form_input {
2362
- --phone-select: 45px;
2363
- .PhoneInput {
2364
- --phone-select: 45px;
2365
- .PhoneInputCountry {
2366
- margin-top: 1px;
2367
- pointer-events: none;
2368
- .PhoneInputCountryIconImg,
2369
- .PhoneInputArrowContainer {
2370
- display: none;
2371
- }
2372
- }
2373
- }
2374
- }
2375
- `;
2376
-
2377
- const PhoneInput = forwardRef((props, ref) => {
2378
- const { defaultCountry, id: idProps, name, placeholder, label, labelElement, labelProps, description, descriptionProps, withAsterisk, inputMode, inputContainer, inputWrapperOrder, error, className, classNames, style, styles } = props, restProps = __rest(props, ["defaultCountry", "id", "name", "placeholder", "label", "labelElement", "labelProps", "description", "descriptionProps", "withAsterisk", "inputMode", "inputContainer", "inputWrapperOrder", "error", "className", "classNames", "style", "styles"]);
2379
- const id = idProps || v1() + name;
2380
- return (React__default.createElement(Input$1.Wrapper, { size: "md", label: label, labelElement: labelElement, labelProps: Object.assign({ htmlFor: id }, labelProps), description: description, descriptionProps: descriptionProps, withAsterisk: withAsterisk, inputMode: inputMode, inputContainer: inputContainer, inputWrapperOrder: inputWrapperOrder, error: error, "data-invalid": !!error, className: className, classNames: classNames, style: style, styles: styles },
2381
- React__default.createElement("div", { className: "mantine-Input-wrapper" },
2382
- React__default.createElement(Phone, Object.assign({}, restProps, { id: id, ref: ref, name: name, spellCheck: false, placeholder: placeholder, defaultCountry: defaultCountry, className: "mantine-Input-input", type: "tel", "data-control": "tel" })))));
2383
- });
2384
-
2385
- const formatLeadGenFormValue = (values, blocks) => {
2386
- const newValues = {};
2387
- for (const block of blocks) {
2388
- const { data } = block || {};
2389
- const { value: fieldName } = data || {};
2390
- if (fieldName in values) {
2391
- newValues[fieldName] = values[fieldName];
2392
- }
2393
- }
2394
- return newValues;
2395
- };
2396
-
2397
- const StyledLeadGenFormInner = styled.div `
2398
- display: flex;
2399
- flex-wrap: wrap;
2400
- gap: 8px;
2401
- .leadgen-form_input {
2402
- width: calc(50% - 4px);
2403
- }
2404
-
2405
- .leadgen-form_input_checkbox {
2406
- width: 100%;
2407
- }
2408
- `;
2409
-
2410
- const cssInputNotShrink$1 = css `
2411
- height: 100% !important;
2412
- min-height: calc(var(--container-height, 56px) * 22 / 56);
2413
- color: ${theme.colors.gray800};
2414
- font-size: var(--input, 16px);
2415
- line-height: calc(var(--container-height, 56px) * 22 / 56);
2416
- border: none !important;
2417
- border-radius: 0 !important;
2418
- outline: none !important;
2419
- box-shadow: none !important;
2420
- padding: 0;
2421
- cursor: pointer;
2422
- opacity: 0;
2423
-
2424
- ::placeholder {
2425
- color: ${theme.colors.gray400};
2426
- }
2427
- `;
2428
- const cssInputShrink$1 = css `
2429
- height: auto !important;
2430
- cursor: text;
2431
- opacity: 1;
2432
- transition: 0.1s ease-in-out all;
2433
- `;
2434
- const cssLabelNotShrink$1 = css `
2435
- position: absolute;
2436
- top: calc(var(--container-height) / 2);
2437
- left: var(--space-x, 16px);
2438
- color: ${theme.colors.gray400};
2439
- font-size: var(--label-not-shrink, 16px);
2440
- font-weight: 400;
2441
- line-height: calc(var(--container-height, 56px) * 18 / 56);
2442
- margin: 0;
2443
- z-index: 1;
2444
- cursor: pointer;
2445
- transform: translateY(-50%);
2446
- transition: 0.125s ease-in all;
2447
- `;
2448
- const cssLabelShrink$1 = css `
2449
- color: ${theme.colors.gray600};
2450
- font-weight: 600;
2451
- font-size: var(--label-shrink, 12px);
2452
- top: calc(var(--container-height) * 7 / 56);
2453
- transform: none;
2454
- transition: 0.125s ease-out all;
2455
- `;
2456
- const cssWrapperInputNotShrink$1 = css `
2457
- min-height: var(--container-height, 56px);
2458
- display: flex;
2459
- align-items: flex-end;
2460
- border: 1px solid ${theme.colors.gray200};
2461
- border-radius: 8px;
2462
- background-color: #fff;
2463
- padding-inline: var(--space-x, 16px);
2464
- padding-block: var(--space-y-not-shrink, 16px);
2465
- cursor: pointer;
2466
- pointer-events: none;
2467
-
2468
- &:has(.mantine-Input-rightSection) {
2469
- padding-right: var(--container-height, 56px);
2470
- }
2471
-
2472
- .mantine-Input-icon {
2473
- display: none;
2474
- }
2475
-
2476
- .mantine-NumberInput-control {
2477
- border-color: ${theme.colors.gray200};
2478
- }
2479
- `;
2480
- const cssWrapperInputShrink$1 = css `
2481
- height: auto;
2482
- min-height: var(--container-height, 56px);
2483
- padding-block: var(--space-y-shrink, 7px);
2484
- cursor: text;
2485
- pointer-events: auto;
2486
- `;
2487
- const cssInputWrapperError$1 = css `
2488
- color: ${theme.colors.red800};
2489
- font-size: 12px;
2490
- line-height: 1.5;
2491
- `;
2492
- const StyledTextFieldContainer$1 = styled.div `
2493
- --space-x: 16px;
2494
- --space-y-not-shrink: 16px;
2495
- --space-y-shrink: 7px;
2496
- --container-height: 56px;
2497
- --label-not-shrink: 16px;
2498
- --label-shrink: 12px;
2499
- --input: 16px;
2500
-
2501
- position: relative;
2502
- min-width: 100px;
2503
- max-width: 100%;
2504
- display: inline-block;
2505
-
2506
- .textField_wrapper {
2507
- display: inline-block;
2508
- width: 100%;
2509
- cursor: pointer;
2510
- }
2511
-
2512
- .mantine-InputWrapper-root {
2513
- &[data-invalid='true'] {
2514
- .mantine-Input-wrapper {
2515
- border-color: ${theme.colors.red400};
2516
- }
2517
- }
2518
-
2519
- .mantine-Input-wrapper {
2520
- &:has([data-invalid]) {
2521
- border-color: ${theme.colors.red400};
2522
- }
2523
- }
2524
-
2525
- .mantine-InputWrapper-error {
2526
- font-size: 12px !important;
2527
- }
2528
- }
2529
-
2530
- .mantine-InputWrapper-label {
2531
- ${cssLabelNotShrink$1}
2532
- }
2533
-
2534
- .mantine-Input-wrapper {
2535
- ${cssWrapperInputNotShrink$1}
2536
-
2537
- + .mantine-Popover-dropdown[data-position="bottom-start"] {
2538
- left: 0 !important;
2539
- }
2540
- + .mantine-Popover-dropdown[data-position='top-start'] {
2541
- top: unset !important;
2542
- left: 0 !important;
2543
- bottom: 100% !important;
2544
- }
2545
- }
2546
-
2547
- .mantine-Input-input {
2548
- ${cssInputNotShrink$1}
2549
- }
2550
-
2551
- &.textField_shrink,
2552
- &:focus-within {
2553
- .mantine-InputWrapper-label {
2554
- ${cssLabelShrink$1}
2555
- }
2556
-
2557
- .mantine-Input-wrapper {
2558
- ${cssWrapperInputShrink$1}
2559
- &.mantine-Select-wrapper {
2560
- .mantine-Select-rightSection {
2561
- pointer-events: auto !important;
2562
- }
2563
- }
2564
- }
2565
-
2566
- .mantine-Input-input {
2567
- ${cssInputShrink$1}
2568
- }
2569
-
2570
- &:has(.PhoneInput) {
2571
- .mantine-InputWrapper-label {
2572
- left: var(--space-x, 16px);
2573
- }
2574
- .PhoneInput {
2575
- .PhoneInputInput {
2576
- opacity: 1;
2577
- }
2578
- }
2579
- }
2580
- }
2581
-
2582
- .PhoneInput {
2583
- --phone-select: 75px;
2584
- --phone-input-space-x: 8px;
2585
- width: 100%;
2586
- opacity: 1;
2587
- border: none;
2588
- .PhoneInputCountry {
2589
- background-color: transparent;
2590
- border: none;
2591
- padding: 0;
2592
- width: var(--phone-select, 75px);
2593
- }
2594
- .PhoneInputInput {
2595
- flex: 1;
2596
- min-width: 0;
2597
- line-height: 1.5;
2598
- outline: none !important;
2599
- border: none;
2600
- box-shadow: none;
2601
- padding: 0 var(--phone-input-space-x, 8px);
2602
- opacity: 0;
2603
- color: ${theme.colors.gray800} !important;
2604
- :focus {
2605
- color: ${theme.colors.gray800} !important;
2606
- }
2607
- }
2608
- }
2609
-
2610
- &:has(.PhoneInput) {
2611
- .mantine-InputWrapper-label {
2612
- left: calc(
2613
- var(--space-x, 16px) + var(--phone-select, 75px) +
2614
- var(--phone-input-space-x, 8px)
2615
- );
2616
- }
2617
- }
2618
- `;
2619
- const StyledChoiceFieldContainer$1 = styled.div `
2620
- &.leadgen-form_checkbox,
2621
- &.leadgen-form_radio {
2622
- width: 100%;
2623
- }
2624
-
2625
- &.leadgen-form_dropdown {
2626
- width: calc(50% - 12px);
2627
- }
2628
-
2629
- .mantine-InputWrapper-root {
2630
- display: block;
2631
- .mantine-InputWrapper-error {
2632
- font-size: 12px !important;
2633
- }
2634
- }
2635
-
2636
- .mantine-InputWrapper-label {
2637
- margin-bottom: 0.5rem;
2638
- color: ${theme.colors.gray800};
2639
- font-size: 16px;
2640
- font-weight: 400;
2641
- line-height: 1.5;
2642
- }
2643
-
2644
- .mantine-Radio-root,
2645
- .mantine-Checkbox-root {
2646
- gap: 8px;
2647
- min-width: calc(50% - 4px);
2648
-
2649
- input[type='radio'],
2650
- input[type='checkbox'] {
2651
- border-color: ${theme.colors.gray600};
2652
- width: 18px;
2653
- height: 18px;
2654
- }
2655
- input[type='checkbox'] {
2656
- border-radius: 4px;
2657
- }
2658
-
2659
- &[data-checked='true'] {
2660
- input[type='radio'],
2661
- input[type='checkbox'] {
2662
- border-color: ${theme.colors.primary600};
2663
- + svg {
2664
- color: ${theme.colors.primary600};
2665
- }
2666
- }
2667
-
2668
- input[type='radio'] {
2669
- background-color: white;
2670
- }
2671
- }
2672
-
2673
- .mantine-Checkbox-input {
2674
- &:checked {
2675
- border-color: ${theme.colors.primary600};
2676
- }
2677
- }
2678
- }
2679
-
2680
- .mantine-Radio-inner,
2681
- .mantine-Checkbox-inner {
2682
- width: 24px;
2683
- height: 24px;
2684
- display: flex;
2685
- align-items: center;
2686
- justify-content: center;
2687
- }
2688
-
2689
- .mantine-Radio-body,
2690
- .mantine-Checkbox-body {
2691
- display: flex;
2692
- align-items: center;
2693
- }
2694
-
2695
- .mantine-Radio-label,
2696
- .mantine-Checkbox-label {
2697
- padding-left: 8px;
2698
- color: ${theme.colors.gray800};
2699
- font-size: 14px;
2700
- line-height: 1.4;
2701
- letter-spacing: -0.2px;
2702
- }
2703
-
2704
- .leadgen-choiceContainer {
2705
- display: flex;
2706
- flex-wrap: wrap;
2707
- align-items: flex-start;
2708
- gap: 8px;
2709
- }
2710
-
2711
- .mantine-InputWrapper-error {
2712
- ${cssInputWrapperError$1}
2713
- }
2714
- `;
2715
-
2716
- const TextField$1 = (props) => {
2717
- const { shrink: shrinkProps, onChangeShrink, className, children } = props, restProps = __rest(props, ["shrink", "onChangeShrink", "className", "children"]);
2718
- const containerRef = useClickOutside(() => {
2719
- if (shrinkProps) {
2720
- return;
2721
- }
2722
- setShrink(false);
2723
- onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(false);
2724
- });
2725
- const [shrink, setShrink] = useState(shrinkProps);
2726
- const onClick = useCallback((e) => {
2727
- setShrink(true);
2728
- onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(true);
2729
- if (shrink) {
2730
- return;
2731
- }
2732
- const $textEl = e.currentTarget.querySelectorAll('input:not([disabled]):not([type="submit"]),select:not([disabled]),textarea:not([disabled])');
2733
- const $focusEl = $textEl.item($textEl.length - 1);
2734
- if ($focusEl) {
2735
- $focusEl.focus();
2736
- setTimeout(() => {
2737
- $focusEl.scrollIntoView({
2738
- behavior: 'auto',
2739
- block: 'center',
2740
- inline: 'start',
2741
- });
2742
- }, 100);
2743
- }
2744
- }, [shrink]);
2745
- useEffect(() => {
2746
- setShrink(shrinkProps);
2747
- }, [shrinkProps]);
2748
- return (React__default.createElement(StyledTextFieldContainer$1, Object.assign({ shrink: shrink, className: clsx(className, 'textField', { textField_shrink: !!shrink }) }, restProps),
2749
- React__default.createElement("div", { ref: containerRef, onClick: onClick, className: "textField_wrapper" }, children)));
2750
- };
2751
- const ChoiceField$1 = (props) => {
2752
- const { children, className } = props, restProps = __rest(props, ["children", "className"]);
2753
- return (React__default.createElement(StyledChoiceFieldContainer$1, Object.assign({ className: clsx(className, 'choiceField') }, restProps), children));
2754
- };
2755
-
2756
- const libraries = ['places'];
2757
- const GoogleLocationBlock = (props) => {
2758
- var _a;
2759
- const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = __rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
2760
- const [LoadScript, setLoadScript] = useState(null);
2761
- const [value, setValue] = useState(defaultValue || valueProps);
2762
- const { predictions } = usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
2763
- const onChangeAutocomplete = useCallback((s) => {
2764
- setValue(s);
2765
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
2766
- }, []);
2767
- const onClickItem = useCallback((item) => {
2768
- /** For sure get value */
2769
- setValue(item.value);
2770
- const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
2771
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
2772
- }, [onChangeProps, predictions]);
2773
- useEffect(() => {
2774
- setValue(valueProps);
2775
- }, [valueProps]);
2776
- useEffect(() => {
2777
- var _a, _b, _c;
2778
- // only load extra google script when not yet loaded
2779
- 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) {
2780
- import('@react-google-maps/api').then((m) => {
2781
- setLoadScript(() => m.LoadScript);
2782
- });
2783
- }
2784
- }, []);
2785
- return (React__default.createElement(Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
2786
- return { value: pred.description, label: pred.description };
2787
- }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
2788
- return (React__default.createElement(React__default.Fragment, null,
2789
- LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default.createElement(React__default.Fragment, null), style: { width: '100%' } })),
2790
- children));
2791
- } }, restProps)));
2792
- };
2793
-
2794
- const LeadGenForm = forwardRef((props, ref) => {
2795
- const { locale, blocks, scrollToErrorField = true, form: formProps, rules: validate, initialValues, onFinish, onFinishFailed, className, style, } = props;
2796
- const formRef = useRef(null);
2797
- const form = formProps || useForm({ initialValues, validate });
2798
- const middlewareFinish = useCallback((values, event) => {
2799
- /** Set `touched` all values for validation when submiting */
2800
- form.setTouched(blocks.reduce((touched, { data }) => {
2801
- touched[data.value] = true;
2802
- return touched;
2803
- }, {}));
2804
- /** Wait for `touched` state and then submit */
2805
- setTimeout(() => {
2806
- const { hasErrors } = form.validate();
2807
- if (hasErrors) {
2808
- return;
2809
- }
2810
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatLeadGenFormValue(values, blocks), event);
2811
- }, 100);
2812
- }, [form, blocks]);
2813
- const middlewareFinishFailed = useCallback((errors, values, events) => {
2814
- if (scrollToErrorField && errors) {
2815
- const firstErrorKey = Object.keys(errors)[0];
2816
- const firstErrorElement = document.querySelector(`[name="${firstErrorKey}"]`);
2817
- if (firstErrorElement && (firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus)) {
2818
- setTimeout(() => {
2819
- firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
2820
- firstErrorElement.scrollIntoView({
2821
- behavior: 'auto',
2822
- block: 'center',
2823
- inline: 'center',
2824
- });
2825
- }, 100);
2826
- }
2827
- }
2828
- onFinishFailed === null || onFinishFailed === void 0 ? void 0 : onFinishFailed(errors, values, events);
2829
- }, [scrollToErrorField]);
2830
- useEffect(() => {
2831
- (() => __awaiter(void 0, void 0, void 0, function* () {
2832
- if (!window.intlTelInputUtils) {
2833
- yield require('intl-tel-input/build/js/utils');
2834
- }
2835
- }))();
2836
- }, []);
2837
- useImperativeHandle(ref, () => (Object.assign(Object.assign({}, form), { submit: () => {
2838
- formRef.current.requestSubmit();
2839
- } })), [form, formRef]);
2840
- if (!blocks || !blocks.length) {
2841
- return null;
2842
- }
2843
- return (React__default.createElement("form", { ref: formRef, onSubmit: form.onSubmit(middlewareFinish, middlewareFinishFailed), className: className, style: style },
2844
- React__default.createElement(StyledLeadGenFormInner, { className: "leadgen-form_inputs" }, blocks.map((block, idx) => {
2845
- const { id, name: blockName, data } = block;
2846
- const { placeholder, value: name, required, listQuestion, valueHTML, isSendMailChimp = false, } = data;
2847
- const formInputProps = form.getInputProps(name);
2848
- const { value, error } = formInputProps;
2849
- const reactKey = `${id}-${idx}`;
2850
- switch (blockName) {
2851
- case LEADGEN_BLOCK.TextBlock: {
2852
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2853
- React__default.createElement(TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "text", "data-control": "text" }, formInputProps))));
2854
- }
2855
- case LEADGEN_BLOCK.NumberBlock: {
2856
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2857
- React__default.createElement(NumberInput$1, Object.assign({ name: value, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "number", "data-control": "number" }, formInputProps))));
2858
- }
2859
- case LEADGEN_BLOCK.EmailBlock: {
2860
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2861
- React__default.createElement(TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, "data-control": "email" }, formInputProps))));
2862
- }
2863
- case LEADGEN_BLOCK.PhoneOtpBlock:
2864
- case LEADGEN_BLOCK.WhatsappOtpBlock:
2865
- case LEADGEN_BLOCK.ZaloOtpBlock:
2866
- case LEADGEN_BLOCK.PhoneBlock: {
2867
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2868
- React__default.createElement(PhoneInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, defaultCountry: (locale ? MAPPED_LOCALE[locale] || 'VN' : 'VN'), type: "text", "data-control": "text" }, formInputProps))));
2869
- }
2870
- case LEADGEN_BLOCK.LocationBlock: {
2871
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2872
- React__default.createElement(GoogleLocationBlock, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, locale: locale, "data-control": "text" }, formInputProps))));
2873
- }
2874
- case LEADGEN_BLOCK.DateBlock: {
2875
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2876
- React__default.createElement(DateInput, Object.assign({ locale: (MAPPED_LOCALE === null || MAPPED_LOCALE === void 0 ? void 0 : MAPPED_LOCALE[locale]) || MAPPED_LOCALE['vi-VN'], valueFormat: "DD/MM/YYYY", name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "default", "data-control": "date" }, formInputProps))));
2877
- }
2878
- case LEADGEN_BLOCK.DropdownBlock:
2879
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2880
- React__default.createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2881
- React__default.createElement(Select$1, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, data: listQuestion.map((l) => ({
2882
- value: l.value,
2883
- label: l.placeholder,
2884
- })) }, formInputProps))));
2885
- case LEADGEN_BLOCK.CheckboxBlock: {
2886
- const formInputCheckboxProps = form.getInputProps(name, {
2887
- type: 'checkbox',
2888
- });
2889
- return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2890
- isSendMailChimp && (React__default.createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2891
- React__default.createElement(Checkbox$1.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, sx: {
2892
- display: 'flex',
2893
- flexDirection: 'column',
2894
- flexWrap: 'wrap',
2895
- gap: 8,
2896
- }, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2897
- return (React__default.createElement("div", { className: "leadgen-choiceContainer" }, children));
2898
- } }, formInputCheckboxProps), listQuestion.map((l, _idx) => (React__default.createElement(Checkbox$1, { name: name, key: _idx, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2899
- }
2900
- case LEADGEN_BLOCK.RadioBlock: {
2901
- return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2902
- isSendMailChimp && (React__default.createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2903
- React__default.createElement(Radio$1.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, spellCheck: true, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2904
- return (React__default.createElement("div", { className: "leadgen-choiceContainer" }, children));
2905
- } }, formInputProps), listQuestion.map((l, _index) => (React__default.createElement(Radio$1, { name: name, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2906
- }
2907
- case LEADGEN_BLOCK.TncBlock:
2908
- return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2909
- React__default.createElement(Input$1.Wrapper, { error: error },
2910
- React__default.createElement(Checkbox$1, Object.assign({ value: value, name: 'TNC-' + id, label: React__default.createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, formInputProps)))));
2911
- default: {
2912
- return null;
2913
- }
2914
- }
2915
- }))));
2916
- });
2917
-
2918
- const LEADGEN_ORDER_INPUT_WRAPPER = ['label', 'input', 'description', 'error'];
2919
-
2920
- const LeadGenSubscriptionBoxA = (props) => {
2921
- const { loading, image, title, submitText, locale, blocks, form, rules, onFinish, } = props;
2922
- const formRef = useRef();
2923
- const imageComp = useMemo(() => {
2924
- if (!image) {
2925
- return null;
2926
- }
2927
- return (React__default.createElement(StyledLeadGenSubscriptionBoxHeaderImage, null,
2928
- React__default.createElement("img", { src: image, alt: "" })));
2929
- }, [image]);
2930
- const titleComp = useMemo(() => {
2931
- if (typeof title === 'string') {
2932
- return (React__default.createElement("p", { className: "leadgen-title", dangerouslySetInnerHTML: { __html: title } }));
2933
- }
2934
- return React__default.createElement("p", { className: "leadgen-title" }, title);
2935
- }, [title]);
2936
- return (React__default.createElement(StyledLeadGenSubscriptionBoxA, { className: "subcription_box_A" },
2937
- React__default.createElement(StyledLeadGenSubscriptionBoxHeader, { className: "leadgen-subscription_box_header" },
2938
- imageComp,
2939
- titleComp),
2940
- React__default.createElement(StyledLeadGenSubscriptionBoxBody, { className: "leadgen-subscription_box_body" },
2941
- React__default.createElement(LeadGenForm, { ref: formRef, form: form, rules: rules, blocks: blocks, locale: locale, onFinish: onFinish, className: "leadgen-subscription_box_form" }),
2942
- React__default.createElement(Button$1, { disabled: loading, loading: loading, variant: "filled", size: "lg", onClick: () => {
2943
- formRef.current.submit();
2944
- }, className: "leadgen-btn leadgen-btn_action", fullWidth: true }, submitText))));
2945
- };
2946
-
2947
- const LeadGenSubscriptionBoxWithoutMemo = ({ locale, userInfo, forceCampaign, categoryId, }) => {
2948
- var _a, _b, _c;
2949
- const { image, extra_fields, id: campaign_id, bot_id: campaign_subot_id = [], ThankYouBlock, } = forceCampaign || {};
2950
- const { textBlocks, listBlockAdded, actionBlocks } = extra_fields || {};
2951
- const { submitBlock } = actionBlocks || {};
2952
- const { apiLeadUrl, subscriptionIcon, subscriptionTitle, submitSubscriptionBox, impression, onFinish, } = useLeadGenContext();
2953
- const { t } = useTranslations();
2954
- const { action: { pushNotifications }, } = useContext(TogetherComponentGlobalContext);
2955
- const refContainer = useRef(null);
2956
- const [loading, setLoading] = useState(false);
2957
- const [showThankyou, setShowThankyou] = useState(false);
2958
- const validatingEmailRef = useRef(false);
2959
- const validatingPhoneRef = useRef(false);
2960
- const { form, validateObj } = useLeadFormConfig({
2961
- listBlockAdded,
2962
- campaignId: campaign_id,
2963
- campaign_subot_id,
2964
- validatingEmailRef,
2965
- validatingPhoneRef,
2966
- userInfo,
2967
- });
2968
- const subscription_title = useMemo(() => {
2969
- var _a, _b;
2970
- return subscriptionTitle ||
2971
- ((_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) ||
2972
- t('leadgen.message.title.default');
2973
- }, [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]);
2974
- const { image: thankyouImage, title: thankyouTitle, description: thankyouDescription, button: thankyouButton, } = ThankYouBlock || {};
2975
- const intersectionObserverCallback = useCallback((entries) => {
2976
- entries.forEach((entry) => {
2977
- const { isIntersecting, target } = entry;
2978
- if (!showThankyou &&
2979
- isIntersecting &&
2980
- target === refContainer.current) {
2981
- impression();
2982
- }
2983
- });
2984
- }, [impression, showThankyou]);
2985
- const IObserver = new IntersectionObserver(intersectionObserverCallback);
2986
- const middlewareOnSubmit = useCallback((values) => __awaiter(void 0, void 0, void 0, function* () {
2987
- const newValues = {
2988
- subscription_title,
2989
- };
2990
- const ssoValues = {
2991
- sso_user_id: undefined,
2992
- sso_uuid: undefined,
2993
- sso_verified_profile: undefined,
2994
- };
2995
- const valueKeys = Object.keys(values);
2996
- for (const key of valueKeys) {
2997
- const isPhoneField = leadGenFieldNamePhone(listBlockAdded).some((k) => k === key);
2998
- if (isPhoneField) {
2999
- const phone = parsePhoneNumber(values[key]);
3000
- if (phone.isValid()) {
3001
- /** Seperate `area_code` and `phone_number` for BE */
3002
- newValues['area_code'] = `+${phone.countryCallingCode}`;
3003
- newValues['phone_number'] = phone.nationalNumber;
3004
- /** Only case login has this update */
3005
- if ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) && (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid)) {
3006
- ssoValues['sso_verified_profile'] =
3007
- phone.number === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone) ? 1 : 0;
3008
- ssoValues['sso_user_id'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.id;
3009
- ssoValues['sso_uuid'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid;
3010
- }
3011
- }
3012
- continue;
3013
- }
3014
- newValues[key] = values[key];
3015
- }
3016
- setLoading(true);
3017
- try {
3018
- const { _data } = (yield submitSubscriptionBox(Object.assign(Object.assign({}, newValues), ssoValues))) || {};
3019
- const { model } = _data || {};
3020
- if (model && (model === null || model === void 0 ? void 0 : model.id)) {
3021
- setShowThankyou(true);
3022
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(Object.assign(Object.assign({}, newValues), ssoValues), listBlockAdded || []);
3023
- }
3024
- }
3025
- catch (error) {
3026
- LeadLog('** LeadGen SubscriptionBox error : ', error);
3027
- pushNotifications({
3028
- message: t('leadgen.message.error.default'),
3029
- type: 'danger',
3030
- });
3031
- }
3032
- setLoading(false);
3033
- }), [
3034
- subscription_title,
3035
- listBlockAdded,
3036
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
3037
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid,
3038
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone,
3039
- ]);
3040
- useEffect(() => {
3041
- if (refContainer.current) {
3042
- IObserver.observe(refContainer.current);
3043
- }
3044
- return () => {
3045
- IObserver.disconnect();
3046
- };
3047
- }, [categoryId]);
3048
- return (React__default.createElement("div", { ref: refContainer },
3049
- React__default.createElement(StyledLeadGenSubscriptionBox, null,
3050
- showThankyou && (React__default.createElement(LeadGenThankYou, { image: Object.assign(Object.assign({}, thankyouImage), { src: thankyouImage.src || `${apiLeadUrl}admin/img/thanksyou.png` }), title: thankyouTitle, description: thankyouDescription, button: thankyouButton })),
3051
- !showThankyou && (React__default.createElement(LeadGenSubscriptionBoxA, { loading: loading, image: subscriptionIcon || image, title: subscription_title, submitText: (_c = submitBlock === null || submitBlock === void 0 ? void 0 : submitBlock.data) === null || _c === void 0 ? void 0 : _c.value, blocks: listBlockAdded, locale: locale, form: form, rules: validateObj, onFinish: middlewareOnSubmit })))));
3052
- };
3053
- const LeadGenSubscriptionBox$1 = memo(LeadGenSubscriptionBoxWithoutMemo);
3054
-
3055
- const Container = () => {
3056
- const context = useContext(LeadGenContext);
3057
- const { campaign_code, locale, siteId, siteDomain, userInfo, forceCampaign } = context;
3058
- if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
3059
- return null;
3060
- }
3061
- return (React__default.createElement(LeadGenSubscriptionBox$1, { locale: locale, siteId: siteId, siteDomain: siteDomain, userInfo: userInfo, forceCampaign: forceCampaign, campaign_code: campaign_code }));
3062
- };
3063
- Container.displayName = 'LeadGenSubscriptionBox';
3064
- const LeadGenSubscriptionBoxContainer = (props) => {
3065
- const { apiUrl, apiSubotUrl } = props;
3066
- return (React__default.createElement(LeadGenContextProvider, Object.assign({}, props, { apiLeadUrl: apiUrl, apiSubotUrl: apiSubotUrl }),
3067
- React__default.createElement(Container, null)));
3068
- };
3069
- const LeadGenSubscriptionBox = LeadGenSubscriptionBoxContainer;
3070
-
3071
- const useImageSize = (src) => {
3072
- const [width, setWidth] = useState(16);
3073
- const [height, setHeight] = useState(9);
3074
- const [loaded, setLoaded] = useState(false);
3075
- // load src image to get its width and height
3076
- useEffect(() => {
3077
- setLoaded(false);
3078
- if (src) {
3079
- const img = new Image();
3080
- img.addEventListener('load', () => {
3081
- setWidth(img.naturalWidth);
3082
- setHeight(img.naturalHeight);
3083
- setLoaded(true);
3084
- });
3085
- img.addEventListener('error', () => {
3086
- setWidth(16);
3087
- setHeight(9);
3088
- setLoaded(true);
3089
- });
3090
- img.src = src;
3091
- }
3092
- else {
3093
- setWidth(16);
3094
- setHeight(9);
3095
- setLoaded(true);
3096
- }
3097
- }, [src]);
3098
- return {
3099
- loaded,
3100
- width,
3101
- height,
3102
- };
3103
- };
3104
-
3105
- const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default.createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
3106
- React__default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
3107
- React__default.createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
3108
-
3109
- // url: imageBlocks.imageMobile.data.url
3110
- // newTab: imageBlocks.imageMobile.data.newtab
3111
- // imageMobile: campaignShow.image
3112
- // imageDestkop: campaignShow.image_desktop
3113
- const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
3114
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3115
- const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
3116
- if (!imageMobileLoaded || !imageDestkopLoaded)
1411
+ const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default.createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
1412
+ React__default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
1413
+ React__default.createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
1414
+
1415
+ // url: imageBlocks.imageMobile.data.url
1416
+ // newTab: imageBlocks.imageMobile.data.newtab
1417
+ // imageMobile: campaignShow.image
1418
+ // imageDestkop: campaignShow.image_desktop
1419
+ const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
1420
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1421
+ const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
1422
+ if (!imageMobileLoaded || !imageDestkopLoaded)
3117
1423
  return null;
3118
1424
  return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
3119
1425
  React__default.createElement("div", { className: "le-center-tab-popup" },
@@ -3182,7 +1488,7 @@ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, su
3182
1488
  };
3183
1489
 
3184
1490
  const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
3185
- const { primaryColor } = useContext(LeadGenContext$1);
1491
+ const { primaryColor } = useContext(LeadGenContext);
3186
1492
  const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
3187
1493
  if (!imageLoaded)
3188
1494
  return null;
@@ -3350,6 +1656,222 @@ const EmptyComponent = ({ onClose, onContinue, }) => {
3350
1656
  React__default.createElement(Button$1, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
3351
1657
  };
3352
1658
 
1659
+ const libraries = ['places'];
1660
+ const GoogleLocationBlock = (props) => {
1661
+ var _a;
1662
+ const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = __rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
1663
+ const [LoadScript, setLoadScript] = useState(null);
1664
+ const [value, setValue] = useState(defaultValue || valueProps);
1665
+ const { predictions } = usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
1666
+ const onChangeAutocomplete = useCallback((s) => {
1667
+ setValue(s);
1668
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
1669
+ }, []);
1670
+ const onClickItem = useCallback((item) => {
1671
+ /** For sure get value */
1672
+ setValue(item.value);
1673
+ const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
1674
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
1675
+ }, [onChangeProps, predictions]);
1676
+ useEffect(() => {
1677
+ setValue(valueProps);
1678
+ }, [valueProps]);
1679
+ useEffect(() => {
1680
+ var _a, _b, _c;
1681
+ // only load extra google script when not yet loaded
1682
+ 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) {
1683
+ import('@react-google-maps/api').then((m) => {
1684
+ setLoadScript(() => m.LoadScript);
1685
+ });
1686
+ }
1687
+ }, []);
1688
+ return (React__default.createElement(Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
1689
+ return { value: pred.description, label: pred.description };
1690
+ }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
1691
+ return (React__default.createElement(React__default.Fragment, null,
1692
+ LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default.createElement(React__default.Fragment, null), style: { width: '100%' } })),
1693
+ children));
1694
+ } }, restProps)));
1695
+ };
1696
+
1697
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
1698
+ const customParseFormat = require('dayjs/plugin/customParseFormat');
1699
+ dayjs.extend(customParseFormat);
1700
+ // You can give context variables any name
1701
+ const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
1702
+ const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
1703
+ const { t } = useTranslations();
1704
+ const initialValues = useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
1705
+ const validateObj = useMemo(() => {
1706
+ const InputBlocks = [
1707
+ 'TextBlock',
1708
+ 'NumberBlock',
1709
+ 'EmailBlock',
1710
+ 'PhoneBlock',
1711
+ 'DateBlock',
1712
+ 'CheckboxBlock',
1713
+ 'RadioBlock',
1714
+ 'DropdownBlock',
1715
+ 'PhoneOtpBlock',
1716
+ 'WhatsappOtpBlock',
1717
+ 'ZaloOtpBlock',
1718
+ 'LocationBlock',
1719
+ 'TncBlock',
1720
+ ];
1721
+ // ALL are required and can skip if not touched yet
1722
+ const withSharedCheck = (name, cb,
1723
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1724
+ block) => {
1725
+ return (value) => {
1726
+ var _a;
1727
+ const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
1728
+ if (!formRef.current.isTouched(name))
1729
+ return;
1730
+ if ((typeof value === 'string' && value.trim() === '') ||
1731
+ typeof value === 'undefined' ||
1732
+ (Array.isArray(value) && value.length === 0)) {
1733
+ return isBLockRequired
1734
+ ? t('validator.required')
1735
+ : cb === null || cb === void 0 ? void 0 : cb(value);
1736
+ }
1737
+ return cb === null || cb === void 0 ? void 0 : cb(value);
1738
+ };
1739
+ };
1740
+ return listBlockAdded
1741
+ .filter((b) => InputBlocks.includes(b.name))
1742
+ .reduce((r, b) => {
1743
+ const { name: fieldType, data } = b || {};
1744
+ const { value: fieldName, required } = data || {};
1745
+ const isRequired = required !== null && required !== void 0 ? required : true;
1746
+ if (fieldType === 'NumberBlock') {
1747
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1748
+ if (value && isNaN(Number(value))) {
1749
+ return t('validator.number');
1750
+ }
1751
+ }, b) });
1752
+ }
1753
+ else if (fieldType === 'EmailBlock') {
1754
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1755
+ if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
1756
+ return t('validator.email');
1757
+ }
1758
+ if (!value)
1759
+ return;
1760
+ validatingEmailRef.current = true;
1761
+ setTimeout(() => {
1762
+ formRef.current.setFieldError(fieldName, 'Validating...');
1763
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1764
+ email: value,
1765
+ })
1766
+ .then((tKey) => {
1767
+ if (tKey) {
1768
+ formRef.current.setFieldError(fieldName, t(tKey));
1769
+ }
1770
+ else {
1771
+ formRef.current.clearFieldError(fieldName);
1772
+ }
1773
+ validatingEmailRef.current = false;
1774
+ })
1775
+ .catch((e) => {
1776
+ console.error(e);
1777
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
1778
+ validatingEmailRef.current = false;
1779
+ });
1780
+ }, 200);
1781
+ }, b) });
1782
+ }
1783
+ else if (fieldType === 'PhoneBlock' ||
1784
+ fieldType === 'PhoneOtpBlock' ||
1785
+ fieldType === 'ZaloOtpBlock' ||
1786
+ fieldType === 'WhatsappOtpBlock') {
1787
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1788
+ if (value &&
1789
+ window.intlTelInputUtils &&
1790
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
1791
+ return t('validator.phone');
1792
+ }
1793
+ if (!value)
1794
+ return;
1795
+ validatingPhoneRef.current = true;
1796
+ setTimeout(() => {
1797
+ formRef.current.setFieldError(fieldName, 'Validating...');
1798
+ if (b.data.singleSubmission) {
1799
+ checkUsedPhoneOnlyWithCache(campaignId, value)
1800
+ .then((tKey) => {
1801
+ if (tKey) {
1802
+ formRef.current.setFieldError(fieldName, t(tKey));
1803
+ }
1804
+ else {
1805
+ formRef.current.clearFieldError(fieldName);
1806
+ }
1807
+ validatingPhoneRef.current = false;
1808
+ })
1809
+ .catch((err) => {
1810
+ console.error(err);
1811
+ formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
1812
+ validatingPhoneRef.current = false;
1813
+ });
1814
+ }
1815
+ else {
1816
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1817
+ phone: value,
1818
+ })
1819
+ .then((tKey) => {
1820
+ if (tKey) {
1821
+ formRef.current.setFieldError(fieldName, t(tKey));
1822
+ }
1823
+ else {
1824
+ formRef.current.clearFieldError(fieldName);
1825
+ }
1826
+ validatingPhoneRef.current = false;
1827
+ })
1828
+ .catch((e) => {
1829
+ console.error(e);
1830
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
1831
+ validatingPhoneRef.current = false;
1832
+ });
1833
+ }
1834
+ }, 200);
1835
+ }, b) });
1836
+ }
1837
+ else if (fieldType === 'DateBlock') {
1838
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1839
+ if (!isRequired && !value) {
1840
+ return;
1841
+ }
1842
+ const errMsg = t('validator.dateInvalid');
1843
+ const dayInJS = typeof value === 'string'
1844
+ ? dayjs(value, format, true)
1845
+ : dayjs(value);
1846
+ if (!dayInJS.isValid()) {
1847
+ return errMsg;
1848
+ }
1849
+ }, b) });
1850
+ }
1851
+ else if (fieldType === 'TncBlock') {
1852
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
1853
+ if (isRequired && !value) {
1854
+ return t('validator.required');
1855
+ }
1856
+ }, b) });
1857
+ }
1858
+ else {
1859
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
1860
+ }
1861
+ }, {});
1862
+ }, [listBlockAdded.map((b) => b.name).join(','), format]);
1863
+ const form = useLeadForm({
1864
+ validateInputOnChange: true,
1865
+ validateInputOnBlur: true,
1866
+ clearInputErrorOnChange: true,
1867
+ validate: validateObj,
1868
+ initialValues,
1869
+ });
1870
+ const formRef = useRef(form);
1871
+ formRef.current = form;
1872
+ return { form, validateObj };
1873
+ };
1874
+
3353
1875
  const SubtitleBlock = ({ children, align, }) => (React__default.createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
3354
1876
 
3355
1877
  const cssInputNotShrink = css `
@@ -3676,13 +2198,11 @@ const TextField = (props) => {
3676
2198
  const $focusEl = $textEl.item($textEl.length - 1);
3677
2199
  if ($focusEl) {
3678
2200
  $focusEl.focus();
3679
- setTimeout(() => {
3680
- $focusEl.scrollIntoView({
3681
- behavior: 'auto',
3682
- block: 'center',
3683
- inline: 'start',
3684
- });
3685
- }, 100);
2201
+ $focusEl.scrollIntoView({
2202
+ behavior: 'auto',
2203
+ block: 'center',
2204
+ inline: 'start',
2205
+ });
3686
2206
  }
3687
2207
  }, [shrink]);
3688
2208
  useEffect(() => {
@@ -3913,7 +2433,7 @@ const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
3913
2433
  };
3914
2434
 
3915
2435
  const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
3916
- const { primaryColor } = useContext(LeadGenContext$1);
2436
+ const { primaryColor } = useContext(LeadGenContext);
3917
2437
  const { t } = useTranslations();
3918
2438
  const phone = otpData.phone;
3919
2439
  const otpType = otpData.type;
@@ -4012,358 +2532,702 @@ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
4012
2532
  if (autoSendWhenOpen && !resendTimer) {
4013
2533
  sendOtp();
4014
2534
  }
4015
- }, []);
4016
- return (React__default.createElement("form", { onSubmit: (e) => {
4017
- e.preventDefault();
4018
- submitOtp();
4019
- }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
4020
- React__default.createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
4021
- phone: `<strong>${displayPhone}</strong>`,
4022
- }), footer: React__default.createElement(React__default.Fragment, null,
4023
- React__default.createElement(Button$1, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
4024
- React__default.createElement(Button$1, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
4025
- sendOtp();
4026
- }, disabled: !!resendTimer }, t('lead.otp.resend', {
4027
- timer: resendTimer ? ` (${resendTimer}s)` : '',
4028
- }))) },
4029
- React__default.createElement("div", { className: "leadgen-form_inner" },
4030
- React__default.createElement(Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
4031
- React__default.createElement(OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
4032
- setIsDirty(true);
4033
- setOtp(v.toString());
4034
- if (isDirty && !v)
4035
- setErrorMsg('OTP is required');
4036
- else
4037
- setErrorMsg(undefined);
4038
- } }))))));
2535
+ }, []);
2536
+ return (React__default.createElement("form", { onSubmit: (e) => {
2537
+ e.preventDefault();
2538
+ submitOtp();
2539
+ }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
2540
+ React__default.createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
2541
+ phone: `<strong>${displayPhone}</strong>`,
2542
+ }), footer: React__default.createElement(React__default.Fragment, null,
2543
+ React__default.createElement(Button$1, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
2544
+ React__default.createElement(Button$1, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
2545
+ sendOtp();
2546
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
2547
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
2548
+ }))) },
2549
+ React__default.createElement("div", { className: "leadgen-form_inner" },
2550
+ React__default.createElement(Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
2551
+ React__default.createElement(OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
2552
+ setIsDirty(true);
2553
+ setOtp(v.toString());
2554
+ if (isDirty && !v)
2555
+ setErrorMsg('OTP is required');
2556
+ else
2557
+ setErrorMsg(undefined);
2558
+ } }))))));
2559
+ };
2560
+
2561
+ // url: imageBlocks.imageMobile.data.url
2562
+ // newTab: imageBlocks.imageMobile.data.newtab
2563
+ // image: campaignShow.image
2564
+ // imageDestkop: campaignShow.image_desktop
2565
+ const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
2566
+ LEADGEN_LAYOUT.Fullscreen,
2567
+ LEADGEN_LAYOUT.Slider,
2568
+ ];
2569
+ const LEADGEN_LIMIT_LIGHTBOXB = 6;
2570
+ const LEADGEN_SHOW_HEADER = [
2571
+ 'LightBoxA',
2572
+ 'InlineA',
2573
+ LEADGEN_LAYOUT.Sidebar,
2574
+ LEADGEN_LAYOUT.Slider,
2575
+ ];
2576
+ const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2577
+ var _a, _b;
2578
+ const { primaryColor } = useContext(LeadGenContext);
2579
+ const { isMobile } = useScreenSize();
2580
+ const [open, setOpen] = useState(!!campaignId);
2581
+ const [showOtpPhone, setShowOtpPhone] = useState(null);
2582
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
2583
+ const [snap, setSnap] = useState(0.8);
2584
+ const formRef = useRef();
2585
+ const onClose = () => {
2586
+ if (showOtpPhone) {
2587
+ setShowOtpPhone(null);
2588
+ }
2589
+ else {
2590
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2591
+ }
2592
+ };
2593
+ const textBlocks = JSON.parse(extraFields.textBlocks);
2594
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
2595
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
2596
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
2597
+ const currentPath = location.pathname;
2598
+ const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
2599
+ const { align: titleAlign } = textBlocks.titleBlock.data || {};
2600
+ const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
2601
+ const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
2602
+ const isLightBox = currentLayout.includes('LightBox');
2603
+ const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
2604
+ const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
2605
+ const isInline = currentLayout.includes('Inline');
2606
+ const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
2607
+ const isInPage = isInline || isSidebar;
2608
+ const isDrawer = isLightBoxB && isMobile;
2609
+ const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
2610
+ const hasForm = isLightBoxA
2611
+ ? listBlockAdded.some((item) => LEADGEN_BLOCK_IN_FORM.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
2612
+ : true;
2613
+ const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
2614
+ const showHeader = !!imageMobile || !!imageDesktop;
2615
+ const onlyHeader = !title && !description;
2616
+ const showButtonClose = !isInline;
2617
+ if (window.innerWidth < 769 &&
2618
+ LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
2619
+ console.log('😎 Not show fullscreen, slider on mobile ');
2620
+ return null;
2621
+ }
2622
+ useEffect(() => {
2623
+ if (isLightBox || isFullscreen) {
2624
+ document.body.classList.add('noscroll');
2625
+ }
2626
+ if (!window.intlTelInputUtils) {
2627
+ require('intl-tel-input/build/js/utils');
2628
+ }
2629
+ clearCacheUsedEmailOrPhone();
2630
+ }, []);
2631
+ const validatingPhoneRef = useRef(false);
2632
+ const validatingEmailRef = useRef(false);
2633
+ const { form, validateObj } = useLeadFormConfig({
2634
+ listBlockAdded,
2635
+ validatingPhoneRef,
2636
+ validatingEmailRef,
2637
+ campaignId,
2638
+ campaign_subot_id,
2639
+ userInfo,
2640
+ format: (_a = (ISO_FORMAT[locale] || ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
2641
+ });
2642
+ const middlewareOnSubmit = (e) => {
2643
+ e.preventDefault();
2644
+ // mark all as touched to allow validation
2645
+ const fields = Object.keys(validateObj);
2646
+ const fieldStatus = fields.reduce((acc, cur) => {
2647
+ acc[cur] = true;
2648
+ return acc;
2649
+ }, {});
2650
+ form.setTouched(fieldStatus);
2651
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
2652
+ return;
2653
+ }
2654
+ setTimeout(() => {
2655
+ form.onSubmit((v) => {
2656
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2657
+ if (Object.keys(form.errors).length)
2658
+ return;
2659
+ let newShowOtpPhone = null;
2660
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
2661
+ // not submit yet, open otp
2662
+ 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;
2663
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
2664
+ newShowOtpPhone = {
2665
+ phone: v[fieldName],
2666
+ type: 'phone',
2667
+ };
2668
+ }
2669
+ }
2670
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
2671
+ // not submit yet, open otp
2672
+ 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;
2673
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
2674
+ newShowOtpPhone = {
2675
+ phone: v[fieldName],
2676
+ type: 'whatsapp',
2677
+ };
2678
+ }
2679
+ }
2680
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
2681
+ // not submit yet, open otp
2682
+ 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;
2683
+ if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
2684
+ newShowOtpPhone = {
2685
+ phone: v[fieldName],
2686
+ type: 'zalo',
2687
+ };
2688
+ }
2689
+ }
2690
+ if (newShowOtpPhone) {
2691
+ setIsSubmitLoading(true);
2692
+ Service.sendSMSOtpLead(newShowOtpPhone)
2693
+ .then((res) => {
2694
+ var _a;
2695
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2696
+ if (respMessage === 'This phone number was verified') {
2697
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2698
+ return;
2699
+ }
2700
+ setShowOtpPhone(newShowOtpPhone);
2701
+ })
2702
+ .finally(() => {
2703
+ setIsSubmitLoading(false);
2704
+ });
2705
+ return;
2706
+ }
2707
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2708
+ })(e);
2709
+ }, 100);
2710
+ };
2711
+ const onOpenChange = (_open) => {
2712
+ setOpen(_open);
2713
+ if (!_open) {
2714
+ setTimeout(() => {
2715
+ onClose();
2716
+ }, 250);
2717
+ }
2718
+ };
2719
+ const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
2720
+ const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
2721
+ const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
2722
+ const renderAfterImageSizes = imageMobileLoaded &&
2723
+ imageDesktopLoaded &&
2724
+ (isFullscreen ? imageBackgroundLoaded : true);
2725
+ const ButtonSubmit = useMemo(() => {
2726
+ var _a;
2727
+ return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default.createElement(Button$1, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
2728
+ }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
2729
+ const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
2730
+ const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default.createElement(React__default.Fragment, null, LinkButtonBlock.map((item, index) => {
2731
+ var _a, _b, _c;
2732
+ return (React__default.createElement(Button$1, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
2733
+ onClose === null || onClose === void 0 ? void 0 : onClose();
2734
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2735
+ } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
2736
+ })));
2737
+ const PopupHeader = showHeader && (React__default.createElement("header", { className: clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default.createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default.createElement(React__default.Fragment, null,
2738
+ React__default.createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
2739
+ React__default.createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
2740
+ const PopupEmpty = showEmpty && (React__default.createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
2741
+ const PopupForm = (React__default.createElement(LeadFormProvider, { form: form },
2742
+ React__default.createElement("form", { ref: formRef, className: "leadgen-form", onSubmit: middlewareOnSubmit },
2743
+ React__default.createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
2744
+ React__default.createElement("div", { className: "leadgen-form_inner" },
2745
+ React__default.createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
2746
+ const PopupOtp = showOtpPhone && (React__default.createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
2747
+ setShowOtpPhone(null);
2748
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
2749
+ } }));
2750
+ const PopupThankYou = showThankyou && (React__default.createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
2751
+ const PopupContent = (React__default.createElement("div", { className: clsx('leadgen-content', {
2752
+ 'leadgen-content_small': limitFieldsLightBoxB,
2753
+ }) },
2754
+ !headerInsideFormContainer && PopupHeader,
2755
+ !onlyHeader && (React__default.createElement("div", { className: "leadgen-inner" },
2756
+ PopupThankYou,
2757
+ !showThankyou && (React__default.createElement(React__default.Fragment, null,
2758
+ PopupOtp,
2759
+ PopupEmpty,
2760
+ !(showOtpPhone || showEmpty) && PopupForm))))));
2761
+ const styleOverlay = useMemo(() => {
2762
+ let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
2763
+ if (isMobile && imageOverlayMobile) {
2764
+ styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
2765
+ }
2766
+ if (!isMobile && imageOverlayDesktop) {
2767
+ styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
2768
+ }
2769
+ return styleContent;
2770
+ }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
2771
+ const PopupWrapper = (React__default.createElement(React__default.Fragment, null,
2772
+ React__default.createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
2773
+ React__default.createElement("div", { className: clsx('leadgen-wrapper', {
2774
+ 'leadgen-wrapper_small': limitFieldsLightBoxB,
2775
+ }) },
2776
+ showButtonClose && (React__default.createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
2777
+ PopupContent)));
2778
+ const popupContainerClassName = clsx('leadgen', `leadgen-${currentLayout}`, {
2779
+ 'leadgen-lightbox': isLightBox,
2780
+ 'leadgen-inline': isInPage,
2781
+ 'leadgen-slider': isSlider,
2782
+ });
2783
+ const PopupContainer = isDrawer ? (React__default.createElement(DrawerComponent, { fadeFromIndex: ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
2784
+ PopupWrapper,
2785
+ React__default.createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default.createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
2786
+ isFullscreen ? (React__default.createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
2787
+ aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
2788
+ } })) : null,
2789
+ PopupWrapper));
2790
+ if (!renderAfterImageSizes)
2791
+ return null;
2792
+ if (isLightBox || isFullscreen || isSlider) {
2793
+ return PopupContainer;
2794
+ }
2795
+ else if (isSidebar) {
2796
+ return React__default.createElement(SideBarLayout, { content: PopupContainer });
2797
+ }
2798
+ else if (isInline) {
2799
+ return (React__default.createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
2800
+ }
2801
+ return null;
2802
+ };
2803
+
2804
+ const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
2805
+ const currentPath = location.pathname;
2806
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
2807
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
2808
+ if (!imageMobileLoaded || !imageDesktopLoaded)
2809
+ return null;
2810
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
2811
+ currentLayout == 'SkinA' ? (React__default.createElement("aside", { className: "le-only-desktop" },
2812
+ React__default.createElement("div", { className: "le-skin-a-desktop" },
2813
+ React__default.createElement("div", { style: { position: 'relative' } },
2814
+ React__default.createElement("img", { src: imageDesktop, style: {
2815
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2816
+ } }),
2817
+ React__default.createElement("a", { style: {
2818
+ position: 'absolute',
2819
+ top: '75%',
2820
+ left: '50%',
2821
+ transform: 'translate(-50%, -50%)',
2822
+ textAlign: 'center',
2823
+ width: 'calc(100% - 15px)',
2824
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2825
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
2826
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default.createElement("aside", { className: "le-only-desktop" },
2827
+ React__default.createElement("div", { className: "" },
2828
+ React__default.createElement("div", { style: { position: 'relative', zIndex: 10000 } },
2829
+ React__default.createElement("img", { src: imageDesktop, style: {
2830
+ width: '100%',
2831
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2832
+ } }),
2833
+ React__default.createElement("a", { style: {
2834
+ position: 'absolute',
2835
+ top: '75%',
2836
+ left: '50%',
2837
+ transform: 'translate(-50%, -50%)',
2838
+ textAlign: 'center',
2839
+ width: '100%',
2840
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2841
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2842
+ React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
2843
+ React__default.createElement("aside", { className: "le-only-mobile" },
2844
+ React__default.createElement("div", { className: "le-skin-mobile" },
2845
+ React__default.createElement("div", { style: { position: 'relative' } },
2846
+ isVideo(imageMobile) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true },
2847
+ React__default.createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default.createElement("img", { src: imageMobile, style: {
2848
+ width: '100%',
2849
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
2850
+ } })),
2851
+ React__default.createElement("a", { style: {
2852
+ position: 'absolute',
2853
+ top: '82%',
2854
+ left: '50%',
2855
+ transform: 'translate(-50%, -50%)',
2856
+ textAlign: 'center',
2857
+ maxWidth: 'calc(100% - 15px)',
2858
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2859
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2860
+ React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4039
2861
  };
4040
2862
 
4041
2863
  // url: imageBlocks.imageMobile.data.url
4042
2864
  // newTab: imageBlocks.imageMobile.data.newtab
4043
2865
  // image: campaignShow.image
4044
2866
  // imageDestkop: campaignShow.image_desktop
4045
- const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
4046
- LEADGEN_LAYOUT.Fullscreen,
4047
- LEADGEN_LAYOUT.Slider,
4048
- ];
4049
- const LEADGEN_LIMIT_LIGHTBOXB = 6;
4050
- const LEADGEN_SHOW_HEADER = [
4051
- 'LightBoxA',
4052
- 'InlineA',
4053
- LEADGEN_LAYOUT.Sidebar,
4054
- LEADGEN_LAYOUT.Slider,
4055
- ];
4056
- const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2867
+ const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
2868
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
2869
+ if (!imageLoaded)
2870
+ return null;
2871
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
2872
+ React__default.createElement("div", { className: "le-tab-popup" },
2873
+ React__default.createElement("div", { style: { position: 'relative' } },
2874
+ React__default.createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
2875
+ React__default.createElement("img", { className: "js-popup-other-submit", src: image, style: {
2876
+ aspectRatio: `${imageWidth}/${imageHeight}`,
2877
+ } })),
2878
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
2879
+ };
2880
+
2881
+ // import mockLeadData from './mockLeadData'
2882
+ const listCampaignScheduled = [];
2883
+ const listCampaignScheduledToActivated = [];
2884
+ const listCampaignActiveButExpired = [];
2885
+ const listCampaignExcludeSonsored = [];
2886
+ const listCampaignDifferentSponsor = [];
2887
+ const listCampaignNotDisplayInRangeOfTime = [];
2888
+ function isMobile() {
2889
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
2890
+ }
2891
+ const getShuffleArray = (array) => {
2892
+ const newArray = [...array];
2893
+ for (let i = newArray.length - 1; i > 0; i--) {
2894
+ const j = Math.floor(Math.random() * (i + 1));
2895
+ const temp = newArray[i];
2896
+ newArray[i] = newArray[j];
2897
+ newArray[j] = temp;
2898
+ }
2899
+ return newArray;
2900
+ };
2901
+ const getTimeByTimezone = (timeZone = 'UTC') => {
2902
+ const date = new Date();
2903
+ return new Date(date.toLocaleString('en-US', { timeZone }));
2904
+ };
2905
+ const parseDateByCampaignTime = (dateStr) => {
2906
+ // Format like this: 2023-04-04 00:00:00
2907
+ try {
2908
+ const [datePart, timePart] = dateStr.split(' ');
2909
+ const [year, month, day] = datePart.split('-').map(Number);
2910
+ const [hours, minutes, seconds] = timePart.split(':').map(Number);
2911
+ /** JavaScript counts months from 0 to 11 */
2912
+ return new Date(year, month - 1, day, hours, minutes, seconds);
2913
+ }
2914
+ catch (err) {
2915
+ return null;
2916
+ }
2917
+ };
2918
+ const checkCampaignNowInTimeframe = (c) => {
2919
+ var _a;
2920
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2921
+ const startedAtStr = c.started_at;
2922
+ const endedAtStr = c.ended_at;
2923
+ const startedDate = parseDateByCampaignTime(startedAtStr);
2924
+ const endedDate = parseDateByCampaignTime(endedAtStr);
2925
+ if (!startedDate || !endedDate) {
2926
+ return false;
2927
+ }
2928
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
2929
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2930
+ if (nowWithTimezoneMs <= endedDate.getTime() &&
2931
+ nowWithTimezoneMs >= startedDate.getTime()) {
2932
+ listCampaignScheduledToActivated.push(c);
2933
+ return true;
2934
+ }
2935
+ return false;
2936
+ };
2937
+ function checkCampaignActiveButExpireAlready(c) {
2938
+ var _a;
2939
+ /** Do not setup timeframe for this campaign. No need to check */
2940
+ if (c.forever === 1) {
2941
+ return true;
2942
+ }
2943
+ const startedAtStr = c.started_at;
2944
+ const endedAtStr = c.ended_at;
2945
+ const startedDate = parseDateByCampaignTime(startedAtStr);
2946
+ const endedDate = parseDateByCampaignTime(endedAtStr);
2947
+ /** Do not setup timeframe for this campaign. No need to check */
2948
+ if (!startedDate || !endedDate) {
2949
+ return true;
2950
+ }
2951
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2952
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
2953
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2954
+ /** Check if this expire already, do not show */
2955
+ if (nowWithTimezoneMs > endedDate.getTime()) {
2956
+ listCampaignActiveButExpired.push(c);
2957
+ return false;
2958
+ }
2959
+ return true;
2960
+ }
2961
+ function shouldNotDisplayIfExcludeAllSponsors(c) {
2962
+ var _a;
2963
+ const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
2964
+ const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
2965
+ if (isSponsored && excludeSponsored) {
2966
+ listCampaignExcludeSonsored.push(c);
2967
+ return true;
2968
+ }
2969
+ return false;
2970
+ }
2971
+ function shouldDisplayWithCurrentSponsor(c) {
4057
2972
  var _a, _b;
4058
- const { primaryColor } = useContext(LeadGenContext$1);
4059
- const { isMobile } = useScreenSize();
4060
- const [open, setOpen] = useState(!!campaignId);
4061
- const [showOtpPhone, setShowOtpPhone] = useState(null);
4062
- const [isSubmitLoading, setIsSubmitLoading] = useState(false);
4063
- const [snap, setSnap] = useState(0.8);
4064
- const formRef = useRef();
4065
- const onClose = () => {
4066
- if (showOtpPhone) {
4067
- setShowOtpPhone(null);
2973
+ try {
2974
+ // TODO: BE will rename `exclude_sponsored_list` later
2975
+ const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
2976
+ const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
2977
+ const dataSponsoredId = Number((_b = document
2978
+ .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
2979
+ // There is no config for sponsor id and white list, should show as default
2980
+ if (!dataSponsoredId ||
2981
+ dataSponsoredId <= 0 ||
2982
+ whiteListSponsors.length === 0) {
2983
+ return true;
4068
2984
  }
4069
- else {
4070
- onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2985
+ // Check the dataSponsoredId exists in the white list or not.
2986
+ const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
2987
+ if (isExist) {
2988
+ return true;
4071
2989
  }
4072
- };
4073
- const textBlocks = JSON.parse(extraFields.textBlocks);
4074
- const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
4075
- const actionBlocks = JSON.parse(extraFields.actionBlocks);
4076
- const popUpSubmitText = actionBlocks.submitBlock.data.value;
4077
- const currentPath = location.pathname;
4078
- const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
4079
- const { align: titleAlign } = textBlocks.titleBlock.data || {};
4080
- const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
4081
- const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
4082
- const isLightBox = currentLayout.includes('LightBox');
4083
- const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
4084
- const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
4085
- const isInline = currentLayout.includes('Inline');
4086
- const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
4087
- const isInPage = isInline || isSidebar;
4088
- const isDrawer = isLightBoxB && isMobile;
4089
- const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
4090
- const hasForm = isLightBoxA
4091
- ? listBlockAdded.some((item) => LEADGEN_BLOCK_INPUT.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
4092
- : true;
4093
- const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
4094
- const showHeader = !!imageMobile || !!imageDesktop;
4095
- const onlyHeader = !title && !description;
4096
- const showButtonClose = !isInline;
4097
- if (window.innerWidth < 769 &&
4098
- LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
4099
- console.log('😎 Not show fullscreen, slider on mobile ');
4100
- return null;
2990
+ listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
2991
+ return false;
4101
2992
  }
4102
- useEffect(() => {
4103
- if (isLightBox || isFullscreen) {
4104
- document.body.classList.add('noscroll');
4105
- }
4106
- if (!window.intlTelInputUtils) {
4107
- require('intl-tel-input/build/js/utils');
2993
+ catch (err) {
2994
+ // Default is show
2995
+ return true;
2996
+ }
2997
+ }
2998
+ const filterFnCampaign = (c) => {
2999
+ if (shouldNotDisplayIfExcludeAllSponsors(c)) {
3000
+ return false;
3001
+ }
3002
+ else if (!shouldDisplayWithCurrentSponsor(c)) {
3003
+ return false;
3004
+ }
3005
+ /** Active */
3006
+ if (c.formatted_status === 1) {
3007
+ return checkCampaignActiveButExpireAlready(c);
3008
+ }
3009
+ /** Schedule */
3010
+ if (c.formatted_status === 0) {
3011
+ listCampaignScheduled.push(c);
3012
+ return checkCampaignNowInTimeframe(c);
3013
+ }
3014
+ return false;
3015
+ };
3016
+ const fillterApprearanceTimeCampaign = (c) => {
3017
+ var _a;
3018
+ try {
3019
+ const isTimeInRange = (currentTime, startTime, endTime) => {
3020
+ const startParts = startTime.split(':');
3021
+ const endParts = endTime.split(':');
3022
+ const startDate = new Date();
3023
+ startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
3024
+ const endDate = new Date();
3025
+ endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
3026
+ return currentTime >= startDate && currentTime <= endDate;
3027
+ };
3028
+ const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
3029
+ const startTime = rulesApprValue.startTime;
3030
+ const endTime = rulesApprValue.endTime || '23:59';
3031
+ if (!startTime) {
3032
+ return true;
4108
3033
  }
4109
- clearCacheUsedEmailOrPhone();
4110
- }, []);
4111
- const validatingPhoneRef = useRef(false);
4112
- const validatingEmailRef = useRef(false);
4113
- const { form, validateObj } = useLeadFormConfig({
4114
- listBlockAdded,
4115
- validatingPhoneRef,
4116
- validatingEmailRef,
4117
- campaignId,
4118
- campaign_subot_id,
4119
- userInfo,
4120
- format: (_a = (ISO_FORMAT[locale] || ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
4121
- });
4122
- const onFocus = (e) => {
4123
- const target = e.target;
4124
- target.scrollIntoView({
4125
- block: 'center',
4126
- inline: 'nearest',
4127
- behavior: 'auto',
4128
- });
4129
- };
4130
- const middlewareOnSubmit = (e) => {
4131
- e.preventDefault();
4132
- // mark all as touched to allow validation
4133
- const fields = Object.keys(validateObj);
4134
- const fieldStatus = fields.reduce((acc, cur) => {
4135
- acc[cur] = true;
4136
- return acc;
4137
- }, {});
4138
- form.setTouched(fieldStatus);
4139
- if (validatingEmailRef.current || validatingPhoneRef.current) {
4140
- return;
3034
+ if (isTimeInRange(new Date(), startTime, endTime)) {
3035
+ return true;
4141
3036
  }
4142
- setTimeout(() => {
4143
- form.onSubmit((v) => {
4144
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4145
- if (Object.keys(form.errors).length)
4146
- return;
4147
- let newShowOtpPhone = null;
4148
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
4149
- // not submit yet, open otp
4150
- 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;
4151
- if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
4152
- newShowOtpPhone = {
4153
- phone: v[fieldName],
4154
- type: 'phone',
4155
- };
3037
+ listCampaignNotDisplayInRangeOfTime.push(c);
3038
+ return false;
3039
+ }
3040
+ catch (err) {
3041
+ return true;
3042
+ }
3043
+ };
3044
+ let timeoutRef = null;
3045
+ let LEAD_SCROLL_EVENT = null;
3046
+ function clearPassiveEvent() {
3047
+ if (timeoutRef) {
3048
+ clearTimeout(timeoutRef);
3049
+ timeoutRef = null;
3050
+ }
3051
+ if (LEAD_SCROLL_EVENT) {
3052
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3053
+ LEAD_SCROLL_EVENT = null;
3054
+ }
3055
+ }
3056
+ function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
3057
+ // clear previous passive event, check for new condition
3058
+ clearPassiveEvent();
3059
+ const leadCurrentUrl = DEBUG_URL ||
3060
+ ('https://' +
3061
+ location.hostname +
3062
+ location.pathname +
3063
+ location.search).toLowerCase();
3064
+ fetch(leadApi + 'api/campaign/' + leadSiteId, {
3065
+ method: 'POST',
3066
+ headers: {
3067
+ 'Content-Type': 'application/json',
3068
+ },
3069
+ body: JSON.stringify({
3070
+ url: leadCurrentUrl,
3071
+ ga_client_id: getCookie('_ga') || null,
3072
+ }),
3073
+ })
3074
+ .then((response) => {
3075
+ return response.json();
3076
+ // return mockLeadData || response.json()
3077
+ })
3078
+ .then((data) => {
3079
+ var _a, _b, _c, _d;
3080
+ LeadLog('List campagin: ', data);
3081
+ LEAD_RESET_VAR();
3082
+ if (data._status == 1) {
3083
+ 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);
3084
+ if (!getCookie('hhg-id')) {
3085
+ setCookie('hhg-id', v1(), {
3086
+ domain: '.' + leadDomain,
3087
+ path: '/',
3088
+ });
3089
+ LeadLog('😍 Set HHG ID cookie');
3090
+ }
3091
+ // getCookie('hhg-id')
3092
+ // TODO: HP-534 Filter desktop
3093
+ let campaignsDevice = [];
3094
+ if (isMobile()) {
3095
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
3096
+ }
3097
+ else {
3098
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
3099
+ }
3100
+ LeadLog(`👓 campaignsDevice`, campaignsDevice);
3101
+ LeadLog('--listCampaignScheduled', listCampaignScheduled);
3102
+ LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
3103
+ LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
3104
+ LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
3105
+ LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
3106
+ LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
3107
+ // Check links
3108
+ let listLinksObj = campaignsDevice
3109
+ .map((i, index) => i.targets
3110
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
3111
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3112
+ .flat(1);
3113
+ // Check list link match current href
3114
+ listLinksObj = listLinksObj.filter((i) => {
3115
+ var _a;
3116
+ const target = new URL(String(i.target).toLowerCase());
3117
+ if (i.option == 'exact_match')
3118
+ // FOR TEST LOCAL:
3119
+ // return Boolean(location.pathname === target.pathname)
3120
+ return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
3121
+ if (i.option == 'start_with') {
3122
+ // FOR TEST LOCAL:
3123
+ // if (location.pathname.includes(target.pathname)) {
3124
+ if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
3125
+ const listExcluding = i.sub_target
3126
+ .filter((i) => i.option == 'excluding')
3127
+ .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
3128
+ return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
4156
3129
  }
4157
- }
4158
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
4159
- // not submit yet, open otp
4160
- 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;
4161
- if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
4162
- newShowOtpPhone = {
4163
- phone: v[fieldName],
4164
- type: 'whatsapp',
4165
- };
3130
+ else {
3131
+ return false;
4166
3132
  }
4167
3133
  }
4168
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
4169
- // not submit yet, open otp
4170
- 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;
4171
- if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
4172
- newShowOtpPhone = {
4173
- phone: v[fieldName],
4174
- type: 'zalo',
4175
- };
4176
- }
3134
+ });
3135
+ // Check tags
3136
+ const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
3137
+ const listTags = listMetaTag.map((i) => i.content);
3138
+ let listCampaignHasTag = [];
3139
+ let listTagsObj = [];
3140
+ if (listTags && listTags.length) {
3141
+ listCampaignHasTag = campaignsDevice
3142
+ .map((i, index) => i.targets
3143
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
3144
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3145
+ .flat(1);
3146
+ listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
3147
+ }
3148
+ const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
3149
+ const cookieKeys = document.cookie
3150
+ .split('; ')
3151
+ .map((i) => i.split('=')[0]);
3152
+ const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
3153
+ LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
3154
+ const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
3155
+ LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
3156
+ const listCampaignSubmitedClosed = [
3157
+ ...listCampaignCodeSubmited,
3158
+ ...listCampaignCodeClosed,
3159
+ ];
3160
+ const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
3161
+ const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
3162
+ return !hasSubmited;
3163
+ });
3164
+ const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
3165
+ // .sort(
3166
+ // (a, b) =>
3167
+ // (listCampaignValid[a.campaignIndex]?.score || 0) -
3168
+ // (listCampaignValid[b.campaignIndex]?.score || 0),
3169
+ // )
3170
+ LeadLog('--listCampaignValid : ', listCampaignValid);
3171
+ if (listCampaignValid && listCampaignValid.length) {
3172
+ const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
3173
+ LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
3174
+ const { rules } = CAMPAIGN_SHOW;
3175
+ // CHECK RULE TRIGGER POPUP
3176
+ const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
3177
+ LeadLog(`timeoutRule`, timeoutRule);
3178
+ const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
3179
+ LeadLog(`scrollRule`, scrollRule);
3180
+ let impressionAction = 'TIME';
3181
+ if (Number.isInteger(timeoutRule)) {
3182
+ impressionAction = 'TIME';
3183
+ LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
3184
+ timeoutRef = setTimeout(() => {
3185
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3186
+ }, timeoutRule * 1000);
4177
3187
  }
4178
- if (newShowOtpPhone) {
4179
- setIsSubmitLoading(true);
4180
- Service.sendSMSOtpLead(newShowOtpPhone)
4181
- .then((res) => {
4182
- var _a;
4183
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4184
- if (respMessage === 'This phone number was verified') {
4185
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4186
- return;
3188
+ if (Number.isInteger(scrollRule)) {
3189
+ impressionAction = 'SCROLL';
3190
+ LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
3191
+ const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
3192
+ document.querySelector('body');
3193
+ const pct = $p.getBoundingClientRect().top;
3194
+ const pb = $p.offsetHeight;
3195
+ LeadLog(`👓 Element check scroll: `, $p);
3196
+ LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
3197
+ const wt = window.pageYOffset || document.documentElement.scrollTop;
3198
+ let percent = 0;
3199
+ if (wt >= pct) {
3200
+ percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
4187
3201
  }
4188
- setShowOtpPhone(newShowOtpPhone);
4189
- })
4190
- .finally(() => {
4191
- setIsSubmitLoading(false);
3202
+ LeadLog('---Scroll', percent, scrollRule);
3203
+ // TODO: CHECK FOOTER HEIGHT
3204
+ if (percent >= scrollRule) {
3205
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3206
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3207
+ }
3208
+ };
3209
+ window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
3210
+ passive: true,
4192
3211
  });
4193
- return;
4194
3212
  }
4195
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4196
- })(e);
4197
- }, 100);
4198
- };
4199
- const onOpenChange = (_open) => {
4200
- setOpen(_open);
4201
- if (!_open) {
4202
- setTimeout(() => {
4203
- onClose();
4204
- }, 250);
4205
- }
4206
- };
4207
- const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
4208
- const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
4209
- const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
4210
- const renderAfterImageSizes = imageMobileLoaded &&
4211
- imageDesktopLoaded &&
4212
- (isFullscreen ? imageBackgroundLoaded : true);
4213
- const ButtonSubmit = useMemo(() => {
4214
- var _a;
4215
- return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default.createElement(Button$1, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
4216
- }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
4217
- const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
4218
- const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default.createElement(React__default.Fragment, null, LinkButtonBlock.map((item, index) => {
4219
- var _a, _b, _c;
4220
- return (React__default.createElement(Button$1, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
4221
- onClose === null || onClose === void 0 ? void 0 : onClose();
4222
- onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
4223
- } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
4224
- })));
4225
- const PopupHeader = showHeader && (React__default.createElement("header", { className: clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default.createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default.createElement(React__default.Fragment, null,
4226
- React__default.createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
4227
- React__default.createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
4228
- const PopupEmpty = showEmpty && (React__default.createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
4229
- const PopupForm = (React__default.createElement(LeadFormProvider, { form: form },
4230
- React__default.createElement("form", { ref: formRef, className: "leadgen-form", onFocus: onFocus, onSubmit: middlewareOnSubmit },
4231
- React__default.createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
4232
- React__default.createElement("div", { className: "leadgen-form_inner" },
4233
- React__default.createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
4234
- const PopupOtp = showOtpPhone && (React__default.createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
4235
- setShowOtpPhone(null);
4236
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
4237
- } }));
4238
- const PopupThankYou = showThankyou && (React__default.createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
4239
- const PopupContent = (React__default.createElement("div", { className: clsx('leadgen-content', {
4240
- 'leadgen-content_small': limitFieldsLightBoxB,
4241
- }) },
4242
- !headerInsideFormContainer && PopupHeader,
4243
- !onlyHeader && (React__default.createElement("div", { className: "leadgen-inner" },
4244
- PopupThankYou,
4245
- !showThankyou && (React__default.createElement(React__default.Fragment, null,
4246
- PopupOtp,
4247
- PopupEmpty,
4248
- !(showOtpPhone || showEmpty) && PopupForm))))));
4249
- const styleOverlay = useMemo(() => {
4250
- let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
4251
- if (isMobile && imageOverlayMobile) {
4252
- styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4253
- }
4254
- if (!isMobile && imageOverlayDesktop) {
4255
- styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
3213
+ }
3214
+ else {
3215
+ LeadLog('🚧 No lead campaigns on current URL, tags');
3216
+ }
4256
3217
  }
4257
- return styleContent;
4258
- }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
4259
- const PopupWrapper = (React__default.createElement(React__default.Fragment, null,
4260
- React__default.createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
4261
- React__default.createElement("div", { className: clsx('leadgen-wrapper', {
4262
- 'leadgen-wrapper_small': limitFieldsLightBoxB,
4263
- }) },
4264
- showButtonClose && (React__default.createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
4265
- PopupContent)));
4266
- const popupContainerClassName = clsx('leadgen', `leadgen-${currentLayout}`, {
4267
- 'leadgen-lightbox': isLightBox,
4268
- 'leadgen-inline': isInPage,
4269
- 'leadgen-slider': isSlider,
3218
+ })
3219
+ .catch((err) => {
3220
+ LeadLog(`Lead error: `, err);
4270
3221
  });
4271
- const PopupContainer = isDrawer ? (React__default.createElement(DrawerComponent, { fadeFromIndex: ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
4272
- PopupWrapper,
4273
- React__default.createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default.createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
4274
- isFullscreen ? (React__default.createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
4275
- aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
4276
- } })) : null,
4277
- PopupWrapper));
4278
- if (!renderAfterImageSizes)
4279
- return null;
4280
- if (isLightBox || isFullscreen || isSlider) {
4281
- return PopupContainer;
4282
- }
4283
- else if (isSidebar) {
4284
- return React__default.createElement(SideBarLayout, { content: PopupContainer });
4285
- }
4286
- else if (isInline) {
4287
- return (React__default.createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
3222
+ }
3223
+ const LeadLog = (...params) => {
3224
+ if (process.env.NODE_ENV !== 'production' ||
3225
+ (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
3226
+ process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
3227
+ (typeof localStorage !== 'undefined' &&
3228
+ localStorage.getItem('hhg_debug') === 'true')) {
3229
+ console.log(...params);
4288
3230
  }
4289
- return null;
4290
- };
4291
-
4292
- const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
4293
- const currentPath = location.pathname;
4294
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
4295
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
4296
- if (!imageMobileLoaded || !imageDesktopLoaded)
4297
- return null;
4298
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
4299
- currentLayout == 'SkinA' ? (React__default.createElement("aside", { className: "le-only-desktop" },
4300
- React__default.createElement("div", { className: "le-skin-a-desktop" },
4301
- React__default.createElement("div", { style: { position: 'relative' } },
4302
- React__default.createElement("img", { src: imageDesktop, style: {
4303
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4304
- } }),
4305
- React__default.createElement("a", { style: {
4306
- position: 'absolute',
4307
- top: '75%',
4308
- left: '50%',
4309
- transform: 'translate(-50%, -50%)',
4310
- textAlign: 'center',
4311
- width: 'calc(100% - 15px)',
4312
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4313
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
4314
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default.createElement("aside", { className: "le-only-desktop" },
4315
- React__default.createElement("div", { className: "" },
4316
- React__default.createElement("div", { style: { position: 'relative', zIndex: 10000 } },
4317
- React__default.createElement("img", { src: imageDesktop, style: {
4318
- width: '100%',
4319
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4320
- } }),
4321
- React__default.createElement("a", { style: {
4322
- position: 'absolute',
4323
- top: '75%',
4324
- left: '50%',
4325
- transform: 'translate(-50%, -50%)',
4326
- textAlign: 'center',
4327
- width: '100%',
4328
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4329
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4330
- React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
4331
- React__default.createElement("aside", { className: "le-only-mobile" },
4332
- React__default.createElement("div", { className: "le-skin-mobile" },
4333
- React__default.createElement("div", { style: { position: 'relative' } },
4334
- isVideo(imageMobile) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true },
4335
- React__default.createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default.createElement("img", { src: imageMobile, style: {
4336
- width: '100%',
4337
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
4338
- } })),
4339
- React__default.createElement("a", { style: {
4340
- position: 'absolute',
4341
- top: '82%',
4342
- left: '50%',
4343
- transform: 'translate(-50%, -50%)',
4344
- textAlign: 'center',
4345
- maxWidth: 'calc(100% - 15px)',
4346
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4347
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4348
- React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4349
- };
4350
-
4351
- // url: imageBlocks.imageMobile.data.url
4352
- // newTab: imageBlocks.imageMobile.data.newtab
4353
- // image: campaignShow.image
4354
- // imageDestkop: campaignShow.image_desktop
4355
- const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
4356
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
4357
- if (!imageLoaded)
4358
- return null;
4359
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
4360
- React__default.createElement("div", { className: "le-tab-popup" },
4361
- React__default.createElement("div", { style: { position: 'relative' } },
4362
- React__default.createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
4363
- React__default.createElement("img", { className: "js-popup-other-submit", src: image, style: {
4364
- aspectRatio: `${imageWidth}/${imageHeight}`,
4365
- } })),
4366
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
4367
3231
  };
4368
3232
 
4369
3233
  function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
@@ -4379,7 +3243,7 @@ function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
4379
3243
  }
4380
3244
  const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, showEmpty, setShowEmpty, userInfo, }) => {
4381
3245
  var _a, _b;
4382
- const { apiUrl, siteDomain } = useContext(LeadGenContext$1);
3246
+ const { apiUrl, siteDomain } = useContext(LeadGenContext);
4383
3247
  useEffect(() => {
4384
3248
  const gaCookie = getCookie('_ga') || null;
4385
3249
  fetch(`${apiUrl}api/campaign/${code}/impression`, {
@@ -4774,7 +3638,7 @@ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, primaryColor
4774
3638
  leadStartTimeRef.current = Date.now();
4775
3639
  }
4776
3640
  }, [showCampaign]);
4777
- return (React__default.createElement(LeadGenContext$1.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
3641
+ return (React__default.createElement(LeadGenContext.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
4778
3642
  React__default.createElement(TranslationsContext.Provider, { value: { locale, values: getTranslations(locale) } }, children ? (React__default.createElement(Component, { campaign: showCampaign, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, setShowThankyou: setShowThankyou, locale: locale, showEmpty: showEmpty, setShowEmpty: setShowEmpty, userInfo: userInfo }, children)) : (React__default.createElement(Portal, { target: getPopupWrapperDom() },
4779
3643
  React__default.createElement(Box, { sx: { position: 'fixed', zIndex: ZINDEX_SSO - 9e6 } },
4780
3644
  React__default.createElement(Transition, { mounted: Boolean(((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1'), transition: "fade", duration: 600, timingFunction: "ease" }, (styles) => {
@@ -4794,4 +3658,4 @@ LeadGen.Thankyou = Thankyou;
4794
3658
  LeadGen.OtpForm = OtpBlock$1;
4795
3659
  LeadGen.Close = Close;
4796
3660
 
4797
- export { LeadGen, LeadGenSubscriptionBox };
3661
+ export { LeadGen };