@livechatta/sdk 0.0.0-stage → 1.0.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 (246) hide show
  1. package/CHANGELOG.md +228 -0
  2. package/LICENSE +21 -0
  3. package/README.md +2558 -2
  4. package/bin/chatta.mjs +7 -0
  5. package/bin/lib/cli.d.mts +46 -0
  6. package/bin/lib/cli.mjs +2088 -0
  7. package/dist/cjs/livechatta.cjs.js +7259 -0
  8. package/dist/cjs/livechatta.cjs.js.map +1 -0
  9. package/dist/cjs/livechatta.cjs.min.js +2 -0
  10. package/dist/cjs/livechatta.cjs.min.js.map +1 -0
  11. package/dist/esm/livechatta.esm.js +7078 -0
  12. package/dist/esm/livechatta.esm.js.map +1 -0
  13. package/dist/esm/livechatta.esm.min.js +2 -0
  14. package/dist/esm/livechatta.esm.min.js.map +1 -0
  15. package/dist/platforms/android/LiveChattaClient.kt +367 -0
  16. package/dist/platforms/android/LiveChattaHttpAPI.kt +2630 -0
  17. package/dist/platforms/android/LiveChattaJson.kt +83 -0
  18. package/dist/platforms/android/LiveChattaModels.kt +22805 -0
  19. package/dist/platforms/android/LiveChattaSentFrom.kt +30 -0
  20. package/dist/platforms/android/LiveChattaSocketAPI.kt +2113 -0
  21. package/dist/platforms/android/LiveChattaTyped.kt +239 -0
  22. package/dist/platforms/android/LiveChattaWebView.kt +158 -0
  23. package/dist/platforms/angular/livechatta-bridge.service.d.ts +35 -0
  24. package/dist/platforms/angular/livechatta-bridge.service.js +1 -0
  25. package/dist/platforms/angular/livechatta-bridge.service.js.map +1 -0
  26. package/dist/platforms/angular/livechatta-embed.component.d.ts +46 -0
  27. package/dist/platforms/angular/livechatta-embed.component.js +1 -0
  28. package/dist/platforms/angular/livechatta-embed.component.js.map +1 -0
  29. package/dist/platforms/angular/livechatta.service.d.ts +66 -0
  30. package/dist/platforms/angular/livechatta.service.js +1 -0
  31. package/dist/platforms/angular/livechatta.service.js.map +1 -0
  32. package/dist/platforms/capacitor/CapacitorBridge.d.ts +27 -0
  33. package/dist/platforms/capacitor/CapacitorBridge.js +1 -0
  34. package/dist/platforms/capacitor/CapacitorBridge.js.map +1 -0
  35. package/dist/platforms/capacitor/CapacitorDeepLinks.d.ts +23 -0
  36. package/dist/platforms/capacitor/CapacitorDeepLinks.js +1 -0
  37. package/dist/platforms/capacitor/CapacitorDeepLinks.js.map +1 -0
  38. package/dist/platforms/capacitor/CapacitorPermissions.d.ts +29 -0
  39. package/dist/platforms/capacitor/CapacitorPermissions.js +1 -0
  40. package/dist/platforms/capacitor/CapacitorPermissions.js.map +1 -0
  41. package/dist/platforms/capacitor/CapacitorPush.d.ts +33 -0
  42. package/dist/platforms/capacitor/CapacitorPush.js +1 -0
  43. package/dist/platforms/capacitor/CapacitorPush.js.map +1 -0
  44. package/dist/platforms/capacitor/index.d.ts +24 -0
  45. package/dist/platforms/capacitor/index.js +1 -0
  46. package/dist/platforms/capacitor/index.js.map +1 -0
  47. package/dist/platforms/flutter/livechatta_client.dart +359 -0
  48. package/dist/platforms/flutter/livechatta_http_api.dart +1942 -0
  49. package/dist/platforms/flutter/livechatta_json.dart +57 -0
  50. package/dist/platforms/flutter/livechatta_models.dart +23531 -0
  51. package/dist/platforms/flutter/livechatta_sent_from.dart +35 -0
  52. package/dist/platforms/flutter/livechatta_socket_api.dart +1504 -0
  53. package/dist/platforms/flutter/livechatta_typed.dart +234 -0
  54. package/dist/platforms/flutter/livechatta_webview.dart +190 -0
  55. package/dist/platforms/ios/LiveChattaClient.swift +374 -0
  56. package/dist/platforms/ios/LiveChattaHttpAPI.swift +2431 -0
  57. package/dist/platforms/ios/LiveChattaJSON.swift +84 -0
  58. package/dist/platforms/ios/LiveChattaModels.swift +27050 -0
  59. package/dist/platforms/ios/LiveChattaSentFrom.swift +32 -0
  60. package/dist/platforms/ios/LiveChattaSocketAPI.swift +1446 -0
  61. package/dist/platforms/ios/LiveChattaTyped.swift +268 -0
  62. package/dist/platforms/ios/LiveChattaWebView.swift +191 -0
  63. package/dist/platforms/nuxt/LiveChattaView.d.ts +1 -0
  64. package/dist/platforms/nuxt/LiveChattaView.js +1 -0
  65. package/dist/platforms/nuxt/LiveChattaView.js.map +1 -0
  66. package/dist/platforms/nuxt/useChattaBridge.d.ts +9 -0
  67. package/dist/platforms/nuxt/useChattaBridge.js +1 -0
  68. package/dist/platforms/nuxt/useChattaBridge.js.map +1 -0
  69. package/dist/platforms/nuxt/useLiveChatta.d.ts +63 -0
  70. package/dist/platforms/nuxt/useLiveChatta.js +1 -0
  71. package/dist/platforms/nuxt/useLiveChatta.js.map +1 -0
  72. package/dist/platforms/react/LiveChattaView.d.ts +58 -0
  73. package/dist/platforms/react/LiveChattaView.js +1 -0
  74. package/dist/platforms/react/LiveChattaView.js.map +1 -0
  75. package/dist/platforms/react/useChattaBridge.d.ts +1 -0
  76. package/dist/platforms/react/useChattaBridge.js +1 -0
  77. package/dist/platforms/react/useChattaBridge.js.map +1 -0
  78. package/dist/platforms/react/useChattaDeepLink.d.ts +2 -0
  79. package/dist/platforms/react/useChattaDeepLink.js +1 -0
  80. package/dist/platforms/react/useChattaDeepLink.js.map +1 -0
  81. package/dist/platforms/react/useChattaPermissions.d.ts +9 -0
  82. package/dist/platforms/react/useChattaPermissions.js +1 -0
  83. package/dist/platforms/react/useChattaPermissions.js.map +1 -0
  84. package/dist/platforms/react/useChattaUnread.d.ts +1 -0
  85. package/dist/platforms/react/useChattaUnread.js +1 -0
  86. package/dist/platforms/react/useChattaUnread.js.map +1 -0
  87. package/dist/platforms/react/useLiveChatta.d.ts +29 -0
  88. package/dist/platforms/react/useLiveChatta.js +1 -0
  89. package/dist/platforms/react/useLiveChatta.js.map +1 -0
  90. package/dist/platforms/react-native/LiveChattaView.d.ts +52 -0
  91. package/dist/platforms/react-native/LiveChattaView.js +1 -0
  92. package/dist/platforms/react-native/LiveChattaView.js.map +1 -0
  93. package/dist/platforms/react-native/useChattaBridge.d.ts +12 -0
  94. package/dist/platforms/react-native/useChattaBridge.js +1 -0
  95. package/dist/platforms/react-native/useChattaBridge.js.map +1 -0
  96. package/dist/platforms/react-native/useLiveChatta.d.ts +29 -0
  97. package/dist/platforms/react-native/useLiveChatta.js +1 -0
  98. package/dist/platforms/react-native/useLiveChatta.js.map +1 -0
  99. package/dist/platforms/svelte/LiveChattaEmbed.d.ts +54 -0
  100. package/dist/platforms/svelte/LiveChattaEmbed.js +1 -0
  101. package/dist/platforms/svelte/LiveChattaEmbed.js.map +1 -0
  102. package/dist/platforms/svelte/chattaBridgeStore.d.ts +19 -0
  103. package/dist/platforms/svelte/chattaBridgeStore.js +1 -0
  104. package/dist/platforms/svelte/chattaBridgeStore.js.map +1 -0
  105. package/dist/platforms/svelte/useLiveChatta.d.ts +61 -0
  106. package/dist/platforms/svelte/useLiveChatta.js +1 -0
  107. package/dist/platforms/svelte/useLiveChatta.js.map +1 -0
  108. package/dist/platforms/tauri/TauriBridge.d.ts +34 -0
  109. package/dist/platforms/tauri/TauriBridge.js +1 -0
  110. package/dist/platforms/tauri/TauriBridge.js.map +1 -0
  111. package/dist/platforms/tauri/TauriDeepLinks.d.ts +29 -0
  112. package/dist/platforms/tauri/TauriDeepLinks.js +1 -0
  113. package/dist/platforms/tauri/TauriDeepLinks.js.map +1 -0
  114. package/dist/platforms/tauri/TauriPermissions.d.ts +21 -0
  115. package/dist/platforms/tauri/TauriPermissions.js +1 -0
  116. package/dist/platforms/tauri/TauriPermissions.js.map +1 -0
  117. package/dist/platforms/tauri/TauriUpdater.d.ts +31 -0
  118. package/dist/platforms/tauri/TauriUpdater.js +1 -0
  119. package/dist/platforms/tauri/TauriUpdater.js.map +1 -0
  120. package/dist/platforms/tauri/index.d.ts +22 -0
  121. package/dist/platforms/tauri/index.js +1 -0
  122. package/dist/platforms/tauri/index.js.map +1 -0
  123. package/dist/platforms/vue/LiveChattaView.d.ts +1 -0
  124. package/dist/platforms/vue/LiveChattaView.js +1 -0
  125. package/dist/platforms/vue/LiveChattaView.js.map +1 -0
  126. package/dist/platforms/vue/useChattaBridge.d.ts +11 -0
  127. package/dist/platforms/vue/useChattaBridge.js +1 -0
  128. package/dist/platforms/vue/useChattaBridge.js.map +1 -0
  129. package/dist/platforms/vue/useChattaDeepLink.d.ts +2 -0
  130. package/dist/platforms/vue/useChattaDeepLink.js +1 -0
  131. package/dist/platforms/vue/useChattaDeepLink.js.map +1 -0
  132. package/dist/platforms/vue/useChattaPermissions.d.ts +9 -0
  133. package/dist/platforms/vue/useChattaPermissions.js +1 -0
  134. package/dist/platforms/vue/useChattaPermissions.js.map +1 -0
  135. package/dist/platforms/vue/useChattaUnread.d.ts +8 -0
  136. package/dist/platforms/vue/useChattaUnread.js +1 -0
  137. package/dist/platforms/vue/useChattaUnread.js.map +1 -0
  138. package/dist/platforms/vue/useLiveChatta.d.ts +58 -0
  139. package/dist/platforms/vue/useLiveChatta.js +1 -0
  140. package/dist/platforms/vue/useLiveChatta.js.map +1 -0
  141. package/dist/platforms/web/LiveChattaEmbed.d.ts +94 -0
  142. package/dist/platforms/web/LiveChattaEmbed.js +1 -0
  143. package/dist/platforms/web/LiveChattaEmbed.js.map +1 -0
  144. package/dist/platforms/web/bridge.d.ts +8 -0
  145. package/dist/platforms/web/bridge.js +1 -0
  146. package/dist/platforms/web/bridge.js.map +1 -0
  147. package/dist/platforms/web/permissions.d.ts +8 -0
  148. package/dist/platforms/web/permissions.js +1 -0
  149. package/dist/platforms/web/permissions.js.map +1 -0
  150. package/dist/types/billing.d.ts +355 -0
  151. package/dist/types/billing.js +53 -0
  152. package/dist/types/billing.js.map +1 -0
  153. package/dist/types/calendar.d.ts +132 -0
  154. package/dist/types/calendar.js +15 -0
  155. package/dist/types/calendar.js.map +1 -0
  156. package/dist/types/chat-core.d.ts +901 -0
  157. package/dist/types/chat-core.js +98 -0
  158. package/dist/types/chat-core.js.map +1 -0
  159. package/dist/types/chat-features.d.ts +775 -0
  160. package/dist/types/chat-features.js +50 -0
  161. package/dist/types/chat-features.js.map +1 -0
  162. package/dist/types/content.d.ts +138 -0
  163. package/dist/types/content.js +2 -0
  164. package/dist/types/content.js.map +1 -0
  165. package/dist/types/core/AutoRefresh.d.ts +68 -0
  166. package/dist/types/core/Bridge.d.ts +124 -0
  167. package/dist/types/core/Config.d.ts +26 -0
  168. package/dist/types/core/DeepLinks.d.ts +38 -0
  169. package/dist/types/core/EventBus.d.ts +15 -0
  170. package/dist/types/core/GrantStore.d.ts +29 -0
  171. package/dist/types/core/LiveChatta.d.ts +128 -0
  172. package/dist/types/core/Permissions.d.ts +34 -0
  173. package/dist/types/core/TokenManager.d.ts +25 -0
  174. package/dist/types/core/events.d.ts +140 -0
  175. package/dist/types/csat.d.ts +110 -0
  176. package/dist/types/csat.js +12 -0
  177. package/dist/types/csat.js.map +1 -0
  178. package/dist/types/events.d.ts +242 -0
  179. package/dist/types/events.js +275 -0
  180. package/dist/types/events.js.map +1 -0
  181. package/dist/types/extras.d.ts +353 -0
  182. package/dist/types/extras.js +31 -0
  183. package/dist/types/extras.js.map +1 -0
  184. package/dist/types/http/HttpAPI.d.ts +944 -0
  185. package/dist/types/http/HttpTransport.d.ts +66 -0
  186. package/dist/types/http/incomingWebhook.d.ts +17 -0
  187. package/dist/types/incoming-webhooks.d.ts +78 -0
  188. package/dist/types/incoming-webhooks.js +16 -0
  189. package/dist/types/incoming-webhooks.js.map +1 -0
  190. package/dist/types/index.d.ts +15 -0
  191. package/dist/types/index.js +16 -0
  192. package/dist/types/index.js.map +1 -0
  193. package/dist/types/liveflex.d.ts +578 -0
  194. package/dist/types/liveflex.js +7 -0
  195. package/dist/types/liveflex.js.map +1 -0
  196. package/dist/types/models.d.ts +1753 -0
  197. package/dist/types/models.js +148 -0
  198. package/dist/types/models.js.map +1 -0
  199. package/dist/types/options.d.ts +190 -0
  200. package/dist/types/options.js +43 -0
  201. package/dist/types/options.js.map +1 -0
  202. package/dist/types/shared-channels.d.ts +236 -0
  203. package/dist/types/shared-channels.js +50 -0
  204. package/dist/types/shared-channels.js.map +1 -0
  205. package/dist/types/socket/SocketAPI.d.ts +1026 -0
  206. package/dist/types/socket/SocketTransport.d.ts +44 -0
  207. package/dist/types/types/billing.d.ts +355 -0
  208. package/dist/types/types/calendar.d.ts +132 -0
  209. package/dist/types/types/chat-core.d.ts +901 -0
  210. package/dist/types/types/chat-features.d.ts +775 -0
  211. package/dist/types/types/content.d.ts +138 -0
  212. package/dist/types/types/csat.d.ts +110 -0
  213. package/dist/types/types/events.d.ts +242 -0
  214. package/dist/types/types/extras.d.ts +353 -0
  215. package/dist/types/types/incoming-webhooks.d.ts +78 -0
  216. package/dist/types/types/index.d.ts +15 -0
  217. package/dist/types/types/liveflex.d.ts +578 -0
  218. package/dist/types/types/models.d.ts +1753 -0
  219. package/dist/types/types/options.d.ts +190 -0
  220. package/dist/types/types/shared-channels.d.ts +236 -0
  221. package/dist/types/types/workspace-gifs.d.ts +95 -0
  222. package/dist/types/types/workspace.d.ts +390 -0
  223. package/dist/types/ui/EmbedConfig.d.ts +38 -0
  224. package/dist/types/ui/EmbedUI.d.ts +44 -0
  225. package/dist/types/ui/Launcher.d.ts +122 -0
  226. package/dist/types/ui/brand.d.ts +27 -0
  227. package/dist/types/ui/embedMessages.d.ts +23 -0
  228. package/dist/types/ui/hours.d.ts +35 -0
  229. package/dist/types/ui/prechat.d.ts +35 -0
  230. package/dist/types/ui/widgetConfig.d.ts +4 -0
  231. package/dist/types/utils/crypto.d.ts +6 -0
  232. package/dist/types/utils/hmac.d.ts +40 -0
  233. package/dist/types/utils/permissions.d.ts +5 -0
  234. package/dist/types/utils/platform.d.ts +18 -0
  235. package/dist/types/utils/visitor.d.ts +2 -0
  236. package/dist/types/workspace-gifs.d.ts +95 -0
  237. package/dist/types/workspace-gifs.js +3 -0
  238. package/dist/types/workspace-gifs.js.map +1 -0
  239. package/dist/types/workspace.d.ts +390 -0
  240. package/dist/types/workspace.js +13 -0
  241. package/dist/types/workspace.js.map +1 -0
  242. package/dist/umd/livechatta.umd.js +7263 -0
  243. package/dist/umd/livechatta.umd.js.map +1 -0
  244. package/dist/umd/livechatta.umd.min.js +2 -0
  245. package/dist/umd/livechatta.umd.min.js.map +1 -0
  246. package/package.json +274 -4
@@ -0,0 +1,239 @@
1
+ package com.livechatta.sdk
2
+
3
+ import org.json.JSONObject
4
+
5
+ /** Result callback with a typed model instead of JSONObject: (model, errorMessage). */
6
+ typealias TypedCallback<T> = (T?, String?) -> Unit
7
+
8
+ internal fun <T> typedCallback(callback: TypedCallback<T>?, decode: (JSONObject) -> T): ApiCallback =
9
+ { json, error -> callback?.invoke(json?.let(decode), error) }
10
+
11
+ private fun messageItem(v: Any?): LiveChattaMessage? = LiveChattaJson.obj(v)?.let { LiveChattaMessage.fromJson(it) }
12
+
13
+ private fun activityItem(v: Any?): LiveChattaActivityNotification? = LiveChattaJson.obj(v)?.let { LiveChattaActivityNotification.fromJson(it) }
14
+
15
+ private fun sharedChannelItem(v: Any?): LiveChattaSharedChannelView? = LiveChattaJson.obj(v)?.let { LiveChattaSharedChannelView.fromJson(it) }
16
+
17
+ private fun meetingItem(v: Any?): LiveChattaOwnerMeeting? = LiveChattaJson.obj(v)?.let { LiveChattaOwnerMeeting.fromJson(it) }
18
+
19
+ /** Typed twin of the deprecated map-based sendMessage: the server sets senderId from the API key. */
20
+ @Suppress("DEPRECATION")
21
+ fun LiveChattaHttpAPI.sendMessageTyped(payload: LiveChattaSendMessagePayload, callback: TypedCallback<LiveChattaMessage>? = null) {
22
+ val body = payload.toJson().also { if (payload.senderId.isBlank()) it.remove("senderId") }
23
+ sendMessage(body, typedCallback(callback) { LiveChattaMessage.fromJson(it) })
24
+ }
25
+
26
+ /** Typed twin of the deprecated listSentMessages (conversationId is sent as chatMessageByConversationIds). */
27
+ @Suppress("DEPRECATION")
28
+ fun LiveChattaHttpAPI.listSentMessagesTyped(
29
+ query: LiveChattaSentMessagesQuery = LiveChattaSentMessagesQuery(),
30
+ callback: TypedCallback<LiveChattaPaginatedResult<LiveChattaMessage>>? = null,
31
+ ) {
32
+ val q = listOfNotNull(
33
+ query.conversationId?.let { "chatMessageByConversationIds" to it },
34
+ query.nextCursor?.let { "nextCursor" to it },
35
+ query.prevCursor?.let { "prevCursor" to it },
36
+ query.limit?.let { "limit" to it },
37
+ ).toMap()
38
+ listSentMessages(q, typedCallback(callback) { LiveChattaPaginatedResult.fromJson(it, ::messageItem) })
39
+ }
40
+
41
+ /** A link's meetings (owner token). */
42
+ fun LiveChattaHttpAPI.listMeetingsTyped(
43
+ linkId: String,
44
+ status: String? = null,
45
+ limit: Int? = null,
46
+ nextCursor: String? = null,
47
+ callback: TypedCallback<LiveChattaPaginatedResult<LiveChattaOwnerMeeting>>? = null,
48
+ ) = listMeetings(linkId, status, limit, nextCursor, typedCallback(callback) { LiveChattaPaginatedResult.fromJson(it, ::meetingItem) })
49
+
50
+ /** Schedule a meeting from a typed request (owner token); the same idempotencyKey replays the first result. */
51
+ fun LiveChattaHttpAPI.scheduleMeetingTyped(
52
+ payload: LiveChattaScheduleOwnerMeetingPayload,
53
+ idempotencyKey: String? = null,
54
+ callback: TypedCallback<LiveChattaScheduledOwnerMeeting>? = null,
55
+ ) = scheduleMeeting(payload.toJson(), idempotencyKey, typedCallback(callback) { LiveChattaScheduledOwnerMeeting.fromJson(it) })
56
+
57
+ /** Cancel a meeting (owner token); repeating it is safe. */
58
+ fun LiveChattaHttpAPI.cancelMeetingTyped(meetingId: String, reason: String? = null, callback: TypedCallback<LiveChattaOwnerMeetingCancelResult>? = null) =
59
+ cancelMeeting(meetingId, reason, typedCallback(callback) { LiveChattaOwnerMeetingCancelResult.fromJson(it) })
60
+
61
+ /** A link's meetings with the API key (/external/meetings). */
62
+ fun LiveChattaHttpAPI.listMeetingsWithKeyTyped(
63
+ linkId: String,
64
+ status: String? = null,
65
+ limit: Int? = null,
66
+ nextCursor: String? = null,
67
+ callback: TypedCallback<LiveChattaPaginatedResult<LiveChattaOwnerMeeting>>? = null,
68
+ ) = listMeetingsWithKey(linkId, status, limit, nextCursor, typedCallback(callback) { LiveChattaPaginatedResult.fromJson(it, ::meetingItem) })
69
+
70
+ /** Schedule a meeting with the API key (/external/meetings). */
71
+ fun LiveChattaHttpAPI.scheduleMeetingWithKeyTyped(
72
+ payload: LiveChattaScheduleOwnerMeetingPayload,
73
+ idempotencyKey: String? = null,
74
+ callback: TypedCallback<LiveChattaScheduledOwnerMeeting>? = null,
75
+ ) = scheduleMeetingWithKey(payload.toJson(), idempotencyKey, typedCallback(callback) { LiveChattaScheduledOwnerMeeting.fromJson(it) })
76
+
77
+ /** Cancel a meeting with the API key (/external/meetings). */
78
+ fun LiveChattaHttpAPI.cancelMeetingWithKeyTyped(meetingId: String, reason: String? = null, callback: TypedCallback<LiveChattaOwnerMeetingCancelResult>? = null) =
79
+ cancelMeetingWithKey(meetingId, reason, typedCallback(callback) { LiveChattaOwnerMeetingCancelResult.fromJson(it) })
80
+
81
+ /** Deliveries kept while you listen to a webhook (owner token). */
82
+ fun LiveChattaHttpAPI.readWebhookCaptureTyped(webhookId: String, after: Int = 0, callback: TypedCallback<LiveChattaWebhookCaptureView>? = null) =
83
+ readWebhookCapture(webhookId, after, typedCallback(callback) { LiveChattaWebhookCaptureView.fromJson(it) })
84
+
85
+ /** Your links as a typed page (member token). */
86
+ fun LiveChattaHttpAPI.listMyChatLinksTyped(query: Map<String, String>? = null, callback: TypedCallback<LiveChattaMyChatLinksPage>? = null) =
87
+ listMyChatLinks(query, typedCallback(callback) { LiveChattaMyChatLinksPage.fromJson(it) })
88
+
89
+ /** Your calendar sync status as a typed model (member token). */
90
+ fun LiveChattaHttpAPI.getCalendarSyncStatusTyped(callback: TypedCallback<LiveChattaCalendarSyncStatus>? = null) =
91
+ getCalendarSyncStatus(typedCallback(callback) { LiveChattaCalendarSyncStatus.fromJson(it) })
92
+
93
+ /** Busy blocks of members who share their calendar, as a typed model (member token). */
94
+ fun LiveChattaHttpAPI.getCalendarBusyTyped(userIds: List<String>, from: String, to: String, callback: TypedCallback<LiveChattaCalendarBusy>? = null) =
95
+ getCalendarBusy(userIds, from, to, typedCallback(callback) { LiveChattaCalendarBusy.fromJson(it) })
96
+
97
+ /** Mentions and reactions as a typed page (member or owner token). */
98
+ fun LiveChattaHttpAPI.listActivityTyped(query: Map<String, String>? = null, callback: TypedCallback<LiveChattaPaginatedResult<LiveChattaActivityNotification>>? = null) =
99
+ listActivity(query, typedCallback(callback) { LiveChattaPaginatedResult.fromJson(it, ::activityItem) })
100
+
101
+ /** GIF picker settings as a typed model (member or owner token; enabled=false when GIF search is off). */
102
+ fun LiveChattaHttpAPI.getGifConfigTyped(callback: TypedCallback<LiveChattaGifConfigView>? = null) =
103
+ getGifConfig(typedCallback(callback) { LiveChattaGifConfigView.fromJson(it) })
104
+
105
+ /** Search GIFs as a typed page; the LiveChatta pack answers when no provider is set; `source` is livechatta or provider (member or owner token). */
106
+ fun LiveChattaHttpAPI.searchGifsTyped(q: String? = null, nextCursor: String? = null, source: String? = null, callback: TypedCallback<LiveChattaGifPage>? = null) =
107
+ searchGifs(q, nextCursor, source, typedCallback(callback) { LiveChattaGifPage.fromJson(it) })
108
+
109
+ /** Trending GIFs as a typed page (member or owner token). */
110
+ fun LiveChattaHttpAPI.trendingGifsTyped(nextCursor: String? = null, source: String? = null, callback: TypedCallback<LiveChattaGifPage>? = null) =
111
+ trendingGifs(nextCursor, source, typedCallback(callback) { LiveChattaGifPage.fromJson(it) })
112
+
113
+ /** Tell the provider a GIF was sent, as a typed result (member or owner token). */
114
+ fun LiveChattaHttpAPI.registerGifShareTyped(provider: String, id: String, q: String? = null, callback: TypedCallback<LiveChattaGifShareResult>? = null) =
115
+ registerGifShare(provider, id, q, typedCallback(callback) { LiveChattaGifShareResult.fromJson(it) })
116
+
117
+ /** Report a GIF, as a typed result (member or owner token). */
118
+ fun LiveChattaHttpAPI.reportGifTyped(provider: String, id: String, reason: String, note: String? = null, messageId: String? = null, callback: TypedCallback<LiveChattaGifReportResult>? = null) =
119
+ reportGif(provider, id, reason, note, messageId, typedCallback(callback) { LiveChattaGifReportResult.fromJson(it) })
120
+
121
+ /** The incoming webhooks of a group or channel, as a typed page (API key). */
122
+ fun LiveChattaHttpAPI.listIncomingWebhooksTyped(conversationId: String, status: String? = null, limit: Int? = null, nextCursor: String? = null, callback: TypedCallback<LiveChattaIncomingWebhookPage>? = null) =
123
+ listIncomingWebhooks(conversationId, status, limit, nextCursor, typedCallback(callback) { LiveChattaIncomingWebhookPage.fromJson(it) })
124
+
125
+ /** Make an incoming webhook, as a typed result: the one-time `url` is in it (API key). */
126
+ fun LiveChattaHttpAPI.createIncomingWebhookTyped(conversationId: String, payload: LiveChattaCreateIncomingWebhookPayload, callback: TypedCallback<LiveChattaIncomingWebhook>? = null) =
127
+ createIncomingWebhook(conversationId, payload.toJson(), typedCallback(callback) { LiveChattaIncomingWebhook.fromJson(it) })
128
+
129
+ /** Rename an incoming webhook, as a typed result (API key). */
130
+ fun LiveChattaHttpAPI.updateIncomingWebhookTyped(conversationId: String, hookId: String, payload: LiveChattaUpdateIncomingWebhookPayload, callback: TypedCallback<LiveChattaIncomingWebhook>? = null) =
131
+ updateIncomingWebhook(conversationId, hookId, payload.toJson(), typedCallback(callback) { LiveChattaIncomingWebhook.fromJson(it) })
132
+
133
+ /** Swap an incoming webhook's secret, as a typed result: the new one-time `url` is in it (API key). */
134
+ fun LiveChattaHttpAPI.regenerateIncomingWebhookTyped(conversationId: String, hookId: String, callback: TypedCallback<LiveChattaIncomingWebhook>? = null) =
135
+ regenerateIncomingWebhook(conversationId, hookId, typedCallback(callback) { LiveChattaIncomingWebhook.fromJson(it) })
136
+
137
+ /** Revoke an incoming webhook, as a typed result (API key). */
138
+ fun LiveChattaHttpAPI.revokeIncomingWebhookTyped(conversationId: String, hookId: String, callback: TypedCallback<LiveChattaIncomingWebhook>? = null) =
139
+ revokeIncomingWebhook(conversationId, hookId, typedCallback(callback) { LiveChattaIncomingWebhook.fromJson(it) })
140
+
141
+ /** Fold the no-email guest this device held into the signed-in member, as a typed result (member token). */
142
+ fun LiveChattaHttpAPI.claimGuestTyped(guestToken: String, callback: TypedCallback<LiveChattaClaimGuestResult>? = null) =
143
+ claimGuest(guestToken, typedCallback(callback) { LiveChattaClaimGuestResult.fromJson(it) })
144
+
145
+ /** Invite another workspace to a channel, as a typed result: the single-use token is in it once (member token). */
146
+ fun LiveChattaHttpAPI.inviteSharedChannelTyped(chatLinkId: String, conversationId: String, partnerLinkCode: String? = null, expiresInHours: Int? = null, callback: TypedCallback<LiveChattaSharedChannelInviteResult>? = null) =
147
+ inviteSharedChannel(chatLinkId, conversationId, partnerLinkCode, expiresInHours, typedCallback(callback) { LiveChattaSharedChannelInviteResult.fromJson(it) })
148
+
149
+ /** Shares of your workspace as a typed page (member token). */
150
+ fun LiveChattaHttpAPI.listSharedChannelsTyped(chatLinkId: String, nextCursor: String? = null, callback: TypedCallback<LiveChattaSharedChannelPage>? = null) =
151
+ listSharedChannels(chatLinkId, nextCursor, typedCallback(callback) { LiveChattaSharedChannelPage.fromJson(it) })
152
+
153
+ /** What an invite link holds, as a typed model; looking does not use it up (member token). */
154
+ fun LiveChattaHttpAPI.previewSharedChannelInviteTyped(token: String, callback: TypedCallback<LiveChattaSharedChannelPreview>? = null) =
155
+ previewSharedChannelInvite(token, typedCallback(callback) { LiveChattaSharedChannelPreview.fromJson(it) })
156
+
157
+ /** People of your workspace to pick for a shared channel, as a typed page: name and handle only (member token). */
158
+ fun LiveChattaHttpAPI.listSharedChannelMembersTyped(chatLinkId: String, q: String? = null, sharedChannelId: String? = null, nextCursor: String? = null, callback: TypedCallback<LiveChattaSharedChannelMembersPage>? = null) =
159
+ listSharedChannelMembers(chatLinkId, q, sharedChannelId, nextCursor, typedCallback(callback) { LiveChattaSharedChannelMembersPage.fromJson(it) })
160
+
161
+ /** The shares of one of your channels as a typed page (member token). */
162
+ fun LiveChattaHttpAPI.getConversationSharedChannelsTyped(conversationId: String, chatLinkId: String, callback: TypedCallback<LiveChattaPaginatedResult<LiveChattaSharedChannelView>>? = null) =
163
+ getConversationSharedChannels(conversationId, chatLinkId, typedCallback(callback) { LiveChattaPaginatedResult.fromJson(it, ::sharedChannelItem) })
164
+
165
+ /** What your workspace may do in a shared channel, as a typed model (member token). */
166
+ fun LiveChattaHttpAPI.getSharedChannelPermissionsTyped(conversationId: String, chatLinkId: String, callback: TypedCallback<LiveChattaSharedConversationPermissions>? = null) =
167
+ getSharedChannelPermissions(conversationId, chatLinkId, typedCallback(callback) { LiveChattaSharedConversationPermissions.fromJson(it) })
168
+
169
+ /** Accept an invite sent to your link code, as a typed share (member token). */
170
+ fun LiveChattaHttpAPI.acceptSharedChannelTyped(sharedChannelId: String, chatLinkId: String, audience: String, memberIds: List<String>? = null, callback: TypedCallback<LiveChattaSharedChannelView>? = null) =
171
+ acceptSharedChannel(sharedChannelId, chatLinkId, audience, memberIds, typedCallback(callback) { LiveChattaSharedChannelView.fromJson(it) })
172
+
173
+ /** Accept a single-use invite link with its token, as a typed share (member token). */
174
+ fun LiveChattaHttpAPI.acceptSharedChannelByTokenTyped(token: String, chatLinkId: String, audience: String, memberIds: List<String>? = null, callback: TypedCallback<LiveChattaSharedChannelView>? = null) =
175
+ acceptSharedChannelByToken(token, chatLinkId, audience, memberIds, typedCallback(callback) { LiveChattaSharedChannelView.fromJson(it) })
176
+
177
+ /** End a share (remove the partner, leave, cancel or decline), as a typed share (member token). */
178
+ fun LiveChattaHttpAPI.endSharedChannelTyped(sharedChannelId: String, chatLinkId: String, callback: TypedCallback<LiveChattaSharedChannelView>? = null) =
179
+ endSharedChannel(sharedChannelId, chatLinkId, typedCallback(callback) { LiveChattaSharedChannelView.fromJson(it) })
180
+
181
+ /** Change who has the channel on the partner side, as a typed share (member token). */
182
+ fun LiveChattaHttpAPI.updateSharedChannelMembersTyped(sharedChannelId: String, chatLinkId: String, audience: String, memberIds: List<String>? = null, callback: TypedCallback<LiveChattaSharedChannelView>? = null) =
183
+ updateSharedChannelMembers(sharedChannelId, chatLinkId, audience, memberIds, typedCallback(callback) { LiveChattaSharedChannelView.fromJson(it) })
184
+
185
+ /** Your workspace's activity log for one share, as a typed page (member token). */
186
+ fun LiveChattaHttpAPI.getSharedChannelAuditTyped(sharedChannelId: String, chatLinkId: String, nextCursor: String? = null, callback: TypedCallback<LiveChattaSharedChannelAuditPage>? = null) =
187
+ getSharedChannelAudit(sharedChannelId, chatLinkId, nextCursor, typedCallback(callback) { LiveChattaSharedChannelAuditPage.fromJson(it) })
188
+
189
+ /** Open a direct message with a partner workspace's person, as a typed result (member token). */
190
+ fun LiveChattaHttpAPI.openSharedDirectTyped(chatLinkId: String, conversationId: String, memberId: String, callback: TypedCallback<LiveChattaSharedDirectResult>? = null) =
191
+ openSharedDirect(chatLinkId, conversationId, memberId, typedCallback(callback) { LiveChattaSharedDirectResult.fromJson(it) })
192
+
193
+ /** Host removes one partner member, as a typed share (member token). */
194
+ fun LiveChattaHttpAPI.removeSharedChannelMemberTyped(chatLinkId: String, conversationId: String, memberId: String, callback: TypedCallback<LiveChattaSharedChannelView>? = null) =
195
+ removeSharedChannelMember(chatLinkId, conversationId, memberId, typedCallback(callback) { LiveChattaSharedChannelView.fromJson(it) })
196
+
197
+ /** Wipe a message in a shared channel for everyone, as a typed result (member token). */
198
+ fun LiveChattaHttpAPI.removeSharedChannelMessageTyped(chatLinkId: String, conversationId: String, messageId: String, callback: TypedCallback<LiveChattaRemoveSharedMessageResult>? = null) =
199
+ removeSharedChannelMessage(chatLinkId, conversationId, messageId, typedCallback(callback) { LiveChattaRemoveSharedMessageResult.fromJson(it) })
200
+
201
+ /** Bind a verified teammate to their chat user, as a typed result (owner token). */
202
+ fun LiveChattaHttpAPI.linkChatUserToAccountTyped(accountId: String, chatUserId: String, callback: TypedCallback<LiveChattaLinkChatUserToAccountResult>? = null) =
203
+ linkChatUserToAccount(accountId, chatUserId, typedCallback(callback) { LiveChattaLinkChatUserToAccountResult.fromJson(it) })
204
+
205
+ /** The app's store versions, typed; `platforms` is null on older servers. */
206
+ fun LiveChattaHttpAPI.getAppVersionTyped(callback: TypedCallback<LiveChattaAppVersionInfo>? = null) =
207
+ getAppVersion(typedCallback(callback) { LiveChattaAppVersionInfo.fromJson(it) })
208
+
209
+ /** Rate a resolved support conversation, as a typed result (member token, the customer). */
210
+ fun LiveChattaHttpAPI.submitCsatTyped(conversationId: String, payload: LiveChattaSubmitCsatPayload, callback: TypedCallback<LiveChattaCsatRating>? = null) =
211
+ submitCsat(conversationId, payload.toJson(), typedCallback(callback) { LiveChattaCsatRating.fromJson(it) })
212
+
213
+ /** Satisfaction ratings, as a typed page (API key). */
214
+ fun LiveChattaHttpAPI.listCsatRatingsTyped(query: Map<String, String>? = null, callback: TypedCallback<LiveChattaCsatRatingPage>? = null) =
215
+ listCsatRatings(query, typedCallback(callback) { LiveChattaCsatRatingPage.fromJson(it) })
216
+
217
+ /** Satisfaction summary, typed (API key). */
218
+ fun LiveChattaHttpAPI.getCsatSummaryTyped(query: Map<String, String>? = null, callback: TypedCallback<LiveChattaCsatSummary>? = null) =
219
+ getCsatSummary(query, typedCallback(callback) { LiveChattaCsatSummary.fromJson(it) })
220
+
221
+ /** Satisfaction ratings, as a typed page (owner token). */
222
+ fun LiveChattaHttpAPI.listCsatRatingsAsOwnerTyped(query: Map<String, String>? = null, callback: TypedCallback<LiveChattaCsatRatingPage>? = null) =
223
+ listCsatRatingsAsOwner(query, typedCallback(callback) { LiveChattaCsatRatingPage.fromJson(it) })
224
+
225
+ /** Satisfaction summary, typed (owner token). */
226
+ fun LiveChattaHttpAPI.getCsatSummaryAsOwnerTyped(query: Map<String, String>? = null, callback: TypedCallback<LiveChattaCsatSummary>? = null) =
227
+ getCsatSummaryAsOwner(query, typedCallback(callback) { LiveChattaCsatSummary.fromJson(it) })
228
+
229
+ /** The owner Members list of a link, as a typed page. */
230
+ fun LiveChattaHttpAPI.getLinkMemberListTyped(linkId: String, query: Map<String, String>? = null, callback: TypedCallback<LiveChattaLinkMemberPage>? = null) =
231
+ getLinkMemberList(linkId, query, typedCallback(callback) { LiveChattaLinkMemberPage.fromJson(it) })
232
+
233
+ /** Take someone off an invite-only link's list, as a typed result (owner token). */
234
+ fun LiveChattaHttpAPI.revokeLinkInviteTyped(linkId: String, memberId: String, callback: TypedCallback<LiveChattaRevokeLinkInviteResult>? = null) =
235
+ revokeLinkInvite(linkId, memberId, typedCallback(callback) { LiveChattaRevokeLinkInviteResult.fromJson(it) })
236
+
237
+ /** A call recording's download link, typed (member token). */
238
+ fun LiveChattaHttpAPI.getRecordingDownloadLinkTyped(messageId: String, callback: TypedCallback<LiveChattaRecordingDownloadLink>? = null) =
239
+ getRecordingDownloadLink(messageId, typedCallback(callback) { LiveChattaRecordingDownloadLink.fromJson(it) })
@@ -0,0 +1,158 @@
1
+ package com.livechatta.sdk
2
+
3
+ import android.annotation.SuppressLint
4
+ import android.content.Context
5
+ import android.os.Build
6
+ import android.util.AttributeSet
7
+ import android.util.Base64
8
+ import android.webkit.JavascriptInterface
9
+ import android.webkit.WebSettings
10
+ import android.webkit.WebView
11
+ import android.webkit.WebViewClient
12
+ import java.security.KeyFactory
13
+ import java.security.spec.X509EncodedKeySpec
14
+ import javax.crypto.Cipher
15
+
16
+ // Android WebView embed: configure(linkCode, apiKey, publicKey, chatUsername, …). Colours are sent
17
+ // only when set (link theme / Signal #D2400B otherwise; "6C5CE7" = no brand); theme: light|dark|system.
18
+ class LiveChattaWebView
19
+ @JvmOverloads
20
+ constructor(
21
+ context: Context,
22
+ attrs: AttributeSet? = null,
23
+ defStyleAttr: Int = 0,
24
+ ) : WebView(context, attrs, defStyleAttr) {
25
+ companion object {
26
+ /** Pre-Signal default primary; treated as "no brand". */
27
+ const val LEGACY_BRAND = "6C5CE7"
28
+ val THEME_MODES = setOf("light", "dark", "system")
29
+ }
30
+
31
+ var onMessageReceived: ((String) -> Unit)? = null
32
+ var onErrorReceived: ((String) -> Unit)? = null
33
+
34
+ private var baseUrl = "https://api.livechatta.com"
35
+
36
+ init {
37
+ setupWebView()
38
+ }
39
+
40
+ @SuppressLint("SetJavaScriptEnabled")
41
+ private fun setupWebView() {
42
+ settings.apply {
43
+ javaScriptEnabled = true
44
+ domStorageEnabled = true
45
+ mediaPlaybackRequiresUserGesture = false
46
+ cacheMode = WebSettings.LOAD_DEFAULT
47
+ }
48
+
49
+ webViewClient = WebViewClient()
50
+
51
+ addJavascriptInterface(
52
+ object {
53
+ @JavascriptInterface
54
+ fun onMessage(data: String) {
55
+ post { onMessageReceived?.invoke(data) }
56
+ }
57
+
58
+ @JavascriptInterface
59
+ fun onError(error: String) {
60
+ post { onErrorReceived?.invoke(error) }
61
+ }
62
+ },
63
+ "LiveChattaBridge",
64
+ )
65
+ }
66
+
67
+ fun configure(
68
+ linkCode: String,
69
+ apiKey: String,
70
+ publicKey: String? = null,
71
+ baseUrl: String = "https://api.livechatta.com",
72
+ chatUsername: String,
73
+ primaryColor: String? = null,
74
+ secondaryColor: String? = null,
75
+ primaryLight: String? = null,
76
+ primaryDark: String? = null,
77
+ primaryBg: String? = null,
78
+ bg: String? = null,
79
+ bgDark: String? = null,
80
+ textColor: String? = null,
81
+ textLight: String? = null,
82
+ textMuted: String? = null,
83
+ borderColor: String? = null,
84
+ borderLight: String? = null,
85
+ fontFamily: String? = null,
86
+ logoUrl: String? = null,
87
+ theme: String = "light",
88
+ layout: String? = null,
89
+ ) {
90
+ this.baseUrl = baseUrl
91
+
92
+ val token = encryptToken(apiKey, linkCode, chatUsername, publicKey)
93
+
94
+ val url =
95
+ buildString {
96
+ append("$baseUrl/in/$linkCode/embed/chat")
97
+ append("?token=${java.net.URLEncoder.encode(token, "UTF-8")}")
98
+ append("&theme=${if (theme in THEME_MODES) theme else "light"}")
99
+ primaryColor?.removePrefix("#")?.takeIf { it.isNotEmpty() && !it.equals(LEGACY_BRAND, true) }
100
+ ?.let { append("&primaryColor=$it") }
101
+ secondaryColor?.removePrefix("#")?.takeIf { it.isNotEmpty() }?.let { append("&secondaryColor=$it") }
102
+ layout?.takeIf { it == "bubbles" || it == "lines" }?.let { append("&layout=$it") }
103
+ // Optional theme overrides
104
+ primaryLight?.let { append("&primaryLight=$it") }
105
+ primaryDark?.let { append("&primaryDark=$it") }
106
+ primaryBg?.let { append("&primaryBg=$it") }
107
+ bg?.let { append("&bg=$it") }
108
+ bgDark?.let { append("&bgDark=$it") }
109
+ textColor?.let { append("&textColor=$it") }
110
+ textLight?.let { append("&textLight=$it") }
111
+ textMuted?.let { append("&textMuted=$it") }
112
+ borderColor?.let { append("&borderColor=$it") }
113
+ borderLight?.let { append("&borderLight=$it") }
114
+ fontFamily?.let { append("&fontFamily=${java.net.URLEncoder.encode(it, "UTF-8")}") }
115
+ logoUrl?.let { append("&logoUrl=${java.net.URLEncoder.encode(it, "UTF-8")}") }
116
+ }
117
+
118
+ loadUrl(url)
119
+ }
120
+
121
+ private fun encryptToken(
122
+ apiKey: String,
123
+ linkCode: String,
124
+ chatUsername: String,
125
+ publicKey: String?,
126
+ ): String {
127
+ val payload =
128
+ buildString {
129
+ append("{\"apiKey\":\"$apiKey\",\"linkCode\":\"$linkCode\",\"chatUsername\":\"$chatUsername\"}")
130
+ }
131
+
132
+ if (publicKey != null) {
133
+ try {
134
+ val pem =
135
+ publicKey
136
+ .replace("-----BEGIN PUBLIC KEY-----", "")
137
+ .replace("-----END PUBLIC KEY-----", "")
138
+ .replace("\\s".toRegex(), "")
139
+
140
+ val keyBytes = Base64.decode(pem, Base64.DEFAULT)
141
+ val keySpec = X509EncodedKeySpec(keyBytes)
142
+ val keyFactory = KeyFactory.getInstance("RSA")
143
+ val key = keyFactory.generatePublic(keySpec)
144
+
145
+ val cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding")
146
+ cipher.init(Cipher.ENCRYPT_MODE, key)
147
+ val encrypted = cipher.doFinal(payload.toByteArray(Charsets.UTF_8))
148
+
149
+ return Base64.encodeToString(encrypted, Base64.URL_SAFE or Base64.NO_WRAP or Base64.NO_PADDING)
150
+ } catch (e: Exception) {
151
+ // Fallback to raw API key
152
+ return apiKey
153
+ }
154
+ }
155
+
156
+ return apiKey
157
+ }
158
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Angular service wrapping the LiveChatta bridge + permissions + unread.
3
+ *
4
+ * constructor(private chatta: LiveChattaBridgeService) {
5
+ * chatta.unread$.subscribe(n => this.unread = n);
6
+ * chatta.requestMicrophone();
7
+ * }
8
+ *
9
+ * Decorate with `@Injectable({ providedIn: 'root' })` at the consumer
10
+ * project — keeping decorators here would force `experimentalDecorators`
11
+ * on every consumer regardless of their tsconfig.
12
+ */
13
+ import { type DeepLinkPayload } from '@livechatta/sdk';
14
+ export interface UnreadSubscriber {
15
+ next(n: number): void;
16
+ }
17
+ declare class UnreadStream {
18
+ subs: Set<UnreadSubscriber>;
19
+ current: number;
20
+ constructor();
21
+ subscribe(observer: UnreadSubscriber | ((n: number) => void)): {
22
+ unsubscribe: () => boolean;
23
+ };
24
+ }
25
+ export declare class LiveChattaBridgeService {
26
+ /** Lightweight observable shim — emits unread counts. */
27
+ readonly unread$: UnreadStream;
28
+ /** Pre-warm microphone permission. */
29
+ requestMicrophone(): Promise<import("@livechatta/sdk").MediaPermissionResult>;
30
+ /** Pre-warm camera permission. */
31
+ requestCamera(): Promise<import("@livechatta/sdk").MediaPermissionResult>;
32
+ /** Listen for parsed deep links forwarded over the bridge. */
33
+ onDeepLink(handler: (payload: DeepLinkPayload) => void): () => void;
34
+ }
35
+ export {};
@@ -0,0 +1 @@
1
+ import{LiveChatta,parseDeepLink}from"@livechatta/sdk";class UnreadStream{constructor(){this.subs=new Set,this.current=0;const e=LiveChatta.bridge;e&&e.on("onUnreadChange",e=>{const t="number"==typeof e?e:(null==e?void 0:e.count)||0;this.current=t,this.subs.forEach(e=>{try{e.next(t)}catch(e){}})})}subscribe(e){const t="function"==typeof e?{next:e}:e;this.subs.add(t);try{t.next(this.current)}catch(e){}return{unsubscribe:()=>this.subs.delete(t)}}}export class LiveChattaBridgeService{constructor(){this.unread$=new UnreadStream}requestMicrophone(){return LiveChatta.permissions.requestMedia({audio:!0,video:!1})}requestCamera(){return LiveChatta.permissions.requestMedia({audio:!1,video:!0})}onDeepLink(e){const t=LiveChatta.bridge;return t?t.on("onDeepLink",t=>{const r="string"==typeof t?t:null==t?void 0:t.url;r&&e(parseDeepLink(r))}):()=>{}}}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"livechatta-bridge.service.js","sourceRoot":"","sources":["../../../src/platforms/angular/livechatta-bridge.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAwB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMlF,MAAM,YAAY;IAIhB;QAHA,SAAI,GAAG,IAAI,GAAG,EAAoB,CAAC;QACnC,YAAO,GAAG,CAAC,CAAC;QAGV,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;QACjC,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,OAAY,EAAE,EAAE;gBAC3C,MAAM,KAAK,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,KAAI,CAAC,CAAC;gBAC1E,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;gBACrB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC;oBAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAAC,CAAC;gBAAC,QAAQ,aAAa,IAAf,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/E,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,SAAS,CAAC,QAAkD;QAC1D,MAAM,GAAG,GACP,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,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AAC;IACL,CAAC;CACF"}
@@ -0,0 +1,46 @@
1
+ import { EventEmitter, ElementRef, OnInit, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
2
+ import type { EmbedPosition, EmbedLayout, ThemeMode } from '@livechatta/sdk';
3
+ export declare class LiveChattaEmbedComponent implements OnInit, OnChanges, OnDestroy {
4
+ containerRef: ElementRef<HTMLDivElement>;
5
+ linkCode: string;
6
+ apiKey: string;
7
+ chatUsername: string;
8
+ publicKey?: string;
9
+ baseUrl?: string;
10
+ primaryColor?: string;
11
+ secondaryColor?: string;
12
+ primaryLight?: string;
13
+ primaryDark?: string;
14
+ primaryBg?: string;
15
+ bg?: string;
16
+ bgDark?: string;
17
+ textColor?: string;
18
+ textLight?: string;
19
+ textMuted?: string;
20
+ borderColor?: string;
21
+ borderLight?: string;
22
+ fontFamily?: string;
23
+ logoUrl?: string;
24
+ theme?: ThemeMode;
25
+ layout?: EmbedLayout;
26
+ floating?: boolean;
27
+ position?: EmbedPosition;
28
+ autoOpen?: boolean;
29
+ greeting?: string;
30
+ greetingDelay?: number;
31
+ title?: string;
32
+ subtitle?: string;
33
+ launcherLabel?: string;
34
+ zIndex?: number;
35
+ preload?: boolean;
36
+ width?: string;
37
+ height?: string;
38
+ embedMessage: EventEmitter<any>;
39
+ embedError: EventEmitter<any>;
40
+ openChange: EventEmitter<boolean>;
41
+ private embed;
42
+ ngOnInit(): void;
43
+ ngOnChanges(changes: SimpleChanges): void;
44
+ ngOnDestroy(): void;
45
+ private mountEmbed;
46
+ }
@@ -0,0 +1 @@
1
+ var __decorate=this&&this.__decorate||function(t,e,o,i){var n,a=arguments.length,r=a<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,o,i);else for(var p=t.length-1;p>=0;p--)(n=t[p])&&(r=(a<3?n(r):a>3?n(e,o,r):n(e,o))||r);return a>3&&r&&Object.defineProperty(e,o,r),r};import{Component,Input,Output,EventEmitter,ViewChild}from"@angular/core";import{LiveChattaEmbed}from"../web/LiveChattaEmbed";import{THEME_ALL_KEYS,EMBED_OPTION_KEYS,pickDefined}from"@livechatta/sdk";const THEME_KEYS=THEME_ALL_KEYS,IDENTITY_KEYS=["linkCode","apiKey","chatUsername","publicKey","baseUrl","floating","position","layout"];let LiveChattaEmbedComponent=class{constructor(){this.embedMessage=new EventEmitter,this.embedError=new EventEmitter,this.openChange=new EventEmitter,this.embed=null}ngOnInit(){this.mountEmbed()}ngOnChanges(t){if(IDENTITY_KEYS.some(e=>t[e]&&!t[e].firstChange))this.mountEmbed();else if(this.embed&&THEME_KEYS.some(e=>t[e]&&!t[e].firstChange)){const t={};for(const e of THEME_KEYS){const o=this[e];void 0!==o&&(t[e]=o)}this.embed.updateTheme(t)}}ngOnDestroy(){this.embed&&(this.embed.unmount(),this.embed=null)}mountEmbed(){var t;this.embed&&(this.embed.unmount(),this.embed=null);const e=null===(t=this.containerRef)||void 0===t?void 0:t.nativeElement;e&&(this.embed=new LiveChattaEmbed({container:e,linkCode:this.linkCode,apiKey:this.apiKey,publicKey:this.publicKey,chatUsername:this.chatUsername,baseUrl:this.baseUrl,primaryColor:this.primaryColor,secondaryColor:this.secondaryColor,primaryLight:this.primaryLight,primaryDark:this.primaryDark,primaryBg:this.primaryBg,bg:this.bg,bgDark:this.bgDark,textColor:this.textColor,textLight:this.textLight,textMuted:this.textMuted,borderColor:this.borderColor,borderLight:this.borderLight,fontFamily:this.fontFamily,logoUrl:this.logoUrl,theme:this.theme,width:this.width,height:this.height,...pickDefined(this,EMBED_OPTION_KEYS),onOpenChange:t=>this.openChange.emit(t)}),this.embed.onMessage(t=>this.embedMessage.emit(t)),this.embed.onError(t=>this.embedError.emit(t)),this.embed.mount())}};__decorate([ViewChild("container",{static:!0})],LiveChattaEmbedComponent.prototype,"containerRef",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"linkCode",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"apiKey",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"chatUsername",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"publicKey",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"baseUrl",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"primaryColor",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"secondaryColor",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"primaryLight",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"primaryDark",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"primaryBg",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"bg",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"bgDark",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"textColor",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"textLight",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"textMuted",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"borderColor",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"borderLight",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"fontFamily",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"logoUrl",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"theme",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"layout",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"floating",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"position",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"autoOpen",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"greeting",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"greetingDelay",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"title",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"subtitle",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"launcherLabel",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"zIndex",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"preload",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"width",void 0),__decorate([Input()],LiveChattaEmbedComponent.prototype,"height",void 0),__decorate([Output()],LiveChattaEmbedComponent.prototype,"embedMessage",void 0),__decorate([Output()],LiveChattaEmbedComponent.prototype,"embedError",void 0),__decorate([Output()],LiveChattaEmbedComponent.prototype,"openChange",void 0),LiveChattaEmbedComponent=__decorate([Component({selector:"livechatta-embed",standalone:!0,template:"<div #container></div>"})],LiveChattaEmbedComponent);export{LiveChattaEmbedComponent};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"livechatta-embed.component.js","sourceRoot":"","sources":["../../../src/platforms/angular/livechatta-embed.component.ts"],"names":[],"mappings":";;;;;;AAAA,oBAAoB;AACpB,gGAAgG;AAChG,6FAA6F;AAC7F,OAAO,EACL,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EAEZ,SAAS,GAKV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEjF,oDAAoD;AACpD,MAAM,UAAU,GAAG,cAAc,CAAC;AAElC,oDAAoD;AACpD,MAAM,aAAa,GAAG;IACpB,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ;CACtF,CAAC;AAOJ,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAA9B;QA8CL,wDAAwD;QAC9C,iBAAY,GAAG,IAAI,YAAY,EAAO,CAAC;QACvC,eAAU,GAAG,IAAI,YAAY,EAAO,CAAC;QACrC,eAAU,GAAG,IAAI,YAAY,EAAW,CAAC;QAE3C,UAAK,GAA2B,IAAI,CAAC;IA2E/C,CAAC;IAzEC,QAAQ;QACN,IAAI,CAA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,KAAK,EAAE;+DAAwB;AACvB;IAAR,KAAK,EAAE;wDAAiB;AAChB;IAAR,KAAK,EAAE;yDAAmB;AAGlB;IAAR,KAAK,EAAE;uDAAgB;AACf;IAAR,KAAK,EAAE;wDAAiB;AAGf;IAAT,MAAM,EAAE;8DAAwC;AACvC;IAAT,MAAM,EAAE;4DAAsC;AACrC;IAAT,MAAM,EAAE;4DAA0C;AAjDxC,wBAAwB;IALpC,SAAS,CAAC;QACT,QAAQ,EAAE,kBAAkB;QAC5B,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,wBAAwB;KACnC,CAAC;GACW,wBAAwB,CA8HpC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Angular service for using the LiveChatta SDK.
3
+ *
4
+ * Wraps the core LiveChatta singleton as an `@Injectable` service with RxJS
5
+ * Observables for reactive connection state tracking. Auto-cleans up when
6
+ * Angular destroys the service (e.g., when the root injector is destroyed).
7
+ *
8
+ * Usage:
9
+ * import { LiveChattaService } from '@livechatta/sdk/platforms/angular';
10
+ *
11
+ * @Component({ ... })
12
+ * export class ChatComponent implements OnInit {
13
+ * private chatta = inject(LiveChattaService);
14
+ *
15
+ * isConnected$ = this.chatta.isConnected$;
16
+ * connectionState$ = this.chatta.connectionState$;
17
+ *
18
+ * ngOnInit() {
19
+ * this.chatta.init({
20
+ * linkCode: 'your-link-code',
21
+ * apiKey: 'your-api-key',
22
+ * publicKey: '-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----',
23
+ * chatUsername: 'john_doe',
24
+ * });
25
+ * this.chatta.connect();
26
+ * }
27
+ * }
28
+ *
29
+ * Requirements:
30
+ * - @angular/core (peer dependency)
31
+ * - rxjs (peer dependency, included with Angular)
32
+ * - socket.io-client (peer dependency, already in the SDK package)
33
+ */
34
+ import { OnDestroy } from '@angular/core';
35
+ import { Observable } from 'rxjs';
36
+ import { ConnectionState } from '@livechatta/sdk';
37
+ import type { InitOptions, SocketAPI, HttpAPI } from '@livechatta/sdk';
38
+ export declare class LiveChattaService implements OnDestroy {
39
+ private connectionStateSubject;
40
+ private initializedSubject;
41
+ /** Observable of the current connection state */
42
+ connectionState$: Observable<ConnectionState>;
43
+ /** Observable that emits true only when connected */
44
+ isConnected$: Observable<boolean>;
45
+ /** Observable that emits true once init() has been called */
46
+ isInitialized$: Observable<boolean>;
47
+ /** Event handler references stored for cleanup */
48
+ private handlers;
49
+ /**
50
+ * Initialize the SDK with connection options.
51
+ * Must be called before connect(), sock(), or api().
52
+ */
53
+ init(options: InitOptions): void;
54
+ /** Connect the WebSocket transport */
55
+ connect(): Promise<void>;
56
+ /** Disconnect the WebSocket transport */
57
+ disconnect(): void;
58
+ /** Get the Socket API for real-time messaging -- null if not initialized */
59
+ sock(): SocketAPI | null;
60
+ /** Get the HTTP API for REST operations -- null if not initialized */
61
+ api(): HttpAPI | null;
62
+ /** Destroy the SDK instance and clean up all listeners */
63
+ destroy(): void;
64
+ /** Auto-cleanup when Angular destroys the service */
65
+ ngOnDestroy(): void;
66
+ }
@@ -0,0 +1 @@
1
+ var __decorate=this&&this.__decorate||function(t,e,n,i){var c,a=arguments.length,o=a<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,n,i);else for(var r=t.length-1;r>=0;r--)(c=t[r])&&(o=(a<3?c(o):a>3?c(e,n,o):c(e,n))||o);return a>3&&o&&Object.defineProperty(e,n,o),o};import{Injectable}from"@angular/core";import{BehaviorSubject}from"rxjs";import{map,distinctUntilChanged}from"rxjs/operators";import{LiveChatta,SDKEvent,ConnectionState}from"@livechatta/sdk";let LiveChattaService=class{constructor(){this.connectionStateSubject=new BehaviorSubject(ConnectionState.DISCONNECTED),this.initializedSubject=new BehaviorSubject(!1),this.connectionState$=this.connectionStateSubject.asObservable(),this.isConnected$=this.connectionStateSubject.pipe(map(t=>t===ConnectionState.CONNECTED),distinctUntilChanged()),this.isInitialized$=this.initializedSubject.pipe(distinctUntilChanged()),this.handlers={}}init(t){LiveChatta.init(t),this.initializedSubject.next(!0),this.handlers={connected:()=>this.connectionStateSubject.next(ConnectionState.CONNECTED),disconnected:()=>this.connectionStateSubject.next(ConnectionState.DISCONNECTED),reconnecting:()=>this.connectionStateSubject.next(ConnectionState.RECONNECTING),reconnected:()=>this.connectionStateSubject.next(ConnectionState.CONNECTED)},LiveChatta.on(SDKEvent.CONNECTED,this.handlers.connected),LiveChatta.on(SDKEvent.DISCONNECTED,this.handlers.disconnected),LiveChatta.on(SDKEvent.RECONNECTING,this.handlers.reconnecting),LiveChatta.on(SDKEvent.RECONNECTED,this.handlers.reconnected)}async connect(){await LiveChatta.connect()}disconnect(){LiveChatta.disconnect()}sock(){try{return LiveChatta.sock()}catch(t){return null}}api(){try{return LiveChatta.api()}catch(t){return null}}destroy(){LiveChatta.off(SDKEvent.CONNECTED,this.handlers.connected),LiveChatta.off(SDKEvent.DISCONNECTED,this.handlers.disconnected),LiveChatta.off(SDKEvent.RECONNECTING,this.handlers.reconnecting),LiveChatta.off(SDKEvent.RECONNECTED,this.handlers.reconnected),LiveChatta.destroy(),this.initializedSubject.next(!1),this.connectionStateSubject.next(ConnectionState.DISCONNECTED)}ngOnDestroy(){this.destroy()}};LiveChattaService=__decorate([Injectable({providedIn:"root"})],LiveChattaService);export{LiveChattaService};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"livechatta.service.js","sourceRoot":"","sources":["../../../src/platforms/angular/livechatta.service.ts"],"names":[],"mappings":";;;;;;AAAA,oBAAoB;AACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,eAAe,EAAc,MAAM,MAAM,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,iBAAi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,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAChE,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IACjE,CAAC;IAED,qDAAqD;IACrD,WAAW;QACT,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;CACF,CAAA;AApFY,iBAAiB;IAD7B,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;GACtB,iBAAiB,CAoF7B"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Capacitor-specific bridge — wraps the core Bridge with auto-routing to
3
+ * the same Capacitor plugins the LiveChatta-shipped mobile shell uses
4
+ * (HopBridge, ScreenshotProtection, Badge, PushNotifications). Lets a
5
+ * third-party Capacitor app integrator wire in `LiveChatta.ui()` and
6
+ * get the same screenshot protection / push hand-off / call lifecycle
7
+ * the official LiveChatta mobile app gets — Rule 61.
8
+ *
9
+ * Usage:
10
+ * import { CapacitorBridge } from '@livechatta/sdk/platforms/capacitor';
11
+ * const bridge = new CapacitorBridge({ allowedOrigin: 'https://livechatta.com' });
12
+ * bridge.attach(iframe);
13
+ * bridge.autoRoute(); // wires every CHATTA_APP:* event to the matching plugin
14
+ */
15
+ import { Bridge } from '@livechatta/sdk';
16
+ export declare class CapacitorBridge extends Bridge {
17
+ private autoRouteUnsubs;
18
+ /**
19
+ * Wire the standard CHATTA_APP:* events to their matching Capacitor
20
+ * plugins. Idempotent — calling twice doesn't double-subscribe.
21
+ */
22
+ autoRoute(): Promise<void>;
23
+ /** Stop all auto-route subscriptions. Safe to call multiple times. */
24
+ stopAutoRoute(): void;
25
+ detach(): void;
26
+ private loadCapacitor;
27
+ }
@@ -0,0 +1 @@
1
+ import{Bridge}from"@livechatta/sdk";export class CapacitorBridge extends Bridge{constructor(){super(...arguments),this.autoRouteUnsubs=[]}async autoRoute(){var t,i,o,a,s,n,e,l,u;if(this.autoRouteUnsubs.length)return;const c=await this.loadCapacitor();if(!c)return;const{Capacitor:r,registerPlugin:h}=c;if(null===(t=r.isPluginAvailable)||void 0===t?void 0:t.call(r,"ScreenshotProtection")){const t=h("ScreenshotProtection");this.autoRouteUnsubs.push(this.on("enableScreenshotProtection",async i=>{try{await t.setEnabled({enabled:!(!i||!i.enabled)})}catch(t){}}))}if(null===(i=r.isPluginAvailable)||void 0===i?void 0:i.call(r,"Badge")){const t=h("Badge");this.autoRouteUnsubs.push(this.on("onUnreadChange",async i=>{const o="number"==typeof i?i:null==i?void 0:i.count;try{"number"==typeof o&&await t.set({count:o})}catch(t){}}))}if(null===(o=r.isPluginAvailable)||void 0===o?void 0:o.call(r,"Browser")){const t=h("Browser");this.autoRouteUnsubs.push(this.on("openExternal",async i=>{if(null==i?void 0:i.url)try{await t.open({url:i.url})}catch(t){try{window.open(i.url,"_blank")}catch(t){}}}))}if(null===(a=r.isPluginAvailable)||void 0===a?void 0:a.call(r,"HopBridge")){const t=h("HopBridge");this.autoRouteUnsubs.push(this.on("hopStartCall",async i=>{try{await t.startCall({sessionId:null==i?void 0:i.sessionId})}catch(t){}})),this.autoRouteUnsubs.push(this.on("hopEndCall",async()=>{try{await t.endCall()}catch(t){}}))}if(null===(s=r.isPluginAvailable)||void 0===s?void 0:s.call(r,"LocalNotifications")){const t=h("LocalNotifications");this.autoRouteUnsubs.push(this.on("notify",async i=>{if(i)try{await t.schedule({notifications:[{id:Date.now()%2147483647,title:i.title||"New message",body:i.body||"",extra:i}]})}catch(t){}}));const i=991001;this.autoRouteUnsubs.push(this.on("hopRecordingStarted",async()=>{try{await t.schedule({notifications:[{id:i,title:"Recording in progress",body:"Tap to return to the call",ongoing:!0,autoCancel:!1}]})}catch(t){}})),this.autoRouteUnsubs.push(this.on("hopRecordingStopped",async()=>{try{await t.cancel({notifications:[{id:i}]})}catch(t){}}))}if(null===(n=r.isPluginAvailable)||void 0===n?void 0:n.call(r,"Share")){const t=h("Share");this.autoRouteUnsubs.push(this.on("share",async i=>{if(i)try{await t.share({title:i.title,text:i.text,url:i.url})}catch(t){}}))}if(null===(e=r.isPluginAvailable)||void 0===e?void 0:e.call(r,"Haptics")){const t=h("Haptics");this.autoRouteUnsubs.push(this.on("haptic",async i=>{const o=i&&i.style||"medium";try{"success"===o||"warning"===o||"error"===o?await t.notification({type:o.toUpperCase()}):await t.impact({style:o.toUpperCase()})}catch(t){}}))}if(null===(l=r.isPluginAvailable)||void 0===l?void 0:l.call(r,"Clipboard")){const t=h("Clipboard");this.autoRouteUnsubs.push(this.on("setClipboard",async i=>{if(null==i?void 0:i.text)try{await t.write({string:i.text})}catch(t){}}))}if(null===(u=r.isPluginAvailable)||void 0===u?void 0:u.call(r,"StatusBar")){const t=h("StatusBar");this.autoRouteUnsubs.push(this.on("onThemeLoaded",async i=>{if(null==i?void 0:i.primaryColor)try{await t.setBackgroundColor({color:i.primaryColor})}catch(t){}}))}}stopAutoRoute(){this.autoRouteUnsubs.forEach(t=>t()),this.autoRouteUnsubs=[]}detach(){this.stopAutoRoute(),super.detach()}async loadCapacitor(){try{const t=await(import("@capacitor/core"));return{Capacitor:t.Capacitor,registerPlugin:t.registerPlugin}}catch(t){return null}}}