@a.izzuddin/ai-chat 0.2.4 → 0.2.6
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/README.md +166 -215
- package/README.npm.md +3 -3
- package/custom-elements.json +188 -12
- package/dist/index.d.mts +55 -1
- package/dist/index.d.ts +55 -1
- package/dist/index.js +384 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +384 -65
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -1
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
15
15
|
if (kind && result) __defProp(target, key, result);
|
|
16
16
|
return result;
|
|
17
17
|
};
|
|
18
|
-
var VERSION = "0.2.
|
|
18
|
+
var VERSION = "0.2.6";
|
|
19
19
|
exports.AIChat = class AIChat extends lit.LitElement {
|
|
20
20
|
constructor() {
|
|
21
21
|
super();
|
|
@@ -27,6 +27,12 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
27
27
|
this.initialMessages = [];
|
|
28
28
|
this.botAvatarUrl = "";
|
|
29
29
|
this.backgroundImageUrl = "";
|
|
30
|
+
this.widgetWidth = "380px";
|
|
31
|
+
this.widgetHeight = "600px";
|
|
32
|
+
this.primaryColor = "#3681D3";
|
|
33
|
+
this.primaryColorHover = "#3457C7";
|
|
34
|
+
this.userMessageBg = "#D6E4FF";
|
|
35
|
+
this.botMessageBg = "#F5F5F5";
|
|
30
36
|
this.messages = [];
|
|
31
37
|
this.input = "";
|
|
32
38
|
this.isLoading = false;
|
|
@@ -35,6 +41,16 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
35
41
|
toggleWidget() {
|
|
36
42
|
this.isOpen = !this.isOpen;
|
|
37
43
|
}
|
|
44
|
+
lightenColor(hex, percent = 15) {
|
|
45
|
+
hex = hex.replace("#", "");
|
|
46
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
47
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
48
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
49
|
+
const newR = Math.min(255, Math.round(r + (255 - r) * (percent / 100)));
|
|
50
|
+
const newG = Math.min(255, Math.round(g + (255 - g) * (percent / 100)));
|
|
51
|
+
const newB = Math.min(255, Math.round(b + (255 - b) * (percent / 100)));
|
|
52
|
+
return `#${newR.toString(16).padStart(2, "0")}${newG.toString(16).padStart(2, "0")}${newB.toString(16).padStart(2, "0")}`;
|
|
53
|
+
}
|
|
38
54
|
connectedCallback() {
|
|
39
55
|
super.connectedCallback();
|
|
40
56
|
if (this.initialMessages && this.initialMessages.length > 0) {
|
|
@@ -95,6 +111,7 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
95
111
|
console.log("\u{1F50D} Raw API response:", data);
|
|
96
112
|
let responseText = "No response from agent";
|
|
97
113
|
let faqs = void 0;
|
|
114
|
+
let suggestedQuestions = void 0;
|
|
98
115
|
if (data && typeof data === "object" && data.response && typeof data.response === "string") {
|
|
99
116
|
console.log("\u{1F4DD} data.response type:", typeof data.response);
|
|
100
117
|
console.log("\u{1F4DD} data.response preview:", data.response.substring(0, 100));
|
|
@@ -106,12 +123,15 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
106
123
|
console.log("\u2705 Parsed inner data with JSON.parse");
|
|
107
124
|
if (innerData && innerData.response && typeof innerData.response === "string") {
|
|
108
125
|
responseText = innerData.response;
|
|
109
|
-
faqs = innerData.faqs_used || void 0;
|
|
126
|
+
faqs = innerData.faq_used || innerData.faqs_used || void 0;
|
|
127
|
+
suggestedQuestions = innerData.suggested_follow_ups || innerData.suggested_questions || void 0;
|
|
110
128
|
console.log("\u2705 Extracted text length:", responseText.length);
|
|
111
129
|
console.log("\u2705 Extracted FAQs count:", faqs?.length || 0);
|
|
130
|
+
console.log("\u2705 Extracted suggested questions count:", suggestedQuestions?.length || 0);
|
|
112
131
|
} else {
|
|
113
132
|
responseText = data.response;
|
|
114
|
-
faqs = data.faqs_used || void 0;
|
|
133
|
+
faqs = data.faq_used || data.faqs_used || void 0;
|
|
134
|
+
suggestedQuestions = data.suggested_follow_ups || data.suggested_questions || void 0;
|
|
115
135
|
}
|
|
116
136
|
} catch (parseError) {
|
|
117
137
|
console.warn("\u26A0\uFE0F JSON.parse failed, using regex extraction...", parseError);
|
|
@@ -124,7 +144,7 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
124
144
|
console.error("\u274C Could not extract response");
|
|
125
145
|
responseText = "Error: Could not parse response";
|
|
126
146
|
}
|
|
127
|
-
const faqsPattern = /"faqs_used"\s*:\s*(\[[^\]]*\])/s;
|
|
147
|
+
const faqsPattern = /"(?:faq_used|faqs_used)"\s*:\s*(\[[^\]]*\])/s;
|
|
128
148
|
const faqsMatch = data.response.match(faqsPattern);
|
|
129
149
|
if (faqsMatch) {
|
|
130
150
|
try {
|
|
@@ -132,7 +152,7 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
132
152
|
console.log("\u2705 Extracted FAQs, count:", faqs?.length || 0);
|
|
133
153
|
} catch {
|
|
134
154
|
console.log("\u26A0\uFE0F Could not parse FAQs, trying multiline...");
|
|
135
|
-
const faqsMultiPattern = /"faqs_used"\s*:\s*(\[[\s\S]*?\n\s*\])/;
|
|
155
|
+
const faqsMultiPattern = /"(?:faq_used|faqs_used)"\s*:\s*(\[[\s\S]*?\n\s*\])/;
|
|
136
156
|
const faqsMultiMatch = data.response.match(faqsMultiPattern);
|
|
137
157
|
if (faqsMultiMatch) {
|
|
138
158
|
try {
|
|
@@ -144,11 +164,32 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
144
164
|
}
|
|
145
165
|
}
|
|
146
166
|
}
|
|
167
|
+
const suggestedPattern = /"(?:suggested_follow_ups|suggested_questions)"\s*:\s*(\[[^\]]*\])/s;
|
|
168
|
+
const suggestedMatch = data.response.match(suggestedPattern);
|
|
169
|
+
if (suggestedMatch) {
|
|
170
|
+
try {
|
|
171
|
+
suggestedQuestions = JSON.parse(suggestedMatch[1]);
|
|
172
|
+
console.log("\u2705 Extracted suggested questions, count:", suggestedQuestions?.length || 0);
|
|
173
|
+
} catch {
|
|
174
|
+
console.log("\u26A0\uFE0F Could not parse suggested questions, trying multiline...");
|
|
175
|
+
const suggestedMultiPattern = /"(?:suggested_follow_ups|suggested_questions)"\s*:\s*(\[[\s\S]*?\n\s*\])/;
|
|
176
|
+
const suggestedMultiMatch = data.response.match(suggestedMultiPattern);
|
|
177
|
+
if (suggestedMultiMatch) {
|
|
178
|
+
try {
|
|
179
|
+
suggestedQuestions = JSON.parse(suggestedMultiMatch[1]);
|
|
180
|
+
console.log("\u2705 Extracted multi-line suggested questions, count:", suggestedQuestions?.length || 0);
|
|
181
|
+
} catch {
|
|
182
|
+
suggestedQuestions = void 0;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
147
187
|
}
|
|
148
188
|
} else {
|
|
149
189
|
console.log("\u{1F4C4} Direct text response (not JSON)");
|
|
150
190
|
responseText = data.response;
|
|
151
|
-
faqs = data.faqs_used || void 0;
|
|
191
|
+
faqs = data.faq_used || data.faqs_used || void 0;
|
|
192
|
+
suggestedQuestions = data.suggested_follow_ups || data.suggested_questions || void 0;
|
|
152
193
|
}
|
|
153
194
|
} else if (typeof data === "string") {
|
|
154
195
|
console.log("\u{1F4C4} Response is a plain string");
|
|
@@ -156,15 +197,19 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
156
197
|
} else if (data && typeof data === "object") {
|
|
157
198
|
console.warn("\u26A0\uFE0F Unexpected format, using fallback");
|
|
158
199
|
responseText = data.message || data.answer || "Error: Unexpected response format";
|
|
200
|
+
faqs = data.faq_used || data.faqs_used || void 0;
|
|
201
|
+
suggestedQuestions = data.suggested_follow_ups || data.suggested_questions || void 0;
|
|
159
202
|
}
|
|
160
203
|
console.log("\u{1F3AF} Final responseText length:", responseText.length);
|
|
161
204
|
console.log("\u{1F3AF} Final responseText preview:", responseText.substring(0, 100));
|
|
162
205
|
console.log("\u{1F3AF} Final FAQs:", faqs);
|
|
206
|
+
console.log("\u{1F3AF} Final suggested questions:", suggestedQuestions);
|
|
163
207
|
const assistantMessage = {
|
|
164
208
|
id: (Date.now() + 1).toString(),
|
|
165
209
|
role: "assistant",
|
|
166
210
|
content: responseText,
|
|
167
|
-
faqs
|
|
211
|
+
faqs,
|
|
212
|
+
suggestedQuestions
|
|
168
213
|
};
|
|
169
214
|
this.messages = [...this.messages, assistantMessage];
|
|
170
215
|
this.dispatchEvent(new CustomEvent("response-received", {
|
|
@@ -192,16 +237,22 @@ Please check your API endpoint configuration.`
|
|
|
192
237
|
}
|
|
193
238
|
}
|
|
194
239
|
renderChatUI() {
|
|
240
|
+
const primaryColorLight = this.lightenColor(this.primaryColor, 15);
|
|
195
241
|
return lit.html`
|
|
196
242
|
<!-- Header -->
|
|
197
|
-
<div class="header">
|
|
243
|
+
<div class="header" style="--primary-color: ${this.primaryColor}; --primary-color-light: ${primaryColorLight}; --primary-color-hover: ${this.primaryColorHover};">
|
|
198
244
|
<div class="header-content">
|
|
245
|
+
<div class="header-avatar">
|
|
246
|
+
${this.botAvatarUrl ? lit.html`<img src="${this.botAvatarUrl}" alt="Bot" class="header-avatar-image" />` : lit.html`<svg viewBox="0 0 24 24" fill="none" stroke="${this.primaryColor}" stroke-width="2" style="width: 1.5rem; height: 1.5rem;">
|
|
247
|
+
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
248
|
+
</svg>`}
|
|
249
|
+
</div>
|
|
199
250
|
<h1 class="title">${this.chatTitle}</h1>
|
|
200
251
|
</div>
|
|
201
252
|
</div>
|
|
202
253
|
|
|
203
254
|
<!-- Messages Area -->
|
|
204
|
-
<div class="messages-area" style="${this.backgroundImageUrl ? `--background-image-url: url('${this.backgroundImageUrl}')
|
|
255
|
+
<div class="messages-area" style="--user-message-bg: ${this.userMessageBg}; --bot-message-bg: ${this.botMessageBg}; --primary-color: ${this.primaryColor}; --primary-color-light: ${primaryColorLight}; --primary-color-hover: ${this.primaryColorHover}; ${this.backgroundImageUrl ? `--background-image-url: url('${this.backgroundImageUrl}');` : ""}">
|
|
205
256
|
<div class="messages-container">
|
|
206
257
|
${this.messages.length === 0 ? lit.html`
|
|
207
258
|
<div class="empty-state">
|
|
@@ -232,6 +283,18 @@ Please check your API endpoint configuration.`
|
|
|
232
283
|
</ul>
|
|
233
284
|
</div>
|
|
234
285
|
` : ""}
|
|
286
|
+
${msg.role === "assistant" && msg.suggestedQuestions && msg.suggestedQuestions.length > 0 ? lit.html`
|
|
287
|
+
<div class="faq-section">
|
|
288
|
+
<p class="faq-title">Suggested Questions:</p>
|
|
289
|
+
<ul class="faq-list">
|
|
290
|
+
${msg.suggestedQuestions.map((question) => lit.html`
|
|
291
|
+
<li class="faq-item" @click=${() => this.handleFAQClick(question)}>
|
|
292
|
+
${question}
|
|
293
|
+
</li>
|
|
294
|
+
`)}
|
|
295
|
+
</ul>
|
|
296
|
+
</div>
|
|
297
|
+
` : ""}
|
|
235
298
|
</div>
|
|
236
299
|
</div>
|
|
237
300
|
`)}
|
|
@@ -252,7 +315,7 @@ Please check your API endpoint configuration.`
|
|
|
252
315
|
</div>
|
|
253
316
|
|
|
254
317
|
<!-- Input Area -->
|
|
255
|
-
<div class="input-area">
|
|
318
|
+
<div class="input-area" style="--primary-color: ${this.primaryColor}; --primary-color-hover: ${this.primaryColorHover};">
|
|
256
319
|
<form class="input-form" @submit=${this.handleSubmit}>
|
|
257
320
|
<input
|
|
258
321
|
type="text"
|
|
@@ -285,17 +348,22 @@ Please check your API endpoint configuration.`
|
|
|
285
348
|
`;
|
|
286
349
|
}
|
|
287
350
|
render() {
|
|
351
|
+
const primaryColorLight = this.lightenColor(this.primaryColor, 15);
|
|
288
352
|
if (this.mode === "widget") {
|
|
289
353
|
return lit.html`
|
|
290
354
|
<div class="widget-container">
|
|
291
355
|
<!-- Chat Window -->
|
|
292
|
-
<div
|
|
356
|
+
<div
|
|
357
|
+
class=${classMap_js.classMap({ "widget-window": true, "open": this.isOpen })}
|
|
358
|
+
style="--widget-width: ${this.widgetWidth}; --widget-height: ${this.widgetHeight};"
|
|
359
|
+
>
|
|
293
360
|
${this.renderChatUI()}
|
|
294
361
|
</div>
|
|
295
362
|
|
|
296
363
|
<!-- Toggle Button -->
|
|
297
364
|
<button
|
|
298
365
|
class="widget-button"
|
|
366
|
+
style="--primary-color: ${this.primaryColor}; --primary-color-light: ${primaryColorLight};"
|
|
299
367
|
@click=${this.toggleWidget}
|
|
300
368
|
aria-label=${this.isOpen ? "Close chat" : "Open chat"}
|
|
301
369
|
>
|
|
@@ -327,7 +395,7 @@ exports.AIChat.styles = lit.css`
|
|
|
327
395
|
display: flex;
|
|
328
396
|
flex-direction: column;
|
|
329
397
|
height: 100vh;
|
|
330
|
-
background: #
|
|
398
|
+
background: #ffffff;
|
|
331
399
|
}
|
|
332
400
|
|
|
333
401
|
:host([mode="fullscreen"][theme="dark"]) {
|
|
@@ -351,19 +419,19 @@ exports.AIChat.styles = lit.css`
|
|
|
351
419
|
width: 60px;
|
|
352
420
|
height: 60px;
|
|
353
421
|
border-radius: 50%;
|
|
354
|
-
background: #
|
|
422
|
+
background: #3681D3;
|
|
355
423
|
border: none;
|
|
356
424
|
cursor: pointer;
|
|
357
425
|
display: flex;
|
|
358
426
|
align-items: center;
|
|
359
427
|
justify-content: center;
|
|
360
|
-
box-shadow: 0 4px
|
|
428
|
+
box-shadow: 0 4px 16px rgba(65, 105, 225, 0.3);
|
|
361
429
|
transition: transform 0.2s, box-shadow 0.2s;
|
|
362
430
|
}
|
|
363
431
|
|
|
364
432
|
.widget-button:hover {
|
|
365
433
|
transform: scale(1.05);
|
|
366
|
-
box-shadow: 0 6px
|
|
434
|
+
box-shadow: 0 6px 20px rgba(65, 105, 225, 0.4);
|
|
367
435
|
}
|
|
368
436
|
|
|
369
437
|
.widget-button svg {
|
|
@@ -376,11 +444,11 @@ exports.AIChat.styles = lit.css`
|
|
|
376
444
|
position: absolute;
|
|
377
445
|
bottom: 80px;
|
|
378
446
|
right: 0;
|
|
379
|
-
width: 380px;
|
|
380
|
-
height: 600px;
|
|
447
|
+
width: var(--widget-width, 380px);
|
|
448
|
+
height: var(--widget-height, 600px);
|
|
381
449
|
background: #fff;
|
|
382
|
-
border-radius:
|
|
383
|
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
|
450
|
+
border-radius: 16px;
|
|
451
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
|
|
384
452
|
display: flex;
|
|
385
453
|
flex-direction: column;
|
|
386
454
|
overflow: hidden;
|
|
@@ -401,35 +469,251 @@ exports.AIChat.styles = lit.css`
|
|
|
401
469
|
color: #fafafa;
|
|
402
470
|
}
|
|
403
471
|
|
|
404
|
-
|
|
472
|
+
/* Tablet breakpoint */
|
|
473
|
+
@media (max-width: 1024px) and (min-width: 769px) {
|
|
474
|
+
.widget-window {
|
|
475
|
+
width: var(--widget-width, 400px);
|
|
476
|
+
height: var(--widget-height, 650px);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/* Small tablet breakpoint */
|
|
481
|
+
@media (max-width: 768px) and (min-width: 481px) {
|
|
482
|
+
.widget-window {
|
|
483
|
+
width: var(--widget-width, 360px);
|
|
484
|
+
height: var(--widget-height, 550px);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/* Mobile portrait */
|
|
489
|
+
@media (max-width: 480px) and (orientation: portrait) {
|
|
405
490
|
.widget-window {
|
|
406
491
|
width: calc(100vw - 40px);
|
|
492
|
+
height: 70vh;
|
|
493
|
+
bottom: 80px;
|
|
494
|
+
right: 0;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
.widget-button {
|
|
498
|
+
width: 56px;
|
|
499
|
+
height: 56px;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.widget-button svg {
|
|
503
|
+
width: 24px;
|
|
504
|
+
height: 24px;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/* Mobile landscape */
|
|
509
|
+
@media (max-width: 900px) and (orientation: landscape) {
|
|
510
|
+
.widget-window {
|
|
511
|
+
width: var(--widget-width, 500px);
|
|
407
512
|
height: calc(100vh - 100px);
|
|
408
513
|
bottom: 80px;
|
|
409
514
|
right: 0;
|
|
410
515
|
}
|
|
516
|
+
|
|
517
|
+
.widget-button {
|
|
518
|
+
width: 56px;
|
|
519
|
+
height: 56px;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
.widget-button svg {
|
|
523
|
+
width: 24px;
|
|
524
|
+
height: 24px;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/* Mobile responsive styles for all modes */
|
|
529
|
+
@media (max-width: 768px) {
|
|
530
|
+
.header {
|
|
531
|
+
padding: 0.875rem 1rem;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
.header-avatar {
|
|
535
|
+
width: 2.25rem;
|
|
536
|
+
height: 2.25rem;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
.title {
|
|
540
|
+
font-size: 1.125rem;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
.messages-area {
|
|
544
|
+
padding: 1rem 0.75rem;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.message {
|
|
548
|
+
gap: 0.75rem;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
.avatar {
|
|
552
|
+
width: 2rem;
|
|
553
|
+
height: 2rem;
|
|
554
|
+
font-size: 0.75rem;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.message-content {
|
|
558
|
+
max-width: 100%;
|
|
559
|
+
padding: 0.625rem 0.875rem;
|
|
560
|
+
font-size: 0.9375rem;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
.empty-state {
|
|
564
|
+
margin-top: 3rem;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
.empty-state p {
|
|
568
|
+
font-size: 1.25rem;
|
|
569
|
+
padding: 0 1rem;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
.faq-section {
|
|
573
|
+
margin-top: 0.75rem;
|
|
574
|
+
padding-top: 0.75rem;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
.faq-item {
|
|
578
|
+
font-size: 0.8125rem;
|
|
579
|
+
padding: 0.375rem;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
.input-area {
|
|
583
|
+
padding: 0.75rem;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
.input-form {
|
|
587
|
+
gap: 0.5rem;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
.input-field {
|
|
591
|
+
height: 2.75rem;
|
|
592
|
+
padding: 0 0.875rem;
|
|
593
|
+
font-size: 0.9375rem;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
.send-button {
|
|
597
|
+
width: 2.75rem;
|
|
598
|
+
height: 2.75rem;
|
|
599
|
+
flex-shrink: 0;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
.send-icon {
|
|
603
|
+
width: 1.125rem;
|
|
604
|
+
height: 1.125rem;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/* Extra small screens */
|
|
609
|
+
@media (max-width: 480px) {
|
|
610
|
+
.header {
|
|
611
|
+
padding: 0.75rem 0.875rem;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
.header-avatar {
|
|
615
|
+
width: 2rem;
|
|
616
|
+
height: 2rem;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
.title {
|
|
620
|
+
font-size: 1rem;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
.messages-area {
|
|
624
|
+
padding: 0.75rem 0.5rem;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
.message {
|
|
628
|
+
gap: 0.5rem;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
.avatar {
|
|
632
|
+
width: 1.75rem;
|
|
633
|
+
height: 1.75rem;
|
|
634
|
+
font-size: 0.7rem;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
.message-content {
|
|
638
|
+
padding: 0.5rem 0.75rem;
|
|
639
|
+
font-size: 0.875rem;
|
|
640
|
+
border-radius: 0.75rem;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
.empty-state {
|
|
644
|
+
margin-top: 2rem;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
.empty-state p {
|
|
648
|
+
font-size: 1.125rem;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
.input-area {
|
|
652
|
+
padding: 0.625rem;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
.input-field {
|
|
656
|
+
height: 2.5rem;
|
|
657
|
+
padding: 0 0.75rem;
|
|
658
|
+
font-size: 0.875rem;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
.send-button {
|
|
662
|
+
width: 2.5rem;
|
|
663
|
+
height: 2.5rem;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
.version-tag {
|
|
667
|
+
font-size: 0.7rem;
|
|
668
|
+
padding: 0.375rem;
|
|
669
|
+
}
|
|
411
670
|
}
|
|
412
671
|
|
|
413
672
|
.header {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
673
|
+
background:#3681D3;
|
|
674
|
+
padding: 1rem 1.25rem;
|
|
675
|
+
display: flex;
|
|
676
|
+
align-items: center;
|
|
677
|
+
gap: 0.75rem;
|
|
678
|
+
box-shadow: 0 2px 8px rgba(65, 105, 225, 0.2);
|
|
417
679
|
}
|
|
418
680
|
|
|
419
681
|
:host([theme="dark"]) .header {
|
|
420
|
-
|
|
421
|
-
background: #18181b;
|
|
682
|
+
background: #3681D3
|
|
422
683
|
}
|
|
423
684
|
|
|
424
685
|
.header-content {
|
|
425
686
|
max-width: 56rem;
|
|
426
687
|
margin: 0 auto;
|
|
688
|
+
display: flex;
|
|
689
|
+
align-items: center;
|
|
690
|
+
gap: 0.75rem;
|
|
691
|
+
width: 100%;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.header-avatar {
|
|
695
|
+
width: 2.5rem;
|
|
696
|
+
height: 2.5rem;
|
|
697
|
+
border-radius: 50%;
|
|
698
|
+
background: #fff;
|
|
699
|
+
display: flex;
|
|
700
|
+
align-items: center;
|
|
701
|
+
justify-content: center;
|
|
702
|
+
overflow: hidden;
|
|
703
|
+
flex-shrink: 0;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
.header-avatar-image {
|
|
707
|
+
width: 100%;
|
|
708
|
+
height: 100%;
|
|
709
|
+
object-fit: cover;
|
|
427
710
|
}
|
|
428
711
|
|
|
429
712
|
.title {
|
|
430
713
|
font-size: 1.25rem;
|
|
431
714
|
font-weight: 600;
|
|
432
715
|
margin: 0;
|
|
716
|
+
color: #fff;
|
|
433
717
|
}
|
|
434
718
|
|
|
435
719
|
.messages-area {
|
|
@@ -437,6 +721,11 @@ exports.AIChat.styles = lit.css`
|
|
|
437
721
|
overflow-y: auto;
|
|
438
722
|
padding: 1.5rem 1rem;
|
|
439
723
|
position: relative;
|
|
724
|
+
background: #ffffff;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
:host([theme="dark"]) .messages-area {
|
|
728
|
+
background: #000;
|
|
440
729
|
}
|
|
441
730
|
|
|
442
731
|
.messages-area::before {
|
|
@@ -450,7 +739,7 @@ exports.AIChat.styles = lit.css`
|
|
|
450
739
|
background-size: 200px auto 60%;
|
|
451
740
|
background-position: center center;
|
|
452
741
|
background-repeat: no-repeat;
|
|
453
|
-
opacity: 0.
|
|
742
|
+
opacity: 0.03;
|
|
454
743
|
pointer-events: none;
|
|
455
744
|
z-index: 0;
|
|
456
745
|
}
|
|
@@ -467,7 +756,7 @@ exports.AIChat.styles = lit.css`
|
|
|
467
756
|
|
|
468
757
|
.empty-state {
|
|
469
758
|
text-align: center;
|
|
470
|
-
color: #
|
|
759
|
+
color: #9ca3af;
|
|
471
760
|
margin-top: 5rem;
|
|
472
761
|
}
|
|
473
762
|
|
|
@@ -494,18 +783,20 @@ exports.AIChat.styles = lit.css`
|
|
|
494
783
|
width: 2.5rem;
|
|
495
784
|
height: 2.5rem;
|
|
496
785
|
border-radius: 9999px;
|
|
497
|
-
background: #
|
|
786
|
+
background: #E5E7EB;
|
|
498
787
|
display: flex;
|
|
499
788
|
align-items: center;
|
|
500
789
|
justify-content: center;
|
|
501
790
|
flex-shrink: 0;
|
|
502
|
-
font-weight:
|
|
791
|
+
font-weight: 600;
|
|
503
792
|
font-size: 0.875rem;
|
|
504
793
|
overflow: hidden;
|
|
794
|
+
color: #6B7280;
|
|
505
795
|
}
|
|
506
796
|
|
|
507
797
|
:host([theme="dark"]) .avatar {
|
|
508
798
|
background: #3f3f46;
|
|
799
|
+
color: #9ca3af;
|
|
509
800
|
}
|
|
510
801
|
|
|
511
802
|
.avatar-image {
|
|
@@ -516,24 +807,30 @@ exports.AIChat.styles = lit.css`
|
|
|
516
807
|
|
|
517
808
|
.message-content {
|
|
518
809
|
max-width: 36rem;
|
|
519
|
-
padding: 0.
|
|
520
|
-
border-radius:
|
|
810
|
+
padding: 0.875rem 1.125rem;
|
|
811
|
+
border-radius: 1.25rem;
|
|
812
|
+
line-height: 1.6;
|
|
521
813
|
}
|
|
522
814
|
|
|
523
815
|
.message.user .message-content {
|
|
524
|
-
background: #
|
|
525
|
-
color: #
|
|
816
|
+
background: var(--user-message-bg, #D6E4FF);
|
|
817
|
+
color: #1a1a1a;
|
|
818
|
+
border-radius: 1.25rem 1.25rem 0.25rem 1.25rem;
|
|
526
819
|
}
|
|
527
820
|
|
|
528
821
|
.message.assistant .message-content {
|
|
529
|
-
background: #
|
|
530
|
-
|
|
531
|
-
|
|
822
|
+
background: var(--bot-message-bg, #F5F5F5);
|
|
823
|
+
color: #1a1a1a;
|
|
824
|
+
border-radius: 1.25rem 1.25rem 1.25rem 0.25rem;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
:host([theme="dark"]) .message.user .message-content {
|
|
828
|
+
background: #3D5A99;
|
|
829
|
+
color: #fff;
|
|
532
830
|
}
|
|
533
831
|
|
|
534
832
|
:host([theme="dark"]) .message.assistant .message-content {
|
|
535
833
|
background: #27272a;
|
|
536
|
-
border-color: #3f3f46;
|
|
537
834
|
color: #fafafa;
|
|
538
835
|
}
|
|
539
836
|
|
|
@@ -545,7 +842,7 @@ exports.AIChat.styles = lit.css`
|
|
|
545
842
|
.faq-section {
|
|
546
843
|
margin-top: 1rem;
|
|
547
844
|
padding-top: 1rem;
|
|
548
|
-
border-top: 1px solid #
|
|
845
|
+
border-top: 1px solid #d1d5db;
|
|
549
846
|
}
|
|
550
847
|
|
|
551
848
|
:host([theme="dark"]) .faq-section {
|
|
@@ -554,13 +851,13 @@ exports.AIChat.styles = lit.css`
|
|
|
554
851
|
|
|
555
852
|
.faq-title {
|
|
556
853
|
font-size: 0.875rem;
|
|
557
|
-
font-weight:
|
|
558
|
-
color: #
|
|
854
|
+
font-weight: 600;
|
|
855
|
+
color: var(--primary-color, #3681D3);
|
|
559
856
|
margin: 0 0 0.5rem 0;
|
|
560
857
|
}
|
|
561
858
|
|
|
562
859
|
:host([theme="dark"]) .faq-title {
|
|
563
|
-
color: #
|
|
860
|
+
color: var(--primary-color-light, #5B7FE8);
|
|
564
861
|
}
|
|
565
862
|
|
|
566
863
|
.faq-list {
|
|
@@ -574,25 +871,28 @@ exports.AIChat.styles = lit.css`
|
|
|
574
871
|
|
|
575
872
|
.faq-item {
|
|
576
873
|
font-size: 0.875rem;
|
|
577
|
-
color: #
|
|
578
|
-
padding: 0.5rem;
|
|
579
|
-
border-radius: 0.
|
|
874
|
+
color: var(--primary-color, #3681D3);
|
|
875
|
+
padding: 0.5rem 0.75rem;
|
|
876
|
+
border-radius: 0.5rem;
|
|
580
877
|
cursor: pointer;
|
|
581
878
|
transition: background-color 0.2s, color 0.2s;
|
|
879
|
+
border: 1px solid transparent;
|
|
582
880
|
}
|
|
583
881
|
|
|
584
882
|
.faq-item:hover {
|
|
585
|
-
background-color: #
|
|
586
|
-
color: #
|
|
883
|
+
background-color: #EEF2FF;
|
|
884
|
+
color: var(--primary-color-hover, #3457C7);
|
|
885
|
+
border-color: #C7D2FE;
|
|
587
886
|
}
|
|
588
887
|
|
|
589
888
|
:host([theme="dark"]) .faq-item {
|
|
590
|
-
color: #
|
|
889
|
+
color: var(--primary-color-light, #5B7FE8);
|
|
591
890
|
}
|
|
592
891
|
|
|
593
892
|
:host([theme="dark"]) .faq-item:hover {
|
|
594
|
-
background-color: #
|
|
595
|
-
color: #
|
|
893
|
+
background-color: #1e293b;
|
|
894
|
+
color: #93C5FD;
|
|
895
|
+
border-color: #3f3f46;
|
|
596
896
|
}
|
|
597
897
|
|
|
598
898
|
.loading {
|
|
@@ -615,14 +915,14 @@ exports.AIChat.styles = lit.css`
|
|
|
615
915
|
}
|
|
616
916
|
|
|
617
917
|
.input-area {
|
|
618
|
-
border-top: 1px solid #
|
|
918
|
+
border-top: 1px solid #e5e7eb;
|
|
619
919
|
background: #fff;
|
|
620
|
-
padding: 1rem;
|
|
920
|
+
padding: 1rem 1.25rem;
|
|
621
921
|
}
|
|
622
922
|
|
|
623
923
|
:host([theme="dark"]) .input-area {
|
|
624
924
|
border-top-color: #27272a;
|
|
625
|
-
background: #
|
|
925
|
+
background: #18181b;
|
|
626
926
|
}
|
|
627
927
|
|
|
628
928
|
.input-form {
|
|
@@ -630,18 +930,24 @@ exports.AIChat.styles = lit.css`
|
|
|
630
930
|
margin: 0 auto;
|
|
631
931
|
display: flex;
|
|
632
932
|
gap: 0.75rem;
|
|
933
|
+
align-items: center;
|
|
633
934
|
}
|
|
634
935
|
|
|
635
936
|
.input-field {
|
|
636
937
|
flex: 1;
|
|
637
938
|
height: 3rem;
|
|
638
939
|
padding: 0 1rem;
|
|
639
|
-
border: 1px solid #
|
|
640
|
-
border-radius:
|
|
641
|
-
font-size:
|
|
940
|
+
border: 1px solid #d1d5db;
|
|
941
|
+
border-radius: 1.5rem;
|
|
942
|
+
font-size: 0.9375rem;
|
|
642
943
|
font-family: inherit;
|
|
643
944
|
background: #fff;
|
|
644
|
-
color: #
|
|
945
|
+
color: #374151;
|
|
946
|
+
transition: border-color 0.2s, box-shadow 0.2s;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
.input-field::placeholder {
|
|
950
|
+
color: #9ca3af;
|
|
645
951
|
}
|
|
646
952
|
|
|
647
953
|
:host([theme="dark"]) .input-field {
|
|
@@ -651,8 +957,9 @@ exports.AIChat.styles = lit.css`
|
|
|
651
957
|
}
|
|
652
958
|
|
|
653
959
|
.input-field:focus {
|
|
654
|
-
outline:
|
|
655
|
-
|
|
960
|
+
outline: none;
|
|
961
|
+
border-color: var(--primary-color, #3681D3);
|
|
962
|
+
box-shadow: 0 0 0 3px rgba(65, 105, 225, 0.1);
|
|
656
963
|
}
|
|
657
964
|
|
|
658
965
|
.input-field:disabled {
|
|
@@ -665,17 +972,23 @@ exports.AIChat.styles = lit.css`
|
|
|
665
972
|
height: 3rem;
|
|
666
973
|
border-radius: 9999px;
|
|
667
974
|
border: none;
|
|
668
|
-
background: #
|
|
975
|
+
background: var(--primary-color, #3681D3);
|
|
669
976
|
color: #fff;
|
|
670
977
|
cursor: pointer;
|
|
671
978
|
display: flex;
|
|
672
979
|
align-items: center;
|
|
673
980
|
justify-content: center;
|
|
674
|
-
transition: background 0.2s;
|
|
981
|
+
transition: background 0.2s, transform 0.1s;
|
|
982
|
+
flex-shrink: 0;
|
|
675
983
|
}
|
|
676
984
|
|
|
677
985
|
.send-button:hover:not(:disabled) {
|
|
678
|
-
background: #
|
|
986
|
+
background: var(--primary-color-hover, #3457C7);
|
|
987
|
+
transform: scale(1.05);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
.send-button:active:not(:disabled) {
|
|
991
|
+
transform: scale(0.95);
|
|
679
992
|
}
|
|
680
993
|
|
|
681
994
|
.send-button:disabled {
|
|
@@ -692,12 +1005,12 @@ exports.AIChat.styles = lit.css`
|
|
|
692
1005
|
text-align: center;
|
|
693
1006
|
padding: 0.5rem;
|
|
694
1007
|
font-size: 0.75rem;
|
|
695
|
-
color: #
|
|
696
|
-
border-top: 1px solid #
|
|
1008
|
+
color: #9ca3af;
|
|
1009
|
+
border-top: 1px solid #e5e7eb;
|
|
697
1010
|
}
|
|
698
1011
|
|
|
699
1012
|
:host([theme="dark"]) .version-tag {
|
|
700
|
-
color: #
|
|
1013
|
+
color: #6b7280;
|
|
701
1014
|
border-top-color: #27272a;
|
|
702
1015
|
}
|
|
703
1016
|
`;
|
|
@@ -709,7 +1022,13 @@ exports.AIChat.properties = {
|
|
|
709
1022
|
mode: { type: String, reflect: true },
|
|
710
1023
|
initialMessages: { type: Array },
|
|
711
1024
|
botAvatarUrl: { type: String, attribute: "bot-avatar-url" },
|
|
712
|
-
backgroundImageUrl: { type: String, attribute: "background-image-url" }
|
|
1025
|
+
backgroundImageUrl: { type: String, attribute: "background-image-url" },
|
|
1026
|
+
widgetWidth: { type: String, attribute: "widget-width" },
|
|
1027
|
+
widgetHeight: { type: String, attribute: "widget-height" },
|
|
1028
|
+
primaryColor: { type: String, attribute: "primary-color" },
|
|
1029
|
+
primaryColorHover: { type: String, attribute: "primary-color-hover" },
|
|
1030
|
+
userMessageBg: { type: String, attribute: "user-message-bg" },
|
|
1031
|
+
botMessageBg: { type: String, attribute: "bot-message-bg" }
|
|
713
1032
|
};
|
|
714
1033
|
__decorateClass([
|
|
715
1034
|
decorators_js.state()
|