@8wave/ai-elements 0.98.0 → 0.99.0-beta.1

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.
Files changed (76) hide show
  1. package/README.md +24 -5
  2. package/dist/_chunks/{PkToolShowForm-BNV4Ja6g.js → PkToolShowForm-dFuoqTPs.js} +84 -80
  3. package/dist/_chunks/PkToolShowForm-dFuoqTPs.js.map +1 -0
  4. package/dist/ai-elements.es.js +3153 -2982
  5. package/dist/ai-elements.es.js.map +1 -1
  6. package/dist-vue/PkChatbot.js +1 -1
  7. package/dist-vue/PkChatbotMessages.js +1 -1
  8. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  9. package/dist-vue/PkChatbotSteps.js +1 -1
  10. package/dist-vue/PkChatbotViewChat.js +1 -1
  11. package/dist-vue/PkChatbotViewConversations.js +1 -1
  12. package/dist-vue/PkChatbotViewFiles.js +1 -1
  13. package/dist-vue/PkChatbotViewProfile.js +1 -1
  14. package/dist-vue/_chunks/{PkChatbot-DHkhT0Jf.js → PkChatbot-BlG1WlAO.js} +7 -7
  15. package/dist-vue/_chunks/{PkChatbot-DHkhT0Jf.js.map → PkChatbot-BlG1WlAO.js.map} +1 -1
  16. package/dist-vue/_chunks/PkChatbotMessages-BrufA7o1.js +752 -0
  17. package/dist-vue/_chunks/PkChatbotMessages-BrufA7o1.js.map +1 -0
  18. package/dist-vue/_chunks/{PkChatbotStepToolDetail-ldThv0t5.js → PkChatbotStepToolDetail-BVI72gyx.js} +2 -2
  19. package/dist-vue/_chunks/{PkChatbotStepToolDetail-ldThv0t5.js.map → PkChatbotStepToolDetail-BVI72gyx.js.map} +1 -1
  20. package/dist-vue/_chunks/PkChatbotSteps-Dv9NkYER.js +172 -0
  21. package/dist-vue/_chunks/{PkChatbotSteps-BpqdFhsG.js.map → PkChatbotSteps-Dv9NkYER.js.map} +1 -1
  22. package/dist-vue/_chunks/{PkChatbotViewChat-C08TsXiL.js → PkChatbotViewChat-CAqvbbfN.js} +66 -66
  23. package/dist-vue/_chunks/PkChatbotViewChat-CAqvbbfN.js.map +1 -0
  24. package/dist-vue/_chunks/{PkChatbotViewConversations-BQZi5kSC.js → PkChatbotViewConversations-Cq41H-tc.js} +2 -2
  25. package/dist-vue/_chunks/{PkChatbotViewConversations-BQZi5kSC.js.map → PkChatbotViewConversations-Cq41H-tc.js.map} +1 -1
  26. package/dist-vue/_chunks/{PkChatbotViewFiles-TLKE_tRw.js → PkChatbotViewFiles-DNuzmBJc.js} +2 -2
  27. package/dist-vue/_chunks/{PkChatbotViewFiles-TLKE_tRw.js.map → PkChatbotViewFiles-DNuzmBJc.js.map} +1 -1
  28. package/dist-vue/_chunks/{PkChatbotViewProfile-B6ANZY96.js → PkChatbotViewProfile-C0BXIY2N.js} +2 -2
  29. package/dist-vue/_chunks/{PkChatbotViewProfile-B6ANZY96.js.map → PkChatbotViewProfile-C0BXIY2N.js.map} +1 -1
  30. package/dist-vue/_chunks/{PkToolShowForm-C-mWyeka.js → PkToolShowForm-CQuX08lk.js} +62 -58
  31. package/dist-vue/_chunks/PkToolShowForm-CQuX08lk.js.map +1 -0
  32. package/dist-vue/_chunks/{createChatbotApiClient-BOBdBxmf.js → createChatbotApiClient-BMZltBLh.js} +367 -363
  33. package/dist-vue/_chunks/createChatbotApiClient-BMZltBLh.js.map +1 -0
  34. package/dist-vue/_chunks/{useChatbotStore-BJ-EDmND.js → useChatbotStore-DZiorgLW.js} +113 -103
  35. package/dist-vue/_chunks/{useChatbotStore-BJ-EDmND.js.map → useChatbotStore-DZiorgLW.js.map} +1 -1
  36. package/dist-vue/_chunks/{utils-BMa8jwJS.js → utils-Cru8TJxe.js} +48 -30
  37. package/dist-vue/_chunks/utils-Cru8TJxe.js.map +1 -0
  38. package/dist-vue/api.js +1 -1
  39. package/dist-vue/composables.js +3 -3
  40. package/dist-vue/index.js +4351 -4041
  41. package/dist-vue/index.js.map +1 -1
  42. package/dist-vue/locales.js +16 -0
  43. package/dist-vue/packages/components/src/PkCheckboxField.d.ts +45 -0
  44. package/dist-vue/packages/components/src/PkEditorRepeater.d.ts +2 -2
  45. package/dist-vue/packages/components/src/PkPwaInstallPrompt.d.ts +4 -0
  46. package/dist-vue/packages/components/src/PkPwaOfflineNotice.d.ts +4 -0
  47. package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +11 -2
  48. package/dist-vue/packages/components/src/chat/PkChatbotMessages.d.ts +24 -2
  49. package/dist-vue/packages/components/src/chat/PkToolApprovalBadge.d.ts +4 -0
  50. package/dist-vue/packages/components/src/chat/PkToolApprovalCard.d.ts +35 -0
  51. package/dist-vue/packages/components/src/chat/PkToolApprovalPreviewMessage.d.ts +11 -0
  52. package/dist-vue/packages/components/src/chat/index.d.ts +2 -1
  53. package/dist-vue/packages/components/src/chat/toolApprovalPreviews.d.ts +12 -0
  54. package/dist-vue/packages/components/src/chat/toolComponentMap.d.ts +5 -3
  55. package/dist-vue/packages/components/src/chat/useChatScroll.d.ts +6 -0
  56. package/dist-vue/packages/components/src/chat/utils.d.ts +13 -0
  57. package/dist-vue/packages/components/src/index.d.ts +4 -1
  58. package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +34 -1
  59. package/dist-vue/packages/models/src/schema/Agent.d.ts +48 -0
  60. package/dist-vue/packages/models/src/schema/ReasoningChat.d.ts +6 -0
  61. package/dist-vue/packages/models/src/schema/SubAgent.d.ts +6 -0
  62. package/dist-vue/style.css +1 -1
  63. package/package.json +1 -1
  64. package/dist/_chunks/PkToolRequestConfirm-FQ9nDFXy.js +0 -48
  65. package/dist/_chunks/PkToolRequestConfirm-FQ9nDFXy.js.map +0 -1
  66. package/dist/_chunks/PkToolShowForm-BNV4Ja6g.js.map +0 -1
  67. package/dist-vue/_chunks/PkChatbotMessages-B4qfTNOJ.js +0 -630
  68. package/dist-vue/_chunks/PkChatbotMessages-B4qfTNOJ.js.map +0 -1
  69. package/dist-vue/_chunks/PkChatbotSteps-BpqdFhsG.js +0 -172
  70. package/dist-vue/_chunks/PkChatbotViewChat-C08TsXiL.js.map +0 -1
  71. package/dist-vue/_chunks/PkToolRequestConfirm-CQNa3seA.js +0 -48
  72. package/dist-vue/_chunks/PkToolRequestConfirm-CQNa3seA.js.map +0 -1
  73. package/dist-vue/_chunks/PkToolShowForm-C-mWyeka.js.map +0 -1
  74. package/dist-vue/_chunks/createChatbotApiClient-BOBdBxmf.js.map +0 -1
  75. package/dist-vue/_chunks/utils-BMa8jwJS.js.map +0 -1
  76. package/dist-vue/packages/components/src/chat/PkToolRequestConfirm.d.ts +0 -11
@@ -1,630 +0,0 @@
1
- import { t as e } from "./PkChatbotError-B2iob9cQ.js";
2
- import "./src-8QXYVWIx.js";
3
- import { a as t, c as n, o as r, r as i, s as a, t as o } from "./message-RohfrdWS.js";
4
- import { r as ee } from "./text-CeT0hpJK.js";
5
- import { t as s } from "./PkRelativeTime-C9zd1ffO.js";
6
- import { t as c } from "./PkStreamingMarkdown-DEhbK-3c.js";
7
- import { t as l } from "./PkChatbotFeedbackForm-BSe40qlc.js";
8
- import { t as u } from "./PkChatbotMessageFeedback-BYmrVaCE.js";
9
- import { t as d } from "./PkChatbotFilePreview-DyrszALJ.js";
10
- import { n as f, t as p } from "./PkChatbotSteps-BpqdFhsG.js";
11
- import { a as m, d as h, i as te, l as g, n as _, r as v, u as ne } from "./utils-BMa8jwJS.js";
12
- import { t as y } from "./PkChatbotOutlineRail-np4g6vsz.js";
13
- import { VvButton as re, VvButtonGroup as ie, VvIcon as b } from "@volverjs/ui-vue/components";
14
- import { Fragment as x, Transition as S, computed as C, createBlock as w, createCommentVNode as T, createElementBlock as E, createElementVNode as D, createTextVNode as ae, createVNode as O, defineAsyncComponent as k, defineComponent as oe, mergeProps as se, nextTick as A, normalizeClass as ce, normalizeStyle as le, onBeforeUnmount as j, onMounted as ue, openBlock as M, ref as N, renderList as de, renderSlot as fe, resolveDynamicComponent as pe, toDisplayString as P, unref as F, useSlots as me, useTemplateRef as I, watch as L, withCtx as R, withModifiers as z } from "vue";
15
- import { useI18n as he } from "vue-i18n";
16
- //#region ../../packages/components/src/chat/toolComponentMap.ts
17
- var ge = {
18
- requestConfirm: k(() => import("./PkToolRequestConfirm-CQNa3seA.js")),
19
- requestOAuthConnection: k(() => import("./PkToolRequestOAuthConnection-lo7hCSBC.js")),
20
- showArtifact: k(() => import("./PkToolShowArtifact-CTBwt4DN.js").then((e) => e.n)),
21
- showCalendarEvent: k(() => import("./PkToolShowCalendarEvent-BmheHwOM.js").then((e) => e.n)),
22
- showComparison: k(() => import("./PkToolShowComparison-XJuKPuK2.js").then((e) => e.n)),
23
- showContactForm: k(() => import("./PkToolShowContactForm-B6-MsExL.js").then((e) => e.n)),
24
- showDiagram: k(() => import("./PkToolShowDiagram-G0hdi_Vf.js")),
25
- showEmail: k(() => import("./PkToolShowEmail-C591LR5N.js").then((e) => e.n)),
26
- showImageGallery: k(() => import("./PkToolShowImageGallery-Bj7YlqbP.js").then((e) => e.n)),
27
- showLocation: k(() => import("./PkToolShowLocation-5G8p9mED.js").then((e) => e.n)),
28
- showMessage: k(() => import("./PkToolShowMessage-CbXERPHI.js").then((e) => e.n)),
29
- showForm: k(() => import("./PkToolShowForm-C-mWyeka.js").then((e) => e.n)),
30
- showMultipleChoice: k(() => import("./PkToolShowForm-C-mWyeka.js").then((e) => e.n)),
31
- showProductList: k(() => import("./PkToolShowProductList-DXMN2UuE.js").then((e) => e.n)),
32
- showQrCode: k(() => import("./PkToolShowQrCode-DEAvfLFu.js").then((e) => e.n)),
33
- showSources: k(() => import("./PkToolShowSources-CFh-i60o.js").then((e) => e.n)),
34
- showSuggestedReply: k(() => import("./PkToolShowSuggestedReply-DoCHIEzz.js").then((e) => e.n)),
35
- showVideo: k(() => import("./PkToolShowVideo-Ox8rFd7j.js")),
36
- showWeather: k(() => import("./PkToolShowWeather-CxDO_5ni.js")),
37
- showWebPages: k(() => import("./PkToolShowWebPages-CsACREOH.js").then((e) => e.n))
38
- }, B = 30, V = 500;
39
- function _e(e) {
40
- let { scrollEl: t, status: n, messagesLength: r, lastMessageRole: i, contentEl: a, onScrollUp: o, onScrollDown: ee } = e, s = N(!1), c = N(!0), l = !1, u = null, d = null, f = null, p = null, m = 0, h = (e = "smooth") => {
41
- !t.value || s.value || (l = !0, t.value.scrollTo({
42
- top: t.value.scrollHeight,
43
- behavior: e
44
- }), setTimeout(() => {
45
- l = !1;
46
- }, e === "instant" ? 0 : V));
47
- }, te = (e) => {
48
- e.deltaY < 0 && (s.value = !0);
49
- }, g = 0, _ = (e) => {
50
- g = e.touches[0]?.clientY ?? 0;
51
- }, v = (e) => {
52
- let t = e.touches[0]?.clientY ?? 0;
53
- t > g && (s.value = !0), g = t;
54
- }, ne = () => {
55
- if (!t.value) return;
56
- let { scrollTop: e, scrollHeight: n, clientHeight: r } = t.value;
57
- if (c.value = n - r - e < B, l) {
58
- m = e;
59
- return;
60
- }
61
- e < m && o?.(), e > m && (c.value && (s.value = !1), ee?.()), m = e;
62
- }, y = () => {
63
- if (l || s.value || !t.value) return;
64
- let e = t.value, n = e.scrollHeight - e.clientHeight;
65
- n <= e.scrollTop || (c.value = !0, l = !0, e.scrollTop = n, requestAnimationFrame(() => {
66
- l = !1;
67
- }));
68
- }, re = () => {
69
- u || !t.value || (u = new MutationObserver(y), u.observe(t.value, {
70
- childList: !0,
71
- subtree: !0,
72
- characterData: !0
73
- }));
74
- }, ie = () => {
75
- u?.disconnect(), u = null;
76
- };
77
- L(n, (e, t) => {
78
- if (e === "streaming" || e === "submitted") {
79
- re();
80
- return;
81
- }
82
- e === "ready" && t === "streaming" || ie();
83
- }), L(r, async () => {
84
- r() && i() !== "assistant" && (S(), s.value = !1, l = !0, await A(), h());
85
- });
86
- let b = null, x = () => {
87
- t.value && (t.value.scrollHeight <= t.value.clientHeight || (t.value.scrollTop = t.value.scrollHeight, b && clearTimeout(b), b = setTimeout(S, 300)));
88
- }, S = () => {
89
- d?.disconnect(), d = null, f?.disconnect(), f = null, b &&= (clearTimeout(b), null);
90
- };
91
- return ue(() => {
92
- if (!t.value) return;
93
- t.value.addEventListener("wheel", te, { passive: !0 }), t.value.addEventListener("touchstart", _, { passive: !0 }), t.value.addEventListener("touchmove", v, { passive: !0 });
94
- let e = n() === "submitted" || n() === "streaming";
95
- e ? re() : (d = new ResizeObserver(x), d.observe(t.value), f = new MutationObserver(x), f.observe(t.value, {
96
- childList: !0,
97
- subtree: !0
98
- }));
99
- let r = a?.() ?? t.value.firstElementChild;
100
- r && (p = new ResizeObserver(y), p.observe(r)), e || x();
101
- }), j(() => {
102
- t.value?.removeEventListener("wheel", te), t.value?.removeEventListener("touchstart", _), t.value?.removeEventListener("touchmove", v), p?.disconnect(), p = null, ie(), S();
103
- }), {
104
- handleScroll: ne,
105
- scrollToBottom: h,
106
- userScrolledUp: s,
107
- isAtBottom: c
108
- };
109
- }
110
- //#endregion
111
- //#region ../../packages/components/src/chat/PkChatbotMessages.vue?vue&type=script&setup=true&lang.ts
112
- var ve = ["aria-busy"], ye = {
113
- key: 0,
114
- class: "pk-chatbot-messages__outline"
115
- }, be = {
116
- key: 0,
117
- class: "pk-chatbot-divider"
118
- }, xe = { class: "pk-chatbot-divider__label" }, Se = { class: "pk-chatbot-message__text" }, Ce = ["title"], we = {
119
- key: 0,
120
- class: "pk-chatbot-message__reaction-emoji"
121
- }, Te = {
122
- key: 0,
123
- class: "pk-chatbot-message__loading-info"
124
- }, Ee = { class: "flex gap-8 items-center" }, De = { class: "font-mono rounded text-12" }, Oe = { class: "flex gap-8 items-center" }, ke = {
125
- key: 0,
126
- class: "pk-chatbot-message__footer"
127
- }, Ae = {
128
- key: 0,
129
- class: "pk-chatbot-message__hover-meta"
130
- }, je = ["datetime", "title"], Me = { class: "truncate" }, Ne = {
131
- key: 0,
132
- class: "flex items-center gap-4 min-w-0"
133
- }, Pe = { class: "truncate" }, Fe = {
134
- key: 1,
135
- class: "flex items-center gap-4 text-12 text-word-3"
136
- }, Ie = { class: "truncate" }, Le = ["datetime"], Re = { class: "truncate" }, ze = {
137
- key: 3,
138
- class: "flex items-center gap-4 text-12 text-word-3"
139
- }, Be = ["title", "aria-label"], Ve = /* @__PURE__ */ oe({
140
- __name: "PkChatbotMessages",
141
- props: {
142
- status: {},
143
- messages: {},
144
- error: {},
145
- actions: {},
146
- mainColor: {},
147
- textColor: {},
148
- revisedAnswers: {},
149
- messageFeedbacks: {},
150
- readonlyFeedback: { type: Boolean },
151
- disableHeightAdjustment: { type: Boolean },
152
- showMessageDateTime: { type: Boolean },
153
- showMessageTokensCount: { type: Boolean },
154
- showAllMessageParts: { type: Boolean },
155
- showExtendedSteps: { type: Boolean },
156
- isDark: { type: Boolean },
157
- showScrollToBottom: { type: Boolean },
158
- feedbackMessageId: {},
159
- feedbackLoading: { type: Boolean },
160
- feedbackSubmitted: { type: Boolean },
161
- feedbackError: {}
162
- },
163
- emits: [
164
- "show-info",
165
- "regenerate",
166
- "revise",
167
- "upvote",
168
- "downvote",
169
- "feedback",
170
- "feedback-submit",
171
- "feedback-close",
172
- "scroll-up",
173
- "scroll-down",
174
- "auto-retry",
175
- "reset-chat"
176
- ],
177
- setup(k, { emit: oe }) {
178
- let j = k, ue = oe, { t: B, d: V, n: Ve } = he({ useScope: "global" }), He = me(), H = I("scrollEl"), U = I("wrapperEl"), Ue = C(() => h(j.textColor, j.mainColor)), We = I("messagesEl"), { handleScroll: Ge, scrollToBottom: Ke, userScrolledUp: qe, isAtBottom: Je } = _e({
179
- scrollEl: H,
180
- status: () => j.status,
181
- messagesLength: () => j.messages?.length,
182
- lastMessageRole: () => j.messages?.[j.messages.length - 1]?.role,
183
- contentEl: () => U.value,
184
- onScrollUp: () => ue("scroll-up"),
185
- onScrollDown: () => ue("scroll-down")
186
- }), Ye = () => {
187
- qe.value = !1, Ke();
188
- }, W = C(() => (j.messages ?? []).filter((e) => e.role === "user").map((e) => ({
189
- id: e.id,
190
- preview: e.parts.find(a)?.text.trim().slice(0, 120) || "…"
191
- }))), Xe = N(), Ze = () => H.value?.querySelectorAll(".pk-chatbot-message--user") ?? [], Qe = () => {
192
- let e = H.value;
193
- if (!e || !j.showScrollToBottom) return;
194
- let t = e.getBoundingClientRect().top + e.clientHeight / 2, n = W.value[0]?.id;
195
- Ze().forEach((e, r) => {
196
- e.getBoundingClientRect().top <= t && (n = W.value[r]?.id);
197
- }), Xe.value = n;
198
- };
199
- L(W, async () => {
200
- await A(), Qe();
201
- });
202
- let $e = () => {
203
- Ge(), Qe();
204
- }, et = (e) => {
205
- let t = H.value, n = W.value.findIndex((t) => t.id === e), r = Ze()[n];
206
- !t || !r || (qe.value = !0, t.scrollTo({
207
- top: t.scrollTop + r.getBoundingClientRect().top - t.getBoundingClientRect().top - Number.parseFloat(getComputedStyle(t).paddingTop),
208
- behavior: "smooth"
209
- }));
210
- }, G = N(0);
211
- L(() => [j.messages?.length, j.messages?.[j.messages.length - 1]?.id], async () => {
212
- let e = j.messages;
213
- if (!e?.length || j.disableHeightAdjustment || !(e[e.length - 1].role === "user" || j.status === "submitted" || j.status === "streaming") || (await A(), !H.value)) return;
214
- let { paddingTop: t, paddingBottom: n } = getComputedStyle(H.value), r = H.value.clientHeight - Number.parseFloat(t) - Number.parseFloat(n), i = U.value && Number.parseFloat(getComputedStyle(U.value).rowGap) || 0, a = e.map((e) => e.role).lastIndexOf("user"), o = r - (We.value?.[a]?.clientHeight ?? 0) - i;
215
- o > 0 && (G.value = o);
216
- }), L(() => j.status, (e) => {
217
- (e === "ready" || e === "error") && (G.value = 0);
218
- });
219
- let K = (e) => j.revisedAnswers?.some((t) => t.messageId === e), q = (e) => j.messageFeedbacks?.find((t) => t.messageId === e), tt = (e, t) => !j.readonlyFeedback && ht(e, t), nt = (e) => j.readonlyFeedback ? q(e) : void 0, J = (e) => nt(e)?.vote, Y = (e) => {
220
- let t = nt(e);
221
- if (t?.vote) return;
222
- let n = t?.metadata?.reactionEmoji;
223
- return typeof n == "string" && /\p{Extended_Pictographic}/u.test(n) ? n : void 0;
224
- }, rt = (e) => !!(J(e) || Y(e)), it = (e) => {
225
- if (Y(e)) return "pk-chatbot-message__reaction--neutral";
226
- let t = J(e);
227
- return t === "upvote" ? "pk-chatbot-message__reaction--positive" : t === "downvote" ? "pk-chatbot-message__reaction--negative" : "pk-chatbot-message__reaction--neutral";
228
- }, at = (e) => {
229
- let t = J(e);
230
- return B(t === "upvote" ? "hint.userFeedbackPositive" : t === "downvote" ? "hint.userFeedbackNegative" : "hint.userFeedbackReaction");
231
- }, ot = (e) => {
232
- let t = lt(e);
233
- for (let e = t.length - 1; e >= 0; --e) if (a(t[e])) return e;
234
- return -1;
235
- }, st = C(() => j.messages?.[j.messages.length - 1]), X = C(() => {
236
- let e = st.value;
237
- return e ? e.parts[e.parts.length - 1] : null;
238
- }), ct = C(() => {
239
- let e = /* @__PURE__ */ new Map();
240
- for (let t of j.messages ?? []) t.role === "assistant" && e.set(t.id, ne(t.parts));
241
- return e;
242
- }), lt = (e) => ct.value.get(e.id) ?? e.parts, Z = C(() => j.status === "submitted" || j.status === "streaming"), ut = C(() => j.status === "error"), dt = C(() => {
243
- let e = X.value;
244
- return m(B, e);
245
- }), ft = C(() => {
246
- let e = X.value;
247
- return v(e);
248
- }), pt = (e) => j.messages?.findIndex((t) => t.id === e), Q = (e) => e === void 0 || !j.messages ? !1 : e === j.messages.length - 1, mt = (e) => Q(e) && j.status === "ready" && !!j.actions?.includes("regenerate"), ht = (e, t) => (!Q(t) || j.status === "ready") && !!j.actions?.includes(e), gt = (e) => {
249
- let t = e.parts[e.parts.length - 1];
250
- return a(t);
251
- }, _t = (e) => e.parts.some((e) => r(e) || n(e)), vt = (e) => !!j.showExtendedSteps && $(e) && _t(e), $ = (e) => e.role === "assistant", yt = (e) => e.role === "user", bt = (e) => j.messages?.slice(0, e).reverse().find((e) => $(e)), xt = (e) => j.messages?.slice(e + 1).find((e) => $(e)), St = (e) => {
252
- let t = bt(e)?.metadata?.createdAt, n = xt(e)?.metadata?.createdAt;
253
- if (!t || !n) return;
254
- let r = new Date(t), i = new Date(n);
255
- return r.toDateString() === i.toDateString() ? void 0 : i;
256
- }, Ct = (e, t) => t === 0 || e.role !== "assistant" ? !1 : !!(j.actions?.length || j.showMessageDateTime && e.metadata?.createdAt !== void 0 || e.metadata?.completedAt !== void 0 || j.showMessageTokensCount && e.metadata?.totalTokens !== void 0), wt = (e) => {
257
- let t = new Date(e), n = t.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
258
- return V(t, n ? "time" : "date-time");
259
- }, Tt = (e) => {
260
- let { createdAt: t, completedAt: n } = e.metadata ?? {};
261
- if (!(!t || !n)) return _(Ve, n - t);
262
- }, Et = I("feedbackMessageEl");
263
- return L(() => j.feedbackMessageId, async () => {
264
- if (await A(), !j.feedbackMessageId) return;
265
- let e = Et.value?.[0]?.$el;
266
- if (e) {
267
- if (Q(pt(j.feedbackMessageId))) {
268
- Ke();
269
- return;
270
- }
271
- e.scrollIntoView({
272
- behavior: "smooth",
273
- block: "center"
274
- });
275
- }
276
- }), (r, m) => {
277
- let h = b, _ = re, ne = ie;
278
- return M(), E("div", {
279
- ref_key: "scrollEl",
280
- ref: H,
281
- class: "pk-chatbot-messages",
282
- role: "log",
283
- "aria-live": "polite",
284
- "aria-relevant": "additions text",
285
- "aria-busy": Z.value,
286
- style: le({
287
- "--chatbot-main-color": k.mainColor,
288
- "--chatbot-contrast-color": Ue.value
289
- }),
290
- onScroll: $e
291
- }, [
292
- k.showScrollToBottom && W.value.length > 1 ? (M(), E("div", ye, [O(y, {
293
- items: W.value,
294
- "active-id": Xe.value,
295
- onSelect: et
296
- }, null, 8, ["items", "active-id"])])) : T("", !0),
297
- D("div", {
298
- ref_key: "wrapperEl",
299
- ref: U,
300
- class: "pk-chatbot-messages__wrapper"
301
- }, [
302
- (M(!0), E(x, null, de(k.messages, (e, y) => (M(), E(x, { key: e.id }, [yt(e) && St(y) ? (M(), E("div", be, [D("span", xe, P(F(V)(St(y), "short")), 1)])) : T("", !0), e.parts.length || Q(y) && Z.value && $(e) ? (M(), E("div", {
303
- key: 1,
304
- ref_for: !0,
305
- ref: "messagesEl",
306
- class: ce(["pk-chatbot-message", [`pk-chatbot-message--${e.role}`, { "pk-chatbot-message--loading": Z.value && Q(y) && $(e) }]]),
307
- style: le({ minHeight: Q(y) && $(e) && !ut.value ? `${G.value}px` : void 0 })
308
- }, [
309
- O(S, {
310
- appear: "",
311
- name: "pk-chatbot-part"
312
- }, {
313
- default: R(() => [vt(e) ? (M(), w(p, {
314
- key: 0,
315
- message: e,
316
- "is-streaming": Z.value && Q(y),
317
- "is-dark": k.isDark
318
- }, null, 8, [
319
- "message",
320
- "is-streaming",
321
- "is-dark"
322
- ])) : T("", !0)]),
323
- _: 2
324
- }, 1024),
325
- (M(!0), E(x, null, de(lt(e), (s, l) => (M(), E(x, { key: l }, [F(a)(s) && s.text.trim() ? (M(), w(S, {
326
- key: 0,
327
- appear: "",
328
- name: "pk-chatbot-part"
329
- }, {
330
- default: R(() => [D("div", Se, [fe(r.$slots, "text", se({ ref_for: !0 }, {
331
- message: e,
332
- part: s,
333
- index: y,
334
- isLoading: Z.value
335
- }), () => [$(e) ? (M(), w(c, {
336
- key: 0,
337
- class: "wysiwyg",
338
- markdown: s.text,
339
- "is-dark": k.isDark,
340
- loading: Q(y) && k.status === "streaming"
341
- }, null, 8, [
342
- "markdown",
343
- "is-dark",
344
- "loading"
345
- ])) : (M(), E(x, { key: 1 }, [ae(P(s.text), 1)], 64))]), rt(e.id) && !q(e.id)?.comment && l === ot(e) ? (M(), E("span", {
346
- key: 0,
347
- class: ce(["pk-chatbot-message__reaction", it(e.id)]),
348
- title: at(e.id)
349
- }, [Y(e.id) ? (M(), E("span", we, P(Y(e.id)), 1)) : (M(), w(h, {
350
- key: 1,
351
- name: J(e.id) === "downvote" ? "ri:thumb-down-fill" : "ri:thumb-up-fill"
352
- }, null, 8, ["name"]))], 10, Ce)) : T("", !0)])]),
353
- _: 2
354
- }, 1024)) : F(t)(s) ? (M(), w(S, {
355
- key: 1,
356
- appear: "",
357
- name: "pk-chatbot-part"
358
- }, {
359
- default: R(() => [O(d, {
360
- "media-type": s.mediaType,
361
- url: s.url,
362
- filename: s.filename,
363
- size: F(o)(s)?.bytesCount
364
- }, null, 8, [
365
- "media-type",
366
- "url",
367
- "filename",
368
- "size"
369
- ])]),
370
- _: 2
371
- }, 1024)) : F(n)(s) && !F(g)(s) && (F(ge)[F(i)(s)] || F(He)[s.type] || k.showAllMessageParts) ? (M(), w(S, {
372
- key: 2,
373
- appear: "",
374
- name: "pk-chatbot-part"
375
- }, {
376
- default: R(() => [!F(He)[s.type] && F(ge)[F(i)(s)] ? (M(), w(pe(F(ge)[F(i)(s)]), {
377
- key: `component-${l}-${F(te)(s)}`,
378
- part: s
379
- }, null, 8, ["part"])) : fe(r.$slots, s.type, se({ ref_for: !0 }, {
380
- message: e,
381
- part: s,
382
- index: y,
383
- isLoading: Z.value
384
- }), () => [k.showAllMessageParts ? (M(), E("div", Te, [D("div", Ee, [F(v)(s) ? (M(), w(h, {
385
- key: 0,
386
- name: F(v)(s),
387
- class: "shrink-0"
388
- }, null, 8, ["name"])) : T("", !0), D("code", De, P(F(ee)(s.type)), 1)])])) : T("", !0)], void 0, 1)]),
389
- _: 2
390
- }, 1024)) : T("", !0), O(S, { mode: "out-in" }, {
391
- default: R(() => [l === ot(e) && k.readonlyFeedback && q(e.id)?.comment ? (M(), w(u, {
392
- key: 0,
393
- feedback: q(e.id)
394
- }, null, 8, ["feedback"])) : T("", !0)]),
395
- _: 2
396
- }, 1024)], 64))), 128)),
397
- O(S, {
398
- name: "fade-in",
399
- mode: "out-in"
400
- }, {
401
- default: R(() => [Z.value && Q(y) && !gt(e) && $(e) && !vt(e) ? (M(), E("div", {
402
- key: `loading-info-${e.id}`,
403
- class: "pk-chatbot-message__loading-info"
404
- }, [D("div", Oe, [
405
- O(h, {
406
- name: "line-md:loading-loop",
407
- class: "shrink-0"
408
- }),
409
- O(S, { mode: "out-in" }, {
410
- default: R(() => [ft.value ? (M(), w(h, {
411
- key: ft.value,
412
- class: "shrink-0",
413
- name: ft.value
414
- }, null, 8, ["name"])) : T("", !0)]),
415
- _: 1
416
- }),
417
- O(S, { mode: "out-in" }, {
418
- default: R(() => [dt.value ? (M(), E("span", {
419
- key: dt.value,
420
- class: "text-12"
421
- }, P(dt.value), 1)) : T("", !0)]),
422
- _: 1
423
- })
424
- ]), O(S, {
425
- name: "fade-in",
426
- mode: "out-in"
427
- }, {
428
- default: R(() => [X.value && "text" in X.value && X.value.text.trim() ? (M(), w(f, {
429
- key: 0,
430
- markdown: X.value.text,
431
- "is-dark": k.isDark,
432
- "inner-class": "wysiwyg",
433
- class: "border border-surface-4 rounded p-4 mt-8 bg-surface-1 max-h-64 text-12 w-full"
434
- }, null, 8, ["markdown", "is-dark"])) : T("", !0)]),
435
- _: 1
436
- })])) : T("", !0)]),
437
- _: 2
438
- }, 1024),
439
- O(S, { mode: "out-in" }, {
440
- default: R(() => [Ct(e, y) ? (M(), E("div", ke, [
441
- O(ne, {
442
- modifiers: "compact",
443
- class: "mr-auto shrink-0"
444
- }, {
445
- default: R(() => [
446
- O(S, { mode: "out-in" }, {
447
- default: R(() => [mt(y) ? (M(), w(_, {
448
- key: 0,
449
- icon: "ri:reset-right-line",
450
- modifiers: "action-quiet-small",
451
- title: F(B)("action.regenerate"),
452
- "aria-label": F(B)("action.regenerate"),
453
- onClick: m[0] ||= z((e) => r.$emit("regenerate"), ["stop"])
454
- }, null, 8, ["title", "aria-label"])) : T("", !0)]),
455
- _: 2
456
- }, 1024),
457
- O(S, { mode: "out-in" }, {
458
- default: R(() => [ht("show-info", y) ? (M(), w(_, {
459
- key: 0,
460
- icon: "ri:information-line",
461
- title: F(B)("action.getMoreInfo"),
462
- "aria-label": F(B)("action.getMoreInfo"),
463
- modifiers: "action-quiet-small",
464
- onClick: z((t) => r.$emit("show-info", e), ["stop"])
465
- }, null, 8, [
466
- "title",
467
- "aria-label",
468
- "onClick"
469
- ])) : T("", !0)]),
470
- _: 2
471
- }, 1024),
472
- O(S, { mode: "out-in" }, {
473
- default: R(() => [ht("revise", y) ? (M(), w(_, {
474
- key: 0,
475
- icon: K(e.id) ? "ri:file-edit-fill" : "ri:file-edit-line",
476
- title: K(e.id) ? F(B)("action.editRevise") : F(B)("action.createRevise"),
477
- "aria-label": K(e.id) ? F(B)("action.editRevise") : F(B)("action.createRevise"),
478
- modifiers: "action-quiet-small",
479
- class: ce({ "text-brand": K(e.id) }),
480
- onClick: z((t) => r.$emit("revise", e), ["stop"])
481
- }, null, 8, [
482
- "icon",
483
- "title",
484
- "aria-label",
485
- "class",
486
- "onClick"
487
- ])) : T("", !0)]),
488
- _: 2
489
- }, 1024),
490
- O(S, { mode: "out-in" }, {
491
- default: R(() => [tt("upvote", y) ? (M(), w(_, {
492
- key: 0,
493
- icon: q(e.id)?.vote === "upvote" ? "ri:thumb-up-fill" : "ri:thumb-up-line",
494
- title: F(B)("action.upvote"),
495
- "aria-label": F(B)("action.upvote"),
496
- modifiers: "action-quiet-small",
497
- onClick: z((t) => r.$emit("upvote", e), ["stop"])
498
- }, null, 8, [
499
- "icon",
500
- "title",
501
- "aria-label",
502
- "onClick"
503
- ])) : T("", !0)]),
504
- _: 2
505
- }, 1024),
506
- O(S, { mode: "out-in" }, {
507
- default: R(() => [tt("downvote", y) ? (M(), w(_, {
508
- key: 0,
509
- icon: q(e.id)?.vote === "downvote" ? "ri:thumb-down-fill" : "ri:thumb-down-line",
510
- title: F(B)("action.downvote"),
511
- "aria-label": F(B)("action.downvote"),
512
- modifiers: "action-quiet-small",
513
- onClick: z((t) => r.$emit("downvote", e), ["stop"])
514
- }, null, 8, [
515
- "icon",
516
- "title",
517
- "aria-label",
518
- "onClick"
519
- ])) : T("", !0)]),
520
- _: 2
521
- }, 1024),
522
- O(S, { mode: "out-in" }, {
523
- default: R(() => [tt("feedback", y) ? (M(), w(_, {
524
- key: 0,
525
- icon: q(e.id)?.comment ? "ri:feedback-fill" : "ri:feedback-line",
526
- title: F(B)("action.feedback"),
527
- "aria-label": F(B)("action.feedback"),
528
- modifiers: "action-quiet-small",
529
- onClick: z((t) => r.$emit("feedback", e), ["stop"])
530
- }, null, 8, [
531
- "icon",
532
- "title",
533
- "aria-label",
534
- "onClick"
535
- ])) : T("", !0)]),
536
- _: 2
537
- }, 1024)
538
- ]),
539
- _: 2
540
- }, 1024),
541
- !k.showMessageDateTime && e.metadata?.createdAt && e.metadata?.completedAt ? (M(), E("div", Ae, [D("time", {
542
- datetime: new Date(e.metadata.createdAt).toISOString(),
543
- title: F(V)(new Date(e.metadata.createdAt), "date-time"),
544
- class: "flex items-center gap-4 min-w-0"
545
- }, [O(h, {
546
- name: "ri:time-line",
547
- class: "shrink-0"
548
- }), D("span", Me, P(wt(e.metadata.createdAt)), 1)], 8, je), Tt(e) ? (M(), E("span", Ne, [O(h, {
549
- name: "ri:hourglass-line",
550
- class: "shrink-0"
551
- }), D("span", Pe, P(Tt(e)), 1)])) : T("", !0)])) : T("", !0),
552
- k.showMessageTokensCount && e.metadata?.totalTokens ? (M(), E("span", Fe, [O(h, {
553
- name: "ri:ai-generate-2-line",
554
- class: "shrink-0"
555
- }), D("span", Ie, P(F(Ve)(e.metadata.totalTokens, "integer")) + " " + P(F(B)("label.tokens")), 1)])) : T("", !0),
556
- k.showMessageDateTime && e.metadata?.createdAt ? (M(), E("time", {
557
- key: 2,
558
- datetime: new Date(e.metadata?.createdAt).toISOString(),
559
- class: "flex items-center gap-4 text-12 text-word-3"
560
- }, [O(h, {
561
- name: "ri:time-line",
562
- class: "shrink-0"
563
- }), D("span", Re, P(F(V)(new Date(e.metadata?.createdAt), "date-time")), 1)], 8, Le)) : T("", !0),
564
- k.showMessageDateTime && e?.metadata?.completedAt && e?.metadata?.createdAt ? (M(), E("div", ze, [O(h, {
565
- name: "ri:hourglass-line",
566
- class: "shrink-0"
567
- }), O(s, {
568
- class: "truncate",
569
- date: e.metadata?.createdAt,
570
- "end-date": e.metadata?.completedAt
571
- }, null, 8, ["date", "end-date"])])) : T("", !0)
572
- ])) : T("", !0)]),
573
- _: 2
574
- }, 1024),
575
- O(S, { mode: "out-in" }, {
576
- default: R(() => [e.id === k.feedbackMessageId ? (M(), w(l, {
577
- key: 0,
578
- ref_for: !0,
579
- ref_key: "feedbackMessageEl",
580
- ref: Et,
581
- loading: k.feedbackLoading,
582
- submitted: k.feedbackSubmitted,
583
- error: k.feedbackError,
584
- onSubmit: m[1] ||= (e) => r.$emit("feedback-submit", e),
585
- onClose: m[2] ||= (e) => r.$emit("feedback-close")
586
- }, null, 8, [
587
- "loading",
588
- "submitted",
589
- "error"
590
- ])) : T("", !0)]),
591
- _: 2
592
- }, 1024)
593
- ], 6)) : T("", !0)], 64))), 128)),
594
- O(S, {
595
- appear: "",
596
- name: "pk-chatbot-part"
597
- }, {
598
- default: R(() => [ut.value ? (M(), w(e, {
599
- key: 0,
600
- error: k.error,
601
- onRetry: m[3] ||= (e) => r.$emit("auto-retry"),
602
- onReset: m[4] ||= (e) => r.$emit("reset-chat")
603
- }, null, 8, ["error"])) : T("", !0)]),
604
- _: 1
605
- }),
606
- st.value?.role === "user" || ut.value ? (M(), E("div", {
607
- key: 0,
608
- class: "pk-chatbot-messages__spacer",
609
- style: le({ minHeight: `${G.value}px` })
610
- }, null, 4)) : T("", !0)
611
- ], 512),
612
- O(S, { name: "pk-chatbot-messages-fab" }, {
613
- default: R(() => [k.showScrollToBottom && (F(qe) || !F(Je)) ? (M(), E("button", {
614
- key: 0,
615
- type: "button",
616
- class: "pk-chatbot-messages__scroll-to-bottom",
617
- title: F(B)("action.scrollToBottom"),
618
- "aria-label": F(B)("action.scrollToBottom"),
619
- onClick: Ye
620
- }, [O(h, { name: "ri:arrow-down-line" })], 8, Be)) : T("", !0)]),
621
- _: 1
622
- })
623
- ], 44, ve);
624
- };
625
- }
626
- });
627
- //#endregion
628
- export { Ve as t };
629
-
630
- //# sourceMappingURL=PkChatbotMessages-B4qfTNOJ.js.map