@progress/kendo-angular-conversational-ui 4.1.0 → 5.0.0-dev.202204131603

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 (163) hide show
  1. package/{dist/es2015/api → api}/action.interface.d.ts +0 -0
  2. package/{dist/es2015/api → api}/attachment.interface.d.ts +0 -0
  3. package/{dist/es2015/api → api}/execute-action-event.d.ts +1 -1
  4. package/{dist/es/api/user.interface.js → api/index.d.ts} +6 -0
  5. package/{dist/es2015/api → api}/message.interface.d.ts +0 -0
  6. package/{dist/es2015/api → api}/post-message-event.d.ts +0 -0
  7. package/{dist/es2015/api → api}/preventable-event.d.ts +0 -0
  8. package/{dist/es2015/api → api}/user.interface.d.ts +0 -0
  9. package/bundles/kendo-angular-conversational-ui.umd.js +5 -0
  10. package/{dist/es2015/cards → cards}/hero-card.component.d.ts +3 -0
  11. package/{dist/es2015/chat → chat}/attachment-template.directive.d.ts +3 -0
  12. package/{dist/es2015/chat → chat}/attachment.component.d.ts +9 -5
  13. package/{dist/es2015/chat → chat}/builtin-actions.d.ts +0 -0
  14. package/{dist/es2015/chat → chat}/chat-item.d.ts +0 -0
  15. package/{dist/es2015/chat → chat}/chat-view.d.ts +1 -1
  16. package/{dist/es2015/chat → chat}/chat.component.d.ts +7 -7
  17. package/{dist/es2015/chat → chat}/chat.directives.d.ts +0 -0
  18. package/chat/chat.module.d.ts +49 -0
  19. package/{dist/es2015/chat → chat}/l10n/custom-messages.component.d.ts +4 -1
  20. package/{dist/es2015/chat → chat}/l10n/localized-messages.directive.d.ts +3 -0
  21. package/{dist/es2015/chat → chat}/l10n/messages.d.ts +3 -0
  22. package/{dist/es2015/chat → chat}/message-attachments.component.d.ts +5 -2
  23. package/{dist/es2015/chat → chat}/message-box.component.d.ts +4 -1
  24. package/{dist/es2015/chat → chat}/message-box.directive.d.ts +3 -0
  25. package/{dist/es2015/chat → chat}/message-list.component.d.ts +9 -8
  26. package/{dist/es2015/chat → chat}/message-template.directive.d.ts +3 -0
  27. package/{dist/es2015/chat → chat}/message.component.d.ts +4 -1
  28. package/{dist/es2015/chat → chat}/suggested-actions.component.d.ts +4 -1
  29. package/common/focused-state.directive.d.ts +15 -0
  30. package/{dist/es2015/common → common}/keys.enum.d.ts +0 -0
  31. package/{dist/es2015/common → common}/models/message-box-options.d.ts +0 -0
  32. package/{dist/es2015/common → common}/scroll-anchor.directive.d.ts +3 -0
  33. package/{dist/es2015/common → common}/utils.d.ts +0 -0
  34. package/{dist/es2015 → esm2015}/api/action.interface.js +2 -1
  35. package/{dist/es2015 → esm2015}/api/attachment.interface.js +1 -0
  36. package/{dist/es2015 → esm2015}/api/execute-action-event.js +0 -0
  37. package/{dist/es/api/attachment.interface.js → esm2015/api/index.js} +6 -0
  38. package/{dist/es → esm2015}/api/message.interface.js +1 -0
  39. package/{dist/es2015 → esm2015}/api/post-message-event.js +0 -0
  40. package/{dist/es2015 → esm2015}/api/preventable-event.js +0 -0
  41. package/{dist/es2015 → esm2015}/api/user.interface.js +1 -0
  42. package/esm2015/cards/hero-card.component.js +90 -0
  43. package/{dist/es2015 → esm2015}/chat/attachment-template.directive.js +14 -12
  44. package/esm2015/chat/attachment.component.js +83 -0
  45. package/{dist/es2015 → esm2015}/chat/builtin-actions.js +13 -16
  46. package/{dist/es2015 → esm2015}/chat/chat-item.js +0 -0
  47. package/{dist/es2015 → esm2015}/chat/chat-view.js +0 -6
  48. package/esm2015/chat/chat.component.js +246 -0
  49. package/{dist/es → esm2015}/chat/chat.directives.js +0 -0
  50. package/{dist/es2015 → esm2015}/chat/chat.module.js +43 -15
  51. package/esm2015/chat/l10n/custom-messages.component.js +42 -0
  52. package/esm2015/chat/l10n/localized-messages.directive.js +37 -0
  53. package/esm2015/chat/l10n/messages.js +25 -0
  54. package/{dist/es2015 → esm2015}/chat/message-attachments.component.js +71 -48
  55. package/esm2015/chat/message-box.component.js +141 -0
  56. package/esm2015/chat/message-box.directive.js +24 -0
  57. package/esm2015/chat/message-list.component.js +279 -0
  58. package/{dist/es2015 → esm2015}/chat/message-template.directive.js +14 -12
  59. package/esm2015/chat/message.component.js +140 -0
  60. package/esm2015/chat/suggested-actions.component.js +113 -0
  61. package/esm2015/common/focused-state.directive.js +37 -0
  62. package/{dist/es2015 → esm2015}/common/keys.enum.js +1 -0
  63. package/{dist/es → esm2015}/common/models/message-box-options.js +1 -0
  64. package/{dist/es2015 → esm2015}/common/scroll-anchor.directive.js +20 -26
  65. package/{dist/es2015 → esm2015}/common/utils.js +0 -0
  66. package/{dist/es/api/action.interface.js → esm2015/kendo-angular-conversational-ui.js} +4 -1
  67. package/esm2015/main.js +10 -0
  68. package/{dist/es2015 → esm2015}/package-metadata.js +1 -1
  69. package/fesm2015/kendo-angular-conversational-ui.js +1757 -0
  70. package/{dist/es2015/common/focused-state.directive.d.ts → kendo-angular-conversational-ui.d.ts} +3 -6
  71. package/main.d.ts +11 -0
  72. package/{dist/es2015/package-metadata.d.ts → package-metadata.d.ts} +0 -0
  73. package/package.json +38 -107
  74. package/schematics/ngAdd/index.js +5 -2
  75. package/schematics/ngAdd/index.js.map +1 -1
  76. package/dist/cdn/js/kendo-angular-conversational-ui.js +0 -20
  77. package/dist/cdn/main.js +0 -5
  78. package/dist/es/api/execute-action-event.js +0 -24
  79. package/dist/es/api/post-message-event.js +0 -18
  80. package/dist/es/api/preventable-event.js +0 -32
  81. package/dist/es/cards/hero-card.component.js +0 -54
  82. package/dist/es/chat/attachment-template.directive.js +0 -32
  83. package/dist/es/chat/attachment.component.js +0 -65
  84. package/dist/es/chat/builtin-actions.js +0 -28
  85. package/dist/es/chat/chat-item.js +0 -13
  86. package/dist/es/chat/chat-view.js +0 -92
  87. package/dist/es/chat/chat.component.js +0 -190
  88. package/dist/es/chat/chat.module.js +0 -80
  89. package/dist/es/chat/l10n/custom-messages.component.js +0 -45
  90. package/dist/es/chat/l10n/localized-messages.directive.js +0 -36
  91. package/dist/es/chat/l10n/messages.js +0 -26
  92. package/dist/es/chat/message-attachments.component.js +0 -148
  93. package/dist/es/chat/message-box.component.js +0 -124
  94. package/dist/es/chat/message-box.directive.js +0 -24
  95. package/dist/es/chat/message-list.component.js +0 -165
  96. package/dist/es/chat/message-template.directive.js +0 -32
  97. package/dist/es/chat/message.component.js +0 -77
  98. package/dist/es/chat/suggested-actions.component.js +0 -91
  99. package/dist/es/common/focused-state.directive.js +0 -43
  100. package/dist/es/common/keys.enum.js +0 -4
  101. package/dist/es/common/scroll-anchor.directive.js +0 -87
  102. package/dist/es/common/utils.js +0 -13
  103. package/dist/es/index.js +0 -22
  104. package/dist/es/main.js +0 -8
  105. package/dist/es/package-metadata.js +0 -15
  106. package/dist/es2015/api/message.interface.js +0 -4
  107. package/dist/es2015/cards/hero-card.component.js +0 -79
  108. package/dist/es2015/chat/attachment.component.js +0 -66
  109. package/dist/es2015/chat/chat.component.js +0 -214
  110. package/dist/es2015/chat/chat.directives.js +0 -8
  111. package/dist/es2015/chat/chat.module.d.ts +0 -27
  112. package/dist/es2015/chat/l10n/custom-messages.component.js +0 -37
  113. package/dist/es2015/chat/l10n/localized-messages.directive.js +0 -32
  114. package/dist/es2015/chat/l10n/messages.js +0 -20
  115. package/dist/es2015/chat/message-box.component.js +0 -157
  116. package/dist/es2015/chat/message-box.directive.js +0 -23
  117. package/dist/es2015/chat/message-list.component.js +0 -227
  118. package/dist/es2015/chat/message.component.js +0 -107
  119. package/dist/es2015/chat/suggested-actions.component.js +0 -105
  120. package/dist/es2015/common/focused-state.directive.js +0 -45
  121. package/dist/es2015/common/models/message-box-options.js +0 -4
  122. package/dist/es2015/index.d.ts +0 -22
  123. package/dist/es2015/index.js +0 -22
  124. package/dist/es2015/index.metadata.json +0 -1
  125. package/dist/es2015/main.d.ts +0 -13
  126. package/dist/es2015/main.js +0 -8
  127. package/dist/fesm2015/index.js +0 -1554
  128. package/dist/fesm5/index.js +0 -1383
  129. package/dist/npm/api/action.interface.js +0 -7
  130. package/dist/npm/api/attachment.interface.js +0 -6
  131. package/dist/npm/api/execute-action-event.js +0 -26
  132. package/dist/npm/api/message.interface.js +0 -6
  133. package/dist/npm/api/post-message-event.js +0 -20
  134. package/dist/npm/api/preventable-event.js +0 -34
  135. package/dist/npm/api/user.interface.js +0 -6
  136. package/dist/npm/cards/hero-card.component.js +0 -56
  137. package/dist/npm/chat/attachment-template.directive.js +0 -34
  138. package/dist/npm/chat/attachment.component.js +0 -67
  139. package/dist/npm/chat/builtin-actions.js +0 -33
  140. package/dist/npm/chat/chat-item.js +0 -15
  141. package/dist/npm/chat/chat-view.js +0 -98
  142. package/dist/npm/chat/chat.component.js +0 -192
  143. package/dist/npm/chat/chat.directives.js +0 -14
  144. package/dist/npm/chat/chat.module.js +0 -82
  145. package/dist/npm/chat/l10n/custom-messages.component.js +0 -47
  146. package/dist/npm/chat/l10n/localized-messages.directive.js +0 -38
  147. package/dist/npm/chat/l10n/messages.js +0 -28
  148. package/dist/npm/chat/message-attachments.component.js +0 -150
  149. package/dist/npm/chat/message-box.component.js +0 -126
  150. package/dist/npm/chat/message-box.directive.js +0 -26
  151. package/dist/npm/chat/message-list.component.js +0 -167
  152. package/dist/npm/chat/message-template.directive.js +0 -34
  153. package/dist/npm/chat/message.component.js +0 -79
  154. package/dist/npm/chat/suggested-actions.component.js +0 -93
  155. package/dist/npm/common/focused-state.directive.js +0 -45
  156. package/dist/npm/common/keys.enum.js +0 -6
  157. package/dist/npm/common/models/message-box-options.js +0 -6
  158. package/dist/npm/common/scroll-anchor.directive.js +0 -89
  159. package/dist/npm/common/utils.js +0 -15
  160. package/dist/npm/index.js +0 -39
  161. package/dist/npm/main.js +0 -11
  162. package/dist/npm/package-metadata.js +0 -17
  163. package/dist/systemjs/kendo-angular-conversational-ui.js +0 -5
@@ -0,0 +1,1757 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import * as i0 from '@angular/core';
6
+ import { Directive, Optional, isDevMode, forwardRef, Component, Input, HostBinding, ElementRef, ViewChild, ViewChildren, EventEmitter, Output, HostListener, ContentChild, NgModule } from '@angular/core';
7
+ import * as i1$2 from '@progress/kendo-angular-l10n';
8
+ import { ComponentMessages, LocalizationService, L10N_PREFIX } from '@progress/kendo-angular-l10n';
9
+ import { validatePackage } from '@progress/kendo-licensing';
10
+ import * as i1 from '@progress/kendo-angular-intl';
11
+ import * as i1$1 from '@angular/common';
12
+ import { CommonModule } from '@angular/common';
13
+ import { fromEvent } from 'rxjs';
14
+ import { debounceTime } from 'rxjs/operators';
15
+ import * as i6 from '@progress/kendo-angular-common';
16
+ import { Keys, ResizeSensorModule } from '@progress/kendo-angular-common';
17
+ import * as i3 from '@progress/kendo-angular-buttons';
18
+ import { ButtonModule } from '@progress/kendo-angular-buttons';
19
+
20
+ /**
21
+ * Defines a template that will be used for displaying message attachments. To define an attachment
22
+ * template, nest an `<ng-template>` tag with the `kendoChatAttachmentTemplate` attribute inside the
23
+ * `<kendo-chat>` component. The template context is set to the attachment instance. For more information,
24
+ * refer to the article on [message attachments]({% slug attachments_chat %}).
25
+ *
26
+ * {% meta height:700 %}
27
+ * {% embed_file attachments/templates/app.component.ts preview %}
28
+ * {% embed_file shared/app.module.ts preview %}
29
+ * {% embed_file shared/main.ts hidden %}
30
+ * {% endmeta %}
31
+ */
32
+ class AttachmentTemplateDirective {
33
+ constructor(templateRef) {
34
+ this.templateRef = templateRef;
35
+ }
36
+ }
37
+ AttachmentTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: AttachmentTemplateDirective, deps: [{ token: i0.TemplateRef, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
38
+ AttachmentTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: AttachmentTemplateDirective, selector: "[kendoChatAttachmentTemplate]", ngImport: i0 });
39
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: AttachmentTemplateDirective, decorators: [{
40
+ type: Directive,
41
+ args: [{
42
+ selector: '[kendoChatAttachmentTemplate]'
43
+ }]
44
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef, decorators: [{
45
+ type: Optional
46
+ }] }]; } });
47
+
48
+ /**
49
+ * Arguments for the `SendMessage` event.
50
+ *
51
+ */
52
+ class SendMessageEvent {
53
+ /**
54
+ * @hidden
55
+ */
56
+ constructor(message) {
57
+ this.message = message;
58
+ }
59
+ }
60
+
61
+ const noop = () => { };
62
+ const handlers = {
63
+ 'reply': (action, sender) => {
64
+ sender.sendMessage.emit(new SendMessageEvent({
65
+ author: sender.user,
66
+ text: action.value,
67
+ timestamp: new Date()
68
+ }));
69
+ },
70
+ 'call': (action) => {
71
+ window.open('tel:' + action.value);
72
+ },
73
+ 'openUrl': (action) => {
74
+ window.open(action.value);
75
+ }
76
+ };
77
+ /**
78
+ * @hidden
79
+ */
80
+ const makeHandler = (action) => handlers[action.type] || noop;
81
+
82
+ /**
83
+ * Defines a template that will be used for displaying Chat messages. To define an attachment
84
+ * template, nest an `<ng-template>` tag with the `kendoChatMessageTemplate` attribute inside the
85
+ * `<kendo-chat>` component. The template context is set to the message instance. For more information,
86
+ * refer to the article on [message templates]({% slug message_templates_chat %}).
87
+ *
88
+ * {% meta height:700 %}
89
+ * {% embed_file messages/templates/app.component.ts preview %}
90
+ * {% embed_file shared/app.module.ts preview %}
91
+ * {% embed_file shared/main.ts hidden %}
92
+ * {% endmeta %}
93
+ */
94
+ class MessageTemplateDirective {
95
+ constructor(templateRef) {
96
+ this.templateRef = templateRef;
97
+ }
98
+ }
99
+ MessageTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MessageTemplateDirective, deps: [{ token: i0.TemplateRef, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
100
+ MessageTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: MessageTemplateDirective, selector: "[kendoChatMessageTemplate]", ngImport: i0 });
101
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MessageTemplateDirective, decorators: [{
102
+ type: Directive,
103
+ args: [{
104
+ selector: '[kendoChatMessageTemplate]'
105
+ }]
106
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef, decorators: [{
107
+ type: Optional
108
+ }] }]; } });
109
+
110
+ /**
111
+ * @hidden
112
+ */
113
+ const packageMetadata = {
114
+ name: '@progress/kendo-angular-conversational-ui',
115
+ productName: 'Kendo UI for Angular',
116
+ productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
117
+ publishDate: 1649865797,
118
+ version: '',
119
+ licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
120
+ };
121
+
122
+ /**
123
+ * Creates a message box area that overrides the default message box of the Conversational UI Component.
124
+ * To define a message-box template, nest an `<ng-template>` tag with the `kendoChatMessageBoxTemplate` directive inside the `<kendo-chat>` tag
125
+ * [see example]({% slug message_box %}#toc-message-box-template).
126
+ */
127
+ class ChatMessageBoxTemplateDirective {
128
+ constructor(templateRef) {
129
+ this.templateRef = templateRef;
130
+ }
131
+ }
132
+ ChatMessageBoxTemplateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ChatMessageBoxTemplateDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
133
+ ChatMessageBoxTemplateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: ChatMessageBoxTemplateDirective, selector: "[kendoChatMessageBoxTemplate]", ngImport: i0 });
134
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ChatMessageBoxTemplateDirective, decorators: [{
135
+ type: Directive,
136
+ args: [{
137
+ selector: '[kendoChatMessageBoxTemplate]'
138
+ }]
139
+ }], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
140
+
141
+ // eslint-disable max-line-length
142
+
143
+ /**
144
+ * @hidden
145
+ */
146
+ class PreventableEvent {
147
+ constructor() {
148
+ this.prevented = false;
149
+ }
150
+ /**
151
+ * Prevents the default action for a specified event.
152
+ * In this way, the source component suppresses
153
+ * the built-in behavior that follows the event.
154
+ */
155
+ preventDefault() {
156
+ this.prevented = true;
157
+ }
158
+ /**
159
+ * Returns `true` if the event was prevented
160
+ * by any of its subscribers.
161
+ *
162
+ * @returns `true` if the default action was prevented.
163
+ * Otherwise, returns `false`.
164
+ */
165
+ isDefaultPrevented() {
166
+ return this.prevented;
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Arguments for the `executeAction` event. The `executeAction` event fires when the user clicks
172
+ * a quick action button. Calling `preventDefault()` suppresses the built-in action handler.
173
+ */
174
+ class ExecuteActionEvent extends PreventableEvent {
175
+ /**
176
+ * @hidden
177
+ */
178
+ constructor(action, message) {
179
+ super();
180
+ this.action = action;
181
+ this.message = message;
182
+ }
183
+ }
184
+
185
+ /**
186
+ * @hidden
187
+ */
188
+ const closest = (node, predicate) => {
189
+ while (node && !predicate(node)) {
190
+ node = node.parentNode;
191
+ }
192
+ return node;
193
+ };
194
+
195
+ /**
196
+ * @hidden
197
+ */
198
+ class ChatItem {
199
+ }
200
+
201
+ /**
202
+ * @hidden
203
+ */
204
+ const isAuthor = (user, msg) => user && msg.author && user.id === msg.author.id;
205
+ const last = (arr) => arr[arr.length - 1];
206
+ const dateChanged = (curr, prev) => (curr && prev) && (prev.getDate() !== curr.getDate() ||
207
+ prev.getMonth() !== curr.getMonth() ||
208
+ prev.getFullYear() !== curr.getFullYear());
209
+ const addDateMarker = (acc, msg) => {
210
+ const timestamp = msg.timestamp;
211
+ const lastItem = last(acc);
212
+ if (!timestamp) {
213
+ return;
214
+ }
215
+ if (!lastItem || dateChanged(timestamp, lastItem.timestamp)) {
216
+ const dateMarker = {
217
+ type: 'date-marker',
218
+ timestamp: timestamp,
219
+ trackBy: timestamp.getTime()
220
+ };
221
+ acc.push(dateMarker);
222
+ }
223
+ };
224
+ const groupMessages = (acc, msg, isLastMessage) => {
225
+ const lastItem = last(acc);
226
+ let messages;
227
+ if (isDevMode() && !msg.author) {
228
+ throw new Error('Author must be set for message: ' + JSON.stringify(msg));
229
+ }
230
+ if (msg.typing && !isLastMessage) {
231
+ return;
232
+ }
233
+ if (lastItem && lastItem.type === 'message-group') {
234
+ messages = lastItem.messages;
235
+ }
236
+ if (messages && isAuthor(msg.author, last(messages))) {
237
+ messages.push(msg);
238
+ }
239
+ else {
240
+ acc.push({
241
+ type: 'message-group',
242
+ messages: [msg],
243
+ author: msg.author,
244
+ timestamp: msg.timestamp,
245
+ trackBy: msg
246
+ });
247
+ }
248
+ };
249
+ const groupItems = (total) => (acc, msg, index) => {
250
+ const isLastMessage = index === total - 1;
251
+ addDateMarker(acc, msg);
252
+ groupMessages(acc, msg, isLastMessage);
253
+ if (msg.attachments && msg.attachments.length > 1) {
254
+ acc.push({
255
+ type: 'attachment-group',
256
+ attachments: msg.attachments,
257
+ attachmentLayout: msg.attachmentLayout,
258
+ timestamp: msg.timestamp,
259
+ trackBy: msg
260
+ });
261
+ }
262
+ if (msg.suggestedActions && isLastMessage) {
263
+ acc.push({
264
+ type: 'action-group',
265
+ actions: msg.suggestedActions,
266
+ timestamp: msg.timestamp,
267
+ trackBy: msg
268
+ });
269
+ }
270
+ return acc;
271
+ };
272
+ /**
273
+ * @hidden
274
+ */
275
+ const chatView = (messages) => messages.reduce(groupItems(messages.length), []);
276
+
277
+ // eslint-disable no-forward-ref
278
+ /**
279
+ * @hidden
280
+ */
281
+ class MessageComponent extends ChatItem {
282
+ constructor(element, intl) {
283
+ super();
284
+ this.element = element;
285
+ this.intl = intl;
286
+ this.cssClass = true;
287
+ }
288
+ get tabIndex() {
289
+ return this.tabbable ? '0' : '-1';
290
+ }
291
+ formatTimeStamp(date) {
292
+ return this.intl.formatDate(date, { datetime: 'short' });
293
+ }
294
+ focus() {
295
+ this.element.nativeElement.focus();
296
+ }
297
+ }
298
+ MessageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MessageComponent, deps: [{ token: i0.ElementRef }, { token: i1.IntlService }], target: i0.ɵɵFactoryTarget.Component });
299
+ MessageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: MessageComponent, selector: "kendo-chat-message", inputs: { message: "message", tabbable: "tabbable", template: "template" }, host: { properties: { "class.k-message": "this.cssClass", "class.k-state-selected": "this.selected", "class.k-state-focused": "this.selected", "attr.tabIndex": "this.tabIndex" } }, providers: [{
300
+ provide: ChatItem,
301
+ useExisting: forwardRef(() => MessageComponent)
302
+ }], usesInheritance: true, ngImport: i0, template: `
303
+ <time
304
+ [attr.aria-hidden]="!selected"
305
+ class="k-message-time"
306
+ *ngIf="message.timestamp"
307
+ >
308
+ {{ formatTimeStamp(message.timestamp) }}
309
+ </time>
310
+
311
+ <ng-container *ngIf="!message.typing; else typing">
312
+ <div class="k-bubble" *ngIf="template">
313
+ <ng-container
314
+ *ngTemplateOutlet="template.templateRef; context: { $implicit: message };"
315
+ >
316
+ </ng-container>
317
+ </div>
318
+
319
+ <div class="k-bubble" *ngIf="!template && message.text">
320
+ {{message.text}}
321
+ </div>
322
+ </ng-container>
323
+
324
+ <span
325
+ class="k-message-status"
326
+ *ngIf="message.status"
327
+ >
328
+ {{ message.status }}
329
+ </span>
330
+
331
+ <ng-template #typing>
332
+ <div class="k-bubble">
333
+ <div class="k-typing-indicator">
334
+ <span></span>
335
+ <span></span>
336
+ <span></span>
337
+ </div>
338
+ </div>
339
+ </ng-template>
340
+ `, isInline: true, directives: [{ type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
341
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MessageComponent, decorators: [{
342
+ type: Component,
343
+ args: [{
344
+ selector: 'kendo-chat-message',
345
+ providers: [{
346
+ provide: ChatItem,
347
+ useExisting: forwardRef(() => MessageComponent)
348
+ }],
349
+ template: `
350
+ <time
351
+ [attr.aria-hidden]="!selected"
352
+ class="k-message-time"
353
+ *ngIf="message.timestamp"
354
+ >
355
+ {{ formatTimeStamp(message.timestamp) }}
356
+ </time>
357
+
358
+ <ng-container *ngIf="!message.typing; else typing">
359
+ <div class="k-bubble" *ngIf="template">
360
+ <ng-container
361
+ *ngTemplateOutlet="template.templateRef; context: { $implicit: message };"
362
+ >
363
+ </ng-container>
364
+ </div>
365
+
366
+ <div class="k-bubble" *ngIf="!template && message.text">
367
+ {{message.text}}
368
+ </div>
369
+ </ng-container>
370
+
371
+ <span
372
+ class="k-message-status"
373
+ *ngIf="message.status"
374
+ >
375
+ {{ message.status }}
376
+ </span>
377
+
378
+ <ng-template #typing>
379
+ <div class="k-bubble">
380
+ <div class="k-typing-indicator">
381
+ <span></span>
382
+ <span></span>
383
+ <span></span>
384
+ </div>
385
+ </div>
386
+ </ng-template>
387
+ `
388
+ }]
389
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.IntlService }]; }, propDecorators: { message: [{
390
+ type: Input
391
+ }], tabbable: [{
392
+ type: Input
393
+ }], template: [{
394
+ type: Input
395
+ }], cssClass: [{
396
+ type: HostBinding,
397
+ args: ['class.k-message']
398
+ }], selected: [{
399
+ type: HostBinding,
400
+ args: ['class.k-state-selected']
401
+ }, {
402
+ type: HostBinding,
403
+ args: ['class.k-state-focused']
404
+ }], tabIndex: [{
405
+ type: HostBinding,
406
+ args: ['attr.tabIndex']
407
+ }] } });
408
+
409
+ /**
410
+ * @hidden
411
+ */
412
+ class AttachmentComponent {
413
+ set attachment(value) {
414
+ this._attachment = value;
415
+ this.context = {
416
+ $implicit: this.attachment
417
+ };
418
+ }
419
+ get attachment() {
420
+ return this._attachment;
421
+ }
422
+ get image() {
423
+ return this.contentType.indexOf('image/') === 0;
424
+ }
425
+ get unknown() {
426
+ return !this.image;
427
+ }
428
+ get contentType() {
429
+ return this.attachment.contentType || '';
430
+ }
431
+ }
432
+ AttachmentComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: AttachmentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
433
+ AttachmentComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: AttachmentComponent, selector: "kendo-chat-attachment", inputs: { attachment: "attachment", template: "template" }, ngImport: i0, template: `
434
+ <ng-container *ngIf="template">
435
+ <ng-container *ngTemplateOutlet="template.templateRef; context: context;">
436
+ </ng-container>
437
+ </ng-container>
438
+
439
+ <div *ngIf="!template" class="k-card">
440
+ <div class="k-card-body">
441
+ <h5 class="k-card-title" *ngIf="attachment.title">
442
+ {{ attachment.title }}
443
+ </h5>
444
+ <h6 class="k-card-subtitle" *ngIf="attachment.subtitle">
445
+ {{ attachment.subtitle }}
446
+ </h6>
447
+ <img *ngIf="image" [attr.src]="attachment.content" />
448
+ <ng-container *ngIf="unknown">
449
+ {{ attachment.content }}
450
+ </ng-container>
451
+ </div>
452
+ </div>
453
+ `, isInline: true, directives: [{ type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
454
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: AttachmentComponent, decorators: [{
455
+ type: Component,
456
+ args: [{
457
+ selector: 'kendo-chat-attachment',
458
+ template: `
459
+ <ng-container *ngIf="template">
460
+ <ng-container *ngTemplateOutlet="template.templateRef; context: context;">
461
+ </ng-container>
462
+ </ng-container>
463
+
464
+ <div *ngIf="!template" class="k-card">
465
+ <div class="k-card-body">
466
+ <h5 class="k-card-title" *ngIf="attachment.title">
467
+ {{ attachment.title }}
468
+ </h5>
469
+ <h6 class="k-card-subtitle" *ngIf="attachment.subtitle">
470
+ {{ attachment.subtitle }}
471
+ </h6>
472
+ <img *ngIf="image" [attr.src]="attachment.content" />
473
+ <ng-container *ngIf="unknown">
474
+ {{ attachment.content }}
475
+ </ng-container>
476
+ </div>
477
+ </div>
478
+ `
479
+ }]
480
+ }], propDecorators: { attachment: [{
481
+ type: Input
482
+ }], template: [{
483
+ type: Input
484
+ }] } });
485
+
486
+ // eslint-disable no-forward-ref
487
+ /**
488
+ * @hidden
489
+ */
490
+ class MessageAttachmentsComponent extends ChatItem {
491
+ constructor(zone) {
492
+ super();
493
+ this.zone = zone;
494
+ this.scrollPosition = 0;
495
+ this.selectedIndex = 0;
496
+ this.carouselKeyHandlers = {
497
+ [37 /* left */]: (e) => this.navigateTo(e, -1),
498
+ [39 /* right */]: (e) => this.navigateTo(e, 1)
499
+ };
500
+ this.listKeyHandlers = {
501
+ [38 /* up */]: (e) => this.navigateTo(e, -1),
502
+ [40 /* down */]: (e) => this.navigateTo(e, 1)
503
+ };
504
+ }
505
+ get carousel() {
506
+ return this.layout !== 'list';
507
+ }
508
+ ngAfterViewInit() {
509
+ this.zone.runOutsideAngular(() => {
510
+ const scrollDebounceTime = 100;
511
+ this.scrollSubscription = fromEvent(this.deck.nativeElement, 'scroll')
512
+ .pipe(debounceTime(scrollDebounceTime))
513
+ .subscribe(() => this.onScroll());
514
+ });
515
+ }
516
+ ngOnDestroy() {
517
+ this.scrollSubscription.unsubscribe();
518
+ }
519
+ isSelected(index) {
520
+ return this.selectedIndex === index;
521
+ }
522
+ itemKeydown(e, attachment) {
523
+ const keyHandlers = this.layout === 'list' ?
524
+ this.listKeyHandlers : this.carouselKeyHandlers;
525
+ const handler = keyHandlers[e.keyCode];
526
+ if (handler) {
527
+ handler(e, attachment);
528
+ }
529
+ }
530
+ itemClick(index) {
531
+ this.select(index);
532
+ }
533
+ focus() {
534
+ this.select(this.selectedIndex);
535
+ }
536
+ scrollTo(dir) {
537
+ const el = this.deck.nativeElement;
538
+ const scrollStep = el.scrollWidth / this.items.length;
539
+ const max = el.scrollWidth - el.offsetWidth;
540
+ const pos = el.scrollLeft + scrollStep * dir;
541
+ el.scrollLeft = Math.max(0, Math.min(max, pos));
542
+ }
543
+ select(index) {
544
+ this.selectedIndex = index;
545
+ const item = this.items.toArray()[index];
546
+ if (item) {
547
+ item.nativeElement.focus();
548
+ }
549
+ }
550
+ navigateTo(e, offset) {
551
+ const prevIndex = this.selectedIndex;
552
+ const nextIndex = Math.max(0, Math.min(prevIndex + offset, this.items.length - 1));
553
+ if (nextIndex !== prevIndex) {
554
+ this.select(nextIndex);
555
+ e.preventDefault();
556
+ }
557
+ }
558
+ onScroll() {
559
+ const el = this.deck.nativeElement;
560
+ if (el.scrollWidth === 0) {
561
+ return;
562
+ }
563
+ const pos = el.scrollLeft / (el.scrollWidth - el.offsetWidth);
564
+ if (pos !== this.scrollPosition) {
565
+ this.zone.run(() => {
566
+ this.scrollPosition = pos;
567
+ });
568
+ }
569
+ }
570
+ }
571
+ MessageAttachmentsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MessageAttachmentsComponent, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
572
+ MessageAttachmentsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: MessageAttachmentsComponent, selector: "kendo-chat-message-attachments", inputs: { attachments: "attachments", layout: "layout", tabbable: "tabbable", template: "template" }, host: { properties: { "class.k-card-deck-scrollwrap": "this.carousel" } }, providers: [{
573
+ provide: ChatItem,
574
+ useExisting: forwardRef(() => MessageAttachmentsComponent)
575
+ }], viewQueries: [{ propertyName: "deck", first: true, predicate: ["deck"], descendants: true, read: ElementRef, static: true }, { propertyName: "items", predicate: ["item"], descendants: true, read: ElementRef }], usesInheritance: true, ngImport: i0, template: `
576
+ <button
577
+ *ngIf="carousel && scrollPosition > 0"
578
+ (click)="scrollTo(-1)"
579
+ class="k-button k-icon-button k-button-md k-rounded-md k-button-solid k-button-solid-base"
580
+ tabindex="-1">
581
+ <span class="k-icon k-button-icon k-i-arrow-chevron-left"></span>
582
+ </button>
583
+ <div #deck [class.k-card-deck]="carousel">
584
+ <kendo-chat-attachment #item
585
+ *ngFor="let att of attachments; index as index; first as first; last as last"
586
+ [attachment]="att"
587
+ [template]="template"
588
+ [class.k-state-selected]="isSelected(index)"
589
+ [class.k-state-focused]="isSelected(index)"
590
+ [class.k-card-wrap]="true"
591
+ [class.k-first]="first"
592
+ [class.k-last]="last"
593
+ [attr.tabindex]="tabbable && isSelected(index) ? '0' : '-1'"
594
+ (click)="itemClick(index)"
595
+ (keydown)="itemKeydown($event, att)"
596
+ >
597
+ </kendo-chat-attachment>
598
+ </div>
599
+ <button
600
+ *ngIf="carousel && scrollPosition < 1"
601
+ (click)="scrollTo(1)"
602
+ class="k-button k-icon-button k-button-md k-rounded-md k-button-solid k-button-solid-base"
603
+ tabindex="-1">
604
+ <span class="k-icon k-button-icon k-i-arrow-chevron-right"></span>
605
+ </button>
606
+ `, isInline: true, components: [{ type: AttachmentComponent, selector: "kendo-chat-attachment", inputs: ["attachment", "template"] }], directives: [{ type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
607
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MessageAttachmentsComponent, decorators: [{
608
+ type: Component,
609
+ args: [{
610
+ providers: [{
611
+ provide: ChatItem,
612
+ useExisting: forwardRef(() => MessageAttachmentsComponent)
613
+ }],
614
+ selector: 'kendo-chat-message-attachments',
615
+ template: `
616
+ <button
617
+ *ngIf="carousel && scrollPosition > 0"
618
+ (click)="scrollTo(-1)"
619
+ class="k-button k-icon-button k-button-md k-rounded-md k-button-solid k-button-solid-base"
620
+ tabindex="-1">
621
+ <span class="k-icon k-button-icon k-i-arrow-chevron-left"></span>
622
+ </button>
623
+ <div #deck [class.k-card-deck]="carousel">
624
+ <kendo-chat-attachment #item
625
+ *ngFor="let att of attachments; index as index; first as first; last as last"
626
+ [attachment]="att"
627
+ [template]="template"
628
+ [class.k-state-selected]="isSelected(index)"
629
+ [class.k-state-focused]="isSelected(index)"
630
+ [class.k-card-wrap]="true"
631
+ [class.k-first]="first"
632
+ [class.k-last]="last"
633
+ [attr.tabindex]="tabbable && isSelected(index) ? '0' : '-1'"
634
+ (click)="itemClick(index)"
635
+ (keydown)="itemKeydown($event, att)"
636
+ >
637
+ </kendo-chat-attachment>
638
+ </div>
639
+ <button
640
+ *ngIf="carousel && scrollPosition < 1"
641
+ (click)="scrollTo(1)"
642
+ class="k-button k-icon-button k-button-md k-rounded-md k-button-solid k-button-solid-base"
643
+ tabindex="-1">
644
+ <span class="k-icon k-button-icon k-i-arrow-chevron-right"></span>
645
+ </button>
646
+ `
647
+ }]
648
+ }], ctorParameters: function () { return [{ type: i0.NgZone }]; }, propDecorators: { attachments: [{
649
+ type: Input
650
+ }], layout: [{
651
+ type: Input
652
+ }], tabbable: [{
653
+ type: Input
654
+ }], template: [{
655
+ type: Input
656
+ }], carousel: [{
657
+ type: HostBinding,
658
+ args: ['class.k-card-deck-scrollwrap']
659
+ }], deck: [{
660
+ type: ViewChild,
661
+ args: ['deck', { read: ElementRef, static: true }]
662
+ }], items: [{
663
+ type: ViewChildren,
664
+ args: ['item', { read: ElementRef }]
665
+ }] } });
666
+
667
+ // eslint-disable no-forward-ref
668
+ /**
669
+ * @hidden
670
+ */
671
+ class SuggestedActionsComponent extends ChatItem {
672
+ constructor() {
673
+ super(...arguments);
674
+ this.dispatch = new EventEmitter();
675
+ this.defaultClass = true;
676
+ this.selectedIndex = 0;
677
+ this.keyHandlers = {
678
+ [37 /* left */]: (e) => this.navigateTo(e, -1),
679
+ [39 /* right */]: (e) => this.navigateTo(e, 1),
680
+ [13 /* enter */]: (_, action) => this.actionClick(action)
681
+ };
682
+ }
683
+ isSelected(index) {
684
+ return this.selected && this.selectedIndex === index;
685
+ }
686
+ actionClick(action) {
687
+ this.dispatch.next(action);
688
+ }
689
+ actionKeydown(e, action) {
690
+ const handler = this.keyHandlers[e.keyCode];
691
+ if (handler) {
692
+ handler(e, action);
693
+ }
694
+ }
695
+ focus() {
696
+ this.select(this.selectedIndex);
697
+ }
698
+ select(index) {
699
+ this.selectedIndex = index;
700
+ const item = this.items.toArray()[index];
701
+ if (item) {
702
+ item.nativeElement.focus();
703
+ }
704
+ }
705
+ navigateTo(e, offset) {
706
+ const prevIndex = this.selectedIndex;
707
+ const nextIndex = Math.max(0, Math.min(prevIndex + offset, this.items.length - 1));
708
+ if (nextIndex !== prevIndex) {
709
+ this.select(nextIndex);
710
+ e.preventDefault();
711
+ }
712
+ }
713
+ }
714
+ SuggestedActionsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SuggestedActionsComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
715
+ SuggestedActionsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SuggestedActionsComponent, selector: "kendo-chat-suggested-actions", inputs: { actions: "actions", tabbable: "tabbable" }, outputs: { dispatch: "dispatch" }, host: { properties: { "class.k-quick-replies": "this.defaultClass" } }, providers: [{
716
+ provide: ChatItem,
717
+ useExisting: forwardRef(() => SuggestedActionsComponent)
718
+ }], viewQueries: [{ propertyName: "items", predicate: ["item"], descendants: true }], usesInheritance: true, ngImport: i0, template: `
719
+ <span
720
+ #item
721
+ *ngFor="let action of actions; index as index; first as first; last as last"
722
+ class="k-quick-reply"
723
+ [class.k-state-selected]="isSelected(index)"
724
+ [class.k-state-focused]="isSelected(index)"
725
+ [class.k-first]="first"
726
+ [class.k-last]="last"
727
+ [attr.tabindex]="tabbable && selectedIndex === index ? '0' : '-1'"
728
+ (click)="actionClick(action)"
729
+ (keydown)="actionKeydown($event, action)"
730
+ >
731
+ {{ action.title || action.value }}
732
+ </span>
733
+ `, isInline: true, directives: [{ type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
734
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SuggestedActionsComponent, decorators: [{
735
+ type: Component,
736
+ args: [{
737
+ selector: 'kendo-chat-suggested-actions',
738
+ providers: [{
739
+ provide: ChatItem,
740
+ useExisting: forwardRef(() => SuggestedActionsComponent)
741
+ }],
742
+ template: `
743
+ <span
744
+ #item
745
+ *ngFor="let action of actions; index as index; first as first; last as last"
746
+ class="k-quick-reply"
747
+ [class.k-state-selected]="isSelected(index)"
748
+ [class.k-state-focused]="isSelected(index)"
749
+ [class.k-first]="first"
750
+ [class.k-last]="last"
751
+ [attr.tabindex]="tabbable && selectedIndex === index ? '0' : '-1'"
752
+ (click)="actionClick(action)"
753
+ (keydown)="actionKeydown($event, action)"
754
+ >
755
+ {{ action.title || action.value }}
756
+ </span>
757
+ `
758
+ }]
759
+ }], propDecorators: { actions: [{
760
+ type: Input
761
+ }], tabbable: [{
762
+ type: Input
763
+ }], dispatch: [{
764
+ type: Output
765
+ }], defaultClass: [{
766
+ type: HostBinding,
767
+ args: ['class.k-quick-replies']
768
+ }], items: [{
769
+ type: ViewChildren,
770
+ args: ['item']
771
+ }] } });
772
+
773
+ /**
774
+ * @hidden
775
+ */
776
+ class MessageListComponent {
777
+ constructor(element, intl) {
778
+ this.element = element;
779
+ this.intl = intl;
780
+ this.executeAction = new EventEmitter();
781
+ this.navigate = new EventEmitter();
782
+ this.resize = new EventEmitter();
783
+ this.cssClass = true;
784
+ this.view = [];
785
+ this.keyActions = {
786
+ [38 /* up */]: (e) => this.navigateTo(e, -1),
787
+ [40 /* down */]: (e) => this.navigateTo(e, 1)
788
+ };
789
+ }
790
+ set messages(value) {
791
+ const data = value || [];
792
+ this.view = chatView(data);
793
+ this._messages = data;
794
+ }
795
+ get messages() {
796
+ return this._messages;
797
+ }
798
+ ngAfterViewInit() {
799
+ this.selectedItem = this.items.last;
800
+ }
801
+ onResize() {
802
+ this.resize.emit();
803
+ }
804
+ formatTimeStamp(date) {
805
+ return this.intl.formatDate(date, { date: 'full' });
806
+ }
807
+ onKeydown(e) {
808
+ const action = this.keyActions[e.keyCode];
809
+ if (action) {
810
+ action(e);
811
+ }
812
+ }
813
+ onBlur(args) {
814
+ const next = args.relatedTarget || document.activeElement;
815
+ const outside = !closest(next, (node) => node === this.element.nativeElement);
816
+ if (outside) {
817
+ this.select(null);
818
+ }
819
+ }
820
+ isOwnMessage(msg) {
821
+ return isAuthor(this.user, msg);
822
+ }
823
+ dispatchAction(action, message) {
824
+ const args = new ExecuteActionEvent(action, message);
825
+ this.executeAction.emit(args);
826
+ }
827
+ trackGroup(_index, item) {
828
+ return item.trackBy;
829
+ }
830
+ select(item) {
831
+ const prevItem = this.selectedItem;
832
+ if (prevItem) {
833
+ prevItem.selected = false;
834
+ }
835
+ if (item) {
836
+ item.selected = true;
837
+ this.selectedItem = item;
838
+ }
839
+ }
840
+ last(items) {
841
+ if (!items || items.length === 0) {
842
+ return;
843
+ }
844
+ return items[items.length - 1];
845
+ }
846
+ navigateTo(e, offset) {
847
+ const items = this.items.toArray();
848
+ const prevItem = this.selectedItem;
849
+ const prevIndex = items.indexOf(prevItem);
850
+ const nextIndex = Math.max(0, Math.min(prevIndex + offset, this.items.length - 1));
851
+ const nextItem = items[nextIndex];
852
+ if (nextItem !== prevItem) {
853
+ this.select(nextItem);
854
+ nextItem.focus();
855
+ this.navigate.emit();
856
+ e.preventDefault();
857
+ }
858
+ }
859
+ }
860
+ MessageListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MessageListComponent, deps: [{ token: i0.ElementRef }, { token: i1.IntlService }], target: i0.ɵɵFactoryTarget.Component });
861
+ MessageListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: MessageListComponent, selector: "kendo-chat-message-list", inputs: { messages: "messages", attachmentTemplate: "attachmentTemplate", messageTemplate: "messageTemplate", user: "user" }, outputs: { executeAction: "executeAction", navigate: "navigate", resize: "resize" }, host: { listeners: { "keydown": "onKeydown($event)", "focusout": "onBlur($event)" }, properties: { "class.k-message-list-content": "this.cssClass" } }, viewQueries: [{ propertyName: "items", predicate: ChatItem, descendants: true }], ngImport: i0, template: `
862
+ <ng-container *ngFor="let group of view; last as lastGroup; trackBy: trackGroup">
863
+ <ng-container [ngSwitch]="group.type">
864
+ <div
865
+ *ngSwitchCase="'date-marker'"
866
+ class="k-timestamp"
867
+ >
868
+ {{ formatTimeStamp(group.timestamp) }}
869
+ </div>
870
+ <div
871
+ *ngSwitchCase="'message-group'"
872
+ class="k-message-group"
873
+ [class.k-alt]="isOwnMessage(group.messages[0])"
874
+ [class.k-no-avatar]="!group.author.avatarUrl"
875
+ >
876
+ <img
877
+ *ngIf="group.author.avatarUrl"
878
+ [attr.src]="group.author.avatarUrl"
879
+ class="k-avatar"
880
+ />
881
+ <p *ngIf="group.author.name" class="k-author">{{ group.author.name }}</p>
882
+ <ng-container
883
+ *ngFor="let msg of group.messages; first as firstMessage; last as lastMessage"
884
+ >
885
+ <img *ngIf="msg.user?.avatarUrl" [src]="msg.user?.avatarUrl" class="k-avatar">
886
+ <kendo-chat-message #message
887
+ [message]="msg"
888
+ [tabbable]="lastGroup && lastMessage"
889
+ [template]="messageTemplate"
890
+ (click)="select(message)"
891
+ (focus)="select(message)"
892
+ [class.k-only]="group.messages.length === 1"
893
+ [class.k-first]="group.messages.length > 1 && firstMessage"
894
+ [class.k-last]="group.messages.length > 1 && lastMessage"
895
+ >
896
+ </kendo-chat-message>
897
+
898
+ <kendo-chat-attachment
899
+ *ngIf="msg.attachments && msg.attachments.length === 1"
900
+ [attachment]="msg.attachments[0]"
901
+ [template]="attachmentTemplate"
902
+ >
903
+ </kendo-chat-attachment>
904
+ </ng-container>
905
+ </div>
906
+
907
+ <kendo-chat-message-attachments #attachments
908
+ *ngSwitchCase="'attachment-group'"
909
+ [attachments]="group.attachments"
910
+ [layout]="group.attachmentLayout"
911
+ [tabbable]="lastGroup"
912
+ [template]="attachmentTemplate"
913
+ (click)="select(attachments)"
914
+ (focus)="select(attachments)"
915
+ >
916
+ </kendo-chat-message-attachments>
917
+
918
+ <kendo-chat-suggested-actions #actions
919
+ *ngSwitchCase="'action-group'"
920
+ [actions]="group.actions"
921
+ [tabbable]="lastGroup"
922
+ (dispatch)="dispatchAction($event, last(group.messages))"
923
+ (click)="select(actions)"
924
+ (focus)="select(actions)"
925
+ >
926
+ </kendo-chat-suggested-actions>
927
+ </ng-container>
928
+ </ng-container>
929
+ <kendo-resize-sensor (resize)="onResize()">
930
+ </kendo-resize-sensor>
931
+ `, isInline: true, components: [{ type: MessageComponent, selector: "kendo-chat-message", inputs: ["message", "tabbable", "template"] }, { type: AttachmentComponent, selector: "kendo-chat-attachment", inputs: ["attachment", "template"] }, { type: MessageAttachmentsComponent, selector: "kendo-chat-message-attachments", inputs: ["attachments", "layout", "tabbable", "template"] }, { type: SuggestedActionsComponent, selector: "kendo-chat-suggested-actions", inputs: ["actions", "tabbable"], outputs: ["dispatch"] }, { type: i6.ResizeSensorComponent, selector: "kendo-resize-sensor", inputs: ["rateLimit"], outputs: ["resize"] }], directives: [{ type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1$1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i1$1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
932
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MessageListComponent, decorators: [{
933
+ type: Component,
934
+ args: [{
935
+ selector: 'kendo-chat-message-list',
936
+ template: `
937
+ <ng-container *ngFor="let group of view; last as lastGroup; trackBy: trackGroup">
938
+ <ng-container [ngSwitch]="group.type">
939
+ <div
940
+ *ngSwitchCase="'date-marker'"
941
+ class="k-timestamp"
942
+ >
943
+ {{ formatTimeStamp(group.timestamp) }}
944
+ </div>
945
+ <div
946
+ *ngSwitchCase="'message-group'"
947
+ class="k-message-group"
948
+ [class.k-alt]="isOwnMessage(group.messages[0])"
949
+ [class.k-no-avatar]="!group.author.avatarUrl"
950
+ >
951
+ <img
952
+ *ngIf="group.author.avatarUrl"
953
+ [attr.src]="group.author.avatarUrl"
954
+ class="k-avatar"
955
+ />
956
+ <p *ngIf="group.author.name" class="k-author">{{ group.author.name }}</p>
957
+ <ng-container
958
+ *ngFor="let msg of group.messages; first as firstMessage; last as lastMessage"
959
+ >
960
+ <img *ngIf="msg.user?.avatarUrl" [src]="msg.user?.avatarUrl" class="k-avatar">
961
+ <kendo-chat-message #message
962
+ [message]="msg"
963
+ [tabbable]="lastGroup && lastMessage"
964
+ [template]="messageTemplate"
965
+ (click)="select(message)"
966
+ (focus)="select(message)"
967
+ [class.k-only]="group.messages.length === 1"
968
+ [class.k-first]="group.messages.length > 1 && firstMessage"
969
+ [class.k-last]="group.messages.length > 1 && lastMessage"
970
+ >
971
+ </kendo-chat-message>
972
+
973
+ <kendo-chat-attachment
974
+ *ngIf="msg.attachments && msg.attachments.length === 1"
975
+ [attachment]="msg.attachments[0]"
976
+ [template]="attachmentTemplate"
977
+ >
978
+ </kendo-chat-attachment>
979
+ </ng-container>
980
+ </div>
981
+
982
+ <kendo-chat-message-attachments #attachments
983
+ *ngSwitchCase="'attachment-group'"
984
+ [attachments]="group.attachments"
985
+ [layout]="group.attachmentLayout"
986
+ [tabbable]="lastGroup"
987
+ [template]="attachmentTemplate"
988
+ (click)="select(attachments)"
989
+ (focus)="select(attachments)"
990
+ >
991
+ </kendo-chat-message-attachments>
992
+
993
+ <kendo-chat-suggested-actions #actions
994
+ *ngSwitchCase="'action-group'"
995
+ [actions]="group.actions"
996
+ [tabbable]="lastGroup"
997
+ (dispatch)="dispatchAction($event, last(group.messages))"
998
+ (click)="select(actions)"
999
+ (focus)="select(actions)"
1000
+ >
1001
+ </kendo-chat-suggested-actions>
1002
+ </ng-container>
1003
+ </ng-container>
1004
+ <kendo-resize-sensor (resize)="onResize()">
1005
+ </kendo-resize-sensor>
1006
+ `
1007
+ }]
1008
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.IntlService }]; }, propDecorators: { messages: [{
1009
+ type: Input
1010
+ }], attachmentTemplate: [{
1011
+ type: Input
1012
+ }], messageTemplate: [{
1013
+ type: Input
1014
+ }], user: [{
1015
+ type: Input
1016
+ }], executeAction: [{
1017
+ type: Output
1018
+ }], navigate: [{
1019
+ type: Output
1020
+ }], resize: [{
1021
+ type: Output
1022
+ }], items: [{
1023
+ type: ViewChildren,
1024
+ args: [ChatItem]
1025
+ }], cssClass: [{
1026
+ type: HostBinding,
1027
+ args: ['class.k-message-list-content']
1028
+ }], onKeydown: [{
1029
+ type: HostListener,
1030
+ args: ['keydown', ['$event']]
1031
+ }], onBlur: [{
1032
+ type: HostListener,
1033
+ args: ['focusout', ['$event']]
1034
+ }] } });
1035
+
1036
+ /**
1037
+ * @hidden
1038
+ */
1039
+ class FocusedStateDirective {
1040
+ constructor() {
1041
+ this.focused = false;
1042
+ }
1043
+ onFocus() {
1044
+ this.focused = true;
1045
+ }
1046
+ onBlur() {
1047
+ this.focused = false;
1048
+ }
1049
+ }
1050
+ FocusedStateDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FocusedStateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1051
+ FocusedStateDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: FocusedStateDirective, selector: "[kendoChatFocusedState]", host: { listeners: { "focusin": "onFocus()", "focusout": "onBlur()" }, properties: { "class.k-focus": "this.focused" } }, ngImport: i0 });
1052
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: FocusedStateDirective, decorators: [{
1053
+ type: Directive,
1054
+ args: [{
1055
+ selector: '[kendoChatFocusedState]'
1056
+ }]
1057
+ }], propDecorators: { focused: [{
1058
+ type: HostBinding,
1059
+ args: ['class.k-focus']
1060
+ }], onFocus: [{
1061
+ type: HostListener,
1062
+ args: ['focusin']
1063
+ }], onBlur: [{
1064
+ type: HostListener,
1065
+ args: ['focusout']
1066
+ }] } });
1067
+
1068
+ // tslint:disable-next-line:max-line-length
1069
+ const sendIcon = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 16 16"><path d="M0,14.3c-0.1,0.6,0.3,0.8,0.8,0.6l14.8-6.5c0.5-0.2,0.5-0.6,0-0.8L0.8,1.1C0.3,0.9-0.1,1.1,0,1.7l0.7,4.2C0.8,6.5,1.4,7,1.9,7.1l8.8,0.8c0.6,0.1,0.6,0.1,0,0.2L1.9,8.9C1.4,9,0.8,9.5,0.7,10.1L0,14.3z"/></svg>';
1070
+ /**
1071
+ * @hidden
1072
+ */
1073
+ class MessageBoxComponent {
1074
+ constructor() {
1075
+ this.hostClasses = 'k-message-box k-input k-input-md k-rounded-md k-input-solid';
1076
+ this.sendMessage = new EventEmitter();
1077
+ }
1078
+ get messageBoxValue() {
1079
+ return this.type === 'textarea';
1080
+ }
1081
+ /**
1082
+ * @hidden
1083
+ */
1084
+ sendClick() {
1085
+ const input = this.messageBoxInput.nativeElement;
1086
+ const value = input.value;
1087
+ if (!value) {
1088
+ return;
1089
+ }
1090
+ const message = {
1091
+ author: this.user,
1092
+ text: value,
1093
+ timestamp: new Date()
1094
+ };
1095
+ this.sendMessage.emit(new SendMessageEvent(message));
1096
+ input.value = null;
1097
+ input.focus();
1098
+ this.autoScroll = true;
1099
+ }
1100
+ /**
1101
+ * @hidden
1102
+ */
1103
+ inputKeydown(e) {
1104
+ if (e.keyCode === Keys.Enter) {
1105
+ this.sendClick();
1106
+ }
1107
+ }
1108
+ /**
1109
+ * @hidden
1110
+ */
1111
+ textAreaKeydown(e) {
1112
+ const isEnter = e.keyCode === Keys.Enter;
1113
+ if (!isEnter) {
1114
+ return;
1115
+ }
1116
+ const newLine = (e.metaKey || e.ctrlKey);
1117
+ const enterOnly = !(e.shiftKey || e.metaKey || e.ctrlKey);
1118
+ if (enterOnly) {
1119
+ e.preventDefault();
1120
+ this.sendClick();
1121
+ }
1122
+ if (newLine) {
1123
+ this.messageBoxInput.nativeElement.value += `\r\n`;
1124
+ }
1125
+ }
1126
+ /**
1127
+ * @hidden
1128
+ */
1129
+ textFor(key) {
1130
+ return this.localization.get(key);
1131
+ }
1132
+ }
1133
+ MessageBoxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MessageBoxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1134
+ MessageBoxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: MessageBoxComponent, selector: "kendo-message-box", inputs: { user: "user", autoScroll: "autoScroll", type: "type", localization: "localization", messageBoxTemplate: "messageBoxTemplate" }, outputs: { sendMessage: "sendMessage" }, host: { properties: { "class": "this.hostClasses", "class.!k-align-items-end": "this.messageBoxValue" } }, viewQueries: [{ propertyName: "messageBoxInput", first: true, predicate: ["messageBoxInput"], descendants: true }], ngImport: i0, template: "\n <ng-container *ngIf=\"!messageBoxTemplate\">\n <input\n *ngIf=\"type === 'textbox'\"\n #messageBoxInput\n kendoChatFocusedState\n type=\"text\"\n class=\"k-textbox k-input k-input-md k-input-solid\"\n [placeholder]=\"textFor('messagePlaceholder')\"\n (keydown)=\"inputKeydown($event)\"\n />\n\n <textarea\n *ngIf=\"type === 'textarea'\"\n #messageBoxInput\n kendoChatFocusedState\n [rows]=\"3\"\n class=\"k-textarea k-input k-input-md k-input-solid !k-overflow-y-auto k-resize-none\"\n [placeholder]=\"textFor('messagePlaceholder')\"\n (keydown)=\"textAreaKeydown($event)\"\n ></textarea>\n\n <button\n kendoButton\n fillMode=\"flat\"\n class=\"k-button-send\"\n [tabindex]=\"0\"\n [attr.title]=\"textFor('send')\"\n (click)=\"sendClick()\"\n >\n <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" x=\"0px\" y=\"0px\" viewBox=\"0 0 16 16\"><path d=\"M0,14.3c-0.1,0.6,0.3,0.8,0.8,0.6l14.8-6.5c0.5-0.2,0.5-0.6,0-0.8L0.8,1.1C0.3,0.9-0.1,1.1,0,1.7l0.7,4.2C0.8,6.5,1.4,7,1.9,7.1l8.8,0.8c0.6,0.1,0.6,0.1,0,0.2L1.9,8.9C1.4,9,0.8,9.5,0.7,10.1L0,14.3z\"/></svg>\n </button>\n </ng-container>\n\n <ng-template *ngIf=\"messageBoxTemplate\" [ngTemplateOutlet]=\"messageBoxTemplate?.templateRef\"></ng-template>\n", isInline: true, directives: [{ type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: FocusedStateDirective, selector: "[kendoChatFocusedState]" }, { type: i3.ButtonDirective, selector: "button[kendoButton], span[kendoButton]", inputs: ["toggleable", "togglable", "selected", "tabIndex", "icon", "iconClass", "imageUrl", "disabled", "size", "rounded", "fillMode", "themeColor", "role", "primary", "look"], outputs: ["selectedChange", "click"], exportAs: ["kendoButton"] }, { type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
1135
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MessageBoxComponent, decorators: [{
1136
+ type: Component,
1137
+ args: [{
1138
+ selector: 'kendo-message-box',
1139
+ template: `
1140
+ <ng-container *ngIf="!messageBoxTemplate">
1141
+ <input
1142
+ *ngIf="type === 'textbox'"
1143
+ #messageBoxInput
1144
+ kendoChatFocusedState
1145
+ type="text"
1146
+ class="k-textbox k-input k-input-md k-input-solid"
1147
+ [placeholder]="textFor('messagePlaceholder')"
1148
+ (keydown)="inputKeydown($event)"
1149
+ />
1150
+
1151
+ <textarea
1152
+ *ngIf="type === 'textarea'"
1153
+ #messageBoxInput
1154
+ kendoChatFocusedState
1155
+ [rows]="3"
1156
+ class="k-textarea k-input k-input-md k-input-solid !k-overflow-y-auto k-resize-none"
1157
+ [placeholder]="textFor('messagePlaceholder')"
1158
+ (keydown)="textAreaKeydown($event)"
1159
+ ></textarea>
1160
+
1161
+ <button
1162
+ kendoButton
1163
+ fillMode="flat"
1164
+ class="k-button-send"
1165
+ [tabindex]="0"
1166
+ [attr.title]="textFor('send')"
1167
+ (click)="sendClick()"
1168
+ >
1169
+ ${sendIcon}
1170
+ </button>
1171
+ </ng-container>
1172
+
1173
+ <ng-template *ngIf="messageBoxTemplate" [ngTemplateOutlet]="messageBoxTemplate?.templateRef"></ng-template>
1174
+ `
1175
+ }]
1176
+ }], propDecorators: { hostClasses: [{
1177
+ type: HostBinding,
1178
+ args: ['class']
1179
+ }], messageBoxValue: [{
1180
+ type: HostBinding,
1181
+ args: ['class.\!k-align-items-end']
1182
+ }], messageBoxInput: [{
1183
+ type: ViewChild,
1184
+ args: ['messageBoxInput', { static: false }]
1185
+ }], user: [{
1186
+ type: Input
1187
+ }], autoScroll: [{
1188
+ type: Input
1189
+ }], type: [{
1190
+ type: Input
1191
+ }], localization: [{
1192
+ type: Input
1193
+ }], messageBoxTemplate: [{
1194
+ type: Input
1195
+ }], sendMessage: [{
1196
+ type: Output
1197
+ }] } });
1198
+
1199
+ /**
1200
+ * @hidden
1201
+ */
1202
+ class Messages extends ComponentMessages {
1203
+ }
1204
+ Messages.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: Messages, deps: null, target: i0.ɵɵFactoryTarget.Directive });
1205
+ Messages.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: Messages, selector: "kendoConversationalUIMessages", inputs: { messagePlaceholder: "messagePlaceholder", send: "send" }, usesInheritance: true, ngImport: i0 });
1206
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: Messages, decorators: [{
1207
+ type: Directive,
1208
+ args: [{
1209
+ // eslint-disable-next-line @angular-eslint/directive-selector
1210
+ selector: 'kendoConversationalUIMessages'
1211
+ }]
1212
+ }], propDecorators: { messagePlaceholder: [{
1213
+ type: Input
1214
+ }], send: [{
1215
+ type: Input
1216
+ }] } });
1217
+
1218
+ // eslint-disable no-forward-ref
1219
+ /**
1220
+ * @hidden
1221
+ */
1222
+ class LocalizedMessagesDirective extends Messages {
1223
+ constructor(service) {
1224
+ super();
1225
+ this.service = service;
1226
+ }
1227
+ }
1228
+ LocalizedMessagesDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LocalizedMessagesDirective, deps: [{ token: i1$2.LocalizationService }], target: i0.ɵɵFactoryTarget.Directive });
1229
+ LocalizedMessagesDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: LocalizedMessagesDirective, selector: "[kendoChatLocalizedMessages]", providers: [
1230
+ {
1231
+ provide: Messages,
1232
+ useExisting: forwardRef(() => LocalizedMessagesDirective)
1233
+ }
1234
+ ], usesInheritance: true, ngImport: i0 });
1235
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: LocalizedMessagesDirective, decorators: [{
1236
+ type: Directive,
1237
+ args: [{
1238
+ providers: [
1239
+ {
1240
+ provide: Messages,
1241
+ useExisting: forwardRef(() => LocalizedMessagesDirective)
1242
+ }
1243
+ ],
1244
+ selector: '[kendoChatLocalizedMessages]'
1245
+ }]
1246
+ }], ctorParameters: function () { return [{ type: i1$2.LocalizationService }]; } });
1247
+
1248
+ // Consider scroll to be at the bottom when within this number of pixels from the container height.
1249
+ const maxDelta = 2;
1250
+ /**
1251
+ * @hidden
1252
+ */
1253
+ class ScrollAnchorDirective {
1254
+ constructor(element, zone, renderer) {
1255
+ this.element = element;
1256
+ this.zone = zone;
1257
+ this.renderer = renderer;
1258
+ this.autoScroll = true;
1259
+ this.autoScrollChange = new EventEmitter();
1260
+ this.overflowAnchor = 'none';
1261
+ this.scrolling = false;
1262
+ }
1263
+ ngOnInit() {
1264
+ this.zone.runOutsideAngular(() => {
1265
+ this.unsubscribe = this.renderer.listen(this.element.nativeElement, 'scroll', () => this.onScroll());
1266
+ });
1267
+ }
1268
+ ngAfterViewInit() {
1269
+ this.scrollToBottom();
1270
+ }
1271
+ ngOnDestroy() {
1272
+ if (this.unsubscribe) {
1273
+ this.unsubscribe();
1274
+ }
1275
+ }
1276
+ onScroll() {
1277
+ if (this.scrolling) {
1278
+ return;
1279
+ }
1280
+ const el = this.element.nativeElement;
1281
+ const bottom = el.scrollTop + el.offsetHeight;
1282
+ const height = el.scrollHeight;
1283
+ const atBottom = height - bottom < maxDelta;
1284
+ if (this.autoScroll !== atBottom) {
1285
+ this.zone.run(() => {
1286
+ this.autoScroll = atBottom;
1287
+ this.autoScrollChange.emit(this.autoScroll);
1288
+ });
1289
+ }
1290
+ }
1291
+ scrollToBottom() {
1292
+ if (!this.autoScroll) {
1293
+ return;
1294
+ }
1295
+ const el = this.element.nativeElement;
1296
+ el.scrollTop = el.scrollHeight - el.clientHeight;
1297
+ this.scrolling = true;
1298
+ this.zone.runOutsideAngular(() => setTimeout(() => this.scrolling = false, 1000));
1299
+ }
1300
+ }
1301
+ ScrollAnchorDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ScrollAnchorDirective, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
1302
+ ScrollAnchorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: ScrollAnchorDirective, selector: "[kendoChatScrollAnchor]", inputs: { autoScroll: "autoScroll" }, outputs: { autoScrollChange: "autoScrollChange" }, host: { properties: { "style.overflow-anchor": "this.overflowAnchor" } }, exportAs: ["scrollAnchor"], ngImport: i0 });
1303
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ScrollAnchorDirective, decorators: [{
1304
+ type: Directive,
1305
+ args: [{
1306
+ selector: '[kendoChatScrollAnchor]',
1307
+ exportAs: 'scrollAnchor'
1308
+ }]
1309
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.Renderer2 }]; }, propDecorators: { autoScroll: [{
1310
+ type: Input
1311
+ }], autoScrollChange: [{
1312
+ type: Output
1313
+ }], overflowAnchor: [{
1314
+ type: HostBinding,
1315
+ args: ['style.overflow-anchor']
1316
+ }] } });
1317
+
1318
+ /**
1319
+ * Represents the Kendo UI Chat component for Angular.
1320
+ *
1321
+ * {% meta height:700 %}
1322
+ * {% embed_file echo/app.component.ts preview %}
1323
+ * {% embed_file shared/app.module.ts %}
1324
+ * {% embed_file shared/main.ts hidden %}
1325
+ * {% endmeta %}
1326
+ *
1327
+ */
1328
+ class ChatComponent {
1329
+ constructor(localization, zone) {
1330
+ this.localization = localization;
1331
+ this.zone = zone;
1332
+ /**
1333
+ * Used to switch between a one-liner input or a textarea.
1334
+ * ([see example]({% slug message_box %})#toc-message-box-types).
1335
+ * @default input
1336
+ */
1337
+ this.messageBoxType = 'textbox';
1338
+ /**
1339
+ * Fires when the user types a message and clicks the **Send** button or presses **Enter**.
1340
+ * Emits the [`SendMessageEvent`]({% slug api_conversational-ui_sendmessageevent %}).
1341
+ *
1342
+ * > The message is not automatically appended to the `messages` array.
1343
+ */
1344
+ this.sendMessage = new EventEmitter();
1345
+ /**
1346
+ * Fires when the user clicks a quick action button.
1347
+ * The Chat internally handles the `reply`, `openUrl`, and `call` [known actions]({% slug api_conversational-ui_actiontype %}).
1348
+ *
1349
+ * Emits the [`ExecuteActionEvent`]({% slug api_conversational-ui_executeactionevent %}).
1350
+ * The event is preventable. If `preventDefault` is called, the built-in action will be suppressed.
1351
+ */
1352
+ this.executeAction = new EventEmitter();
1353
+ /**
1354
+ * @hidden
1355
+ */
1356
+ this.autoScroll = true;
1357
+ validatePackage(packageMetadata);
1358
+ this.direction = localization.rtl ? 'rtl' : 'ltr';
1359
+ this.localizationChangeSubscription = localization.changes.subscribe(({ rtl }) => {
1360
+ this.direction = rtl ? 'rtl' : 'ltr';
1361
+ });
1362
+ }
1363
+ get className() {
1364
+ return 'k-chat';
1365
+ }
1366
+ get dirAttr() {
1367
+ return this.direction;
1368
+ }
1369
+ /**
1370
+ * @hidden
1371
+ */
1372
+ get localizationText() {
1373
+ return this.localization;
1374
+ }
1375
+ ngOnChanges() {
1376
+ this.zone.runOutsideAngular(() => setTimeout(() => {
1377
+ this.messageList.nativeElement.style.flex = '1 1 auto';
1378
+ }));
1379
+ }
1380
+ ngAfterViewInit() {
1381
+ if (!isDevMode()) {
1382
+ return;
1383
+ }
1384
+ if (!this.user) {
1385
+ throw new Error('User must be set and have a valid id.');
1386
+ }
1387
+ }
1388
+ ngOnDestroy() {
1389
+ if (this.localizationChangeSubscription) {
1390
+ this.localizationChangeSubscription.unsubscribe();
1391
+ }
1392
+ }
1393
+ /**
1394
+ * @hidden
1395
+ */
1396
+ dispatchAction(e) {
1397
+ this.executeAction.emit(e);
1398
+ if (!e.isDefaultPrevented()) {
1399
+ const handler = makeHandler(e.action);
1400
+ handler(e.action, this);
1401
+ if (!this.messageBoxTemplate) {
1402
+ this.messageBox.messageBoxInput.nativeElement.focus();
1403
+ }
1404
+ }
1405
+ }
1406
+ /**
1407
+ * @hidden
1408
+ */
1409
+ textFor(key) {
1410
+ return this.localization.get(key);
1411
+ }
1412
+ }
1413
+ ChatComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ChatComponent, deps: [{ token: i1$2.LocalizationService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
1414
+ ChatComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: ChatComponent, selector: "kendo-chat", inputs: { messages: "messages", user: "user", messageBoxType: "messageBoxType" }, outputs: { sendMessage: "sendMessage", executeAction: "executeAction" }, host: { properties: { "class": "this.className", "attr.dir": "this.dirAttr" } }, providers: [
1415
+ LocalizationService,
1416
+ {
1417
+ provide: L10N_PREFIX,
1418
+ useValue: 'kendo.chat'
1419
+ }
1420
+ ], queries: [{ propertyName: "attachmentTemplate", first: true, predicate: AttachmentTemplateDirective, descendants: true }, { propertyName: "messageTemplate", first: true, predicate: MessageTemplateDirective, descendants: true }, { propertyName: "messageBoxTemplate", first: true, predicate: ChatMessageBoxTemplateDirective, descendants: true }], viewQueries: [{ propertyName: "messageBox", first: true, predicate: ["messageBox"], descendants: true }, { propertyName: "messageList", first: true, predicate: ["messageList"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: `
1421
+ <ng-container
1422
+ kendoChatLocalizedMessages
1423
+ i18n-messagePlaceholder="kendo.chat.messagePlaceholder|The placholder text of the message text input"
1424
+ messagePlaceholder="Type a message..."
1425
+
1426
+ i18n-send="kendo.chat.send|The text for the Send button"
1427
+ send="Send..."
1428
+ >
1429
+ </ng-container>
1430
+
1431
+ <div
1432
+ #messageList
1433
+ class="k-message-list k-avatars"
1434
+ aria-live="polite" role="log"
1435
+ kendoChatScrollAnchor
1436
+ #anchor="scrollAnchor"
1437
+ [(autoScroll)]="autoScroll"
1438
+ >
1439
+ <kendo-chat-message-list
1440
+ [messages]="messages"
1441
+ [messageTemplate]="messageTemplate"
1442
+ [attachmentTemplate]="attachmentTemplate"
1443
+ [user]="user"
1444
+ (executeAction)="dispatchAction($event)"
1445
+ (resize)="anchor.scrollToBottom()"
1446
+ (navigate)="this.autoScroll = false"
1447
+ >
1448
+ </kendo-chat-message-list>
1449
+ </div>
1450
+ <kendo-message-box
1451
+ #messageBox
1452
+ [messageBoxTemplate]="messageBoxTemplate"
1453
+ [type]="messageBoxType"
1454
+ [user]="user"
1455
+ [autoScroll]="autoScroll"
1456
+ [localization]="localizationText"
1457
+ (sendMessage)="sendMessage.emit($event)"
1458
+ >
1459
+ </kendo-message-box>
1460
+ `, isInline: true, components: [{ type: MessageListComponent, selector: "kendo-chat-message-list", inputs: ["messages", "attachmentTemplate", "messageTemplate", "user"], outputs: ["executeAction", "navigate", "resize"] }, { type: MessageBoxComponent, selector: "kendo-message-box", inputs: ["user", "autoScroll", "type", "localization", "messageBoxTemplate"], outputs: ["sendMessage"] }], directives: [{ type: LocalizedMessagesDirective, selector: "[kendoChatLocalizedMessages]" }, { type: ScrollAnchorDirective, selector: "[kendoChatScrollAnchor]", inputs: ["autoScroll"], outputs: ["autoScrollChange"], exportAs: ["scrollAnchor"] }] });
1461
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ChatComponent, decorators: [{
1462
+ type: Component,
1463
+ args: [{
1464
+ providers: [
1465
+ LocalizationService,
1466
+ {
1467
+ provide: L10N_PREFIX,
1468
+ useValue: 'kendo.chat'
1469
+ }
1470
+ ],
1471
+ selector: 'kendo-chat',
1472
+ template: `
1473
+ <ng-container
1474
+ kendoChatLocalizedMessages
1475
+ i18n-messagePlaceholder="kendo.chat.messagePlaceholder|The placholder text of the message text input"
1476
+ messagePlaceholder="Type a message..."
1477
+
1478
+ i18n-send="kendo.chat.send|The text for the Send button"
1479
+ send="Send..."
1480
+ >
1481
+ </ng-container>
1482
+
1483
+ <div
1484
+ #messageList
1485
+ class="k-message-list k-avatars"
1486
+ aria-live="polite" role="log"
1487
+ kendoChatScrollAnchor
1488
+ #anchor="scrollAnchor"
1489
+ [(autoScroll)]="autoScroll"
1490
+ >
1491
+ <kendo-chat-message-list
1492
+ [messages]="messages"
1493
+ [messageTemplate]="messageTemplate"
1494
+ [attachmentTemplate]="attachmentTemplate"
1495
+ [user]="user"
1496
+ (executeAction)="dispatchAction($event)"
1497
+ (resize)="anchor.scrollToBottom()"
1498
+ (navigate)="this.autoScroll = false"
1499
+ >
1500
+ </kendo-chat-message-list>
1501
+ </div>
1502
+ <kendo-message-box
1503
+ #messageBox
1504
+ [messageBoxTemplate]="messageBoxTemplate"
1505
+ [type]="messageBoxType"
1506
+ [user]="user"
1507
+ [autoScroll]="autoScroll"
1508
+ [localization]="localizationText"
1509
+ (sendMessage)="sendMessage.emit($event)"
1510
+ >
1511
+ </kendo-message-box>
1512
+ `
1513
+ }]
1514
+ }], ctorParameters: function () { return [{ type: i1$2.LocalizationService }, { type: i0.NgZone }]; }, propDecorators: { messages: [{
1515
+ type: Input
1516
+ }], user: [{
1517
+ type: Input
1518
+ }], messageBoxType: [{
1519
+ type: Input
1520
+ }], sendMessage: [{
1521
+ type: Output
1522
+ }], executeAction: [{
1523
+ type: Output
1524
+ }], className: [{
1525
+ type: HostBinding,
1526
+ args: ['class']
1527
+ }], dirAttr: [{
1528
+ type: HostBinding,
1529
+ args: ['attr.dir']
1530
+ }], attachmentTemplate: [{
1531
+ type: ContentChild,
1532
+ args: [AttachmentTemplateDirective, { static: false }]
1533
+ }], messageTemplate: [{
1534
+ type: ContentChild,
1535
+ args: [MessageTemplateDirective, { static: false }]
1536
+ }], messageBoxTemplate: [{
1537
+ type: ContentChild,
1538
+ args: [ChatMessageBoxTemplateDirective, { static: false }]
1539
+ }], messageBox: [{
1540
+ type: ViewChild,
1541
+ args: ['messageBox', { static: false }]
1542
+ }], messageList: [{
1543
+ type: ViewChild,
1544
+ args: ['messageList', { static: true }]
1545
+ }] } });
1546
+
1547
+ // eslint-disable no-forward-ref
1548
+ /**
1549
+ * Custom component messages override default component messages
1550
+ * ([see example]({% slug globalization_chat %}#toc-custom-messages)).
1551
+ */
1552
+ class CustomMessagesComponent extends Messages {
1553
+ constructor(service) {
1554
+ super();
1555
+ this.service = service;
1556
+ }
1557
+ get override() {
1558
+ return true;
1559
+ }
1560
+ }
1561
+ CustomMessagesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CustomMessagesComponent, deps: [{ token: i1$2.LocalizationService }], target: i0.ɵɵFactoryTarget.Component });
1562
+ CustomMessagesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: CustomMessagesComponent, selector: "kendo-chat-messages", providers: [
1563
+ {
1564
+ provide: Messages,
1565
+ useExisting: forwardRef(() => CustomMessagesComponent)
1566
+ }
1567
+ ], usesInheritance: true, ngImport: i0, template: ``, isInline: true });
1568
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: CustomMessagesComponent, decorators: [{
1569
+ type: Component,
1570
+ args: [{
1571
+ providers: [
1572
+ {
1573
+ provide: Messages,
1574
+ useExisting: forwardRef(() => CustomMessagesComponent)
1575
+ }
1576
+ ],
1577
+ selector: 'kendo-chat-messages',
1578
+ template: ``
1579
+ }]
1580
+ }], ctorParameters: function () { return [{ type: i1$2.LocalizationService }]; } });
1581
+
1582
+ /**
1583
+ * Represents a Hero Card component ([see example]({% slug dialogflow_chat %})).
1584
+ * Hero cards host a single large image and action buttons with text content.
1585
+ */
1586
+ class HeroCardComponent {
1587
+ constructor() {
1588
+ this.cssClass = true;
1589
+ /**
1590
+ * Fires when the user clicks a button.
1591
+ */
1592
+ this.executeAction = new EventEmitter();
1593
+ }
1594
+ onClick(action) {
1595
+ this.executeAction.next(action);
1596
+ }
1597
+ }
1598
+ HeroCardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: HeroCardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1599
+ HeroCardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: HeroCardComponent, selector: "kendo-chat-hero-card", inputs: { imageUrl: "imageUrl", title: "title", subtitle: "subtitle", actions: "actions" }, outputs: { executeAction: "executeAction" }, host: { properties: { "class.k-card": "this.cssClass" } }, ngImport: i0, template: `
1600
+ <img class="k-card-image" [src]="imageUrl" *ngIf="imageUrl" />
1601
+ <div class="k-card-body">
1602
+ <h5 class="k-card-title" *ngIf="title">
1603
+ {{ title }}
1604
+ </h5>
1605
+ <h6 class="k-card-subtitle" *ngIf="subtitle">
1606
+ {{ subtitle }}
1607
+ </h6>
1608
+ </div>
1609
+ <div class="k-card-actions k-card-actions-vertical">
1610
+ <span class="k-card-action"
1611
+ *ngFor="let act of actions"
1612
+ >
1613
+ <button
1614
+ kendoButton fillMode="flat"
1615
+ (click)="onClick(act)"
1616
+ >
1617
+ {{ act.title }}
1618
+ </button>
1619
+ </span>
1620
+ </div>
1621
+ `, isInline: true, directives: [{ type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.ButtonDirective, selector: "button[kendoButton], span[kendoButton]", inputs: ["toggleable", "togglable", "selected", "tabIndex", "icon", "iconClass", "imageUrl", "disabled", "size", "rounded", "fillMode", "themeColor", "role", "primary", "look"], outputs: ["selectedChange", "click"], exportAs: ["kendoButton"] }] });
1622
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: HeroCardComponent, decorators: [{
1623
+ type: Component,
1624
+ args: [{
1625
+ selector: 'kendo-chat-hero-card',
1626
+ template: `
1627
+ <img class="k-card-image" [src]="imageUrl" *ngIf="imageUrl" />
1628
+ <div class="k-card-body">
1629
+ <h5 class="k-card-title" *ngIf="title">
1630
+ {{ title }}
1631
+ </h5>
1632
+ <h6 class="k-card-subtitle" *ngIf="subtitle">
1633
+ {{ subtitle }}
1634
+ </h6>
1635
+ </div>
1636
+ <div class="k-card-actions k-card-actions-vertical">
1637
+ <span class="k-card-action"
1638
+ *ngFor="let act of actions"
1639
+ >
1640
+ <button
1641
+ kendoButton fillMode="flat"
1642
+ (click)="onClick(act)"
1643
+ >
1644
+ {{ act.title }}
1645
+ </button>
1646
+ </span>
1647
+ </div>
1648
+ `
1649
+ }]
1650
+ }], propDecorators: { imageUrl: [{
1651
+ type: Input
1652
+ }], title: [{
1653
+ type: Input
1654
+ }], subtitle: [{
1655
+ type: Input
1656
+ }], actions: [{
1657
+ type: Input
1658
+ }], cssClass: [{
1659
+ type: HostBinding,
1660
+ args: ['class.k-card']
1661
+ }], executeAction: [{
1662
+ type: Output
1663
+ }] } });
1664
+
1665
+ const PUBLIC_DIRECTIVES = [
1666
+ ChatComponent,
1667
+ CustomMessagesComponent,
1668
+ AttachmentTemplateDirective,
1669
+ MessageTemplateDirective,
1670
+ HeroCardComponent,
1671
+ ChatMessageBoxTemplateDirective
1672
+ ];
1673
+ const PRIVATE_DIRECTIVES = [
1674
+ AttachmentComponent,
1675
+ FocusedStateDirective,
1676
+ LocalizedMessagesDirective,
1677
+ MessageAttachmentsComponent,
1678
+ MessageComponent,
1679
+ MessageListComponent,
1680
+ MessageTemplateDirective,
1681
+ ScrollAnchorDirective,
1682
+ SuggestedActionsComponent,
1683
+ MessageBoxComponent
1684
+ ];
1685
+ /**
1686
+ * The [NgModule]({{ site.data.urls.angular['ngmodules'] }}) for the Chat component.
1687
+ *
1688
+ * @example
1689
+ * ```ts-no-run
1690
+ * import { NgModule } from '@angular/core';
1691
+ * import { Component } from '@angular/core';
1692
+ * import { BrowserModule } from '@angular/platform-browser';
1693
+ *
1694
+ * import { ChatModule } from '@progress/kendo-angular-conversational-ui';
1695
+ * import { AppComponent } from './app.component';
1696
+ *
1697
+ * _@NgModule({
1698
+ * imports: [ BrowserModule, ChatModule ],
1699
+ * declarations: [ AppComponent ],
1700
+ * bootstrap: [ AppComponent ]
1701
+ * })
1702
+ *
1703
+ * export class AppModule { }
1704
+ * ```
1705
+ */
1706
+ class ChatModule {
1707
+ }
1708
+ ChatModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ChatModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1709
+ ChatModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ChatModule, declarations: [ChatComponent,
1710
+ CustomMessagesComponent,
1711
+ AttachmentTemplateDirective,
1712
+ MessageTemplateDirective,
1713
+ HeroCardComponent,
1714
+ ChatMessageBoxTemplateDirective, AttachmentComponent,
1715
+ FocusedStateDirective,
1716
+ LocalizedMessagesDirective,
1717
+ MessageAttachmentsComponent,
1718
+ MessageComponent,
1719
+ MessageListComponent,
1720
+ MessageTemplateDirective,
1721
+ ScrollAnchorDirective,
1722
+ SuggestedActionsComponent,
1723
+ MessageBoxComponent], imports: [ButtonModule,
1724
+ CommonModule,
1725
+ ResizeSensorModule], exports: [ChatComponent,
1726
+ CustomMessagesComponent,
1727
+ AttachmentTemplateDirective,
1728
+ MessageTemplateDirective,
1729
+ HeroCardComponent,
1730
+ ChatMessageBoxTemplateDirective] });
1731
+ ChatModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ChatModule, imports: [[
1732
+ ButtonModule,
1733
+ CommonModule,
1734
+ ResizeSensorModule
1735
+ ]] });
1736
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: ChatModule, decorators: [{
1737
+ type: NgModule,
1738
+ args: [{
1739
+ declarations: [
1740
+ ...PUBLIC_DIRECTIVES,
1741
+ ...PRIVATE_DIRECTIVES
1742
+ ],
1743
+ exports: [PUBLIC_DIRECTIVES],
1744
+ imports: [
1745
+ ButtonModule,
1746
+ CommonModule,
1747
+ ResizeSensorModule
1748
+ ]
1749
+ }]
1750
+ }] });
1751
+
1752
+ /**
1753
+ * Generated bundle index. Do not edit.
1754
+ */
1755
+
1756
+ export { AttachmentTemplateDirective, ChatComponent, ChatMessageBoxTemplateDirective, ChatModule, CustomMessagesComponent, ExecuteActionEvent, HeroCardComponent, MessageTemplateDirective, SendMessageEvent };
1757
+