@dssp/project 1.0.0-alpha.41 → 1.0.0-alpha.47
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-client/pages/lib/chatbot-widget.d.ts +18 -8
- package/dist-client/pages/lib/chatbot-widget.js +249 -87
- package/dist-client/pages/lib/chatbot-widget.js.map +1 -1
- package/dist-client/pages/lib/select2-component.d.ts +1 -1
- package/dist-client/pages/lib/select2-component.js +35 -35
- package/dist-client/pages/lib/select2-component.js.map +1 -1
- package/dist-client/pages/project/project-detail.js.map +1 -1
- package/dist-client/pages/project/project-list.d.ts +34 -0
- package/dist-client/pages/project/project-list.js +35 -0
- package/dist-client/pages/project/project-list.js.map +1 -1
- package/dist-client/pages/project/project-update.js +168 -29
- package/dist-client/pages/project/project-update.js.map +1 -1
- package/dist-client/route.d.ts +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/index.d.ts +2 -2
- package/dist-server/service/project/project-mutation.d.ts +2 -1
- package/dist-server/service/project/project-mutation.js +35 -1
- package/dist-server/service/project/project-mutation.js.map +1 -1
- package/dist-server/service/project/project-query.d.ts +1 -0
- package/dist-server/service/project/project-query.js +16 -0
- package/dist-server/service/project/project-query.js.map +1 -1
- package/dist-server/service/project/project-type.d.ts +6 -0
- package/dist-server/service/project/project-type.js +23 -1
- package/dist-server/service/project/project-type.js.map +1 -1
- package/dist-server/service/project/project.d.ts +2 -0
- package/dist-server/service/project/project.js +10 -0
- package/dist-server/service/project/project.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { LitElement } from 'lit
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
interface SourceItem {
|
|
3
|
+
title: string;
|
|
4
|
+
url: string;
|
|
5
|
+
}
|
|
2
6
|
interface ChatMessage {
|
|
3
7
|
id: string;
|
|
4
8
|
text: string;
|
|
5
9
|
isUser: boolean;
|
|
6
10
|
timestamp: Date;
|
|
11
|
+
sources?: SourceItem[];
|
|
7
12
|
}
|
|
8
13
|
export declare class ChatbotWidget extends LitElement {
|
|
14
|
+
static styles: import("lit").CSSResult;
|
|
9
15
|
static get properties(): {
|
|
10
16
|
isOpen: {
|
|
11
17
|
type: BooleanConstructor;
|
|
@@ -19,25 +25,29 @@ export declare class ChatbotWidget extends LitElement {
|
|
|
19
25
|
isLoading: {
|
|
20
26
|
type: BooleanConstructor;
|
|
21
27
|
};
|
|
28
|
+
isSourcesOpen: {
|
|
29
|
+
type: BooleanConstructor;
|
|
30
|
+
};
|
|
31
|
+
currentSources: {
|
|
32
|
+
type: ArrayConstructor;
|
|
33
|
+
};
|
|
22
34
|
};
|
|
23
35
|
isOpen: boolean;
|
|
24
36
|
messages: ChatMessage[];
|
|
25
37
|
inputValue: string;
|
|
26
38
|
isLoading: boolean;
|
|
39
|
+
isSourcesOpen: boolean;
|
|
40
|
+
currentSources: SourceItem[];
|
|
41
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
27
42
|
private boundHandleEscapeKey;
|
|
28
43
|
connectedCallback(): void;
|
|
29
44
|
disconnectedCallback(): void;
|
|
30
45
|
handleEscapeKey(event: KeyboardEvent): void;
|
|
31
|
-
static styles: import("lit-element").CSSResult;
|
|
32
46
|
toggleChat(): void;
|
|
33
47
|
scrollToBottom(): void;
|
|
34
48
|
sendMessage(): Promise<void>;
|
|
49
|
+
openSourcesOverlay(sources: SourceItem[]): void;
|
|
50
|
+
closeSourcesOverlay(): void;
|
|
35
51
|
handleKeyPress(event: KeyboardEvent): void;
|
|
36
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
37
|
-
}
|
|
38
|
-
declare global {
|
|
39
|
-
interface HTMLElementTagNameMap {
|
|
40
|
-
'chatbot-widget': ChatbotWidget;
|
|
41
|
-
}
|
|
42
52
|
}
|
|
43
53
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LitElement, html, css } from 'lit
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
2
|
// API 상수
|
|
3
|
-
const CHATBOT_API_URL = 'https://
|
|
3
|
+
const CHATBOT_API_URL = 'https://korea-uni-chat-ui.ettisoft.com/chat';
|
|
4
4
|
export class ChatbotWidget extends LitElement {
|
|
5
5
|
constructor() {
|
|
6
6
|
super(...arguments);
|
|
@@ -8,6 +8,8 @@ export class ChatbotWidget extends LitElement {
|
|
|
8
8
|
this.messages = [];
|
|
9
9
|
this.inputValue = '';
|
|
10
10
|
this.isLoading = false;
|
|
11
|
+
this.isSourcesOpen = false;
|
|
12
|
+
this.currentSources = [];
|
|
11
13
|
this.boundHandleEscapeKey = this.handleEscapeKey.bind(this);
|
|
12
14
|
}
|
|
13
15
|
static get properties() {
|
|
@@ -15,9 +17,116 @@ export class ChatbotWidget extends LitElement {
|
|
|
15
17
|
isOpen: { type: Boolean },
|
|
16
18
|
messages: { type: Array },
|
|
17
19
|
inputValue: { type: String },
|
|
18
|
-
isLoading: { type: Boolean }
|
|
20
|
+
isLoading: { type: Boolean },
|
|
21
|
+
isSourcesOpen: { type: Boolean },
|
|
22
|
+
currentSources: { type: Array }
|
|
19
23
|
};
|
|
20
24
|
}
|
|
25
|
+
render() {
|
|
26
|
+
return html `
|
|
27
|
+
<div class="chatbot-container">
|
|
28
|
+
<!-- 챗봇 아이콘 -->
|
|
29
|
+
<button class="chatbot-icon" @click="${this.toggleChat}">
|
|
30
|
+
<svg viewBox="0 0 24 24">
|
|
31
|
+
<path
|
|
32
|
+
d="M20 2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h4l4 4 4-4h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z"
|
|
33
|
+
/>
|
|
34
|
+
</svg>
|
|
35
|
+
</button>
|
|
36
|
+
|
|
37
|
+
<!-- 대화창 -->
|
|
38
|
+
<div class="chat-window ${this.isOpen ? 'open' : ''}">
|
|
39
|
+
<!-- 헤더 -->
|
|
40
|
+
<div class="chat-header">
|
|
41
|
+
<h3>챗봇 도우미</h3>
|
|
42
|
+
<button class="close-btn" @click="${this.toggleChat}">×</button>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<!-- 메시지 영역 -->
|
|
46
|
+
<div class="messages-container">
|
|
47
|
+
${this.messages.length === 0
|
|
48
|
+
? html `
|
|
49
|
+
<div class="message bot">
|
|
50
|
+
<div class="message-avatar">🤖</div>
|
|
51
|
+
<div class="message-bubble">안녕하세요! 무엇을 도와드릴까요?</div>
|
|
52
|
+
</div>
|
|
53
|
+
`
|
|
54
|
+
: ''}
|
|
55
|
+
${this.messages.map(message => html `
|
|
56
|
+
<div class="message ${message.isUser ? 'user' : 'bot'}">
|
|
57
|
+
<div class="message-avatar">${message.isUser ? '👤' : '🤖'}</div>
|
|
58
|
+
<div class="message-bubble">
|
|
59
|
+
${message.text}
|
|
60
|
+
${!message.isUser && message.sources && message.sources.length
|
|
61
|
+
? html `
|
|
62
|
+
<div>
|
|
63
|
+
<button class="evidence-btn" @click="${() => this.openSourcesOverlay(message.sources || [])}">
|
|
64
|
+
근거 ${message.sources.length}개 보기
|
|
65
|
+
</button>
|
|
66
|
+
</div>
|
|
67
|
+
`
|
|
68
|
+
: ''}
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
`)}
|
|
72
|
+
${this.isLoading
|
|
73
|
+
? html `
|
|
74
|
+
<div class="message bot">
|
|
75
|
+
<div class="message-avatar">🤖</div>
|
|
76
|
+
<div class="message-bubble">
|
|
77
|
+
<div class="loading-indicator">
|
|
78
|
+
<span>답변 중</span>
|
|
79
|
+
<div class="loading-dots">
|
|
80
|
+
<div class="loading-dot"></div>
|
|
81
|
+
<div class="loading-dot"></div>
|
|
82
|
+
<div class="loading-dot"></div>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
`
|
|
88
|
+
: ''}
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<!-- 입력 영역 -->
|
|
92
|
+
<div class="input-container">
|
|
93
|
+
<input
|
|
94
|
+
class="message-input"
|
|
95
|
+
type="text"
|
|
96
|
+
placeholder="메시지를 입력하세요..."
|
|
97
|
+
.value="${this.inputValue}"
|
|
98
|
+
@input="${(e) => (this.inputValue = e.target.value)}"
|
|
99
|
+
@keypress="${this.handleKeyPress}"
|
|
100
|
+
?disabled="${this.isLoading}"
|
|
101
|
+
/>
|
|
102
|
+
<button class="send-btn" @click="${this.sendMessage}" ?disabled="${this.isLoading || !this.inputValue.trim()}">
|
|
103
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
|
|
104
|
+
<path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" />
|
|
105
|
+
</svg>
|
|
106
|
+
</button>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
<!-- 근거 오버레이 -->
|
|
110
|
+
<div class="overlay ${this.isSourcesOpen ? 'open' : ''}" @click="${this.closeSourcesOverlay}">
|
|
111
|
+
<div class="overlay-panel" @click="${(e) => e.stopPropagation()}">
|
|
112
|
+
<div class="overlay-header">
|
|
113
|
+
<div class="overlay-title">근거 ${this.currentSources.length}개</div>
|
|
114
|
+
<button class="overlay-close" @click="${this.closeSourcesOverlay}">×</button>
|
|
115
|
+
</div>
|
|
116
|
+
<div class="overlay-body">
|
|
117
|
+
<ul class="source-list">
|
|
118
|
+
${this.currentSources.map((s, idx) => html ` <li class="source-item">
|
|
119
|
+
<a class="source-link" href="${s.url}" target="_blank" rel="noopener noreferrer"
|
|
120
|
+
>[#${idx + 1}] ${s.title}</a
|
|
121
|
+
>
|
|
122
|
+
</li>`)}
|
|
123
|
+
</ul>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
`;
|
|
129
|
+
}
|
|
21
130
|
connectedCallback() {
|
|
22
131
|
super.connectedCallback();
|
|
23
132
|
}
|
|
@@ -27,8 +136,13 @@ export class ChatbotWidget extends LitElement {
|
|
|
27
136
|
document.removeEventListener('keydown', this.boundHandleEscapeKey);
|
|
28
137
|
}
|
|
29
138
|
handleEscapeKey(event) {
|
|
30
|
-
if (event.key === 'Escape'
|
|
31
|
-
this.
|
|
139
|
+
if (event.key === 'Escape') {
|
|
140
|
+
if (this.isSourcesOpen) {
|
|
141
|
+
this.isSourcesOpen = false;
|
|
142
|
+
}
|
|
143
|
+
else if (this.isOpen) {
|
|
144
|
+
this.isOpen = false;
|
|
145
|
+
}
|
|
32
146
|
}
|
|
33
147
|
}
|
|
34
148
|
toggleChat() {
|
|
@@ -43,6 +157,8 @@ export class ChatbotWidget extends LitElement {
|
|
|
43
157
|
else {
|
|
44
158
|
// 챗봇이 닫힐 때 ESC 키 이벤트 리스너 제거
|
|
45
159
|
document.removeEventListener('keydown', this.boundHandleEscapeKey);
|
|
160
|
+
this.isSourcesOpen = false;
|
|
161
|
+
this.currentSources = [];
|
|
46
162
|
}
|
|
47
163
|
}
|
|
48
164
|
scrollToBottom() {
|
|
@@ -53,7 +169,7 @@ export class ChatbotWidget extends LitElement {
|
|
|
53
169
|
}
|
|
54
170
|
}
|
|
55
171
|
async sendMessage() {
|
|
56
|
-
var _a;
|
|
172
|
+
var _a, _b;
|
|
57
173
|
if (!this.inputValue.trim() || this.isLoading)
|
|
58
174
|
return;
|
|
59
175
|
const userMessage = {
|
|
@@ -77,21 +193,24 @@ export class ChatbotWidget extends LitElement {
|
|
|
77
193
|
headers: {
|
|
78
194
|
'Content-Type': 'application/json'
|
|
79
195
|
},
|
|
80
|
-
body: JSON.stringify({
|
|
196
|
+
body: JSON.stringify({ query: messageText, top_k: 6 })
|
|
81
197
|
});
|
|
198
|
+
if (!response.ok) {
|
|
199
|
+
throw new Error(`HTTP ${response.status}`);
|
|
200
|
+
}
|
|
82
201
|
const data = await response.json();
|
|
83
202
|
const botMessage = {
|
|
84
203
|
id: (Date.now() + 1).toString(),
|
|
85
|
-
text: data.
|
|
204
|
+
text: ((_b = data === null || data === void 0 ? void 0 : data.answer) === null || _b === void 0 ? void 0 : _b.trim()) || '죄송합니다. 응답을 처리할 수 없습니다.',
|
|
86
205
|
isUser: false,
|
|
87
|
-
timestamp: new Date()
|
|
206
|
+
timestamp: new Date(),
|
|
207
|
+
sources: (data === null || data === void 0 ? void 0 : data.sources) || []
|
|
88
208
|
};
|
|
89
209
|
this.messages = [...this.messages, botMessage];
|
|
90
210
|
// 봇 메시지 추가 후 스크롤을 맨 아래로
|
|
91
211
|
setTimeout(() => this.scrollToBottom(), 50);
|
|
92
212
|
}
|
|
93
213
|
catch (error) {
|
|
94
|
-
console.error('챗봇 API 오류:', error);
|
|
95
214
|
const errorMessage = {
|
|
96
215
|
id: (Date.now() + 1).toString(),
|
|
97
216
|
text: '죄송합니다. 일시적인 오류가 발생했습니다. 잠시 후 다시 시도해주세요.',
|
|
@@ -112,88 +231,22 @@ export class ChatbotWidget extends LitElement {
|
|
|
112
231
|
}, 100);
|
|
113
232
|
}
|
|
114
233
|
}
|
|
234
|
+
openSourcesOverlay(sources) {
|
|
235
|
+
if (!sources || sources.length === 0)
|
|
236
|
+
return;
|
|
237
|
+
this.currentSources = sources;
|
|
238
|
+
this.isSourcesOpen = true;
|
|
239
|
+
}
|
|
240
|
+
closeSourcesOverlay() {
|
|
241
|
+
this.isSourcesOpen = false;
|
|
242
|
+
this.currentSources = [];
|
|
243
|
+
}
|
|
115
244
|
handleKeyPress(event) {
|
|
116
245
|
if (event.key === 'Enter' && !event.shiftKey) {
|
|
117
246
|
event.preventDefault();
|
|
118
247
|
this.sendMessage();
|
|
119
248
|
}
|
|
120
249
|
}
|
|
121
|
-
render() {
|
|
122
|
-
return html `
|
|
123
|
-
<div class="chatbot-container">
|
|
124
|
-
<!-- 챗봇 아이콘 -->
|
|
125
|
-
<button class="chatbot-icon" @click="${this.toggleChat}">
|
|
126
|
-
<svg viewBox="0 0 24 24">
|
|
127
|
-
<path
|
|
128
|
-
d="M20 2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h4l4 4 4-4h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z"
|
|
129
|
-
/>
|
|
130
|
-
</svg>
|
|
131
|
-
</button>
|
|
132
|
-
|
|
133
|
-
<!-- 대화창 -->
|
|
134
|
-
<div class="chat-window ${this.isOpen ? 'open' : ''}">
|
|
135
|
-
<!-- 헤더 -->
|
|
136
|
-
<div class="chat-header">
|
|
137
|
-
<h3>챗봇 도우미</h3>
|
|
138
|
-
<button class="close-btn" @click="${this.toggleChat}">×</button>
|
|
139
|
-
</div>
|
|
140
|
-
|
|
141
|
-
<!-- 메시지 영역 -->
|
|
142
|
-
<div class="messages-container">
|
|
143
|
-
${this.messages.length === 0
|
|
144
|
-
? html `
|
|
145
|
-
<div class="message bot">
|
|
146
|
-
<div class="message-avatar">🤖</div>
|
|
147
|
-
<div class="message-bubble">안녕하세요! 무엇을 도와드릴까요?</div>
|
|
148
|
-
</div>
|
|
149
|
-
`
|
|
150
|
-
: ''}
|
|
151
|
-
${this.messages.map(message => html `
|
|
152
|
-
<div class="message ${message.isUser ? 'user' : 'bot'}">
|
|
153
|
-
<div class="message-avatar">${message.isUser ? '👤' : '🤖'}</div>
|
|
154
|
-
<div class="message-bubble">${message.text}</div>
|
|
155
|
-
</div>
|
|
156
|
-
`)}
|
|
157
|
-
${this.isLoading
|
|
158
|
-
? html `
|
|
159
|
-
<div class="message bot">
|
|
160
|
-
<div class="message-avatar">🤖</div>
|
|
161
|
-
<div class="message-bubble">
|
|
162
|
-
<div class="loading-indicator">
|
|
163
|
-
<span>답변 중</span>
|
|
164
|
-
<div class="loading-dots">
|
|
165
|
-
<div class="loading-dot"></div>
|
|
166
|
-
<div class="loading-dot"></div>
|
|
167
|
-
<div class="loading-dot"></div>
|
|
168
|
-
</div>
|
|
169
|
-
</div>
|
|
170
|
-
</div>
|
|
171
|
-
</div>
|
|
172
|
-
`
|
|
173
|
-
: ''}
|
|
174
|
-
</div>
|
|
175
|
-
|
|
176
|
-
<!-- 입력 영역 -->
|
|
177
|
-
<div class="input-container">
|
|
178
|
-
<input
|
|
179
|
-
class="message-input"
|
|
180
|
-
type="text"
|
|
181
|
-
placeholder="메시지를 입력하세요..."
|
|
182
|
-
.value="${this.inputValue}"
|
|
183
|
-
@input="${(e) => (this.inputValue = e.target.value)}"
|
|
184
|
-
@keypress="${this.handleKeyPress}"
|
|
185
|
-
?disabled="${this.isLoading}"
|
|
186
|
-
/>
|
|
187
|
-
<button class="send-btn" @click="${this.sendMessage}" ?disabled="${this.isLoading || !this.inputValue.trim()}">
|
|
188
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
|
|
189
|
-
<path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" />
|
|
190
|
-
</svg>
|
|
191
|
-
</button>
|
|
192
|
-
</div>
|
|
193
|
-
</div>
|
|
194
|
-
</div>
|
|
195
|
-
`;
|
|
196
|
-
}
|
|
197
250
|
}
|
|
198
251
|
ChatbotWidget.styles = css `
|
|
199
252
|
:host {
|
|
@@ -463,7 +516,116 @@ ChatbotWidget.styles = css `
|
|
|
463
516
|
.messages-container::-webkit-scrollbar-thumb:hover {
|
|
464
517
|
background: #a8a8a8;
|
|
465
518
|
}
|
|
519
|
+
|
|
520
|
+
/* 근거 버튼 */
|
|
521
|
+
.evidence-btn {
|
|
522
|
+
margin-top: 8px;
|
|
523
|
+
display: inline-flex;
|
|
524
|
+
align-items: center;
|
|
525
|
+
gap: 6px;
|
|
526
|
+
border: 1px solid #d6daf0;
|
|
527
|
+
background: #ffffff;
|
|
528
|
+
color: #3b4cca;
|
|
529
|
+
border-radius: 14px;
|
|
530
|
+
padding: 6px 10px;
|
|
531
|
+
font-size: 12px;
|
|
532
|
+
cursor: pointer;
|
|
533
|
+
transition:
|
|
534
|
+
background-color 0.2s ease,
|
|
535
|
+
border-color 0.2s ease;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
.evidence-btn:hover {
|
|
539
|
+
background-color: #f4f6ff;
|
|
540
|
+
border-color: #c2c8ef;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/* 오버레이 */
|
|
544
|
+
.overlay {
|
|
545
|
+
position: fixed;
|
|
546
|
+
inset: 0;
|
|
547
|
+
background: rgba(0, 0, 0, 0.35);
|
|
548
|
+
display: flex;
|
|
549
|
+
align-items: center;
|
|
550
|
+
justify-content: center;
|
|
551
|
+
opacity: 0;
|
|
552
|
+
pointer-events: none;
|
|
553
|
+
transition: opacity 0.2s ease;
|
|
554
|
+
z-index: 1100; /* 챗봇보다 위 */
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.overlay.open {
|
|
558
|
+
opacity: 1;
|
|
559
|
+
pointer-events: auto;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
.overlay-panel {
|
|
563
|
+
width: min(520px, calc(100vw - 40px));
|
|
564
|
+
max-height: min(70vh, 560px);
|
|
565
|
+
background: #ffffff;
|
|
566
|
+
border-radius: 14px;
|
|
567
|
+
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
|
|
568
|
+
display: flex;
|
|
569
|
+
flex-direction: column;
|
|
570
|
+
overflow: hidden;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
.overlay-header {
|
|
574
|
+
padding: 14px 16px;
|
|
575
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
576
|
+
color: #ffffff;
|
|
577
|
+
display: flex;
|
|
578
|
+
align-items: center;
|
|
579
|
+
justify-content: space-between;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
.overlay-title {
|
|
583
|
+
font-weight: 600;
|
|
584
|
+
font-size: 16px;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
.overlay-close {
|
|
588
|
+
background: none;
|
|
589
|
+
border: none;
|
|
590
|
+
color: #ffffff;
|
|
591
|
+
font-size: 26px;
|
|
592
|
+
width: 32px;
|
|
593
|
+
height: 32px;
|
|
594
|
+
border-radius: 50%;
|
|
595
|
+
cursor: pointer;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.overlay-body {
|
|
599
|
+
padding: 12px 16px 16px 16px;
|
|
600
|
+
overflow-y: auto;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.source-list {
|
|
604
|
+
display: flex;
|
|
605
|
+
flex-direction: column;
|
|
606
|
+
gap: 10px;
|
|
607
|
+
margin: 0;
|
|
608
|
+
padding: 0;
|
|
609
|
+
list-style: none;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
.source-item {
|
|
613
|
+
border: 1px solid #e6e9f2;
|
|
614
|
+
border-radius: 10px;
|
|
615
|
+
padding: 10px 12px;
|
|
616
|
+
background: #f9fafc;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
.source-link {
|
|
620
|
+
color: #1e3a8a;
|
|
621
|
+
text-decoration: none;
|
|
622
|
+
display: block;
|
|
623
|
+
word-break: break-all;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
.source-link:hover {
|
|
627
|
+
text-decoration: underline;
|
|
628
|
+
}
|
|
466
629
|
`;
|
|
467
|
-
// 커스텀 엘리먼트 등록
|
|
468
630
|
customElements.define('chatbot-widget', ChatbotWidget);
|
|
469
631
|
//# sourceMappingURL=chatbot-widget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatbot-widget.js","sourceRoot":"","sources":["../../../client/pages/lib/chatbot-widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEnD,SAAS;AACT,MAAM,eAAe,GAAG,iCAAiC,CAAA;AASzD,MAAM,OAAO,aAAc,SAAQ,UAAU;IAA7C;;QAUE,WAAM,GAAG,KAAK,CAAA;QAC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UAAU,CAAC,IAAI,EAAE;;;;;;;;KAQnH,CAAA;IACH,CAAC;;AAxbM,oBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4QlB,AA5QY,CA4QZ;AA+KH,cAAc;AACd,cAAc,CAAC,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA","sourcesContent":["import { LitElement, html, css } from 'lit-element'\n\n// API 상수\nconst CHATBOT_API_URL = 'https://api.example.com/chatbot'\n\ninterface ChatMessage {\n id: string\n text: string\n isUser: boolean\n timestamp: Date\n}\n\nexport class ChatbotWidget extends LitElement {\n static get properties() {\n return {\n isOpen: { type: Boolean },\n messages: { type: Array },\n inputValue: { type: String },\n isLoading: { type: Boolean }\n }\n }\n\n isOpen = false\n messages: ChatMessage[] = []\n inputValue = ''\n isLoading = false\n\n private boundHandleEscapeKey = this.handleEscapeKey.bind(this)\n\n connectedCallback() {\n super.connectedCallback()\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n // 컴포넌트가 제거될 때 이벤트 리스너 정리\n document.removeEventListener('keydown', this.boundHandleEscapeKey)\n }\n\n handleEscapeKey(event: KeyboardEvent) {\n if (event.key === 'Escape' && this.isOpen) {\n this.isOpen = false\n }\n }\n\n static styles = css`\n :host {\n position: fixed;\n bottom: 40px;\n right: 20px;\n z-index: 1000;\n }\n\n .chatbot-container {\n position: relative;\n }\n\n .chatbot-icon {\n width: 60px;\n height: 60px;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);\n transition: all 0.3s ease;\n border: none;\n outline: none;\n }\n\n .chatbot-icon:hover {\n transform: scale(1.1);\n box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);\n }\n\n .chatbot-icon svg {\n width: 28px;\n height: 28px;\n fill: white;\n }\n\n .chat-window {\n position: absolute;\n bottom: 80px;\n right: 0;\n width: 350px;\n height: 500px;\n background: white;\n border-radius: 20px;\n box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n transform: translateY(20px) scale(0.95);\n opacity: 0;\n transition: all 0.3s ease;\n border: 1px solid #e1e5e9;\n pointer-events: none; /* 닫혀있을 때 클릭 차단 해제 */\n }\n\n .chat-window.open {\n transform: translateY(0) scale(1);\n opacity: 1;\n pointer-events: auto; /* 열렸을 때 클릭 가능 */\n }\n\n .chat-header {\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n padding: 15px 20px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n }\n\n .chat-header h3 {\n margin: 0;\n font-size: 18px;\n font-weight: 600;\n }\n\n .close-btn {\n background: none;\n border: none;\n color: white;\n cursor: pointer;\n font-size: 32px;\n padding: 0;\n width: 36px;\n height: 36px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n transition: background-color 0.2s ease;\n }\n\n .close-btn:hover {\n background-color: rgba(255, 255, 255, 0.2);\n }\n\n .messages-container {\n flex: 1;\n overflow-y: auto;\n padding: 20px;\n display: flex;\n flex-direction: column;\n gap: 15px;\n }\n\n .message {\n display: flex;\n align-items: flex-end;\n gap: 10px;\n max-width: 80%;\n }\n\n .message.user {\n align-self: flex-end;\n flex-direction: row-reverse;\n }\n\n .message.bot {\n align-self: flex-start;\n }\n\n .message-bubble {\n padding: 12px 16px;\n border-radius: 18px;\n font-size: 14px;\n line-height: 1.4;\n word-wrap: break-word;\n position: relative;\n }\n\n .message.user .message-bubble {\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n border-bottom-right-radius: 4px;\n }\n\n .message.bot .message-bubble {\n background: #f1f3f4;\n color: #333;\n border-bottom-left-radius: 4px;\n }\n\n .message-avatar {\n width: 32px;\n height: 32px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 12px;\n font-weight: 600;\n flex-shrink: 0;\n }\n\n .message.user .message-avatar {\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n }\n\n .message.bot .message-avatar {\n background: #e8eaf0;\n color: #666;\n }\n\n .input-container {\n padding: 20px;\n border-top: 1px solid #e1e5e9;\n display: flex;\n gap: 10px;\n align-items: center;\n }\n\n .message-input {\n flex: 1;\n border: 1px solid #e1e5e9;\n border-radius: 25px;\n padding: 12px 16px;\n font-size: 14px;\n outline: none;\n transition: border-color 0.2s ease;\n }\n\n .message-input:focus {\n border-color: #667eea;\n }\n\n .send-btn {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n border: none;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n }\n\n .send-btn:hover:not(:disabled) {\n transform: scale(1.05);\n }\n\n .send-btn:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .loading-indicator {\n display: flex;\n align-items: center;\n gap: 8px;\n color: #666;\n font-size: 12px;\n }\n\n .loading-dots {\n display: flex;\n gap: 4px;\n }\n\n .loading-dot {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: #667eea;\n animation: loading 1.4s infinite ease-in-out;\n }\n\n .loading-dot:nth-child(1) {\n animation-delay: -0.32s;\n }\n .loading-dot:nth-child(2) {\n animation-delay: -0.16s;\n }\n\n @keyframes loading {\n 0%,\n 80%,\n 100% {\n transform: scale(0);\n }\n 40% {\n transform: scale(1);\n }\n }\n\n /* 스크롤바 스타일링 */\n .messages-container::-webkit-scrollbar {\n width: 6px;\n }\n\n .messages-container::-webkit-scrollbar-track {\n background: #f1f1f1;\n border-radius: 3px;\n }\n\n .messages-container::-webkit-scrollbar-thumb {\n background: #c1c1c1;\n border-radius: 3px;\n }\n\n .messages-container::-webkit-scrollbar-thumb:hover {\n background: #a8a8a8;\n }\n `\n\n toggleChat() {\n this.isOpen = !this.isOpen\n if (this.isOpen) {\n // 챗봇이 열릴 때 ESC 키 이벤트 리스너 추가\n document.addEventListener('keydown', this.boundHandleEscapeKey)\n // 챗봇이 열릴 때 스크롤을 맨 아래로\n this.requestUpdate()\n setTimeout(() => this.scrollToBottom(), 100)\n } else {\n // 챗봇이 닫힐 때 ESC 키 이벤트 리스너 제거\n document.removeEventListener('keydown', this.boundHandleEscapeKey)\n }\n }\n\n scrollToBottom() {\n const messagesContainer = this.shadowRoot?.querySelector('.messages-container') as HTMLElement\n if (messagesContainer) {\n messagesContainer.scrollTop = messagesContainer.scrollHeight\n }\n }\n\n async sendMessage() {\n if (!this.inputValue.trim() || this.isLoading) return\n\n const userMessage: ChatMessage = {\n id: Date.now().toString(),\n text: this.inputValue.trim(),\n isUser: true,\n timestamp: new Date()\n }\n\n this.messages = [...this.messages, userMessage]\n const messageText = this.inputValue.trim()\n this.inputValue = ''\n this.isLoading = true\n\n // 사용자 메시지 추가 후 스크롤을 맨 아래로\n setTimeout(() => this.scrollToBottom(), 50)\n\n // 포커스 유지를 위해 input 요소 참조 저장\n const input = this.shadowRoot?.querySelector('.message-input') as HTMLInputElement\n\n try {\n // API 호출\n const response = await fetch(CHATBOT_API_URL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({ message: messageText })\n })\n\n const data = await response.json()\n\n const botMessage: ChatMessage = {\n id: (Date.now() + 1).toString(),\n text: data.response || '죄송합니다. 응답을 처리할 수 없습니다.',\n isUser: false,\n timestamp: new Date()\n }\n\n this.messages = [...this.messages, botMessage]\n // 봇 메시지 추가 후 스크롤을 맨 아래로\n setTimeout(() => this.scrollToBottom(), 50)\n } catch (error) {\n console.error('챗봇 API 오류:', error)\n const errorMessage: ChatMessage = {\n id: (Date.now() + 1).toString(),\n text: '죄송합니다. 일시적인 오류가 발생했습니다. 잠시 후 다시 시도해주세요.',\n isUser: false,\n timestamp: new Date()\n }\n this.messages = [...this.messages, errorMessage]\n // 에러 메시지 추가 후 스크롤을 맨 아래로\n setTimeout(() => this.scrollToBottom(), 50)\n } finally {\n this.isLoading = false\n // 로딩 완료 후 포커스 복원\n setTimeout(() => {\n if (input) {\n input.focus()\n }\n }, 100)\n }\n }\n\n handleKeyPress(event: KeyboardEvent) {\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault()\n this.sendMessage()\n }\n }\n\n render() {\n return html`\n <div class=\"chatbot-container\">\n <!-- 챗봇 아이콘 -->\n <button class=\"chatbot-icon\" @click=\"${this.toggleChat}\">\n <svg viewBox=\"0 0 24 24\">\n <path\n d=\"M20 2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h4l4 4 4-4h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z\"\n />\n </svg>\n </button>\n\n <!-- 대화창 -->\n <div class=\"chat-window ${this.isOpen ? 'open' : ''}\">\n <!-- 헤더 -->\n <div class=\"chat-header\">\n <h3>챗봇 도우미</h3>\n <button class=\"close-btn\" @click=\"${this.toggleChat}\">×</button>\n </div>\n\n <!-- 메시지 영역 -->\n <div class=\"messages-container\">\n ${this.messages.length === 0\n ? html`\n <div class=\"message bot\">\n <div class=\"message-avatar\">🤖</div>\n <div class=\"message-bubble\">안녕하세요! 무엇을 도와드릴까요?</div>\n </div>\n `\n : ''}\n ${this.messages.map(\n message => html`\n <div class=\"message ${message.isUser ? 'user' : 'bot'}\">\n <div class=\"message-avatar\">${message.isUser ? '👤' : '🤖'}</div>\n <div class=\"message-bubble\">${message.text}</div>\n </div>\n `\n )}\n ${this.isLoading\n ? html`\n <div class=\"message bot\">\n <div class=\"message-avatar\">🤖</div>\n <div class=\"message-bubble\">\n <div class=\"loading-indicator\">\n <span>답변 중</span>\n <div class=\"loading-dots\">\n <div class=\"loading-dot\"></div>\n <div class=\"loading-dot\"></div>\n <div class=\"loading-dot\"></div>\n </div>\n </div>\n </div>\n </div>\n `\n : ''}\n </div>\n\n <!-- 입력 영역 -->\n <div class=\"input-container\">\n <input\n class=\"message-input\"\n type=\"text\"\n placeholder=\"메시지를 입력하세요...\"\n .value=\"${this.inputValue}\"\n @input=\"${(e: Event) => (this.inputValue = (e.target as HTMLInputElement).value)}\"\n @keypress=\"${this.handleKeyPress}\"\n ?disabled=\"${this.isLoading}\"\n />\n <button class=\"send-btn\" @click=\"${this.sendMessage}\" ?disabled=\"${this.isLoading || !this.inputValue.trim()}\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <path d=\"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z\" />\n </svg>\n </button>\n </div>\n </div>\n </div>\n `\n }\n}\n\n// 커스텀 엘리먼트 등록\ncustomElements.define('chatbot-widget', ChatbotWidget)\n\n// 전역에서 사용할 수 있도록 선언\ndeclare global {\n interface HTMLElementTagNameMap {\n 'chatbot-widget': ChatbotWidget\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chatbot-widget.js","sourceRoot":"","sources":["../../../client/pages/lib/chatbot-widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE3C,SAAS;AACT,MAAM,eAAe,GAAG,6CAA6C,CAAA;AAerE,MAAM,OAAO,aAAc,SAAQ,UAAU;IAA7C;;QAwYE,WAAM,GAAG,KAAK,CAAA;QACd,aAAQ,GAAkB,EAAE,CAAA;QAC5B,eAAU,GAAG,EAAE,CAAA;QACf,cAAS,GAAG,KAA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,OAAO,CAAA;QAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA;IAC3B,CAAC;IAED,mBAAmB;QACjB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAA;QAC1B,IAAI,CAAC,cAAc,GAAG,EAAE,CAAA;IAC1B,CAAC;IAED,cAAc,CAAC,KAAoB;QACjC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YAC7C,KAAK,CAAC,cAAc,EAAE,CAAA;YACtB,IAAI,CAAC,WAAW,EAAE,CAAA;QACpB,CAAC;IACH,CAAC;;AA/nBM,oBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0XlB,AA1XY,CA0XZ;AAwQH,cAAc,CAAC,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA","sourcesContent":["import { LitElement, html, css } from 'lit'\n\n// API 상수\nconst CHATBOT_API_URL = 'https://korea-uni-chat-ui.ettisoft.com/chat'\n\ninterface SourceItem {\n title: string\n url: string\n}\n\ninterface ChatMessage {\n id: string\n text: string\n isUser: boolean\n timestamp: Date\n sources?: SourceItem[]\n}\n\nexport class ChatbotWidget extends LitElement {\n static styles = css`\n :host {\n position: fixed;\n bottom: 40px;\n right: 20px;\n z-index: 1000;\n }\n\n .chatbot-container {\n position: relative;\n }\n\n .chatbot-icon {\n width: 60px;\n height: 60px;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);\n transition: all 0.3s ease;\n border: none;\n outline: none;\n }\n\n .chatbot-icon:hover {\n transform: scale(1.1);\n box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);\n }\n\n .chatbot-icon svg {\n width: 28px;\n height: 28px;\n fill: white;\n }\n\n .chat-window {\n position: absolute;\n bottom: 80px;\n right: 0;\n width: 350px;\n height: 500px;\n background: white;\n border-radius: 20px;\n box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n transform: translateY(20px) scale(0.95);\n opacity: 0;\n transition: all 0.3s ease;\n border: 1px solid #e1e5e9;\n pointer-events: none; /* 닫혀있을 때 클릭 차단 해제 */\n }\n\n .chat-window.open {\n transform: translateY(0) scale(1);\n opacity: 1;\n pointer-events: auto; /* 열렸을 때 클릭 가능 */\n }\n\n .chat-header {\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n padding: 15px 20px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n }\n\n .chat-header h3 {\n margin: 0;\n font-size: 18px;\n font-weight: 600;\n }\n\n .close-btn {\n background: none;\n border: none;\n color: white;\n cursor: pointer;\n font-size: 32px;\n padding: 0;\n width: 36px;\n height: 36px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 50%;\n transition: background-color 0.2s ease;\n }\n\n .close-btn:hover {\n background-color: rgba(255, 255, 255, 0.2);\n }\n\n .messages-container {\n flex: 1;\n overflow-y: auto;\n padding: 20px;\n display: flex;\n flex-direction: column;\n gap: 15px;\n }\n\n .message {\n display: flex;\n align-items: flex-end;\n gap: 10px;\n max-width: 80%;\n }\n\n .message.user {\n align-self: flex-end;\n flex-direction: row-reverse;\n }\n\n .message.bot {\n align-self: flex-start;\n }\n\n .message-bubble {\n padding: 12px 16px;\n border-radius: 18px;\n font-size: 14px;\n line-height: 1.4;\n word-wrap: break-word;\n position: relative;\n }\n\n .message.user .message-bubble {\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n border-bottom-right-radius: 4px;\n }\n\n .message.bot .message-bubble {\n background: #f1f3f4;\n color: #333;\n border-bottom-left-radius: 4px;\n }\n\n .message-avatar {\n width: 32px;\n height: 32px;\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 12px;\n font-weight: 600;\n flex-shrink: 0;\n }\n\n .message.user .message-avatar {\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: white;\n }\n\n .message.bot .message-avatar {\n background: #e8eaf0;\n color: #666;\n }\n\n .input-container {\n padding: 20px;\n border-top: 1px solid #e1e5e9;\n display: flex;\n gap: 10px;\n align-items: center;\n }\n\n .message-input {\n flex: 1;\n border: 1px solid #e1e5e9;\n border-radius: 25px;\n padding: 12px 16px;\n font-size: 14px;\n outline: none;\n transition: border-color 0.2s ease;\n }\n\n .message-input:focus {\n border-color: #667eea;\n }\n\n .send-btn {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n border: none;\n color: white;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.2s ease;\n }\n\n .send-btn:hover:not(:disabled) {\n transform: scale(1.05);\n }\n\n .send-btn:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .loading-indicator {\n display: flex;\n align-items: center;\n gap: 8px;\n color: #666;\n font-size: 12px;\n }\n\n .loading-dots {\n display: flex;\n gap: 4px;\n }\n\n .loading-dot {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: #667eea;\n animation: loading 1.4s infinite ease-in-out;\n }\n\n .loading-dot:nth-child(1) {\n animation-delay: -0.32s;\n }\n .loading-dot:nth-child(2) {\n animation-delay: -0.16s;\n }\n\n @keyframes loading {\n 0%,\n 80%,\n 100% {\n transform: scale(0);\n }\n 40% {\n transform: scale(1);\n }\n }\n\n /* 스크롤바 스타일링 */\n .messages-container::-webkit-scrollbar {\n width: 6px;\n }\n\n .messages-container::-webkit-scrollbar-track {\n background: #f1f1f1;\n border-radius: 3px;\n }\n\n .messages-container::-webkit-scrollbar-thumb {\n background: #c1c1c1;\n border-radius: 3px;\n }\n\n .messages-container::-webkit-scrollbar-thumb:hover {\n background: #a8a8a8;\n }\n\n /* 근거 버튼 */\n .evidence-btn {\n margin-top: 8px;\n display: inline-flex;\n align-items: center;\n gap: 6px;\n border: 1px solid #d6daf0;\n background: #ffffff;\n color: #3b4cca;\n border-radius: 14px;\n padding: 6px 10px;\n font-size: 12px;\n cursor: pointer;\n transition:\n background-color 0.2s ease,\n border-color 0.2s ease;\n }\n\n .evidence-btn:hover {\n background-color: #f4f6ff;\n border-color: #c2c8ef;\n }\n\n /* 오버레이 */\n .overlay {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.35);\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.2s ease;\n z-index: 1100; /* 챗봇보다 위 */\n }\n\n .overlay.open {\n opacity: 1;\n pointer-events: auto;\n }\n\n .overlay-panel {\n width: min(520px, calc(100vw - 40px));\n max-height: min(70vh, 560px);\n background: #ffffff;\n border-radius: 14px;\n box-shadow: 0 18px 60px rgba(0, 0, 0, 0.18);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n\n .overlay-header {\n padding: 14px 16px;\n background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n color: #ffffff;\n display: flex;\n align-items: center;\n justify-content: space-between;\n }\n\n .overlay-title {\n font-weight: 600;\n font-size: 16px;\n }\n\n .overlay-close {\n background: none;\n border: none;\n color: #ffffff;\n font-size: 26px;\n width: 32px;\n height: 32px;\n border-radius: 50%;\n cursor: pointer;\n }\n\n .overlay-body {\n padding: 12px 16px 16px 16px;\n overflow-y: auto;\n }\n\n .source-list {\n display: flex;\n flex-direction: column;\n gap: 10px;\n margin: 0;\n padding: 0;\n list-style: none;\n }\n\n .source-item {\n border: 1px solid #e6e9f2;\n border-radius: 10px;\n padding: 10px 12px;\n background: #f9fafc;\n }\n\n .source-link {\n color: #1e3a8a;\n text-decoration: none;\n display: block;\n word-break: break-all;\n }\n\n .source-link:hover {\n text-decoration: underline;\n }\n `\n\n static get properties() {\n return {\n isOpen: { type: Boolean },\n messages: { type: Array },\n inputValue: { type: String },\n isLoading: { type: Boolean },\n isSourcesOpen: { type: Boolean },\n currentSources: { type: Array }\n }\n }\n\n isOpen = false\n messages: ChatMessage[] = []\n inputValue = ''\n isLoading = false\n isSourcesOpen = false\n currentSources: SourceItem[] = []\n\n render() {\n return html`\n <div class=\"chatbot-container\">\n <!-- 챗봇 아이콘 -->\n <button class=\"chatbot-icon\" @click=\"${this.toggleChat}\">\n <svg viewBox=\"0 0 24 24\">\n <path\n d=\"M20 2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h4l4 4 4-4h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z\"\n />\n </svg>\n </button>\n\n <!-- 대화창 -->\n <div class=\"chat-window ${this.isOpen ? 'open' : ''}\">\n <!-- 헤더 -->\n <div class=\"chat-header\">\n <h3>챗봇 도우미</h3>\n <button class=\"close-btn\" @click=\"${this.toggleChat}\">×</button>\n </div>\n\n <!-- 메시지 영역 -->\n <div class=\"messages-container\">\n ${this.messages.length === 0\n ? html`\n <div class=\"message bot\">\n <div class=\"message-avatar\">🤖</div>\n <div class=\"message-bubble\">안녕하세요! 무엇을 도와드릴까요?</div>\n </div>\n `\n : ''}\n ${this.messages.map(\n message => html`\n <div class=\"message ${message.isUser ? 'user' : 'bot'}\">\n <div class=\"message-avatar\">${message.isUser ? '👤' : '🤖'}</div>\n <div class=\"message-bubble\">\n ${message.text}\n ${!message.isUser && message.sources && message.sources.length\n ? html`\n <div>\n <button class=\"evidence-btn\" @click=\"${() => this.openSourcesOverlay(message.sources || [])}\">\n 근거 ${message.sources.length}개 보기\n </button>\n </div>\n `\n : ''}\n </div>\n </div>\n `\n )}\n ${this.isLoading\n ? html`\n <div class=\"message bot\">\n <div class=\"message-avatar\">🤖</div>\n <div class=\"message-bubble\">\n <div class=\"loading-indicator\">\n <span>답변 중</span>\n <div class=\"loading-dots\">\n <div class=\"loading-dot\"></div>\n <div class=\"loading-dot\"></div>\n <div class=\"loading-dot\"></div>\n </div>\n </div>\n </div>\n </div>\n `\n : ''}\n </div>\n\n <!-- 입력 영역 -->\n <div class=\"input-container\">\n <input\n class=\"message-input\"\n type=\"text\"\n placeholder=\"메시지를 입력하세요...\"\n .value=\"${this.inputValue}\"\n @input=\"${(e: Event) => (this.inputValue = (e.target as HTMLInputElement).value)}\"\n @keypress=\"${this.handleKeyPress}\"\n ?disabled=\"${this.isLoading}\"\n />\n <button class=\"send-btn\" @click=\"${this.sendMessage}\" ?disabled=\"${this.isLoading || !this.inputValue.trim()}\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <path d=\"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z\" />\n </svg>\n </button>\n </div>\n </div>\n <!-- 근거 오버레이 -->\n <div class=\"overlay ${this.isSourcesOpen ? 'open' : ''}\" @click=\"${this.closeSourcesOverlay}\">\n <div class=\"overlay-panel\" @click=\"${(e: Event) => e.stopPropagation()}\">\n <div class=\"overlay-header\">\n <div class=\"overlay-title\">근거 ${this.currentSources.length}개</div>\n <button class=\"overlay-close\" @click=\"${this.closeSourcesOverlay}\">×</button>\n </div>\n <div class=\"overlay-body\">\n <ul class=\"source-list\">\n ${this.currentSources.map(\n (s, idx) =>\n html` <li class=\"source-item\">\n <a class=\"source-link\" href=\"${s.url}\" target=\"_blank\" rel=\"noopener noreferrer\"\n >[#${idx + 1}] ${s.title}</a\n >\n </li>`\n )}\n </ul>\n </div>\n </div>\n </div>\n </div>\n `\n }\n\n private boundHandleEscapeKey = this.handleEscapeKey.bind(this)\n\n connectedCallback() {\n super.connectedCallback()\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n // 컴포넌트가 제거될 때 이벤트 리스너 정리\n document.removeEventListener('keydown', this.boundHandleEscapeKey)\n }\n\n handleEscapeKey(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n if (this.isSourcesOpen) {\n this.isSourcesOpen = false\n } else if (this.isOpen) {\n this.isOpen = false\n }\n }\n }\n\n toggleChat() {\n this.isOpen = !this.isOpen\n if (this.isOpen) {\n // 챗봇이 열릴 때 ESC 키 이벤트 리스너 추가\n document.addEventListener('keydown', this.boundHandleEscapeKey)\n // 챗봇이 열릴 때 스크롤을 맨 아래로\n this.requestUpdate()\n setTimeout(() => this.scrollToBottom(), 100)\n } else {\n // 챗봇이 닫힐 때 ESC 키 이벤트 리스너 제거\n document.removeEventListener('keydown', this.boundHandleEscapeKey)\n this.isSourcesOpen = false\n this.currentSources = []\n }\n }\n\n scrollToBottom() {\n const messagesContainer = this.shadowRoot?.querySelector('.messages-container') as HTMLElement\n if (messagesContainer) {\n messagesContainer.scrollTop = messagesContainer.scrollHeight\n }\n }\n\n async sendMessage() {\n if (!this.inputValue.trim() || this.isLoading) return\n\n const userMessage: ChatMessage = {\n id: Date.now().toString(),\n text: this.inputValue.trim(),\n isUser: true,\n timestamp: new Date()\n }\n\n this.messages = [...this.messages, userMessage]\n const messageText = this.inputValue.trim()\n this.inputValue = ''\n this.isLoading = true\n\n // 사용자 메시지 추가 후 스크롤을 맨 아래로\n setTimeout(() => this.scrollToBottom(), 50)\n\n // 포커스 유지를 위해 input 요소 참조 저장\n const input = this.shadowRoot?.querySelector('.message-input') as HTMLInputElement\n\n try {\n // API 호출\n const response = await fetch(CHATBOT_API_URL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({ query: messageText, top_k: 6 })\n })\n\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}`)\n }\n\n const data = await response.json()\n\n const botMessage: ChatMessage = {\n id: (Date.now() + 1).toString(),\n text: data?.answer?.trim() || '죄송합니다. 응답을 처리할 수 없습니다.',\n isUser: false,\n timestamp: new Date(),\n sources: data?.sources || []\n }\n\n this.messages = [...this.messages, botMessage]\n // 봇 메시지 추가 후 스크롤을 맨 아래로\n setTimeout(() => this.scrollToBottom(), 50)\n } catch (error) {\n const errorMessage: ChatMessage = {\n id: (Date.now() + 1).toString(),\n text: '죄송합니다. 일시적인 오류가 발생했습니다. 잠시 후 다시 시도해주세요.',\n isUser: false,\n timestamp: new Date()\n }\n this.messages = [...this.messages, errorMessage]\n // 에러 메시지 추가 후 스크롤을 맨 아래로\n setTimeout(() => this.scrollToBottom(), 50)\n } finally {\n this.isLoading = false\n // 로딩 완료 후 포커스 복원\n setTimeout(() => {\n if (input) {\n input.focus()\n }\n }, 100)\n }\n }\n\n openSourcesOverlay(sources: SourceItem[]) {\n if (!sources || sources.length === 0) return\n this.currentSources = sources\n this.isSourcesOpen = true\n }\n\n closeSourcesOverlay() {\n this.isSourcesOpen = false\n this.currentSources = []\n }\n\n handleKeyPress(event: KeyboardEvent) {\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault()\n this.sendMessage()\n }\n }\n}\n\ncustomElements.define('chatbot-widget', ChatbotWidget)\n"]}
|
|
@@ -12,6 +12,7 @@ export declare class Select2Component extends LitElement {
|
|
|
12
12
|
name: string;
|
|
13
13
|
value: string;
|
|
14
14
|
} | undefined)[];
|
|
15
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
15
16
|
connectedCallback(): void;
|
|
16
17
|
disconnectedCallback(): void;
|
|
17
18
|
private _handleOutsideClick;
|
|
@@ -19,5 +20,4 @@ export declare class Select2Component extends LitElement {
|
|
|
19
20
|
private _handleSelect;
|
|
20
21
|
private _handleRemove;
|
|
21
22
|
private _dispatchEvent;
|
|
22
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
23
23
|
}
|