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