@repzo/widget-react-native 1.0.0

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 (448) hide show
  1. package/README.md +482 -0
  2. package/lib/commonjs/agent-ui-blocks.js +159 -0
  3. package/lib/commonjs/agent-ui-blocks.js.map +1 -0
  4. package/lib/commonjs/api/client.js +267 -0
  5. package/lib/commonjs/api/client.js.map +1 -0
  6. package/lib/commonjs/api/realtime.js +193 -0
  7. package/lib/commonjs/api/realtime.js.map +1 -0
  8. package/lib/commonjs/api/sse-parser.js +58 -0
  9. package/lib/commonjs/api/sse-parser.js.map +1 -0
  10. package/lib/commonjs/controller.js +23 -0
  11. package/lib/commonjs/controller.js.map +1 -0
  12. package/lib/commonjs/device-id.js +75 -0
  13. package/lib/commonjs/device-id.js.map +1 -0
  14. package/lib/commonjs/events.js +49 -0
  15. package/lib/commonjs/events.js.map +1 -0
  16. package/lib/commonjs/i18n.js +106 -0
  17. package/lib/commonjs/i18n.js.map +1 -0
  18. package/lib/commonjs/index.js +98 -0
  19. package/lib/commonjs/index.js.map +1 -0
  20. package/lib/commonjs/locales.js +85 -0
  21. package/lib/commonjs/locales.js.map +1 -0
  22. package/lib/commonjs/package.json +1 -0
  23. package/lib/commonjs/push/push-notifications.js +208 -0
  24. package/lib/commonjs/push/push-notifications.js.map +1 -0
  25. package/lib/commonjs/state/use-widget-state.js +23 -0
  26. package/lib/commonjs/state/use-widget-state.js.map +1 -0
  27. package/lib/commonjs/state/widget-store.js +1682 -0
  28. package/lib/commonjs/state/widget-store.js.map +1 -0
  29. package/lib/commonjs/storage.js +147 -0
  30. package/lib/commonjs/storage.js.map +1 -0
  31. package/lib/commonjs/types.js +44 -0
  32. package/lib/commonjs/types.js.map +1 -0
  33. package/lib/commonjs/ui/WidgetProvider.js +404 -0
  34. package/lib/commonjs/ui/WidgetProvider.js.map +1 -0
  35. package/lib/commonjs/ui/components/AgentUiBlocks.js +864 -0
  36. package/lib/commonjs/ui/components/AgentUiBlocks.js.map +1 -0
  37. package/lib/commonjs/ui/components/Avatar.js +76 -0
  38. package/lib/commonjs/ui/components/Avatar.js.map +1 -0
  39. package/lib/commonjs/ui/components/ConversationRow.js +155 -0
  40. package/lib/commonjs/ui/components/ConversationRow.js.map +1 -0
  41. package/lib/commonjs/ui/components/ErrorBoundary.js +44 -0
  42. package/lib/commonjs/ui/components/ErrorBoundary.js.map +1 -0
  43. package/lib/commonjs/ui/components/Gradient.js +168 -0
  44. package/lib/commonjs/ui/components/Gradient.js.map +1 -0
  45. package/lib/commonjs/ui/components/Launcher.js +125 -0
  46. package/lib/commonjs/ui/components/Launcher.js.map +1 -0
  47. package/lib/commonjs/ui/components/Markdown.js +257 -0
  48. package/lib/commonjs/ui/components/Markdown.js.map +1 -0
  49. package/lib/commonjs/ui/components/OutboundMessageCard.js +157 -0
  50. package/lib/commonjs/ui/components/OutboundMessageCard.js.map +1 -0
  51. package/lib/commonjs/ui/components/WidgetPanel.js +131 -0
  52. package/lib/commonjs/ui/components/WidgetPanel.js.map +1 -0
  53. package/lib/commonjs/ui/components/icons.js +383 -0
  54. package/lib/commonjs/ui/components/icons.js.map +1 -0
  55. package/lib/commonjs/ui/hooks/use-keyboard-overlap.js +113 -0
  56. package/lib/commonjs/ui/hooks/use-keyboard-overlap.js.map +1 -0
  57. package/lib/commonjs/ui/hooks/use-reduce-motion.js +38 -0
  58. package/lib/commonjs/ui/hooks/use-reduce-motion.js.map +1 -0
  59. package/lib/commonjs/ui/hooks/use-widget-insets.js +41 -0
  60. package/lib/commonjs/ui/hooks/use-widget-insets.js.map +1 -0
  61. package/lib/commonjs/ui/screens/chat/ChatView.js +590 -0
  62. package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -0
  63. package/lib/commonjs/ui/screens/chat/ChatView.styles.js +362 -0
  64. package/lib/commonjs/ui/screens/chat/ChatView.styles.js.map +1 -0
  65. package/lib/commonjs/ui/screens/chat/ChatView.types.js +6 -0
  66. package/lib/commonjs/ui/screens/chat/ChatView.types.js.map +1 -0
  67. package/lib/commonjs/ui/screens/conversations/ConversationsList.js +150 -0
  68. package/lib/commonjs/ui/screens/conversations/ConversationsList.js.map +1 -0
  69. package/lib/commonjs/ui/screens/conversations/ConversationsList.styles.js +118 -0
  70. package/lib/commonjs/ui/screens/conversations/ConversationsList.styles.js.map +1 -0
  71. package/lib/commonjs/ui/screens/conversations/ConversationsList.types.js +6 -0
  72. package/lib/commonjs/ui/screens/conversations/ConversationsList.types.js.map +1 -0
  73. package/lib/commonjs/ui/screens/home/HomeView.js +336 -0
  74. package/lib/commonjs/ui/screens/home/HomeView.js.map +1 -0
  75. package/lib/commonjs/ui/screens/home/HomeView.styles.js +245 -0
  76. package/lib/commonjs/ui/screens/home/HomeView.styles.js.map +1 -0
  77. package/lib/commonjs/ui/screens/home/HomeView.types.js +6 -0
  78. package/lib/commonjs/ui/screens/home/HomeView.types.js.map +1 -0
  79. package/lib/commonjs/ui/screens/home/greeting.js +49 -0
  80. package/lib/commonjs/ui/screens/home/greeting.js.map +1 -0
  81. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.js +229 -0
  82. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.js.map +1 -0
  83. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.styles.js +125 -0
  84. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.styles.js.map +1 -0
  85. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.types.js +6 -0
  86. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.types.js.map +1 -0
  87. package/lib/commonjs/ui/styles/global.js +55 -0
  88. package/lib/commonjs/ui/styles/global.js.map +1 -0
  89. package/lib/commonjs/ui/styles/theme.js +148 -0
  90. package/lib/commonjs/ui/styles/theme.js.map +1 -0
  91. package/lib/commonjs/ui/utils/conversations.js +125 -0
  92. package/lib/commonjs/ui/utils/conversations.js.map +1 -0
  93. package/lib/commonjs/ui/utils/html.js +44 -0
  94. package/lib/commonjs/ui/utils/html.js.map +1 -0
  95. package/lib/commonjs/ui/utils/native-gradient.js +65 -0
  96. package/lib/commonjs/ui/utils/native-gradient.js.map +1 -0
  97. package/lib/commonjs/ui/utils/rtl.js +56 -0
  98. package/lib/commonjs/ui/utils/rtl.js.map +1 -0
  99. package/lib/commonjs/ui/utils/safe-url.js +67 -0
  100. package/lib/commonjs/ui/utils/safe-url.js.map +1 -0
  101. package/lib/module/agent-ui-blocks.js +152 -0
  102. package/lib/module/agent-ui-blocks.js.map +1 -0
  103. package/lib/module/api/client.js +261 -0
  104. package/lib/module/api/client.js.map +1 -0
  105. package/lib/module/api/realtime.js +189 -0
  106. package/lib/module/api/realtime.js.map +1 -0
  107. package/lib/module/api/sse-parser.js +53 -0
  108. package/lib/module/api/sse-parser.js.map +1 -0
  109. package/lib/module/controller.js +19 -0
  110. package/lib/module/controller.js.map +1 -0
  111. package/lib/module/device-id.js +69 -0
  112. package/lib/module/device-id.js.map +1 -0
  113. package/lib/module/events.js +44 -0
  114. package/lib/module/events.js.map +1 -0
  115. package/lib/module/i18n.js +99 -0
  116. package/lib/module/i18n.js.map +1 -0
  117. package/lib/module/index.js +55 -0
  118. package/lib/module/index.js.map +1 -0
  119. package/lib/module/locales.js +80 -0
  120. package/lib/module/locales.js.map +1 -0
  121. package/lib/module/package.json +1 -0
  122. package/lib/module/push/push-notifications.js +204 -0
  123. package/lib/module/push/push-notifications.js.map +1 -0
  124. package/lib/module/state/use-widget-state.js +18 -0
  125. package/lib/module/state/use-widget-state.js.map +1 -0
  126. package/lib/module/state/widget-store.js +1677 -0
  127. package/lib/module/state/widget-store.js.map +1 -0
  128. package/lib/module/storage.js +141 -0
  129. package/lib/module/storage.js.map +1 -0
  130. package/lib/module/types.js +40 -0
  131. package/lib/module/types.js.map +1 -0
  132. package/lib/module/ui/WidgetProvider.js +400 -0
  133. package/lib/module/ui/WidgetProvider.js.map +1 -0
  134. package/lib/module/ui/components/AgentUiBlocks.js +857 -0
  135. package/lib/module/ui/components/AgentUiBlocks.js.map +1 -0
  136. package/lib/module/ui/components/Avatar.js +71 -0
  137. package/lib/module/ui/components/Avatar.js.map +1 -0
  138. package/lib/module/ui/components/ConversationRow.js +150 -0
  139. package/lib/module/ui/components/ConversationRow.js.map +1 -0
  140. package/lib/module/ui/components/ErrorBoundary.js +39 -0
  141. package/lib/module/ui/components/ErrorBoundary.js.map +1 -0
  142. package/lib/module/ui/components/Gradient.js +165 -0
  143. package/lib/module/ui/components/Gradient.js.map +1 -0
  144. package/lib/module/ui/components/Launcher.js +121 -0
  145. package/lib/module/ui/components/Launcher.js.map +1 -0
  146. package/lib/module/ui/components/Markdown.js +253 -0
  147. package/lib/module/ui/components/Markdown.js.map +1 -0
  148. package/lib/module/ui/components/OutboundMessageCard.js +153 -0
  149. package/lib/module/ui/components/OutboundMessageCard.js.map +1 -0
  150. package/lib/module/ui/components/WidgetPanel.js +127 -0
  151. package/lib/module/ui/components/WidgetPanel.js.map +1 -0
  152. package/lib/module/ui/components/icons.js +370 -0
  153. package/lib/module/ui/components/icons.js.map +1 -0
  154. package/lib/module/ui/hooks/use-keyboard-overlap.js +109 -0
  155. package/lib/module/ui/hooks/use-keyboard-overlap.js.map +1 -0
  156. package/lib/module/ui/hooks/use-reduce-motion.js +34 -0
  157. package/lib/module/ui/hooks/use-reduce-motion.js.map +1 -0
  158. package/lib/module/ui/hooks/use-widget-insets.js +37 -0
  159. package/lib/module/ui/hooks/use-widget-insets.js.map +1 -0
  160. package/lib/module/ui/screens/chat/ChatView.js +586 -0
  161. package/lib/module/ui/screens/chat/ChatView.js.map +1 -0
  162. package/lib/module/ui/screens/chat/ChatView.styles.js +358 -0
  163. package/lib/module/ui/screens/chat/ChatView.styles.js.map +1 -0
  164. package/lib/module/ui/screens/chat/ChatView.types.js +4 -0
  165. package/lib/module/ui/screens/chat/ChatView.types.js.map +1 -0
  166. package/lib/module/ui/screens/conversations/ConversationsList.js +146 -0
  167. package/lib/module/ui/screens/conversations/ConversationsList.js.map +1 -0
  168. package/lib/module/ui/screens/conversations/ConversationsList.styles.js +114 -0
  169. package/lib/module/ui/screens/conversations/ConversationsList.styles.js.map +1 -0
  170. package/lib/module/ui/screens/conversations/ConversationsList.types.js +4 -0
  171. package/lib/module/ui/screens/conversations/ConversationsList.types.js.map +1 -0
  172. package/lib/module/ui/screens/home/HomeView.js +332 -0
  173. package/lib/module/ui/screens/home/HomeView.js.map +1 -0
  174. package/lib/module/ui/screens/home/HomeView.styles.js +242 -0
  175. package/lib/module/ui/screens/home/HomeView.styles.js.map +1 -0
  176. package/lib/module/ui/screens/home/HomeView.types.js +4 -0
  177. package/lib/module/ui/screens/home/HomeView.types.js.map +1 -0
  178. package/lib/module/ui/screens/home/greeting.js +44 -0
  179. package/lib/module/ui/screens/home/greeting.js.map +1 -0
  180. package/lib/module/ui/screens/pre-chat/PreChatForm.js +225 -0
  181. package/lib/module/ui/screens/pre-chat/PreChatForm.js.map +1 -0
  182. package/lib/module/ui/screens/pre-chat/PreChatForm.styles.js +121 -0
  183. package/lib/module/ui/screens/pre-chat/PreChatForm.styles.js.map +1 -0
  184. package/lib/module/ui/screens/pre-chat/PreChatForm.types.js +4 -0
  185. package/lib/module/ui/screens/pre-chat/PreChatForm.types.js.map +1 -0
  186. package/lib/module/ui/styles/global.js +51 -0
  187. package/lib/module/ui/styles/global.js.map +1 -0
  188. package/lib/module/ui/styles/theme.js +137 -0
  189. package/lib/module/ui/styles/theme.js.map +1 -0
  190. package/lib/module/ui/utils/conversations.js +115 -0
  191. package/lib/module/ui/utils/conversations.js.map +1 -0
  192. package/lib/module/ui/utils/html.js +39 -0
  193. package/lib/module/ui/utils/html.js.map +1 -0
  194. package/lib/module/ui/utils/native-gradient.js +60 -0
  195. package/lib/module/ui/utils/native-gradient.js.map +1 -0
  196. package/lib/module/ui/utils/rtl.js +49 -0
  197. package/lib/module/ui/utils/rtl.js.map +1 -0
  198. package/lib/module/ui/utils/safe-url.js +59 -0
  199. package/lib/module/ui/utils/safe-url.js.map +1 -0
  200. package/lib/typescript/commonjs/agent-ui-blocks.d.ts +20 -0
  201. package/lib/typescript/commonjs/agent-ui-blocks.d.ts.map +1 -0
  202. package/lib/typescript/commonjs/api/client.d.ts +115 -0
  203. package/lib/typescript/commonjs/api/client.d.ts.map +1 -0
  204. package/lib/typescript/commonjs/api/realtime.d.ts +39 -0
  205. package/lib/typescript/commonjs/api/realtime.d.ts.map +1 -0
  206. package/lib/typescript/commonjs/api/sse-parser.d.ts +13 -0
  207. package/lib/typescript/commonjs/api/sse-parser.d.ts.map +1 -0
  208. package/lib/typescript/commonjs/controller.d.ts +15 -0
  209. package/lib/typescript/commonjs/controller.d.ts.map +1 -0
  210. package/lib/typescript/commonjs/device-id.d.ts +15 -0
  211. package/lib/typescript/commonjs/device-id.d.ts.map +1 -0
  212. package/lib/typescript/commonjs/events.d.ts +41 -0
  213. package/lib/typescript/commonjs/events.d.ts.map +1 -0
  214. package/lib/typescript/commonjs/i18n.d.ts +78 -0
  215. package/lib/typescript/commonjs/i18n.d.ts.map +1 -0
  216. package/lib/typescript/commonjs/index.d.ts +103 -0
  217. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  218. package/lib/typescript/commonjs/locales.d.ts +18 -0
  219. package/lib/typescript/commonjs/locales.d.ts.map +1 -0
  220. package/lib/typescript/commonjs/package.json +1 -0
  221. package/lib/typescript/commonjs/push/push-notifications.d.ts +71 -0
  222. package/lib/typescript/commonjs/push/push-notifications.d.ts.map +1 -0
  223. package/lib/typescript/commonjs/state/use-widget-state.d.ts +10 -0
  224. package/lib/typescript/commonjs/state/use-widget-state.d.ts.map +1 -0
  225. package/lib/typescript/commonjs/state/widget-store.d.ts +227 -0
  226. package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -0
  227. package/lib/typescript/commonjs/storage.d.ts +42 -0
  228. package/lib/typescript/commonjs/storage.d.ts.map +1 -0
  229. package/lib/typescript/commonjs/types.d.ts +391 -0
  230. package/lib/typescript/commonjs/types.d.ts.map +1 -0
  231. package/lib/typescript/commonjs/ui/WidgetProvider.d.ts +15 -0
  232. package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -0
  233. package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts +27 -0
  234. package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts.map +1 -0
  235. package/lib/typescript/commonjs/ui/components/Avatar.d.ts +19 -0
  236. package/lib/typescript/commonjs/ui/components/Avatar.d.ts.map +1 -0
  237. package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts +26 -0
  238. package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts.map +1 -0
  239. package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts +27 -0
  240. package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts.map +1 -0
  241. package/lib/typescript/commonjs/ui/components/Gradient.d.ts +33 -0
  242. package/lib/typescript/commonjs/ui/components/Gradient.d.ts.map +1 -0
  243. package/lib/typescript/commonjs/ui/components/Launcher.d.ts +18 -0
  244. package/lib/typescript/commonjs/ui/components/Launcher.d.ts.map +1 -0
  245. package/lib/typescript/commonjs/ui/components/Markdown.d.ts +19 -0
  246. package/lib/typescript/commonjs/ui/components/Markdown.d.ts.map +1 -0
  247. package/lib/typescript/commonjs/ui/components/OutboundMessageCard.d.ts +20 -0
  248. package/lib/typescript/commonjs/ui/components/OutboundMessageCard.d.ts.map +1 -0
  249. package/lib/typescript/commonjs/ui/components/WidgetPanel.d.ts +26 -0
  250. package/lib/typescript/commonjs/ui/components/WidgetPanel.d.ts.map +1 -0
  251. package/lib/typescript/commonjs/ui/components/icons.d.ts +38 -0
  252. package/lib/typescript/commonjs/ui/components/icons.d.ts.map +1 -0
  253. package/lib/typescript/commonjs/ui/hooks/use-keyboard-overlap.d.ts +33 -0
  254. package/lib/typescript/commonjs/ui/hooks/use-keyboard-overlap.d.ts.map +1 -0
  255. package/lib/typescript/commonjs/ui/hooks/use-reduce-motion.d.ts +11 -0
  256. package/lib/typescript/commonjs/ui/hooks/use-reduce-motion.d.ts.map +1 -0
  257. package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts +16 -0
  258. package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts.map +1 -0
  259. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts +11 -0
  260. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -0
  261. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts +349 -0
  262. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts.map +1 -0
  263. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +48 -0
  264. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -0
  265. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts +10 -0
  266. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts.map +1 -0
  267. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.styles.d.ts +113 -0
  268. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.styles.d.ts.map +1 -0
  269. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts +31 -0
  270. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -0
  271. package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts +17 -0
  272. package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts.map +1 -0
  273. package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts +227 -0
  274. package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts.map +1 -0
  275. package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts +40 -0
  276. package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts.map +1 -0
  277. package/lib/typescript/commonjs/ui/screens/home/greeting.d.ts +19 -0
  278. package/lib/typescript/commonjs/ui/screens/home/greeting.d.ts.map +1 -0
  279. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.d.ts +7 -0
  280. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.d.ts.map +1 -0
  281. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.styles.d.ts +115 -0
  282. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.styles.d.ts.map +1 -0
  283. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.types.d.ts +20 -0
  284. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.types.d.ts.map +1 -0
  285. package/lib/typescript/commonjs/ui/styles/global.d.ts +46 -0
  286. package/lib/typescript/commonjs/ui/styles/global.d.ts.map +1 -0
  287. package/lib/typescript/commonjs/ui/styles/theme.d.ts +103 -0
  288. package/lib/typescript/commonjs/ui/styles/theme.d.ts.map +1 -0
  289. package/lib/typescript/commonjs/ui/utils/conversations.d.ts +41 -0
  290. package/lib/typescript/commonjs/ui/utils/conversations.d.ts.map +1 -0
  291. package/lib/typescript/commonjs/ui/utils/html.d.ts +10 -0
  292. package/lib/typescript/commonjs/ui/utils/html.d.ts.map +1 -0
  293. package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts +61 -0
  294. package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts.map +1 -0
  295. package/lib/typescript/commonjs/ui/utils/rtl.d.ts +33 -0
  296. package/lib/typescript/commonjs/ui/utils/rtl.d.ts.map +1 -0
  297. package/lib/typescript/commonjs/ui/utils/safe-url.d.ts +21 -0
  298. package/lib/typescript/commonjs/ui/utils/safe-url.d.ts.map +1 -0
  299. package/lib/typescript/module/agent-ui-blocks.d.ts +20 -0
  300. package/lib/typescript/module/agent-ui-blocks.d.ts.map +1 -0
  301. package/lib/typescript/module/api/client.d.ts +115 -0
  302. package/lib/typescript/module/api/client.d.ts.map +1 -0
  303. package/lib/typescript/module/api/realtime.d.ts +39 -0
  304. package/lib/typescript/module/api/realtime.d.ts.map +1 -0
  305. package/lib/typescript/module/api/sse-parser.d.ts +13 -0
  306. package/lib/typescript/module/api/sse-parser.d.ts.map +1 -0
  307. package/lib/typescript/module/controller.d.ts +15 -0
  308. package/lib/typescript/module/controller.d.ts.map +1 -0
  309. package/lib/typescript/module/device-id.d.ts +15 -0
  310. package/lib/typescript/module/device-id.d.ts.map +1 -0
  311. package/lib/typescript/module/events.d.ts +41 -0
  312. package/lib/typescript/module/events.d.ts.map +1 -0
  313. package/lib/typescript/module/i18n.d.ts +78 -0
  314. package/lib/typescript/module/i18n.d.ts.map +1 -0
  315. package/lib/typescript/module/index.d.ts +103 -0
  316. package/lib/typescript/module/index.d.ts.map +1 -0
  317. package/lib/typescript/module/locales.d.ts +18 -0
  318. package/lib/typescript/module/locales.d.ts.map +1 -0
  319. package/lib/typescript/module/package.json +1 -0
  320. package/lib/typescript/module/push/push-notifications.d.ts +71 -0
  321. package/lib/typescript/module/push/push-notifications.d.ts.map +1 -0
  322. package/lib/typescript/module/state/use-widget-state.d.ts +10 -0
  323. package/lib/typescript/module/state/use-widget-state.d.ts.map +1 -0
  324. package/lib/typescript/module/state/widget-store.d.ts +227 -0
  325. package/lib/typescript/module/state/widget-store.d.ts.map +1 -0
  326. package/lib/typescript/module/storage.d.ts +42 -0
  327. package/lib/typescript/module/storage.d.ts.map +1 -0
  328. package/lib/typescript/module/types.d.ts +391 -0
  329. package/lib/typescript/module/types.d.ts.map +1 -0
  330. package/lib/typescript/module/ui/WidgetProvider.d.ts +15 -0
  331. package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -0
  332. package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts +27 -0
  333. package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts.map +1 -0
  334. package/lib/typescript/module/ui/components/Avatar.d.ts +19 -0
  335. package/lib/typescript/module/ui/components/Avatar.d.ts.map +1 -0
  336. package/lib/typescript/module/ui/components/ConversationRow.d.ts +26 -0
  337. package/lib/typescript/module/ui/components/ConversationRow.d.ts.map +1 -0
  338. package/lib/typescript/module/ui/components/ErrorBoundary.d.ts +27 -0
  339. package/lib/typescript/module/ui/components/ErrorBoundary.d.ts.map +1 -0
  340. package/lib/typescript/module/ui/components/Gradient.d.ts +33 -0
  341. package/lib/typescript/module/ui/components/Gradient.d.ts.map +1 -0
  342. package/lib/typescript/module/ui/components/Launcher.d.ts +18 -0
  343. package/lib/typescript/module/ui/components/Launcher.d.ts.map +1 -0
  344. package/lib/typescript/module/ui/components/Markdown.d.ts +19 -0
  345. package/lib/typescript/module/ui/components/Markdown.d.ts.map +1 -0
  346. package/lib/typescript/module/ui/components/OutboundMessageCard.d.ts +20 -0
  347. package/lib/typescript/module/ui/components/OutboundMessageCard.d.ts.map +1 -0
  348. package/lib/typescript/module/ui/components/WidgetPanel.d.ts +26 -0
  349. package/lib/typescript/module/ui/components/WidgetPanel.d.ts.map +1 -0
  350. package/lib/typescript/module/ui/components/icons.d.ts +38 -0
  351. package/lib/typescript/module/ui/components/icons.d.ts.map +1 -0
  352. package/lib/typescript/module/ui/hooks/use-keyboard-overlap.d.ts +33 -0
  353. package/lib/typescript/module/ui/hooks/use-keyboard-overlap.d.ts.map +1 -0
  354. package/lib/typescript/module/ui/hooks/use-reduce-motion.d.ts +11 -0
  355. package/lib/typescript/module/ui/hooks/use-reduce-motion.d.ts.map +1 -0
  356. package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts +16 -0
  357. package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts.map +1 -0
  358. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts +11 -0
  359. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -0
  360. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts +349 -0
  361. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts.map +1 -0
  362. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +48 -0
  363. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -0
  364. package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts +10 -0
  365. package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts.map +1 -0
  366. package/lib/typescript/module/ui/screens/conversations/ConversationsList.styles.d.ts +113 -0
  367. package/lib/typescript/module/ui/screens/conversations/ConversationsList.styles.d.ts.map +1 -0
  368. package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts +31 -0
  369. package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -0
  370. package/lib/typescript/module/ui/screens/home/HomeView.d.ts +17 -0
  371. package/lib/typescript/module/ui/screens/home/HomeView.d.ts.map +1 -0
  372. package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts +227 -0
  373. package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts.map +1 -0
  374. package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts +40 -0
  375. package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts.map +1 -0
  376. package/lib/typescript/module/ui/screens/home/greeting.d.ts +19 -0
  377. package/lib/typescript/module/ui/screens/home/greeting.d.ts.map +1 -0
  378. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.d.ts +7 -0
  379. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.d.ts.map +1 -0
  380. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.styles.d.ts +115 -0
  381. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.styles.d.ts.map +1 -0
  382. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.types.d.ts +20 -0
  383. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.types.d.ts.map +1 -0
  384. package/lib/typescript/module/ui/styles/global.d.ts +46 -0
  385. package/lib/typescript/module/ui/styles/global.d.ts.map +1 -0
  386. package/lib/typescript/module/ui/styles/theme.d.ts +103 -0
  387. package/lib/typescript/module/ui/styles/theme.d.ts.map +1 -0
  388. package/lib/typescript/module/ui/utils/conversations.d.ts +41 -0
  389. package/lib/typescript/module/ui/utils/conversations.d.ts.map +1 -0
  390. package/lib/typescript/module/ui/utils/html.d.ts +10 -0
  391. package/lib/typescript/module/ui/utils/html.d.ts.map +1 -0
  392. package/lib/typescript/module/ui/utils/native-gradient.d.ts +61 -0
  393. package/lib/typescript/module/ui/utils/native-gradient.d.ts.map +1 -0
  394. package/lib/typescript/module/ui/utils/rtl.d.ts +33 -0
  395. package/lib/typescript/module/ui/utils/rtl.d.ts.map +1 -0
  396. package/lib/typescript/module/ui/utils/safe-url.d.ts +21 -0
  397. package/lib/typescript/module/ui/utils/safe-url.d.ts.map +1 -0
  398. package/metro.js +40 -0
  399. package/package.json +116 -0
  400. package/src/agent-ui-blocks.ts +302 -0
  401. package/src/api/client.ts +332 -0
  402. package/src/api/realtime.ts +225 -0
  403. package/src/api/sse-parser.ts +51 -0
  404. package/src/controller.ts +20 -0
  405. package/src/device-id.ts +71 -0
  406. package/src/events.ts +74 -0
  407. package/src/i18n.ts +114 -0
  408. package/src/index.tsx +199 -0
  409. package/src/locales.ts +80 -0
  410. package/src/push/push-notifications.ts +254 -0
  411. package/src/state/use-widget-state.ts +20 -0
  412. package/src/state/widget-store.ts +1815 -0
  413. package/src/storage.ts +153 -0
  414. package/src/types.ts +445 -0
  415. package/src/ui/WidgetProvider.tsx +434 -0
  416. package/src/ui/components/AgentUiBlocks.tsx +912 -0
  417. package/src/ui/components/Avatar.tsx +86 -0
  418. package/src/ui/components/ConversationRow.tsx +163 -0
  419. package/src/ui/components/ErrorBoundary.tsx +49 -0
  420. package/src/ui/components/Gradient.tsx +165 -0
  421. package/src/ui/components/Launcher.tsx +128 -0
  422. package/src/ui/components/Markdown.tsx +291 -0
  423. package/src/ui/components/OutboundMessageCard.tsx +154 -0
  424. package/src/ui/components/WidgetPanel.tsx +133 -0
  425. package/src/ui/components/icons.tsx +315 -0
  426. package/src/ui/hooks/use-keyboard-overlap.ts +134 -0
  427. package/src/ui/hooks/use-reduce-motion.ts +39 -0
  428. package/src/ui/hooks/use-widget-insets.ts +44 -0
  429. package/src/ui/screens/chat/ChatView.styles.ts +357 -0
  430. package/src/ui/screens/chat/ChatView.tsx +690 -0
  431. package/src/ui/screens/chat/ChatView.types.ts +46 -0
  432. package/src/ui/screens/conversations/ConversationsList.styles.ts +111 -0
  433. package/src/ui/screens/conversations/ConversationsList.tsx +144 -0
  434. package/src/ui/screens/conversations/ConversationsList.types.ts +33 -0
  435. package/src/ui/screens/home/HomeView.styles.ts +246 -0
  436. package/src/ui/screens/home/HomeView.tsx +336 -0
  437. package/src/ui/screens/home/HomeView.types.ts +42 -0
  438. package/src/ui/screens/home/greeting.ts +50 -0
  439. package/src/ui/screens/pre-chat/PreChatForm.styles.ts +120 -0
  440. package/src/ui/screens/pre-chat/PreChatForm.tsx +221 -0
  441. package/src/ui/screens/pre-chat/PreChatForm.types.ts +22 -0
  442. package/src/ui/styles/global.ts +50 -0
  443. package/src/ui/styles/theme.ts +155 -0
  444. package/src/ui/utils/conversations.ts +122 -0
  445. package/src/ui/utils/html.ts +58 -0
  446. package/src/ui/utils/native-gradient.ts +60 -0
  447. package/src/ui/utils/rtl.ts +43 -0
  448. package/src/ui/utils/safe-url.ts +63 -0
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RepzoWidgetEvents = exports.EventEmitter = void 0;
7
+ /**
8
+ * Tiny typed event emitter. Pure JS — no NativeEventEmitter, so listeners work
9
+ * identically on iOS, Android and in tests.
10
+ */
11
+
12
+ const RepzoWidgetEvents = exports.RepzoWidgetEvents = {
13
+ UnreadCountDidChange: 'repzoWidget.unreadCountDidChange',
14
+ MessageDidArrive: 'repzoWidget.messageDidArrive',
15
+ /** The visitor opened a thread — hosts use it to dismiss that conversation's push notification. */
16
+ ConversationDidRead: 'repzoWidget.conversationDidRead',
17
+ WindowDidShow: 'repzoWidget.windowDidShow',
18
+ WindowDidHide: 'repzoWidget.windowDidHide'
19
+ };
20
+ class EventEmitter {
21
+ listeners = new Map();
22
+ addListener(event, listener) {
23
+ const current = this.listeners.get(event) ?? new Set();
24
+ current.add(listener);
25
+ this.listeners.set(event, current);
26
+ return {
27
+ remove: () => {
28
+ this.listeners.get(event)?.delete(listener);
29
+ }
30
+ };
31
+ }
32
+ emit(event, payload) {
33
+ const current = this.listeners.get(event);
34
+ if (!current) return;
35
+ // Copy first: a listener may remove itself while we iterate.
36
+ for (const listener of Array.from(current)) {
37
+ try {
38
+ listener(payload);
39
+ } catch (error) {
40
+ console.warn('[repzo-widget] event listener threw', error);
41
+ }
42
+ }
43
+ }
44
+ removeAllListeners() {
45
+ this.listeners.clear();
46
+ }
47
+ }
48
+ exports.EventEmitter = EventEmitter;
49
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["RepzoWidgetEvents","exports","UnreadCountDidChange","MessageDidArrive","ConversationDidRead","WindowDidShow","WindowDidHide","EventEmitter","listeners","Map","addListener","event","listener","current","get","Set","add","set","remove","delete","emit","payload","Array","from","error","console","warn","removeAllListeners","clear"],"sourceRoot":"../../src","sources":["events.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAIO,MAAMA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG;EAC/BE,oBAAoB,EAAE,kCAAkC;EACxDC,gBAAgB,EAAE,8BAA8B;EAChD;EACAC,mBAAmB,EAAE,iCAAiC;EACtDC,aAAa,EAAE,2BAA2B;EAC1CC,aAAa,EAAE;AACjB,CAAU;AAyBH,MAAMC,YAAY,CAAC;EAChBC,SAAS,GAAG,IAAIC,GAAG,CAAwB,CAAC;EAEpDC,WAAWA,CACTC,KAAQ,EACRC,QAAwD,EACrC;IACnB,MAAMC,OAAO,GAAG,IAAI,CAACL,SAAS,CAACM,GAAG,CAACH,KAAK,CAAC,IAAI,IAAII,GAAG,CAAW,CAAC;IAChEF,OAAO,CAACG,GAAG,CAACJ,QAAoB,CAAC;IACjC,IAAI,CAACJ,SAAS,CAACS,GAAG,CAACN,KAAK,EAAEE,OAAO,CAAC;IAElC,OAAO;MACLK,MAAM,EAAEA,CAAA,KAAM;QACZ,IAAI,CAACV,SAAS,CAACM,GAAG,CAACH,KAAK,CAAC,EAAEQ,MAAM,CAACP,QAAoB,CAAC;MACzD;IACF,CAAC;EACH;EAEAQ,IAAIA,CAA6BT,KAAQ,EAAEU,OAAoC,EAAQ;IACrF,MAAMR,OAAO,GAAG,IAAI,CAACL,SAAS,CAACM,GAAG,CAACH,KAAK,CAAC;IACzC,IAAI,CAACE,OAAO,EAAE;IACd;IACA,KAAK,MAAMD,QAAQ,IAAIU,KAAK,CAACC,IAAI,CAACV,OAAO,CAAC,EAAE;MAC1C,IAAI;QACFD,QAAQ,CAACS,OAAO,CAAC;MACnB,CAAC,CAAC,OAAOG,KAAK,EAAE;QACdC,OAAO,CAACC,IAAI,CAAC,qCAAqC,EAAEF,KAAK,CAAC;MAC5D;IACF;EACF;EAEAG,kBAAkBA,CAAA,EAAS;IACzB,IAAI,CAACnB,SAAS,CAACoB,KAAK,CAAC,CAAC;EACxB;AACF;AAAC3B,OAAA,CAAAM,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DEFAULT_LABELS = void 0;
7
+ exports.buildLabels = buildLabels;
8
+ exports.createTranslator = createTranslator;
9
+ exports.formatLabel = formatLabel;
10
+ var _locales = require("./locales.js");
11
+ /**
12
+ * Translations come from the widget config (`translations[locale][key]`), with
13
+ * the widget's default locale as the fallback chain — same lookup as the web
14
+ * widget's `t()` in `client/src/widget/App.tsx`.
15
+ */
16
+
17
+ /**
18
+ * Resolution order, most specific first: what the workspace configured for the
19
+ * active locale, what the SDK ships for it, then the same pair for the
20
+ * workspace's default locale, and finally the English built-in. Dashboard
21
+ * copy always outranks a bundled translation.
22
+ */
23
+ function createTranslator(config, locale) {
24
+ const defaultLocale = config?.defaultLocale || 'en';
25
+ const active = (0, _locales.baseLanguage)(locale);
26
+ const fallbackLocale = (0, _locales.baseLanguage)(defaultLocale);
27
+ return (key, fallback) => config?.translations?.[locale]?.[key] || config?.translations?.[active]?.[key] || _locales.BUNDLED_TRANSLATIONS[active]?.[key] || config?.translations?.[defaultLocale]?.[key] || _locales.BUNDLED_TRANSLATIONS[fallbackLocale]?.[key] || fallback;
28
+ }
29
+ const DEFAULT_LABELS = exports.DEFAULT_LABELS = {
30
+ back: 'Back',
31
+ loading: 'Loading...',
32
+ loadEarlier: 'Load earlier messages',
33
+ emptyConversation: 'Send a message to start the conversation',
34
+ messagePlaceholder: 'Type a message...',
35
+ attachFile: 'Attach file',
36
+ failedToSend: 'Failed to send',
37
+ thinking: 'Typing',
38
+ messages: 'Messages',
39
+ noMessages: 'No messages yet',
40
+ historyHidden: 'Conversation history is hidden',
41
+ startBelow: 'Start a conversation below',
42
+ preChatTitle: 'Before we chat',
43
+ preChatSubtitle: 'Let us know a bit about you so we can help you better.',
44
+ preChatSkip: 'Skip',
45
+ preChatSubmit: 'Start chat',
46
+ viewPreviousConversations: 'View previous conversations',
47
+ homeRecentTitle: 'Recent',
48
+ homeViewAllCount: 'View all ({count})',
49
+ homeNoConversations: 'Your conversations will show up here',
50
+ homeStatusOnline: "We're online",
51
+ homeStatusAway: "We're away",
52
+ unreadBadge: '{count} unread',
53
+ team: 'Team',
54
+ home: 'Home',
55
+ close: 'Close',
56
+ retry: 'Retry',
57
+ connectionError: 'We could not load the chat. Please try again.',
58
+ connecting: 'Connecting you to the team',
59
+ // Terminal errors — no Retry, nothing the visitor can fix from here.
60
+ chatUnavailable: 'Chat is not available right now.',
61
+ identityVerificationError: "We couldn't verify your account. Please sign in again.",
62
+ // Shown if the widget's own UI hits a render error.
63
+ widgetCrashed: 'Something went wrong.',
64
+ // Relative timestamps on the conversation lists.
65
+ timeJustNow: 'Just now',
66
+ timeMinutes: '{count}m',
67
+ timeHours: '{count}h',
68
+ timeDays: '{count}d',
69
+ timeMonths: '{count}mo',
70
+ timeYears: '{count}y',
71
+ // Day separators inside a thread.
72
+ today: 'Today',
73
+ yesterday: 'Yesterday',
74
+ conversationUpdated: 'Conversation updated',
75
+ // Forms.
76
+ procedureSend: 'Send details',
77
+ procedureSent: 'Sent',
78
+ fieldRequired: '{field} is required',
79
+ invalidEmail: 'Enter a valid email address',
80
+ working: 'Working...',
81
+ // Proactive card.
82
+ outboundTitle: 'New update',
83
+ outboundCta: 'Learn more',
84
+ dismiss: 'Dismiss',
85
+ // Rich blocks an agent can send.
86
+ blockService: 'Service',
87
+ blockProduct: 'Product',
88
+ blockChooseTime: 'Choose a time',
89
+ blockProfessional: 'Professional',
90
+ blockPriceOffer: 'Price offer'
91
+ };
92
+ /**
93
+ * Fill `{token}` placeholders in a translated string. Interpolation belongs in
94
+ * the string layer so translators keep control of word order.
95
+ */
96
+ function formatLabel(template, values) {
97
+ return template.replace(/\{(\w+)\}/g, (match, key) => key in values ? String(values[key]) : match);
98
+ }
99
+ function buildLabels(translate) {
100
+ const labels = {};
101
+ Object.keys(DEFAULT_LABELS).forEach(key => {
102
+ labels[key] = translate(key, DEFAULT_LABELS[key]);
103
+ });
104
+ return labels;
105
+ }
106
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_locales","require","createTranslator","config","locale","defaultLocale","active","baseLanguage","fallbackLocale","key","fallback","translations","BUNDLED_TRANSLATIONS","DEFAULT_LABELS","exports","back","loading","loadEarlier","emptyConversation","messagePlaceholder","attachFile","failedToSend","thinking","messages","noMessages","historyHidden","startBelow","preChatTitle","preChatSubtitle","preChatSkip","preChatSubmit","viewPreviousConversations","homeRecentTitle","homeViewAllCount","homeNoConversations","homeStatusOnline","homeStatusAway","unreadBadge","team","home","close","retry","connectionError","connecting","chatUnavailable","identityVerificationError","widgetCrashed","timeJustNow","timeMinutes","timeHours","timeDays","timeMonths","timeYears","today","yesterday","conversationUpdated","procedureSend","procedureSent","fieldRequired","invalidEmail","working","outboundTitle","outboundCta","dismiss","blockService","blockProduct","blockChooseTime","blockProfessional","blockPriceOffer","formatLabel","template","values","replace","match","String","buildLabels","translate","labels","Object","keys","forEach"],"sourceRoot":"../../src","sources":["i18n.ts"],"mappings":";;;;;;;;;AAMA,IAAAA,QAAA,GAAAC,OAAA;AANA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAACC,MAA2B,EAAEC,MAAc,EAAc;EACxF,MAAMC,aAAa,GAAGF,MAAM,EAAEE,aAAa,IAAI,IAAI;EACnD,MAAMC,MAAM,GAAG,IAAAC,qBAAY,EAACH,MAAM,CAAC;EACnC,MAAMI,cAAc,GAAG,IAAAD,qBAAY,EAACF,aAAa,CAAC;EAElD,OAAO,CAACI,GAAG,EAAEC,QAAQ,KACnBP,MAAM,EAAEQ,YAAY,GAAGP,MAAM,CAAC,GAAGK,GAAG,CAAC,IACrCN,MAAM,EAAEQ,YAAY,GAAGL,MAAM,CAAC,GAAGG,GAAG,CAAC,IACrCG,6BAAoB,CAACN,MAAM,CAAC,GAAGG,GAAG,CAAgC,IAClEN,MAAM,EAAEQ,YAAY,GAAGN,aAAa,CAAC,GAAGI,GAAG,CAAC,IAC5CG,6BAAoB,CAACJ,cAAc,CAAC,GAAGC,GAAG,CAAgC,IAC1EC,QAAQ;AACZ;AAEO,MAAMG,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG;EAC5BE,IAAI,EAAE,MAAM;EACZC,OAAO,EAAE,YAAY;EACrBC,WAAW,EAAE,uBAAuB;EACpCC,iBAAiB,EAAE,0CAA0C;EAC7DC,kBAAkB,EAAE,mBAAmB;EACvCC,UAAU,EAAE,aAAa;EACzBC,YAAY,EAAE,gBAAgB;EAC9BC,QAAQ,EAAE,QAAQ;EAClBC,QAAQ,EAAE,UAAU;EACpBC,UAAU,EAAE,iBAAiB;EAC7BC,aAAa,EAAE,gCAAgC;EAC/CC,UAAU,EAAE,4BAA4B;EACxCC,YAAY,EAAE,gBAAgB;EAC9BC,eAAe,EAAE,wDAAwD;EACzEC,WAAW,EAAE,MA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ACvDA,GAAG,IAAI8D,MAAM,GAAGG,MAAM,CAACH,MAAM,CAAC9D,GAAG,CAAC,CAAC,GAAGgE,KACxC,CAAC;AACH;AAEO,SAASE,WAAWA,CAACC,SAAqB,EAA4B;EAC3E,MAAMC,MAAM,GAAG,CAAC,CAA6B;EAC5CC,MAAM,CAACC,IAAI,CAAClE,cAAc,CAAC,CAAgBmE,OAAO,CAAEvE,GAAG,IAAK;IAC3DoE,MAAM,CAACpE,GAAG,CAAC,GAAGmE,SAAS,CAACnE,GAAG,EAAEI,cAAc,CAACJ,GAAG,CAAC,CAAC;EACnD,CAAC,CAAC;EACF,OAAOoE,MAAM;AACf","ignoreList":[]}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "DEFAULT_BASE_URL", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _types.DEFAULT_BASE_URL;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "Events", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _events.RepzoWidgetEvents;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "RepzoWidgetError", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _client.RepzoWidgetError;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "RepzoWidgetEvents", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _events.RepzoWidgetEvents;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "RepzoWidgetLauncher", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _Launcher.Launcher;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "RepzoWidgetProvider", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _WidgetProvider.RepzoWidgetProvider;
40
+ }
41
+ });
42
+ exports.default = exports.Space = void 0;
43
+ Object.defineProperty(exports, "useWidgetState", {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _useWidgetState.useWidgetState;
47
+ }
48
+ });
49
+ var _controller = require("./controller.js");
50
+ var _events = require("./events.js");
51
+ var _storage = require("./storage.js");
52
+ var _WidgetProvider = require("./ui/WidgetProvider.js");
53
+ var _Launcher = require("./ui/components/Launcher.js");
54
+ var _client = require("./api/client.js");
55
+ var _types = require("./types.js");
56
+ var _useWidgetState = require("./state/use-widget-state.js");
57
+ /**
58
+ * @repzo/widget-react-native — the Repzo chat widget for React Native.
59
+ *
60
+ * Pure JavaScript: no native modules, no config plugin, no pod install. The
61
+ * public surface mirrors `@intercom/intercom-react-native` so swapping the two
62
+ * is a rename at each call site.
63
+ */
64
+ /** Spaces the widget can open into — the analogue of Intercom's `Space`. */
65
+ let Space = exports.Space = /*#__PURE__*/function (Space) {
66
+ Space["home"] = "home";
67
+ Space["messages"] = "messages";
68
+ return Space;
69
+ }({});
70
+ const RepzoWidget = {
71
+ boot: options => _controller.controller.store.boot(options),
72
+ loginUnidentifiedUser: () => _controller.controller.store.loginUnidentifiedUser(),
73
+ loginUserWithUserAttributes: user => _controller.controller.store.loginUserWithUserAttributes(user),
74
+ updateUser: attributes => _controller.controller.store.updateUser(attributes),
75
+ logout: () => _controller.controller.store.logout(),
76
+ present: async () => {
77
+ _controller.controller.store.present();
78
+ },
79
+ presentSpace: async space => {
80
+ _controller.controller.store.present(space);
81
+ },
82
+ presentConversation: conversationId => _controller.controller.store.openConversation(conversationId),
83
+ hide: async () => {
84
+ _controller.controller.store.hide();
85
+ },
86
+ getUnreadConversationCount: async () => Object.values(_controller.controller.store.getState().unreadByConversation).filter(count => count > 0).length,
87
+ getUnreadMessageCount: async () => _controller.controller.store.getState().unreadCount,
88
+ logEvent: async (eventName, metadata) => {
89
+ _controller.controller.store.track(eventName, metadata ?? {});
90
+ },
91
+ setLocale: locale => _controller.controller.store.setLocale(locale),
92
+ addEventListener: (event, listener) => _controller.controller.events.addListener(event, listener),
93
+ setStorageAdapter: adapter => (0, _storage.setStorageAdapter)(adapter),
94
+ setSecureStorageAdapter: adapter => (0, _storage.setSecureStorageAdapter)(adapter),
95
+ setPushToken: options => _controller.controller.store.push.setManualToken(options)
96
+ };
97
+ var _default = exports.default = RepzoWidget;
98
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_controller","require","_events","_storage","_WidgetProvider","_Launcher","_client","_types","_useWidgetState","Space","exports","RepzoWidget","boot","options","controller","store","loginUnidentifiedUser","loginUserWithUserAttributes","user","updateUser","attributes","logout","present","presentSpace","space","presentConversation","conversationId","openConversation","hide","getUnreadConversationCount","Object","values","getState","unreadByConversation","filter","count","length","getUnreadMessageCount","unreadCount","logEvent","eventName","metadata","track","setLocale","locale","addEventListener","event","listener","events","addListener","setStorageAdapter","adapter","setSecureStorageAdapter","setPushToken","push","setManualToken","_default","default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AASA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAEA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAP,OAAA;AAxBA;AACA;AACA;AACA;AACA;AACA;AACA;AA+CA;AAAA,IACYQ,KAAK,GAAAC,OAAA,CAAAD,KAAA,0BAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAAA,OAALA,KAAK;AAAA;AAiGjB,MAAME,WAA4B,GAAG;EACnCC,IAAI,EAAGC,OAAO,IAAKC,sBAAU,CAACC,KAAK,CAACH,IAAI,CAACC,OAAO,CAAC;EAEjDG,qBAAqB,EAAEA,CAAA,KAAMF,sBAAU,CAACC,KAAK,CAACC,qBAAqB,CAAC,CAAC;EAErEC,2BAA2B,EAAGC,IAAI,IAAKJ,sBAAU,CAACC,KAAK,CAACE,2B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ACC,WAAW,CAACH,KAAK,EAAEC,QAAQ,CAAC;EAErFG,iBAAiB,EAAGC,OAAO,IAAK,IAAAD,0BAAiB,EAACC,OAAO,CAAC;EAE1DC,uBAAuB,EAAGD,OAAO,IAAK,IAAAC,gCAAuB,EAACD,OAAO,CAAC;EAEtEE,YAAY,EAAGxC,OAAO,IAAKC,sBAAU,CAACC,KAAK,CAACuC,IAAI,CAACC,cAAc,CAAC1C,OAAO;AACzE,CAAC;AAAC,IAAA2C,QAAA,GAAA9C,OAAA,CAAA+C,OAAA,GAEa9C,WAAW","ignoreList":[]}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BUNDLED_TRANSLATIONS = void 0;
7
+ exports.baseLanguage = baseLanguage;
8
+ /**
9
+ * Translations bundled with the SDK.
10
+ *
11
+ * A workspace can still override any key from the dashboard — those win. These
12
+ * exist so a widget running in a supported language is usable out of the box,
13
+ * instead of falling back to English for every string an admin has not filled
14
+ * in by hand.
15
+ *
16
+ * Keys mirror `DEFAULT_LABELS` in `./i18n`; `{token}` placeholders must be kept
17
+ * so word order stays under the translator's control.
18
+ */
19
+
20
+ const ar = {
21
+ back: 'رجوع',
22
+ loading: 'جارٍ التحميل...',
23
+ loadEarlier: 'تحميل الرسائل السابقة',
24
+ emptyConversation: 'أرسل رسالة لبدء المحادثة',
25
+ messagePlaceholder: 'اكتب رسالة...',
26
+ attachFile: 'إرفاق ملف',
27
+ failedToSend: 'تعذر الإرسال',
28
+ thinking: 'يكتب',
29
+ messages: 'الرسائل',
30
+ noMessages: 'لا توجد رسائل بعد',
31
+ historyHidden: 'سجل المحادثات مخفي',
32
+ startBelow: 'ابدأ محادثة من الأسفل',
33
+ preChatTitle: 'قبل أن نبدأ',
34
+ preChatSubtitle: 'أخبرنا قليلاً عنك حتى نتمكن من مساعدتك بشكل أفضل.',
35
+ preChatSkip: 'تخطٍ',
36
+ preChatSubmit: 'ابدأ المحادثة',
37
+ viewPreviousConversations: 'عرض المحادثات السابقة',
38
+ homeRecentTitle: 'الأحدث',
39
+ homeViewAllCount: 'عرض الكل ({count})',
40
+ homeNoConversations: 'ستظهر محادثاتك هنا',
41
+ homeStatusOnline: 'نحن متصلون',
42
+ homeStatusAway: 'نحن غير متصلين',
43
+ unreadBadge: '{count} غير مقروءة',
44
+ team: 'الفريق',
45
+ home: 'الرئيسية',
46
+ close: 'إغلاق',
47
+ retry: 'إعادة المحاولة',
48
+ connectionError: 'تعذر تحميل المحادثة. يرجى المحاولة مرة أخرى.',
49
+ connecting: 'جارٍ توصيلك بالفريق',
50
+ chatUnavailable: 'المحادثة غير متاحة حاليًا.',
51
+ identityVerificationError: 'تعذر التحقق من حسابك. يرجى تسجيل الدخول مرة أخرى.',
52
+ widgetCrashed: 'حدث خطأ ما.',
53
+ // Kept short: these sit in a tight row beside the agent's name.
54
+ timeJustNow: 'الآن',
55
+ timeMinutes: '{count} د',
56
+ timeHours: '{count} س',
57
+ timeDays: '{count} ي',
58
+ timeMonths: '{count} شهر',
59
+ timeYears: '{count} سنة',
60
+ today: 'اليوم',
61
+ yesterday: 'أمس',
62
+ conversationUpdated: 'تم تحديث المحادثة',
63
+ procedureSend: 'إرسال التفاصيل',
64
+ procedureSent: 'تم الإرسال',
65
+ fieldRequired: '{field} مطلوب',
66
+ invalidEmail: 'أدخل بريدًا إلكترونيًا صالحًا',
67
+ working: 'جارٍ العمل...',
68
+ outboundTitle: 'تحديث جديد',
69
+ outboundCta: 'اعرف المزيد',
70
+ dismiss: 'تجاهل',
71
+ blockService: 'خدمة',
72
+ blockProduct: 'منتج',
73
+ blockChooseTime: 'اختر وقتًا',
74
+ blockProfessional: 'الموظف',
75
+ blockPriceOffer: 'عرض سعر'
76
+ };
77
+ const BUNDLED_TRANSLATIONS = exports.BUNDLED_TRANSLATIONS = {
78
+ ar
79
+ };
80
+
81
+ /** `ar-JO`, `ar_SA` and `AR` all resolve to the `ar` bundle. */
82
+ function baseLanguage(locale) {
83
+ return (locale ?? '').split(/[-_]/)[0]?.toLowerCase() ?? '';
84
+ }
85
+ //# sourceMappingURL=locales.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ar","back","loading","loadEarlier","emptyConversation","messagePlaceholder","attachFile","failedToSend","thinking","messages","noMessages","historyHidden","startBelow","preChatTitle","preChatSubtitle","preChatSkip","preChatSubmit","viewPreviousConversations","homeRecentTitle","homeViewAllCount","homeNoConversations","homeStatusOnline","homeStatusAway","unreadBadge","team","home","close","retry","connectionError","connecting","chatUnavailable","identityVerificationError","widgetCrashed","timeJustNow","timeMinutes","timeHours","timeDays","timeMonths","timeYears","today","yesterday","conversationUpdated","procedureSend","procedureSent","fieldRequired","invalidEmail","working","outboundTitle","outboundCta","dismiss","blockService","blockProduct","blockChooseTime","blockProfessional","blockPriceOffer","BUNDLED_TRANSLATIONS","exports","baseLanguage","locale","split","toLowerCase"],"sourceRoot":"../../src","sources":["locales.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,MAAMA,EAAY,GAAG;EACnBC,IAAI,EAAE,MAAM;EACZC,OAAO,EAAE,iBAAiB;EAC1BC,WAAW,EAAE,uBAAuB;EACpCC,iBAAiB,EAAE,0BAA0B;EAC7CC,kBAAkB,EAAE,eAAe;EACnCC,UAAU,EAAE,WAAW;EACvBC,YAAY,EAAE,cAAc;EAC5BC,QAAQ,EAAE,MAAM;EAChBC,QAAQ,EAAE,SAAS;EACnBC,UAAU,EAAE,mBAAmB;EAC/BC,aAAa,EAAE,oBAAoB;EACnCC,UAAU,EAAE,uBAAuB;EACnCC,YAAY,EAAE,aAAa;EAC3BC,eAAe,EAAE,mDAAmD;EACpEC,WAAW,EAAE,MAAM;EACnBC,aAAa,EAAE,eAAe;EAC9BC,yBAAyB,EAAE,uBAAuB;EAClDC,eAAe,EAAE,QAAQ;EACzBC,gBAAgB,EAAE,oBAAoB;EACtCC,mBAAmB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s"}
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PushManager = void 0;
7
+ var _reactNative = require("react-native");
8
+ /**
9
+ * FCM push notifications — optional.
10
+ *
11
+ * Powered by the HOST app's `@react-native-firebase/messaging` native module,
12
+ * loaded via a dynamic require so the SDK itself stays pure JavaScript. Hosts
13
+ * without Firebase installed get a warn-once no-op; hosts that can't install
14
+ * it can still register a token manually through `RepzoWidget.setPushToken()`.
15
+ *
16
+ * Supports both RNFB API generations: the modular API (`getMessaging()` etc.,
17
+ * the only one left in v26+) and the legacy namespaced `messaging()` factory.
18
+ *
19
+ * The Workstation channel must have its push provider set to FCM — with
20
+ * OneSignal selected these registrations are stored but unused.
21
+ */
22
+
23
+ /** Version-agnostic view over the host's Firebase messaging module. */
24
+
25
+ function resolveMessaging() {
26
+ try {
27
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require
28
+ const mod = require('@react-native-firebase/messaging');
29
+
30
+ // Modular API — the only one in RNFB v26+ (the namespaced default export
31
+ // was removed). Every call takes the messaging instance as its first arg.
32
+ if (typeof mod?.getMessaging === 'function') {
33
+ const instance = mod.getMessaging();
34
+ return {
35
+ requestPermission: () => mod.requestPermission(instance),
36
+ registerDeviceForRemoteMessages: () => typeof mod.registerDeviceForRemoteMessages === 'function' ? mod.registerDeviceForRemoteMessages(instance) : Promise.resolve(),
37
+ getToken: () => mod.getToken(instance),
38
+ onTokenRefresh: cb => mod.onTokenRefresh(instance, cb),
39
+ onNotificationOpenedApp: cb => mod.onNotificationOpenedApp(instance, cb),
40
+ getInitialNotification: () => mod.getInitialNotification(instance)
41
+ };
42
+ }
43
+
44
+ // Legacy namespaced API (RNFB <= v22): default export is a factory.
45
+ const factory = mod?.default ?? mod;
46
+ if (typeof factory !== 'function') return null;
47
+ const instance = factory();
48
+ if (!instance) return null;
49
+ return {
50
+ requestPermission: () => instance.requestPermission?.() ?? Promise.resolve(),
51
+ registerDeviceForRemoteMessages: () => typeof instance.registerDeviceForRemoteMessages === 'function' ? instance.registerDeviceForRemoteMessages() : Promise.resolve(),
52
+ getToken: () => instance.getToken(),
53
+ onTokenRefresh: cb => instance.onTokenRefresh?.(cb),
54
+ onNotificationOpenedApp: cb => instance.onNotificationOpenedApp?.(cb),
55
+ getInitialNotification: () => instance.getInitialNotification?.() ?? Promise.resolve(null)
56
+ };
57
+ } catch {
58
+ return null;
59
+ }
60
+ }
61
+ class PushManager {
62
+ options = {};
63
+ listenersWired = false;
64
+ lastToken = null;
65
+ manualToken = null;
66
+ warnedMissingModule = false;
67
+
68
+ /** False while signed out — token refreshes must not register anywhere. */
69
+ active = false;
70
+
71
+ /** Registrations still on the wire; unregister() waits for them. */
72
+ inflight = new Set();
73
+ constructor(client, openConversation) {
74
+ this.client = client;
75
+ this.openConversation = openConversation;
76
+ }
77
+
78
+ /** Remember the boot options; actual work happens in start() post-init. */
79
+ configure(options) {
80
+ this.options = options ?? {};
81
+ }
82
+
83
+ /**
84
+ * Called after every successful session init — the widget token is valid
85
+ * from here. Re-running after a login switch re-registers the token under
86
+ * the new identity (the server upsert moves it).
87
+ */
88
+ async start() {
89
+ this.active = true;
90
+ if (this.manualToken) {
91
+ await this.register(this.manualToken);
92
+ }
93
+ if (!this.options.enabled) return;
94
+ const messaging = resolveMessaging();
95
+ if (!messaging) {
96
+ if (!this.warnedMissingModule) {
97
+ this.warnedMissingModule = true;
98
+ console.warn('[repzo-widget] push is enabled but @react-native-firebase/messaging is not installed — ' + 'install it in the app, or provide a token via RepzoWidget.setPushToken()');
99
+ }
100
+ return;
101
+ }
102
+ try {
103
+ if (this.options.requestPermission !== false) {
104
+ // A denial isn't an error: getToken still succeeds, the OS just
105
+ // won't display anything until the user flips the setting.
106
+ await messaging.requestPermission();
107
+ }
108
+ } catch {
109
+ // Permission prompt unavailable (e.g. older Android) — keep going.
110
+ }
111
+
112
+ // Wired once and kept for the app's lifetime — taps must work even while
113
+ // the widget UI is closed, so there is deliberately no teardown.
114
+ if (!this.listenersWired) {
115
+ this.listenersWired = true;
116
+ this.wireTapHandlers(messaging);
117
+ messaging.onTokenRefresh(token => {
118
+ void this.register({
119
+ token
120
+ });
121
+ });
122
+ }
123
+
124
+ // iOS needs the APNs registration before an FCM token exists; RNFB
125
+ // auto-registers by default, this covers hosts that turned that off.
126
+ try {
127
+ await messaging.registerDeviceForRemoteMessages();
128
+ } catch {
129
+ // Already registered, or simulator without push support — getToken
130
+ // decides whether that actually matters.
131
+ }
132
+ try {
133
+ const token = await messaging.getToken();
134
+ if (token) await this.register({
135
+ token
136
+ });
137
+ } catch (error) {
138
+ console.warn('[repzo-widget] push token fetch failed', error);
139
+ }
140
+ }
141
+
142
+ /** Host-supplied token for apps without the Firebase module. */
143
+ async setManualToken(manual) {
144
+ this.manualToken = manual;
145
+ // Before boot (or after logout) it is only remembered; start() sends it.
146
+ if (this.active) await this.register(manual);
147
+ }
148
+
149
+ /**
150
+ * Called by logout with the session's token captured up front: the DELETE
151
+ * is authenticated with it explicitly and never triggers a re-init.
152
+ * Waits for an in-flight registration first so its token is not missed.
153
+ */
154
+ async unregister(authToken) {
155
+ this.active = false;
156
+ await Promise.all([...this.inflight]);
157
+ const token = this.lastToken;
158
+ this.lastToken = null;
159
+ if (!token || !authToken) return;
160
+ try {
161
+ await this.client.removePushToken(token, {
162
+ authToken,
163
+ skipReauth: true
164
+ });
165
+ } catch (error) {
166
+ console.warn('[repzo-widget] push token removal failed', error);
167
+ }
168
+ }
169
+ register(manual) {
170
+ if (!this.active) return Promise.resolve();
171
+ const run = this.client.registerPushToken({
172
+ token: manual.token,
173
+ platform: manual.platform ?? (_reactNative.Platform.OS === 'ios' ? 'ios' : 'android'),
174
+ bundleId: manual.bundleId ?? this.options.bundleId ?? undefined
175
+ }).then(() => {
176
+ this.lastToken = manual.token;
177
+ }, error => {
178
+ console.warn('[repzo-widget] push token registration failed', error);
179
+ }).finally(() => {
180
+ this.inflight.delete(run);
181
+ });
182
+ this.inflight.add(run);
183
+ return run;
184
+ }
185
+ wireTapHandlers(messaging) {
186
+ // Background → tapped: the app was alive, just not in front.
187
+ messaging.onNotificationOpenedApp(remoteMessage => {
188
+ this.handleTap(remoteMessage);
189
+ });
190
+
191
+ // Killed → tapped: the click that launched the app.
192
+ void messaging.getInitialNotification().then(remoteMessage => {
193
+ if (remoteMessage) this.handleTap(remoteMessage);
194
+ }).catch(() => {});
195
+ }
196
+
197
+ /** Only widget pushes are ours — host app notifications pass through. */
198
+ handleTap(remoteMessage) {
199
+ const data = remoteMessage?.data;
200
+ if (data?.document_type !== 'widget_message') return;
201
+ const conversationId = data?.document_id;
202
+ if (typeof conversationId === 'string' && conversationId) {
203
+ this.openConversation(conversationId);
204
+ }
205
+ }
206
+ }
207
+ exports.PushManager = PushManager;
208
+ //# sourceMappingURL=push-notifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","resolveMessaging","mod","getMessaging","instance","requestPermission","registerDeviceForRemoteMessages","Promise","resolve","getToken","onTokenRefresh","cb","onNotificationOpenedApp","getInitialNotification","factory","default","PushManager","options","listenersWired","lastToken","manualToken","warnedMissingModule","active","inflight","Set","constructor","client","openConversation","configure","start","register","enabled","messaging","console","warn","wireTapHandlers","token","error","setManualToken","manual","unregister","authToken","all","removePushToken","skipReauth","run","registerPushToken","platform","Platform","OS","bundleId","undefined","then","finally","delete","add","remoteMessage","handleTap","catch","data","document_type","conversationId","document_id","exports"],"sourceRoot":"../../../src","sources":["push/push-notifications.ts"],"mappings":";;;;;;AAeA,IAAAA,YAAA,GAAAC,OAAA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA2BA;;AAUA,SAASC,gBAAgBA,CAAA,EAA2B;EAClD,IAAI;IACF;IACA,MAAMC,GAAG,GAAGF,OAAO,CAAC,kCAAkC,CAAC;;IAEvD;IACA;IACA,IAAI,OAAOE,GAAG,EAAEC,YAAY,KAAK,UA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,CAACpB,uBAAuB,CAAE4C,aAAkB,IAAK;MACxD,IAAI,CAACC,SAAS,CAACD,aAAa,CAAC;IAC/B,CAAC,CAAC;;IAEF;IACA,KAAKxB,SAAS,CACXnB,sBAAsB,CAAC,CAAC,CACxBuC,IAAI,CAAEI,aAAkB,IAAK;MAC5B,IAAIA,aAAa,EAAE,IAAI,CAACC,SAAS,CAACD,aAAa,CAAC;IAClD,CAAC,CAAC,CACDE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;EACpB;;EAEA;EACQD,SAASA,CAACD,aAAkB,EAAE;IACpC,MAAMG,IAAI,GAAGH,aAAa,EAAEG,IAAI;IAChC,IAAIA,IAAI,EAAEC,aAAa,KAAK,gBAAgB,EAAE;IAC9C,MAAMC,cAAc,GAAGF,IAAI,EAAEG,WAAW;IACxC,IAAI,OAAOD,cAAc,KAAK,QAAQ,IAAIA,cAAc,EAAE;MACxD,IAAI,CAAClC,gBAAgB,CAACkC,cAAc,CAAC;IACvC;EACF;AACF;AAACE,OAAA,CAAA/C,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useWidgetState = useWidgetState;
7
+ exports.useWidgetStore = useWidgetStore;
8
+ var _react = require("react");
9
+ var _controller = require("../controller.js");
10
+ /**
11
+ * React binding for the store. The store lives in the controller singleton, so
12
+ * the widget keeps its session, SSE stream and unread count even when no
13
+ * component is mounted; this hook only subscribes to it.
14
+ */
15
+
16
+ function useWidgetState() {
17
+ const store = _controller.controller.store;
18
+ return (0, _react.useSyncExternalStore)(store.subscribe, store.getState, store.getState);
19
+ }
20
+ function useWidgetStore() {
21
+ return _controller.controller.store;
22
+ }
23
+ //# sourceMappingURL=use-widget-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_controller","useWidgetState","store","controller","useSyncExternalStore","subscribe","getState","useWidgetStore"],"sourceRoot":"../../../src","sources":["state/use-widget-state.ts"],"mappings":";;;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AARA;AACA;AACA;AACA;AACA;;AAQO,SAASE,cAAcA,CAAA,EAAgB;EAC5C,MAAMC,KAAK,GAAGC,sBAAU,CAACD,KAAK;EAC9B,OAAO,IAAAE,2BAAoB,EAACF,KAAK,CAACG,SAAS,EAAEH,KAAK,CAACI,QAAQ,EAAEJ,KAAK,CAACI,QAAQ,CAAC;AAC9E;AAEO,SAASC,cAAcA,CAAA,EAAgB;EAC5C,OAAOJ,sBAAU,CAACD,KAAK;AACzB","ignoreList":[]}