@envive-ai/react-hooks 0.2.6-alpha-5 → 0.2.6-alpha-7

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 (504) hide show
  1. package/dist/{AmplitudeOperations-CNFlPr53.cjs → AmplitudeOperations-DbUiR0N_.cjs} +3 -3
  2. package/dist/{AmplitudeOperations-cmAprPCA.js → AmplitudeOperations-DjqOM3uE.js} +2 -2
  3. package/dist/{NewOrgConfig-Bicbf8I7.js → NewOrgConfig-C_1T1iOt.js} +2 -2
  4. package/dist/{NewOrgConfig-6dFyYjJG.cjs → NewOrgConfig-D2Kvqa1z.cjs} +2 -2
  5. package/dist/{TrackComponentVisibleEvent-BebTjNtS.js → TrackComponentVisibleEvent-BxOhr9Da.js} +4 -4
  6. package/dist/{TrackComponentVisibleEvent-COwxsJRE.cjs → TrackComponentVisibleEvent-CDbecFPM.cjs} +5 -5
  7. package/dist/amplitudeContext-BWmXliMI.cjs +243 -0
  8. package/dist/amplitudeContext-BjMlg5RV.js +227 -0
  9. package/dist/amplitudeTrackEventAtom-D66l5oFp.js +8 -0
  10. package/dist/amplitudeTrackEventAtom-f22P2U0u.cjs +15 -0
  11. package/dist/app-Bs2KxG_8.js +515 -0
  12. package/dist/app-DSnDDqcW.cjs +570 -0
  13. package/dist/application/models/graphql/index.d.ts +1 -1
  14. package/dist/application/models/guards/api/index.d.ts +2 -2
  15. package/dist/application/models/guards/utils.d.ts +1 -1
  16. package/dist/application/models/index.cjs +2 -2
  17. package/dist/application/models/index.d.ts +4 -4
  18. package/dist/application/models/index.js +2 -2
  19. package/dist/application/utils/index.cjs +5 -14
  20. package/dist/application/utils/index.d.cts +7 -8
  21. package/dist/application/utils/index.d.ts +8 -9
  22. package/dist/application/utils/index.js +5 -14
  23. package/dist/{atomStore-CZKe3itM.cjs → atomStore-BQVO5haU.cjs} +1 -1
  24. package/dist/{atomStore-BuopbV9k.js → atomStore-CfzCqWB9.js} +1 -1
  25. package/dist/atoms/app/index.cjs +17 -19
  26. package/dist/atoms/app/index.d.cts +7 -7
  27. package/dist/atoms/app/index.d.ts +7 -7
  28. package/dist/atoms/app/index.js +12 -14
  29. package/dist/atoms/atomStore/index.cjs +1 -1
  30. package/dist/atoms/atomStore/index.d.ts +1 -1
  31. package/dist/atoms/atomStore/index.js +1 -1
  32. package/dist/atoms/chat/index.cjs +15 -17
  33. package/dist/atoms/chat/index.d.cts +33 -34
  34. package/dist/atoms/chat/index.d.ts +34 -35
  35. package/dist/atoms/chat/index.js +15 -17
  36. package/dist/atoms/globalSearch/index.cjs +1 -1
  37. package/dist/atoms/globalSearch/index.d.cts +6 -6
  38. package/dist/atoms/globalSearch/index.d.ts +6 -6
  39. package/dist/atoms/globalSearch/index.js +1 -1
  40. package/dist/atoms/org/index.cjs +2 -2
  41. package/dist/atoms/org/index.d.cts +17 -17
  42. package/dist/atoms/org/index.d.ts +17 -17
  43. package/dist/atoms/org/index.js +2 -2
  44. package/dist/atoms/search/index.cjs +6 -6
  45. package/dist/atoms/search/index.d.cts +15 -15
  46. package/dist/atoms/search/index.d.ts +14 -14
  47. package/dist/atoms/search/index.js +6 -6
  48. package/dist/atoms/search/utils.cjs +1 -1
  49. package/dist/atoms/search/utils.d.cts +1 -1
  50. package/dist/atoms/search/utils.d.ts +1 -1
  51. package/dist/atoms/search/utils.js +1 -1
  52. package/dist/{cdnContext-CuZwc-PI.js → cdnContext-CJ2BNLAD.js} +2 -2
  53. package/dist/{cdnContext-ClAEcKhO.cjs → cdnContext-lkC-AE6A.cjs} +2 -2
  54. package/dist/chat-C5afTKUY.js +226 -0
  55. package/dist/{chat-BJL3nXR7.cjs → chat-CCjM6fS_.cjs} +6 -7
  56. package/dist/{chat-DCGriB7h.cjs → chat-CJ9D8n7g.cjs} +1 -1
  57. package/dist/{chat-ClvJ9xEj.js → chat-EJbfGWRr.js} +1 -1
  58. package/dist/chatState-BbI93m6r.js +33 -0
  59. package/dist/chatState-DlJpHAsW.cjs +119 -0
  60. package/dist/{common-DQPvV_S_.cjs → common-CuwWqIJ1.cjs} +1 -1
  61. package/dist/{common-c_4eX0qn.js → common-Df2bwzd2.js} +1 -1
  62. package/dist/{components-DKwVHIjq.cjs → components-BCfFLf9X.cjs} +1 -1
  63. package/dist/{components-CDpaMUjK.js → components-QGCWJ26c.js} +1 -1
  64. package/dist/config/index.cjs +4 -4
  65. package/dist/config/index.d.cts +4 -4
  66. package/dist/config/index.d.ts +4 -4
  67. package/dist/config/index.js +4 -4
  68. package/dist/config/locators/components/chat/index.cjs +1 -1
  69. package/dist/config/locators/components/chat/index.d.cts +1 -1
  70. package/dist/config/locators/components/chat/index.d.ts +1 -1
  71. package/dist/config/locators/components/chat/index.js +1 -1
  72. package/dist/config/locators/components/common/index.cjs +1 -1
  73. package/dist/config/locators/components/common/index.d.cts +1 -1
  74. package/dist/config/locators/components/common/index.d.ts +1 -1
  75. package/dist/config/locators/components/common/index.js +1 -1
  76. package/dist/config/locators/components/index.cjs +1 -1
  77. package/dist/config/locators/components/index.d.cts +1 -1
  78. package/dist/config/locators/components/index.d.ts +1 -1
  79. package/dist/config/locators/components/index.js +1 -1
  80. package/dist/config/locators/index.cjs +4 -4
  81. package/dist/config/locators/index.d.cts +4 -4
  82. package/dist/config/locators/index.d.ts +4 -4
  83. package/dist/config/locators/index.js +4 -4
  84. package/dist/contexts/amplitudeContext/index.cjs +18 -17
  85. package/dist/contexts/amplitudeContext/index.d.cts +11 -2
  86. package/dist/contexts/amplitudeContext/index.d.ts +11 -2
  87. package/dist/contexts/amplitudeContext/index.js +17 -15
  88. package/dist/contexts/cdnContext/index.cjs +3 -3
  89. package/dist/contexts/cdnContext/index.d.cts +1 -1
  90. package/dist/contexts/cdnContext/index.js +3 -3
  91. package/dist/contexts/enviveConfigContext/index.cjs +3 -3
  92. package/dist/contexts/enviveConfigContext/index.d.cts +1 -1
  93. package/dist/contexts/enviveConfigContext/index.js +3 -3
  94. package/dist/contexts/enviveCssContext/index.cjs +10 -10
  95. package/dist/contexts/enviveCssContext/index.js +10 -10
  96. package/dist/contexts/featureFlagContext/index.cjs +4 -4
  97. package/dist/contexts/featureFlagContext/index.js +4 -4
  98. package/dist/contexts/featureFlagServiceContext/index.cjs +3 -3
  99. package/dist/contexts/featureFlagServiceContext/index.d.cts +1 -1
  100. package/dist/contexts/featureFlagServiceContext/index.d.ts +1 -1
  101. package/dist/contexts/featureFlagServiceContext/index.js +3 -3
  102. package/dist/contexts/graphqlContext/index.cjs +4 -4
  103. package/dist/contexts/graphqlContext/index.js +4 -4
  104. package/dist/contexts/localStorageContext/index.cjs +2 -2
  105. package/dist/contexts/localStorageContext/index.d.cts +1 -1
  106. package/dist/contexts/localStorageContext/index.js +2 -2
  107. package/dist/contexts/newOrgConfigContext/index.cjs +9 -9
  108. package/dist/contexts/newOrgConfigContext/index.js +9 -9
  109. package/dist/contexts/searchContext/index.cjs +18 -19
  110. package/dist/contexts/searchContext/index.js +18 -19
  111. package/dist/contexts/sessionStorageContext/index.cjs +1 -1
  112. package/dist/contexts/sessionStorageContext/index.js +1 -1
  113. package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
  114. package/dist/contexts/shopifyUrlContext/index.d.cts +1 -1
  115. package/dist/contexts/shopifyUrlContext/index.js +2 -2
  116. package/dist/contexts/systemSettingsContext/index.cjs +3 -3
  117. package/dist/contexts/systemSettingsContext/index.d.cts +2 -2
  118. package/dist/contexts/systemSettingsContext/index.js +3 -3
  119. package/dist/contexts/userIdentityContext/index.cjs +14 -16
  120. package/dist/contexts/userIdentityContext/index.js +12 -14
  121. package/dist/{dist-CIM4YRqp.js → dist-C38adNK1.js} +1 -1
  122. package/dist/{dist-BZX_Mgfn.cjs → dist-VxRI6eQv.cjs} +1 -1
  123. package/dist/{domObserver-CwieVNgj.cjs → domObserver-C2oQO8vi.cjs} +1 -1
  124. package/dist/{domObserver-B19-69gW.js → domObserver-DNeeSh1F.js} +1 -1
  125. package/dist/{enviveConfig-CBnoutoK.js → enviveConfig-Ciq4ASoV.js} +2 -2
  126. package/dist/{enviveConfig-BwIaVAAm.cjs → enviveConfig-Dp80h9yu.cjs} +2 -2
  127. package/dist/{enviveConfigContext-B4nejwV9.js → enviveConfigContext-CCjJUmwp.js} +2 -2
  128. package/dist/{enviveConfigContext-DgewMgYS.cjs → enviveConfigContext-DoYP8KSw.cjs} +2 -2
  129. package/dist/events/index.cjs +1 -1
  130. package/dist/events/index.js +1 -1
  131. package/dist/{events-BHBRLPWS.js → events-CXiS1aTc.js} +1 -1
  132. package/dist/{events-C8LA-0Tp.cjs → events-DBin1Z7o.cjs} +1 -1
  133. package/dist/exceptions/index.cjs +1 -1
  134. package/dist/exceptions/index.d.ts +1 -1
  135. package/dist/exceptions/index.js +1 -1
  136. package/dist/{exceptions-BBXmiU8P.cjs → exceptions-BjDgLzGi.cjs} +1 -1
  137. package/dist/{exceptions--fSXOzkB.js → exceptions-CUGY31Ua.js} +1 -1
  138. package/dist/{featureFlagServiceContext-B7je7VZV.d.cts → featureFlagServiceContext-ClnlCJV5.d.cts} +1 -1
  139. package/dist/{featureFlagServiceContext-CZj3qPX7.js → featureFlagServiceContext-Cvp7NlpC.js} +2 -2
  140. package/dist/{featureFlagServiceContext-DiYIv0jI.d.ts → featureFlagServiceContext-CyPGEe2d.d.ts} +1 -1
  141. package/dist/{featureFlagServiceContext-BkamHViU.cjs → featureFlagServiceContext-DHtkQAtq.cjs} +2 -2
  142. package/dist/{globalSearch-C94-vEVh.cjs → globalSearch-Cpc8egsM.cjs} +1 -1
  143. package/dist/{globalSearch-Dlbnfasm.js → globalSearch-nmrfGLOn.js} +1 -1
  144. package/dist/{graphqlContext-Capum8x6.js → graphqlContext-0cg9fEUw.js} +3 -3
  145. package/dist/{graphqlContext-C3HXFiHx.cjs → graphqlContext-ChXlE8Ul.cjs} +3 -3
  146. package/dist/hooks/AmplitudeOperations/index.cjs +17 -15
  147. package/dist/hooks/AmplitudeOperations/index.d.cts +1 -1
  148. package/dist/hooks/AmplitudeOperations/index.js +17 -15
  149. package/dist/hooks/AppDetails/index.cjs +15 -17
  150. package/dist/hooks/AppDetails/index.js +15 -17
  151. package/dist/hooks/BlockBackButton/index.d.cts +1 -1
  152. package/dist/hooks/CdnOperations/index.cjs +3 -3
  153. package/dist/hooks/CdnOperations/index.d.cts +1 -1
  154. package/dist/hooks/CdnOperations/index.d.ts +1 -1
  155. package/dist/hooks/CdnOperations/index.js +3 -3
  156. package/dist/hooks/ChatToggle/index.cjs +21 -19
  157. package/dist/hooks/ChatToggle/index.d.cts +1 -1
  158. package/dist/hooks/ChatToggle/index.js +20 -18
  159. package/dist/hooks/ChatToggleAnalytics/index.cjs +19 -17
  160. package/dist/hooks/ChatToggleAnalytics/index.d.cts +1 -1
  161. package/dist/hooks/ChatToggleAnalytics/index.js +19 -17
  162. package/dist/hooks/Debounce/index.d.cts +1 -1
  163. package/dist/hooks/ElementObserver/index.cjs +1 -1
  164. package/dist/hooks/ElementObserver/index.d.cts +1 -1
  165. package/dist/hooks/ElementObserver/index.d.ts +1 -1
  166. package/dist/hooks/ElementObserver/index.js +1 -1
  167. package/dist/hooks/GraphQLConfig/index.cjs +5 -5
  168. package/dist/hooks/GraphQLConfig/index.d.cts +1 -1
  169. package/dist/hooks/GraphQLConfig/index.js +5 -5
  170. package/dist/hooks/IdentifyUser/index.cjs +14 -16
  171. package/dist/hooks/IdentifyUser/index.d.cts +1 -1
  172. package/dist/hooks/IdentifyUser/index.js +13 -15
  173. package/dist/hooks/ImageResolver/index.cjs +2 -2
  174. package/dist/hooks/ImageResolver/index.d.cts +1 -1
  175. package/dist/hooks/ImageResolver/index.js +2 -2
  176. package/dist/hooks/Intersection/index.cjs +1 -1
  177. package/dist/hooks/Intersection/index.js +1 -1
  178. package/dist/hooks/IsSmallScreen/index.d.cts +1 -1
  179. package/dist/hooks/LocalStorageOperations/index.cjs +2 -2
  180. package/dist/hooks/LocalStorageOperations/index.d.cts +1 -1
  181. package/dist/hooks/LocalStorageOperations/index.js +2 -2
  182. package/dist/hooks/MessageFilter/index.cjs +1 -1
  183. package/dist/hooks/MessageFilter/index.d.cts +1 -1
  184. package/dist/hooks/MessageFilter/index.js +1 -1
  185. package/dist/hooks/MessageScrollObserver/index.d.cts +1 -1
  186. package/dist/hooks/NewOrgConfig/index.cjs +10 -10
  187. package/dist/hooks/NewOrgConfig/index.d.cts +2 -2
  188. package/dist/hooks/NewOrgConfig/index.d.ts +2 -2
  189. package/dist/hooks/NewOrgConfig/index.js +10 -10
  190. package/dist/hooks/Search/index.cjs +25 -23
  191. package/dist/hooks/Search/index.js +25 -23
  192. package/dist/hooks/SearchOperations/index.cjs +19 -20
  193. package/dist/hooks/SearchOperations/index.js +19 -20
  194. package/dist/hooks/SessionStorageOperations/index.cjs +1 -1
  195. package/dist/hooks/SessionStorageOperations/index.js +1 -1
  196. package/dist/hooks/ShopifyUrlOperations/index.cjs +2 -2
  197. package/dist/hooks/ShopifyUrlOperations/index.d.cts +2 -2
  198. package/dist/hooks/ShopifyUrlOperations/index.d.ts +2 -2
  199. package/dist/hooks/ShopifyUrlOperations/index.js +2 -2
  200. package/dist/hooks/SystemSettingsContext/index.cjs +3 -3
  201. package/dist/hooks/SystemSettingsContext/index.d.cts +4 -4
  202. package/dist/hooks/SystemSettingsContext/index.d.ts +4 -4
  203. package/dist/hooks/SystemSettingsContext/index.js +3 -3
  204. package/dist/hooks/TrackComponentVisibleEvent/index.cjs +18 -16
  205. package/dist/hooks/TrackComponentVisibleEvent/index.js +18 -16
  206. package/dist/hooks/UpdateAnalyticsProps/index.cjs +20 -18
  207. package/dist/hooks/UpdateAnalyticsProps/index.js +17 -15
  208. package/dist/hooks/utils.cjs +1 -1
  209. package/dist/hooks/utils.d.cts +1 -1
  210. package/dist/hooks/utils.js +1 -1
  211. package/dist/{index-CAhGZxMI.d.ts → index-5li6ZMDu.d.ts} +1 -1
  212. package/dist/{index-ca7Qn8o0.d.cts → index-BbqT4BQv.d.cts} +1 -1
  213. package/dist/{index-w64il54a.d.cts → index-CAJq_8bO.d.cts} +1 -1
  214. package/dist/index-CMZcE7pk.d.cts +1 -1
  215. package/dist/{index-BQpWG3Jm.d.cts → index-ChiZg0yw.d.cts} +1 -1
  216. package/dist/{index-DNccxbJi.d.ts → index-CsmO1rDH.d.ts} +1 -1
  217. package/dist/{index-Dgu085Lu.d.ts → index-CuihhoIF.d.ts} +2 -2
  218. package/dist/{index-BR1G8yyg.d.ts → index-DtzPIcQp.d.ts} +1 -1
  219. package/dist/{index-ZQMda2Iu.d.ts → index-bEjLKG_Q.d.ts} +1 -1
  220. package/dist/{index-DiIHuPq2.d.ts → index-jFQefHda.d.ts} +1 -1
  221. package/dist/{index-BO-ZLYtR.d.ts → index-mv7KvWDq.d.ts} +1 -1
  222. package/dist/{index-ClVBVK15.d.cts → index-npqPeJ1g.d.cts} +1 -1
  223. package/dist/interceptors/index.cjs +1 -1
  224. package/dist/interceptors/index.d.cts +1 -1
  225. package/dist/interceptors/index.d.ts +1 -1
  226. package/dist/interceptors/index.js +1 -1
  227. package/dist/{localStorageContext-p_4U0RPI.js → localStorageContext-BFwvuEcf.js} +2 -2
  228. package/dist/{localStorageContext-CPrkpt8i.cjs → localStorageContext-CWc5xJ6U.cjs} +2 -2
  229. package/dist/{locators-BMQGmGLq.js → locators-C2fWd-74.js} +1 -1
  230. package/dist/{locators-DxYdak1F.cjs → locators-Cx3q6Z_h.cjs} +1 -1
  231. package/dist/{models-L2w8FYCa.js → models-Cw0QcbQv.js} +2 -2
  232. package/dist/{models-OyYkll03.cjs → models-Dl0_Ujgj.cjs} +2 -2
  233. package/dist/{newOrgConfigAtom-Dsk0fJNR.js → newOrgConfigAtom-BuQE_zPK.js} +1 -1
  234. package/dist/{newOrgConfigAtom-hs5A1pbZ.cjs → newOrgConfigAtom-rrYHmp1b.cjs} +1 -1
  235. package/dist/{newOrgConfigContext-BuqDUkPz.js → newOrgConfigContext-D-gU5ppl.js} +5 -5
  236. package/dist/{newOrgConfigContext-N4CQzvlH.cjs → newOrgConfigContext-d3RHl430.cjs} +5 -5
  237. package/dist/{nodeSelector-0gJ8Xayf.d.ts → nodeSelector-BAKg1h_y.d.ts} +1 -1
  238. package/dist/{nodeSelector-Cj-Xl1LP.d.cts → nodeSelector-BYEAyrsj.d.cts} +1 -1
  239. package/dist/org-15F128Ah.js +32 -0
  240. package/dist/org-CIFgIcO4.cjs +111 -0
  241. package/dist/{search-C_N_oRVZ.js → search--80x6CfL.js} +5 -5
  242. package/dist/{search-8bPfo07V.cjs → search-Ch6LKNh4.cjs} +5 -5
  243. package/dist/{searchContext-DdJbpDsU.cjs → searchContext-B0qEUoKb.cjs} +6 -6
  244. package/dist/{searchContext-BohH5i8s.js → searchContext-BkPoTq1o.js} +6 -6
  245. package/dist/{searchServiceAdapter-BSPZOg1r.js → searchServiceAdapter-B0h7psvh.js} +1 -1
  246. package/dist/{searchServiceAdapter-DrjFCiw8.cjs → searchServiceAdapter-BclWy4fE.cjs} +1 -1
  247. package/dist/{sessionStorageContext-CH37Dkb-.cjs → sessionStorageContext-BuWrJQwc.cjs} +1 -1
  248. package/dist/{sessionStorageContext-CqrutoVq.js → sessionStorageContext-DvFHbk81.js} +1 -1
  249. package/dist/{shopifyUrlContext-Ba6MQdNV.cjs → shopifyUrlContext-Bw1kAZ2P.cjs} +2 -2
  250. package/dist/{shopifyUrlContext-BI3fVtA5.js → shopifyUrlContext-DnJiUmMA.js} +2 -2
  251. package/dist/src/application/commerce-api.js +408 -0
  252. package/dist/src/application/logging/logger.js +16 -0
  253. package/dist/src/application/models/graphql/index.js +3 -0
  254. package/dist/src/application/models/graphql/queries/getMerchantColorsQuery.js +13 -0
  255. package/dist/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.js +13 -0
  256. package/dist/src/application/models/graphql/queries/getMerchantOrgIdQuery.js +10 -0
  257. package/dist/src/application/models/guards/api/index.js +12 -0
  258. package/dist/src/application/models/guards/api/isApiFormResponse.js +59 -0
  259. package/dist/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.js +22 -0
  260. package/dist/src/application/models/guards/api/isApiOrderResponseAttributes.js +91 -0
  261. package/dist/src/application/models/guards/api/isApiOrgConfigResults.js +188 -0
  262. package/dist/src/application/models/guards/api/isApiOrganizationConfig.js +115 -0
  263. package/dist/src/application/models/guards/api/isApiPDPEventAttributes.js +16 -0
  264. package/dist/src/application/models/guards/api/isApiPLPEventAttributes.js +26 -0
  265. package/dist/src/application/models/guards/api/isApiPageResponseAttributes.js +15 -0
  266. package/dist/src/application/models/guards/api/isApiProductResponseAttributes.js +65 -0
  267. package/dist/src/application/models/guards/api/isApiProductSearchAttributes.js +15 -0
  268. package/dist/src/application/models/guards/api/isApiProductSearchFilterAttributes.js +10 -0
  269. package/dist/src/application/models/guards/api/isApiQueryTypedEventAttributes.js +4 -0
  270. package/dist/src/application/models/guards/api/isApiResponse.js +33 -0
  271. package/dist/src/application/models/guards/api/isApiReviewResponseAttributes.js +22 -0
  272. package/dist/src/application/models/guards/api/isApiReviewRichInformation.js +23 -0
  273. package/dist/src/application/models/guards/api/isApiSearchEventAttributes.js +20 -0
  274. package/dist/src/application/models/guards/api/isApiSuggestion.js +24 -0
  275. package/dist/src/application/models/guards/api/isApiSuggestionClickedEventAttributes.js +4 -0
  276. package/dist/src/application/models/guards/api/isApiTextResponseAttributes.js +4 -0
  277. package/dist/src/application/models/guards/api/isApiUserEvent.js +18 -0
  278. package/dist/src/application/models/guards/graphQL/isGraphQLColorsConfig.js +41 -0
  279. package/dist/src/application/models/guards/isBaseEcommerceEvent.js +14 -0
  280. package/dist/src/application/models/guards/isGA4EcommerceEvent.js +14 -0
  281. package/dist/src/application/models/guards/isLegacyUAEcommerceEvent.js +14 -0
  282. package/dist/src/application/models/guards/isMobilePLPChatPlacementParameter.js +4 -0
  283. package/dist/src/application/models/guards/isSpanxTakeAQuizCtaParameter.js +1 -0
  284. package/dist/src/application/models/guards/isVariantInfo.js +28 -0
  285. package/dist/src/application/models/guards/utils.js +34 -0
  286. package/dist/src/application/models/index.js +34 -0
  287. package/dist/src/application/models/utils/snakeToCamelTransformer.js +71 -0
  288. package/dist/src/application/models/utils/stringToFulfillmentDisplayStatusEnumValue.js +65 -0
  289. package/dist/src/application/models/validators/validateGraphQLColorsConfig.js +9 -0
  290. package/dist/src/application/models/validators/validateGraphQLFrontendConfig.js +420 -0
  291. package/dist/src/application/models/validators/validateGraphQLOrgId.js +6 -0
  292. package/dist/src/application/models/validators/validateMobilePLPChatPlacementParameter.js +9 -0
  293. package/dist/src/application/models/validators/validateOrgConfigResults.js +44 -0
  294. package/dist/src/application/models/validators/validateOrganizationConfig.js +34 -0
  295. package/dist/src/application/models/validators/validateResponse.js +173 -0
  296. package/dist/src/application/models/validators/validateSuggestion.js +13 -0
  297. package/dist/src/application/models/validators/validateUserEvent.js +91 -0
  298. package/dist/src/application/utils/analyticsUtils.js +95 -0
  299. package/dist/src/application/utils/coreContextToApiContext.js +8 -0
  300. package/dist/src/application/utils/coreUserEventToApiUserEvent.js +90 -0
  301. package/dist/src/application/utils/divideArray.js +7 -0
  302. package/dist/src/application/utils/domObserver.js +85 -0
  303. package/dist/src/application/utils/elementObserver.js +186 -0
  304. package/dist/src/application/utils/imageFilter.js +11 -0
  305. package/dist/src/application/utils/index.js +21 -0
  306. package/dist/src/application/utils/merchantUtils.js +15 -0
  307. package/dist/src/application/utils/messageFromFormSubmittedEvent.js +19 -0
  308. package/dist/src/application/utils/messageFromQueryEvent.js +35 -0
  309. package/dist/src/application/utils/messageFromResponse.js +123 -0
  310. package/dist/src/application/utils/messageFromSuggestionEvent.js +27 -0
  311. package/dist/src/application/utils/mouseEventTypes.js +1 -0
  312. package/dist/src/application/utils/mutationHelper.js +33 -0
  313. package/dist/src/application/utils/nextMessageRequestToApiRequest.js +29 -0
  314. package/dist/src/application/utils/nodeSelector.js +101 -0
  315. package/dist/src/application/utils/overrides.js +144 -0
  316. package/dist/src/application/utils/stringUtils.js +47 -0
  317. package/dist/src/application/utils/supportedEventRequestToApiRequest.js +7 -0
  318. package/dist/src/application/utils/urlsParser.js +33 -0
  319. package/dist/src/application/utils/validation.js +5 -0
  320. package/dist/src/atoms/amplitude/amplitudeTrackEventAtom.js +4 -0
  321. package/dist/src/atoms/app/index.js +23 -0
  322. package/dist/src/atoms/app/variant.js +102 -0
  323. package/dist/src/atoms/atomStore/atomStore.js +28 -0
  324. package/dist/src/atoms/atomStore/index.js +1 -0
  325. package/dist/src/atoms/chat/chatState.js +32 -0
  326. package/dist/src/atoms/chat/form.js +16 -0
  327. package/dist/src/atoms/chat/index.js +23 -0
  328. package/dist/src/atoms/chat/lastMessage.js +10 -0
  329. package/dist/src/atoms/chat/messageQueue.js +68 -0
  330. package/dist/src/atoms/chat/performanceMetrics.js +70 -0
  331. package/dist/src/atoms/chat/renderedWidgetRefs.js +24 -0
  332. package/dist/src/atoms/chat/replies.js +42 -0
  333. package/dist/src/atoms/chat/suggestions.js +29 -0
  334. package/dist/src/atoms/envive/enviveConfig.js +67 -0
  335. package/dist/src/atoms/globalSearch/globalSearch.js +8 -0
  336. package/dist/src/atoms/globalSearch/index.js +1 -0
  337. package/dist/src/atoms/org/customerService.js +6 -0
  338. package/dist/src/atoms/org/graphqlConfig.js +8 -0
  339. package/dist/src/atoms/org/index.js +4 -0
  340. package/dist/src/atoms/org/newOrgConfigAtom.js +2 -0
  341. package/dist/src/atoms/org/orgAnalyticsConfig.js +8 -0
  342. package/dist/src/atoms/search/index.js +1 -0
  343. package/dist/src/atoms/search/productFilters.js +163 -0
  344. package/dist/src/atoms/search/productRetrievalAPI.js +50 -0
  345. package/dist/src/atoms/search/productRetrievalAdapter.js +14 -0
  346. package/dist/src/atoms/search/productSorter.js +13 -0
  347. package/dist/src/atoms/search/searchAPI.js +140 -0
  348. package/dist/src/atoms/search/searchServiceAdapter.js +14 -0
  349. package/dist/src/atoms/search/utils.js +15 -0
  350. package/dist/src/config/index.js +1 -0
  351. package/dist/src/config/locators/components/chat/entrypoints.js +10 -0
  352. package/dist/src/config/locators/components/chat/index.js +21 -0
  353. package/dist/src/config/locators/components/chat/preview.js +11 -0
  354. package/dist/src/config/locators/components/chat/variants/index.js +12 -0
  355. package/dist/src/config/locators/components/common/buttons.js +6 -0
  356. package/dist/src/config/locators/components/common/cards.js +17 -0
  357. package/dist/src/config/locators/components/common/index.js +4 -0
  358. package/dist/src/config/locators/components/common/links.js +1 -0
  359. package/dist/src/config/locators/components/common/tables.js +1 -0
  360. package/dist/src/config/locators/components/floating-button.js +2 -0
  361. package/dist/src/config/locators/components/index.js +3 -0
  362. package/dist/src/config/locators/components/report-issue.js +13 -0
  363. package/dist/src/config/locators/components/search/index.js +5 -0
  364. package/dist/src/config/locators/components/shadow-dom.js +1 -0
  365. package/dist/src/config/locators/embedded.js +20 -0
  366. package/dist/src/config/locators/index.js +4 -0
  367. package/dist/src/contexts/amplitudeContext/amplitudeContext.js +271 -0
  368. package/dist/src/contexts/amplitudeContext/index.js +1 -0
  369. package/dist/src/contexts/cdnContext/cdnContext.js +28 -0
  370. package/dist/src/contexts/cdnContext/index.js +1 -0
  371. package/dist/src/contexts/enviveConfigContext/enviveConfigContext.js +37 -0
  372. package/dist/src/contexts/enviveConfigContext/index.js +1 -0
  373. package/dist/src/contexts/enviveCssContext/enviveCssContext.js +31 -0
  374. package/dist/src/contexts/enviveCssContext/index.js +1 -0
  375. package/dist/src/contexts/featureFlagContext/featureFlagContext.js +109 -0
  376. package/dist/src/contexts/featureFlagContext/index.js +1 -0
  377. package/dist/src/contexts/featureFlagServiceContext/featureFlagServiceContext.js +47 -0
  378. package/dist/src/contexts/featureFlagServiceContext/index.js +1 -0
  379. package/dist/src/contexts/graphqlContext/graphqlContext.js +87 -0
  380. package/dist/src/contexts/graphqlContext/index.js +1 -0
  381. package/dist/src/contexts/localStorageContext/index.js +1 -0
  382. package/dist/src/contexts/localStorageContext/localStorageContext.js +95 -0
  383. package/dist/src/contexts/newOrgConfigContext/index.js +1 -0
  384. package/dist/src/contexts/newOrgConfigContext/newOrgConfigContext.js +33 -0
  385. package/dist/src/contexts/searchContext/index.js +1 -0
  386. package/dist/src/contexts/searchContext/searchContext.js +131 -0
  387. package/dist/src/contexts/sessionStorageContext/index.js +1 -0
  388. package/dist/src/contexts/sessionStorageContext/sessionStorageContext.js +43 -0
  389. package/dist/src/contexts/shopifyUrlContext/index.js +1 -0
  390. package/dist/src/contexts/shopifyUrlContext/shopifyUrlContext.js +62 -0
  391. package/dist/src/contexts/systemSettingsContext/index.js +1 -0
  392. package/dist/src/contexts/systemSettingsContext/systemSettingsContext.js +29 -0
  393. package/dist/src/contexts/userIdentityContext/index.js +1 -0
  394. package/dist/src/contexts/userIdentityContext/userIdentityContext.js +118 -0
  395. package/dist/src/events/index.js +51 -0
  396. package/dist/src/events/registerAnalyticsListeners.js +32 -0
  397. package/dist/src/exceptions/index.js +2 -0
  398. package/dist/src/exceptions/sessionExceptions.js +6 -0
  399. package/dist/src/exceptions/unsupportedProductExceptions.js +6 -0
  400. package/dist/src/hooks/AmplitudeOperations/index.js +1 -0
  401. package/dist/src/hooks/AmplitudeOperations/useAmplitudeOperations.js +24 -0
  402. package/dist/src/hooks/AppDetails/index.js +1 -0
  403. package/dist/src/hooks/AppDetails/useAppDetails.js +26 -0
  404. package/dist/src/hooks/BlockBackButton/index.js +1 -0
  405. package/dist/src/hooks/BlockBackButton/useBlockBackButton.js +23 -0
  406. package/dist/src/hooks/CdnOperations/index.js +1 -0
  407. package/dist/src/hooks/CdnOperations/useCdnOperations.js +13 -0
  408. package/dist/src/hooks/ChatToggle/index.js +1 -0
  409. package/dist/src/hooks/ChatToggle/useChatToggle.js +50 -0
  410. package/dist/src/hooks/ChatToggleAnalytics/index.js +1 -0
  411. package/dist/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.js +11 -0
  412. package/dist/src/hooks/CustomerSupportHandoff/index.js +1 -0
  413. package/dist/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.js +32 -0
  414. package/dist/src/hooks/Debounce/index.js +1 -0
  415. package/dist/src/hooks/Debounce/useDebounce.js +13 -0
  416. package/dist/src/hooks/ElementObserver/index.js +1 -0
  417. package/dist/src/hooks/ElementObserver/useElementObserver.js +208 -0
  418. package/dist/src/hooks/GrabAndScroll/index.js +1 -0
  419. package/dist/src/hooks/GrabAndScroll/useGrabAndScroll.js +105 -0
  420. package/dist/src/hooks/GraphQLConfig/index.js +1 -0
  421. package/dist/src/hooks/GraphQLConfig/useGraphQLConfig.js +54 -0
  422. package/dist/src/hooks/IdentifyUser/index.js +1 -0
  423. package/dist/src/hooks/IdentifyUser/useIdentifyUser.js +28 -0
  424. package/dist/src/hooks/ImageResolver/index.js +1 -0
  425. package/dist/src/hooks/ImageResolver/useImageResolver.js +45 -0
  426. package/dist/src/hooks/Intersection/index.js +1 -0
  427. package/dist/src/hooks/Intersection/useIntersection.js +20 -0
  428. package/dist/src/hooks/IsSmallScreen/index.js +1 -0
  429. package/dist/src/hooks/IsSmallScreen/useIsSmallScreen.js +16 -0
  430. package/dist/src/hooks/LocalStorageOperations/index.js +1 -0
  431. package/dist/src/hooks/LocalStorageOperations/useLocalStorageOperations.js +64 -0
  432. package/dist/src/hooks/MessageFilter/index.js +1 -0
  433. package/dist/src/hooks/MessageFilter/useMessageFilter.js +37 -0
  434. package/dist/src/hooks/MessageScrollObserver/index.js +1 -0
  435. package/dist/src/hooks/MessageScrollObserver/useMessageScrollObserver.js +35 -0
  436. package/dist/src/hooks/NewOrgConfig/index.js +1 -0
  437. package/dist/src/hooks/NewOrgConfig/useNewOrgConfig.js +5 -0
  438. package/dist/src/hooks/Search/index.js +1 -0
  439. package/dist/src/hooks/Search/useRecommendedProducts.js +35 -0
  440. package/dist/src/hooks/Search/useSearch.js +224 -0
  441. package/dist/src/hooks/Search/useSearchInput.js +192 -0
  442. package/dist/src/hooks/SearchOperations/index.js +1 -0
  443. package/dist/src/hooks/SearchOperations/useSearchOperations.js +78 -0
  444. package/dist/src/hooks/SessionStorageOperations/index.js +1 -0
  445. package/dist/src/hooks/SessionStorageOperations/useSessionStorageOperations.js +20 -0
  446. package/dist/src/hooks/ShopifyUrlOperations/index.js +1 -0
  447. package/dist/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.js +34 -0
  448. package/dist/src/hooks/SnapCalculator/index.js +1 -0
  449. package/dist/src/hooks/SnapCalculator/useSnapCalculator.js +22 -0
  450. package/dist/src/hooks/SystemSettingsContext/index.js +1 -0
  451. package/dist/src/hooks/SystemSettingsContext/useSystemSettingsContext.js +9 -0
  452. package/dist/src/hooks/TrackComponentVisibleEvent/index.js +1 -0
  453. package/dist/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +45 -0
  454. package/dist/src/hooks/UpdateAnalyticsProps/index.js +1 -0
  455. package/dist/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +43 -0
  456. package/dist/src/hooks/utils.js +116 -0
  457. package/dist/src/interceptors/index.js +1 -0
  458. package/dist/src/interceptors/useMessageInterceptor.js +24 -0
  459. package/dist/src/types/ApiResponse.js +1 -0
  460. package/dist/src/types/FilterAttribute.js +3 -0
  461. package/dist/src/types/Message.js +24 -0
  462. package/dist/src/types/Suggestion.js +3 -0
  463. package/dist/src/types/index.js +4 -0
  464. package/dist/src/util/colorVar.js +3 -0
  465. package/dist/src/util/configVersion.js +4 -0
  466. package/dist/src/util/domInsertion.js +16 -0
  467. package/dist/{systemSettingsContext-CYce8iqH.cjs → systemSettingsContext-068vQuP2.cjs} +2 -2
  468. package/dist/{systemSettingsContext-D9BZ9EwQ.js → systemSettingsContext-DPdDfVhj.js} +2 -2
  469. package/dist/types/index.d.ts +1 -1
  470. package/dist/{urlsParser-C-Vzs--G.cjs → urlsParser-bb8ciRFg.cjs} +1 -1
  471. package/dist/{urlsParser-G7Ocwg0M.js → urlsParser-v_1DKvyf.js} +1 -1
  472. package/dist/{useAppDetails-CSpw8teP.js → useAppDetails-BPXln8UE.js} +4 -4
  473. package/dist/{useAppDetails-DNG_-DI9.cjs → useAppDetails-eP2hBuid.cjs} +7 -7
  474. package/dist/{useGraphQLConfig-D1REGfFB.js → useGraphQLConfig-Btszi6cG.js} +2 -2
  475. package/dist/{useGraphQLConfig-CKtaLlQ-.cjs → useGraphQLConfig-v9veUbvJ.cjs} +2 -2
  476. package/dist/{useIntersection-BQMfiS4x.cjs → useIntersection-BcBCa890.cjs} +1 -1
  477. package/dist/{useIntersection-D-ol9eH8.js → useIntersection-BkMkuJcZ.js} +1 -1
  478. package/dist/{utils-sosM0bEk.d.ts → utils-BitIIghf.d.ts} +1 -1
  479. package/dist/{utils-hYTjy7hJ.cjs → utils-CJk5iwQI.cjs} +1 -1
  480. package/dist/utils-CWzuvlOR.js +607 -0
  481. package/dist/{utils-BBICrPjW.cjs → utils-CqVRbvfN.cjs} +1 -1
  482. package/dist/{utils-w4-xONRA.js → utils-DQhbbAnt.js} +1 -1
  483. package/dist/{utils-D_kATUj6.js → utils-D_nGHczN.js} +1 -1
  484. package/dist/utils-SjlIHajO.cjs +716 -0
  485. package/package.json +1 -1
  486. package/src/application/commerce-api.ts +2 -0
  487. package/src/application/utils/analyticsUtils.ts +31 -16
  488. package/src/atoms/amplitude/amplitudeTrackEventAtom.ts +1 -1
  489. package/src/atoms/chat/chatState.ts +12 -7
  490. package/src/atoms/chat/replies.ts +42 -40
  491. package/src/contexts/amplitudeContext/amplitudeContext.tsx +116 -130
  492. package/dist/amplitudeContext-CMTvCsJC.d.ts +0 -52
  493. package/dist/amplitudeContext-ZkerrMUa.d.cts +0 -52
  494. package/dist/amplitudeTrackEventAtom-D9vs8dpE.cjs +0 -15
  495. package/dist/amplitudeTrackEventAtom-iEIu11Om.js +0 -8
  496. package/dist/chat-ChCtIEwh.js +0 -227
  497. package/dist/chatState-BYB77nbx.cjs +0 -120
  498. package/dist/chatState-CzH7APPP.js +0 -34
  499. package/dist/org-C2kLSSe9.cjs +0 -111
  500. package/dist/org-CIczyLRP.js +0 -32
  501. package/dist/utils-DGpMn2pp.js +0 -1364
  502. package/dist/utils-DqxtxrFe.cjs +0 -1546
  503. /package/dist/{featureFlagServiceContext-DgoR6euC.js → featureFlagServiceContext-CISyb90N.js} +0 -0
  504. /package/dist/{featureFlagServiceContext-b-rYgf0u.cjs → featureFlagServiceContext-Csgo-MUv.cjs} +0 -0
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo } from "react";
3
+ import { FeatureGates } from "@envive-ai/types";
4
+ import Logger from "src/application/logging/logger";
5
+ // This is the class that was previously implicitly used or defined elsewhere
6
+ export class FeatureFlagService {
7
+ constructor(featureGates) {
8
+ this.isFeatureGateEnabled = (featureGate) => {
9
+ const gateValue = this.featureGates.find((gate) => gate.name === featureGate);
10
+ // TODO: Add logic for overrides (query params, window, stored) if needed, similar to the old FeatureFlagContext.tsx
11
+ // For now, direct value from config is used.
12
+ if (gateValue == null || gateValue.value == null) {
13
+ Logger.logDebug(`[spiffy-ai] isFeatureGateEnabled featureGate:${featureGate} value is undefined - returning false`);
14
+ return false;
15
+ }
16
+ return gateValue.value;
17
+ };
18
+ this.isClientSessionEnabled = () => {
19
+ const isEnabled = this.featureGates.filter((gate) => gate.name === FeatureGates.IsClientSessionEnabled &&
20
+ gate.value === true).length > 0;
21
+ return isEnabled;
22
+ };
23
+ this.getFeatureFlags = () => {
24
+ return Object.fromEntries(Object.values(FeatureGates).map((featureGate) => [
25
+ featureGate,
26
+ this.isFeatureGateEnabled(featureGate),
27
+ ]));
28
+ };
29
+ this.featureGates = featureGates;
30
+ }
31
+ }
32
+ const FeatureFlagServiceContext = createContext(undefined);
33
+ export const FeatureFlagServiceProvider = ({ featureGates, children }) => {
34
+ const featureFlagService = useMemo(() => new FeatureFlagService(featureGates), [featureGates]);
35
+ const contextValue = useMemo(() => ({
36
+ featureFlagService,
37
+ isFeatureGateEnabled: featureFlagService.isFeatureGateEnabled,
38
+ }), [featureFlagService]);
39
+ return (_jsx(FeatureFlagServiceContext.Provider, { value: contextValue, children: children }));
40
+ };
41
+ export const useFeatureFlagService = () => {
42
+ const context = useContext(FeatureFlagServiceContext);
43
+ if (context === undefined) {
44
+ throw new Error("useFeatureFlagService must be used within a FeatureFlagServiceProvider");
45
+ }
46
+ return context;
47
+ };
@@ -0,0 +1 @@
1
+ export * from "./featureFlagServiceContext";
@@ -0,0 +1,87 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useCallback, useMemo } from 'react';
3
+ import { useAtomValue } from 'jotai';
4
+ import { baseUrlAtom, orgLevelApiKeyAtom } from '../../atoms/envive/enviveConfig';
5
+ import { getMerchantOrgIdQuery } from '../../application/models/graphql/queries/getMerchantOrgIdQuery';
6
+ import { validateGraphQLOrgId } from '../../application/models/validators/validateGraphQLOrgId';
7
+ import Logger from '../../application/logging/logger';
8
+ import { transformSnakeToCamel } from '../../application/models';
9
+ import { configVersion } from '../../util/configVersion';
10
+ const GraphQLContext = createContext(null);
11
+ const colorsAndFrontendConfigQuery = () => `
12
+ query ($version: String = "${configVersion()}") {
13
+ me {
14
+ getProductsConfigByVersion(version: $version) {
15
+ frontend { values }
16
+ colors { values }
17
+ }
18
+ }
19
+ }
20
+ `;
21
+ export const GraphQLProvider = ({ children }) => {
22
+ const apiKey = useAtomValue(orgLevelApiKeyAtom);
23
+ const baseUrl = useAtomValue(baseUrlAtom);
24
+ const isReady = Boolean(apiKey && baseUrl);
25
+ const executeQuery = useCallback(async (query, variables) => {
26
+ if (!isReady) {
27
+ throw new Error('GraphQL client not ready - missing apiKey or baseUrl');
28
+ }
29
+ const response = await fetch(`${baseUrl}/v1/graphql`, {
30
+ method: 'POST',
31
+ headers: {
32
+ 'Content-Type': 'application/json',
33
+ Authorization: `Bearer ${apiKey}`,
34
+ },
35
+ body: JSON.stringify({ query, variables }),
36
+ });
37
+ if (!response.ok) {
38
+ throw new Error(`GraphQL request failed: ${response.statusText}`);
39
+ }
40
+ const result = await response.json();
41
+ if (result.errors) {
42
+ throw new Error(`GraphQL errors: ${JSON.stringify(result.errors)}`);
43
+ }
44
+ return result.data;
45
+ }, [apiKey, baseUrl, isReady]);
46
+ const getOrgId = useCallback(async () => {
47
+ var _a;
48
+ const response = await executeQuery(getMerchantOrgIdQuery);
49
+ return validateGraphQLOrgId((_a = response.me.org) === null || _a === void 0 ? void 0 : _a.id);
50
+ }, [executeQuery]);
51
+ const getColorsAndFrontendConfig = useCallback(async () => {
52
+ var _a, _b, _c, _d;
53
+ try {
54
+ const query = await colorsAndFrontendConfigQuery();
55
+ if (!query) {
56
+ throw new Error('Colors and frontend config query is not defined');
57
+ }
58
+ const response = await executeQuery(query);
59
+ const colorsConfig = (_b = (_a = response.me.getProductsConfigByVersion) === null || _a === void 0 ? void 0 : _a.colors) === null || _b === void 0 ? void 0 : _b.values;
60
+ const frontendConfig = (_d = (_c = response.me.getProductsConfigByVersion) === null || _c === void 0 ? void 0 : _c.frontend) === null || _d === void 0 ? void 0 : _d.values;
61
+ const transformedColorConfig = transformSnakeToCamel(colorsConfig);
62
+ const transformedFrontendConfig = transformSnakeToCamel(frontendConfig);
63
+ return {
64
+ colorsConfig: transformedColorConfig,
65
+ frontendConfig: transformedFrontendConfig,
66
+ };
67
+ }
68
+ catch (err) {
69
+ Logger.logError('Error fetching graphql colors and frontend config', err);
70
+ return { colorsConfig: undefined, frontendConfig: undefined };
71
+ }
72
+ }, [executeQuery]);
73
+ const value = useMemo(() => ({
74
+ executeQuery,
75
+ getOrgId,
76
+ getColorsAndFrontendConfig,
77
+ isReady,
78
+ }), [executeQuery, getOrgId, getColorsAndFrontendConfig, isReady]);
79
+ return _jsx(GraphQLContext.Provider, { value: value, children: children });
80
+ };
81
+ export const useGraphQLClient = () => {
82
+ const context = useContext(GraphQLContext);
83
+ if (!context) {
84
+ throw new Error('useGraphQLClient must be used within a GraphQLProvider');
85
+ }
86
+ return context;
87
+ };
@@ -0,0 +1 @@
1
+ export * from "./graphqlContext";
@@ -0,0 +1 @@
1
+ export * from "./localStorageContext";
@@ -0,0 +1,95 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useCallback, useMemo, useEffect } from 'react';
3
+ import Logger from '../../application/logging/logger';
4
+ import { LocalStorageKeys, } from '@envive-ai/types';
5
+ const LocalStorageContext = createContext(null);
6
+ export const LocalStorageProvider = ({ children }) => {
7
+ const isAvailable = useMemo(() => {
8
+ try {
9
+ return typeof window !== 'undefined' && !!window.localStorage;
10
+ }
11
+ catch {
12
+ return false;
13
+ }
14
+ }, []);
15
+ useEffect(() => {
16
+ if (!isAvailable) {
17
+ Logger.logError('localStorage is not available', undefined);
18
+ }
19
+ }, [isAvailable]);
20
+ const setItem = useCallback((key, value) => {
21
+ if (!isAvailable)
22
+ return;
23
+ localStorage.setItem(key, value);
24
+ window.dispatchEvent(new StorageEvent('storage', { key, newValue: value }));
25
+ }, [isAvailable]);
26
+ const getItem = useCallback((key) => {
27
+ if (!isAvailable)
28
+ return null;
29
+ return localStorage.getItem(key);
30
+ }, [isAvailable]);
31
+ const setSpiffyOnFeatureFlag = useCallback((value) => {
32
+ if (!isAvailable)
33
+ return;
34
+ if (value === true) {
35
+ localStorage.setItem(LocalStorageKeys.SpiffyOnOverride, 'true');
36
+ }
37
+ else if (value === false) {
38
+ localStorage.setItem(LocalStorageKeys.SpiffyOnOverride, 'false');
39
+ }
40
+ }, [isAvailable]);
41
+ const getSpiffyOnFeatureFlag = useCallback(() => {
42
+ if (!isAvailable)
43
+ return null;
44
+ return localStorage.getItem(LocalStorageKeys.SpiffyOnOverride);
45
+ }, [isAvailable]);
46
+ const listenersCache = useMemo(() => new Map(), []);
47
+ const listenerForKey = useCallback((listener) => {
48
+ if (!listenersCache.has(listener.storageKey)) {
49
+ const handler = (event) => {
50
+ if (event.key !== listener.storageKey) {
51
+ return;
52
+ }
53
+ Logger.logDebug(`[spiffy-ai] Storage event key=${event.key}, value=`, event.newValue);
54
+ listener.listener(event);
55
+ };
56
+ listenersCache.set(listener.storageKey, handler);
57
+ }
58
+ return listenersCache.get(listener.storageKey);
59
+ }, [listenersCache]);
60
+ const attachListener = useCallback((listener) => {
61
+ if (!isAvailable)
62
+ return;
63
+ window.addEventListener('storage', listenerForKey(listener));
64
+ }, [isAvailable, listenerForKey]);
65
+ const detachListener = useCallback((listener) => {
66
+ if (!isAvailable)
67
+ return;
68
+ window.removeEventListener('storage', listenerForKey(listener));
69
+ }, [isAvailable, listenerForKey]);
70
+ const value = useMemo(() => ({
71
+ setItem,
72
+ getItem,
73
+ setSpiffyOnFeatureFlag,
74
+ getSpiffyOnFeatureFlag,
75
+ attachListener,
76
+ detachListener,
77
+ isAvailable,
78
+ }), [
79
+ setItem,
80
+ getItem,
81
+ setSpiffyOnFeatureFlag,
82
+ getSpiffyOnFeatureFlag,
83
+ attachListener,
84
+ detachListener,
85
+ isAvailable,
86
+ ]);
87
+ return _jsx(LocalStorageContext.Provider, { value: value, children: children });
88
+ };
89
+ export const useLocalStorage = () => {
90
+ const context = useContext(LocalStorageContext);
91
+ if (!context) {
92
+ throw new Error('useLocalStorage must be used within a LocalStorageProvider');
93
+ }
94
+ return context;
95
+ };
@@ -0,0 +1 @@
1
+ export * from "./newOrgConfigContext";
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo } from 'react';
3
+ import { useAtomValue, useSetAtom } from 'jotai';
4
+ import { useColorsAndFrontendConfig } from 'src/hooks/GraphQLConfig/useGraphQLConfig';
5
+ import { orgShortNameAtom } from 'src/atoms/envive/enviveConfig';
6
+ import { newOrgConfigAtom } from 'src/atoms/org/newOrgConfigAtom';
7
+ import { FeatureFlagServiceProvider } from '../featureFlagServiceContext';
8
+ const NewOrgConfigContext = createContext(undefined);
9
+ export const NewOrgConfigProvider = ({ children }) => {
10
+ const orgShortName = useAtomValue(orgShortNameAtom);
11
+ const setNewOrgConfig = useSetAtom(newOrgConfigAtom);
12
+ const { data: newConfig, loading, error } = useColorsAndFrontendConfig();
13
+ const contextValue = useMemo(() => {
14
+ if (!orgShortName || loading) {
15
+ return { ...newConfig, loading: true, error: null };
16
+ }
17
+ if (error) {
18
+ return { ...newConfig, loading: false, error };
19
+ }
20
+ setNewOrgConfig(newConfig);
21
+ return { ...newConfig, loading: false, error: null };
22
+ }, [orgShortName, loading, error]);
23
+ // TODO: Provide actual featureGates when available in combinedConfig
24
+ const featureGates = [];
25
+ return (_jsx(NewOrgConfigContext.Provider, { value: contextValue, children: _jsx(FeatureFlagServiceProvider, { featureGates: featureGates, children: children }) }));
26
+ };
27
+ export const useNewOrgConfigContext = () => {
28
+ const context = useContext(NewOrgConfigContext);
29
+ if (context === undefined) {
30
+ throw new Error('useNewOrgConfigContext must be used within a NewOrgConfigProvider');
31
+ }
32
+ return context;
33
+ };
@@ -0,0 +1 @@
1
+ export * from "./searchContext";
@@ -0,0 +1,131 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useCallback, useMemo, useEffect } from 'react';
3
+ import { useAtomValue } from 'jotai';
4
+ import { Configuration, ResponseCategory, ResponseError, SearchApi, } from '@spiffy-ai/commerce-api-client';
5
+ import { baseUrlAtom } from '../../atoms/envive/enviveConfig';
6
+ import Logger from '../../application/logging/logger';
7
+ import { SessionRestartRequired, UnsupportedProductException } from '../../exceptions';
8
+ import { useAppDetails } from '../../hooks/AppDetails/useAppDetails';
9
+ import { useEnviveConfig } from '../../contexts/enviveConfigContext/enviveConfigContext';
10
+ import { clearSearchServiceFunction, setSearchServiceFunction, } from '../../atoms/search/searchServiceAdapter';
11
+ const transformProductResponses = (products) => products.map((data) => ({
12
+ id: data.id,
13
+ responseId: data.response_id,
14
+ category: ResponseCategory.Product,
15
+ description: data.description,
16
+ imageUrl: data.image_url,
17
+ imageUrls: data.image_urls,
18
+ title: data.title,
19
+ url: data.url,
20
+ originalPrice: data.original_price,
21
+ salePrice: data.sale_price,
22
+ averageRating: data.average_rating,
23
+ numberReviews: data.number_reviews,
24
+ metadata: data.metadata,
25
+ isForGrid: data.is_for_grid,
26
+ colors: data.colors,
27
+ sizes: data.sizes,
28
+ filters: data.filters,
29
+ }));
30
+ async function errorResponseBody(error) {
31
+ try {
32
+ return await error.response.json();
33
+ }
34
+ catch {
35
+ return {};
36
+ }
37
+ }
38
+ async function throwSessionRestartRequiredIf(errorMsg, error) {
39
+ var _a, _b, _c, _d;
40
+ if (!(error instanceof ResponseError)) {
41
+ Logger.logInfo(errorMsg, error);
42
+ throw error;
43
+ }
44
+ const errorResponse = await errorResponseBody(error);
45
+ if (((_a = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'unsupported product' ||
46
+ ((_b = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.app_code) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === 'PRODUCT_NOT_FOUND') {
47
+ throw new UnsupportedProductException();
48
+ }
49
+ else if (((_c = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.app_code) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === 'RESTART_SESSION' ||
50
+ ((_d = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.sub_code) === null || _d === void 0 ? void 0 : _d.toUpperCase()) === 'NOT_FOUND') {
51
+ Logger.logInfo('Session does not exist. Re-start session', error, error.response, errorResponse);
52
+ throw new SessionRestartRequired();
53
+ }
54
+ Logger.logInfo(errorMsg, error);
55
+ throw error;
56
+ }
57
+ const SearchContext = createContext(undefined);
58
+ export const SearchProvider = ({ children }) => {
59
+ const { orgLevelApiKey, publicKey } = useEnviveConfig();
60
+ const apiKey = orgLevelApiKey || publicKey; // Replicate apiKeyAtom logic
61
+ const appDetails = useAppDetails();
62
+ const baseUrl = useAtomValue(baseUrlAtom);
63
+ const isReady = Boolean(apiKey && appDetails && baseUrl);
64
+ const searchApi = useMemo(() => {
65
+ if (!isReady)
66
+ return null;
67
+ const config = new Configuration({
68
+ accessToken: apiKey,
69
+ basePath: baseUrl,
70
+ headers: {
71
+ 'Content-Type': 'application/json',
72
+ Accept: 'application/json',
73
+ },
74
+ });
75
+ return new SearchApi(config);
76
+ }, [apiKey, baseUrl, isReady]);
77
+ const searchProducts = useCallback(async (params) => {
78
+ if (!isReady || !searchApi) {
79
+ throw new Error('SearchService not ready - missing dependencies');
80
+ }
81
+ try {
82
+ const response = await searchApi.v1SearchQueryGet({
83
+ query: params.query,
84
+ limit: params.limit,
85
+ org_id: appDetails.orgId,
86
+ user_id: appDetails.userId,
87
+ });
88
+ const { products, filters, search_response_id: searchResponseId } = response;
89
+ return {
90
+ products: transformProductResponses(products) || [],
91
+ filters: filters || [],
92
+ totalProductCount: (products === null || products === void 0 ? void 0 : products.length) || 0,
93
+ searchResponseId: searchResponseId || '',
94
+ };
95
+ }
96
+ catch (error) {
97
+ await throwSessionRestartRequiredIf('Failed to search products', error);
98
+ // This part will not be reached if an exception is thrown, but it's required for type safety
99
+ return {
100
+ products: [],
101
+ filters: [],
102
+ totalProductCount: 0,
103
+ searchResponseId: '',
104
+ };
105
+ }
106
+ }, [searchApi, isReady, appDetails]);
107
+ // Register the search function with the adapter for use in atoms
108
+ useEffect(() => {
109
+ if (isReady) {
110
+ setSearchServiceFunction(searchProducts);
111
+ }
112
+ else {
113
+ clearSearchServiceFunction();
114
+ }
115
+ return () => {
116
+ clearSearchServiceFunction();
117
+ };
118
+ }, [searchProducts, isReady]);
119
+ const value = useMemo(() => ({
120
+ searchProducts,
121
+ isReady,
122
+ }), [searchProducts, isReady]);
123
+ return _jsx(SearchContext.Provider, { value: value, children: children });
124
+ };
125
+ export const useSearchService = () => {
126
+ const context = useContext(SearchContext);
127
+ if (!context) {
128
+ throw new Error('useSearchService must be used within a SearchProvider');
129
+ }
130
+ return context;
131
+ };
@@ -0,0 +1 @@
1
+ export * from "./sessionStorageContext";
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useCallback, useMemo, useEffect } from 'react';
3
+ import Logger from '../../application/logging/logger';
4
+ const SessionStorageContext = createContext(null);
5
+ export const SessionStorageProvider = ({ children }) => {
6
+ const isAvailable = useMemo(() => {
7
+ try {
8
+ return typeof window !== 'undefined' && !!window.sessionStorage;
9
+ }
10
+ catch {
11
+ return false;
12
+ }
13
+ }, []);
14
+ useEffect(() => {
15
+ if (!isAvailable) {
16
+ Logger.logError('sessionStorage is not available', undefined);
17
+ }
18
+ }, [isAvailable]);
19
+ const setItem = useCallback((key, value) => {
20
+ if (!isAvailable)
21
+ return;
22
+ sessionStorage.setItem(key, value);
23
+ window.dispatchEvent(new StorageEvent('storage', { key, newValue: value }));
24
+ }, [isAvailable]);
25
+ const getItem = useCallback((key) => {
26
+ if (!isAvailable)
27
+ return null;
28
+ return sessionStorage.getItem(key);
29
+ }, [isAvailable]);
30
+ const value = useMemo(() => ({
31
+ setItem,
32
+ getItem,
33
+ isAvailable,
34
+ }), [setItem, getItem, isAvailable]);
35
+ return _jsx(SessionStorageContext.Provider, { value: value, children: children });
36
+ };
37
+ export const useSessionStorage = () => {
38
+ const context = useContext(SessionStorageContext);
39
+ if (!context) {
40
+ throw new Error('useSessionStorage must be used within a SessionStorageProvider');
41
+ }
42
+ return context;
43
+ };
@@ -0,0 +1 @@
1
+ export * from "./shopifyUrlContext";
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useCallback, useContext, useMemo } from 'react';
3
+ import { parseHref } from '../../application/utils/urlsParser';
4
+ const ShopifyUrlContext = createContext(undefined);
5
+ export const ShopifyUrlProvider = ({ children }) => {
6
+ const isReady = true; // No external dependencies, so always ready
7
+ const getTrimmedPathName = useCallback(() => {
8
+ let { pathname } = window.location;
9
+ // strip out the proxy path so local dev still works
10
+ pathname = pathname.replace('/proxy', '');
11
+ // remove trailing hash if it exists
12
+ pathname = pathname.replace(/#.*$/, '');
13
+ // remove trailing /, ie. some URLs can end with '/' like /collections/cast-iron/
14
+ pathname = pathname.replace(/\/$/, '');
15
+ if (pathname === undefined || pathname === null || pathname.length === 0) {
16
+ return null;
17
+ }
18
+ return pathname;
19
+ }, []);
20
+ const getPlpOrPdpId = useCallback((extractor) => {
21
+ var _a, _b;
22
+ if (extractor === 'shopify-product-variant-id') {
23
+ const parsedHref = parseHref(window.location.href);
24
+ const variantId = (_a = parsedHref === null || parsedHref === void 0 ? void 0 : parsedHref.urlSearchParams) === null || _a === void 0 ? void 0 : _a.get('variant');
25
+ if (!variantId) {
26
+ return getPlpOrPdpId('shopify-product-id');
27
+ }
28
+ return variantId;
29
+ }
30
+ const pathSegment = extractor === 'shopify-product-id' ? 'products' : 'collections';
31
+ const tokens = (_b = getTrimmedPathName()) === null || _b === void 0 ? void 0 : _b.split('/');
32
+ const idIndex = tokens === null || tokens === void 0 ? void 0 : tokens.findIndex((token) => token === pathSegment);
33
+ if (idIndex !== undefined && idIndex >= 0 && tokens) {
34
+ return decodeURIComponent(tokens[idIndex + 1]);
35
+ }
36
+ return null;
37
+ }, [getTrimmedPathName]);
38
+ const isOnPdpPage = useCallback(() => {
39
+ var _a, _b;
40
+ return (_b = (_a = getTrimmedPathName()) === null || _a === void 0 ? void 0 : _a.includes('/products')) !== null && _b !== void 0 ? _b : false;
41
+ }, [getTrimmedPathName]);
42
+ const isOnPlpPage = useCallback(() => {
43
+ var _a, _b, _c;
44
+ return ((_c = (((_a = getTrimmedPathName()) === null || _a === void 0 ? void 0 : _a.includes('/collections')) &&
45
+ !((_b = getTrimmedPathName()) === null || _b === void 0 ? void 0 : _b.includes('/products')))) !== null && _c !== void 0 ? _c : false);
46
+ }, [getTrimmedPathName]);
47
+ const value = useMemo(() => ({
48
+ getTrimmedPathName,
49
+ getPlpOrPdpId,
50
+ isOnPdpPage,
51
+ isOnPlpPage,
52
+ isReady,
53
+ }), [getTrimmedPathName, getPlpOrPdpId, isOnPdpPage, isOnPlpPage, isReady]);
54
+ return _jsx(ShopifyUrlContext.Provider, { value: value, children: children });
55
+ };
56
+ export const useShopifyUrl = () => {
57
+ const context = useContext(ShopifyUrlContext);
58
+ if (!context) {
59
+ throw new Error('useShopifyUrl must be used within a ShopifyUrlProvider');
60
+ }
61
+ return context;
62
+ };
@@ -0,0 +1 @@
1
+ export * from "./systemSettingsContext";
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useAtomValue } from 'jotai';
3
+ import { createContext, useMemo, useState } from 'react';
4
+ import { baseUrlAtom } from 'src/atoms/envive/enviveConfig';
5
+ // TODO: Refactor this to a common service that handles query params (and spiffy variables all together)
6
+ const getChatModelName = () => {
7
+ const urlObj = new URL(window.location.href);
8
+ const params = new URLSearchParams(urlObj.search);
9
+ const paramsObj = Object.fromEntries(params.entries());
10
+ return paramsObj.llm_model_name;
11
+ };
12
+ const defaultGenerationParams = {
13
+ stream: true,
14
+ numSuggestions: 3,
15
+ model: getChatModelName(),
16
+ };
17
+ const SystemSettingsContext = createContext(undefined);
18
+ const SystemSettingsContextProvider = ({ children, generationParams, showDebugBar, }) => {
19
+ const [params, setParams] = useState(() => generationParams !== null && generationParams !== void 0 ? generationParams : defaultGenerationParams);
20
+ const endpointURL = useAtomValue(baseUrlAtom);
21
+ const settingsContextValues = useMemo(() => ({
22
+ generationParams: params,
23
+ showDebugBar,
24
+ setGenerationParams: setParams,
25
+ endpointURL,
26
+ }), [generationParams, endpointURL, showDebugBar]);
27
+ return (_jsx(SystemSettingsContext.Provider, { value: settingsContextValues, children: children }));
28
+ };
29
+ export { SystemSettingsContextProvider, SystemSettingsContext, defaultGenerationParams };
@@ -0,0 +1 @@
1
+ export * from "./userIdentityContext";