@hhgtech/hhg-components 1.29.375 → 1.29.377-beta-1

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 (555) hide show
  1. package/build/{InputDate-9746e093.js → InputDate-abe5f7d3.js} +3 -3
  2. package/build/{LastPeriod-b3289339.js → LastPeriod-1a87434b.js} +1 -1
  3. package/build/{MobileBottomNavigationIcon-e1b98872.js → MobileBottomNavigationIcon-a9432107.js} +3 -3
  4. package/build/{Spinner-d314a67a.js → Spinner-e10b7a0d.js} +1 -1
  5. package/build/{WhatsApp-a8b76a33.js → WhatsApp-b3745def.js} +1 -1
  6. package/build/adapters.js +19 -19
  7. package/build/atoms.js +48 -48
  8. package/build/babyGrowth.js +83 -83
  9. package/build/cache.js +2 -2
  10. package/build/care.js +17 -17
  11. package/build/careBookingSearchBar.js +14 -14
  12. package/build/careBookingSearchBarV2.js +15 -15
  13. package/build/components/mantine/phone/index.d.ts +2 -0
  14. package/build/components/mantine/phoneInput/PhoneInput.d.ts +17 -0
  15. package/build/components/mantine/phoneInput/index.d.ts +1 -0
  16. package/build/components.js +97 -96
  17. package/build/{constants-6af492f0.js → constants-568a22fc.js} +1 -1
  18. package/build/constants.js +3 -3
  19. package/build/constantsDomainLocales.js +1 -1
  20. package/build/constantsRiskScreener.js +2 -2
  21. package/build/constantsSite.js +2 -2
  22. package/build/{core-1953f8f6.js → core-a559ea40.js} +1 -1
  23. package/build/{dataTransform-299d341e.js → dataTransform-17114bfa.js} +1 -1
  24. package/build/ecom.js +4 -4
  25. package/build/{editor-9e5803b8.js → editor-5fcd14e8.js} +11 -11
  26. package/build/embeddedHeathToolCards_babyGrowth.js +23 -23
  27. package/build/embeddedHeathToolCards_babyPoop.js +19 -19
  28. package/build/embeddedHeathToolCards_babyVaccine.js +22 -22
  29. package/build/embeddedHeathToolCards_bmi_bmi.js +25 -25
  30. package/build/embeddedHeathToolCards_bmrBmr.js +25 -25
  31. package/build/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  32. package/build/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  33. package/build/embeddedHeathToolCards_pwg_pwg.js +26 -26
  34. package/build/embeddedHeathToolCards_targetHeartRate.js +27 -27
  35. package/build/esm/{InputDate-c0b788ac.js → InputDate-b2ce7a01.js} +3 -3
  36. package/build/esm/{LastPeriod-da33c15d.js → LastPeriod-8cfbf528.js} +1 -1
  37. package/build/esm/{MobileBottomNavigationIcon-12879b99.js → MobileBottomNavigationIcon-526d012c.js} +3 -3
  38. package/build/esm/{Spinner-db469081.js → Spinner-331b4c48.js} +1 -1
  39. package/build/esm/{WhatsApp-73d081fc.js → WhatsApp-56430558.js} +1 -1
  40. package/build/esm/adapters.js +19 -19
  41. package/build/esm/atoms.js +48 -48
  42. package/build/esm/babyGrowth.js +83 -83
  43. package/build/esm/cache.js +2 -2
  44. package/build/esm/care.js +17 -17
  45. package/build/esm/careBookingSearchBar.js +14 -14
  46. package/build/esm/careBookingSearchBarV2.js +15 -15
  47. package/build/esm/components/mantine/phone/index.d.ts +2 -0
  48. package/build/esm/components/mantine/phoneInput/PhoneInput.d.ts +17 -0
  49. package/build/esm/components/mantine/phoneInput/index.d.ts +1 -0
  50. package/build/esm/components.js +97 -96
  51. package/build/esm/{constants-18894c10.js → constants-7709acdd.js} +1 -1
  52. package/build/esm/constants.js +3 -3
  53. package/build/esm/constantsDomainLocales.js +1 -1
  54. package/build/esm/constantsRiskScreener.js +2 -2
  55. package/build/esm/constantsSite.js +2 -2
  56. package/build/esm/{core-9f8d6b2f.js → core-5b7c1e40.js} +1 -1
  57. package/build/esm/{dataTransform-7a22b3a7.js → dataTransform-649b0786.js} +1 -1
  58. package/build/esm/ecom.js +4 -4
  59. package/build/esm/{editor-df66b793.js → editor-7920cf94.js} +11 -11
  60. package/build/esm/embeddedHeathToolCards_babyGrowth.js +23 -23
  61. package/build/esm/embeddedHeathToolCards_babyPoop.js +19 -19
  62. package/build/esm/embeddedHeathToolCards_babyVaccine.js +22 -22
  63. package/build/esm/embeddedHeathToolCards_bmi_bmi.js +25 -25
  64. package/build/esm/embeddedHeathToolCards_bmrBmr.js +25 -25
  65. package/build/esm/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  66. package/build/esm/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  67. package/build/esm/embeddedHeathToolCards_pwg_pwg.js +26 -26
  68. package/build/esm/embeddedHeathToolCards_targetHeartRate.js +27 -27
  69. package/build/esm/footer.js +21 -21
  70. package/build/esm/gAssets.js +2 -2
  71. package/build/esm/{healthTools-f90bfa20.js → healthTools-edfd2eb5.js} +1 -1
  72. package/build/esm/healthToolsCardWrapper.js +18 -18
  73. package/build/esm/healthToolsForm.js +33 -33
  74. package/build/esm/hooks.js +13 -13
  75. package/build/esm/i18n/translationKeys.d.ts +1 -1
  76. package/build/esm/i18n-values/en-PH.js +2 -0
  77. package/build/esm/i18n-values/hi-IN.js +2 -0
  78. package/build/esm/i18n-values/id-ID.js +2 -0
  79. package/build/esm/i18n-values/km-KH.js +2 -0
  80. package/build/esm/i18n-values/ms-MY.js +2 -0
  81. package/build/esm/i18n-values/my-MM.js +2 -0
  82. package/build/esm/i18n-values/th-TH.js +2 -0
  83. package/build/esm/i18n-values/tl-PH.js +2 -0
  84. package/build/esm/i18n-values/vi-VN.js +2 -0
  85. package/build/esm/i18n-values/vi-VN_MB.js +2 -0
  86. package/build/esm/i18n-values/zh-TW.js +2 -0
  87. package/build/esm/i18n.js +14 -56
  88. package/build/esm/i18nV2.js +2 -2
  89. package/build/esm/{index-26f91073.js → index-00fabdad.js} +2 -2
  90. package/build/esm/{index-5e6dc6db.js → index-03537835.js} +3 -3
  91. package/build/esm/{index-0e19d192.js → index-058ac87e.js} +2 -2
  92. package/build/esm/{index-f5f10d16.js → index-060f6f12.js} +1 -1
  93. package/build/esm/{index-f3b8d349.js → index-0aa91bdd.js} +22 -22
  94. package/build/esm/{index-56b5378a.js → index-0c44d75a.js} +15 -15
  95. package/build/esm/{index-98cfd37b.js → index-1092f0f5.js} +13 -13
  96. package/build/esm/{index-ef81684d.js → index-1304a21b.js} +6 -6
  97. package/build/esm/{index-316933cd.js → index-15801ba3.js} +17 -17
  98. package/build/esm/{index-07b81bb7.js → index-1efb6f1c.js} +36 -27
  99. package/build/esm/{index-7f770fe8.js → index-1f49627e.js} +6 -6
  100. package/build/esm/{index-f9f05826.js → index-2578b291.js} +5 -5
  101. package/build/esm/{index-3c763567.js → index-2936c86d.js} +24 -24
  102. package/build/esm/{index-e04827a2.js → index-2c42c4b1.js} +13 -13
  103. package/build/esm/{index-6ac72472.js → index-2d681bb1.js} +2 -2
  104. package/build/esm/{index-61a111f8.js → index-387b6a7e.js} +7 -7
  105. package/build/esm/{index-34ffb6c1.js → index-40d6d872.js} +16 -16
  106. package/build/esm/{index-1c00c095.js → index-41de2790.js} +16 -16
  107. package/build/esm/{index-8c47541d.js → index-48b9dacc.js} +32 -32
  108. package/build/esm/{index-6e1ef507.js → index-49483897.js} +13 -13
  109. package/build/esm/{index-1a274479.js → index-4dd012ed.js} +1 -1
  110. package/build/esm/{index-5aef6986.js → index-4e070ed4.js} +25 -25
  111. package/build/esm/{index-db312639.js → index-4fb26806.js} +8 -8
  112. package/build/esm/{index-5d0200f0.js → index-55426f3f.js} +6 -6
  113. package/build/esm/{index-7e78248e.js → index-5aa2abd0.js} +6 -6
  114. package/build/esm/{index-7dbb26d3.js → index-644ce9eb.js} +6 -6
  115. package/build/esm/{index-0a217701.js → index-75a80699.js} +1 -1
  116. package/build/esm/{index-d2068808.js → index-7cd5e936.js} +18 -18
  117. package/build/esm/{index-996fae38.js → index-856879fb.js} +32 -32
  118. package/build/esm/{index-ad8d1314.js → index-8e419708.js} +1 -1
  119. package/build/esm/{index-a4c8373a.js → index-90e1f459.js} +3 -3
  120. package/build/esm/{index-5a7a5244.js → index-91660a5d.js} +31 -31
  121. package/build/esm/{index-df5a5394.js → index-92e80bd7.js} +5 -5
  122. package/build/esm/{index-9fe97cf0.js → index-938b5315.js} +1 -1
  123. package/build/esm/{index-90bb49a7.js → index-95992399.js} +18 -18
  124. package/build/esm/{index-13feaf1a.js → index-961a5ff8.js} +4 -4
  125. package/build/esm/{index-681d28d8.js → index-99f48e63.js} +2 -2
  126. package/build/esm/{index-c3500f4e.js → index-9b0507b8.js} +2 -2
  127. package/build/esm/{index-99b5a528.js → index-9b4a3e00.js} +3 -3
  128. package/build/esm/{index-8b74f8e4.js → index-9f65f06b.js} +1 -1
  129. package/build/esm/{index-d534eff3.js → index-ac92b012.js} +3 -3
  130. package/build/esm/{index-126572b4.js → index-aee4ed06.js} +17 -17
  131. package/build/esm/{index-1fd83190.js → index-b0fc12d7.js} +2 -2
  132. package/build/esm/{index-b23acf00.js → index-b15bd936.js} +17 -17
  133. package/build/esm/{index-d1038670.js → index-b6372191.js} +2 -2
  134. package/build/esm/{index-57aabb5e.js → index-b6ab4200.js} +7 -7
  135. package/build/esm/{index-6a5f45df.js → index-b842173b.js} +1 -1
  136. package/build/esm/{index-388b5a52.js → index-bdc0639a.js} +3 -3
  137. package/build/esm/{index-eeb5bd9e.js → index-c4baa985.js} +13 -13
  138. package/build/esm/{index-cd5faa30.js → index-ca3139c5.js} +1 -1
  139. package/build/esm/{index-3e1277d2.js → index-ca5bc107.js} +2 -2
  140. package/build/esm/{index-4ba59648.js → index-ced11bc9.js} +2 -2
  141. package/build/esm/{index-2a6cde75.js → index-cfc15885.js} +2 -2
  142. package/build/esm/{index-cc1d1a1a.js → index-d067f615.js} +2 -2
  143. package/build/esm/{index-6fac949c.js → index-d1796a79.js} +2 -2
  144. package/build/esm/{index-46b0d30a.js → index-d53f1699.js} +2 -2
  145. package/build/esm/{index-760ba1e0.js → index-d5478827.js} +10 -10
  146. package/build/esm/{index-53894be7.js → index-d8aa73a2.js} +16 -16
  147. package/build/esm/index-de1b0c2d.js +183 -0
  148. package/build/esm/{index-ef33fd3f.js → index-e58d215e.js} +1 -1
  149. package/build/esm/{index-4f0a6c84.js → index-e5dfbc47.js} +3 -3
  150. package/build/esm/{index-dfb047ee.js → index-e6cd3c3e.js} +16 -16
  151. package/build/esm/{index-128f0837.js → index-f56fc17d.js} +3 -3
  152. package/build/esm/{index-0c735d3c.js → index-fdb9cf96.js} +17 -17
  153. package/build/esm/{index-9bfc12bd.js → index-fe11f730.js} +21 -21
  154. package/build/esm/index.js +118 -117
  155. package/build/esm/interfaces/types/index.d.ts +1 -0
  156. package/build/esm/{labelSorting-5231682b.js → labelSorting-cc32d5cf.js} +4 -4
  157. package/build/esm/lead/LeadGen.type.d.ts +34 -0
  158. package/build/esm/lead/LeadGenForm/LeadGenForm.d.ts +41 -0
  159. package/build/esm/lead/LeadGenForm/LeadGenForm.helpers.d.ts +2 -0
  160. package/build/esm/lead/LeadGenForm/LeadGenForm.styled.d.ts +5 -0
  161. package/build/esm/lead/LeadGenForm/LeadGenFormPhone.d.ts +17 -0
  162. package/build/esm/lead/LeadGenForm/LeadGenThankYou.d.ts +20 -0
  163. package/build/esm/lead/LeadGenForm/index.d.ts +3 -0
  164. package/build/esm/lead/LeadGenForm/textField/index.d.ts +13 -0
  165. package/build/esm/lead/LeadGenForm/textField/index.styled.d.ts +11 -0
  166. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +66 -0
  167. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +4 -0
  168. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +21 -0
  169. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +3 -0
  170. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +24 -0
  171. package/build/esm/lead/LeadGenSubscriptionBox/index.d.ts +1 -0
  172. package/build/esm/lead/LeadGenTranslationContext.d.ts +6 -0
  173. package/build/esm/lead/helpers.d.ts +56 -1
  174. package/build/esm/lead/index.d.ts +2 -1
  175. package/build/esm/lead/services/index.d.ts +21 -0
  176. package/build/esm/lead/store/index.d.ts +1 -0
  177. package/build/esm/lead.js +2428 -1232
  178. package/build/esm/{logoIcon-c50c983d.js → logoIcon-a4e12f74.js} +2 -2
  179. package/build/esm/mantine.js +25 -25
  180. package/build/esm/misc.js +17 -17
  181. package/build/esm/miscGetDynamicHealthTool.js +4 -4
  182. package/build/esm/miscGetSocialList.js +8 -8
  183. package/build/esm/miscScreenSizeContext.js +1 -1
  184. package/build/esm/mobileBottomNavigation.js +5 -5
  185. package/build/esm/mobileBottomNavigationIcon.js +5 -5
  186. package/build/esm/molecules.js +74 -73
  187. package/build/esm/moleculesArticleCard.js +6 -6
  188. package/build/esm/moleculesArticleCardV2.js +16 -16
  189. package/build/esm/navigation.js +46 -45
  190. package/build/esm/navigationLogoutPopup.js +9 -9
  191. package/build/esm/navigationProfileButton.js +23 -23
  192. package/build/esm/onboardingV2.js +29 -29
  193. package/build/esm/organisms.js +50 -49
  194. package/build/esm/{post-6fd50030.js → post-32f29bf1.js} +2 -2
  195. package/build/esm/profileNavigation.js +19 -19
  196. package/build/esm/progressBar.js +1 -1
  197. package/build/esm/pwg.js +22 -22
  198. package/build/esm/ssoV2/api/featureFlag.d.ts +2 -1
  199. package/build/esm/ssoV2.js +53 -40
  200. package/build/esm/{store-1c63d8b0.js → store-153a7fff.js} +6 -183
  201. package/build/esm/subot.js +36 -35
  202. package/build/esm/surveyOrPremiumBanner.js +33 -32
  203. package/build/esm/surveyQuestionCard.js +10 -10
  204. package/build/esm/{surveyThankyouCard-a0c5903d.js → surveyThankyouCard-4ecd0d1a.js} +5 -5
  205. package/build/esm/together.js +56 -55
  206. package/build/esm/togetherApiUtils.js +4 -4
  207. package/build/esm/togetherAtoms.js +30 -30
  208. package/build/esm/togetherComponentGlobalContext.js +4 -4
  209. package/build/esm/togetherMolecules.js +51 -50
  210. package/build/esm/togetherMoleculesCardAuthor.js +28 -28
  211. package/build/esm/togetherMoleculesPostImagePreview.js +11 -11
  212. package/build/esm/togetherMoleculesProfileDetail.js +39 -38
  213. package/build/esm/togetherOrganisms.js +50 -49
  214. package/build/esm/togetherRichTextEditor.js +17 -17
  215. package/build/esm/togetherShareBox.js +10 -10
  216. package/build/esm/translationsProvider-29cea8e8.js +55 -0
  217. package/build/esm/{treePopoverMenu-a42b3049.js → treePopoverMenu-c517adc1.js} +19 -19
  218. package/build/esm/{types-580c541f.js → types-920c3a9c.js} +2 -2
  219. package/build/esm/types.js +2 -2
  220. package/build/esm/{useCategory-b739faac.js → useCategory-c161d669.js} +5 -5
  221. package/build/esm/{useHealthToolCache-87091430.js → useHealthToolCache-8512f36c.js} +1 -1
  222. package/build/esm/{useMantineLocale-27cbe6c8.js → useMantineLocale-0c63022c.js} +6 -6
  223. package/build/esm/{usePlacesAutocomplete-b2c58eae.js → usePlacesAutocomplete-3c2245f3.js} +1 -1
  224. package/build/esm/{useScreenSize-9f683ab9.js → useScreenSize-894c30a9.js} +2 -2
  225. package/build/esm/useTogetherAuthRequiredAction.js +10 -9
  226. package/build/esm/{utils-ec0a690b.js → utils-0ecdc2af.js} +3 -3
  227. package/build/esm/{utils-0714a33c.js → utils-4646dd58.js} +2 -2
  228. package/build/esm/{utils-c3c90e9c.js → utils-86e4df70.js} +5 -4
  229. package/build/esm/{utils-c1df8b61.js → utils-a23085d4.js} +2 -2
  230. package/build/esm/vaccination.js +21 -21
  231. package/build/footer.js +21 -21
  232. package/build/gAssets.js +2 -2
  233. package/build/{healthTools-c138e13a.js → healthTools-677836e5.js} +1 -1
  234. package/build/healthToolsCardWrapper.js +18 -18
  235. package/build/healthToolsForm.js +33 -33
  236. package/build/hooks.js +13 -13
  237. package/build/i18n/translationKeys.d.ts +1 -1
  238. package/build/i18n-values/en-PH.js +2 -0
  239. package/build/i18n-values/hi-IN.js +2 -0
  240. package/build/i18n-values/id-ID.js +2 -0
  241. package/build/i18n-values/km-KH.js +2 -0
  242. package/build/i18n-values/ms-MY.js +2 -0
  243. package/build/i18n-values/my-MM.js +2 -0
  244. package/build/i18n-values/th-TH.js +2 -0
  245. package/build/i18n-values/tl-PH.js +2 -0
  246. package/build/i18n-values/vi-VN.js +2 -0
  247. package/build/i18n-values/vi-VN_MB.js +2 -0
  248. package/build/i18n-values/zh-TW.js +2 -0
  249. package/build/i18n.js +16 -57
  250. package/build/i18nV2.js +1 -1
  251. package/build/{index-25bf564e.js → index-044505da.js} +25 -25
  252. package/build/{index-aa5a595c.js → index-080b19fa.js} +8 -8
  253. package/build/{index-3d563929.js → index-0a73d8c3.js} +1 -1
  254. package/build/{index-98b8aa1a.js → index-0c6016f4.js} +3 -3
  255. package/build/{index-008eedb8.js → index-0d993f39.js} +7 -7
  256. package/build/{index-c60ecec1.js → index-0daffd74.js} +16 -16
  257. package/build/{index-f05dc08c.js → index-0ed1baad.js} +2 -2
  258. package/build/{index-5d8490cb.js → index-0f31a476.js} +1 -1
  259. package/build/{index-02e0fc3f.js → index-115c08ce.js} +2 -2
  260. package/build/{index-50426772.js → index-15e429ef.js} +36 -27
  261. package/build/{index-5387bc40.js → index-163a8f85.js} +5 -5
  262. package/build/{index-2965cadb.js → index-17ce08a5.js} +1 -1
  263. package/build/{index-7306bd8c.js → index-1d7b9fe1.js} +18 -18
  264. package/build/{index-aa749e85.js → index-2031ede1.js} +17 -17
  265. package/build/{index-6568d0d4.js → index-2d3bc935.js} +7 -7
  266. package/build/{index-dd83dbad.js → index-30720512.js} +10 -10
  267. package/build/{index-fe1b090f.js → index-36fc8534.js} +15 -15
  268. package/build/{index-1d4f69ed.js → index-3d78afeb.js} +1 -1
  269. package/build/{index-a2637997.js → index-42564e08.js} +13 -13
  270. package/build/{index-4bfd812a.js → index-43db21b1.js} +1 -1
  271. package/build/{index-d1da0386.js → index-45be986f.js} +32 -32
  272. package/build/{index-22387adf.js → index-49897940.js} +6 -6
  273. package/build/{index-a62351d2.js → index-4b7f1a29.js} +22 -22
  274. package/build/{index-0649d573.js → index-4ba8ba72.js} +6 -6
  275. package/build/{index-6937ab6f.js → index-4f113c7f.js} +17 -17
  276. package/build/{index-e98b6385.js → index-507817fb.js} +2 -2
  277. package/build/{index-3c5af87d.js → index-5142ee00.js} +2 -2
  278. package/build/{index-06b6f920.js → index-6186d0e5.js} +5 -5
  279. package/build/index-64b63c16.js +196 -0
  280. package/build/{index-dda0b9d1.js → index-74c7cb7e.js} +3 -3
  281. package/build/{index-e81dd9db.js → index-7a331e2c.js} +13 -13
  282. package/build/{index-e6660745.js → index-7eeee772.js} +2 -2
  283. package/build/{index-ecc24c2c.js → index-83a4853d.js} +3 -3
  284. package/build/{index-1da24aa7.js → index-8456e012.js} +16 -16
  285. package/build/{index-8a3b8367.js → index-87df4abb.js} +2 -2
  286. package/build/{index-e5f20367.js → index-883656f5.js} +2 -2
  287. package/build/{index-2364e8df.js → index-8b294cc4.js} +6 -6
  288. package/build/{index-3f93e79e.js → index-909d1423.js} +18 -18
  289. package/build/{index-92e68ec9.js → index-9210bbc3.js} +13 -13
  290. package/build/{index-11217e12.js → index-95ee82c7.js} +4 -4
  291. package/build/{index-99272d11.js → index-9811eaa3.js} +16 -16
  292. package/build/{index-ad7933f9.js → index-9d954d59.js} +1 -1
  293. package/build/{index-af21979d.js → index-a17cbbc6.js} +17 -17
  294. package/build/{index-c034f39c.js → index-a5f3796f.js} +2 -2
  295. package/build/{index-446beb43.js → index-a7da996c.js} +2 -2
  296. package/build/{index-bd129201.js → index-aa8680e2.js} +1 -1
  297. package/build/{index-e7f07eca.js → index-ad21f04e.js} +31 -31
  298. package/build/{index-d15413c2.js → index-b7f4a93f.js} +24 -24
  299. package/build/{index-0b4028d0.js → index-bb36c4ad.js} +2 -2
  300. package/build/{index-7cc099d8.js → index-bcafdfd1.js} +3 -3
  301. package/build/{index-f90e1c8e.js → index-c19f9fd2.js} +21 -21
  302. package/build/{index-c926a6a3.js → index-c6b9c0e6.js} +6 -6
  303. package/build/{index-a09cd67f.js → index-c6bc3571.js} +1 -1
  304. package/build/{index-1007e179.js → index-cc378fad.js} +2 -2
  305. package/build/{index-59d5c076.js → index-ccfaed40.js} +16 -16
  306. package/build/{index-06f14e03.js → index-d201b05b.js} +32 -32
  307. package/build/{index-ca8ec47e.js → index-d3068066.js} +3 -3
  308. package/build/{index-9b9e59a2.js → index-d44227b8.js} +1 -1
  309. package/build/{index-d4caff5b.js → index-da507bcb.js} +2 -2
  310. package/build/{index-bf1efdbb.js → index-dd53933e.js} +6 -6
  311. package/build/{index-b81a335e.js → index-e7df401d.js} +2 -2
  312. package/build/{index-1de4bd11.js → index-eef58d21.js} +17 -17
  313. package/build/{index-72db33ac.js → index-f3ba8eaa.js} +2 -2
  314. package/build/{index-169f743e.js → index-f48b4b75.js} +13 -13
  315. package/build/{index-201a8d71.js → index-fb2d3004.js} +3 -3
  316. package/build/index.js +118 -117
  317. package/build/interfaces/types/index.d.ts +1 -0
  318. package/build/{labelSorting-b5d28c8b.js → labelSorting-f961ba4e.js} +4 -4
  319. package/build/lead/LeadGen.type.d.ts +34 -0
  320. package/build/lead/LeadGenForm/LeadGenForm.d.ts +41 -0
  321. package/build/lead/LeadGenForm/LeadGenForm.helpers.d.ts +2 -0
  322. package/build/lead/LeadGenForm/LeadGenForm.styled.d.ts +5 -0
  323. package/build/lead/LeadGenForm/LeadGenFormPhone.d.ts +17 -0
  324. package/build/lead/LeadGenForm/LeadGenThankYou.d.ts +20 -0
  325. package/build/lead/LeadGenForm/index.d.ts +3 -0
  326. package/build/lead/LeadGenForm/textField/index.d.ts +13 -0
  327. package/build/lead/LeadGenForm/textField/index.styled.d.ts +11 -0
  328. package/build/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +66 -0
  329. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +4 -0
  330. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +21 -0
  331. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +3 -0
  332. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +24 -0
  333. package/build/lead/LeadGenSubscriptionBox/index.d.ts +1 -0
  334. package/build/lead/LeadGenTranslationContext.d.ts +6 -0
  335. package/build/lead/helpers.d.ts +56 -1
  336. package/build/lead/index.d.ts +2 -1
  337. package/build/lead/services/index.d.ts +21 -0
  338. package/build/lead/store/index.d.ts +1 -0
  339. package/build/lead.js +2466 -1269
  340. package/build/{logoIcon-5c2ba163.js → logoIcon-675ac049.js} +2 -2
  341. package/build/mantine.js +22 -22
  342. package/build/misc.js +17 -17
  343. package/build/miscGetDynamicHealthTool.js +4 -4
  344. package/build/miscGetSocialList.js +8 -8
  345. package/build/miscScreenSizeContext.js +1 -1
  346. package/build/mobileBottomNavigation.js +5 -5
  347. package/build/mobileBottomNavigationIcon.js +5 -5
  348. package/build/molecules.js +74 -73
  349. package/build/moleculesArticleCard.js +6 -6
  350. package/build/moleculesArticleCardV2.js +16 -16
  351. package/build/navigation.js +46 -45
  352. package/build/navigationLogoutPopup.js +9 -9
  353. package/build/navigationProfileButton.js +23 -23
  354. package/build/onboardingV2.js +28 -28
  355. package/build/organisms.js +50 -49
  356. package/build/{post-34bb441f.js → post-fed4a366.js} +2 -2
  357. package/build/profileNavigation.js +19 -19
  358. package/build/progressBar.js +1 -1
  359. package/build/pwg.js +22 -22
  360. package/build/ssoV2/api/featureFlag.d.ts +2 -1
  361. package/build/ssoV2.js +130 -117
  362. package/build/{store-1ddbc453.js → store-fde45a68.js} +8 -196
  363. package/build/subot.js +35 -34
  364. package/build/surveyOrPremiumBanner.js +33 -32
  365. package/build/surveyQuestionCard.js +10 -10
  366. package/build/{surveyThankyouCard-ac96d4b4.js → surveyThankyouCard-de7bf1f9.js} +5 -5
  367. package/build/together.js +56 -55
  368. package/build/togetherApiUtils.js +4 -4
  369. package/build/togetherAtoms.js +30 -30
  370. package/build/togetherComponentGlobalContext.js +4 -4
  371. package/build/togetherMolecules.js +51 -50
  372. package/build/togetherMoleculesCardAuthor.js +28 -28
  373. package/build/togetherMoleculesPostImagePreview.js +11 -11
  374. package/build/togetherMoleculesProfileDetail.js +39 -38
  375. package/build/togetherOrganisms.js +50 -49
  376. package/build/togetherRichTextEditor.js +17 -17
  377. package/build/togetherShareBox.js +10 -10
  378. package/build/translationsProvider-88a463a2.js +62 -0
  379. package/build/{treePopoverMenu-faee82ba.js → treePopoverMenu-fa27a056.js} +19 -19
  380. package/build/{types-6a849d0f.js → types-2bd53431.js} +2 -2
  381. package/build/types.js +2 -2
  382. package/build/{useCategory-457cf1c5.js → useCategory-30af3485.js} +5 -5
  383. package/build/{useHealthToolCache-8246efd1.js → useHealthToolCache-0fc43cf2.js} +1 -1
  384. package/build/{useMantineLocale-70ce0f42.js → useMantineLocale-76876cec.js} +6 -6
  385. package/build/{usePlacesAutocomplete-c1253ff8.js → usePlacesAutocomplete-b1415820.js} +1 -1
  386. package/build/{useScreenSize-0d50d147.js → useScreenSize-2091bf8d.js} +2 -2
  387. package/build/useTogetherAuthRequiredAction.js +10 -9
  388. package/build/{utils-0a02bd15.js → utils-7609c557.js} +2 -2
  389. package/build/{utils-e1a9bf2b.js → utils-e001abee.js} +9 -8
  390. package/build/{utils-47903e31.js → utils-e872c45a.js} +3 -3
  391. package/build/{utils-4c8af11f.js → utils-fa95b796.js} +2 -2
  392. package/build/vaccination.js +21 -21
  393. package/package.json +3 -3
  394. /package/build/{BMI_BOYS.percentile.monthly-df2482bd.js → BMI_BOYS.percentile.monthly-f7ad0b8a.js} +0 -0
  395. /package/build/{BMI_BOYS.percentile.weekly-035eb626.js → BMI_BOYS.percentile.weekly-d1fb0a5e.js} +0 -0
  396. /package/build/{BMI_BOYS.percentile.yearly-5fe8b43f.js → BMI_BOYS.percentile.yearly-e8ab92a3.js} +0 -0
  397. /package/build/{BMI_BOYS.zscore.monthly-324ae79e.js → BMI_BOYS.zscore.monthly-56170e19.js} +0 -0
  398. /package/build/{BMI_BOYS.zscore.weekly-0f5f08fc.js → BMI_BOYS.zscore.weekly-b00ef96f.js} +0 -0
  399. /package/build/{BMI_BOYS.zscore.yearly-83add2b5.js → BMI_BOYS.zscore.yearly-f2efe533.js} +0 -0
  400. /package/build/{BMI_GIRLS.percentile.monthly-19bcd66d.js → BMI_GIRLS.percentile.monthly-6a66c274.js} +0 -0
  401. /package/build/{BMI_GIRLS.percentile.weekly-3f7c8830.js → BMI_GIRLS.percentile.weekly-0fed7eca.js} +0 -0
  402. /package/build/{BMI_GIRLS.percentile.yearly-032b7aa7.js → BMI_GIRLS.percentile.yearly-e886a29f.js} +0 -0
  403. /package/build/{BMI_GIRLS.zscore.monthly-345313ae.js → BMI_GIRLS.zscore.monthly-4518b852.js} +0 -0
  404. /package/build/{BMI_GIRLS.zscore.weekly-4bff215b.js → BMI_GIRLS.zscore.weekly-c0f09e6a.js} +0 -0
  405. /package/build/{BMI_GIRLS.zscore.yearly-b090beec.js → BMI_GIRLS.zscore.yearly-c42c2e8b.js} +0 -0
  406. /package/build/{ChevronDown-41194899.js → ChevronDown-a1dc3a1c.js} +0 -0
  407. /package/build/{Close-2add3da2.js → Close-f1c64ef4.js} +0 -0
  408. /package/build/{Google-39a84f2a.js → Google-f9f12977.js} +0 -0
  409. /package/build/{HEAD CIRCUM_BOYS.percentile.monthly-c2fab73c.js → HEAD CIRCUM_BOYS.percentile.monthly-ff516a3b.js} +0 -0
  410. /package/build/{HEAD CIRCUM_BOYS.percentile.weekly-166966e5.js → HEAD CIRCUM_BOYS.percentile.weekly-43db1f16.js} +0 -0
  411. /package/build/{HEAD CIRCUM_BOYS.percentile.yearly-f779680b.js → HEAD CIRCUM_BOYS.percentile.yearly-40140a1c.js} +0 -0
  412. /package/build/{HEAD CIRCUM_BOYS.zscore.monthly-e2ded6bc.js → HEAD CIRCUM_BOYS.zscore.monthly-2b13995c.js} +0 -0
  413. /package/build/{HEAD CIRCUM_BOYS.zscore.weekly-beb5c911.js → HEAD CIRCUM_BOYS.zscore.weekly-142f877a.js} +0 -0
  414. /package/build/{HEAD CIRCUM_BOYS.zscore.yearly-b85cf0d6.js → HEAD CIRCUM_BOYS.zscore.yearly-1c0a7022.js} +0 -0
  415. /package/build/{HEAD CIRCUM_GIRLS.percentile.monthly-d681a0ee.js → HEAD CIRCUM_GIRLS.percentile.monthly-d6336ad5.js} +0 -0
  416. /package/build/{HEAD CIRCUM_GIRLS.percentile.weekly-9e4cb570.js → HEAD CIRCUM_GIRLS.percentile.weekly-f52e2087.js} +0 -0
  417. /package/build/{HEAD CIRCUM_GIRLS.percentile.yearly-23f33f5d.js → HEAD CIRCUM_GIRLS.percentile.yearly-ebce0ea3.js} +0 -0
  418. /package/build/{HEAD CIRCUM_GIRLS.zscore.monthly-2bae97cf.js → HEAD CIRCUM_GIRLS.zscore.monthly-5daae840.js} +0 -0
  419. /package/build/{HEAD CIRCUM_GIRLS.zscore.weekly-999a9564.js → HEAD CIRCUM_GIRLS.zscore.weekly-66571be7.js} +0 -0
  420. /package/build/{HEAD CIRCUM_GIRLS.zscore.yearly-c5ee4f98.js → HEAD CIRCUM_GIRLS.zscore.yearly-9ae59833.js} +0 -0
  421. /package/build/{HEIGHT_BOYS.percentile.monthly-af1bbd51.js → HEIGHT_BOYS.percentile.monthly-33722ac5.js} +0 -0
  422. /package/build/{HEIGHT_BOYS.percentile.weekly-dc4597cf.js → HEIGHT_BOYS.percentile.weekly-54fdfa51.js} +0 -0
  423. /package/build/{HEIGHT_BOYS.percentile.yearly-226b11ca.js → HEIGHT_BOYS.percentile.yearly-e904410d.js} +0 -0
  424. /package/build/{HEIGHT_BOYS.zscore.monthly-2ce0c9c1.js → HEIGHT_BOYS.zscore.monthly-fcf33ce3.js} +0 -0
  425. /package/build/{HEIGHT_BOYS.zscore.weekly-3cbf2c2a.js → HEIGHT_BOYS.zscore.weekly-08efb65f.js} +0 -0
  426. /package/build/{HEIGHT_BOYS.zscore.yearly-1c8a3c1d.js → HEIGHT_BOYS.zscore.yearly-0071cc3f.js} +0 -0
  427. /package/build/{HEIGHT_GIRLS.percentile.monthly-c8266607.js → HEIGHT_GIRLS.percentile.monthly-97f015fe.js} +0 -0
  428. /package/build/{HEIGHT_GIRLS.percentile.weekly-db44a8d4.js → HEIGHT_GIRLS.percentile.weekly-05d8a054.js} +0 -0
  429. /package/build/{HEIGHT_GIRLS.percentile.yearly-a85b0b4d.js → HEIGHT_GIRLS.percentile.yearly-ed10c9cd.js} +0 -0
  430. /package/build/{HEIGHT_GIRLS.zscore.monthly-7893ef51.js → HEIGHT_GIRLS.zscore.monthly-df472cab.js} +0 -0
  431. /package/build/{HEIGHT_GIRLS.zscore.weekly-b40844c5.js → HEIGHT_GIRLS.zscore.weekly-f46cf4a6.js} +0 -0
  432. /package/build/{HEIGHT_GIRLS.zscore.yearly-9f26867c.js → HEIGHT_GIRLS.zscore.yearly-f04fcbd3.js} +0 -0
  433. /package/build/{Locale-836a0da1.js → Locale-82bdbbbd.js} +0 -0
  434. /package/build/{Visible-51d5d954.js → Visible-b23efffe.js} +0 -0
  435. /package/build/{WEIGHT_BOYS.percentile.monthly-e075c1a3.js → WEIGHT_BOYS.percentile.monthly-a96fd5a9.js} +0 -0
  436. /package/build/{WEIGHT_BOYS.percentile.weekly-b8a78276.js → WEIGHT_BOYS.percentile.weekly-6a2ce3da.js} +0 -0
  437. /package/build/{WEIGHT_BOYS.percentile.yearly-f2d9c7c9.js → WEIGHT_BOYS.percentile.yearly-b6b2cb40.js} +0 -0
  438. /package/build/{WEIGHT_BOYS.zscore.monthly-0c7c819f.js → WEIGHT_BOYS.zscore.monthly-dd195eb4.js} +0 -0
  439. /package/build/{WEIGHT_BOYS.zscore.weekly-b19ddebe.js → WEIGHT_BOYS.zscore.weekly-16dbebe0.js} +0 -0
  440. /package/build/{WEIGHT_BOYS.zscore.yearly-0c6b12a8.js → WEIGHT_BOYS.zscore.yearly-aa9746f3.js} +0 -0
  441. /package/build/{WEIGHT_GIRLS.percentile.monthly-c8002622.js → WEIGHT_GIRLS.percentile.monthly-028576ff.js} +0 -0
  442. /package/build/{WEIGHT_GIRLS.percentile.weekly-bfc763f2.js → WEIGHT_GIRLS.percentile.weekly-91f28b87.js} +0 -0
  443. /package/build/{WEIGHT_GIRLS.percentile.yearly-88606367.js → WEIGHT_GIRLS.percentile.yearly-41f67536.js} +0 -0
  444. /package/build/{WEIGHT_GIRLS.zscore.monthly-8ac01726.js → WEIGHT_GIRLS.zscore.monthly-158817bf.js} +0 -0
  445. /package/build/{WEIGHT_GIRLS.zscore.weekly-bda518a0.js → WEIGHT_GIRLS.zscore.weekly-93b37712.js} +0 -0
  446. /package/build/{WEIGHT_GIRLS.zscore.yearly-c8521c02.js → WEIGHT_GIRLS.zscore.yearly-77610268.js} +0 -0
  447. /package/build/{animation-953a4127.js → animation-49610ed1.js} +0 -0
  448. /package/build/{constants-32022ceb.js → constants-2dd982bc.js} +0 -0
  449. /package/build/{constants-1416f348.js → constants-323d5418.js} +0 -0
  450. /package/build/{constants-49711f56.js → constants-f85af0d2.js} +0 -0
  451. /package/build/{dataTransform-4de10d58.js → dataTransform-4617e3d3.js} +0 -0
  452. /package/build/{doctor-3bc8f39e.js → doctor-6bab9719.js} +0 -0
  453. /package/build/esm/{BMI_BOYS.percentile.monthly-01cdb562.js → BMI_BOYS.percentile.monthly-bf00c0bb.js} +0 -0
  454. /package/build/esm/{BMI_BOYS.percentile.weekly-8893dd3e.js → BMI_BOYS.percentile.weekly-86a125d2.js} +0 -0
  455. /package/build/esm/{BMI_BOYS.percentile.yearly-9d4b69c9.js → BMI_BOYS.percentile.yearly-d7e33fc2.js} +0 -0
  456. /package/build/esm/{BMI_BOYS.zscore.monthly-c6671ee4.js → BMI_BOYS.zscore.monthly-bd9b69a2.js} +0 -0
  457. /package/build/esm/{BMI_BOYS.zscore.weekly-92e1d131.js → BMI_BOYS.zscore.weekly-87724b96.js} +0 -0
  458. /package/build/esm/{BMI_BOYS.zscore.yearly-05bbdd7b.js → BMI_BOYS.zscore.yearly-3726efea.js} +0 -0
  459. /package/build/esm/{BMI_GIRLS.percentile.monthly-ec51639e.js → BMI_GIRLS.percentile.monthly-bdaa3198.js} +0 -0
  460. /package/build/esm/{BMI_GIRLS.percentile.weekly-7c0c8b4a.js → BMI_GIRLS.percentile.weekly-58ecf5bb.js} +0 -0
  461. /package/build/esm/{BMI_GIRLS.percentile.yearly-6cc143f2.js → BMI_GIRLS.percentile.yearly-a8259c11.js} +0 -0
  462. /package/build/esm/{BMI_GIRLS.zscore.monthly-1f018468.js → BMI_GIRLS.zscore.monthly-aa4ebf2c.js} +0 -0
  463. /package/build/esm/{BMI_GIRLS.zscore.weekly-af5a4b2b.js → BMI_GIRLS.zscore.weekly-81953623.js} +0 -0
  464. /package/build/esm/{BMI_GIRLS.zscore.yearly-c7a07f25.js → BMI_GIRLS.zscore.yearly-005c2fcd.js} +0 -0
  465. /package/build/esm/{ChevronDown-42f671e1.js → ChevronDown-d09f7f90.js} +0 -0
  466. /package/build/esm/{Close-5e54b2d5.js → Close-61e8f548.js} +0 -0
  467. /package/build/esm/{Google-6652e3bc.js → Google-74249849.js} +0 -0
  468. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.monthly-7e66fc3a.js → HEAD CIRCUM_BOYS.percentile.monthly-98034ec2.js} +0 -0
  469. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.weekly-64473467.js → HEAD CIRCUM_BOYS.percentile.weekly-aa9c115e.js} +0 -0
  470. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.yearly-08606ae2.js → HEAD CIRCUM_BOYS.percentile.yearly-70b9e404.js} +0 -0
  471. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.monthly-4e140e3f.js → HEAD CIRCUM_BOYS.zscore.monthly-2d83de79.js} +0 -0
  472. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.weekly-4e1b5770.js → HEAD CIRCUM_BOYS.zscore.weekly-cba9b2c3.js} +0 -0
  473. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.yearly-0dec10da.js → HEAD CIRCUM_BOYS.zscore.yearly-77601b1d.js} +0 -0
  474. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.monthly-d18303ca.js → HEAD CIRCUM_GIRLS.percentile.monthly-ffd6f707.js} +0 -0
  475. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.weekly-55770071.js → HEAD CIRCUM_GIRLS.percentile.weekly-7bfbf288.js} +0 -0
  476. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.yearly-25e4a2c9.js → HEAD CIRCUM_GIRLS.percentile.yearly-ef7517f5.js} +0 -0
  477. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.monthly-d33b6246.js → HEAD CIRCUM_GIRLS.zscore.monthly-0d8bdeb9.js} +0 -0
  478. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.weekly-abef6f22.js → HEAD CIRCUM_GIRLS.zscore.weekly-522eab4c.js} +0 -0
  479. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.yearly-444bc2b4.js → HEAD CIRCUM_GIRLS.zscore.yearly-5664e89f.js} +0 -0
  480. /package/build/esm/{HEIGHT_BOYS.percentile.monthly-dc5d6faf.js → HEIGHT_BOYS.percentile.monthly-aa9e9c85.js} +0 -0
  481. /package/build/esm/{HEIGHT_BOYS.percentile.weekly-75b1b9f1.js → HEIGHT_BOYS.percentile.weekly-48ce2664.js} +0 -0
  482. /package/build/esm/{HEIGHT_BOYS.percentile.yearly-bc5c7a34.js → HEIGHT_BOYS.percentile.yearly-b2dafebf.js} +0 -0
  483. /package/build/esm/{HEIGHT_BOYS.zscore.monthly-bbad4abb.js → HEIGHT_BOYS.zscore.monthly-1eaea7b2.js} +0 -0
  484. /package/build/esm/{HEIGHT_BOYS.zscore.weekly-736c87b3.js → HEIGHT_BOYS.zscore.weekly-b5f43a5f.js} +0 -0
  485. /package/build/esm/{HEIGHT_BOYS.zscore.yearly-31f0f935.js → HEIGHT_BOYS.zscore.yearly-d1c77696.js} +0 -0
  486. /package/build/esm/{HEIGHT_GIRLS.percentile.monthly-95c5c1fc.js → HEIGHT_GIRLS.percentile.monthly-c66402d3.js} +0 -0
  487. /package/build/esm/{HEIGHT_GIRLS.percentile.weekly-12d97ac4.js → HEIGHT_GIRLS.percentile.weekly-9f4d2ae3.js} +0 -0
  488. /package/build/esm/{HEIGHT_GIRLS.percentile.yearly-c188d8d7.js → HEIGHT_GIRLS.percentile.yearly-9d7c159e.js} +0 -0
  489. /package/build/esm/{HEIGHT_GIRLS.zscore.monthly-2885a84f.js → HEIGHT_GIRLS.zscore.monthly-faa70b19.js} +0 -0
  490. /package/build/esm/{HEIGHT_GIRLS.zscore.weekly-4623c6b8.js → HEIGHT_GIRLS.zscore.weekly-5b8be1b1.js} +0 -0
  491. /package/build/esm/{HEIGHT_GIRLS.zscore.yearly-0f241320.js → HEIGHT_GIRLS.zscore.yearly-e0992a78.js} +0 -0
  492. /package/build/esm/{Locale-cd9c33a3.js → Locale-08cf14fd.js} +0 -0
  493. /package/build/esm/{Visible-4b6153b5.js → Visible-511ebf4d.js} +0 -0
  494. /package/build/esm/{WEIGHT_BOYS.percentile.monthly-52cbd675.js → WEIGHT_BOYS.percentile.monthly-c6d5a221.js} +0 -0
  495. /package/build/esm/{WEIGHT_BOYS.percentile.weekly-d9aebf61.js → WEIGHT_BOYS.percentile.weekly-a12236d2.js} +0 -0
  496. /package/build/esm/{WEIGHT_BOYS.percentile.yearly-2f93ab0a.js → WEIGHT_BOYS.percentile.yearly-63be7c54.js} +0 -0
  497. /package/build/esm/{WEIGHT_BOYS.zscore.monthly-249fcf8d.js → WEIGHT_BOYS.zscore.monthly-af1daa70.js} +0 -0
  498. /package/build/esm/{WEIGHT_BOYS.zscore.weekly-293fb368.js → WEIGHT_BOYS.zscore.weekly-42012393.js} +0 -0
  499. /package/build/esm/{WEIGHT_BOYS.zscore.yearly-ba2bba37.js → WEIGHT_BOYS.zscore.yearly-7050fa46.js} +0 -0
  500. /package/build/esm/{WEIGHT_GIRLS.percentile.monthly-db69de41.js → WEIGHT_GIRLS.percentile.monthly-e4db88d3.js} +0 -0
  501. /package/build/esm/{WEIGHT_GIRLS.percentile.weekly-fb7303bc.js → WEIGHT_GIRLS.percentile.weekly-778dc41c.js} +0 -0
  502. /package/build/esm/{WEIGHT_GIRLS.percentile.yearly-7604d8f5.js → WEIGHT_GIRLS.percentile.yearly-3d517d80.js} +0 -0
  503. /package/build/esm/{WEIGHT_GIRLS.zscore.monthly-998a69bf.js → WEIGHT_GIRLS.zscore.monthly-dffdadf0.js} +0 -0
  504. /package/build/esm/{WEIGHT_GIRLS.zscore.weekly-468c577f.js → WEIGHT_GIRLS.zscore.weekly-decb78f7.js} +0 -0
  505. /package/build/esm/{WEIGHT_GIRLS.zscore.yearly-0f83301c.js → WEIGHT_GIRLS.zscore.yearly-fe7ab8cd.js} +0 -0
  506. /package/build/esm/{animation-3b7fbeb8.js → animation-023020b4.js} +0 -0
  507. /package/build/esm/{constants-936d56a3.js → constants-244675b6.js} +0 -0
  508. /package/build/esm/{constants-8550ea4b.js → constants-9db2cf7b.js} +0 -0
  509. /package/build/esm/{constants-56418598.js → constants-ee588916.js} +0 -0
  510. /package/build/esm/{dataTransform-1365e4e2.js → dataTransform-a2a7f0d5.js} +0 -0
  511. /package/build/esm/{doctor-933f26b5.js → doctor-0c957965.js} +0 -0
  512. /package/build/esm/{index-66938a55.js → index-00dbe6a4.js} +0 -0
  513. /package/build/esm/{index-578f4600.js → index-04096c0e.js} +0 -0
  514. /package/build/esm/{index-cb171154.js → index-44149ed7.js} +0 -0
  515. /package/build/esm/{index-f44c62ca.js → index-4f87e96c.js} +0 -0
  516. /package/build/esm/{index-243908c8.js → index-5734a17a.js} +0 -0
  517. /package/build/esm/{index-610d69af.js → index-6852e524.js} +0 -0
  518. /package/build/esm/{index-0db4da34.js → index-c3a793f9.js} +0 -0
  519. /package/build/esm/{index-a318c025.js → index-fb8c72b9.js} +0 -0
  520. /package/build/esm/{index.styles-4a412578.js → index.styles-af10d377.js} +0 -0
  521. /package/build/esm/{localizeNumberFormat-79aefc62.js → localizeNumberFormat-1e126a82.js} +0 -0
  522. /package/build/esm/{normalizeLink-69a06b00.js → normalizeLink-ea829312.js} +0 -0
  523. /package/build/esm/{number-7472b20c.js → number-1345706c.js} +0 -0
  524. /package/build/esm/{other-756a8244.js → other-992dbd32.js} +0 -0
  525. /package/build/esm/{paths-f75a5925.js → paths-e9913c38.js} +0 -0
  526. /package/build/esm/{translationsContext-1df74fcc.js → translationsContext-1929a314.js} +0 -0
  527. /package/build/esm/{tslib.es6-6b8750ce.js → tslib.es6-b58336fd.js} +0 -0
  528. /package/build/esm/{types-160c2989.js → types-d42ef078.js} +0 -0
  529. /package/build/esm/{useIsInit-9df1e8e2.js → useIsInit-66e79024.js} +0 -0
  530. /package/build/esm/{useOutsideClick-1023869e.js → useOutsideClick-620c59db.js} +0 -0
  531. /package/build/esm/{useScrollbarSize-0adaf38c.js → useScrollbarSize-b9ed161e.js} +0 -0
  532. /package/build/esm/{useUniqueId-0d0b484a.js → useUniqueId-e0c6727a.js} +0 -0
  533. /package/build/esm/{utils-ee78bcad.js → utils-c4dc2bfe.js} +0 -0
  534. /package/build/{index-6602fed3.js → index-013dd762.js} +0 -0
  535. /package/build/{index-e80a72b8.js → index-3f959041.js} +0 -0
  536. /package/build/{index-51127a60.js → index-4dd6f7ee.js} +0 -0
  537. /package/build/{index-f73f06bf.js → index-9e9d5c22.js} +0 -0
  538. /package/build/{index-7155ed17.js → index-ad884ea4.js} +0 -0
  539. /package/build/{index-39692ed5.js → index-bc52473b.js} +0 -0
  540. /package/build/{index-6b6c86d5.js → index-c007890c.js} +0 -0
  541. /package/build/{index-215c8c86.js → index-dd879d27.js} +0 -0
  542. /package/build/{index.styles-01d7e5fb.js → index.styles-cbc41136.js} +0 -0
  543. /package/build/{localizeNumberFormat-18110dda.js → localizeNumberFormat-13af5fd8.js} +0 -0
  544. /package/build/{normalizeLink-b8d7fe5a.js → normalizeLink-ac169899.js} +0 -0
  545. /package/build/{number-94987413.js → number-fa5563f7.js} +0 -0
  546. /package/build/{other-23c85ba5.js → other-b80616ea.js} +0 -0
  547. /package/build/{paths-2de4f842.js → paths-91a1738f.js} +0 -0
  548. /package/build/{translationsContext-55646101.js → translationsContext-adc177bc.js} +0 -0
  549. /package/build/{tslib.es6-a4e6f6fe.js → tslib.es6-01e64ef5.js} +0 -0
  550. /package/build/{types-a7667594.js → types-926bcf4b.js} +0 -0
  551. /package/build/{useIsInit-407bd907.js → useIsInit-c9c1b280.js} +0 -0
  552. /package/build/{useOutsideClick-205a8b3e.js → useOutsideClick-017737e0.js} +0 -0
  553. /package/build/{useScrollbarSize-ff4a550a.js → useScrollbarSize-c534409e.js} +0 -0
  554. /package/build/{useUniqueId-188a010a.js → useUniqueId-ff8f4531.js} +0 -0
  555. /package/build/{utils-eb50a5d6.js → utils-8540b9b5.js} +0 -0
package/build/lead.js CHANGED
@@ -2,55 +2,76 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('./tslib.es6-a4e6f6fe.js');
5
+ var tslib_es6 = require('./tslib.es6-01e64ef5.js');
6
6
  var React = require('react');
7
7
  var core = require('@mantine/core');
8
8
  var dayjs = require('dayjs');
9
9
  var debounce = require('lodash/debounce');
10
10
  var form = require('@mantine/form');
11
- var index = require('./index-3d563929.js');
12
- var translationsContext = require('./translationsContext-55646101.js');
11
+ var index = require('./index-64b63c16.js');
13
12
  var miscCookieHelper = require('./miscCookieHelper.js');
14
- var utils$1 = require('./utils-eb50a5d6.js');
15
- var index$1 = require('./index-c034f39c.js');
16
- var index$2 = require('./index-50426772.js');
17
- var index$4 = require('./index-2364e8df.js');
18
- var index$3 = require('./index-9b9e59a2.js');
19
- require('./index.styles-01d7e5fb.js');
13
+ var index$1 = require('./index-0a73d8c3.js');
14
+ var translationsContext = require('./translationsContext-adc177bc.js');
15
+ var utils$1 = require('./utils-8540b9b5.js');
16
+ var index$2 = require('./index-a5f3796f.js');
17
+ var index$3 = require('./index-15e429ef.js');
18
+ var index$5 = require('./index-8b294cc4.js');
19
+ var index$4 = require('./index-d44227b8.js');
20
+ require('./index.styles-cbc41136.js');
20
21
  var hooks = require('@mantine/hooks');
21
- require('./useMantineLocale-70ce0f42.js');
22
- var index$8 = require('./index-1d4f69ed.js');
23
- require('./index-f73f06bf.js');
24
- var index$7 = require('./index-72db33ac.js');
25
- require('./other-23c85ba5.js');
26
- require('./index-7cc099d8.js');
27
- var utils = require('./utils-0a02bd15.js');
28
- require('@mantine/dates');
29
- var usePlacesAutocomplete = require('./usePlacesAutocomplete-c1253ff8.js');
30
- var index$5 = require('./index-1007e179.js');
22
+ require('./useMantineLocale-76876cec.js');
23
+ var index$9 = require('./index-3d78afeb.js');
24
+ require('./index-9e9d5c22.js');
25
+ var index$7 = require('./index-f3ba8eaa.js');
26
+ require('./other-b80616ea.js');
27
+ require('./index-bcafdfd1.js');
28
+ var utils = require('./utils-7609c557.js');
29
+ var dates = require('@mantine/dates');
30
+ var usePlacesAutocomplete = require('./usePlacesAutocomplete-b1415820.js');
31
+ var index$6 = require('./index-cc378fad.js');
32
+ var translationsProvider = require('./translationsProvider-88a463a2.js');
33
+ var Locale = require('./Locale-82bdbbbd.js');
31
34
  var uuid = require('uuid');
32
- var index$6 = require('./index-6602fed3.js');
33
- var index$a = require('./index-e6660745.js');
34
- var useScreenSize = require('./useScreenSize-0d50d147.js');
35
- var ReactDOM = require('react-dom');
36
- var react = require('@emotion/react');
35
+ var PhoneInputBase = require('react-phone-number-input');
37
36
  var styled = require('@emotion/styled');
38
37
  var miscTheme = require('./miscTheme.js');
39
- var index$9 = require('./index-b81a335e.js');
40
- var InputDate = require('./InputDate-9746e093.js');
41
- var Close = require('./Close-2add3da2.js');
38
+ var react = require('@emotion/react');
39
+ var togetherComponentGlobalContext = require('./utils-e872c45a.js');
40
+ var index$8 = require('./index-013dd762.js');
41
+ var index$b = require('./index-7eeee772.js');
42
+ var useScreenSize = require('./useScreenSize-2091bf8d.js');
43
+ var ReactDOM = require('react-dom');
44
+ var index$a = require('./index-e7df401d.js');
45
+ var InputDate = require('./InputDate-abe5f7d3.js');
46
+ var Close = require('./Close-f1c64ef4.js');
47
+ require('./constantsIsProduction.js');
48
+ require('./normalizeLink-ac169899.js');
49
+ require('./constantsDomainLocales.js');
42
50
  require('@hhgtech/icons/other');
43
51
  require('@mantine/carousel');
44
- require('./Locale-836a0da1.js');
45
52
  require('classnames');
46
- require('./useUniqueId-188a010a.js');
53
+ require('./useUniqueId-ff8f4531.js');
47
54
  require('./constantsSite.js');
48
55
  require('@hhgtech/icons/core');
49
56
  require('@mantine/notifications');
50
- require('./constantsDomainLocales.js');
51
- require('./constantsIsProduction.js');
52
57
  require('date-fns/locale');
53
58
  require('./constantsRiskScreener.js');
59
+ require('./i18n-values/en-PH.js');
60
+ require('./i18n-values/hi-IN.js');
61
+ require('./i18n-values/id-ID.js');
62
+ require('./i18n-values/km-KH.js');
63
+ require('./i18n-values/ms-MY.js');
64
+ require('./i18n-values/my-MM.js');
65
+ require('./i18n-values/th-TH.js');
66
+ require('./i18n-values/tl-PH.js');
67
+ require('./i18n-values/vi-VN.js');
68
+ require('./i18n-values/vi-VN_MB.js');
69
+ require('./i18n-values/zh-TW.js');
70
+ require('./index-c007890c.js');
71
+ require('slugify');
72
+ require('string-format');
73
+ require('./togetherApiPaths.js');
74
+ require('./constants-f85af0d2.js');
54
75
  require('vaul');
55
76
 
56
77
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -102,7 +123,7 @@ if (sessionStorage.getItem('insider_object')) {
102
123
  }
103
124
  const docLang = document.documentElement.lang;
104
125
  // TODO: country code
105
- const LEAD_LOCALE_DATA = {
126
+ const LEAD_LOCALE_DATA$1 = {
106
127
  'vi-VN': {
107
128
  popupLang: 'vi',
108
129
  countryCode: 'vn',
@@ -144,7 +165,7 @@ const LEAD_LOCALE_DATA = {
144
165
  countryCodeNumber: 91,
145
166
  },
146
167
  };
147
- const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
168
+ const LEAD_LOCALE = LEAD_LOCALE_DATA$1[docLang] || LEAD_LOCALE_DATA$1['vi-VN'];
148
169
  function LEAD_RESET_VAR() {
149
170
  // LEAD_CURRENT_URL = location.href.toLowerCase();
150
171
  LEAD_CURRENT_URL =
@@ -165,6 +186,11 @@ const LEAD_TIMEZONE_DATA = {
165
186
  9: 'Asia/Manila', // Philippines / Filipinos Site
166
187
  };
167
188
 
189
+ const LEADGEN_ACTIONS = {
190
+ SHOW: 'SHOW',
191
+ SCROLL: 'SCROLL',
192
+ TIME: 'TIME',
193
+ };
168
194
  const LEADGEN_LAYOUT = {
169
195
  LightBoxA: 'LightBoxA',
170
196
  LightBoxB: 'LightBoxB',
@@ -194,8 +220,10 @@ const LEADGEN_BLOCK = {
194
220
  DropdownBlock: 'DropdownBlock',
195
221
  CheckboxBlock: 'CheckboxBlock',
196
222
  TncBlock: 'TncBlock',
223
+ TitleBlock: 'TitleBlock',
224
+ SubtitleBlock: 'SubtitleBlock',
197
225
  };
198
- const LEADGEN_BLOCK_IN_FORM = [
226
+ const LEADGEN_BLOCK_INPUT = [
199
227
  LEADGEN_BLOCK.TextBlock,
200
228
  LEADGEN_BLOCK.NumberBlock,
201
229
  LEADGEN_BLOCK.DateBlock,
@@ -210,7 +238,59 @@ const LEADGEN_BLOCK_IN_FORM = [
210
238
  LEADGEN_BLOCK.CheckboxBlock,
211
239
  LEADGEN_BLOCK.TncBlock,
212
240
  ];
241
+ const leadGenFieldNamePhone = (listBlockAdded) => {
242
+ return listBlockAdded
243
+ .filter(({ name }) => [
244
+ LEADGEN_BLOCK.PhoneBlock,
245
+ LEADGEN_BLOCK.PhoneOtpBlock,
246
+ LEADGEN_BLOCK.WhatsappOtpBlock,
247
+ LEADGEN_BLOCK.ZaloOtpBlock,
248
+ ].includes(name))
249
+ .map(({ data }) => data.value);
250
+ };
213
251
  const SSO_MAP_LEAD = ['name', 'email', 'birthday', 'phone', 'gender'];
252
+ const LEAD_LOCALE_DATA = {
253
+ 'vi-VN': {
254
+ popupLang: 'vi',
255
+ countryCode: 'vn',
256
+ countryCodeNumber: 84,
257
+ },
258
+ 'id-ID': {
259
+ popupLang: 'id',
260
+ countryCode: 'id',
261
+ countryCodeNumber: 62,
262
+ },
263
+ 'th-TH': {
264
+ popupLang: 'th',
265
+ countryCode: 'th',
266
+ countryCodeNumber: 66,
267
+ },
268
+ 'ms-MY': {
269
+ popupLang: 'ms',
270
+ countryCode: 'my',
271
+ countryCodeNumber: 60,
272
+ },
273
+ 'zh-TW': {
274
+ popupLang: 'zh',
275
+ countryCode: 'tw',
276
+ countryCodeNumber: 886,
277
+ },
278
+ 'km-KH': {
279
+ popupLang: 'km',
280
+ countryCode: 'kh',
281
+ countryCodeNumber: 855,
282
+ },
283
+ 'my-MM': {
284
+ popupLang: 'my',
285
+ countryCode: 'mm',
286
+ countryCodeNumber: 95,
287
+ },
288
+ 'hi-IN': {
289
+ popupLang: 'hi',
290
+ countryCode: 'in',
291
+ countryCodeNumber: 91,
292
+ },
293
+ };
214
294
  const mappingSSOToLead = (userInfoProps) => {
215
295
  var _a, _b;
216
296
  try {
@@ -226,7 +306,7 @@ const mappingSSOToLead = (userInfoProps) => {
226
306
  if (ssoKey === 'birthday') {
227
307
  const dob = dayjs__default["default"](initValue, 'YYYY-MM-DD', true);
228
308
  if (dob.isValid()) {
229
- user.birthday = dob;
309
+ user.birthday = dob.toDate();
230
310
  }
231
311
  }
232
312
  else if (ssoKey === 'gender') {
@@ -249,16 +329,83 @@ const mappingSSOToLead = (userInfoProps) => {
249
329
  catch (error) {
250
330
  return;
251
331
  }
332
+ };
333
+ const formatCampaignDetail = (campaign) => {
334
+ if (!campaign) {
335
+ return {};
336
+ }
337
+ try {
338
+ const { extra_fields, thank_you_image } = campaign || {};
339
+ const { textBlocks: exTextBlocks, imageBlocks: exImageBlocks, listBlockAdded: exListBlockAdded, listBlockThankyou: exListBlockThankyou, actionBlocks: exActionBlocks, } = extra_fields;
340
+ const textBlocks = JSON.parse(exTextBlocks);
341
+ const imageBlocks = JSON.parse(exImageBlocks);
342
+ const listBlockAdded = JSON.parse(exListBlockAdded);
343
+ const listBlockThankyou = JSON.parse(exListBlockThankyou);
344
+ const actionBlocks = JSON.parse(exActionBlocks);
345
+ const ThankYouBlock = {
346
+ image: { src: thank_you_image },
347
+ };
348
+ listBlockThankyou.forEach((block) => {
349
+ const { name, data } = block || {};
350
+ const { value: htmlText, align, newtab, url } = data || {};
351
+ switch (name) {
352
+ case LEADGEN_BLOCK.TitleBlock: {
353
+ ThankYouBlock.title = { htmlText, align };
354
+ }
355
+ case LEADGEN_BLOCK.SubtitleBlock: {
356
+ ThankYouBlock.description = { htmlText, align };
357
+ }
358
+ case LEADGEN_BLOCK.LinkButtonBlock: {
359
+ ThankYouBlock.button = { htmlText, newtab, url };
360
+ }
361
+ }
362
+ });
363
+ return Object.assign(Object.assign({}, campaign), { extra_fields: Object.assign(Object.assign({}, extra_fields), { textBlocks,
364
+ imageBlocks,
365
+ listBlockAdded,
366
+ listBlockThankyou,
367
+ actionBlocks }), ThankYouBlock });
368
+ }
369
+ catch (error) {
370
+ return {};
371
+ }
252
372
  };
253
373
 
254
374
  class Store {
255
375
  constructor() {
376
+ this.apiSsoUrl = 'https://staging-id.hellobacsi.com/';
256
377
  this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
257
378
  this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
258
379
  }
259
380
  }
260
381
  const leadStore = new Store();
261
382
 
383
+ const METHOD = {
384
+ GET: 'get',
385
+ POST: 'POST',
386
+ };
387
+ const LEADGEN_API_PATH = {
388
+ V2_CAMPAIGN: 'api/v2/campaign',
389
+ V2_SUBSCRIPTION_LEAD: 'api/v2/subscription-box',
390
+ V2_SUBSCRIPTION_INFO: 'api/campaign/get-title',
391
+ };
392
+ const SSO_API_PATH = {
393
+ USER_UPDATE: 'api/user/update',
394
+ };
395
+ const ssoApi = {
396
+ call(_a) {
397
+ var { url, data } = _a, config = tslib_es6.__rest(_a, ["url", "data"]);
398
+ const token = miscCookieHelper.getCookie(index.BEARER_TOKEN_COOKIE);
399
+ config.body = JSON.stringify(data);
400
+ config.headers = {
401
+ 'Content-Type': 'application/json',
402
+ Authorization: `Bearer ${token}`,
403
+ };
404
+ return fetch(`${leadStore.apiSsoUrl}${url}`, config)
405
+ .then((res) => res.json())
406
+ .catch(() => ({}));
407
+ },
408
+ };
262
409
  const leadApi = {
263
410
  call(_a) {
264
411
  var { url, data = undefined } = _a, config = tslib_es6.__rest(_a, ["url", "data"]);
@@ -362,8 +509,54 @@ const verifyOtpLead = ({ phone, otp, type, }) => {
362
509
  },
363
510
  });
364
511
  };
512
+ const getCampaignByCode = (campaign_code) => {
513
+ return leadApi.call({
514
+ url: `${LEADGEN_API_PATH.V2_CAMPAIGN}/${campaign_code}`,
515
+ method: METHOD.GET,
516
+ });
517
+ };
518
+ const getSubscriptionBoxInfo = ({ category, site, }) => {
519
+ return leadApi.call({
520
+ url: `${LEADGEN_API_PATH.V2_SUBSCRIPTION_INFO}?category=${category}&site=${site}`,
521
+ method: METHOD.GET,
522
+ });
523
+ };
524
+ const postSubscriptionBoxLead = ({ data }) => {
525
+ return leadApi.call({
526
+ url: LEADGEN_API_PATH.V2_SUBSCRIPTION_LEAD,
527
+ method: METHOD.POST,
528
+ data,
529
+ });
530
+ };
531
+ const postUserInfoFromLeadGen = ({ name }) => {
532
+ return ssoApi.call({
533
+ url: SSO_API_PATH.USER_UPDATE,
534
+ method: METHOD.POST,
535
+ data: { name },
536
+ });
537
+ };
538
+ const campaignPostImpression = ({ code, action, title_article, ga_client_id, cookie_id, extra, url, referrer, }) => {
539
+ return leadApi.call({
540
+ url: `api/campaign/${code}/impression`,
541
+ method: METHOD.POST,
542
+ data: {
543
+ action,
544
+ title_article,
545
+ cookie_id,
546
+ ga_client_id,
547
+ url,
548
+ extra,
549
+ referrer,
550
+ },
551
+ });
552
+ };
365
553
  const Service = {
366
554
  campaignGetById,
555
+ getCampaignByCode,
556
+ getSubscriptionBoxInfo,
557
+ postSubscriptionBoxLead,
558
+ postUserInfoFromLeadGen,
559
+ campaignPostImpression,
367
560
  validateEmailOrPhoneOnSubot,
368
561
  validateEmailOrPhoneOnLeadGen,
369
562
  validatePhoneNumberOnLeadGen,
@@ -470,7 +663,7 @@ const clearCacheUsedEmailOrPhone = () => {
470
663
  // You can give context variables any name
471
664
  const [LeadFormProvider$1, useLeadFormContext$1, useLeadForm$1] = form.createFormContext();
472
665
  const useLeadFormConfig$1 = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, }) => {
473
- const { t } = index.useTranslations();
666
+ const { t } = index$1.useTranslations();
474
667
  const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
475
668
  React.useEffect(() => {
476
669
  if (!window.intlTelInputUtils) {
@@ -700,10 +893,10 @@ const Component = ({ campaign, onClose: onCloseProp, onOtherSubmit, onSubmit, sh
700
893
  const Description = (_a) => {
701
894
  var rest = tslib_es6.__rest(_a, []);
702
895
  const { description } = React.useContext(LeadGenComponentContext);
703
- return description ? (React__default["default"].createElement(index$1.Text, Object.assign({ size: "p3" }, rest), description)) : null;
896
+ return description ? (React__default["default"].createElement(index$2.Text, Object.assign({ size: "p3" }, rest), description)) : null;
704
897
  };
705
898
 
706
- const LeadGenContext = React.createContext({});
899
+ const LeadGenContext$1 = React.createContext({});
707
900
 
708
901
  var useStyles$2 = core.createStyles(() => {
709
902
  return {
@@ -756,7 +949,7 @@ const LocationBlock = ({ name, placeholder, locale, required = true, }) => {
756
949
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
757
950
  LoadScript && (React__default["default"].createElement(LoadScript, { googleMapsApiKey: usePlacesAutocomplete.GOOGLE_API_KEY, libraries: libraries$1, loadingElement: React__default["default"].createElement(React__default["default"].Fragment, null) })),
758
951
  React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": name, "data-control": 'text' }),
759
- React__default["default"].createElement(index$2.Select, Object.assign({ className: "lead-modal__form-control", label: placeholder, placeholder: placeholder, withAsterisk: required, name: name, data: options, searchValue: searchValue, onSearchChange: (query) => {
952
+ React__default["default"].createElement(index$3.Select, Object.assign({ className: "lead-modal__form-control", label: placeholder, placeholder: placeholder, withAsterisk: required, name: name, data: options, searchValue: searchValue, onSearchChange: (query) => {
760
953
  setSearchValue(query);
761
954
  }, filter: () => true, clearable: true, searchable: true, onChange: (val) => setAddress(val || ''), icon: React__default["default"].createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" },
762
955
  React__default["default"].createElement("path", { d: "M10 9.792q.605 0 1.032-.427.426-.428.426-1.032 0-.603-.426-1.031A1.4 1.4 0 0 0 10 6.875q-.604 0-1.032.427a1.4 1.4 0 0 0-.426 1.031q0 .604.426 1.032.428.426 1.032.427m0 8.083q-.145 0-.292-.042a.7.7 0 0 1-.27-.145Q6.478 15 5.01 12.708 3.54 10.418 3.54 8.5q0-3.021 1.949-4.823T10 1.875t4.51 1.802q1.95 1.802 1.949 4.823 0 1.917-1.468 4.208-1.47 2.292-4.427 4.98a.7.7 0 0 1-.271.145 1 1 0 0 1-.292.042", fill: "#8C8C8C" })), autoComplete: 'no-auto-complete-' + randRef.current, rightSection: React__default["default"].createElement(React__default["default"].Fragment, null) }, form.getInputProps(name)))));
@@ -767,7 +960,7 @@ const SubtitleBlock$1 = ({ children, align, }) => (React__default["default"].cre
767
960
  const TitleBlock$1 = ({ children, align, }) => (React__default["default"].createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
768
961
 
769
962
  const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, popoverProps, }) => {
770
- const { primaryColor } = React.useContext(LeadGenContext);
963
+ const { primaryColor } = React.useContext(LeadGenContext$1);
771
964
  const { classes, cx } = useStyles$2(undefined, {
772
965
  name: 'LeadGen__Field',
773
966
  styles,
@@ -785,15 +978,15 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
785
978
  case 'SubtitleBlock':
786
979
  return (React__default["default"].createElement(SubtitleBlock$1, { key: index, align: align }, value));
787
980
  case 'TextBlock':
788
- return (React__default["default"].createElement(index$2.Input, Object.assign({ key: index, withAsterisk: required, spellCheck: false, type: "text", placeholder: placeholder, className: cx('leadgen-control', classes.control),
981
+ return (React__default["default"].createElement(index$3.Input, Object.assign({ key: index, withAsterisk: required, spellCheck: false, type: "text", placeholder: placeholder, className: cx('leadgen-control', classes.control),
789
982
  // onChangeRaw={(e) => inputOnChange('text', e)}
790
983
  label: placeholder, "data-control": "text", name: value }, form.getInputProps(value))));
791
984
  case 'NumberBlock':
792
- return (React__default["default"].createElement(index$2.NumberInput, Object.assign({ key: index, withAsterisk: required, spellCheck: false, type: "number", placeholder: placeholder, className: cx('leadgen-control', classes.control),
985
+ return (React__default["default"].createElement(index$3.NumberInput, Object.assign({ key: index, withAsterisk: required, spellCheck: false, type: "number", placeholder: placeholder, className: cx('leadgen-control', classes.control),
793
986
  // onChange={(e) => inputOnChange('number', e)}
794
987
  label: placeholder, "data-control": "number", name: value }, form.getInputProps(value))));
795
988
  case 'EmailBlock':
796
- return (React__default["default"].createElement(index$2.Input, Object.assign({ key: index, withAsterisk: required, spellCheck: false,
989
+ return (React__default["default"].createElement(index$3.Input, Object.assign({ key: index, withAsterisk: required, spellCheck: false,
797
990
  // type="email"
798
991
  placeholder: placeholder, className: cx('leadgen-control', classes.control), label: placeholder, "data-control": "email", name: value }, form.getInputProps(value))));
799
992
  case 'PhoneOtpBlock':
@@ -801,12 +994,12 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
801
994
  case 'ZaloOtpBlock':
802
995
  case 'PhoneBlock': {
803
996
  const id = popupId + '-' + value + '-' + index;
804
- return (React__default["default"].createElement(index$2.Input.Wrapper, Object.assign({ size: "md", withAsterisk: required, key: index, label: placeholder,
997
+ return (React__default["default"].createElement(index$3.Input.Wrapper, Object.assign({ size: "md", withAsterisk: required, key: index, label: placeholder,
805
998
  // error={errorField.phone}
806
999
  className: cx('leadgen-control', classes.control), labelProps: {
807
1000
  htmlFor: id,
808
1001
  } }, form.getInputProps(value)),
809
- React__default["default"].createElement(index$2.Phone, { name: value, spellCheck: false, type: "tel", placeholder: placeholder, value: form.getInputProps(value).value, onChange: (v) => {
1002
+ React__default["default"].createElement(index$3.Phone, { name: value, spellCheck: false, type: "tel", placeholder: placeholder, value: form.getInputProps(value).value, onChange: (v) => {
810
1003
  form.setFieldValue(value, v);
811
1004
  },
812
1005
  // onBlur={(e) => inputOnBlur('tel', e)}
@@ -817,12 +1010,12 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
817
1010
  }
818
1011
  case 'DateBlock':
819
1012
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
820
- React__default["default"].createElement(index$4.DatePicker, Object.assign({ withAsterisk: required, key: index, type: "default", name: value, placeholder: placeholder, className: cx('leadgen-control', classes.control), label: placeholder, "data-control": "date", popoverProps: popoverProps }, form.getInputProps(value))),
1013
+ React__default["default"].createElement(index$5.DatePicker, Object.assign({ withAsterisk: required, key: index, type: "default", name: value, placeholder: placeholder, className: cx('leadgen-control', classes.control), label: placeholder, "data-control": "date", popoverProps: popoverProps }, form.getInputProps(value))),
821
1014
  React__default["default"].createElement("input", { type: "hidden", name: value, "data-control": "date" })));
822
1015
  case 'LinkButtonBlock':
823
1016
  return (React__default["default"].createElement("div", { key: index },
824
1017
  React__default["default"].createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
825
- React__default["default"].createElement(index$3.Button, { type: "button", size: "md", color: primaryColor, className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
1018
+ React__default["default"].createElement(index$4.Button, { type: "button", size: "md", color: primaryColor, className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
826
1019
  onClose === null || onClose === void 0 ? void 0 : onClose();
827
1020
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
828
1021
  } }, value))));
@@ -831,26 +1024,26 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
831
1024
  isSendMailChimp && (React__default["default"].createElement("div", { style: {
832
1025
  display: 'none',
833
1026
  }, "data-name": value + '-mailchimp' })),
834
- React__default["default"].createElement(index$2.Checkbox.Group, Object.assign({ withAsterisk: required, className: cx('leadgen-control', classes.control), key: index, label: placeholder, size: "md", sx: {
1027
+ React__default["default"].createElement(index$3.Checkbox.Group, Object.assign({ withAsterisk: required, className: cx('leadgen-control', classes.control), key: index, label: placeholder, size: "md", sx: {
835
1028
  display: 'flex',
836
1029
  flexDirection: 'column',
837
1030
  gap: 8,
838
- } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$2.Checkbox, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
1031
+ } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$3.Checkbox, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
839
1032
  case 'RadioBlock':
840
1033
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
841
- isSendMailChimp && (React__default["default"].createElement(index$2.Input, { type: "hidden", name: value + '-mailchimp', value: isSendMailChimp })),
842
- React__default["default"].createElement(index$2.Radio.Group, Object.assign({ withAsterisk: required, className: cx('leadgen-control', classes.control), key: index, label: placeholder, size: "md" }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$2.Radio, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
1034
+ isSendMailChimp && (React__default["default"].createElement(index$3.Input, { type: "hidden", name: value + '-mailchimp', value: isSendMailChimp })),
1035
+ React__default["default"].createElement(index$3.Radio.Group, Object.assign({ withAsterisk: required, className: cx('leadgen-control', classes.control), key: index, label: placeholder, size: "md" }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$3.Radio, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
843
1036
  case 'DropdownBlock':
844
1037
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
845
1038
  React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
846
- React__default["default"].createElement(index$2.Select, Object.assign({ key: index, className: cx('leadgen-control', classes.control), label: placeholder, withAsterisk: required, name: value, data: listQuestion.map((l) => ({
1039
+ React__default["default"].createElement(index$3.Select, Object.assign({ key: index, className: cx('leadgen-control', classes.control), label: placeholder, withAsterisk: required, name: value, data: listQuestion.map((l) => ({
847
1040
  value: l.value,
848
1041
  label: l.placeholder,
849
1042
  })) }, form.getInputProps(value)))));
850
1043
  case 'TncBlock':
851
1044
  const tncInputProps = form.getInputProps('TNC-' + b.id);
852
1045
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
853
- React__default["default"].createElement(index$2.Checkbox, Object.assign({ name: 'TNC-' + b.id, key: b.id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps, { error: tncInputProps.error ? tncInputProps.error : undefined }))));
1046
+ React__default["default"].createElement(index$3.Checkbox, Object.assign({ name: 'TNC-' + b.id, key: b.id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps, { error: tncInputProps.error ? tncInputProps.error : undefined }))));
854
1047
  }
855
1048
  return null;
856
1049
  })));
@@ -877,12 +1070,12 @@ var useStyles$1 = core.createStyles((theme) => {
877
1070
  const Heading = (_a) => {
878
1071
  var rest = tslib_es6.__rest(_a, []);
879
1072
  const { heading } = React.useContext(LeadGenComponentContext);
880
- return heading ? (React__default["default"].createElement(index$1.Text, Object.assign({ size: "h3" }, rest), heading)) : null;
1073
+ return heading ? (React__default["default"].createElement(index$2.Text, Object.assign({ size: "h3" }, rest), heading)) : null;
881
1074
  };
882
1075
 
883
1076
  const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps, submitProps, }) => {
884
1077
  var _a;
885
- const { primaryColor } = React.useContext(LeadGenContext);
1078
+ const { primaryColor } = React.useContext(LeadGenContext$1);
886
1079
  const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, setFormRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = React.useContext(LeadGenComponentContext);
887
1080
  const { classes, cx } = useStyles$1(undefined, {
888
1081
  name: 'LeadGen__FormComponent',
@@ -971,7 +1164,7 @@ const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps,
971
1164
  control: classes.control,
972
1165
  }, listBlockAdded: listBlockAdded, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit, popoverProps: popoverProps })),
973
1166
  ((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) ? null : (React__default["default"].createElement("div", { className: classes.submitBtnWrapper },
974
- React__default["default"].createElement(index$3.Button, Object.assign({ size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, loading: isSubmitLoading, color: primaryColor }, submitProps), popUpSubmitText))))));
1167
+ React__default["default"].createElement(index$4.Button, Object.assign({ size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, loading: isSubmitLoading, color: primaryColor }, submitProps), popUpSubmitText))))));
975
1168
  };
976
1169
  const Form = (props) => {
977
1170
  const { showOtpPhone, showThankyou } = React.useContext(LeadGenComponentContext);
@@ -992,7 +1185,7 @@ var useStyles = core.createStyles(() => {
992
1185
  });
993
1186
 
994
1187
  const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, styles, classNames, }) => {
995
- const { t } = index.useTranslations();
1188
+ const { t } = index$1.useTranslations();
996
1189
  const phone = otpData.phone;
997
1190
  const otpType = otpData.type;
998
1191
  const [otp, setOtp] = React.useState('');
@@ -1102,9 +1295,9 @@ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, st
1102
1295
  submitOtp();
1103
1296
  }, className: cx(classes.root, className) },
1104
1297
  React__default["default"].createElement("div", { className: classes.header },
1105
- React__default["default"].createElement(index$5.Heading, { tag: "h3", className: classes.heading }, t('lead.otp.title')),
1106
- React__default["default"].createElement(index$1.Text, { size: "p3", className: classes.description }, t('lead.otp.desc', { phone: displayPhone }))),
1107
- React__default["default"].createElement(index$2.Input, { ref: inputRef, name: '_' + name + '-otp', spellCheck: false, type: "number", placeholder: t('lead.otp.phonePlaceholder'), className: classes.control, label: t('lead.otp.phoneLabel'), "data-control": "otp", withAsterisk: true, pattern: "[0-9]*", value: otp, maxLength: 6, onChange: (v) => {
1298
+ React__default["default"].createElement(index$6.Heading, { tag: "h3", className: classes.heading }, t('lead.otp.title')),
1299
+ React__default["default"].createElement(index$2.Text, { size: "p3", className: classes.description }, t('lead.otp.desc', { phone: displayPhone }))),
1300
+ React__default["default"].createElement(index$3.Input, { ref: inputRef, name: '_' + name + '-otp', spellCheck: false, type: "number", placeholder: t('lead.otp.phonePlaceholder'), className: classes.control, label: t('lead.otp.phoneLabel'), "data-control": "otp", withAsterisk: true, pattern: "[0-9]*", value: otp, maxLength: 6, onChange: (v) => {
1108
1301
  setIsDirty(true);
1109
1302
  setOtp(v);
1110
1303
  if (isDirty && !v)
@@ -1113,10 +1306,10 @@ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, st
1113
1306
  setErrorMsg(undefined);
1114
1307
  }, error: isDirty ? errorMsg : undefined }),
1115
1308
  React__default["default"].createElement("div", { className: classes.actions },
1116
- React__default["default"].createElement(index$3.Button, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1309
+ React__default["default"].createElement(index$4.Button, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1117
1310
  // onClick={() => submitOtp()}
1118
1311
  disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
1119
- React__default["default"].createElement(index$3.Button, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1312
+ React__default["default"].createElement(index$4.Button, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1120
1313
  sendOtp();
1121
1314
  }, disabled: !!resendTimer }, t('lead.otp.resend', {
1122
1315
  timer: resendTimer ? ` (${resendTimer}s)` : '',
@@ -1397,148 +1590,1709 @@ const translationsMap = {
1397
1590
  'tl-PH': enPH,
1398
1591
  };
1399
1592
  const getTranslations = (locale) => {
1400
- const translations = translationsMap[locale];
1593
+ const translations = Object.assign(Object.assign({}, translationsProvider.translationsMap[locale]), translationsMap[locale]);
1401
1594
  if (translations) {
1402
1595
  return translations;
1403
1596
  }
1404
1597
  return translationsMap['en-PH'];
1405
1598
  };
1406
1599
 
1407
- const useImageSize = (src) => {
1408
- const [width, setWidth] = React.useState(16);
1409
- const [height, setHeight] = React.useState(9);
1410
- const [loaded, setLoaded] = React.useState(false);
1411
- // load src image to get its width and height
1412
- React.useEffect(() => {
1413
- setLoaded(false);
1414
- if (src) {
1415
- const img = new Image();
1416
- img.addEventListener('load', () => {
1417
- setWidth(img.naturalWidth);
1418
- setHeight(img.naturalHeight);
1419
- setLoaded(true);
1420
- });
1421
- img.addEventListener('error', () => {
1422
- setWidth(16);
1423
- setHeight(9);
1424
- setLoaded(true);
1425
- });
1426
- img.src = src;
1427
- }
1428
- else {
1429
- setWidth(16);
1430
- setHeight(9);
1431
- setLoaded(true);
1432
- }
1433
- }, [src]);
1434
- return {
1435
- loaded,
1436
- width,
1437
- height,
1438
- };
1439
- };
1440
-
1441
- const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default["default"].createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
1442
- React__default["default"].createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
1443
- React__default["default"].createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
1444
-
1445
- // url: imageBlocks.imageMobile.data.url
1446
- // newTab: imageBlocks.imageMobile.data.newtab
1447
- // imageMobile: campaignShow.image
1448
- // imageDestkop: campaignShow.image_desktop
1449
- const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
1450
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1451
- const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
1452
- if (!imageMobileLoaded || !imageDestkopLoaded)
1453
- return null;
1454
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
1455
- React__default["default"].createElement("div", { className: "le-center-tab-popup" },
1456
- React__default["default"].createElement("div", { style: { position: 'relative' } },
1457
- React__default["default"].createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
1458
- index$6.isVideo(imageMobile) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
1459
- React__default["default"].createElement("source", { src: imageMobile }))) : (React__default["default"].createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
1460
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1461
- } })),
1462
- index$6.isVideo(imageDestkop) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
1463
- React__default["default"].createElement("source", { src: imageDestkop }))) : (React__default["default"].createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
1464
- aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
1465
- } }))),
1466
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
1467
- };
1468
-
1469
- // title: titleText
1470
- // titleAlign: textBlocks.titleBlock.data.align
1471
- // subtitle: textBlocks.subtitleBlock.data.value
1472
- // subtitleAlign: textBlocks.subtitleBlock.data.align
1473
- // url: actionBlocks.linkButtonBlock.data.url
1474
- // urlText: actionBlocks.linkButtonBlock.data.value
1475
- // newTab: actionBlocks.linkButtonBlock.data.newtab
1476
- // imageMobile: campaignShow.image
1477
- // imageDesktop: campaignShow.image_desktop
1478
- const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
1479
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1480
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
1481
- if (!imageMobileLoaded || !imageDesktopLoaded)
1482
- return null;
1483
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
1484
- React__default["default"].createElement("aside", { className: "le-only-desktop" },
1485
- React__default["default"].createElement("div", { className: "le-floating-desktop" },
1486
- React__default["default"].createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
1487
- imageDesktop ? (React__default["default"].createElement("div", null,
1488
- React__default["default"].createElement("img", { style: {
1489
- maxWidth: 120,
1490
- borderTopLeftRadius: 5,
1491
- borderBottomLeftRadius: 5,
1492
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
1493
- }, src: imageDesktop }))) : null,
1494
- React__default["default"].createElement("div", { style: { padding: 20 } },
1495
- React__default["default"].createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
1496
- React__default["default"].createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
1497
- React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
1498
- React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
1499
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
1500
- React__default["default"].createElement("aside", { className: "le-only-mobile" },
1501
- React__default["default"].createElement("div", { className: "le-floating-mobile" },
1502
- React__default["default"].createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
1503
- React__default["default"].createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
1504
- React__default["default"].createElement("div", null,
1505
- React__default["default"].createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
1506
- React__default["default"].createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
1507
- imageMobile ? (React__default["default"].createElement("div", null,
1508
- React__default["default"].createElement("img", { style: {
1509
- marginLeft: 15,
1510
- marginTop: 4,
1511
- maxWidth: 100,
1512
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1513
- }, src: imageMobile }))) : null),
1514
- React__default["default"].createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
1515
- React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
1516
- React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
1517
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
1600
+ const LeadGenTranslationProvider = (props) => {
1601
+ const { locale, children } = props;
1602
+ const translationContextValue = React.useMemo(() => ({ locale, values: getTranslations(locale) }), [locale]);
1603
+ return (React__default["default"].createElement(translationsContext.TranslationsContext.Provider, { value: translationContextValue }, children));
1518
1604
  };
1519
1605
 
1520
- const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
1521
- const { primaryColor } = React.useContext(LeadGenContext);
1522
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
1523
- if (!imageLoaded)
1606
+ // import mockLeadData from './mockLeadData'
1607
+ const listCampaignScheduled = [];
1608
+ const listCampaignScheduledToActivated = [];
1609
+ const listCampaignActiveButExpired = [];
1610
+ const listCampaignExcludeSonsored = [];
1611
+ const listCampaignDifferentSponsor = [];
1612
+ const listCampaignNotDisplayInRangeOfTime = [];
1613
+ function isMobile() {
1614
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
1615
+ }
1616
+ const getShuffleArray = (array) => {
1617
+ const newArray = [...array];
1618
+ for (let i = newArray.length - 1; i > 0; i--) {
1619
+ const j = Math.floor(Math.random() * (i + 1));
1620
+ const temp = newArray[i];
1621
+ newArray[i] = newArray[j];
1622
+ newArray[j] = temp;
1623
+ }
1624
+ return newArray;
1625
+ };
1626
+ const getTimeByTimezone = (timeZone = 'UTC') => {
1627
+ const date = new Date();
1628
+ return new Date(date.toLocaleString('en-US', { timeZone }));
1629
+ };
1630
+ const parseDateByCampaignTime = (dateStr) => {
1631
+ // Format like this: 2023-04-04 00:00:00
1632
+ try {
1633
+ const [datePart, timePart] = dateStr.split(' ');
1634
+ const [year, month, day] = datePart.split('-').map(Number);
1635
+ const [hours, minutes, seconds] = timePart.split(':').map(Number);
1636
+ /** JavaScript counts months from 0 to 11 */
1637
+ return new Date(year, month - 1, day, hours, minutes, seconds);
1638
+ }
1639
+ catch (err) {
1524
1640
  return null;
1525
- return (React__default["default"].createElement("div", { className: "lead-modal__thank-you leadgen-inner_thankyou" },
1526
- React__default["default"].createElement("div", { style: { width: '100%' } },
1527
- React__default["default"].createElement("img", { src: image, style: {
1528
- maxHeight: 162,
1529
- objectFit: 'cover',
1530
- aspectRatio: `${imageWidth}/${imageHeight}`,
1531
- }, loading: "lazy" }),
1532
- title && (React__default["default"].createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
1533
- subtitle && (React__default["default"].createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle.split('\n').map((text, idx, list) => {
1534
- const isShowBr = idx < list.length - 1;
1535
- return (React__default["default"].createElement(React__default["default"].Fragment, null,
1536
- text,
1537
- isShowBr && React__default["default"].createElement("br", null)));
1538
- }))),
1539
- linkText && (React__default["default"].createElement("div", null,
1540
- React__default["default"].createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
1541
- React__default["default"].createElement(index$3.Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
1641
+ }
1642
+ };
1643
+ const checkCampaignNowInTimeframe = (c) => {
1644
+ var _a;
1645
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1646
+ const startedAtStr = c.started_at;
1647
+ const endedAtStr = c.ended_at;
1648
+ const startedDate = parseDateByCampaignTime(startedAtStr);
1649
+ const endedDate = parseDateByCampaignTime(endedAtStr);
1650
+ if (!startedDate || !endedDate) {
1651
+ return false;
1652
+ }
1653
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
1654
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1655
+ if (nowWithTimezoneMs <= endedDate.getTime() &&
1656
+ nowWithTimezoneMs >= startedDate.getTime()) {
1657
+ listCampaignScheduledToActivated.push(c);
1658
+ return true;
1659
+ }
1660
+ return false;
1661
+ };
1662
+ function checkCampaignActiveButExpireAlready(c) {
1663
+ var _a;
1664
+ /** Do not setup timeframe for this campaign. No need to check */
1665
+ if (c.forever === 1) {
1666
+ return true;
1667
+ }
1668
+ const startedAtStr = c.started_at;
1669
+ const endedAtStr = c.ended_at;
1670
+ const startedDate = parseDateByCampaignTime(startedAtStr);
1671
+ const endedDate = parseDateByCampaignTime(endedAtStr);
1672
+ /** Do not setup timeframe for this campaign. No need to check */
1673
+ if (!startedDate || !endedDate) {
1674
+ return true;
1675
+ }
1676
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1677
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
1678
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1679
+ /** Check if this expire already, do not show */
1680
+ if (nowWithTimezoneMs > endedDate.getTime()) {
1681
+ listCampaignActiveButExpired.push(c);
1682
+ return false;
1683
+ }
1684
+ return true;
1685
+ }
1686
+ function shouldNotDisplayIfExcludeAllSponsors(c) {
1687
+ var _a;
1688
+ const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
1689
+ const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
1690
+ if (isSponsored && excludeSponsored) {
1691
+ listCampaignExcludeSonsored.push(c);
1692
+ return true;
1693
+ }
1694
+ return false;
1695
+ }
1696
+ function shouldDisplayWithCurrentSponsor(c) {
1697
+ var _a, _b;
1698
+ try {
1699
+ // TODO: BE will rename `exclude_sponsored_list` later
1700
+ const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
1701
+ const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
1702
+ const dataSponsoredId = Number((_b = document
1703
+ .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
1704
+ // There is no config for sponsor id and white list, should show as default
1705
+ if (!dataSponsoredId ||
1706
+ dataSponsoredId <= 0 ||
1707
+ whiteListSponsors.length === 0) {
1708
+ return true;
1709
+ }
1710
+ // Check the dataSponsoredId exists in the white list or not.
1711
+ const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
1712
+ if (isExist) {
1713
+ return true;
1714
+ }
1715
+ listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
1716
+ return false;
1717
+ }
1718
+ catch (err) {
1719
+ // Default is show
1720
+ return true;
1721
+ }
1722
+ }
1723
+ const filterFnCampaign = (c) => {
1724
+ if (shouldNotDisplayIfExcludeAllSponsors(c)) {
1725
+ return false;
1726
+ }
1727
+ else if (!shouldDisplayWithCurrentSponsor(c)) {
1728
+ return false;
1729
+ }
1730
+ /** Active */
1731
+ if (c.formatted_status === 1) {
1732
+ return checkCampaignActiveButExpireAlready(c);
1733
+ }
1734
+ /** Schedule */
1735
+ if (c.formatted_status === 0) {
1736
+ listCampaignScheduled.push(c);
1737
+ return checkCampaignNowInTimeframe(c);
1738
+ }
1739
+ return false;
1740
+ };
1741
+ const fillterApprearanceTimeCampaign = (c) => {
1742
+ var _a;
1743
+ try {
1744
+ const isTimeInRange = (currentTime, startTime, endTime) => {
1745
+ const startParts = startTime.split(':');
1746
+ const endParts = endTime.split(':');
1747
+ const startDate = new Date();
1748
+ startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
1749
+ const endDate = new Date();
1750
+ endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
1751
+ return currentTime >= startDate && currentTime <= endDate;
1752
+ };
1753
+ const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
1754
+ const startTime = rulesApprValue.startTime;
1755
+ const endTime = rulesApprValue.endTime || '23:59';
1756
+ if (!startTime) {
1757
+ return true;
1758
+ }
1759
+ if (isTimeInRange(new Date(), startTime, endTime)) {
1760
+ return true;
1761
+ }
1762
+ listCampaignNotDisplayInRangeOfTime.push(c);
1763
+ return false;
1764
+ }
1765
+ catch (err) {
1766
+ return true;
1767
+ }
1768
+ };
1769
+ let timeoutRef = null;
1770
+ let LEAD_SCROLL_EVENT = null;
1771
+ function clearPassiveEvent() {
1772
+ if (timeoutRef) {
1773
+ clearTimeout(timeoutRef);
1774
+ timeoutRef = null;
1775
+ }
1776
+ if (LEAD_SCROLL_EVENT) {
1777
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1778
+ LEAD_SCROLL_EVENT = null;
1779
+ }
1780
+ }
1781
+ function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
1782
+ // clear previous passive event, check for new condition
1783
+ clearPassiveEvent();
1784
+ const leadCurrentUrl = DEBUG_URL ||
1785
+ ('https://' +
1786
+ location.hostname +
1787
+ location.pathname +
1788
+ location.search).toLowerCase();
1789
+ fetch(leadApi + 'api/campaign/' + leadSiteId, {
1790
+ method: 'POST',
1791
+ headers: {
1792
+ 'Content-Type': 'application/json',
1793
+ },
1794
+ body: JSON.stringify({
1795
+ url: leadCurrentUrl,
1796
+ ga_client_id: miscCookieHelper.getCookie('_ga') || null,
1797
+ }),
1798
+ })
1799
+ .then((response) => {
1800
+ return response.json();
1801
+ // return mockLeadData || response.json()
1802
+ })
1803
+ .then((data) => {
1804
+ var _a, _b, _c, _d;
1805
+ LeadLog('List campagin: ', data);
1806
+ LEAD_RESET_VAR();
1807
+ if (data._status == 1) {
1808
+ const campaigns = (((_b = (_a = data._data) === null || _a === void 0 ? void 0 : _a.campaigns) === null || _b === void 0 ? void 0 : _b.filter(filterFnCampaign)) || []).filter(fillterApprearanceTimeCampaign);
1809
+ if (!miscCookieHelper.getCookie('hhg-id')) {
1810
+ miscCookieHelper.setCookie('hhg-id', uuid.v1(), {
1811
+ domain: '.' + leadDomain,
1812
+ path: '/',
1813
+ });
1814
+ LeadLog('😍 Set HHG ID cookie');
1815
+ }
1816
+ // getCookie('hhg-id')
1817
+ // TODO: HP-534 Filter desktop
1818
+ let campaignsDevice = [];
1819
+ if (isMobile()) {
1820
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
1821
+ }
1822
+ else {
1823
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
1824
+ }
1825
+ LeadLog(`👓 campaignsDevice`, campaignsDevice);
1826
+ LeadLog('--listCampaignScheduled', listCampaignScheduled);
1827
+ LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
1828
+ LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
1829
+ LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
1830
+ LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
1831
+ LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
1832
+ // Check links
1833
+ let listLinksObj = campaignsDevice
1834
+ .map((i, index) => i.targets
1835
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
1836
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1837
+ .flat(1);
1838
+ // Check list link match current href
1839
+ listLinksObj = listLinksObj.filter((i) => {
1840
+ var _a;
1841
+ const target = new URL(String(i.target).toLowerCase());
1842
+ if (i.option == 'exact_match')
1843
+ // FOR TEST LOCAL:
1844
+ // return Boolean(location.pathname === target.pathname)
1845
+ return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
1846
+ if (i.option == 'start_with') {
1847
+ // FOR TEST LOCAL:
1848
+ // if (location.pathname.includes(target.pathname)) {
1849
+ if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
1850
+ const listExcluding = i.sub_target
1851
+ .filter((i) => i.option == 'excluding')
1852
+ .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
1853
+ return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
1854
+ }
1855
+ else {
1856
+ return false;
1857
+ }
1858
+ }
1859
+ });
1860
+ // Check tags
1861
+ const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
1862
+ const listTags = listMetaTag.map((i) => i.content);
1863
+ let listCampaignHasTag = [];
1864
+ let listTagsObj = [];
1865
+ if (listTags && listTags.length) {
1866
+ listCampaignHasTag = campaignsDevice
1867
+ .map((i, index) => i.targets
1868
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
1869
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1870
+ .flat(1);
1871
+ listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
1872
+ }
1873
+ const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
1874
+ const cookieKeys = document.cookie
1875
+ .split('; ')
1876
+ .map((i) => i.split('=')[0]);
1877
+ const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
1878
+ LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
1879
+ const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
1880
+ LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
1881
+ const listCampaignSubmitedClosed = [
1882
+ ...listCampaignCodeSubmited,
1883
+ ...listCampaignCodeClosed,
1884
+ ];
1885
+ const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
1886
+ const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
1887
+ return !hasSubmited;
1888
+ });
1889
+ const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
1890
+ // .sort(
1891
+ // (a, b) =>
1892
+ // (listCampaignValid[a.campaignIndex]?.score || 0) -
1893
+ // (listCampaignValid[b.campaignIndex]?.score || 0),
1894
+ // )
1895
+ LeadLog('--listCampaignValid : ', listCampaignValid);
1896
+ if (listCampaignValid && listCampaignValid.length) {
1897
+ const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
1898
+ LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
1899
+ const { rules } = CAMPAIGN_SHOW;
1900
+ // CHECK RULE TRIGGER POPUP
1901
+ const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
1902
+ LeadLog(`timeoutRule`, timeoutRule);
1903
+ const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
1904
+ LeadLog(`scrollRule`, scrollRule);
1905
+ let impressionAction = 'TIME';
1906
+ if (Number.isInteger(timeoutRule)) {
1907
+ impressionAction = 'TIME';
1908
+ LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
1909
+ timeoutRef = setTimeout(() => {
1910
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1911
+ }, timeoutRule * 1000);
1912
+ }
1913
+ if (Number.isInteger(scrollRule)) {
1914
+ impressionAction = 'SCROLL';
1915
+ LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
1916
+ const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
1917
+ document.querySelector('body');
1918
+ const pct = $p.getBoundingClientRect().top;
1919
+ const pb = $p.offsetHeight;
1920
+ LeadLog(`👓 Element check scroll: `, $p);
1921
+ LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
1922
+ const wt = window.pageYOffset || document.documentElement.scrollTop;
1923
+ let percent = 0;
1924
+ if (wt >= pct) {
1925
+ percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
1926
+ }
1927
+ LeadLog('---Scroll', percent, scrollRule);
1928
+ // TODO: CHECK FOOTER HEIGHT
1929
+ if (percent >= scrollRule) {
1930
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1931
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1932
+ }
1933
+ };
1934
+ window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
1935
+ passive: true,
1936
+ });
1937
+ }
1938
+ }
1939
+ else {
1940
+ LeadLog('🚧 No lead campaigns on current URL, tags');
1941
+ }
1942
+ }
1943
+ })
1944
+ .catch((err) => {
1945
+ LeadLog(`Lead error: `, err);
1946
+ });
1947
+ }
1948
+ const LeadLog = (...params) => {
1949
+ if (process.env.NODE_ENV !== 'production' ||
1950
+ (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
1951
+ process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
1952
+ (typeof localStorage !== 'undefined' &&
1953
+ localStorage.getItem('hhg_debug') === 'true')) {
1954
+ console.log(...params);
1955
+ }
1956
+ };
1957
+
1958
+ const LeadGenContext = React.createContext({
1959
+ submit(value) {
1960
+ /** Init for FAKING function */
1961
+ LeadLog('** LeadGen Submit : ', value);
1962
+ return Promise.reject(value);
1963
+ },
1964
+ submitSubscriptionBox(value) {
1965
+ /** Init for FAKING function */
1966
+ LeadLog('** LeadGen SubmitSubscriptionBox : ', value);
1967
+ return Promise.reject(value);
1968
+ },
1969
+ impression(value) {
1970
+ /** Init for FAKING function */
1971
+ LeadLog('** LeadGen Impression : ', value);
1972
+ return Promise.reject(value);
1973
+ },
1974
+ /** For Subscription Box */
1975
+ subscriptionIcon: '',
1976
+ subscriptionTitle: '',
1977
+ });
1978
+ const LeadGenContextProvider = (props) => {
1979
+ const { campaign_code: campaignCodeProps, apiSsoUrl, apiLeadUrl, apiSubotUrl, locale: localeProps, forceCampaign: forceCampaignProps, extraValues, articleId = 1, categoryId = 1, siteDomain: site_domain, children, } = props;
1980
+ const [forceCampaign, setForceCampaign] = React.useState(forceCampaignProps);
1981
+ const [subscriptionInfo, setSubscriptionInfo] = React.useState({
1982
+ subscriptionIcon: '',
1983
+ subscriptionTitle: '',
1984
+ });
1985
+ const locale = React.useMemo(() => {
1986
+ return localeProps || Locale.LOCALE['PhilippinesEnglish'];
1987
+ }, [localeProps]);
1988
+ const leadGenContextValue = React.useMemo(() => (Object.assign(Object.assign({}, props), { forceCampaign })), [...Object.values(props), forceCampaign]);
1989
+ const { url, campaign_id, campaign_code, cookie_id, ga_client_id, category_id, article_id, article_title, } = React.useMemo(() => ({
1990
+ url: location.href.toLowerCase() || '',
1991
+ cookie_id: miscCookieHelper.getCookie('hhg-id') || null,
1992
+ ga_client_id: miscCookieHelper.getCookie('_ga'),
1993
+ campaign_id: forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id,
1994
+ campaign_code: campaignCodeProps || (forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.code),
1995
+ category_id: categoryId,
1996
+ article_id: articleId,
1997
+ article_title: document.title || '',
1998
+ }), [campaignCodeProps, articleId, categoryId, forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id]);
1999
+ const fetchCampaign = React.useCallback((campaign_code) => {
2000
+ Service.getCampaignByCode(campaign_code).then((res) => {
2001
+ const { _data } = res || {};
2002
+ const { campaigns } = _data || {};
2003
+ LeadLog('** LeadGen Campaign : ', campaigns);
2004
+ setForceCampaign(formatCampaignDetail(campaigns));
2005
+ });
2006
+ }, [campaignCodeProps]);
2007
+ // TODO : Update form for LeadGen
2008
+ const submit = React.useCallback((data) => {
2009
+ return Service.postSubscriptionBoxLead({ data });
2010
+ }, []);
2011
+ const submitSubscriptionBox = React.useCallback((value) => {
2012
+ const data = Object.assign(Object.assign(Object.assign(Object.assign({}, value), { campaign_id,
2013
+ site_domain, url: (value === null || value === void 0 ? void 0 : value.url) || url, ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id }), extraValues), { article_id,
2014
+ category_id, article_title: (extraValues === null || extraValues === void 0 ? void 0 : extraValues.article_title) || article_title });
2015
+ return Service.postSubscriptionBoxLead({ data });
2016
+ }, [
2017
+ extraValues,
2018
+ site_domain,
2019
+ campaign_id,
2020
+ article_id,
2021
+ article_title,
2022
+ category_id,
2023
+ url,
2024
+ ga_client_id,
2025
+ ]);
2026
+ const impression = React.useCallback((value) => {
2027
+ return Service.campaignPostImpression({
2028
+ url: (value === null || value === void 0 ? void 0 : value.url) || url,
2029
+ action: (value === null || value === void 0 ? void 0 : value.action) || LEADGEN_ACTIONS.SCROLL,
2030
+ code: (value === null || value === void 0 ? void 0 : value.code) || campaign_code,
2031
+ title_article: (value === null || value === void 0 ? void 0 : value.title_article) || article_title,
2032
+ cookie_id: (value === null || value === void 0 ? void 0 : value.cookie_id) || cookie_id,
2033
+ ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id,
2034
+ extra: (value === null || value === void 0 ? void 0 : value.extra) || Object.assign({ cookie_id,
2035
+ article_id, subscription_title: subscriptionInfo.subscriptionTitle }, extraValues),
2036
+ referrer: value === null || value === void 0 ? void 0 : value.referrer,
2037
+ });
2038
+ }, [
2039
+ extraValues,
2040
+ campaign_id,
2041
+ url,
2042
+ campaign_code,
2043
+ article_title,
2044
+ cookie_id,
2045
+ ga_client_id,
2046
+ article_id,
2047
+ subscriptionInfo.subscriptionTitle,
2048
+ ]);
2049
+ React.useEffect(() => {
2050
+ if (forceCampaignProps) {
2051
+ setForceCampaign(forceCampaignProps);
2052
+ return;
2053
+ }
2054
+ /** For Subscription Box */
2055
+ if (categoryId) {
2056
+ Service.getSubscriptionBoxInfo({
2057
+ category: categoryId,
2058
+ site: site_domain,
2059
+ }).then((res) => {
2060
+ const { _data } = res || {};
2061
+ const { item, campaign_code } = _data || {};
2062
+ const { icon, content } = item || {};
2063
+ LeadLog('** LeadGen SubscriptionBox campaign_code : ', campaign_code);
2064
+ LeadLog('** LeadGen SubscriptionBox subscription_icon : ', icon);
2065
+ LeadLog('** LeadGen SubscriptionBox subscription_title : ', content);
2066
+ setSubscriptionInfo({
2067
+ subscriptionIcon: icon,
2068
+ subscriptionTitle: content,
2069
+ });
2070
+ if (campaign_code) {
2071
+ fetchCampaign(campaign_code);
2072
+ }
2073
+ });
2074
+ return;
2075
+ }
2076
+ if (campaignCodeProps) {
2077
+ fetchCampaign(campaignCodeProps);
2078
+ }
2079
+ }, [campaignCodeProps, categoryId]);
2080
+ React.useEffect(() => {
2081
+ leadStore.apiSsoUrl = apiSsoUrl;
2082
+ leadStore.apiLeadUrl = apiLeadUrl;
2083
+ leadStore.apiSubotUrl = apiSubotUrl;
2084
+ }, [apiLeadUrl, apiSubotUrl, apiSsoUrl]);
2085
+ if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
2086
+ return null;
2087
+ }
2088
+ return (React__default["default"].createElement(LeadGenContext.Provider, { value: Object.assign(Object.assign(Object.assign({}, leadGenContextValue), subscriptionInfo), { submit,
2089
+ submitSubscriptionBox,
2090
+ impression }) },
2091
+ React__default["default"].createElement(LeadGenTranslationProvider, { locale: locale }, children)));
2092
+ };
2093
+ const useLeadGenContext = () => {
2094
+ const context = React.useContext(LeadGenContext);
2095
+ return Object.assign(Object.assign({}, context), { apiLeadUrl: context.apiLeadUrl || leadStore.apiLeadUrl, apiSubotUrl: context.apiSubotUrl || leadStore.apiSubotUrl });
2096
+ };
2097
+
2098
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
2099
+ const customParseFormat = require('dayjs/plugin/customParseFormat');
2100
+ dayjs__default["default"].extend(customParseFormat);
2101
+ /** https://hhgdev.atlassian.net/browse/EL-565 */
2102
+ const LEADGEN_MAP_VALIDATE = {
2103
+ name: 'leadgen.message.error.name_required',
2104
+ };
2105
+ // You can give context variables any name
2106
+ const [LeadFormProvider, useLeadFormContext, useLeadForm] = form.createFormContext();
2107
+ const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
2108
+ var _a;
2109
+ const { t } = index$1.useTranslations();
2110
+ const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
2111
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[(_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.lang] ||
2112
+ LEAD_LOCALE_DATA['vi-VN'];
2113
+ const validateObj = React.useMemo(() => {
2114
+ const InputBlocks = [
2115
+ 'TextBlock',
2116
+ 'NumberBlock',
2117
+ 'EmailBlock',
2118
+ 'PhoneBlock',
2119
+ 'DateBlock',
2120
+ 'CheckboxBlock',
2121
+ 'RadioBlock',
2122
+ 'DropdownBlock',
2123
+ 'PhoneOtpBlock',
2124
+ 'WhatsappOtpBlock',
2125
+ 'ZaloOtpBlock',
2126
+ 'LocationBlock',
2127
+ 'TncBlock',
2128
+ ];
2129
+ // ALL are required and can skip if not touched yet
2130
+ const withSharedCheck = (name, cb,
2131
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2132
+ block) => {
2133
+ return (value) => {
2134
+ var _a;
2135
+ const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
2136
+ const { data } = block || {};
2137
+ const { value: fieldName } = data;
2138
+ if (!formRef.current.isTouched(name))
2139
+ return;
2140
+ if ((typeof value === 'string' && value.trim() === '') ||
2141
+ typeof value === 'undefined' ||
2142
+ (Array.isArray(value) && value.length === 0)) {
2143
+ return isBLockRequired
2144
+ ? t((LEADGEN_MAP_VALIDATE === null || LEADGEN_MAP_VALIDATE === void 0 ? void 0 : LEADGEN_MAP_VALIDATE[fieldName]) ||
2145
+ 'validator.required')
2146
+ : cb === null || cb === void 0 ? void 0 : cb(value);
2147
+ }
2148
+ return cb === null || cb === void 0 ? void 0 : cb(value);
2149
+ };
2150
+ };
2151
+ return listBlockAdded
2152
+ .filter((b) => InputBlocks.includes(b.name))
2153
+ .reduce((r, b) => {
2154
+ const { name: fieldType, data } = b || {};
2155
+ const { value: fieldName, required } = data || {};
2156
+ const isRequired = required !== null && required !== void 0 ? required : true;
2157
+ if (fieldType === 'NumberBlock') {
2158
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2159
+ if (value && isNaN(Number(value))) {
2160
+ return t('validator.number');
2161
+ }
2162
+ }, b) });
2163
+ }
2164
+ else if (fieldType === 'EmailBlock') {
2165
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2166
+ if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
2167
+ return t('validator.email');
2168
+ }
2169
+ if (!value)
2170
+ return;
2171
+ validatingEmailRef.current = true;
2172
+ setTimeout(() => {
2173
+ formRef.current.setFieldError(fieldName, 'Validating...');
2174
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2175
+ email: value,
2176
+ })
2177
+ .then((tKey) => {
2178
+ if (tKey) {
2179
+ formRef.current.setFieldError(fieldName, t(tKey));
2180
+ }
2181
+ else {
2182
+ formRef.current.clearFieldError(fieldName);
2183
+ }
2184
+ validatingEmailRef.current = false;
2185
+ })
2186
+ .catch((e) => {
2187
+ console.error(e);
2188
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2189
+ validatingEmailRef.current = false;
2190
+ });
2191
+ }, 200);
2192
+ }, b) });
2193
+ }
2194
+ else if (fieldType === 'PhoneBlock' ||
2195
+ fieldType === 'PhoneOtpBlock' ||
2196
+ fieldType === 'ZaloOtpBlock' ||
2197
+ fieldType === 'WhatsappOtpBlock') {
2198
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2199
+ if (value &&
2200
+ window.intlTelInputUtils &&
2201
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
2202
+ return t('leadgen.message.error.phone_invalid');
2203
+ }
2204
+ if (!value)
2205
+ return;
2206
+ validatingPhoneRef.current = true;
2207
+ setTimeout(() => {
2208
+ formRef.current.setFieldError(fieldName, 'Validating...');
2209
+ if (b.data.singleSubmission) {
2210
+ checkUsedPhoneOnlyWithCache(campaignId, value)
2211
+ .then((tKey) => {
2212
+ if (tKey) {
2213
+ formRef.current.setFieldError(fieldName, t(tKey));
2214
+ }
2215
+ else {
2216
+ formRef.current.clearFieldError(fieldName);
2217
+ }
2218
+ validatingPhoneRef.current = false;
2219
+ })
2220
+ .catch((err) => {
2221
+ console.error(err);
2222
+ formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
2223
+ validatingPhoneRef.current = false;
2224
+ });
2225
+ }
2226
+ else {
2227
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2228
+ phone: value,
2229
+ })
2230
+ .then((tKey) => {
2231
+ if (tKey) {
2232
+ formRef.current.setFieldError(fieldName, t(tKey));
2233
+ }
2234
+ else {
2235
+ formRef.current.clearFieldError(fieldName);
2236
+ }
2237
+ validatingPhoneRef.current = false;
2238
+ })
2239
+ .catch((e) => {
2240
+ console.error(e);
2241
+ formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2242
+ validatingPhoneRef.current = false;
2243
+ });
2244
+ }
2245
+ }, 200);
2246
+ }, b) });
2247
+ }
2248
+ else if (fieldType === 'DateBlock') {
2249
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2250
+ if (!isRequired && !value) {
2251
+ return;
2252
+ }
2253
+ const errMsg = t('validator.dateInvalid');
2254
+ const dayInJS = typeof value === 'string'
2255
+ ? dayjs__default["default"](value, format, true)
2256
+ : dayjs__default["default"](value);
2257
+ if (!dayInJS.isValid()) {
2258
+ return errMsg;
2259
+ }
2260
+ }, b) });
2261
+ }
2262
+ else if (fieldType === 'TncBlock') {
2263
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
2264
+ if (isRequired && !value) {
2265
+ return t('validator.required');
2266
+ }
2267
+ }, b) });
2268
+ }
2269
+ else {
2270
+ return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
2271
+ }
2272
+ }, {});
2273
+ }, [listBlockAdded.map((b) => b.name).join(','), format]);
2274
+ const form = useLeadForm({
2275
+ validateInputOnChange: true,
2276
+ validateInputOnBlur: true,
2277
+ clearInputErrorOnChange: true,
2278
+ validate: validateObj,
2279
+ initialValues,
2280
+ });
2281
+ const formRef = React.useRef(form);
2282
+ formRef.current = form;
2283
+ return { form, validateObj };
2284
+ };
2285
+
2286
+ const StyledLeadGenThankYou = styled__default["default"].div `
2287
+ display: flex;
2288
+ gap: 8px;
2289
+ flex-direction: column;
2290
+ padding-block: 24px;
2291
+
2292
+ .leadgen-image {
2293
+ width: 120px;
2294
+ height: 120px;
2295
+ margin-inline: auto;
2296
+ object-fit: contain;
2297
+ object-position: center;
2298
+ text-align: center;
2299
+ }
2300
+
2301
+ .leadgen-title {
2302
+ margin-block: 0;
2303
+ color: ${miscTheme.theme.colors.gray900};
2304
+ font-weight: 700;
2305
+ font-size: 18px;
2306
+ line-height: 28px;
2307
+ letter-spacing: -0.2px;
2308
+ }
2309
+
2310
+ .leadgen-description {
2311
+ margin-block: 0;
2312
+ color: ${miscTheme.theme.colors.gray600};
2313
+ font-weight: 400;
2314
+ font-size: 14px;
2315
+ line-height: 22px;
2316
+ letter-spacing: -0.2px;
2317
+ text-align: center;
2318
+ }
2319
+
2320
+ > [data-align] {
2321
+ &[data-align='right'] {
2322
+ text-align: right;
2323
+ }
2324
+ &[data-align='center'] {
2325
+ text-align: center;
2326
+ }
2327
+ }
2328
+ `;
2329
+ const LeadGenThankYou = ({ image, title, description, showButton = false, button, className, style, }) => {
2330
+ const { src } = image;
2331
+ const { htmlText: titleText, align: titleAlign } = title;
2332
+ const { htmlText: descriptionText, align: descriptionAlign } = description;
2333
+ const { htmlText: buttonText, newtab, url, onClick } = button;
2334
+ return (React__default["default"].createElement(StyledLeadGenThankYou, { className: className, style: style },
2335
+ React__default["default"].createElement("img", { src: src, alt: "", className: "leadgen-thankyou_image leadgen-image" }),
2336
+ React__default["default"].createElement("p", { className: "leadgen-thankyou_title leadgen-title", "data-align": titleAlign }, titleText),
2337
+ React__default["default"].createElement("p", { className: "leadgen-thankyou_description leadgen-description", "data-align": descriptionAlign }, descriptionText),
2338
+ !!buttonText && showButton && (React__default["default"].createElement(core.Button, { component: url ? 'a' : 'button', target: newtab ? '_blank' : undefined, href: url, size: "lg", variant: "filled", className: "leadgen-thankyoue_btn leadgen-btn", onClick: onClick }, buttonText))));
2339
+ };
2340
+
2341
+ const StyledLeadGenSubscriptionBoxBody = styled__default["default"].div `
2342
+ margin-top: 16px;
2343
+ .leadgen-btn {
2344
+ margin-top: 16px;
2345
+ }
2346
+ `;
2347
+ const StyledLeadGenSubscriptionBoxHeaderImage = styled__default["default"].div `
2348
+ margin-top: 3px;
2349
+ margin-right: 20px;
2350
+ width: 44px;
2351
+ height: 44px;
2352
+
2353
+ img {
2354
+ width: 100%;
2355
+ height: 100%;
2356
+ object-fix: contain;
2357
+ onject-position: center;
2358
+ }
2359
+
2360
+ :has(img[src='']) {
2361
+ display: none;
2362
+ }
2363
+ `;
2364
+ const StyledLeadGenSubscriptionBoxHeader = styled__default["default"].div `
2365
+ display: flex;
2366
+ align-items: center;
2367
+ margin-bottom: 16px;
2368
+ .leadgen-title {
2369
+ margin-bottom: 0;
2370
+ flex: 1;
2371
+ min-width: 0;
2372
+ color: ${miscTheme.theme.colors.gray900};
2373
+ font-size: 18px;
2374
+ font-weight: 400;
2375
+ line-height: 1.4;
2376
+ letter-spacing: -0.8px;
2377
+ }
2378
+ `;
2379
+ const StyledLeadGenSubscriptionBox = styled__default["default"].div `
2380
+ padding: 16px;
2381
+ border: 1px solid ${miscTheme.theme.colors.neutral100};
2382
+ border-radius: 12px;
2383
+ margin-inline: auto;
2384
+ .leadgen-form_inputs {
2385
+ .leadgen-form_input {
2386
+ width: 100%;
2387
+ }
2388
+ }
2389
+
2390
+ .leadgen-form_input {
2391
+ .mantine-Input-wrapper {
2392
+ max-height: 56px;
2393
+ }
2394
+ }
2395
+
2396
+ ${utils$1.MediaQueries.mbUp} {
2397
+ .leadgen-subscription_box_body {
2398
+ display: flex;
2399
+ > form {
2400
+ flex: 1;
2401
+ min-width: 0;
2402
+
2403
+ .leadgen-form_inputs {
2404
+ .leadgen-form_input {
2405
+ width: calc(50% - 4px);
2406
+ }
2407
+ }
2408
+ }
2409
+
2410
+ .leadgen-btn {
2411
+ margin-top: 0;
2412
+ margin-left: 8px;
2413
+ width: auto;
2414
+ min-height: 56px;
2415
+ }
2416
+ }
2417
+ }
2418
+
2419
+ ${utils$1.MediaQueries.smbDown} {
2420
+ &[data-type='subscription_box_A'] {
2421
+ border-inline: 0;
2422
+ border-radius: 0;
2423
+ margin-inline: -16px;
2424
+ box-shadow: 0px 0px 1px 0px #0000000a, 0px 0px 2px 0px #0000000f,
2425
+ 0px 4px 8px 0px #0000000a;
2426
+ }
2427
+ }
2428
+ `;
2429
+ const StyledLeadGenSubscriptionBoxA = styled__default["default"].div `
2430
+ .leadgen-form_input {
2431
+ --phone-select: 45px;
2432
+ .PhoneInput {
2433
+ --phone-select: 45px;
2434
+ .PhoneInputCountry {
2435
+ margin-top: 1px;
2436
+ pointer-events: none;
2437
+ .PhoneInputCountryIconImg,
2438
+ .PhoneInputArrowContainer {
2439
+ display: none;
2440
+ }
2441
+ }
2442
+ }
2443
+ }
2444
+ `;
2445
+
2446
+ const PhoneInput = React.forwardRef((props, ref) => {
2447
+ const { defaultCountry, id: idProps, name, placeholder, label, labelElement, labelProps, description, descriptionProps, withAsterisk, inputMode, inputContainer, inputWrapperOrder, error, className, classNames, style, styles } = props, restProps = tslib_es6.__rest(props, ["defaultCountry", "id", "name", "placeholder", "label", "labelElement", "labelProps", "description", "descriptionProps", "withAsterisk", "inputMode", "inputContainer", "inputWrapperOrder", "error", "className", "classNames", "style", "styles"]);
2448
+ const id = idProps || uuid.v1() + name;
2449
+ return (React__default["default"].createElement(core.Input.Wrapper, { size: "md", label: label, labelElement: labelElement, labelProps: Object.assign({ htmlFor: id }, labelProps), description: description, descriptionProps: descriptionProps, withAsterisk: withAsterisk, inputMode: inputMode, inputContainer: inputContainer, inputWrapperOrder: inputWrapperOrder, error: error, "data-invalid": !!error, className: className, classNames: classNames, style: style, styles: styles },
2450
+ React__default["default"].createElement("div", { className: "mantine-Input-wrapper" },
2451
+ React__default["default"].createElement(index$3.Phone, Object.assign({}, restProps, { id: id, ref: ref, name: name, spellCheck: false, placeholder: placeholder, defaultCountry: defaultCountry, className: "mantine-Input-input", type: "tel", "data-control": "tel" })))));
2452
+ });
2453
+
2454
+ const formatLeadGenFormValue = (values, blocks) => {
2455
+ const newValues = {};
2456
+ for (const block of blocks) {
2457
+ const { data } = block || {};
2458
+ const { value: fieldName } = data || {};
2459
+ if (fieldName in values) {
2460
+ newValues[fieldName] = values[fieldName];
2461
+ }
2462
+ }
2463
+ return newValues;
2464
+ };
2465
+
2466
+ const StyledLeadGenFormInner = styled__default["default"].div `
2467
+ display: flex;
2468
+ flex-wrap: wrap;
2469
+ gap: 8px;
2470
+ .leadgen-form_input {
2471
+ width: calc(50% - 4px);
2472
+ }
2473
+
2474
+ .leadgen-form_input_checkbox {
2475
+ width: 100%;
2476
+ }
2477
+ `;
2478
+
2479
+ const cssInputNotShrink$1 = react.css `
2480
+ height: 100% !important;
2481
+ min-height: calc(var(--container-height, 56px) * 22 / 56);
2482
+ color: ${miscTheme.theme.colors.gray800};
2483
+ font-size: var(--input, 16px);
2484
+ line-height: calc(var(--container-height, 56px) * 22 / 56);
2485
+ border: none !important;
2486
+ border-radius: 0 !important;
2487
+ outline: none !important;
2488
+ box-shadow: none !important;
2489
+ padding: 0;
2490
+ cursor: pointer;
2491
+ opacity: 0;
2492
+
2493
+ ::placeholder {
2494
+ color: ${miscTheme.theme.colors.gray400};
2495
+ }
2496
+ `;
2497
+ const cssInputShrink$1 = react.css `
2498
+ height: auto !important;
2499
+ cursor: text;
2500
+ opacity: 1;
2501
+ transition: 0.1s ease-in-out all;
2502
+ `;
2503
+ const cssLabelNotShrink$1 = react.css `
2504
+ position: absolute;
2505
+ top: calc(var(--container-height) / 2);
2506
+ left: var(--space-x, 16px);
2507
+ color: ${miscTheme.theme.colors.gray400};
2508
+ font-size: var(--label-not-shrink, 16px);
2509
+ font-weight: 400;
2510
+ line-height: calc(var(--container-height, 56px) * 18 / 56);
2511
+ margin: 0;
2512
+ z-index: 1;
2513
+ cursor: pointer;
2514
+ transform: translateY(-50%);
2515
+ transition: 0.125s ease-in all;
2516
+ `;
2517
+ const cssLabelShrink$1 = react.css `
2518
+ color: ${miscTheme.theme.colors.gray600};
2519
+ font-weight: 600;
2520
+ font-size: var(--label-shrink, 12px);
2521
+ top: calc(var(--container-height) * 7 / 56);
2522
+ transform: none;
2523
+ transition: 0.125s ease-out all;
2524
+ `;
2525
+ const cssWrapperInputNotShrink$1 = react.css `
2526
+ min-height: var(--container-height, 56px);
2527
+ display: flex;
2528
+ align-items: flex-end;
2529
+ border: 1px solid ${miscTheme.theme.colors.gray200};
2530
+ border-radius: 8px;
2531
+ background-color: #fff;
2532
+ padding-inline: var(--space-x, 16px);
2533
+ padding-block: var(--space-y-not-shrink, 16px);
2534
+ cursor: pointer;
2535
+ pointer-events: none;
2536
+
2537
+ &:has(.mantine-Input-rightSection) {
2538
+ padding-right: var(--container-height, 56px);
2539
+ }
2540
+
2541
+ .mantine-Input-icon {
2542
+ display: none;
2543
+ }
2544
+
2545
+ .mantine-NumberInput-control {
2546
+ border-color: ${miscTheme.theme.colors.gray200};
2547
+ }
2548
+ `;
2549
+ const cssWrapperInputShrink$1 = react.css `
2550
+ height: auto;
2551
+ min-height: var(--container-height, 56px);
2552
+ padding-block: var(--space-y-shrink, 7px);
2553
+ cursor: text;
2554
+ pointer-events: auto;
2555
+ `;
2556
+ const cssInputWrapperError$1 = react.css `
2557
+ color: ${miscTheme.theme.colors.red800};
2558
+ font-size: 12px;
2559
+ line-height: 1.5;
2560
+ `;
2561
+ const StyledTextFieldContainer$1 = styled__default["default"].div `
2562
+ --space-x: 16px;
2563
+ --space-y-not-shrink: 16px;
2564
+ --space-y-shrink: 7px;
2565
+ --container-height: 56px;
2566
+ --label-not-shrink: 16px;
2567
+ --label-shrink: 12px;
2568
+ --input: 16px;
2569
+
2570
+ position: relative;
2571
+ min-width: 100px;
2572
+ max-width: 100%;
2573
+ display: inline-block;
2574
+
2575
+ .textField_wrapper {
2576
+ display: inline-block;
2577
+ width: 100%;
2578
+ cursor: pointer;
2579
+ }
2580
+
2581
+ .mantine-InputWrapper-root {
2582
+ &[data-invalid='true'] {
2583
+ .mantine-Input-wrapper {
2584
+ border-color: ${miscTheme.theme.colors.red400};
2585
+ }
2586
+ }
2587
+
2588
+ .mantine-Input-wrapper {
2589
+ &:has([data-invalid]) {
2590
+ border-color: ${miscTheme.theme.colors.red400};
2591
+ }
2592
+ }
2593
+
2594
+ .mantine-InputWrapper-error {
2595
+ font-size: 12px !important;
2596
+ }
2597
+ }
2598
+
2599
+ .mantine-InputWrapper-label {
2600
+ ${cssLabelNotShrink$1}
2601
+ }
2602
+
2603
+ .mantine-Input-wrapper {
2604
+ ${cssWrapperInputNotShrink$1}
2605
+
2606
+ + .mantine-Popover-dropdown[data-position="bottom-start"] {
2607
+ left: 0 !important;
2608
+ }
2609
+ + .mantine-Popover-dropdown[data-position='top-start'] {
2610
+ top: unset !important;
2611
+ left: 0 !important;
2612
+ bottom: 100% !important;
2613
+ }
2614
+ }
2615
+
2616
+ .mantine-Input-input {
2617
+ ${cssInputNotShrink$1}
2618
+ }
2619
+
2620
+ &.textField_shrink,
2621
+ &:focus-within {
2622
+ .mantine-InputWrapper-label {
2623
+ ${cssLabelShrink$1}
2624
+ }
2625
+
2626
+ .mantine-Input-wrapper {
2627
+ ${cssWrapperInputShrink$1}
2628
+ &.mantine-Select-wrapper {
2629
+ .mantine-Select-rightSection {
2630
+ pointer-events: auto !important;
2631
+ }
2632
+ }
2633
+ }
2634
+
2635
+ .mantine-Input-input {
2636
+ ${cssInputShrink$1}
2637
+ }
2638
+
2639
+ &:has(.PhoneInput) {
2640
+ .mantine-InputWrapper-label {
2641
+ left: var(--space-x, 16px);
2642
+ }
2643
+ .PhoneInput {
2644
+ .PhoneInputInput {
2645
+ opacity: 1;
2646
+ }
2647
+ }
2648
+ }
2649
+ }
2650
+
2651
+ .PhoneInput {
2652
+ --phone-select: 75px;
2653
+ --phone-input-space-x: 8px;
2654
+ width: 100%;
2655
+ opacity: 1;
2656
+ border: none;
2657
+ .PhoneInputCountry {
2658
+ background-color: transparent;
2659
+ border: none;
2660
+ padding: 0;
2661
+ width: var(--phone-select, 75px);
2662
+ }
2663
+ .PhoneInputInput {
2664
+ flex: 1;
2665
+ min-width: 0;
2666
+ line-height: 1.5;
2667
+ outline: none !important;
2668
+ border: none;
2669
+ box-shadow: none;
2670
+ padding: 0 var(--phone-input-space-x, 8px);
2671
+ opacity: 0;
2672
+ color: ${miscTheme.theme.colors.gray800} !important;
2673
+ :focus {
2674
+ color: ${miscTheme.theme.colors.gray800} !important;
2675
+ }
2676
+ }
2677
+ }
2678
+
2679
+ &:has(.PhoneInput) {
2680
+ .mantine-InputWrapper-label {
2681
+ left: calc(
2682
+ var(--space-x, 16px) + var(--phone-select, 75px) +
2683
+ var(--phone-input-space-x, 8px)
2684
+ );
2685
+ }
2686
+ }
2687
+ `;
2688
+ const StyledChoiceFieldContainer$1 = styled__default["default"].div `
2689
+ &.leadgen-form_checkbox,
2690
+ &.leadgen-form_radio {
2691
+ width: 100%;
2692
+ }
2693
+
2694
+ &.leadgen-form_dropdown {
2695
+ width: calc(50% - 12px);
2696
+ }
2697
+
2698
+ .mantine-InputWrapper-root {
2699
+ display: block;
2700
+ .mantine-InputWrapper-error {
2701
+ font-size: 12px !important;
2702
+ }
2703
+ }
2704
+
2705
+ .mantine-InputWrapper-label {
2706
+ margin-bottom: 0.5rem;
2707
+ color: ${miscTheme.theme.colors.gray800};
2708
+ font-size: 16px;
2709
+ font-weight: 400;
2710
+ line-height: 1.5;
2711
+ }
2712
+
2713
+ .mantine-Radio-root,
2714
+ .mantine-Checkbox-root {
2715
+ gap: 8px;
2716
+ min-width: calc(50% - 4px);
2717
+
2718
+ input[type='radio'],
2719
+ input[type='checkbox'] {
2720
+ border-color: ${miscTheme.theme.colors.gray600};
2721
+ width: 18px;
2722
+ height: 18px;
2723
+ }
2724
+ input[type='checkbox'] {
2725
+ border-radius: 4px;
2726
+ }
2727
+
2728
+ &[data-checked='true'] {
2729
+ input[type='radio'],
2730
+ input[type='checkbox'] {
2731
+ border-color: ${miscTheme.theme.colors.primary600};
2732
+ + svg {
2733
+ color: ${miscTheme.theme.colors.primary600};
2734
+ }
2735
+ }
2736
+
2737
+ input[type='radio'] {
2738
+ background-color: white;
2739
+ }
2740
+ }
2741
+
2742
+ .mantine-Checkbox-input {
2743
+ &:checked {
2744
+ border-color: ${miscTheme.theme.colors.primary600};
2745
+ }
2746
+ }
2747
+ }
2748
+
2749
+ .mantine-Radio-inner,
2750
+ .mantine-Checkbox-inner {
2751
+ width: 24px;
2752
+ height: 24px;
2753
+ display: flex;
2754
+ align-items: center;
2755
+ justify-content: center;
2756
+ }
2757
+
2758
+ .mantine-Radio-body,
2759
+ .mantine-Checkbox-body {
2760
+ display: flex;
2761
+ align-items: center;
2762
+ }
2763
+
2764
+ .mantine-Radio-label,
2765
+ .mantine-Checkbox-label {
2766
+ padding-left: 8px;
2767
+ color: ${miscTheme.theme.colors.gray800};
2768
+ font-size: 14px;
2769
+ line-height: 1.4;
2770
+ letter-spacing: -0.2px;
2771
+ }
2772
+
2773
+ .leadgen-choiceContainer {
2774
+ display: flex;
2775
+ flex-wrap: wrap;
2776
+ align-items: flex-start;
2777
+ gap: 8px;
2778
+ }
2779
+
2780
+ .mantine-InputWrapper-error {
2781
+ ${cssInputWrapperError$1}
2782
+ }
2783
+ `;
2784
+
2785
+ const TextField$1 = (props) => {
2786
+ const { shrink: shrinkProps, onChangeShrink, className, children } = props, restProps = tslib_es6.__rest(props, ["shrink", "onChangeShrink", "className", "children"]);
2787
+ const containerRef = hooks.useClickOutside(() => {
2788
+ if (shrinkProps) {
2789
+ return;
2790
+ }
2791
+ setShrink(false);
2792
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(false);
2793
+ });
2794
+ const [shrink, setShrink] = React.useState(shrinkProps);
2795
+ const onClick = React.useCallback((e) => {
2796
+ setShrink(true);
2797
+ onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(true);
2798
+ if (shrink) {
2799
+ return;
2800
+ }
2801
+ const $textEl = e.currentTarget.querySelectorAll('input:not([disabled]):not([type="submit"]),select:not([disabled]),textarea:not([disabled])');
2802
+ const $focusEl = $textEl.item($textEl.length - 1);
2803
+ if ($focusEl) {
2804
+ $focusEl.focus();
2805
+ setTimeout(() => {
2806
+ $focusEl.scrollIntoView({
2807
+ behavior: 'auto',
2808
+ block: 'center',
2809
+ inline: 'start',
2810
+ });
2811
+ }, 100);
2812
+ }
2813
+ }, [shrink]);
2814
+ React.useEffect(() => {
2815
+ setShrink(shrinkProps);
2816
+ }, [shrinkProps]);
2817
+ return (React__default["default"].createElement(StyledTextFieldContainer$1, Object.assign({ shrink: shrink, className: core.clsx(className, 'textField', { textField_shrink: !!shrink }) }, restProps),
2818
+ React__default["default"].createElement("div", { ref: containerRef, onClick: onClick, className: "textField_wrapper" }, children)));
2819
+ };
2820
+ const ChoiceField$1 = (props) => {
2821
+ const { children, className } = props, restProps = tslib_es6.__rest(props, ["children", "className"]);
2822
+ return (React__default["default"].createElement(StyledChoiceFieldContainer$1, Object.assign({ className: core.clsx(className, 'choiceField') }, restProps), children));
2823
+ };
2824
+
2825
+ const libraries = ['places'];
2826
+ const GoogleLocationBlock = (props) => {
2827
+ var _a;
2828
+ const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = tslib_es6.__rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
2829
+ const [LoadScript, setLoadScript] = React.useState(null);
2830
+ const [value, setValue] = React.useState(defaultValue || valueProps);
2831
+ const { predictions } = usePlacesAutocomplete.usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
2832
+ const onChangeAutocomplete = React.useCallback((s) => {
2833
+ setValue(s);
2834
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
2835
+ }, []);
2836
+ const onClickItem = React.useCallback((item) => {
2837
+ /** For sure get value */
2838
+ setValue(item.value);
2839
+ const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
2840
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
2841
+ }, [onChangeProps, predictions]);
2842
+ React.useEffect(() => {
2843
+ setValue(valueProps);
2844
+ }, [valueProps]);
2845
+ React.useEffect(() => {
2846
+ var _a, _b, _c;
2847
+ // only load extra google script when not yet loaded
2848
+ 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) {
2849
+ Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@react-google-maps/api')); }).then((m) => {
2850
+ setLoadScript(() => m.LoadScript);
2851
+ });
2852
+ }
2853
+ }, []);
2854
+ return (React__default["default"].createElement(core.Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
2855
+ return { value: pred.description, label: pred.description };
2856
+ }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: index$7.ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
2857
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
2858
+ LoadScript && (React__default["default"].createElement(LoadScript, { googleMapsApiKey: usePlacesAutocomplete.GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default["default"].createElement(React__default["default"].Fragment, null), style: { width: '100%' } })),
2859
+ children));
2860
+ } }, restProps)));
2861
+ };
2862
+
2863
+ const LeadGenForm = React.forwardRef((props, ref) => {
2864
+ const { locale, blocks, scrollToErrorField = true, form: formProps, rules: validate, initialValues, onFinish, onFinishFailed, className, style, } = props;
2865
+ const formRef = React.useRef(null);
2866
+ const form$1 = formProps || form.useForm({ initialValues, validate });
2867
+ const middlewareFinish = React.useCallback((values, event) => {
2868
+ /** Set `touched` all values for validation when submiting */
2869
+ form$1.setTouched(blocks.reduce((touched, { data }) => {
2870
+ touched[data.value] = true;
2871
+ return touched;
2872
+ }, {}));
2873
+ /** Wait for `touched` state and then submit */
2874
+ setTimeout(() => {
2875
+ const { hasErrors } = form$1.validate();
2876
+ if (hasErrors) {
2877
+ return;
2878
+ }
2879
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatLeadGenFormValue(values, blocks), event);
2880
+ }, 100);
2881
+ }, [form$1, blocks]);
2882
+ const middlewareFinishFailed = React.useCallback((errors, values, events) => {
2883
+ if (scrollToErrorField && errors) {
2884
+ const firstErrorKey = Object.keys(errors)[0];
2885
+ const firstErrorElement = document.querySelector(`[name="${firstErrorKey}"]`);
2886
+ if (firstErrorElement && (firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus)) {
2887
+ setTimeout(() => {
2888
+ firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
2889
+ firstErrorElement.scrollIntoView({
2890
+ behavior: 'auto',
2891
+ block: 'center',
2892
+ inline: 'center',
2893
+ });
2894
+ }, 100);
2895
+ }
2896
+ }
2897
+ onFinishFailed === null || onFinishFailed === void 0 ? void 0 : onFinishFailed(errors, values, events);
2898
+ }, [scrollToErrorField]);
2899
+ React.useEffect(() => {
2900
+ (() => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
2901
+ if (!window.intlTelInputUtils) {
2902
+ yield require('intl-tel-input/build/js/utils');
2903
+ }
2904
+ }))();
2905
+ }, []);
2906
+ React.useImperativeHandle(ref, () => (Object.assign(Object.assign({}, form$1), { submit: () => {
2907
+ formRef.current.requestSubmit();
2908
+ } })), [form$1, formRef]);
2909
+ if (!blocks || !blocks.length) {
2910
+ return null;
2911
+ }
2912
+ return (React__default["default"].createElement("form", { ref: formRef, onSubmit: form$1.onSubmit(middlewareFinish, middlewareFinishFailed), className: className, style: style },
2913
+ React__default["default"].createElement(StyledLeadGenFormInner, { className: "leadgen-form_inputs" }, blocks.map((block, idx) => {
2914
+ const { id, name: blockName, data } = block;
2915
+ const { placeholder, value: name, required, listQuestion, valueHTML, isSendMailChimp = false, } = data;
2916
+ const formInputProps = form$1.getInputProps(name);
2917
+ const { value, error } = formInputProps;
2918
+ const reactKey = `${id}-${idx}`;
2919
+ switch (blockName) {
2920
+ case LEADGEN_BLOCK.TextBlock: {
2921
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2922
+ React__default["default"].createElement(core.TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "text", "data-control": "text" }, formInputProps))));
2923
+ }
2924
+ case LEADGEN_BLOCK.NumberBlock: {
2925
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2926
+ React__default["default"].createElement(core.NumberInput, Object.assign({ name: value, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "number", "data-control": "number" }, formInputProps))));
2927
+ }
2928
+ case LEADGEN_BLOCK.EmailBlock: {
2929
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2930
+ React__default["default"].createElement(core.TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, "data-control": "email" }, formInputProps))));
2931
+ }
2932
+ case LEADGEN_BLOCK.PhoneOtpBlock:
2933
+ case LEADGEN_BLOCK.WhatsappOtpBlock:
2934
+ case LEADGEN_BLOCK.ZaloOtpBlock:
2935
+ case LEADGEN_BLOCK.PhoneBlock: {
2936
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2937
+ React__default["default"].createElement(PhoneInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, defaultCountry: (locale ? utils.MAPPED_LOCALE[locale] || 'VN' : 'VN'), type: "text", "data-control": "text" }, formInputProps))));
2938
+ }
2939
+ case LEADGEN_BLOCK.LocationBlock: {
2940
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2941
+ React__default["default"].createElement(GoogleLocationBlock, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, locale: locale, "data-control": "text" }, formInputProps))));
2942
+ }
2943
+ case LEADGEN_BLOCK.DateBlock: {
2944
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2945
+ React__default["default"].createElement(dates.DateInput, Object.assign({ locale: (utils.MAPPED_LOCALE === null || utils.MAPPED_LOCALE === void 0 ? void 0 : utils.MAPPED_LOCALE[locale]) || utils.MAPPED_LOCALE['vi-VN'], valueFormat: "DD/MM/YYYY", name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "default", "data-control": "date" }, formInputProps))));
2946
+ }
2947
+ case LEADGEN_BLOCK.DropdownBlock:
2948
+ return (React__default["default"].createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2949
+ React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2950
+ React__default["default"].createElement(core.Select, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, data: listQuestion.map((l) => ({
2951
+ value: l.value,
2952
+ label: l.placeholder,
2953
+ })) }, formInputProps))));
2954
+ case LEADGEN_BLOCK.CheckboxBlock: {
2955
+ const formInputCheckboxProps = form$1.getInputProps(name, {
2956
+ type: 'checkbox',
2957
+ });
2958
+ return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2959
+ isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2960
+ React__default["default"].createElement(core.Checkbox.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, sx: {
2961
+ display: 'flex',
2962
+ flexDirection: 'column',
2963
+ flexWrap: 'wrap',
2964
+ gap: 8,
2965
+ }, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2966
+ return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2967
+ } }, formInputCheckboxProps), listQuestion.map((l, _idx) => (React__default["default"].createElement(core.Checkbox, { name: name, key: _idx, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2968
+ }
2969
+ case LEADGEN_BLOCK.RadioBlock: {
2970
+ return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2971
+ isSendMailChimp && (React__default["default"].createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2972
+ React__default["default"].createElement(core.Radio.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, spellCheck: true, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2973
+ return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2974
+ } }, formInputProps), listQuestion.map((l, _index) => (React__default["default"].createElement(core.Radio, { name: name, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2975
+ }
2976
+ case LEADGEN_BLOCK.TncBlock:
2977
+ return (React__default["default"].createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2978
+ React__default["default"].createElement(core.Input.Wrapper, { error: error },
2979
+ React__default["default"].createElement(core.Checkbox, Object.assign({ value: value, name: 'TNC-' + id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, formInputProps)))));
2980
+ default: {
2981
+ return null;
2982
+ }
2983
+ }
2984
+ }))));
2985
+ });
2986
+
2987
+ const LEADGEN_ORDER_INPUT_WRAPPER = ['label', 'input', 'description', 'error'];
2988
+
2989
+ const LeadGenSubscriptionBoxA = (props) => {
2990
+ const { loading, image, title, submitText, locale, blocks, form, rules, onFinish, } = props;
2991
+ const formRef = React.useRef();
2992
+ const imageComp = React.useMemo(() => {
2993
+ if (!image) {
2994
+ return null;
2995
+ }
2996
+ return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeaderImage, null,
2997
+ React__default["default"].createElement("img", { src: image, alt: "" })));
2998
+ }, [image]);
2999
+ const titleComp = React.useMemo(() => {
3000
+ if (typeof title === 'string') {
3001
+ return (React__default["default"].createElement("p", { className: "leadgen-title", dangerouslySetInnerHTML: { __html: title } }));
3002
+ }
3003
+ return React__default["default"].createElement("p", { className: "leadgen-title" }, title);
3004
+ }, [title]);
3005
+ return (React__default["default"].createElement(StyledLeadGenSubscriptionBoxA, { className: "subcription_box_A" },
3006
+ React__default["default"].createElement(StyledLeadGenSubscriptionBoxHeader, { className: "leadgen-subscription_box_header" },
3007
+ imageComp,
3008
+ titleComp),
3009
+ React__default["default"].createElement(StyledLeadGenSubscriptionBoxBody, { className: "leadgen-subscription_box_body" },
3010
+ React__default["default"].createElement(LeadGenForm, { ref: formRef, form: form, rules: rules, blocks: blocks, locale: locale, onFinish: onFinish, className: "leadgen-subscription_box_form" }),
3011
+ React__default["default"].createElement(core.Button, { disabled: loading, loading: loading, variant: "filled", size: "lg", onClick: () => {
3012
+ formRef.current.submit();
3013
+ }, className: "leadgen-btn leadgen-btn_action", fullWidth: true }, submitText))));
3014
+ };
3015
+
3016
+ const LeadGenSubscriptionBoxWithoutMemo = ({ locale, userInfo, forceCampaign, categoryId, }) => {
3017
+ var _a, _b, _c;
3018
+ const { image, extra_fields, id: campaign_id, bot_id: campaign_subot_id = [], ThankYouBlock, } = forceCampaign || {};
3019
+ const { textBlocks, listBlockAdded, actionBlocks } = extra_fields || {};
3020
+ const { submitBlock } = actionBlocks || {};
3021
+ const { apiLeadUrl, subscriptionIcon, subscriptionTitle, submitSubscriptionBox, impression, onFinish, } = useLeadGenContext();
3022
+ const { t } = index$1.useTranslations();
3023
+ const { action: { pushNotifications }, } = React.useContext(togetherComponentGlobalContext.TogetherComponentGlobalContext);
3024
+ const refContainer = React.useRef(null);
3025
+ const [loading, setLoading] = React.useState(false);
3026
+ const [showThankyou, setShowThankyou] = React.useState(false);
3027
+ const validatingEmailRef = React.useRef(false);
3028
+ const validatingPhoneRef = React.useRef(false);
3029
+ const { form, validateObj } = useLeadFormConfig({
3030
+ listBlockAdded,
3031
+ campaignId: campaign_id,
3032
+ campaign_subot_id,
3033
+ validatingEmailRef,
3034
+ validatingPhoneRef,
3035
+ userInfo,
3036
+ });
3037
+ const subscription_title = React.useMemo(() => {
3038
+ var _a, _b;
3039
+ return subscriptionTitle ||
3040
+ ((_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) ||
3041
+ t('leadgen.message.title.default');
3042
+ }, [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]);
3043
+ const { image: thankyouImage, title: thankyouTitle, description: thankyouDescription, button: thankyouButton, } = ThankYouBlock || {};
3044
+ const intersectionObserverCallback = React.useCallback((entries) => {
3045
+ entries.forEach((entry) => {
3046
+ const { isIntersecting, target } = entry;
3047
+ if (!showThankyou &&
3048
+ isIntersecting &&
3049
+ target === refContainer.current) {
3050
+ impression();
3051
+ }
3052
+ });
3053
+ }, [impression, showThankyou]);
3054
+ const IObserver = new IntersectionObserver(intersectionObserverCallback);
3055
+ const middlewareOnSubmit = React.useCallback((values) => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
3056
+ const newValues = {
3057
+ subscription_title,
3058
+ };
3059
+ const ssoValues = {
3060
+ sso_user_id: undefined,
3061
+ sso_uuid: undefined,
3062
+ sso_verified_profile: undefined,
3063
+ };
3064
+ const valueKeys = Object.keys(values);
3065
+ for (const key of valueKeys) {
3066
+ const isPhoneField = leadGenFieldNamePhone(listBlockAdded).some((k) => k === key);
3067
+ if (isPhoneField) {
3068
+ const phone = PhoneInputBase.parsePhoneNumber(values[key]);
3069
+ if (phone.isValid()) {
3070
+ /** Seperate `area_code` and `phone_number` for BE */
3071
+ newValues['area_code'] = `+${phone.countryCallingCode}`;
3072
+ newValues['phone_number'] = phone.nationalNumber;
3073
+ /** Only case login has this update */
3074
+ if ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) && (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid)) {
3075
+ const userInfoPhone = (userInfo === null || userInfo === void 0 ? void 0 : userInfo.area_code) + (userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone);
3076
+ ssoValues['sso_verified_profile'] =
3077
+ phone.number === userInfoPhone ? 1 : 0;
3078
+ ssoValues['sso_user_id'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.id;
3079
+ ssoValues['sso_uuid'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid;
3080
+ LeadLog('** LeadGen SB userInfoPhone : ', userInfoPhone);
3081
+ LeadLog('** LeadGen SB userInfoPhoneInput : ', phone.number);
3082
+ }
3083
+ }
3084
+ continue;
3085
+ }
3086
+ newValues[key] = values[key];
3087
+ }
3088
+ setLoading(true);
3089
+ try {
3090
+ const reqValues = Object.assign(Object.assign({}, newValues), ssoValues);
3091
+ const { _data } = (yield submitSubscriptionBox(reqValues)) || {};
3092
+ const { model } = _data || {};
3093
+ if (model && (model === null || model === void 0 ? void 0 : model.id)) {
3094
+ setShowThankyou(true);
3095
+ const metaValues = {
3096
+ blocks: listBlockAdded || [],
3097
+ isUpdateSso: false,
3098
+ };
3099
+ /**
3100
+ * https://hhgdev.atlassian.net/browse/EL-468
3101
+ * This feature is just using in Subscription Box
3102
+ */
3103
+ if (newValues === null || newValues === void 0 ? void 0 : newValues.name) {
3104
+ const { _data: ssoData, code: ssoErrorCode } = yield Service.postUserInfoFromLeadGen({ name: newValues === null || newValues === void 0 ? void 0 : newValues.name });
3105
+ if (ssoErrorCode && !ssoData) {
3106
+ return;
3107
+ }
3108
+ metaValues.isUpdateSso = true;
3109
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(reqValues, metaValues);
3110
+ return;
3111
+ }
3112
+ onFinish === null || onFinish === void 0 ? void 0 : onFinish(reqValues, metaValues);
3113
+ }
3114
+ }
3115
+ catch (error) {
3116
+ LeadLog('** LeadGen SubscriptionBox error : ', error);
3117
+ pushNotifications({
3118
+ message: t('leadgen.message.error.default'),
3119
+ type: 'danger',
3120
+ });
3121
+ }
3122
+ setLoading(false);
3123
+ }), [
3124
+ subscription_title,
3125
+ listBlockAdded,
3126
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
3127
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid,
3128
+ userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone,
3129
+ ]);
3130
+ React.useEffect(() => {
3131
+ if (refContainer.current) {
3132
+ IObserver.observe(refContainer.current);
3133
+ }
3134
+ return () => {
3135
+ IObserver.disconnect();
3136
+ };
3137
+ }, [categoryId]);
3138
+ return (React__default["default"].createElement("div", { ref: refContainer },
3139
+ React__default["default"].createElement(StyledLeadGenSubscriptionBox, { "data-type": "subscription_box_A" },
3140
+ showThankyou && (React__default["default"].createElement(LeadGenThankYou, { image: Object.assign(Object.assign({}, thankyouImage), { src: thankyouImage.src || `${apiLeadUrl}admin/img/thanksyou.png` }), title: thankyouTitle, description: thankyouDescription, button: thankyouButton })),
3141
+ !showThankyou && (React__default["default"].createElement(LeadGenSubscriptionBoxA, { loading: loading, image: subscriptionIcon || image, title: subscription_title, submitText: (_c = submitBlock === null || submitBlock === void 0 ? void 0 : submitBlock.data) === null || _c === void 0 ? void 0 : _c.value, blocks: listBlockAdded, locale: locale, form: form, rules: validateObj, onFinish: middlewareOnSubmit })))));
3142
+ };
3143
+ const LeadGenSubscriptionBox$1 = React.memo(LeadGenSubscriptionBoxWithoutMemo);
3144
+
3145
+ const Container = () => {
3146
+ const context = React.useContext(LeadGenContext);
3147
+ const { campaign_code, locale, siteId, siteDomain, userInfo, forceCampaign } = context;
3148
+ if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
3149
+ return null;
3150
+ }
3151
+ return (React__default["default"].createElement(LeadGenSubscriptionBox$1, { locale: locale, siteId: siteId, siteDomain: siteDomain, userInfo: userInfo, forceCampaign: forceCampaign, campaign_code: campaign_code }));
3152
+ };
3153
+ Container.displayName = 'LeadGenSubscriptionBox';
3154
+ const LeadGenSubscriptionBoxContainer = (props) => {
3155
+ const { apiUrl, apiSubotUrl } = props;
3156
+ return (React__default["default"].createElement(LeadGenContextProvider, Object.assign({}, props, { apiLeadUrl: apiUrl, apiSubotUrl: apiSubotUrl }),
3157
+ React__default["default"].createElement(Container, null)));
3158
+ };
3159
+ const LeadGenSubscriptionBox = LeadGenSubscriptionBoxContainer;
3160
+
3161
+ const useImageSize = (src) => {
3162
+ const [width, setWidth] = React.useState(16);
3163
+ const [height, setHeight] = React.useState(9);
3164
+ const [loaded, setLoaded] = React.useState(false);
3165
+ // load src image to get its width and height
3166
+ React.useEffect(() => {
3167
+ setLoaded(false);
3168
+ if (src) {
3169
+ const img = new Image();
3170
+ img.addEventListener('load', () => {
3171
+ setWidth(img.naturalWidth);
3172
+ setHeight(img.naturalHeight);
3173
+ setLoaded(true);
3174
+ });
3175
+ img.addEventListener('error', () => {
3176
+ setWidth(16);
3177
+ setHeight(9);
3178
+ setLoaded(true);
3179
+ });
3180
+ img.src = src;
3181
+ }
3182
+ else {
3183
+ setWidth(16);
3184
+ setHeight(9);
3185
+ setLoaded(true);
3186
+ }
3187
+ }, [src]);
3188
+ return {
3189
+ loaded,
3190
+ width,
3191
+ height,
3192
+ };
3193
+ };
3194
+
3195
+ const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default["default"].createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
3196
+ React__default["default"].createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
3197
+ React__default["default"].createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
3198
+
3199
+ // url: imageBlocks.imageMobile.data.url
3200
+ // newTab: imageBlocks.imageMobile.data.newtab
3201
+ // imageMobile: campaignShow.image
3202
+ // imageDestkop: campaignShow.image_desktop
3203
+ const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
3204
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3205
+ const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
3206
+ if (!imageMobileLoaded || !imageDestkopLoaded)
3207
+ return null;
3208
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
3209
+ React__default["default"].createElement("div", { className: "le-center-tab-popup" },
3210
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
3211
+ React__default["default"].createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
3212
+ index$8.isVideo(imageMobile) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
3213
+ React__default["default"].createElement("source", { src: imageMobile }))) : (React__default["default"].createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
3214
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3215
+ } })),
3216
+ index$8.isVideo(imageDestkop) ? (React__default["default"].createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
3217
+ React__default["default"].createElement("source", { src: imageDestkop }))) : (React__default["default"].createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
3218
+ aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
3219
+ } }))),
3220
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3221
+ };
3222
+
3223
+ // title: titleText
3224
+ // titleAlign: textBlocks.titleBlock.data.align
3225
+ // subtitle: textBlocks.subtitleBlock.data.value
3226
+ // subtitleAlign: textBlocks.subtitleBlock.data.align
3227
+ // url: actionBlocks.linkButtonBlock.data.url
3228
+ // urlText: actionBlocks.linkButtonBlock.data.value
3229
+ // newTab: actionBlocks.linkButtonBlock.data.newtab
3230
+ // imageMobile: campaignShow.image
3231
+ // imageDesktop: campaignShow.image_desktop
3232
+ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
3233
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3234
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
3235
+ if (!imageMobileLoaded || !imageDesktopLoaded)
3236
+ return null;
3237
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
3238
+ React__default["default"].createElement("aside", { className: "le-only-desktop" },
3239
+ React__default["default"].createElement("div", { className: "le-floating-desktop" },
3240
+ React__default["default"].createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
3241
+ imageDesktop ? (React__default["default"].createElement("div", null,
3242
+ React__default["default"].createElement("img", { style: {
3243
+ maxWidth: 120,
3244
+ borderTopLeftRadius: 5,
3245
+ borderBottomLeftRadius: 5,
3246
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
3247
+ }, src: imageDesktop }))) : null,
3248
+ React__default["default"].createElement("div", { style: { padding: 20 } },
3249
+ React__default["default"].createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
3250
+ React__default["default"].createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
3251
+ React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
3252
+ React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
3253
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
3254
+ React__default["default"].createElement("aside", { className: "le-only-mobile" },
3255
+ React__default["default"].createElement("div", { className: "le-floating-mobile" },
3256
+ React__default["default"].createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
3257
+ React__default["default"].createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
3258
+ React__default["default"].createElement("div", null,
3259
+ React__default["default"].createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
3260
+ React__default["default"].createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
3261
+ imageMobile ? (React__default["default"].createElement("div", null,
3262
+ React__default["default"].createElement("img", { style: {
3263
+ marginLeft: 15,
3264
+ marginTop: 4,
3265
+ maxWidth: 100,
3266
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3267
+ }, src: imageMobile }))) : null),
3268
+ React__default["default"].createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
3269
+ React__default["default"].createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
3270
+ React__default["default"].createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
3271
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
3272
+ };
3273
+
3274
+ const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
3275
+ const { primaryColor } = React.useContext(LeadGenContext$1);
3276
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
3277
+ if (!imageLoaded)
3278
+ return null;
3279
+ return (React__default["default"].createElement("div", { className: "lead-modal__thank-you leadgen-inner_thankyou" },
3280
+ React__default["default"].createElement("div", { style: { width: '100%' } },
3281
+ React__default["default"].createElement("img", { src: image, style: {
3282
+ maxHeight: 162,
3283
+ objectFit: 'cover',
3284
+ aspectRatio: `${imageWidth}/${imageHeight}`,
3285
+ }, loading: "lazy" }),
3286
+ title && (React__default["default"].createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
3287
+ subtitle && (React__default["default"].createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle.split('\n').map((text, idx, list) => {
3288
+ const isShowBr = idx < list.length - 1;
3289
+ return (React__default["default"].createElement(React__default["default"].Fragment, null,
3290
+ text,
3291
+ isShowBr && React__default["default"].createElement("br", null)));
3292
+ }))),
3293
+ linkText && (React__default["default"].createElement("div", null,
3294
+ React__default["default"].createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
3295
+ React__default["default"].createElement(index$4.Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
1542
3296
  };
1543
3297
 
1544
3298
  const InlineLayout = ({ content, inlinePosition, }) => {
@@ -1651,257 +3405,41 @@ const InlineLayout = ({ content, inlinePosition, }) => {
1651
3405
  return ReactDOM.createPortal(content, target);
1652
3406
  };
1653
3407
 
1654
- const SideBarLayout = ({ content }) => {
1655
- const targets = React.useMemo(() => {
1656
- const targetDoms = Array.from(document.querySelectorAll('.hc2-sidebar-with-ads,.page-main-col .right-col.f-right,.hhg-lead-sidebar'));
1657
- targetDoms.forEach((dom) => {
1658
- if (dom.querySelector('.sidebar-lead-modal-wrapper'))
1659
- return;
1660
- const wrapper = document.createElement('div');
1661
- wrapper.classList.add('sidebar-lead-modal-wrapper');
1662
- dom.prepend(wrapper);
1663
- });
1664
- return targetDoms.map((d) => d.querySelector('.sidebar-lead-modal-wrapper'));
1665
- }, []);
1666
- return (React__default["default"].createElement(React__default["default"].Fragment, null, targets.map((target) => ReactDOM.createPortal(content, utils$1.getWrapperDomWithSelector(target, 'sidebar-lead-modal-wrapper')))));
1667
- };
1668
-
1669
- const EmptyIcon = (props) => {
1670
- const { className, style } = props;
1671
- return (React__default["default"].createElement("svg", { width: "160", height: "160", viewBox: "0 0 160 160", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, style: style },
1672
- React__default["default"].createElement("path", { d: "M79.9974 113.333C98.4069 113.333 113.331 98.4096 113.331 80.0001C113.331 61.5906 98.4069 46.6667 79.9974 46.6667C61.5879 46.6667 46.6641 61.5906 46.6641 80.0001C46.6641 98.4096 61.5879 113.333 79.9974 113.333Z", fill: "#F44D2C" }),
1673
- React__default["default"].createElement("path", { d: "M92.434 95.0004C91.7771 95.0004 91.1213 94.7499 90.6194 94.249L65.7521 69.3807C64.7493 68.3779 64.7493 66.7542 65.7521 65.7524C66.7549 64.7507 68.3786 64.7497 69.3804 65.7524L94.2487 90.6208C95.2515 91.6235 95.2515 93.2473 94.2487 94.249C93.7468 94.7499 93.0909 95.0004 92.434 95.0004Z", fill: "white" }),
1674
- React__default["default"].createElement("path", { d: "M67.5648 95C66.9079 95 66.252 94.7496 65.7501 94.2487C64.7474 93.2459 64.7474 91.6222 65.7501 90.6204L90.6185 65.7521C91.6212 64.7493 93.245 64.7493 94.2467 65.7521C95.2485 66.7549 95.2495 68.3786 94.2467 69.3804L69.3794 94.2487C68.8786 94.7496 68.2217 95 67.5648 95Z", fill: "white" })));
1675
- };
1676
-
1677
- const EmptyComponent = ({ onClose, onContinue, }) => {
1678
- const { t } = index.useTranslations();
1679
- return (React__default["default"].createElement("div", { className: "leadgen-empty" },
1680
- React__default["default"].createElement("div", { className: "leadgen-empty_body" },
1681
- React__default["default"].createElement("div", { className: "leadgen-empty_wrapper" },
1682
- React__default["default"].createElement(EmptyIcon, { className: "leadgen-empty_image" }),
1683
- React__default["default"].createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
1684
- React__default["default"].createElement("div", { className: "leadgen-empty_footer" },
1685
- React__default["default"].createElement(core.Button, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
1686
- React__default["default"].createElement(core.Button, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
1687
- };
1688
-
1689
- const libraries = ['places'];
1690
- const GoogleLocationBlock = (props) => {
1691
- var _a;
1692
- const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = tslib_es6.__rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
1693
- const [LoadScript, setLoadScript] = React.useState(null);
1694
- const [value, setValue] = React.useState(defaultValue || valueProps);
1695
- const { predictions } = usePlacesAutocomplete.usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
1696
- const onChangeAutocomplete = React.useCallback((s) => {
1697
- setValue(s);
1698
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
1699
- }, []);
1700
- const onClickItem = React.useCallback((item) => {
1701
- /** For sure get value */
1702
- setValue(item.value);
1703
- const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
1704
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
1705
- }, [onChangeProps, predictions]);
1706
- React.useEffect(() => {
1707
- setValue(valueProps);
1708
- }, [valueProps]);
1709
- React.useEffect(() => {
1710
- var _a, _b, _c;
1711
- // only load extra google script when not yet loaded
1712
- if (!((_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.places) === null || _c === void 0 ? void 0 : _c.AutocompleteService) && !LoadScript) {
1713
- Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@react-google-maps/api')); }).then((m) => {
1714
- setLoadScript(() => m.LoadScript);
1715
- });
1716
- }
1717
- }, []);
1718
- return (React__default["default"].createElement(core.Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
1719
- return { value: pred.description, label: pred.description };
1720
- }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: index$7.ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
1721
- return (React__default["default"].createElement(React__default["default"].Fragment, null,
1722
- LoadScript && (React__default["default"].createElement(LoadScript, { googleMapsApiKey: usePlacesAutocomplete.GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default["default"].createElement(React__default["default"].Fragment, null), style: { width: '100%' } })),
1723
- children));
1724
- } }, restProps)));
1725
- };
1726
-
1727
- // eslint-disable-next-line @typescript-eslint/no-var-requires
1728
- const customParseFormat = require('dayjs/plugin/customParseFormat');
1729
- dayjs__default["default"].extend(customParseFormat);
1730
- // You can give context variables any name
1731
- const [LeadFormProvider, useLeadFormContext, useLeadForm] = form.createFormContext();
1732
- const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
1733
- const { t } = index.useTranslations();
1734
- const initialValues = React.useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
1735
- const validateObj = React.useMemo(() => {
1736
- const InputBlocks = [
1737
- 'TextBlock',
1738
- 'NumberBlock',
1739
- 'EmailBlock',
1740
- 'PhoneBlock',
1741
- 'DateBlock',
1742
- 'CheckboxBlock',
1743
- 'RadioBlock',
1744
- 'DropdownBlock',
1745
- 'PhoneOtpBlock',
1746
- 'WhatsappOtpBlock',
1747
- 'ZaloOtpBlock',
1748
- 'LocationBlock',
1749
- 'TncBlock',
1750
- ];
1751
- // ALL are required and can skip if not touched yet
1752
- const withSharedCheck = (name, cb,
1753
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1754
- block) => {
1755
- return (value) => {
1756
- var _a;
1757
- const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
1758
- if (!formRef.current.isTouched(name))
1759
- return;
1760
- if ((typeof value === 'string' && value.trim() === '') ||
1761
- typeof value === 'undefined' ||
1762
- (Array.isArray(value) && value.length === 0)) {
1763
- return isBLockRequired
1764
- ? t('validator.required')
1765
- : cb === null || cb === void 0 ? void 0 : cb(value);
1766
- }
1767
- return cb === null || cb === void 0 ? void 0 : cb(value);
1768
- };
1769
- };
1770
- return listBlockAdded
1771
- .filter((b) => InputBlocks.includes(b.name))
1772
- .reduce((r, b) => {
1773
- const { name: fieldType, data } = b || {};
1774
- const { value: fieldName, required } = data || {};
1775
- const isRequired = required !== null && required !== void 0 ? required : true;
1776
- if (fieldType === 'NumberBlock') {
1777
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1778
- if (value && isNaN(Number(value))) {
1779
- return t('validator.number');
1780
- }
1781
- }, b) });
1782
- }
1783
- else if (fieldType === 'EmailBlock') {
1784
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1785
- if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
1786
- return t('validator.email');
1787
- }
1788
- if (!value)
1789
- return;
1790
- validatingEmailRef.current = true;
1791
- setTimeout(() => {
1792
- formRef.current.setFieldError(fieldName, 'Validating...');
1793
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1794
- email: value,
1795
- })
1796
- .then((tKey) => {
1797
- if (tKey) {
1798
- formRef.current.setFieldError(fieldName, t(tKey));
1799
- }
1800
- else {
1801
- formRef.current.clearFieldError(fieldName);
1802
- }
1803
- validatingEmailRef.current = false;
1804
- })
1805
- .catch((e) => {
1806
- console.error(e);
1807
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
1808
- validatingEmailRef.current = false;
1809
- });
1810
- }, 200);
1811
- }, b) });
1812
- }
1813
- else if (fieldType === 'PhoneBlock' ||
1814
- fieldType === 'PhoneOtpBlock' ||
1815
- fieldType === 'ZaloOtpBlock' ||
1816
- fieldType === 'WhatsappOtpBlock') {
1817
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1818
- if (value &&
1819
- window.intlTelInputUtils &&
1820
- !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
1821
- return t('validator.phone');
1822
- }
1823
- if (!value)
1824
- return;
1825
- validatingPhoneRef.current = true;
1826
- setTimeout(() => {
1827
- formRef.current.setFieldError(fieldName, 'Validating...');
1828
- if (b.data.singleSubmission) {
1829
- checkUsedPhoneOnlyWithCache(campaignId, value)
1830
- .then((tKey) => {
1831
- if (tKey) {
1832
- formRef.current.setFieldError(fieldName, t(tKey));
1833
- }
1834
- else {
1835
- formRef.current.clearFieldError(fieldName);
1836
- }
1837
- validatingPhoneRef.current = false;
1838
- })
1839
- .catch((err) => {
1840
- console.error(err);
1841
- formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
1842
- validatingPhoneRef.current = false;
1843
- });
1844
- }
1845
- else {
1846
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1847
- phone: value,
1848
- })
1849
- .then((tKey) => {
1850
- if (tKey) {
1851
- formRef.current.setFieldError(fieldName, t(tKey));
1852
- }
1853
- else {
1854
- formRef.current.clearFieldError(fieldName);
1855
- }
1856
- validatingPhoneRef.current = false;
1857
- })
1858
- .catch((e) => {
1859
- console.error(e);
1860
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
1861
- validatingPhoneRef.current = false;
1862
- });
1863
- }
1864
- }, 200);
1865
- }, b) });
1866
- }
1867
- else if (fieldType === 'DateBlock') {
1868
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
1869
- if (!isRequired && !value) {
1870
- return;
1871
- }
1872
- const errMsg = t('validator.dateInvalid');
1873
- const dayInJS = typeof value === 'string'
1874
- ? dayjs__default["default"](value, format, true)
1875
- : dayjs__default["default"](value);
1876
- if (!dayInJS.isValid()) {
1877
- return errMsg;
1878
- }
1879
- }, b) });
1880
- }
1881
- else if (fieldType === 'TncBlock') {
1882
- return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
1883
- if (isRequired && !value) {
1884
- return t('validator.required');
1885
- }
1886
- }, b) });
1887
- }
1888
- else {
1889
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
1890
- }
1891
- }, {});
1892
- }, [listBlockAdded.map((b) => b.name).join(','), format]);
1893
- const form = useLeadForm({
1894
- validateInputOnChange: true,
1895
- validateInputOnBlur: true,
1896
- clearInputErrorOnChange: true,
1897
- validate: validateObj,
1898
- initialValues,
1899
- });
1900
- const formRef = React.useRef(form);
1901
- formRef.current = form;
1902
- return { form, validateObj };
1903
- };
1904
-
3408
+ const SideBarLayout = ({ content }) => {
3409
+ const targets = React.useMemo(() => {
3410
+ const targetDoms = Array.from(document.querySelectorAll('.hc2-sidebar-with-ads,.page-main-col .right-col.f-right,.hhg-lead-sidebar'));
3411
+ targetDoms.forEach((dom) => {
3412
+ if (dom.querySelector('.sidebar-lead-modal-wrapper'))
3413
+ return;
3414
+ const wrapper = document.createElement('div');
3415
+ wrapper.classList.add('sidebar-lead-modal-wrapper');
3416
+ dom.prepend(wrapper);
3417
+ });
3418
+ return targetDoms.map((d) => d.querySelector('.sidebar-lead-modal-wrapper'));
3419
+ }, []);
3420
+ return (React__default["default"].createElement(React__default["default"].Fragment, null, targets.map((target) => ReactDOM.createPortal(content, utils$1.getWrapperDomWithSelector(target, 'sidebar-lead-modal-wrapper')))));
3421
+ };
3422
+
3423
+ const EmptyIcon = (props) => {
3424
+ const { className, style } = props;
3425
+ return (React__default["default"].createElement("svg", { width: "160", height: "160", viewBox: "0 0 160 160", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, style: style },
3426
+ React__default["default"].createElement("path", { d: "M79.9974 113.333C98.4069 113.333 113.331 98.4096 113.331 80.0001C113.331 61.5906 98.4069 46.6667 79.9974 46.6667C61.5879 46.6667 46.6641 61.5906 46.6641 80.0001C46.6641 98.4096 61.5879 113.333 79.9974 113.333Z", fill: "#F44D2C" }),
3427
+ React__default["default"].createElement("path", { d: "M92.434 95.0004C91.7771 95.0004 91.1213 94.7499 90.6194 94.249L65.7521 69.3807C64.7493 68.3779 64.7493 66.7542 65.7521 65.7524C66.7549 64.7507 68.3786 64.7497 69.3804 65.7524L94.2487 90.6208C95.2515 91.6235 95.2515 93.2473 94.2487 94.249C93.7468 94.7499 93.0909 95.0004 92.434 95.0004Z", fill: "white" }),
3428
+ React__default["default"].createElement("path", { d: "M67.5648 95C66.9079 95 66.252 94.7496 65.7501 94.2487C64.7474 93.2459 64.7474 91.6222 65.7501 90.6204L90.6185 65.7521C91.6212 64.7493 93.245 64.7493 94.2467 65.7521C95.2485 66.7549 95.2495 68.3786 94.2467 69.3804L69.3794 94.2487C68.8786 94.7496 68.2217 95 67.5648 95Z", fill: "white" })));
3429
+ };
3430
+
3431
+ const EmptyComponent = ({ onClose, onContinue, }) => {
3432
+ const { t } = index$1.useTranslations();
3433
+ return (React__default["default"].createElement("div", { className: "leadgen-empty" },
3434
+ React__default["default"].createElement("div", { className: "leadgen-empty_body" },
3435
+ React__default["default"].createElement("div", { className: "leadgen-empty_wrapper" },
3436
+ React__default["default"].createElement(EmptyIcon, { className: "leadgen-empty_image" }),
3437
+ React__default["default"].createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
3438
+ React__default["default"].createElement("div", { className: "leadgen-empty_footer" },
3439
+ React__default["default"].createElement(core.Button, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
3440
+ React__default["default"].createElement(core.Button, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
3441
+ };
3442
+
1905
3443
  const SubtitleBlock = ({ children, align, }) => (React__default["default"].createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
1906
3444
 
1907
3445
  const cssInputNotShrink = react.css `
@@ -2228,11 +3766,13 @@ const TextField = (props) => {
2228
3766
  const $focusEl = $textEl.item($textEl.length - 1);
2229
3767
  if ($focusEl) {
2230
3768
  $focusEl.focus();
2231
- $focusEl.scrollIntoView({
2232
- behavior: 'auto',
2233
- block: 'center',
2234
- inline: 'start',
2235
- });
3769
+ setTimeout(() => {
3770
+ $focusEl.scrollIntoView({
3771
+ behavior: 'auto',
3772
+ block: 'center',
3773
+ inline: 'start',
3774
+ });
3775
+ }, 100);
2236
3776
  }
2237
3777
  }, [shrink]);
2238
3778
  React.useEffect(() => {
@@ -2249,13 +3789,13 @@ const ChoiceField = (props) => {
2249
3789
  const TitleBlock = ({ children, align, }) => (React__default["default"].createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
2250
3790
 
2251
3791
  const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, }) => {
2252
- const { t } = index.useTranslations();
3792
+ const { t } = index$1.useTranslations();
2253
3793
  const form = useLeadFormContext();
2254
3794
  const formValues = form.values;
2255
3795
  const labelTuples = React.useMemo(() => {
2256
3796
  return ((index$7.ISO_FORMAT === null || index$7.ISO_FORMAT === void 0 ? void 0 : index$7.ISO_FORMAT[locale]) || index$7.ISO_FORMAT['vi-VN']).dateFormat
2257
3797
  .split('/')
2258
- .map((key) => { var _a; return t((_a = index$8.COMMON_DATE_TRANSLATE_KEY === null || index$8.COMMON_DATE_TRANSLATE_KEY === void 0 ? void 0 : index$8.COMMON_DATE_TRANSLATE_KEY[key]) === null || _a === void 0 ? void 0 : _a.id); });
3798
+ .map((key) => { var _a; return t((_a = index$9.COMMON_DATE_TRANSLATE_KEY === null || index$9.COMMON_DATE_TRANSLATE_KEY === void 0 ? void 0 : index$9.COMMON_DATE_TRANSLATE_KEY[key]) === null || _a === void 0 ? void 0 : _a.id); });
2259
3799
  }, [locale]);
2260
3800
  return (React__default["default"].createElement(React__default["default"].Fragment, null, listBlockAdded.map((b, index) => {
2261
3801
  var _a;
@@ -2298,7 +3838,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2298
3838
  }) },
2299
3839
  React__default["default"].createElement(core.Input.Wrapper, { size: "md", withAsterisk: required, label: placeholder, "data-invalid": !!error, labelProps: { htmlFor: htmlForId }, inputWrapperOrder: ['label', 'input', 'description', 'error'], error: error },
2300
3840
  React__default["default"].createElement("div", { className: "mantine-Input-wrapper" },
2301
- React__default["default"].createElement(index$2.Phone, Object.assign({ className: "mantine-Input-input", name: value, spellCheck: false, type: "tel", placeholder: placeholder,
3841
+ React__default["default"].createElement(index$3.Phone, Object.assign({ className: "mantine-Input-input", name: value, spellCheck: false, type: "tel", placeholder: placeholder,
2302
3842
  // onBlur={(e) => inputOnBlur('tel', e)}
2303
3843
  id: htmlForId, defaultCountry: (locale ? utils.MAPPED_LOCALE[locale] || 'VN' : 'VN'), "data-control": "tel" }, formPhoneInputWrapper))))));
2304
3844
  }
@@ -2314,7 +3854,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2314
3854
  case 'LinkButtonBlock':
2315
3855
  return (React__default["default"].createElement("div", { key: index },
2316
3856
  React__default["default"].createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
2317
- React__default["default"].createElement(index$9.Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
3857
+ React__default["default"].createElement(index$a.Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
2318
3858
  onClose === null || onClose === void 0 ? void 0 : onClose();
2319
3859
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2320
3860
  } }, value))));
@@ -2323,7 +3863,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2323
3863
  isSendMailChimp && (React__default["default"].createElement("div", { style: {
2324
3864
  display: 'none',
2325
3865
  }, "data-name": value + '-mailchimp' })),
2326
- React__default["default"].createElement(index$2.Checkbox.Group, Object.assign({ withAsterisk: required,
3866
+ React__default["default"].createElement(index$3.Checkbox.Group, Object.assign({ withAsterisk: required,
2327
3867
  // className="lead-modal__form-control leadgen-form_field"
2328
3868
  label: placeholder, size: "md", sx: {
2329
3869
  display: 'flex',
@@ -2332,19 +3872,19 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2332
3872
  gap: 8,
2333
3873
  }, inputWrapperOrder: ['label', 'input', 'description', 'error'], inputContainer: (children) => {
2334
3874
  return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2335
- } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$2.Checkbox, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
3875
+ } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$3.Checkbox, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2336
3876
  case 'RadioBlock':
2337
3877
  return (React__default["default"].createElement(ChoiceField, { className: "leadgen-form_radio", key: index },
2338
3878
  isSendMailChimp && (React__default["default"].createElement(core.Input, { type: "hidden", name: value + '-mailchimp', value: isSendMailChimp })),
2339
- React__default["default"].createElement(index$2.Radio.Group, Object.assign({ withAsterisk: required,
3879
+ React__default["default"].createElement(index$3.Radio.Group, Object.assign({ withAsterisk: required,
2340
3880
  // className="lead-modal__form-control leadgen-form_field"
2341
3881
  label: placeholder, size: "md", inputWrapperOrder: ['label', 'input', 'description', 'error'], inputContainer: (children) => {
2342
3882
  return (React__default["default"].createElement("div", { className: "leadgen-choiceContainer" }, children));
2343
- } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$2.Radio, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
3883
+ } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default["default"].createElement(index$3.Radio, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2344
3884
  case 'DropdownBlock':
2345
3885
  return (React__default["default"].createElement(TextField, { shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field", key: index },
2346
3886
  React__default["default"].createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2347
- React__default["default"].createElement(index$2.Select
3887
+ React__default["default"].createElement(index$3.Select
2348
3888
  // className="lead-modal__form-control leadgen-form_field"
2349
3889
  , Object.assign({
2350
3890
  // className="lead-modal__form-control leadgen-form_field"
@@ -2356,7 +3896,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
2356
3896
  const _d = form.getInputProps(`TNC-${id}`), { error } = _d, tncInputProps = tslib_es6.__rest(_d, ["error"]);
2357
3897
  return (React__default["default"].createElement(ChoiceField, { className: "leadgen-form_checkbox", key: id },
2358
3898
  React__default["default"].createElement(core.Input.Wrapper, { error: error },
2359
- React__default["default"].createElement(index$2.Checkbox, Object.assign({ name: 'TNC-' + id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps)))));
3899
+ React__default["default"].createElement(index$3.Checkbox, Object.assign({ name: 'TNC-' + id, label: React__default["default"].createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps)))));
2360
3900
  }
2361
3901
  return null;
2362
3902
  })));
@@ -2422,842 +3962,498 @@ const FormContainer = (_a) => {
2422
3962
  var { title, titleAlign, description, descriptionAlign, className, style, children, header, footer } = _a, restProps = tslib_es6.__rest(_a, ["title", "titleAlign", "description", "descriptionAlign", "className", "style", "children", "header", "footer"]);
2423
3963
  const HeaderContent = (React__default["default"].createElement("div", { className: "leadgen-form_header" },
2424
3964
  React__default["default"].createElement("h2", { title: title, className: "leadgen-title", "data-align": titleAlign }, title),
2425
- !!description && (React__default["default"].createElement("p", { title: description, className: "leadgen-description", "data-align": descriptionAlign, dangerouslySetInnerHTML: { __html: description } }))));
2426
- if (!title && !description) {
2427
- return null;
2428
- }
2429
- return (React__default["default"].createElement(StyledFormContainer, Object.assign({ className: core.clsx(className, 'leadgen-form_container'), style: style }, restProps),
2430
- React__default["default"].createElement("div", { className: "leadgen-form_wrapper" },
2431
- !!header && (React__default["default"].createElement("div", { className: "leadgen-form_scrollable" },
2432
- header,
2433
- HeaderContent,
2434
- React__default["default"].createElement("div", { className: "leadgen-form_body" }, children))),
2435
- !header && (React__default["default"].createElement(React__default["default"].Fragment, null,
2436
- HeaderContent,
2437
- React__default["default"].createElement("div", { className: "leadgen-form_body" }, children))),
2438
- React__default["default"].createElement("div", { className: "leadgen-form_footer" }, footer))));
2439
- };
2440
-
2441
- const StyleHeaderImage = styled__default["default"].div `
2442
- position: relative;
2443
- overflow: hidden;
2444
- width: 100%;
2445
- height: 100%;
2446
- padding-top: ${({ paddingTop }) => paddingTop}%;
2447
- .leadgen-header_image_feature {
2448
- position: absolute;
2449
- inset: 0;
2450
- min-width: 100%;
2451
- min-height: 100%;
2452
- max-width: 100%;
2453
- max-height: 100%;
2454
- object-fit: cover;
2455
- object-position: center;
2456
- }
2457
- `;
2458
- const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
2459
- if (!src) {
2460
- return null;
2461
- }
2462
- return (React__default["default"].createElement(StyleHeaderImage, { paddingTop: (1 / ratio) * 100, className: core.clsx(className, 'leadgen-header_image'), style: style }, index$6.isVideo(src) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true, className: "leadgen-header_image_feature leadgen-header_image_video", src: src })) : (React__default["default"].createElement("img", { src: src, draggable: "false", alt: "", className: "leadgen-header_image_feature leadgen-header_image_image" }))));
2463
- };
2464
-
2465
- const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
2466
- const { primaryColor } = React.useContext(LeadGenContext);
2467
- const { t } = index.useTranslations();
2468
- const phone = otpData.phone;
2469
- const otpType = otpData.type;
2470
- const [otp, setOtp] = React.useState('');
2471
- const [isDirty, setIsDirty] = React.useState(false);
2472
- const [resendTimer, setResendTimer] = React.useState(autoSendWhenOpen ? 0 : 60);
2473
- const inputRef = React.useRef(null);
2474
- const [errorMsg, setErrorMsg] = React.useState();
2475
- const [displayPhone, setDisplayPhone] = React.useState('');
2476
- const formatPhoneNumberIntlRef = React.useRef();
2477
- const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
2478
- React.useEffect(() => {
2479
- (() => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
2480
- var _a;
2481
- if (!formatPhoneNumberIntlRef.current) {
2482
- const res = yield Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('react-phone-number-input')); });
2483
- formatPhoneNumberIntlRef.current = res.formatPhoneNumberIntl;
2484
- }
2485
- setDisplayPhone(((_a = formatPhoneNumberIntlRef.current) === null || _a === void 0 ? void 0 : _a.call(formatPhoneNumberIntlRef, phone)) || phone);
2486
- }))();
2487
- }, [phone]);
2488
- const sendOtp = () => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
2489
- var _a;
2490
- if (!phone) {
2491
- return;
2492
- }
2493
- const res = yield Service.sendSMSOtpLead({
2494
- phone,
2495
- type: otpType,
2496
- });
2497
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2498
- if (respMessage === 'Send sms successfully' ||
2499
- respMessage === 'Send WhatsApp successfully' ||
2500
- respMessage === 'Send Zalo successfully') {
2501
- setResendTimer(60);
2502
- setTimeout(() => {
2503
- if (inputRef.current) {
2504
- inputRef.current.focus();
2505
- inputRef.current.scrollIntoView({ block: 'center' });
2506
- }
2507
- }, 100);
2508
- }
2509
- else if (respMessage === 'This phone number was verified') {
2510
- onSuccess();
2511
- }
2512
- else {
2513
- setErrorMsg(respMessage || 'Something went wrong!');
2514
- // const defaultError = f({ id: 'notification.comment.somethingWrong' })
2515
- // setStatusVerifyOTP('idle')
2516
- // pushNotifications({
2517
- // title: respMessage || defaultError,
2518
- // message: '',
2519
- // type: 'danger',
2520
- // })
2521
- }
2522
- });
2523
- const submitOtp = () => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
2524
- if (!phone || !otp) {
2525
- return;
2526
- }
2527
- setIsSubmitLoading(true);
2528
- const res = yield Service.verifyOtpLead({
2529
- phone,
2530
- otp,
2531
- type: otpType,
2532
- });
2533
- const respMessage = res === null || res === void 0 ? void 0 : res._messages[0];
2534
- if (respMessage === 'Verify successfully' ||
2535
- respMessage === 'Verify WhatsApp OTP sucess' ||
2536
- respMessage === 'Verify Zalo OTP sucess') {
2537
- onSuccess();
2538
- }
2539
- else if (respMessage === 'This phone number was verified') {
2540
- onSuccess();
2541
- }
2542
- else {
2543
- setErrorMsg(respMessage || 'something Wrong');
2544
- // setIsShowError(true)
2545
- // setStatusVerifyOTP('sent')
2546
- // pushNotifications({
2547
- // title: res?._messages[0] || defaultError,
2548
- // message: '',
2549
- // type: 'danger',
2550
- // })
2551
- }
2552
- setIsSubmitLoading(false);
2553
- });
2554
- React.useEffect(() => {
2555
- setTimeout(() => {
2556
- if (resendTimer > 0) {
2557
- setResendTimer((r) => r - 1);
2558
- }
2559
- }, 1000);
2560
- }, [resendTimer]);
2561
- React.useEffect(() => {
2562
- if (autoSendWhenOpen && !resendTimer) {
2563
- sendOtp();
2564
- }
2565
- }, []);
2566
- return (React__default["default"].createElement("form", { onSubmit: (e) => {
2567
- e.preventDefault();
2568
- submitOtp();
2569
- }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
2570
- React__default["default"].createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
2571
- phone: `<strong>${displayPhone}</strong>`,
2572
- }), footer: React__default["default"].createElement(React__default["default"].Fragment, null,
2573
- React__default["default"].createElement(core.Button, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
2574
- React__default["default"].createElement(core.Button, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
2575
- sendOtp();
2576
- }, disabled: !!resendTimer }, t('lead.otp.resend', {
2577
- timer: resendTimer ? ` (${resendTimer}s)` : '',
2578
- }))) },
2579
- React__default["default"].createElement("div", { className: "leadgen-form_inner" },
2580
- React__default["default"].createElement(index$2.Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
2581
- React__default["default"].createElement(index$2.OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
2582
- setIsDirty(true);
2583
- setOtp(v.toString());
2584
- if (isDirty && !v)
2585
- setErrorMsg('OTP is required');
2586
- else
2587
- setErrorMsg(undefined);
2588
- } }))))));
2589
- };
2590
-
2591
- // url: imageBlocks.imageMobile.data.url
2592
- // newTab: imageBlocks.imageMobile.data.newtab
2593
- // image: campaignShow.image
2594
- // imageDestkop: campaignShow.image_desktop
2595
- const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
2596
- LEADGEN_LAYOUT.Fullscreen,
2597
- LEADGEN_LAYOUT.Slider,
2598
- ];
2599
- const LEADGEN_LIMIT_LIGHTBOXB = 6;
2600
- const LEADGEN_SHOW_HEADER = [
2601
- 'LightBoxA',
2602
- 'InlineA',
2603
- LEADGEN_LAYOUT.Sidebar,
2604
- LEADGEN_LAYOUT.Slider,
2605
- ];
2606
- const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2607
- var _a, _b;
2608
- const { primaryColor } = React.useContext(LeadGenContext);
2609
- const { isMobile } = useScreenSize.useScreenSize();
2610
- const [open, setOpen] = React.useState(!!campaignId);
2611
- const [showOtpPhone, setShowOtpPhone] = React.useState(null);
2612
- const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
2613
- const [snap, setSnap] = React.useState(0.8);
2614
- const formRef = React.useRef();
2615
- const onClose = () => {
2616
- if (showOtpPhone) {
2617
- setShowOtpPhone(null);
2618
- }
2619
- else {
2620
- onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2621
- }
2622
- };
2623
- const textBlocks = JSON.parse(extraFields.textBlocks);
2624
- const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
2625
- const actionBlocks = JSON.parse(extraFields.actionBlocks);
2626
- const popUpSubmitText = actionBlocks.submitBlock.data.value;
2627
- const currentPath = location.pathname;
2628
- const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
2629
- const { align: titleAlign } = textBlocks.titleBlock.data || {};
2630
- const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
2631
- const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
2632
- const isLightBox = currentLayout.includes('LightBox');
2633
- const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
2634
- const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
2635
- const isInline = currentLayout.includes('Inline');
2636
- const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
2637
- const isInPage = isInline || isSidebar;
2638
- const isDrawer = isLightBoxB && isMobile;
2639
- const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
2640
- const hasForm = isLightBoxA
2641
- ? listBlockAdded.some((item) => LEADGEN_BLOCK_IN_FORM.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
2642
- : true;
2643
- const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
2644
- const showHeader = !!imageMobile || !!imageDesktop;
2645
- const onlyHeader = !title && !description;
2646
- const showButtonClose = !isInline;
2647
- if (window.innerWidth < 769 &&
2648
- LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
2649
- console.log('😎 Not show fullscreen, slider on mobile ');
3965
+ !!description && (React__default["default"].createElement("p", { title: description, className: "leadgen-description", "data-align": descriptionAlign, dangerouslySetInnerHTML: { __html: description } }))));
3966
+ if (!title && !description) {
3967
+ return null;
3968
+ }
3969
+ return (React__default["default"].createElement(StyledFormContainer, Object.assign({ className: core.clsx(className, 'leadgen-form_container'), style: style }, restProps),
3970
+ React__default["default"].createElement("div", { className: "leadgen-form_wrapper" },
3971
+ !!header && (React__default["default"].createElement("div", { className: "leadgen-form_scrollable" },
3972
+ header,
3973
+ HeaderContent,
3974
+ React__default["default"].createElement("div", { className: "leadgen-form_body" }, children))),
3975
+ !header && (React__default["default"].createElement(React__default["default"].Fragment, null,
3976
+ HeaderContent,
3977
+ React__default["default"].createElement("div", { className: "leadgen-form_body" }, children))),
3978
+ React__default["default"].createElement("div", { className: "leadgen-form_footer" }, footer))));
3979
+ };
3980
+
3981
+ const StyleHeaderImage = styled__default["default"].div `
3982
+ position: relative;
3983
+ overflow: hidden;
3984
+ width: 100%;
3985
+ height: 100%;
3986
+ padding-top: ${({ paddingTop }) => paddingTop}%;
3987
+ .leadgen-header_image_feature {
3988
+ position: absolute;
3989
+ inset: 0;
3990
+ min-width: 100%;
3991
+ min-height: 100%;
3992
+ max-width: 100%;
3993
+ max-height: 100%;
3994
+ object-fit: cover;
3995
+ object-position: center;
3996
+ }
3997
+ `;
3998
+ const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
3999
+ if (!src) {
2650
4000
  return null;
2651
4001
  }
4002
+ return (React__default["default"].createElement(StyleHeaderImage, { paddingTop: (1 / ratio) * 100, className: core.clsx(className, 'leadgen-header_image'), style: style }, index$8.isVideo(src) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true, className: "leadgen-header_image_feature leadgen-header_image_video", src: src })) : (React__default["default"].createElement("img", { src: src, draggable: "false", alt: "", className: "leadgen-header_image_feature leadgen-header_image_image" }))));
4003
+ };
4004
+
4005
+ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
4006
+ const { primaryColor } = React.useContext(LeadGenContext$1);
4007
+ const { t } = index$1.useTranslations();
4008
+ const phone = otpData.phone;
4009
+ const otpType = otpData.type;
4010
+ const [otp, setOtp] = React.useState('');
4011
+ const [isDirty, setIsDirty] = React.useState(false);
4012
+ const [resendTimer, setResendTimer] = React.useState(autoSendWhenOpen ? 0 : 60);
4013
+ const inputRef = React.useRef(null);
4014
+ const [errorMsg, setErrorMsg] = React.useState();
4015
+ const [displayPhone, setDisplayPhone] = React.useState('');
4016
+ const formatPhoneNumberIntlRef = React.useRef();
4017
+ const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
2652
4018
  React.useEffect(() => {
2653
- if (isLightBox || isFullscreen) {
2654
- document.body.classList.add('noscroll');
4019
+ (() => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
4020
+ var _a;
4021
+ if (!formatPhoneNumberIntlRef.current) {
4022
+ const res = yield Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('react-phone-number-input')); });
4023
+ formatPhoneNumberIntlRef.current = res.formatPhoneNumberIntl;
4024
+ }
4025
+ setDisplayPhone(((_a = formatPhoneNumberIntlRef.current) === null || _a === void 0 ? void 0 : _a.call(formatPhoneNumberIntlRef, phone)) || phone);
4026
+ }))();
4027
+ }, [phone]);
4028
+ const sendOtp = () => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
4029
+ var _a;
4030
+ if (!phone) {
4031
+ return;
2655
4032
  }
2656
- if (!window.intlTelInputUtils) {
2657
- require('intl-tel-input/build/js/utils');
4033
+ const res = yield Service.sendSMSOtpLead({
4034
+ phone,
4035
+ type: otpType,
4036
+ });
4037
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4038
+ if (respMessage === 'Send sms successfully' ||
4039
+ respMessage === 'Send WhatsApp successfully' ||
4040
+ respMessage === 'Send Zalo successfully') {
4041
+ setResendTimer(60);
4042
+ setTimeout(() => {
4043
+ if (inputRef.current) {
4044
+ inputRef.current.focus();
4045
+ inputRef.current.scrollIntoView({ block: 'center' });
4046
+ }
4047
+ }, 100);
4048
+ }
4049
+ else if (respMessage === 'This phone number was verified') {
4050
+ onSuccess();
4051
+ }
4052
+ else {
4053
+ setErrorMsg(respMessage || 'Something went wrong!');
4054
+ // const defaultError = f({ id: 'notification.comment.somethingWrong' })
4055
+ // setStatusVerifyOTP('idle')
4056
+ // pushNotifications({
4057
+ // title: respMessage || defaultError,
4058
+ // message: '',
4059
+ // type: 'danger',
4060
+ // })
2658
4061
  }
2659
- clearCacheUsedEmailOrPhone();
2660
- }, []);
2661
- const validatingPhoneRef = React.useRef(false);
2662
- const validatingEmailRef = React.useRef(false);
2663
- const { form, validateObj } = useLeadFormConfig({
2664
- listBlockAdded,
2665
- validatingPhoneRef,
2666
- validatingEmailRef,
2667
- campaignId,
2668
- campaign_subot_id,
2669
- userInfo,
2670
- format: (_a = (index$7.ISO_FORMAT[locale] || index$7.ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
2671
4062
  });
2672
- const middlewareOnSubmit = (e) => {
2673
- e.preventDefault();
2674
- // mark all as touched to allow validation
2675
- const fields = Object.keys(validateObj);
2676
- const fieldStatus = fields.reduce((acc, cur) => {
2677
- acc[cur] = true;
2678
- return acc;
2679
- }, {});
2680
- form.setTouched(fieldStatus);
2681
- if (validatingEmailRef.current || validatingPhoneRef.current) {
4063
+ const submitOtp = () => tslib_es6.__awaiter(void 0, void 0, void 0, function* () {
4064
+ if (!phone || !otp) {
2682
4065
  return;
2683
4066
  }
2684
- setTimeout(() => {
2685
- form.onSubmit((v) => {
2686
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2687
- if (Object.keys(form.errors).length)
2688
- return;
2689
- let newShowOtpPhone = null;
2690
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
2691
- // not submit yet, open otp
2692
- const fieldName = (_b = (_a = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock)) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value;
2693
- if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
2694
- newShowOtpPhone = {
2695
- phone: v[fieldName],
2696
- type: 'phone',
2697
- };
2698
- }
2699
- }
2700
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
2701
- // not submit yet, open otp
2702
- const fieldName = (_e = (_d = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock)) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.value;
2703
- if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
2704
- newShowOtpPhone = {
2705
- phone: v[fieldName],
2706
- type: 'whatsapp',
2707
- };
2708
- }
2709
- }
2710
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
2711
- // not submit yet, open otp
2712
- const fieldName = (_h = (_g = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock)) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.value;
2713
- if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
2714
- newShowOtpPhone = {
2715
- phone: v[fieldName],
2716
- type: 'zalo',
2717
- };
2718
- }
2719
- }
2720
- if (newShowOtpPhone) {
2721
- setIsSubmitLoading(true);
2722
- Service.sendSMSOtpLead(newShowOtpPhone)
2723
- .then((res) => {
2724
- var _a;
2725
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2726
- if (respMessage === 'This phone number was verified') {
2727
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2728
- return;
2729
- }
2730
- setShowOtpPhone(newShowOtpPhone);
2731
- })
2732
- .finally(() => {
2733
- setIsSubmitLoading(false);
2734
- });
2735
- return;
2736
- }
2737
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2738
- })(e);
2739
- }, 100);
2740
- };
2741
- const onOpenChange = (_open) => {
2742
- setOpen(_open);
2743
- if (!_open) {
2744
- setTimeout(() => {
2745
- onClose();
2746
- }, 250);
2747
- }
2748
- };
2749
- const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
2750
- const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
2751
- const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
2752
- const renderAfterImageSizes = imageMobileLoaded &&
2753
- imageDesktopLoaded &&
2754
- (isFullscreen ? imageBackgroundLoaded : true);
2755
- const ButtonSubmit = React.useMemo(() => {
2756
- var _a;
2757
- return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default["default"].createElement(core.Button, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
2758
- }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
2759
- const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
2760
- const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default["default"].createElement(React__default["default"].Fragment, null, LinkButtonBlock.map((item, index) => {
2761
- var _a, _b, _c;
2762
- return (React__default["default"].createElement(core.Button, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
2763
- onClose === null || onClose === void 0 ? void 0 : onClose();
2764
- onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2765
- } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
2766
- })));
2767
- const PopupHeader = showHeader && (React__default["default"].createElement("header", { className: core.clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default["default"].createElement(React__default["default"].Fragment, null,
2768
- React__default["default"].createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
2769
- React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
2770
- const PopupEmpty = showEmpty && (React__default["default"].createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
2771
- const PopupForm = (React__default["default"].createElement(LeadFormProvider, { form: form },
2772
- React__default["default"].createElement("form", { ref: formRef, className: "leadgen-form", onSubmit: middlewareOnSubmit },
2773
- React__default["default"].createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
2774
- React__default["default"].createElement("div", { className: "leadgen-form_inner" },
2775
- React__default["default"].createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
2776
- const PopupOtp = showOtpPhone && (React__default["default"].createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
2777
- setShowOtpPhone(null);
2778
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
2779
- } }));
2780
- const PopupThankYou = showThankyou && (React__default["default"].createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
2781
- const PopupContent = (React__default["default"].createElement("div", { className: core.clsx('leadgen-content', {
2782
- 'leadgen-content_small': limitFieldsLightBoxB,
2783
- }) },
2784
- !headerInsideFormContainer && PopupHeader,
2785
- !onlyHeader && (React__default["default"].createElement("div", { className: "leadgen-inner" },
2786
- PopupThankYou,
2787
- !showThankyou && (React__default["default"].createElement(React__default["default"].Fragment, null,
2788
- PopupOtp,
2789
- PopupEmpty,
2790
- !(showOtpPhone || showEmpty) && PopupForm))))));
2791
- const styleOverlay = React.useMemo(() => {
2792
- let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
2793
- if (isMobile && imageOverlayMobile) {
2794
- styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4067
+ setIsSubmitLoading(true);
4068
+ const res = yield Service.verifyOtpLead({
4069
+ phone,
4070
+ otp,
4071
+ type: otpType,
4072
+ });
4073
+ const respMessage = res === null || res === void 0 ? void 0 : res._messages[0];
4074
+ if (respMessage === 'Verify successfully' ||
4075
+ respMessage === 'Verify WhatsApp OTP sucess' ||
4076
+ respMessage === 'Verify Zalo OTP sucess') {
4077
+ onSuccess();
2795
4078
  }
2796
- if (!isMobile && imageOverlayDesktop) {
2797
- styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4079
+ else if (respMessage === 'This phone number was verified') {
4080
+ onSuccess();
2798
4081
  }
2799
- return styleContent;
2800
- }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
2801
- const PopupWrapper = (React__default["default"].createElement(React__default["default"].Fragment, null,
2802
- React__default["default"].createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
2803
- React__default["default"].createElement("div", { className: core.clsx('leadgen-wrapper', {
2804
- 'leadgen-wrapper_small': limitFieldsLightBoxB,
2805
- }) },
2806
- showButtonClose && (React__default["default"].createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
2807
- PopupContent)));
2808
- const popupContainerClassName = core.clsx('leadgen', `leadgen-${currentLayout}`, {
2809
- 'leadgen-lightbox': isLightBox,
2810
- 'leadgen-inline': isInPage,
2811
- 'leadgen-slider': isSlider,
4082
+ else {
4083
+ setErrorMsg(respMessage || 'something Wrong');
4084
+ // setIsShowError(true)
4085
+ // setStatusVerifyOTP('sent')
4086
+ // pushNotifications({
4087
+ // title: res?._messages[0] || defaultError,
4088
+ // message: '',
4089
+ // type: 'danger',
4090
+ // })
4091
+ }
4092
+ setIsSubmitLoading(false);
2812
4093
  });
2813
- const PopupContainer = isDrawer ? (React__default["default"].createElement(index$a.DrawerComponent, { fadeFromIndex: index$7.ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
2814
- PopupWrapper,
2815
- React__default["default"].createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default["default"].createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
2816
- isFullscreen ? (React__default["default"].createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
2817
- aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
2818
- } })) : null,
2819
- PopupWrapper));
2820
- if (!renderAfterImageSizes)
2821
- return null;
2822
- if (isLightBox || isFullscreen || isSlider) {
2823
- return PopupContainer;
2824
- }
2825
- else if (isSidebar) {
2826
- return React__default["default"].createElement(SideBarLayout, { content: PopupContainer });
2827
- }
2828
- else if (isInline) {
2829
- return (React__default["default"].createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
2830
- }
2831
- return null;
2832
- };
2833
-
2834
- const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
2835
- const currentPath = location.pathname;
2836
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
2837
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
2838
- if (!imageMobileLoaded || !imageDesktopLoaded)
2839
- return null;
2840
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
2841
- currentLayout == 'SkinA' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
2842
- React__default["default"].createElement("div", { className: "le-skin-a-desktop" },
2843
- React__default["default"].createElement("div", { style: { position: 'relative' } },
2844
- React__default["default"].createElement("img", { src: imageDesktop, style: {
2845
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2846
- } }),
2847
- React__default["default"].createElement("a", { style: {
2848
- position: 'absolute',
2849
- top: '75%',
2850
- left: '50%',
2851
- transform: 'translate(-50%, -50%)',
2852
- textAlign: 'center',
2853
- width: 'calc(100% - 15px)',
2854
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2855
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
2856
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
2857
- React__default["default"].createElement("div", { className: "" },
2858
- React__default["default"].createElement("div", { style: { position: 'relative', zIndex: 10000 } },
2859
- React__default["default"].createElement("img", { src: imageDesktop, style: {
2860
- width: '100%',
2861
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2862
- } }),
2863
- React__default["default"].createElement("a", { style: {
2864
- position: 'absolute',
2865
- top: '75%',
2866
- left: '50%',
2867
- transform: 'translate(-50%, -50%)',
2868
- textAlign: 'center',
2869
- width: '100%',
2870
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2871
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2872
- React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
2873
- React__default["default"].createElement("aside", { className: "le-only-mobile" },
2874
- React__default["default"].createElement("div", { className: "le-skin-mobile" },
2875
- React__default["default"].createElement("div", { style: { position: 'relative' } },
2876
- index$6.isVideo(imageMobile) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true },
2877
- React__default["default"].createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default["default"].createElement("img", { src: imageMobile, style: {
2878
- width: '100%',
2879
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
2880
- } })),
2881
- React__default["default"].createElement("a", { style: {
2882
- position: 'absolute',
2883
- top: '82%',
2884
- left: '50%',
2885
- transform: 'translate(-50%, -50%)',
2886
- textAlign: 'center',
2887
- maxWidth: 'calc(100% - 15px)',
2888
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2889
- React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2890
- React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4094
+ React.useEffect(() => {
4095
+ setTimeout(() => {
4096
+ if (resendTimer > 0) {
4097
+ setResendTimer((r) => r - 1);
4098
+ }
4099
+ }, 1000);
4100
+ }, [resendTimer]);
4101
+ React.useEffect(() => {
4102
+ if (autoSendWhenOpen && !resendTimer) {
4103
+ sendOtp();
4104
+ }
4105
+ }, []);
4106
+ return (React__default["default"].createElement("form", { onSubmit: (e) => {
4107
+ e.preventDefault();
4108
+ submitOtp();
4109
+ }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
4110
+ React__default["default"].createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
4111
+ phone: `<strong>${displayPhone}</strong>`,
4112
+ }), footer: React__default["default"].createElement(React__default["default"].Fragment, null,
4113
+ React__default["default"].createElement(core.Button, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
4114
+ React__default["default"].createElement(core.Button, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
4115
+ sendOtp();
4116
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
4117
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
4118
+ }))) },
4119
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4120
+ React__default["default"].createElement(index$3.Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
4121
+ React__default["default"].createElement(index$3.OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
4122
+ setIsDirty(true);
4123
+ setOtp(v.toString());
4124
+ if (isDirty && !v)
4125
+ setErrorMsg('OTP is required');
4126
+ else
4127
+ setErrorMsg(undefined);
4128
+ } }))))));
2891
4129
  };
2892
4130
 
2893
4131
  // url: imageBlocks.imageMobile.data.url
2894
4132
  // newTab: imageBlocks.imageMobile.data.newtab
2895
4133
  // image: campaignShow.image
2896
4134
  // imageDestkop: campaignShow.image_desktop
2897
- const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
2898
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
2899
- if (!imageLoaded)
2900
- return null;
2901
- return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
2902
- React__default["default"].createElement("div", { className: "le-tab-popup" },
2903
- React__default["default"].createElement("div", { style: { position: 'relative' } },
2904
- React__default["default"].createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
2905
- React__default["default"].createElement("img", { className: "js-popup-other-submit", src: image, style: {
2906
- aspectRatio: `${imageWidth}/${imageHeight}`,
2907
- } })),
2908
- React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
2909
- };
2910
-
2911
- // import mockLeadData from './mockLeadData'
2912
- const listCampaignScheduled = [];
2913
- const listCampaignScheduledToActivated = [];
2914
- const listCampaignActiveButExpired = [];
2915
- const listCampaignExcludeSonsored = [];
2916
- const listCampaignDifferentSponsor = [];
2917
- const listCampaignNotDisplayInRangeOfTime = [];
2918
- function isMobile() {
2919
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
2920
- }
2921
- const getShuffleArray = (array) => {
2922
- const newArray = [...array];
2923
- for (let i = newArray.length - 1; i > 0; i--) {
2924
- const j = Math.floor(Math.random() * (i + 1));
2925
- const temp = newArray[i];
2926
- newArray[i] = newArray[j];
2927
- newArray[j] = temp;
2928
- }
2929
- return newArray;
2930
- };
2931
- const getTimeByTimezone = (timeZone = 'UTC') => {
2932
- const date = new Date();
2933
- return new Date(date.toLocaleString('en-US', { timeZone }));
2934
- };
2935
- const parseDateByCampaignTime = (dateStr) => {
2936
- // Format like this: 2023-04-04 00:00:00
2937
- try {
2938
- const [datePart, timePart] = dateStr.split(' ');
2939
- const [year, month, day] = datePart.split('-').map(Number);
2940
- const [hours, minutes, seconds] = timePart.split(':').map(Number);
2941
- /** JavaScript counts months from 0 to 11 */
2942
- return new Date(year, month - 1, day, hours, minutes, seconds);
2943
- }
2944
- catch (err) {
2945
- return null;
2946
- }
2947
- };
2948
- const checkCampaignNowInTimeframe = (c) => {
2949
- var _a;
2950
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2951
- const startedAtStr = c.started_at;
2952
- const endedAtStr = c.ended_at;
2953
- const startedDate = parseDateByCampaignTime(startedAtStr);
2954
- const endedDate = parseDateByCampaignTime(endedAtStr);
2955
- if (!startedDate || !endedDate) {
2956
- return false;
2957
- }
2958
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
2959
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2960
- if (nowWithTimezoneMs <= endedDate.getTime() &&
2961
- nowWithTimezoneMs >= startedDate.getTime()) {
2962
- listCampaignScheduledToActivated.push(c);
2963
- return true;
2964
- }
2965
- return false;
2966
- };
2967
- function checkCampaignActiveButExpireAlready(c) {
2968
- var _a;
2969
- /** Do not setup timeframe for this campaign. No need to check */
2970
- if (c.forever === 1) {
2971
- return true;
2972
- }
2973
- const startedAtStr = c.started_at;
2974
- const endedAtStr = c.ended_at;
2975
- const startedDate = parseDateByCampaignTime(startedAtStr);
2976
- const endedDate = parseDateByCampaignTime(endedAtStr);
2977
- /** Do not setup timeframe for this campaign. No need to check */
2978
- if (!startedDate || !endedDate) {
2979
- return true;
2980
- }
2981
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2982
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
2983
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2984
- /** Check if this expire already, do not show */
2985
- if (nowWithTimezoneMs > endedDate.getTime()) {
2986
- listCampaignActiveButExpired.push(c);
2987
- return false;
2988
- }
2989
- return true;
2990
- }
2991
- function shouldNotDisplayIfExcludeAllSponsors(c) {
2992
- var _a;
2993
- const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
2994
- const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
2995
- if (isSponsored && excludeSponsored) {
2996
- listCampaignExcludeSonsored.push(c);
2997
- return true;
2998
- }
2999
- return false;
3000
- }
3001
- function shouldDisplayWithCurrentSponsor(c) {
4135
+ const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
4136
+ LEADGEN_LAYOUT.Fullscreen,
4137
+ LEADGEN_LAYOUT.Slider,
4138
+ ];
4139
+ const LEADGEN_LIMIT_LIGHTBOXB = 6;
4140
+ const LEADGEN_SHOW_HEADER = [
4141
+ 'LightBoxA',
4142
+ 'InlineA',
4143
+ LEADGEN_LAYOUT.Sidebar,
4144
+ LEADGEN_LAYOUT.Slider,
4145
+ ];
4146
+ const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
3002
4147
  var _a, _b;
3003
- try {
3004
- // TODO: BE will rename `exclude_sponsored_list` later
3005
- const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
3006
- const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
3007
- const dataSponsoredId = Number((_b = document
3008
- .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
3009
- // There is no config for sponsor id and white list, should show as default
3010
- if (!dataSponsoredId ||
3011
- dataSponsoredId <= 0 ||
3012
- whiteListSponsors.length === 0) {
3013
- return true;
4148
+ const { primaryColor } = React.useContext(LeadGenContext$1);
4149
+ const { isMobile } = useScreenSize.useScreenSize();
4150
+ const [open, setOpen] = React.useState(!!campaignId);
4151
+ const [showOtpPhone, setShowOtpPhone] = React.useState(null);
4152
+ const [isSubmitLoading, setIsSubmitLoading] = React.useState(false);
4153
+ const [snap, setSnap] = React.useState(0.8);
4154
+ const formRef = React.useRef();
4155
+ const onClose = () => {
4156
+ if (showOtpPhone) {
4157
+ setShowOtpPhone(null);
3014
4158
  }
3015
- // Check the dataSponsoredId exists in the white list or not.
3016
- const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
3017
- if (isExist) {
3018
- return true;
4159
+ else {
4160
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
3019
4161
  }
3020
- listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
3021
- return false;
3022
- }
3023
- catch (err) {
3024
- // Default is show
3025
- return true;
3026
- }
3027
- }
3028
- const filterFnCampaign = (c) => {
3029
- if (shouldNotDisplayIfExcludeAllSponsors(c)) {
3030
- return false;
3031
- }
3032
- else if (!shouldDisplayWithCurrentSponsor(c)) {
3033
- return false;
3034
- }
3035
- /** Active */
3036
- if (c.formatted_status === 1) {
3037
- return checkCampaignActiveButExpireAlready(c);
3038
- }
3039
- /** Schedule */
3040
- if (c.formatted_status === 0) {
3041
- listCampaignScheduled.push(c);
3042
- return checkCampaignNowInTimeframe(c);
4162
+ };
4163
+ const textBlocks = JSON.parse(extraFields.textBlocks);
4164
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
4165
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
4166
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
4167
+ const currentPath = location.pathname;
4168
+ const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
4169
+ const { align: titleAlign } = textBlocks.titleBlock.data || {};
4170
+ const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
4171
+ const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
4172
+ const isLightBox = currentLayout.includes('LightBox');
4173
+ const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
4174
+ const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
4175
+ const isInline = currentLayout.includes('Inline');
4176
+ const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
4177
+ const isInPage = isInline || isSidebar;
4178
+ const isDrawer = isLightBoxB && isMobile;
4179
+ const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
4180
+ const hasForm = isLightBoxA
4181
+ ? listBlockAdded.some((item) => LEADGEN_BLOCK_INPUT.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
4182
+ : true;
4183
+ const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
4184
+ const showHeader = !!imageMobile || !!imageDesktop;
4185
+ const onlyHeader = !title && !description;
4186
+ const showButtonClose = !isInline;
4187
+ if (window.innerWidth < 769 &&
4188
+ LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
4189
+ console.log('😎 Not show fullscreen, slider on mobile ');
4190
+ return null;
3043
4191
  }
3044
- return false;
3045
- };
3046
- const fillterApprearanceTimeCampaign = (c) => {
3047
- var _a;
3048
- try {
3049
- const isTimeInRange = (currentTime, startTime, endTime) => {
3050
- const startParts = startTime.split(':');
3051
- const endParts = endTime.split(':');
3052
- const startDate = new Date();
3053
- startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
3054
- const endDate = new Date();
3055
- endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
3056
- return currentTime >= startDate && currentTime <= endDate;
3057
- };
3058
- const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
3059
- const startTime = rulesApprValue.startTime;
3060
- const endTime = rulesApprValue.endTime || '23:59';
3061
- if (!startTime) {
3062
- return true;
4192
+ React.useEffect(() => {
4193
+ if (isLightBox || isFullscreen) {
4194
+ document.body.classList.add('noscroll');
3063
4195
  }
3064
- if (isTimeInRange(new Date(), startTime, endTime)) {
3065
- return true;
4196
+ if (!window.intlTelInputUtils) {
4197
+ require('intl-tel-input/build/js/utils');
3066
4198
  }
3067
- listCampaignNotDisplayInRangeOfTime.push(c);
3068
- return false;
3069
- }
3070
- catch (err) {
3071
- return true;
3072
- }
3073
- };
3074
- let timeoutRef = null;
3075
- let LEAD_SCROLL_EVENT = null;
3076
- function clearPassiveEvent() {
3077
- if (timeoutRef) {
3078
- clearTimeout(timeoutRef);
3079
- timeoutRef = null;
3080
- }
3081
- if (LEAD_SCROLL_EVENT) {
3082
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3083
- LEAD_SCROLL_EVENT = null;
3084
- }
3085
- }
3086
- function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
3087
- // clear previous passive event, check for new condition
3088
- clearPassiveEvent();
3089
- const leadCurrentUrl = DEBUG_URL ||
3090
- ('https://' +
3091
- location.hostname +
3092
- location.pathname +
3093
- location.search).toLowerCase();
3094
- fetch(leadApi + 'api/campaign/' + leadSiteId, {
3095
- method: 'POST',
3096
- headers: {
3097
- 'Content-Type': 'application/json',
3098
- },
3099
- body: JSON.stringify({
3100
- url: leadCurrentUrl,
3101
- ga_client_id: miscCookieHelper.getCookie('_ga') || null,
3102
- }),
3103
- })
3104
- .then((response) => {
3105
- return response.json();
3106
- // return mockLeadData || response.json()
3107
- })
3108
- .then((data) => {
3109
- var _a, _b, _c, _d;
3110
- LeadLog('List campagin: ', data);
3111
- LEAD_RESET_VAR();
3112
- if (data._status == 1) {
3113
- const campaigns = (((_b = (_a = data._data) === null || _a === void 0 ? void 0 : _a.campaigns) === null || _b === void 0 ? void 0 : _b.filter(filterFnCampaign)) || []).filter(fillterApprearanceTimeCampaign);
3114
- if (!miscCookieHelper.getCookie('hhg-id')) {
3115
- miscCookieHelper.setCookie('hhg-id', uuid.v1(), {
3116
- domain: '.' + leadDomain,
3117
- path: '/',
3118
- });
3119
- LeadLog('😍 Set HHG ID cookie');
3120
- }
3121
- // getCookie('hhg-id')
3122
- // TODO: HP-534 Filter desktop
3123
- let campaignsDevice = [];
3124
- if (isMobile()) {
3125
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
3126
- }
3127
- else {
3128
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
3129
- }
3130
- LeadLog(`👓 campaignsDevice`, campaignsDevice);
3131
- LeadLog('--listCampaignScheduled', listCampaignScheduled);
3132
- LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
3133
- LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
3134
- LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
3135
- LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
3136
- LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
3137
- // Check links
3138
- let listLinksObj = campaignsDevice
3139
- .map((i, index) => i.targets
3140
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
3141
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3142
- .flat(1);
3143
- // Check list link match current href
3144
- listLinksObj = listLinksObj.filter((i) => {
3145
- var _a;
3146
- const target = new URL(String(i.target).toLowerCase());
3147
- if (i.option == 'exact_match')
3148
- // FOR TEST LOCAL:
3149
- // return Boolean(location.pathname === target.pathname)
3150
- return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
3151
- if (i.option == 'start_with') {
3152
- // FOR TEST LOCAL:
3153
- // if (location.pathname.includes(target.pathname)) {
3154
- if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
3155
- const listExcluding = i.sub_target
3156
- .filter((i) => i.option == 'excluding')
3157
- .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
3158
- return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
3159
- }
3160
- else {
3161
- return false;
3162
- }
3163
- }
3164
- });
3165
- // Check tags
3166
- const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
3167
- const listTags = listMetaTag.map((i) => i.content);
3168
- let listCampaignHasTag = [];
3169
- let listTagsObj = [];
3170
- if (listTags && listTags.length) {
3171
- listCampaignHasTag = campaignsDevice
3172
- .map((i, index) => i.targets
3173
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
3174
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3175
- .flat(1);
3176
- listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
3177
- }
3178
- const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
3179
- const cookieKeys = document.cookie
3180
- .split('; ')
3181
- .map((i) => i.split('=')[0]);
3182
- const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
3183
- LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
3184
- const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
3185
- LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
3186
- const listCampaignSubmitedClosed = [
3187
- ...listCampaignCodeSubmited,
3188
- ...listCampaignCodeClosed,
3189
- ];
3190
- const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
3191
- const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
3192
- return !hasSubmited;
3193
- });
3194
- const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
3195
- // .sort(
3196
- // (a, b) =>
3197
- // (listCampaignValid[a.campaignIndex]?.score || 0) -
3198
- // (listCampaignValid[b.campaignIndex]?.score || 0),
3199
- // )
3200
- LeadLog('--listCampaignValid : ', listCampaignValid);
3201
- if (listCampaignValid && listCampaignValid.length) {
3202
- const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
3203
- LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
3204
- const { rules } = CAMPAIGN_SHOW;
3205
- // CHECK RULE TRIGGER POPUP
3206
- const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
3207
- LeadLog(`timeoutRule`, timeoutRule);
3208
- const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
3209
- LeadLog(`scrollRule`, scrollRule);
3210
- let impressionAction = 'TIME';
3211
- if (Number.isInteger(timeoutRule)) {
3212
- impressionAction = 'TIME';
3213
- LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
3214
- timeoutRef = setTimeout(() => {
3215
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3216
- }, timeoutRule * 1000);
4199
+ clearCacheUsedEmailOrPhone();
4200
+ }, []);
4201
+ const validatingPhoneRef = React.useRef(false);
4202
+ const validatingEmailRef = React.useRef(false);
4203
+ const { form, validateObj } = useLeadFormConfig({
4204
+ listBlockAdded,
4205
+ validatingPhoneRef,
4206
+ validatingEmailRef,
4207
+ campaignId,
4208
+ campaign_subot_id,
4209
+ userInfo,
4210
+ format: (_a = (index$7.ISO_FORMAT[locale] || index$7.ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
4211
+ });
4212
+ const onFocus = (e) => {
4213
+ const target = e.target;
4214
+ target.scrollIntoView({
4215
+ block: 'center',
4216
+ inline: 'nearest',
4217
+ behavior: 'auto',
4218
+ });
4219
+ };
4220
+ const middlewareOnSubmit = (e) => {
4221
+ e.preventDefault();
4222
+ // mark all as touched to allow validation
4223
+ const fields = Object.keys(validateObj);
4224
+ const fieldStatus = fields.reduce((acc, cur) => {
4225
+ acc[cur] = true;
4226
+ return acc;
4227
+ }, {});
4228
+ form.setTouched(fieldStatus);
4229
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
4230
+ return;
4231
+ }
4232
+ setTimeout(() => {
4233
+ form.onSubmit((v) => {
4234
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4235
+ if (Object.keys(form.errors).length)
4236
+ return;
4237
+ let newShowOtpPhone = null;
4238
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
4239
+ // not submit yet, open otp
4240
+ 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;
4241
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
4242
+ newShowOtpPhone = {
4243
+ phone: v[fieldName],
4244
+ type: 'phone',
4245
+ };
4246
+ }
3217
4247
  }
3218
- if (Number.isInteger(scrollRule)) {
3219
- impressionAction = 'SCROLL';
3220
- LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
3221
- const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
3222
- document.querySelector('body');
3223
- const pct = $p.getBoundingClientRect().top;
3224
- const pb = $p.offsetHeight;
3225
- LeadLog(`👓 Element check scroll: `, $p);
3226
- LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
3227
- const wt = window.pageYOffset || document.documentElement.scrollTop;
3228
- let percent = 0;
3229
- if (wt >= pct) {
3230
- percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
3231
- }
3232
- LeadLog('---Scroll', percent, scrollRule);
3233
- // TODO: CHECK FOOTER HEIGHT
3234
- if (percent >= scrollRule) {
3235
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3236
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
4248
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
4249
+ // not submit yet, open otp
4250
+ 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;
4251
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
4252
+ newShowOtpPhone = {
4253
+ phone: v[fieldName],
4254
+ type: 'whatsapp',
4255
+ };
4256
+ }
4257
+ }
4258
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
4259
+ // not submit yet, open otp
4260
+ 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;
4261
+ if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
4262
+ newShowOtpPhone = {
4263
+ phone: v[fieldName],
4264
+ type: 'zalo',
4265
+ };
4266
+ }
4267
+ }
4268
+ if (newShowOtpPhone) {
4269
+ setIsSubmitLoading(true);
4270
+ Service.sendSMSOtpLead(newShowOtpPhone)
4271
+ .then((res) => {
4272
+ var _a;
4273
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4274
+ if (respMessage === 'This phone number was verified') {
4275
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4276
+ return;
3237
4277
  }
3238
- };
3239
- window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
3240
- passive: true,
4278
+ setShowOtpPhone(newShowOtpPhone);
4279
+ })
4280
+ .finally(() => {
4281
+ setIsSubmitLoading(false);
3241
4282
  });
4283
+ return;
3242
4284
  }
3243
- }
3244
- else {
3245
- LeadLog('🚧 No lead campaigns on current URL, tags');
3246
- }
4285
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4286
+ })(e);
4287
+ }, 100);
4288
+ };
4289
+ const onOpenChange = (_open) => {
4290
+ setOpen(_open);
4291
+ if (!_open) {
4292
+ setTimeout(() => {
4293
+ onClose();
4294
+ }, 250);
3247
4295
  }
3248
- })
3249
- .catch((err) => {
3250
- LeadLog(`Lead error: `, err);
4296
+ };
4297
+ const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
4298
+ const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
4299
+ const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
4300
+ const renderAfterImageSizes = imageMobileLoaded &&
4301
+ imageDesktopLoaded &&
4302
+ (isFullscreen ? imageBackgroundLoaded : true);
4303
+ const ButtonSubmit = React.useMemo(() => {
4304
+ var _a;
4305
+ return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default["default"].createElement(core.Button, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
4306
+ }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
4307
+ const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
4308
+ const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default["default"].createElement(React__default["default"].Fragment, null, LinkButtonBlock.map((item, index) => {
4309
+ var _a, _b, _c;
4310
+ return (React__default["default"].createElement(core.Button, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
4311
+ onClose === null || onClose === void 0 ? void 0 : onClose();
4312
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
4313
+ } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
4314
+ })));
4315
+ const PopupHeader = showHeader && (React__default["default"].createElement("header", { className: core.clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default["default"].createElement(React__default["default"].Fragment, null,
4316
+ React__default["default"].createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
4317
+ React__default["default"].createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
4318
+ const PopupEmpty = showEmpty && (React__default["default"].createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
4319
+ const PopupForm = (React__default["default"].createElement(LeadFormProvider, { form: form },
4320
+ React__default["default"].createElement("form", { ref: formRef, className: "leadgen-form", onFocus: onFocus, onSubmit: middlewareOnSubmit },
4321
+ React__default["default"].createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
4322
+ React__default["default"].createElement("div", { className: "leadgen-form_inner" },
4323
+ React__default["default"].createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
4324
+ const PopupOtp = showOtpPhone && (React__default["default"].createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
4325
+ setShowOtpPhone(null);
4326
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
4327
+ } }));
4328
+ const PopupThankYou = showThankyou && (React__default["default"].createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
4329
+ const PopupContent = (React__default["default"].createElement("div", { className: core.clsx('leadgen-content', {
4330
+ 'leadgen-content_small': limitFieldsLightBoxB,
4331
+ }) },
4332
+ !headerInsideFormContainer && PopupHeader,
4333
+ !onlyHeader && (React__default["default"].createElement("div", { className: "leadgen-inner" },
4334
+ PopupThankYou,
4335
+ !showThankyou && (React__default["default"].createElement(React__default["default"].Fragment, null,
4336
+ PopupOtp,
4337
+ PopupEmpty,
4338
+ !(showOtpPhone || showEmpty) && PopupForm))))));
4339
+ const styleOverlay = React.useMemo(() => {
4340
+ let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
4341
+ if (isMobile && imageOverlayMobile) {
4342
+ styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4343
+ }
4344
+ if (!isMobile && imageOverlayDesktop) {
4345
+ styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4346
+ }
4347
+ return styleContent;
4348
+ }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
4349
+ const PopupWrapper = (React__default["default"].createElement(React__default["default"].Fragment, null,
4350
+ React__default["default"].createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
4351
+ React__default["default"].createElement("div", { className: core.clsx('leadgen-wrapper', {
4352
+ 'leadgen-wrapper_small': limitFieldsLightBoxB,
4353
+ }) },
4354
+ showButtonClose && (React__default["default"].createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
4355
+ PopupContent)));
4356
+ const popupContainerClassName = core.clsx('leadgen', `leadgen-${currentLayout}`, {
4357
+ 'leadgen-lightbox': isLightBox,
4358
+ 'leadgen-inline': isInPage,
4359
+ 'leadgen-slider': isSlider,
3251
4360
  });
3252
- }
3253
- const LeadLog = (...params) => {
3254
- if (process.env.NODE_ENV !== 'production' ||
3255
- (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
3256
- process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
3257
- (typeof localStorage !== 'undefined' &&
3258
- localStorage.getItem('hhg_debug') === 'true')) {
3259
- console.log(...params);
4361
+ const PopupContainer = isDrawer ? (React__default["default"].createElement(index$b.DrawerComponent, { fadeFromIndex: index$7.ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
4362
+ PopupWrapper,
4363
+ React__default["default"].createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default["default"].createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
4364
+ isFullscreen ? (React__default["default"].createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
4365
+ aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
4366
+ } })) : null,
4367
+ PopupWrapper));
4368
+ if (!renderAfterImageSizes)
4369
+ return null;
4370
+ if (isLightBox || isFullscreen || isSlider) {
4371
+ return PopupContainer;
4372
+ }
4373
+ else if (isSidebar) {
4374
+ return React__default["default"].createElement(SideBarLayout, { content: PopupContainer });
3260
4375
  }
4376
+ else if (isInline) {
4377
+ return (React__default["default"].createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
4378
+ }
4379
+ return null;
4380
+ };
4381
+
4382
+ const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
4383
+ const currentPath = location.pathname;
4384
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
4385
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
4386
+ if (!imageMobileLoaded || !imageDesktopLoaded)
4387
+ return null;
4388
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
4389
+ currentLayout == 'SkinA' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4390
+ React__default["default"].createElement("div", { className: "le-skin-a-desktop" },
4391
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
4392
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
4393
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4394
+ } }),
4395
+ React__default["default"].createElement("a", { style: {
4396
+ position: 'absolute',
4397
+ top: '75%',
4398
+ left: '50%',
4399
+ transform: 'translate(-50%, -50%)',
4400
+ textAlign: 'center',
4401
+ width: 'calc(100% - 15px)',
4402
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4403
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
4404
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default["default"].createElement("aside", { className: "le-only-desktop" },
4405
+ React__default["default"].createElement("div", { className: "" },
4406
+ React__default["default"].createElement("div", { style: { position: 'relative', zIndex: 10000 } },
4407
+ React__default["default"].createElement("img", { src: imageDesktop, style: {
4408
+ width: '100%',
4409
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4410
+ } }),
4411
+ React__default["default"].createElement("a", { style: {
4412
+ position: 'absolute',
4413
+ top: '75%',
4414
+ left: '50%',
4415
+ transform: 'translate(-50%, -50%)',
4416
+ textAlign: 'center',
4417
+ width: '100%',
4418
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4419
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4420
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
4421
+ React__default["default"].createElement("aside", { className: "le-only-mobile" },
4422
+ React__default["default"].createElement("div", { className: "le-skin-mobile" },
4423
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
4424
+ index$8.isVideo(imageMobile) ? (React__default["default"].createElement("video", { muted: true, autoPlay: true, loop: true },
4425
+ React__default["default"].createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default["default"].createElement("img", { src: imageMobile, style: {
4426
+ width: '100%',
4427
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
4428
+ } })),
4429
+ React__default["default"].createElement("a", { style: {
4430
+ position: 'absolute',
4431
+ top: '82%',
4432
+ left: '50%',
4433
+ transform: 'translate(-50%, -50%)',
4434
+ textAlign: 'center',
4435
+ maxWidth: 'calc(100% - 15px)',
4436
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4437
+ React__default["default"].createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4438
+ React__default["default"].createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4439
+ };
4440
+
4441
+ // url: imageBlocks.imageMobile.data.url
4442
+ // newTab: imageBlocks.imageMobile.data.newtab
4443
+ // image: campaignShow.image
4444
+ // imageDestkop: campaignShow.image_desktop
4445
+ const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
4446
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
4447
+ if (!imageLoaded)
4448
+ return null;
4449
+ return (React__default["default"].createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
4450
+ React__default["default"].createElement("div", { className: "le-tab-popup" },
4451
+ React__default["default"].createElement("div", { style: { position: 'relative' } },
4452
+ React__default["default"].createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
4453
+ React__default["default"].createElement("img", { className: "js-popup-other-submit", src: image, style: {
4454
+ aspectRatio: `${imageWidth}/${imageHeight}`,
4455
+ } })),
4456
+ React__default["default"].createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3261
4457
  };
3262
4458
 
3263
4459
  function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
@@ -3273,7 +4469,7 @@ function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
3273
4469
  }
3274
4470
  const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, showEmpty, setShowEmpty, userInfo, }) => {
3275
4471
  var _a, _b;
3276
- const { apiUrl, siteDomain } = React.useContext(LeadGenContext);
4472
+ const { apiUrl, siteDomain } = React.useContext(LeadGenContext$1);
3277
4473
  React.useEffect(() => {
3278
4474
  const gaCookie = miscCookieHelper.getCookie('_ga') || null;
3279
4475
  fetch(`${apiUrl}api/campaign/${code}/impression`, {
@@ -3668,7 +4864,7 @@ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, primaryColor
3668
4864
  leadStartTimeRef.current = Date.now();
3669
4865
  }
3670
4866
  }, [showCampaign]);
3671
- return (React__default["default"].createElement(LeadGenContext.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
4867
+ return (React__default["default"].createElement(LeadGenContext$1.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
3672
4868
  React__default["default"].createElement(translationsContext.TranslationsContext.Provider, { value: { locale, values: getTranslations(locale) } }, children ? (React__default["default"].createElement(Component, { campaign: showCampaign, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, setShowThankyou: setShowThankyou, locale: locale, showEmpty: showEmpty, setShowEmpty: setShowEmpty, userInfo: userInfo }, children)) : (React__default["default"].createElement(core.Portal, { target: utils$1.getPopupWrapperDom() },
3673
4869
  React__default["default"].createElement(core.Box, { sx: { position: 'fixed', zIndex: index$7.ZINDEX_SSO - 9e6 } },
3674
4870
  React__default["default"].createElement(core.Transition, { mounted: Boolean(((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1'), transition: "fade", duration: 600, timingFunction: "ease" }, (styles) => {
@@ -3689,3 +4885,4 @@ LeadGen.OtpForm = OtpBlock$1;
3689
4885
  LeadGen.Close = Close.Close;
3690
4886
 
3691
4887
  exports.LeadGen = LeadGen;
4888
+ exports.LeadGenSubscriptionBox = LeadGenSubscriptionBox;