@nabeh/chat-widget 0.1.3 → 0.1.5

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