@acorex/components 17.0.15 → 17.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. package/calendar/lib/calendar.module.d.ts +2 -1
  2. package/conversation/index.d.ts +12 -0
  3. package/conversation/lib/conversation-input/conversation-input.component.d.ts +35 -0
  4. package/conversation/lib/conversation-message/conversation-message.component.d.ts +20 -0
  5. package/conversation/lib/conversation-messages/conversation-message-text.component.d.ts +9 -0
  6. package/{chat/lib/chat-messages/chat-messages-voice/chat-message-voice.component.d.ts → conversation/lib/conversation-messages/conversation-messages-voice/conversation-message-voice.component.d.ts} +6 -4
  7. package/conversation/lib/conversation-view/conversation-view.component.d.ts +13 -0
  8. package/conversation/lib/conversation.module.d.ts +37 -0
  9. package/conversation/lib/conversation.types.d.ts +23 -0
  10. package/conversation/lib/services/conversation-message-type-registry.service.d.ts +9 -0
  11. package/conversation/lib/services/conversation.service.d.ts +5 -0
  12. package/esm2022/audio-wave/lib/audio-wave.component.mjs +4 -4
  13. package/esm2022/calendar/lib/calendar.component.mjs +5 -4
  14. package/esm2022/calendar/lib/calendar.module.mjs +5 -4
  15. package/esm2022/conversation/acorex-components-conversation.mjs +5 -0
  16. package/esm2022/conversation/index.mjs +14 -0
  17. package/esm2022/conversation/lib/classes/events.interface.mjs +2 -0
  18. package/esm2022/conversation/lib/conversation-input/conversation-input.component.mjs +117 -0
  19. package/esm2022/conversation/lib/conversation-input/conversation-input.interface.mjs +2 -0
  20. package/esm2022/conversation/lib/conversation-message/conversation-message.component.mjs +70 -0
  21. package/esm2022/conversation/lib/conversation-messages/conversation-message-text.component.mjs +23 -0
  22. package/esm2022/conversation/lib/conversation-messages/conversation-messages-voice/conversation-message-voice.component.mjs +112 -0
  23. package/esm2022/conversation/lib/conversation-view/conversation-view.component.mjs +31 -0
  24. package/esm2022/conversation/lib/conversation.module.mjs +154 -0
  25. package/esm2022/conversation/lib/conversation.types.mjs +10 -0
  26. package/esm2022/conversation/lib/services/conversation-message-type-registry.service.mjs +20 -0
  27. package/esm2022/conversation/lib/services/conversation.service.mjs +10 -0
  28. package/esm2022/conversation/lib/services/recording.service.mjs +78 -0
  29. package/fesm2022/acorex-components-audio-wave.mjs +3 -3
  30. package/fesm2022/acorex-components-audio-wave.mjs.map +1 -1
  31. package/fesm2022/acorex-components-calendar.mjs +7 -5
  32. package/fesm2022/acorex-components-calendar.mjs.map +1 -1
  33. package/fesm2022/acorex-components-conversation.mjs +589 -0
  34. package/fesm2022/acorex-components-conversation.mjs.map +1 -0
  35. package/package.json +13 -13
  36. package/chat/index.d.ts +0 -12
  37. package/chat/lib/chat-input/chat-input.component.d.ts +0 -35
  38. package/chat/lib/chat-message/chat-message.component.d.ts +0 -16
  39. package/chat/lib/chat-messages/chat-message-text.component.d.ts +0 -8
  40. package/chat/lib/chat-view/chat-view.component.d.ts +0 -10
  41. package/chat/lib/chat.module.d.ts +0 -35
  42. package/chat/lib/chat.types.d.ts +0 -21
  43. package/chat/lib/services/chat-message-type-registry.service.d.ts +0 -9
  44. package/chat/lib/services/chat.service.d.ts +0 -5
  45. package/esm2022/chat/acorex-components-chat.mjs +0 -5
  46. package/esm2022/chat/index.mjs +0 -14
  47. package/esm2022/chat/lib/chat-input/chat-input.component.mjs +0 -125
  48. package/esm2022/chat/lib/chat-input/chat-input.interface.mjs +0 -2
  49. package/esm2022/chat/lib/chat-message/chat-message.component.mjs +0 -54
  50. package/esm2022/chat/lib/chat-messages/chat-message-text.component.mjs +0 -23
  51. package/esm2022/chat/lib/chat-messages/chat-messages-voice/chat-message-voice.component.mjs +0 -97
  52. package/esm2022/chat/lib/chat-view/chat-view.component.mjs +0 -22
  53. package/esm2022/chat/lib/chat.module.mjs +0 -146
  54. package/esm2022/chat/lib/chat.types.mjs +0 -10
  55. package/esm2022/chat/lib/classes/events.interface.mjs +0 -2
  56. package/esm2022/chat/lib/services/chat-message-type-registry.service.mjs +0 -20
  57. package/esm2022/chat/lib/services/chat.service.mjs +0 -10
  58. package/esm2022/chat/lib/services/recording.service.mjs +0 -78
  59. package/fesm2022/acorex-components-chat.mjs +0 -552
  60. package/fesm2022/acorex-components-chat.mjs.map +0 -1
  61. /package/{chat → conversation}/README.md +0 -0
  62. /package/{chat → conversation}/lib/classes/events.interface.d.ts +0 -0
  63. /package/{chat/lib/chat-input/chat-input.interface.d.ts → conversation/lib/conversation-input/conversation-input.interface.d.ts} +0 -0
  64. /package/{chat → conversation}/lib/services/recording.service.d.ts +0 -0
@@ -0,0 +1,589 @@
1
+ import { MXInputBaseValueComponent, MXLookComponent, AXComponent, AXFocusableComponent, AXValuableComponent, MXBaseComponent, AXRippleDirective } from '@acorex/components/common';
2
+ import * as i0 from '@angular/core';
3
+ import { signal, Injectable, output, inject, forwardRef, Component, ChangeDetectionStrategy, ViewEncapsulation, ViewChild, Input, input, HostBinding, ViewContainerRef, afterNextRender, NgModule, Optional, Inject } from '@angular/core';
4
+ import * as i1 from '@angular/forms';
5
+ import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
6
+ import { classes } from 'polytype';
7
+ import * as i1$1 from '@acorex/components/button';
8
+ import { AXButtonModule } from '@acorex/components/button';
9
+ import * as i2 from '@acorex/components/decorators';
10
+ import { AXDecoratorModule } from '@acorex/components/decorators';
11
+ import * as i4 from '@acorex/components/dropdown';
12
+ import { AXDropdownModule } from '@acorex/components/dropdown';
13
+ import * as i5 from '@angular/common';
14
+ import { CommonModule, AsyncPipe } from '@angular/common';
15
+ import * as i6 from '@acorex/core/translation';
16
+ import { AXTranslationModule } from '@acorex/core/translation';
17
+ import * as i5$1 from '@acorex/components/popover';
18
+ import { AXPopoverModule } from '@acorex/components/popover';
19
+ import { isBrowser } from '@acorex/core/platform';
20
+ import * as i3 from '@angular/cdk/portal';
21
+ import { ComponentPortal, CdkPortalOutlet } from '@angular/cdk/portal';
22
+ import * as i4$1 from '@acorex/components/avatar';
23
+ import { AXAvatarModule } from '@acorex/components/avatar';
24
+ import * as i7 from '@acorex/core/format';
25
+ import { AXFormatModule } from '@acorex/core/format';
26
+ import * as i2$1 from '@acorex/components/audio-wave';
27
+ import { AXAudioWaveModule } from '@acorex/components/audio-wave';
28
+ import { AXCircularProgressModule } from '@acorex/components/circular-progress';
29
+ import * as i3$1 from '@acorex/components/loading';
30
+ import { AXLoadingModule } from '@acorex/components/loading';
31
+ import { AXDateTimeModule } from '@acorex/core/date-time';
32
+
33
+ class AXRecordingService {
34
+ constructor() {
35
+ this.audioBlobs = [];
36
+ this.streamBeingCaptured = null;
37
+ this.timer = signal('00:0');
38
+ this.time = {
39
+ seconds: 0,
40
+ minutes: 0,
41
+ hours: 0,
42
+ };
43
+ }
44
+ startRecording() {
45
+ if (!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia)) {
46
+ return Promise.reject(new Error('mediaDevices API or getUserMedia method is not supported in this browser.'));
47
+ }
48
+ else {
49
+ return navigator.mediaDevices
50
+ .getUserMedia({ audio: true })
51
+ .then((stream) => {
52
+ this.streamBeingCaptured = stream;
53
+ this.mediaRecorder = new MediaRecorder(stream);
54
+ this.audioBlobs = [];
55
+ this.mediaRecorder.addEventListener('dataavailable', (event) => {
56
+ this.audioBlobs.push(event.data);
57
+ });
58
+ this.mediaRecorder.start();
59
+ this.timerInterval = setInterval(() => {
60
+ this.calculateTime();
61
+ }, 1000);
62
+ });
63
+ }
64
+ }
65
+ stopRecording() {
66
+ return new Promise((resolve) => {
67
+ const mimeType = this.mediaRecorder?.mimeType;
68
+ this.mediaRecorder?.addEventListener('stop', () => {
69
+ const audioBlob = new Blob(this.audioBlobs, { type: mimeType });
70
+ resolve(audioBlob);
71
+ });
72
+ this.mediaRecorder?.stop();
73
+ this.streamBeingCaptured.getTracks().forEach((track) => track.stop());
74
+ this.mediaRecorder = null;
75
+ this.streamBeingCaptured = null;
76
+ this.resetTimer();
77
+ });
78
+ }
79
+ calculateTime() {
80
+ this.time.seconds++;
81
+ if (this.time.seconds >= 60) {
82
+ this.time.seconds = 0;
83
+ this.time.minutes++;
84
+ if (this.time.minutes >= 60) {
85
+ this.time.minutes = 0;
86
+ this.time.hours++;
87
+ }
88
+ }
89
+ const formattedTime = (this.time.hours > 0 ? this.time.hours + ':' : '') +
90
+ (this.time.minutes < 10 ? '0' + this.time.minutes : this.time.minutes) +
91
+ ':' +
92
+ (this.time.seconds < 10 ? '0' + this.time.seconds : this.time.seconds);
93
+ this.timer.set(formattedTime);
94
+ }
95
+ resetTimer() {
96
+ clearInterval(this.timerInterval);
97
+ this.time.seconds = 0;
98
+ this.time.minutes = 0;
99
+ this.time.hours = 0;
100
+ this.timer.set('00:0');
101
+ }
102
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXRecordingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
103
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXRecordingService }); }
104
+ }
105
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXRecordingService, decorators: [{
106
+ type: Injectable
107
+ }] });
108
+
109
+ class AXConversationInputComponent extends classes((MXInputBaseValueComponent), MXLookComponent) {
110
+ constructor() {
111
+ super(...arguments);
112
+ this.hasAttachment = true;
113
+ this.haVoice = true;
114
+ this.acceptFileType = '*';
115
+ this.onSendClick = output();
116
+ this.onStartRecording = output();
117
+ this.onStopRecording = output();
118
+ this.onFileChange = output();
119
+ this.recording = signal(false);
120
+ this.recordingService = inject(AXRecordingService);
121
+ this._updateOn = 'change';
122
+ this.recordedAudio = null;
123
+ }
124
+ _handleModelChange(value) {
125
+ this.commitValue(value, true);
126
+ }
127
+ handleRecordClick() {
128
+ this.recordedAudio = null;
129
+ this.recording.set(true);
130
+ this.recordingService
131
+ ?.startRecording()
132
+ .then(() => {
133
+ this.onStartRecording.emit({
134
+ component: this,
135
+ data: { recording: true },
136
+ isUserInteraction: true,
137
+ });
138
+ })
139
+ .catch((e) => {
140
+ console.error(e);
141
+ });
142
+ }
143
+ handleStopRecordingClick() {
144
+ this.recordingService.stopRecording().then((c) => {
145
+ this.recording.set(false);
146
+ this.recordedAudio = c;
147
+ this.onStopRecording.emit({
148
+ component: this,
149
+ data: { value: this.recordedAudio },
150
+ });
151
+ });
152
+ }
153
+ handleAttachClick() {
154
+ this.inputFile.nativeElement.click();
155
+ }
156
+ handleChangeFile(event) {
157
+ this.onFileChange.emit({
158
+ component: this,
159
+ data: { value: event.target.files },
160
+ });
161
+ }
162
+ handleSendClick() {
163
+ this.onSendClick.emit({
164
+ component: this,
165
+ data: { value: this.value },
166
+ isUserInteraction: true,
167
+ });
168
+ }
169
+ handleSendVoiceClick() {
170
+ this.handleStopRecordingClick();
171
+ this.onSendClick.emit({
172
+ component: this,
173
+ data: { value: this.value },
174
+ isUserInteraction: true,
175
+ });
176
+ }
177
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationInputComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
178
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: AXConversationInputComponent, selector: "ax-conversation-input", inputs: { maxLength: "maxLength", hasAttachment: "hasAttachment", haVoice: "haVoice", acceptFileType: "acceptFileType" }, outputs: { onSendClick: "onSendClick", onStartRecording: "onStartRecording", onStopRecording: "onStopRecording", onFileChange: "onFileChange" }, providers: [
179
+ { provide: AXComponent, useExisting: AXConversationInputComponent },
180
+ { provide: AXFocusableComponent, useExisting: AXConversationInputComponent },
181
+ { provide: AXValuableComponent, useExisting: AXConversationInputComponent },
182
+ {
183
+ provide: NG_VALUE_ACCESSOR,
184
+ useExisting: forwardRef(() => AXConversationInputComponent),
185
+ multi: true,
186
+ },
187
+ ], viewQueries: [{ propertyName: "inputFile", first: true, predicate: ["inputFile"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"ax-conversation-input\" [class.ax-state-recording]=\"recording()\">\n @if (recording()) {\n <div class=\"ax-conversation-input-start-side\">\n <span class=\"ax-record-dot\"></span>\n <span>{{ recordingService.timer() }}</span>\n </div>\n <div class=\"ax-conversation-input-main-side\">\n <ax-button class=\"ax-sm\" look=\"blank\" color=\"primary\" [text]=\"'cancel' | translate | async\"\n (onClick)=\"handleStopRecordingClick()\"></ax-button>\n </div>\n <div class=\"ax-conversation-input-end-side\">\n <ax-button look=\"solid\" color=\"danger\" class=\"ax-blob ax-sm\" (onClick)=\"handleSendVoiceClick()\">\n <ax-icon>\n <i class=\"ax-icon ax-icon-send\"></i>\n </ax-icon>\n </ax-button>\n </div>\n } @else {\n <div class=\"ax-conversation-input-start-side\">\n <ax-button look=\"blank\" class=\"ax-sm\">\n <ax-icon>\n <i class=\"ax-icon ax-icon-emoji\"></i>\n </ax-icon>\n <ax-dropdown-panel>\n <ng-container>\n <div class=\"ax-emoji-container\">\n <div>\u26A0\uFE0F</div>\n <div>\u27A1\uFE0F</div>\n <div>\uD83D\uDD03</div>\n <div>\uD83D\uDD37</div>\n <div>\uD83E\uDD1A</div>\n <div>\uD83D\uDE02</div>\n <div>\uD83D\uDE0A</div>\n </div>\n </ng-container>\n </ax-dropdown-panel>\n </ax-button>\n </div>\n <textarea class=\"ax-conversation-input-main-side\"\n oninput='this.style.height = \"\";this.style.height = this.scrollHeight + \"px\"' type=\"text\" rows=\"1\" [id]=\"id\"\n [name]=\"name\" [attr.placeholder]=\"placeholder\" [attr.maxlength]=\"maxLength\" [disabled]=\"disabled\"\n [readonly]=\"readonly\" [tabindex]=\"tabIndex\" [ngModel]=\"value\" (ngModelChange)=\"_handleModelChange($event)\"\n [ngModelOptions]=\"{ updateOn: _updateOn }\" (keydown)=\"emitOnKeydownEvent($event)\" (keyup)=\"emitOnKeyupEvent($event)\"\n (keypress)=\"emitOnKeypressEvent($event)\" (focus)=\"emitOnFocusEvent($event)\"\n (blur)=\"emitOnBlurEvent($event)\"></textarea>\n <div class=\"ax-conversation-input-end-side\">\n @if (!value) {\n <ax-button look=\"blank\" class=\"ax-sm\" (onClick)=\"handleAttachClick()\">\n <ax-icon>\n <i class=\"ax-icon ax-icon-attach\"></i>\n </ax-icon>\n </ax-button>\n <ax-button look=\"blank\" class=\"ax-sm\" (onClick)=\"handleRecordClick()\">\n <ax-icon>\n <i class=\"ax-icon ax-icon-mic\"></i>\n </ax-icon>\n </ax-button>\n <input #inputFile [accept]=\"acceptFileType\" type=\"file\" class=\"ax-attach-input\" (change)=\"handleChangeFile($event)\">\n }\n\n @if (value) {\n <ax-button look=\"solid\" color=\"primary\" class=\"ax-sm\" (onClick)=\"handleSendClick()\">\n <ax-icon>\n <i class=\"ax-icon ax-icon-send\"></i>\n </ax-icon>\n </ax-button>\n }\n </div>\n }\n</div>", styles: [".ax-dark .ax-conversation-input:focus-within{box-shadow:0 0 0 1px rgba(var(--ax-color-primary-200));border-color:rgba(var(--ax-color-primary-200))}ax-conversation-input{width:100%}ax-conversation-input .ax-conversation-input{border:1px solid;border-color:rgba(var(--ax-color-border-default));display:flex;align-items:flex-end;border-radius:var(--ax-rounded-border-default);position:relative;resize:vertical;height:auto;padding:.5rem;font-size:.875rem}ax-conversation-input .ax-conversation-input.ax-state-recording{align-items:center;display:grid;grid-template-columns:repeat(3,1fr)}ax-conversation-input .ax-conversation-input.ax-state-recording .ax-conversation-input-start-side{justify-content:flex-start}ax-conversation-input .ax-conversation-input.ax-state-recording .ax-conversation-input-end-side{justify-content:flex-end}ax-conversation-input .ax-conversation-input:focus-within{box-shadow:0 0 0 1px rgba(var(--ax-color-primary-500));border-color:rgba(var(--ax-color-primary-500))}ax-conversation-input .ax-conversation-input>textarea{font-size:.875rem;background-color:transparent;max-height:10rem;min-height:1.5rem;line-height:2rem;flex:1 1 auto;height:auto;resize:none}ax-conversation-input .ax-conversation-input>textarea:focus,ax-conversation-input .ax-conversation-input>textarea:focus-visible{outline:unset}ax-conversation-input .ax-conversation-input .ax-conversation-input-start-side,ax-conversation-input .ax-conversation-input .ax-conversation-input-end-side{display:flex;align-items:center;justify-content:center}ax-conversation-input .ax-conversation-input .ax-conversation-input-start-side{padding-inline-end:.75rem}ax-conversation-input .ax-conversation-input .ax-conversation-input-main-side{flex:1 1 auto;display:flex;align-items:center;justify-content:center}ax-conversation-input .ax-conversation-input .ax-conversation-input-end-side{padding-inline-start:.75rem;gap:.5rem}ax-conversation-input .ax-conversation-input .ax-record-dot{display:inline-flex;width:.5rem;height:.5rem;background-color:rgba(var(--ax-color-danger-500));border-radius:999rem;margin-inline-end:.5rem}ax-conversation-input .ax-conversation-input .ax-blob{animation:pulse .75s infinite}@keyframes pulse{0%{transform:scale(1);box-shadow:0 0 rgba(var(--ax-color-danger-500),.7)}70%{transform:scale(1);box-shadow:0 0 0 10px rgba(var(--ax-color-danger-500),0)}to{transform:scale(1);box-shadow:0 0 rgba(var(--ax-color-danger-500),0)}}ax-conversation-input .ax-conversation-input .ax-attach-input{opacity:0;width:0;height:0;position:absolute}ax-conversation-input .ax-emoji-container{padding:.75rem;gap:.5rem;display:grid;grid-template-columns:repeat(7,1fr)}ax-conversation-input .ax-emoji-container>div{padding:.25rem;cursor:pointer;border-radius:var(--ax-rounded-border-default)}ax-conversation-input .ax-emoji-container>div:hover{background-color:rgba(var(--ax-color-on-surface))}\n"], dependencies: [{ kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i1$1.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "type"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange"] }, { kind: "component", type: i2.AXDecoratorIconComponent, selector: "ax-icon", inputs: ["icon"] }, { kind: "component", type: i4.AXDropdownPanelComponent, selector: "ax-dropdown-panel", inputs: ["isOpen", "fitParent", "dropdownWidth", "position", "_target", "adaptivityEnabled"], outputs: ["onOpened", "onClosed"] }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }, { kind: "pipe", type: i6.AXTranslatorPipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
188
+ }
189
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationInputComponent, decorators: [{
190
+ type: Component,
191
+ args: [{ selector: 'ax-conversation-input', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [
192
+ { provide: AXComponent, useExisting: AXConversationInputComponent },
193
+ { provide: AXFocusableComponent, useExisting: AXConversationInputComponent },
194
+ { provide: AXValuableComponent, useExisting: AXConversationInputComponent },
195
+ {
196
+ provide: NG_VALUE_ACCESSOR,
197
+ useExisting: forwardRef(() => AXConversationInputComponent),
198
+ multi: true,
199
+ },
200
+ ], template: "<div class=\"ax-conversation-input\" [class.ax-state-recording]=\"recording()\">\n @if (recording()) {\n <div class=\"ax-conversation-input-start-side\">\n <span class=\"ax-record-dot\"></span>\n <span>{{ recordingService.timer() }}</span>\n </div>\n <div class=\"ax-conversation-input-main-side\">\n <ax-button class=\"ax-sm\" look=\"blank\" color=\"primary\" [text]=\"'cancel' | translate | async\"\n (onClick)=\"handleStopRecordingClick()\"></ax-button>\n </div>\n <div class=\"ax-conversation-input-end-side\">\n <ax-button look=\"solid\" color=\"danger\" class=\"ax-blob ax-sm\" (onClick)=\"handleSendVoiceClick()\">\n <ax-icon>\n <i class=\"ax-icon ax-icon-send\"></i>\n </ax-icon>\n </ax-button>\n </div>\n } @else {\n <div class=\"ax-conversation-input-start-side\">\n <ax-button look=\"blank\" class=\"ax-sm\">\n <ax-icon>\n <i class=\"ax-icon ax-icon-emoji\"></i>\n </ax-icon>\n <ax-dropdown-panel>\n <ng-container>\n <div class=\"ax-emoji-container\">\n <div>\u26A0\uFE0F</div>\n <div>\u27A1\uFE0F</div>\n <div>\uD83D\uDD03</div>\n <div>\uD83D\uDD37</div>\n <div>\uD83E\uDD1A</div>\n <div>\uD83D\uDE02</div>\n <div>\uD83D\uDE0A</div>\n </div>\n </ng-container>\n </ax-dropdown-panel>\n </ax-button>\n </div>\n <textarea class=\"ax-conversation-input-main-side\"\n oninput='this.style.height = \"\";this.style.height = this.scrollHeight + \"px\"' type=\"text\" rows=\"1\" [id]=\"id\"\n [name]=\"name\" [attr.placeholder]=\"placeholder\" [attr.maxlength]=\"maxLength\" [disabled]=\"disabled\"\n [readonly]=\"readonly\" [tabindex]=\"tabIndex\" [ngModel]=\"value\" (ngModelChange)=\"_handleModelChange($event)\"\n [ngModelOptions]=\"{ updateOn: _updateOn }\" (keydown)=\"emitOnKeydownEvent($event)\" (keyup)=\"emitOnKeyupEvent($event)\"\n (keypress)=\"emitOnKeypressEvent($event)\" (focus)=\"emitOnFocusEvent($event)\"\n (blur)=\"emitOnBlurEvent($event)\"></textarea>\n <div class=\"ax-conversation-input-end-side\">\n @if (!value) {\n <ax-button look=\"blank\" class=\"ax-sm\" (onClick)=\"handleAttachClick()\">\n <ax-icon>\n <i class=\"ax-icon ax-icon-attach\"></i>\n </ax-icon>\n </ax-button>\n <ax-button look=\"blank\" class=\"ax-sm\" (onClick)=\"handleRecordClick()\">\n <ax-icon>\n <i class=\"ax-icon ax-icon-mic\"></i>\n </ax-icon>\n </ax-button>\n <input #inputFile [accept]=\"acceptFileType\" type=\"file\" class=\"ax-attach-input\" (change)=\"handleChangeFile($event)\">\n }\n\n @if (value) {\n <ax-button look=\"solid\" color=\"primary\" class=\"ax-sm\" (onClick)=\"handleSendClick()\">\n <ax-icon>\n <i class=\"ax-icon ax-icon-send\"></i>\n </ax-icon>\n </ax-button>\n }\n </div>\n }\n</div>", styles: [".ax-dark .ax-conversation-input:focus-within{box-shadow:0 0 0 1px rgba(var(--ax-color-primary-200));border-color:rgba(var(--ax-color-primary-200))}ax-conversation-input{width:100%}ax-conversation-input .ax-conversation-input{border:1px solid;border-color:rgba(var(--ax-color-border-default));display:flex;align-items:flex-end;border-radius:var(--ax-rounded-border-default);position:relative;resize:vertical;height:auto;padding:.5rem;font-size:.875rem}ax-conversation-input .ax-conversation-input.ax-state-recording{align-items:center;display:grid;grid-template-columns:repeat(3,1fr)}ax-conversation-input .ax-conversation-input.ax-state-recording .ax-conversation-input-start-side{justify-content:flex-start}ax-conversation-input .ax-conversation-input.ax-state-recording .ax-conversation-input-end-side{justify-content:flex-end}ax-conversation-input .ax-conversation-input:focus-within{box-shadow:0 0 0 1px rgba(var(--ax-color-primary-500));border-color:rgba(var(--ax-color-primary-500))}ax-conversation-input .ax-conversation-input>textarea{font-size:.875rem;background-color:transparent;max-height:10rem;min-height:1.5rem;line-height:2rem;flex:1 1 auto;height:auto;resize:none}ax-conversation-input .ax-conversation-input>textarea:focus,ax-conversation-input .ax-conversation-input>textarea:focus-visible{outline:unset}ax-conversation-input .ax-conversation-input .ax-conversation-input-start-side,ax-conversation-input .ax-conversation-input .ax-conversation-input-end-side{display:flex;align-items:center;justify-content:center}ax-conversation-input .ax-conversation-input .ax-conversation-input-start-side{padding-inline-end:.75rem}ax-conversation-input .ax-conversation-input .ax-conversation-input-main-side{flex:1 1 auto;display:flex;align-items:center;justify-content:center}ax-conversation-input .ax-conversation-input .ax-conversation-input-end-side{padding-inline-start:.75rem;gap:.5rem}ax-conversation-input .ax-conversation-input .ax-record-dot{display:inline-flex;width:.5rem;height:.5rem;background-color:rgba(var(--ax-color-danger-500));border-radius:999rem;margin-inline-end:.5rem}ax-conversation-input .ax-conversation-input .ax-blob{animation:pulse .75s infinite}@keyframes pulse{0%{transform:scale(1);box-shadow:0 0 rgba(var(--ax-color-danger-500),.7)}70%{transform:scale(1);box-shadow:0 0 0 10px rgba(var(--ax-color-danger-500),0)}to{transform:scale(1);box-shadow:0 0 rgba(var(--ax-color-danger-500),0)}}ax-conversation-input .ax-conversation-input .ax-attach-input{opacity:0;width:0;height:0;position:absolute}ax-conversation-input .ax-emoji-container{padding:.75rem;gap:.5rem;display:grid;grid-template-columns:repeat(7,1fr)}ax-conversation-input .ax-emoji-container>div{padding:.25rem;cursor:pointer;border-radius:var(--ax-rounded-border-default)}ax-conversation-input .ax-emoji-container>div:hover{background-color:rgba(var(--ax-color-on-surface))}\n"] }]
201
+ }], propDecorators: { inputFile: [{
202
+ type: ViewChild,
203
+ args: ['inputFile']
204
+ }], maxLength: [{
205
+ type: Input
206
+ }], hasAttachment: [{
207
+ type: Input
208
+ }], haVoice: [{
209
+ type: Input
210
+ }], acceptFileType: [{
211
+ type: Input
212
+ }] } });
213
+
214
+ class AXConversationMessageTypeRegistryService {
215
+ constructor() {
216
+ this.plugins = new Map();
217
+ }
218
+ register(...plugins) {
219
+ plugins.forEach((p) => this.plugins.set(p.name, p));
220
+ }
221
+ resolve(name) {
222
+ return this.plugins.get(name);
223
+ }
224
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationMessageTypeRegistryService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
225
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationMessageTypeRegistryService, providedIn: 'root' }); }
226
+ }
227
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationMessageTypeRegistryService, decorators: [{
228
+ type: Injectable,
229
+ args: [{ providedIn: 'root' }]
230
+ }] });
231
+
232
+ class AXConversationMessageComponent extends MXBaseComponent {
233
+ constructor() {
234
+ super(...arguments);
235
+ this.chatMessage = input();
236
+ this.registryService = inject(AXConversationMessageTypeRegistryService);
237
+ }
238
+ get isOwn() {
239
+ return !this.chatMessage().fromId;
240
+ }
241
+ get __hostClass() {
242
+ return `${this.isOwn ? 'ax-state-own' : ''} ${!this.isOwn ? 'ax-state-other' : ''}`;
243
+ }
244
+ ngOnInit() {
245
+ this._portal = new ComponentPortal(this.registryService.resolve(this.chatMessage().type).component);
246
+ }
247
+ _handleAttched(ref) {
248
+ ref = ref;
249
+ if (ref.instance && isBrowser()) {
250
+ Object.assign(ref.instance, { message: this.chatMessage() });
251
+ this.cdr.markForCheck();
252
+ const prefix = this.getHostElement().querySelector('ax-prefix');
253
+ const suffix = this.getHostElement().querySelector('ax-suffix');
254
+ const prefixContainer = this.getHostElement().querySelector('.ax-message-prefix');
255
+ const suffixContainer = this.getHostElement().querySelector('.ax-message-suffix');
256
+ if (prefix && prefixContainer) {
257
+ prefix.style.display = 'flex';
258
+ prefixContainer.append(prefix);
259
+ }
260
+ if (suffix && suffixContainer) {
261
+ suffix.style.display = 'flex';
262
+ suffixContainer.append(suffix);
263
+ }
264
+ }
265
+ }
266
+ handleResendClick() {
267
+ this.popover.close();
268
+ this.chatMessage().onResendClick();
269
+ }
270
+ handleDeleteClick() {
271
+ this.popover.close();
272
+ this.chatMessage().onDeleteClick();
273
+ }
274
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationMessageComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
275
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: AXConversationMessageComponent, selector: "ax-conversation-message", inputs: { chatMessage: { classPropertyName: "chatMessage", publicName: "chatMessage", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "this.__hostClass" } }, viewQueries: [{ propertyName: "popover", first: true, predicate: ["popover"], descendants: true }], usesInheritance: true, ngImport: i0, template: "@if(chatMessage().fromId){\n<ax-avatar [size]=\"36\"></ax-avatar>\n}\n<div class=\"ax-message-content\" [class.ax-state-own]=\"!chatMessage().fromId\"\n [class.ax-state-other]=\"chatMessage().fromId\">\n <ng-template [cdkPortalOutlet]=\"_portal\" (attached)=\"_handleAttched($event)\"></ng-template>\n\n <div class=\"ax-chat-message-status\">\n <div class=\"ax-message-prefix\">\n </div>\n <div>\n <div class=\"ax-message-suffix\"></div>\n <span>\n {{ chatMessage().sendTime | format:'datetime':'HH:mm' | async }}\n </span>\n <span>\n @if(isOwn) {\n @if(chatMessage().deliverTime && chatMessage().sendTime){\n <i class=\"ax-icon ax-icon-check ax-message-status\"></i>\n }\n @if(chatMessage().readTime && chatMessage().sendTime){\n <i class=\"ax-icon ax-icon-dobble-check ax-message-status\"></i>\n }\n }\n </span>\n </div>\n </div>\n</div>\n@if(!chatMessage().sendTime){\n<ax-button class=\"ax-resend-button ax-xs\" color=\"danger\" #b>\n <ax-icon class=\"ax-icon ax-icon-error\"></ax-icon>\n\n <ax-popover [target]=\"b\" placement=\"bottom-end\" #popover>\n <div class=\"ax-overlay-pane\">\n\n <ax-content>\n </ax-content>\n <ax-button-item-list>\n @if(chatMessage().onResendClick){\n <ax-button-item text=\"Resend\" (onClick)=\"handleResendClick()\">\n <ax-icon class=\"ax-icon ax-icon-reload ax-bold\"></ax-icon>\n </ax-button-item>\n }\n @if(chatMessage().onDeleteClick){\n <ax-button-item text=\"Delete\" color=\"danger\" (onClick)=\"handleDeleteClick()\">\n <ax-icon class=\"ax-icon ax-icon-clear ax-bold\"></ax-icon>\n </ax-button-item>\n }\n\n </ax-button-item-list>\n </div>\n\n </ax-popover>\n</ax-button>\n}", styles: [":root{--ax-message-other-color: rgba(var(--ax-color-primary-500));--ax-message-other-color-fore: rgba(var(--ax-color-primary-fore));--ax-message-status-color: rgba(var(--ax-color-primary-700));--ax-message-other-bar-color: rgba(var(--ax-color-primary-400));--ax-message-other-progress-color: rgba(var(--ax-color-primary-fore));--ax-message-own-color: rgba(var(--ax-color-primary-100));--ax-message-own-color-fore: rgba(var(--ax-color-primary-700));--ax-message-own-bar-color: rgba(var(--ax-color-primary-200));--ax-message-own-progress-color: rgba(var(--ax-color-primary-700))}ax-conversation-message{display:flex;gap:.5rem;align-items:flex-end}ax-conversation-message.ax-state-own{justify-content:flex-end}ax-conversation-message .ax-message-content{display:block;padding:.5rem .75rem;font-size:.875rem;line-height:1.25rem;border-radius:1rem;width:fit-content;max-width:50%}ax-conversation-message .ax-message-content.ax-state-own{border-end-end-radius:0!important;background-color:var(--ax-message-own-color);color:var(--ax-message-own-color-fore);justify-content:flex-end}ax-conversation-message .ax-message-content.ax-state-own .ax-chat-message-status{color:var(--ax-message-own-color-fore)}ax-conversation-message .ax-message-content.ax-state-other{border-end-start-radius:0!important;background-color:var(--ax-message-other-color);color:var(--ax-message-other-color-fore)}ax-conversation-message .ax-message-content.ax-state-other .ax-chat-message-status{color:var(--ax-message-other-color-fore)}ax-conversation-message .ax-message-content .ax-chat-message-status{display:flex;justify-content:space-between;align-items:center;font-size:.75rem}ax-conversation-message .ax-message-content .ax-chat-message-status>div{display:flex;gap:.125rem;align-items:center}ax-conversation-message .ax-message-content .ax-chat-message-status .ax-message-status{color:var(--ax-message-status-color)}ax-conversation-message .ax-message-content .ax-chat-message-status .ax-icon{font-weight:700;font-size:.875rem}ax-conversation-message .ax-message-content .ax-chat-message-status .ax-icon-error{color:rgba(var(--ax-color-danger-500))}ax-conversation-message .ax-message-content ax-prefix,ax-conversation-message .ax-message-content ax-suffix{display:none}ax-conversation-message .ax-resend-button{border-radius:999rem}@media (min-width: 320px) and (max-width: 600px){ax-conversation-message ax-avatar{display:none!important}}\n"], dependencies: [{ kind: "component", type: i1$1.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "type"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange"] }, { kind: "component", type: i1$1.AXButtonItemComponent, selector: "ax-button-item", inputs: ["color", "disabled", "text", "selected", "divided", "data", "name"], outputs: ["onClick", "onFocus", "onBlur", "disabledChange"] }, { kind: "component", type: i1$1.AXButtonItemListComponent, selector: "ax-button-item-list", inputs: ["items"], outputs: ["onItemClick"] }, { kind: "component", type: i2.AXDecoratorIconComponent, selector: "ax-icon", inputs: ["icon"] }, { kind: "component", type: i2.AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title , ax-sub-title, ax-placeholder, ax-overlay" }, { kind: "directive", type: i3.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "component", type: i4$1.AXAvatarComponent, selector: "ax-avatar", inputs: ["color", "size", "look"] }, { kind: "component", type: i5$1.AXPopoverComponent, selector: "ax-popover", inputs: ["offsetX", "offsetY", "target", "placement", "content", "openOn", "closeOn", "hasBackdrop", "openAfter", "closeAfter", "backdropClass", "adaptivityEnabled"], outputs: ["onOpened", "onClosed"] }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }, { kind: "pipe", type: i7.AXFormatPipe, name: "format" }], encapsulation: i0.ViewEncapsulation.None }); }
276
+ }
277
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationMessageComponent, decorators: [{
278
+ type: Component,
279
+ args: [{ selector: 'ax-conversation-message', encapsulation: ViewEncapsulation.None, template: "@if(chatMessage().fromId){\n<ax-avatar [size]=\"36\"></ax-avatar>\n}\n<div class=\"ax-message-content\" [class.ax-state-own]=\"!chatMessage().fromId\"\n [class.ax-state-other]=\"chatMessage().fromId\">\n <ng-template [cdkPortalOutlet]=\"_portal\" (attached)=\"_handleAttched($event)\"></ng-template>\n\n <div class=\"ax-chat-message-status\">\n <div class=\"ax-message-prefix\">\n </div>\n <div>\n <div class=\"ax-message-suffix\"></div>\n <span>\n {{ chatMessage().sendTime | format:'datetime':'HH:mm' | async }}\n </span>\n <span>\n @if(isOwn) {\n @if(chatMessage().deliverTime && chatMessage().sendTime){\n <i class=\"ax-icon ax-icon-check ax-message-status\"></i>\n }\n @if(chatMessage().readTime && chatMessage().sendTime){\n <i class=\"ax-icon ax-icon-dobble-check ax-message-status\"></i>\n }\n }\n </span>\n </div>\n </div>\n</div>\n@if(!chatMessage().sendTime){\n<ax-button class=\"ax-resend-button ax-xs\" color=\"danger\" #b>\n <ax-icon class=\"ax-icon ax-icon-error\"></ax-icon>\n\n <ax-popover [target]=\"b\" placement=\"bottom-end\" #popover>\n <div class=\"ax-overlay-pane\">\n\n <ax-content>\n </ax-content>\n <ax-button-item-list>\n @if(chatMessage().onResendClick){\n <ax-button-item text=\"Resend\" (onClick)=\"handleResendClick()\">\n <ax-icon class=\"ax-icon ax-icon-reload ax-bold\"></ax-icon>\n </ax-button-item>\n }\n @if(chatMessage().onDeleteClick){\n <ax-button-item text=\"Delete\" color=\"danger\" (onClick)=\"handleDeleteClick()\">\n <ax-icon class=\"ax-icon ax-icon-clear ax-bold\"></ax-icon>\n </ax-button-item>\n }\n\n </ax-button-item-list>\n </div>\n\n </ax-popover>\n</ax-button>\n}", styles: [":root{--ax-message-other-color: rgba(var(--ax-color-primary-500));--ax-message-other-color-fore: rgba(var(--ax-color-primary-fore));--ax-message-status-color: rgba(var(--ax-color-primary-700));--ax-message-other-bar-color: rgba(var(--ax-color-primary-400));--ax-message-other-progress-color: rgba(var(--ax-color-primary-fore));--ax-message-own-color: rgba(var(--ax-color-primary-100));--ax-message-own-color-fore: rgba(var(--ax-color-primary-700));--ax-message-own-bar-color: rgba(var(--ax-color-primary-200));--ax-message-own-progress-color: rgba(var(--ax-color-primary-700))}ax-conversation-message{display:flex;gap:.5rem;align-items:flex-end}ax-conversation-message.ax-state-own{justify-content:flex-end}ax-conversation-message .ax-message-content{display:block;padding:.5rem .75rem;font-size:.875rem;line-height:1.25rem;border-radius:1rem;width:fit-content;max-width:50%}ax-conversation-message .ax-message-content.ax-state-own{border-end-end-radius:0!important;background-color:var(--ax-message-own-color);color:var(--ax-message-own-color-fore);justify-content:flex-end}ax-conversation-message .ax-message-content.ax-state-own .ax-chat-message-status{color:var(--ax-message-own-color-fore)}ax-conversation-message .ax-message-content.ax-state-other{border-end-start-radius:0!important;background-color:var(--ax-message-other-color);color:var(--ax-message-other-color-fore)}ax-conversation-message .ax-message-content.ax-state-other .ax-chat-message-status{color:var(--ax-message-other-color-fore)}ax-conversation-message .ax-message-content .ax-chat-message-status{display:flex;justify-content:space-between;align-items:center;font-size:.75rem}ax-conversation-message .ax-message-content .ax-chat-message-status>div{display:flex;gap:.125rem;align-items:center}ax-conversation-message .ax-message-content .ax-chat-message-status .ax-message-status{color:var(--ax-message-status-color)}ax-conversation-message .ax-message-content .ax-chat-message-status .ax-icon{font-weight:700;font-size:.875rem}ax-conversation-message .ax-message-content .ax-chat-message-status .ax-icon-error{color:rgba(var(--ax-color-danger-500))}ax-conversation-message .ax-message-content ax-prefix,ax-conversation-message .ax-message-content ax-suffix{display:none}ax-conversation-message .ax-resend-button{border-radius:999rem}@media (min-width: 320px) and (max-width: 600px){ax-conversation-message ax-avatar{display:none!important}}\n"] }]
280
+ }], propDecorators: { popover: [{
281
+ type: ViewChild,
282
+ args: ['popover']
283
+ }], __hostClass: [{
284
+ type: HostBinding,
285
+ args: ['class']
286
+ }] } });
287
+
288
+ class AXConversationViewComponent extends MXBaseComponent {
289
+ set conversations(items) {
290
+ this._conversations.set(items);
291
+ }
292
+ constructor() {
293
+ super();
294
+ this._conversations = signal([]);
295
+ this.viewRef = inject(ViewContainerRef);
296
+ afterNextRender(() => {
297
+ this.scrollIntoEndOfView();
298
+ });
299
+ }
300
+ scrollIntoEndOfView() {
301
+ const el = this.viewRef.element.nativeElement;
302
+ el.scroll({ top: el.scrollHeight });
303
+ console.log(this.viewRef);
304
+ }
305
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationViewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
306
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: AXConversationViewComponent, selector: "ax-conversation-view", inputs: { conversations: "conversations" }, usesInheritance: true, ngImport: i0, template: "@for (item of _conversations(); track $index) {\n<ax-conversation-message [chatMessage]=\"item\"></ax-conversation-message>\n}", styles: ["ax-conversation-view{display:flex;flex-direction:column;gap:.5rem;height:100%;width:100%;overflow-y:auto;overflow-x:hidden}\n"], dependencies: [{ kind: "component", type: AXConversationMessageComponent, selector: "ax-conversation-message", inputs: ["chatMessage"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
307
+ }
308
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationViewComponent, decorators: [{
309
+ type: Component,
310
+ args: [{ selector: 'ax-conversation-view', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "@for (item of _conversations(); track $index) {\n<ax-conversation-message [chatMessage]=\"item\"></ax-conversation-message>\n}", styles: ["ax-conversation-view{display:flex;flex-direction:column;gap:.5rem;height:100%;width:100%;overflow-y:auto;overflow-x:hidden}\n"] }]
311
+ }], ctorParameters: () => [], propDecorators: { conversations: [{
312
+ type: Input
313
+ }] } });
314
+
315
+ class AXConversationMessageBaseComponent {
316
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationMessageBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
317
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationMessageBaseComponent }); }
318
+ }
319
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationMessageBaseComponent, decorators: [{
320
+ type: Injectable
321
+ }] });
322
+
323
+ class AXConversationTextMessageComponent extends AXConversationMessageBaseComponent {
324
+ constructor() {
325
+ super(...arguments);
326
+ this._text = signal('');
327
+ }
328
+ ngOnInit() {
329
+ this._text.set(this.message?.content);
330
+ }
331
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationTextMessageComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
332
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.2", type: AXConversationTextMessageComponent, selector: "ng-component", inputs: { message: "message" }, usesInheritance: true, ngImport: i0, template: `<div [innerHtml]="_text()"></div>`, isInline: true, encapsulation: i0.ViewEncapsulation.None }); }
333
+ }
334
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationTextMessageComponent, decorators: [{
335
+ type: Component,
336
+ args: [{
337
+ template: `<div [innerHtml]="_text()"></div>`,
338
+ encapsulation: ViewEncapsulation.None,
339
+ inputs: ['message'],
340
+ }]
341
+ }] });
342
+
343
+ class AXConversationAudioMessageComponent extends AXConversationMessageBaseComponent {
344
+ constructor() {
345
+ super();
346
+ this.config = { url: '' };
347
+ this.audioState = signal('paused');
348
+ this.selectedRate = signal(1);
349
+ this.selectedRateIndex = signal(1);
350
+ this.audioProgress = signal(0);
351
+ this.timeLeft = signal(0);
352
+ this.currentTime = signal(0);
353
+ this.duration = signal(0);
354
+ afterNextRender(() => {
355
+ this.config.url = this.message?.content;
356
+ this.config.audioRate = 0.25;
357
+ this.setWaveColor();
358
+ this.handleLoadingProgress();
359
+ });
360
+ }
361
+ setWaveColor() {
362
+ let waveColor = '';
363
+ let progressColor = '';
364
+ if (this.message.fromId) {
365
+ waveColor = getComputedStyle(document.body).getPropertyValue('--ax-message-other-bar-color');
366
+ progressColor = getComputedStyle(document.body).getPropertyValue('--ax-message-other-progress-color');
367
+ }
368
+ else {
369
+ waveColor = getComputedStyle(document.body).getPropertyValue('--ax-message-own-bar-color');
370
+ progressColor = getComputedStyle(document.body).getPropertyValue('--ax-message-own-progress-color');
371
+ }
372
+ this.config.waveColor = waveColor;
373
+ this.config.progressColor = progressColor;
374
+ }
375
+ handlePauseClick() {
376
+ this.audio?.pause();
377
+ this.audioState.set('paused');
378
+ }
379
+ handlePlayClick() {
380
+ this.audio?.play()?.then(() => {
381
+ this.audioState.set('playing');
382
+ });
383
+ }
384
+ handleOnStatusChanged(e) {
385
+ if (e.status === 'load' || e.status === 'loading') {
386
+ this.audioState.set('loading');
387
+ }
388
+ if (e.status === 'loading') {
389
+ this.audioProgress.set(e.data.percent);
390
+ this.duration.set(Math.ceil(e.data.duration * 1000));
391
+ }
392
+ if (e.status === 'ready') {
393
+ this.audioState.set('ready');
394
+ this.duration.set(Math.ceil(e.data.duration * 1000));
395
+ }
396
+ if (e.status === 'finish') {
397
+ this.audioState.set('paused');
398
+ }
399
+ if (e.status === 'timeupdate') {
400
+ this.timeLeft.set(this.duration() - e.data.currentTime * 1000);
401
+ this.currentTime.set(e.data.currentTime * 1000);
402
+ }
403
+ if (e.status === 'error') {
404
+ this.audioState.set('error');
405
+ }
406
+ }
407
+ handleLoadingProgress() {
408
+ // this.audioLoaderProgress?.nativeElement.style.cssText = `--ax-audio-progress: ${this.audioProgress()}`;
409
+ }
410
+ handleCancelLoading() {
411
+ //
412
+ }
413
+ handleReloadClick() {
414
+ //
415
+ this.audioState.set('loading');
416
+ this.audio.load();
417
+ }
418
+ handleRateClick() {
419
+ const rates = [0.5, 1, 2, 4];
420
+ if (this.selectedRateIndex() == rates.length - 1) {
421
+ this.selectedRateIndex.set(0);
422
+ }
423
+ else {
424
+ this.selectedRateIndex.set(this.selectedRateIndex() + 1);
425
+ }
426
+ this.selectedRate.set(rates[this.selectedRateIndex()]);
427
+ this.audio.setRate(this.selectedRate());
428
+ }
429
+ get __hostClass() {
430
+ return `${this.message.fromId ? 'ax-state-other' : 'ax-state-own'}`;
431
+ }
432
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationAudioMessageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
433
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.2", type: AXConversationAudioMessageComponent, selector: "ax-conversation-message-audio", inputs: { message: "message" }, host: { properties: { "class": "this.__hostClass" } }, viewQueries: [{ propertyName: "audio", first: true, predicate: ["a"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<ax-prefix>\n @switch (audioState()) {\n @case ('paused')\n {\n {{currentTime() | format:'time-duration' | async}}\n }\n @case ('playing')\n {\n {{currentTime() | format:'time-duration' | async}}\n }\n @default {\n {{duration() | format:'time-duration' | async}}\n }\n }\n <button class=\"ax-audio-speed\" (click)=\"handleRateClick()\"></button>\n\n</ax-prefix>\n<div class=\"ax-audio-controller\">\n\n @switch (audioState()) {\n @case ('playing') {\n <button (click)=\"handlePauseClick()\">\n <i class=\"ax-icon ax-icon-pause\"></i>\n </button>\n }\n\n @case ('ready') {\n <button (click)=\"handlePlayClick()\">\n <i class=\"ax-icon ax-icon-play\"></i>\n </button>\n }\n\n @case ('paused')\n {\n <button (click)=\"handlePlayClick()\">\n <i class=\"ax-icon ax-icon-play\"></i>\n </button>\n }\n\n @case ('error')\n {\n <button class=\"ax-state-error\" (click)=\"handleReloadClick()\">\n <i class=\"ax-icon ax-icon-reload\"></i>\n </button>\n }\n\n @default {\n <button (click)=\"handleCancelLoading()\">\n <ax-loading-spinner [size]=\"24\" [stroke]=\"2\"\n [color]=\"message.fromId?'var(--ax-other-color)':'var(--ax-own-color)'\"></ax-loading-spinner>\n </button>\n }\n }\n\n</div>\n<ax-audio-wave #a [config]=\"config\" (onStatusChanged)=\"handleOnStatusChanged($event)\"></ax-audio-wave>\n<ax-suffix>\n <div class=\"ax-audio-rate-button\" [class.ax-state-own]=\"!message?.fromId\" (click)=\"handleRateClick()\">\n {{selectedRate()}}X</div>\n</ax-suffix>", styles: ["ax-conversation-message-audio{display:flex;align-items:center;justify-content:space-between;gap:.5rem;min-width:18rem;max-width:100%}ax-conversation-message-audio.ax-state-own .ax-audio-controller button{background-color:var(--ax-message-own-color-fore);color:var(--ax-message-own-color)}ax-conversation-message-audio.ax-state-other .ax-audio-controller button{background-color:var(--ax-message-other-color-fore);color:var(--ax-message-other-color)}ax-conversation-message-audio .ax-audio-controller button{width:2.5rem;height:2.5rem;border-radius:999rem;display:flex;align-items:center;justify-content:center}ax-conversation-message-audio .ax-audio-controller button ax-loading-spinner{display:flex}ax-conversation-message-audio .ax-audio-controller button.ax-state-error{background-color:rgba(var(--ax-color-danger-500));color:rgba(var(--ax-color-danger-fore))}ax-conversation-message-audio .ax-audio-controller button>i{width:1.5rem;height:1.5rem;display:flex;align-items:center;justify-content:center;font-size:1.25rem;font-weight:700}ax-conversation-message-audio .ax-audio-wave{flex:1}.ax-audio-rate-button{background-color:var(--ax-message-other-color-fore);color:var(--ax-message-other-color);border-radius:.5rem;padding:0 .5rem;font-weight:700;margin-inline-end:.5rem;cursor:pointer;-webkit-user-select:none;user-select:none}.ax-audio-rate-button.ax-state-own{background-color:var(--ax-message-own-color-fore);color:var(--ax-message-own-color)}html[dir=rtl] ax-conversation-message-audio{flex-direction:row-reverse}\n"], dependencies: [{ kind: "component", type: i2.AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title , ax-sub-title, ax-placeholder, ax-overlay" }, { kind: "component", type: i2$1.AXAudioWaveComponent, selector: "ax-audio-wave", inputs: ["config"], outputs: ["onStatusChanged"] }, { kind: "component", type: i3$1.AXLoadingSpinnerComponent, selector: "ax-loading-spinner", inputs: ["color", "size", "stroke"] }, { kind: "pipe", type: i5.AsyncPipe, name: "async" }, { kind: "pipe", type: i7.AXFormatPipe, name: "format" }], encapsulation: i0.ViewEncapsulation.None }); }
434
+ }
435
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationAudioMessageComponent, decorators: [{
436
+ type: Component,
437
+ args: [{ selector: 'ax-conversation-message-audio', encapsulation: ViewEncapsulation.None, inputs: ['message'], template: "<ax-prefix>\n @switch (audioState()) {\n @case ('paused')\n {\n {{currentTime() | format:'time-duration' | async}}\n }\n @case ('playing')\n {\n {{currentTime() | format:'time-duration' | async}}\n }\n @default {\n {{duration() | format:'time-duration' | async}}\n }\n }\n <button class=\"ax-audio-speed\" (click)=\"handleRateClick()\"></button>\n\n</ax-prefix>\n<div class=\"ax-audio-controller\">\n\n @switch (audioState()) {\n @case ('playing') {\n <button (click)=\"handlePauseClick()\">\n <i class=\"ax-icon ax-icon-pause\"></i>\n </button>\n }\n\n @case ('ready') {\n <button (click)=\"handlePlayClick()\">\n <i class=\"ax-icon ax-icon-play\"></i>\n </button>\n }\n\n @case ('paused')\n {\n <button (click)=\"handlePlayClick()\">\n <i class=\"ax-icon ax-icon-play\"></i>\n </button>\n }\n\n @case ('error')\n {\n <button class=\"ax-state-error\" (click)=\"handleReloadClick()\">\n <i class=\"ax-icon ax-icon-reload\"></i>\n </button>\n }\n\n @default {\n <button (click)=\"handleCancelLoading()\">\n <ax-loading-spinner [size]=\"24\" [stroke]=\"2\"\n [color]=\"message.fromId?'var(--ax-other-color)':'var(--ax-own-color)'\"></ax-loading-spinner>\n </button>\n }\n }\n\n</div>\n<ax-audio-wave #a [config]=\"config\" (onStatusChanged)=\"handleOnStatusChanged($event)\"></ax-audio-wave>\n<ax-suffix>\n <div class=\"ax-audio-rate-button\" [class.ax-state-own]=\"!message?.fromId\" (click)=\"handleRateClick()\">\n {{selectedRate()}}X</div>\n</ax-suffix>", styles: ["ax-conversation-message-audio{display:flex;align-items:center;justify-content:space-between;gap:.5rem;min-width:18rem;max-width:100%}ax-conversation-message-audio.ax-state-own .ax-audio-controller button{background-color:var(--ax-message-own-color-fore);color:var(--ax-message-own-color)}ax-conversation-message-audio.ax-state-other .ax-audio-controller button{background-color:var(--ax-message-other-color-fore);color:var(--ax-message-other-color)}ax-conversation-message-audio .ax-audio-controller button{width:2.5rem;height:2.5rem;border-radius:999rem;display:flex;align-items:center;justify-content:center}ax-conversation-message-audio .ax-audio-controller button ax-loading-spinner{display:flex}ax-conversation-message-audio .ax-audio-controller button.ax-state-error{background-color:rgba(var(--ax-color-danger-500));color:rgba(var(--ax-color-danger-fore))}ax-conversation-message-audio .ax-audio-controller button>i{width:1.5rem;height:1.5rem;display:flex;align-items:center;justify-content:center;font-size:1.25rem;font-weight:700}ax-conversation-message-audio .ax-audio-wave{flex:1}.ax-audio-rate-button{background-color:var(--ax-message-other-color-fore);color:var(--ax-message-other-color);border-radius:.5rem;padding:0 .5rem;font-weight:700;margin-inline-end:.5rem;cursor:pointer;-webkit-user-select:none;user-select:none}.ax-audio-rate-button.ax-state-own{background-color:var(--ax-message-own-color-fore);color:var(--ax-message-own-color)}html[dir=rtl] ax-conversation-message-audio{flex-direction:row-reverse}\n"] }]
438
+ }], ctorParameters: () => [], propDecorators: { audio: [{
439
+ type: ViewChild,
440
+ args: ['a']
441
+ }], __hostClass: [{
442
+ type: HostBinding,
443
+ args: ['class']
444
+ }] } });
445
+
446
+ const COMPONENT = [
447
+ AXConversationViewComponent,
448
+ AXConversationInputComponent,
449
+ AXConversationMessageComponent,
450
+ AXConversationTextMessageComponent,
451
+ AXConversationAudioMessageComponent,
452
+ ];
453
+ const MODULES = [
454
+ CommonModule,
455
+ FormsModule,
456
+ AsyncPipe,
457
+ AXRippleDirective,
458
+ AXButtonModule,
459
+ AXDecoratorModule,
460
+ AXTranslationModule,
461
+ AXDropdownModule,
462
+ AXFormatModule,
463
+ AXAudioWaveModule,
464
+ AXCircularProgressModule,
465
+ AXDateTimeModule,
466
+ CdkPortalOutlet,
467
+ AXLoadingModule,
468
+ AXAvatarModule,
469
+ AXPopoverModule,
470
+ ];
471
+ class AXConversationModule {
472
+ static forRoot(config) {
473
+ return {
474
+ ngModule: AXConversationModule,
475
+ providers: [
476
+ {
477
+ provide: 'AXChatModuleFactory',
478
+ useFactory: (registry) => () => {
479
+ if (config?.types?.length) {
480
+ registry.register(...config.types);
481
+ }
482
+ registry.register({
483
+ name: 'text',
484
+ component: AXConversationTextMessageComponent,
485
+ });
486
+ registry.register({
487
+ name: 'audio',
488
+ component: AXConversationAudioMessageComponent,
489
+ });
490
+ },
491
+ deps: [AXConversationMessageTypeRegistryService],
492
+ multi: true,
493
+ },
494
+ ],
495
+ };
496
+ }
497
+ static forChild(config) {
498
+ return {
499
+ ngModule: AXConversationModule,
500
+ providers: [
501
+ {
502
+ provide: 'AXPWorkflowModuleFactory',
503
+ useFactory: (registry) => () => {
504
+ if (config?.types?.length) {
505
+ registry.register(...config.types);
506
+ }
507
+ },
508
+ deps: [AXConversationMessageTypeRegistryService],
509
+ multi: true,
510
+ },
511
+ ],
512
+ };
513
+ }
514
+ /**
515
+ * @ignore
516
+ */
517
+ constructor(instances) {
518
+ instances?.forEach((f) => {
519
+ f();
520
+ });
521
+ }
522
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationModule, deps: [{ token: 'AXChatModuleFactory', optional: true }], target: i0.ɵɵFactoryTarget.NgModule }); }
523
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.2", ngImport: i0, type: AXConversationModule, declarations: [AXConversationViewComponent,
524
+ AXConversationInputComponent,
525
+ AXConversationMessageComponent,
526
+ AXConversationTextMessageComponent,
527
+ AXConversationAudioMessageComponent], imports: [CommonModule,
528
+ FormsModule,
529
+ AsyncPipe,
530
+ AXRippleDirective,
531
+ AXButtonModule,
532
+ AXDecoratorModule,
533
+ AXTranslationModule,
534
+ AXDropdownModule,
535
+ AXFormatModule,
536
+ AXAudioWaveModule,
537
+ AXCircularProgressModule,
538
+ AXDateTimeModule,
539
+ CdkPortalOutlet,
540
+ AXLoadingModule,
541
+ AXAvatarModule,
542
+ AXPopoverModule], exports: [AXConversationViewComponent,
543
+ AXConversationInputComponent,
544
+ AXConversationMessageComponent,
545
+ AXConversationTextMessageComponent,
546
+ AXConversationAudioMessageComponent] }); }
547
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationModule, providers: [AXRecordingService], imports: [CommonModule,
548
+ FormsModule,
549
+ AXButtonModule,
550
+ AXDecoratorModule,
551
+ AXTranslationModule,
552
+ AXDropdownModule,
553
+ AXFormatModule,
554
+ AXAudioWaveModule,
555
+ AXCircularProgressModule,
556
+ AXDateTimeModule,
557
+ AXLoadingModule,
558
+ AXAvatarModule,
559
+ AXPopoverModule] }); }
560
+ }
561
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationModule, decorators: [{
562
+ type: NgModule,
563
+ args: [{
564
+ declarations: [...COMPONENT],
565
+ imports: [...MODULES],
566
+ exports: [...COMPONENT],
567
+ providers: [AXRecordingService],
568
+ }]
569
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
570
+ type: Optional
571
+ }, {
572
+ type: Inject,
573
+ args: ['AXChatModuleFactory']
574
+ }] }] });
575
+
576
+ class AXConversationService {
577
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
578
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationService }); }
579
+ }
580
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.2", ngImport: i0, type: AXConversationService, decorators: [{
581
+ type: Injectable
582
+ }] });
583
+
584
+ /**
585
+ * Generated bundle index. Do not edit.
586
+ */
587
+
588
+ export { AXConversationAudioMessageComponent, AXConversationInputComponent, AXConversationMessageBaseComponent, AXConversationMessageComponent, AXConversationMessageTypeRegistryService, AXConversationModule, AXConversationService, AXConversationTextMessageComponent, AXConversationViewComponent, AXRecordingService };
589
+ //# sourceMappingURL=acorex-components-conversation.mjs.map