@salla.sa/ui-ai-kit-core 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ai-card.cjs.entry.js +2 -2
- package/dist/cjs/ai-chat-container.cjs.entry.js +84 -57
- package/dist/cjs/ai-chat-header.cjs.entry.js +29 -19
- package/dist/cjs/ai-chat-message.cjs.entry.js +1456 -21
- package/dist/cjs/ai-conversation-list.cjs.entry.js +80 -0
- package/dist/cjs/ai-conversation-summary.cjs.entry.js +33 -0
- package/dist/cjs/ai-icon.cjs.entry.js +2 -2
- package/dist/cjs/ai-link.cjs.entry.js +4 -4
- package/dist/cjs/ai-loading.cjs.entry.js +35 -22
- package/dist/cjs/ai-message-input.cjs.entry.js +48 -15
- package/dist/cjs/ai-rating.cjs.entry.js +2 -2
- package/dist/cjs/ai-route-decision.cjs.entry.js +48 -0
- package/dist/cjs/ai-suggestion.cjs.entry.js +4 -4
- package/dist/cjs/ai-voice-input.cjs.entry.js +75 -21
- package/dist/cjs/{icon-registry-dmfLA-Dj.js → icon-registry-BKb9-2Nt.js} +24 -0
- package/dist/cjs/{index-DLJcLHFH.js → index-BkNg07SW.js} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/ui-ai-kit.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/ai-card/ai-card.css +5 -8
- package/dist/collection/components/ai-chat-container/ai-chat-container.css +17 -14
- package/dist/collection/components/ai-chat-container/ai-chat-container.js +125 -53
- package/dist/collection/components/ai-chat-header/ai-chat-header.css +50 -17
- package/dist/collection/components/ai-chat-header/ai-chat-header.js +53 -18
- package/dist/collection/components/ai-chat-message/ai-chat-message.css +47 -38
- package/dist/collection/components/ai-chat-message/ai-chat-message.js +68 -18
- package/dist/collection/components/ai-conversation-list/ai-conversation-list.css +196 -0
- package/dist/collection/components/ai-conversation-list/ai-conversation-list.js +176 -0
- package/dist/collection/components/ai-conversation-summary/ai-conversation-summary.css +103 -0
- package/dist/collection/components/ai-conversation-summary/ai-conversation-summary.js +118 -0
- package/dist/collection/components/ai-icon/ai-icon.js +1 -1
- package/dist/collection/components/ai-link/ai-link.css +3 -7
- package/dist/collection/components/ai-link/ai-link.js +1 -1
- package/dist/collection/components/ai-loading/ai-loading.css +149 -20
- package/dist/collection/components/ai-loading/ai-loading.js +100 -23
- package/dist/collection/components/ai-message-input/ai-message-input.css +41 -37
- package/dist/collection/components/ai-message-input/ai-message-input.js +100 -19
- package/dist/collection/components/ai-rating/ai-rating.css +8 -14
- package/dist/collection/components/ai-route-decision/ai-route-decision.css +132 -0
- package/dist/collection/components/ai-route-decision/ai-route-decision.js +195 -0
- package/dist/collection/components/ai-suggestion/ai-suggestion.css +5 -11
- package/dist/collection/components/ai-suggestion/ai-suggestion.js +2 -2
- package/dist/collection/components/ai-voice-input/ai-voice-input.css +27 -22
- package/dist/collection/components/ai-voice-input/ai-voice-input.js +116 -20
- package/dist/collection/utils/icon-registry.js +24 -0
- package/dist/components/ai-card.js +1 -1
- package/dist/components/ai-chat-container.js +1 -1
- package/dist/components/ai-chat-header.js +1 -1
- package/dist/components/ai-chat-message.js +2 -1
- package/dist/components/ai-conversation-list.d.ts +11 -0
- package/dist/components/ai-conversation-list.js +1 -0
- package/dist/components/ai-conversation-summary.d.ts +11 -0
- package/dist/components/ai-conversation-summary.js +1 -0
- package/dist/components/ai-icon.js +1 -1
- package/dist/components/ai-link.js +1 -1
- package/dist/components/ai-loading.js +1 -1
- package/dist/components/ai-message-input.js +1 -1
- package/dist/components/ai-rating.js +1 -1
- package/dist/components/ai-route-decision.d.ts +11 -0
- package/dist/components/ai-route-decision.js +1 -0
- package/dist/components/ai-suggestion.js +1 -1
- package/dist/components/ai-voice-input.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/p-CX1Yp79q.js +1 -0
- package/dist/components/p-DnO4dikr.js +1 -0
- package/dist/components/{p-CY6emva2.js → p-Dr2tAPV7.js} +1 -1
- package/dist/{ui-ai-kit/p-DYv5ef4M.js → components/p-SJZ6Ujn9.js} +1 -1
- package/dist/esm/ai-card.entry.js +2 -2
- package/dist/esm/ai-chat-container.entry.js +84 -57
- package/dist/esm/ai-chat-header.entry.js +29 -19
- package/dist/esm/ai-chat-message.entry.js +1456 -21
- package/dist/esm/ai-conversation-list.entry.js +78 -0
- package/dist/esm/ai-conversation-summary.entry.js +31 -0
- package/dist/esm/ai-icon.entry.js +2 -2
- package/dist/esm/ai-link.entry.js +4 -4
- package/dist/esm/ai-loading.entry.js +35 -22
- package/dist/esm/ai-message-input.entry.js +48 -15
- package/dist/esm/ai-rating.entry.js +2 -2
- package/dist/esm/ai-route-decision.entry.js +46 -0
- package/dist/esm/ai-suggestion.entry.js +4 -4
- package/dist/esm/ai-voice-input.entry.js +75 -21
- package/dist/esm/{icon-registry-DYv5ef4M.js → icon-registry-SJZ6Ujn9.js} +24 -0
- package/dist/esm/{index-7hrZ8FOQ.js → index-B0yIzgh4.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/ui-ai-kit.js +3 -3
- package/dist/types/components/ai-chat-container/ai-chat-container.d.ts +11 -1
- package/dist/types/components/ai-chat-header/ai-chat-header.d.ts +7 -2
- package/dist/types/components/ai-conversation-list/ai-conversation-list.d.ts +24 -0
- package/dist/types/components/ai-conversation-summary/ai-conversation-summary.d.ts +12 -0
- package/dist/types/components/ai-loading/ai-loading.d.ts +12 -6
- package/dist/types/components/ai-message-input/ai-message-input.d.ts +17 -3
- package/dist/types/components/ai-route-decision/ai-route-decision.d.ts +21 -0
- package/dist/types/components/ai-voice-input/ai-voice-input.d.ts +7 -0
- package/dist/types/components.d.ts +335 -11
- package/dist/types/index.d.ts +2 -0
- package/dist/types/utils/icon-registry.d.ts +1 -1
- package/dist/ui-ai-kit/p-2955439f.entry.js +1 -0
- package/dist/ui-ai-kit/p-5c9e9822.entry.js +1 -0
- package/dist/ui-ai-kit/p-5caf1c38.entry.js +1 -0
- package/dist/ui-ai-kit/p-74c5c83f.entry.js +1 -0
- package/dist/ui-ai-kit/p-76195745.entry.js +1 -0
- package/dist/ui-ai-kit/p-79c78d8e.entry.js +1 -0
- package/dist/ui-ai-kit/p-87e9739b.entry.js +1 -0
- package/dist/ui-ai-kit/p-9c4c6c01.entry.js +1 -0
- package/dist/ui-ai-kit/p-B0yIzgh4.js +2 -0
- package/dist/{components/p-DYv5ef4M.js → ui-ai-kit/p-SJZ6Ujn9.js} +1 -1
- package/dist/ui-ai-kit/p-a099fcfb.entry.js +1 -0
- package/dist/ui-ai-kit/p-b28af13a.entry.js +1 -0
- package/dist/ui-ai-kit/p-d1bb1ad0.entry.js +1 -0
- package/dist/ui-ai-kit/p-eb0c7e7a.entry.js +1 -0
- package/dist/ui-ai-kit/{p-455daa17.entry.js → p-eec6f083.entry.js} +1 -1
- package/dist/ui-ai-kit/p-ef07638f.entry.js +2 -0
- package/dist/ui-ai-kit/ui-ai-kit.css +1 -1
- package/dist/ui-ai-kit/ui-ai-kit.esm.js +1 -1
- package/package.json +5 -13
- package/dist/collection/components/ai-card/ai-card.stories.js +0 -52
- package/dist/collection/components/ai-chat-container/ai-chat-container.stories.js +0 -160
- package/dist/collection/components/ai-chat-header/ai-chat-header.stories.js +0 -138
- package/dist/collection/components/ai-chat-message/ai-chat-message.stories.js +0 -164
- package/dist/collection/components/ai-link/ai-link.stories.js +0 -79
- package/dist/collection/components/ai-loading/ai-loading.stories.js +0 -145
- package/dist/collection/components/ai-message-input/ai-message-input.stories.js +0 -125
- package/dist/collection/components/ai-rating/ai-rating.stories.js +0 -78
- package/dist/collection/components/ai-suggestion/ai-suggestion.stories.js +0 -62
- package/dist/collection/components/ai-voice-input/ai-voice-input.stories.js +0 -118
- package/dist/components/p-CWjXxYJI.js +0 -1
- package/dist/types/components/ai-card/ai-card.stories.d.ts +0 -7
- package/dist/types/components/ai-chat-container/ai-chat-container.stories.d.ts +0 -7
- package/dist/types/components/ai-chat-header/ai-chat-header.stories.d.ts +0 -8
- package/dist/types/components/ai-chat-message/ai-chat-message.stories.d.ts +0 -10
- package/dist/types/components/ai-link/ai-link.stories.d.ts +0 -8
- package/dist/types/components/ai-loading/ai-loading.stories.d.ts +0 -10
- package/dist/types/components/ai-message-input/ai-message-input.stories.d.ts +0 -13
- package/dist/types/components/ai-rating/ai-rating.stories.d.ts +0 -8
- package/dist/types/components/ai-suggestion/ai-suggestion.stories.d.ts +0 -8
- package/dist/types/components/ai-voice-input/ai-voice-input.stories.d.ts +0 -9
- package/dist/ui-ai-kit/p-11facfad.entry.js +0 -1
- package/dist/ui-ai-kit/p-128a2ed4.entry.js +0 -1
- package/dist/ui-ai-kit/p-227bdb8f.entry.js +0 -1
- package/dist/ui-ai-kit/p-56163e8c.entry.js +0 -1
- package/dist/ui-ai-kit/p-6d21d0fd.entry.js +0 -1
- package/dist/ui-ai-kit/p-6ddcd77b.entry.js +0 -1
- package/dist/ui-ai-kit/p-7hrZ8FOQ.js +0 -2
- package/dist/ui-ai-kit/p-8e90143e.entry.js +0 -1
- package/dist/ui-ai-kit/p-9938c277.entry.js +0 -1
- package/dist/ui-ai-kit/p-dc5b4a7f.entry.js +0 -1
- package/dist/ui-ai-kit/p-fb1702de.entry.js +0 -1
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
:host {
|
|
2
2
|
display: block;
|
|
3
3
|
width: 100%;
|
|
4
|
-
font-family: var(--ai-font-family, "PingARLT", sans-serif);
|
|
5
|
-
|
|
6
|
-
--ai-input-bg: var(--ai-bg-input, #ffffff);
|
|
7
|
-
--ai-input-border-color: var(--ai-border-default, #eeeeee);
|
|
8
|
-
--ai-send-button-bg: var(--ai-border-default, #eeeeee);
|
|
9
|
-
--ai-send-button-border: var(--ai-border-default, #eeeeee);
|
|
10
|
-
--ai-send-button-color: var(--ai-text-secondary, #737373);
|
|
11
|
-
--ai-send-button-active-color: var(--ai-text-primary, #333333);
|
|
12
|
-
--ai-voice-timer-color: var(--ai-text-secondary, #737373);
|
|
13
4
|
}
|
|
14
5
|
|
|
15
6
|
/* Mirrors ai-message-input wrapper */
|
|
16
7
|
.wrapper {
|
|
17
8
|
position: relative;
|
|
18
|
-
padding: var(--
|
|
9
|
+
padding: var(--Spacing-Sizes-lg, 12px);
|
|
19
10
|
}
|
|
20
11
|
|
|
21
|
-
/* Same glow as message input */
|
|
12
|
+
/* Same glow as message input — always in DOM to avoid layout shift */
|
|
22
13
|
.glow {
|
|
23
14
|
position: absolute;
|
|
24
15
|
bottom: 20px;
|
|
@@ -28,17 +19,22 @@
|
|
|
28
19
|
border-radius: 9999px;
|
|
29
20
|
background: var(--ai-input-glow);
|
|
30
21
|
filter: blur(20px);
|
|
31
|
-
opacity: 0
|
|
22
|
+
opacity: 0;
|
|
32
23
|
pointer-events: none;
|
|
24
|
+
transition: opacity 0.2s ease;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.glow.visible {
|
|
28
|
+
opacity: 0.9;
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
/* Same pill container as message input */
|
|
36
32
|
.input-container {
|
|
37
33
|
position: relative;
|
|
38
|
-
background-color: var(--ai-input
|
|
34
|
+
background-color: var(--ai-bg-input);
|
|
39
35
|
border-radius: var(--ai-input-border-radius, 9999px);
|
|
40
|
-
border: 1px solid var(--ai-
|
|
41
|
-
box-shadow:
|
|
36
|
+
border: 1px solid var(--ai-border-default);
|
|
37
|
+
box-shadow: var(--ai-shadow-sm);
|
|
42
38
|
padding: var(--ai-input-padding, 12px);
|
|
43
39
|
overflow: hidden;
|
|
44
40
|
}
|
|
@@ -60,9 +56,9 @@
|
|
|
60
56
|
max-height: 32px;
|
|
61
57
|
padding: 4px 8px;
|
|
62
58
|
border-radius: 32px;
|
|
63
|
-
border: 2px solid var(--ai-
|
|
64
|
-
background-color: var(--ai-
|
|
65
|
-
color: var(--ai-
|
|
59
|
+
border: 2px solid var(--ai-border-default);
|
|
60
|
+
background-color: var(--ai-border-default);
|
|
61
|
+
color: var(--ai-text-secondary);
|
|
66
62
|
cursor: pointer;
|
|
67
63
|
flex-shrink: 0;
|
|
68
64
|
transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
|
|
@@ -96,12 +92,21 @@
|
|
|
96
92
|
border-color: var(--ai-send-button-active-hover-border, var(--ai-accent));
|
|
97
93
|
}
|
|
98
94
|
|
|
95
|
+
@keyframes pulse-once {
|
|
96
|
+
0% { transform: scale(1); }
|
|
97
|
+
40% { transform: scale(1.18); }
|
|
98
|
+
100% { transform: scale(1); }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.submit-button.pulse {
|
|
102
|
+
animation: pulse-once 0.35s ease;
|
|
103
|
+
}
|
|
104
|
+
|
|
99
105
|
/* Timer */
|
|
100
106
|
.timer {
|
|
101
107
|
font-size: 13px;
|
|
102
108
|
font-weight: 500;
|
|
103
|
-
|
|
104
|
-
color: var(--ai-voice-timer-color, #737373);
|
|
109
|
+
color: var(--ai-text-secondary);
|
|
105
110
|
min-width: 36px;
|
|
106
111
|
text-align: center;
|
|
107
112
|
flex-shrink: 0;
|
|
@@ -114,8 +119,8 @@
|
|
|
114
119
|
/* Waveform canvas */
|
|
115
120
|
.waveform {
|
|
116
121
|
flex: 1;
|
|
122
|
+
min-width: 0;
|
|
117
123
|
height: 32px;
|
|
118
|
-
max-width: 100%;
|
|
119
124
|
}
|
|
120
125
|
|
|
121
126
|
/* Error message */
|
|
@@ -130,7 +135,7 @@
|
|
|
130
135
|
padding: 6px 12px;
|
|
131
136
|
border-radius: 6px;
|
|
132
137
|
white-space: nowrap;
|
|
133
|
-
box-shadow:
|
|
138
|
+
box-shadow: var(--ai-shadow-error);
|
|
134
139
|
border: 1px solid var(--ai-voice-error-border, var(--ai-danger-border));
|
|
135
140
|
z-index: 10;
|
|
136
141
|
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
const MAX_RECORDING_TIME = 60; // seconds
|
|
3
3
|
export class VoiceInput {
|
|
4
|
+
el;
|
|
4
5
|
/** Whether the voice input is disabled */
|
|
5
6
|
disabled = false;
|
|
6
7
|
/** Whether to show the waveform animation */
|
|
7
8
|
showWaveform = true;
|
|
8
9
|
/** Whether to auto-start recording on mount */
|
|
9
10
|
autoStart = false;
|
|
11
|
+
/** Error text to display on mic access failure. Defaults to Arabic; falls back to English when document lang is 'en' */
|
|
12
|
+
errorText = '';
|
|
13
|
+
/** Waveform bar color. Falls back to --ai-waveform-color CSS var, then #9ca3af */
|
|
14
|
+
waveformColor = '';
|
|
10
15
|
/** Internal state */
|
|
11
16
|
state = 'idle';
|
|
12
17
|
error = null;
|
|
13
18
|
recordingDuration = 0;
|
|
19
|
+
submitPulse = false;
|
|
14
20
|
/** Event emitted when audio blob is ready */
|
|
15
21
|
audioRecorded;
|
|
16
22
|
/** Event emitted when recording is canceled */
|
|
@@ -28,7 +34,7 @@ export class VoiceInput {
|
|
|
28
34
|
animationFrameId = 0;
|
|
29
35
|
prevHeights = [];
|
|
30
36
|
componentDidLoad() {
|
|
31
|
-
if (this.autoStart) {
|
|
37
|
+
if (this.autoStart && !this.disabled) {
|
|
32
38
|
this.startRecording();
|
|
33
39
|
}
|
|
34
40
|
}
|
|
@@ -64,6 +70,11 @@ export class VoiceInput {
|
|
|
64
70
|
this.streamRef = null;
|
|
65
71
|
}
|
|
66
72
|
};
|
|
73
|
+
getErrorText() {
|
|
74
|
+
if (this.errorText)
|
|
75
|
+
return this.errorText;
|
|
76
|
+
return document.documentElement.lang === 'en' ? 'Microphone access denied' : 'تعذّر الوصول للميكروفون';
|
|
77
|
+
}
|
|
67
78
|
startRecording = async () => {
|
|
68
79
|
try {
|
|
69
80
|
this.error = null;
|
|
@@ -102,10 +113,10 @@ export class VoiceInput {
|
|
|
102
113
|
this.drawWaveform();
|
|
103
114
|
});
|
|
104
115
|
}
|
|
105
|
-
// Start timer
|
|
116
|
+
// Start timer — 1 s interval avoids unnecessary re-renders
|
|
106
117
|
this.recordingTimer = window.setInterval(() => {
|
|
107
118
|
this.recordingDuration = Math.floor((Date.now() - this.recordingStartTime) / 1000);
|
|
108
|
-
},
|
|
119
|
+
}, 1000);
|
|
109
120
|
// Auto-stop after max time
|
|
110
121
|
this.maxTimeoutRef = window.setTimeout(() => {
|
|
111
122
|
this.stopRecording();
|
|
@@ -113,27 +124,41 @@ export class VoiceInput {
|
|
|
113
124
|
}
|
|
114
125
|
catch (err) {
|
|
115
126
|
console.error('Error starting recording:', err);
|
|
116
|
-
this.error =
|
|
127
|
+
this.error = this.getErrorText();
|
|
117
128
|
this.state = 'idle';
|
|
118
129
|
}
|
|
119
130
|
};
|
|
120
131
|
setupMediaRecorder = (stream) => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
132
|
+
// Pick a supported MIME type — audio/webm is unavailable on iOS/Safari
|
|
133
|
+
const mimeType = MediaRecorder.isTypeSupported('audio/webm')
|
|
134
|
+
? 'audio/webm'
|
|
135
|
+
: MediaRecorder.isTypeSupported('audio/ogg')
|
|
136
|
+
? 'audio/ogg'
|
|
137
|
+
: '';
|
|
138
|
+
const options = mimeType ? { mimeType } : {};
|
|
139
|
+
const mediaRecorder = new MediaRecorder(stream, options);
|
|
124
140
|
mediaRecorder.ondataavailable = e => {
|
|
125
141
|
if (e.data.size > 0) {
|
|
126
142
|
this.audioChunks.push(e.data);
|
|
127
143
|
}
|
|
128
144
|
};
|
|
129
145
|
mediaRecorder.onstop = () => {
|
|
130
|
-
const
|
|
146
|
+
const blobType = mimeType || 'audio/mp4';
|
|
147
|
+
const audioBlob = new Blob(this.audioChunks, { type: blobType });
|
|
131
148
|
this.audioRecorded.emit({ blob: audioBlob, duration: this.recordingDuration });
|
|
132
149
|
};
|
|
133
150
|
this.mediaRecorderRef = mediaRecorder;
|
|
134
151
|
mediaRecorder.start(100); // Collect data every 100ms
|
|
135
152
|
};
|
|
136
153
|
stopRecording = () => {
|
|
154
|
+
// Guard: require at least 1 second of audio
|
|
155
|
+
if (this.recordingDuration < 1) {
|
|
156
|
+
this.submitPulse = true;
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
this.submitPulse = false;
|
|
159
|
+
}, 400);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
137
162
|
if (this.recordingTimer) {
|
|
138
163
|
clearInterval(this.recordingTimer);
|
|
139
164
|
this.recordingTimer = null;
|
|
@@ -163,21 +188,51 @@ export class VoiceInput {
|
|
|
163
188
|
const ctx = canvas.getContext('2d');
|
|
164
189
|
if (!ctx)
|
|
165
190
|
return;
|
|
166
|
-
const barCount = 100;
|
|
167
191
|
const barWidth = 1;
|
|
168
192
|
const gap = 2;
|
|
193
|
+
const minHeight = 4;
|
|
169
194
|
const bufferLength = this.analyserRef.frequencyBinCount;
|
|
170
195
|
const dataArray = new Uint8Array(bufferLength);
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
196
|
+
// Resolve waveform color from prop → CSS var → fallback
|
|
197
|
+
const resolvedColor = this.waveformColor ||
|
|
198
|
+
getComputedStyle(this.el).getPropertyValue('--ai-waveform-color').trim() ||
|
|
199
|
+
'#9ca3af';
|
|
200
|
+
const drawRoundRect = (x, y, w, h, r) => {
|
|
201
|
+
ctx.beginPath();
|
|
202
|
+
if (typeof ctx.roundRect === 'function') {
|
|
203
|
+
ctx.roundRect(x, y, w, h, r);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
// arc-based fallback for Safari < 15.4
|
|
207
|
+
const cr = Math.min(r, w / 2, h / 2);
|
|
208
|
+
ctx.moveTo(x + cr, y);
|
|
209
|
+
ctx.lineTo(x + w - cr, y);
|
|
210
|
+
ctx.arcTo(x + w, y, x + w, y + cr, cr);
|
|
211
|
+
ctx.lineTo(x + w, y + h - cr);
|
|
212
|
+
ctx.arcTo(x + w, y + h, x + w - cr, y + h, cr);
|
|
213
|
+
ctx.lineTo(x + cr, y + h);
|
|
214
|
+
ctx.arcTo(x, y + h, x, y + h - cr, cr);
|
|
215
|
+
ctx.lineTo(x, y + cr);
|
|
216
|
+
ctx.arcTo(x, y, x + cr, y, cr);
|
|
217
|
+
ctx.closePath();
|
|
218
|
+
}
|
|
219
|
+
};
|
|
177
220
|
const draw = () => {
|
|
178
221
|
if (this.state !== 'recording')
|
|
179
222
|
return;
|
|
180
223
|
this.animationFrameId = requestAnimationFrame(draw);
|
|
224
|
+
// Sync canvas buffer to actual rendered size so it never overflows
|
|
225
|
+
const renderedWidth = canvas.offsetWidth;
|
|
226
|
+
if (renderedWidth > 0 && canvas.width !== renderedWidth) {
|
|
227
|
+
canvas.width = renderedWidth;
|
|
228
|
+
}
|
|
229
|
+
// Recompute barCount each frame based on actual canvas width
|
|
230
|
+
const barCount = Math.min(100, Math.floor(canvas.width / (barWidth + gap)));
|
|
231
|
+
const binsPerBar = Math.max(1, Math.floor(bufferLength / barCount));
|
|
232
|
+
// Re-initialize lerp state when barCount changes
|
|
233
|
+
if (this.prevHeights.length !== barCount) {
|
|
234
|
+
this.prevHeights = new Array(barCount).fill(minHeight);
|
|
235
|
+
}
|
|
181
236
|
this.analyserRef.getByteFrequencyData(dataArray);
|
|
182
237
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
183
238
|
const centerY = canvas.height / 2;
|
|
@@ -200,9 +255,8 @@ export class VoiceInput {
|
|
|
200
255
|
const barHeight = this.prevHeights[i];
|
|
201
256
|
const x = startX + i * (barWidth + gap);
|
|
202
257
|
const y = centerY - barHeight / 2;
|
|
203
|
-
ctx.fillStyle =
|
|
204
|
-
|
|
205
|
-
ctx.roundRect(x, y, barWidth, barHeight, barWidth / 2);
|
|
258
|
+
ctx.fillStyle = resolvedColor;
|
|
259
|
+
drawRoundRect(x, y, barWidth, barHeight, barWidth / 2);
|
|
206
260
|
ctx.fill();
|
|
207
261
|
}
|
|
208
262
|
};
|
|
@@ -215,7 +269,7 @@ export class VoiceInput {
|
|
|
215
269
|
};
|
|
216
270
|
render() {
|
|
217
271
|
const remaining = MAX_RECORDING_TIME - this.recordingDuration;
|
|
218
|
-
return (h(Host, { key: '
|
|
272
|
+
return (h(Host, { key: '225036c9c966084bcbdef9760d08cb677c985cc1' }, h("div", { key: '3cb3841dcb8a8e283cc325a200073ba3d540d7f8', class: "wrapper" }, h("div", { key: '1e71acf6ceb25d50d4131bf1a8021837756d0a41', class: `glow${this.state === 'recording' ? ' visible' : ''}`, "aria-hidden": "true" }), h("div", { key: 'c96027342fdf08edc990cae9f25ebb087dd33612', class: "input-container" }, this.state === 'idle' ? (h("div", { class: "recording-row" }, h("button", { type: "button", class: "submit-button", onClick: this.startRecording, disabled: this.disabled, "aria-label": "Start recording" }, h("ai-icon", { name: "mic", size: 16 })), this.error && (h("div", { class: "error-message", role: "alert" }, this.error)))) : (h("div", { class: "recording-row" }, h("button", { type: "button", class: "cancel-button", onClick: this.cancelRecording, "aria-label": "Cancel" }, h("ai-icon", { name: "cancel", size: 14 })), h("div", { class: `timer${remaining <= 5 ? ' warning' : ''}` }, this.formatDuration(this.recordingDuration)), this.showWaveform && h("canvas", { ref: el => (this.canvasRef = el), class: "waveform", height: "32" }), h("button", { type: "button", class: `submit-button${this.submitPulse ? ' pulse' : ''}`, onClick: this.stopRecording, "aria-label": "Send" }, h("ai-icon", { name: "arrow-up", size: 14 }))))))));
|
|
219
273
|
}
|
|
220
274
|
static get is() { return "ai-voice-input"; }
|
|
221
275
|
static get encapsulation() { return "shadow"; }
|
|
@@ -290,6 +344,46 @@ export class VoiceInput {
|
|
|
290
344
|
"reflect": false,
|
|
291
345
|
"attribute": "auto-start",
|
|
292
346
|
"defaultValue": "false"
|
|
347
|
+
},
|
|
348
|
+
"errorText": {
|
|
349
|
+
"type": "string",
|
|
350
|
+
"mutable": false,
|
|
351
|
+
"complexType": {
|
|
352
|
+
"original": "string",
|
|
353
|
+
"resolved": "string",
|
|
354
|
+
"references": {}
|
|
355
|
+
},
|
|
356
|
+
"required": false,
|
|
357
|
+
"optional": false,
|
|
358
|
+
"docs": {
|
|
359
|
+
"tags": [],
|
|
360
|
+
"text": "Error text to display on mic access failure. Defaults to Arabic; falls back to English when document lang is 'en'"
|
|
361
|
+
},
|
|
362
|
+
"getter": false,
|
|
363
|
+
"setter": false,
|
|
364
|
+
"reflect": false,
|
|
365
|
+
"attribute": "error-text",
|
|
366
|
+
"defaultValue": "''"
|
|
367
|
+
},
|
|
368
|
+
"waveformColor": {
|
|
369
|
+
"type": "string",
|
|
370
|
+
"mutable": false,
|
|
371
|
+
"complexType": {
|
|
372
|
+
"original": "string",
|
|
373
|
+
"resolved": "string",
|
|
374
|
+
"references": {}
|
|
375
|
+
},
|
|
376
|
+
"required": false,
|
|
377
|
+
"optional": false,
|
|
378
|
+
"docs": {
|
|
379
|
+
"tags": [],
|
|
380
|
+
"text": "Waveform bar color. Falls back to --ai-waveform-color CSS var, then #9ca3af"
|
|
381
|
+
},
|
|
382
|
+
"getter": false,
|
|
383
|
+
"setter": false,
|
|
384
|
+
"reflect": false,
|
|
385
|
+
"attribute": "waveform-color",
|
|
386
|
+
"defaultValue": "''"
|
|
293
387
|
}
|
|
294
388
|
};
|
|
295
389
|
}
|
|
@@ -297,7 +391,8 @@ export class VoiceInput {
|
|
|
297
391
|
return {
|
|
298
392
|
"state": {},
|
|
299
393
|
"error": {},
|
|
300
|
-
"recordingDuration": {}
|
|
394
|
+
"recordingDuration": {},
|
|
395
|
+
"submitPulse": {}
|
|
301
396
|
};
|
|
302
397
|
}
|
|
303
398
|
static get events() {
|
|
@@ -338,4 +433,5 @@ export class VoiceInput {
|
|
|
338
433
|
}
|
|
339
434
|
}];
|
|
340
435
|
}
|
|
436
|
+
static get elementRef() { return "el"; }
|
|
341
437
|
}
|
|
@@ -75,4 +75,28 @@ export const iconRegistry = {
|
|
|
75
75
|
viewBox: '0 0 24 24',
|
|
76
76
|
content: ` <path d="M15.1667 0.999756L15.7646 2.11753C16.1689 2.87322 16.371 3.25107 16.2374 3.41289C16.1037 3.57471 15.6635 3.44402 14.7831 3.18264C13.9029 2.92131 12.9684 2.78071 12 2.78071C6.75329 2.78071 2.5 6.90822 2.5 11.9998C2.5 13.6789 2.96262 15.2533 3.77093 16.6093M8.83333 22.9998L8.23536 21.882C7.83108 21.1263 7.62894 20.7484 7.7626 20.5866C7.89627 20.4248 8.33649 20.5555 9.21689 20.8169C10.0971 21.0782 11.0316 21.2188 12 21.2188C17.2467 21.2188 21.5 17.0913 21.5 11.9998C21.5 10.3206 21.0374 8.74623 20.2291 7.39023" stroke="currentColor" />`,
|
|
77
77
|
},
|
|
78
|
+
'list': {
|
|
79
|
+
viewBox: '0 0 24 24',
|
|
80
|
+
content: '<path d="M8 6h13M8 12h13M8 18h13" stroke="currentColor" stroke-width="2" stroke-linecap="round" fill="none"/><path d="M3 6h.01M3 12h.01M3 18h.01" stroke="currentColor" stroke-width="2" stroke-linecap="round" fill="none"/>',
|
|
81
|
+
},
|
|
82
|
+
'route': {
|
|
83
|
+
viewBox: '0 0 24 24',
|
|
84
|
+
content: '<circle cx="6" cy="19" r="2" stroke="currentColor" stroke-width="2" fill="none"/><circle cx="18" cy="5" r="2" stroke="currentColor" stroke-width="2" fill="none"/><path d="M6 17V11a6 6 0 0 1 6-6h2" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none"/><path d="M15 8l3-3-3-3" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',
|
|
85
|
+
},
|
|
86
|
+
'check-circle': {
|
|
87
|
+
viewBox: '0 0 24 24',
|
|
88
|
+
content: '<circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="2" fill="none"/><path d="M8 12l3 3 5-5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',
|
|
89
|
+
},
|
|
90
|
+
'wifi-off': {
|
|
91
|
+
viewBox: '0 0 24 24',
|
|
92
|
+
content: '<path d="M1 1l22 22M16.72 11.06A11 11 0 0 0 12 10c-2.06 0-3.96.57-5.59 1.56M5 12.55a11 11 0 0 0-1.48 1.45M10.71 5.05A16 16 0 0 1 22.56 9M1.42 9a15.91 15.91 0 0 1 4.7-2.88M8.53 16.11a6 6 0 0 1 6.95 0M12 20h.01" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',
|
|
93
|
+
},
|
|
94
|
+
'warning': {
|
|
95
|
+
viewBox: '0 0 24 24',
|
|
96
|
+
content: '<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none"/><path d="M12 9v4M12 17h.01" stroke="currentColor" stroke-width="2" stroke-linecap="round" fill="none"/>',
|
|
97
|
+
},
|
|
98
|
+
'ellipsis': {
|
|
99
|
+
viewBox: '0 0 24 24',
|
|
100
|
+
content: '<circle cx="5" cy="12" r="2" fill="currentColor"/><circle cx="12" cy="12" r="2" fill="currentColor"/><circle cx="19" cy="12" r="2" fill="currentColor"/>',
|
|
101
|
+
},
|
|
78
102
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as a,t as d,H as r,h as
|
|
1
|
+
import{p as a,t as d,H as r,h as o,c as i}from"./p-DnO4dikr.js";const e=a(class extends r{constructor(a){super(),!1!==a&&this.__registerHost(),this.__attachShadow()}noPadding=!1;noShadow=!1;render(){return o(i,{key:"4805b02b4eee8e01d0233de788a58770a85db2aa"},o("div",{key:"75576f8a791fc49c3a750d491b0e835d0e5ce8cb",class:{card:!0,"card--no-padding":this.noPadding,"card--no-shadow":this.noShadow}},o("slot",{key:"e16cdb10e803451fdd47006a98656168fe2495f4"})))}static get style(){return":host{--ai-card-border:1px solid var(--ai-border-default);--ai-card-radius:16px;--ai-card-padding:16px;--ai-card-gap:12px;--ai-card-shadow:var(--ai-shadow-sm);display:block}.card{background:var(--ai-bg-card);border:var(--ai-card-border);border-radius:var(--ai-card-radius);padding:var(--ai-card-padding);box-shadow:var(--ai-card-shadow);box-sizing:border-box;overflow:hidden;color:var(--ai-text-primary);width:100%;display:flex;flex-direction:column;gap:var(--ai-card-gap);text-align:start;font-size:14px;line-height:20px}.card--no-padding{padding:0}.card--no-shadow{box-shadow:none}"}},[769,"ai-card",{noPadding:[4,"no-padding"],noShadow:[4,"no-shadow"]}]),s=e,n=function(){"undefined"!=typeof customElements&&["ai-card"].forEach((a=>{"ai-card"===a&&(customElements.get(d(a))||customElements.define(d(a),e))}))};export{s as AiCard,n as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as
|
|
1
|
+
import{p as t,H as a,h as e,c as i,t as o}from"./p-DnO4dikr.js";import{d as r}from"./p-Dr2tAPV7.js";const s=t(class extends a{get el(){return this}isOpen=!1;position="right";width="28rem";autoScroll=!0;showWatermark=!1;floatHeight="600px";theme="light";isMobile=!1;floatLeft="24px";floatTop="24px";containerRef;messagesAreaRef;dragState=null;dragListener=t=>{const a=this.containerRef;if(!a)return;const{clientX:e,clientY:i}=t.detail,o=a.getBoundingClientRect();this.dragState={startX:e,startY:i,initLeft:o.left,initTop:o.top},this.floatLeft=o.left+"px",this.floatTop=o.top+"px";const r=t=>{if(!this.dragState)return;let e=this.dragState.initLeft+(t.clientX-this.dragState.startX),i=this.dragState.initTop+(t.clientY-this.dragState.startY);const o=window.innerWidth,r=window.innerHeight,s=a.offsetHeight;e=Math.max(0,Math.min(e,o-a.offsetWidth)),i=Math.max(0,Math.min(i,r-s)),this.floatLeft=e+"px",this.floatTop=i+"px"},s=()=>{this.dragState=null,document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",s)};document.addEventListener("pointermove",r),document.addEventListener("pointerup",s)};constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.checkMobile=this.checkMobile.bind(this)}componentWillLoad(){this.checkMobile()}componentDidLoad(){"undefined"!=typeof window&&(window.addEventListener("resize",this.checkMobile),"float"===this.position&&this.setupDrag())}isOpenChanged(t){t&&this.autoScroll&&this.messagesAreaRef&&requestAnimationFrame((()=>{this.messagesAreaRef.scrollTop=this.messagesAreaRef.scrollHeight}))}positionChanged(t){"float"===t&&this.setupDrag()}disconnectedCallback(){window.removeEventListener("resize",this.checkMobile),this.el.removeEventListener("headerDragStart",this.dragListener)}async scrollToBottom(){this.messagesAreaRef&&(this.messagesAreaRef.scrollTop=this.messagesAreaRef.scrollHeight)}checkMobile(){"undefined"!=typeof window&&(this.isMobile=window.innerWidth<768)}setupDrag(){this.el.removeEventListener("headerDragStart",this.dragListener),this.el.addEventListener("headerDragStart",this.dragListener)}getContainerClasses(){const t=["chat-container",this.position];return this.isOpen&&t.push("open"),this.isMobile&&t.push("mobile"),t.join(" ")}getContainerStyle(){const t={};return this.isMobile||("float"===this.position?(t.width=this.width,t.height=this.floatHeight,t.left=this.floatLeft,t.top=this.floatTop):t.width=this.width),t}isDark(){return"dark"===this.theme||"auto"===this.theme&&"undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches}render(){return e(i,{key:"dd656127f6974b6eef12f64c78c072f2c1f92a6a",class:{dark:this.isDark()}},e("div",{key:"0eb43bc5c8b80e5576146f01998e5279eb860162",class:this.getContainerClasses(),style:this.getContainerStyle(),ref:t=>this.containerRef=t},this.showWatermark&&e("div",{key:"363046f0e73ab7aa0209d5f41562031fb34d6c2d",class:"watermark"},e("ai-icon",{key:"1f3c26ba6a145f8532f6e1a40ea344249e8e5b43",name:"watermark",size:133})),e("slot",{key:"3ec10548660ff721c094be36a15a152fdf6dac78",name:"header"}),e("div",{key:"9babb87041287ac400322b910aa64f7a7b1743a5",class:"messages-area",ref:t=>this.messagesAreaRef=t},e("slot",{key:"937c0c0bd675e5a619d46883e7c1f890754aae4b"})),e("slot",{key:"0982b8bc96537c6cecca757926d5849ba386bd69",name:"footer"})))}static get watchers(){return{isOpen:[{isOpenChanged:0}],position:[{positionChanged:0}]}}static get style(){return":host{display:contents}.chat-container{font-family:var(--ai-font-family);display:flex;flex-direction:column;overflow:hidden;position:relative;background-color:var(--ai-container-bg, var(--ai-bg-card));border:1px solid var(--ai-border-default);z-index:50;box-sizing:border-box}.messages-area{flex:1;overflow-y:auto;min-height:0;scrollbar-width:thin;padding:var(--ai-spacing-2xl, 16px);scrollbar-color:var(--ai-scrollbar-thumb) transparent}.messages-area::-webkit-scrollbar{width:3px}.messages-area::-webkit-scrollbar-track{background:transparent}.messages-area::-webkit-scrollbar-thumb{background:var(--ai-scrollbar-thumb);border-radius:99px}.messages-area::-webkit-scrollbar-thumb:hover{background:var(--ai-scrollbar-thumb-hover)}.chat-container.left,.chat-container.right{position:fixed;top:0;bottom:0;transition:transform 300ms cubic-bezier(0.4, 0, 0.2, 1)}.chat-container.left{left:0;transform:translateX(-100%)}.chat-container.right{right:0;transform:translateX(100%)}.chat-container.left.open,.chat-container.right.open{transform:translateX(0)}.chat-container.float{position:fixed;border-radius:16px;box-shadow:var(--ai-shadow-float);opacity:0;pointer-events:none;transform:scale(0.95);transform-origin:bottom left;transition:opacity 200ms ease, transform 200ms ease}.chat-container.float.open{opacity:1;pointer-events:auto;transform:scale(1)}.watermark{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);pointer-events:none}.watermark ai-icon{opacity:0.8;filter:var(--ai-shadow-watermark)}.chat-container.mobile{width:100% !important}.chat-container.float.mobile{left:0 !important;right:0 !important;top:0 !important;bottom:0 !important;height:100% !important;border-radius:0 !important}@media (max-width: 767px){.chat-container{width:100% !important}.chat-container.float{left:0 !important;right:0 !important;top:0 !important;bottom:0 !important;height:100% !important;border-radius:0 !important}}:host(.dark) .watermark ai-icon{opacity:0.6}"}},[769,"ai-chat-container",{isOpen:[4,"is-open"],position:[1],width:[1],autoScroll:[4,"auto-scroll"],showWatermark:[4,"show-watermark"],floatHeight:[1,"float-height"],theme:[1],isMobile:[32],floatLeft:[32],floatTop:[32],scrollToBottom:[64]},void 0,{isOpen:[{isOpenChanged:0}],position:[{positionChanged:0}]}]),n=s,c=function(){"undefined"!=typeof customElements&&["ai-chat-container","ai-icon"].forEach((t=>{switch(t){case"ai-chat-container":customElements.get(o(t))||customElements.define(o(t),s);break;case"ai-icon":customElements.get(o(t))||r()}}))};export{n as AiChatContainer,c as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as
|
|
1
|
+
import{p as t,H as a,d as i,h as e,c as n,t as s}from"./p-DnO4dikr.js";import{i as r}from"./p-SJZ6Ujn9.js";const o=t(class extends a{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.closeClick=i(this,"closeClick"),this.editClick=i(this,"editClick"),this.dropdownClick=i(this,"dropdownClick"),this.positionClick=i(this,"positionClick"),this.backClick=i(this,"backClick"),this.headerDragStart=i(this,"headerDragStart")}mode="agent";conversation="محادثة جديدة";agentName="";agentStatus="";agentAvatar="";showBack=!0;isDraggable=!1;statusIndicator="online";avatarError=!1;closeClick;editClick;dropdownClick;positionClick;backClick;headerDragStart;renderIcon(t,a,i){const n=r[t];return n?e("span",{class:"icon-wrap",innerHTML:`<svg width="${a}" height="${i}" viewBox="${n.viewBox}" fill="none" xmlns="http://www.w3.org/2000/svg">${n.content}</svg>`}):null}renderAvatar(){const t=this.agentName?this.agentName.charAt(0):"?";return!this.agentAvatar||this.avatarError?e("div",{class:"avatar-fallback"},t):e("img",{class:"avatar",src:this.agentAvatar,alt:this.agentName,onError:()=>{this.avatarError=!0}})}renderDragBtn(){return this.isDraggable&&e("button",{class:"action-btn drag-btn","aria-label":"سحب / Drag",onPointerDown:t=>{t.preventDefault(),this.headerDragStart.emit({clientX:t.clientX,clientY:t.clientY})}},this.renderIcon("drag",11,15))}renderAgentMode(){return[this.renderDragBtn(),e("div",{class:"content agent dropdown-trigger",role:"button",onClick:()=>this.dropdownClick.emit(),"aria-haspopup":"listbox","aria-expanded":!1,"aria-label":this.conversation+", افتح قائمة المحادثات"},e("span",{class:"title"},this.conversation),e("span",{class:"dropdown-chevron"},this.renderIcon("chevron-down",24,24))),e("div",{class:"actions"},e("button",{class:"action-btn","aria-label":"تعديل / Edit",onClick:()=>this.editClick.emit()},this.renderIcon("pencil-edit",22,22)),e("button",{class:"action-btn","aria-label":"العرض / Position",onClick:()=>this.positionClick.emit()},this.renderIcon("hand",22,22)),e("button",{class:"action-btn","aria-label":"إغلاق / Close",onClick:()=>this.closeClick.emit()},this.renderIcon("cancel",22,22)))]}renderHumanMode(){return[this.renderDragBtn(),e("div",{class:"content human"},this.showBack&&e("button",{class:"back-btn","aria-label":"رجوع / Back",onClick:()=>this.backClick.emit()},this.renderIcon("arrow-right",24,24)),e("div",{class:"avatar-wrapper"},this.renderAvatar(),e("span",{class:"online-dot status-"+this.statusIndicator},this.renderIcon("online-dot",10,10))),e("div",{class:"text-block"},e("span",{class:"agent-name"},this.agentName),this.agentStatus&&e("span",{class:"agent-status"},this.agentStatus))),e("div",{class:"actions"},e("button",{class:"action-btn","aria-label":"العرض / Position",onClick:()=>this.positionClick.emit()},this.renderIcon("hand",22,22)),e("button",{class:"action-btn","aria-label":"إغلاق / Close",onClick:()=>this.closeClick.emit()},this.renderIcon("cancel",22,22)))]}render(){return e(n,{key:"f96f4d5c533747b2843706c165866769b834fb98"},e("div",{key:"8643a8cb214cbe40f0ee1a0b64c483829b5de6c9",class:"header-container"},"agent"===this.mode?this.renderAgentMode():this.renderHumanMode()))}static get style(){return":host{display:block}.header-container{display:flex;align-items:center;gap:8px;padding:16px;background:var(--ai-bg-card);border-bottom:1px solid var(--ai-border-light);width:100%;box-sizing:border-box}.drag-btn{cursor:grab;color:var(--ai-text-muted)}.drag-btn:active{cursor:grabbing}.action-btn,.back-btn{width:40px;height:40px;padding:4px;display:flex;align-items:center;justify-content:center;background:var(--ai-bg-card);border:none;border-radius:8px;cursor:pointer;flex-shrink:0;color:var(--ai-text-primary);transition:background 0.15s ease}.action-btn:hover,.back-btn:hover{background:var(--ai-bg-surface)}.action-btn:focus-visible,.back-btn:focus-visible{outline:2px solid var(--ai-focus-ring);outline-offset:2px}.action-btn:active,.back-btn:active{background:var(--ai-bg-surface)}.actions{display:flex;align-items:center;gap:8px;flex-shrink:0}.content{flex:1 0 0;display:flex;align-items:center;justify-content:flex-start;min-width:0}.content.agent{gap:4px;height:40px}.content.human{gap:8px}.dropdown-trigger{display:flex;align-items:center;gap:4px;background:none;border:none;cursor:pointer;padding:0;flex-shrink:0;color:var(--ai-text-primary)}.dropdown-trigger:focus-visible{outline:2px solid var(--ai-focus-ring);outline-offset:2px}.title{font-size:16px;font-weight:700;color:var(--ai-text-primary);white-space:nowrap;line-height:normal;min-width:0;overflow:hidden;text-overflow:ellipsis}.avatar-wrapper{position:relative;width:40px;height:40px;flex-shrink:0}.avatar{width:40px;height:40px;border-radius:9999px;border:1px solid var(--ai-border-default);object-fit:cover;display:block}.avatar-fallback{width:40px;height:40px;border-radius:9999px;border:1px solid var(--ai-border-default);background:var(--ai-bg-surface);color:var(--ai-text-primary);font-size:16px;font-weight:600;display:flex;align-items:center;justify-content:center;flex-shrink:0}.online-dot{position:absolute;bottom:0;inset-inline-end:0;width:10px;height:10px;display:inline-flex;align-items:center;justify-content:center;color:var(--ai-bg-card);}.online-dot.status-online{color:#22c55e;}.online-dot.status-offline{color:#9ca3af;}.online-dot.status-busy{color:#ef4444;}.online-dot.status-away{color:#f59e0b;}.text-block{display:flex;flex-direction:column;align-items:flex-start;gap:0;flex-shrink:0}.agent-name{font-size:14px;font-weight:500;color:var(--ai-text-primary);line-height:20px;white-space:nowrap}.agent-status{font-size:14px;font-weight:400;color:var(--ai-text-secondary);line-height:20px;white-space:nowrap}.icon-wrap{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}.icon-wrap svg{display:block}:host-context([dir='ltr']) .back-btn .icon-wrap,:host([dir='ltr']) .back-btn .icon-wrap{transform:scaleX(-1)}"}},[513,"ai-chat-header",{mode:[1],conversation:[1],agentName:[1,"agent-name"],agentStatus:[1,"agent-status"],agentAvatar:[1,"agent-avatar"],showBack:[4,"show-back"],isDraggable:[4,"is-draggable"],statusIndicator:[1,"status-indicator"],avatarError:[32]}]),c=o,l=function(){"undefined"!=typeof customElements&&["ai-chat-header"].forEach((t=>{"ai-chat-header"===t&&(customElements.get(s(t))||customElements.define(s(t),o))}))};export{c as AiChatHeader,l as defineCustomElement}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{p as e,H as t,d as
|
|
1
|
+
import{p as e,H as t,d as n,h as i,c as r,t as a}from"./p-DnO4dikr.js";import{i as o}from"./p-SJZ6Ujn9.js";
|
|
2
|
+
/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:s,setPrototypeOf:l,isFrozen:c,getPrototypeOf:u,getOwnPropertyDescriptor:d}=Object;let{freeze:p,seal:f,create:m}=Object,{apply:g,construct:h}="undefined"!=typeof Reflect&&Reflect;p||(p=function(e){return e}),f||(f=function(e){return e}),g||(g=function(e,t){for(var n=arguments.length,i=Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return e.apply(t,i)}),h||(h=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const b=L(Array.prototype.forEach),y=L(Array.prototype.lastIndexOf),x=L(Array.prototype.pop),v=L(Array.prototype.push),w=L(Array.prototype.splice),k=L(String.prototype.toLowerCase),T=L(String.prototype.toString),A=L(String.prototype.match),S=L(String.prototype.replace),E=L(String.prototype.indexOf),R=L(String.prototype.trim),_=L(Object.prototype.hasOwnProperty),z=L(RegExp.prototype.test),O=function(e){return function(){for(var t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];return h(e,n)}}(TypeError);function L(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return g(e,t,i)}}function D(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k;l&&l(e,null);let i=t.length;for(;i--;){let r=t[i];if("string"==typeof r){const e=n(r);e!==r&&(c(t)||(t[i]=e),r=e)}e[r]=!0}return e}function C(e){for(let t=0;t<e.length;t++)_(e,t)||(e[t]=null);return e}function M(e){const t=m(null);for(const[n,i]of s(e))_(e,n)&&(t[n]=Array.isArray(i)?C(i):i&&"object"==typeof i&&i.constructor===Object?M(i):i);return t}function $(e,t){for(;null!==e;){const n=d(e,t);if(n){if(n.get)return L(n.get);if("function"==typeof n.value)return L(n.value)}e=u(e)}return function(){return null}}const F=p(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),I=p(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),N=p(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),j=p(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),B=p(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),P=p(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),U=p(["#text"]),W=p(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),q=p(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),H=p(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Y=p(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),K=f(/\{\{[\w\W]*|[\w\W]*\}\}/gm),G=f(/<%[\w\W]*|[\w\W]*%>/gm),X=f(/\$\{[\w\W]*/gm),V=f(/^data-[\-\w.\u00B7-\uFFFF]+$/),J=f(/^aria-[\-\w]+$/),Z=f(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Q=f(/^(?:\w+script|data):/i),ee=f(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),te=f(/^html$/i),ne=f(/^[a-z][.\w]*(-[.\w]+)+$/i);var ie=Object.freeze({__proto__:null,ARIA_ATTR:J,ATTR_WHITESPACE:ee,CUSTOM_ELEMENT:ne,DATA_ATTR:V,DOCTYPE_NAME:te,ERB_EXPR:G,IS_ALLOWED_URI:Z,IS_SCRIPT_OR_DATA:Q,MUSTACHE_EXPR:K,TMPLIT_EXPR:X});const re=function(){return"undefined"==typeof window?null:window};var ae=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:re();const n=t=>e(t);if(n.version="3.3.3",n.removed=[],!t||!t.document||9!==t.document.nodeType||!t.Element)return n.isSupported=!1,n;let{document:i}=t;const r=i,a=r.currentScript,{DocumentFragment:o,HTMLTemplateElement:l,Node:c,Element:u,NodeFilter:d,NamedNodeMap:f=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:g,DOMParser:h,trustedTypes:L}=t,C=u.prototype,K=$(C,"cloneNode"),G=$(C,"remove"),X=$(C,"nextSibling"),V=$(C,"childNodes"),J=$(C,"parentNode");if("function"==typeof l){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let Q,ee="";const{implementation:ne,createNodeIterator:ae,createDocumentFragment:oe,getElementsByTagName:se}=i,{importNode:le}=r;let ce={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof s&&"function"==typeof J&&ne&&void 0!==ne.createHTMLDocument;const{MUSTACHE_EXPR:ue,ERB_EXPR:de,TMPLIT_EXPR:pe,DATA_ATTR:fe,ARIA_ATTR:me,IS_SCRIPT_OR_DATA:ge,ATTR_WHITESPACE:he,CUSTOM_ELEMENT:be}=ie;let{IS_ALLOWED_URI:ye}=ie,xe=null;const ve=D({},[...F,...I,...N,...B,...U]);let we=null;const ke=D({},[...W,...q,...H,...Y]);let Te=Object.seal(m(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,Se=null;const Ee=Object.seal(m(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Re=!0,_e=!0,ze=!1,Oe=!0,Le=!1,De=!0,Ce=!1,Me=!1,$e=!1,Fe=!1,Ie=!1,Ne=!1,je=!0,Be=!1,Pe=!0,Ue=!1,We={},qe=null;const He=D({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ye=null;const Ke=D({},["audio","video","img","source","image","track"]);let Ge=null;const Xe=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ve="http://www.w3.org/1998/Math/MathML",Je="http://www.w3.org/2000/svg",Ze="http://www.w3.org/1999/xhtml";let Qe=Ze,et=!1,tt=null;const nt=D({},[Ve,Je,Ze],T);let it=D({},["mi","mo","mn","ms","mtext"]),rt=D({},["annotation-xml"]);const at=D({},["title","style","font","a","script"]);let ot=null;const st=["application/xhtml+xml","text/html"];let lt=null,ct=null;const ut=i.createElement("form"),dt=function(e){return e instanceof RegExp||e instanceof Function},pt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!ct||ct!==e){if(e&&"object"==typeof e||(e={}),e=M(e),ot=-1===st.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,lt="application/xhtml+xml"===ot?T:k,xe=_(e,"ALLOWED_TAGS")?D({},e.ALLOWED_TAGS,lt):ve,we=_(e,"ALLOWED_ATTR")?D({},e.ALLOWED_ATTR,lt):ke,tt=_(e,"ALLOWED_NAMESPACES")?D({},e.ALLOWED_NAMESPACES,T):nt,Ge=_(e,"ADD_URI_SAFE_ATTR")?D(M(Xe),e.ADD_URI_SAFE_ATTR,lt):Xe,Ye=_(e,"ADD_DATA_URI_TAGS")?D(M(Ke),e.ADD_DATA_URI_TAGS,lt):Ke,qe=_(e,"FORBID_CONTENTS")?D({},e.FORBID_CONTENTS,lt):He,Ae=_(e,"FORBID_TAGS")?D({},e.FORBID_TAGS,lt):M({}),Se=_(e,"FORBID_ATTR")?D({},e.FORBID_ATTR,lt):M({}),We=!!_(e,"USE_PROFILES")&&e.USE_PROFILES,Re=!1!==e.ALLOW_ARIA_ATTR,_e=!1!==e.ALLOW_DATA_ATTR,ze=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Oe=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Le=e.SAFE_FOR_TEMPLATES||!1,De=!1!==e.SAFE_FOR_XML,Ce=e.WHOLE_DOCUMENT||!1,Fe=e.RETURN_DOM||!1,Ie=e.RETURN_DOM_FRAGMENT||!1,Ne=e.RETURN_TRUSTED_TYPE||!1,$e=e.FORCE_BODY||!1,je=!1!==e.SANITIZE_DOM,Be=e.SANITIZE_NAMED_PROPS||!1,Pe=!1!==e.KEEP_CONTENT,Ue=e.IN_PLACE||!1,ye=e.ALLOWED_URI_REGEXP||Z,Qe=e.NAMESPACE||Ze,it=e.MATHML_TEXT_INTEGRATION_POINTS||it,rt=e.HTML_INTEGRATION_POINTS||rt,Te=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&dt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Te.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&dt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Te.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Te.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Le&&(_e=!1),Ie&&(Fe=!0),We&&(xe=D({},U),we=m(null),!0===We.html&&(D(xe,F),D(we,W)),!0===We.svg&&(D(xe,I),D(we,q),D(we,Y)),!0===We.svgFilters&&(D(xe,N),D(we,q),D(we,Y)),!0===We.mathMl&&(D(xe,B),D(we,H),D(we,Y))),_(e,"ADD_TAGS")||(Ee.tagCheck=null),_(e,"ADD_ATTR")||(Ee.attributeCheck=null),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?Ee.tagCheck=e.ADD_TAGS:(xe===ve&&(xe=M(xe)),D(xe,e.ADD_TAGS,lt))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?Ee.attributeCheck=e.ADD_ATTR:(we===ke&&(we=M(we)),D(we,e.ADD_ATTR,lt))),e.ADD_URI_SAFE_ATTR&&D(Ge,e.ADD_URI_SAFE_ATTR,lt),e.FORBID_CONTENTS&&(qe===He&&(qe=M(qe)),D(qe,e.FORBID_CONTENTS,lt)),e.ADD_FORBID_CONTENTS&&(qe===He&&(qe=M(qe)),D(qe,e.ADD_FORBID_CONTENTS,lt)),Pe&&(xe["#text"]=!0),Ce&&D(xe,["html","head","body"]),xe.table&&(D(xe,["tbody"]),delete Ae.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw O('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw O('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');Q=e.TRUSTED_TYPES_POLICY,ee=Q.createHTML("")}else void 0===Q&&(Q=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(L,a)),null!==Q&&"string"==typeof ee&&(ee=Q.createHTML(""));p&&p(e),ct=e}},ft=D({},[...I,...N,...j]),mt=D({},[...B,...P]),gt=function(e){v(n.removed,{element:e});try{J(e).removeChild(e)}catch(t){G(e)}},ht=function(e,t){try{v(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){v(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(Fe||Ie)try{gt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},bt=function(e){let t=null,n=null;if($e)e="<remove></remove>"+e;else{const t=A(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===ot&&Qe===Ze&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const r=Q?Q.createHTML(e):e;if(Qe===Ze)try{t=(new h).parseFromString(r,ot)}catch(e){}if(!t||!t.documentElement){t=ne.createDocument(Qe,"template",null);try{t.documentElement.innerHTML=et?ee:r}catch(e){}}const a=t.body||t.documentElement;return e&&n&&a.insertBefore(i.createTextNode(n),a.childNodes[0]||null),Qe===Ze?se.call(t,Ce?"html":"body")[0]:Ce?t.documentElement:a},yt=function(e){return ae.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},xt=function(e){return e instanceof g&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof f)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},vt=function(e){return"function"==typeof c&&e instanceof c};function wt(e,t,i){b(e,(e=>{e.call(n,t,i,ct)}))}const kt=function(e){let t=null;if(wt(ce.beforeSanitizeElements,e,null),xt(e))return gt(e),!0;const i=lt(e.nodeName);if(wt(ce.uponSanitizeElement,e,{tagName:i,allowedTags:xe}),De&&e.hasChildNodes()&&!vt(e.firstElementChild)&&z(/<[/\w!]/g,e.innerHTML)&&z(/<[/\w!]/g,e.textContent))return gt(e),!0;if(7===e.nodeType)return gt(e),!0;if(De&&8===e.nodeType&&z(/<[/\w]/g,e.data))return gt(e),!0;if(!(Ee.tagCheck instanceof Function&&Ee.tagCheck(i))&&(!xe[i]||Ae[i])){if(!Ae[i]&&At(i)){if(Te.tagNameCheck instanceof RegExp&&z(Te.tagNameCheck,i))return!1;if(Te.tagNameCheck instanceof Function&&Te.tagNameCheck(i))return!1}if(Pe&&!qe[i]){const t=J(e)||e.parentNode,n=V(e)||e.childNodes;if(n&&t)for(let i=n.length-1;i>=0;--i){const r=K(n[i],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,X(e))}}return gt(e),!0}return e instanceof u&&!function(e){let t=J(e);t&&t.tagName||(t={namespaceURI:Qe,tagName:"template"});const n=k(e.tagName),i=k(t.tagName);return!!tt[e.namespaceURI]&&(e.namespaceURI===Je?t.namespaceURI===Ze?"svg"===n:t.namespaceURI===Ve?"svg"===n&&("annotation-xml"===i||it[i]):!!ft[n]:e.namespaceURI===Ve?t.namespaceURI===Ze?"math"===n:t.namespaceURI===Je?"math"===n&&rt[i]:!!mt[n]:e.namespaceURI===Ze?!(t.namespaceURI===Je&&!rt[i])&&!(t.namespaceURI===Ve&&!it[i])&&!mt[n]&&(at[n]||!ft[n]):!("application/xhtml+xml"!==ot||!tt[e.namespaceURI]))}(e)?(gt(e),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!z(/<\/no(script|embed|frames)/i,e.innerHTML)?(Le&&3===e.nodeType&&(t=e.textContent,b([ue,de,pe],(e=>{t=S(t,e," ")})),e.textContent!==t&&(v(n.removed,{element:e.cloneNode()}),e.textContent=t)),wt(ce.afterSanitizeElements,e,null),!1):(gt(e),!0)},Tt=function(e,t,n){if(Se[t])return!1;if(je&&("id"===t||"name"===t)&&(n in i||n in ut))return!1;if(_e&&!Se[t]&&z(fe,t));else if(Re&&z(me,t));else if(Ee.attributeCheck instanceof Function&&Ee.attributeCheck(t,e));else if(!we[t]||Se[t]){if(!(At(e)&&(Te.tagNameCheck instanceof RegExp&&z(Te.tagNameCheck,e)||Te.tagNameCheck instanceof Function&&Te.tagNameCheck(e))&&(Te.attributeNameCheck instanceof RegExp&&z(Te.attributeNameCheck,t)||Te.attributeNameCheck instanceof Function&&Te.attributeNameCheck(t,e))||"is"===t&&Te.allowCustomizedBuiltInElements&&(Te.tagNameCheck instanceof RegExp&&z(Te.tagNameCheck,n)||Te.tagNameCheck instanceof Function&&Te.tagNameCheck(n))))return!1}else if(Ge[t]);else if(z(ye,S(n,he,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==E(n,"data:")||!Ye[e])if(ze&&!z(ge,S(n,he,"")));else if(n)return!1;return!0},At=function(e){return"annotation-xml"!==e&&A(e,be)},St=function(e){wt(ce.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||xt(e))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:we,forceKeepAttr:void 0};let r=t.length;for(;r--;){const a=t[r],{name:o,namespaceURI:s,value:l}=a,c=lt(o),u=l;let d="value"===o?u:R(u);if(i.attrName=c,i.attrValue=d,i.keepAttr=!0,i.forceKeepAttr=void 0,wt(ce.uponSanitizeAttribute,e,i),d=i.attrValue,!Be||"id"!==c&&"name"!==c||(ht(o,e),d="user-content-"+d),De&&z(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){ht(o,e);continue}if("attributename"===c&&A(d,"href")){ht(o,e);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){ht(o,e);continue}if(!Oe&&z(/\/>/i,d)){ht(o,e);continue}Le&&b([ue,de,pe],(e=>{d=S(d,e," ")}));const p=lt(e.nodeName);if(Tt(p,c,d)){if(Q&&"object"==typeof L&&"function"==typeof L.getAttributeType)if(s);else switch(L.getAttributeType(p,c)){case"TrustedHTML":d=Q.createHTML(d);break;case"TrustedScriptURL":d=Q.createScriptURL(d)}if(d!==u)try{s?e.setAttributeNS(s,o,d):e.setAttribute(o,d),xt(e)?gt(e):x(n.removed)}catch(t){ht(o,e)}}else ht(o,e)}wt(ce.afterSanitizeAttributes,e,null)},Et=function e(t){let n=null;const i=yt(t);for(wt(ce.beforeSanitizeShadowDOM,t,null);n=i.nextNode();)wt(ce.uponSanitizeShadowNode,n,null),kt(n),St(n),n.content instanceof o&&e(n.content);wt(ce.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,a=null,s=null,l=null;if(et=!e,et&&(e="\x3c!--\x3e"),"string"!=typeof e&&!vt(e)){if("function"!=typeof e.toString)throw O("toString is not a function");if("string"!=typeof(e=""+e))throw O("dirty is not a string, aborting")}if(!n.isSupported)return e;if(Me||pt(t),n.removed=[],"string"==typeof e&&(Ue=!1),Ue){if(e.nodeName){const t=lt(e.nodeName);if(!xe[t]||Ae[t])throw O("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof c)i=bt("\x3c!----\x3e"),a=i.ownerDocument.importNode(e,!0),1===a.nodeType&&"BODY"===a.nodeName||"HTML"===a.nodeName?i=a:i.appendChild(a);else{if(!Fe&&!Le&&!Ce&&-1===e.indexOf("<"))return Q&&Ne?Q.createHTML(e):e;if(i=bt(e),!i)return Fe?null:Ne?ee:""}i&&$e&>(i.firstChild);const u=yt(Ue?e:i);for(;s=u.nextNode();)kt(s),St(s),s.content instanceof o&&Et(s.content);if(Ue)return e;if(Fe){if(Ie)for(l=oe.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(we.shadowroot||we.shadowrootmode)&&(l=le.call(r,l,!0)),l}let d=Ce?i.outerHTML:i.innerHTML;return Ce&&xe["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&z(te,i.ownerDocument.doctype.name)&&(d="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+d),Le&&b([ue,de,pe],(e=>{d=S(d,e," ")})),Q&&Ne?Q.createHTML(d):d},n.setConfig=function(){pt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Me=!0},n.clearConfig=function(){ct=null,Me=!1},n.isValidAttribute=function(e,t,n){ct||pt({});const i=lt(e),r=lt(t);return Tt(i,r,n)},n.addHook=function(e,t){"function"==typeof t&&v(ce[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=y(ce[e],t);return-1===n?void 0:w(ce[e],n,1)[0]}return x(ce[e])},n.removeHooks=function(e){ce[e]=[]},n.removeAllHooks=function(){ce={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();const oe={ALLOWED_TAGS:["p","br","strong","em","del","code","pre","ul","ol","li","h2","h3","a","blockquote","table","thead","tbody","tr","th","td"],ALLOWED_ATTR:["href","target","rel"]},se=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.messageCopy=n(this,"messageCopy"),this.messageFeedback=n(this,"messageFeedback"),this.messageRegenerate=n(this,"messageRegenerate")}role="user";content="";format="text";agentName="";timestamp="";showActions=!0;enableRegenerate=!1;feedbackValue=null;messageCopy;messageFeedback;messageRegenerate;copySuccess=!1;copyTimeout;disconnectedCallback(){this.copyTimeout&&clearTimeout(this.copyTimeout)}renderIcon(e,t=16){const n=o[e];return n?i("span",{class:"icon-wrap",innerHTML:`<svg width="${t}" height="${t}" viewBox="${n.viewBox}" fill="none" xmlns="http://www.w3.org/2000/svg">${n.content}</svg>`}):null}parseMarkdown(e){let t=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");const n=[];return t=t.replace(/```(?:\w+)?\n?([\s\S]*?)```/g,((e,t)=>{const i=n.length;return n.push(`<pre><code>${t}</code></pre>`),`\0BLOCK${i}\0`})),t=t.replace(/((?:^[ \t]*\|.+\|\n?)+)/gm,(e=>{const t=e.trim().split("\n").filter((e=>e.trim()));if(t.length<2)return e;let i="<table>",r=!1;t.forEach(((e,t)=>{if((e=>/^[\s|:-]+$/.test(e))(e))return r=!0,void(i+="<tbody>");const n=e.split("|").filter(((e,t,n)=>t>0&&t<n.length-1));i+=r||0!==t?`<tr>${n.map((e=>`<td>${e.trim()}</td>`)).join("")}</tr>`:`<thead><tr>${n.map((e=>`<th>${e.trim()}</th>`)).join("")}</tr></thead>`})),r&&(i+="</tbody>"),i+="</table>";const a=n.length;return n.push(i),`\0BLOCK${a}\0`})),t=t.replace(/((?:^> .+\n?)+)/gm,(e=>{const t=e.replace(/^> /gm,"").trim(),i=n.length;return n.push(`<blockquote>${t}</blockquote>`),`\0BLOCK${i}\0`})),t=t.replace(/`([^`]+)`/g,"<code>$1</code>"),t=t.replace(/^## (.+)$/gm,"<h2>$1</h2>"),t=t.replace(/^### (.+)$/gm,"<h3>$1</h3>"),t=t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*([^*\n]+)\*/g,"<em>$1</em>"),t=t.replace(/~~(.+?)~~/g,"<del>$1</del>"),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),t=t.replace(/((?:^[ \t]*[-*] .+\n?)+)/gm,(e=>{const t=e.trim().split("\n").filter((e=>e.trim())).map((e=>`<li>${e.replace(/^[ \t]*[-*] /,"")}</li>`)).join(""),i=n.length;return n.push(`<ul>${t}</ul>`),`\0BLOCK${i}\0`})),t=t.replace(/((?:^[ \t]*\d+\. .+\n?)+)/gm,(e=>{const t=e.trim().split("\n").filter((e=>e.trim())).map((e=>`<li>${e.replace(/^[ \t]*\d+\. /,"")}</li>`)).join(""),i=n.length;return n.push(`<ol>${t}</ol>`),`\0BLOCK${i}\0`})),t=t.split(/\n{2,}/).map((e=>{const t=e.trim();return t?/^\x00BLOCK\d+\x00$/.test(t)?t:`<p>${t.replace(/\n/g,"<br>")}</p>`:""})).join(""),t=t.replace(/\x00BLOCK(\d+)\x00/g,((e,t)=>n[parseInt(t,10)]||"")),t}getRenderedContent(){return this.content?ae.sanitize(this.parseMarkdown(this.content),oe):""}getRelativeTime(){if(!this.timestamp)return"";try{const e=new Date(this.timestamp);if(isNaN(e.getTime()))return this.timestamp;const t=Date.now()-e.getTime(),n=Math.floor(t/6e4),i=Math.floor(n/60),r=Math.floor(i/24),a="undefined"!=typeof document&&document.documentElement.lang||"ar",o=new Intl.RelativeTimeFormat(a,{numeric:"auto"});return n<1?o.format(0,"second"):n<60?o.format(-n,"minute"):i<24?o.format(-i,"hour"):o.format(-r,"day")}catch{return this.timestamp}}async handleCopy(){try{await navigator.clipboard.writeText(this.content)}catch(e){}this.copySuccess=!0,this.messageCopy.emit(),this.copyTimeout=setTimeout((()=>this.copySuccess=!1),1500)}handleFeedback(e){this.feedbackValue=this.feedbackValue===e?null:e,this.messageFeedback.emit(e)}renderActionsBar(){return i("div",{class:"actions-bar"},this.enableRegenerate&&i("button",{class:"action-btn",onClick:()=>this.messageRegenerate.emit(),title:"إعادة تحميل"},this.renderIcon("reload",16)),i("button",{class:"action-btn copy-btn"+(this.copySuccess?" copy-success":""),onClick:()=>this.handleCopy(),title:"نسخ"},this.renderIcon("copy",16)),i("div",{class:"feedback-group"},i("button",{class:"feedback-btn thumbs-down-btn"+("down"===this.feedbackValue?" active":""),onClick:()=>this.handleFeedback("down"),title:"غير مفيد"},this.renderIcon("thumbs-down",16)),i("button",{class:"feedback-btn thumbs-up-btn"+("up"===this.feedbackValue?" active":""),onClick:()=>this.handleFeedback("up"),title:"مفيد"},this.renderIcon("thumbs-up",16))))}renderUserMessage(){return i("div",{class:"message-row user-row"},i("div",{class:"bubble user-bubble"},i("div",{class:"message-content",ref:e=>{e&&("markdown"===this.format?e.innerHTML=this.getRenderedContent():e.textContent=this.content)}})))}renderAgentMessage(){const e=this.showActions;return i("div",{class:"message-row agent-row"},i("div",{class:"agent-bubble-wrapper"},i("div",{class:"bubble agent-bubble"},this.content&&i("div",{class:"message-content",ref:e=>{e&&("markdown"===this.format?e.innerHTML=this.getRenderedContent():e.textContent=this.content)}}),i("slot",null),e&&this.renderActionsBar()),(this.agentName||this.timestamp)&&i("div",{class:"agent-info"},this.agentName&&i("span",{class:"agent-info-name"},this.agentName),this.agentName&&this.timestamp&&this.renderIcon("eclipse",10),this.timestamp&&i("span",{class:"agent-info-time"},this.getRelativeTime()))))}render(){return i(r,{key:"a3da55a7f023469f2538b363ff691674c241227e"},"user"===this.role?this.renderUserMessage():this.renderAgentMessage())}static get style(){return":host{--ai-msg-user-bg:var(--ai-user-bubble-bg);--ai-msg-user-border:1px solid var(--ai-border-default);--ai-msg-agent-bg:var(--ai-agent-bubble-bg);--ai-msg-agent-border:1px solid var(--ai-border-default);--ai-msg-border-radius:16px;--ai-msg-padding:16px;--ai-msg-font-size:14px;--ai-msg-action-active-bg:var(--ai-accent);--ai-user-msg-max-width:80%;--ai-agent-msg-max-width:80%;display:block}.message-row{display:flex}.user-row{flex-direction:column;align-items:flex-end}.user-bubble{background:var(--ai-msg-user-bg);color:var(--ai-text-primary);border:var(--ai-msg-user-border);border-radius:var(--ai-msg-border-radius);padding:var(--ai-msg-padding);font-size:var(--ai-msg-font-size);max-width:var(--ai-user-msg-max-width);line-height:1.5;word-break:break-word;box-shadow:var(--ai-shadow-sm)}.user-row .timestamp{font-size:12px;color:var(--ai-text-secondary);margin-top:4px}.agent-row{flex-direction:row;justify-content:flex-start}.agent-bubble-wrapper{display:flex;flex-direction:column;gap:6px;width:100%;max-width:var(--ai-msg-agent-max-width);min-width:0}.agent-bubble{background:var(--ai-msg-agent-bg);color:var(--ai-text-primary);border:var(--ai-msg-agent-border);border-radius:var(--ai-msg-border-radius);padding:var(--ai-msg-padding);font-size:var(--ai-msg-font-size);line-height:1.6;word-break:break-word;box-shadow:var(--ai-shadow-sm);display:flex;flex-direction:column;gap:12px}.message-content{white-space:pre-wrap}.message-content p{margin:0 0 8px 0}.message-content p:last-child{margin-bottom:0}.message-content h2{font-size:16px;font-weight:700;margin:0 0 8px 0}.message-content h3{font-size:15px;font-weight:600;margin:0 0 6px 0}.message-content strong{font-weight:700}.message-content em{font-style:italic}.message-content code{background:var(--ai-bg-surface);border-radius:4px;padding:1px 5px;font-family:var(--ai-font-family-mono);font-size:13px;color:var(--ai-text-primary)}.message-content pre{background:var(--ai-bg-surface);border-radius:8px;padding:10px 12px;overflow-x:auto;margin:8px 0}.message-content pre code{background:none;padding:0;font-size:13px}.message-content ul,.message-content ol{padding-inline-start:20px;margin:4px 0 8px 0}.message-content li{margin-bottom:3px}.actions-bar{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:6px;height:0;overflow:hidden;opacity:0;pointer-events:none;transition:height 0.15s ease, opacity 0.15s ease}.agent-bubble:hover .actions-bar{height:32px;opacity:1;pointer-events:auto}.action-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:8px;background:var(--ai-bg-card);border:1px solid var(--ai-border-default);cursor:pointer;color:var(--ai-text-primary);transition:background 0.15s, color 0.15s;padding:0;flex-shrink:0}.action-btn:hover{background:var(--ai-bg-surface)}.action-btn.copy-success{background:var(--ai-msg-action-active-bg);color:var(--ai-accent-text);border-color:var(--ai-accent)}.feedback-group{display:flex;align-items:center;border:1px solid var(--ai-border-default);border-radius:8px;overflow:hidden;background:var(--ai-bg-card)}.feedback-btn{display:flex;align-items:center;justify-content:center;height:32px;padding:0 8px;background:var(--ai-bg-card);border:none;border-inline-start:1px solid var(--ai-border-default);cursor:pointer;color:var(--ai-text-primary);transition:background 0.15s, color 0.15s}.feedback-btn:first-child{border-inline-start:none}.feedback-btn:hover{background:var(--ai-bg-surface)}.feedback-btn.active{background:var(--ai-msg-action-active-bg);color:var(--ai-accent-text)}.icon-wrap{display:flex;align-items:center;justify-content:center;line-height:0}.agent-info{display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:6px;color:var(--ai-text-muted)}.agent-info-name,.agent-info-time{font-size:12px;color:inherit;line-height:16px;white-space:nowrap}.agent-info .icon-wrap{display:flex;align-items:center;color:inherit;opacity:0.6;flex-shrink:0}.typing-indicator{display:flex;align-items:center;gap:5px;padding:4px 2px}.typing-dot{width:8px;height:8px;border-radius:50%;background:var(--ai-text-muted);animation:typingBounce 1.2s ease-in-out infinite}.typing-dot:nth-child(2){animation-delay:0.2s}.typing-dot:nth-child(3){animation-delay:0.4s}@keyframes typingBounce{0%,60%,100%{transform:translateY(0)}30%{transform:translateY(-6px)}}.streaming-cursor{display:inline-block;width:2px;height:1em;background:currentColor;vertical-align:text-bottom;margin-inline-start:2px;animation:cursorBlink 0.8s step-start infinite}@keyframes cursorBlink{0%,100%{opacity:1}50%{opacity:0}}"}},[769,"ai-chat-message",{role:[1],content:[1],format:[1],agentName:[1,"agent-name"],timestamp:[1],showActions:[4,"show-actions"],enableRegenerate:[4,"enable-regenerate"],feedbackValue:[1025,"feedback-value"],copySuccess:[32]}]),le=se,ce=function(){"undefined"!=typeof customElements&&["ai-chat-message"].forEach((e=>{"ai-chat-message"===e&&(customElements.get(a(e))||customElements.define(a(e),se))}))};export{le as AiChatMessage,ce as defineCustomElement}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface AiConversationList extends Components.AiConversationList, HTMLElement {}
|
|
4
|
+
export const AiConversationList: {
|
|
5
|
+
prototype: AiConversationList;
|
|
6
|
+
new (): AiConversationList;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|