@athoscommerce/snap-preact 1.2.2 → 1.2.3-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/dist/cjs/components/src/components/Atoms/Button/Button.d.ts +1 -1
  2. package/dist/cjs/components/src/components/Atoms/Button/Button.d.ts.map +1 -1
  3. package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.d.ts +7 -0
  4. package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.d.ts.map +1 -0
  5. package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.js +85 -0
  6. package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/index.d.ts +2 -0
  7. package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/index.d.ts.map +1 -0
  8. package/dist/cjs/components/src/components/Atoms/ChatLoadingIndicator/index.js +17 -0
  9. package/dist/cjs/components/src/components/Atoms/Dropdown/Dropdown.d.ts +1 -0
  10. package/dist/cjs/components/src/components/Atoms/Dropdown/Dropdown.d.ts.map +1 -1
  11. package/dist/cjs/components/src/components/Atoms/Dropdown/Dropdown.js +30 -13
  12. package/dist/cjs/components/src/components/Atoms/Icon/paths.d.ts +21 -0
  13. package/dist/cjs/components/src/components/Atoms/Icon/paths.d.ts.map +1 -1
  14. package/dist/cjs/components/src/components/Atoms/Icon/paths.js +21 -0
  15. package/dist/cjs/components/src/components/Molecules/CalloutBadge/CalloutBadge.js +2 -2
  16. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts +18 -0
  17. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts.map +1 -0
  18. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.js +115 -0
  19. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/index.d.ts +2 -0
  20. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/index.d.ts.map +1 -0
  21. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/index.js +17 -0
  22. package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts +17 -0
  23. package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts.map +1 -0
  24. package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.js +106 -0
  25. package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/index.d.ts +2 -0
  26. package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/index.d.ts.map +1 -0
  27. package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/index.js +17 -0
  28. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts +23 -0
  29. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts.map +1 -0
  30. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +445 -0
  31. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts +2 -0
  32. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts.map +1 -0
  33. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/index.js +17 -0
  34. package/dist/cjs/components/src/components/Molecules/OverlayBadge/OverlayBadge.js +2 -2
  35. package/dist/cjs/components/src/components/Molecules/Result/Result.d.ts +3 -3
  36. package/dist/cjs/components/src/components/Molecules/Result/Result.d.ts.map +1 -1
  37. package/dist/cjs/components/src/components/Molecules/Result/Result.js +4 -4
  38. package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.d.ts +2 -0
  39. package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.d.ts.map +1 -1
  40. package/dist/cjs/components/src/components/Molecules/SearchInput/SearchInput.js +19 -2
  41. package/dist/cjs/components/src/components/Molecules/Slideout/Slideout.d.ts.map +1 -1
  42. package/dist/cjs/components/src/components/Molecules/Slideout/Slideout.js +30 -12
  43. package/dist/cjs/components/src/components/Organisms/Chat/Chat.d.ts +14 -0
  44. package/dist/cjs/components/src/components/Organisms/Chat/Chat.d.ts.map +1 -0
  45. package/dist/cjs/components/src/components/Organisms/Chat/Chat.js +1619 -0
  46. package/dist/cjs/components/src/components/Organisms/Chat/ChatAttachmentContext.d.ts +19 -0
  47. package/dist/cjs/components/src/components/Organisms/Chat/ChatAttachmentContext.d.ts.map +1 -0
  48. package/dist/cjs/components/src/components/Organisms/Chat/ChatAttachmentContext.js +22 -0
  49. package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.d.ts +12 -0
  50. package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.d.ts.map +1 -0
  51. package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.js +158 -0
  52. package/dist/cjs/components/src/components/Organisms/Chat/MessageText.d.ts +13 -0
  53. package/dist/cjs/components/src/components/Organisms/Chat/MessageText.d.ts.map +1 -0
  54. package/dist/cjs/components/src/components/Organisms/Chat/MessageText.js +170 -0
  55. package/dist/cjs/components/src/components/Organisms/Chat/MessageUser.d.ts +11 -0
  56. package/dist/cjs/components/src/components/Organisms/Chat/MessageUser.d.ts.map +1 -0
  57. package/dist/cjs/components/src/components/Organisms/Chat/MessageUser.js +192 -0
  58. package/dist/cjs/components/src/components/Organisms/Chat/ResultsDisplay.d.ts +11 -0
  59. package/dist/cjs/components/src/components/Organisms/Chat/ResultsDisplay.d.ts.map +1 -0
  60. package/dist/cjs/components/src/components/Organisms/Chat/ResultsDisplay.js +86 -0
  61. package/dist/cjs/components/src/components/Organisms/Chat/SuggestedQuestions.d.ts +12 -0
  62. package/dist/cjs/components/src/components/Organisms/Chat/SuggestedQuestions.d.ts.map +1 -0
  63. package/dist/cjs/components/src/components/Organisms/Chat/SuggestedQuestions.js +73 -0
  64. package/dist/cjs/components/src/components/Organisms/Chat/index.d.ts +2 -0
  65. package/dist/cjs/components/src/components/Organisms/Chat/index.d.ts.map +1 -0
  66. package/dist/cjs/components/src/components/Organisms/Chat/index.js +17 -0
  67. package/dist/cjs/components/src/components/Organisms/FacetsHorizontal/FacetsHorizontal.js +2 -2
  68. package/dist/cjs/components/src/components/Organisms/MobileSidebar/MobileSidebar.d.ts +1 -0
  69. package/dist/cjs/components/src/components/Organisms/MobileSidebar/MobileSidebar.d.ts.map +1 -1
  70. package/dist/cjs/components/src/components/Organisms/MobileSidebar/MobileSidebar.js +2 -2
  71. package/dist/cjs/components/src/components/Organisms/Results/Results.js +1 -1
  72. package/dist/cjs/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.d.ts.map +1 -1
  73. package/dist/cjs/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.js +2 -0
  74. package/dist/cjs/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts.map +1 -1
  75. package/dist/cjs/components/src/components/Templates/AutocompleteModal/AutocompleteModal.js +2 -0
  76. package/dist/cjs/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.d.ts.map +1 -1
  77. package/dist/cjs/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.js +2 -0
  78. package/dist/cjs/components/src/components/Templates/Search/Search.d.ts +2 -2
  79. package/dist/cjs/components/src/components/Templates/Search/Search.d.ts.map +1 -1
  80. package/dist/cjs/components/src/hooks/useLayoutOptions.d.ts.map +1 -1
  81. package/dist/cjs/components/src/hooks/useLayoutOptions.js +21 -11
  82. package/dist/cjs/components/src/index.d.ts +1 -0
  83. package/dist/cjs/components/src/index.d.ts.map +1 -1
  84. package/dist/cjs/components/src/index.js +1 -0
  85. package/dist/cjs/components/src/providers/themeComponents.d.ts +50 -16
  86. package/dist/cjs/components/src/providers/themeComponents.d.ts.map +1 -1
  87. package/dist/cjs/components/src/providers/withTracking.d.ts +2 -2
  88. package/dist/cjs/components/src/providers/withTracking.d.ts.map +1 -1
  89. package/dist/cjs/components/src/types.d.ts +2 -0
  90. package/dist/cjs/components/src/types.d.ts.map +1 -1
  91. package/dist/cjs/src/Snap.d.ts +2 -1
  92. package/dist/cjs/src/Snap.d.ts.map +1 -1
  93. package/dist/cjs/src/Snap.js +124 -24
  94. package/dist/cjs/src/Templates/SnapTemplates.d.ts +12 -2
  95. package/dist/cjs/src/Templates/SnapTemplates.d.ts.map +1 -1
  96. package/dist/cjs/src/Templates/SnapTemplates.js +54 -1
  97. package/dist/cjs/src/Templates/Stores/LibraryStore.d.ts +4 -0
  98. package/dist/cjs/src/Templates/Stores/LibraryStore.d.ts.map +1 -1
  99. package/dist/cjs/src/Templates/Stores/LibraryStore.js +19 -0
  100. package/dist/cjs/src/Templates/Stores/TemplateStore.d.ts +5 -2
  101. package/dist/cjs/src/Templates/Stores/TemplateStore.d.ts.map +1 -1
  102. package/dist/cjs/src/Templates/Stores/TemplateStore.js +1 -0
  103. package/dist/cjs/src/Templates/Stores/library/components/Chat.d.ts +2 -0
  104. package/dist/cjs/src/Templates/Stores/library/components/Chat.d.ts.map +1 -0
  105. package/dist/cjs/src/Templates/Stores/library/components/Chat.js +5 -0
  106. package/dist/cjs/src/Templates/Stores/library/languages/es.d.ts.map +1 -1
  107. package/dist/cjs/src/Templates/Stores/library/languages/es.js +5 -0
  108. package/dist/cjs/src/Templates/Stores/library/languages/fr.d.ts.map +1 -1
  109. package/dist/cjs/src/Templates/Stores/library/languages/fr.js +5 -0
  110. package/dist/cjs/src/create/createChatController.d.ts +5 -0
  111. package/dist/cjs/src/create/createChatController.d.ts.map +1 -0
  112. package/dist/cjs/src/create/createChatController.js +43 -0
  113. package/dist/cjs/src/setupEvents.d.ts.map +1 -1
  114. package/dist/cjs/src/setupEvents.js +39 -0
  115. package/dist/cjs/src/types.d.ts +15 -3
  116. package/dist/cjs/src/types.d.ts.map +1 -1
  117. package/dist/esm/components/src/components/Atoms/Button/Button.d.ts +1 -1
  118. package/dist/esm/components/src/components/Atoms/Button/Button.d.ts.map +1 -1
  119. package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.d.ts +7 -0
  120. package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.d.ts.map +1 -0
  121. package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/ChatLoadingIndicator.js +67 -0
  122. package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/index.d.ts +2 -0
  123. package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/index.d.ts.map +1 -0
  124. package/dist/esm/components/src/components/Atoms/ChatLoadingIndicator/index.js +1 -0
  125. package/dist/esm/components/src/components/Atoms/Dropdown/Dropdown.d.ts +1 -0
  126. package/dist/esm/components/src/components/Atoms/Dropdown/Dropdown.d.ts.map +1 -1
  127. package/dist/esm/components/src/components/Atoms/Dropdown/Dropdown.js +33 -9
  128. package/dist/esm/components/src/components/Atoms/Icon/paths.d.ts +21 -0
  129. package/dist/esm/components/src/components/Atoms/Icon/paths.d.ts.map +1 -1
  130. package/dist/esm/components/src/components/Atoms/Icon/paths.js +21 -0
  131. package/dist/esm/components/src/components/Molecules/CalloutBadge/CalloutBadge.js +1 -1
  132. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts +18 -0
  133. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts.map +1 -0
  134. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.js +109 -0
  135. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/index.d.ts +2 -0
  136. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/index.d.ts.map +1 -0
  137. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/index.js +1 -0
  138. package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts +17 -0
  139. package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts.map +1 -0
  140. package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.js +85 -0
  141. package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/index.d.ts +2 -0
  142. package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/index.d.ts.map +1 -0
  143. package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/index.js +1 -0
  144. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts +23 -0
  145. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts.map +1 -0
  146. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +421 -0
  147. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts +2 -0
  148. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts.map +1 -0
  149. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/index.js +1 -0
  150. package/dist/esm/components/src/components/Molecules/OverlayBadge/OverlayBadge.js +1 -1
  151. package/dist/esm/components/src/components/Molecules/Result/Result.d.ts +3 -3
  152. package/dist/esm/components/src/components/Molecules/Result/Result.d.ts.map +1 -1
  153. package/dist/esm/components/src/components/Molecules/Result/Result.js +2 -2
  154. package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.d.ts +2 -0
  155. package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.d.ts.map +1 -1
  156. package/dist/esm/components/src/components/Molecules/SearchInput/SearchInput.js +35 -2
  157. package/dist/esm/components/src/components/Molecules/Slideout/Slideout.d.ts.map +1 -1
  158. package/dist/esm/components/src/components/Molecules/Slideout/Slideout.js +30 -12
  159. package/dist/esm/components/src/components/Organisms/Chat/Chat.d.ts +14 -0
  160. package/dist/esm/components/src/components/Organisms/Chat/Chat.d.ts.map +1 -0
  161. package/dist/esm/components/src/components/Organisms/Chat/Chat.js +1560 -0
  162. package/dist/esm/components/src/components/Organisms/Chat/ChatAttachmentContext.d.ts +19 -0
  163. package/dist/esm/components/src/components/Organisms/Chat/ChatAttachmentContext.d.ts.map +1 -0
  164. package/dist/esm/components/src/components/Organisms/Chat/ChatAttachmentContext.js +16 -0
  165. package/dist/esm/components/src/components/Organisms/Chat/ChatResult.d.ts +12 -0
  166. package/dist/esm/components/src/components/Organisms/Chat/ChatResult.d.ts.map +1 -0
  167. package/dist/esm/components/src/components/Organisms/Chat/ChatResult.js +143 -0
  168. package/dist/esm/components/src/components/Organisms/Chat/MessageText.d.ts +13 -0
  169. package/dist/esm/components/src/components/Organisms/Chat/MessageText.d.ts.map +1 -0
  170. package/dist/esm/components/src/components/Organisms/Chat/MessageText.js +152 -0
  171. package/dist/esm/components/src/components/Organisms/Chat/MessageUser.d.ts +11 -0
  172. package/dist/esm/components/src/components/Organisms/Chat/MessageUser.d.ts.map +1 -0
  173. package/dist/esm/components/src/components/Organisms/Chat/MessageUser.js +164 -0
  174. package/dist/esm/components/src/components/Organisms/Chat/ResultsDisplay.d.ts +11 -0
  175. package/dist/esm/components/src/components/Organisms/Chat/ResultsDisplay.d.ts.map +1 -0
  176. package/dist/esm/components/src/components/Organisms/Chat/ResultsDisplay.js +70 -0
  177. package/dist/esm/components/src/components/Organisms/Chat/SuggestedQuestions.d.ts +12 -0
  178. package/dist/esm/components/src/components/Organisms/Chat/SuggestedQuestions.d.ts.map +1 -0
  179. package/dist/esm/components/src/components/Organisms/Chat/SuggestedQuestions.js +58 -0
  180. package/dist/esm/components/src/components/Organisms/Chat/index.d.ts +2 -0
  181. package/dist/esm/components/src/components/Organisms/Chat/index.d.ts.map +1 -0
  182. package/dist/esm/components/src/components/Organisms/Chat/index.js +1 -0
  183. package/dist/esm/components/src/components/Organisms/FacetsHorizontal/FacetsHorizontal.js +2 -2
  184. package/dist/esm/components/src/components/Organisms/MobileSidebar/MobileSidebar.d.ts +1 -0
  185. package/dist/esm/components/src/components/Organisms/MobileSidebar/MobileSidebar.d.ts.map +1 -1
  186. package/dist/esm/components/src/components/Organisms/MobileSidebar/MobileSidebar.js +2 -2
  187. package/dist/esm/components/src/components/Organisms/Results/Results.js +1 -1
  188. package/dist/esm/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.d.ts.map +1 -1
  189. package/dist/esm/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.js +3 -0
  190. package/dist/esm/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts.map +1 -1
  191. package/dist/esm/components/src/components/Templates/AutocompleteModal/AutocompleteModal.js +3 -0
  192. package/dist/esm/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.d.ts.map +1 -1
  193. package/dist/esm/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.js +3 -0
  194. package/dist/esm/components/src/components/Templates/Search/Search.d.ts +2 -2
  195. package/dist/esm/components/src/components/Templates/Search/Search.d.ts.map +1 -1
  196. package/dist/esm/components/src/hooks/useLayoutOptions.d.ts.map +1 -1
  197. package/dist/esm/components/src/hooks/useLayoutOptions.js +21 -11
  198. package/dist/esm/components/src/index.d.ts +1 -0
  199. package/dist/esm/components/src/index.d.ts.map +1 -1
  200. package/dist/esm/components/src/index.js +1 -0
  201. package/dist/esm/components/src/providers/themeComponents.d.ts +50 -16
  202. package/dist/esm/components/src/providers/themeComponents.d.ts.map +1 -1
  203. package/dist/esm/components/src/providers/withTracking.d.ts +2 -2
  204. package/dist/esm/components/src/providers/withTracking.d.ts.map +1 -1
  205. package/dist/esm/components/src/types.d.ts +2 -0
  206. package/dist/esm/components/src/types.d.ts.map +1 -1
  207. package/dist/esm/src/Snap.d.ts +2 -1
  208. package/dist/esm/src/Snap.d.ts.map +1 -1
  209. package/dist/esm/src/Snap.js +59 -0
  210. package/dist/esm/src/Templates/SnapTemplates.d.ts +12 -2
  211. package/dist/esm/src/Templates/SnapTemplates.d.ts.map +1 -1
  212. package/dist/esm/src/Templates/SnapTemplates.js +43 -0
  213. package/dist/esm/src/Templates/Stores/LibraryStore.d.ts +4 -0
  214. package/dist/esm/src/Templates/Stores/LibraryStore.d.ts.map +1 -1
  215. package/dist/esm/src/Templates/Stores/LibraryStore.js +6 -0
  216. package/dist/esm/src/Templates/Stores/TemplateStore.d.ts +5 -2
  217. package/dist/esm/src/Templates/Stores/TemplateStore.d.ts.map +1 -1
  218. package/dist/esm/src/Templates/Stores/TemplateStore.js +1 -0
  219. package/dist/esm/src/Templates/Stores/library/components/Chat.d.ts +2 -0
  220. package/dist/esm/src/Templates/Stores/library/components/Chat.d.ts.map +1 -0
  221. package/dist/esm/src/Templates/Stores/library/components/Chat.js +1 -0
  222. package/dist/esm/src/Templates/Stores/library/languages/es.d.ts.map +1 -1
  223. package/dist/esm/src/Templates/Stores/library/languages/es.js +5 -0
  224. package/dist/esm/src/Templates/Stores/library/languages/fr.d.ts.map +1 -1
  225. package/dist/esm/src/Templates/Stores/library/languages/fr.js +5 -0
  226. package/dist/esm/src/create/createChatController.d.ts +5 -0
  227. package/dist/esm/src/create/createChatController.d.ts.map +1 -0
  228. package/dist/esm/src/create/createChatController.js +29 -0
  229. package/dist/esm/src/setupEvents.d.ts.map +1 -1
  230. package/dist/esm/src/setupEvents.js +23 -0
  231. package/dist/esm/src/types.d.ts +15 -3
  232. package/dist/esm/src/types.d.ts.map +1 -1
  233. package/package.json +13 -12
@@ -0,0 +1,1619 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
+ if (ar || !(i in from)) {
52
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
+ ar[i] = from[i];
54
+ }
55
+ }
56
+ return to.concat(ar || Array.prototype.slice.call(from));
57
+ };
58
+ var __importDefault = (this && this.__importDefault) || function (mod) {
59
+ return (mod && mod.__esModule) ? mod : { "default": mod };
60
+ };
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ exports.Chat = void 0;
63
+ var jsx_runtime_1 = require("@emotion/react/jsx-runtime");
64
+ var react_1 = require("@emotion/react");
65
+ var classnames_1 = __importDefault(require("classnames"));
66
+ var deepmerge_1 = __importDefault(require("deepmerge"));
67
+ var mobx_react_lite_1 = require("mobx-react-lite");
68
+ var providers_1 = require("../../../providers");
69
+ var utilities_1 = require("../../../utilities");
70
+ var Button_1 = require("../../Atoms/Button");
71
+ var hooks_1 = require("preact/hooks");
72
+ var MessageUser_1 = require("./MessageUser");
73
+ var MessageText_1 = require("./MessageText");
74
+ var SuggestedQuestions_1 = require("./SuggestedQuestions");
75
+ var ChatAttachmentContext_1 = require("./ChatAttachmentContext");
76
+ var Image_1 = require("../../Atoms/Image");
77
+ var ChatLoadingIndicator_1 = require("../../Atoms/ChatLoadingIndicator");
78
+ var __1 = require("../../..");
79
+ var ChatInspirationResultMessage_1 = require("../../Molecules/ChatInspirationResultMessage");
80
+ var ChatProductComparisonMessage_1 = require("../../Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage");
81
+ var ChatProductQueryMessage_1 = require("../../Molecules/ChatProductQueryMessage/ChatProductQueryMessage");
82
+ var defaultStyles = function (_a) {
83
+ var mobile = _a.mobile, offset = _a.offset, hasSideChat = _a.hasSideChat, footerHeight = _a.footerHeight;
84
+ var colorPrimary = '#253B80';
85
+ var offsetValue = offset !== undefined ? (typeof offset === 'number' ? "".concat(offset, "px") : offset) : undefined;
86
+ return (0, react_1.css)({
87
+ position: 'fixed',
88
+ left: '20px',
89
+ bottom: '20px',
90
+ zIndex: 1002,
91
+ color: '#333',
92
+ '@keyframes ss-chat-slide-up': {
93
+ from: { transform: 'translateY(100%)' },
94
+ to: { transform: 'translateY(0)' },
95
+ },
96
+ '.ss__chat__primary': __assign(__assign({}, (mobile
97
+ ? { width: '100%', height: '100%' }
98
+ : hasSideChat
99
+ ? { flex: '1 1 0', minWidth: 0, maxWidth: 600, height: '70vh' }
100
+ : { width: 600, maxWidth: 'calc(100vw - 60px)', height: '70vh' })), { display: 'flex', flexDirection: 'column', justifyContent: 'flex-end', overflow: 'hidden', order: 1, '.ss__chat__header__title': {
101
+ gap: '22px',
102
+ }, '.ss__chat__messages': {
103
+ padding: '1em',
104
+ } }),
105
+ '.ss__chat__secondary': __assign(__assign(__assign(__assign(__assign(__assign({}, (mobile
106
+ ? {
107
+ width: '100%',
108
+ maxWidth: '100%',
109
+ height: "calc(100% - 70px".concat(footerHeight > 0 ? " - ".concat(footerHeight, "px") : '', ")"),
110
+ maxHeight: "calc(100% - 70px".concat(footerHeight > 0 ? " - ".concat(footerHeight, "px") : '', ")"),
111
+ }
112
+ : { flex: '1 1 0', minWidth: 0, maxWidth: 600, height: '70vh', maxHeight: '70vh' })), { display: 'flex', flexDirection: 'column', overflow: 'hidden', order: 2 }), (mobile
113
+ ? {
114
+ position: 'absolute',
115
+ bottom: footerHeight > 0 ? footerHeight : 0,
116
+ left: 0,
117
+ right: 0,
118
+ zIndex: 10,
119
+ borderTopLeftRadius: '12px',
120
+ borderTopRightRadius: '12px',
121
+ overflow: 'hidden',
122
+ overscrollBehavior: 'contain',
123
+ boxShadow: '0 -4px 20px rgba(0, 0, 0, 0.15)',
124
+ background: '#fff',
125
+ willChange: 'transform',
126
+ animation: 'ss-chat-slide-up 0.3s ease-out',
127
+ }
128
+ : {})), { '.ss__chat__secondary__drag-handle': {
129
+ display: 'flex',
130
+ justifyContent: 'center',
131
+ alignItems: 'center',
132
+ padding: '10px 0 2px',
133
+ background: colorPrimary,
134
+ touchAction: 'none',
135
+ cursor: 'grab',
136
+ '.ss__chat__secondary__drag-handle__indicator': {
137
+ width: '36px',
138
+ height: '4px',
139
+ borderRadius: '2px',
140
+ background: 'rgba(255, 255, 255, 0.4)',
141
+ },
142
+ } }), (mobile
143
+ ? {
144
+ '.ss__chat__header': {
145
+ touchAction: 'none',
146
+ cursor: 'grab',
147
+ },
148
+ }
149
+ : {})), { '.ss__chat__header__title': {
150
+ flexDirection: 'column',
151
+ gap: '2px',
152
+ '.ss__chat__header__title__primary': {
153
+ fontWeight: 'bold',
154
+ },
155
+ '.ss__chat__header__title__secondary': {
156
+ fontSize: '80%',
157
+ opacity: 0.85,
158
+ },
159
+ }, '.ss__chat__messages': {
160
+ background: '#fff!important',
161
+ } }),
162
+ '.ss__button': {
163
+ border: 'none',
164
+ background: 'none',
165
+ color: 'inherit',
166
+ '&:not(.ss__button--disabled):hover': {
167
+ background: '#dfeaf6',
168
+ },
169
+ svg: {
170
+ fill: colorPrimary,
171
+ stroke: colorPrimary,
172
+ },
173
+ },
174
+ '.ss__chat__bubble': {
175
+ position: mobile ? 'fixed' : 'absolute',
176
+ bottom: mobile ? '20px' : 0,
177
+ left: mobile ? '20px' : 0,
178
+ width: '60px',
179
+ height: '60px',
180
+ borderRadius: '50%',
181
+ background: colorPrimary,
182
+ color: 'white',
183
+ display: 'flex',
184
+ alignItems: 'center',
185
+ justifyContent: 'center',
186
+ cursor: 'pointer',
187
+ fontSize: '24px',
188
+ boxShadow: '0 4px 8px rgba(0, 0, 0, 0.2)',
189
+ zIndex: 10,
190
+ '&:hover': {
191
+ background: '#0052a3',
192
+ transform: 'scale(1.05)',
193
+ },
194
+ '.ss__icon': {
195
+ height: '33px',
196
+ width: '33px',
197
+ fill: '#fff',
198
+ stroke: '#fff',
199
+ },
200
+ },
201
+ '.ss__chat__suggested-questions': {
202
+ position: mobile ? 'fixed' : 'absolute',
203
+ bottom: mobile ? '90px' : '70px',
204
+ left: mobile ? '20px' : 0,
205
+ display: 'flex',
206
+ flexDirection: 'column',
207
+ gap: '8px',
208
+ width: '250px',
209
+ zIndex: 10,
210
+ '.ss__chat__suggested-questions__item': {
211
+ background: '#fff',
212
+ borderRadius: '12px',
213
+ padding: '12px 16px',
214
+ fontSize: '14px',
215
+ color: '#333',
216
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
217
+ cursor: 'pointer',
218
+ lineHeight: 1.4,
219
+ '&:hover': {
220
+ boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
221
+ },
222
+ },
223
+ },
224
+ '&.ss__chat--minimized': {
225
+ width: '60px',
226
+ height: '60px',
227
+ minHeight: '60px',
228
+ },
229
+ '&.ss__chat--open': __assign(__assign({ display: 'flex', flexDirection: mobile ? 'column' : 'row', gap: mobile ? 0 : '12px' }, (mobile
230
+ ? {
231
+ top: offsetValue || 0,
232
+ left: 0,
233
+ right: 0,
234
+ bottom: 0,
235
+ width: '100%',
236
+ height: offsetValue ? "calc(100% - ".concat(offsetValue, ")") : '100%',
237
+ }
238
+ : {
239
+ width: hasSideChat ? 'calc(100vw - 60px)' : 'auto',
240
+ maxWidth: 'calc(100vw - 60px)',
241
+ maxHeight: 'calc(100vh - 40px)',
242
+ })), { '.ss__chat__bubble': {
243
+ display: 'none',
244
+ } }),
245
+ '.ss__chat__header': {
246
+ display: 'flex',
247
+ justifyContent: 'space-between',
248
+ alignItems: 'center',
249
+ fontSize: '16px',
250
+ position: 'relative',
251
+ padding: '10px 15px',
252
+ color: '#fff',
253
+ background: colorPrimary,
254
+ borderTopLeftRadius: mobile ? 0 : '12px',
255
+ borderTopRightRadius: mobile ? 0 : '12px',
256
+ '.ss__chat__header__title': {
257
+ display: 'flex',
258
+ '.ss__chat__header__title__logo': {
259
+ height: '44px',
260
+ },
261
+ '.ss__chat__header__title__text': {
262
+ display: 'flex',
263
+ flexDirection: 'column',
264
+ '.ss__chat__header__title__text__primary': {
265
+ fontWeight: 'bold',
266
+ },
267
+ '.ss__chat__header__title__text__secondary': {
268
+ fontSize: '80%',
269
+ },
270
+ },
271
+ },
272
+ '.ss__chat__header__buttons': {
273
+ display: 'flex',
274
+ gap: '10px',
275
+ '.ss__button': {
276
+ display: 'flex',
277
+ flexDirection: 'row-reverse',
278
+ padding: '5px',
279
+ border: 0,
280
+ fontSize: '70%',
281
+ '&:hover': {
282
+ backgroundColor: 'transparent',
283
+ },
284
+ svg: {
285
+ fill: '#fff',
286
+ stroke: '#fff',
287
+ },
288
+ },
289
+ },
290
+ '.ss__chat__header__dropdown-history': {
291
+ '&.ss__dropdown--open': {
292
+ '.ss__dropdown__button': {
293
+ backgroundColor: '#dddddd33',
294
+ borderRadius: '6px',
295
+ },
296
+ },
297
+ '.ss__dropdown__button': {
298
+ display: 'flex',
299
+ alignItems: 'center',
300
+ },
301
+ },
302
+ '.ss__chat__history': {
303
+ color: '#333',
304
+ position: 'absolute',
305
+ width: 300,
306
+ minHeight: 170,
307
+ top: 6,
308
+ right: 0,
309
+ background: 'white',
310
+ zIndex: 2,
311
+ boxShadow: '0px 3px 6px 0px rgba(0, 0, 0, 0.2)',
312
+ borderRadius: '6px',
313
+ display: 'flex',
314
+ flexDirection: 'column',
315
+ gap: 5,
316
+ padding: '10px',
317
+ boxSizing: 'border-box',
318
+ '.ss__chat__history__header': {
319
+ display: 'flex',
320
+ justifyContent: 'space-between',
321
+ alignItems: 'center',
322
+ h4: {
323
+ margin: 0,
324
+ fontSize: '14px',
325
+ },
326
+ '.ss__chat__history__header__buttons': {
327
+ '.ss__button': {
328
+ fontSize: '14px',
329
+ color: '#333',
330
+ '&:hover': {
331
+ background: 'none',
332
+ color: '#000',
333
+ },
334
+ },
335
+ },
336
+ },
337
+ '.ss__chat__history__chats': {
338
+ display: 'flex',
339
+ flexDirection: 'column-reverse',
340
+ gap: 5,
341
+ '.ss__chat__history__chats__chat': {
342
+ '.ss__button': {
343
+ borderRadius: '12px',
344
+ width: '100%',
345
+ border: '1px solid #eee',
346
+ fontSize: '12px',
347
+ display: 'flex',
348
+ flexDirection: 'column',
349
+ boxSizing: 'border-box',
350
+ '.ss__chat__history__chat__button__text': {
351
+ fontWeight: 'bold',
352
+ },
353
+ '.ss__chat__history__chat__button__date': {},
354
+ },
355
+ },
356
+ },
357
+ },
358
+ },
359
+ '.ss__chat__session-feedback': {
360
+ display: 'flex',
361
+ alignItems: 'center',
362
+ gap: '10px',
363
+ padding: '8px 15px',
364
+ background: '#40528e',
365
+ color: '#fff',
366
+ fontSize: '14px',
367
+ '.ss__chat__session-feedback__icon': {
368
+ flex: '0 0 auto',
369
+ display: 'flex',
370
+ alignItems: 'center',
371
+ svg: {
372
+ fill: '#fff',
373
+ stroke: '#fff',
374
+ },
375
+ },
376
+ '.ss__chat__session-feedback__label': {
377
+ flex: '1 1 auto',
378
+ whiteSpace: 'nowrap',
379
+ },
380
+ '.ss__chat__session-feedback__actions': {
381
+ display: 'flex',
382
+ gap: '10px',
383
+ alignItems: 'center',
384
+ '> span': {
385
+ display: 'flex',
386
+ alignItems: 'center',
387
+ justifyContent: 'center',
388
+ },
389
+ svg: {
390
+ cursor: 'pointer',
391
+ fill: '#fff',
392
+ stroke: '#fff',
393
+ opacity: 0.7,
394
+ '&:hover': {
395
+ opacity: 1,
396
+ },
397
+ },
398
+ '&.ss__chat__session-feedback__actions--rated svg': {
399
+ opacity: 1,
400
+ cursor: 'default',
401
+ },
402
+ },
403
+ '.ss__chat__session-feedback__close': {
404
+ flex: '0 0 auto',
405
+ display: 'flex',
406
+ alignItems: 'center',
407
+ cursor: 'pointer',
408
+ svg: {
409
+ fill: '#fff',
410
+ stroke: '#fff',
411
+ opacity: 0.7,
412
+ '&:hover': {
413
+ opacity: 1,
414
+ },
415
+ },
416
+ },
417
+ },
418
+ '.ss__chat__content': {
419
+ background: '#fff',
420
+ maxHeight: mobile ? undefined : '90vh',
421
+ overflow: 'hidden',
422
+ display: 'flex',
423
+ flexDirection: 'column',
424
+ border: '1px solid #0066cc',
425
+ borderTop: 'none',
426
+ marginTop: '-1px',
427
+ borderBottomRightRadius: mobile ? 0 : '12px',
428
+ borderBottomLeftRadius: mobile ? 0 : '12px',
429
+ flexGrow: 1,
430
+ '.ss__chat__content__header': {
431
+ // '.ss__chat__attachments': {
432
+ // '.ss__chat__attachment': {
433
+ // borderRadius: 0,
434
+ // borderLeft: 0,
435
+ // borderRight: 0,
436
+ // },
437
+ // },
438
+ '.ss__chat__content__header__comparisons': {
439
+ display: 'flex',
440
+ flexDirection: 'column',
441
+ gap: '1em',
442
+ background: '#f4f4ff',
443
+ padding: '1em',
444
+ '.ss__chat__content__header__comparisons__header': {
445
+ display: 'flex',
446
+ justifyContent: 'space-between',
447
+ '.ss__chat__content__header__comparisons__header__title': {
448
+ fontWeight: 'bold',
449
+ fontSize: '1.2em',
450
+ display: 'flex',
451
+ alignItems: 'center',
452
+ gap: '0.5em',
453
+ '.ss__chat__content__header__comparisons__header__title__icon': {
454
+ background: colorPrimary,
455
+ borderRadius: '50%',
456
+ padding: '5px',
457
+ fill: '#fff',
458
+ height: '25px',
459
+ width: '25px',
460
+ },
461
+ },
462
+ '.ss__chat__content__header__comparisons__header__actions': {
463
+ '.ss__button': {
464
+ border: 'none',
465
+ background: 'none',
466
+ },
467
+ },
468
+ },
469
+ '.ss__chat__content__header__comparisons__content': {
470
+ display: 'flex',
471
+ gap: '1em',
472
+ alignItems: 'stretch',
473
+ '.ss__chat__content__header__comparisons__content__items': {
474
+ display: 'flex',
475
+ gap: '1em',
476
+ flex: '1 1 calc(100% - 100px)',
477
+ justifyContent: 'space-between',
478
+ },
479
+ '.ss__chat__content__header__comparisons__content__comparison': {
480
+ background: '#fff',
481
+ padding: '0.5em',
482
+ borderRadius: '1em',
483
+ display: 'flex',
484
+ flexDirection: 'column',
485
+ gap: '0.5em',
486
+ flex: '0 1 20%',
487
+ position: 'relative',
488
+ '&.ss__chat__content__header__comparisons__content__comparison--placeholder': {
489
+ border: '2px dashed #ddd',
490
+ display: 'flex',
491
+ alignItems: 'center',
492
+ justifyContent: 'center',
493
+ '.ss__chat__content__header__comparisons__content__comparison--placeholder__text': {
494
+ color: '#999',
495
+ fontStyle: 'italic',
496
+ },
497
+ },
498
+ '.ss__chat__content__header__comparisons__content__comparison__remove': {
499
+ position: 'absolute',
500
+ top: '-3px',
501
+ right: '-3px',
502
+ cursor: 'pointer',
503
+ background: 'red',
504
+ borderRadius: '50%',
505
+ padding: '0.4em',
506
+ height: 20,
507
+ width: 20,
508
+ display: 'flex',
509
+ alignItems: 'center',
510
+ justifyContent: 'center',
511
+ svg: {
512
+ fill: '#fff',
513
+ stroke: '#fff',
514
+ },
515
+ },
516
+ },
517
+ '.ss__chat__content__header__comparisons__action': {
518
+ display: 'flex',
519
+ alignItems: 'center',
520
+ marginLeft: 'auto',
521
+ flex: '1 1 auto',
522
+ '&.ss__chat__content__header__comparisons__action--hidden': {
523
+ visibility: 'hidden',
524
+ },
525
+ '.ss__button': {
526
+ flexDirection: 'row-reverse',
527
+ borderRadius: '1em',
528
+ padding: '0.5em 1em',
529
+ background: colorPrimary,
530
+ color: '#fff',
531
+ textAlign: 'center',
532
+ svg: {
533
+ fill: '#fff',
534
+ stroke: '#fff',
535
+ },
536
+ },
537
+ },
538
+ },
539
+ },
540
+ },
541
+ '.ss__chat__messages': {
542
+ flex: '1 1 auto',
543
+ overflowY: 'auto',
544
+ overscrollBehavior: 'contain',
545
+ margin: 0,
546
+ maxHeight: '100%',
547
+ background: '#f9fafc',
548
+ '.ss__chat__messages__end': {
549
+ height: '1px',
550
+ },
551
+ '.ss__chat__message': {
552
+ marginBottom: '30px',
553
+ ul: {
554
+ margin: 0,
555
+ listStyle: 'inside',
556
+ },
557
+ p: {
558
+ margin: 0,
559
+ },
560
+ thead: {
561
+ backgroundColor: '#eee',
562
+ },
563
+ 'tbody tr:nth-child(even)': {
564
+ backgroundColor: '#f5f5f5',
565
+ },
566
+ 'table th, table td': {
567
+ padding: '0.2em 0.5em',
568
+ },
569
+ 'table + h3': {
570
+ margin: '1em 0 0 0',
571
+ fontSize: '1.3em',
572
+ },
573
+ },
574
+ '.ss__chat__welcome': {
575
+ display: 'flex',
576
+ flexDirection: 'column',
577
+ height: '100%',
578
+ '.ss__chat__welcome__message': {
579
+ fontSize: '15px',
580
+ lineHeight: 1.5,
581
+ color: '#333',
582
+ padding: '2em',
583
+ textAlign: 'center',
584
+ },
585
+ '.ss__chat__suggestions': {
586
+ marginTop: 'auto',
587
+ },
588
+ },
589
+ },
590
+ '.ss__chat__actions': {
591
+ display: 'flex',
592
+ flexDirection: 'column',
593
+ gap: '6px',
594
+ overflow: 'hidden',
595
+ '.ss__chat__actions__wrap': {
596
+ display: 'flex',
597
+ flexDirection: 'column',
598
+ gap: '6px',
599
+ padding: '8px 10px',
600
+ background: '#f4f4ff',
601
+ border: '1px solid #e3e3f5',
602
+ borderRadius: '8px',
603
+ },
604
+ '.ss__chat__actions--title': {
605
+ fontSize: '14px',
606
+ color: '#333',
607
+ },
608
+ '.ss__chat__actions--facets, .ss__chat__actions--suggested': {
609
+ display: 'flex',
610
+ flexDirection: 'row',
611
+ gap: '6px',
612
+ '.ss__button': {
613
+ flex: '0 0 auto',
614
+ background: '#fff',
615
+ border: '1px solid #ddd',
616
+ borderRadius: '999px',
617
+ padding: '3px 10px',
618
+ fontSize: '14px',
619
+ color: '#333',
620
+ '&:hover': {
621
+ background: '#f9f9ff',
622
+ },
623
+ },
624
+ },
625
+ '.ss__chat__actions--facets': {
626
+ overflowX: 'auto',
627
+ overflowY: 'hidden',
628
+ scrollbarWidth: 'none',
629
+ '&::-webkit-scrollbar': {
630
+ display: 'none',
631
+ },
632
+ },
633
+ '.ss__chat__actions--suggested': {
634
+ overflowX: 'scroll',
635
+ },
636
+ '.ss__chat__actions__facet': {},
637
+ '.ss__chat__actions__facets-dropdown': {
638
+ '.ss__dropdown__content': {
639
+ bottom: '0',
640
+ top: 'auto',
641
+ left: '-15px',
642
+ width: mobile ? '100vw' : '600px',
643
+ zIndex: 100,
644
+ background: 'white',
645
+ borderTop: '1px solid #ddd',
646
+ },
647
+ },
648
+ },
649
+ '.ss__chat__facets': {
650
+ '.ss__chat__facets__header': {
651
+ display: 'flex',
652
+ flexDirection: mobile ? 'column' : 'row',
653
+ justifyContent: 'space-between',
654
+ alignItems: 'center',
655
+ padding: '10px',
656
+ '.ss__chat__facets__header__title': {
657
+ width: mobile ? '100%' : undefined,
658
+ fontSize: '18px',
659
+ fontWeight: 'bold',
660
+ color: '#333',
661
+ order: mobile ? 1 : 0,
662
+ marginTop: mobile ? '10px' : 0,
663
+ },
664
+ '.ss__chat__facets__close': {
665
+ order: mobile ? 0 : 1,
666
+ display: 'flex',
667
+ justifyContent: mobile ? 'center' : 'flex-end',
668
+ '.ss__chat__facets__close__button': {
669
+ width: mobile ? '100px' : '20px',
670
+ borderRadius: mobile ? '4px' : undefined,
671
+ background: mobile ? '#ccc' : 'none',
672
+ padding: '5px',
673
+ flexGrow: 0,
674
+ border: 'none',
675
+ '.ss__icon': {
676
+ display: mobile ? 'none' : 'inline',
677
+ },
678
+ },
679
+ },
680
+ },
681
+ '.ss__chat__facets__wrapper': {
682
+ padding: '10px',
683
+ display: 'flex',
684
+ flexDirection: 'column',
685
+ gap: '10px',
686
+ '.ss__chat__facets__facet': {
687
+ display: 'flex',
688
+ justifyContent: 'flex-start',
689
+ alignItems: 'center',
690
+ '.ss__chat__facets__facet__label': {
691
+ fontWeight: 'bold',
692
+ fontSize: '14px',
693
+ marginRight: '10px',
694
+ },
695
+ '.ss__chat__facets__facet__options': {
696
+ display: 'flex',
697
+ gap: '5px',
698
+ overflowX: 'scroll',
699
+ '.ss__chat__facets__facet__options__option': {
700
+ flexGrow: 0,
701
+ },
702
+ },
703
+ },
704
+ },
705
+ },
706
+ '.ss__chat__actions__facets-header': {
707
+ display: 'flex',
708
+ justifyContent: 'space-between',
709
+ alignItems: 'center',
710
+ },
711
+ '.ss__chat__actions__facets-apply': {
712
+ display: 'flex',
713
+ justifyContent: 'flex-end',
714
+ padding: '0 2px',
715
+ '.ss__button': {
716
+ background: '#253B80',
717
+ color: '#fff',
718
+ border: 'none',
719
+ borderRadius: '999px',
720
+ padding: '6px 16px',
721
+ fontSize: '14px',
722
+ cursor: 'pointer',
723
+ '&:not(.ss__button--disabled):hover': {
724
+ background: '#1a2a5c',
725
+ },
726
+ '&.ss__button--disabled': {
727
+ opacity: 0.5,
728
+ cursor: 'not-allowed',
729
+ },
730
+ },
731
+ },
732
+ '@keyframes ss-chat-dot-pulse': {
733
+ '0%, 80%, 100%': {
734
+ transform: 'scale(0.6)',
735
+ opacity: 0.5,
736
+ },
737
+ '40%': {
738
+ transform: 'scale(1)',
739
+ opacity: 1,
740
+ },
741
+ },
742
+ '.ss__chat__attachment-context': {
743
+ display: 'flex',
744
+ flexDirection: 'column',
745
+ gap: '6px',
746
+ padding: '8px 10px',
747
+ background: '#f4f4ff',
748
+ border: '1px solid #e3e3f5',
749
+ borderRadius: '8px',
750
+ '.ss__chat__attachment-context__label': {
751
+ fontSize: '14px',
752
+ display: 'flex',
753
+ alignItems: 'center',
754
+ justifyContent: 'space-between',
755
+ gap: '8px',
756
+ '.ss__chat__attachment-context__label__close': {
757
+ display: 'flex',
758
+ alignItems: 'center',
759
+ justifyContent: 'center',
760
+ cursor: 'pointer',
761
+ flex: '0 0 auto',
762
+ },
763
+ },
764
+ '.ss__chat__attachment-context__items': {
765
+ display: 'flex',
766
+ flexWrap: 'wrap',
767
+ gap: '6px',
768
+ },
769
+ '.ss__chat__attachment-context__item': {
770
+ display: 'flex',
771
+ alignItems: 'center',
772
+ gap: '6px',
773
+ padding: '3px 8px 3px 3px',
774
+ background: '#fff',
775
+ border: '1px solid #ddd',
776
+ borderRadius: '999px',
777
+ maxWidth: 'calc(50% - 3px)',
778
+ position: 'relative',
779
+ '.ss__chat__attachment-context__item__content': {
780
+ display: 'flex',
781
+ alignItems: 'center',
782
+ justifyContent: 'center',
783
+ flex: '0 0 auto',
784
+ '.ss__image': {
785
+ width: '30px',
786
+ height: '30px',
787
+ margin: 0,
788
+ img: {
789
+ width: '30px',
790
+ height: '30px',
791
+ borderRadius: '50%',
792
+ objectFit: 'cover',
793
+ },
794
+ },
795
+ },
796
+ '.ss__chat__attachment-context__item__name': {
797
+ fontSize: '14px',
798
+ color: '#333',
799
+ whiteSpace: 'nowrap',
800
+ overflow: 'hidden',
801
+ textOverflow: 'ellipsis',
802
+ flex: '1 1 auto',
803
+ minWidth: 0,
804
+ },
805
+ '.ss__chat__attachment-context__item__remove': {
806
+ width: '18px',
807
+ height: '18px',
808
+ minWidth: 'auto',
809
+ margin: 0,
810
+ padding: 0,
811
+ background: 'none',
812
+ border: 'none',
813
+ display: 'flex',
814
+ alignItems: 'center',
815
+ justifyContent: 'center',
816
+ cursor: 'pointer',
817
+ flex: '0 0 auto',
818
+ svg: {
819
+ fill: '#6A7282',
820
+ stroke: '#6A7282',
821
+ },
822
+ '&:hover': {
823
+ svg: {
824
+ fill: '#000',
825
+ stroke: '#000',
826
+ },
827
+ },
828
+ },
829
+ '.ss__chat__attachment-context__item__loading': {
830
+ display: 'flex',
831
+ gap: '3px',
832
+ margin: 0,
833
+ '.ss__chat__loading__dot': {
834
+ width: '5px',
835
+ height: '5px',
836
+ borderRadius: '50%',
837
+ backgroundColor: '#ccc',
838
+ animation: 'ss-chat-dot-pulse 1.4s infinite ease-in-out both',
839
+ '&:nth-of-type(1)': {
840
+ animationDelay: '-0.32s',
841
+ },
842
+ '&:nth-of-type(2)': {
843
+ animationDelay: '-0.16s',
844
+ },
845
+ },
846
+ },
847
+ '&.error': {
848
+ border: '1px solid #dc3545',
849
+ background: '#fff5f5',
850
+ '.ss__chat__attachment-context__item__error-icon': {
851
+ fontSize: '14px',
852
+ color: '#dc3545',
853
+ margin: '0 4px',
854
+ flex: '0 0 auto',
855
+ },
856
+ '.ss__chat__attachment-context__item__error-message': {
857
+ fontSize: '12px',
858
+ color: '#dc3545',
859
+ whiteSpace: 'normal',
860
+ wordBreak: 'break-word',
861
+ flex: '1 1 auto',
862
+ minWidth: 0,
863
+ },
864
+ '.ss__button': {
865
+ svg: {
866
+ fill: '#dc3545',
867
+ stroke: '#dc3545',
868
+ },
869
+ },
870
+ },
871
+ img: {
872
+ '&.loading': {
873
+ opacity: 0.3,
874
+ },
875
+ },
876
+ },
877
+ },
878
+ '.ss__chat__content__footer': __assign({ padding: '1em', display: 'flex', flexDirection: 'column', gap: '8px', flexShrink: 0 }, (mobile
879
+ ? {
880
+ position: 'relative',
881
+ zIndex: 11,
882
+ background: '#fff',
883
+ }
884
+ : {})),
885
+ '.ss__chat__topic-drift': {
886
+ display: 'flex',
887
+ alignItems: 'center',
888
+ gap: '12px',
889
+ padding: '12px 16px',
890
+ border: '1px solid #93C5FD',
891
+ borderRadius: '8px',
892
+ backgroundColor: '#fff',
893
+ '.ss__chat__topic-drift__icon--info': {
894
+ flex: '0 0 auto',
895
+ fill: colorPrimary,
896
+ stroke: colorPrimary,
897
+ svg: {
898
+ fill: colorPrimary,
899
+ stroke: colorPrimary,
900
+ },
901
+ },
902
+ '.ss__chat__topic-drift__text': {
903
+ flex: '1 1 0%',
904
+ display: 'flex',
905
+ flexDirection: 'column',
906
+ gap: '2px',
907
+ 'span:first-of-type': {
908
+ fontWeight: 'bold',
909
+ color: colorPrimary,
910
+ fontSize: '14px',
911
+ },
912
+ 'span:last-of-type': {
913
+ color: '#6A7282',
914
+ fontSize: '13px',
915
+ },
916
+ },
917
+ '.ss__chat__topic-drift__button': {
918
+ flex: '0 0 auto',
919
+ backgroundColor: colorPrimary,
920
+ color: '#fff',
921
+ borderRadius: '6px',
922
+ padding: '8px 14px',
923
+ fontSize: '13px',
924
+ fontWeight: 500,
925
+ cursor: 'pointer',
926
+ whiteSpace: 'nowrap',
927
+ '&:not(.ss__button--disabled):hover': {
928
+ background: '#1a2a5c',
929
+ },
930
+ },
931
+ '.ss__chat__topic-drift__icon--close': {
932
+ flex: '0 0 auto',
933
+ cursor: 'pointer',
934
+ fill: '#6A7282',
935
+ stroke: '#6A7282',
936
+ svg: {
937
+ fill: '#6A7282',
938
+ stroke: '#6A7282',
939
+ },
940
+ },
941
+ },
942
+ '.ss__chat__input': {
943
+ display: 'flex',
944
+ justifyContent: 'space-between',
945
+ gap: '8px',
946
+ flexShrink: 0,
947
+ '.ss__chat__input__input': {
948
+ flex: '1 1 0%',
949
+ minWidth: 0,
950
+ border: '1px solid #ccc',
951
+ borderRadius: '2em',
952
+ display: 'flex',
953
+ justifyContent: 'space-between',
954
+ overflow: 'auto',
955
+ 'input[type="text"]': {
956
+ padding: '0.5em 0',
957
+ margin: '0 0 0 1em',
958
+ flex: '1 0 auto',
959
+ '&::placeholder': {
960
+ color: '#999',
961
+ opacity: 0.7,
962
+ },
963
+ '&:focus': {
964
+ outline: 'none',
965
+ borderColor: '#0066cc',
966
+ },
967
+ },
968
+ '.ss__button': {
969
+ margin: '0 0.5em 0 0',
970
+ '&:hover': {
971
+ backgroundColor: 'transparent',
972
+ },
973
+ },
974
+ 'input[type="file"]': {
975
+ display: 'none',
976
+ },
977
+ },
978
+ '.ss__chat__input__actions': {
979
+ '.ss__button': {
980
+ backgroundColor: colorPrimary,
981
+ borderRadius: '50%',
982
+ height: '3em',
983
+ width: '3em',
984
+ cursor: 'pointer',
985
+ justifyContent: 'center',
986
+ '&:disabled': {
987
+ opacity: 0.5,
988
+ cursor: 'not-allowed',
989
+ },
990
+ svg: {
991
+ fill: '#fff',
992
+ stroke: '#fff',
993
+ },
994
+ },
995
+ },
996
+ },
997
+ '.ss__chat__disclaimer': {
998
+ fontSize: '10px',
999
+ color: '#6A7282',
1000
+ textAlign: 'center',
1001
+ flexShrink: 0,
1002
+ },
1003
+ },
1004
+ });
1005
+ };
1006
+ exports.Chat = (0, mobx_react_lite_1.observer)(function (properties) {
1007
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
1008
+ var globalTheme = (0, providers_1.useTheme)();
1009
+ var globalTreePath = (0, providers_1.useTreePath)();
1010
+ var isMobile = (0, __1.useMediaQuery)('(max-width: 767px)');
1011
+ var defaultProps = {
1012
+ treePath: globalTreePath,
1013
+ logo: 'https://cdn.athoscommerce.net/snap/images/Athos%20Commerce_Icon_white.svg',
1014
+ title: 'Athos Conversational Assistant',
1015
+ subtitle: 'Ready to assist you',
1016
+ multiselectFacets: true,
1017
+ };
1018
+ var props = (0, utilities_1.mergeProps)('facets', globalTheme, defaultProps, properties);
1019
+ var className = props.className, internalClassName = props.internalClassName, controller = props.controller, logo = props.logo, title = props.title, subtitle = props.subtitle, offset = props.offset, multiselectFacets = props.multiselectFacets;
1020
+ var store = controller.store;
1021
+ var themeDefaults = {
1022
+ components: {},
1023
+ };
1024
+ // merge deeply the themeDefaults with the theme props and the displaySettings theme props (do not merge arrays, but replace them)
1025
+ var theme = (0, deepmerge_1.default)(themeDefaults, (props === null || props === void 0 ? void 0 : props.theme) || {}, { arrayMerge: function (destinationArray, sourceArray) { return sourceArray; } });
1026
+ props = __assign(__assign({}, props), { theme: theme });
1027
+ var fileInputRef = (0, hooks_1.useRef)(null);
1028
+ var messagesEndRef = (0, hooks_1.useRef)(null);
1029
+ var messagesContainerRef = (0, hooks_1.useRef)(null);
1030
+ var footerRef = (0, hooks_1.useRef)(null);
1031
+ // Swipe-to-dismiss state for mobile secondary panel
1032
+ var secondaryRef = (0, hooks_1.useRef)(null);
1033
+ var swipeStartY = (0, hooks_1.useRef)(0);
1034
+ var swipeStartTime = (0, hooks_1.useRef)(0);
1035
+ var swipeActive = (0, hooks_1.useRef)(false);
1036
+ var swipeOffsetRef = (0, hooks_1.useRef)(0);
1037
+ var _y = (0, hooks_1.useState)(0), swipeOffset = _y[0], setSwipeOffsetRaw = _y[1];
1038
+ var _z = (0, hooks_1.useState)(false), swipeAnimating = _z[0], setSwipeAnimating = _z[1];
1039
+ var _0 = (0, hooks_1.useState)(false), mobileProductInfoOpen = _0[0], setMobileProductInfoOpen = _0[1];
1040
+ var _1 = (0, hooks_1.useState)(0), footerHeight = _1[0], setFooterHeight = _1[1];
1041
+ var updateSwipeOffset = function (value) {
1042
+ swipeOffsetRef.current = value;
1043
+ setSwipeOffsetRaw(value);
1044
+ };
1045
+ var scrollToBottom = function () {
1046
+ var _a;
1047
+ (_a = messagesEndRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ behavior: 'smooth' });
1048
+ };
1049
+ // Auto-scroll to bottom when new messages are added or chat state changes
1050
+ (0, hooks_1.useEffect)(function () {
1051
+ // if (store.open && messagesContainerRef.current) {
1052
+ // messagesContainerRef.current.scrollTop = messagesContainerRef.current.scrollHeight;
1053
+ // }
1054
+ if (store.open) {
1055
+ scrollToBottom();
1056
+ }
1057
+ }, [(_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.chat.length, store.loading, store.open]);
1058
+ // const subProps: ChatSubProps = {};
1059
+ var activeMessage = (_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.activeMessage;
1060
+ // On mobile, only auto-open the secondary panel for the first productComparison
1061
+ // message in the chat session. Subsequent comparison results show a "Show Details"
1062
+ // button instead (handled in MessageText via sideChatLabel toggle).
1063
+ var isFirstMobileComparison = (function () {
1064
+ var _a, _b;
1065
+ if (!isMobile || (activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.messageType) !== 'productComparison')
1066
+ return true;
1067
+ // If the user explicitly activated a comparison (via "Show Details" or the
1068
+ // view-side-chat button), always allow it regardless of position in the chat
1069
+ if ((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.activeMessageId)
1070
+ return true;
1071
+ var comparisonMessages = (((_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.chat) || []).filter(function (m) { return m.messageType === 'productComparison'; });
1072
+ return comparisonMessages.length <= 1;
1073
+ })();
1074
+ var sideChatTypes = isMobile
1075
+ ? __spreadArray(__spreadArray(['inspirationResult'], (isFirstMobileComparison ? ['productComparison'] : []), true), (mobileProductInfoOpen ? ['productQuery'] : []), true) : ['inspirationResult', 'productComparison', 'productQuery'];
1076
+ var shouldShowSideChat = activeMessage && sideChatTypes.includes(activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.messageType) && ((_c = store.currentChat) === null || _c === void 0 ? void 0 : _c.dismissedSideChatMessageId) !== activeMessage.id;
1077
+ var styling = (0, utilities_1.mergeStyles)({ mobile: isMobile, offset: offset, hasSideChat: !!shouldShowSideChat, footerHeight: footerHeight }, defaultStyles);
1078
+ // Lock body scroll while chat is open so touch/wheel scrolls don't leak to the page behind
1079
+ (0, hooks_1.useEffect)(function () {
1080
+ if (!store.open)
1081
+ return;
1082
+ var body = document.body;
1083
+ var previousOverflow = body.style.overflow;
1084
+ var previousOverscroll = body.style.overscrollBehavior;
1085
+ body.style.overflow = 'hidden';
1086
+ body.style.overscrollBehavior = 'contain';
1087
+ return function () {
1088
+ body.style.overflow = previousOverflow;
1089
+ body.style.overscrollBehavior = previousOverscroll;
1090
+ };
1091
+ }, [store.open]);
1092
+ // Track the primary footer height so the mobile secondary panel can sit above it
1093
+ (0, hooks_1.useEffect)(function () {
1094
+ var el = footerRef.current;
1095
+ if (!el)
1096
+ return;
1097
+ var observer = new ResizeObserver(function (entries) {
1098
+ var _a, _b, _c;
1099
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
1100
+ var entry = entries_1[_i];
1101
+ setFooterHeight((_c = (_b = (_a = entry.borderBoxSize) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.blockSize) !== null && _c !== void 0 ? _c : entry.target.getBoundingClientRect().height);
1102
+ }
1103
+ });
1104
+ observer.observe(el);
1105
+ return function () { return observer.disconnect(); };
1106
+ }, [store.open, (_d = store.currentChat) === null || _d === void 0 ? void 0 : _d.isExpired]);
1107
+ var HistoryButton = function (props) { return ((0, jsx_runtime_1.jsx)(Button_1.Button, { className: "ss__chat__header__button--history", disabled: props.disabled, icon: {
1108
+ icon: 'history',
1109
+ title: 'Chat History',
1110
+ } })); };
1111
+ var HistoryPopup = function (props) { return ((0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__history", children: [(0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__history__header", children: [(0, jsx_runtime_1.jsx)("h4", { children: "History" }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__history__header__buttons", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { content: "clear", onClick: function () {
1112
+ controller.store.clearHistory();
1113
+ props.toggleOpen && props.toggleOpen();
1114
+ } }) })] }), store.chats.length > 0 ? ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__history__chats", children: store.chats.map(function (chat) { return ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__history__chats__chat", children: (0, jsx_runtime_1.jsxs)(Button_1.Button, { className: "ss__chat__history__chat__button", onClick: function () {
1115
+ controller.store.switchChat(chat.id);
1116
+ }, disabled: chat.id === store.currentChatId, children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__chat__history__chat__button__text", children: (function () {
1117
+ var lastUserMessage = __spreadArray([], chat.chat, true).reverse().find(function (message) { return message.messageType === 'user'; });
1118
+ if (!lastUserMessage)
1119
+ return 'New Chat';
1120
+ var text = lastUserMessage.text;
1121
+ return text.length > 50 ? "".concat(text.slice(0, 50), "...") : text;
1122
+ })() }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__history__chat__button__date", children: chat.createdAt.toLocaleString() })] }) }, chat.id)); }) })) : null] })); };
1123
+ var FacetButton = function (props) { return (0, jsx_runtime_1.jsx)(Button_1.Button, { icon: props.open ? 'angle-down' : 'angle-up', children: props.label }); };
1124
+ // TODO: if starting a new chat and it's expired, this button would then disappear
1125
+ if (!controller.store.chatEnabled) {
1126
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
1127
+ }
1128
+ // Reset swipe state when secondary panel opens/closes or active message changes
1129
+ (0, hooks_1.useEffect)(function () {
1130
+ updateSwipeOffset(0);
1131
+ setSwipeAnimating(false);
1132
+ swipeActive.current = false;
1133
+ }, [shouldShowSideChat, activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.id]);
1134
+ var onSwipeStart = function (e) {
1135
+ swipeStartY.current = e.touches[0].clientY;
1136
+ swipeStartTime.current = Date.now();
1137
+ swipeActive.current = false; // only activate after dead-zone threshold
1138
+ setSwipeAnimating(false);
1139
+ };
1140
+ var onSwipeMove = function (e) {
1141
+ var diff = e.touches[0].clientY - swipeStartY.current;
1142
+ // Require a minimum drag distance before activating the swipe,
1143
+ // so taps on buttons (e.g. close) still fire their click events.
1144
+ if (!swipeActive.current) {
1145
+ if (Math.abs(diff) < 8)
1146
+ return; // still within dead-zone
1147
+ swipeActive.current = true;
1148
+ }
1149
+ if (diff > 0) {
1150
+ e.preventDefault();
1151
+ updateSwipeOffset(diff);
1152
+ }
1153
+ else {
1154
+ updateSwipeOffset(0);
1155
+ }
1156
+ };
1157
+ var onSwipeEnd = function () {
1158
+ var _a;
1159
+ if (!swipeActive.current)
1160
+ return;
1161
+ swipeActive.current = false;
1162
+ var offset = swipeOffsetRef.current;
1163
+ var height = ((_a = secondaryRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 400;
1164
+ var elapsed = Date.now() - swipeStartTime.current;
1165
+ var velocity = offset / (elapsed || 1); // px per ms
1166
+ // Dismiss if dragged past 25% threshold OR a quick flick (>0.5 px/ms with >50px travel)
1167
+ var shouldDismiss = offset > height * 0.25 || (velocity > 0.5 && offset > 50);
1168
+ if (shouldDismiss) {
1169
+ // Animate out then dismiss
1170
+ setSwipeAnimating(true);
1171
+ updateSwipeOffset(height);
1172
+ setTimeout(function () {
1173
+ var _a, _b;
1174
+ var attachments = ((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.attached) || [];
1175
+ var productAttachments = attachments.filter(function (item) { return item.type === 'product' && item.requestType !== 'productSimilar' && item.requestType !== 'productComparison'; });
1176
+ productAttachments.forEach(function (item) { var _a; return (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.remove(item.id); });
1177
+ setMobileProductInfoOpen(false);
1178
+ (_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.dismissSideChat();
1179
+ updateSwipeOffset(0);
1180
+ setSwipeAnimating(false);
1181
+ }, 300);
1182
+ }
1183
+ else {
1184
+ // Snap back
1185
+ setSwipeAnimating(true);
1186
+ updateSwipeOffset(0);
1187
+ setTimeout(function () { return setSwipeAnimating(false); }, 300);
1188
+ }
1189
+ };
1190
+ var requestType = (_e = store.currentChat) === null || _e === void 0 ? void 0 : _e.requestType;
1191
+ var loadingVerbs = (0, hooks_1.useMemo)(function () {
1192
+ switch (requestType) {
1193
+ case 'productQuery':
1194
+ return ['Thinking', 'Searching', 'Analyzing', 'Gathering details'];
1195
+ case 'productSearch':
1196
+ return ['Searching', 'Browsing catalog', 'Finding products', 'Curating results'];
1197
+ case 'productComparison':
1198
+ return ['Comparing', 'Analyzing', 'Evaluating', 'Weighing options'];
1199
+ case 'imageSearch':
1200
+ return ['Analyzing image', 'Identifying', 'Searching', 'Matching'];
1201
+ case 'productSimilar':
1202
+ return ['Finding similar items', 'Searching', 'Matching', 'Curating'];
1203
+ case 'inspirationRequest':
1204
+ return ['Brainstorming', 'Imagining', 'Curating', 'Inspiring'];
1205
+ case 'general':
1206
+ default:
1207
+ return undefined;
1208
+ }
1209
+ }, [requestType]);
1210
+ return ((0, jsx_runtime_1.jsx)(providers_1.CacheProvider, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ className: (0, classnames_1.default)('ss__chat', {
1211
+ 'ss__chat--open': store.open,
1212
+ 'ss__chat--minimized': !store.open,
1213
+ 'ss__chat--mobile': isMobile,
1214
+ }, className, internalClassName) }, styling, { children: [!store.open && !store.currentChat && ((_f = store.suggestedQuestions) === null || _f === void 0 ? void 0 : _f.length) > 0 && ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__suggested-questions", children: store.suggestedQuestions.map(function (question, index) { return ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__suggested-questions__item", onClick: function () {
1215
+ controller.openChat(question);
1216
+ }, children: question }, index)); }) })), (0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__bubble', onClick: function () { return controller.handlers.button.click(); }, children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: "chat", title: "Open Chat" }) }), store.open && shouldShowSideChat && activeMessage ? ((0, jsx_runtime_1.jsxs)("div", { ref: secondaryRef, className: (0, classnames_1.default)('ss__chat__secondary'), style: isMobile
1217
+ ? {
1218
+ // Touch swipe animations need to be inline to prevent visual jumps
1219
+ transform: swipeOffset > 0 ? "translateY(".concat(swipeOffset, "px)") : undefined,
1220
+ transition: swipeAnimating ? 'transform 0.3s ease-out' : 'none',
1221
+ }
1222
+ : undefined, children: [isMobile && ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__secondary__drag-handle", onTouchStart: onSwipeStart, onTouchMove: onSwipeMove, onTouchEnd: onSwipeEnd, children: (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__secondary__drag-handle__indicator" }) })), (0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__header', onTouchStart: isMobile ? onSwipeStart : undefined, onTouchMove: isMobile ? onSwipeMove : undefined, onTouchEnd: isMobile ? onSwipeEnd : undefined, children: [(0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__header__title", children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__chat__header__title__primary", children: {
1223
+ inspirationResult: 'Inspiration Scenarios',
1224
+ productComparison: 'Product Comparison',
1225
+ productQuery: 'Product Information',
1226
+ }[activeMessage.messageType] || null }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__header__title__secondary", children: {
1227
+ inspirationResult: 'Choose a style direction to explore',
1228
+ productComparison: "Comparing ".concat(((_g = activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.comparisonData) === null || _g === void 0 ? void 0 : _g.features.length) ||
1229
+ ((_h = activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.searchResults) === null || _h === void 0 ? void 0 : _h.length), " products"),
1230
+ productQuery: 'Complete product details',
1231
+ }[activeMessage.messageType] || null })] }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__header__buttons", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { className: "ss__chat__header__button--close", icon: { icon: 'close2', title: 'Close Chat' }, onClick: function () {
1232
+ var _a, _b;
1233
+ // clear any product attachments tied to the side chat (discuss product flow)
1234
+ // so the attachments bar disappears alongside the secondary panel
1235
+ // but preserve productComparison attachments so the user can continue comparing
1236
+ var productAttachmentsToRemove = (((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.attached) || []).filter(function (item) {
1237
+ return item.type === 'product' &&
1238
+ item.requestType !== 'productSimilar' &&
1239
+ item.requestType !== 'productComparison';
1240
+ });
1241
+ productAttachmentsToRemove.forEach(function (item) { var _a; return (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.remove(item.id); });
1242
+ setMobileProductInfoOpen(false);
1243
+ (_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.dismissSideChat();
1244
+ } }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__content", children: (0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__messages', children: {
1245
+ inspirationResult: ((0, jsx_runtime_1.jsx)(ChatInspirationResultMessage_1.ChatInspirationResultMessage, { chatItem: activeMessage, controller: controller, onViewProduct: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined })),
1246
+ productComparison: ((0, jsx_runtime_1.jsx)(ChatProductComparisonMessage_1.ChatProductComparisonMessage, { chatItem: activeMessage, controller: controller })),
1247
+ productQuery: ((0, jsx_runtime_1.jsx)(ChatProductQueryMessage_1.ChatProductQueryMessage, { chatItem: activeMessage, controller: controller, displayFields: (_j = controller.config.settings) === null || _j === void 0 ? void 0 : _j.displayFields })),
1248
+ }[activeMessage.messageType] || null }) })] })) : null, store.open ? ((0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__primary', children: [(0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__header', children: [(0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__header__title", children: [logo ? (0, jsx_runtime_1.jsx)("img", { className: "ss__chat__header__title__logo", src: logo }) : null, (0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__header__title__text", children: [title ? (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__header__title__text__primary", children: title }) : null, subtitle ? (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__header__title__text__secondary", children: subtitle }) : null] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__header__buttons", children: [(0, jsx_runtime_1.jsx)(Button_1.Button
1249
+ // disabled={store.currentChat?.chat && store.currentChat.chat.length <= 1}
1250
+ , {
1251
+ // disabled={store.currentChat?.chat && store.currentChat.chat.length <= 1}
1252
+ className: "ss__chat__header__button--new", icon: { icon: controller.store.initChatLoading ? 'spinner' : 'plus2', title: 'New Chat' }, onClick: function () { return controller.store.createChat(); } }), store.chats.length > 1 && ((0, jsx_runtime_1.jsx)(__1.Dropdown, { disabled: store.chats.length == 1 && store.currentChat && store.currentChat.chat.length <= 1, className: "ss__chat__header__dropdown-history", button: (0, jsx_runtime_1.jsx)(HistoryButton, {}), children: (0, jsx_runtime_1.jsx)(HistoryPopup, {}) })), (0, jsx_runtime_1.jsx)(Button_1.Button, { className: "ss__chat__header__button--close", icon: { icon: 'close2', title: 'Close Chat' }, onClick: function () { return controller.handlers.button.click(); } })] })] }), (function () {
1253
+ var _a, _b, _c, _d, _e, _f;
1254
+ var feedbackAfterMessages = (_a = controller.config.settings) === null || _a === void 0 ? void 0 : _a.feedbackAfterMessages;
1255
+ var systemMessages = (((_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.chat) || []).filter(function (msg) { return msg.messageType !== 'user' && msg.messageType !== 'productQuery'; });
1256
+ var currentRating = (_d = (_c = store.currentChat) === null || _c === void 0 ? void 0 : _c.sessionFeedback) === null || _d === void 0 ? void 0 : _d.rating;
1257
+ var hasRated = !!currentRating;
1258
+ var shouldShowFeedback = feedbackAfterMessages &&
1259
+ systemMessages.length >= feedbackAfterMessages &&
1260
+ !((_e = store.currentChat) === null || _e === void 0 ? void 0 : _e.feedbackDismissed) &&
1261
+ (!hasRated || ((_f = store.currentChat) === null || _f === void 0 ? void 0 : _f.feedbackJustGiven));
1262
+ return shouldShowFeedback ? ((0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__session-feedback", children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__chat__session-feedback__icon", children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: "chat", size: "16px" }) }), (0, jsx_runtime_1.jsx)("span", { className: "ss__chat__session-feedback__label", children: hasRated ? 'Thank you for your feedback' : "How's your experience so far?" }), (0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__session-feedback__actions".concat(hasRated ? ' ss__chat__session-feedback__actions--rated' : ''), children: [(!hasRated || currentRating === 'UP') && ((0, jsx_runtime_1.jsx)("span", { onClick: function () { return !hasRated && controller.handleFeedback('UP'); }, children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: 'thumbs-up', title: 'Thumbs Up' }) })), (!hasRated || currentRating === 'DOWN') && ((0, jsx_runtime_1.jsx)("span", { onClick: function () { return !hasRated && controller.handleFeedback('DOWN'); }, children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: 'thumbs-down', title: 'Thumbs Down' }) }))] }), !hasRated && ((0, jsx_runtime_1.jsx)("span", { className: "ss__chat__session-feedback__close", onClick: function () {
1263
+ if (store.currentChat) {
1264
+ store.currentChat.feedbackDismissed = true;
1265
+ store.currentChat.save();
1266
+ }
1267
+ }, children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: "close-thin", size: "14px" }) }))] })) : null;
1268
+ })(), (0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__content", children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__chat__content__header", children: ((_k = store.currentChat) === null || _k === void 0 ? void 0 : _k.comparisons.compared) && store.currentChat.comparisons.compared.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__content__header__comparisons', children: [(0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__content__header__comparisons__header', children: [(0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__content__header__comparisons__header__title', children: [(0, jsx_runtime_1.jsx)(__1.Icon, { className: 'ss__chat__content__header__comparisons__header__title__icon', icon: 'clipboard' }), (0, jsx_runtime_1.jsxs)("span", { className: 'ss__chat__content__header__comparisons__header__title__text', children: ["Compare Products (", (_l = store.currentChat) === null || _l === void 0 ? void 0 : _l.comparisons.compared.length, "/", (_m = store.currentChat) === null || _m === void 0 ? void 0 : _m.comparisons.maxItems, ")"] })] }), (0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__content__header__comparisons__header__actions', children: (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: function () { var _a; return (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.comparisons.reset(); }, children: "clear" }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__content__header__comparisons__content', children: [(0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__content__header__comparisons__content__items', children: Array.from({ length: (_o = store.currentChat) === null || _o === void 0 ? void 0 : _o.comparisons.maxItems }).map(function (_, index) {
1269
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1270
+ var comparisonItem = (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.comparisons.compared[index];
1271
+ return ((0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ss__chat__content__header__comparisons__content__comparison', {
1272
+ 'ss__chat__content__header__comparisons__content__comparison--placeholder': !comparisonItem,
1273
+ }), children: comparisonItem ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Image_1.Image
1274
+ // onClick={() => {
1275
+ // controller?.viewProduct(product as any);
1276
+ // }}
1277
+ , {
1278
+ // onClick={() => {
1279
+ // controller?.viewProduct(product as any);
1280
+ // }}
1281
+ alt: ((_e = (_d = (_c = (((_b = comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result) === null || _b === void 0 ? void 0 : _b.display) || (comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result))) === null || _c === void 0 ? void 0 : _c.mappings) === null || _d === void 0 ? void 0 : _d.core) === null || _e === void 0 ? void 0 : _e.name) || '', src: ((_j = (_h = (_g = (((_f = comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result) === null || _f === void 0 ? void 0 : _f.display) || (comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result))) === null || _g === void 0 ? void 0 : _g.mappings) === null || _h === void 0 ? void 0 : _h.core) === null || _j === void 0 ? void 0 : _j.imageUrl) || '' }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__content__header__comparisons__content__comparison__remove", onClick: function () {
1282
+ var _a;
1283
+ (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.comparisons.remove(comparisonItem.result.id);
1284
+ }, children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: 'close-thin', size: '12px' }) })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(__1.Icon, { icon: 'plus-thin' }), (0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__content__header__comparisons__content__comparison--placeholder__text', children: "Add" })] })) }, index));
1285
+ }) }), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ss__chat__content__header__comparisons__action', {
1286
+ 'ss__chat__content__header__comparisons__action--hidden': (((_p = store.currentChat) === null || _p === void 0 ? void 0 : _p.comparisons.compared.length) || 0) < 2,
1287
+ }), children: (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: function () { return controller.search(); }, icon: { icon: 'compare', title: 'Compare' }, children: "Compare" }) })] })] })) }), (0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__messages', ref: messagesContainerRef, children: [(!((_q = store.currentChat) === null || _q === void 0 ? void 0 : _q.chat) || store.currentChat.chat.length === 0) && store.welcomeMessage && ((0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__welcome", children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__chat__welcome__message", children: store.welcomeMessage }), (0, jsx_runtime_1.jsx)(SuggestedQuestions_1.SuggestedQuestions, { questions: store.suggestedQuestions, controller: controller })] })), (_r = store.currentChat) === null || _r === void 0 ? void 0 : _r.chat.filter(function (chatItem) { return chatItem.messageType !== 'productQuery'; }).map(function (chatItem, index) { return ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__message ss__chat__message--".concat(chatItem.messageType), children: {
1288
+ user: ((0, jsx_runtime_1.jsx)(MessageUser_1.MessageUser, { chatItem: chatItem, controller: controller, onViewProduct: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined })),
1289
+ text: ((0, jsx_runtime_1.jsx)(MessageText_1.MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottom, onViewProduct: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, sideChatOpen: !!shouldShowSideChat })),
1290
+ content: ((0, jsx_runtime_1.jsx)(MessageText_1.MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottom, onViewProduct: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, sideChatOpen: !!shouldShowSideChat })),
1291
+ productSearchResult: ((0, jsx_runtime_1.jsx)(MessageText_1.MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottom, onViewProduct: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, sideChatOpen: !!shouldShowSideChat })),
1292
+ inspirationResult: ((0, jsx_runtime_1.jsx)(MessageText_1.MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottom, onViewProduct: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, sideChatOpen: !!shouldShowSideChat })),
1293
+ productAnswer: ((0, jsx_runtime_1.jsx)(MessageText_1.MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottom, onViewProduct: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, sideChatOpen: !!shouldShowSideChat })),
1294
+ productComparison: (function () {
1295
+ var _a;
1296
+ // On mobile, only the first productComparison in the session
1297
+ // auto-opens the secondary panel. Subsequent ones get a
1298
+ // prominent "Show Details" button instead.
1299
+ var comparisonMessages = (((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.chat) || []).filter(function (m) { return m.messageType === 'productComparison'; });
1300
+ var isFirst = comparisonMessages.length > 0 && comparisonMessages[0].id === chatItem.id;
1301
+ return ((0, jsx_runtime_1.jsx)(MessageText_1.MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottom, onViewProduct: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, showDetailsButton: isMobile && !isFirst, sideChatOpen: !!shouldShowSideChat }));
1302
+ })(),
1303
+ productRecommendation: ((0, jsx_runtime_1.jsx)(MessageText_1.MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottom, onViewProduct: isMobile ? function () { return setMobileProductInfoOpen(true); } : undefined, sideChatOpen: !!shouldShowSideChat })),
1304
+ actions: (0, jsx_runtime_1.jsx)(SuggestedQuestions_1.SuggestedQuestions, { actions: chatItem.actions, controller: controller }),
1305
+ errorResponse: ((0, jsx_runtime_1.jsx)(MessageText_1.MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottom, sideChatOpen: !!shouldShowSideChat })),
1306
+ topicDrift: ((0, jsx_runtime_1.jsx)(MessageText_1.MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottom, sideChatOpen: !!shouldShowSideChat })),
1307
+ productQuery: null,
1308
+ }[chatItem.messageType] || null }, index)); }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__messages__end", ref: messagesEndRef })] }), (0, jsx_runtime_1.jsx)(ChatLoadingIndicator_1.ChatLoadingIndicator, { loading: store.loading, verbs: loadingVerbs }), !((_s = store.currentChat) === null || _s === void 0 ? void 0 : _s.isExpired) ? ((0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__content__footer", ref: footerRef, children: [store.error && (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__error", children: store.error.message }), ((_t = store.currentChat) === null || _t === void 0 ? void 0 : _t.sessionLimitReached) && ((0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__topic-drift', children: [(0, jsx_runtime_1.jsx)(__1.Icon, { icon: "info", size: "18px", className: 'ss__chat__topic-drift__icon--info' }), (0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__topic-drift__text', children: [(0, jsx_runtime_1.jsx)("span", { children: "Session limit reached" }), (0, jsx_runtime_1.jsx)("span", { children: "This chat has reached its maximum number of interactions. Start a new session to continue." })] }), (0, jsx_runtime_1.jsx)(Button_1.Button, { className: 'ss__chat__topic-drift__button', onClick: function () {
1309
+ controller.store.createChat();
1310
+ }, children: "New Session" })] })), ((_u = store.currentChat) === null || _u === void 0 ? void 0 : _u.actions) && store.currentChat.actions.length > 0 && ((0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__actions', children: (_v = store.currentChat) === null || _v === void 0 ? void 0 : _v.actions.map(function (action, index) {
1311
+ var _a;
1312
+ return ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__actions__wrap", children: {
1313
+ facets: action.data.length ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__actions__facets-header", children: [(0, jsx_runtime_1.jsx)("div", { className: "ss__chat__actions--title", children: "Filter by:" }), multiselectFacets && (((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.attached.some(function (item) { return item.type === 'facet'; })) || false) && ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__actions__facets-apply", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: function () {
1314
+ controller.search();
1315
+ }, children: "Apply Filters" }) }))] }), (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__actions--facets", children: action.data.slice(0, 10).map(function (facet, idx) {
1316
+ var _a;
1317
+ if (!((_a = facet.values) === null || _a === void 0 ? void 0 : _a.length))
1318
+ return null;
1319
+ return ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__actions__facet ss__chat__actions__facet--".concat(facet.type), children: (0, jsx_runtime_1.jsx)(__1.Dropdown, { usePortal: true, dropUp: true, button: (0, jsx_runtime_1.jsx)(FacetButton, { label: facet.label || facet.field }), style: {
1320
+ '.ss__dropdown__content': __assign({ width: '150px', maxHeight: '200px', overflowY: 'auto', background: 'white', boxShadow: '0px 3px 6px 0px rgba(0, 0, 0, 0.2)', borderRadius: '6px' }, (multiselectFacets
1321
+ ? {
1322
+ '.ss__chat__actions__facet__option--checkbox': {
1323
+ display: 'flex',
1324
+ alignItems: 'center',
1325
+ gap: '8px',
1326
+ padding: '6px 10px',
1327
+ cursor: 'pointer',
1328
+ width: '100%',
1329
+ boxSizing: 'border-box',
1330
+ background: '#fff',
1331
+ border: 'none',
1332
+ borderBottom: '1px solid #f0f0f0',
1333
+ '&:hover': {
1334
+ background: '#f4f4ff',
1335
+ },
1336
+ '&:last-child': {
1337
+ borderBottom: 'none',
1338
+ },
1339
+ '.ss__chat__actions__facet__option__checkbox': {
1340
+ width: '16px',
1341
+ height: '16px',
1342
+ borderRadius: '3px',
1343
+ border: '2px solid #ccc',
1344
+ display: 'flex',
1345
+ alignItems: 'center',
1346
+ justifyContent: 'center',
1347
+ flexShrink: 0,
1348
+ '&.ss__chat__actions__facet__option__checkbox--checked': {
1349
+ background: '#253B80',
1350
+ borderColor: '#253B80',
1351
+ },
1352
+ },
1353
+ '.ss__chat__actions__facet__option__label': {
1354
+ fontSize: '14px',
1355
+ color: '#333',
1356
+ flex: '1 1 auto',
1357
+ textAlign: 'left',
1358
+ },
1359
+ },
1360
+ }
1361
+ : {
1362
+ '.ss__button': {
1363
+ width: '100%',
1364
+ border: 'none',
1365
+ borderRadius: 0,
1366
+ boxSizing: 'border-box',
1367
+ background: '#fff',
1368
+ '&:hover': {
1369
+ background: '#f4f4ff',
1370
+ },
1371
+ },
1372
+ })),
1373
+ }, children: (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__actions__facet__options", children: facet.type === 'range-buckets'
1374
+ ? facet.values.map(function (option) {
1375
+ var _a, _b;
1376
+ var optionValue = "".concat((_a = option.low) !== null && _a !== void 0 ? _a : '*', ":").concat((_b = option.high) !== null && _b !== void 0 ? _b : '*');
1377
+ if (multiselectFacets) {
1378
+ var isSelected_1 = controller.store.isFacetSelected(facet.field, optionValue);
1379
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__actions__facet__option--checkbox", onClick: function () {
1380
+ if (isSelected_1) {
1381
+ controller.store.removeFacet(facet.field, optionValue);
1382
+ }
1383
+ else {
1384
+ controller.store.addFacet({
1385
+ key: facet.field,
1386
+ facetLabel: facet.label,
1387
+ value: optionValue,
1388
+ label: option.label,
1389
+ count: option.count,
1390
+ });
1391
+ }
1392
+ }, children: [(0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ss__chat__actions__facet__option__checkbox', {
1393
+ 'ss__chat__actions__facet__option__checkbox--checked': isSelected_1,
1394
+ }), children: isSelected_1 && (0, jsx_runtime_1.jsx)(__1.Icon, { icon: "check-thin", size: "10px" }) }), (0, jsx_runtime_1.jsx)("span", { className: "ss__chat__actions__facet__option__label", children: option.label })] }, optionValue));
1395
+ }
1396
+ return ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: function () {
1397
+ controller.store.addFacet({
1398
+ key: facet.field,
1399
+ facetLabel: facet.label,
1400
+ value: optionValue,
1401
+ label: option.label,
1402
+ count: option.count,
1403
+ });
1404
+ controller.search();
1405
+ }, children: option.label }, optionValue));
1406
+ })
1407
+ : facet.values.map(function (option) {
1408
+ var optionValue = option.value || option.label;
1409
+ if (multiselectFacets) {
1410
+ var isSelected_2 = controller.store.isFacetSelected(facet.field, optionValue);
1411
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__actions__facet__option--checkbox", onClick: function () {
1412
+ if (isSelected_2) {
1413
+ controller.store.removeFacet(facet.field, optionValue);
1414
+ }
1415
+ else {
1416
+ controller.store.addFacet({
1417
+ key: facet.field,
1418
+ facetLabel: facet.label,
1419
+ value: optionValue,
1420
+ label: option.label,
1421
+ count: option.count,
1422
+ });
1423
+ }
1424
+ }, children: [(0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)('ss__chat__actions__facet__option__checkbox', {
1425
+ 'ss__chat__actions__facet__option__checkbox--checked': isSelected_2,
1426
+ }), children: isSelected_2 && (0, jsx_runtime_1.jsx)(__1.Icon, { icon: "check-thin", size: "10px" }) }), (0, jsx_runtime_1.jsx)("span", { className: "ss__chat__actions__facet__option__label", children: option.label })] }, optionValue));
1427
+ }
1428
+ return ((0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: function () {
1429
+ controller.store.addFacet({
1430
+ key: facet.field,
1431
+ facetLabel: facet.label,
1432
+ value: optionValue,
1433
+ label: option.label,
1434
+ count: option.count,
1435
+ });
1436
+ controller.search();
1437
+ }, children: option.label }, optionValue));
1438
+ }) }) }, facet.field) }, idx));
1439
+ }) })] })) : null,
1440
+ actions: ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__actions--suggested" })),
1441
+ }[action.type] || null }, index));
1442
+ }) })), (function () {
1443
+ var _a, _b, _c;
1444
+ var activeComparisonSearchResults = shouldShowSideChat && (activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.messageType) === 'productComparison'
1445
+ ? activeMessage.searchResults || []
1446
+ : null;
1447
+ var showCommittedComparisons = !activeComparisonSearchResults &&
1448
+ ((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.comparisons.committed) &&
1449
+ store.currentChat.comparisons.committed.length > 0 &&
1450
+ ((activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.messageType) === 'user' ||
1451
+ (activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.messageType) === 'productComparison' ||
1452
+ (activeMessage === null || activeMessage === void 0 ? void 0 : activeMessage.messageType) === 'productQuery');
1453
+ var visibleAttachments = ((_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.attachments.attached.filter(function (item) { return item.state === 'attached' || item.state === 'active' || item.state === 'loading' || item.state === 'error'; })) || [];
1454
+ var productAttachments = visibleAttachments.filter(function (item) {
1455
+ return item.type === 'product' &&
1456
+ item.requestType !== 'productSimilar' &&
1457
+ item.requestType !== 'productComparison';
1458
+ });
1459
+ var imageAttachments = visibleAttachments.filter(function (item) { return item.type === 'image'; });
1460
+ var comparisonItems = activeComparisonSearchResults
1461
+ ? activeComparisonSearchResults.map(function (result) {
1462
+ var _a, _b, _c, _d, _e, _f;
1463
+ var d = (result === null || result === void 0 ? void 0 : result.display) || result;
1464
+ return {
1465
+ id: result === null || result === void 0 ? void 0 : result.id,
1466
+ name: ((_b = (_a = d === null || d === void 0 ? void 0 : d.mappings) === null || _a === void 0 ? void 0 : _a.core) === null || _b === void 0 ? void 0 : _b.name) || '',
1467
+ imageUrl: ((_d = (_c = d === null || d === void 0 ? void 0 : d.mappings) === null || _c === void 0 ? void 0 : _c.core) === null || _d === void 0 ? void 0 : _d.thumbnailImageUrl) || ((_f = (_e = d === null || d === void 0 ? void 0 : d.mappings) === null || _e === void 0 ? void 0 : _e.core) === null || _f === void 0 ? void 0 : _f.imageUrl) || '',
1468
+ onClick: isMobile
1469
+ ? function () {
1470
+ controller.viewProduct(result);
1471
+ setMobileProductInfoOpen(true);
1472
+ }
1473
+ : undefined,
1474
+ };
1475
+ })
1476
+ : showCommittedComparisons
1477
+ ? (((_c = store.currentChat) === null || _c === void 0 ? void 0 : _c.comparisons.committed) || []).map(function (comparisonItem) {
1478
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1479
+ var d = ((_a = comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result) === null || _a === void 0 ? void 0 : _a.display) || (comparisonItem === null || comparisonItem === void 0 ? void 0 : comparisonItem.result);
1480
+ return {
1481
+ id: (_b = comparisonItem.result) === null || _b === void 0 ? void 0 : _b.id,
1482
+ name: ((_d = (_c = d === null || d === void 0 ? void 0 : d.mappings) === null || _c === void 0 ? void 0 : _c.core) === null || _d === void 0 ? void 0 : _d.name) || '',
1483
+ imageUrl: ((_f = (_e = d === null || d === void 0 ? void 0 : d.mappings) === null || _e === void 0 ? void 0 : _e.core) === null || _f === void 0 ? void 0 : _f.thumbnailImageUrl) || ((_h = (_g = d === null || d === void 0 ? void 0 : d.mappings) === null || _g === void 0 ? void 0 : _g.core) === null || _h === void 0 ? void 0 : _h.imageUrl) || '',
1484
+ onClick: isMobile
1485
+ ? function () {
1486
+ controller.viewProduct(comparisonItem.result);
1487
+ setMobileProductInfoOpen(true);
1488
+ }
1489
+ : undefined,
1490
+ };
1491
+ })
1492
+ : [];
1493
+ var productItems = productAttachments.map(function (item) { return ({
1494
+ id: item.id,
1495
+ name: item.name || '',
1496
+ imageUrl: item.thumbnailUrl || '',
1497
+ onClick: isMobile
1498
+ ? function () {
1499
+ setMobileProductInfoOpen(true);
1500
+ }
1501
+ : function () {
1502
+ var _a, _b, _c;
1503
+ (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.setActiveMessage(((_c = (_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.activeMessage) === null || _c === void 0 ? void 0 : _c.id) || '');
1504
+ },
1505
+ onRemove: function () {
1506
+ var _a, _b;
1507
+ (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.remove(item.id);
1508
+ setMobileProductInfoOpen(false);
1509
+ (_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.dismissSideChat();
1510
+ },
1511
+ }); });
1512
+ var imageItems = imageAttachments.map(function (item) {
1513
+ var _a;
1514
+ return ({
1515
+ id: item.id,
1516
+ name: item.fileName || 'Image',
1517
+ imageUrl: item.base64 || item.thumbnailUrl || '',
1518
+ isLoading: item.state === 'loading',
1519
+ hasError: !!item.error,
1520
+ errorMessage: (_a = item.error) === null || _a === void 0 ? void 0 : _a.message,
1521
+ onRemove: function () { var _a; return (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.remove(item.id); },
1522
+ });
1523
+ });
1524
+ var productTitle = productItems.length > 1 ? 'Compare these products' : 'Ask about this product' + (isMobile ? '' : ' (click for details)');
1525
+ var hasImageError = imageItems.some(function (item) { return item.hasError; });
1526
+ var imageTitle = imageItems.length > 0 && !hasImageError ? 'Find products similar to this image:' : '';
1527
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [comparisonItems.length > 0 && ((0, jsx_runtime_1.jsx)(ChatAttachmentContext_1.ChatAttachmentContext, { title: 'Compare these products', items: comparisonItems, onClose: function () {
1528
+ var _a, _b;
1529
+ (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.comparisons.resetCommitted();
1530
+ (_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.dismissSideChat();
1531
+ } })), productItems.length > 0 && ((0, jsx_runtime_1.jsx)(ChatAttachmentContext_1.ChatAttachmentContext, { title: productTitle, items: productItems, onClose: function () {
1532
+ var _a;
1533
+ productAttachments.forEach(function (item) { var _a; return (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.remove(item.id); });
1534
+ setMobileProductInfoOpen(false);
1535
+ (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.dismissSideChat();
1536
+ } })), imageItems.length > 0 && (0, jsx_runtime_1.jsx)(ChatAttachmentContext_1.ChatAttachmentContext, { title: imageTitle, items: imageItems })] }));
1537
+ })(), (function () {
1538
+ var _a;
1539
+ var drift = (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.topicDrift;
1540
+ if (!drift)
1541
+ return null;
1542
+ // recommendedAction is the prescription; driftType is the diagnosis.
1543
+ // Hide the banner when the backend says to keep flowing, or when no drift was detected.
1544
+ if (drift.recommendedAction === 'CONTINUE' || drift.driftType === 'NO_DRIFT')
1545
+ return null;
1546
+ var isScopeRedirect = drift.recommendedAction === 'SCOPE_REDIRECT';
1547
+ var primaryText = isScopeRedirect ? "I'm here to help with shopping" : 'Looking for something new?';
1548
+ var secondaryText = isScopeRedirect
1549
+ ? 'Try asking about products, comparisons, or recommendations'
1550
+ : 'Start a fresh session for better assistance, or keep going in this one?';
1551
+ var buttonText = isScopeRedirect ? '' : 'New Session';
1552
+ return ((0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__topic-drift', children: [(0, jsx_runtime_1.jsx)(__1.Icon, { icon: "info", size: "18px", className: 'ss__chat__topic-drift__icon--info' }), (0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__topic-drift__text', children: [(0, jsx_runtime_1.jsx)("span", { children: primaryText }), (0, jsx_runtime_1.jsx)("span", { children: secondaryText })] }), buttonText && ((0, jsx_runtime_1.jsx)(Button_1.Button, { className: 'ss__chat__topic-drift__button', onClick: function () {
1553
+ var _a, _b;
1554
+ if (isScopeRedirect) {
1555
+ (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.dismissTopicDrift();
1556
+ return;
1557
+ }
1558
+ var messageText = (_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.handleTopicDrift();
1559
+ if (messageText) {
1560
+ controller.store.createChat();
1561
+ }
1562
+ }, children: buttonText })), (0, jsx_runtime_1.jsx)("span", { onClick: function () {
1563
+ var _a;
1564
+ (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.dismissTopicDrift();
1565
+ }, children: (0, jsx_runtime_1.jsx)(__1.Icon, { icon: "close-thin", size: "14px", className: 'ss__chat__topic-drift__icon--close' }) })] }));
1566
+ })(), (0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__input', children: [(0, jsx_runtime_1.jsxs)("div", { className: 'ss__chat__input__input', children: [(0, jsx_runtime_1.jsx)("input", { type: "text", name: "ss-chat-input", disabled: store.loading || store.blocked || ((_w = store.currentChat) === null || _w === void 0 ? void 0 : _w.sessionLimitReached), placeholder: (function () {
1567
+ var _a, _b, _c;
1568
+ var comparedCount = ((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.comparisons.compared.length) || 0;
1569
+ var committedCount = ((_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.comparisons.committed.length) || 0;
1570
+ var attached = ((_c = store.currentChat) === null || _c === void 0 ? void 0 : _c.attachments.attached.filter(function (item) { return item.state === 'attached' || item.state === 'active'; })) || [];
1571
+ var attachedProducts = attached.filter(function (item) { return item.type === 'product'; });
1572
+ var attachedImages = attached.filter(function (item) { return item.type === 'image' && !item.error; });
1573
+ if (attachedProducts.length === 1) {
1574
+ return 'Ask about this product...';
1575
+ }
1576
+ if (comparedCount > 1 || attachedProducts.length > 1) {
1577
+ return 'What would you like to compare?';
1578
+ }
1579
+ if (committedCount > 0) {
1580
+ return 'Ask about the compared products...';
1581
+ }
1582
+ if (attachedImages.length > 0) {
1583
+ return 'Ask about this image...';
1584
+ }
1585
+ if (comparedCount === 1) {
1586
+ return 'Add another product to compare...';
1587
+ }
1588
+ return 'Type your message...';
1589
+ })(), onInput: function (e) { return controller.handlers.input.input(e); }, onKeyDown: function (e) {
1590
+ controller.handlers.input.enterKey(e);
1591
+ if (e.keyCode === 13 && isMobile && mobileProductInfoOpen) {
1592
+ setMobileProductInfoOpen(false);
1593
+ }
1594
+ }, value: controller.store.inputValue }), store.features.imageSearch.enabled && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { className: 'ss__chat__upload-button', disabled: store.loading || store.blocked || ((_x = store.currentChat) === null || _x === void 0 ? void 0 : _x.sessionLimitReached), onClick: function () { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, icon: { icon: 'image', title: 'Upload Image' } }), (0, jsx_runtime_1.jsx)("input", { ref: fileInputRef, onChange: function (e) { return __awaiter(void 0, void 0, void 0, function () {
1595
+ return __generator(this, function (_a) {
1596
+ switch (_a.label) {
1597
+ case 0: return [4 /*yield*/, controller.upload(e.target.files)];
1598
+ case 1:
1599
+ _a.sent();
1600
+ // reset value
1601
+ e.target.value = '';
1602
+ return [2 /*return*/];
1603
+ }
1604
+ });
1605
+ }); }, multiple: true, type: "file", accept: "image/*", className: "ss__chat__input__input__file" })] }))] }), (0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__input__actions', children: (function () {
1606
+ var _a, _b;
1607
+ var hasImageAttachment = (((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.attached) || []).some(function (item) { return item.type === 'image' && !item.error; });
1608
+ var messageEmpty = !controller.store.inputValue.trim();
1609
+ var sendDisabled = store.blocked || ((_b = store.currentChat) === null || _b === void 0 ? void 0 : _b.sessionLimitReached) || (hasImageAttachment && messageEmpty);
1610
+ return ((0, jsx_runtime_1.jsx)(Button_1.Button, { className: "ss__chat__send-button", icon: { icon: 'send', title: 'Send Message' }, disabled: sendDisabled, onClick: function () {
1611
+ if (sendDisabled)
1612
+ return;
1613
+ controller.search();
1614
+ if (isMobile && mobileProductInfoOpen) {
1615
+ setMobileProductInfoOpen(false);
1616
+ }
1617
+ } }));
1618
+ })() })] }), (0, jsx_runtime_1.jsx)("div", { className: 'ss__chat__disclaimer', children: (0, jsx_runtime_1.jsxs)("i", { children: ["Powered by Athos Commerce. AI-powered assistant. It sometimes make mistakes. Avoid sharing personal data.", ' ', (0, jsx_runtime_1.jsx)("a", { href: "https://athoscommerce.com/legal/privacy-policy/", target: "_blank", rel: "noopener noreferrer", children: "Privacy Policy" })] }) })] })) : ((0, jsx_runtime_1.jsx)("div", { children: "This chat is expired. Please start a new chat." }))] })] })) : null] })), (0, jsx_runtime_1.jsx)(__1.Overlay, { style: { zIndex: 1001 }, color: "transparent", active: store.open, onClick: function () { return controller.handlers.button.click(); } })] }) }));
1619
+ });