@botonic/react 0.22.0-alpha.0 → 0.22.0-alpha.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 (693) hide show
  1. package/lib/cjs/app.d.ts +2 -0
  2. package/lib/cjs/app.js +10 -0
  3. package/lib/cjs/app.js.map +1 -0
  4. package/lib/cjs/botonic-tester.d.ts +18 -0
  5. package/lib/cjs/botonic-tester.js +70 -0
  6. package/lib/cjs/botonic-tester.js.map +1 -0
  7. package/lib/cjs/components/audio.d.ts +8 -0
  8. package/lib/cjs/components/audio.js +27 -0
  9. package/lib/cjs/components/audio.js.map +1 -0
  10. package/lib/cjs/components/button.d.ts +15 -0
  11. package/lib/cjs/components/button.js +156 -0
  12. package/lib/cjs/components/button.js.map +1 -0
  13. package/lib/cjs/components/buttons-disabler.d.ts +24 -0
  14. package/lib/cjs/components/buttons-disabler.js +88 -0
  15. package/lib/cjs/components/buttons-disabler.js.map +1 -0
  16. package/lib/cjs/components/carousel.d.ts +10 -0
  17. package/lib/cjs/components/carousel.js +120 -0
  18. package/lib/cjs/components/carousel.js.map +1 -0
  19. package/lib/cjs/components/components.d.ts +12 -0
  20. package/lib/{components → cjs/components}/components.js +6 -11
  21. package/lib/cjs/components/components.js.map +1 -0
  22. package/lib/cjs/components/custom-message.d.ts +43 -0
  23. package/lib/cjs/components/custom-message.js +65 -0
  24. package/lib/cjs/components/custom-message.js.map +1 -0
  25. package/lib/cjs/components/document.d.ts +8 -0
  26. package/lib/cjs/components/document.js +50 -0
  27. package/lib/cjs/components/document.js.map +1 -0
  28. package/lib/cjs/components/element.d.ts +4 -0
  29. package/lib/cjs/components/element.js +55 -0
  30. package/lib/cjs/components/element.js.map +1 -0
  31. package/lib/cjs/components/handoff.d.ts +1 -0
  32. package/lib/cjs/components/handoff.js +58 -0
  33. package/lib/cjs/components/handoff.js.map +1 -0
  34. package/lib/cjs/components/image.d.ts +8 -0
  35. package/lib/cjs/components/image.js +42 -0
  36. package/lib/cjs/components/image.js.map +1 -0
  37. package/lib/cjs/components/index.d.ts +20 -0
  38. package/lib/cjs/components/index.js +44 -0
  39. package/lib/cjs/components/index.js.map +1 -0
  40. package/lib/cjs/components/location.d.ts +11 -0
  41. package/lib/cjs/components/location.js +38 -0
  42. package/lib/cjs/components/location.js.map +1 -0
  43. package/lib/cjs/components/markdown.d.ts +7 -0
  44. package/lib/cjs/components/markdown.js +162 -0
  45. package/lib/cjs/components/markdown.js.map +1 -0
  46. package/lib/cjs/components/message-template.d.ts +1 -0
  47. package/lib/cjs/components/message-template.js +15 -0
  48. package/lib/cjs/components/message-template.js.map +1 -0
  49. package/lib/cjs/components/message.d.ts +1 -0
  50. package/lib/cjs/components/message.js +206 -0
  51. package/lib/cjs/components/message.js.map +1 -0
  52. package/lib/cjs/components/multichannel/facebook/facebook.d.ts +17 -0
  53. package/lib/cjs/components/multichannel/facebook/facebook.js +47 -0
  54. package/lib/cjs/components/multichannel/facebook/facebook.js.map +1 -0
  55. package/lib/cjs/components/multichannel/index.d.ts +6 -0
  56. package/lib/cjs/components/multichannel/index.js +14 -0
  57. package/lib/cjs/components/multichannel/index.js.map +1 -0
  58. package/lib/cjs/components/multichannel/multichannel-button.d.ts +1 -0
  59. package/lib/cjs/components/multichannel/multichannel-button.js +77 -0
  60. package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -0
  61. package/lib/cjs/components/multichannel/multichannel-carousel.d.ts +1 -0
  62. package/lib/cjs/components/multichannel/multichannel-carousel.js +95 -0
  63. package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -0
  64. package/lib/cjs/components/multichannel/multichannel-context.d.ts +11 -0
  65. package/lib/cjs/components/multichannel/multichannel-context.js +16 -0
  66. package/lib/cjs/components/multichannel/multichannel-context.js.map +1 -0
  67. package/lib/cjs/components/multichannel/multichannel-reply.d.ts +1 -0
  68. package/lib/cjs/components/multichannel/multichannel-reply.js +24 -0
  69. package/lib/cjs/components/multichannel/multichannel-reply.js.map +1 -0
  70. package/lib/cjs/components/multichannel/multichannel-text.d.ts +1 -0
  71. package/lib/cjs/components/multichannel/multichannel-text.js +147 -0
  72. package/lib/cjs/components/multichannel/multichannel-text.js.map +1 -0
  73. package/lib/cjs/components/multichannel/multichannel-utils.d.ts +24 -0
  74. package/lib/cjs/components/multichannel/multichannel-utils.js +83 -0
  75. package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -0
  76. package/lib/cjs/components/multichannel/multichannel.d.ts +1 -0
  77. package/lib/cjs/components/multichannel/multichannel.js +72 -0
  78. package/lib/cjs/components/multichannel/multichannel.js.map +1 -0
  79. package/lib/cjs/components/pic.d.ts +6 -0
  80. package/lib/cjs/components/pic.js +29 -0
  81. package/lib/cjs/components/pic.js.map +1 -0
  82. package/lib/cjs/components/raw.d.ts +9 -0
  83. package/lib/cjs/components/raw.js +53 -0
  84. package/lib/cjs/components/raw.js.map +1 -0
  85. package/lib/cjs/components/reply.d.ts +9 -0
  86. package/lib/cjs/components/reply.js +57 -0
  87. package/lib/cjs/components/reply.js.map +1 -0
  88. package/lib/cjs/components/share-button.d.ts +1 -0
  89. package/lib/cjs/components/share-button.js +15 -0
  90. package/lib/cjs/components/share-button.js.map +1 -0
  91. package/lib/cjs/components/subtitle.d.ts +6 -0
  92. package/lib/cjs/components/subtitle.js +25 -0
  93. package/lib/cjs/components/subtitle.js.map +1 -0
  94. package/lib/cjs/components/text.d.ts +8 -0
  95. package/lib/cjs/components/text.js +50 -0
  96. package/lib/cjs/components/text.js.map +1 -0
  97. package/lib/cjs/components/timestamps.d.ts +10 -0
  98. package/lib/cjs/components/timestamps.js +54 -0
  99. package/lib/cjs/components/timestamps.js.map +1 -0
  100. package/lib/cjs/components/title.d.ts +6 -0
  101. package/lib/cjs/components/title.js +21 -0
  102. package/lib/cjs/components/title.js.map +1 -0
  103. package/lib/cjs/components/video.d.ts +8 -0
  104. package/lib/cjs/components/video.js +34 -0
  105. package/lib/cjs/components/video.js.map +1 -0
  106. package/lib/cjs/components/webchat-settings.d.ts +10 -0
  107. package/lib/cjs/components/webchat-settings.js +78 -0
  108. package/lib/cjs/components/webchat-settings.js.map +1 -0
  109. package/lib/cjs/components/whatsapp-template.d.ts +1 -0
  110. package/lib/cjs/components/whatsapp-template.js +26 -0
  111. package/lib/cjs/components/whatsapp-template.js.map +1 -0
  112. package/lib/cjs/constants.d.ts +168 -0
  113. package/lib/cjs/constants.js +190 -0
  114. package/lib/cjs/constants.js.map +1 -0
  115. package/lib/cjs/contexts.d.ts +69 -0
  116. package/lib/cjs/contexts.js +38 -0
  117. package/lib/cjs/contexts.js.map +1 -0
  118. package/lib/cjs/dev-app.d.ts +30 -0
  119. package/lib/cjs/dev-app.js +71 -0
  120. package/lib/cjs/dev-app.js.map +1 -0
  121. package/lib/cjs/index.d.ts +10 -0
  122. package/lib/cjs/index.js +28 -0
  123. package/lib/cjs/index.js.map +1 -0
  124. package/lib/cjs/message-utils.d.ts +19 -0
  125. package/lib/cjs/message-utils.js +61 -0
  126. package/lib/cjs/message-utils.js.map +1 -0
  127. package/lib/cjs/msg-to-botonic.d.ts +18 -0
  128. package/lib/cjs/msg-to-botonic.js +160 -0
  129. package/lib/cjs/msg-to-botonic.js.map +1 -0
  130. package/lib/cjs/node-app.d.ts +12 -0
  131. package/lib/cjs/node-app.js +25 -0
  132. package/lib/cjs/node-app.js.map +1 -0
  133. package/lib/cjs/react-bot.d.ts +8 -0
  134. package/lib/cjs/react-bot.js +35 -0
  135. package/lib/cjs/react-bot.js.map +1 -0
  136. package/lib/cjs/util/dom.d.ts +13 -0
  137. package/lib/cjs/util/dom.js +55 -0
  138. package/lib/cjs/util/dom.js.map +1 -0
  139. package/lib/cjs/util/environment.d.ts +6 -0
  140. package/lib/cjs/util/environment.js +68 -0
  141. package/lib/cjs/util/environment.js.map +1 -0
  142. package/lib/cjs/util/error-boundary.d.ts +40 -0
  143. package/lib/cjs/util/error-boundary.js +46 -0
  144. package/lib/cjs/util/error-boundary.js.map +1 -0
  145. package/lib/cjs/util/index.d.ts +0 -0
  146. package/lib/cjs/util/index.js +2 -0
  147. package/lib/cjs/util/index.js.map +1 -0
  148. package/lib/cjs/util/logs.d.ts +2 -0
  149. package/lib/cjs/util/logs.js +20 -0
  150. package/lib/cjs/util/logs.js.map +1 -0
  151. package/lib/cjs/util/objects.d.ts +3 -0
  152. package/lib/cjs/util/objects.js +44 -0
  153. package/lib/cjs/util/objects.js.map +1 -0
  154. package/lib/cjs/util/react.d.ts +12 -0
  155. package/lib/cjs/util/react.js +42 -0
  156. package/lib/cjs/util/react.js.map +1 -0
  157. package/lib/cjs/util/regexs.d.ts +2 -0
  158. package/lib/cjs/util/regexs.js +23 -0
  159. package/lib/cjs/util/regexs.js.map +1 -0
  160. package/lib/cjs/util/webchat.d.ts +11 -0
  161. package/lib/cjs/util/webchat.js +62 -0
  162. package/lib/cjs/util/webchat.js.map +1 -0
  163. package/lib/cjs/webchat/actions.d.ts +23 -0
  164. package/lib/cjs/webchat/actions.js +27 -0
  165. package/lib/cjs/webchat/actions.js.map +1 -0
  166. package/lib/cjs/webchat/components/attachment.d.ts +5 -0
  167. package/lib/cjs/webchat/components/attachment.js +32 -0
  168. package/lib/cjs/webchat/components/attachment.js.map +1 -0
  169. package/lib/cjs/webchat/components/common.d.ts +1 -0
  170. package/lib/cjs/webchat/components/common.js +13 -0
  171. package/lib/cjs/webchat/components/common.js.map +1 -0
  172. package/lib/cjs/webchat/components/conditional-animation.d.ts +1 -0
  173. package/lib/cjs/webchat/components/conditional-animation.js +18 -0
  174. package/lib/cjs/webchat/components/conditional-animation.js.map +1 -0
  175. package/lib/cjs/webchat/components/emoji-picker.d.ts +5 -0
  176. package/lib/cjs/webchat/components/emoji-picker.js +52 -0
  177. package/lib/cjs/webchat/components/emoji-picker.js.map +1 -0
  178. package/lib/cjs/webchat/components/persistent-menu.d.ts +10 -0
  179. package/lib/cjs/webchat/components/persistent-menu.js +59 -0
  180. package/lib/cjs/webchat/components/persistent-menu.js.map +1 -0
  181. package/lib/cjs/webchat/components/send-button.d.ts +3 -0
  182. package/lib/cjs/webchat/components/send-button.js +24 -0
  183. package/lib/cjs/webchat/components/send-button.js.map +1 -0
  184. package/lib/cjs/webchat/components/styled-scrollbar.d.ts +1 -0
  185. package/lib/cjs/webchat/components/styled-scrollbar.js +54 -0
  186. package/lib/cjs/webchat/components/styled-scrollbar.js.map +1 -0
  187. package/lib/cjs/webchat/components/typing-indicator.d.ts +1 -0
  188. package/lib/cjs/webchat/components/typing-indicator.js +14 -0
  189. package/lib/cjs/webchat/components/typing-indicator.js.map +1 -0
  190. package/lib/cjs/webchat/devices/device-adapter.d.ts +12 -0
  191. package/lib/cjs/webchat/devices/device-adapter.js +47 -0
  192. package/lib/cjs/webchat/devices/device-adapter.js.map +1 -0
  193. package/lib/cjs/webchat/devices/index.d.ts +11 -0
  194. package/lib/cjs/webchat/devices/index.js +23 -0
  195. package/lib/cjs/webchat/devices/index.js.map +1 -0
  196. package/lib/cjs/webchat/devices/scrollbar-controller.d.ts +12 -0
  197. package/lib/cjs/webchat/devices/scrollbar-controller.js +103 -0
  198. package/lib/cjs/webchat/devices/scrollbar-controller.js.map +1 -0
  199. package/lib/cjs/webchat/devices/webchat-resizer.d.ts +9 -0
  200. package/lib/cjs/webchat/devices/webchat-resizer.js +47 -0
  201. package/lib/cjs/webchat/devices/webchat-resizer.js.map +1 -0
  202. package/lib/cjs/webchat/header.d.ts +3 -0
  203. package/lib/cjs/webchat/header.js +95 -0
  204. package/lib/cjs/webchat/header.js.map +1 -0
  205. package/lib/cjs/webchat/hooks.d.ts +80 -0
  206. package/lib/cjs/webchat/hooks.js +218 -0
  207. package/lib/cjs/webchat/hooks.js.map +1 -0
  208. package/lib/cjs/webchat/index.d.ts +6 -0
  209. package/lib/cjs/webchat/index.js +17 -0
  210. package/lib/cjs/webchat/index.js.map +1 -0
  211. package/lib/cjs/webchat/message-list.d.ts +1 -0
  212. package/lib/cjs/webchat/message-list.js +46 -0
  213. package/lib/cjs/webchat/message-list.js.map +1 -0
  214. package/lib/cjs/webchat/messages-reducer.d.ts +1 -0
  215. package/lib/cjs/webchat/messages-reducer.js +58 -0
  216. package/lib/cjs/webchat/messages-reducer.js.map +1 -0
  217. package/lib/cjs/webchat/replies.d.ts +1 -0
  218. package/lib/cjs/webchat/replies.js +46 -0
  219. package/lib/cjs/webchat/replies.js.map +1 -0
  220. package/lib/cjs/webchat/session-view.d.ts +1 -0
  221. package/lib/cjs/webchat/session-view.js +124 -0
  222. package/lib/cjs/webchat/session-view.js.map +1 -0
  223. package/lib/cjs/webchat/use-storage-state-hook.d.ts +1 -0
  224. package/lib/cjs/webchat/use-storage-state-hook.js +32 -0
  225. package/lib/cjs/webchat/use-storage-state-hook.js.map +1 -0
  226. package/lib/cjs/webchat/webchat-dev.d.ts +7 -0
  227. package/lib/cjs/webchat/webchat-dev.js +64 -0
  228. package/lib/cjs/webchat/webchat-dev.js.map +1 -0
  229. package/lib/cjs/webchat/webchat-reducer.d.ts +1 -0
  230. package/lib/cjs/webchat/webchat-reducer.js +48 -0
  231. package/lib/cjs/webchat/webchat-reducer.js.map +1 -0
  232. package/lib/cjs/webchat/webchat.d.ts +3 -0
  233. package/lib/cjs/webchat/webchat.js +704 -0
  234. package/lib/cjs/webchat/webchat.js.map +1 -0
  235. package/lib/cjs/webchat/webview.d.ts +2 -0
  236. package/lib/cjs/webchat/webview.js +92 -0
  237. package/lib/cjs/webchat/webview.js.map +1 -0
  238. package/lib/cjs/webchat-app.d.ts +99 -0
  239. package/lib/cjs/webchat-app.js +269 -0
  240. package/lib/cjs/webchat-app.js.map +1 -0
  241. package/lib/cjs/webview-app.d.ts +7 -0
  242. package/lib/cjs/webview-app.js +103 -0
  243. package/lib/cjs/webview-app.js.map +1 -0
  244. package/lib/esm/app.d.ts +2 -0
  245. package/lib/esm/app.js +6 -0
  246. package/lib/esm/app.js.map +1 -0
  247. package/lib/esm/assets/attachment-icon.svg +7 -0
  248. package/lib/esm/assets/audio.svg +4 -0
  249. package/lib/esm/assets/botonic_react_logo100x100.png +0 -0
  250. package/lib/esm/assets/document.svg +3 -0
  251. package/lib/esm/assets/emojiButton.svg +6 -0
  252. package/lib/esm/assets/image.svg +4 -0
  253. package/lib/esm/assets/leftArrow.svg +3 -0
  254. package/lib/esm/assets/menuButton.svg +3 -0
  255. package/lib/esm/assets/rightArrow.svg +3 -0
  256. package/lib/esm/assets/send-button.svg +1 -0
  257. package/lib/esm/assets/video.svg +3 -0
  258. package/lib/esm/botonic-tester.d.ts +18 -0
  259. package/lib/esm/botonic-tester.js +64 -0
  260. package/lib/esm/botonic-tester.js.map +1 -0
  261. package/lib/esm/components/audio.d.ts +8 -0
  262. package/lib/esm/components/audio.js +22 -0
  263. package/lib/esm/components/audio.js.map +1 -0
  264. package/lib/esm/components/button.d.ts +15 -0
  265. package/lib/esm/components/button.js +151 -0
  266. package/lib/esm/components/button.js.map +1 -0
  267. package/lib/esm/components/buttons-disabler.d.ts +24 -0
  268. package/lib/esm/components/buttons-disabler.js +84 -0
  269. package/lib/esm/components/buttons-disabler.js.map +1 -0
  270. package/lib/esm/components/carousel.d.ts +9 -0
  271. package/lib/esm/components/carousel.js +115 -0
  272. package/lib/esm/components/carousel.js.map +1 -0
  273. package/lib/esm/components/components.d.ts +12 -0
  274. package/lib/esm/components/components.js +17 -0
  275. package/lib/esm/components/components.js.map +1 -0
  276. package/lib/esm/components/custom-message.d.ts +43 -0
  277. package/lib/esm/components/custom-message.js +61 -0
  278. package/lib/esm/components/custom-message.js.map +1 -0
  279. package/lib/esm/components/document.d.ts +8 -0
  280. package/lib/esm/components/document.js +45 -0
  281. package/lib/esm/components/document.js.map +1 -0
  282. package/lib/esm/components/element.d.ts +4 -0
  283. package/lib/esm/components/element.js +50 -0
  284. package/lib/esm/components/element.js.map +1 -0
  285. package/lib/esm/components/handoff.d.ts +1 -0
  286. package/lib/esm/components/handoff.js +53 -0
  287. package/lib/esm/components/handoff.js.map +1 -0
  288. package/lib/esm/components/image.d.ts +8 -0
  289. package/lib/esm/components/image.js +37 -0
  290. package/lib/esm/components/image.js.map +1 -0
  291. package/lib/esm/components/index.d.ts +19 -0
  292. package/lib/esm/components/index.js +21 -0
  293. package/lib/esm/components/index.js.map +1 -0
  294. package/lib/esm/components/location.d.ts +11 -0
  295. package/lib/esm/components/location.js +33 -0
  296. package/lib/esm/components/location.js.map +1 -0
  297. package/lib/esm/components/markdown.d.ts +7 -0
  298. package/lib/esm/components/markdown.js +152 -0
  299. package/lib/esm/components/markdown.js.map +1 -0
  300. package/lib/esm/components/message-template.d.ts +1 -0
  301. package/lib/esm/components/message-template.js +10 -0
  302. package/lib/esm/components/message-template.js.map +1 -0
  303. package/lib/esm/components/message.d.ts +1 -0
  304. package/lib/esm/components/message.js +202 -0
  305. package/lib/esm/components/message.js.map +1 -0
  306. package/lib/esm/components/multichannel/facebook/facebook.d.ts +17 -0
  307. package/lib/esm/components/multichannel/facebook/facebook.js +43 -0
  308. package/lib/esm/components/multichannel/facebook/facebook.js.map +1 -0
  309. package/lib/esm/components/multichannel/index.d.ts +6 -0
  310. package/lib/esm/components/multichannel/index.js +11 -0
  311. package/lib/esm/components/multichannel/index.js.map +1 -0
  312. package/lib/esm/components/multichannel/multichannel-button.d.ts +1 -0
  313. package/lib/esm/components/multichannel/multichannel-button.js +72 -0
  314. package/lib/esm/components/multichannel/multichannel-button.js.map +1 -0
  315. package/lib/esm/components/multichannel/multichannel-carousel.d.ts +1 -0
  316. package/lib/esm/components/multichannel/multichannel-carousel.js +90 -0
  317. package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -0
  318. package/lib/esm/components/multichannel/multichannel-context.d.ts +11 -0
  319. package/lib/esm/components/multichannel/multichannel-context.js +12 -0
  320. package/lib/esm/components/multichannel/multichannel-context.js.map +1 -0
  321. package/lib/esm/components/multichannel/multichannel-reply.d.ts +1 -0
  322. package/lib/esm/components/multichannel/multichannel-reply.js +19 -0
  323. package/lib/esm/components/multichannel/multichannel-reply.js.map +1 -0
  324. package/lib/esm/components/multichannel/multichannel-text.d.ts +1 -0
  325. package/lib/esm/components/multichannel/multichannel-text.js +142 -0
  326. package/lib/esm/components/multichannel/multichannel-text.js.map +1 -0
  327. package/lib/esm/components/multichannel/multichannel-utils.d.ts +24 -0
  328. package/lib/esm/components/multichannel/multichannel-utils.js +67 -0
  329. package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -0
  330. package/lib/esm/components/multichannel/multichannel.d.ts +1 -0
  331. package/lib/esm/components/multichannel/multichannel.js +67 -0
  332. package/lib/esm/components/multichannel/multichannel.js.map +1 -0
  333. package/lib/esm/components/pic.d.ts +6 -0
  334. package/lib/esm/components/pic.js +24 -0
  335. package/lib/esm/components/pic.js.map +1 -0
  336. package/lib/esm/components/raw.d.ts +9 -0
  337. package/lib/esm/components/raw.js +48 -0
  338. package/lib/esm/components/raw.js.map +1 -0
  339. package/lib/esm/components/reply.d.ts +9 -0
  340. package/lib/esm/components/reply.js +52 -0
  341. package/lib/esm/components/reply.js.map +1 -0
  342. package/lib/esm/components/share-button.d.ts +1 -0
  343. package/lib/esm/components/share-button.js +10 -0
  344. package/lib/esm/components/share-button.js.map +1 -0
  345. package/lib/esm/components/subtitle.d.ts +6 -0
  346. package/lib/esm/components/subtitle.js +20 -0
  347. package/lib/esm/components/subtitle.js.map +1 -0
  348. package/lib/esm/components/text.d.ts +8 -0
  349. package/lib/esm/components/text.js +45 -0
  350. package/lib/esm/components/text.js.map +1 -0
  351. package/lib/esm/components/timestamps.d.ts +10 -0
  352. package/lib/esm/components/timestamps.js +48 -0
  353. package/lib/esm/components/timestamps.js.map +1 -0
  354. package/lib/esm/components/title.d.ts +6 -0
  355. package/lib/esm/components/title.js +16 -0
  356. package/lib/esm/components/title.js.map +1 -0
  357. package/lib/esm/components/video.d.ts +8 -0
  358. package/lib/esm/components/video.js +29 -0
  359. package/lib/esm/components/video.js.map +1 -0
  360. package/lib/esm/components/webchat-settings.d.ts +10 -0
  361. package/lib/esm/components/webchat-settings.js +72 -0
  362. package/lib/esm/components/webchat-settings.js.map +1 -0
  363. package/lib/esm/components/whatsapp-template.d.ts +1 -0
  364. package/lib/esm/components/whatsapp-template.js +21 -0
  365. package/lib/esm/components/whatsapp-template.js.map +1 -0
  366. package/lib/esm/constants.d.ts +168 -0
  367. package/lib/esm/constants.js +186 -0
  368. package/lib/esm/constants.js.map +1 -0
  369. package/lib/esm/contexts.d.ts +69 -0
  370. package/lib/esm/contexts.js +34 -0
  371. package/lib/esm/contexts.js.map +1 -0
  372. package/lib/esm/dev-app.d.ts +30 -0
  373. package/lib/esm/dev-app.js +67 -0
  374. package/lib/esm/dev-app.js.map +1 -0
  375. package/lib/esm/index.d.ts +9 -0
  376. package/lib/esm/index.js +11 -0
  377. package/lib/esm/index.js.map +1 -0
  378. package/lib/esm/message-utils.d.ts +18 -0
  379. package/lib/esm/message-utils.js +41 -0
  380. package/lib/esm/message-utils.js.map +1 -0
  381. package/lib/esm/msg-to-botonic.d.ts +18 -0
  382. package/lib/esm/msg-to-botonic.js +154 -0
  383. package/lib/esm/msg-to-botonic.js.map +1 -0
  384. package/lib/esm/node-app.d.ts +12 -0
  385. package/lib/esm/node-app.js +21 -0
  386. package/lib/esm/node-app.js.map +1 -0
  387. package/lib/esm/react-bot.d.ts +7 -0
  388. package/lib/esm/react-bot.js +30 -0
  389. package/lib/esm/react-bot.js.map +1 -0
  390. package/lib/esm/util/dom.d.ts +13 -0
  391. package/lib/esm/util/dom.js +46 -0
  392. package/lib/esm/util/dom.js.map +1 -0
  393. package/lib/esm/util/environment.d.ts +6 -0
  394. package/lib/esm/util/environment.js +61 -0
  395. package/lib/esm/util/environment.js.map +1 -0
  396. package/lib/esm/util/error-boundary.d.ts +40 -0
  397. package/lib/esm/util/error-boundary.js +41 -0
  398. package/lib/esm/util/error-boundary.js.map +1 -0
  399. package/lib/esm/util/index.d.ts +0 -0
  400. package/lib/esm/util/index.js +2 -0
  401. package/lib/esm/util/index.js.map +1 -0
  402. package/lib/esm/util/logs.d.ts +2 -0
  403. package/lib/esm/util/logs.js +15 -0
  404. package/lib/esm/util/logs.js.map +1 -0
  405. package/lib/esm/util/objects.d.ts +3 -0
  406. package/lib/esm/util/objects.js +38 -0
  407. package/lib/esm/util/objects.js.map +1 -0
  408. package/lib/esm/util/react.d.ts +12 -0
  409. package/lib/esm/util/react.js +34 -0
  410. package/lib/esm/util/react.js.map +1 -0
  411. package/lib/esm/util/regexs.d.ts +2 -0
  412. package/lib/esm/util/regexs.js +18 -0
  413. package/lib/esm/util/regexs.js.map +1 -0
  414. package/lib/esm/util/webchat.d.ts +11 -0
  415. package/lib/esm/util/webchat.js +53 -0
  416. package/lib/esm/util/webchat.js.map +1 -0
  417. package/lib/esm/webchat/actions.d.ts +23 -0
  418. package/lib/esm/webchat/actions.js +24 -0
  419. package/lib/esm/webchat/actions.js.map +1 -0
  420. package/lib/esm/webchat/components/attachment.d.ts +5 -0
  421. package/lib/esm/webchat/components/attachment.js +27 -0
  422. package/lib/esm/webchat/components/attachment.js.map +1 -0
  423. package/lib/esm/webchat/components/common.d.ts +1 -0
  424. package/lib/esm/webchat/components/common.js +8 -0
  425. package/lib/esm/webchat/components/common.js.map +1 -0
  426. package/lib/esm/webchat/components/conditional-animation.d.ts +1 -0
  427. package/lib/esm/webchat/components/conditional-animation.js +13 -0
  428. package/lib/esm/webchat/components/conditional-animation.js.map +1 -0
  429. package/lib/esm/webchat/components/emoji-picker.d.ts +5 -0
  430. package/lib/esm/webchat/components/emoji-picker.js +46 -0
  431. package/lib/esm/webchat/components/emoji-picker.js.map +1 -0
  432. package/lib/esm/webchat/components/persistent-menu.d.ts +10 -0
  433. package/lib/esm/webchat/components/persistent-menu.js +53 -0
  434. package/lib/esm/webchat/components/persistent-menu.js.map +1 -0
  435. package/lib/esm/webchat/components/send-button.d.ts +3 -0
  436. package/lib/esm/webchat/components/send-button.js +19 -0
  437. package/lib/esm/webchat/components/send-button.js.map +1 -0
  438. package/lib/esm/webchat/components/styled-scrollbar.d.ts +1 -0
  439. package/lib/esm/webchat/components/styled-scrollbar.js +50 -0
  440. package/lib/esm/webchat/components/styled-scrollbar.js.map +1 -0
  441. package/lib/esm/webchat/components/styled-scrollbar.scss +12 -0
  442. package/lib/esm/webchat/components/typing-indicator.d.ts +1 -0
  443. package/lib/esm/webchat/components/typing-indicator.js +9 -0
  444. package/lib/esm/webchat/components/typing-indicator.js.map +1 -0
  445. package/lib/esm/webchat/components/typing-indicator.scss +38 -0
  446. package/lib/esm/webchat/devices/device-adapter.d.ts +12 -0
  447. package/lib/esm/webchat/devices/device-adapter.js +43 -0
  448. package/lib/esm/webchat/devices/device-adapter.js.map +1 -0
  449. package/lib/esm/webchat/devices/index.d.ts +11 -0
  450. package/lib/esm/webchat/devices/index.js +18 -0
  451. package/lib/esm/webchat/devices/index.js.map +1 -0
  452. package/lib/esm/webchat/devices/scrollbar-controller.d.ts +12 -0
  453. package/lib/esm/webchat/devices/scrollbar-controller.js +99 -0
  454. package/lib/esm/webchat/devices/scrollbar-controller.js.map +1 -0
  455. package/lib/esm/webchat/devices/webchat-resizer.d.ts +9 -0
  456. package/lib/esm/webchat/devices/webchat-resizer.js +43 -0
  457. package/lib/esm/webchat/devices/webchat-resizer.js.map +1 -0
  458. package/lib/esm/webchat/header.d.ts +3 -0
  459. package/lib/esm/webchat/header.js +89 -0
  460. package/lib/esm/webchat/header.js.map +1 -0
  461. package/lib/esm/webchat/hooks.d.ts +80 -0
  462. package/lib/esm/webchat/hooks.js +210 -0
  463. package/lib/esm/webchat/hooks.js.map +1 -0
  464. package/lib/esm/webchat/index.d.ts +6 -0
  465. package/lib/esm/webchat/index.js +11 -0
  466. package/lib/esm/webchat/index.js.map +1 -0
  467. package/lib/esm/webchat/message-list.d.ts +1 -0
  468. package/lib/esm/webchat/message-list.js +41 -0
  469. package/lib/esm/webchat/message-list.js.map +1 -0
  470. package/lib/esm/webchat/messages-reducer.d.ts +1 -0
  471. package/lib/esm/webchat/messages-reducer.js +54 -0
  472. package/lib/esm/webchat/messages-reducer.js.map +1 -0
  473. package/lib/esm/webchat/replies.d.ts +1 -0
  474. package/lib/esm/webchat/replies.js +41 -0
  475. package/lib/esm/webchat/replies.js.map +1 -0
  476. package/lib/esm/webchat/session-view.d.ts +1 -0
  477. package/lib/esm/webchat/session-view.js +119 -0
  478. package/lib/esm/webchat/session-view.js.map +1 -0
  479. package/lib/esm/webchat/use-storage-state-hook.d.ts +1 -0
  480. package/lib/esm/webchat/use-storage-state-hook.js +28 -0
  481. package/lib/esm/webchat/use-storage-state-hook.js.map +1 -0
  482. package/lib/esm/webchat/webchat-dev.d.ts +7 -0
  483. package/lib/esm/webchat/webchat-dev.js +60 -0
  484. package/lib/esm/webchat/webchat-dev.js.map +1 -0
  485. package/lib/esm/webchat/webchat-reducer.d.ts +1 -0
  486. package/lib/esm/webchat/webchat-reducer.js +44 -0
  487. package/lib/esm/webchat/webchat-reducer.js.map +1 -0
  488. package/lib/esm/webchat/webchat.d.ts +3 -0
  489. package/lib/esm/webchat/webchat.js +699 -0
  490. package/lib/esm/webchat/webchat.js.map +1 -0
  491. package/lib/esm/webchat/webview.d.ts +2 -0
  492. package/lib/esm/webchat/webview.js +86 -0
  493. package/lib/esm/webchat/webview.js.map +1 -0
  494. package/lib/esm/webchat-app.d.ts +98 -0
  495. package/lib/esm/webchat-app.js +265 -0
  496. package/lib/esm/webchat-app.js.map +1 -0
  497. package/lib/esm/webchat.template.html +37 -0
  498. package/lib/esm/webview-app.d.ts +7 -0
  499. package/lib/esm/webview-app.js +98 -0
  500. package/lib/esm/webview-app.js.map +1 -0
  501. package/lib/esm/webview.template.html +39 -0
  502. package/package.json +27 -20
  503. package/src/components/audio.jsx +2 -0
  504. package/src/components/document.jsx +2 -0
  505. package/src/components/image.jsx +2 -0
  506. package/src/components/location.jsx +2 -2
  507. package/src/components/pic.jsx +3 -1
  508. package/src/components/video.jsx +2 -0
  509. package/src/index.js +1 -1
  510. package/src/msg-to-botonic.jsx +1 -1
  511. package/src/util/environment.js +31 -2
  512. package/src/{webview.jsx → webview-app.tsx} +7 -1
  513. package/lib/app.js +0 -19
  514. package/lib/app.js.map +0 -1
  515. package/lib/botonic-tester.js +0 -224
  516. package/lib/botonic-tester.js.map +0 -1
  517. package/lib/components/audio.js +0 -48
  518. package/lib/components/audio.js.map +0 -1
  519. package/lib/components/button.js +0 -224
  520. package/lib/components/button.js.map +0 -1
  521. package/lib/components/buttons-disabler.js +0 -133
  522. package/lib/components/buttons-disabler.js.map +0 -1
  523. package/lib/components/carousel.js +0 -194
  524. package/lib/components/carousel.js.map +0 -1
  525. package/lib/components/components.js.map +0 -1
  526. package/lib/components/custom-message.js +0 -131
  527. package/lib/components/custom-message.js.map +0 -1
  528. package/lib/components/document.js +0 -76
  529. package/lib/components/document.js.map +0 -1
  530. package/lib/components/element.js +0 -69
  531. package/lib/components/element.js.map +0 -1
  532. package/lib/components/handoff.js +0 -69
  533. package/lib/components/handoff.js.map +0 -1
  534. package/lib/components/image.js +0 -91
  535. package/lib/components/image.js.map +0 -1
  536. package/lib/components/index.d.ts +0 -228
  537. package/lib/components/index.js +0 -193
  538. package/lib/components/index.js.map +0 -1
  539. package/lib/components/location.js +0 -69
  540. package/lib/components/location.js.map +0 -1
  541. package/lib/components/markdown.js +0 -108
  542. package/lib/components/markdown.js.map +0 -1
  543. package/lib/components/message-template.js +0 -36
  544. package/lib/components/message-template.js.map +0 -1
  545. package/lib/components/message.js +0 -351
  546. package/lib/components/message.js.map +0 -1
  547. package/lib/components/multichannel/facebook/facebook.js +0 -96
  548. package/lib/components/multichannel/facebook/facebook.js.map +0 -1
  549. package/lib/components/multichannel/index.d.ts +0 -65
  550. package/lib/components/multichannel/index.js +0 -46
  551. package/lib/components/multichannel/index.js.map +0 -1
  552. package/lib/components/multichannel/multichannel-button.js +0 -119
  553. package/lib/components/multichannel/multichannel-button.js.map +0 -1
  554. package/lib/components/multichannel/multichannel-carousel.js +0 -143
  555. package/lib/components/multichannel/multichannel-carousel.js.map +0 -1
  556. package/lib/components/multichannel/multichannel-context.js +0 -24
  557. package/lib/components/multichannel/multichannel-context.js.map +0 -1
  558. package/lib/components/multichannel/multichannel-reply.js +0 -46
  559. package/lib/components/multichannel/multichannel-reply.js.map +0 -1
  560. package/lib/components/multichannel/multichannel-text.js +0 -222
  561. package/lib/components/multichannel/multichannel-text.js.map +0 -1
  562. package/lib/components/multichannel/multichannel-utils.js +0 -126
  563. package/lib/components/multichannel/multichannel-utils.js.map +0 -1
  564. package/lib/components/multichannel/multichannel.js +0 -111
  565. package/lib/components/multichannel/multichannel.js.map +0 -1
  566. package/lib/components/pic.js +0 -50
  567. package/lib/components/pic.js.map +0 -1
  568. package/lib/components/raw.js +0 -70
  569. package/lib/components/raw.js.map +0 -1
  570. package/lib/components/reply.js +0 -107
  571. package/lib/components/reply.js.map +0 -1
  572. package/lib/components/share-button.js +0 -36
  573. package/lib/components/share-button.js.map +0 -1
  574. package/lib/components/subtitle.js +0 -54
  575. package/lib/components/subtitle.js.map +0 -1
  576. package/lib/components/text.js +0 -80
  577. package/lib/components/text.js.map +0 -1
  578. package/lib/components/timestamps.js +0 -69
  579. package/lib/components/timestamps.js.map +0 -1
  580. package/lib/components/title.js +0 -52
  581. package/lib/components/title.js.map +0 -1
  582. package/lib/components/video.js +0 -51
  583. package/lib/components/video.js.map +0 -1
  584. package/lib/components/webchat-settings.js +0 -118
  585. package/lib/components/webchat-settings.js.map +0 -1
  586. package/lib/components/whatsapp-template.js +0 -53
  587. package/lib/components/whatsapp-template.js.map +0 -1
  588. package/lib/constants.js +0 -203
  589. package/lib/constants.js.map +0 -1
  590. package/lib/contexts.js +0 -57
  591. package/lib/contexts.js.map +0 -1
  592. package/lib/dev-app.js +0 -241
  593. package/lib/dev-app.js.map +0 -1
  594. package/lib/index.d.ts +0 -238
  595. package/lib/index.js +0 -131
  596. package/lib/index.js.map +0 -1
  597. package/lib/message-utils.js +0 -149
  598. package/lib/message-utils.js.map +0 -1
  599. package/lib/msg-to-botonic.js +0 -199
  600. package/lib/msg-to-botonic.js.map +0 -1
  601. package/lib/node-app.js +0 -97
  602. package/lib/node-app.js.map +0 -1
  603. package/lib/react-bot.js +0 -167
  604. package/lib/react-bot.js.map +0 -1
  605. package/lib/util/dom.js +0 -84
  606. package/lib/util/dom.js.map +0 -1
  607. package/lib/util/environment.js +0 -42
  608. package/lib/util/environment.js.map +0 -1
  609. package/lib/util/error-boundary.js +0 -105
  610. package/lib/util/error-boundary.js.map +0 -1
  611. package/lib/util/index.d.ts +0 -9
  612. package/lib/util/index.js +0 -2
  613. package/lib/util/index.js.map +0 -1
  614. package/lib/util/logs.js +0 -28
  615. package/lib/util/logs.js.map +0 -1
  616. package/lib/util/objects.js +0 -60
  617. package/lib/util/objects.js.map +0 -1
  618. package/lib/util/react.js +0 -75
  619. package/lib/util/react.js.map +0 -1
  620. package/lib/util/regexs.js +0 -31
  621. package/lib/util/regexs.js.map +0 -1
  622. package/lib/util/webchat.js +0 -92
  623. package/lib/util/webchat.js.map +0 -1
  624. package/lib/webchat/actions.js +0 -53
  625. package/lib/webchat/actions.js.map +0 -1
  626. package/lib/webchat/components/attachment.js +0 -68
  627. package/lib/webchat/components/attachment.js.map +0 -1
  628. package/lib/webchat/components/common.js +0 -29
  629. package/lib/webchat/components/common.js.map +0 -1
  630. package/lib/webchat/components/conditional-animation.js +0 -42
  631. package/lib/webchat/components/conditional-animation.js.map +0 -1
  632. package/lib/webchat/components/emoji-picker.js +0 -89
  633. package/lib/webchat/components/emoji-picker.js.map +0 -1
  634. package/lib/webchat/components/persistent-menu.js +0 -104
  635. package/lib/webchat/components/persistent-menu.js.map +0 -1
  636. package/lib/webchat/components/send-button.js +0 -45
  637. package/lib/webchat/components/send-button.js.map +0 -1
  638. package/lib/webchat/components/styled-scrollbar.js +0 -55
  639. package/lib/webchat/components/styled-scrollbar.js.map +0 -1
  640. package/lib/webchat/components/typing-indicator.js +0 -27
  641. package/lib/webchat/components/typing-indicator.js.map +0 -1
  642. package/lib/webchat/devices/device-adapter.js +0 -82
  643. package/lib/webchat/devices/device-adapter.js.map +0 -1
  644. package/lib/webchat/devices/index.js +0 -32
  645. package/lib/webchat/devices/index.js.map +0 -1
  646. package/lib/webchat/devices/scrollbar-controller.js +0 -152
  647. package/lib/webchat/devices/scrollbar-controller.js.map +0 -1
  648. package/lib/webchat/devices/webchat-resizer.js +0 -76
  649. package/lib/webchat/devices/webchat-resizer.js.map +0 -1
  650. package/lib/webchat/header.js +0 -116
  651. package/lib/webchat/header.js.map +0 -1
  652. package/lib/webchat/hooks.js +0 -359
  653. package/lib/webchat/hooks.js.map +0 -1
  654. package/lib/webchat/index.d.ts +0 -62
  655. package/lib/webchat/index.js +0 -32
  656. package/lib/webchat/index.js.map +0 -1
  657. package/lib/webchat/message-list.js +0 -88
  658. package/lib/webchat/message-list.js.map +0 -1
  659. package/lib/webchat/messages-reducer.js +0 -93
  660. package/lib/webchat/messages-reducer.js.map +0 -1
  661. package/lib/webchat/replies.js +0 -78
  662. package/lib/webchat/replies.js.map +0 -1
  663. package/lib/webchat/session-view.js +0 -106
  664. package/lib/webchat/session-view.js.map +0 -1
  665. package/lib/webchat/use-storage-state-hook.js +0 -60
  666. package/lib/webchat/use-storage-state-hook.js.map +0 -1
  667. package/lib/webchat/webchat-dev.js +0 -109
  668. package/lib/webchat/webchat-dev.js.map +0 -1
  669. package/lib/webchat/webchat-reducer.js +0 -108
  670. package/lib/webchat/webchat-reducer.js.map +0 -1
  671. package/lib/webchat/webchat.js +0 -1108
  672. package/lib/webchat/webchat.js.map +0 -1
  673. package/lib/webchat/webview.js +0 -122
  674. package/lib/webchat/webview.js.map +0 -1
  675. package/lib/webchat-app.js +0 -660
  676. package/lib/webchat-app.js.map +0 -1
  677. package/lib/webview.js +0 -231
  678. package/lib/webview.js.map +0 -1
  679. /package/lib/{assets → cjs/assets}/attachment-icon.svg +0 -0
  680. /package/lib/{assets → cjs/assets}/audio.svg +0 -0
  681. /package/lib/{assets → cjs/assets}/botonic_react_logo100x100.png +0 -0
  682. /package/lib/{assets → cjs/assets}/document.svg +0 -0
  683. /package/lib/{assets → cjs/assets}/emojiButton.svg +0 -0
  684. /package/lib/{assets → cjs/assets}/image.svg +0 -0
  685. /package/lib/{assets → cjs/assets}/leftArrow.svg +0 -0
  686. /package/lib/{assets → cjs/assets}/menuButton.svg +0 -0
  687. /package/lib/{assets → cjs/assets}/rightArrow.svg +0 -0
  688. /package/lib/{assets → cjs/assets}/send-button.svg +0 -0
  689. /package/lib/{assets → cjs/assets}/video.svg +0 -0
  690. /package/lib/{webchat → cjs/webchat}/components/styled-scrollbar.scss +0 -0
  691. /package/lib/{webchat → cjs/webchat}/components/typing-indicator.scss +0 -0
  692. /package/lib/{webchat.template.html → cjs/webchat.template.html} +0 -0
  693. /package/lib/{webview.template.html → cjs/webview.template.html} +0 -0
@@ -0,0 +1,704 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Webchat = exports.getParsedAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@botonic/core");
6
+ const framer_motion_1 = require("framer-motion");
7
+ const lodash_merge_1 = tslib_1.__importDefault(require("lodash.merge"));
8
+ const react_1 = tslib_1.__importStar(require("react"));
9
+ const react_textarea_autosize_1 = tslib_1.__importDefault(require("react-textarea-autosize"));
10
+ const styled_components_1 = tslib_1.__importStar(require("styled-components"));
11
+ const use_async_effect_1 = require("use-async-effect");
12
+ const uuid_1 = require("uuid");
13
+ const components_1 = require("../components");
14
+ const handoff_1 = require("../components/handoff");
15
+ const webchat_settings_1 = require("../components/webchat-settings");
16
+ const constants_1 = require("../constants");
17
+ const contexts_1 = require("../contexts");
18
+ const message_utils_1 = require("../message-utils");
19
+ const msg_to_botonic_1 = require("../msg-to-botonic");
20
+ const dom_1 = require("../util/dom");
21
+ const environment_1 = require("../util/environment");
22
+ const regexs_1 = require("../util/regexs");
23
+ const webchat_1 = require("../util/webchat");
24
+ const attachment_1 = require("./components/attachment");
25
+ const emoji_picker_1 = require("./components/emoji-picker");
26
+ const persistent_menu_1 = require("./components/persistent-menu");
27
+ const send_button_1 = require("./components/send-button");
28
+ const typing_indicator_1 = require("./components/typing-indicator");
29
+ const device_adapter_1 = require("./devices/device-adapter");
30
+ const header_1 = require("./header");
31
+ const hooks_1 = require("./hooks");
32
+ const message_list_1 = require("./message-list");
33
+ const replies_1 = require("./replies");
34
+ const use_storage_state_hook_1 = require("./use-storage-state-hook");
35
+ const webview_1 = require("./webview");
36
+ const getParsedAction = botonicAction => {
37
+ const splittedAction = botonicAction.split('create_case:');
38
+ if (splittedAction.length <= 1)
39
+ return undefined;
40
+ return JSON.parse(splittedAction[1]);
41
+ };
42
+ exports.getParsedAction = getParsedAction;
43
+ const StyledWebchat = styled_components_1.default.div `
44
+ position: fixed;
45
+ right: 20px;
46
+ bottom: 20px;
47
+ width: ${props => props.width}px;
48
+ height: ${props => props.height}px;
49
+ margin: auto;
50
+ background-color: ${constants_1.COLORS.SOLID_WHITE};
51
+ border-radius: 10px;
52
+ box-shadow: ${constants_1.COLORS.SOLID_BLACK_ALPHA_0_2} 0px 0px 12px;
53
+ display: flex;
54
+ flex-direction: column;
55
+ `;
56
+ const StyledTriggerButton = styled_components_1.default.div `
57
+ cursor: pointer;
58
+ position: fixed;
59
+ background: ${constants_1.COLORS.SOLID_WHITE};
60
+ border-radius: 50%;
61
+ display: flex;
62
+ align-items: center;
63
+ justify-content: center;
64
+ overflow: hidden;
65
+ width: 65px;
66
+ height: 65px;
67
+ bottom: 20px;
68
+ right: 10px;
69
+ padding: 8px;
70
+ `;
71
+ const UserInputContainer = styled_components_1.default.div `
72
+ min-height: 52px;
73
+ position: relative;
74
+ display: flex;
75
+ align-items: center;
76
+ justify-content: flex-start;
77
+ gap: 16px;
78
+ padding: 0px 16px;
79
+ z-index: 1;
80
+ border-top: 1px solid ${constants_1.COLORS.SOLID_BLACK_ALPHA_0_5};
81
+ `;
82
+ const TextAreaContainer = styled_components_1.default.div `
83
+ display: flex;
84
+ flex: 1 1 auto;
85
+ align-items: center;
86
+ `;
87
+ const TriggerImage = styled_components_1.default.img `
88
+ max-width: 100%;
89
+ max-height: 100%;
90
+ `;
91
+ const ErrorMessageContainer = styled_components_1.default.div `
92
+ position: relative;
93
+ display: flex;
94
+ z-index: 1;
95
+ justify-content: center;
96
+ width: 100%;
97
+ `;
98
+ const ErrorMessage = styled_components_1.default.div `
99
+ position: absolute;
100
+ top: 10px;
101
+ font-size: 14px;
102
+ line-height: 20px;
103
+ padding: 4px 11px;
104
+ display: flex;
105
+ background-color: ${constants_1.COLORS.ERROR_RED};
106
+ color: ${constants_1.COLORS.CONCRETE_WHITE};
107
+ border-radius: 5px;
108
+ align-items: center;
109
+ justify-content: center;
110
+ font-family: ${constants_1.WEBCHAT.DEFAULTS.FONT_FAMILY};
111
+ `;
112
+ const DarkBackgroundMenu = styled_components_1.default.div `
113
+ background: ${constants_1.COLORS.SOLID_BLACK};
114
+ opacity: 0.3;
115
+ z-index: 1;
116
+ right: 0;
117
+ bottom: 0;
118
+ border-radius: 10px;
119
+ position: absolute;
120
+ width: 100%;
121
+ height: 100%;
122
+ `;
123
+ // eslint-disable-next-line complexity
124
+ exports.Webchat = (0, react_1.forwardRef)((props, ref) => {
125
+ const { webchatState, addMessage, addMessageComponent, updateMessage, updateReplies, updateLatestInput, updateTyping, updateWebview, updateSession, updateLastRoutePath, updateHandoff, updateTheme, updateDevSettings, toggleWebchat, toggleEmojiPicker, togglePersistentMenu, toggleCoverComponent, doRenderCustomComponent, setError, setOnline, clearMessages, openWebviewT, closeWebviewT, updateLastMessageDate, setCurrentAttachment,
126
+ // eslint-disable-next-line react-hooks/rules-of-hooks
127
+ } = props.webchatHooks || (0, hooks_1.useWebchat)();
128
+ const firstUpdate = (0, react_1.useRef)(true);
129
+ const isOnline = () => webchatState.online;
130
+ const currentDateString = () => new Date().toISOString();
131
+ const theme = (0, lodash_merge_1.default)(webchatState.theme, props.theme);
132
+ const { initialSession, initialDevSettings, onStateChange } = props;
133
+ const getThemeProperty = (0, webchat_1._getThemeProperty)(theme);
134
+ const [customComponent, setCustomComponent] = (0, react_1.useState)(null);
135
+ const storage = props.storage;
136
+ const storageKey = typeof props.storageKey === 'function'
137
+ ? props.storageKey()
138
+ : props.storageKey;
139
+ const [botonicState, saveState] = (0, use_storage_state_hook_1.useStorageState)(storage, storageKey);
140
+ const host = props.host || document.body;
141
+ const deviceAdapter = new device_adapter_1.DeviceAdapter();
142
+ const saveWebchatState = webchatState => {
143
+ storage &&
144
+ saveState(JSON.parse((0, regexs_1.stringifyWithRegexs)({
145
+ messages: webchatState.messagesJSON,
146
+ session: webchatState.session,
147
+ lastRoutePath: webchatState.lastRoutePath,
148
+ devSettings: webchatState.devSettings,
149
+ lastMessageUpdate: webchatState.lastMessageUpdate,
150
+ themeUpdates: webchatState.themeUpdates,
151
+ })));
152
+ };
153
+ const handleAttachment = event => {
154
+ if (!(0, message_utils_1.isAllowedSize)(event.target.files[0].size)) {
155
+ throw new Error(`The file is too large. A maximum of ${constants_1.MAX_ALLOWED_SIZE_MB}MB is allowed.`);
156
+ }
157
+ setCurrentAttachment({
158
+ fileName: event.target.files[0].name,
159
+ file: event.target.files[0],
160
+ attachmentType: (0, message_utils_1.getMediaType)(event.target.files[0].type),
161
+ });
162
+ };
163
+ (0, react_1.useEffect)(() => {
164
+ if (webchatState.currentAttachment)
165
+ sendAttachment(webchatState.currentAttachment);
166
+ }, [webchatState.currentAttachment]);
167
+ const sendUserInput = async (input) => {
168
+ props.onUserInput &&
169
+ props.onUserInput({
170
+ user: webchatState.session.user,
171
+ input: input,
172
+ session: webchatState.session,
173
+ lastRoutePath: webchatState.lastRoutePath,
174
+ });
175
+ };
176
+ const sendChatEvent = async (chatEvent) => {
177
+ const chatEventInput = {
178
+ id: (0, uuid_1.v4)(),
179
+ type: core_1.INPUT.CHAT_EVENT,
180
+ data: chatEvent,
181
+ };
182
+ props.onUserInput &&
183
+ props.onUserInput({
184
+ user: webchatState.session.user,
185
+ input: chatEventInput,
186
+ session: webchatState.session,
187
+ lastRoutePath: webchatState.lastRoutePath,
188
+ });
189
+ };
190
+ // Load styles stored in window._botonicInsertStyles by Webpack
191
+ (0, hooks_1.useComponentWillMount)(() => {
192
+ if (window._botonicInsertStyles && window._botonicInsertStyles.length) {
193
+ for (const botonicStyle of window._botonicInsertStyles) {
194
+ // Injecting styles at head is needed even if we use shadowDOM
195
+ // as some dependencies like simplebar rely on creating ephemeral elements
196
+ // on document.body and assume styles will be available globally
197
+ document.head.appendChild(botonicStyle);
198
+ // injecting styles in host node too so that shadowDOM works
199
+ if (props.shadowDOM)
200
+ host.appendChild(botonicStyle.cloneNode(true));
201
+ }
202
+ delete window._botonicInsertStyles;
203
+ }
204
+ if (props.shadowDOM) {
205
+ // emoji-picker-react injects styles in head, so we need to
206
+ // re-inject them in our host node to make it work with shadowDOM
207
+ for (const style of document.querySelectorAll('style')) {
208
+ if (style.textContent &&
209
+ style.textContent.includes('emoji-picker-react'))
210
+ host.appendChild(style.cloneNode(true));
211
+ }
212
+ }
213
+ });
214
+ // Load initial state from storage
215
+ (0, react_1.useEffect)(() => {
216
+ let { messages, session, lastRoutePath, devSettings, lastMessageUpdate, themeUpdates, } = botonicState || {};
217
+ session = (0, webchat_1.initSession)(session);
218
+ updateSession(session);
219
+ if ((0, webchat_1.shouldKeepSessionOnReload)({ initialDevSettings, devSettings })) {
220
+ if (messages) {
221
+ messages.forEach(m => {
222
+ addMessage(m);
223
+ const newComponent = (0, msg_to_botonic_1.msgToBotonic)(Object.assign(Object.assign({}, m), { delay: 0, typing: 0 }), (props.theme.message && props.theme.message.customTypes) ||
224
+ props.theme.customMessageTypes);
225
+ if (newComponent)
226
+ addMessageComponent(newComponent);
227
+ });
228
+ }
229
+ if (initialSession)
230
+ updateSession((0, lodash_merge_1.default)(initialSession, session));
231
+ if (lastRoutePath)
232
+ updateLastRoutePath(lastRoutePath);
233
+ }
234
+ else
235
+ updateSession((0, lodash_merge_1.default)(initialSession, session));
236
+ if (devSettings)
237
+ updateDevSettings(devSettings);
238
+ else if (initialDevSettings)
239
+ updateDevSettings(initialDevSettings);
240
+ if (lastMessageUpdate)
241
+ updateLastMessageDate(lastMessageUpdate);
242
+ if (themeUpdates !== undefined)
243
+ updateTheme((0, lodash_merge_1.default)(props.theme, themeUpdates), themeUpdates);
244
+ if (props.onInit)
245
+ setTimeout(() => props.onInit(), 100);
246
+ }, []);
247
+ (0, react_1.useEffect)(() => {
248
+ if (!webchatState.isWebchatOpen)
249
+ return;
250
+ deviceAdapter.init(host);
251
+ (0, dom_1.scrollToBottom)({ behavior: 'auto', host });
252
+ }, [webchatState.isWebchatOpen]);
253
+ (0, react_1.useEffect)(() => {
254
+ if (onStateChange && typeof onStateChange === 'function')
255
+ onStateChange(webchatState);
256
+ saveWebchatState(webchatState);
257
+ }, [
258
+ webchatState.messagesJSON,
259
+ webchatState.session,
260
+ webchatState.lastRoutePath,
261
+ webchatState.devSettings,
262
+ webchatState.lastMessageUpdate,
263
+ ]);
264
+ (0, use_async_effect_1.useAsyncEffect)(async () => {
265
+ if (!webchatState.online) {
266
+ setError({
267
+ message: (0, webchat_1.getServerErrorMessage)(props.server),
268
+ });
269
+ }
270
+ else {
271
+ if (!firstUpdate.current) {
272
+ setError(undefined);
273
+ }
274
+ }
275
+ }, [webchatState.online]);
276
+ (0, hooks_1.useTyping)({ webchatState, updateTyping, updateMessage, host });
277
+ (0, react_1.useEffect)(() => {
278
+ updateTheme((0, lodash_merge_1.default)(props.theme, theme, webchatState.themeUpdates));
279
+ }, [props.theme, webchatState.themeUpdates]);
280
+ const openWebview = (webviewComponent, params) => updateWebview(webviewComponent, params);
281
+ const handleSelectedEmoji = (event, emojiObject) => {
282
+ textArea.current.value += emojiObject.emoji;
283
+ textArea.current.focus();
284
+ };
285
+ const closeWebview = options => {
286
+ updateWebview();
287
+ if (userInputEnabled) {
288
+ textArea.current.focus();
289
+ }
290
+ if (options && options.payload) {
291
+ sendPayload(options.payload);
292
+ }
293
+ else if (options && options.path) {
294
+ let params = '';
295
+ if (options.params)
296
+ params = (0, core_1.params2queryString)(options.params);
297
+ sendPayload(`__PATH_PAYLOAD__${options.path}?${params}`);
298
+ }
299
+ };
300
+ const handleMenu = () => {
301
+ togglePersistentMenu(!webchatState.isPersistentMenuOpen);
302
+ };
303
+ const handleEmojiClick = () => {
304
+ toggleEmojiPicker(!webchatState.isEmojiPickerOpen);
305
+ };
306
+ const persistentMenuOptions = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.persistentMenu, props.persistentMenu);
307
+ const darkBackgroundMenu = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.darkBackgroundMenu, false);
308
+ const getBlockInputs = (rule, inputData) => {
309
+ const processedInput = rule.preprocess
310
+ ? rule.preprocess(inputData)
311
+ : inputData;
312
+ return rule.match.some(regex => {
313
+ if (typeof regex === 'string')
314
+ regex = (0, regexs_1.deserializeRegex)(regex);
315
+ return regex.test(processedInput);
316
+ });
317
+ };
318
+ const checkBlockInput = input => {
319
+ // if is a text we check if it is a serialized RE
320
+ const blockInputs = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.blockInputs, props.blockInputs);
321
+ if (!Array.isArray(blockInputs))
322
+ return false;
323
+ for (const rule of blockInputs) {
324
+ if (getBlockInputs(rule, input.data)) {
325
+ addMessageComponent(<components_1.Text id={input.id} from={constants_1.SENDERS.user} blob={false} style={{
326
+ backgroundColor: constants_1.COLORS.SCORPION_GRAY,
327
+ borderColor: constants_1.COLORS.SCORPION_GRAY,
328
+ padding: '8px 12px',
329
+ }}>
330
+ {rule.message}
331
+ </components_1.Text>);
332
+ updateReplies(false);
333
+ return true;
334
+ }
335
+ }
336
+ return false;
337
+ };
338
+ const closeMenu = () => {
339
+ togglePersistentMenu(false);
340
+ };
341
+ const persistentMenu = () => {
342
+ return (<persistent_menu_1.OpenedPersistentMenu onClick={closeMenu} options={persistentMenuOptions} borderRadius={webchatState.theme.style.borderRadius || '10px'}/>);
343
+ };
344
+ const getCoverComponent = () => {
345
+ return getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.coverComponent, props.coverComponent &&
346
+ (props.coverComponent.component || props.coverComponent));
347
+ };
348
+ const CoverComponent = getCoverComponent();
349
+ const closeCoverComponent = () => {
350
+ toggleCoverComponent(false);
351
+ };
352
+ (0, react_1.useEffect)(() => {
353
+ if (!CoverComponent)
354
+ return;
355
+ if (!botonicState ||
356
+ (botonicState.messages && botonicState.messages.length == 0))
357
+ toggleCoverComponent(true);
358
+ }, []);
359
+ const coverComponent = () => {
360
+ const coverComponentProps = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.coverComponentProps, props.coverComponent && props.coverComponent.props);
361
+ if (CoverComponent && webchatState.isCoverComponentOpen)
362
+ return (<CoverComponent closeComponent={closeCoverComponent} {...coverComponentProps}/>);
363
+ return null;
364
+ };
365
+ const messageComponentFromInput = input => {
366
+ let messageComponent = null;
367
+ if ((0, message_utils_1.isText)(input)) {
368
+ messageComponent = (<components_1.Text id={input.id} payload={input.payload} from={constants_1.SENDERS.user}>
369
+ {input.data}
370
+ </components_1.Text>);
371
+ }
372
+ else if ((0, message_utils_1.isMedia)(input)) {
373
+ const temporaryDisplayUrl = URL.createObjectURL(input.data);
374
+ const mediaProps = {
375
+ id: input.id,
376
+ from: constants_1.SENDERS.user,
377
+ src: temporaryDisplayUrl,
378
+ };
379
+ if ((0, message_utils_1.isImage)(input))
380
+ messageComponent = <components_1.Image {...mediaProps}/>;
381
+ else if ((0, message_utils_1.isAudio)(input))
382
+ messageComponent = <components_1.Audio {...mediaProps}/>;
383
+ else if ((0, message_utils_1.isVideo)(input))
384
+ messageComponent = <components_1.Video {...mediaProps}/>;
385
+ else if ((0, message_utils_1.isDocument)(input))
386
+ messageComponent = <components_1.Document {...mediaProps}/>;
387
+ }
388
+ return messageComponent;
389
+ };
390
+ const sendInput = async (input) => {
391
+ if (!input || Object.keys(input).length == 0)
392
+ return;
393
+ if ((0, message_utils_1.isText)(input) && (!input.data || !input.data.trim()))
394
+ return; // in case trim() doesn't work in a browser we can use !/\S/.test(input.data)
395
+ if ((0, message_utils_1.isText)(input) && checkBlockInput(input))
396
+ return;
397
+ if (!input.id)
398
+ input.id = (0, uuid_1.v4)();
399
+ const messageComponent = messageComponentFromInput(input);
400
+ if (messageComponent)
401
+ addMessageComponent(messageComponent);
402
+ if ((0, message_utils_1.isMedia)(input))
403
+ input.data = await (0, message_utils_1.readDataURL)(input.data);
404
+ sendUserInput(input);
405
+ updateLatestInput(input);
406
+ isOnline() && updateLastMessageDate(currentDateString());
407
+ updateReplies(false);
408
+ togglePersistentMenu(false);
409
+ toggleEmojiPicker(false);
410
+ };
411
+ /* This is the public API this component exposes to its parents
412
+ https://stackoverflow.com/questions/37949981/call-child-method-from-parent
413
+ */
414
+ const updateSessionWithUser = userToUpdate => updateSession((0, lodash_merge_1.default)(webchatState.session, { user: userToUpdate }));
415
+ (0, react_1.useImperativeHandle)(ref, () => ({
416
+ addBotResponse: ({ response, session, lastRoutePath }) => {
417
+ updateTyping(false);
418
+ if (Array.isArray(response))
419
+ response.map(r => addMessageComponent(r));
420
+ else if (response)
421
+ addMessageComponent(response);
422
+ if (session) {
423
+ updateSession((0, lodash_merge_1.default)(session, { user: webchatState.session.user }));
424
+ const action = session._botonic_action || '';
425
+ const handoff = action.startsWith('create_case');
426
+ if (handoff && environment_1.isDev)
427
+ addMessageComponent(<handoff_1.Handoff />);
428
+ updateHandoff(handoff);
429
+ }
430
+ if (lastRoutePath)
431
+ updateLastRoutePath(lastRoutePath);
432
+ updateLastMessageDate(currentDateString());
433
+ },
434
+ setTyping: typing => updateTyping(typing),
435
+ addUserMessage: message => sendInput(message),
436
+ updateUser: updateSessionWithUser,
437
+ openWebchat: () => toggleWebchat(true),
438
+ closeWebchat: () => toggleWebchat(false),
439
+ toggleWebchat: () => toggleWebchat(!webchatState.isWebchatOpen),
440
+ openCoverComponent: () => toggleCoverComponent(true),
441
+ closeCoverComponent: () => toggleCoverComponent(false),
442
+ renderCustomComponent: _customComponent => {
443
+ setCustomComponent(_customComponent);
444
+ doRenderCustomComponent(true);
445
+ },
446
+ unmountCustomComponent: () => doRenderCustomComponent(false),
447
+ toggleCoverComponent: () => toggleCoverComponent(!webchatState.isCoverComponentOpen),
448
+ openWebviewApi: component => openWebviewT(component),
449
+ setError,
450
+ setOnline,
451
+ getMessages: () => webchatState.messagesJSON,
452
+ isOnline,
453
+ clearMessages: () => {
454
+ clearMessages();
455
+ updateReplies(false);
456
+ },
457
+ getLastMessageUpdate: () => webchatState.lastMessageUpdate,
458
+ updateMessageInfo: (msgId, messageInfo) => {
459
+ const messageToUpdate = webchatState.messagesJSON.filter(m => m.id == msgId)[0];
460
+ const updatedMsg = (0, lodash_merge_1.default)(messageToUpdate, messageInfo);
461
+ if (updatedMsg.ack === 1)
462
+ delete updatedMsg.unsentInput;
463
+ updateMessage(updatedMsg);
464
+ },
465
+ updateWebchatSettings: settings => {
466
+ const themeUpdates = (0, webchat_settings_1.normalizeWebchatSettings)(settings);
467
+ updateTheme((0, lodash_merge_1.default)(webchatState.theme, themeUpdates), themeUpdates);
468
+ },
469
+ }));
470
+ const resolveCase = () => {
471
+ updateHandoff(false);
472
+ updateSession(Object.assign(Object.assign({}, webchatState.session), { _botonic_action: null }));
473
+ };
474
+ const prevSession = (0, hooks_1.usePrevious)(webchatState.session);
475
+ (0, react_1.useEffect)(() => {
476
+ // Resume conversation after handoff
477
+ if (prevSession &&
478
+ prevSession._botonic_action &&
479
+ !webchatState.session._botonic_action) {
480
+ const action = (0, exports.getParsedAction)(prevSession._botonic_action);
481
+ if (action && action.on_finish)
482
+ sendPayload(action.on_finish);
483
+ }
484
+ }, [webchatState.session._botonic_action]);
485
+ const sendText = async (text, payload) => {
486
+ if (!text)
487
+ return;
488
+ const input = { type: core_1.INPUT.TEXT, data: text, payload };
489
+ await sendInput(input);
490
+ };
491
+ const sendPayload = async (payload) => {
492
+ if (!payload)
493
+ return;
494
+ const input = { type: core_1.INPUT.POSTBACK, payload };
495
+ await sendInput(input);
496
+ };
497
+ const sendAttachment = async (attachment) => {
498
+ if (attachment.file) {
499
+ const attachmentType = (0, message_utils_1.getMediaType)(attachment.file.type);
500
+ if (!attachmentType)
501
+ return;
502
+ const input = {
503
+ type: attachmentType,
504
+ data: attachment.file,
505
+ };
506
+ await sendInput(input);
507
+ setCurrentAttachment(undefined);
508
+ }
509
+ };
510
+ const sendTextAreaText = () => {
511
+ sendText(textArea.current.value);
512
+ textArea.current.value = '';
513
+ };
514
+ let isTyping = false;
515
+ let typingTimeout = null;
516
+ function clearTimeoutWithReset(reset) {
517
+ const waitTime = 20 * 1000;
518
+ if (typingTimeout)
519
+ clearTimeout(typingTimeout);
520
+ if (reset)
521
+ typingTimeout = setTimeout(stopTyping, waitTime);
522
+ }
523
+ function startTyping() {
524
+ isTyping = true;
525
+ sendChatEvent('typing_on');
526
+ }
527
+ function stopTyping() {
528
+ clearTimeoutWithReset(false);
529
+ isTyping = false;
530
+ sendChatEvent('typing_off');
531
+ }
532
+ const onKeyDown = event => {
533
+ if (event.keyCode === 13 && event.shiftKey === false) {
534
+ event.preventDefault();
535
+ sendTextAreaText();
536
+ stopTyping();
537
+ }
538
+ };
539
+ const onKeyUp = () => {
540
+ if (textArea.current.value === '') {
541
+ stopTyping();
542
+ return;
543
+ }
544
+ if (!isTyping) {
545
+ startTyping();
546
+ }
547
+ clearTimeoutWithReset(true);
548
+ };
549
+ const webviewRequestContext = {
550
+ getString: stringId => props.getString(stringId, webchatState.session),
551
+ setLocale: locale => props.getString(locale, webchatState.session),
552
+ session: webchatState.session || {},
553
+ params: webchatState.webviewParams || {},
554
+ closeWebview: closeWebview,
555
+ defaultDelay: props.defaultDelay || 0,
556
+ defaultTyping: props.defaultTyping || 0,
557
+ };
558
+ (0, react_1.useEffect)(() => {
559
+ if (firstUpdate.current) {
560
+ firstUpdate.current = false;
561
+ return;
562
+ }
563
+ if (webchatState.isWebchatOpen && props.onOpen)
564
+ props.onOpen();
565
+ if (!webchatState.isWebchatOpen && props.onClose && !firstUpdate.current) {
566
+ props.onClose();
567
+ toggleEmojiPicker(false);
568
+ togglePersistentMenu(false);
569
+ }
570
+ }, [webchatState.isWebchatOpen]);
571
+ const textArea = (0, react_1.useRef)();
572
+ const getTriggerImage = () => {
573
+ const triggerImage = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.triggerButtonImage, null);
574
+ if (triggerImage === null) {
575
+ webchatState.theme.triggerButtonImage = constants_1.WEBCHAT.DEFAULTS.LOGO;
576
+ return null;
577
+ }
578
+ return triggerImage;
579
+ };
580
+ const triggerButtonStyle = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.triggerButtonStyle);
581
+ const CustomTriggerButton = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.customTrigger, undefined);
582
+ const triggerButton = () => {
583
+ if (CustomTriggerButton) {
584
+ return <CustomTriggerButton />;
585
+ }
586
+ return (<StyledTriggerButton role={constants_1.ROLES.TRIGGER_BUTTON} style={Object.assign({}, triggerButtonStyle)}>
587
+ {getTriggerImage() && (<TriggerImage src={(0, environment_1.resolveImage)(getTriggerImage())}/>)}
588
+ </StyledTriggerButton>);
589
+ };
590
+ const webchatMessageList = () => (<message_list_1.WebchatMessageList style={{ flex: 1 }}>
591
+ {webchatState.typing && <typing_indicator_1.TypingIndicator />}
592
+ </message_list_1.WebchatMessageList>);
593
+ const webchatReplies = () => <replies_1.WebchatReplies replies={webchatState.replies}/>;
594
+ const isUserInputEnabled = () => {
595
+ const isUserInputEnabled = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.enableUserInput, props.enableUserInput !== undefined ? props.enableUserInput : true);
596
+ return isUserInputEnabled && !webchatState.isCoverComponentOpen;
597
+ };
598
+ const userInputEnabled = isUserInputEnabled();
599
+ const userInputArea = () => {
600
+ return (userInputEnabled && (<UserInputContainer style={Object.assign({}, getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.userInputStyle))} className='user-input-container'>
601
+ {webchatState.isEmojiPickerOpen && (<emoji_picker_1.OpenedEmojiPicker height={webchatState.theme.style.height} onEmojiClick={handleSelectedEmoji} onClick={handleEmojiClick}/>)}
602
+
603
+ <persistent_menu_1.PersistentMenu onClick={handleMenu} persistentMenu={props.persistentMenu}/>
604
+
605
+ <TextAreaContainer>
606
+ <react_textarea_autosize_1.default name='text' onFocus={() => deviceAdapter.onFocus(host)} onBlur={() => deviceAdapter.onBlur()} maxRows={4} wrap='soft' maxLength='1000' placeholder={getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.textPlaceholder, constants_1.WEBCHAT.DEFAULTS.PLACEHOLDER)} autoFocus={true} inputRef={textArea} onKeyDown={e => onKeyDown(e)} onKeyUp={onKeyUp} style={Object.assign({ display: 'flex', fontSize: deviceAdapter.fontSize(14), width: '100%', border: 'none', resize: 'none', overflow: 'auto', outline: 'none', flex: '1 1 auto', padding: 10, paddingLeft: persistentMenuOptions ? 0 : 10, fontFamily: 'inherit' }, getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.userInputBoxStyle))}/>
607
+ </TextAreaContainer>
608
+
609
+ <emoji_picker_1.EmojiPicker enableEmojiPicker={props.enableEmojiPicker} onClick={handleEmojiClick}/>
610
+
611
+ <attachment_1.Attachment enableAttachments={props.enableAttachments} onChange={handleAttachment} accept={(0, message_utils_1.getFullMimeWhitelist)().join(',')}/>
612
+
613
+ <send_button_1.SendButton onClick={sendTextAreaText}/>
614
+ </UserInputContainer>));
615
+ };
616
+ const webchatWebview = () => (<contexts_1.RequestContext.Provider value={webviewRequestContext}>
617
+ <webview_1.WebviewContainer style={Object.assign(Object.assign({}, getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.webviewStyle)), mobileStyle)} webview={webchatState.webview}/>
618
+ </contexts_1.RequestContext.Provider>);
619
+ let mobileStyle = {};
620
+ if ((0, core_1.isMobile)(getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.mobileBreakpoint))) {
621
+ mobileStyle = getThemeProperty(constants_1.WEBCHAT.CUSTOM_PROPERTIES.mobileStyle) || {
622
+ width: '100%',
623
+ height: '100%',
624
+ right: 0,
625
+ bottom: 0,
626
+ borderRadius: 0,
627
+ };
628
+ }
629
+ (0, react_1.useEffect)(() => {
630
+ // Prod mode
631
+ saveWebchatState(webchatState);
632
+ (0, dom_1.scrollToBottom)({ host });
633
+ }, [webchatState.themeUpdates]);
634
+ // Only needed for dev/serve mode
635
+ const updateWebchatDevSettings = settings => {
636
+ // eslint-disable-next-line react-hooks/rules-of-hooks
637
+ (0, react_1.useEffect)(() => {
638
+ const themeUpdates = (0, webchat_settings_1.normalizeWebchatSettings)(settings);
639
+ updateTheme((0, lodash_merge_1.default)(webchatState.theme, themeUpdates), themeUpdates);
640
+ }, [webchatState.messagesJSON]);
641
+ };
642
+ const DarkenBackground = ({ component }) => {
643
+ return (<div>
644
+ {darkBackgroundMenu && (<DarkBackgroundMenu style={{
645
+ borderRadius: webchatState.theme.style.borderRadius,
646
+ }}/>)}
647
+ {component}
648
+ </div>);
649
+ };
650
+ const _renderCustomComponent = () => {
651
+ if (!customComponent)
652
+ return <></>;
653
+ else
654
+ return customComponent;
655
+ };
656
+ const WebchatComponent = (<contexts_1.WebchatContext.Provider value={{
657
+ sendText,
658
+ sendAttachment,
659
+ sendPayload,
660
+ sendInput,
661
+ openWebview,
662
+ resolveCase,
663
+ webchatState,
664
+ getThemeProperty,
665
+ addMessage,
666
+ toggleWebchat,
667
+ updateMessage,
668
+ updateReplies,
669
+ updateLatestInput,
670
+ updateUser: updateSessionWithUser,
671
+ updateWebchatDevSettings: updateWebchatDevSettings,
672
+ }}>
673
+ {!webchatState.isWebchatOpen && (<div onClick={event => {
674
+ toggleWebchat(true);
675
+ event.preventDefault();
676
+ }}>
677
+ {triggerButton()}
678
+ </div>)}
679
+
680
+ {webchatState.isWebchatOpen && (<StyledWebchat
681
+ // TODO: Distinguis between multiple instances of webchat, e.g. `${uniqueId}-botonic-webchat`
682
+ role={constants_1.ROLES.WEBCHAT} id={constants_1.WEBCHAT.DEFAULTS.ID} width={webchatState.width} height={webchatState.height} style={Object.assign(Object.assign({}, webchatState.theme.style), mobileStyle)}>
683
+ <header_1.StyledWebchatHeader onCloseClick={() => {
684
+ toggleWebchat(false);
685
+ }}/>
686
+ {webchatState.error.message && (<ErrorMessageContainer>
687
+ <ErrorMessage>{webchatState.error.message}</ErrorMessage>
688
+ </ErrorMessageContainer>)}
689
+ {webchatMessageList()}
690
+ {webchatState.replies &&
691
+ Object.keys(webchatState.replies).length > 0 &&
692
+ webchatReplies()}
693
+ {webchatState.isPersistentMenuOpen && (<DarkenBackground component={persistentMenu()}/>)}
694
+ {!webchatState.handoff && userInputArea()}
695
+ {webchatState.webview && webchatWebview()}
696
+ {webchatState.isCoverComponentOpen && coverComponent()}
697
+ {webchatState.isCustomComponentRendered &&
698
+ customComponent &&
699
+ _renderCustomComponent()}
700
+ </StyledWebchat>)}
701
+ </contexts_1.WebchatContext.Provider>);
702
+ return props.shadowDOM ? (<styled_components_1.StyleSheetManager target={host}>{WebchatComponent}</styled_components_1.StyleSheetManager>) : (WebchatComponent);
703
+ });
704
+ //# sourceMappingURL=webchat.js.map