@nabeh/chat-widget 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +452 -0
- package/dist/browser.cjs +872 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +12 -0
- package/dist/browser.d.ts +12 -0
- package/dist/browser.iife.js +872 -0
- package/dist/browser.iife.js.map +1 -0
- package/dist/browser.js +2 -0
- package/dist/browser.js.map +1 -0
- package/dist/chunk-T4LQIVBI.js +872 -0
- package/dist/chunk-T4LQIVBI.js.map +1 -0
- package/dist/index.cjs +872 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +111 -0
- package/dist/index.d.ts +111 -0
- package/dist/index.iife.js +872 -0
- package/dist/index.iife.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,872 @@
|
|
|
1
|
+
"use strict";var ChatWidget=(()=>{var re=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var ct=Object.prototype.hasOwnProperty;var ut=(e,t)=>{for(var n in t)re(e,n,{get:t[n],enumerable:!0})},gt=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of dt(t))!ct.call(e,i)&&i!==n&&re(e,i,{get:()=>t[i],enumerable:!(s=lt(t,i))||s.enumerable});return e};var ft=e=>gt(re({},"__esModule",{value:!0}),e);var yt={};ut(yt,{createChatWidget:()=>qe});function Se(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function ie(e,t){let n={...e};for(let s of Object.keys(t)){let i=t[s],l=n[s];if(Se(l)&&Se(i)){n[s]=ie(l,i);continue}i!==void 0&&(n[s]=i)}return n}function ze(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error("Unexpected widget error")}function V(e,t){return`${e.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}function D(e,t,n){return{"Content-Type":"application/json",...e.customHeaders,...n?{"X-Chat-User-Context":n}:{},...t?{Authorization:`Bearer ${t}`}:{}}}async function _(e){if(!e.getUserContext)return null;let t=await e.getUserContext();return t?JSON.stringify(t):null}function pe(e,t,n={}){let s=t.replace(/\{chatId\}/g,encodeURIComponent(n.chatId??"")).replace(/:chatId\b/g,encodeURIComponent(n.chatId??""));return V(e.apiBaseUrl,s)}async function We(e,t){let n=e.getAccessToken?await e.getAccessToken():null,s=await _(e),i=pe(e,e.endpoints.ask,{chatId:t.chatId}),r=/(\{chatId\}|:chatId\b)/.test(e.endpoints.ask)?{message:t.message,knowledgeNames:t.knowledgeNames,editLastQa:t.editLastQa??!1,enableReferences:t.enableReferences??!0}:{query:t.message,chat_id:t.chatId,knowledge_names:t.knowledgeNames,edit_last_qa:t.editLastQa??!1,enable_references:t.enableReferences??!0},u=await fetch(i,{method:"POST",headers:D(e,n,s),body:JSON.stringify(r)});if(!u.ok)throw new Error(`Chat backend returned ${u.status}.`);let p=await u.json();if(!Array.isArray(p)){if(!p.answer||typeof p.answer!="string")throw new Error("Chat backend response is missing a valid answer.");return{chatId:p.chatId??t.chatId,answer:p.answer,suggestions:p.suggestions??[],citations:p.citations??[]}}let c=p[0];if(!c?.answer||typeof c.answer!="string")throw new Error("Chat backend response is missing a valid answer.");let f=c.content,g=f?.source_documents??[],m=f?.scores??[],z=f?.page_numbers??[],W=f?.sheet_names??[],N=f?.row_numbers??[],K=f?.knowledge_names??[],J=g.map((G,b)=>({sourceDocument:G,score:m[b]??null,pageNumber:z[b]??null,sheetName:W[b]??null,rowNumber:N[b]??null,knowledgeName:K[b]??null}));return{chatId:t.chatId,answer:c.answer,suggestions:[],citations:J}}async function Ne(e,t){if(!e.endpoints.history)return[];let n=e.getAccessToken?await e.getAccessToken():null,s=await _(e),l=/(\{chatId\}|:chatId\b)/.test(e.endpoints.history)?pe(e,e.endpoints.history,{chatId:t}):(()=>{let p=new URL(V(e.apiBaseUrl,e.endpoints.history));return p.searchParams.set("chat_id",t),p.toString()})(),r=await fetch(l,{method:"GET",headers:D(e,n,s)});if(!r.ok)throw new Error(`Chat history endpoint returned ${r.status}.`);let u=await r.json();return Array.isArray(u)?u.map(p=>{if(!p||typeof p!="object")return null;let c=p,f=c.role??c.type??c.sender??c.author,g=c.text??c.message??c.content??c.answer;if(typeof g!="string")return null;let m=typeof f=="string"?f.toLowerCase():"assistant";return{role:m==="user"||m==="human"?"user":"assistant",text:g}}).filter(p=>!!p):[]}async function Oe(e){if(!e.endpoints.listChats)return[];let t=e.getAccessToken?await e.getAccessToken():null,n=await _(e),s=await fetch(V(e.apiBaseUrl,e.endpoints.listChats),{method:"GET",headers:D(e,t,n)});if(!s.ok)throw new Error(`Chat list endpoint returned ${s.status}.`);let i=await s.json();return Array.isArray(i)?i.map(l=>{if(!l||typeof l!="object")return null;let r=l,u=r.chatId??r.chat_id??r.id,p=r.title??r.name??r.chatId;if(typeof u!="string"||typeof p!="string")return null;let c=typeof r.createdAt=="string"?r.createdAt:typeof r.created_at=="string"?r.created_at:null,f=typeof r.updatedAt=="string"?r.updatedAt:typeof r.updated_at=="string"?r.updated_at:null,g={chatId:u,title:p,pinned:typeof r.pinned=="boolean"?r.pinned:!1};return c&&(g.createdAt=c),f&&(g.updatedAt=f),g}).filter(l=>!!l):[]}async function Ue(e,t,n){let s=e.endpoints.createChat??e.endpoints.listChats;if(!s)return;let i=e.getAccessToken?await e.getAccessToken():null,l=await _(e),r=await fetch(V(e.apiBaseUrl,s),{method:"POST",headers:D(e,i,l),body:JSON.stringify({chatId:t,...n?{title:n}:{}})});if(!r.ok)throw new Error(`Create chat endpoint returned ${r.status}.`)}async function Be(e,t,n){if(!e.endpoints.updateChat)return;let s=e.getAccessToken?await e.getAccessToken():null,i=await _(e),l=pe(e,e.endpoints.updateChat,{chatId:t}),r=await fetch(l,{method:"PATCH",headers:D(e,s,i),body:JSON.stringify(n)});if(!r.ok)throw new Error(`Update chat endpoint returned ${r.status}.`)}function j(e,t){let n=ze(t);return e.onError?.(n),n}var le={accent:"#0f766e",accentSoft:"#ecfeff",panelBackground:"#ffffff",surfaceBackground:"#f8fafc",text:"#1f2937",mutedText:"#64748b",borderColor:"#dbe4ee",shadow:"0 24px 64px rgba(15, 23, 42, 0.20)",zIndex:2147483e3,fontFamily:'"Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif'},h={position:"bottom-right",title:"Knowledge Assistant",subtitle:"Answers are generated based on your access permissions",welcomeMessage:"How can I assist you today?",inputPlaceholder:"Ask your question...",launcherAriaLabel:"Open chat assistant",closeAriaLabel:"Close chat assistant",initialSuggestions:["Which indicators reflect the achievements of Vision KSA goals?","Case studies of real estate initiatives for economic growth","Study of UX for the ministry external portal"],sourceApp:"knowledge-platform",locale:"en",customHeaders:{},rag:{knowledgeNames:[],enableReferences:!0,loadHistoryOnOpen:!1},theme:le,getAccessToken:void 0,getUserContext:void 0,onOpen:void 0,onClose:void 0,onError:void 0};function $e(e){if(!e.apiBaseUrl?.trim())throw new Error("Chat widget config requires a non-empty apiBaseUrl.");if(!e.endpoints?.ask?.trim())throw new Error("Chat widget config requires endpoints.ask to be provided.");let t=e.mount??document.body,n=ie(le,e.theme??{});return{apiBaseUrl:e.apiBaseUrl,endpoints:{...e.endpoints},mount:t,position:e.position??h.position,title:e.title??h.title,subtitle:e.subtitle??h.subtitle,welcomeMessage:e.welcomeMessage??h.welcomeMessage,inputPlaceholder:e.inputPlaceholder??h.inputPlaceholder,launcherAriaLabel:e.launcherAriaLabel??h.launcherAriaLabel,closeAriaLabel:e.closeAriaLabel??h.closeAriaLabel,initialSuggestions:e.initialSuggestions??h.initialSuggestions,sourceApp:e.sourceApp??h.sourceApp,locale:e.locale??h.locale,customHeaders:e.customHeaders??h.customHeaders,rag:{...h.rag,...e.rag??{}},theme:n,getAccessToken:e.getAccessToken,getUserContext:e.getUserContext,onOpen:e.onOpen,onClose:e.onClose,onError:e.onError}}function o(e,t,n){let s=document.createElement(e);return t&&(s.className=t),n!==void 0&&(s.textContent=n),s}var Ve="kp-chat-widget-styles";function De(e,t){if(e.getElementById(Ve))return;let n=document.createElement("style");n.id=Ve,n.textContent=ht(t),e.appendChild(n)}function ht(e){return`
|
|
2
|
+
:host {
|
|
3
|
+
all: initial;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.kp-chat-widget {
|
|
7
|
+
--kp-accent: ${e.accent};
|
|
8
|
+
--kp-accent-soft: ${e.accentSoft};
|
|
9
|
+
--kp-panel-background: ${e.panelBackground};
|
|
10
|
+
--kp-surface-background: ${e.surfaceBackground};
|
|
11
|
+
--kp-text: ${e.text};
|
|
12
|
+
--kp-muted-text: ${e.mutedText};
|
|
13
|
+
--kp-border-color: ${e.borderColor};
|
|
14
|
+
--kp-shadow: ${e.shadow};
|
|
15
|
+
--kp-z-index: ${e.zIndex};
|
|
16
|
+
--kp-font-family: ${e.fontFamily};
|
|
17
|
+
position: fixed;
|
|
18
|
+
bottom: 24px;
|
|
19
|
+
right: 24px;
|
|
20
|
+
z-index: var(--kp-z-index);
|
|
21
|
+
font-family: var(--kp-font-family);
|
|
22
|
+
color: var(--kp-text);
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
*,
|
|
27
|
+
*::before,
|
|
28
|
+
*::after {
|
|
29
|
+
box-sizing: border-box;
|
|
30
|
+
font-family: inherit;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.kp-chat-widget.bottom-left {
|
|
34
|
+
left: 24px;
|
|
35
|
+
right: auto;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.kp-launcher {
|
|
39
|
+
width: 72px;
|
|
40
|
+
height: 72px;
|
|
41
|
+
border: none;
|
|
42
|
+
border-radius: 999px;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
background: radial-gradient(circle at 30% 30%, #f8fffe 0%, #ecfdf5 52%, #d6f4ef 100%);
|
|
45
|
+
box-shadow: 0 16px 32px rgba(15, 118, 110, 0.18);
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
|
|
50
|
+
color: var(--kp-accent);
|
|
51
|
+
position: relative;
|
|
52
|
+
overflow: hidden;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.kp-launcher:hover {
|
|
56
|
+
transform: translateY(-1px);
|
|
57
|
+
box-shadow: 0 20px 36px rgba(15, 118, 110, 0.22);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.kp-launcher:focus-visible,
|
|
61
|
+
.kp-close:focus-visible,
|
|
62
|
+
.kp-send:focus-visible,
|
|
63
|
+
.kp-suggestion:focus-visible,
|
|
64
|
+
.kp-input:focus-visible,
|
|
65
|
+
.kp-full-page-new-chat:focus-visible,
|
|
66
|
+
.kp-full-page-close:focus-visible,
|
|
67
|
+
.kp-full-page-search-input:focus-visible,
|
|
68
|
+
.kp-full-page-chat-item:focus-visible,
|
|
69
|
+
.kp-chat-pin:focus-visible {
|
|
70
|
+
outline: 2px solid var(--kp-accent);
|
|
71
|
+
outline-offset: 2px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.kp-launcher.hidden {
|
|
75
|
+
opacity: 0;
|
|
76
|
+
pointer-events: none;
|
|
77
|
+
transform: translateY(8px) scale(0.96);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.kp-star-cluster {
|
|
81
|
+
position: relative;
|
|
82
|
+
width: 50px;
|
|
83
|
+
height: 50px;
|
|
84
|
+
animation: kp-cluster-rotate 8.5s linear infinite;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.kp-star {
|
|
88
|
+
position: absolute;
|
|
89
|
+
color: #08384c;
|
|
90
|
+
line-height: 1;
|
|
91
|
+
transform-origin: center;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.kp-star.main {
|
|
95
|
+
top: 50%;
|
|
96
|
+
left: 50%;
|
|
97
|
+
font-size: 30px;
|
|
98
|
+
transform: translate(-50%, -50%) scale(0.96);
|
|
99
|
+
animation: kp-main-pulse 3s ease-in-out infinite;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.kp-star.orbit-a {
|
|
103
|
+
top: -3px;
|
|
104
|
+
left: 50%;
|
|
105
|
+
font-size: 18px;
|
|
106
|
+
transform: translateX(-50%);
|
|
107
|
+
animation: kp-orbit-a 3s ease-in-out infinite;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.kp-star.orbit-b {
|
|
111
|
+
right: -3px;
|
|
112
|
+
bottom: 5px;
|
|
113
|
+
font-size: 18px;
|
|
114
|
+
animation: kp-orbit-b 3s ease-in-out infinite;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.kp-star.orbit-c {
|
|
118
|
+
left: -1px;
|
|
119
|
+
bottom: 5px;
|
|
120
|
+
font-size: 18px;
|
|
121
|
+
animation: kp-orbit-c 3s ease-in-out infinite;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.kp-overlay {
|
|
125
|
+
position: fixed;
|
|
126
|
+
inset: 0;
|
|
127
|
+
background: rgba(15, 23, 42, 0.18);
|
|
128
|
+
opacity: 0;
|
|
129
|
+
pointer-events: none;
|
|
130
|
+
transition: opacity 220ms ease;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.kp-overlay.visible {
|
|
134
|
+
opacity: 1;
|
|
135
|
+
pointer-events: auto;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.kp-panel {
|
|
139
|
+
position: fixed;
|
|
140
|
+
bottom: 88px;
|
|
141
|
+
right: 24px;
|
|
142
|
+
width: 480px;
|
|
143
|
+
max-width: calc(100vw - 24px);
|
|
144
|
+
height: min(730px, calc(100vh - 118px));
|
|
145
|
+
background: var(--kp-panel-background);
|
|
146
|
+
border: 1px solid rgba(255, 255, 255, 0.35);
|
|
147
|
+
border-radius: 20px;
|
|
148
|
+
box-shadow: var(--kp-shadow);
|
|
149
|
+
overflow: hidden;
|
|
150
|
+
display: flex;
|
|
151
|
+
flex-direction: column;
|
|
152
|
+
opacity: 0;
|
|
153
|
+
transform: translateX(112px) scale(0.97);
|
|
154
|
+
transform-origin: bottom right;
|
|
155
|
+
pointer-events: none;
|
|
156
|
+
transition: opacity 420ms cubic-bezier(0.16, 1, 0.3, 1),
|
|
157
|
+
transform 620ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.kp-chat-widget.bottom-left .kp-panel {
|
|
161
|
+
left: 24px;
|
|
162
|
+
right: auto;
|
|
163
|
+
transform: translateX(-112px) scale(0.97);
|
|
164
|
+
transform-origin: bottom left;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.kp-panel.open {
|
|
168
|
+
opacity: 1;
|
|
169
|
+
transform: translateX(0) scale(1);
|
|
170
|
+
pointer-events: auto;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.kp-full-page {
|
|
174
|
+
position: fixed;
|
|
175
|
+
inset: 0;
|
|
176
|
+
background:
|
|
177
|
+
radial-gradient(circle at top, rgba(32, 185, 210, 0.12), transparent 24%),
|
|
178
|
+
linear-gradient(180deg, #f9fbfd 0%, #eef3f8 100%);
|
|
179
|
+
opacity: 0;
|
|
180
|
+
pointer-events: none;
|
|
181
|
+
transform: translateY(18px);
|
|
182
|
+
transition: opacity 260ms ease, transform 320ms ease;
|
|
183
|
+
z-index: calc(var(--kp-z-index) + 2);
|
|
184
|
+
overflow: hidden;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.kp-full-page.open {
|
|
188
|
+
opacity: 1;
|
|
189
|
+
pointer-events: auto;
|
|
190
|
+
transform: translateY(0);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.kp-full-page-shell {
|
|
194
|
+
height: 100vh;
|
|
195
|
+
display: flex;
|
|
196
|
+
flex-direction: column;
|
|
197
|
+
padding: 22px 34px 26px;
|
|
198
|
+
gap: 16px;
|
|
199
|
+
overflow: hidden;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.kp-full-page-header {
|
|
203
|
+
display: flex;
|
|
204
|
+
align-items: center;
|
|
205
|
+
justify-content: space-between;
|
|
206
|
+
gap: 16px;
|
|
207
|
+
padding: 12px 4px 0;
|
|
208
|
+
flex: none;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.kp-full-page-brand {
|
|
212
|
+
display: flex;
|
|
213
|
+
align-items: center;
|
|
214
|
+
gap: 12px;
|
|
215
|
+
color: #08384c;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.kp-full-page-brand-mark {
|
|
219
|
+
width: 44px;
|
|
220
|
+
height: 44px;
|
|
221
|
+
border-radius: 14px;
|
|
222
|
+
display: flex;
|
|
223
|
+
align-items: center;
|
|
224
|
+
justify-content: center;
|
|
225
|
+
background: linear-gradient(135deg, rgba(37, 181, 192, 0.14), rgba(15, 118, 110, 0.08));
|
|
226
|
+
font-size: 26px;
|
|
227
|
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.kp-full-page-brand-text {
|
|
231
|
+
font-size: 20px;
|
|
232
|
+
font-weight: 700;
|
|
233
|
+
letter-spacing: -0.02em;
|
|
234
|
+
color: #16394b;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.kp-full-page-header-actions {
|
|
238
|
+
display: flex;
|
|
239
|
+
align-items: center;
|
|
240
|
+
gap: 12px;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.kp-full-page-badge {
|
|
244
|
+
padding: 10px 14px;
|
|
245
|
+
border-radius: 999px;
|
|
246
|
+
font-size: 13px;
|
|
247
|
+
line-height: 1;
|
|
248
|
+
color: #0b556c;
|
|
249
|
+
background: rgba(255, 255, 255, 0.82);
|
|
250
|
+
border: 1px solid rgba(15, 118, 110, 0.12);
|
|
251
|
+
box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.kp-full-page-close {
|
|
255
|
+
width: 44px;
|
|
256
|
+
height: 44px;
|
|
257
|
+
border: none;
|
|
258
|
+
border-radius: 14px;
|
|
259
|
+
background: rgba(255, 255, 255, 0.82);
|
|
260
|
+
color: #61788a;
|
|
261
|
+
font-size: 28px;
|
|
262
|
+
line-height: 1;
|
|
263
|
+
cursor: pointer;
|
|
264
|
+
box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.kp-full-page-breadcrumb {
|
|
268
|
+
padding: 0 4px;
|
|
269
|
+
color: #8192a0;
|
|
270
|
+
font-size: 13px;
|
|
271
|
+
line-height: 1.5;
|
|
272
|
+
flex: none;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.kp-full-page-content {
|
|
276
|
+
display: grid;
|
|
277
|
+
grid-template-columns: 290px minmax(0, 1fr);
|
|
278
|
+
gap: 16px;
|
|
279
|
+
flex: 1;
|
|
280
|
+
min-height: 0;
|
|
281
|
+
overflow: hidden;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.kp-full-page-sidebar,
|
|
285
|
+
.kp-full-page-panel {
|
|
286
|
+
border-radius: 22px;
|
|
287
|
+
border: 1px solid rgba(219, 228, 238, 0.9);
|
|
288
|
+
background: rgba(255, 255, 255, 0.88);
|
|
289
|
+
box-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
|
|
290
|
+
backdrop-filter: blur(12px);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.kp-full-page-sidebar {
|
|
294
|
+
padding: 18px;
|
|
295
|
+
display: flex;
|
|
296
|
+
flex-direction: column;
|
|
297
|
+
gap: 16px;
|
|
298
|
+
min-height: 0;
|
|
299
|
+
overflow: auto;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.kp-full-page-new-chat {
|
|
303
|
+
width: 100%;
|
|
304
|
+
height: 48px;
|
|
305
|
+
border: none;
|
|
306
|
+
border-radius: 12px;
|
|
307
|
+
background: linear-gradient(135deg, #0a465d 0%, #0f6a75 100%);
|
|
308
|
+
color: #ffffff;
|
|
309
|
+
font-size: 16px;
|
|
310
|
+
font-weight: 600;
|
|
311
|
+
cursor: pointer;
|
|
312
|
+
box-shadow: 0 14px 30px rgba(10, 70, 93, 0.18);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.kp-full-page-search {
|
|
316
|
+
display: flex;
|
|
317
|
+
align-items: center;
|
|
318
|
+
gap: 8px;
|
|
319
|
+
height: 44px;
|
|
320
|
+
border-radius: 12px;
|
|
321
|
+
border: 1px solid rgba(203, 213, 225, 0.95);
|
|
322
|
+
background: #ffffff;
|
|
323
|
+
padding: 0 12px;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.kp-full-page-search-input {
|
|
327
|
+
flex: 1;
|
|
328
|
+
border: none;
|
|
329
|
+
outline: none;
|
|
330
|
+
background: transparent;
|
|
331
|
+
color: #334155;
|
|
332
|
+
font-size: 14px;
|
|
333
|
+
min-width: 0;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.kp-full-page-search-icon {
|
|
337
|
+
color: #607082;
|
|
338
|
+
font-size: 20px;
|
|
339
|
+
line-height: 1;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.kp-full-page-section-label {
|
|
343
|
+
font-size: 12px;
|
|
344
|
+
line-height: 1.4;
|
|
345
|
+
text-transform: uppercase;
|
|
346
|
+
letter-spacing: 0.08em;
|
|
347
|
+
color: #8a98a6;
|
|
348
|
+
margin-top: 4px;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.kp-full-page-recent-list,
|
|
352
|
+
.kp-full-page-pinned-list {
|
|
353
|
+
display: flex;
|
|
354
|
+
flex-direction: column;
|
|
355
|
+
gap: 8px;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.kp-full-page-item {
|
|
359
|
+
padding: 12px 12px 13px;
|
|
360
|
+
border-radius: 12px;
|
|
361
|
+
color: #293845;
|
|
362
|
+
font-size: 15px;
|
|
363
|
+
line-height: 1.5;
|
|
364
|
+
background: rgba(247, 250, 252, 0.9);
|
|
365
|
+
border: 1px solid rgba(219, 228, 238, 0.88);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.kp-full-page-chat-item {
|
|
369
|
+
display: flex;
|
|
370
|
+
align-items: center;
|
|
371
|
+
justify-content: space-between;
|
|
372
|
+
gap: 10px;
|
|
373
|
+
cursor: pointer;
|
|
374
|
+
transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.kp-full-page-chat-item:hover {
|
|
378
|
+
border-color: rgba(15, 118, 110, 0.34);
|
|
379
|
+
background: rgba(240, 253, 250, 0.95);
|
|
380
|
+
transform: translateY(-1px);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
.kp-full-page-chat-item.active {
|
|
384
|
+
border-color: rgba(15, 118, 110, 0.5);
|
|
385
|
+
background: rgba(220, 252, 231, 0.72);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.kp-full-page-item-title {
|
|
389
|
+
min-width: 0;
|
|
390
|
+
overflow: hidden;
|
|
391
|
+
text-overflow: ellipsis;
|
|
392
|
+
white-space: nowrap;
|
|
393
|
+
flex: 1;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.kp-chat-pin {
|
|
397
|
+
flex: none;
|
|
398
|
+
border: none;
|
|
399
|
+
background: transparent;
|
|
400
|
+
color: #0f6a75;
|
|
401
|
+
font-size: 16px;
|
|
402
|
+
line-height: 1;
|
|
403
|
+
padding: 0;
|
|
404
|
+
cursor: pointer;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.kp-full-page-empty {
|
|
408
|
+
padding: 8px 4px 0;
|
|
409
|
+
color: #7a8a99;
|
|
410
|
+
font-size: 14px;
|
|
411
|
+
line-height: 1.5;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.kp-full-page-item-pinned {
|
|
415
|
+
background: rgba(237, 248, 251, 0.92);
|
|
416
|
+
border-color: rgba(127, 208, 217, 0.4);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.kp-full-page-main {
|
|
420
|
+
min-width: 0;
|
|
421
|
+
min-height: 0;
|
|
422
|
+
display: flex;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.kp-full-page-panel {
|
|
426
|
+
flex: 1;
|
|
427
|
+
display: flex;
|
|
428
|
+
flex-direction: column;
|
|
429
|
+
min-height: 0;
|
|
430
|
+
overflow: hidden;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
.kp-full-page-body {
|
|
434
|
+
flex: 1;
|
|
435
|
+
overflow: auto;
|
|
436
|
+
display: flex;
|
|
437
|
+
flex-direction: column;
|
|
438
|
+
gap: 14px;
|
|
439
|
+
padding: 42px 28px 18px;
|
|
440
|
+
background:
|
|
441
|
+
radial-gradient(circle at top, rgba(54, 196, 220, 0.14), transparent 22%),
|
|
442
|
+
linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
|
|
443
|
+
scroll-behavior: smooth;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
.kp-full-page-body.kp-conversation-active {
|
|
447
|
+
padding-top: 24px;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
.kp-full-page-hero {
|
|
451
|
+
display: flex;
|
|
452
|
+
flex-direction: column;
|
|
453
|
+
align-items: center;
|
|
454
|
+
text-align: center;
|
|
455
|
+
gap: 22px;
|
|
456
|
+
padding: 18px 18px 12px;
|
|
457
|
+
max-width: 880px;
|
|
458
|
+
width: 100%;
|
|
459
|
+
margin: 0 auto;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.kp-full-page-hero-badge {
|
|
463
|
+
width: 140px;
|
|
464
|
+
height: 140px;
|
|
465
|
+
border-radius: 999px;
|
|
466
|
+
display: flex;
|
|
467
|
+
align-items: center;
|
|
468
|
+
justify-content: center;
|
|
469
|
+
background: radial-gradient(circle at 30% 30%, #f8fdff 0%, #edf8ff 50%, #e4eef8 100%);
|
|
470
|
+
box-shadow:
|
|
471
|
+
inset 0 2px 0 rgba(255, 255, 255, 0.9),
|
|
472
|
+
0 22px 40px rgba(15, 23, 42, 0.08);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
.kp-star-cluster-static {
|
|
476
|
+
animation: none;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
.kp-full-page-hero-text {
|
|
480
|
+
max-width: 760px;
|
|
481
|
+
font-size: 26px;
|
|
482
|
+
line-height: 1.5;
|
|
483
|
+
font-weight: 700;
|
|
484
|
+
letter-spacing: -0.03em;
|
|
485
|
+
color: #374151;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
.kp-full-page-suggestions {
|
|
489
|
+
width: min(520px, 100%);
|
|
490
|
+
margin: auto auto 0;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.kp-full-page-footer {
|
|
494
|
+
flex: none;
|
|
495
|
+
padding: 0 16px 18px;
|
|
496
|
+
background: rgba(255, 255, 255, 0.72);
|
|
497
|
+
border-top: 1px solid rgba(219, 228, 238, 0.75);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
.kp-full-page-form {
|
|
501
|
+
max-width: none;
|
|
502
|
+
min-height: 56px;
|
|
503
|
+
border-radius: 16px;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
.kp-full-page-note {
|
|
507
|
+
font-size: 13px;
|
|
508
|
+
margin-top: 10px;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
.kp-header {
|
|
512
|
+
display: flex;
|
|
513
|
+
justify-content: space-between;
|
|
514
|
+
align-items: center;
|
|
515
|
+
gap: 12px;
|
|
516
|
+
padding: 18px 18px 8px;
|
|
517
|
+
background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.kp-toolbar {
|
|
521
|
+
position: relative;
|
|
522
|
+
display: flex;
|
|
523
|
+
align-items: center;
|
|
524
|
+
gap: 8px;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.kp-tool-button {
|
|
528
|
+
width: 36px;
|
|
529
|
+
height: 36px;
|
|
530
|
+
border: none;
|
|
531
|
+
border-radius: 12px;
|
|
532
|
+
background: transparent;
|
|
533
|
+
color: #0f4f68;
|
|
534
|
+
cursor: pointer;
|
|
535
|
+
display: inline-flex;
|
|
536
|
+
align-items: center;
|
|
537
|
+
justify-content: center;
|
|
538
|
+
padding: 0;
|
|
539
|
+
transition: background 140ms ease;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
.kp-tool-button:hover {
|
|
543
|
+
background: rgba(15, 118, 110, 0.08);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
.kp-pencil-icon {
|
|
547
|
+
width: 22px;
|
|
548
|
+
height: 22px;
|
|
549
|
+
position: relative;
|
|
550
|
+
display: inline-block;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
.kp-pencil-icon::before {
|
|
554
|
+
content: "";
|
|
555
|
+
position: absolute;
|
|
556
|
+
width: 14px;
|
|
557
|
+
height: 2.5px;
|
|
558
|
+
background: currentColor;
|
|
559
|
+
border-radius: 999px;
|
|
560
|
+
transform: rotate(-45deg);
|
|
561
|
+
top: 3px;
|
|
562
|
+
right: 1px;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.kp-pencil-icon::after {
|
|
566
|
+
content: "";
|
|
567
|
+
position: absolute;
|
|
568
|
+
left: 2px;
|
|
569
|
+
bottom: 2px;
|
|
570
|
+
width: 11px;
|
|
571
|
+
height: 11px;
|
|
572
|
+
border: 2px solid currentColor;
|
|
573
|
+
border-radius: 4px;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
.kp-chevron {
|
|
577
|
+
font-size: 13px;
|
|
578
|
+
color: #66839a;
|
|
579
|
+
transition: transform 160ms ease;
|
|
580
|
+
margin-left: -2px;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
.kp-menu-trigger.open .kp-chevron {
|
|
584
|
+
transform: rotate(180deg);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
.kp-dropdown {
|
|
588
|
+
position: absolute;
|
|
589
|
+
top: 44px;
|
|
590
|
+
left: 0;
|
|
591
|
+
width: 164px;
|
|
592
|
+
background: #ffffff;
|
|
593
|
+
border: 1px solid rgba(15, 79, 104, 0.12);
|
|
594
|
+
border-radius: 10px;
|
|
595
|
+
box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
|
|
596
|
+
padding: 8px;
|
|
597
|
+
opacity: 0;
|
|
598
|
+
transform: translateY(-6px);
|
|
599
|
+
pointer-events: none;
|
|
600
|
+
transition: opacity 180ms ease, transform 180ms ease;
|
|
601
|
+
z-index: 2;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
.kp-dropdown.open {
|
|
605
|
+
opacity: 1;
|
|
606
|
+
transform: translateY(0);
|
|
607
|
+
pointer-events: auto;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
.kp-dropdown-item {
|
|
611
|
+
width: 100%;
|
|
612
|
+
border: none;
|
|
613
|
+
background: transparent;
|
|
614
|
+
text-align: left;
|
|
615
|
+
padding: 10px 12px;
|
|
616
|
+
border-radius: 8px;
|
|
617
|
+
font-size: 14px;
|
|
618
|
+
color: var(--kp-text);
|
|
619
|
+
cursor: pointer;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
.kp-dropdown-item:hover {
|
|
623
|
+
background: rgba(15, 118, 110, 0.08);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
.kp-title-wrap {
|
|
627
|
+
display: none;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
.kp-close {
|
|
631
|
+
border: none;
|
|
632
|
+
background: transparent;
|
|
633
|
+
font-size: 24px;
|
|
634
|
+
line-height: 1;
|
|
635
|
+
color: var(--kp-muted-text);
|
|
636
|
+
cursor: pointer;
|
|
637
|
+
padding: 0;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
.kp-body {
|
|
641
|
+
flex: 1;
|
|
642
|
+
overflow: auto;
|
|
643
|
+
display: flex;
|
|
644
|
+
flex-direction: column;
|
|
645
|
+
gap: 12px;
|
|
646
|
+
padding: 10px 16px 16px;
|
|
647
|
+
background: linear-gradient(180deg, #ffffff 0%, var(--kp-surface-background) 100%);
|
|
648
|
+
scroll-behavior: smooth;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
.kp-body.kp-conversation-active {
|
|
652
|
+
padding-top: 16px;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
.kp-hero {
|
|
656
|
+
display: flex;
|
|
657
|
+
gap: 10px;
|
|
658
|
+
padding: 4px 2px 8px;
|
|
659
|
+
align-items: flex-start;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
.kp-hero-icon {
|
|
663
|
+
color: #0ea5b7;
|
|
664
|
+
font-size: 28px;
|
|
665
|
+
line-height: 1;
|
|
666
|
+
margin-top: 2px;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
.kp-hero-text {
|
|
670
|
+
font-size: 20px;
|
|
671
|
+
line-height: 1.45;
|
|
672
|
+
font-weight: 700;
|
|
673
|
+
color: #374151;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
.kp-bubble {
|
|
677
|
+
max-width: 85%;
|
|
678
|
+
padding: 12px 14px;
|
|
679
|
+
border-radius: 18px;
|
|
680
|
+
font-size: 14px;
|
|
681
|
+
line-height: 1.5;
|
|
682
|
+
white-space: pre-wrap;
|
|
683
|
+
border: 1px solid var(--kp-border-color);
|
|
684
|
+
background: #ffffff;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
.kp-bubble.user {
|
|
688
|
+
align-self: flex-end;
|
|
689
|
+
background: var(--kp-accent-soft);
|
|
690
|
+
border-color: rgba(15, 118, 110, 0.22);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
.kp-bubble.bot {
|
|
694
|
+
align-self: flex-start;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
.kp-meta {
|
|
698
|
+
font-size: 11px;
|
|
699
|
+
line-height: 1.4;
|
|
700
|
+
color: var(--kp-muted-text);
|
|
701
|
+
margin-top: 6px;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
.kp-suggestions {
|
|
705
|
+
display: flex;
|
|
706
|
+
flex-direction: column;
|
|
707
|
+
gap: 10px;
|
|
708
|
+
margin-top: auto;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
.kp-suggestion {
|
|
712
|
+
border: 1px solid rgba(15, 118, 110, 0.18);
|
|
713
|
+
background: rgba(247, 251, 255, 0.92);
|
|
714
|
+
color: var(--kp-text);
|
|
715
|
+
border-radius: 999px;
|
|
716
|
+
padding: 11px 14px;
|
|
717
|
+
cursor: pointer;
|
|
718
|
+
text-align: left;
|
|
719
|
+
font-size: 14px;
|
|
720
|
+
line-height: 1.35;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
.kp-footer {
|
|
724
|
+
padding: 10px 16px 12px;
|
|
725
|
+
border-top: 1px solid rgba(219, 228, 238, 0.85);
|
|
726
|
+
background: #ffffff;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
.kp-form {
|
|
730
|
+
display: flex;
|
|
731
|
+
align-items: center;
|
|
732
|
+
gap: 10px;
|
|
733
|
+
border: 1px solid var(--kp-border-color);
|
|
734
|
+
border-radius: 14px;
|
|
735
|
+
padding: 10px 12px;
|
|
736
|
+
background: #ffffff;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
.kp-input {
|
|
740
|
+
flex: 1;
|
|
741
|
+
border: none;
|
|
742
|
+
outline: none;
|
|
743
|
+
box-shadow: none;
|
|
744
|
+
background: transparent;
|
|
745
|
+
color: var(--kp-text);
|
|
746
|
+
font-size: 14px;
|
|
747
|
+
line-height: 1.5;
|
|
748
|
+
min-width: 0;
|
|
749
|
+
appearance: none;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
.kp-input:focus,
|
|
753
|
+
.kp-input:focus-visible,
|
|
754
|
+
.kp-input:active {
|
|
755
|
+
border: none;
|
|
756
|
+
outline: none;
|
|
757
|
+
box-shadow: none;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
.kp-send {
|
|
761
|
+
width: 40px;
|
|
762
|
+
height: 40px;
|
|
763
|
+
border: none;
|
|
764
|
+
border-radius: 999px;
|
|
765
|
+
background: #e4f1f8;
|
|
766
|
+
color: var(--kp-accent);
|
|
767
|
+
cursor: pointer;
|
|
768
|
+
font-size: 20px;
|
|
769
|
+
line-height: 1;
|
|
770
|
+
display: flex;
|
|
771
|
+
align-items: center;
|
|
772
|
+
justify-content: center;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
.kp-note {
|
|
776
|
+
margin-top: 8px;
|
|
777
|
+
text-align: center;
|
|
778
|
+
font-size: 11px;
|
|
779
|
+
line-height: 1.4;
|
|
780
|
+
color: var(--kp-muted-text);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
.kp-loading {
|
|
784
|
+
font-size: 13px;
|
|
785
|
+
line-height: 1.4;
|
|
786
|
+
color: var(--kp-muted-text);
|
|
787
|
+
padding: 4px 2px;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
@media (max-width: 640px) {
|
|
791
|
+
.kp-chat-widget,
|
|
792
|
+
.kp-chat-widget.bottom-left {
|
|
793
|
+
left: auto;
|
|
794
|
+
right: 16px;
|
|
795
|
+
bottom: 16px;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
.kp-panel,
|
|
799
|
+
.kp-chat-widget.bottom-left .kp-panel {
|
|
800
|
+
inset: 0;
|
|
801
|
+
width: 100vw;
|
|
802
|
+
max-width: none;
|
|
803
|
+
height: 100vh;
|
|
804
|
+
border-radius: 0;
|
|
805
|
+
transform: translateX(72px) scale(0.985);
|
|
806
|
+
transform-origin: center right;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
.kp-panel.open {
|
|
810
|
+
transform: translateX(0) scale(1);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
.kp-full-page-shell {
|
|
814
|
+
padding: 14px;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
.kp-full-page-header {
|
|
818
|
+
padding: 0;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
.kp-full-page-content {
|
|
822
|
+
grid-template-columns: 1fr;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
.kp-full-page-sidebar {
|
|
826
|
+
order: 2;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
.kp-full-page-body {
|
|
830
|
+
padding: 24px 16px 16px;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
.kp-full-page-hero-badge {
|
|
834
|
+
width: 112px;
|
|
835
|
+
height: 112px;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
.kp-full-page-hero-text {
|
|
839
|
+
font-size: 22px;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
@keyframes kp-cluster-rotate {
|
|
844
|
+
from { transform: rotate(0deg); }
|
|
845
|
+
to { transform: rotate(360deg); }
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
@keyframes kp-main-pulse {
|
|
849
|
+
0%, 100% { transform: translate(-50%, -50%) scale(0.82); opacity: 0.45; }
|
|
850
|
+
38% { transform: translate(-50%, -50%) scale(1.04); opacity: 1; }
|
|
851
|
+
60% { transform: translate(-50%, -50%) scale(0.94); opacity: 0.88; }
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
@keyframes kp-orbit-a {
|
|
855
|
+
0%, 100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
|
|
856
|
+
40% { transform: translate(-50%, 17px) scale(0.92); opacity: 0.96; }
|
|
857
|
+
62% { transform: translate(-50%, 2px) scale(1); opacity: 0.98; }
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
@keyframes kp-orbit-b {
|
|
861
|
+
0%, 100% { transform: translate(0, 0) scale(1); opacity: 1; }
|
|
862
|
+
40% { transform: translate(-16px, -13px) scale(0.92); opacity: 0.96; }
|
|
863
|
+
62% { transform: translate(-2px, -2px) scale(1); opacity: 0.98; }
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
@keyframes kp-orbit-c {
|
|
867
|
+
0%, 100% { transform: translate(0, 0) scale(1); opacity: 1; }
|
|
868
|
+
40% { transform: translate(16px, -13px) scale(0.92); opacity: 0.96; }
|
|
869
|
+
62% { transform: translate(2px, -2px) scale(1); opacity: 0.98; }
|
|
870
|
+
}
|
|
871
|
+
`}function qe(e){if(typeof document>"u")throw new Error("Chat widget can only be initialized in a browser.");let t=$e(e),n={chatId:de(t),open:!1,fullPageOpen:!1,accessTokenProvider:t.getAccessToken,historyLoadedChatId:null,menuOpen:!1,chats:[],chatSearchTerm:"",loadingChats:!1},s=document.createElement("div");s.dataset.chatWidgetHost="true",t.mount.appendChild(s);let i=s.attachShadow({mode:"open"});De(i,t.theme);let l=o("div",`kp-chat-widget ${t.position}`),r=o("div","kp-overlay"),u=o("button","kp-launcher");u.type="button",u.setAttribute("aria-label",t.launcherAriaLabel),u.innerHTML=['<span class="kp-star-cluster" aria-hidden="true">','<span class="kp-star orbit-a">\u2726</span>','<span class="kp-star orbit-b">\u2726</span>','<span class="kp-star orbit-c">\u2726</span>','<span class="kp-star main">\u2726</span>',"</span>"].join("");let p=o("section","kp-panel");p.setAttribute("role","dialog"),p.setAttribute("aria-modal","true"),p.setAttribute("aria-label",t.title);let c=o("div","kp-header"),f=o("div","kp-toolbar"),g=o("button","kp-tool-button kp-menu-trigger");g.type="button",g.setAttribute("aria-label","Open chat actions"),g.innerHTML=['<span class="kp-pencil-icon" aria-hidden="true"></span>','<span class="kp-chevron" aria-hidden="true">\u2304</span>'].join("");let m=o("div","kp-dropdown"),z=o("button","kp-dropdown-item","New Chat");z.type="button";let W=o("button","kp-dropdown-item","My Chats");W.type="button";let N=o("button","kp-dropdown-item","Open Knowledge Assistant");N.type="button",m.append(z,W,N),f.append(g,m);let K=o("div","kp-title-wrap"),J=o("h2","kp-title",t.title),G=o("div","kp-subtitle",t.subtitle);K.append(J,G);let b=o("button","kp-close","\xD7");b.type="button",b.setAttribute("aria-label",t.closeAriaLabel),c.append(f,K,b);let F=o("div","kp-body"),Q=o("div","kp-hero"),Fe=o("div","kp-hero-icon","\u2726"),Xe=o("div","kp-hero-text",t.welcomeMessage);Q.append(Fe,Xe);let ue=o("div","kp-footer"),Z=o("form","kp-form"),I=o("input","kp-input");I.type="text",I.autocomplete="off",I.placeholder=t.inputPlaceholder;let ge=o("button","kp-send","\u279C");ge.type="submit";let Ye=o("div","kp-note","Auth token is forwarded from the host app when configured.");Z.append(I,ge),ue.append(Z,Ye),p.append(c,F,ue),l.append(r,u,p),i.appendChild(l),F.appendChild(Q);let fe=o("div","kp-suggestions");F.appendChild(fe);let A={body:F,input:I,suggestions:fe,hero:Q},x=o("section","kp-full-page");x.setAttribute("role","dialog"),x.setAttribute("aria-modal","true"),x.setAttribute("aria-label",`${t.title} page`);let he=o("div","kp-full-page-shell"),me=o("div","kp-full-page-header"),be=o("div","kp-full-page-brand"),Je=o("div","kp-full-page-brand-mark","\u2726"),Ge=o("div","kp-full-page-brand-text",t.title);be.append(Je,Ge);let ke=o("div","kp-full-page-header-actions"),Qe=o("div","kp-full-page-badge","Knowledge Assistant"),X=o("button","kp-full-page-close","\xD7");X.type="button",X.setAttribute("aria-label","Close knowledge assistant page"),ke.append(Qe,X),me.append(be,ke);let Ze=o("div","kp-full-page-breadcrumb","Home \u203A Knowledge Assistant"),xe=o("div","kp-full-page-content"),ye=o("aside","kp-full-page-sidebar"),ee=o("button","kp-full-page-new-chat","+ New Chat");ee.type="button";let ve=o("div","kp-full-page-search"),O=o("input","kp-full-page-search-input");O.type="search",O.placeholder="Search Chat";let et=o("span","kp-full-page-search-icon","\u2315");ve.append(O,et);let tt=o("div","kp-full-page-section-label","Recent Activity"),y=o("div","kp-full-page-recent-list"),nt=o("div","kp-full-page-section-label","Pinned Collections"),v=o("div","kp-full-page-pinned-list");ye.append(ee,ve,tt,y,nt,v);let we=o("main","kp-full-page-main"),Ce=o("section","kp-full-page-panel"),te=o("div","kp-full-page-body"),ne=o("div","kp-full-page-hero"),Le=o("div","kp-full-page-hero-badge");Le.innerHTML=['<span class="kp-star-cluster kp-star-cluster-static" aria-hidden="true">','<span class="kp-star orbit-a">\u2726</span>','<span class="kp-star orbit-b">\u2726</span>','<span class="kp-star orbit-c">\u2726</span>','<span class="kp-star main">\u2726</span>',"</span>"].join("");let at=o("div","kp-full-page-hero-text",t.welcomeMessage);ne.append(Le,at);let Pe=o("div","kp-suggestions kp-full-page-suggestions");te.append(ne,Pe);let Ie=o("div","kp-full-page-footer"),ae=o("form","kp-form kp-full-page-form"),w=o("input","kp-input kp-full-page-input");w.type="text",w.autocomplete="off",w.placeholder=t.inputPlaceholder;let Ae=o("button","kp-send kp-full-page-send","\u279C");Ae.type="submit";let ot=o("div","kp-note kp-full-page-note","Answers are generated based on your access permissions");ae.append(w,Ae),Ie.append(ae,ot),Ce.append(te,Ie),we.appendChild(Ce),xe.append(ye,we),he.append(me,Ze,xe),x.appendChild(he),l.appendChild(x);let k={body:te,input:w,suggestions:Pe,hero:ne},U=()=>({...t,getAccessToken:n.accessTokenProvider});S(A,t.initialSuggestions,async a=>{await C(a,A)}),S(k,t.initialSuggestions,async a=>{await C(a,k)}),R(y,v,n,async a=>{await E(a.chatId)},async a=>{await H(a)});function Te(){n.open||(n.open=!0,n.fullPageOpen=!1,x.classList.remove("open"),u.classList.add("hidden"),r.classList.add("visible"),p.classList.add("open"),t.onOpen?.(),t.rag.loadHistoryOnOpen&&se.loadHistory(),queueMicrotask(()=>I.focus()))}function B(){n.open&&(T(),n.open=!1,u.classList.remove("hidden"),r.classList.remove("visible"),p.classList.remove("open"),t.onClose?.())}async function C(a,d){let L=a.trim();if(!L)return;d.input.value="";try{await pt(L)}catch(P){let $=j(t,P);q(d.body,"bot",`Unable to create chat: ${$.message}`);return}_e(d),q(d.body,"user",L),d.body.scrollTop=d.body.scrollHeight;let M=o("div","kp-loading","Thinking...");d.body.appendChild(M),d.body.scrollTop=d.body.scrollHeight;try{let P=await We(U(),{message:L,chatId:n.chatId,knowledgeNames:await mt(t),...t.rag.enableReferences!==void 0?{enableReferences:t.rag.enableReferences}:{}});M.isConnected&&M.remove(),q(d.body,"bot",P.answer,P.citations?.length),n.historyLoadedChatId=null,await Y(),P.suggestions?.length&&S(d,P.suggestions,async $=>{await C($,d)})}catch(P){let $=j(t,P);M.isConnected&&M.remove(),q(d.body,"bot",`Request failed: ${$.message}`)}}async function Ee(a){let d=n.fullPageOpen?k:A;await C(a,d)}async function He(){n.fullPageOpen=!0,n.open=!1,T(),p.classList.remove("open"),r.classList.remove("visible"),u.classList.add("hidden"),x.classList.add("open"),await Y(),await oe(k,n.chatId),queueMicrotask(()=>w.focus())}function Me(){n.fullPageOpen&&(n.fullPageOpen=!1,x.classList.remove("open"),u.classList.remove("hidden"))}function st(){n.menuOpen=!0,g.classList.add("open"),m.classList.add("open")}function T(){n.menuOpen=!1,g.classList.remove("open"),m.classList.remove("open")}function rt(){n.chatId=de(t),n.historyLoadedChatId=null,ce(A),S(A,t.initialSuggestions,async a=>{await C(a,A)}),T()}async function it(){n.chatId=de(t),n.historyLoadedChatId=null,ce(k),S(k,t.initialSuggestions,async a=>{await C(a,k)}),R(y,v,n,async a=>{await E(a.chatId)},async a=>{await H(a)})}async function Y(){if(!t.endpoints.listChats)return R(y,v,n,async a=>{await E(a.chatId)},async a=>{await H(a)}),[];n.loadingChats=!0,R(y,v,n,async a=>{await E(a.chatId)},async a=>{await H(a)});try{let a=await Oe(U());return n.chats=a,a}catch(a){return j(t,a),n.chats}finally{n.loadingChats=!1,R(y,v,n,async a=>{await E(a.chatId)},async a=>{await H(a)})}}async function pt(a){!t.endpoints.listChats&&!t.endpoints.createChat||n.chats.some(d=>d.chatId===n.chatId)||await Ue(U(),n.chatId,a?xt(a):void 0)}async function E(a){n.chatId=a,n.historyLoadedChatId=null,await oe(k,a),R(y,v,n,async d=>{await E(d.chatId)},async d=>{await H(d)})}async function H(a){if(t.endpoints.updateChat)try{await Be(U(),a.chatId,{pinned:!a.pinned}),await Y()}catch(d){j(t,d)}}async function oe(a,d){ce(a),S(a,t.initialSuggestions,async M=>{await C(M,a)});let L=await Ne(U(),d);return L.length>0&&(_e(a),Ke(a.body,a.hero,a.suggestions),kt(a.body,L)),n.historyLoadedChatId=d,L}let se={open:Te,close:B,toggle(){if(n.open){B();return}Te()},destroy(){document.removeEventListener("keydown",Re),s.remove()},sendMessage:Ee,setAccessTokenProvider(a){n.accessTokenProvider=a},getChatId(){return n.chatId},loadChats(){return Y()},async loadHistory(){let a=n.fullPageOpen?k:A;return oe(a,n.chatId)}};u.addEventListener("click",()=>se.toggle()),b.addEventListener("click",B),r.addEventListener("click",B),g.addEventListener("click",a=>{if(a.stopPropagation(),!n.menuOpen){st();return}T()}),z.addEventListener("click",rt),W.addEventListener("click",async()=>{T(),await He()}),N.addEventListener("click",()=>{He()}),X.addEventListener("click",Me),ee.addEventListener("click",()=>{it(),queueMicrotask(()=>w.focus())}),O.addEventListener("input",()=>{n.chatSearchTerm=O.value.trim().toLowerCase(),R(y,v,n,async a=>{await E(a.chatId)},async a=>{await H(a)})}),p.addEventListener("click",a=>{n.menuOpen&&!m.contains(a.target)&&!g.contains(a.target)&&T(),a.stopPropagation()}),i.addEventListener("click",a=>{let d=a.target;n.menuOpen&&d instanceof Node&&!m.contains(d)&&!g.contains(d)&&T()}),Z.addEventListener("submit",async a=>{a.preventDefault(),await Ee(I.value)}),ae.addEventListener("submit",async a=>{a.preventDefault(),await C(w.value,k)});function Re(a){if(a.key==="Escape"){if(n.fullPageOpen){Me();return}n.open&&B()}}return document.addEventListener("keydown",Re),se}async function mt(e){if(e.rag.getKnowledgeNames){let t=await e.rag.getKnowledgeNames();return Array.isArray(t)?t.filter(Boolean):[]}return(e.rag.knowledgeNames??[]).filter(Boolean)}function de(e){return e.rag.chatId?.trim()?e.rag.chatId:e.rag.chatIdFactory?e.rag.chatIdFactory():typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`kp-chat-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function q(e,t,n,s){let i=o("div",`kp-bubble ${t}`,n);if(s){let l=o("div","kp-meta",`${s} citation${s>1?"s":""} attached`);i.appendChild(l)}return e.appendChild(i),e.scrollTop=e.scrollHeight,i}function bt(e,t,n){e.textContent="";for(let s of t){let i=o("button","kp-suggestion",s);i.type="button",i.addEventListener("click",async()=>{await n(s)}),e.appendChild(i)}}function S(e,t,n){bt(e.suggestions,t,async s=>{e.input.value=s,await n(s)})}function Ke(e,t,n){let s=new Set([t,n]);for(let i of Array.from(e.children))s.has(i)||i.remove()}function _e(e){e.body.classList.add("kp-conversation-active"),e.hero.remove(),e.suggestions.remove()}function ce(e){e.body.classList.remove("kp-conversation-active"),e.hero.isConnected||e.body.prepend(e.hero),e.suggestions.isConnected||e.body.appendChild(e.suggestions),Ke(e.body,e.hero,e.suggestions),e.input.value=""}function kt(e,t){for(let n of t)q(e,n.role==="assistant"?"bot":"user",n.text)}function R(e,t,n,s,i){if(e.textContent="",t.textContent="",n.loadingChats){e.appendChild(o("div","kp-full-page-empty","Loading chats..."));return}let l=n.chats.filter(r=>n.chatSearchTerm?r.title.toLowerCase().includes(n.chatSearchTerm):!0);if(l.length>0){let r=l.filter(p=>p.pinned),u=l.filter(p=>!p.pinned).slice(0,8);je(e,u,n.chatId,s,i),je(t,r,n.chatId,s,i),u.length===0&&e.appendChild(o("div","kp-full-page-empty","No recent chats yet.")),r.length===0&&t.appendChild(o("div","kp-full-page-empty","No pinned chats yet."));return}e.appendChild(o("div","kp-full-page-empty","No chats yet.")),t.appendChild(o("div","kp-full-page-empty","No pinned chats yet."))}function je(e,t,n,s,i){for(let l of t){let r=o("div",`kp-full-page-item kp-full-page-chat-item${l.chatId===n?" active":""}`),u=o("span","kp-full-page-item-title",l.title),p=o("button","kp-chat-pin",l.pinned?"\u2605":"\u2606");p.type="button",p.setAttribute("aria-label",l.pinned?"Unpin chat":"Pin chat"),p.addEventListener("click",async c=>{c.stopPropagation(),await i(l)}),r.append(u,p),r.setAttribute("role","button"),r.tabIndex=0,r.addEventListener("click",async()=>{await s(l)}),r.addEventListener("keydown",async c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),await s(l))}),e.appendChild(r)}}function xt(e){return e.trim().slice(0,60)||"New Chat"}return ft(yt);})();
|
|
872
|
+
//# sourceMappingURL=index.iife.js.map
|