@nabeh/chat-widget 0.1.3 → 0.1.4

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.
@@ -0,0 +1,1885 @@
1
+ function ht(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Re(e,t){let o={...e};for(let n of Object.keys(t)){let r=t[n],l=o[n];if(ht(l)&&ht(r)){o[n]=Re(l,r);continue}r!==void 0&&(o[n]=r)}return o}function mt(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error("Unexpected widget error")}function ae(e,t){return`${e.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}function X(e,t,o){return{"Content-Type":"application/json",...e.customHeaders,...o?{"X-Chat-User-Context":o}:{},...t?{Authorization:`Bearer ${t}`}:{}}}async function J(e){if(!e.getUserContext)return null;let t=await e.getUserContext();return t?JSON.stringify(t):null}function me(e,t,o={}){let n=t.replace(/\{chatId\}/g,encodeURIComponent(o.chatId??"")).replace(/:chatId\b/g,encodeURIComponent(o.chatId??""));return ae(e.apiBaseUrl,n)}async function bt(e,t){let o=e.getAccessToken?await e.getAccessToken():null,n=await J(e),r=me(e,e.endpoints.ask,{chatId:t.chatId}),i=/(\{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},p=await fetch(r,{method:"POST",headers:X(e,o,n),body:JSON.stringify(i)});if(!p.ok)throw new Error(`Chat backend returned ${p.status}.`);let c=await p.json();if(!Array.isArray(c)){if(!c.answer||typeof c.answer!="string")throw new Error("Chat backend response is missing a valid answer.");return{chatId:c.chatId??t.chatId,answer:c.answer,suggestions:c.suggestions??[],citations:c.citations??[]}}let u=c[0];if(!u?.answer||typeof u.answer!="string")throw new Error("Chat backend response is missing a valid answer.");let g=u.content,f=g?.source_documents??[],h=g?.scores??[],v=g?.page_numbers??[],P=g?.sheet_names??[],b=g?.row_numbers??[],y=g?.knowledge_names??[],x=f.map((U,w)=>({sourceDocument:U,score:h[w]??null,pageNumber:v[w]??null,sheetName:P[w]??null,rowNumber:b[w]??null,knowledgeName:y[w]??null}));return{chatId:t.chatId,answer:u.answer,suggestions:[],citations:x}}async function xt(e,t){if(!e.endpoints.history)return[];let o=e.getAccessToken?await e.getAccessToken():null,n=await J(e),l=/(\{chatId\}|:chatId\b)/.test(e.endpoints.history)?me(e,e.endpoints.history,{chatId:t}):(()=>{let u=new URL(ae(e.apiBaseUrl,e.endpoints.history));return u.searchParams.set("chat_id",t),u.toString()})(),i=await fetch(l,{method:"GET",headers:X(e,o,n)});if(!i.ok)throw new Error(`Chat history endpoint returned ${i.status}.`);let p=await i.json(),c=Array.isArray(p)?p:p&&typeof p=="object"?p.history??p.messages??p.data??[]:[];return Array.isArray(c)?c.map(u=>{if(!u||typeof u!="object")return null;let g=u;if(typeof g.question=="string"&&typeof g.answer=="string")return[{role:"user",text:g.question},{role:"assistant",text:g.answer}];let f=g.role??g.type??g.sender??g.author,h=g.text??g.message??g.content??g.answer;if(typeof h!="string")return null;let v=typeof f=="string"?f.toLowerCase():"assistant";return[{role:v==="user"||v==="human"?"user":"assistant",text:h}]}).flat().filter(u=>!!u):[]}async function kt(e){if(!e.endpoints.listChats)return[];let t=e.getAccessToken?await e.getAccessToken():null,o=await J(e),n=await fetch(ae(e.apiBaseUrl,e.endpoints.listChats),{method:"GET",headers:X(e,t,o)});if(!n.ok)throw new Error(`Chat list endpoint returned ${n.status}.`);let r=await n.json(),l=Array.isArray(r)?r:r&&typeof r=="object"?r.chats??r.data??r.items??[]:[];return Array.isArray(l)?l.map(i=>{if(!i||typeof i!="object")return null;let p=i,c=p.chatId??p.chat_id??p.id,u=p.title??p.name??p.chatId;if(typeof c!="string"||typeof u!="string")return null;let g=typeof p.createdAt=="string"?p.createdAt:typeof p.created_at=="string"?p.created_at:null,f=typeof p.updatedAt=="string"?p.updatedAt:typeof p.updated_at=="string"?p.updated_at:null,h={chatId:c,title:u,pinned:typeof p.pinned=="boolean"?p.pinned:!1};return g&&(h.createdAt=g),f&&(h.updatedAt=f),h}).filter(i=>!!i):[]}async function yt(e,t,o){let n=e.endpoints.createChat??e.endpoints.listChats;if(!n)return;let r=e.getAccessToken?await e.getAccessToken():null,l=await J(e),i=await fetch(ae(e.apiBaseUrl,n),{method:"POST",headers:X(e,r,l),body:JSON.stringify({chatId:t,...o?{title:o}:{}})});if(!i.ok)throw new Error(`Create chat endpoint returned ${i.status}.`)}async function Ie(e,t,o){if(!e.endpoints.updateChat)return;let n=e.getAccessToken?await e.getAccessToken():null,r=await J(e),l=me(e,e.endpoints.updateChat,{chatId:t}),i=await fetch(l,{method:"PATCH",headers:X(e,n,r),body:JSON.stringify(o)});if(!i.ok)throw new Error(`Update chat endpoint returned ${i.status}.`)}async function vt(e,t){if(!e.endpoints.deleteChat)return;let o=e.getAccessToken?await e.getAccessToken():null,n=await J(e),r=me(e,e.endpoints.deleteChat,{chatId:t}),l=await fetch(r,{method:"DELETE",headers:X(e,o,n)});if(!l.ok)throw new Error(`Delete chat endpoint returned ${l.status}.`)}function V(e,t){let o=mt(t);return e.onError?.(o),o}var ze={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'},k={displayMode:"widget",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:{},assistantPageUrl:"/knowledge-assistant",embedded:{showHeader:!1},rag:{knowledgeNames:[],enableReferences:!0,loadHistoryOnOpen:!1},theme:ze,getAccessToken:void 0,getUserContext:void 0,onOpen:void 0,onClose:void 0,onError:void 0,onOpenAssistantPage:void 0};function wt(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,o=Re(ze,e.theme??{});return{apiBaseUrl:e.apiBaseUrl,endpoints:{...e.endpoints},mount:t,displayMode:e.displayMode??k.displayMode,position:e.position??k.position,title:e.title??k.title,subtitle:e.subtitle??k.subtitle,welcomeMessage:e.welcomeMessage??k.welcomeMessage,inputPlaceholder:e.inputPlaceholder??k.inputPlaceholder,launcherAriaLabel:e.launcherAriaLabel??k.launcherAriaLabel,closeAriaLabel:e.closeAriaLabel??k.closeAriaLabel,initialSuggestions:e.initialSuggestions??k.initialSuggestions,sourceApp:e.sourceApp??k.sourceApp,locale:e.locale??k.locale,customHeaders:e.customHeaders??k.customHeaders,embedded:{...k.embedded,...e.embedded??{}},rag:{...k.rag,...e.rag??{}},assistantPageUrl:e.assistantPageUrl??k.assistantPageUrl,theme:o,getAccessToken:e.getAccessToken,getUserContext:e.getUserContext,onOpen:e.onOpen,onClose:e.onClose,onError:e.onError,onOpenAssistantPage:e.onOpenAssistantPage}}function a(e,t,o){let n=document.createElement(e);return t&&(n.className=t),o!==void 0&&(n.textContent=o),n}var Ct="kp-chat-widget-styles";function Lt(e,t){if(e.getElementById(Ct))return;let o=document.createElement("style");o.id=Ct,o.textContent=cn(t),e.appendChild(o)}function cn(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
+ --kp-card-background: rgba(255, 255, 255, 0.92);
18
+ --kp-soft-highlight: rgba(236, 254, 255, 0.82);
19
+ position: fixed;
20
+ bottom: 24px;
21
+ right: 24px;
22
+ z-index: var(--kp-z-index);
23
+ font-family: var(--kp-font-family);
24
+ color: var(--kp-text);
25
+ box-sizing: border-box;
26
+ }
27
+
28
+ .kp-chat-widget.kp-chat-widget-embedded {
29
+ position: relative;
30
+ inset: auto;
31
+ width: 100%;
32
+ height: 100%;
33
+ min-height: 640px;
34
+ display: block;
35
+ }
36
+
37
+ *,
38
+ *::before,
39
+ *::after {
40
+ box-sizing: border-box;
41
+ font-family: inherit;
42
+ }
43
+
44
+ .kp-chat-widget.bottom-left {
45
+ left: 24px;
46
+ right: auto;
47
+ }
48
+
49
+ .kp-chat-widget.kp-chat-widget-embedded.bottom-left {
50
+ left: auto;
51
+ right: auto;
52
+ }
53
+
54
+ .kp-rtl .kp-dropdown-item,
55
+ .kp-rtl .kp-suggestion,
56
+ .kp-rtl .kp-input,
57
+ .kp-rtl .kp-full-page-search-input,
58
+ .kp-rtl .kp-bubble-content,
59
+ .kp-rtl .kp-source-card,
60
+ .kp-rtl .kp-source-panel {
61
+ text-align: right;
62
+ }
63
+
64
+ .kp-launcher {
65
+ width: 72px;
66
+ height: 72px;
67
+ border: none;
68
+ border-radius: 999px;
69
+ cursor: pointer;
70
+ background: radial-gradient(circle at 30% 30%, #f8fffe 0%, #ecfdf5 52%, #d6f4ef 100%);
71
+ box-shadow: 0 16px 32px rgba(15, 118, 110, 0.18);
72
+ display: flex;
73
+ align-items: center;
74
+ justify-content: center;
75
+ transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
76
+ color: var(--kp-accent);
77
+ position: relative;
78
+ overflow: hidden;
79
+ }
80
+
81
+ .kp-launcher:hover {
82
+ transform: translateY(-1px);
83
+ box-shadow: 0 20px 36px rgba(15, 118, 110, 0.22);
84
+ }
85
+
86
+ .kp-launcher:focus-visible,
87
+ .kp-close:focus-visible,
88
+ .kp-send:focus-visible,
89
+ .kp-suggestion:focus-visible,
90
+ .kp-input:focus-visible,
91
+ .kp-full-page-new-chat:focus-visible,
92
+ .kp-full-page-close:focus-visible,
93
+ .kp-full-page-chat-item:focus-visible,
94
+ .kp-chat-pin:focus-visible,
95
+ .kp-message-action:focus-visible,
96
+ .kp-source-chip:focus-visible,
97
+ .kp-source-panel-close:focus-visible {
98
+ outline: 2px solid var(--kp-accent);
99
+ outline-offset: 2px;
100
+ }
101
+
102
+ .kp-launcher.hidden {
103
+ opacity: 0;
104
+ pointer-events: none;
105
+ transform: translateY(8px) scale(0.96);
106
+ }
107
+
108
+ .kp-star-cluster {
109
+ position: relative;
110
+ width: 50px;
111
+ height: 50px;
112
+ animation: kp-cluster-rotate 8.5s linear infinite;
113
+ }
114
+
115
+ .kp-star {
116
+ position: absolute;
117
+ color: #08384c;
118
+ line-height: 1;
119
+ transform-origin: center;
120
+ }
121
+
122
+ .kp-star.main {
123
+ top: 50%;
124
+ left: 50%;
125
+ font-size: 30px;
126
+ transform: translate(-50%, -50%) scale(0.96);
127
+ animation: kp-main-pulse 3s ease-in-out infinite;
128
+ }
129
+
130
+ .kp-star.orbit-a {
131
+ top: -3px;
132
+ left: 50%;
133
+ font-size: 18px;
134
+ transform: translateX(-50%);
135
+ animation: kp-orbit-a 3s ease-in-out infinite;
136
+ }
137
+
138
+ .kp-star.orbit-b {
139
+ right: -3px;
140
+ bottom: 5px;
141
+ font-size: 18px;
142
+ animation: kp-orbit-b 3s ease-in-out infinite;
143
+ }
144
+
145
+ .kp-star.orbit-c {
146
+ left: -1px;
147
+ bottom: 5px;
148
+ font-size: 18px;
149
+ animation: kp-orbit-c 3s ease-in-out infinite;
150
+ }
151
+
152
+ .kp-overlay {
153
+ position: fixed;
154
+ inset: 0;
155
+ background: rgba(15, 23, 42, 0.18);
156
+ opacity: 0;
157
+ pointer-events: none;
158
+ transition: opacity 220ms ease;
159
+ }
160
+
161
+ .kp-overlay.visible {
162
+ opacity: 1;
163
+ pointer-events: auto;
164
+ }
165
+
166
+ .kp-panel {
167
+ position: fixed;
168
+ bottom: 88px;
169
+ right: 24px;
170
+ width: min(480px, calc(100vw - 48px));
171
+ height: min(730px, calc(100vh - 118px));
172
+ background: var(--kp-panel-background);
173
+ border: 1px solid rgba(255, 255, 255, 0.35);
174
+ border-radius: 24px;
175
+ box-shadow: var(--kp-shadow);
176
+ overflow: hidden;
177
+ display: flex;
178
+ flex-direction: column;
179
+ opacity: 0;
180
+ transform: translateX(112px) scale(0.97);
181
+ transform-origin: bottom right;
182
+ pointer-events: none;
183
+ transition: opacity 420ms cubic-bezier(0.16, 1, 0.3, 1),
184
+ transform 620ms cubic-bezier(0.16, 1, 0.3, 1);
185
+ }
186
+
187
+ .kp-chat-widget.bottom-left .kp-panel {
188
+ left: 24px;
189
+ right: auto;
190
+ transform: translateX(-112px) scale(0.97);
191
+ transform-origin: bottom left;
192
+ }
193
+
194
+ .kp-panel.open {
195
+ opacity: 1;
196
+ transform: translateX(0) scale(1);
197
+ pointer-events: auto;
198
+ }
199
+
200
+ .kp-full-page {
201
+ position: fixed;
202
+ inset: 0;
203
+ background: #ffffff;
204
+ opacity: 0;
205
+ pointer-events: none;
206
+ transform: translateY(18px);
207
+ transition: opacity 260ms ease, transform 320ms ease;
208
+ z-index: calc(var(--kp-z-index) + 2);
209
+ overflow: hidden;
210
+ }
211
+
212
+ .kp-full-page.kp-full-page-embedded {
213
+ position: relative;
214
+ inset: auto;
215
+ opacity: 1;
216
+ pointer-events: auto;
217
+ transform: none;
218
+ min-height: 100%;
219
+ height: 100%;
220
+ z-index: auto;
221
+ background: transparent;
222
+ }
223
+
224
+ .kp-full-page.open {
225
+ opacity: 1;
226
+ pointer-events: auto;
227
+ transform: translateY(0);
228
+ }
229
+
230
+ .kp-full-page-shell {
231
+ height: 100vh;
232
+ display: flex;
233
+ flex-direction: column;
234
+ padding: 22px 28px 26px;
235
+ gap: 16px;
236
+ overflow: hidden;
237
+ }
238
+
239
+ .kp-full-page-embedded .kp-full-page-shell {
240
+ height: 100%;
241
+ min-height: 100%;
242
+ padding: 0;
243
+ gap: 12px;
244
+ }
245
+
246
+ .kp-full-page-header {
247
+ display: flex;
248
+ align-items: center;
249
+ justify-content: space-between;
250
+ gap: 16px;
251
+ padding: 8px 4px 0;
252
+ flex: none;
253
+ }
254
+
255
+ .kp-hidden {
256
+ display: none !important;
257
+ }
258
+
259
+ .kp-full-page-brand {
260
+ display: flex;
261
+ align-items: center;
262
+ gap: 12px;
263
+ color: #08384c;
264
+ }
265
+
266
+ .kp-full-page-brand-mark {
267
+ width: 44px;
268
+ height: 44px;
269
+ border-radius: 14px;
270
+ display: flex;
271
+ align-items: center;
272
+ justify-content: center;
273
+ background: linear-gradient(135deg, rgba(37, 181, 192, 0.14), rgba(15, 118, 110, 0.08));
274
+ font-size: 26px;
275
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
276
+ }
277
+
278
+ .kp-full-page-brand-text {
279
+ font-size: 20px;
280
+ font-weight: 700;
281
+ letter-spacing: -0.02em;
282
+ color: #16394b;
283
+ }
284
+
285
+ .kp-full-page-header-actions {
286
+ display: flex;
287
+ align-items: center;
288
+ gap: 12px;
289
+ }
290
+
291
+ .kp-full-page-badge {
292
+ padding: 10px 14px;
293
+ border-radius: 999px;
294
+ font-size: 13px;
295
+ line-height: 1;
296
+ color: #0b556c;
297
+ background: rgba(255, 255, 255, 0.82);
298
+ border: 1px solid rgba(15, 118, 110, 0.12);
299
+ box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
300
+ }
301
+
302
+ .kp-full-page-close,
303
+ .kp-source-panel-close {
304
+ width: 40px;
305
+ height: 40px;
306
+ border: none;
307
+ border-radius: 14px;
308
+ background: rgba(255, 255, 255, 0.82);
309
+ color: #61788a;
310
+ font-size: 24px;
311
+ line-height: 1;
312
+ cursor: pointer;
313
+ box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
314
+ }
315
+
316
+ .kp-full-page-content {
317
+ display: grid;
318
+ grid-template-columns: 290px minmax(0, 1fr) minmax(0, 0);
319
+ gap: 16px;
320
+ flex: 1;
321
+ min-height: 0;
322
+ overflow: hidden;
323
+ align-items: stretch;
324
+ }
325
+
326
+ .kp-full-page-embedded .kp-full-page-content {
327
+ height: 100%;
328
+ }
329
+
330
+ .kp-full-page-sidebar,
331
+ .kp-full-page-panel,
332
+ .kp-source-panel {
333
+ border-radius: 24px;
334
+ border: 1px solid rgba(219, 228, 238, 0.9);
335
+ background: rgba(255, 255, 255, 0.88);
336
+ box-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
337
+ backdrop-filter: blur(12px);
338
+ }
339
+
340
+ .kp-full-page-sidebar {
341
+ padding: 18px;
342
+ display: flex;
343
+ flex-direction: column;
344
+ gap: 16px;
345
+ min-height: 0;
346
+ overflow: auto;
347
+ }
348
+
349
+ .kp-full-page-new-chat {
350
+ width: 100%;
351
+ height: 48px;
352
+ border: none;
353
+ border-radius: 12px;
354
+ background: linear-gradient(135deg, #0a465d 0%, #0f6a75 100%);
355
+ color: #ffffff;
356
+ font-size: 16px;
357
+ font-weight: 600;
358
+ cursor: pointer;
359
+ box-shadow: 0 14px 30px rgba(10, 70, 93, 0.18);
360
+ }
361
+
362
+ .kp-full-page-search {
363
+ display: flex;
364
+ align-items: center;
365
+ gap: 8px;
366
+ height: 44px;
367
+ border-radius: 12px;
368
+ border: 1px solid rgba(203, 213, 225, 0.95);
369
+ background: #ffffff;
370
+ padding: 0 12px;
371
+ }
372
+
373
+ .kp-full-page-search-input {
374
+ flex: 1;
375
+ border: none;
376
+ outline: none;
377
+ background: transparent;
378
+ color: #334155;
379
+ font-size: 14px;
380
+ min-width: 0;
381
+ box-shadow: none;
382
+ }
383
+
384
+ .kp-full-page-search-input:focus,
385
+ .kp-full-page-search-input:focus-visible,
386
+ .kp-full-page-search-input:active {
387
+ outline: none;
388
+ box-shadow: none;
389
+ border: none;
390
+ }
391
+
392
+ .kp-full-page-search-icon {
393
+ color: #607082;
394
+ font-size: 20px;
395
+ line-height: 1;
396
+ }
397
+
398
+ .kp-full-page-section-label {
399
+ font-size: 12px;
400
+ line-height: 1.4;
401
+ text-transform: uppercase;
402
+ letter-spacing: 0.08em;
403
+ color: #8a98a6;
404
+ margin-top: 4px;
405
+ }
406
+
407
+ .kp-full-page-recent-list,
408
+ .kp-full-page-pinned-list {
409
+ display: flex;
410
+ flex-direction: column;
411
+ gap: 8px;
412
+ }
413
+
414
+ .kp-full-page-item {
415
+ padding: 12px 12px 13px;
416
+ border-radius: 14px;
417
+ color: #293845;
418
+ font-size: 15px;
419
+ line-height: 1.5;
420
+ background: rgba(247, 250, 252, 0.9);
421
+ border: 1px solid rgba(219, 228, 238, 0.88);
422
+ }
423
+
424
+ .kp-full-page-chat-item {
425
+ position: relative;
426
+ display: flex;
427
+ align-items: center;
428
+ justify-content: space-between;
429
+ gap: 10px;
430
+ cursor: pointer;
431
+ transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
432
+ overflow: visible;
433
+ }
434
+
435
+ .kp-full-page-chat-item:hover {
436
+ border-color: rgba(15, 118, 110, 0.34);
437
+ background: rgba(240, 253, 250, 0.95);
438
+ transform: translateY(-1px);
439
+ }
440
+
441
+ .kp-full-page-chat-item.active {
442
+ border-color: rgba(15, 118, 110, 0.5);
443
+ background: rgba(220, 252, 231, 0.72);
444
+ }
445
+
446
+ .kp-full-page-chat-item.menu-open {
447
+ z-index: 4;
448
+ }
449
+
450
+ .kp-full-page-item-title {
451
+ min-width: 0;
452
+ overflow: hidden;
453
+ text-overflow: ellipsis;
454
+ white-space: nowrap;
455
+ flex: 1;
456
+ }
457
+
458
+ .kp-chat-pin {
459
+ flex: none;
460
+ border: none;
461
+ background: transparent;
462
+ color: #0f6a75;
463
+ font-size: 16px;
464
+ line-height: 1;
465
+ padding: 0;
466
+ cursor: pointer;
467
+ }
468
+
469
+ .kp-full-page-empty {
470
+ padding: 8px 4px 0;
471
+ color: #7a8a99;
472
+ font-size: 14px;
473
+ line-height: 1.5;
474
+ }
475
+
476
+ .kp-full-page-main {
477
+ min-width: 0;
478
+ min-height: 0;
479
+ display: flex;
480
+ }
481
+
482
+ .kp-full-page-panel {
483
+ flex: 1;
484
+ display: flex;
485
+ flex-direction: column;
486
+ min-height: 0;
487
+ overflow: hidden;
488
+ }
489
+
490
+ .kp-source-panel {
491
+ min-width: 0;
492
+ min-height: 0;
493
+ overflow: hidden;
494
+ display: none;
495
+ flex-direction: column;
496
+ }
497
+
498
+ .kp-source-panel.open {
499
+ display: flex;
500
+ }
501
+
502
+ .kp-full-page-content:has(.kp-source-panel.open) {
503
+ grid-template-columns: 290px minmax(0, 1fr) 320px;
504
+ }
505
+
506
+ .kp-source-panel-header {
507
+ display: flex;
508
+ align-items: flex-start;
509
+ justify-content: space-between;
510
+ gap: 12px;
511
+ padding: 18px 18px 12px;
512
+ border-bottom: 1px solid rgba(219, 228, 238, 0.7);
513
+ }
514
+
515
+ .kp-source-panel-title {
516
+ font-size: 17px;
517
+ font-weight: 700;
518
+ color: #16394b;
519
+ }
520
+
521
+ .kp-source-panel-subtitle {
522
+ margin-top: 4px;
523
+ font-size: 12px;
524
+ color: #7a8a99;
525
+ }
526
+
527
+ .kp-source-panel-list {
528
+ display: flex;
529
+ flex-direction: column;
530
+ gap: 12px;
531
+ padding: 16px;
532
+ overflow: auto;
533
+ }
534
+
535
+ .kp-source-panel-empty {
536
+ color: #7a8a99;
537
+ font-size: 14px;
538
+ line-height: 1.5;
539
+ }
540
+
541
+ .kp-source-card {
542
+ width: 100%;
543
+ text-align: left;
544
+ cursor: pointer;
545
+ appearance: none;
546
+ border: 1px solid rgba(219, 228, 238, 0.9);
547
+ border-radius: 16px;
548
+ background: #ffffff;
549
+ padding: 14px;
550
+ }
551
+
552
+ .kp-source-card-media {
553
+ display: flex;
554
+ align-items: center;
555
+ margin-bottom: 10px;
556
+ }
557
+
558
+ .kp-source-thumb,
559
+ .kp-source-thumb-large {
560
+ flex: none;
561
+ width: 32px;
562
+ height: 32px;
563
+ border-radius: 999px;
564
+ display: inline-flex;
565
+ align-items: center;
566
+ justify-content: center;
567
+ background: linear-gradient(180deg, #eefcf8 0%, #dff7f2 100%);
568
+ border: 1px solid rgba(15, 118, 110, 0.18);
569
+ color: #0f6a75;
570
+ font-size: 14px;
571
+ line-height: 1;
572
+ box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
573
+ }
574
+
575
+ .kp-source-thumb-large {
576
+ width: 42px;
577
+ height: 42px;
578
+ font-size: 18px;
579
+ }
580
+
581
+ .kp-source-card-title {
582
+ font-size: 14px;
583
+ font-weight: 700;
584
+ color: #16394b;
585
+ word-break: break-word;
586
+ }
587
+
588
+ .kp-source-card-meta {
589
+ margin-top: 8px;
590
+ font-size: 12px;
591
+ line-height: 1.5;
592
+ color: #667a8d;
593
+ word-break: break-word;
594
+ }
595
+
596
+ .kp-full-page-body {
597
+ flex: 1;
598
+ overflow: auto;
599
+ display: flex;
600
+ flex-direction: column;
601
+ gap: 14px;
602
+ padding: 42px 28px 18px;
603
+ background: #ffffff;
604
+ scroll-behavior: smooth;
605
+ }
606
+
607
+ .kp-full-page-body.kp-conversation-active {
608
+ padding-top: 24px;
609
+ }
610
+
611
+ .kp-full-page-hero {
612
+ display: flex;
613
+ flex-direction: column;
614
+ align-items: center;
615
+ text-align: center;
616
+ gap: 22px;
617
+ padding: 18px 18px 12px;
618
+ max-width: 880px;
619
+ width: 100%;
620
+ margin: 0 auto;
621
+ }
622
+
623
+ .kp-full-page-hero-badge {
624
+ width: 140px;
625
+ height: 140px;
626
+ border-radius: 999px;
627
+ display: flex;
628
+ align-items: center;
629
+ justify-content: center;
630
+ background: radial-gradient(circle at 30% 30%, #f8fdff 0%, #edf8ff 50%, #e4eef8 100%);
631
+ box-shadow:
632
+ inset 0 2px 0 rgba(255, 255, 255, 0.9),
633
+ 0 22px 40px rgba(15, 23, 42, 0.08);
634
+ }
635
+
636
+ .kp-star-cluster-static {
637
+ animation: none;
638
+ }
639
+
640
+ .kp-full-page-hero-text {
641
+ max-width: 760px;
642
+ font-size: 26px;
643
+ line-height: 1.5;
644
+ font-weight: 700;
645
+ letter-spacing: -0.03em;
646
+ color: #374151;
647
+ }
648
+
649
+ .kp-full-page-suggestions {
650
+ width: min(520px, 100%);
651
+ margin: auto auto 0;
652
+ }
653
+
654
+ .kp-full-page-footer {
655
+ flex: none;
656
+ padding: 0 16px 18px;
657
+ background: rgba(255, 255, 255, 0.72);
658
+ border-top: 1px solid rgba(219, 228, 238, 0.75);
659
+ }
660
+
661
+ .kp-full-page-form {
662
+ max-width: none;
663
+ min-height: 56px;
664
+ border-radius: 16px;
665
+ }
666
+
667
+ .kp-full-page-note {
668
+ font-size: 13px;
669
+ margin-top: 10px;
670
+ }
671
+
672
+ .kp-header {
673
+ display: flex;
674
+ justify-content: space-between;
675
+ align-items: center;
676
+ gap: 12px;
677
+ padding: 18px 18px 8px;
678
+ background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
679
+ }
680
+
681
+ .kp-toolbar {
682
+ position: relative;
683
+ display: flex;
684
+ align-items: center;
685
+ gap: 8px;
686
+ }
687
+
688
+ .kp-tool-button {
689
+ width: 36px;
690
+ height: 36px;
691
+ border: none;
692
+ border-radius: 12px;
693
+ background: transparent;
694
+ color: #0f4f68;
695
+ cursor: pointer;
696
+ display: inline-flex;
697
+ align-items: center;
698
+ justify-content: center;
699
+ padding: 0;
700
+ transition: background 140ms ease;
701
+ }
702
+
703
+ .kp-tool-button:hover {
704
+ background: rgba(15, 118, 110, 0.08);
705
+ }
706
+
707
+ .kp-pencil-icon {
708
+ width: 22px;
709
+ height: 22px;
710
+ position: relative;
711
+ display: inline-block;
712
+ }
713
+
714
+ .kp-pencil-icon::before {
715
+ content: "";
716
+ position: absolute;
717
+ width: 14px;
718
+ height: 2.5px;
719
+ background: currentColor;
720
+ border-radius: 999px;
721
+ transform: rotate(-45deg);
722
+ top: 3px;
723
+ right: 1px;
724
+ }
725
+
726
+ .kp-pencil-icon::after {
727
+ content: "";
728
+ position: absolute;
729
+ left: 2px;
730
+ bottom: 2px;
731
+ width: 11px;
732
+ height: 11px;
733
+ border: 2px solid currentColor;
734
+ border-radius: 4px;
735
+ }
736
+
737
+ .kp-chevron {
738
+ font-size: 13px;
739
+ color: #66839a;
740
+ transition: transform 160ms ease;
741
+ margin-left: -2px;
742
+ }
743
+
744
+ .kp-menu-trigger.open .kp-chevron {
745
+ transform: rotate(180deg);
746
+ }
747
+
748
+ .kp-dropdown {
749
+ position: absolute;
750
+ top: 44px;
751
+ left: 0;
752
+ width: 184px;
753
+ background: #ffffff;
754
+ border: 1px solid rgba(15, 79, 104, 0.12);
755
+ border-radius: 10px;
756
+ box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
757
+ padding: 8px;
758
+ opacity: 0;
759
+ transform: translateY(-6px);
760
+ pointer-events: none;
761
+ transition: opacity 180ms ease, transform 180ms ease;
762
+ z-index: 2;
763
+ }
764
+
765
+ .kp-rtl .kp-dropdown {
766
+ left: auto;
767
+ right: 0;
768
+ }
769
+
770
+ .kp-dropdown.open {
771
+ opacity: 1;
772
+ transform: translateY(0);
773
+ pointer-events: auto;
774
+ }
775
+
776
+ .kp-dropdown-item {
777
+ width: 100%;
778
+ border: none;
779
+ background: transparent;
780
+ text-align: left;
781
+ padding: 10px 12px;
782
+ border-radius: 8px;
783
+ font-size: 14px;
784
+ color: var(--kp-text);
785
+ cursor: pointer;
786
+ }
787
+
788
+ .kp-dropdown-item:hover {
789
+ background: rgba(15, 118, 110, 0.08);
790
+ }
791
+
792
+ .kp-title-wrap {
793
+ display: none;
794
+ }
795
+
796
+ .kp-close {
797
+ border: none;
798
+ background: transparent;
799
+ font-size: 24px;
800
+ line-height: 1;
801
+ color: var(--kp-muted-text);
802
+ cursor: pointer;
803
+ padding: 0;
804
+ }
805
+
806
+ .kp-body {
807
+ flex: 1;
808
+ overflow: auto;
809
+ display: flex;
810
+ flex-direction: column;
811
+ gap: 12px;
812
+ padding: 10px 16px 16px;
813
+ background: linear-gradient(180deg, #ffffff 0%, var(--kp-surface-background) 100%);
814
+ scroll-behavior: smooth;
815
+ }
816
+
817
+ .kp-body.kp-conversation-active {
818
+ padding-top: 16px;
819
+ }
820
+
821
+ .kp-panel.kp-sheet-open .kp-body,
822
+ .kp-panel.kp-sheet-open .kp-footer,
823
+ .kp-panel.kp-sheet-open .kp-header {
824
+ opacity: 0;
825
+ pointer-events: none;
826
+ }
827
+
828
+ .kp-my-chats-sheet {
829
+ position: absolute;
830
+ inset: 0;
831
+ border-radius: inherit;
832
+ border: none;
833
+ background: #ffffff;
834
+ box-shadow: none;
835
+ display: none;
836
+ flex-direction: column;
837
+ z-index: 3;
838
+ overflow: hidden;
839
+ }
840
+
841
+ .kp-my-chats-sheet.open {
842
+ display: flex;
843
+ }
844
+
845
+ .kp-my-chats-header {
846
+ display: flex;
847
+ align-items: center;
848
+ justify-content: space-between;
849
+ padding: 18px 18px 10px;
850
+ flex: none;
851
+ background: #ffffff;
852
+ }
853
+
854
+ .kp-my-chats-nav {
855
+ width: 36px;
856
+ height: 36px;
857
+ border: none;
858
+ border-radius: 999px;
859
+ background: transparent;
860
+ color: #61788a;
861
+ font-size: 22px;
862
+ line-height: 1;
863
+ cursor: pointer;
864
+ }
865
+
866
+ .kp-my-chats-body {
867
+ flex: 1;
868
+ overflow: auto;
869
+ padding: 8px 18px 18px;
870
+ background: #ffffff;
871
+ }
872
+
873
+ .kp-my-chats-section-label {
874
+ font-size: 14px;
875
+ line-height: 1.5;
876
+ color: #7a8a99;
877
+ margin: 14px 0 10px;
878
+ }
879
+
880
+ .kp-my-chats-list {
881
+ display: flex;
882
+ flex-direction: column;
883
+ gap: 10px;
884
+ }
885
+
886
+ .kp-chat-actions {
887
+ position: relative;
888
+ flex: none;
889
+ }
890
+
891
+ .kp-chat-actions-trigger {
892
+ width: 28px;
893
+ height: 28px;
894
+ border: none;
895
+ border-radius: 999px;
896
+ background: transparent;
897
+ color: #526678;
898
+ font-size: 20px;
899
+ line-height: 1;
900
+ cursor: pointer;
901
+ display: inline-flex;
902
+ align-items: center;
903
+ justify-content: center;
904
+ }
905
+
906
+ .kp-chat-actions-menu {
907
+ position: absolute;
908
+ top: 30px;
909
+ inset-inline-end: 0;
910
+ width: 120px;
911
+ padding: 8px;
912
+ border-radius: 10px;
913
+ border: 1px solid rgba(219, 228, 238, 0.95);
914
+ background: #ffffff;
915
+ box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
916
+ display: none;
917
+ flex-direction: column;
918
+ gap: 2px;
919
+ z-index: 20;
920
+ }
921
+
922
+ .kp-chat-actions.open .kp-chat-actions-menu {
923
+ display: flex;
924
+ }
925
+
926
+ .kp-chat-actions-item {
927
+ width: 100%;
928
+ border: none;
929
+ background: transparent;
930
+ color: #1f2937;
931
+ text-align: left;
932
+ padding: 10px 12px;
933
+ border-radius: 8px;
934
+ font-size: 14px;
935
+ cursor: pointer;
936
+ }
937
+
938
+ .kp-chat-actions-item:hover {
939
+ background: rgba(241, 245, 249, 0.95);
940
+ }
941
+
942
+ .kp-hero {
943
+ display: flex;
944
+ gap: 10px;
945
+ padding: 4px 2px 8px;
946
+ align-items: flex-start;
947
+ }
948
+
949
+ .kp-hero-icon {
950
+ color: #0ea5b7;
951
+ font-size: 28px;
952
+ line-height: 1;
953
+ margin-top: 2px;
954
+ }
955
+
956
+ .kp-hero-text {
957
+ font-size: 20px;
958
+ line-height: 1.45;
959
+ font-weight: 700;
960
+ color: #374151;
961
+ }
962
+
963
+ .kp-message-row {
964
+ display: flex;
965
+ align-items: flex-start;
966
+ gap: 10px;
967
+ width: 100%;
968
+ }
969
+
970
+ .kp-message-row.user {
971
+ justify-content: flex-end;
972
+ }
973
+
974
+ .kp-avatar {
975
+ flex: none;
976
+ width: 36px;
977
+ height: 36px;
978
+ border-radius: 999px;
979
+ display: flex;
980
+ align-items: center;
981
+ justify-content: center;
982
+ font-size: 13px;
983
+ font-weight: 700;
984
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
985
+ }
986
+
987
+ .kp-avatar.bot {
988
+ background: linear-gradient(180deg, #e8fbff 0%, #dff7f2 100%);
989
+ color: #0f6a75;
990
+ border: 1px solid rgba(15, 118, 110, 0.16);
991
+ }
992
+
993
+ .kp-avatar.user {
994
+ background: linear-gradient(180deg, #fff4ee 0%, #fbe3d5 100%);
995
+ color: #8c4b1f;
996
+ border: 1px solid rgba(180, 102, 43, 0.16);
997
+ }
998
+
999
+ .kp-bubble {
1000
+ max-width: min(85%, 720px);
1001
+ padding: 14px 16px;
1002
+ border-radius: 20px;
1003
+ font-size: 14px;
1004
+ line-height: 1.65;
1005
+ border: 1px solid var(--kp-border-color);
1006
+ background: #ffffff;
1007
+ box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
1008
+ }
1009
+
1010
+ .kp-bubble.user {
1011
+ background: linear-gradient(180deg, #fff8f3 0%, #fdf1e8 100%);
1012
+ border-color: rgba(222, 184, 135, 0.34);
1013
+ }
1014
+
1015
+ .kp-bubble.bot {
1016
+ background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
1017
+ }
1018
+
1019
+ .kp-bubble-content {
1020
+ color: var(--kp-text);
1021
+ white-space: normal;
1022
+ word-break: break-word;
1023
+ }
1024
+
1025
+ .kp-bubble-content p,
1026
+ .kp-bubble-content ul,
1027
+ .kp-bubble-content ol,
1028
+ .kp-bubble-content table,
1029
+ .kp-bubble-content blockquote {
1030
+ margin: 0;
1031
+ }
1032
+
1033
+ .kp-bubble-content p + p,
1034
+ .kp-bubble-content p + ul,
1035
+ .kp-bubble-content p + ol,
1036
+ .kp-bubble-content ul + p,
1037
+ .kp-bubble-content ol + p,
1038
+ .kp-bubble-content .kp-table-wrap + p,
1039
+ .kp-bubble-content p + .kp-table-wrap,
1040
+ .kp-bubble-content h1 + p,
1041
+ .kp-bubble-content h2 + p,
1042
+ .kp-bubble-content h3 + p {
1043
+ margin-top: 12px;
1044
+ }
1045
+
1046
+ .kp-bubble-content h1,
1047
+ .kp-bubble-content h2,
1048
+ .kp-bubble-content h3,
1049
+ .kp-bubble-content h4,
1050
+ .kp-bubble-content h5,
1051
+ .kp-bubble-content h6 {
1052
+ margin: 0 0 10px;
1053
+ font-size: 16px;
1054
+ line-height: 1.4;
1055
+ color: #16394b;
1056
+ }
1057
+
1058
+ .kp-bubble-content ul,
1059
+ .kp-bubble-content ol {
1060
+ padding-inline-start: 20px;
1061
+ }
1062
+
1063
+ .kp-bubble-content code {
1064
+ padding: 2px 6px;
1065
+ border-radius: 8px;
1066
+ background: rgba(226, 232, 240, 0.66);
1067
+ font-size: 0.92em;
1068
+ }
1069
+
1070
+ .kp-bubble-content a {
1071
+ color: #0f6a75;
1072
+ text-decoration: underline;
1073
+ }
1074
+
1075
+ .kp-table-wrap {
1076
+ overflow-x: auto;
1077
+ margin-top: 8px;
1078
+ }
1079
+
1080
+ .kp-bubble-content table {
1081
+ width: 100%;
1082
+ border-collapse: collapse;
1083
+ border: 1px solid rgba(203, 213, 225, 0.95);
1084
+ border-radius: 14px;
1085
+ overflow: hidden;
1086
+ background: #ffffff;
1087
+ }
1088
+
1089
+ .kp-bubble-content th,
1090
+ .kp-bubble-content td {
1091
+ padding: 10px 12px;
1092
+ border-bottom: 1px solid rgba(226, 232, 240, 0.95);
1093
+ border-inline-end: 1px solid rgba(226, 232, 240, 0.95);
1094
+ vertical-align: top;
1095
+ text-align: start;
1096
+ }
1097
+
1098
+ .kp-bubble-content tr:last-child td {
1099
+ border-bottom: none;
1100
+ }
1101
+
1102
+ .kp-bubble-content th:last-child,
1103
+ .kp-bubble-content td:last-child {
1104
+ border-inline-end: none;
1105
+ }
1106
+
1107
+ .kp-bubble-content th {
1108
+ background: #f4fbfc;
1109
+ color: #16394b;
1110
+ font-weight: 700;
1111
+ }
1112
+
1113
+ .kp-meta {
1114
+ font-size: 11px;
1115
+ line-height: 1.4;
1116
+ color: var(--kp-muted-text);
1117
+ margin-top: 10px;
1118
+ }
1119
+
1120
+ .kp-source-preview {
1121
+ margin-top: 10px;
1122
+ padding: 12px;
1123
+ border-radius: 16px;
1124
+ border: 1px solid rgba(219, 228, 238, 0.88);
1125
+ background: #ffffff;
1126
+ }
1127
+
1128
+ .kp-source-preview-title {
1129
+ font-size: 12px;
1130
+ font-weight: 700;
1131
+ color: #16394b;
1132
+ margin-bottom: 8px;
1133
+ }
1134
+
1135
+ .kp-source-preview-list {
1136
+ display: flex;
1137
+ flex-wrap: nowrap;
1138
+ gap: 8px;
1139
+ overflow-x: auto;
1140
+ }
1141
+
1142
+ .kp-source-chip {
1143
+ display: inline-flex;
1144
+ align-items: center;
1145
+ gap: 10px;
1146
+ border: 1px solid rgba(15, 118, 110, 0.16);
1147
+ background: #ffffff;
1148
+ color: #0f4f68;
1149
+ border-radius: 999px;
1150
+ padding: 8px 12px;
1151
+ cursor: pointer;
1152
+ font-size: 12px;
1153
+ line-height: 1.3;
1154
+ max-width: 100%;
1155
+ min-width: 0;
1156
+ }
1157
+
1158
+ .kp-source-chip-more {
1159
+ background: rgba(236, 254, 255, 0.9);
1160
+ }
1161
+
1162
+ .kp-source-chip-label {
1163
+ min-width: 0;
1164
+ overflow: hidden;
1165
+ text-overflow: ellipsis;
1166
+ white-space: nowrap;
1167
+ }
1168
+
1169
+ .kp-source-thumb-stack {
1170
+ display: inline-flex;
1171
+ align-items: center;
1172
+ margin-inline-end: 2px;
1173
+ }
1174
+
1175
+ .kp-source-thumb.stacked {
1176
+ margin-inline-end: -10px;
1177
+ background: #ffffff;
1178
+ }
1179
+
1180
+ .kp-message-actions {
1181
+ display: flex;
1182
+ align-items: center;
1183
+ gap: 8px;
1184
+ margin-top: 10px;
1185
+ }
1186
+
1187
+ .kp-message-action {
1188
+ border: 1px solid rgba(219, 228, 238, 0.9);
1189
+ background: #ffffff;
1190
+ color: #4b6478;
1191
+ border-radius: 999px;
1192
+ padding: 7px 10px;
1193
+ cursor: pointer;
1194
+ font-size: 12px;
1195
+ line-height: 1;
1196
+ }
1197
+
1198
+ .kp-message-action.active {
1199
+ color: #0f6a75;
1200
+ border-color: rgba(15, 118, 110, 0.3);
1201
+ background: rgba(236, 254, 255, 0.92);
1202
+ }
1203
+
1204
+ .kp-suggestions {
1205
+ display: flex;
1206
+ flex-direction: column;
1207
+ gap: 10px;
1208
+ margin-top: auto;
1209
+ }
1210
+
1211
+ .kp-suggestion {
1212
+ border: 1px solid rgba(15, 118, 110, 0.18);
1213
+ background: rgba(247, 251, 255, 0.92);
1214
+ color: var(--kp-text);
1215
+ border-radius: 999px;
1216
+ padding: 11px 14px;
1217
+ cursor: pointer;
1218
+ text-align: left;
1219
+ font-size: 14px;
1220
+ line-height: 1.35;
1221
+ }
1222
+
1223
+ .kp-footer {
1224
+ padding: 10px 16px 12px;
1225
+ border-top: 1px solid rgba(219, 228, 238, 0.85);
1226
+ background: #ffffff;
1227
+ }
1228
+
1229
+ .kp-form {
1230
+ display: flex;
1231
+ align-items: center;
1232
+ gap: 10px;
1233
+ border: 1px solid var(--kp-border-color);
1234
+ border-radius: 16px;
1235
+ padding: 10px 12px;
1236
+ background: #ffffff;
1237
+ }
1238
+
1239
+ .kp-rtl .kp-form {
1240
+ flex-direction: row-reverse;
1241
+ }
1242
+
1243
+ .kp-input {
1244
+ flex: 1;
1245
+ border: none;
1246
+ outline: none;
1247
+ box-shadow: none;
1248
+ background: transparent;
1249
+ color: var(--kp-text);
1250
+ font-size: 14px;
1251
+ line-height: 1.5;
1252
+ min-width: 0;
1253
+ appearance: none;
1254
+ }
1255
+
1256
+ .kp-input:focus,
1257
+ .kp-input:focus-visible,
1258
+ .kp-input:active {
1259
+ border: none;
1260
+ outline: none;
1261
+ box-shadow: none;
1262
+ }
1263
+
1264
+ .kp-send {
1265
+ width: 40px;
1266
+ height: 40px;
1267
+ border: none;
1268
+ border-radius: 999px;
1269
+ background: #e4f1f8;
1270
+ color: var(--kp-accent);
1271
+ cursor: pointer;
1272
+ font-size: 20px;
1273
+ line-height: 1;
1274
+ display: flex;
1275
+ align-items: center;
1276
+ justify-content: center;
1277
+ flex: none;
1278
+ }
1279
+
1280
+ .kp-rtl .kp-send {
1281
+ transform: scaleX(-1);
1282
+ }
1283
+
1284
+ .kp-note {
1285
+ margin-top: 8px;
1286
+ text-align: center;
1287
+ font-size: 11px;
1288
+ line-height: 1.4;
1289
+ color: var(--kp-muted-text);
1290
+ }
1291
+
1292
+ .kp-loading {
1293
+ font-size: 13px;
1294
+ line-height: 1.4;
1295
+ color: var(--kp-muted-text);
1296
+ padding: 4px 2px;
1297
+ }
1298
+
1299
+ @media (max-width: 1100px) {
1300
+ .kp-full-page-content:has(.kp-source-panel.open) {
1301
+ grid-template-columns: 260px minmax(0, 1fr);
1302
+ }
1303
+
1304
+ .kp-source-panel.open {
1305
+ position: absolute;
1306
+ inset-inline-end: 28px;
1307
+ top: 92px;
1308
+ bottom: 26px;
1309
+ width: min(320px, calc(100vw - 56px));
1310
+ z-index: 3;
1311
+ }
1312
+ }
1313
+
1314
+ @media (max-width: 860px) {
1315
+ .kp-full-page-content,
1316
+ .kp-full-page-content:has(.kp-source-panel.open) {
1317
+ grid-template-columns: 1fr;
1318
+ }
1319
+
1320
+ .kp-full-page-sidebar {
1321
+ max-height: 260px;
1322
+ }
1323
+
1324
+ .kp-full-page-embedded .kp-full-page-sidebar {
1325
+ max-height: none;
1326
+ }
1327
+
1328
+ .kp-source-panel.open {
1329
+ position: static;
1330
+ inset: auto;
1331
+ width: auto;
1332
+ max-height: 280px;
1333
+ }
1334
+ }
1335
+
1336
+ @media (max-width: 640px) {
1337
+ .kp-chat-widget,
1338
+ .kp-chat-widget.bottom-left {
1339
+ left: auto;
1340
+ right: 16px;
1341
+ bottom: 16px;
1342
+ }
1343
+
1344
+ .kp-chat-widget.kp-chat-widget-embedded,
1345
+ .kp-chat-widget.kp-chat-widget-embedded.bottom-left {
1346
+ left: auto;
1347
+ right: auto;
1348
+ bottom: auto;
1349
+ }
1350
+
1351
+ .kp-panel,
1352
+ .kp-chat-widget.bottom-left .kp-panel {
1353
+ inset: 0;
1354
+ width: 100vw;
1355
+ height: 100vh;
1356
+ border-radius: 0;
1357
+ transform: translateX(72px) scale(0.985);
1358
+ transform-origin: center right;
1359
+ }
1360
+
1361
+ .kp-panel.open {
1362
+ transform: translateX(0) scale(1);
1363
+ }
1364
+
1365
+ .kp-full-page-shell {
1366
+ padding: 14px;
1367
+ }
1368
+
1369
+ .kp-full-page-embedded .kp-full-page-shell {
1370
+ padding: 0;
1371
+ }
1372
+
1373
+ .kp-full-page-header {
1374
+ padding: 0;
1375
+ }
1376
+
1377
+ .kp-full-page-body {
1378
+ padding: 24px 16px 16px;
1379
+ }
1380
+
1381
+ .kp-full-page-hero-badge {
1382
+ width: 112px;
1383
+ height: 112px;
1384
+ }
1385
+
1386
+ .kp-full-page-hero-text {
1387
+ font-size: 22px;
1388
+ }
1389
+
1390
+ .kp-message-row {
1391
+ gap: 8px;
1392
+ }
1393
+
1394
+ .kp-avatar {
1395
+ width: 32px;
1396
+ height: 32px;
1397
+ }
1398
+
1399
+ .kp-bubble {
1400
+ max-width: calc(100% - 40px);
1401
+ }
1402
+ }
1403
+
1404
+ @keyframes kp-cluster-rotate {
1405
+ from { transform: rotate(0deg); }
1406
+ to { transform: rotate(360deg); }
1407
+ }
1408
+
1409
+ @keyframes kp-main-pulse {
1410
+ 0%, 100% { transform: translate(-50%, -50%) scale(0.82); opacity: 0.45; }
1411
+ 38% { transform: translate(-50%, -50%) scale(1.04); opacity: 1; }
1412
+ 60% { transform: translate(-50%, -50%) scale(0.94); opacity: 0.88; }
1413
+ }
1414
+
1415
+ @keyframes kp-orbit-a {
1416
+ 0%, 100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
1417
+ 40% { transform: translate(-50%, 17px) scale(0.92); opacity: 0.96; }
1418
+ 62% { transform: translate(-50%, 2px) scale(1); opacity: 0.98; }
1419
+ }
1420
+
1421
+ @keyframes kp-orbit-b {
1422
+ 0%, 100% { transform: translate(0, 0) scale(1); opacity: 1; }
1423
+ 40% { transform: translate(-16px, -13px) scale(0.92); opacity: 0.96; }
1424
+ 62% { transform: translate(-2px, -2px) scale(1); opacity: 0.98; }
1425
+ }
1426
+
1427
+ @keyframes kp-orbit-c {
1428
+ 0%, 100% { transform: translate(0, 0) scale(1); opacity: 1; }
1429
+ 40% { transform: translate(16px, -13px) scale(0.92); opacity: 0.96; }
1430
+ 62% { transform: translate(2px, -2px) scale(1); opacity: 0.98; }
1431
+ }
1432
+
1433
+ /* In-Widget Premium Document Preview Overlay Styles */
1434
+ .kp-citation-overlay {
1435
+ position: fixed;
1436
+ inset: 0;
1437
+ background: #f8fafc;
1438
+ color: #1f2937;
1439
+ display: flex;
1440
+ flex-direction: column;
1441
+ opacity: 0;
1442
+ pointer-events: none;
1443
+ transform: translateY(18px);
1444
+ transition: opacity 260ms ease, transform 320ms ease;
1445
+ z-index: 100000;
1446
+ overflow: hidden;
1447
+ box-sizing: border-box;
1448
+ }
1449
+
1450
+ .kp-chat-widget-embedded .kp-citation-overlay {
1451
+ position: absolute;
1452
+ inset: 0;
1453
+ z-index: 100000;
1454
+ }
1455
+
1456
+ .kp-citation-overlay.open {
1457
+ opacity: 1;
1458
+ pointer-events: auto;
1459
+ transform: translateY(0);
1460
+ }
1461
+
1462
+ .kp-citation-overlay-header {
1463
+ background: #ffffff;
1464
+ border-bottom: 1px solid rgba(226, 232, 240, 0.8);
1465
+ height: 64px;
1466
+ display: flex;
1467
+ align-items: center;
1468
+ padding: 0 24px;
1469
+ justify-content: space-between;
1470
+ flex: none;
1471
+ box-sizing: border-box;
1472
+ }
1473
+
1474
+ .kp-citation-overlay-brand {
1475
+ display: flex;
1476
+ align-items: center;
1477
+ gap: 12px;
1478
+ font-weight: 600;
1479
+ font-size: 16px;
1480
+ color: #0f766e;
1481
+ }
1482
+
1483
+ .kp-citation-overlay-brand-logo {
1484
+ font-size: 20px;
1485
+ }
1486
+
1487
+ .kp-citation-overlay-close {
1488
+ width: 40px;
1489
+ height: 40px;
1490
+ border: none;
1491
+ border-radius: 14px;
1492
+ background: rgba(255, 255, 255, 0.82);
1493
+ color: #61788a;
1494
+ font-size: 24px;
1495
+ line-height: 1;
1496
+ cursor: pointer;
1497
+ box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
1498
+ display: flex;
1499
+ align-items: center;
1500
+ justify-content: center;
1501
+ transition: background 140ms ease;
1502
+ }
1503
+
1504
+ .kp-citation-overlay-close:hover {
1505
+ background: rgba(15, 118, 110, 0.08);
1506
+ }
1507
+
1508
+ .kp-citation-overlay-content {
1509
+ display: grid;
1510
+ grid-template-columns: 380px minmax(0, 1fr);
1511
+ flex: 1;
1512
+ overflow: hidden;
1513
+ align-items: stretch;
1514
+ box-sizing: border-box;
1515
+ }
1516
+
1517
+ .kp-citation-overlay-metadata-panel {
1518
+ background: #ffffff;
1519
+ border-right: 1px solid #e2e8f0;
1520
+ padding: 32px 24px;
1521
+ overflow-y: auto;
1522
+ display: flex;
1523
+ flex-direction: column;
1524
+ gap: 24px;
1525
+ box-sizing: border-box;
1526
+ }
1527
+
1528
+ .kp-citation-overlay-viewer-panel {
1529
+ flex: 1;
1530
+ background: #f1f5f9;
1531
+ display: flex;
1532
+ flex-direction: column;
1533
+ overflow: hidden;
1534
+ box-sizing: border-box;
1535
+ }
1536
+
1537
+ .doc-badge-wrapper {
1538
+ display: flex;
1539
+ align-items: center;
1540
+ gap: 16px;
1541
+ }
1542
+
1543
+ .doc-icon {
1544
+ background: #ecfeff;
1545
+ color: #0f766e;
1546
+ width: 48px;
1547
+ height: 48px;
1548
+ border-radius: 12px;
1549
+ display: flex;
1550
+ align-items: center;
1551
+ justify-content: center;
1552
+ font-size: 20px;
1553
+ font-weight: bold;
1554
+ }
1555
+
1556
+ .doc-badge-info h2 {
1557
+ font-size: 11px;
1558
+ text-transform: uppercase;
1559
+ letter-spacing: 0.05em;
1560
+ color: #64748b;
1561
+ font-weight: 600;
1562
+ margin: 0;
1563
+ }
1564
+
1565
+ .doc-title-section h1 {
1566
+ font-size: 18px;
1567
+ font-weight: 700;
1568
+ line-height: 1.4;
1569
+ color: #0f172a;
1570
+ margin: 8px 0 0;
1571
+ }
1572
+
1573
+ .doc-source-type {
1574
+ font-size: 12px;
1575
+ color: #64748b;
1576
+ margin-top: 4px;
1577
+ }
1578
+
1579
+ .section-divider {
1580
+ height: 1px;
1581
+ background: #e2e8f0;
1582
+ }
1583
+
1584
+ .meta-section-title {
1585
+ font-size: 11px;
1586
+ text-transform: uppercase;
1587
+ letter-spacing: 0.05em;
1588
+ color: #0f766e;
1589
+ font-weight: 600;
1590
+ margin-bottom: 12px;
1591
+ }
1592
+
1593
+ .summary-box {
1594
+ background: #f8fafc;
1595
+ border: 1px solid #e2e8f0;
1596
+ border-radius: 12px;
1597
+ padding: 16px;
1598
+ font-size: 13.5px;
1599
+ line-height: 1.6;
1600
+ color: #374151;
1601
+ white-space: pre-wrap;
1602
+ }
1603
+
1604
+ .meta-list {
1605
+ display: flex;
1606
+ flex-direction: column;
1607
+ gap: 12px;
1608
+ }
1609
+
1610
+ .meta-item {
1611
+ display: flex;
1612
+ justify-content: space-between;
1613
+ font-size: 13px;
1614
+ line-height: 1.5;
1615
+ border-bottom: 1px dashed #f1f5f9;
1616
+ padding-bottom: 8px;
1617
+ }
1618
+
1619
+ .meta-label {
1620
+ color: #64748b;
1621
+ font-weight: 500;
1622
+ }
1623
+
1624
+ .meta-value {
1625
+ color: #1f2937;
1626
+ font-weight: 600;
1627
+ text-align: right;
1628
+ max-width: 200px;
1629
+ word-wrap: break-word;
1630
+ }
1631
+
1632
+ .viewer-toolbar {
1633
+ background: #0f172a;
1634
+ color: #ffffff;
1635
+ height: 48px;
1636
+ display: flex;
1637
+ align-items: center;
1638
+ justify-content: space-between;
1639
+ padding: 0 20px;
1640
+ font-size: 13px;
1641
+ flex: none;
1642
+ box-sizing: border-box;
1643
+ }
1644
+
1645
+ .toolbar-left {
1646
+ font-weight: 500;
1647
+ max-width: 300px;
1648
+ white-space: nowrap;
1649
+ overflow: hidden;
1650
+ text-overflow: ellipsis;
1651
+ }
1652
+
1653
+ .toolbar-center {
1654
+ display: flex;
1655
+ align-items: center;
1656
+ gap: 16px;
1657
+ }
1658
+
1659
+ .page-indicator {
1660
+ background: rgba(255, 255, 255, 0.15);
1661
+ padding: 4px 10px;
1662
+ border-radius: 6px;
1663
+ font-weight: 500;
1664
+ }
1665
+
1666
+ .toolbar-btn {
1667
+ background: transparent;
1668
+ border: none;
1669
+ color: #e2e8f0;
1670
+ cursor: pointer;
1671
+ padding: 4px 12px;
1672
+ border-radius: 6px;
1673
+ font-size: 13px;
1674
+ display: flex;
1675
+ align-items: center;
1676
+ justify-content: center;
1677
+ transition: all 0.2s;
1678
+ font-weight: 500;
1679
+ }
1680
+
1681
+ .toolbar-btn:hover {
1682
+ background: rgba(255, 255, 255, 0.1);
1683
+ color: #ffffff;
1684
+ }
1685
+
1686
+ .toolbar-right {
1687
+ display: flex;
1688
+ align-items: center;
1689
+ gap: 12px;
1690
+ }
1691
+
1692
+ .viewer-body {
1693
+ flex: 1;
1694
+ overflow: auto;
1695
+ padding: 40px;
1696
+ display: flex;
1697
+ justify-content: center;
1698
+ align-items: flex-start;
1699
+ box-sizing: border-box;
1700
+ }
1701
+
1702
+ .document-sheet {
1703
+ background: #ffffff;
1704
+ width: 100%;
1705
+ max-width: 800px;
1706
+ min-height: 1000px;
1707
+ box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
1708
+ border-radius: 4px;
1709
+ padding: 60px 50px;
1710
+ display: flex;
1711
+ flex-direction: column;
1712
+ position: relative;
1713
+ transition: transform 0.2s ease;
1714
+ transform-origin: top center;
1715
+ box-sizing: border-box;
1716
+ }
1717
+
1718
+ .sheet-header {
1719
+ border-bottom: 2px solid #0f766e;
1720
+ padding-bottom: 15px;
1721
+ margin-bottom: 30px;
1722
+ display: flex;
1723
+ justify-content: space-between;
1724
+ align-items: center;
1725
+ font-size: 11px;
1726
+ color: #64748b;
1727
+ text-transform: uppercase;
1728
+ letter-spacing: 0.1em;
1729
+ font-weight: 600;
1730
+ }
1731
+
1732
+ .sheet-content {
1733
+ font-size: 14.5px;
1734
+ line-height: 1.8;
1735
+ color: #27272a;
1736
+ white-space: pre-wrap;
1737
+ flex: 1;
1738
+ font-family: 'Inter', sans-serif;
1739
+ text-align: left;
1740
+ }
1741
+
1742
+ .sheet-footer {
1743
+ border-top: 1px solid #e2e8f0;
1744
+ padding-top: 15px;
1745
+ margin-top: 40px;
1746
+ display: flex;
1747
+ justify-content: space-between;
1748
+ align-items: center;
1749
+ font-size: 11px;
1750
+ color: #64748b;
1751
+ }
1752
+
1753
+ .kp-citation-overlay iframe {
1754
+ width: 100%;
1755
+ height: 100%;
1756
+ border: none;
1757
+ }
1758
+
1759
+ @media (max-width: 860px) {
1760
+ .kp-citation-overlay-content {
1761
+ grid-template-columns: 1fr;
1762
+ overflow-y: auto;
1763
+ }
1764
+
1765
+ .kp-citation-overlay-metadata-panel {
1766
+ border-right: none;
1767
+ border-bottom: 1px solid #e2e8f0;
1768
+ padding: 20px 16px;
1769
+ }
1770
+
1771
+ .viewer-body {
1772
+ padding: 20px;
1773
+ }
1774
+
1775
+ .document-sheet {
1776
+ padding: 30px 20px;
1777
+ min-height: auto;
1778
+ }
1779
+ }
1780
+ `}var Pt={en:{openChatActions:"Open chat actions",newChat:"New Chat",myChats:"My Chats",openAssistant:"Open Knowledge Assistant",back:"Back",close:"Close",assistantBadge:"Knowledge Assistant",closeAssistantPage:"Close knowledge assistant page",searchChat:"Search Chat",recentActivity:"Recent Activity",pinnedCollections:"Pinned Collections",answersBasedOnPermissions:"Answers are generated based on your access permissions",authTokenForwarded:"Auth token is forwarded from the host app when configured.",thinking:"Thinking...",unableToCreateChat:"Unable to create chat",requestFailed:"Request failed",noRecentChats:"No recent chats yet.",noPinnedChats:"No pinned chats yet.",noChats:"No chats yet.",loadingChats:"Loading chats...",pinChat:"Pin chat",unpinChat:"Unpin chat",renameChat:"Rename",deleteChat:"Delete",chatActions:"Chat actions",renamePrompt:"Enter a new chat name",citationsAttached:e=>`${e} citation${e>1?"s":""} attached`,sourcesUsed:"Sources Used",allSourcesUsed:"All Sources Used",documentsAndReferences:"AI documents and references",showAll:"Show All",noSources:"No sources were returned for this answer.",closeSourcesPanel:"Close sources panel",openSource:"Open source",sourceScore:"Score",sourcePage:"Page",sourceSheet:"Sheet",sourceRow:"Row",sourceKnowledge:"Knowledge Base",untitledSource:"Untitled Source",copy:"Copy",copied:"Copied",helpful:"Helpful",notHelpful:"Needs work",send:"Send message",assistantAvatar:"Assistant",userAvatar:"User"},ar:{openChatActions:"\u0641\u062A\u062D \u0625\u062C\u0631\u0627\u0621\u0627\u062A \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",newChat:"\u0645\u062D\u0627\u062F\u062B\u0629 \u062C\u062F\u064A\u062F\u0629",myChats:"\u0645\u062D\u0627\u062F\u062B\u0627\u062A\u064A",openAssistant:"\u0641\u062A\u062D \u0645\u0633\u0627\u0639\u062F \u0627\u0644\u0645\u0639\u0631\u0641\u0629",back:"\u0631\u062C\u0648\u0639",close:"\u0625\u063A\u0644\u0627\u0642",assistantBadge:"\u0645\u0633\u0627\u0639\u062F \u0627\u0644\u0645\u0639\u0631\u0641\u0629",closeAssistantPage:"\u0625\u063A\u0644\u0627\u0642 \u0635\u0641\u062D\u0629 \u0645\u0633\u0627\u0639\u062F \u0627\u0644\u0645\u0639\u0631\u0641\u0629",searchChat:"\u0627\u0628\u062D\u062B \u0641\u064A \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0627\u062A",recentActivity:"\u0627\u0644\u0646\u0634\u0627\u0637 \u0627\u0644\u0623\u062E\u064A\u0631",pinnedCollections:"\u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0627\u062A \u0627\u0644\u0645\u062B\u0628\u062A\u0629",answersBasedOnPermissions:"\u064A\u062A\u0645 \u0625\u0646\u0634\u0627\u0621 \u0627\u0644\u0625\u062C\u0627\u0628\u0627\u062A \u0628\u0646\u0627\u0621\u064B \u0639\u0644\u0649 \u0635\u0644\u0627\u062D\u064A\u0627\u062A \u0627\u0644\u0648\u0635\u0648\u0644 \u0627\u0644\u062E\u0627\u0635\u0629 \u0628\u0643",authTokenForwarded:"\u064A\u062A\u0645 \u062A\u0645\u0631\u064A\u0631 \u0631\u0645\u0632 \u0627\u0644\u062A\u062D\u0642\u0642 \u0645\u0646 \u0627\u0644\u062A\u0637\u0628\u064A\u0642 \u0627\u0644\u0645\u0636\u064A\u0641 \u0639\u0646\u062F \u0627\u0644\u0625\u0639\u062F\u0627\u062F.",thinking:"\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u0641\u0643\u064A\u0631...",unableToCreateChat:"\u062A\u0639\u0630\u0631 \u0625\u0646\u0634\u0627\u0621 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",requestFailed:"\u0641\u0634\u0644 \u0627\u0644\u0637\u0644\u0628",noRecentChats:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0645\u062D\u0627\u062F\u062B\u0627\u062A \u062D\u062F\u064A\u062B\u0629 \u0628\u0639\u062F.",noPinnedChats:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0645\u062D\u0627\u062F\u062B\u0627\u062A \u0645\u062B\u0628\u062A\u0629 \u0628\u0639\u062F.",noChats:"\u0644\u0627 \u062A\u0648\u062C\u062F \u0645\u062D\u0627\u062F\u062B\u0627\u062A \u0628\u0639\u062F.",loadingChats:"\u062C\u0627\u0631\u064D \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0627\u062A...",pinChat:"\u062A\u062B\u0628\u064A\u062A \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",unpinChat:"\u0625\u0644\u063A\u0627\u0621 \u062A\u062B\u0628\u064A\u062A \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",renameChat:"\u0625\u0639\u0627\u062F\u0629 \u062A\u0633\u0645\u064A\u0629",deleteChat:"\u062D\u0630\u0641",chatActions:"\u0625\u062C\u0631\u0627\u0621\u0627\u062A \u0627\u0644\u0645\u062D\u0627\u062F\u062B\u0629",renamePrompt:"\u0623\u062F\u062E\u0644 \u0627\u0633\u0645\u064B\u0627 \u062C\u062F\u064A\u062F\u064B\u0627 \u0644\u0644\u0645\u062D\u0627\u062F\u062B\u0629",citationsAttached:e=>`\u062A\u0645 \u0625\u0631\u0641\u0627\u0642 ${e} \u0645\u0631\u062C\u0639${e>1?"\u0627\u062A":""}`,sourcesUsed:"\u0627\u0644\u0645\u0635\u0627\u062F\u0631 \u0627\u0644\u0645\u0633\u062A\u062E\u062F\u0645\u0629",allSourcesUsed:"\u0643\u0644 \u0627\u0644\u0645\u0635\u0627\u062F\u0631 \u0627\u0644\u0645\u0633\u062A\u062E\u062F\u0645\u0629",documentsAndReferences:"\u0645\u0633\u062A\u0646\u062F\u0627\u062A \u0648\u0645\u0631\u0627\u062C\u0639 \u0627\u0644\u0630\u0643\u0627\u0621 \u0627\u0644\u0627\u0635\u0637\u0646\u0627\u0639\u064A",showAll:"\u0639\u0631\u0636 \u0627\u0644\u0643\u0644",noSources:"\u0644\u0645 \u064A\u062A\u0645 \u0625\u0631\u062C\u0627\u0639 \u0645\u0635\u0627\u062F\u0631 \u0644\u0647\u0630\u0647 \u0627\u0644\u0625\u062C\u0627\u0628\u0629.",closeSourcesPanel:"\u0625\u063A\u0644\u0627\u0642 \u0644\u0648\u062D\u0629 \u0627\u0644\u0645\u0635\u0627\u062F\u0631",openSource:"\u0641\u062A\u062D \u0627\u0644\u0645\u0635\u062F\u0631",sourceScore:"\u0627\u0644\u062F\u0631\u062C\u0629",sourcePage:"\u0627\u0644\u0635\u0641\u062D\u0629",sourceSheet:"\u0627\u0644\u0648\u0631\u0642\u0629",sourceRow:"\u0627\u0644\u0635\u0641",sourceKnowledge:"\u0642\u0627\u0639\u062F\u0629 \u0627\u0644\u0645\u0639\u0631\u0641\u0629",untitledSource:"\u0645\u0635\u062F\u0631 \u0628\u062F\u0648\u0646 \u0639\u0646\u0648\u0627\u0646",copy:"\u0646\u0633\u062E",copied:"\u062A\u0645 \u0627\u0644\u0646\u0633\u062E",helpful:"\u0645\u0641\u064A\u062F",notHelpful:"\u064A\u062D\u062A\u0627\u062C \u062A\u062D\u0633\u064A\u0646",send:"\u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0631\u0633\u0627\u0644\u0629",assistantAvatar:"\u0627\u0644\u0645\u0633\u0627\u0639\u062F",userAvatar:"\u0627\u0644\u0645\u0633\u062A\u062E\u062F\u0645"}};function Kn(e){if(typeof document>"u")throw new Error("Chat widget can only be initialized in a browser.");let t=wt(e),o=$e(t.locale),n=bn(t.locale),r=xn(o),l=t.displayMode==="embedded",i={chatId:be(t),open:!1,fullPageOpen:l,myChatsOpen:!1,accessTokenProvider:t.getAccessToken,historyLoadedChatId:null,menuOpen:!1,chats:[],chatSearchTerm:"",loadingChats:!1,sourcePanelOpen:!1,sourcePanelTitle:null},p=document.createElement("div");p.dataset.chatWidgetHost="true",t.mount.appendChild(p);let c=p.attachShadow({mode:"open"});Lt(c,t.theme);let u=a("div",`kp-chat-widget ${t.position}`);u.lang=o,u.dir=r?"rtl":"ltr",l&&(u.classList.add("kp-chat-widget-embedded"),Et(!0)),r&&u.classList.add("kp-rtl");let g=a("div","kp-overlay"),f=a("button","kp-launcher");f.type="button",f.setAttribute("aria-label",t.launcherAriaLabel),f.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 h=a("section","kp-panel");h.setAttribute("role","dialog"),h.setAttribute("aria-modal","true"),h.setAttribute("aria-label",t.title);let v=a("div","kp-header"),P=a("div","kp-toolbar"),b=a("button","kp-tool-button kp-menu-trigger");b.type="button",b.setAttribute("aria-label",n.openChatActions),b.innerHTML=['<span class="kp-pencil-icon" aria-hidden="true"></span>','<span class="kp-chevron" aria-hidden="true">\u2304</span>'].join("");let y=a("div","kp-dropdown"),x=a("button","kp-dropdown-item",n.newChat);x.type="button";let U=a("button","kp-dropdown-item",n.myChats);U.type="button";let w=a("button","kp-dropdown-item",n.openAssistant);w.type="button",y.append(x,U,w),P.append(b,y);let Me=a("div","kp-title-wrap"),zt=a("h2","kp-title",t.title),$t=a("div","kp-subtitle",t.subtitle);Me.append(zt,$t);let ie=a("button","kp-close","\xD7");ie.type="button",ie.setAttribute("aria-label",t.closeAriaLabel),v.append(P,Me,ie);let re=a("div","kp-body"),xe=a("div","kp-hero"),Ht=a("div","kp-hero-icon","\u2726"),Mt=a("div","kp-hero-text",t.welcomeMessage);xe.append(Ht,Mt);let Ne=a("div","kp-footer"),ke=a("form","kp-form"),z=a("input","kp-input");z.type="text",z.autocomplete="off",z.placeholder=t.inputPlaceholder,z.setAttribute("aria-label",t.inputPlaceholder);let ye=a("button","kp-send","\u279C");ye.type="submit",ye.setAttribute("aria-label",n.send);let Nt=a("div","kp-note",n.authTokenForwarded);ke.append(z,ye),Ne.append(ke,Nt),h.append(v,re,Ne),l||u.append(g,f,h),c.appendChild(u),re.appendChild(xe);let Oe=a("div","kp-suggestions");re.appendChild(Oe);let le=a("section","kp-my-chats-sheet"),Ue=a("div","kp-my-chats-header"),pe=a("button","kp-my-chats-nav","\u2190");pe.type="button",pe.setAttribute("aria-label",n.back);let ce=a("button","kp-my-chats-nav kp-my-chats-close","\xD7");ce.type="button",ce.setAttribute("aria-label",n.close),Ue.append(pe,ce);let Be=a("div","kp-my-chats-body"),Ot=a("div","kp-my-chats-section-label",n.recentActivity),je=a("div","kp-my-chats-list"),Ut=a("div","kp-my-chats-section-label",n.pinnedCollections),De=a("div","kp-my-chats-list");Be.append(Ot,je,Ut,De),le.append(Ue,Be),h.appendChild(le);let E={body:re,input:z,suggestions:Oe,hero:xe,kind:"panel"},A=a("section","kp-full-page");l&&A.classList.add("kp-full-page-embedded","open"),A.setAttribute("role","dialog"),l||A.setAttribute("aria-modal","true"),A.setAttribute("aria-label",`${t.title} page`);let We=a("div","kp-full-page-shell"),ve=a("div","kp-full-page-header"),qe=a("div","kp-full-page-brand"),Bt=a("div","kp-full-page-brand-mark","\u2726"),jt=a("div","kp-full-page-brand-text",t.title);qe.append(Bt,jt);let Ve=a("div","kp-full-page-header-actions"),Dt=a("div","kp-full-page-badge",n.assistantBadge),de=a("button","kp-full-page-close","\xD7");de.type="button",de.setAttribute("aria-label",n.closeAssistantPage),Ve.append(Dt,de),ve.append(qe,Ve),t.embedded.showHeader||ve.classList.add("kp-hidden");let Fe=a("div","kp-full-page-content"),_e=a("aside","kp-full-page-sidebar"),we=a("button","kp-full-page-new-chat",`+ ${n.newChat}`);we.type="button";let Ke=a("div","kp-full-page-search"),Z=a("input","kp-full-page-search-input");Z.type="search",Z.placeholder=n.searchChat;let Wt=a("span","kp-full-page-search-icon","\u2315");Ke.append(Z,Wt);let qt=a("div","kp-full-page-section-label",n.recentActivity),Ye=a("div","kp-full-page-recent-list"),Vt=a("div","kp-full-page-section-label",n.pinnedCollections),Xe=a("div","kp-full-page-pinned-list");_e.append(we,Ke,qt,Ye,Vt,Xe);let Je=a("main","kp-full-page-main"),Qe=a("section","kp-full-page-panel"),Ce=a("div","kp-full-page-body"),Le=a("div","kp-full-page-hero"),Ge=a("div","kp-full-page-hero-badge");Ge.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 Ft=a("div","kp-full-page-hero-text",t.welcomeMessage);Le.append(Ge,Ft);let Ze=a("div","kp-suggestions kp-full-page-suggestions");Ce.append(Le,Ze);let et=a("div","kp-full-page-footer"),Pe=a("form","kp-form kp-full-page-form"),T=a("input","kp-input kp-full-page-input");T.type="text",T.autocomplete="off",T.placeholder=t.inputPlaceholder,T.setAttribute("aria-label",t.inputPlaceholder);let Ae=a("button","kp-send kp-full-page-send","\u279C");Ae.type="submit",Ae.setAttribute("aria-label",n.send);let _t=a("div","kp-note kp-full-page-note",n.answersBasedOnPermissions);Pe.append(T,Ae),et.append(Pe,_t),Qe.append(Ce,et),Je.appendChild(Qe);let ue=a("aside","kp-source-panel"),tt=a("div","kp-source-panel-header"),nt=a("div","kp-source-panel-title-wrap"),at=a("div","kp-source-panel-title",n.allSourcesUsed),Kt=a("div","kp-source-panel-subtitle",n.documentsAndReferences);nt.append(at,Kt);let ge=a("button","kp-source-panel-close","\xD7");ge.type="button",ge.setAttribute("aria-label",n.closeSourcesPanel),tt.append(nt,ge);let ee=a("div","kp-source-panel-list"),Yt=a("div","kp-source-panel-empty",n.noSources);ee.appendChild(Yt),ue.append(tt,ee),Fe.append(_e,Je,ue),We.append(ve,Fe),A.appendChild(We),u.appendChild(A);let te=a("div","kp-citation-overlay");u.appendChild(te);let C={body:Ce,input:T,suggestions:Ze,hero:Le,kind:"full-page"},B=()=>({...t,getAccessToken:i.accessTokenProvider}),ot=async()=>{if(!t.getUserContext)return null;try{let s=await t.getUserContext();return s?.displayName?.trim()||s?.email?.trim()||s?.userId?.trim()||null}catch{return null}},F=s=>{let d=He(s)??n.untitledSource,m=(s.text||"").trim(),S=m,L=m.split(`
1781
+ `);if(L.length>1&&L[0]){let N=L[0].trim().replace(/\s*\|\s*Page\s*\d+\s*$/i,"").trim();N&&(N===d||d.indexOf(N)!==-1||N.indexOf(d)!==-1)&&(S=L.slice(1).join(`
1782
+ `).trim())}let I=Tn(s.sourceDocument),W=[];(s.pageNumber||s.pageNumber===0)&&W.push(`
1783
+ <div class="meta-item">
1784
+ <span class="meta-label">Page Number</span>
1785
+ <span class="meta-value">${s.pageNumber}</span>
1786
+ </div>
1787
+ `),typeof s.score=="number"&&W.push(`
1788
+ <div class="meta-item">
1789
+ <span class="meta-label">Relevance Score</span>
1790
+ <span class="meta-value">${s.score.toFixed(2)}</span>
1791
+ </div>
1792
+ `),s.sheetName&&W.push(`
1793
+ <div class="meta-item">
1794
+ <span class="meta-label">Sheet Name</span>
1795
+ <span class="meta-value">${O(s.sheetName)}</span>
1796
+ </div>
1797
+ `),(s.rowNumber||s.rowNumber===0)&&W.push(`
1798
+ <div class="meta-item">
1799
+ <span class="meta-label">Row Number</span>
1800
+ <span class="meta-value">${s.rowNumber}</span>
1801
+ </div>
1802
+ `),s.knowledgeName&&W.push(`
1803
+ <div class="meta-item">
1804
+ <span class="meta-label">Database Source</span>
1805
+ <span class="meta-value">${O(s.knowledgeName)}</span>
1806
+ </div>
1807
+ `),W.push(`
1808
+ <div class="meta-item">
1809
+ <span class="meta-label">Classification</span>
1810
+ <span class="meta-value">Uploaded Knowledge</span>
1811
+ </div>
1812
+ <div class="meta-item">
1813
+ <span class="meta-label">Confidentiality</span>
1814
+ <span class="meta-value" style="color: #0f766e;">Public</span>
1815
+ </div>
1816
+ <div class="meta-item">
1817
+ <span class="meta-label">Language</span>
1818
+ <span class="meta-value">English</span>
1819
+ </div>
1820
+ `);let an=W.join(""),on=S?O(S):"No text snippet available for this citation.",sn=`
1821
+ <div class="doc-badge-wrapper">
1822
+ <div class="doc-icon">\u{1F4C4}</div>
1823
+ <div class="doc-badge-info">
1824
+ <h2>Document Citation</h2>
1825
+ </div>
1826
+ </div>
1827
+
1828
+ <div class="doc-title-section">
1829
+ <h1>${O(d)}</h1>
1830
+ <div class="doc-source-type">Uploaded Knowledge Resource</div>
1831
+ </div>
1832
+
1833
+ <div class="section-divider"></div>
1834
+
1835
+ <div>
1836
+ <h3 class="meta-section-title">Retrieved Passage Snippet</h3>
1837
+ <div class="summary-box">${on}</div>
1838
+ </div>
1839
+
1840
+ <div class="section-divider"></div>
1841
+
1842
+ <div>
1843
+ <h3 class="meta-section-title">Metadata & Classification</h3>
1844
+ <div class="meta-list">
1845
+ ${an}
1846
+ </div>
1847
+ </div>
1848
+ `,Ee="";I?Ee=`<iframe src="${I}" title="Document Viewer"></iframe>`:Ee=`
1849
+ <div class="viewer-toolbar">
1850
+ <div class="toolbar-left">${O(d)}</div>
1851
+ <div class="toolbar-center">
1852
+ <button class="toolbar-btn zoom-out-btn">\u2212</button>
1853
+ <span class="page-indicator">Page ${s.pageNumber||1}</span>
1854
+ <button class="toolbar-btn zoom-in-btn">+</button>
1855
+ </div>
1856
+ <div class="toolbar-right">
1857
+ <button class="toolbar-btn print-btn">\u{1F5A8}\uFE0F Print</button>
1858
+ </div>
1859
+ </div>
1860
+ <div class="viewer-body">
1861
+ <div class="document-sheet">
1862
+ <div class="sheet-header">
1863
+ <span>${O(d)}</span>
1864
+ <span>Page ${s.pageNumber||1}</span>
1865
+ </div>
1866
+ <div class="sheet-content">${O(m||"No document content retrieved.")}</div>
1867
+ <div class="sheet-footer">
1868
+ <span>Confidentiality: Public</span>
1869
+ <span>Knowledge Platform CB</span>
1870
+ </div>
1871
+ </div>
1872
+ </div>
1873
+ `,te.textContent="";let dt=a("header","kp-citation-overlay-header"),ut=a("div","kp-citation-overlay-brand");ut.innerHTML=`
1874
+ <span class="kp-citation-overlay-brand-logo">\u2726</span>
1875
+ <span>Knowledge Assistant Document Viewer</span>
1876
+ `;let he=a("button","kp-citation-overlay-close","\xD7");he.type="button",he.setAttribute("aria-label","Close document preview"),he.addEventListener("click",()=>{te.classList.remove("open")}),dt.append(ut,he);let gt=a("div","kp-citation-overlay-content"),ft=a("aside","kp-citation-overlay-metadata-panel");ft.innerHTML=sn;let Y=a("main","kp-citation-overlay-viewer-panel");if(Y.innerHTML=Ee,gt.append(ft,Y),te.append(dt,gt),!I){let q=1,N=Y.querySelector(".document-sheet"),rn=Y.querySelector(".zoom-in-btn"),ln=Y.querySelector(".zoom-out-btn"),pn=Y.querySelector(".print-btn");N&&(rn?.addEventListener("click",()=>{q<1.5&&(q+=.1,N.style.transform=`scale(${q})`)}),ln?.addEventListener("click",()=>{q>.6&&(q-=.1,N.style.transform=`scale(${q})`)}),pn?.addEventListener("click",()=>{window.print()}))}te.classList.add("open")},ne=(s,d)=>{if(i.sourcePanelOpen=!0,i.sourcePanelTitle=d??n.allSourcesUsed,at.textContent=i.sourcePanelTitle,ue.classList.add("open"),ee.textContent="",s.length===0){ee.appendChild(a("div","kp-source-panel-empty",n.noSources));return}for(let m of s)ee.appendChild(Sn(m,n,()=>{F(m)}))},_=()=>{i.sourcePanelOpen=!1,i.sourcePanelTitle=null,ue.classList.remove("open")};Q(E,t.initialSuggestions,async s=>{await $(s,E)}),Q(C,t.initialSuggestions,async s=>{await $(s,C)}),D(),fe(),l&&(R(),t.rag.loadHistoryOnOpen&&K(C,i.chatId));function Se(){if(l){i.fullPageOpen=!0,A.classList.add("open");return}i.open||(i.open=!0,i.fullPageOpen=!1,M(),A.classList.remove("open"),f.classList.add("hidden"),g.classList.add("visible"),h.classList.add("open"),t.onOpen?.(),t.rag.loadHistoryOnOpen&&Te.loadHistory(),queueMicrotask(()=>z.focus()))}function j(){if(l){_();return}i.open&&(H(),M(),i.open=!1,f.classList.remove("hidden"),g.classList.remove("visible"),h.classList.remove("open"),t.onClose?.())}async function $(s,d){let m=s.trim();if(!m)return;d.input.value="";try{await Zt(m)}catch(L){let I=V(t,L);se(d.body,"bot",`${n.unableToCreateChat}: ${I.message}`,{strings:n,view:d,userName:null,onShowSources:ne,onShowCitation:F});return}At(d),se(d.body,"user",m,{strings:n,view:d,userName:await ot(),onShowSources:ne,onShowCitation:F}),d.body.scrollTop=d.body.scrollHeight;let S=a("div","kp-loading",n.thinking);d.body.appendChild(S),d.body.scrollTop=d.body.scrollHeight;try{let L=await bt(B(),{message:m,chatId:i.chatId,knowledgeNames:await dn(t),...t.rag.enableReferences!==void 0?{enableReferences:t.rag.enableReferences}:{}});S.isConnected&&S.remove(),se(d.body,"bot",L.answer,{strings:n,view:d,userName:null,citations:L.citations??[],onShowSources:ne,onShowCitation:F}),i.historyLoadedChatId=null,await R(),L.suggestions?.length&&Q(d,L.suggestions,async I=>{await $(I,d)})}catch(L){let I=V(t,L);S.isConnected&&S.remove(),se(d.body,"bot",`${n.requestFailed}: ${I.message}`,{strings:n,view:d,userName:null,onShowSources:ne,onShowCitation:F})}}async function st(s){let d=i.fullPageOpen?C:E;await $(s,d)}async function Xt(){if(l){i.fullPageOpen=!0,A.classList.add("open"),await R(),await K(C,i.chatId),queueMicrotask(()=>T.focus());return}i.fullPageOpen=!0,i.open=!1,H(),M(),h.classList.remove("open"),g.classList.remove("visible"),f.classList.add("hidden"),A.classList.add("open"),await R(),await K(C,i.chatId),queueMicrotask(()=>T.focus())}function it(){if(l){_();return}i.fullPageOpen&&(i.fullPageOpen=!1,A.classList.remove("open"),f.classList.remove("hidden"),_())}function Jt(){i.menuOpen=!0,b.classList.add("open"),y.classList.add("open")}function H(){i.menuOpen=!1,b.classList.remove("open"),y.classList.remove("open")}function Qt(){i.chatId=be(t),i.historyLoadedChatId=null,M(),oe(E),Q(E,t.initialSuggestions,async s=>{await $(s,E)}),H()}async function Gt(){i.chatId=be(t),i.historyLoadedChatId=null,oe(C),_(),Q(C,t.initialSuggestions,async s=>{await $(s,C)}),D()}async function R(){if(!t.endpoints.listChats)return D(),fe(),[];i.loadingChats=!0,D(),fe();try{let s=await kt(B());return i.chats=s,s}catch(s){return V(t,s),i.chats}finally{i.loadingChats=!1,D(),fe()}}async function Zt(s){!t.endpoints.listChats&&!t.endpoints.createChat||i.chats.some(d=>d.chatId===i.chatId)||await yt(B(),i.chatId,s?mn(s,n.newChat):void 0)}async function en(s){i.chatId=s,i.historyLoadedChatId=null,await K(C,s),D()}async function tn(s){i.chatId=s,i.historyLoadedChatId=null,await K(E,s),M()}async function nn(){H(),await R(),i.myChatsOpen=!0,h.classList.add("kp-sheet-open"),le.classList.add("open")}function M(){i.myChatsOpen=!1,h.classList.remove("kp-sheet-open"),le.classList.remove("open")}async function rt(s){if(!t.endpoints.updateChat)return;let d=window.prompt(n.renamePrompt,s.title)?.trim();if(!(!d||d===s.title))try{await Ie(B(),s.chatId,{title:d}),await R()}catch(m){V(t,m)}}async function lt(s){if(t.endpoints.deleteChat)try{await vt(B(),s.chatId),i.chatId===s.chatId&&(i.chatId=be(t),i.historyLoadedChatId=null,oe(E),oe(C)),await R()}catch(d){V(t,d)}}function D(){St(Ye,Xe,i,n,async s=>{await en(s.chatId)},async s=>{await pt(s)},async s=>{await rt(s)},async s=>{await lt(s)})}function fe(){St(je,De,i,n,async s=>{await tn(s.chatId)},async s=>{await pt(s)},async s=>{await rt(s)},async s=>{await lt(s)})}async function pt(s){if(t.endpoints.updateChat)try{await Ie(B(),s.chatId,{pinned:!s.pinned}),await R()}catch(d){V(t,d)}}async function K(s,d){oe(s),Q(s,t.initialSuggestions,async S=>{await $(S,s)});let m=await xt(B(),d);return m.length>0&&(At(s),Rt(s.body,s.hero,s.suggestions),hn(s.body,m,{strings:n,view:s,userName:await ot(),onShowSources:ne,onShowCitation:F})),i.historyLoadedChatId=d,m}let Te={open:Se,close:j,toggle(){if(l){Se();return}if(i.open){j();return}Se()},destroy(){if(document.removeEventListener("keydown",ct),p.remove(),l){let s=!1;document.querySelectorAll("[data-chat-widget-host]").forEach(d=>{let m=d.shadowRoot;m&&m.querySelector(".kp-chat-widget-embedded")&&(s=!0)}),s||Et(!1)}},sendMessage:st,setAccessTokenProvider(s){i.accessTokenProvider=s},getChatId(){return i.chatId},loadChats(){return R()},async loadHistory(){let s=i.fullPageOpen?C:E;return K(s,i.chatId)}};f.addEventListener("click",()=>Te.toggle()),ie.addEventListener("click",j),g.addEventListener("click",j),ge.addEventListener("click",_),pe.addEventListener("click",M),ce.addEventListener("click",M),b.addEventListener("click",s=>{if(s.stopPropagation(),!i.menuOpen){Jt();return}H()}),x.addEventListener("click",Qt),U.addEventListener("click",async()=>{await nn()}),w.addEventListener("click",()=>{if(H(),t.onOpenAssistantPage){j(),t.onOpenAssistantPage();return}if(t.assistantPageUrl){j(),window.location.href=t.assistantPageUrl;return}Xt()}),de.addEventListener("click",it),we.addEventListener("click",()=>{Gt(),queueMicrotask(()=>T.focus())}),Z.addEventListener("input",()=>{i.chatSearchTerm=Z.value.trim().toLowerCase(),D()}),h.addEventListener("click",s=>{let d=s.target;if(!(d instanceof Element)||!d.closest(".kp-chat-actions")){for(let m of Array.from(c.querySelectorAll(".kp-chat-actions.open")))m.classList.remove("open");for(let m of Array.from(c.querySelectorAll(".kp-full-page-chat-item.menu-open")))m.classList.remove("menu-open")}i.menuOpen&&!y.contains(d)&&!b.contains(d)&&H(),s.stopPropagation()}),c.addEventListener("click",s=>{let d=s.target;if(i.menuOpen&&d instanceof Node&&!y.contains(d)&&!b.contains(d)&&H(),d instanceof Element&&!d.closest(".kp-chat-actions")){for(let m of Array.from(c.querySelectorAll(".kp-chat-actions.open")))m.classList.remove("open");for(let m of Array.from(c.querySelectorAll(".kp-full-page-chat-item.menu-open")))m.classList.remove("menu-open")}}),ke.addEventListener("submit",async s=>{s.preventDefault(),await st(z.value)}),Pe.addEventListener("submit",async s=>{s.preventDefault(),await $(T.value,C)});function ct(s){if(s.key==="Escape"){if(i.sourcePanelOpen){_();return}if(i.myChatsOpen){M();return}if(i.fullPageOpen){if(l)return;it();return}i.open&&j()}}return document.addEventListener("keydown",ct),Te}async function dn(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 be(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 se(e,t,o,n){let r=t==="bot"?yn(o,n.citations??[]):{displayText:o,citations:n.citations??[]},l=a("div",`kp-message-row ${t}`),i=gn(t==="bot"?n.strings.assistantAvatar:n.userName??n.strings.userAvatar,t),p=a("div",`kp-bubble ${t}`),c=a("div","kp-bubble-content");En(c,r.displayText),p.appendChild(c);let u=r.citations;if(u.length){let g=a("div","kp-meta",n.strings.citationsAttached(u.length));p.appendChild(g);let f=a("div","kp-source-preview"),h=a("div","kp-source-preview-title",n.strings.sourcesUsed),v=a("div","kp-source-preview-list");for(let b of u.slice(0,2)){let y=Pn(b,n.strings);y.addEventListener("click",async()=>{n.onShowCitation(b)}),v.appendChild(y)}let P=An(n.strings);P.addEventListener("click",async()=>{n.onShowSources(u,n.strings.allSourcesUsed)}),v.appendChild(P),f.append(h,v),p.appendChild(f)}return t==="bot"&&p.appendChild(un(r.displayText,n.strings)),t==="user"?l.append(p,i):l.append(i,p),e.appendChild(l),e.scrollTop=e.scrollHeight,l}function un(e,t){let o=a("div","kp-message-actions"),n=a("button","kp-message-action",t.copy);n.type="button",n.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(e),n.textContent=t.copied,window.setTimeout(()=>{n.textContent=t.copy},1200)}catch{n.textContent=t.copy}});let r=a("button","kp-message-action","\u{1F44D}");r.type="button",r.setAttribute("aria-label",t.helpful),r.addEventListener("click",()=>{r.classList.toggle("active"),l.classList.remove("active")});let l=a("button","kp-message-action","\u{1F44E}");return l.type="button",l.setAttribute("aria-label",t.notHelpful),l.addEventListener("click",()=>{l.classList.toggle("active"),r.classList.remove("active")}),o.append(n,r,l),o}function gn(e,t){let o=a("div",`kp-avatar ${t}`),n=t==="bot"?"\u2726":kn(e);return o.textContent=n,o.setAttribute("aria-hidden","true"),o}function fn(e,t,o){e.textContent="";for(let n of t){let r=a("button","kp-suggestion",n);r.type="button",r.addEventListener("click",async()=>{await o(n)}),e.appendChild(r)}}function Q(e,t,o){fn(e.suggestions,t,async n=>{e.input.value=n,await o(n)})}function Rt(e,t,o){let n=new Set([t,o]);for(let r of Array.from(e.children))n.has(r)||r.remove()}function At(e){e.body.classList.add("kp-conversation-active"),e.hero.remove(),e.suggestions.remove()}function oe(e){e.body.classList.remove("kp-conversation-active"),e.hero.isConnected||e.body.prepend(e.hero),e.suggestions.isConnected||e.body.appendChild(e.suggestions),Rt(e.body,e.hero,e.suggestions),e.input.value=""}function hn(e,t,o){for(let n of t)se(e,n.role==="assistant"?"bot":"user",n.text,o)}function St(e,t,o,n,r,l,i,p){if(e.textContent="",t.textContent="",o.loadingChats){e.appendChild(a("div","kp-full-page-empty",n.loadingChats));return}let c=o.chats.filter(u=>o.chatSearchTerm?u.title.toLowerCase().includes(o.chatSearchTerm):!0);if(c.length>0){let u=c.filter(f=>f.pinned),g=c.filter(f=>!f.pinned).slice(0,8);Tt(e,g,o.chatId,n,r,l,i,p),Tt(t,u,o.chatId,n,r,l,i,p),g.length===0&&e.appendChild(a("div","kp-full-page-empty",n.noRecentChats)),u.length===0&&t.appendChild(a("div","kp-full-page-empty",n.noPinnedChats));return}e.appendChild(a("div","kp-full-page-empty",n.noChats)),t.appendChild(a("div","kp-full-page-empty",n.noPinnedChats))}function Tt(e,t,o,n,r,l,i,p){for(let c of t){let u=a("div",`kp-full-page-item kp-full-page-chat-item${c.chatId===o?" active":""}`),g=a("span","kp-full-page-item-title",c.title),f=a("div","kp-chat-actions"),h=a("button","kp-chat-actions-trigger","\u22EF");h.type="button",h.setAttribute("aria-label",n.chatActions);let v=a("div","kp-chat-actions-menu"),P=a("button","kp-chat-actions-item",c.pinned?n.unpinChat:n.pinChat);P.type="button",P.addEventListener("click",async x=>{x.stopPropagation(),await l(c)});let b=a("button","kp-chat-actions-item",n.renameChat);b.type="button",b.addEventListener("click",async x=>{x.stopPropagation(),await i(c)});let y=a("button","kp-chat-actions-item",n.deleteChat);y.type="button",y.addEventListener("click",async x=>{x.stopPropagation(),await p(c)}),v.append(P,b,y),f.append(h,v),h.addEventListener("click",x=>{x.stopPropagation();let U=f.classList.contains("open");for(let w of Array.from(e.querySelectorAll(".kp-chat-actions.open")))w.classList.remove("open");for(let w of Array.from(e.querySelectorAll(".kp-full-page-chat-item.menu-open")))w.classList.remove("menu-open");U||(f.classList.add("open"),u.classList.add("menu-open"))}),u.append(g,f),u.setAttribute("role","button"),u.tabIndex=0,u.addEventListener("click",async()=>{await r(c)}),u.addEventListener("keydown",async x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),await r(c))}),u.addEventListener("blur",()=>{f.classList.remove("open"),u.classList.remove("menu-open")}),e.appendChild(u)}}function mn(e,t){return e.trim().slice(0,60)||t}function $e(e){return e.toLowerCase().split("-")[0]||"en"}function bn(e){let t=Pt.en;return Pt[$e(e)]??t}function xn(e){return["ar","fa","he","ur"].includes($e(e))}function kn(e){let t=e.split(/\s+/).filter(Boolean).slice(0,2);return t.length===0?"U":t.map(o=>o[0]?.toUpperCase()??"").join("")}function He(e){if(e.knowledgeName?.trim())return e.knowledgeName.trim();if(e.text){let t=e.text.split(`
1877
+ `)[0]?.trim();if(t){let o=t.replace(/\s*\|\s*Page\s*\d+\s*$/i,"").trim();if(o)return o}}if(e.sourceDocument&&/^https?:\/\//i.test(e.sourceDocument)){try{let t=new URL(e.sourceDocument),o=decodeURIComponent(t.pathname),n=o.substring(o.lastIndexOf("/")+1);if(n)return n}catch{}return e.sourceDocument}return e.sourceDocument?.trim()&&!/^c\d+$/i.test(e.sourceDocument)?e.sourceDocument.trim():null}function yn(e,t){let o=vn(e);return{displayText:o.displayText,citations:t.length>0?Ln(t,o.citations):o.citations}}function vn(e){let o=It(e).split(`
1878
+ `),n=-1;for(let c=0;c<o.length;c+=1)/^#{0,6}\s*References\s*$/i.test(o[c]?.trim()??"")&&(n=c);if(n===-1)return{displayText:e,citations:[]};let r=o.slice(0,n).join(`
1879
+ `).trimEnd(),l=o.slice(n+1).join(`
1880
+ `).trim(),p=wn(l).map(c=>Cn(c)).filter(c=>!!c);return{displayText:r,citations:p}}function wn(e){let t=[],o="";for(let n of e.split(`
1881
+ `)){let r=n.trim();if(r){if(/^\d+\.\s+/.test(r)){o&&t.push(o.trim()),o=r.replace(/^\d+\.\s+/,"");continue}o&&(o=`${o} ${r}`)}}return o&&t.push(o.trim()),t}function Cn(e){let t=e.match(/https?:\/\/\S+/i);if(!t)return null;let o=t[0],n=e.slice(0,t.index).replace(/[.\s]+$/,"").trim();return{sourceDocument:o,knowledgeName:n||o}}function Ln(e,t){let o=[],n=new Set;for(let r of[...e,...t]){let l=`${r.knowledgeName??""}::${r.sourceDocument??""}`;n.has(l)||(n.add(l),o.push(r))}return o}function Pn(e,t){let o=a("button","kp-source-chip");o.type="button",o.setAttribute("aria-label",t.openSource);let n=a("span","kp-source-thumb");n.textContent="\u2726";let r=a("span","kp-source-chip-label",He(e)??t.untitledSource);return o.append(n,r),o}function An(e){let t=a("button","kp-source-chip kp-source-chip-more");t.type="button";let o=a("span","kp-source-thumb-stack");for(let r=0;r<3;r+=1){let l=a("span","kp-source-thumb stacked");l.textContent="\u2726",o.appendChild(l)}let n=a("span","kp-source-chip-label",e.showAll);return t.append(o,n),t}function Sn(e,t,o){let n=a("button","kp-source-card");n.type="button",n.setAttribute("aria-label",t.openSource),n.addEventListener("click",o);let r=a("div","kp-source-card-media"),l=a("span","kp-source-thumb kp-source-thumb-large");l.textContent="\u2726";let i=a("div","kp-source-card-title",He(e)??t.untitledSource),p=a("div","kp-source-card-meta"),c=[];return typeof e.score=="number"&&c.push(`${t.sourceScore}: ${e.score.toFixed(2)}`),typeof e.pageNumber=="number"&&c.push(`${t.sourcePage}: ${e.pageNumber}`),e.sheetName&&c.push(`${t.sourceSheet}: ${e.sheetName}`),typeof e.rowNumber=="number"&&c.push(`${t.sourceRow}: ${e.rowNumber}`),e.knowledgeName&&c.push(`${t.sourceKnowledge}: ${e.knowledgeName}`),p.textContent=c.join(" \u2022 "),r.appendChild(l),n.append(r,i,p),n}function Tn(e){if(!e)return null;let t=e.trim();return/^https?:\/\//i.test(t)?t:null}function En(e,t){e.innerHTML=Rn(It(t))}function It(e){return e.replace(/\r\n/g,`
1882
+ `).replace(/<br\s*\/?>/gi,`
1883
+ `)}function Rn(e){return e.split(/\n{2,}/).map(o=>o.trim()).filter(Boolean).map(In).join("")}function In(e){let t=e.split(`
1884
+ `).map(n=>n.trimEnd());if(t.every(n=>/^\s*\|.*\|\s*$/.test(n))&&t.length>=2)return zn(t);if(t.every(n=>/^\d+\.\s+/.test(n)))return`<ol>${t.map(n=>`<li>${G(n.replace(/^\d+\.\s+/,""))}</li>`).join("")}</ol>`;if(t.every(n=>/^[-*]\s+/.test(n)))return`<ul>${t.map(n=>`<li>${G(n.replace(/^[-*]\s+/,""))}</li>`).join("")}</ul>`;let o=t[0]?.match(/^(#{1,6})\s+(.*)$/);if(o){let n=o[1]??"#",r=o[2]??"",l=n.length;return`<h${l}>${G(r)}</h${l}>`}return`<p>${t.map(n=>G(n)).join("<br>")}</p>`}function zn(e){let t=e.filter((i,p)=>!(p===1&&/^\s*\|?(\s*:?-{3,}:?\s*\|)+\s*$/.test(i))).map(i=>$n(i));if(t.length===0)return"";let o=t[0]??[],n=t.slice(1),r=`<thead><tr>${o.map(i=>`<th>${G(i)}</th>`).join("")}</tr></thead>`,l=n.length?`<tbody>${n.map(i=>`<tr>${i.map(p=>`<td>${G(p)}</td>`).join("")}</tr>`).join("")}</tbody>`:"";return`<div class="kp-table-wrap"><table>${r}${l}</table></div>`}function $n(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim())}function G(e){let t=O(e);return t=t.replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>'),t=t.replace(/`([^`]+)`/g,"<code>$1</code>"),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replace(/\*([^*]+)\*/g,"<em>$1</em>"),t}function O(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Et(e){typeof document>"u"||document.querySelectorAll("[data-chat-widget-host]").forEach(t=>{let o=t.shadowRoot;if(o){let n=o.querySelector(".kp-chat-widget");n&&!n.classList.contains("kp-chat-widget-embedded")&&(t.style.display=e?"none":"")}})}export{Kn as a};
1885
+ //# sourceMappingURL=chunk-JHMDAOE6.js.map