@hhgtech/hhg-components 1.28.79 → 1.28.81

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 (309) hide show
  1. package/build/Close-371dc7d6.js +29 -0
  2. package/build/adapters.js +14 -14
  3. package/build/babyGrowth.js +77 -77
  4. package/build/cache.js +3 -3
  5. package/build/care.js +17 -17
  6. package/build/components.js +55 -55
  7. package/build/{constants-8023e54c.js → constants-8c5b5a61.js} +2 -2
  8. package/build/{constants-4e3b8eea.js → constants-a82fd7a4.js} +2 -2
  9. package/build/constants.js +3 -3
  10. package/build/{core-5ccd5f28.js → core-8a2194ba.js} +2 -2
  11. package/build/{dataTransform-e07e040d.js → dataTransform-b2c8970e.js} +1 -1
  12. package/build/ecom.js +6 -6
  13. package/build/esm/Close-c8578459.js +7 -0
  14. package/build/esm/adapters.js +14 -14
  15. package/build/esm/babyGrowth.js +78 -78
  16. package/build/esm/cache.js +3 -3
  17. package/build/esm/care.js +17 -17
  18. package/build/esm/components.js +55 -55
  19. package/build/esm/{constants-4ea5ae41.js → constants-8a771ad9.js} +2 -2
  20. package/build/esm/{constants-328aaf66.js → constants-b2c68b93.js} +2 -2
  21. package/build/esm/constants.js +3 -3
  22. package/build/esm/{core-c8dca256.js → core-73fb353f.js} +2 -2
  23. package/build/esm/{dataTransform-66574912.js → dataTransform-d998d2e7.js} +1 -1
  24. package/build/esm/ecom.js +6 -6
  25. package/build/esm/footer.js +19 -19
  26. package/build/esm/gAssets.js +4 -4
  27. package/build/esm/{getDynamicHealthTool-d1509b7d.js → getDynamicHealthTool-0cbbb8c4.js} +4 -4
  28. package/build/esm/{getSocialList-a1af3491.js → getSocialList-a5495771.js} +2 -2
  29. package/build/esm/hooks.js +17 -17
  30. package/build/esm/i18n.js +2 -2
  31. package/build/esm/i18nV2.js +2 -2
  32. package/build/esm/{index-219dd023.js → index-11e5eb5b.js} +1 -1
  33. package/build/esm/{index-80a1ccbd.js → index-1bd362f6.js} +2 -2
  34. package/build/esm/{index-6d0db6db.js → index-1c26d0a2.js} +47 -43
  35. package/build/esm/{index-8bd363fa.js → index-25679ac7.js} +29 -29
  36. package/build/esm/{index-4c09a22b.js → index-2b274bca.js} +2 -2
  37. package/build/esm/{index-f2e62740.js → index-4193d039.js} +2 -2
  38. package/build/esm/{index-d4998039.js → index-57ac9922.js} +4 -4
  39. package/build/esm/{index-b8ea5a23.js → index-58f6cd4c.js} +8 -8
  40. package/build/esm/{index-2aa3b49f.js → index-5df6602b.js} +9 -9
  41. package/build/esm/{index-5e669834.js → index-644cb2d0.js} +3 -3
  42. package/build/esm/{index-34c718a9.js → index-6457f5ee.js} +13 -13
  43. package/build/esm/{index-9de0216f.js → index-686fc3c3.js} +2 -2
  44. package/build/esm/{index-91eacfa6.js → index-7c7c041c.js} +1 -1
  45. package/build/esm/{index-95da4552.js → index-818a2c8b.js} +5 -5
  46. package/build/esm/{index-5a4f0130.js → index-8789543a.js} +10 -10
  47. package/build/esm/{index-6b9e9cd1.js → index-950e8dd9.js} +5 -5
  48. package/build/esm/{index-191caa64.js → index-b90eea09.js} +2 -2
  49. package/build/esm/{index-3abc2ca4.js → index-c4c8c952.js} +2 -2
  50. package/build/esm/{index-84d11205.js → index-cba45b6d.js} +6 -6
  51. package/build/esm/{index-dc498320.js → index-d849bbd4.js} +9 -9
  52. package/build/esm/{index-a0e6fe5a.js → index-dde90310.js} +9 -9
  53. package/build/esm/{index-611c21bf.js → index-e95289e3.js} +2 -2
  54. package/build/esm/{index-68780c19.js → index-ed188bb1.js} +4 -4
  55. package/build/esm/{index-41561634.js → index-f7917d15.js} +3 -3
  56. package/build/esm/{index-6c13160b.js → index-fdb8322b.js} +2 -2
  57. package/build/esm/index.js +69 -68
  58. package/build/esm/{index.styled-007a7d61.js → index.styled-039b3964.js} +2 -2
  59. package/build/esm/{index.styles-ea8ece6c.js → index.styles-d2f89af8.js} +6 -6
  60. package/build/esm/lead/components/close.d.ts +9 -0
  61. package/build/esm/lead/components/context.d.ts +35 -0
  62. package/build/esm/lead/components/description.d.ts +3 -0
  63. package/build/esm/lead/components/form/fields/index.d.ts +10 -0
  64. package/build/esm/lead/components/form/fields/index.styles.d.ts +8 -0
  65. package/build/esm/lead/components/form/fields/locationBlock.d.ts +6 -0
  66. package/build/esm/lead/components/form/fields/subtitleBlock.d.ts +5 -0
  67. package/build/esm/lead/components/form/fields/titleBlock.d.ts +5 -0
  68. package/build/esm/lead/components/form/formContext.d.ts +12 -0
  69. package/build/esm/lead/components/form/index.d.ts +10 -0
  70. package/build/esm/lead/components/form/index.styles.d.ts +15 -0
  71. package/build/esm/lead/components/heading.d.ts +3 -0
  72. package/build/esm/lead/components/index.d.ts +12 -0
  73. package/build/esm/lead/components/otpBlock/index.d.ts +9 -0
  74. package/build/esm/lead/components/otpBlock/index.styles.d.ts +13 -0
  75. package/build/esm/lead/components/thankyou.d.ts +4 -0
  76. package/build/esm/lead/index.d.ts +18 -2
  77. package/build/esm/lead.js +836 -221
  78. package/build/esm/mantine.js +19 -19
  79. package/build/esm/misc.js +17 -17
  80. package/build/esm/navigation.js +34 -34
  81. package/build/esm/onboardingV2.js +29 -29
  82. package/build/esm/pwg.js +18 -18
  83. package/build/esm/{routing-519f014d.js → routing-621fd8e3.js} +2 -2
  84. package/build/esm/subot.js +20 -20
  85. package/build/esm/together.js +33 -32
  86. package/build/esm/{types-a6c6c403.js → types-4a0f1a27.js} +13 -13
  87. package/build/esm/{types-28a9c748.js → types-ba4d2f85.js} +30 -34
  88. package/build/esm/types.js +1 -1
  89. package/build/esm/{useCategory-a6a5af27.js → useCategory-ddad4950.js} +5 -5
  90. package/build/esm/{useHealthToolCache-683560a0.js → useHealthToolCache-1388cb53.js} +2 -2
  91. package/build/esm/{usePlacesAutocomplete-17fceeb6.js → usePlacesAutocomplete-a5ad4aec.js} +1 -1
  92. package/build/esm/{useTranslations-23fdfbc6.js → useTranslations-e495c7f4.js} +1 -1
  93. package/build/esm/{utils-b5c85238.js → utils-241a19fc.js} +1 -1
  94. package/build/esm/{utils-ed2b6b73.js → utils-3cf2dc87.js} +4 -4
  95. package/build/esm/{utils-dad13492.js → utils-5d206543.js} +6 -6
  96. package/build/esm/vaccination.js +24 -24
  97. package/build/footer.js +19 -19
  98. package/build/gAssets.js +4 -4
  99. package/build/{getDynamicHealthTool-def1121e.js → getDynamicHealthTool-55dda645.js} +4 -4
  100. package/build/{getSocialList-e60c0877.js → getSocialList-cdaa32f1.js} +2 -2
  101. package/build/hooks.js +17 -17
  102. package/build/i18n.js +1 -1
  103. package/build/i18nV2.js +1 -1
  104. package/build/{index-59e6ab87.js → index-0527509e.js} +3 -3
  105. package/build/{index-043ebe63.js → index-0683191b.js} +2 -2
  106. package/build/{index-73797cf1.js → index-0f2ce01e.js} +46 -42
  107. package/build/{index-f06ce46a.js → index-14986caf.js} +2 -2
  108. package/build/{index-01ed5223.js → index-1e5a1e13.js} +4 -4
  109. package/build/{index-ce679f9a.js → index-20e6996f.js} +2 -2
  110. package/build/{index-42566468.js → index-23fbb6b8.js} +9 -9
  111. package/build/{index-c52d0489.js → index-28ec77c2.js} +2 -2
  112. package/build/{index-cbeab4a6.js → index-3f5506d6.js} +1 -1
  113. package/build/{index-3f272096.js → index-4817b299.js} +2 -2
  114. package/build/{index-c4aae21d.js → index-4f78e046.js} +1 -1
  115. package/build/{index-4d4699ec.js → index-531792ba.js} +5 -5
  116. package/build/{index-cc24bf8a.js → index-590bf6af.js} +3 -3
  117. package/build/{index-991334f4.js → index-69bf5288.js} +2 -2
  118. package/build/{index-641337b8.js → index-7133dcfc.js} +8 -8
  119. package/build/{index-35f2808a.js → index-73233fa8.js} +4 -4
  120. package/build/{index-815f4bdb.js → index-791ab78c.js} +2 -2
  121. package/build/{index-cdad6882.js → index-8a75e074.js} +9 -9
  122. package/build/{index-e023f4f1.js → index-aaf3efa9.js} +10 -10
  123. package/build/{index-fdc31354.js → index-cd910555.js} +2 -2
  124. package/build/{index-fbf70389.js → index-d0d87437.js} +13 -13
  125. package/build/{index-2a7a1ff0.js → index-e4b6789d.js} +29 -29
  126. package/build/{index-dba46a36.js → index-e590e194.js} +9 -9
  127. package/build/{index-be1aaf60.js → index-ef7ec870.js} +4 -4
  128. package/build/{index-fa31a970.js → index-f99a192e.js} +6 -6
  129. package/build/index.js +113 -112
  130. package/build/{index.styled-c00771d3.js → index.styled-d7310859.js} +2 -2
  131. package/build/{index.styles-e837a685.js → index.styles-c8c7fed9.js} +5 -5
  132. package/build/lead/components/close.d.ts +9 -0
  133. package/build/lead/components/context.d.ts +35 -0
  134. package/build/lead/components/description.d.ts +3 -0
  135. package/build/lead/components/form/fields/index.d.ts +10 -0
  136. package/build/lead/components/form/fields/index.styles.d.ts +8 -0
  137. package/build/lead/components/form/fields/locationBlock.d.ts +6 -0
  138. package/build/lead/components/form/fields/subtitleBlock.d.ts +5 -0
  139. package/build/lead/components/form/fields/titleBlock.d.ts +5 -0
  140. package/build/lead/components/form/formContext.d.ts +12 -0
  141. package/build/lead/components/form/index.d.ts +10 -0
  142. package/build/lead/components/form/index.styles.d.ts +15 -0
  143. package/build/lead/components/heading.d.ts +3 -0
  144. package/build/lead/components/index.d.ts +12 -0
  145. package/build/lead/components/otpBlock/index.d.ts +9 -0
  146. package/build/lead/components/otpBlock/index.styles.d.ts +13 -0
  147. package/build/lead/components/thankyou.d.ts +4 -0
  148. package/build/lead/index.d.ts +18 -2
  149. package/build/lead.js +859 -244
  150. package/build/mantine.js +17 -17
  151. package/build/misc.js +17 -17
  152. package/build/navigation.js +34 -34
  153. package/build/onboardingV2.js +28 -28
  154. package/build/pwg.js +18 -18
  155. package/build/{routing-6c762e84.js → routing-88fd2091.js} +2 -2
  156. package/build/subot.js +20 -20
  157. package/build/together.js +33 -32
  158. package/build/{types-ef54c184.js → types-15f81b78.js} +13 -13
  159. package/build/{types-4f6c5fb8.js → types-c7fb28e5.js} +656 -660
  160. package/build/types.js +1 -1
  161. package/build/{useCategory-746e7249.js → useCategory-0088ed13.js} +5 -5
  162. package/build/{useHealthToolCache-2c0db73c.js → useHealthToolCache-50505451.js} +2 -2
  163. package/build/{usePlacesAutocomplete-6601cd7e.js → usePlacesAutocomplete-21ca4da6.js} +1 -1
  164. package/build/{useTranslations-4804b349.js → useTranslations-4270da1c.js} +1 -1
  165. package/build/{utils-09717f21.js → utils-05be4163.js} +1 -1
  166. package/build/{utils-0ff62762.js → utils-dfa0103c.js} +4 -4
  167. package/build/{utils-e7e35048.js → utils-eb2dac71.js} +5 -5
  168. package/build/vaccination.js +24 -24
  169. package/package.json +1 -1
  170. /package/build/{BMI_BOYS.percentile.monthly-67b45bc7.js → BMI_BOYS.percentile.monthly-4276d4a3.js} +0 -0
  171. /package/build/{BMI_BOYS.percentile.weekly-8efa4b63.js → BMI_BOYS.percentile.weekly-47277d32.js} +0 -0
  172. /package/build/{BMI_BOYS.percentile.yearly-465e6d4b.js → BMI_BOYS.percentile.yearly-132e4c6a.js} +0 -0
  173. /package/build/{BMI_BOYS.zscore.monthly-1d53737c.js → BMI_BOYS.zscore.monthly-a8871e0a.js} +0 -0
  174. /package/build/{BMI_BOYS.zscore.weekly-087f544d.js → BMI_BOYS.zscore.weekly-ae61a4ec.js} +0 -0
  175. /package/build/{BMI_BOYS.zscore.yearly-98a8df14.js → BMI_BOYS.zscore.yearly-068ecb81.js} +0 -0
  176. /package/build/{BMI_GIRLS.percentile.monthly-b6536309.js → BMI_GIRLS.percentile.monthly-71356da3.js} +0 -0
  177. /package/build/{BMI_GIRLS.percentile.weekly-af6cb628.js → BMI_GIRLS.percentile.weekly-78b3e5e9.js} +0 -0
  178. /package/build/{BMI_GIRLS.percentile.yearly-0aac9851.js → BMI_GIRLS.percentile.yearly-db9a067f.js} +0 -0
  179. /package/build/{BMI_GIRLS.zscore.monthly-7d88f50c.js → BMI_GIRLS.zscore.monthly-7f8db7d2.js} +0 -0
  180. /package/build/{BMI_GIRLS.zscore.weekly-54e4c51b.js → BMI_GIRLS.zscore.weekly-b8b1e57f.js} +0 -0
  181. /package/build/{BMI_GIRLS.zscore.yearly-06f436be.js → BMI_GIRLS.zscore.yearly-b5389ef2.js} +0 -0
  182. /package/build/{ChevronDown-dfb37b0e.js → ChevronDown-35c9b69f.js} +0 -0
  183. /package/build/{HEAD CIRCUM_BOYS.percentile.monthly-97c28a58.js → HEAD CIRCUM_BOYS.percentile.monthly-c2ad06fe.js} +0 -0
  184. /package/build/{HEAD CIRCUM_BOYS.percentile.weekly-0c97fd9c.js → HEAD CIRCUM_BOYS.percentile.weekly-1c31ecf6.js} +0 -0
  185. /package/build/{HEAD CIRCUM_BOYS.percentile.yearly-54275f5b.js → HEAD CIRCUM_BOYS.percentile.yearly-2423e199.js} +0 -0
  186. /package/build/{HEAD CIRCUM_BOYS.zscore.monthly-49735c17.js → HEAD CIRCUM_BOYS.zscore.monthly-920bfcfa.js} +0 -0
  187. /package/build/{HEAD CIRCUM_BOYS.zscore.weekly-8aaa695d.js → HEAD CIRCUM_BOYS.zscore.weekly-7cc02110.js} +0 -0
  188. /package/build/{HEAD CIRCUM_BOYS.zscore.yearly-da262754.js → HEAD CIRCUM_BOYS.zscore.yearly-9ad50e51.js} +0 -0
  189. /package/build/{HEAD CIRCUM_GIRLS.percentile.monthly-2243ecfe.js → HEAD CIRCUM_GIRLS.percentile.monthly-1bb577eb.js} +0 -0
  190. /package/build/{HEAD CIRCUM_GIRLS.percentile.weekly-04cd2e1d.js → HEAD CIRCUM_GIRLS.percentile.weekly-2f389f82.js} +0 -0
  191. /package/build/{HEAD CIRCUM_GIRLS.percentile.yearly-d63e7c9f.js → HEAD CIRCUM_GIRLS.percentile.yearly-6971c79c.js} +0 -0
  192. /package/build/{HEAD CIRCUM_GIRLS.zscore.monthly-81c68d98.js → HEAD CIRCUM_GIRLS.zscore.monthly-84851484.js} +0 -0
  193. /package/build/{HEAD CIRCUM_GIRLS.zscore.weekly-a0e98c08.js → HEAD CIRCUM_GIRLS.zscore.weekly-536bb4b1.js} +0 -0
  194. /package/build/{HEAD CIRCUM_GIRLS.zscore.yearly-d0d6cbcc.js → HEAD CIRCUM_GIRLS.zscore.yearly-5a321cdb.js} +0 -0
  195. /package/build/{HEIGHT_BOYS.percentile.monthly-d69e7e60.js → HEIGHT_BOYS.percentile.monthly-4d34c8eb.js} +0 -0
  196. /package/build/{HEIGHT_BOYS.percentile.weekly-08b91789.js → HEIGHT_BOYS.percentile.weekly-c4eaf8f5.js} +0 -0
  197. /package/build/{HEIGHT_BOYS.percentile.yearly-0c17152c.js → HEIGHT_BOYS.percentile.yearly-cffc4c3f.js} +0 -0
  198. /package/build/{HEIGHT_BOYS.zscore.monthly-c2793872.js → HEIGHT_BOYS.zscore.monthly-00085607.js} +0 -0
  199. /package/build/{HEIGHT_BOYS.zscore.weekly-708f14ff.js → HEIGHT_BOYS.zscore.weekly-7883cc26.js} +0 -0
  200. /package/build/{HEIGHT_BOYS.zscore.yearly-a7076fa2.js → HEIGHT_BOYS.zscore.yearly-044f928d.js} +0 -0
  201. /package/build/{HEIGHT_GIRLS.percentile.monthly-8cb300b6.js → HEIGHT_GIRLS.percentile.monthly-b49d9899.js} +0 -0
  202. /package/build/{HEIGHT_GIRLS.percentile.weekly-efd17aae.js → HEIGHT_GIRLS.percentile.weekly-133dc801.js} +0 -0
  203. /package/build/{HEIGHT_GIRLS.percentile.yearly-4e02aa34.js → HEIGHT_GIRLS.percentile.yearly-53ac9934.js} +0 -0
  204. /package/build/{HEIGHT_GIRLS.zscore.monthly-eeec3e4e.js → HEIGHT_GIRLS.zscore.monthly-f1e2c9e5.js} +0 -0
  205. /package/build/{HEIGHT_GIRLS.zscore.weekly-9f2d5de0.js → HEIGHT_GIRLS.zscore.weekly-e35af9c0.js} +0 -0
  206. /package/build/{HEIGHT_GIRLS.zscore.yearly-e5bad371.js → HEIGHT_GIRLS.zscore.yearly-68ea54ae.js} +0 -0
  207. /package/build/{Subot-48b9baf6.js → Subot-a43074dc.js} +0 -0
  208. /package/build/{Visible-c1268da8.js → Visible-9be25cf7.js} +0 -0
  209. /package/build/{WEIGHT_BOYS.percentile.monthly-92cac8bb.js → WEIGHT_BOYS.percentile.monthly-940f3601.js} +0 -0
  210. /package/build/{WEIGHT_BOYS.percentile.weekly-cef0861e.js → WEIGHT_BOYS.percentile.weekly-aac85e21.js} +0 -0
  211. /package/build/{WEIGHT_BOYS.percentile.yearly-f7a67820.js → WEIGHT_BOYS.percentile.yearly-bd866c8b.js} +0 -0
  212. /package/build/{WEIGHT_BOYS.zscore.monthly-c44320f9.js → WEIGHT_BOYS.zscore.monthly-b0dd909a.js} +0 -0
  213. /package/build/{WEIGHT_BOYS.zscore.weekly-fd0ee996.js → WEIGHT_BOYS.zscore.weekly-d48a630e.js} +0 -0
  214. /package/build/{WEIGHT_BOYS.zscore.yearly-1ffe914a.js → WEIGHT_BOYS.zscore.yearly-5c51401c.js} +0 -0
  215. /package/build/{WEIGHT_GIRLS.percentile.monthly-8c509873.js → WEIGHT_GIRLS.percentile.monthly-430e43a5.js} +0 -0
  216. /package/build/{WEIGHT_GIRLS.percentile.weekly-8acc8c12.js → WEIGHT_GIRLS.percentile.weekly-7fd17b87.js} +0 -0
  217. /package/build/{WEIGHT_GIRLS.percentile.yearly-52d175e3.js → WEIGHT_GIRLS.percentile.yearly-77248d52.js} +0 -0
  218. /package/build/{WEIGHT_GIRLS.zscore.monthly-20dc4379.js → WEIGHT_GIRLS.zscore.monthly-576a278b.js} +0 -0
  219. /package/build/{WEIGHT_GIRLS.zscore.weekly-8e70083a.js → WEIGHT_GIRLS.zscore.weekly-eb305041.js} +0 -0
  220. /package/build/{WEIGHT_GIRLS.zscore.yearly-3241a1bf.js → WEIGHT_GIRLS.zscore.yearly-4bfdbd5b.js} +0 -0
  221. /package/build/{animation-693dcf31.js → animation-b70285be.js} +0 -0
  222. /package/build/{cookieHelper-51fe8b9c.js → cookieHelper-3d181027.js} +0 -0
  223. /package/build/esm/{BMI_BOYS.percentile.monthly-30b47425.js → BMI_BOYS.percentile.monthly-72af05b9.js} +0 -0
  224. /package/build/esm/{BMI_BOYS.percentile.weekly-dc18a954.js → BMI_BOYS.percentile.weekly-7b5bc7bf.js} +0 -0
  225. /package/build/esm/{BMI_BOYS.percentile.yearly-46570f22.js → BMI_BOYS.percentile.yearly-64cddf60.js} +0 -0
  226. /package/build/esm/{BMI_BOYS.zscore.monthly-0c249adc.js → BMI_BOYS.zscore.monthly-b301ee71.js} +0 -0
  227. /package/build/esm/{BMI_BOYS.zscore.weekly-aec3c7f6.js → BMI_BOYS.zscore.weekly-93edb3b9.js} +0 -0
  228. /package/build/esm/{BMI_BOYS.zscore.yearly-a690e4e7.js → BMI_BOYS.zscore.yearly-870ec8cb.js} +0 -0
  229. /package/build/esm/{BMI_GIRLS.percentile.monthly-a93aa923.js → BMI_GIRLS.percentile.monthly-444a0cea.js} +0 -0
  230. /package/build/esm/{BMI_GIRLS.percentile.weekly-8464b56f.js → BMI_GIRLS.percentile.weekly-579ef36e.js} +0 -0
  231. /package/build/esm/{BMI_GIRLS.percentile.yearly-dd28a8e3.js → BMI_GIRLS.percentile.yearly-e7e95b67.js} +0 -0
  232. /package/build/esm/{BMI_GIRLS.zscore.monthly-f70006ce.js → BMI_GIRLS.zscore.monthly-c74b30d4.js} +0 -0
  233. /package/build/esm/{BMI_GIRLS.zscore.weekly-7337b4b1.js → BMI_GIRLS.zscore.weekly-ff5439b5.js} +0 -0
  234. /package/build/esm/{BMI_GIRLS.zscore.yearly-c3fa5e19.js → BMI_GIRLS.zscore.yearly-91f40e82.js} +0 -0
  235. /package/build/esm/{ChevronDown-ec19197d.js → ChevronDown-4f335914.js} +0 -0
  236. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.monthly-0c7fc386.js → HEAD CIRCUM_BOYS.percentile.monthly-a5c9fcc0.js} +0 -0
  237. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.weekly-41d4ec43.js → HEAD CIRCUM_BOYS.percentile.weekly-35c77652.js} +0 -0
  238. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.yearly-fd423c7c.js → HEAD CIRCUM_BOYS.percentile.yearly-fbcc57f9.js} +0 -0
  239. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.monthly-9b146551.js → HEAD CIRCUM_BOYS.zscore.monthly-0e8ca1c8.js} +0 -0
  240. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.weekly-57cb8c81.js → HEAD CIRCUM_BOYS.zscore.weekly-f02c2a1e.js} +0 -0
  241. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.yearly-4d1f2139.js → HEAD CIRCUM_BOYS.zscore.yearly-9c033f16.js} +0 -0
  242. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.monthly-630afc45.js → HEAD CIRCUM_GIRLS.percentile.monthly-eed7f867.js} +0 -0
  243. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.weekly-cb82686c.js → HEAD CIRCUM_GIRLS.percentile.weekly-7777e546.js} +0 -0
  244. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.yearly-3fa87019.js → HEAD CIRCUM_GIRLS.percentile.yearly-4c50522e.js} +0 -0
  245. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.monthly-c16b14e5.js → HEAD CIRCUM_GIRLS.zscore.monthly-9770f280.js} +0 -0
  246. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.weekly-2e8dc488.js → HEAD CIRCUM_GIRLS.zscore.weekly-562619b5.js} +0 -0
  247. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.yearly-3376dc6e.js → HEAD CIRCUM_GIRLS.zscore.yearly-b44dacc2.js} +0 -0
  248. /package/build/esm/{HEIGHT_BOYS.percentile.monthly-75afa773.js → HEIGHT_BOYS.percentile.monthly-3db479a3.js} +0 -0
  249. /package/build/esm/{HEIGHT_BOYS.percentile.weekly-635561f4.js → HEIGHT_BOYS.percentile.weekly-e856d473.js} +0 -0
  250. /package/build/esm/{HEIGHT_BOYS.percentile.yearly-cf442ef0.js → HEIGHT_BOYS.percentile.yearly-719a1dc2.js} +0 -0
  251. /package/build/esm/{HEIGHT_BOYS.zscore.monthly-b62bbbdc.js → HEIGHT_BOYS.zscore.monthly-1615ee8b.js} +0 -0
  252. /package/build/esm/{HEIGHT_BOYS.zscore.weekly-b32358ff.js → HEIGHT_BOYS.zscore.weekly-f6a72564.js} +0 -0
  253. /package/build/esm/{HEIGHT_BOYS.zscore.yearly-5269cf8f.js → HEIGHT_BOYS.zscore.yearly-b54b4974.js} +0 -0
  254. /package/build/esm/{HEIGHT_GIRLS.percentile.monthly-571c1f33.js → HEIGHT_GIRLS.percentile.monthly-af8ea2ff.js} +0 -0
  255. /package/build/esm/{HEIGHT_GIRLS.percentile.weekly-74645237.js → HEIGHT_GIRLS.percentile.weekly-ce92f884.js} +0 -0
  256. /package/build/esm/{HEIGHT_GIRLS.percentile.yearly-fcb535d5.js → HEIGHT_GIRLS.percentile.yearly-6cdb5569.js} +0 -0
  257. /package/build/esm/{HEIGHT_GIRLS.zscore.monthly-11f4b03a.js → HEIGHT_GIRLS.zscore.monthly-df4407a2.js} +0 -0
  258. /package/build/esm/{HEIGHT_GIRLS.zscore.weekly-d32f79ca.js → HEIGHT_GIRLS.zscore.weekly-8bfdc3ee.js} +0 -0
  259. /package/build/esm/{HEIGHT_GIRLS.zscore.yearly-24d2056e.js → HEIGHT_GIRLS.zscore.yearly-ef455afa.js} +0 -0
  260. /package/build/esm/{Subot-8b616873.js → Subot-8065fe17.js} +0 -0
  261. /package/build/esm/{Visible-f33957d7.js → Visible-c56edd4b.js} +0 -0
  262. /package/build/esm/{WEIGHT_BOYS.percentile.monthly-06e8279e.js → WEIGHT_BOYS.percentile.monthly-24370701.js} +0 -0
  263. /package/build/esm/{WEIGHT_BOYS.percentile.weekly-6da891d7.js → WEIGHT_BOYS.percentile.weekly-44275cd1.js} +0 -0
  264. /package/build/esm/{WEIGHT_BOYS.percentile.yearly-60af91dd.js → WEIGHT_BOYS.percentile.yearly-a49353df.js} +0 -0
  265. /package/build/esm/{WEIGHT_BOYS.zscore.monthly-5c74895f.js → WEIGHT_BOYS.zscore.monthly-d97eabc2.js} +0 -0
  266. /package/build/esm/{WEIGHT_BOYS.zscore.weekly-123acce9.js → WEIGHT_BOYS.zscore.weekly-3cf5a18b.js} +0 -0
  267. /package/build/esm/{WEIGHT_BOYS.zscore.yearly-eff30911.js → WEIGHT_BOYS.zscore.yearly-5a3046ec.js} +0 -0
  268. /package/build/esm/{WEIGHT_GIRLS.percentile.monthly-293eee77.js → WEIGHT_GIRLS.percentile.monthly-03efd9b9.js} +0 -0
  269. /package/build/esm/{WEIGHT_GIRLS.percentile.weekly-3a629d81.js → WEIGHT_GIRLS.percentile.weekly-d463bd90.js} +0 -0
  270. /package/build/esm/{WEIGHT_GIRLS.percentile.yearly-34dbff44.js → WEIGHT_GIRLS.percentile.yearly-a025cd00.js} +0 -0
  271. /package/build/esm/{WEIGHT_GIRLS.zscore.monthly-acc6961d.js → WEIGHT_GIRLS.zscore.monthly-308e54a1.js} +0 -0
  272. /package/build/esm/{WEIGHT_GIRLS.zscore.weekly-d9eeff9f.js → WEIGHT_GIRLS.zscore.weekly-cd8f8697.js} +0 -0
  273. /package/build/esm/{WEIGHT_GIRLS.zscore.yearly-1c204293.js → WEIGHT_GIRLS.zscore.yearly-18797797.js} +0 -0
  274. /package/build/esm/{animation-fa81f721.js → animation-67521349.js} +0 -0
  275. /package/build/esm/{cookieHelper-144d1108.js → cookieHelper-13c63d93.js} +0 -0
  276. /package/build/esm/{index-bd70c317.js → index-59c86484.js} +0 -0
  277. /package/build/esm/{index-01ad05b9.js → index-9152f8d9.js} +0 -0
  278. /package/build/esm/{index-dc65ac91.js → index-957e35cd.js} +0 -0
  279. /package/build/esm/{isProduction-1651fbe3.js → isProduction-d1236464.js} +0 -0
  280. /package/build/esm/{localizeNumberFormat-ad09362f.js → localizeNumberFormat-3603a0ca.js} +0 -0
  281. /package/build/esm/{normalizeLink-b0251b2e.js → normalizeLink-68e4b7c2.js} +0 -0
  282. /package/build/esm/{number-1cc61dbd.js → number-4cb25850.js} +0 -0
  283. /package/build/esm/{paths-b77bbdfe.js → paths-80c13f3b.js} +0 -0
  284. /package/build/esm/{theme-a3e5a214.js → theme-740e5383.js} +0 -0
  285. /package/build/esm/{translationsContext-b0ae072f.js → translationsContext-6753b7e0.js} +0 -0
  286. /package/build/esm/{tslib.es6-0f26fe74.js → tslib.es6-e4528e01.js} +0 -0
  287. /package/build/esm/{types-ff572579.js → types-d2d4593a.js} +0 -0
  288. /package/build/esm/{useIsInit-33e3bd4a.js → useIsInit-e8ff71b5.js} +0 -0
  289. /package/build/esm/{useOutsideClick-38645332.js → useOutsideClick-e7f8d48c.js} +0 -0
  290. /package/build/esm/{useScrollbarSize-2da03206.js → useScrollbarSize-4ba46362.js} +0 -0
  291. /package/build/esm/{useUniqueId-b04da7b3.js → useUniqueId-da5ec3cc.js} +0 -0
  292. /package/build/esm/{utils-59d61ca1.js → utils-3f2b2c0e.js} +0 -0
  293. /package/build/{index-87fa99ae.js → index-ac51574b.js} +0 -0
  294. /package/build/{index-f707c820.js → index-dc42d5be.js} +0 -0
  295. /package/build/{index-dc8be5b5.js → index-ee3c6276.js} +0 -0
  296. /package/build/{isProduction-f6ac6db3.js → isProduction-8fedbbbc.js} +0 -0
  297. /package/build/{localizeNumberFormat-cc6ff0f2.js → localizeNumberFormat-98053a9b.js} +0 -0
  298. /package/build/{normalizeLink-a75dcce6.js → normalizeLink-28eb3fff.js} +0 -0
  299. /package/build/{number-38620770.js → number-8a9a5294.js} +0 -0
  300. /package/build/{paths-cdef268e.js → paths-a6876b7b.js} +0 -0
  301. /package/build/{theme-fde2b656.js → theme-d33ee285.js} +0 -0
  302. /package/build/{translationsContext-5d32e21d.js → translationsContext-3ab3c2d1.js} +0 -0
  303. /package/build/{tslib.es6-3b38ec78.js → tslib.es6-b1dd0cb3.js} +0 -0
  304. /package/build/{types-eb12b071.js → types-bbcf56cb.js} +0 -0
  305. /package/build/{useIsInit-6aed4c96.js → useIsInit-94af7860.js} +0 -0
  306. /package/build/{useOutsideClick-b7334761.js → useOutsideClick-7fc14cb6.js} +0 -0
  307. /package/build/{useScrollbarSize-29a463ce.js → useScrollbarSize-f3f2ab9f.js} +0 -0
  308. /package/build/{useUniqueId-7c6ca6f9.js → useUniqueId-b5ddf270.js} +0 -0
  309. /package/build/{utils-25a8cc7b.js → utils-22cfc5b3.js} +0 -0
package/build/esm/lead.js CHANGED
@@ -1,47 +1,50 @@
1
- import { _ as __rest, a as __awaiter } from './tslib.es6-0f26fe74.js';
2
- import React__default, { createContext, useState, useEffect, useMemo, useRef, useContext } from 'react';
1
+ import { _ as __rest, a as __awaiter } from './tslib.es6-e4528e01.js';
2
+ import React__default, { createContext, useMemo, useRef, useState, useEffect, useContext } from 'react';
3
3
  import debounce from 'lodash/debounce';
4
- import { v1 } from 'uuid';
5
- import { B as Button } from './index-6c13160b.js';
6
- import { C as CommonGAssets } from './index-3abc2ca4.js';
7
- import { Portal, Box, Transition, Overlay } from '@mantine/core';
8
- import { T as Text } from './index-219dd023.js';
9
- import './index.styles-ea8ece6c.js';
10
- import { S as Select, d as Checkbox, c as Input, R as Radio, P as Phone, N as NumberInput } from './index-b8ea5a23.js';
11
- import './constants-328aaf66.js';
12
- import './Subot-8b616873.js';
13
- import './utils-ed2b6b73.js';
14
- import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-59d61ca1.js';
15
- import { D as DatePicker } from './index-95da4552.js';
16
- import { t as theme } from './theme-a3e5a214.js';
17
- import { T as TranslationsContext } from './translationsContext-b0ae072f.js';
4
+ import { createFormContext } from '@mantine/form';
5
+ import { u as useTranslations } from './useTranslations-e495c7f4.js';
6
+ import { T as Text } from './index-11e5eb5b.js';
7
+ import { createStyles, Box, Portal, Transition, Overlay } from '@mantine/core';
8
+ import './index.styles-d2f89af8.js';
9
+ import { S as Select, d as Checkbox, c as Input, R as Radio, P as Phone, N as NumberInput, B as Button$1 } from './index-58f6cd4c.js';
10
+ import { B as Button } from './index-fdb8322b.js';
11
+ import { C as CommonGAssets } from './index-c4c8c952.js';
12
+ import './constants-b2c68b93.js';
13
+ import './Subot-8065fe17.js';
14
+ import './utils-3cf2dc87.js';
15
+ import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-3f2b2c0e.js';
16
+ import { D as DatePicker } from './index-818a2c8b.js';
17
+ import { t as theme } from './theme-740e5383.js';
18
+ import { T as TranslationsContext } from './translationsContext-6753b7e0.js';
18
19
  import 'string-format';
19
20
  import '@mantine/hooks';
20
- import './index-9de0216f.js';
21
- import './utils-dad13492.js';
22
- import './index.styled-007a7d61.js';
23
- import './index-bd70c317.js';
24
- import { M as MAPPED_LOCALE } from './utils-b5c85238.js';
21
+ import './index-686fc3c3.js';
22
+ import './utils-5d206543.js';
23
+ import './index.styled-039b3964.js';
24
+ import './index-59c86484.js';
25
+ import { M as MAPPED_LOCALE } from './utils-241a19fc.js';
25
26
  import '@mantine/dates';
26
- import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-17fceeb6.js';
27
- import { createFormContext } from '@mantine/form';
28
- import { u as useTranslations } from './useTranslations-23fdfbc6.js';
29
- import { H as Heading } from './index-611c21bf.js';
27
+ import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-a5ad4aec.js';
28
+ import { H as Heading$1 } from './index-e95289e3.js';
29
+ import { v1 } from 'uuid';
30
30
  import { createPortal } from 'react-dom';
31
- import { g as getCookie, s as setCookie } from './cookieHelper-144d1108.js';
31
+ import { g as getCookie, s as setCookie } from './cookieHelper-13c63d93.js';
32
32
  import dayjs from 'dayjs';
33
- import './isProduction-1651fbe3.js';
33
+ import { C as Close } from './Close-c8578459.js';
34
34
  import 'styled-components';
35
- import './animation-fa81f721.js';
35
+ import './animation-67521349.js';
36
36
  import 'react-keyed-flatten-children';
37
37
  import '@hhgtech/icons/other';
38
38
  import '@mantine/carousel';
39
39
  import 'classnames';
40
- import './useUniqueId-b04da7b3.js';
40
+ import './useUniqueId-da5ec3cc.js';
41
41
  import '@hhgtech/icons/core';
42
+ import './isProduction-d1236464.js';
42
43
  import 'date-fns/locale';
43
44
  import 'slugify';
44
45
 
46
+ const LeadGenComponentContext = createContext({});
47
+
45
48
  const CAMPAIGN_TARGET_TYPE = { LINKS: 1, TAGS: 2 };
46
49
  let LEAD_API = 'https://dev.leadgen.hellobacsi.com/';
47
50
  const LEAD_DEVICE_TYPE = {
@@ -106,25 +109,790 @@ const LEAD_LOCALE_DATA = {
106
109
  countryCodeNumber: 91,
107
110
  },
108
111
  };
109
- const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
110
- function LEAD_RESET_VAR() {
111
- // LEAD_CURRENT_URL = location.href.toLowerCase();
112
- LEAD_CURRENT_URL =
113
- 'https://' + location.hostname + location.pathname + location.search;
114
- }
115
- const LEAD_TIMEZONE_DATA = {
116
- 1: 'Asia/Ho_Chi_Minh',
117
- 10: 'Asia/Ho_Chi_Minh',
118
- 11: 'Asia/Ho_Chi_Minh',
119
- 12: 'Asia/Ho_Chi_Minh',
120
- 2: 'Asia/Jakarta',
121
- 3: 'Asia/Bangkok',
122
- 4: 'Asia/Phnom_Penh',
123
- 5: 'Asia/Kuala_Lumpur',
124
- 6: 'Asia/Taipei',
125
- 7: 'Asia/Yangon',
126
- 8: 'Asia/Kolkata',
127
- 9: 'Asia/Manila', // Philippines / Filipinos Site
112
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
113
+ function LEAD_RESET_VAR() {
114
+ // LEAD_CURRENT_URL = location.href.toLowerCase();
115
+ LEAD_CURRENT_URL =
116
+ 'https://' + location.hostname + location.pathname + location.search;
117
+ }
118
+ const LEAD_TIMEZONE_DATA = {
119
+ 1: 'Asia/Ho_Chi_Minh',
120
+ 10: 'Asia/Ho_Chi_Minh',
121
+ 11: 'Asia/Ho_Chi_Minh',
122
+ 12: 'Asia/Ho_Chi_Minh',
123
+ 2: 'Asia/Jakarta',
124
+ 3: 'Asia/Bangkok',
125
+ 4: 'Asia/Phnom_Penh',
126
+ 5: 'Asia/Kuala_Lumpur',
127
+ 6: 'Asia/Taipei',
128
+ 7: 'Asia/Yangon',
129
+ 8: 'Asia/Kolkata',
130
+ 9: 'Asia/Manila', // Philippines / Filipinos Site
131
+ };
132
+
133
+ class Store {
134
+ constructor() {
135
+ this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
136
+ this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
137
+ }
138
+ }
139
+ const leadStore = new Store();
140
+
141
+ const leadApi = {
142
+ call(_a) {
143
+ var { url, data = undefined } = _a, config = __rest(_a, ["url", "data"]);
144
+ config.body = JSON.stringify(data);
145
+ config.headers = {
146
+ 'Content-Type': 'application/json',
147
+ };
148
+ return fetch(`${leadStore.apiLeadUrl}${url}`, config)
149
+ .then((res) => res.json())
150
+ .catch(() => ({}));
151
+ },
152
+ };
153
+ const subotApi = {
154
+ call(_a) {
155
+ var { url, data } = _a, config = __rest(_a, ["url", "data"]);
156
+ config.body = JSON.stringify(data);
157
+ config.headers = {
158
+ 'Content-Type': 'application/json',
159
+ };
160
+ return fetch(`${leadStore.apiSubotUrl}${url}`, config)
161
+ .then((res) => res.json())
162
+ .catch(() => ({}));
163
+ },
164
+ };
165
+ const campaignGetById = (id) => {
166
+ return leadApi.call({
167
+ url: `api/internal/campaign/${id}`,
168
+ method: 'get',
169
+ });
170
+ };
171
+ const validateEmailOrPhoneOnLeadGen = ({ campaign_id, email, phone, }) => {
172
+ let phoneToSend = phone;
173
+ // Remove the '0' part. Logic from Back to check between Subot and Lead with different format
174
+ if (phoneToSend && phoneToSend.startsWith('0')) {
175
+ phoneToSend = phoneToSend.substring(1);
176
+ }
177
+ return leadApi.call({
178
+ url: 'api/subot-campaign/check',
179
+ method: 'post',
180
+ data: {
181
+ campaign_id,
182
+ email,
183
+ phone: phoneToSend,
184
+ },
185
+ });
186
+ };
187
+ const validateEmailOrPhoneOnSubot = ({ bot_id, email, phone, }) => {
188
+ let phoneToSend = phone;
189
+ // Remove the '0' part. Logic from Back to check between Subot and Lead with different format
190
+ if (phoneToSend && phoneToSend.startsWith('0')) {
191
+ phoneToSend = phoneToSend.substring(1);
192
+ }
193
+ return subotApi.call({
194
+ url: 'frontend/api/subot-campaign/check',
195
+ method: 'post',
196
+ data: {
197
+ bot_id,
198
+ email,
199
+ phone: phoneToSend,
200
+ },
201
+ });
202
+ };
203
+ const sendSMSOtpLead = ({ phone, type, }) => {
204
+ return leadApi.call({
205
+ url: type === 'phone' ? 'api/sms/otp' : 'api/sms/whatsapp_otp',
206
+ method: 'post',
207
+ data: {
208
+ // The type Whatsapp do not remove the '+'
209
+ phone_number: type === 'phone' ? phone.replace('+', '') : phone,
210
+ },
211
+ });
212
+ };
213
+ const verifyOtpLead = ({ phone, otp, type, }) => {
214
+ return leadApi.call({
215
+ url: type === 'phone' ? 'api/sms/verify' : 'api/sms/whatsapp_verify',
216
+ method: 'post',
217
+ data: {
218
+ // The type Whatsapp do not remove the '+'
219
+ otp_code: otp,
220
+ phone_number: type === 'phone' ? phone.replace('+', '') : phone,
221
+ },
222
+ });
223
+ };
224
+ const Service = {
225
+ campaignGetById,
226
+ validateEmailOrPhoneOnSubot,
227
+ validateEmailOrPhoneOnLeadGen,
228
+ sendSMSOtpLead,
229
+ verifyOtpLead,
230
+ };
231
+
232
+ const checkUsedEmailOrPhone = (campaignId, campaign_subot_id, data) => __awaiter(void 0, void 0, void 0, function* () {
233
+ const key = 'email' in data ? 'email' : 'phone';
234
+ const value = 'email' in data ? data.email : data.phone;
235
+ const errorMsg = 'email' in data ? 'validator.emailUsed' : 'validator.phoneUsed';
236
+ /** Check on Leadgen Tool */
237
+ const resLeadGen = yield Service.validateEmailOrPhoneOnLeadGen({
238
+ campaign_id: [campaignId],
239
+ [key]: value, // Can be email or phone
240
+ });
241
+ if (resLeadGen._errorCode === 'SubmitLeadWithBotId_ERR_001' ||
242
+ resLeadGen._errorCode === 'SubmitLeadWithBotId_ERR_002') {
243
+ return errorMsg;
244
+ }
245
+ /** Check on Subot */
246
+ if (campaign_subot_id.length) {
247
+ const resSubot = yield Service.validateEmailOrPhoneOnSubot({
248
+ bot_id: campaign_subot_id,
249
+ [key]: value, // Can be email or phone
250
+ });
251
+ if (resSubot._errorCode === 'CheckSuBotLeadTool_ERR_001') {
252
+ return errorMsg;
253
+ }
254
+ }
255
+ });
256
+ const validatedCache = {
257
+ email: {},
258
+ phone: {},
259
+ };
260
+ const checkUsedEmailOrPhoneWithCache = (campaignId, campaign_subot_id, data) => __awaiter(void 0, void 0, void 0, function* () {
261
+ const key = 'email' in data ? 'email' : 'phone';
262
+ const value = 'email' in data ? data.email : data.phone;
263
+ const errorMsg = 'email' in data ? 'validator.emailUsed' : 'validator.phoneUsed';
264
+ if (validatedCache[key][value]) {
265
+ if (validatedCache[key][value].value) {
266
+ return errorMsg;
267
+ }
268
+ else if (!validatedCache[key][value].value &&
269
+ validatedCache[key][value].expire > Date.now()) {
270
+ return '';
271
+ }
272
+ }
273
+ const res = yield checkUsedEmailOrPhone(campaignId, campaign_subot_id, data);
274
+ if (res) {
275
+ validatedCache[key][value] = {
276
+ value: true,
277
+ };
278
+ }
279
+ else {
280
+ validatedCache[key][value] = {
281
+ value: false,
282
+ expire: Date.now() + 1000 * 60,
283
+ };
284
+ }
285
+ return res;
286
+ });
287
+ const clearCacheUsedEmailOrPhone = () => {
288
+ validatedCache.email = {};
289
+ validatedCache.phone = {};
290
+ };
291
+
292
+ // You can give context variables any name
293
+ const [LeadFormProvider$1, useLeadFormContext$1, useLeadForm$1] = createFormContext();
294
+ const useLeadFormConfig$1 = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], }) => {
295
+ const { t } = useTranslations();
296
+ const validateObj = useMemo(() => {
297
+ const InputBlocks = [
298
+ 'TextBlock',
299
+ 'NumberBlock',
300
+ 'EmailBlock',
301
+ 'PhoneBlock',
302
+ 'DateBlock',
303
+ 'CheckboxBlock',
304
+ 'RadioBlock',
305
+ 'DropdownBlock',
306
+ 'PhoneOtpBlock',
307
+ 'WhatsappOtpBlock',
308
+ 'LocationBlock',
309
+ 'TncBlock',
310
+ ];
311
+ // ALL are required and can skip if not touched yet
312
+ const withSharedCheck = (name, cb) => {
313
+ return (value) => {
314
+ if (!formRef.current.isTouched(name))
315
+ return;
316
+ if (typeof value === 'undefined' ||
317
+ value === '' ||
318
+ (Array.isArray(value) && value.length === 0)) {
319
+ return t('validator.required');
320
+ }
321
+ return cb === null || cb === void 0 ? void 0 : cb(value);
322
+ };
323
+ };
324
+ return listBlockAdded
325
+ .filter((b) => InputBlocks.includes(b.name))
326
+ .reduce((r, b) => {
327
+ if (b.name === 'NumberBlock') {
328
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
329
+ if (isNaN(Number(value))) {
330
+ return t('validator.number');
331
+ }
332
+ }) });
333
+ }
334
+ else if (b.name === 'EmailBlock') {
335
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
336
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
337
+ return t('validator.email');
338
+ }
339
+ validatingEmailRef.current = true;
340
+ setTimeout(() => {
341
+ formRef.current.setFieldError(b.data.value, 'Validating...');
342
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
343
+ email: value,
344
+ })
345
+ .then((tKey) => {
346
+ if (tKey) {
347
+ formRef.current.setFieldError(b.data.value, t(tKey));
348
+ }
349
+ else {
350
+ formRef.current.clearFieldError(b.data.value);
351
+ }
352
+ validatingEmailRef.current = false;
353
+ })
354
+ .catch((e) => {
355
+ console.error(e);
356
+ formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
357
+ validatingEmailRef.current = false;
358
+ });
359
+ }, 200);
360
+ }) });
361
+ }
362
+ else if (b.name === 'PhoneBlock' ||
363
+ b.name === 'PhoneOtpBlock' ||
364
+ b.name === 'WhatsappOtpBlock') {
365
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
366
+ if (window.intlTelInputUtils &&
367
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
368
+ return t('validator.phone');
369
+ }
370
+ validatingPhoneRef.current = true;
371
+ setTimeout(() => {
372
+ formRef.current.setFieldError(b.data.value, 'Validating...');
373
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
374
+ phone: value,
375
+ })
376
+ .then((tKey) => {
377
+ if (tKey) {
378
+ formRef.current.setFieldError(b.data.value, t(tKey));
379
+ }
380
+ else {
381
+ formRef.current.clearFieldError(b.data.value);
382
+ }
383
+ validatingPhoneRef.current = false;
384
+ })
385
+ .catch((e) => {
386
+ console.error(e);
387
+ formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
388
+ validatingPhoneRef.current = false;
389
+ });
390
+ }, 200);
391
+ }) });
392
+ }
393
+ else if (b.name === 'DateBlock') {
394
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
395
+ if (isNaN(Date.parse(value))) {
396
+ return t('validator.date');
397
+ }
398
+ }) });
399
+ }
400
+ else if (b.name === 'TncBlock') {
401
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id) });
402
+ }
403
+ else {
404
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value) });
405
+ }
406
+ }, {});
407
+ }, [listBlockAdded.map((b) => b.name).join(',')]);
408
+ const form = useLeadForm$1({
409
+ validateInputOnChange: true,
410
+ clearInputErrorOnChange: true,
411
+ validate: validateObj,
412
+ });
413
+ const formRef = useRef(form);
414
+ formRef.current = form;
415
+ return { form, validateObj };
416
+ };
417
+
418
+ const Component = ({ campaign, onClose: onCloseProp, onOtherSubmit, onSubmit, showThankyou, locale, children, }) => {
419
+ var _a, _b;
420
+ const extraFields = campaign.extra_fields;
421
+ const campaignId = campaign.id;
422
+ const campaign_subot_id = campaign.bot_id || [];
423
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
424
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
425
+ const textBlocks = JSON.parse(extraFields.textBlocks);
426
+ const heading = ((_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) || '';
427
+ const description = textBlocks.subtitleBlock.data.value;
428
+ const validatingPhoneRef = useRef(false);
429
+ const validatingEmailRef = useRef(false);
430
+ const leadFormConfig = useLeadFormConfig$1({
431
+ listBlockAdded,
432
+ validatingPhoneRef,
433
+ validatingEmailRef,
434
+ campaignId,
435
+ campaign_subot_id,
436
+ });
437
+ const [showOtpPhone, setShowOtpPhone] = useState(null);
438
+ const formRef = useRef();
439
+ const onClose = () => {
440
+ if (showOtpPhone) {
441
+ setShowOtpPhone(null);
442
+ }
443
+ else {
444
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
445
+ }
446
+ };
447
+ useEffect(() => {
448
+ if (!window.intlTelInputUtils) {
449
+ require('intl-tel-input/build/js/utils');
450
+ }
451
+ clearCacheUsedEmailOrPhone();
452
+ }, []);
453
+ return campaign ? (React__default.createElement(LeadGenComponentContext.Provider, { value: {
454
+ campaignId,
455
+ campaign_subot_id,
456
+ heading,
457
+ description,
458
+ listBlockAdded,
459
+ textBlocks,
460
+ actionBlocks,
461
+ leadFormConfig,
462
+ validatingEmailRef,
463
+ validatingPhoneRef,
464
+ formRef,
465
+ locale,
466
+ onClose,
467
+ onOtherSubmit,
468
+ showOtpPhone,
469
+ setShowOtpPhone,
470
+ onSubmit,
471
+ showThankyou,
472
+ } }, children)) : null;
473
+ };
474
+
475
+ const Description = (_a) => {
476
+ var rest = __rest(_a, []);
477
+ const { description } = useContext(LeadGenComponentContext);
478
+ return description ? (React__default.createElement(Text, Object.assign({ size: "p3" }, rest), description)) : null;
479
+ };
480
+
481
+ var useStyles$2 = createStyles(() => {
482
+ return {
483
+ control: {},
484
+ };
485
+ });
486
+
487
+ const libraries$1 = ['places'];
488
+ const LocationBlock$1 = ({ name, placeholder, locale, }) => {
489
+ var _a;
490
+ const form = useLeadFormContext$1();
491
+ const [searchValue, setSearchValue] = useState('');
492
+ const [address, setAddress] = useState('');
493
+ const { predictions } = usePlacesAutocomplete(searchValue, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
494
+ const [LoadScript, setLoadScript] = useState(null);
495
+ const [ready, setReady] = useState(false);
496
+ const randRef = useRef(Math.random().toString(36).substring(7));
497
+ const options = useMemo(() => {
498
+ const _opts = predictions.map((p) => {
499
+ return {
500
+ value: p.description,
501
+ label: p.description,
502
+ };
503
+ });
504
+ const isExist = _opts.find((o) => o.value === address);
505
+ if (!address || isExist) {
506
+ return _opts;
507
+ }
508
+ return [{ value: address, label: address }].concat(_opts);
509
+ }, [predictions, address]);
510
+ useEffect(() => {
511
+ var _a, _b, _c;
512
+ // only load extra google script when not yet loaded
513
+ 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)) {
514
+ import('@react-google-maps/api').then((m) => {
515
+ setLoadScript(() => m.LoadScript);
516
+ setTimeout(() => {
517
+ setReady(true);
518
+ }, 200);
519
+ });
520
+ }
521
+ else {
522
+ setReady(true);
523
+ }
524
+ }, []);
525
+ if (!ready)
526
+ return (React__default.createElement("div", { style: {
527
+ height: 73,
528
+ } }));
529
+ return (React__default.createElement(React__default.Fragment, null,
530
+ LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries$1, loadingElement: React__default.createElement(React__default.Fragment, null) })),
531
+ React__default.createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": name, "data-control": 'text' }),
532
+ React__default.createElement(Select, Object.assign({ className: "lead-modal__form-control", label: placeholder, placeholder: placeholder, withAsterisk: true, name: name, data: options, searchValue: searchValue, onSearchChange: (query) => {
533
+ setSearchValue(query);
534
+ }, filter: () => true, clearable: true, searchable: true, onChange: (val) => setAddress(val || ''), icon: React__default.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" },
535
+ React__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.createElement(React__default.Fragment, null) }, form.getInputProps(name)))));
536
+ };
537
+
538
+ const SubtitleBlock$1 = ({ children, align, }) => (React__default.createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
539
+
540
+ const TitleBlock$1 = ({ children, align, }) => (React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
541
+
542
+ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, }) => {
543
+ const { classes, cx } = useStyles$2(undefined, {
544
+ name: 'LeadGen__Field',
545
+ styles,
546
+ classNames,
547
+ });
548
+ const form = useLeadFormContext$1();
549
+ return (React__default.createElement(React__default.Fragment, null, listBlockAdded.map((b, index) => {
550
+ const { name = '', data = {} } = b || {};
551
+ const { placeholder, value, align, listQuestion, isSendMailChimp = false, newtab, url, } = data;
552
+ switch (name) {
553
+ case 'TitleBlock':
554
+ return (React__default.createElement(TitleBlock$1, { key: index, align: align }, value));
555
+ case 'SubtitleBlock':
556
+ return (React__default.createElement(SubtitleBlock$1, { key: index, align: align }, value));
557
+ case 'TextBlock':
558
+ return (React__default.createElement(Input, Object.assign({ key: index, withAsterisk: true, spellCheck: false, type: "text", placeholder: placeholder, className: cx('leadgen-control', classes.control),
559
+ // onChangeRaw={(e) => inputOnChange('text', e)}
560
+ label: placeholder, "data-control": "text", name: value }, form.getInputProps(value))));
561
+ case 'NumberBlock':
562
+ return (React__default.createElement(NumberInput, Object.assign({ key: index, withAsterisk: true, spellCheck: false, type: "number", placeholder: placeholder, className: cx('leadgen-control', classes.control),
563
+ // onChange={(e) => inputOnChange('number', e)}
564
+ label: placeholder, "data-control": "number", name: value }, form.getInputProps(value))));
565
+ case 'EmailBlock':
566
+ return (React__default.createElement(Input, Object.assign({ key: index, withAsterisk: true, spellCheck: false,
567
+ // type="email"
568
+ placeholder: placeholder, className: cx('leadgen-control', classes.control), label: placeholder, "data-control": "email", name: value }, form.getInputProps(value))));
569
+ case 'PhoneOtpBlock':
570
+ case 'WhatsappOtpBlock':
571
+ case 'PhoneBlock': {
572
+ const id = popupId + '-' + value + '-' + index;
573
+ return (React__default.createElement(Input.Wrapper, Object.assign({ size: "md", withAsterisk: true, key: index, label: placeholder,
574
+ // error={errorField.phone}
575
+ className: cx('leadgen-control', classes.control), labelProps: {
576
+ htmlFor: id,
577
+ } }, form.getInputProps(value)),
578
+ React__default.createElement(Phone, { name: value, spellCheck: false, type: "tel", placeholder: placeholder, onChange: (v) => {
579
+ form.setFieldValue(value, v);
580
+ },
581
+ // onBlur={(e) => inputOnBlur('tel', e)}
582
+ id: id, defaultCountry: (locale ? MAPPED_LOCALE[locale] || 'VN' : 'VN'), "data-control": "tel" })));
583
+ }
584
+ case 'LocationBlock': {
585
+ return (React__default.createElement(LocationBlock$1, { key: index, name: value, placeholder: placeholder, locale: locale }));
586
+ }
587
+ case 'DateBlock':
588
+ return (React__default.createElement(React__default.Fragment, null,
589
+ React__default.createElement(DatePicker, Object.assign({ withAsterisk: true, key: index, type: "default", name: value, placeholder: placeholder, className: cx('leadgen-control', classes.control), label: placeholder, "data-control": "date" }, form.getInputProps(value))),
590
+ React__default.createElement("input", { type: "hidden", name: value, "data-control": "date" })));
591
+ case 'LinkButtonBlock':
592
+ return (React__default.createElement("div", { key: index },
593
+ React__default.createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
594
+ React__default.createElement(Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
595
+ onClose === null || onClose === void 0 ? void 0 : onClose();
596
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
597
+ } }, value))));
598
+ case 'CheckboxBlock':
599
+ return (React__default.createElement(React__default.Fragment, null,
600
+ isSendMailChimp && (React__default.createElement("div", { style: {
601
+ display: 'none',
602
+ }, "data-name": value + '-mailchimp' })),
603
+ React__default.createElement(Checkbox.Group, Object.assign({ withAsterisk: true, className: cx('leadgen-control', classes.control), key: index, label: placeholder, size: "md", sx: {
604
+ display: 'flex',
605
+ flexDirection: 'column',
606
+ gap: 8,
607
+ } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default.createElement(Checkbox, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
608
+ case 'RadioBlock':
609
+ return (React__default.createElement(React__default.Fragment, null,
610
+ isSendMailChimp && (React__default.createElement(Input, { type: "hidden", name: value + '-mailchimp', value: isSendMailChimp })),
611
+ React__default.createElement(Radio.Group, Object.assign({ withAsterisk: true, className: cx('leadgen-control', classes.control), key: index, label: placeholder, size: "md" }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default.createElement(Radio, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
612
+ case 'DropdownBlock':
613
+ return (React__default.createElement(React__default.Fragment, null,
614
+ React__default.createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
615
+ React__default.createElement(Select, Object.assign({ key: index, className: cx('leadgen-control', classes.control), label: placeholder, withAsterisk: true, name: value, data: listQuestion.map((l) => ({
616
+ value: l.value,
617
+ label: l.placeholder,
618
+ })) }, form.getInputProps(value)))));
619
+ case 'TncBlock':
620
+ const tncInputProps = form.getInputProps('TNC-' + b.id);
621
+ return (React__default.createElement(React__default.Fragment, null,
622
+ React__default.createElement(Checkbox, Object.assign({ name: 'TNC-' + b.id, key: b.id, label: React__default.createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps, { error: tncInputProps.error ? React__default.createElement(React__default.Fragment, null) : undefined }))));
623
+ }
624
+ return null;
625
+ })));
626
+ };
627
+
628
+ var useStyles$1 = createStyles(() => {
629
+ return {
630
+ root: {},
631
+ header: {},
632
+ heading: {},
633
+ description: {},
634
+ term: {},
635
+ controlList: {},
636
+ control: {},
637
+ submitBtn: {},
638
+ };
639
+ });
640
+
641
+ const Heading = (_a) => {
642
+ var rest = __rest(_a, []);
643
+ const { heading } = useContext(LeadGenComponentContext);
644
+ return heading ? (React__default.createElement(Text, Object.assign({ size: "h3" }, rest), heading)) : null;
645
+ };
646
+
647
+ const FormComponent = ({ styles, className, classNames, fillInfo }) => {
648
+ var _a;
649
+ const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = useContext(LeadGenComponentContext);
650
+ const { classes, cx } = useStyles$1(undefined, {
651
+ name: 'LeadGen__FormComponent',
652
+ styles,
653
+ classNames,
654
+ });
655
+ const [checkedTerm, setCheckedTerm] = useState(true);
656
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
657
+ const popUpTermURL = actionBlocks.submitBlock.data.url;
658
+ const popUpTermAgreeText = actionBlocks.submitBlock.data.text;
659
+ const popUpTermText = actionBlocks.submitBlock.data.text2;
660
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
661
+ const middlewareOnSubmit = (e) => {
662
+ e.preventDefault();
663
+ // mark all as touched to allow validation
664
+ form.setTouched(Object.keys(validateObj).reduce((acc, cur) => {
665
+ acc[cur] = true;
666
+ return acc;
667
+ }, {}));
668
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
669
+ return;
670
+ }
671
+ setTimeout(() => {
672
+ form.onSubmit((v) => {
673
+ var _a, _b, _c, _d, _e, _f;
674
+ if (Object.keys(form.errors).length)
675
+ return;
676
+ let newShowOtpPhone = null;
677
+ if (listBlockAdded.findIndex((x) => x.name === 'PhoneOtpBlock') > -1) {
678
+ // not submit yet, open otp
679
+ const fieldName = (_b = (_a = listBlockAdded.find((x) => x.name === 'PhoneOtpBlock')) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value;
680
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
681
+ newShowOtpPhone = {
682
+ phone: v[fieldName],
683
+ type: 'phone',
684
+ };
685
+ }
686
+ }
687
+ if (listBlockAdded.findIndex((x) => x.name === 'WhatsappOtpBlock') > -1) {
688
+ // not submit yet, open otp
689
+ const fieldName = (_e = (_d = listBlockAdded.find((x) => x.name === 'WhatsappOtpBlock')) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.value;
690
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
691
+ newShowOtpPhone = {
692
+ phone: v[fieldName],
693
+ type: 'whatsapp',
694
+ };
695
+ }
696
+ }
697
+ if (newShowOtpPhone) {
698
+ setIsSubmitLoading(true);
699
+ Service.sendSMSOtpLead(newShowOtpPhone)
700
+ .then((res) => {
701
+ var _a;
702
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
703
+ if (respMessage === 'This phone number was verified') {
704
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
705
+ return;
706
+ }
707
+ setShowOtpPhone(newShowOtpPhone);
708
+ })
709
+ .finally(() => {
710
+ setIsSubmitLoading(false);
711
+ });
712
+ return;
713
+ }
714
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
715
+ })(e);
716
+ }, 100);
717
+ };
718
+ useEffect(() => {
719
+ form === null || form === void 0 ? void 0 : form.setValues(fillInfo);
720
+ }, [fillInfo]);
721
+ return (React__default.createElement(LeadFormProvider$1, { form: form },
722
+ React__default.createElement(Box, { component: "form", ref: formRef, className: cx(className, classes.root), onSubmit: middlewareOnSubmit, styles: styles },
723
+ React__default.createElement("div", { className: classes.header },
724
+ React__default.createElement(Heading, { className: classes.heading }),
725
+ React__default.createElement(Description, { className: classes.description })),
726
+ React__default.createElement("div", { className: classes.controlList },
727
+ React__default.createElement(Fields, { classNames: {
728
+ control: classes.control,
729
+ }, listBlockAdded: listBlockAdded, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit })),
730
+ ((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) ? null : (React__default.createElement(React__default.Fragment, null,
731
+ React__default.createElement("div", { className: classes.term },
732
+ React__default.createElement("div", { className: "lead-modal__checkbox" },
733
+ React__default.createElement("input", { id: "lead-term-checkbox", className: `lead-modal__checkbox__input ${LEAD_CLASS}`, type: "checkbox", "aria-label": "Checkbox label", checked: checkedTerm, onChange: (e) => setCheckedTerm(e.currentTarget.checked) }),
734
+ React__default.createElement("div", { className: "lead-modal__checkbox__control", "aria-hidden": "true" })),
735
+ React__default.createElement("label", { htmlFor: "checkbox", className: "lead-modal__checkbox__label" },
736
+ popUpTermAgreeText,
737
+ ' ',
738
+ React__default.createElement("span", { style: { fontWeight: 'bold' } },
739
+ React__default.createElement("a", { target: "blank", href: popUpTermURL || 'https://hellobacsi.com/chinh-sach', rel: "noopener noreferrer", style: { textDecoration: 'none' } }, popUpTermText)))),
740
+ React__default.createElement(Button$1, { size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, disabled: !checkedTerm, loading: isSubmitLoading }, popUpSubmitText))))));
741
+ };
742
+ const Form = (props) => {
743
+ const { showOtpPhone, showThankyou } = useContext(LeadGenComponentContext);
744
+ return showThankyou || showOtpPhone ? null : React__default.createElement(FormComponent, Object.assign({}, props));
745
+ };
746
+
747
+ var useStyles = createStyles(() => {
748
+ return {
749
+ root: {},
750
+ heading: {},
751
+ description: {},
752
+ control: {},
753
+ submitBtn: {},
754
+ resendOtp: {},
755
+ };
756
+ });
757
+
758
+ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, styles, classNames, }) => {
759
+ const { t } = useTranslations();
760
+ const phone = otpData.phone;
761
+ const otpType = otpData.type;
762
+ const [otp, setOtp] = useState('');
763
+ const [isDirty, setIsDirty] = useState(false);
764
+ const [resendTimer, setResendTimer] = useState(autoSendWhenOpen ? 0 : 60);
765
+ const inputRef = useRef(null);
766
+ const [errorMsg, setErrorMsg] = useState();
767
+ const [displayPhone, setDisplayPhone] = useState('');
768
+ const formatPhoneNumberIntlRef = useRef();
769
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
770
+ const { classes, cx } = useStyles(undefined, {
771
+ name: 'LeadGen__OTP',
772
+ styles,
773
+ classNames,
774
+ });
775
+ useEffect(() => {
776
+ (() => __awaiter(void 0, void 0, void 0, function* () {
777
+ var _a;
778
+ if (!formatPhoneNumberIntlRef.current) {
779
+ const res = yield import('react-phone-number-input');
780
+ formatPhoneNumberIntlRef.current = res.formatPhoneNumberIntl;
781
+ }
782
+ setDisplayPhone(((_a = formatPhoneNumberIntlRef.current) === null || _a === void 0 ? void 0 : _a.call(formatPhoneNumberIntlRef, phone)) || phone);
783
+ }))();
784
+ }, [phone]);
785
+ const sendOtp = () => __awaiter(void 0, void 0, void 0, function* () {
786
+ var _a;
787
+ if (!phone) {
788
+ return;
789
+ }
790
+ const res = yield Service.sendSMSOtpLead({
791
+ phone,
792
+ type: otpType,
793
+ });
794
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
795
+ if (respMessage === 'Send sms successfully' ||
796
+ respMessage === 'Send WhatsApp successfully') {
797
+ setResendTimer(60);
798
+ setTimeout(() => {
799
+ if (inputRef.current) {
800
+ inputRef.current.focus();
801
+ inputRef.current.scrollIntoView({ block: 'center' });
802
+ }
803
+ }, 100);
804
+ }
805
+ else if (respMessage === 'This phone number was verified') {
806
+ onSuccess();
807
+ }
808
+ else {
809
+ setErrorMsg(respMessage || 'Something went wrong!');
810
+ // const defaultError = f({ id: 'notification.comment.somethingWrong' })
811
+ // setStatusVerifyOTP('idle')
812
+ // pushNotifications({
813
+ // title: respMessage || defaultError,
814
+ // message: '',
815
+ // type: 'danger',
816
+ // })
817
+ }
818
+ });
819
+ const submitOtp = () => __awaiter(void 0, void 0, void 0, function* () {
820
+ if (!phone || !otp) {
821
+ return;
822
+ }
823
+ setIsSubmitLoading(true);
824
+ const res = yield Service.verifyOtpLead({
825
+ phone,
826
+ otp,
827
+ type: otpType,
828
+ });
829
+ const respMessage = res === null || res === void 0 ? void 0 : res._messages[0];
830
+ if (respMessage === 'Verify successfully' ||
831
+ respMessage === 'Verify WhatsApp OTP sucess') {
832
+ onSuccess();
833
+ }
834
+ else if (respMessage === 'This phone number was verified') {
835
+ onSuccess();
836
+ }
837
+ else {
838
+ setErrorMsg(respMessage || 'something Wrong');
839
+ // setIsShowError(true)
840
+ // setStatusVerifyOTP('sent')
841
+ // pushNotifications({
842
+ // title: res?._messages[0] || defaultError,
843
+ // message: '',
844
+ // type: 'danger',
845
+ // })
846
+ }
847
+ setIsSubmitLoading(false);
848
+ });
849
+ useEffect(() => {
850
+ setTimeout(() => {
851
+ if (resendTimer > 0) {
852
+ setResendTimer((r) => r - 1);
853
+ }
854
+ }, 1000);
855
+ }, [resendTimer]);
856
+ useEffect(() => {
857
+ if (autoSendWhenOpen && !resendTimer) {
858
+ sendOtp();
859
+ }
860
+ }, []);
861
+ return (React__default.createElement(React__default.Fragment, null,
862
+ React__default.createElement(Box, { component: "form", onSubmit: (e) => {
863
+ e.preventDefault();
864
+ submitOtp();
865
+ }, className: cx(classes.root, className) },
866
+ React__default.createElement(Heading$1, { tag: "h3", className: classes.heading }, t('lead.otp.title')),
867
+ React__default.createElement(Text, { size: "p1", className: classes.description }, t('lead.otp.desc', { phone: displayPhone })),
868
+ React__default.createElement(Input, { ref: inputRef, name: '_' + name + '-otp', spellCheck: false, type: "number", placeholder: "Enter OTP", className: classes.control, label: "Phone OTP", "data-control": "otp", withAsterisk: true, pattern: "[0-9]*", value: otp, maxLength: 6, onChange: (v) => {
869
+ setIsDirty(true);
870
+ setOtp(v);
871
+ if (isDirty && !v)
872
+ setErrorMsg('OTP is required');
873
+ else
874
+ setErrorMsg(undefined);
875
+ }, error: isDirty ? errorMsg : undefined }),
876
+ React__default.createElement(Button$1, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
877
+ // onClick={() => submitOtp()}
878
+ disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
879
+ React__default.createElement(Button$1, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
880
+ sendOtp();
881
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
882
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
883
+ })))));
884
+ };
885
+ const OtpBlock$1 = ({}) => {
886
+ const { showOtpPhone, setShowOtpPhone, onSubmit, formRef, leadFormConfig: { form }, } = useContext(LeadGenComponentContext);
887
+ return showOtpPhone ? (React__default.createElement(OtpBlockComponent, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
888
+ setShowOtpPhone(null);
889
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
890
+ } })) : null;
891
+ };
892
+
893
+ const Thankyou = ({ children, }) => {
894
+ const { showThankyou } = useContext(LeadGenComponentContext);
895
+ return showThankyou ? children(showThankyou) : null;
128
896
  };
129
897
 
130
898
  var enPH = {
@@ -427,165 +1195,6 @@ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, su
427
1195
  React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
428
1196
  };
429
1197
 
430
- class Store {
431
- constructor() {
432
- this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
433
- this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
434
- }
435
- }
436
- const leadStore = new Store();
437
-
438
- const leadApi = {
439
- call(_a) {
440
- var { url, data = undefined } = _a, config = __rest(_a, ["url", "data"]);
441
- config.body = JSON.stringify(data);
442
- config.headers = {
443
- 'Content-Type': 'application/json',
444
- };
445
- return fetch(`${leadStore.apiLeadUrl}${url}`, config)
446
- .then((res) => res.json())
447
- .catch(() => ({}));
448
- },
449
- };
450
- const subotApi = {
451
- call(_a) {
452
- var { url, data } = _a, config = __rest(_a, ["url", "data"]);
453
- config.body = JSON.stringify(data);
454
- config.headers = {
455
- 'Content-Type': 'application/json',
456
- };
457
- return fetch(`${leadStore.apiSubotUrl}${url}`, config)
458
- .then((res) => res.json())
459
- .catch(() => ({}));
460
- },
461
- };
462
- const campaignGetById = (id) => {
463
- return leadApi.call({
464
- url: `api/internal/campaign/${id}`,
465
- method: 'get',
466
- });
467
- };
468
- const validateEmailOrPhoneOnLeadGen = ({ campaign_id, email, phone, }) => {
469
- let phoneToSend = phone;
470
- // Remove the '0' part. Logic from Back to check between Subot and Lead with different format
471
- if (phoneToSend && phoneToSend.startsWith('0')) {
472
- phoneToSend = phoneToSend.substring(1);
473
- }
474
- return leadApi.call({
475
- url: 'api/subot-campaign/check',
476
- method: 'post',
477
- data: {
478
- campaign_id,
479
- email,
480
- phone: phoneToSend,
481
- },
482
- });
483
- };
484
- const validateEmailOrPhoneOnSubot = ({ bot_id, email, phone, }) => {
485
- let phoneToSend = phone;
486
- // Remove the '0' part. Logic from Back to check between Subot and Lead with different format
487
- if (phoneToSend && phoneToSend.startsWith('0')) {
488
- phoneToSend = phoneToSend.substring(1);
489
- }
490
- return subotApi.call({
491
- url: 'frontend/api/subot-campaign/check',
492
- method: 'post',
493
- data: {
494
- bot_id,
495
- email,
496
- phone: phoneToSend,
497
- },
498
- });
499
- };
500
- const sendSMSOtpLead = ({ phone, type, }) => {
501
- return leadApi.call({
502
- url: type === 'phone' ? 'api/sms/otp' : 'api/sms/whatsapp_otp',
503
- method: 'post',
504
- data: {
505
- // The type Whatsapp do not remove the '+'
506
- phone_number: type === 'phone' ? phone.replace('+', '') : phone,
507
- },
508
- });
509
- };
510
- const verifyOtpLead = ({ phone, otp, type, }) => {
511
- return leadApi.call({
512
- url: type === 'phone' ? 'api/sms/verify' : 'api/sms/whatsapp_verify',
513
- method: 'post',
514
- data: {
515
- // The type Whatsapp do not remove the '+'
516
- otp_code: otp,
517
- phone_number: type === 'phone' ? phone.replace('+', '') : phone,
518
- },
519
- });
520
- };
521
- const Service = {
522
- campaignGetById,
523
- validateEmailOrPhoneOnSubot,
524
- validateEmailOrPhoneOnLeadGen,
525
- sendSMSOtpLead,
526
- verifyOtpLead,
527
- };
528
-
529
- const checkUsedEmailOrPhone = (campaignId, campaign_subot_id, data) => __awaiter(void 0, void 0, void 0, function* () {
530
- const key = 'email' in data ? 'email' : 'phone';
531
- const value = 'email' in data ? data.email : data.phone;
532
- const errorMsg = 'email' in data ? 'validator.emailUsed' : 'validator.phoneUsed';
533
- /** Check on Leadgen Tool */
534
- const resLeadGen = yield Service.validateEmailOrPhoneOnLeadGen({
535
- campaign_id: [campaignId],
536
- [key]: value, // Can be email or phone
537
- });
538
- if (resLeadGen._errorCode === 'SubmitLeadWithBotId_ERR_001' ||
539
- resLeadGen._errorCode === 'SubmitLeadWithBotId_ERR_002') {
540
- return errorMsg;
541
- }
542
- /** Check on Subot */
543
- if (campaign_subot_id.length) {
544
- const resSubot = yield Service.validateEmailOrPhoneOnSubot({
545
- bot_id: campaign_subot_id,
546
- [key]: value, // Can be email or phone
547
- });
548
- if (resSubot._errorCode === 'CheckSuBotLeadTool_ERR_001') {
549
- return errorMsg;
550
- }
551
- }
552
- });
553
- const validatedCache = {
554
- email: {},
555
- phone: {},
556
- };
557
- const checkUsedEmailOrPhoneWithCache = (campaignId, campaign_subot_id, data) => __awaiter(void 0, void 0, void 0, function* () {
558
- const key = 'email' in data ? 'email' : 'phone';
559
- const value = 'email' in data ? data.email : data.phone;
560
- const errorMsg = 'email' in data ? 'validator.emailUsed' : 'validator.phoneUsed';
561
- if (validatedCache[key][value]) {
562
- if (validatedCache[key][value].value) {
563
- return errorMsg;
564
- }
565
- else if (!validatedCache[key][value].value &&
566
- validatedCache[key][value].expire > Date.now()) {
567
- return '';
568
- }
569
- }
570
- const res = yield checkUsedEmailOrPhone(campaignId, campaign_subot_id, data);
571
- if (res) {
572
- validatedCache[key][value] = {
573
- value: true,
574
- };
575
- }
576
- else {
577
- validatedCache[key][value] = {
578
- value: false,
579
- expire: Date.now() + 1000 * 60,
580
- };
581
- }
582
- return res;
583
- });
584
- const clearCacheUsedEmailOrPhone = () => {
585
- validatedCache.email = {};
586
- validatedCache.phone = {};
587
- };
588
-
589
1198
  // You can give context variables any name
590
1199
  const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
591
1200
  const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], }) => {
@@ -951,7 +1560,7 @@ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
951
1560
  e.preventDefault();
952
1561
  submitOtp();
953
1562
  }, className: "lead-phone-otp-form" },
954
- React__default.createElement(Heading, { tag: "h3", fontWeight: "bold", style: { marginBottom: 4 } }, t('lead.otp.title')),
1563
+ React__default.createElement(Heading$1, { tag: "h3", fontWeight: "bold", style: { marginBottom: 4 } }, t('lead.otp.title')),
955
1564
  React__default.createElement(Text, { size: "p1", color: theme.colors.gray600 }, t('lead.otp.desc', { phone: displayPhone })),
956
1565
  React__default.createElement(Input, { ref: inputRef, name: '_' + name + '-otp', spellCheck: false, type: "number", placeholder: "Enter OTP", className: "lead-modal__form-control", label: "Phone OTP", "data-control": "otp", withAsterisk: true, pattern: "[0-9]*", value: otp, maxLength: 6, onChange: (v) => {
957
1566
  setIsDirty(true);
@@ -1867,7 +2476,7 @@ const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, local
1867
2476
  };
1868
2477
 
1869
2478
  // mount css
1870
- const LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl, DEBUG_URL, forceCampaign, }) => {
2479
+ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl, DEBUG_URL, forceCampaign, children, }) => {
1871
2480
  var _a;
1872
2481
  const scrollEventHandlerRef = useRef();
1873
2482
  const leadStartTimeRef = useRef(Date.now());
@@ -2124,17 +2733,23 @@ const LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl,
2124
2733
  React__default.createElement(TranslationsContext.Provider, { value: {
2125
2734
  locale,
2126
2735
  values: getTranslations(locale),
2127
- } },
2128
- React__default.createElement(Portal, { target: getPopupWrapperDom() },
2129
- React__default.createElement(Box, { sx: { position: 'fixed', zIndex: 9999999999 } },
2130
- React__default.createElement(Transition, { mounted: Boolean(((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1'), transition: "fade", duration: 600, timingFunction: "ease" }, (styles) => {
2131
- var _a;
2132
- return (React__default.createElement(Box, { style: styles }, ((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1' && (React__default.createElement(React__default.Fragment, null,
2133
- !!showCampaign.extra_fields.currentLayout &&
2134
- !showCampaign.extra_fields.currentLayout.includes('Inline') &&
2135
- !showCampaign.extra_fields.currentLayout.includes('Sidebar') && (React__default.createElement(Overlay, { color: "#000", opacity: 0.5, center: true, zIndex: 400, pos: 'fixed', onClick: () => onClose() })),
2136
- React__default.createElement(NewLeadPopup, { campaign: showCampaign, action: action, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, locale: locale })))));
2137
- }))))));
2138
- };
2736
+ } }, children ? (React__default.createElement(Component, { campaign: showCampaign, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, locale: locale }, children)) : (React__default.createElement(Portal, { target: getPopupWrapperDom() },
2737
+ React__default.createElement(Box, { sx: { position: 'fixed', zIndex: 9999999999 } },
2738
+ React__default.createElement(Transition, { mounted: Boolean(((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1'), transition: "fade", duration: 600, timingFunction: "ease" }, (styles) => {
2739
+ var _a;
2740
+ return (React__default.createElement(Box, { style: styles }, ((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1' && (React__default.createElement(React__default.Fragment, null,
2741
+ !!showCampaign.extra_fields.currentLayout &&
2742
+ !showCampaign.extra_fields.currentLayout.includes('Inline') &&
2743
+ !showCampaign.extra_fields.currentLayout.includes('Sidebar') && (React__default.createElement(Overlay, { color: "#000", opacity: 0.5, center: true, zIndex: 400, pos: 'fixed', onClick: () => onClose() })),
2744
+ React__default.createElement(NewLeadPopup, { campaign: showCampaign, action: action, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, locale: locale })))));
2745
+ })))))));
2746
+ };
2747
+ const LeadGen = _LeadGen;
2748
+ LeadGen.Heading = Heading;
2749
+ LeadGen.Description = Description;
2750
+ LeadGen.Form = Form;
2751
+ LeadGen.Thankyou = Thankyou;
2752
+ LeadGen.OtpForm = OtpBlock$1;
2753
+ LeadGen.Close = Close;
2139
2754
 
2140
2755
  export { LeadGen };