@inkeep/cxkit-primitives 0.5.107 → 0.5.109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/embedded-chat/use-chat-action.cjs +1 -1
- package/dist/components/embedded-chat/use-chat-action.js +8 -12
- package/dist/components/embedded-chat/use-inkeep-chat.cjs +3 -3
- package/dist/components/embedded-chat/use-inkeep-chat.js +103 -103
- package/dist/components/embedded-chat.cjs +3 -3
- package/dist/components/embedded-chat.js +5 -0
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/providers/base-events-provider.cjs +1 -1
- package/dist/providers/base-events-provider.js +1 -1
- package/dist/providers/chat-events-provider.cjs +1 -1
- package/dist/providers/chat-events-provider.js +59 -58
- package/dist/providers/chat-form-provider.cjs +1 -1
- package/dist/providers/chat-form-provider.js +51 -40
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../providers/conversation-provider.cjs"),l=require("../../providers/chat-events-provider.cjs"),a=require("../../providers/chat-form-provider.cjs"),p=require("../modal/modal-provider.cjs"),c=e=>{const{logEvent:n}=l.useChatEvents(),{conversation:o}=s.useInkeepConversation(),{openForm:t}=a.useChatForm(),r=p.useModal();return{handleAction:i=>{e.action.type==="open_form"?(i?.onOpenForm?.(),t?.(e.action.formSettings,e)):e.action.type==="invoke_callback"&&(e.action.callback({conversation:o}),e.action.shouldCloseModal&&r?.setOpen(!1))},logHelpAction:()=>{"name"in e&&(n({eventName:"get_help_option_clicked",properties:{getHelpOption:e,conversation:o}}),e.action.type!=="open_form"&&n({eventName:"user_escalation_indicated",properties:{escalationType:"get_help_option",getHelpOption:e,conversation:o}}))}}};exports.useChatAction=c;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useInkeepConversation as
|
|
3
|
-
import { useChatEvents as
|
|
4
|
-
import { useChatForm as
|
|
5
|
-
import { useModal as
|
|
6
|
-
const
|
|
7
|
-
const { logEvent: n } =
|
|
2
|
+
import { useInkeepConversation as s } from "../../providers/conversation-provider.js";
|
|
3
|
+
import { useChatEvents as l } from "../../providers/chat-events-provider.js";
|
|
4
|
+
import { useChatForm as r } from "../../providers/chat-form-provider.js";
|
|
5
|
+
import { useModal as a } from "../modal/modal-provider.js";
|
|
6
|
+
const g = (e) => {
|
|
7
|
+
const { logEvent: n } = l(), { conversation: o } = s(), { openForm: t } = r(), p = a();
|
|
8
8
|
return { handleAction: (i) => {
|
|
9
|
-
|
|
10
|
-
i?.onOpenForm?.();
|
|
11
|
-
const s = "name" in e ? e : void 0;
|
|
12
|
-
t?.(e.action.formSettings, s);
|
|
13
|
-
} else e.action.type === "invoke_callback" && (e.action.callback({
|
|
9
|
+
e.action.type === "open_form" ? (i?.onOpenForm?.(), t?.(e.action.formSettings, e)) : e.action.type === "invoke_callback" && (e.action.callback({
|
|
14
10
|
conversation: o
|
|
15
11
|
}), e.action.shouldCloseModal && p?.setOpen(!1));
|
|
16
12
|
}, logHelpAction: () => {
|
|
@@ -31,5 +27,5 @@ const v = (e) => {
|
|
|
31
27
|
} };
|
|
32
28
|
};
|
|
33
29
|
export {
|
|
34
|
-
|
|
30
|
+
g as useChatAction
|
|
35
31
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ae=require("openai"),t=require("react"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ae=require("openai"),t=require("react"),Be=require("../../providers/config-provider.cjs"),Oe=require("../../providers/conversation-provider.cjs"),De=require("../../providers/chat-events-provider.cjs"),D=require("../../utils/get-message-metadata.cjs"),re=require("../../utils/reset-query-params.cjs"),Fe=require("../../providers/chat-form-provider.cjs"),Te=require("../../providers/widget-provider.cjs"),Ke=require("../../hooks/use-media-query.cjs"),Qe=require("./use-captcha.cjs"),We=require("../modal/modal-provider.cjs"),g=require("../../utils/generate-uid.cjs"),Je=require("../../utils/tools/links-tool.cjs"),ze=require("../../atoms/api/analytics/conversation.cjs"),He=require("../../utils/misc.cjs"),je=()=>{const{chatId:y,isSharedChat:ie,setConversation:ce,conversation:le,resetConversation:ue}=Oe.useInkeepConversation(),{baseSettings:q,aiChatSettings:F}=Be.useInkeepConfig(),{aiApiBaseUrl:T,shouldBypassCaptcha:K,filters:Q}=q,W=We.useModal(),{getSolution:de,prefetchSolution:P,invalidateSolution:J}=Qe.useCaptcha({fetchUrl:`${T}/v1/challenge`,shouldBypassCaptcha:K,shouldMakeInitialRequest:W?W.isOpen:!0}),ge=new ae({baseURL:`${T}/v1`,apiKey:q.apiKey??"",dangerouslyAllowBrowser:!0}),{onInputMessageChange:me,getTools:pe,prompts:fe,model:he,filters:z,onToolCall:ve}=F,[S,A]=t.useState(""),H=t.useRef(null);t.useEffect(()=>{me?.(S)},[S]);const[m,l]=t.useState([]),[j,w]=t.useState(!1),[ye,C]=t.useState(!1),[Se,G]=t.useState(null),[L,V]=t.useState(null),[M,I]=t.useState([]),we=e=>{I(s=>[...s,e])},[Ce,X]=t.useState({}),o=t.useRef([]),k=t.useRef(null),{logEvent:b,getLatestConversation:Y}=De.useChatEvents(),Z=fe?.map((e,s)=>({id:`system-${Date.now().toString()}-${g.generateUid(4)}-${s}`,role:"system",content:e})),[Me,Ie]=t.useState(!!y);t.useEffect(()=>{if(y){const{apiKey:e,analyticsApiBaseUrl:s}=q;ze.getConversation(y,e,s).then(a=>{if(a){b({eventName:"shared_chat_loaded",properties:{conversation:a}}),Ie(!1),ce({...a});const r=a.messages.map(p=>({...p,content:He.parseIfJson(p.content)}));l(r),o.current=r}})}},[y]);const ke=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${q.organizationDisplayName??"Administrator"}`;default:return`Hmm..
|
|
2
2
|
|
|
3
|
-
It seems I might be having some issues right now. Please clear the chat and try again.`}},ee=e=>{
|
|
4
|
-
${
|
|
3
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`}},ee=e=>{G(e),l(s=>{const a=[...s],r=a[a.length-1];return r&&(r.content=ke(e)),a}),w(!1),C(!1),J(),P()},R=!S.trim()&&!M.length||j,be=e=>{e.key==="Enter"&&!e.shiftKey&&!R&&!e.nativeEvent.isComposing&&(e.preventDefault(),x())},_e=e=>{const s=e.target.value;A(s)},x=async(e=S)=>{if(R&&(!e||e.trim().length===0))return;w(!0);const s=L?m.length===2:m.length===0,a=D.getMessageMetadata(L,M,s);let r;const p=D.serializeAttachments(M);M.length&&p?r=[{type:"text",text:p}]:r=e;const se={id:`${Date.now().toString()}-${g.generateUid(4)}-1`,role:"user",content:r,metadata:a},f=[...m.length?[]:Z,se];if(ie&&y){re.resetQueryParams();const u=o.current.map((i,E)=>({id:`${i.id}-${g.generateUid(6)}-${E}`,role:i.role,...i.role==="assistant"?{links:i.links??[]}:{},content:i.content,metadata:i.metadata,tool_calls:i.tool_calls}));l([...u,...f]),o.current=[...u,...f]}else l(u=>[...u,...f]),o.current=[...o.current,...f];I([]),A(""),await b({eventName:"user_message_submitted",properties:{}},o.current);const Ne=Y(),ne=[Je.provideLinksTool,...pe?.({conversation:Ne})||[]];try{const u={model:he,messages:o.current,stream:!0,tools:ne,tool_choice:"auto"},i=await de(),E=i?btoa(JSON.stringify(i)):null,oe=Q||z?JSON.stringify({...Q,...z}):void 0,U={};!K&&E&&(U["X-INKEEP-CHALLENGE-SOLUTION"]=E),oe&&(U["inkeep-filters"]=oe);const h=ge.beta.chat.completions.stream(u,Object.keys(U).length>0?{headers:U}:void 0),n={id:`${Date.now().toString()}-${g.generateUid(4)}-2`,role:"assistant",content:"",links:[],tool_calls:[]};l(d=>[...d,n]),h.on("content",(d,_)=>{C(!0),n.content=_,l(N=>{const c=[...N],B=c.findIndex($=>$.id===n.id);return B===-1?[...c,n]:(c[B]={...n},c)})}),h.on("tool_calls.function.arguments.done",async d=>{const{name:_,arguments:N}=d,c=ne?.find(v=>v.function.name===_);if(!c)return;const $=("parse"in c.function?c.function.parse:JSON.parse)(N),Ae=c.function.function?.($,h),Le=c.renderMessageButtons?.({args:$,execution:Ae})??[];_==="provideLinks"?n.links=$.links??[]:X(v=>({...v,[n.id]:[...v[n.id]??[],...Le]})),n.tool_calls?.push({id:"call_"+g.generateUid(24),type:"function",function:{name:_,arguments:N}}),l(v=>{const O=[...v],Re=O.findIndex(xe=>xe.id===n.id);return O[Re]={...n},O}),ve?.(d,{conversation:{...Y(),messages:[...o.current,n]}})}),h.on("error",ee),h.finalChatCompletion().then(async()=>{o.current=[...o.current,n],k.current=null,w(!1),C(!1),P(),await b({eventName:"assistant_message_received",properties:{}},o.current),b({eventName:"assistant_answer_displayed",properties:{}})}).catch(d=>{d instanceof ae.APIUserAbortError||console.warn(d)}),k.current=h.controller}catch(u){ee(u),w(!1),C(!1)}},$e=()=>{k.current&&(k.current.abort(),k.current=null),w(!1),C(!1),P()},te=()=>{G(null),l([]),o.current=[],ue(),X({}),I([]),re.resetQueryParams(),V(null),J(),P(),b({eventName:"chat_clear_button_clicked",properties:{conversation:le}})},qe=e=>{V(e);const{initialReplyMessage:s,displayName:a}=e,r={id:m.length.toString()+g.generateUid(4),role:"user",content:a},p={id:(m.length+1).toString()+g.generateUid(4),role:"assistant",content:s,links:[]},f=[{id:`system-${Date.now().toString()}-${g.generateUid(4)}-${e.id}`,role:"system",content:`Company has asked user to follow this guided workflow:
|
|
4
|
+
${D.serializeWorkflow(e)}`},...Z,r,p];l(f),I([])},{openForm:Pe}=Fe.useChatForm(),Ee=Te.useWidget();t.useImperativeHandle(F.chatFunctionsRef,()=>({submitMessage:x,updateInputMessage(e){A(e)},clearChat:te,openForm:e=>{Ee?.setView("chat"),Pe(e)},focusInput:()=>{H.current?.focus()}}));const Ue=Ke.useMediaQuery("(max-width: 768px)");return{messages:m,input:S,isLoading:j,isStreaming:ye,isLoadingConversation:Me,error:Se,isSubmitDisabled:R,handleInputChange:_e,handleInputKeyDown:be,handleSubmit:x,stop:$e,clear:te,handleWorkflow:qe,selectedWorkflow:L,messageAttachments:M,setMessageAttachments:I,addAttachment:we,messageButtons:Ce,isEmpty:m.length===0,inputRef:H,isMobile:Ue}};exports.useInkeepChat=je;
|
|
@@ -1,68 +1,68 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import { useState as l, useRef as
|
|
4
|
-
import { useInkeepConfig as
|
|
5
|
-
import { useInkeepConversation as
|
|
6
|
-
import { useChatEvents as
|
|
7
|
-
import { getMessageMetadata as
|
|
2
|
+
import Re, { APIUserAbortError as Ue } from "openai";
|
|
3
|
+
import { useState as l, useRef as F, useEffect as ae, useImperativeHandle as Fe } from "react";
|
|
4
|
+
import { useInkeepConfig as Ke } from "../../providers/config-provider.js";
|
|
5
|
+
import { useInkeepConversation as Te } from "../../providers/conversation-provider.js";
|
|
6
|
+
import { useChatEvents as We } from "../../providers/chat-events-provider.js";
|
|
7
|
+
import { getMessageMetadata as Je, serializeAttachments as ze, serializeWorkflow as He } from "../../utils/get-message-metadata.js";
|
|
8
8
|
import { resetQueryParams as re } from "../../utils/reset-query-params.js";
|
|
9
|
-
import { useChatForm as
|
|
10
|
-
import { useWidget as
|
|
11
|
-
import { useMediaQuery as
|
|
12
|
-
import { useCaptcha as
|
|
13
|
-
import { useModal as
|
|
9
|
+
import { useChatForm as Qe } from "../../providers/chat-form-provider.js";
|
|
10
|
+
import { useWidget as je } from "../../providers/widget-provider.js";
|
|
11
|
+
import { useMediaQuery as qe } from "../../hooks/use-media-query.js";
|
|
12
|
+
import { useCaptcha as Ge } from "./use-captcha.js";
|
|
13
|
+
import { useModal as Ve } from "../modal/modal-provider.js";
|
|
14
14
|
import { generateUid as g } from "../../utils/generate-uid.js";
|
|
15
|
-
import { provideLinksTool as
|
|
16
|
-
import { getConversation as
|
|
17
|
-
import { parseIfJson as
|
|
18
|
-
const
|
|
19
|
-
const { chatId:
|
|
20
|
-
fetchUrl: `${
|
|
21
|
-
shouldBypassCaptcha:
|
|
22
|
-
shouldMakeInitialRequest:
|
|
23
|
-
}),
|
|
24
|
-
baseURL: `${
|
|
15
|
+
import { provideLinksTool as Xe } from "../../utils/tools/links-tool.js";
|
|
16
|
+
import { getConversation as Ye } from "../../atoms/api/analytics/conversation.js";
|
|
17
|
+
import { parseIfJson as Ze } from "../../utils/misc.js";
|
|
18
|
+
const ht = () => {
|
|
19
|
+
const { chatId: v, isSharedChat: ie, setConversation: ce, conversation: le, resetConversation: ue } = Te(), { baseSettings: E, aiChatSettings: K } = Ke(), { aiApiBaseUrl: T, shouldBypassCaptcha: W, filters: J } = E, z = Ve(), { getSolution: me, prefetchSolution: N, invalidateSolution: H } = Ge({
|
|
20
|
+
fetchUrl: `${T}/v1/challenge`,
|
|
21
|
+
shouldBypassCaptcha: W,
|
|
22
|
+
shouldMakeInitialRequest: z ? z.isOpen : !0
|
|
23
|
+
}), ge = new Re({
|
|
24
|
+
baseURL: `${T}/v1`,
|
|
25
25
|
apiKey: E.apiKey ?? "",
|
|
26
26
|
dangerouslyAllowBrowser: !0
|
|
27
27
|
}), {
|
|
28
|
-
onInputMessageChange:
|
|
29
|
-
getTools:
|
|
30
|
-
prompts:
|
|
31
|
-
model:
|
|
32
|
-
filters:
|
|
33
|
-
onToolCall:
|
|
34
|
-
} =
|
|
28
|
+
onInputMessageChange: pe,
|
|
29
|
+
getTools: de,
|
|
30
|
+
prompts: fe,
|
|
31
|
+
model: he,
|
|
32
|
+
filters: Q,
|
|
33
|
+
onToolCall: ye
|
|
34
|
+
} = K, [w, B] = l(""), j = F(null);
|
|
35
35
|
ae(() => {
|
|
36
|
-
|
|
37
|
-
}, [
|
|
38
|
-
const [p, c] = l([]), [
|
|
36
|
+
pe?.(w);
|
|
37
|
+
}, [w]);
|
|
38
|
+
const [p, c] = l([]), [q, C] = l(!1), [ve, I] = l(!1), [we, G] = l(null), [D, V] = l(null), [M, S] = l([]), Ce = (e) => {
|
|
39
39
|
S((t) => [...t, e]);
|
|
40
|
-
}, [
|
|
40
|
+
}, [Ie, X] = l({}), n = F([]), k = F(null), { logEvent: _, getLatestConversation: Y } = We(), Z = fe?.map((e, t) => ({
|
|
41
41
|
id: `system-${Date.now().toString()}-${g(4)}-${t}`,
|
|
42
42
|
role: "system",
|
|
43
43
|
content: e
|
|
44
|
-
})), [
|
|
44
|
+
})), [Me, Se] = l(!!v);
|
|
45
45
|
ae(() => {
|
|
46
|
-
if (
|
|
46
|
+
if (v) {
|
|
47
47
|
const { apiKey: e, analyticsApiBaseUrl: t } = E;
|
|
48
|
-
|
|
48
|
+
Ye(v, e, t).then((o) => {
|
|
49
49
|
if (o) {
|
|
50
50
|
_({
|
|
51
51
|
eventName: "shared_chat_loaded",
|
|
52
52
|
properties: {
|
|
53
53
|
conversation: o
|
|
54
54
|
}
|
|
55
|
-
}),
|
|
55
|
+
}), Se(!1), ce({ ...o });
|
|
56
56
|
const a = o.messages.map((d) => ({
|
|
57
57
|
...d,
|
|
58
|
-
content:
|
|
58
|
+
content: Ze(d.content)
|
|
59
59
|
}));
|
|
60
60
|
c(a), n.current = a;
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
}, [
|
|
65
|
-
const
|
|
64
|
+
}, [v]);
|
|
65
|
+
const ke = (e) => {
|
|
66
66
|
switch (e.code) {
|
|
67
67
|
case 400:
|
|
68
68
|
return e.message;
|
|
@@ -74,21 +74,21 @@ const dt = () => {
|
|
|
74
74
|
It seems I might be having some issues right now. Please clear the chat and try again.`;
|
|
75
75
|
}
|
|
76
76
|
}, ee = (e) => {
|
|
77
|
-
|
|
77
|
+
G(e), c((t) => {
|
|
78
78
|
const o = [...t], a = o[o.length - 1];
|
|
79
|
-
return a && (a.content =
|
|
80
|
-
}), C(!1), I(!1),
|
|
81
|
-
},
|
|
82
|
-
e.key === "Enter" && !e.shiftKey && !
|
|
83
|
-
},
|
|
79
|
+
return a && (a.content = ke(e)), o;
|
|
80
|
+
}), C(!1), I(!1), H(), N();
|
|
81
|
+
}, O = !w.trim() && !M.length || q, _e = (e) => {
|
|
82
|
+
e.key === "Enter" && !e.shiftKey && !O && !e.nativeEvent.isComposing && (e.preventDefault(), P());
|
|
83
|
+
}, be = (e) => {
|
|
84
84
|
const t = e.target.value;
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
if (
|
|
85
|
+
B(t);
|
|
86
|
+
}, P = async (e = w) => {
|
|
87
|
+
if (O && (!e || e.trim().length === 0)) return;
|
|
88
88
|
C(!0);
|
|
89
|
-
const t =
|
|
89
|
+
const t = D ? p.length === 2 : p.length === 0, o = Je(D, M, t);
|
|
90
90
|
let a;
|
|
91
|
-
const d =
|
|
91
|
+
const d = ze(M);
|
|
92
92
|
M.length && d ? a = [{ type: "text", text: d }] : a = e;
|
|
93
93
|
const se = {
|
|
94
94
|
id: `${Date.now().toString()}-${g(4)}-1`,
|
|
@@ -96,7 +96,7 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
96
96
|
content: a,
|
|
97
97
|
metadata: o
|
|
98
98
|
}, f = [...p.length ? [] : Z, se];
|
|
99
|
-
if (ie &&
|
|
99
|
+
if (ie && v) {
|
|
100
100
|
re();
|
|
101
101
|
const u = n.current.map((r, A) => ({
|
|
102
102
|
id: `${r.id}-${g(6)}-${A}`,
|
|
@@ -109,29 +109,29 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
109
109
|
c([...u, ...f]), n.current = [...u, ...f];
|
|
110
110
|
} else
|
|
111
111
|
c((u) => [...u, ...f]), n.current = [...n.current, ...f];
|
|
112
|
-
S([]),
|
|
112
|
+
S([]), B(""), await _(
|
|
113
113
|
{
|
|
114
114
|
eventName: "user_message_submitted",
|
|
115
115
|
properties: {}
|
|
116
116
|
},
|
|
117
117
|
n.current
|
|
118
118
|
);
|
|
119
|
-
const ne = [
|
|
119
|
+
const xe = Y(), ne = [Xe, ...de?.({ conversation: xe }) || []];
|
|
120
120
|
try {
|
|
121
121
|
const u = {
|
|
122
|
-
model:
|
|
122
|
+
model: he,
|
|
123
123
|
messages: n.current,
|
|
124
124
|
stream: !0,
|
|
125
125
|
tools: ne,
|
|
126
126
|
tool_choice: "auto"
|
|
127
|
-
}, r = await
|
|
128
|
-
...
|
|
129
|
-
...
|
|
130
|
-
}) : void 0,
|
|
131
|
-
!
|
|
132
|
-
const h =
|
|
127
|
+
}, r = await me(), A = r ? btoa(JSON.stringify(r)) : null, oe = J || Q ? JSON.stringify({
|
|
128
|
+
...J,
|
|
129
|
+
...Q
|
|
130
|
+
}) : void 0, L = {};
|
|
131
|
+
!W && A && (L["X-INKEEP-CHALLENGE-SOLUTION"] = A), oe && (L["inkeep-filters"] = oe);
|
|
132
|
+
const h = ge.beta.chat.completions.stream(
|
|
133
133
|
u,
|
|
134
|
-
Object.keys(
|
|
134
|
+
Object.keys(L).length > 0 ? { headers: L } : void 0
|
|
135
135
|
), s = {
|
|
136
136
|
id: `${Date.now().toString()}-${g(4)}-2`,
|
|
137
137
|
role: "assistant",
|
|
@@ -140,30 +140,30 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
140
140
|
tool_calls: []
|
|
141
141
|
};
|
|
142
142
|
c((m) => [...m, s]), h.on("content", (m, b) => {
|
|
143
|
-
I(!0), s.content = b, c((
|
|
144
|
-
const i = [...
|
|
145
|
-
return
|
|
143
|
+
I(!0), s.content = b, c((x) => {
|
|
144
|
+
const i = [...x], R = i.findIndex(($) => $.id === s.id);
|
|
145
|
+
return R === -1 ? [...i, s] : (i[R] = { ...s }, i);
|
|
146
146
|
});
|
|
147
147
|
}), h.on("tool_calls.function.arguments.done", async (m) => {
|
|
148
|
-
const { name: b, arguments:
|
|
148
|
+
const { name: b, arguments: x } = m, i = ne?.find((y) => y.function.name === b);
|
|
149
149
|
if (!i) return;
|
|
150
|
-
const $ = ("parse" in i.function ? i.function.parse : JSON.parse)(
|
|
151
|
-
b === "provideLinks" ? s.links = $.links ?? [] :
|
|
150
|
+
const $ = ("parse" in i.function ? i.function.parse : JSON.parse)(x), Be = i.function.function?.($, h), De = i.renderMessageButtons?.({ args: $, execution: Be }) ?? [];
|
|
151
|
+
b === "provideLinks" ? s.links = $.links ?? [] : X((y) => ({
|
|
152
152
|
...y,
|
|
153
|
-
[s.id]: [...y[s.id] ?? [], ...
|
|
153
|
+
[s.id]: [...y[s.id] ?? [], ...De]
|
|
154
154
|
})), s.tool_calls?.push({
|
|
155
155
|
id: "call_" + g(24),
|
|
156
156
|
type: "function",
|
|
157
157
|
function: {
|
|
158
158
|
name: b,
|
|
159
|
-
arguments:
|
|
159
|
+
arguments: x
|
|
160
160
|
}
|
|
161
161
|
}), c((y) => {
|
|
162
|
-
const
|
|
163
|
-
return
|
|
164
|
-
}),
|
|
162
|
+
const U = [...y], Oe = U.findIndex((Pe) => Pe.id === s.id);
|
|
163
|
+
return U[Oe] = { ...s }, U;
|
|
164
|
+
}), ye?.(m, {
|
|
165
165
|
conversation: {
|
|
166
|
-
...
|
|
166
|
+
...Y(),
|
|
167
167
|
messages: [...n.current, s]
|
|
168
168
|
}
|
|
169
169
|
});
|
|
@@ -179,22 +179,22 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
179
179
|
properties: {}
|
|
180
180
|
});
|
|
181
181
|
}).catch((m) => {
|
|
182
|
-
m instanceof
|
|
182
|
+
m instanceof Ue || console.warn(m);
|
|
183
183
|
}), k.current = h.controller;
|
|
184
184
|
} catch (u) {
|
|
185
185
|
ee(u), C(!1), I(!1);
|
|
186
186
|
}
|
|
187
|
-
},
|
|
187
|
+
}, $e = () => {
|
|
188
188
|
k.current && (k.current.abort(), k.current = null), C(!1), I(!1), N();
|
|
189
189
|
}, te = () => {
|
|
190
|
-
|
|
190
|
+
G(null), c([]), n.current = [], ue(), X({}), S([]), re(), V(null), H(), N(), _({
|
|
191
191
|
eventName: "chat_clear_button_clicked",
|
|
192
192
|
properties: {
|
|
193
|
-
conversation:
|
|
193
|
+
conversation: le
|
|
194
194
|
}
|
|
195
195
|
});
|
|
196
|
-
},
|
|
197
|
-
|
|
196
|
+
}, Ee = (e) => {
|
|
197
|
+
V(e);
|
|
198
198
|
const { initialReplyMessage: t, displayName: o } = e, a = {
|
|
199
199
|
id: p.length.toString() + g(4),
|
|
200
200
|
role: "user",
|
|
@@ -208,48 +208,48 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
208
208
|
id: `system-${Date.now().toString()}-${g(4)}-${e.id}`,
|
|
209
209
|
role: "system",
|
|
210
210
|
content: `Company has asked user to follow this guided workflow:
|
|
211
|
-
${
|
|
211
|
+
${He(e)}`
|
|
212
212
|
}, ...Z, a, d];
|
|
213
213
|
c(f), S([]);
|
|
214
|
-
}, { openForm:
|
|
215
|
-
|
|
216
|
-
submitMessage:
|
|
214
|
+
}, { openForm: Ne } = Qe(), Ae = je();
|
|
215
|
+
Fe(K.chatFunctionsRef, () => ({
|
|
216
|
+
submitMessage: P,
|
|
217
217
|
updateInputMessage(e) {
|
|
218
|
-
|
|
218
|
+
B(e);
|
|
219
219
|
},
|
|
220
220
|
clearChat: te,
|
|
221
221
|
openForm: (e) => {
|
|
222
|
-
|
|
222
|
+
Ae?.setView("chat"), Ne(e);
|
|
223
223
|
},
|
|
224
224
|
focusInput: () => {
|
|
225
|
-
|
|
225
|
+
j.current?.focus();
|
|
226
226
|
}
|
|
227
227
|
}));
|
|
228
|
-
const
|
|
228
|
+
const Le = qe("(max-width: 768px)");
|
|
229
229
|
return {
|
|
230
230
|
messages: p,
|
|
231
|
-
input:
|
|
232
|
-
isLoading:
|
|
233
|
-
isStreaming:
|
|
234
|
-
isLoadingConversation:
|
|
231
|
+
input: w,
|
|
232
|
+
isLoading: q,
|
|
233
|
+
isStreaming: ve,
|
|
234
|
+
isLoadingConversation: Me,
|
|
235
235
|
error: we,
|
|
236
|
-
isSubmitDisabled:
|
|
237
|
-
handleInputChange:
|
|
238
|
-
handleInputKeyDown:
|
|
239
|
-
handleSubmit:
|
|
240
|
-
stop:
|
|
236
|
+
isSubmitDisabled: O,
|
|
237
|
+
handleInputChange: be,
|
|
238
|
+
handleInputKeyDown: _e,
|
|
239
|
+
handleSubmit: P,
|
|
240
|
+
stop: $e,
|
|
241
241
|
clear: te,
|
|
242
|
-
handleWorkflow:
|
|
243
|
-
selectedWorkflow:
|
|
242
|
+
handleWorkflow: Ee,
|
|
243
|
+
selectedWorkflow: D,
|
|
244
244
|
messageAttachments: M,
|
|
245
245
|
setMessageAttachments: S,
|
|
246
|
-
addAttachment:
|
|
247
|
-
messageButtons:
|
|
246
|
+
addAttachment: Ce,
|
|
247
|
+
messageButtons: Ie,
|
|
248
248
|
isEmpty: p.length === 0,
|
|
249
|
-
inputRef:
|
|
250
|
-
isMobile:
|
|
249
|
+
inputRef: j,
|
|
250
|
+
isMobile: Le
|
|
251
251
|
};
|
|
252
252
|
};
|
|
253
253
|
export {
|
|
254
|
-
|
|
254
|
+
ht as useInkeepChat
|
|
255
255
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("react"),ae=require("react-textarea-autosize"),ba=require("@radix-ui/react-avatar"),ga=require("@radix-ui/react-checkbox"),Pa=require("@radix-ui/react-popover"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("react"),ae=require("react-textarea-autosize"),ba=require("@radix-ui/react-avatar"),ga=require("@radix-ui/react-checkbox"),Pa=require("@radix-ui/react-popover"),_a=require("@radix-ui/react-tooltip"),Aa=require("@radix-ui/react-scroll-area"),I=require("../atoms/select.cjs"),_=require("../atoms/dialog.cjs"),Ea=require("../atoms/avatars/ai.cjs"),Fa=require("../atoms/avatars/user.cjs"),E=require("../atoms/icons/custom-icon.cjs"),x=require("../atoms/icons/built-in-icon-renderer.cjs"),ka=require("../atoms/link.cjs"),U=require("../atoms/markdown/index.cjs"),w=require("../providers/attachment-item-provider.cjs"),F=require("../providers/attachments-bar-provider.cjs"),f=require("../providers/source-item-provider.cjs"),p=require("../providers/config-provider.cjs"),L=require("../providers/conversation-provider.cjs"),O=require("../providers/chat-events-provider.cjs"),ne=require("../providers/feedback-provider.cjs"),q=require("../providers/message-attachments-provider.cjs"),P=require("../providers/message-provider.cjs"),be=require("../atoms/icons/checkbox-icon.cjs"),te=require("../hooks/use-copy-to-clipboard.cjs"),K=require("../providers/feedback-item-provider.cjs"),Ia=require("../utils/get-message-metadata.cjs"),h=require("../utils/misc.cjs"),a=require("./factory.cjs"),v=require("./embedded-chat/chat-provider.cjs"),Ma=require("./tagline-logo-icon.cjs"),Sa=require("../hooks/use-settle-action.cjs"),xa=require("../hooks/use-container-size.cjs"),se=require("./embedded-chat/use-chat-action.cjs"),ie=require("../providers/help-menu-provider.cjs"),A=require("../providers/chat-form-provider.cjs"),B=require("../providers/form-field-provider.cjs"),fa=require("react-hook-form"),Ba=require("../utils/highlight-emphasis.cjs"),Ta=require("./modal/modal-provider.cjs"),ja=require("@inkeep/cxkit-color-mode"),re=require("../utils/compose-refs.cjs"),u=require("../utils/compose-event-handlers.cjs"),ya=require("../hooks/use-scroll-to-bottom.cjs"),Ha=require("../atoms/api/analytics/conversation.cjs"),wa=require("../utils/transform-source/index.cjs"),La=require("../hooks/use-debounce.cjs"),oe=require("../providers/hover-popover-provider.cjs"),Da=require("./modal/widget-auto-focus.cjs");function R(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>t[i]})}}return e.default=t,Object.freeze(e)}const de=R(ba),z=R(ga),T=R(Pa),j=R(_a),W=R(Aa),Oa="__intro__",qa=a.ikp("div",{_id:"aiChatWrapper"}),ge=g.forwardRef((t,e)=>{const{...i}=t,{isHidden:s,isMobile:r}=v.useChat(),[o,d]=xa.useContainerSize(),c=re.useComposedRefs(e,o),m=d?.width?d.width>580:!0,l=Ta.useModal();return n.jsx(qa,{ref:c,"data-widget-md":h.dataAttr(m),"data-hidden":h.dataAttr(s),"data-in-modal":h.dataAttr(!!l),"data-mobile":h.dataAttr(r),...i})}),Ra=a.ikp("div",{_id:"aiChatConversationLoading"}),Pe=t=>{const{isLoadingConversation:e}=v.useChat();return e?n.jsx(Ra,{children:n.jsx("span",{children:"Loading..."}),...t}):null},Wa=a.ikp("div",{_id:"aiChatRoot"}),_e=t=>{const{isLoadingConversation:e,isHidden:i}=v.useChat(),{form:s}=A.useChatForm();return e||s?null:n.jsx(Wa,{"data-hidden":h.dataAttr(i),...t})},Na=a.ikp("div",{_id:"aiChatHeader"}),Ae=a.ikp("div",{_id:"aiChatHeader__Toolbar"}),Ee=a.ikp("div",{_id:"aiChatHeader__ToolbarHeaderWrapper"}),Qa=a.ikp("div",{_id:"aiChatHeader__ToolbarHeader"}),Fe=g.memo(t=>{const{aiChatSettings:e}=p.useInkeepConfig(),i=`Ask ${e.aiAssistantName||"AI"}`;return n.jsx(Qa,{...t,children:i})}),ke=a.ikp("div",{_id:"aiChatContent"}),Ie=a.ikp(W.Root,{_id:"aiChatContentScrollArea"}),$a=a.ikp(W.Viewport,{_id:"aiChatContentScrollArea__Viewport"}),Me=g.forwardRef(({children:t,...e},i)=>{const{containerRef:s}=ya.useScrollToBottom(),r=re.useComposedRefs(i,s);return n.jsx($a,{ref:r,children:n.jsx("div",{"data-part":"grid",style:{display:"grid"},children:t}),...e})}),Se=a.ikp(W.ScrollAreaScrollbar,{_id:"aiChatContentScrollArea__Scrollbar"}),xe=a.ikp(W.ScrollAreaThumb,{_id:"aiChatContentScrollArea__Thumb"}),fe=a.ikp(W.Corner,{_id:"aiChatContentScrollArea__Corner"}),Va=a.ikp("div",{_id:"aiChatMessages"}),Be=t=>{const e=v.useChat(),{children:i,...s}=t;return n.jsx(Va,{children:h.maybeRender(i,e),...s})},Ua=a.ikp("div",{_id:"aiChatDisclaimer"}),Te=g.memo(t=>{const{aiChatSettings:e}=p.useInkeepConfig(),[i,s]=g.useState(!1),r=La.useDebounce(i,100);return e.disclaimerSettings?.isEnabled?n.jsx(oe.HoverPopoverProvider,{open:i,setOpen:s,children:n.jsx(T.Root,{open:r,onOpenChange:s,children:n.jsx(Ua,{...t})})}):null}),Ka=a.ikp("span",{_id:"aiChatDisclaimerLabel"}),je=g.memo(t=>{const{aiChatSettings:e}=p.useInkeepConfig(),i=e.disclaimerSettings;return n.jsx(Ka,{children:i?.label,...t})}),za=a.ikp(T.Trigger,{_id:"aiChatDisclaimerTrigger",children:n.jsx(E.CustomIcon,{iconKey:"info"})}),ye=g.memo(t=>{const{setOpen:e}=oe.useHoverPopover(),i=()=>e(!0),s=()=>e(!1);return n.jsx(za,{onMouseEnter:i,onMouseLeave:s,...t})}),Ga=a.ikp(T.Content,{_id:"aiChatDisclaimerContent"}),He=t=>{const{setOpen:e}=oe.useHoverPopover(),i=()=>e(!0),s=()=>e(!1);return n.jsx(Ga,{onMouseEnter:i,onMouseLeave:s,side:"top",sideOffset:8,align:"end",alignOffset:-10,...t})},Ya=a.ikp(U.Markdown,{_id:"aiChatDisclaimerText"}),we=g.memo(t=>{const{aiChatSettings:e}=p.useInkeepConfig(),i=e.aiAssistantName,r=e.disclaimerSettings?.tooltip||`Information provided by ${i||"this AI assistant"} is not guaranteed to be accurate or comprehensive.`;return n.jsx(Ya,{shouldOpenLinksInNewTab:!0,children:r,...t})}),Le=a.ikp(T.Arrow,{_id:"aiChatDisclaimerArrow"}),Ja=a.ikp("div",{_id:"aiChatExampleQuestions"}),De=t=>{const{aiChatSettings:e}=p.useInkeepConfig(),{messages:i}=v.useChat();return!e.exampleQuestions?.length||i.length?null:n.jsx(Ja,{...t})},Xa=a.ikp("h3",{_id:"aiChatExampleQuestionsLabel"}),Oe=g.memo(t=>{const{aiChatSettings:e}=p.useInkeepConfig();return n.jsx(Xa,{children:e.exampleQuestionsLabel,...t})}),Za=a.ikp("div",{_id:"aiChatExampleQuestionsList"}),qe=g.memo(t=>{const{aiChatSettings:e}=p.useInkeepConfig(),i=e.exampleQuestions,{children:s,...r}=t;return n.jsx(Za,{children:h.maybeRender(s,i),...r})}),en=a.ikp("div",{_id:"aiChatExampleQuestion"}),Re=g.forwardRef((t,e)=>{const{aiChatSettings:i}=p.useInkeepConfig(),s=i.isFirstExampleQuestionHighlighted;return n.jsx(en,{ref:e,"data-highlight":h.dataAttr(s),...t})}),tn=a.ikp("button",{_id:"aiChatExampleQuestionButton"}),We=t=>{const{question:e,onClick:i,...s}=t,{handleSubmit:r}=v.useChat();return n.jsx(tn,{onClick:u.composeEventHandlers(i,()=>r(e)),children:e,...s})},an=a.ikp("div",{_id:"aiChatWorkflows"}),Ne=t=>{const{aiChatSettings:e}=p.useInkeepConfig(),{messages:i}=v.useChat();return!e.workflows?.length||i.length?null:n.jsx(an,{...t})},nn=a.ikp("h3",{_id:"aiChatWorkflowsLabel"}),Qe=g.memo(t=>{const{aiChatSettings:e}=p.useInkeepConfig();return n.jsx(nn,{children:e.workflowsHeader,...t})}),sn=a.ikp("div",{_id:"aiChatWorkflowsList"}),$e=g.memo(t=>{const{aiChatSettings:e}=p.useInkeepConfig(),i=e.workflows,{children:s,...r}=t;return n.jsx(sn,{children:h.maybeRender(s,i),...r})}),rn=a.ikp("button",{_id:"aiChatWorkflow"}),Ve=t=>{const{workflow:e,onClick:i,...s}=t,{handleWorkflow:r}=v.useChat();return n.jsx(rn,{onClick:u.composeEventHandlers(i,()=>r(e)),children:e.displayName,...s})},on=a.ikp("div",{_id:"aiChatMessageWrapper"}),ce=t=>{const{message:e,...i}=t;return e.role==="system"?null:n.jsx(P.MessageProvider,{message:e,children:n.jsx(on,{"data-role":e.role,...i})})},Ue=g.memo(t=>{const{message:e,...i}=t,{aiChatSettings:s,baseSettings:r}=p.useInkeepConfig(),o=s.aiAssistantName,d=o?`Hi, I'm ${o}!`:"Hi!",c=s.chatSubjectName??r.organizationDisplayName,m=`${d}
|
|
2
2
|
|
|
3
3
|
I'm an AI assistant trained on documentation, help articles, and other content.`,l=c?`
|
|
4
4
|
|
|
5
5
|
Ask me anything about \`${c}\`.`:`
|
|
6
6
|
|
|
7
|
-
Let me know how I can help.`,b={content:s.introMessage??`${m}${l}`,id:Oa,...e,role:"assistant",links:[]};return n.jsx(ce,{message:b,...i})}),dn=a.ikp("div",{_id:"aiChatMessageHeader"}),Ke=t=>{const{message:e}=P.useMessage();return n.jsx(dn,{"data-role":e.role,...t})},cn=a.ikp("div",{_id:"aiChatMessageLoading"}),ze=t=>{const{isLoading:e,isStreaming:i,messages:s}=v.useChat(),{message:r}=P.useMessage();return!(s.at(-1)?.id===r?.id)||r.role!=="assistant"||!e||i?null:n.jsx(cn,{children:"Thinking...",...t})},mn=a.ikp("div",{_id:"aiChatMessageAvatar"}),Ge=t=>{const{message:e}=P.useMessage();return n.jsx(mn,{"data-role":e.role,...t})},ln=a.ikp(de.Root,{_id:"aiChatMessageAvatarContent"}),Ye=t=>{const{message:e}=P.useMessage(),{baseSettings:i}=p.useInkeepConfig();return n.jsx(ln,{"data-username":h.dataAttr(e.role==="user"&&!!i.userProperties.name),"data-role":e.role,...t})},hn=a.ikp(de.Fallback,{_id:"aiChatMessageAvatarFallback"}),Je=g.memo(t=>{const{baseSettings:e}=p.useInkeepConfig(),{message:i}=P.useMessage();return e.userProperties.name?n.jsx(hn,{"data-role":i.role,children:h.getInitials(e.userProperties.name),...t}):null}),pe=a.ikp(de.Image,{_id:"aiChatMessageAvatarImage"}),Xe=g.memo(t=>{const{onLoadingStatusChange:e,...i}=t,{aiChatSettings:s,baseSettings:{userProperties:r}}=p.useInkeepConfig(),{message:o}=P.useMessage(),{aiAssistantAvatar:d}=s??{},c=typeof d=="string"?d:d?.light,m=(typeof d=="string"?d:d?.dark)??c,l=ja.useColorModeValue(c,m),[C,b]=g.useState(l);g.useEffect(()=>{b(l)},[l]);const k=y=>{y==="error"&&b(null)};return o.role==="user"?r.name?null:s.userAvatar?n.jsx(pe,{"data-type":"image",alt:"User avatar","data-role":o.role,src:s.userAvatar,...t}):n.jsx(Fa.default,{"data-type":"icon","data-role":o.role,...t}):C?n.jsx(pe,{src:C,alt:"AI assistant avatar","data-type":"image","data-role":o.role,onLoadingStatusChange:u.composeEventHandlers(e,k),...i}):n.jsx(Ea.default,{"data-type":"icon","data-role":o.role,...t})}),un=a.ikp("span",{_id:"aiChatMessageName"}),Ze=t=>{const{message:e}=P.useMessage();return n.jsx(un,{"data-role":e.role,children:e.role==="user"?"You":"AI assistant",...t})},Cn=a.ikp("div",{_id:"aiChatMessageContentWrapper"}),et=t=>{const{message:e}=P.useMessage(),{messageButtons:i}=v.useChat(),s=i[e.id]||[];return n.jsx(Cn,{"data-role":e.role,"data-has-message-buttons":h.dataAttr(!!s.length),...t})},pn=a.ikp("div",{_id:"aiChatMessageContent"}),tt=t=>{const{message:e}=P.useMessage();return n.jsx(pn,{"data-role":e.role,...t})},vn=a.ikp("div",{_id:"aiChatMessageAttachments"}),it=t=>{const{message:e}=P.useMessage(),i=e.metadata?.attributes?.attachments;return e.role!=="user"||!i?.length?null:n.jsx(q.MessageAttachmentsProvider,{children:n.jsx(vn,{...t})})},bn=a.ikp("div",{_id:"aiChatMessageAttachments__List"}),at=t=>{const{children:e,...i}=t,{message:s}=P.useMessage(),r=s.metadata?.attributes?.attachments;return r?n.jsx(bn,{children:h.maybeRender(e,r),...i}):null},gn=a.ikp("div",{_id:"aiChatMessageAttachments__Item"}),nt=t=>{const{attachment:e,onClick:i,...s}=t,{selectItem:r,onOpen:o}=q.useMessageAttachments(),d=()=>{r(e),o()};return n.jsx(w.AttachmentItemProvider,{attachment:e,children:n.jsx(gn,{onClick:u.composeEventHandlers(i,d),...s})})},Pn=a.ikp(x.BuiltInIconRenderer,{_id:"aiChatMessageAttachments__ItemIcon"}),st=t=>{const{attachment:e}=w.useAttachmentItem(),i=e.contentType?.attachmentIcon;return i?n.jsx(Pn,{iconSettings:i,...t}):null},An=a.ikp("span",{_id:"aiChatMessageAttachments__ItemTitle"}),rt=t=>{const{attachment:e}=w.useAttachmentItem();return n.jsx(An,{children:e.title,...t})},_n=a.ikp(A.Root,{_id:"aiChatMessageAttachmentsPreview"}),ot=t=>{const{onOpenChange:e,...i}=t,{selectItem:s,isOpen:r,onClose:o,selectedItem:d}=q.useMessageAttachments(),c=m=>{m||(o(),s(null))};return n.jsx(_n,{open:r&&d!==null,onOpenChange:u.composeEventHandlers(e,c),...i})},dt=a.ikp(A.Overlay,{_id:"aiChatMessageAttachmentsPreview__Overlay"}),ct=a.ikp(A.Content,{_id:"aiChatMessageAttachmentsPreview__Content","aria-describedby":void 0}),En=a.ikp(A.Title,{_id:"aiChatMessageAttachmentsPreview__Header"}),mt=t=>{const{selectedItem:e}=q.useMessageAttachments();return n.jsx(En,{children:e?.title||"Attachment",...t})},lt=a.ikp(A.Close,{_id:"aiChatMessageAttachmentsPreview__Close",children:n.jsx(E.CustomIcon,{iconKey:"close"})}),Fn=a.ikp("p",{_id:"aiChatMessageAttachmentsPreview__Body"}),ht=t=>{const{selectedItem:e}=q.useMessageAttachments();return n.jsx(Fn,{children:e?.content,...t})},ve=a.ikp("div",{_id:"aiChatMessage"}),ut=t=>{const{aiChatSettings:e}=p.useInkeepConfig(),{componentStyles:i,...s}=t,{message:r}=P.useMessage(),{logEvent:o}=O.useChatEvents(),d=h.getMessageContent(r),{conversation:c}=L.useInkeepConversation();return r.role==="user"?n.jsx(ve,{"data-role":r.role,children:d,...s}):n.jsx(ve,{"data-role":r.role,...s,children:n.jsx(U.Markdown,{children:d,componentStyles:i,shouldOpenLinksInNewTab:e.shouldOpenLinksInNewTab,onLinkClick:(m,l)=>{o({eventName:"assistant_message_inline_link_opened",properties:{title:l?.toString(),url:m}})},onCodeCopy:(m,l)=>{o({eventName:"assistant_code_block_copied",properties:{conversation:c,language:m,code:l}})}})})},kn=a.ikp("div",{_id:"aiChatMessageToolbar"}),Ct=t=>{const{isLoading:e,messages:i}=v.useChat(),{message:s}=P.useMessage();return i.at(-1)?.id===s?.id&&e||s.role==="user"?null:n.jsx(kn,{...t})},In=a.ikp("div",{_id:"aiChatMessageToolActions"}),pt=t=>{const{children:e,...i}=t,{message:s}=P.useMessage(),{messageButtons:r}=v.useChat(),o=r[s.id]||[];return n.jsx(In,{children:h.maybeRender(e,o),...i})},Mn=a.ikp("a",{_id:"aiChatMessageToolAction"}),Sn=a.ikp("button",{_id:"aiChatMessageToolAction"}),vt=t=>{const{onClick:e,action:i,...s}=t,{handleAction:r}=se.useChatAction(i),{logEvent:o}=O.useChatEvents(),{conversation:d}=L.useInkeepConversation(),c=()=>{r(),o({eventName:"user_escalation_indicated",properties:{escalationType:"contact_us",conversation:d}})},m=i.label||"Contact Support",l=n.jsxs(n.Fragment,{children:[i.icon&&n.jsx(x.BuiltInIconRenderer,{iconSettings:i.icon}),m]});return i.action.type==="open_link"?n.jsx(Mn,{href:i.action.url,target:"_blank",rel:"noopener","data-type":i.action.type,onClick:u.composeEventHandlers(e,c),children:l,...s}):n.jsx(Sn,{"data-type":i.action.type,onClick:u.composeEventHandlers(e,c),children:l,...s})},xn=a.ikp("button",{_id:"aiChatMessageAction"}),bt=t=>{const{action:e,onClick:i,className:s,...r}=t,{conversation:o}=L.useInkeepConversation(),{message:d}=P.useMessage(),{isStreaming:c,messages:m}=v.useChat(),[l,C]=te.useCopyToClipboard(),{feedback:b,submitPositiveFeedback:k,setCurrentFeedback:y,currentFeedback:N}=ne.useMessageFeedback(),{logEvent:J}=O.useChatEvents(),[Q,X]=Sa.useSettleAction(),{baseSettings:{privacyPreferences:he}}=p.useInkeepConfig(),{optOutAllAnalytics:Z}=he,ue=m.at(-1)?.id===d?.id,ee=d.role==="assistant";if(ue&&c||!ee||{copy:!1,upvote:Z,downvote:Z}[e])return null;const H={copy(){C(h.getMessageContent(d)),J({eventName:"assistant_message_copied",properties:{conversation:o}})},upvote(){k(d.id).then(()=>{X()})},downvote(){y(d.id)}},D={copy:"Copy Message",upvote:"Upvote Message",downvote:"Downvote Message"},M={copy:n.jsx(E.CustomIcon,{iconKey:l?"messageCopied":"messageCopy"}),upvote:n.jsx(E.CustomIcon,{iconKey:Q?"messageCopied":"thumbsUp"}),downvote:n.jsx(E.CustomIcon,{iconKey:"thumbsDown"})},S={copy:{"data-copied":h.dataAttr(l)},upvote:{"data-upvoted":h.dataAttr(b[d.id]?.type==="positive")},downvote:{"data-downvoted":h.dataAttr(b[d.id]?.type==="negative"),"data-state":N===null?"closed":"open"}};return n.jsx(xn,{"data-action":e,...S[e],children:M[e],"aria-label":D[e],className:`${s} ${e}`,onClick:u.composeEventHandlers(i,H[e]),...r})},Bn=a.ikp("div",{_id:"aiChatMessageSources"}),gt=t=>{const{message:e}=P.useMessage();return e.role!=="assistant"||!e.links?.length?null:n.jsx(Bn,{...t})},fn=a.ikp("div",{_id:"aiChatMessageSources__Header"}),Pt=t=>n.jsx(fn,{children:"Sources",...t}),Tn=a.ikp("div",{_id:"aiChatMessageSources__List"}),At=t=>{const{message:e}=P.useMessage(),{children:i,...s}=t,{baseSettings:{transformSource:r,organizationDisplayName:o},aiChatSettings:{shouldOpenLinksInNewTab:d},searchSettings:{tabs:c}}=p.useInkeepConfig();if(e.role!=="assistant")return null;const m=e.links.map(l=>{const C=wa.transformInkeepSource(l,"chatSourceItem",{organizationDisplayName:o,tabs:c,transformSource:r}),b=C.shouldOpenInNewTab!==void 0?C.shouldOpenInNewTab:d;return{...C,isExternal:b}});return n.jsx(Tn,{children:h.maybeRender(i,m),...s})},jn=a.ikp(ka.LinkWithQueryParams,{_id:"aiChatMessageSourceItem"}),_t=t=>{const{source:e,onClick:i,...s}=t,{logEvent:r}=O.useChatEvents(),{conversation:o}=L.useInkeepConversation(),d=()=>{r({eventName:"assistant_source_item_clicked",properties:{conversation:o,link:e}})};return n.jsx(B.SourceItemProvider,{source:e,children:n.jsx(jn,{"data-type":e.type,appendToUrl:e.appendToUrl,isExternal:e.isExternal,"data-breadcrumbs":!!e.breadcrumbs?.length,onClick:u.composeEventHandlers(i,d),...s})})},yn=a.ikp("div",{_id:"aiChatMessageSourceItem__Breadcrumbs"}),Et=t=>{const{source:e}=B.useSourceItem();return e.breadcrumbs?.length?n.jsx(yn,{"data-type":e.type,...t}):null},Hn=a.ikp(E.CustomIcon,{_id:"aiChatMessageSourceItem__BreadcrumbIcon",iconKey:"breadcrumbSeparator"}),wn=a.ikp(x.BuiltInIconRenderer,{_id:"aiChatMessageSourceItem__Icon"}),Ft=t=>{const{source:e}=B.useSourceItem();return n.jsx(wn,{iconSettings:e.icon,"data-type":e.type,...t})},Ln=a.ikp("span",{_id:"aiChatMessageSourceItem__Title"}),kt=t=>{const{source:e}=B.useSourceItem();return n.jsx(Ln,{"data-type":e.type,children:e.title,...t})},Dn=a.ikp("span",{_id:"aiChatMessageSourceItem__Tag"}),It=t=>{const{source:e}=B.useSourceItem();return n.jsx(Dn,{"data-type":e.type,...t})},On=a.ikp("span",{_id:"aiChatMessageSourceItem__Description"}),Mt=t=>{const{source:e}=B.useSourceItem(),{children:i,...s}=t,r=g.useMemo(()=>e.description?fa.highlightEmphasis(e.description):[],[e.description]);return r.length?n.jsx(On,{"data-type":e.type,children:h.maybeRender(i,r),...s}):null},qn=a.ikp("span",{_id:"aiChatMessageSourceItem__DescriptionPart"}),St=t=>{const{part:e,...i}=t,{source:s}=B.useSourceItem();return typeof e=="string"?e:n.jsx(qn,{"data-type":s.type,children:e.content,"data-highlighted":h.dataAttr(e.highlighted),...i})},Rn=a.ikp(E.CustomIcon,{_id:"aiChatMessageSourceItem__Indicator"}),xt=t=>{const{source:e}=B.useSourceItem();return n.jsx(Rn,{iconKey:e.isExternal?"openLinkInNewTab":"openLinkInSameTab",...t})},Bt=a.ikp("div",{_id:"aiChatFooter"}),ft=a.ikp("div",{_id:"aiChatInput__Fieldset"}),Tt=a.ikp("div",{_id:"aiChatInput__Group"}),Wn=a.ikp("textarea",{_id:"aiChatInput"}),jt=g.forwardRef(({onChange:t,onKeyDown:e,...i},s)=>{const{handleInputChange:r,handleInputKeyDown:o,input:d,error:c,shouldAutoFocusInput:m,inputRef:l}=v.useChat(),{aiChatSettings:C}=p.useInkeepConfig(),b=re.useComposedRefs(s,l);return Da.useWidgetAutoFocus("chat",l,m),n.jsx(Wn,{asChild:!0,ref:b,maxLength:99999,placeholder:C.placeholder,value:d,onChange:u.composeEventHandlers(t,r),onKeyDown:u.composeEventHandlers(e,o),disabled:!!c||C.isViewOnly,...i,children:n.jsx(ae,{})})}),Nn=a.ikp("button",{_id:"aiChatInput__SendButton"}),yt=t=>{const{handleSubmit:e,isSubmitDisabled:i,error:s}=v.useChat(),{aiChatSettings:r}=p.useInkeepConfig(),{onClick:o,...d}=t;return n.jsx(Nn,{onClick:u.composeEventHandlers(o,()=>e()),"aria-label":"Send message",disabled:i||!!s||r.isViewOnly,...d})},Ht=a.ikp(E.CustomIcon,{_id:"aiChatInput__SendButtonIcon",iconKey:"chatSubmit"}),Qn=a.ikp("div",{_id:"aiChatAttachmentsBar"}),wt=t=>{const{selectedWorkflow:e}=v.useChat();return!e||!e.supportedInputs?.length?null:n.jsx(F.AttachmentsBarProvider,{children:n.jsx(Qn,{...t})})},$n=a.ikp("div",{_id:"aiChatAttachmentsBar__List"}),Lt=t=>{const{children:e,...i}=t,{messageAttachments:s}=v.useChat();return n.jsx($n,{children:h.maybeRender(e,s),...i})},Vn=a.ikp("div",{_id:"aiChatAttachmentsBar__Attachment"}),Dt=t=>{const{attachment:e,...i}=t;return n.jsx(w.AttachmentItemProvider,{attachment:e,children:n.jsx(Vn,{...i})})},Un=a.ikp(x.BuiltInIconRenderer,{_id:"aiChatAttachmentsBar__AttachmentIcon"}),Ot=t=>{const{attachment:e}=w.useAttachmentItem(),i=e.contentType?.attachmentIcon;return i?n.jsx(Un,{iconSettings:i,...t}):null},Kn=a.ikp("span",{_id:"aiChatAttachmentsBar__AttachmentTitle"}),qt=t=>{const{attachment:e}=w.useAttachmentItem();return n.jsx(Kn,{children:e.title,...t})},zn=a.ikp("button",{_id:"aiChatAttachmentsBar__AttachmentDelete"}),Rt=t=>{const{onClick:e,...i}=t,{attachment:s}=w.useAttachmentItem(),{setMessageAttachments:r}=v.useChat(),o=()=>{r(d=>d.filter(c=>c.id!==s.id))};return n.jsx(zn,{"aria-label":"Remove attachment",children:n.jsx(E.CustomIcon,{iconKey:"close"}),onClick:u.composeEventHandlers(e,o),...i})},Wt=a.ikp("div",{_id:"aiChatAttachmentsBar__Actions"}),Nt=a.ikp(j.Tooltip,{_id:"aiChatAttachmentsBar__InfoTip",delayDuration:0}),Qt=a.ikp(j.Trigger,{_id:"aiChatAttachmentsBar__InfoTipIcon",children:n.jsx(E.CustomIcon,{iconKey:"info"})}),me=a.ikp(j.Arrow,{_id:"aiChatAttachmentsBar__InfoTipArrow"}),$t=a.ikp(j.Content,{_id:"aiChatAttachmentsBar__InfoTipText",side:"bottom",sideOffset:3,align:"center",children:n.jsxs(n.Fragment,{children:[n.jsx(me,{}),"Attachments will be kept in context for the entire conversation."]})}),Gn=a.ikp("div",{_id:"aiChatAttachmentsBar__Inputs"}),Vt=t=>{const{children:e,...i}=t,{selectedWorkflow:s}=v.useChat();return s?.supportedInputs?n.jsx(Gn,{children:h.maybeRender(e,s.supportedInputs),...i}):null},Yn=a.ikp("button",{_id:"aiChatAttachmentsBar__Input"}),Ut=t=>{const{input:e,onClick:i,...s}=t,{selectedWorkflow:r,messageAttachments:o,setMessageAttachments:d}=v.useChat(),{selectInput:c,onOpen:m}=F.useAttachmentsBar(),l=()=>{if(e.type==="FUNCTIONAL_MULTI_ATTACHMENT")return r?e.onInvoke(r,e,d,[...o]):void 0;c(e),m()};return n.jsx(Yn,{children:e.displayName,onClick:u.composeEventHandlers(i,l),...s})},Jn=a.ikp(A.Root,{_id:"aiChatAttachmentsBar__Modal"}),Kt=t=>{const{onOpenChange:e,...i}=t,{selectInput:s,isOpen:r,onClose:o,selectedInput:d}=F.useAttachmentsBar(),c=m=>{m||(o(),s(null))};return n.jsx(Jn,{open:r&&d!==null,onOpenChange:u.composeEventHandlers(e,c),...i})},zt=a.ikp(A.Overlay,{_id:"aiChatAttachmentsBar__ModalOverlay"}),Gt=a.ikp(A.Content,{_id:"aiChatAttachmentsBar__ModalContent","aria-describedby":void 0}),Yt=a.ikp("div",{_id:"aiChatAttachmentsBar__ModalHeader"}),Xn=a.ikp(A.Title,{_id:"aiChatAttachmentsBar__ModalHeading"}),Jt=t=>{const{selectedInput:e}=F.useAttachmentsBar(),i=`Add ${e?.displayName}`;return n.jsx(Xn,{children:i,...t})},Zn=a.ikp("span",{_id:"aiChatAttachmentsBar__ModalDescription"}),Xt=t=>{const{selectedInput:e}=F.useAttachmentsBar(),i=e?.workflowModalProps?.modalHelpText;return i?n.jsx(Zn,{children:i,...t}):null},es=a.ikp("div",{_id:"aiChatAttachmentsBar__ModalHelp"}),Zt=t=>{const{children:e,...i}=t,{selectedInput:s}=F.useAttachmentsBar(),r=s?.workflowModalProps?.modalHelpElement;return r?n.jsx(es,{asChild:!e,children:e||r,...i}):null},ei=a.ikp(A.Close,{_id:"aiChatAttachmentsBar__ModalClose",children:n.jsx(E.CustomIcon,{iconKey:"close"})}),ti=a.ikp("div",{_id:"aiChatAttachmentsBar__ModalBody"}),ts=a.ikp("form",{_id:"aiChatAttachmentsBar__Form"}),ii=t=>{const{onSubmit:e,...i}=t,{form:s}=F.useAttachmentsBar();return n.jsx(ts,{onSubmit:u.composeEventHandlers(e,s.onSubmit),...i})},ai=a.ikp("div",{_id:"aiChatAttachmentsBar__FormTitle",role:"group"}),is=a.ikp("label",{_id:"aiChatAttachmentsBar__FormTitleLabel"}),ni=t=>{const{form:e,selectedInput:i}=F.useAttachmentsBar();return n.jsx(is,{htmlFor:`${i?.id}-title`,children:e.labels.title,...t})},as=a.ikp("input",{_id:"aiChatAttachmentsBar__FormTitleInput"}),si=t=>{const{onChange:e,...i}=t,{form:s,selectedInput:r}=F.useAttachmentsBar();return n.jsx(as,{name:"title",value:s.data.title,id:`${r?.id}-title`,"data-invalid":h.dataAttr(!!s.errors.title),"aria-invalid":!!s.errors.title,onChange:u.composeEventHandlers(e,s.onChange),...i})},ns=a.ikp("span",{_id:"aiChatAttachmentsBar__FormTitleError"}),ri=t=>{const{form:e}=F.useAttachmentsBar();return e.errors.title?n.jsx(ns,{"aria-live":"polite",children:e.errors.title,...t}):null},oi=a.ikp("div",{_id:"aiChatAttachmentsBar__FormTitle",role:"group"}),ss=a.ikp("label",{_id:"aiChatAttachmentsBar__FormContentLabel"}),di=t=>{const{form:e,selectedInput:i}=F.useAttachmentsBar();return n.jsx(ss,{htmlFor:`${i?.id}-content`,children:e.labels.content,...t})},rs=a.ikp("textarea",{_id:"aiChatAttachmentsBar__FormTitleInput"}),ci=t=>{const{onChange:e,...i}=t,{form:s,selectedInput:r}=F.useAttachmentsBar();return n.jsx(rs,{asChild:!0,rows:4,name:"content",value:s.data.content,id:`${r?.id}-content`,"data-invalid":h.dataAttr(!!s.errors.content),"aria-invalid":!!s.errors.content,onChange:u.composeEventHandlers(e,s.onChange),...i,children:n.jsx(ae,{maxRows:10})})},os=a.ikp("span",{_id:"aiChatAttachmentsBar__FormContentError"}),mi=t=>{const{form:e}=F.useAttachmentsBar();return e.errors.content?n.jsx(os,{"aria-live":"polite",children:e.errors.content,...t}):null},li=a.ikp("button",{_id:"aiChatAttachmentsBar__FormSubmitButton",children:"Upload",type:"submit"}),hi=a.ikp("div",{_id:"aiChatActionBar"}),ui=a.ikp("div",{_id:"aiChat__ChatActions"}),Ci=a.ikp("div",{_id:"aiChatTagline__Container"}),pi=a.ikp("span",{_id:"aiChatTagline__Text",children:"Powered by"}),vi=a.ikp(Ma.default,{_id:"aiChatTagline__Logo"}),bi=a.ikp("a",{_id:"aiChatTagline__BrandName",children:"inkeep",href:"https://www.inkeep.com/",target:"_blank",rel:"noopener noreferrer"}),ds=a.ikp(j.Trigger,{_id:"aiChat__ChatAction"}),G=t=>{const{action:e,onClick:i,className:s,...r}=t,{clear:o,stop:d,isLoading:c,messages:m,selectedWorkflow:l}=v.useChat(),{conversation:C}=L.useInkeepConversation(),{aiChatSettings:b,baseSettings:k}=p.useInkeepConfig(),{logEvent:y}=O.useChatEvents(),[N,J]=te.useCopyToClipboard(),[Q,X]=te.useCopyToClipboard();if({help:!1,copy:m.length===0||!b.isCopyChatButtonVisible||c,share:m.length===0||!b.isShareButtonVisible||!C.id||!!l||c,clear:m.length===0||b.isViewOnly||c,stop:!c}[e])return null;const ee={help:()=>{},copy:()=>{const $=m.map(H=>{const D=`**${H.role==="assistant"?"AI Assistant":"User"}**`,M=h.getMessageContent(H),S=Ia.stringifyAttachments(H.metadata?.attributes?.attachments),V=S?`
|
|
7
|
+
Let me know how I can help.`,b={content:s.introMessage??`${m}${l}`,id:Oa,...e,role:"assistant",links:[]};return n.jsx(ce,{message:b,...i})}),dn=a.ikp("div",{_id:"aiChatMessageHeader"}),Ke=t=>{const{message:e}=P.useMessage();return n.jsx(dn,{"data-role":e.role,...t})},cn=a.ikp("div",{_id:"aiChatMessageLoading"}),ze=t=>{const{isLoading:e,isStreaming:i,messages:s}=v.useChat(),{message:r}=P.useMessage();return!(s.at(-1)?.id===r?.id)||r.role!=="assistant"||!e||i?null:n.jsx(cn,{children:"Thinking...",...t})},mn=a.ikp("div",{_id:"aiChatMessageAvatar"}),Ge=t=>{const{message:e}=P.useMessage();return n.jsx(mn,{"data-role":e.role,...t})},ln=a.ikp(de.Root,{_id:"aiChatMessageAvatarContent"}),Ye=t=>{const{message:e}=P.useMessage(),{baseSettings:i}=p.useInkeepConfig();return n.jsx(ln,{"data-username":h.dataAttr(e.role==="user"&&!!i.userProperties.name),"data-role":e.role,...t})},hn=a.ikp(de.Fallback,{_id:"aiChatMessageAvatarFallback"}),Je=g.memo(t=>{const{baseSettings:e}=p.useInkeepConfig(),{message:i}=P.useMessage();return e.userProperties.name?n.jsx(hn,{"data-role":i.role,children:h.getInitials(e.userProperties.name),...t}):null}),pe=a.ikp(de.Image,{_id:"aiChatMessageAvatarImage"}),Xe=g.memo(t=>{const{onLoadingStatusChange:e,...i}=t,{aiChatSettings:s,baseSettings:{userProperties:r}}=p.useInkeepConfig(),{message:o}=P.useMessage(),{aiAssistantAvatar:d}=s??{},c=typeof d=="string"?d:d?.light,m=(typeof d=="string"?d:d?.dark)??c,l=ja.useColorModeValue(c,m),[C,b]=g.useState(l);g.useEffect(()=>{b(l)},[l]);const k=y=>{y==="error"&&b(null)};return o.role==="user"?r.name?null:s.userAvatar?n.jsx(pe,{"data-type":"image",alt:"User avatar","data-role":o.role,src:s.userAvatar,...t}):n.jsx(Fa.default,{"data-type":"icon","data-role":o.role,...t}):C?n.jsx(pe,{src:C,alt:"AI assistant avatar","data-type":"image","data-role":o.role,onLoadingStatusChange:u.composeEventHandlers(e,k),...i}):n.jsx(Ea.default,{"data-type":"icon","data-role":o.role,...t})}),un=a.ikp("span",{_id:"aiChatMessageName"}),Ze=t=>{const{message:e}=P.useMessage();return n.jsx(un,{"data-role":e.role,children:e.role==="user"?"You":"AI assistant",...t})},Cn=a.ikp("div",{_id:"aiChatMessageContentWrapper"}),et=t=>{const{message:e}=P.useMessage(),{messageButtons:i}=v.useChat(),s=i[e.id]||[];return n.jsx(Cn,{"data-role":e.role,"data-has-message-buttons":h.dataAttr(!!s.length),...t})},pn=a.ikp("div",{_id:"aiChatMessageContent"}),tt=t=>{const{message:e}=P.useMessage();return n.jsx(pn,{"data-role":e.role,...t})},vn=a.ikp("div",{_id:"aiChatMessageAttachments"}),it=t=>{const{message:e}=P.useMessage(),i=e.metadata?.attributes?.attachments;return e.role!=="user"||!i?.length?null:n.jsx(q.MessageAttachmentsProvider,{children:n.jsx(vn,{...t})})},bn=a.ikp("div",{_id:"aiChatMessageAttachments__List"}),at=t=>{const{children:e,...i}=t,{message:s}=P.useMessage(),r=s.metadata?.attributes?.attachments;return r?n.jsx(bn,{children:h.maybeRender(e,r),...i}):null},gn=a.ikp("div",{_id:"aiChatMessageAttachments__Item"}),nt=t=>{const{attachment:e,onClick:i,...s}=t,{selectItem:r,onOpen:o}=q.useMessageAttachments(),d=()=>{r(e),o()};return n.jsx(w.AttachmentItemProvider,{attachment:e,children:n.jsx(gn,{onClick:u.composeEventHandlers(i,d),...s})})},Pn=a.ikp(x.BuiltInIconRenderer,{_id:"aiChatMessageAttachments__ItemIcon"}),st=t=>{const{attachment:e}=w.useAttachmentItem(),i=e.contentType?.attachmentIcon;return i?n.jsx(Pn,{iconSettings:i,...t}):null},_n=a.ikp("span",{_id:"aiChatMessageAttachments__ItemTitle"}),rt=t=>{const{attachment:e}=w.useAttachmentItem();return n.jsx(_n,{children:e.title,...t})},An=a.ikp(_.Root,{_id:"aiChatMessageAttachmentsPreview"}),ot=t=>{const{onOpenChange:e,...i}=t,{selectItem:s,isOpen:r,onClose:o,selectedItem:d}=q.useMessageAttachments(),c=m=>{m||(o(),s(null))};return n.jsx(An,{open:r&&d!==null,onOpenChange:u.composeEventHandlers(e,c),...i})},dt=a.ikp(_.Overlay,{_id:"aiChatMessageAttachmentsPreview__Overlay"}),ct=a.ikp(_.Content,{_id:"aiChatMessageAttachmentsPreview__Content","aria-describedby":void 0}),En=a.ikp(_.Title,{_id:"aiChatMessageAttachmentsPreview__Header"}),mt=t=>{const{selectedItem:e}=q.useMessageAttachments();return n.jsx(En,{children:e?.title||"Attachment",...t})},lt=a.ikp(_.Close,{_id:"aiChatMessageAttachmentsPreview__Close",children:n.jsx(E.CustomIcon,{iconKey:"close"})}),Fn=a.ikp("p",{_id:"aiChatMessageAttachmentsPreview__Body"}),ht=t=>{const{selectedItem:e}=q.useMessageAttachments();return n.jsx(Fn,{children:e?.content,...t})},ve=a.ikp("div",{_id:"aiChatMessage"}),ut=t=>{const{aiChatSettings:e}=p.useInkeepConfig(),{componentStyles:i,...s}=t,{message:r}=P.useMessage(),{logEvent:o}=O.useChatEvents(),d=h.getMessageContent(r),{conversation:c}=L.useInkeepConversation();return r.role==="user"?n.jsx(ve,{"data-role":r.role,children:d,...s}):n.jsx(ve,{"data-role":r.role,...s,children:n.jsx(U.Markdown,{children:d,componentStyles:i,shouldOpenLinksInNewTab:e.shouldOpenLinksInNewTab,onLinkClick:(m,l)=>{o({eventName:"assistant_message_inline_link_opened",properties:{title:l?.toString(),url:m}})},onCodeCopy:(m,l)=>{o({eventName:"assistant_code_block_copied",properties:{conversation:c,language:m,code:l}})}})})},kn=a.ikp("div",{_id:"aiChatMessageToolbar"}),Ct=t=>{const{isLoading:e,messages:i}=v.useChat(),{message:s}=P.useMessage();return i.at(-1)?.id===s?.id&&e||s.role==="user"?null:n.jsx(kn,{...t})},In=a.ikp("div",{_id:"aiChatMessageToolActions"}),pt=t=>{const{children:e,...i}=t,{message:s}=P.useMessage(),{messageButtons:r}=v.useChat(),o=r[s.id]||[];return n.jsx(In,{children:h.maybeRender(e,o),...i})},Mn=a.ikp("a",{_id:"aiChatMessageToolAction"}),Sn=a.ikp("button",{_id:"aiChatMessageToolAction"}),vt=t=>{const{onClick:e,action:i,...s}=t,{handleAction:r}=se.useChatAction(i),{logEvent:o}=O.useChatEvents(),{conversation:d}=L.useInkeepConversation(),c=()=>{r(),o({eventName:"tool_call_action_clicked",properties:{conversation:d}}),i.action.type!=="open_form"&&o({eventName:"user_escalation_indicated",properties:{escalationType:"contact_us",conversation:d}})},m=i.label||"Contact Support",l=n.jsxs(n.Fragment,{children:[i.icon&&n.jsx(x.BuiltInIconRenderer,{iconSettings:i.icon}),m]});return i.action.type==="open_link"?n.jsx(Mn,{href:i.action.url,target:"_blank",rel:"noopener","data-type":i.action.type,onClick:u.composeEventHandlers(e,c),children:l,...s}):n.jsx(Sn,{"data-type":i.action.type,onClick:u.composeEventHandlers(e,c),children:l,...s})},xn=a.ikp("button",{_id:"aiChatMessageAction"}),bt=t=>{const{action:e,onClick:i,className:s,...r}=t,{conversation:o}=L.useInkeepConversation(),{message:d}=P.useMessage(),{isStreaming:c,messages:m}=v.useChat(),[l,C]=te.useCopyToClipboard(),{feedback:b,submitPositiveFeedback:k,setCurrentFeedback:y,currentFeedback:N}=ne.useMessageFeedback(),{logEvent:J}=O.useChatEvents(),[Q,X]=Sa.useSettleAction(),{baseSettings:{privacyPreferences:he}}=p.useInkeepConfig(),{optOutAllAnalytics:Z}=he,ue=m.at(-1)?.id===d?.id,ee=d.role==="assistant";if(ue&&c||!ee||{copy:!1,upvote:Z,downvote:Z}[e])return null;const H={copy(){C(h.getMessageContent(d)),J({eventName:"assistant_message_copied",properties:{conversation:o}})},upvote(){k(d.id).then(()=>{X()})},downvote(){y(d.id)}},D={copy:"Copy Message",upvote:"Upvote Message",downvote:"Downvote Message"},M={copy:n.jsx(E.CustomIcon,{iconKey:l?"messageCopied":"messageCopy"}),upvote:n.jsx(E.CustomIcon,{iconKey:Q?"messageCopied":"thumbsUp"}),downvote:n.jsx(E.CustomIcon,{iconKey:"thumbsDown"})},S={copy:{"data-copied":h.dataAttr(l)},upvote:{"data-upvoted":h.dataAttr(b[d.id]?.type==="positive")},downvote:{"data-downvoted":h.dataAttr(b[d.id]?.type==="negative"),"data-state":N===null?"closed":"open"}};return n.jsx(xn,{"data-action":e,...S[e],children:M[e],"aria-label":D[e],className:`${s} ${e}`,onClick:u.composeEventHandlers(i,H[e]),...r})},fn=a.ikp("div",{_id:"aiChatMessageSources"}),gt=t=>{const{message:e}=P.useMessage();return e.role!=="assistant"||!e.links?.length?null:n.jsx(fn,{...t})},Bn=a.ikp("div",{_id:"aiChatMessageSources__Header"}),Pt=t=>n.jsx(Bn,{children:"Sources",...t}),Tn=a.ikp("div",{_id:"aiChatMessageSources__List"}),_t=t=>{const{message:e}=P.useMessage(),{children:i,...s}=t,{baseSettings:{transformSource:r,organizationDisplayName:o},aiChatSettings:{shouldOpenLinksInNewTab:d},searchSettings:{tabs:c}}=p.useInkeepConfig();if(e.role!=="assistant")return null;const m=e.links.map(l=>{const C=wa.transformInkeepSource(l,"chatSourceItem",{organizationDisplayName:o,tabs:c,transformSource:r}),b=C.shouldOpenInNewTab!==void 0?C.shouldOpenInNewTab:d;return{...C,isExternal:b}});return n.jsx(Tn,{children:h.maybeRender(i,m),...s})},jn=a.ikp(ka.LinkWithQueryParams,{_id:"aiChatMessageSourceItem"}),At=t=>{const{source:e,onClick:i,...s}=t,{logEvent:r}=O.useChatEvents(),{conversation:o}=L.useInkeepConversation(),d=()=>{r({eventName:"assistant_source_item_clicked",properties:{conversation:o,link:e}})};return n.jsx(f.SourceItemProvider,{source:e,children:n.jsx(jn,{"data-type":e.type,appendToUrl:e.appendToUrl,isExternal:e.isExternal,"data-breadcrumbs":!!e.breadcrumbs?.length,onClick:u.composeEventHandlers(i,d),...s})})},yn=a.ikp("div",{_id:"aiChatMessageSourceItem__Breadcrumbs"}),Et=t=>{const{source:e}=f.useSourceItem();return e.breadcrumbs?.length?n.jsx(yn,{"data-type":e.type,...t}):null},Hn=a.ikp(E.CustomIcon,{_id:"aiChatMessageSourceItem__BreadcrumbIcon",iconKey:"breadcrumbSeparator"}),wn=a.ikp(x.BuiltInIconRenderer,{_id:"aiChatMessageSourceItem__Icon"}),Ft=t=>{const{source:e}=f.useSourceItem();return n.jsx(wn,{iconSettings:e.icon,"data-type":e.type,...t})},Ln=a.ikp("span",{_id:"aiChatMessageSourceItem__Title"}),kt=t=>{const{source:e}=f.useSourceItem();return n.jsx(Ln,{"data-type":e.type,children:e.title,...t})},Dn=a.ikp("span",{_id:"aiChatMessageSourceItem__Tag"}),It=t=>{const{source:e}=f.useSourceItem();return n.jsx(Dn,{"data-type":e.type,...t})},On=a.ikp("span",{_id:"aiChatMessageSourceItem__Description"}),Mt=t=>{const{source:e}=f.useSourceItem(),{children:i,...s}=t,r=g.useMemo(()=>e.description?Ba.highlightEmphasis(e.description):[],[e.description]);return r.length?n.jsx(On,{"data-type":e.type,children:h.maybeRender(i,r),...s}):null},qn=a.ikp("span",{_id:"aiChatMessageSourceItem__DescriptionPart"}),St=t=>{const{part:e,...i}=t,{source:s}=f.useSourceItem();return typeof e=="string"?e:n.jsx(qn,{"data-type":s.type,children:e.content,"data-highlighted":h.dataAttr(e.highlighted),...i})},Rn=a.ikp(E.CustomIcon,{_id:"aiChatMessageSourceItem__Indicator"}),xt=t=>{const{source:e}=f.useSourceItem();return n.jsx(Rn,{iconKey:e.isExternal?"openLinkInNewTab":"openLinkInSameTab",...t})},ft=a.ikp("div",{_id:"aiChatFooter"}),Bt=a.ikp("div",{_id:"aiChatInput__Fieldset"}),Tt=a.ikp("div",{_id:"aiChatInput__Group"}),Wn=a.ikp("textarea",{_id:"aiChatInput"}),jt=g.forwardRef(({onChange:t,onKeyDown:e,...i},s)=>{const{handleInputChange:r,handleInputKeyDown:o,input:d,error:c,shouldAutoFocusInput:m,inputRef:l}=v.useChat(),{aiChatSettings:C}=p.useInkeepConfig(),b=re.useComposedRefs(s,l);return Da.useWidgetAutoFocus("chat",l,m),n.jsx(Wn,{asChild:!0,ref:b,maxLength:99999,placeholder:C.placeholder,value:d,onChange:u.composeEventHandlers(t,r),onKeyDown:u.composeEventHandlers(e,o),disabled:!!c||C.isViewOnly,...i,children:n.jsx(ae,{})})}),Nn=a.ikp("button",{_id:"aiChatInput__SendButton"}),yt=t=>{const{handleSubmit:e,isSubmitDisabled:i,error:s}=v.useChat(),{aiChatSettings:r}=p.useInkeepConfig(),{onClick:o,...d}=t;return n.jsx(Nn,{onClick:u.composeEventHandlers(o,()=>e()),"aria-label":"Send message",disabled:i||!!s||r.isViewOnly,...d})},Ht=a.ikp(E.CustomIcon,{_id:"aiChatInput__SendButtonIcon",iconKey:"chatSubmit"}),Qn=a.ikp("div",{_id:"aiChatAttachmentsBar"}),wt=t=>{const{selectedWorkflow:e}=v.useChat();return!e||!e.supportedInputs?.length?null:n.jsx(F.AttachmentsBarProvider,{children:n.jsx(Qn,{...t})})},$n=a.ikp("div",{_id:"aiChatAttachmentsBar__List"}),Lt=t=>{const{children:e,...i}=t,{messageAttachments:s}=v.useChat();return n.jsx($n,{children:h.maybeRender(e,s),...i})},Vn=a.ikp("div",{_id:"aiChatAttachmentsBar__Attachment"}),Dt=t=>{const{attachment:e,...i}=t;return n.jsx(w.AttachmentItemProvider,{attachment:e,children:n.jsx(Vn,{...i})})},Un=a.ikp(x.BuiltInIconRenderer,{_id:"aiChatAttachmentsBar__AttachmentIcon"}),Ot=t=>{const{attachment:e}=w.useAttachmentItem(),i=e.contentType?.attachmentIcon;return i?n.jsx(Un,{iconSettings:i,...t}):null},Kn=a.ikp("span",{_id:"aiChatAttachmentsBar__AttachmentTitle"}),qt=t=>{const{attachment:e}=w.useAttachmentItem();return n.jsx(Kn,{children:e.title,...t})},zn=a.ikp("button",{_id:"aiChatAttachmentsBar__AttachmentDelete"}),Rt=t=>{const{onClick:e,...i}=t,{attachment:s}=w.useAttachmentItem(),{setMessageAttachments:r}=v.useChat(),o=()=>{r(d=>d.filter(c=>c.id!==s.id))};return n.jsx(zn,{"aria-label":"Remove attachment",children:n.jsx(E.CustomIcon,{iconKey:"close"}),onClick:u.composeEventHandlers(e,o),...i})},Wt=a.ikp("div",{_id:"aiChatAttachmentsBar__Actions"}),Nt=a.ikp(j.Tooltip,{_id:"aiChatAttachmentsBar__InfoTip",delayDuration:0}),Qt=a.ikp(j.Trigger,{_id:"aiChatAttachmentsBar__InfoTipIcon",children:n.jsx(E.CustomIcon,{iconKey:"info"})}),me=a.ikp(j.Arrow,{_id:"aiChatAttachmentsBar__InfoTipArrow"}),$t=a.ikp(j.Content,{_id:"aiChatAttachmentsBar__InfoTipText",side:"bottom",sideOffset:3,align:"center",children:n.jsxs(n.Fragment,{children:[n.jsx(me,{}),"Attachments will be kept in context for the entire conversation."]})}),Gn=a.ikp("div",{_id:"aiChatAttachmentsBar__Inputs"}),Vt=t=>{const{children:e,...i}=t,{selectedWorkflow:s}=v.useChat();return s?.supportedInputs?n.jsx(Gn,{children:h.maybeRender(e,s.supportedInputs),...i}):null},Yn=a.ikp("button",{_id:"aiChatAttachmentsBar__Input"}),Ut=t=>{const{input:e,onClick:i,...s}=t,{selectedWorkflow:r,messageAttachments:o,setMessageAttachments:d}=v.useChat(),{selectInput:c,onOpen:m}=F.useAttachmentsBar(),l=()=>{if(e.type==="FUNCTIONAL_MULTI_ATTACHMENT")return r?e.onInvoke(r,e,d,[...o]):void 0;c(e),m()};return n.jsx(Yn,{children:e.displayName,onClick:u.composeEventHandlers(i,l),...s})},Jn=a.ikp(_.Root,{_id:"aiChatAttachmentsBar__Modal"}),Kt=t=>{const{onOpenChange:e,...i}=t,{selectInput:s,isOpen:r,onClose:o,selectedInput:d}=F.useAttachmentsBar(),c=m=>{m||(o(),s(null))};return n.jsx(Jn,{open:r&&d!==null,onOpenChange:u.composeEventHandlers(e,c),...i})},zt=a.ikp(_.Overlay,{_id:"aiChatAttachmentsBar__ModalOverlay"}),Gt=a.ikp(_.Content,{_id:"aiChatAttachmentsBar__ModalContent","aria-describedby":void 0}),Yt=a.ikp("div",{_id:"aiChatAttachmentsBar__ModalHeader"}),Xn=a.ikp(_.Title,{_id:"aiChatAttachmentsBar__ModalHeading"}),Jt=t=>{const{selectedInput:e}=F.useAttachmentsBar(),i=`Add ${e?.displayName}`;return n.jsx(Xn,{children:i,...t})},Zn=a.ikp("span",{_id:"aiChatAttachmentsBar__ModalDescription"}),Xt=t=>{const{selectedInput:e}=F.useAttachmentsBar(),i=e?.workflowModalProps?.modalHelpText;return i?n.jsx(Zn,{children:i,...t}):null},es=a.ikp("div",{_id:"aiChatAttachmentsBar__ModalHelp"}),Zt=t=>{const{children:e,...i}=t,{selectedInput:s}=F.useAttachmentsBar(),r=s?.workflowModalProps?.modalHelpElement;return r?n.jsx(es,{asChild:!e,children:e||r,...i}):null},ei=a.ikp(_.Close,{_id:"aiChatAttachmentsBar__ModalClose",children:n.jsx(E.CustomIcon,{iconKey:"close"})}),ti=a.ikp("div",{_id:"aiChatAttachmentsBar__ModalBody"}),ts=a.ikp("form",{_id:"aiChatAttachmentsBar__Form"}),ii=t=>{const{onSubmit:e,...i}=t,{form:s}=F.useAttachmentsBar();return n.jsx(ts,{onSubmit:u.composeEventHandlers(e,s.onSubmit),...i})},ai=a.ikp("div",{_id:"aiChatAttachmentsBar__FormTitle",role:"group"}),is=a.ikp("label",{_id:"aiChatAttachmentsBar__FormTitleLabel"}),ni=t=>{const{form:e,selectedInput:i}=F.useAttachmentsBar();return n.jsx(is,{htmlFor:`${i?.id}-title`,children:e.labels.title,...t})},as=a.ikp("input",{_id:"aiChatAttachmentsBar__FormTitleInput"}),si=t=>{const{onChange:e,...i}=t,{form:s,selectedInput:r}=F.useAttachmentsBar();return n.jsx(as,{name:"title",value:s.data.title,id:`${r?.id}-title`,"data-invalid":h.dataAttr(!!s.errors.title),"aria-invalid":!!s.errors.title,onChange:u.composeEventHandlers(e,s.onChange),...i})},ns=a.ikp("span",{_id:"aiChatAttachmentsBar__FormTitleError"}),ri=t=>{const{form:e}=F.useAttachmentsBar();return e.errors.title?n.jsx(ns,{"aria-live":"polite",children:e.errors.title,...t}):null},oi=a.ikp("div",{_id:"aiChatAttachmentsBar__FormTitle",role:"group"}),ss=a.ikp("label",{_id:"aiChatAttachmentsBar__FormContentLabel"}),di=t=>{const{form:e,selectedInput:i}=F.useAttachmentsBar();return n.jsx(ss,{htmlFor:`${i?.id}-content`,children:e.labels.content,...t})},rs=a.ikp("textarea",{_id:"aiChatAttachmentsBar__FormTitleInput"}),ci=t=>{const{onChange:e,...i}=t,{form:s,selectedInput:r}=F.useAttachmentsBar();return n.jsx(rs,{asChild:!0,rows:4,name:"content",value:s.data.content,id:`${r?.id}-content`,"data-invalid":h.dataAttr(!!s.errors.content),"aria-invalid":!!s.errors.content,onChange:u.composeEventHandlers(e,s.onChange),...i,children:n.jsx(ae,{maxRows:10})})},os=a.ikp("span",{_id:"aiChatAttachmentsBar__FormContentError"}),mi=t=>{const{form:e}=F.useAttachmentsBar();return e.errors.content?n.jsx(os,{"aria-live":"polite",children:e.errors.content,...t}):null},li=a.ikp("button",{_id:"aiChatAttachmentsBar__FormSubmitButton",children:"Upload",type:"submit"}),hi=a.ikp("div",{_id:"aiChatActionBar"}),ui=a.ikp("div",{_id:"aiChat__ChatActions"}),Ci=a.ikp("div",{_id:"aiChatTagline__Container"}),pi=a.ikp("span",{_id:"aiChatTagline__Text",children:"Powered by"}),vi=a.ikp(Ma.default,{_id:"aiChatTagline__Logo"}),bi=a.ikp("a",{_id:"aiChatTagline__BrandName",children:"inkeep",href:"https://www.inkeep.com/",target:"_blank",rel:"noopener noreferrer"}),ds=a.ikp(j.Trigger,{_id:"aiChat__ChatAction"}),G=t=>{const{action:e,onClick:i,className:s,...r}=t,{clear:o,stop:d,isLoading:c,messages:m,selectedWorkflow:l}=v.useChat(),{conversation:C}=L.useInkeepConversation(),{aiChatSettings:b,baseSettings:k}=p.useInkeepConfig(),{logEvent:y}=O.useChatEvents(),[N,J]=te.useCopyToClipboard(),[Q,X]=te.useCopyToClipboard();if({help:!1,copy:m.length===0||!b.isCopyChatButtonVisible||c,share:m.length===0||!b.isShareButtonVisible||!C.id||!!l||c,clear:m.length===0||b.isViewOnly||c,stop:!c}[e])return null;const ee={help:()=>{},copy:()=>{const $=m.map(H=>{const D=`**${H.role==="assistant"?"AI Assistant":"User"}**`,M=h.getMessageContent(H),S=Ia.stringifyAttachments(H.metadata?.attributes?.attachments),V=S?`
|
|
8
8
|
|
|
9
9
|
**Attachments**
|
|
10
10
|
|
|
@@ -14,4 +14,4 @@ ${M}${V}`}).join(`
|
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
-
`);J($)},share:async()=>{const $={visibility:"public",tags:[],userProperties:{},messages:C.messages.map(S=>({...S,createdAt:void 0,updatedAt:void 0,id:Date.now().toString()+S.id,conversationId:void 0}))},{apiKey:H,analyticsApiBaseUrl:D}=k,M=await Ha.logConversation("",$,H,D);if(M){const V=`${b.shareChatUrlBasePath}?${L.SHARE_QUERY_PARAM}=${M?.id}`;X(V),y({eventName:"chat_share_button_clicked",properties:{sharedConversationId:M?.id,originalConversationId:C.id,sharedChatUrl:V,conversation:M}})}},clear:o,stop:d},Ce={copy:N,share:Q};return n.jsx(j.Tooltip,{delayDuration:0,open:Ce[e],children:n.jsx(ds,{"data-type":e,"data-copied":h.dataAttr(N||Q),className:`${s} ${e}`,children:n.jsx(le,{action:e}),onClick:u.composeEventHandlers(i,ee[e]),...r})})},cs=a.ikp("span",{_id:"aiChat__ChatActionLabel"}),le=t=>{const{action:e,...i}=t,{aiChatSettings:s}=p.useInkeepConfig(),r=s.toolbarButtonLabels??{},o={help:r.getHelp??"Get Help",copy:r.copyChat??"Copy",share:r.share??"Share",clear:r.clear??"Clear",stop:r.stop??"Stop"};return n.jsx(cs,{children:o[e],...i})},ms=a.ikp(j.TooltipContent,{_id:"aiChat__ChatActionFeeback"}),gi=t=>{const{action:e,children:i,...s}=t,r={copy:"Copied!",share:"Link copied!"};return n.jsxs(ms,{sideOffset:5,...s,children:[n.jsx(j.Arrow,{}),i||r[e]]})},ls=a.ikp(T.Root,{_id:"aiChatHelpActions"}),Pi=t=>{const{children:e,...i}=t,{aiChatSettings:s}=p.useInkeepConfig(),{getHelpOptions:r}=s;if(!r||(r??[]).length===0)return null;const{_pinned:o,_unpinned:d}=r.reduce((C,b)=>{const k=b.isPinnedToToolbar?"_pinned":"_unpinned";return{...C,[k]:[...C[k],b]}},{_pinned:[],_unpinned:[]}),c=d.length===1?[...o,d[0]]:o,m=d.length===1?[]:d,l=ie.useHelpMenuState();return n.jsx(ie.HelpMenuProvider,{value:l,children:n.jsx(ls,{open:l.open,onOpenChange:l.setOpen,children:h.maybeRender(e,{pinned:c,unpinned:m}),...i})})},hs=a.ikp(G,{_id:"aiChatHelpAction",action:"help"}),us=a.ikp("a",{_id:"aiChatHelpAction",target:"_blank",rel:"noreferrer"}),Ai=t=>{const{action:e,onClick:i,...s}=t,{handleAction:r,logHelpAction:o}=se.useChatAction(e),d=e.action.type,c={"aria-label":e.name,"data-name":e.name,children:e.name,onClick:u.composeEventHandlers(i,()=>{r(),o()}),...s};return d==="open_link"?n.jsx(us,{href:e.action.url,...c}):n.jsx(hs,{...c})},Cs=a.ikp(T.Trigger,{_id:"aiChatHelpActions__Trigger"}),_i=g.memo(t=>{const{aiChatSettings:e}=p.useInkeepConfig();return n.jsx(G,{action:"help",...t,asChild:!0,children:n.jsx(Cs,{children:e.toolbarButtonLabels?.getHelp??"Get Help"})})}),ps=a.ikp(T.Content,{_id:"aiChatHelpActions__Menu"}),Ei=t=>n.jsx(ps,{side:"top",sideOffset:8,align:"center",alignOffset:-10,...t}),Fi=a.ikp(T.Arrow,{_id:"aiChatHelpActions__MenuArrow"}),ki=t=>{const{action:e,onClick:i,...s}=t,{handleAction:r,logHelpAction:o}=se.useChatAction(e),{setOpen:d}=ie.useHelpMenu(),c=()=>{r({onOpenForm:()=>d(!1)}),o()},m=e.action.type,l=a.ikp(m==="open_link"?"a":"button",{_id:"aiChatHelpActions__MenuItem",children:e.name,"aria-label":e.name,"data-name":e.name,"data-type":e.action.type,...m==="open_link"&&{href:e.action.url,target:"_blank",rel:"noopener"},onClick:u.composeEventHandlers(i,c)});return n.jsx(l,{...s})},vs=a.ikp(x.BuiltInIconRenderer,{_id:"aiChatHelpActions_MenuItemIcon"}),Ii=t=>{const{action:e,...i}=t;return e.icon?n.jsx(vs,{iconSettings:e.icon,...i}):null},bs=a.ikp(A.Root,{_id:"aiChatFeedbackModal"}),Mi=t=>{const{onOpenChange:e,...i}=t,{currentFeedback:s,setCurrentFeedback:r}=ne.useMessageFeedback();return n.jsx(bs,{open:s!==null,onOpenChange:u.composeEventHandlers(e,()=>r(null)),...i})},Si=a.ikp(A.Overlay,{_id:"aiChatFeedbackModal__Overlay"}),xi=a.ikp(A.Content,{_id:"aiChatFeedbackModal__Content","aria-describedby":void 0}),Bi=a.ikp(A.Title,{_id:"aiChatFeedbackModal__Header",children:"Help improve my answers!"}),fi=a.ikp(A.Close,{_id:"aiChatFeedbackModal__Close",children:n.jsx(E.CustomIcon,{iconKey:"close"})}),Ti=a.ikp("div",{_id:"aiChatFeedbackModal__Body"}),gs=a.ikp("form",{_id:"aiChatFeedbackForm"}),ji=t=>{const{onSubmit:e,...i}=t,{submitNegativeFeedback:s,currentFeedback:r,setCurrentFeedback:o}=ne.useMessageFeedback(),d=c=>{c.preventDefault();const m=c.target,l=new FormData(m),C=Object.fromEntries(l.entries());r&&(s(r,C),o(null))};return n.jsx(gs,{onSubmit:u.composeEventHandlers(e,d),...i})},Ps=a.ikp("div",{_id:"aiChatFeedbackItem"}),yi=t=>{const{name:e,...i}=t;return n.jsx(K.FeedbackItemProvider,{name:e,children:n.jsx(Ps,{...i})})},As=a.ikp(z.Root,{_id:"aiChatFeedbackItem__Checkbox"}),Hi=t=>{const{name:e,focusItem:i}=K.useFeedbackItem(),{onCheckedChange:s,...r}=t,o=d=>{d&&i?.current?.focus()};return n.jsx(As,{id:`feedback-${e}`,name:e,onCheckedChange:u.composeEventHandlers(s,o),...r})},wi=a.ikp(z.Indicator,{_id:"aiChatFeedbackItem__CheckboxIndicator",children:n.jsx(be.CheckboxIcon,{})}),_s=a.ikp("label",{_id:"aiChatFeedbackItem__Label"}),Li=t=>{const{name:e}=K.useFeedbackItem(),i={unrelated_response:"Didn't answer my question",inaccurate_statement:"Inaccurate statement",inaccurate_code_snippet:"Inaccurate code snippet",irrelevant_citations:"Irrelevant citations"};return n.jsx(_s,{htmlFor:`feedback-${e}`,children:i[e],...t})},Es=a.ikp("textarea",{_id:"aiChatFeedbackItem__Description",placeholder:"Please describe"}),Di=t=>{const{name:e,focusItem:i}=K.useFeedbackItem();return n.jsx(Es,{ref:i,name:`${e}:description`,...t})},Oi=a.ikp("button",{_id:"aiChatFeedbackForm__SubmitButton",children:"Submit",type:"submit"}),Fs=a.ikp("div",{_id:"aiChatForm__Wrapper"}),qi=t=>{const{form:e}=_.useChatForm();return e?n.jsx(Fs,{...t}):null},ks=a.ikp("form",{_id:"aiChatForm"}),Ri=t=>{const{onSubmit:e,...i}=t,{handleSubmit:s,isSuccess:r}=_.useChatForm();return r?null:n.jsx(ks,{onSubmit:u.composeEventHandlers(e,s),...i})},Is=a.ikp("button",{_id:"aiChatForm__Close",children:n.jsx(E.CustomIcon,{iconKey:"close"})}),Wi=t=>{const{onClick:e,...i}=t,{closeForm:s}=_.useChatForm();return n.jsx(Is,{onClick:u.composeEventHandlers(e,s),...i})},Ni=a.ikp("div",{_id:"aiChatForm__Header"}),Ms=a.ikp("h2",{_id:"aiChatForm__Heading"}),Qi=t=>{const{form:e}=_.useChatForm();return e?.heading?n.jsx(Ms,{children:e.heading,...t}):null},Ss=a.ikp(U.Markdown,{_id:"aiChatForm__Description"}),$i=t=>{const{form:e}=_.useChatForm();return e?.description?n.jsx(Ss,{children:e.description,...t}):null},xs=a.ikp("div",{_id:"aiChatForm__Content"}),Vi=t=>{const{children:e,...i}=t,{fields:s=[]}=_.useChatForm();return n.jsx(xs,{children:h.maybeRender(e,s),...i})},Bs=a.ikp("div",{_id:"aiChatForm__Field"}),Ui=t=>{const{field:e,autoFocus:i,...s}=t,{control:r,errors:o}=_.useChatForm();return n.jsx(Ba.Controller,{name:e.name,control:r,rules:{required:e.isRequired?`${e.label} is required.`:void 0},render:({field:d})=>{const c=d.value!==void 0||e.inputType==="file";return n.jsx(f.FormFieldProvider,{"data-invalid":h.dataAttr(!!o[e.name]),field:e,fieldProps:d,autoFocus:i,children:c&&n.jsx(Bs,{"data-input-type":e.inputType,"data-hidden":h.dataAttr(e.isHidden),...s})})}})},fs=a.ikp("label",{_id:"aiChatForm__FieldLabel"}),Ki=t=>{const{field:e}=f.useFormField();return n.jsx(fs,{"data-required":h.dataAttr(e.isRequired),htmlFor:e.name,children:e.label,...t})},Ts=a.ikp("input",{_id:"aiChatForm__FieldText",type:"text"}),Y=t=>{const{field:e,error:i,fieldProps:{onChange:s,onBlur:r,...o},autoFocus:d}=f.useFormField(),{onChange:c,onBlur:m,...l}=t;return n.jsx(Ts,{id:e.name,autoFocus:d,placeholder:"placeholder"in e?e.placeholder:void 0,"data-invalid":h.dataAttr(!!i),onChange:u.composeEventHandlers(c,s),onBlur:u.composeEventHandlers(m,r),...o,...l})},zi=a.ikp(Y,{_id:"aiChatForm__FieldEmail",type:"email"}),js=a.ikp("input",{_id:"aiChatForm__FieldFile",type:"file",multiple:!0}),Gi=t=>{const{field:e,error:i,fieldProps:{value:s,onChange:r,onBlur:o,...d},autoFocus:c}=f.useFormField(),{onChange:m,onBlur:l,...C}=t,b=k=>{const y=k.target.files;r(y)};return n.jsx(js,{id:e.name,autoFocus:c,"data-value":s,"data-invalid":h.dataAttr(!!i),...C,...d,onChange:u.composeEventHandlers(m,b),onBlur:u.composeEventHandlers(l,o)})},Yi=a.ikp(Y,{_id:"aiChatForm__FieldTextArea",type:"textarea",asChild:!0,children:n.jsx(ae,{maxRows:8})}),ys=a.ikp(z.Root,{_id:"aiChatForm__FieldCheckbox"}),Ji=t=>{const{field:e,error:i,fieldProps:s,autoFocus:r}=f.useFormField(),{onCheckedChange:o,...d}=t;return n.jsx(ys,{id:e.name,name:e.name,autoFocus:r,"data-invalid":h.dataAttr(!!i),checked:s.value,onCheckedChange:u.composeEventHandlers(o,s.onChange),...d})},Xi=a.ikp(z.Indicator,{_id:"aiChatForm__FieldCheckboxIndicator",children:n.jsx(be.CheckboxIcon,{})}),Hs=a.ikp(I.Root,{_id:"aiChatForm__FieldSelect"}),Zi=t=>{const{field:e,error:i,fieldProps:s}=f.useFormField(),{onValueChange:r,...o}=t;return n.jsx(Hs,{name:e.name,"data-invalid":h.dataAttr(!!i),value:s.value,onValueChange:u.composeEventHandlers(r,s.onChange),...o})},ea=a.ikp(I.Trigger,{_id:"aiChatForm__FieldSelect__Trigger"}),ws=a.ikp(I.Value,{_id:"aiChatForm__FieldSelect__Value"}),ta=t=>{const{field:e}=f.useFormField();return n.jsx(ws,{placeholder:"placeholder"in e?e.placeholder:void 0,...t})},ia=a.ikp(I.Icon,{_id:"aiChatForm__FieldSelect__Icon",asChild:!0,children:n.jsx(x.BuiltInIconRenderer,{iconSettings:{builtIn:"LuChevronDown"}})}),aa=a.ikp(I.Content,{_id:"aiChatForm__FieldSelect__Content",position:"popper"}),na=a.ikp(I.Viewport,{_id:"aiChatForm__FieldSelect__Viewport"}),sa=a.ikp(I.Item,{_id:"aiChatForm__FieldSelect__Item"}),ra=a.ikp(I.ItemText,{_id:"aiChatForm__FieldSelect__ItemText"}),oa=a.ikp(I.ItemIndicator,{_id:"aiChatForm__FieldSelect__ItemIndicator",asChild:!0,children:n.jsx(x.BuiltInIconRenderer,{iconSettings:{builtIn:"LuCheck"}})}),Ls=a.ikp("span",{_id:"aiChatForm__FieldError"}),da=t=>{const{error:e}=f.useFormField();return e?n.jsx(Ls,{children:e.message?.toString(),...t}):null},Ds=a.ikp("span",{_id:"aiChatForm__Error"}),ca=t=>{const{formError:e}=_.useChatForm();return e?n.jsx(Ds,{children:e.message,...t}):null},ma=a.ikp("div",{_id:"aiChatForm__Footer"}),Os=a.ikp("button",{_id:"aiChatForm__Cancel",children:"Cancel",type:"button"}),la=t=>{const{onClick:e,...i}=t,{closeForm:s}=_.useChatForm();return n.jsx(Os,{onClick:u.composeEventHandlers(e,s),...i})},qs=a.ikp("button",{_id:"aiChatForm__Submit",children:"Submit",type:"submit"}),ha=t=>{const{onClick:e,...i}=t,{isSubmitting:s,form:r}=_.useChatForm(),o=r?.buttons.submit.label||"Submit";return n.jsx(qs,{disabled:s,...i,children:o})},Rs=a.ikp("div",{_id:"aiChatForm__Success"}),ua=t=>{const{isSuccess:e}=_.useChatForm();return e?n.jsx(Rs,{...t}):null},Ws=a.ikp("h2",{_id:"aiChatForm__SuccessHeading"}),Ca=t=>{const{form:e}=_.useChatForm();return n.jsx(Ws,{children:e?.successView?.heading,...t})},Ns=a.ikp(U.Markdown,{_id:"aiChatForm__SuccessMessage"}),pa=t=>{const{form:e}=_.useChatForm();return n.jsx(Ns,{children:e?.successView?.message,...t})},Qs=a.ikp("button",{_id:"aiChatForm__SuccessButton"}),va=t=>{const{onClick:e,...i}=t,{form:s,closeForm:r}=_.useChatForm(),o=s?.successView?.doneButton;if(!o)return null;const d=o.icon&&n.jsx(x.BuiltInIconRenderer,{iconSettings:o.icon}),c=o.label;return n.jsx(Qs,{onClick:u.composeEventHandlers(e,r),children:n.jsxs(n.Fragment,{children:[d,c]}),...i})};exports.Provider=v.ChatProvider;exports.ActionBar=hi;exports.Actions=ui;exports.AttachmentsBar=wt;exports.AttachmentsBarActions=Wt;exports.AttachmentsBarAttachment=Dt;exports.AttachmentsBarAttachmentDelete=Rt;exports.AttachmentsBarAttachmentIcon=Ot;exports.AttachmentsBarAttachmentTitle=qt;exports.AttachmentsBarForm=ii;exports.AttachmentsBarFormContent=oi;exports.AttachmentsBarFormContentError=mi;exports.AttachmentsBarFormContentInput=ci;exports.AttachmentsBarFormContentLabel=di;exports.AttachmentsBarFormSubmitButton=li;exports.AttachmentsBarFormTitle=ai;exports.AttachmentsBarFormTitleError=ri;exports.AttachmentsBarFormTitleInput=si;exports.AttachmentsBarFormTitleLabel=ni;exports.AttachmentsBarInfoTip=Nt;exports.AttachmentsBarInfoTipArrow=me;exports.AttachmentsBarInfoTipIcon=Qt;exports.AttachmentsBarInfoTipText=$t;exports.AttachmentsBarInput=Ut;exports.AttachmentsBarInputs=Vt;exports.AttachmentsBarList=Lt;exports.AttachmentsBarModal=Kt;exports.AttachmentsBarModalBody=ti;exports.AttachmentsBarModalClose=ei;exports.AttachmentsBarModalContent=Gt;exports.AttachmentsBarModalDescription=Xt;exports.AttachmentsBarModalHeader=Yt;exports.AttachmentsBarModalHeading=Jt;exports.AttachmentsBarModalHelp=Zt;exports.AttachmentsBarModalOverlay=zt;exports.ChatAction=G;exports.ChatActionFeedback=gi;exports.ChatActionLabel=le;exports.ChatHelpAction=Ai;exports.Content=ke;exports.ContentScrollArea=Ie;exports.ContentScrollAreaCorner=Be;exports.ContentScrollAreaScrollbar=Se;exports.ContentScrollAreaThumb=xe;exports.ContentScrollAreaViewport=Me;exports.ConversationLoading=Pe;exports.Disclaimer=Te;exports.DisclaimerArrow=Le;exports.DisclaimerContent=He;exports.DisclaimerLabel=je;exports.DisclaimerText=we;exports.DisclaimerTrigger=ye;exports.EmbeddedChatPrimitiveActionBar=hi;exports.EmbeddedChatPrimitiveActions=ui;exports.EmbeddedChatPrimitiveAttachmentsBar=wt;exports.EmbeddedChatPrimitiveAttachmentsBarActions=Wt;exports.EmbeddedChatPrimitiveAttachmentsBarAttachment=Dt;exports.EmbeddedChatPrimitiveAttachmentsBarAttachmentDelete=Rt;exports.EmbeddedChatPrimitiveAttachmentsBarAttachmentIcon=Ot;exports.EmbeddedChatPrimitiveAttachmentsBarAttachmentTitle=qt;exports.EmbeddedChatPrimitiveAttachmentsBarForm=ii;exports.EmbeddedChatPrimitiveAttachmentsBarFormContent=oi;exports.EmbeddedChatPrimitiveAttachmentsBarFormContentError=mi;exports.EmbeddedChatPrimitiveAttachmentsBarFormContentInput=ci;exports.EmbeddedChatPrimitiveAttachmentsBarFormContentLabel=di;exports.EmbeddedChatPrimitiveAttachmentsBarFormSubmitButton=li;exports.EmbeddedChatPrimitiveAttachmentsBarFormTitle=ai;exports.EmbeddedChatPrimitiveAttachmentsBarFormTitleError=ri;exports.EmbeddedChatPrimitiveAttachmentsBarFormTitleInput=si;exports.EmbeddedChatPrimitiveAttachmentsBarFormTitleLabel=ni;exports.EmbeddedChatPrimitiveAttachmentsBarInfoTip=Nt;exports.EmbeddedChatPrimitiveAttachmentsBarInfoTipArrow=me;exports.EmbeddedChatPrimitiveAttachmentsBarInfoTipIcon=Qt;exports.EmbeddedChatPrimitiveAttachmentsBarInfoTipText=$t;exports.EmbeddedChatPrimitiveAttachmentsBarInput=Ut;exports.EmbeddedChatPrimitiveAttachmentsBarInputs=Vt;exports.EmbeddedChatPrimitiveAttachmentsBarList=Lt;exports.EmbeddedChatPrimitiveAttachmentsBarModal=Kt;exports.EmbeddedChatPrimitiveAttachmentsBarModalBody=ti;exports.EmbeddedChatPrimitiveAttachmentsBarModalClose=ei;exports.EmbeddedChatPrimitiveAttachmentsBarModalContent=Gt;exports.EmbeddedChatPrimitiveAttachmentsBarModalDescription=Xt;exports.EmbeddedChatPrimitiveAttachmentsBarModalHeader=Yt;exports.EmbeddedChatPrimitiveAttachmentsBarModalHeading=Jt;exports.EmbeddedChatPrimitiveAttachmentsBarModalHelp=Zt;exports.EmbeddedChatPrimitiveAttachmentsBarModalOverlay=zt;exports.EmbeddedChatPrimitiveChatAction=G;exports.EmbeddedChatPrimitiveChatActionFeedback=gi;exports.EmbeddedChatPrimitiveChatActionLabel=le;exports.EmbeddedChatPrimitiveChatHelpAction=Ai;exports.EmbeddedChatPrimitiveContent=ke;exports.EmbeddedChatPrimitiveContentScrollArea=Ie;exports.EmbeddedChatPrimitiveContentScrollAreaCorner=Be;exports.EmbeddedChatPrimitiveContentScrollAreaScrollbar=Se;exports.EmbeddedChatPrimitiveContentScrollAreaThumb=xe;exports.EmbeddedChatPrimitiveContentScrollAreaViewport=Me;exports.EmbeddedChatPrimitiveConversationLoading=Pe;exports.EmbeddedChatPrimitiveDisclaimer=Te;exports.EmbeddedChatPrimitiveDisclaimerArrow=Le;exports.EmbeddedChatPrimitiveDisclaimerContent=He;exports.EmbeddedChatPrimitiveDisclaimerLabel=je;exports.EmbeddedChatPrimitiveDisclaimerText=we;exports.EmbeddedChatPrimitiveDisclaimerTrigger=ye;exports.EmbeddedChatPrimitiveExampleQuestion=Re;exports.EmbeddedChatPrimitiveExampleQuestionButton=We;exports.EmbeddedChatPrimitiveExampleQuestions=De;exports.EmbeddedChatPrimitiveExampleQuestionsLabel=Oe;exports.EmbeddedChatPrimitiveExampleQuestionsList=qe;exports.EmbeddedChatPrimitiveFeedbackForm=ji;exports.EmbeddedChatPrimitiveFeedbackItem=yi;exports.EmbeddedChatPrimitiveFeedbackItemCheckbox=Hi;exports.EmbeddedChatPrimitiveFeedbackItemCheckboxIndicator=wi;exports.EmbeddedChatPrimitiveFeedbackItemDescription=Di;exports.EmbeddedChatPrimitiveFeedbackItemLabel=Li;exports.EmbeddedChatPrimitiveFeedbackModal=Mi;exports.EmbeddedChatPrimitiveFeedbackModalBody=Ti;exports.EmbeddedChatPrimitiveFeedbackModalClose=fi;exports.EmbeddedChatPrimitiveFeedbackModalContent=xi;exports.EmbeddedChatPrimitiveFeedbackModalHeader=Bi;exports.EmbeddedChatPrimitiveFeedbackModalOverlay=Si;exports.EmbeddedChatPrimitiveFeedbackSubmitButton=Oi;exports.EmbeddedChatPrimitiveFooter=Bt;exports.EmbeddedChatPrimitiveForm=Ri;exports.EmbeddedChatPrimitiveFormCancel=la;exports.EmbeddedChatPrimitiveFormClose=Wi;exports.EmbeddedChatPrimitiveFormContent=Vi;exports.EmbeddedChatPrimitiveFormDescription=$i;exports.EmbeddedChatPrimitiveFormError=ca;exports.EmbeddedChatPrimitiveFormField=Ui;exports.EmbeddedChatPrimitiveFormFieldCheckbox=Ji;exports.EmbeddedChatPrimitiveFormFieldCheckboxIndicator=Xi;exports.EmbeddedChatPrimitiveFormFieldEmail=zi;exports.EmbeddedChatPrimitiveFormFieldError=da;exports.EmbeddedChatPrimitiveFormFieldFile=Gi;exports.EmbeddedChatPrimitiveFormFieldLabel=Ki;exports.EmbeddedChatPrimitiveFormFieldSelect=Zi;exports.EmbeddedChatPrimitiveFormFieldSelectContent=aa;exports.EmbeddedChatPrimitiveFormFieldSelectIcon=ia;exports.EmbeddedChatPrimitiveFormFieldSelectItem=sa;exports.EmbeddedChatPrimitiveFormFieldSelectItemIndicator=oa;exports.EmbeddedChatPrimitiveFormFieldSelectItemText=ra;exports.EmbeddedChatPrimitiveFormFieldSelectTrigger=ea;exports.EmbeddedChatPrimitiveFormFieldSelectValue=ta;exports.EmbeddedChatPrimitiveFormFieldSelectViewport=na;exports.EmbeddedChatPrimitiveFormFieldText=Y;exports.EmbeddedChatPrimitiveFormFieldTextArea=Yi;exports.EmbeddedChatPrimitiveFormFooter=ma;exports.EmbeddedChatPrimitiveFormHeader=Ni;exports.EmbeddedChatPrimitiveFormHeading=Qi;exports.EmbeddedChatPrimitiveFormSubmit=ha;exports.EmbeddedChatPrimitiveFormSuccess=ua;exports.EmbeddedChatPrimitiveFormSuccessButton=va;exports.EmbeddedChatPrimitiveFormSuccessHeading=Ca;exports.EmbeddedChatPrimitiveFormSuccessMessage=pa;exports.EmbeddedChatPrimitiveFormWrapper=qi;exports.EmbeddedChatPrimitiveHeaderToolbar=_e;exports.EmbeddedChatPrimitiveHelpActions=Pi;exports.EmbeddedChatPrimitiveHelpActionsMenu=Ei;exports.EmbeddedChatPrimitiveHelpActionsMenuArrow=Fi;exports.EmbeddedChatPrimitiveHelpActionsMenuItem=ki;exports.EmbeddedChatPrimitiveHelpActionsMenuItemIcon=Ii;exports.EmbeddedChatPrimitiveHelpActionsTrigger=_i;exports.EmbeddedChatPrimitiveInput=jt;exports.EmbeddedChatPrimitiveInputFieldset=ft;exports.EmbeddedChatPrimitiveInputGroup=Tt;exports.EmbeddedChatPrimitiveIntroMessageWrapper=Ue;exports.EmbeddedChatPrimitiveMessage=ut;exports.EmbeddedChatPrimitiveMessageAction=bt;exports.EmbeddedChatPrimitiveMessageAttachments=it;exports.EmbeddedChatPrimitiveMessageAttachmentsItem=nt;exports.EmbeddedChatPrimitiveMessageAttachmentsItemIcon=st;exports.EmbeddedChatPrimitiveMessageAttachmentsItemTitle=rt;exports.EmbeddedChatPrimitiveMessageAttachmentsList=at;exports.EmbeddedChatPrimitiveMessageAttachmentsPreview=ot;exports.EmbeddedChatPrimitiveMessageAttachmentsPreviewBody=ht;exports.EmbeddedChatPrimitiveMessageAttachmentsPreviewClose=lt;exports.EmbeddedChatPrimitiveMessageAttachmentsPreviewContent=ct;exports.EmbeddedChatPrimitiveMessageAttachmentsPreviewHeader=mt;exports.EmbeddedChatPrimitiveMessageAttachmentsPreviewOverlay=dt;exports.EmbeddedChatPrimitiveMessageAvatar=Ge;exports.EmbeddedChatPrimitiveMessageAvatarContent=Ye;exports.EmbeddedChatPrimitiveMessageAvatarFallback=Je;exports.EmbeddedChatPrimitiveMessageAvatarImage=Xe;exports.EmbeddedChatPrimitiveMessageContent=tt;exports.EmbeddedChatPrimitiveMessageContentWrapper=et;exports.EmbeddedChatPrimitiveMessageHeader=Ke;exports.EmbeddedChatPrimitiveMessageLoading=ze;exports.EmbeddedChatPrimitiveMessageName=Ze;exports.EmbeddedChatPrimitiveMessageSourceItem=_t;exports.EmbeddedChatPrimitiveMessageSourceItemBreadcrumbs=Et;exports.EmbeddedChatPrimitiveMessageSourceItemDescription=Mt;exports.EmbeddedChatPrimitiveMessageSourceItemDescriptionPart=St;exports.EmbeddedChatPrimitiveMessageSourceItemIcon=Ft;exports.EmbeddedChatPrimitiveMessageSourceItemIndicator=xt;exports.EmbeddedChatPrimitiveMessageSourceItemTag=It;exports.EmbeddedChatPrimitiveMessageSourceItemTitle=kt;exports.EmbeddedChatPrimitiveMessageSources=gt;exports.EmbeddedChatPrimitiveMessageSourcesHeader=Pt;exports.EmbeddedChatPrimitiveMessageSourcesList=At;exports.EmbeddedChatPrimitiveMessageToolAction=vt;exports.EmbeddedChatPrimitiveMessageToolActions=pt;exports.EmbeddedChatPrimitiveMessageToolbar=Ct;exports.EmbeddedChatPrimitiveMessageWrapper=ce;exports.EmbeddedChatPrimitiveMessages=fe;exports.EmbeddedChatPrimitiveRoot=Ae;exports.EmbeddedChatPrimitiveSendButton=yt;exports.EmbeddedChatPrimitiveSendButtonIcon=Ht;exports.EmbeddedChatPrimitiveTaglineBrandName=bi;exports.EmbeddedChatPrimitiveTaglineContainer=Ci;exports.EmbeddedChatPrimitiveTaglineLogo=vi;exports.EmbeddedChatPrimitiveTaglineText=pi;exports.EmbeddedChatPrimitiveToolbarHeader=Fe;exports.EmbeddedChatPrimitiveToolbarHeaderWrapper=Ee;exports.EmbeddedChatPrimitiveWorkflow=Ve;exports.EmbeddedChatPrimitiveWorkflows=Ne;exports.EmbeddedChatPrimitiveWorkflowsLabel=Qe;exports.EmbeddedChatPrimitiveWorkflowsList=$e;exports.EmbeddedChatPrimitiveWrapper=ge;exports.ExampleQuestion=Re;exports.ExampleQuestionButton=We;exports.ExampleQuestions=De;exports.ExampleQuestionsLabel=Oe;exports.ExampleQuestionsList=qe;exports.FeedbackForm=ji;exports.FeedbackItem=yi;exports.FeedbackItemCheckbox=Hi;exports.FeedbackItemCheckboxIndicator=wi;exports.FeedbackItemDescription=Di;exports.FeedbackItemLabel=Li;exports.FeedbackModal=Mi;exports.FeedbackModalBody=Ti;exports.FeedbackModalClose=fi;exports.FeedbackModalContent=xi;exports.FeedbackModalHeader=Bi;exports.FeedbackModalOverlay=Si;exports.FeedbackSubmitButton=Oi;exports.Footer=Bt;exports.Form=Ri;exports.FormCancel=la;exports.FormClose=Wi;exports.FormContent=Vi;exports.FormDescription=$i;exports.FormError=ca;exports.FormField=Ui;exports.FormFieldCheckbox=Ji;exports.FormFieldCheckboxIndicator=Xi;exports.FormFieldEmail=zi;exports.FormFieldError=da;exports.FormFieldFile=Gi;exports.FormFieldLabel=Ki;exports.FormFieldSelect=Zi;exports.FormFieldSelectContent=aa;exports.FormFieldSelectIcon=ia;exports.FormFieldSelectItem=sa;exports.FormFieldSelectItemIndicator=oa;exports.FormFieldSelectItemText=ra;exports.FormFieldSelectTrigger=ea;exports.FormFieldSelectValue=ta;exports.FormFieldSelectViewport=na;exports.FormFieldText=Y;exports.FormFieldTextArea=Yi;exports.FormFooter=ma;exports.FormHeader=Ni;exports.FormHeading=Qi;exports.FormSubmit=ha;exports.FormSuccess=ua;exports.FormSuccessButton=va;exports.FormSuccessHeading=Ca;exports.FormSuccessMessage=pa;exports.FormWrapper=qi;exports.Header=Na;exports.HeaderToolbar=_e;exports.HeaderToolbarWrapper=Ee;exports.HelpActions=Pi;exports.HelpActionsMenu=Ei;exports.HelpActionsMenuArrow=Fi;exports.HelpActionsMenuItem=ki;exports.HelpActionsMenuItemIcon=Ii;exports.HelpActionsTrigger=_i;exports.Input=jt;exports.InputFieldset=ft;exports.InputGroup=Tt;exports.IntroMessageWrapper=Ue;exports.Message=ut;exports.MessageAction=bt;exports.MessageAttachments=it;exports.MessageAttachmentsItem=nt;exports.MessageAttachmentsItemIcon=st;exports.MessageAttachmentsItemTitle=rt;exports.MessageAttachmentsList=at;exports.MessageAttachmentsPreview=ot;exports.MessageAttachmentsPreviewBody=ht;exports.MessageAttachmentsPreviewClose=lt;exports.MessageAttachmentsPreviewContent=ct;exports.MessageAttachmentsPreviewHeader=mt;exports.MessageAttachmentsPreviewOverlay=dt;exports.MessageAvatar=Ge;exports.MessageAvatarContent=Ye;exports.MessageAvatarFallback=Je;exports.MessageAvatarImage=Xe;exports.MessageContent=tt;exports.MessageContentWrapper=et;exports.MessageHeader=Ke;exports.MessageLoading=ze;exports.MessageName=Ze;exports.MessageSourceItem=_t;exports.MessageSourceItemBreadcrumbIcon=Hn;exports.MessageSourceItemBreadcrumbs=Et;exports.MessageSourceItemDescription=Mt;exports.MessageSourceItemDescriptionPart=St;exports.MessageSourceItemIcon=Ft;exports.MessageSourceItemIndicator=xt;exports.MessageSourceItemTag=It;exports.MessageSourceItemTitle=kt;exports.MessageSources=gt;exports.MessageSourcesHeader=Pt;exports.MessageSourcesList=At;exports.MessageToolAction=vt;exports.MessageToolActions=pt;exports.MessageToolbar=Ct;exports.MessageWrapper=ce;exports.Messages=fe;exports.Root=Ae;exports.SendButton=yt;exports.SendButtonIcon=Ht;exports.TaglineBrandName=bi;exports.TaglineContainer=Ci;exports.TaglineLogo=vi;exports.TaglineText=pi;exports.ToolbarHeader=Fe;exports.Workflow=Ve;exports.Workflows=Ne;exports.WorkflowsLabel=Qe;exports.WorkflowsList=$e;exports.Wrapper=ge;
|
|
17
|
+
`);J($)},share:async()=>{const $={visibility:"public",tags:[],userProperties:{},messages:C.messages.map(S=>({...S,createdAt:void 0,updatedAt:void 0,id:Date.now().toString()+S.id,conversationId:void 0}))},{apiKey:H,analyticsApiBaseUrl:D}=k,M=await Ha.logConversation("",$,H,D);if(M){const V=`${b.shareChatUrlBasePath}?${L.SHARE_QUERY_PARAM}=${M?.id}`;X(V),y({eventName:"chat_share_button_clicked",properties:{sharedConversationId:M?.id,originalConversationId:C.id,sharedChatUrl:V,conversation:M}})}},clear:o,stop:d},Ce={copy:N,share:Q};return n.jsx(j.Tooltip,{delayDuration:0,open:Ce[e],children:n.jsx(ds,{"data-type":e,"data-copied":h.dataAttr(N||Q),className:`${s} ${e}`,children:n.jsx(le,{action:e}),onClick:u.composeEventHandlers(i,ee[e]),...r})})},cs=a.ikp("span",{_id:"aiChat__ChatActionLabel"}),le=t=>{const{action:e,...i}=t,{aiChatSettings:s}=p.useInkeepConfig(),r=s.toolbarButtonLabels??{},o={help:r.getHelp??"Get Help",copy:r.copyChat??"Copy",share:r.share??"Share",clear:r.clear??"Clear",stop:r.stop??"Stop"};return n.jsx(cs,{children:o[e],...i})},ms=a.ikp(j.TooltipContent,{_id:"aiChat__ChatActionFeeback"}),gi=t=>{const{action:e,children:i,...s}=t,r={copy:"Copied!",share:"Link copied!"};return n.jsxs(ms,{sideOffset:5,...s,children:[n.jsx(j.Arrow,{}),i||r[e]]})},ls=a.ikp(T.Root,{_id:"aiChatHelpActions"}),Pi=t=>{const{children:e,...i}=t,{aiChatSettings:s}=p.useInkeepConfig(),{getHelpOptions:r}=s;if(!r||(r??[]).length===0)return null;const{_pinned:o,_unpinned:d}=r.reduce((C,b)=>{const k=b.isPinnedToToolbar?"_pinned":"_unpinned";return{...C,[k]:[...C[k],b]}},{_pinned:[],_unpinned:[]}),c=d.length===1?[...o,d[0]]:o,m=d.length===1?[]:d,l=ie.useHelpMenuState();return n.jsx(ie.HelpMenuProvider,{value:l,children:n.jsx(ls,{open:l.open,onOpenChange:l.setOpen,children:h.maybeRender(e,{pinned:c,unpinned:m}),...i})})},hs=a.ikp(G,{_id:"aiChatHelpAction",action:"help"}),us=a.ikp("a",{_id:"aiChatHelpAction",target:"_blank",rel:"noreferrer"}),_i=t=>{const{action:e,onClick:i,...s}=t,{handleAction:r,logHelpAction:o}=se.useChatAction(e),d=e.action.type,c={"aria-label":e.name,"data-name":e.name,children:e.name,onClick:u.composeEventHandlers(i,()=>{r(),o()}),...s};return d==="open_link"?n.jsx(us,{href:e.action.url,...c}):n.jsx(hs,{...c})},Cs=a.ikp(T.Trigger,{_id:"aiChatHelpActions__Trigger"}),Ai=g.memo(t=>{const{aiChatSettings:e}=p.useInkeepConfig();return n.jsx(G,{action:"help",...t,asChild:!0,children:n.jsx(Cs,{children:e.toolbarButtonLabels?.getHelp??"Get Help"})})}),ps=a.ikp(T.Content,{_id:"aiChatHelpActions__Menu"}),Ei=t=>n.jsx(ps,{side:"top",sideOffset:8,align:"center",alignOffset:-10,...t}),Fi=a.ikp(T.Arrow,{_id:"aiChatHelpActions__MenuArrow"}),ki=t=>{const{action:e,onClick:i,...s}=t,{handleAction:r,logHelpAction:o}=se.useChatAction(e),{setOpen:d}=ie.useHelpMenu(),c=()=>{r({onOpenForm:()=>d(!1)}),o()},m=e.action.type,l=a.ikp(m==="open_link"?"a":"button",{_id:"aiChatHelpActions__MenuItem",children:e.name,"aria-label":e.name,"data-name":e.name,"data-type":e.action.type,...m==="open_link"&&{href:e.action.url,target:"_blank",rel:"noopener"},onClick:u.composeEventHandlers(i,c)});return n.jsx(l,{...s})},vs=a.ikp(x.BuiltInIconRenderer,{_id:"aiChatHelpActions_MenuItemIcon"}),Ii=t=>{const{action:e,...i}=t;return e.icon?n.jsx(vs,{iconSettings:e.icon,...i}):null},bs=a.ikp(_.Root,{_id:"aiChatFeedbackModal"}),Mi=t=>{const{onOpenChange:e,...i}=t,{currentFeedback:s,setCurrentFeedback:r}=ne.useMessageFeedback();return n.jsx(bs,{open:s!==null,onOpenChange:u.composeEventHandlers(e,()=>r(null)),...i})},Si=a.ikp(_.Overlay,{_id:"aiChatFeedbackModal__Overlay"}),xi=a.ikp(_.Content,{_id:"aiChatFeedbackModal__Content","aria-describedby":void 0}),fi=a.ikp(_.Title,{_id:"aiChatFeedbackModal__Header",children:"Help improve my answers!"}),Bi=a.ikp(_.Close,{_id:"aiChatFeedbackModal__Close",children:n.jsx(E.CustomIcon,{iconKey:"close"})}),Ti=a.ikp("div",{_id:"aiChatFeedbackModal__Body"}),gs=a.ikp("form",{_id:"aiChatFeedbackForm"}),ji=t=>{const{onSubmit:e,...i}=t,{submitNegativeFeedback:s,currentFeedback:r,setCurrentFeedback:o}=ne.useMessageFeedback(),d=c=>{c.preventDefault();const m=c.target,l=new FormData(m),C=Object.fromEntries(l.entries());r&&(s(r,C),o(null))};return n.jsx(gs,{onSubmit:u.composeEventHandlers(e,d),...i})},Ps=a.ikp("div",{_id:"aiChatFeedbackItem"}),yi=t=>{const{name:e,...i}=t;return n.jsx(K.FeedbackItemProvider,{name:e,children:n.jsx(Ps,{...i})})},_s=a.ikp(z.Root,{_id:"aiChatFeedbackItem__Checkbox"}),Hi=t=>{const{name:e,focusItem:i}=K.useFeedbackItem(),{onCheckedChange:s,...r}=t,o=d=>{d&&i?.current?.focus()};return n.jsx(_s,{id:`feedback-${e}`,name:e,onCheckedChange:u.composeEventHandlers(s,o),...r})},wi=a.ikp(z.Indicator,{_id:"aiChatFeedbackItem__CheckboxIndicator",children:n.jsx(be.CheckboxIcon,{})}),As=a.ikp("label",{_id:"aiChatFeedbackItem__Label"}),Li=t=>{const{name:e}=K.useFeedbackItem(),i={unrelated_response:"Didn't answer my question",inaccurate_statement:"Inaccurate statement",inaccurate_code_snippet:"Inaccurate code snippet",irrelevant_citations:"Irrelevant citations"};return n.jsx(As,{htmlFor:`feedback-${e}`,children:i[e],...t})},Es=a.ikp("textarea",{_id:"aiChatFeedbackItem__Description",placeholder:"Please describe"}),Di=t=>{const{name:e,focusItem:i}=K.useFeedbackItem();return n.jsx(Es,{ref:i,name:`${e}:description`,...t})},Oi=a.ikp("button",{_id:"aiChatFeedbackForm__SubmitButton",children:"Submit",type:"submit"}),Fs=a.ikp("div",{_id:"aiChatForm__Wrapper"}),qi=t=>{const{form:e}=A.useChatForm();return e?n.jsx(Fs,{...t}):null},ks=a.ikp("form",{_id:"aiChatForm"}),Ri=t=>{const{onSubmit:e,...i}=t,{handleSubmit:s,isSuccess:r}=A.useChatForm();return r?null:n.jsx(ks,{onSubmit:u.composeEventHandlers(e,s),...i})},Is=a.ikp("button",{_id:"aiChatForm__Close",children:n.jsx(E.CustomIcon,{iconKey:"close"})}),Wi=t=>{const{onClick:e,...i}=t,{closeForm:s}=A.useChatForm();return n.jsx(Is,{onClick:u.composeEventHandlers(e,s),...i})},Ni=a.ikp("div",{_id:"aiChatForm__Header"}),Ms=a.ikp("h2",{_id:"aiChatForm__Heading"}),Qi=t=>{const{form:e}=A.useChatForm();return e?.heading?n.jsx(Ms,{children:e.heading,...t}):null},Ss=a.ikp(U.Markdown,{_id:"aiChatForm__Description"}),$i=t=>{const{form:e}=A.useChatForm();return e?.description?n.jsx(Ss,{children:e.description,...t}):null},xs=a.ikp("div",{_id:"aiChatForm__Content"}),Vi=t=>{const{children:e,...i}=t,{fields:s=[]}=A.useChatForm();return n.jsx(xs,{children:h.maybeRender(e,s),...i})},fs=a.ikp("div",{_id:"aiChatForm__Field"}),Ui=t=>{const{field:e,autoFocus:i,...s}=t,{control:r,errors:o}=A.useChatForm();return n.jsx(fa.Controller,{name:e.name,control:r,rules:{required:e.isRequired?`${e.label} is required.`:void 0},render:({field:d})=>{const c=d.value!==void 0||e.inputType==="file";return n.jsx(B.FormFieldProvider,{"data-invalid":h.dataAttr(!!o[e.name]),field:e,fieldProps:d,autoFocus:i,children:c&&n.jsx(fs,{"data-input-type":e.inputType,"data-hidden":h.dataAttr(e.isHidden),...s})})}})},Bs=a.ikp("label",{_id:"aiChatForm__FieldLabel"}),Ki=t=>{const{field:e}=B.useFormField();return n.jsx(Bs,{"data-required":h.dataAttr(e.isRequired),htmlFor:e.name,children:e.label,...t})},Ts=a.ikp("input",{_id:"aiChatForm__FieldText",type:"text"}),Y=t=>{const{field:e,error:i,fieldProps:{onChange:s,onBlur:r,...o},autoFocus:d}=B.useFormField(),{onChange:c,onBlur:m,...l}=t;return n.jsx(Ts,{id:e.name,autoFocus:d,placeholder:"placeholder"in e?e.placeholder:void 0,"data-invalid":h.dataAttr(!!i),onChange:u.composeEventHandlers(c,s),onBlur:u.composeEventHandlers(m,r),...o,...l})},zi=a.ikp(Y,{_id:"aiChatForm__FieldEmail",type:"email"}),js=a.ikp("input",{_id:"aiChatForm__FieldFile",type:"file",multiple:!0}),Gi=t=>{const{field:e,error:i,fieldProps:{value:s,onChange:r,onBlur:o,...d},autoFocus:c}=B.useFormField(),{onChange:m,onBlur:l,...C}=t,b=k=>{const y=k.target.files;r(y)};return n.jsx(js,{id:e.name,autoFocus:c,"data-value":s,"data-invalid":h.dataAttr(!!i),...C,...d,onChange:u.composeEventHandlers(m,b),onBlur:u.composeEventHandlers(l,o)})},Yi=a.ikp(Y,{_id:"aiChatForm__FieldTextArea",type:"textarea",asChild:!0,children:n.jsx(ae,{maxRows:8})}),ys=a.ikp(z.Root,{_id:"aiChatForm__FieldCheckbox"}),Ji=t=>{const{field:e,error:i,fieldProps:s,autoFocus:r}=B.useFormField(),{onCheckedChange:o,...d}=t;return n.jsx(ys,{id:e.name,name:e.name,autoFocus:r,"data-invalid":h.dataAttr(!!i),checked:s.value,onCheckedChange:u.composeEventHandlers(o,s.onChange),...d})},Xi=a.ikp(z.Indicator,{_id:"aiChatForm__FieldCheckboxIndicator",children:n.jsx(be.CheckboxIcon,{})}),Hs=a.ikp(I.Root,{_id:"aiChatForm__FieldSelect"}),Zi=t=>{const{field:e,error:i,fieldProps:s}=B.useFormField(),{onValueChange:r,...o}=t;return n.jsx(Hs,{name:e.name,"data-invalid":h.dataAttr(!!i),value:s.value,onValueChange:u.composeEventHandlers(r,s.onChange),...o})},ea=a.ikp(I.Trigger,{_id:"aiChatForm__FieldSelect__Trigger"}),ws=a.ikp(I.Value,{_id:"aiChatForm__FieldSelect__Value"}),ta=t=>{const{field:e}=B.useFormField();return n.jsx(ws,{placeholder:"placeholder"in e?e.placeholder:void 0,...t})},ia=a.ikp(I.Icon,{_id:"aiChatForm__FieldSelect__Icon",asChild:!0,children:n.jsx(x.BuiltInIconRenderer,{iconSettings:{builtIn:"LuChevronDown"}})}),aa=a.ikp(I.Content,{_id:"aiChatForm__FieldSelect__Content",position:"popper"}),na=a.ikp(I.Viewport,{_id:"aiChatForm__FieldSelect__Viewport"}),sa=a.ikp(I.Item,{_id:"aiChatForm__FieldSelect__Item"}),ra=a.ikp(I.ItemText,{_id:"aiChatForm__FieldSelect__ItemText"}),oa=a.ikp(I.ItemIndicator,{_id:"aiChatForm__FieldSelect__ItemIndicator",asChild:!0,children:n.jsx(x.BuiltInIconRenderer,{iconSettings:{builtIn:"LuCheck"}})}),Ls=a.ikp("span",{_id:"aiChatForm__FieldError"}),da=t=>{const{error:e}=B.useFormField();return e?n.jsx(Ls,{children:e.message?.toString(),...t}):null},Ds=a.ikp("span",{_id:"aiChatForm__Error"}),ca=t=>{const{formError:e}=A.useChatForm();return e?n.jsx(Ds,{children:e.message,...t}):null},ma=a.ikp("div",{_id:"aiChatForm__Footer"}),Os=a.ikp("button",{_id:"aiChatForm__Cancel",children:"Cancel",type:"button"}),la=t=>{const{onClick:e,...i}=t,{closeForm:s}=A.useChatForm();return n.jsx(Os,{onClick:u.composeEventHandlers(e,s),...i})},qs=a.ikp("button",{_id:"aiChatForm__Submit",children:"Submit",type:"submit"}),ha=t=>{const{onClick:e,...i}=t,{isSubmitting:s,form:r}=A.useChatForm(),o=r?.buttons.submit.label||"Submit";return n.jsx(qs,{disabled:s,...i,children:o})},Rs=a.ikp("div",{_id:"aiChatForm__Success"}),ua=t=>{const{isSuccess:e}=A.useChatForm();return e?n.jsx(Rs,{...t}):null},Ws=a.ikp("h2",{_id:"aiChatForm__SuccessHeading"}),Ca=t=>{const{form:e}=A.useChatForm();return n.jsx(Ws,{children:e?.successView?.heading,...t})},Ns=a.ikp(U.Markdown,{_id:"aiChatForm__SuccessMessage"}),pa=t=>{const{form:e}=A.useChatForm();return n.jsx(Ns,{children:e?.successView?.message,...t})},Qs=a.ikp("button",{_id:"aiChatForm__SuccessButton"}),va=t=>{const{onClick:e,...i}=t,{form:s,closeForm:r}=A.useChatForm(),o=s?.successView?.doneButton;if(!o)return null;const d=o.icon&&n.jsx(x.BuiltInIconRenderer,{iconSettings:o.icon}),c=o.label;return n.jsx(Qs,{onClick:u.composeEventHandlers(e,r),children:n.jsxs(n.Fragment,{children:[d,c]}),...i})};exports.Provider=v.ChatProvider;exports.ActionBar=hi;exports.Actions=ui;exports.AttachmentsBar=wt;exports.AttachmentsBarActions=Wt;exports.AttachmentsBarAttachment=Dt;exports.AttachmentsBarAttachmentDelete=Rt;exports.AttachmentsBarAttachmentIcon=Ot;exports.AttachmentsBarAttachmentTitle=qt;exports.AttachmentsBarForm=ii;exports.AttachmentsBarFormContent=oi;exports.AttachmentsBarFormContentError=mi;exports.AttachmentsBarFormContentInput=ci;exports.AttachmentsBarFormContentLabel=di;exports.AttachmentsBarFormSubmitButton=li;exports.AttachmentsBarFormTitle=ai;exports.AttachmentsBarFormTitleError=ri;exports.AttachmentsBarFormTitleInput=si;exports.AttachmentsBarFormTitleLabel=ni;exports.AttachmentsBarInfoTip=Nt;exports.AttachmentsBarInfoTipArrow=me;exports.AttachmentsBarInfoTipIcon=Qt;exports.AttachmentsBarInfoTipText=$t;exports.AttachmentsBarInput=Ut;exports.AttachmentsBarInputs=Vt;exports.AttachmentsBarList=Lt;exports.AttachmentsBarModal=Kt;exports.AttachmentsBarModalBody=ti;exports.AttachmentsBarModalClose=ei;exports.AttachmentsBarModalContent=Gt;exports.AttachmentsBarModalDescription=Xt;exports.AttachmentsBarModalHeader=Yt;exports.AttachmentsBarModalHeading=Jt;exports.AttachmentsBarModalHelp=Zt;exports.AttachmentsBarModalOverlay=zt;exports.ChatAction=G;exports.ChatActionFeedback=gi;exports.ChatActionLabel=le;exports.ChatHelpAction=_i;exports.Content=ke;exports.ContentScrollArea=Ie;exports.ContentScrollAreaCorner=fe;exports.ContentScrollAreaScrollbar=Se;exports.ContentScrollAreaThumb=xe;exports.ContentScrollAreaViewport=Me;exports.ConversationLoading=Pe;exports.Disclaimer=Te;exports.DisclaimerArrow=Le;exports.DisclaimerContent=He;exports.DisclaimerLabel=je;exports.DisclaimerText=we;exports.DisclaimerTrigger=ye;exports.EmbeddedChatPrimitiveActionBar=hi;exports.EmbeddedChatPrimitiveActions=ui;exports.EmbeddedChatPrimitiveAttachmentsBar=wt;exports.EmbeddedChatPrimitiveAttachmentsBarActions=Wt;exports.EmbeddedChatPrimitiveAttachmentsBarAttachment=Dt;exports.EmbeddedChatPrimitiveAttachmentsBarAttachmentDelete=Rt;exports.EmbeddedChatPrimitiveAttachmentsBarAttachmentIcon=Ot;exports.EmbeddedChatPrimitiveAttachmentsBarAttachmentTitle=qt;exports.EmbeddedChatPrimitiveAttachmentsBarForm=ii;exports.EmbeddedChatPrimitiveAttachmentsBarFormContent=oi;exports.EmbeddedChatPrimitiveAttachmentsBarFormContentError=mi;exports.EmbeddedChatPrimitiveAttachmentsBarFormContentInput=ci;exports.EmbeddedChatPrimitiveAttachmentsBarFormContentLabel=di;exports.EmbeddedChatPrimitiveAttachmentsBarFormSubmitButton=li;exports.EmbeddedChatPrimitiveAttachmentsBarFormTitle=ai;exports.EmbeddedChatPrimitiveAttachmentsBarFormTitleError=ri;exports.EmbeddedChatPrimitiveAttachmentsBarFormTitleInput=si;exports.EmbeddedChatPrimitiveAttachmentsBarFormTitleLabel=ni;exports.EmbeddedChatPrimitiveAttachmentsBarInfoTip=Nt;exports.EmbeddedChatPrimitiveAttachmentsBarInfoTipArrow=me;exports.EmbeddedChatPrimitiveAttachmentsBarInfoTipIcon=Qt;exports.EmbeddedChatPrimitiveAttachmentsBarInfoTipText=$t;exports.EmbeddedChatPrimitiveAttachmentsBarInput=Ut;exports.EmbeddedChatPrimitiveAttachmentsBarInputs=Vt;exports.EmbeddedChatPrimitiveAttachmentsBarList=Lt;exports.EmbeddedChatPrimitiveAttachmentsBarModal=Kt;exports.EmbeddedChatPrimitiveAttachmentsBarModalBody=ti;exports.EmbeddedChatPrimitiveAttachmentsBarModalClose=ei;exports.EmbeddedChatPrimitiveAttachmentsBarModalContent=Gt;exports.EmbeddedChatPrimitiveAttachmentsBarModalDescription=Xt;exports.EmbeddedChatPrimitiveAttachmentsBarModalHeader=Yt;exports.EmbeddedChatPrimitiveAttachmentsBarModalHeading=Jt;exports.EmbeddedChatPrimitiveAttachmentsBarModalHelp=Zt;exports.EmbeddedChatPrimitiveAttachmentsBarModalOverlay=zt;exports.EmbeddedChatPrimitiveChatAction=G;exports.EmbeddedChatPrimitiveChatActionFeedback=gi;exports.EmbeddedChatPrimitiveChatActionLabel=le;exports.EmbeddedChatPrimitiveChatHelpAction=_i;exports.EmbeddedChatPrimitiveContent=ke;exports.EmbeddedChatPrimitiveContentScrollArea=Ie;exports.EmbeddedChatPrimitiveContentScrollAreaCorner=fe;exports.EmbeddedChatPrimitiveContentScrollAreaScrollbar=Se;exports.EmbeddedChatPrimitiveContentScrollAreaThumb=xe;exports.EmbeddedChatPrimitiveContentScrollAreaViewport=Me;exports.EmbeddedChatPrimitiveConversationLoading=Pe;exports.EmbeddedChatPrimitiveDisclaimer=Te;exports.EmbeddedChatPrimitiveDisclaimerArrow=Le;exports.EmbeddedChatPrimitiveDisclaimerContent=He;exports.EmbeddedChatPrimitiveDisclaimerLabel=je;exports.EmbeddedChatPrimitiveDisclaimerText=we;exports.EmbeddedChatPrimitiveDisclaimerTrigger=ye;exports.EmbeddedChatPrimitiveExampleQuestion=Re;exports.EmbeddedChatPrimitiveExampleQuestionButton=We;exports.EmbeddedChatPrimitiveExampleQuestions=De;exports.EmbeddedChatPrimitiveExampleQuestionsLabel=Oe;exports.EmbeddedChatPrimitiveExampleQuestionsList=qe;exports.EmbeddedChatPrimitiveFeedbackForm=ji;exports.EmbeddedChatPrimitiveFeedbackItem=yi;exports.EmbeddedChatPrimitiveFeedbackItemCheckbox=Hi;exports.EmbeddedChatPrimitiveFeedbackItemCheckboxIndicator=wi;exports.EmbeddedChatPrimitiveFeedbackItemDescription=Di;exports.EmbeddedChatPrimitiveFeedbackItemLabel=Li;exports.EmbeddedChatPrimitiveFeedbackModal=Mi;exports.EmbeddedChatPrimitiveFeedbackModalBody=Ti;exports.EmbeddedChatPrimitiveFeedbackModalClose=Bi;exports.EmbeddedChatPrimitiveFeedbackModalContent=xi;exports.EmbeddedChatPrimitiveFeedbackModalHeader=fi;exports.EmbeddedChatPrimitiveFeedbackModalOverlay=Si;exports.EmbeddedChatPrimitiveFeedbackSubmitButton=Oi;exports.EmbeddedChatPrimitiveFooter=ft;exports.EmbeddedChatPrimitiveForm=Ri;exports.EmbeddedChatPrimitiveFormCancel=la;exports.EmbeddedChatPrimitiveFormClose=Wi;exports.EmbeddedChatPrimitiveFormContent=Vi;exports.EmbeddedChatPrimitiveFormDescription=$i;exports.EmbeddedChatPrimitiveFormError=ca;exports.EmbeddedChatPrimitiveFormField=Ui;exports.EmbeddedChatPrimitiveFormFieldCheckbox=Ji;exports.EmbeddedChatPrimitiveFormFieldCheckboxIndicator=Xi;exports.EmbeddedChatPrimitiveFormFieldEmail=zi;exports.EmbeddedChatPrimitiveFormFieldError=da;exports.EmbeddedChatPrimitiveFormFieldFile=Gi;exports.EmbeddedChatPrimitiveFormFieldLabel=Ki;exports.EmbeddedChatPrimitiveFormFieldSelect=Zi;exports.EmbeddedChatPrimitiveFormFieldSelectContent=aa;exports.EmbeddedChatPrimitiveFormFieldSelectIcon=ia;exports.EmbeddedChatPrimitiveFormFieldSelectItem=sa;exports.EmbeddedChatPrimitiveFormFieldSelectItemIndicator=oa;exports.EmbeddedChatPrimitiveFormFieldSelectItemText=ra;exports.EmbeddedChatPrimitiveFormFieldSelectTrigger=ea;exports.EmbeddedChatPrimitiveFormFieldSelectValue=ta;exports.EmbeddedChatPrimitiveFormFieldSelectViewport=na;exports.EmbeddedChatPrimitiveFormFieldText=Y;exports.EmbeddedChatPrimitiveFormFieldTextArea=Yi;exports.EmbeddedChatPrimitiveFormFooter=ma;exports.EmbeddedChatPrimitiveFormHeader=Ni;exports.EmbeddedChatPrimitiveFormHeading=Qi;exports.EmbeddedChatPrimitiveFormSubmit=ha;exports.EmbeddedChatPrimitiveFormSuccess=ua;exports.EmbeddedChatPrimitiveFormSuccessButton=va;exports.EmbeddedChatPrimitiveFormSuccessHeading=Ca;exports.EmbeddedChatPrimitiveFormSuccessMessage=pa;exports.EmbeddedChatPrimitiveFormWrapper=qi;exports.EmbeddedChatPrimitiveHeaderToolbar=Ae;exports.EmbeddedChatPrimitiveHelpActions=Pi;exports.EmbeddedChatPrimitiveHelpActionsMenu=Ei;exports.EmbeddedChatPrimitiveHelpActionsMenuArrow=Fi;exports.EmbeddedChatPrimitiveHelpActionsMenuItem=ki;exports.EmbeddedChatPrimitiveHelpActionsMenuItemIcon=Ii;exports.EmbeddedChatPrimitiveHelpActionsTrigger=Ai;exports.EmbeddedChatPrimitiveInput=jt;exports.EmbeddedChatPrimitiveInputFieldset=Bt;exports.EmbeddedChatPrimitiveInputGroup=Tt;exports.EmbeddedChatPrimitiveIntroMessageWrapper=Ue;exports.EmbeddedChatPrimitiveMessage=ut;exports.EmbeddedChatPrimitiveMessageAction=bt;exports.EmbeddedChatPrimitiveMessageAttachments=it;exports.EmbeddedChatPrimitiveMessageAttachmentsItem=nt;exports.EmbeddedChatPrimitiveMessageAttachmentsItemIcon=st;exports.EmbeddedChatPrimitiveMessageAttachmentsItemTitle=rt;exports.EmbeddedChatPrimitiveMessageAttachmentsList=at;exports.EmbeddedChatPrimitiveMessageAttachmentsPreview=ot;exports.EmbeddedChatPrimitiveMessageAttachmentsPreviewBody=ht;exports.EmbeddedChatPrimitiveMessageAttachmentsPreviewClose=lt;exports.EmbeddedChatPrimitiveMessageAttachmentsPreviewContent=ct;exports.EmbeddedChatPrimitiveMessageAttachmentsPreviewHeader=mt;exports.EmbeddedChatPrimitiveMessageAttachmentsPreviewOverlay=dt;exports.EmbeddedChatPrimitiveMessageAvatar=Ge;exports.EmbeddedChatPrimitiveMessageAvatarContent=Ye;exports.EmbeddedChatPrimitiveMessageAvatarFallback=Je;exports.EmbeddedChatPrimitiveMessageAvatarImage=Xe;exports.EmbeddedChatPrimitiveMessageContent=tt;exports.EmbeddedChatPrimitiveMessageContentWrapper=et;exports.EmbeddedChatPrimitiveMessageHeader=Ke;exports.EmbeddedChatPrimitiveMessageLoading=ze;exports.EmbeddedChatPrimitiveMessageName=Ze;exports.EmbeddedChatPrimitiveMessageSourceItem=At;exports.EmbeddedChatPrimitiveMessageSourceItemBreadcrumbs=Et;exports.EmbeddedChatPrimitiveMessageSourceItemDescription=Mt;exports.EmbeddedChatPrimitiveMessageSourceItemDescriptionPart=St;exports.EmbeddedChatPrimitiveMessageSourceItemIcon=Ft;exports.EmbeddedChatPrimitiveMessageSourceItemIndicator=xt;exports.EmbeddedChatPrimitiveMessageSourceItemTag=It;exports.EmbeddedChatPrimitiveMessageSourceItemTitle=kt;exports.EmbeddedChatPrimitiveMessageSources=gt;exports.EmbeddedChatPrimitiveMessageSourcesHeader=Pt;exports.EmbeddedChatPrimitiveMessageSourcesList=_t;exports.EmbeddedChatPrimitiveMessageToolAction=vt;exports.EmbeddedChatPrimitiveMessageToolActions=pt;exports.EmbeddedChatPrimitiveMessageToolbar=Ct;exports.EmbeddedChatPrimitiveMessageWrapper=ce;exports.EmbeddedChatPrimitiveMessages=Be;exports.EmbeddedChatPrimitiveRoot=_e;exports.EmbeddedChatPrimitiveSendButton=yt;exports.EmbeddedChatPrimitiveSendButtonIcon=Ht;exports.EmbeddedChatPrimitiveTaglineBrandName=bi;exports.EmbeddedChatPrimitiveTaglineContainer=Ci;exports.EmbeddedChatPrimitiveTaglineLogo=vi;exports.EmbeddedChatPrimitiveTaglineText=pi;exports.EmbeddedChatPrimitiveToolbarHeader=Fe;exports.EmbeddedChatPrimitiveToolbarHeaderWrapper=Ee;exports.EmbeddedChatPrimitiveWorkflow=Ve;exports.EmbeddedChatPrimitiveWorkflows=Ne;exports.EmbeddedChatPrimitiveWorkflowsLabel=Qe;exports.EmbeddedChatPrimitiveWorkflowsList=$e;exports.EmbeddedChatPrimitiveWrapper=ge;exports.ExampleQuestion=Re;exports.ExampleQuestionButton=We;exports.ExampleQuestions=De;exports.ExampleQuestionsLabel=Oe;exports.ExampleQuestionsList=qe;exports.FeedbackForm=ji;exports.FeedbackItem=yi;exports.FeedbackItemCheckbox=Hi;exports.FeedbackItemCheckboxIndicator=wi;exports.FeedbackItemDescription=Di;exports.FeedbackItemLabel=Li;exports.FeedbackModal=Mi;exports.FeedbackModalBody=Ti;exports.FeedbackModalClose=Bi;exports.FeedbackModalContent=xi;exports.FeedbackModalHeader=fi;exports.FeedbackModalOverlay=Si;exports.FeedbackSubmitButton=Oi;exports.Footer=ft;exports.Form=Ri;exports.FormCancel=la;exports.FormClose=Wi;exports.FormContent=Vi;exports.FormDescription=$i;exports.FormError=ca;exports.FormField=Ui;exports.FormFieldCheckbox=Ji;exports.FormFieldCheckboxIndicator=Xi;exports.FormFieldEmail=zi;exports.FormFieldError=da;exports.FormFieldFile=Gi;exports.FormFieldLabel=Ki;exports.FormFieldSelect=Zi;exports.FormFieldSelectContent=aa;exports.FormFieldSelectIcon=ia;exports.FormFieldSelectItem=sa;exports.FormFieldSelectItemIndicator=oa;exports.FormFieldSelectItemText=ra;exports.FormFieldSelectTrigger=ea;exports.FormFieldSelectValue=ta;exports.FormFieldSelectViewport=na;exports.FormFieldText=Y;exports.FormFieldTextArea=Yi;exports.FormFooter=ma;exports.FormHeader=Ni;exports.FormHeading=Qi;exports.FormSubmit=ha;exports.FormSuccess=ua;exports.FormSuccessButton=va;exports.FormSuccessHeading=Ca;exports.FormSuccessMessage=pa;exports.FormWrapper=qi;exports.Header=Na;exports.HeaderToolbar=Ae;exports.HeaderToolbarWrapper=Ee;exports.HelpActions=Pi;exports.HelpActionsMenu=Ei;exports.HelpActionsMenuArrow=Fi;exports.HelpActionsMenuItem=ki;exports.HelpActionsMenuItemIcon=Ii;exports.HelpActionsTrigger=Ai;exports.Input=jt;exports.InputFieldset=Bt;exports.InputGroup=Tt;exports.IntroMessageWrapper=Ue;exports.Message=ut;exports.MessageAction=bt;exports.MessageAttachments=it;exports.MessageAttachmentsItem=nt;exports.MessageAttachmentsItemIcon=st;exports.MessageAttachmentsItemTitle=rt;exports.MessageAttachmentsList=at;exports.MessageAttachmentsPreview=ot;exports.MessageAttachmentsPreviewBody=ht;exports.MessageAttachmentsPreviewClose=lt;exports.MessageAttachmentsPreviewContent=ct;exports.MessageAttachmentsPreviewHeader=mt;exports.MessageAttachmentsPreviewOverlay=dt;exports.MessageAvatar=Ge;exports.MessageAvatarContent=Ye;exports.MessageAvatarFallback=Je;exports.MessageAvatarImage=Xe;exports.MessageContent=tt;exports.MessageContentWrapper=et;exports.MessageHeader=Ke;exports.MessageLoading=ze;exports.MessageName=Ze;exports.MessageSourceItem=At;exports.MessageSourceItemBreadcrumbIcon=Hn;exports.MessageSourceItemBreadcrumbs=Et;exports.MessageSourceItemDescription=Mt;exports.MessageSourceItemDescriptionPart=St;exports.MessageSourceItemIcon=Ft;exports.MessageSourceItemIndicator=xt;exports.MessageSourceItemTag=It;exports.MessageSourceItemTitle=kt;exports.MessageSources=gt;exports.MessageSourcesHeader=Pt;exports.MessageSourcesList=_t;exports.MessageToolAction=vt;exports.MessageToolActions=pt;exports.MessageToolbar=Ct;exports.MessageWrapper=ce;exports.Messages=Be;exports.Root=_e;exports.SendButton=yt;exports.SendButtonIcon=Ht;exports.TaglineBrandName=bi;exports.TaglineContainer=Ci;exports.TaglineLogo=vi;exports.TaglineText=pi;exports.ToolbarHeader=Fe;exports.Workflow=Ve;exports.Workflows=Ne;exports.WorkflowsLabel=Qe;exports.WorkflowsList=$e;exports.Wrapper=ge;
|
|
@@ -507,6 +507,11 @@ const ct = "__intro__", dt = i("div", {
|
|
|
507
507
|
}), os = (t) => {
|
|
508
508
|
const { onClick: e, action: a, ...s } = t, { handleAction: o } = me(a), { logEvent: r } = W(), { conversation: c } = O(), d = () => {
|
|
509
509
|
o(), r({
|
|
510
|
+
eventName: "tool_call_action_clicked",
|
|
511
|
+
properties: {
|
|
512
|
+
conversation: c
|
|
513
|
+
}
|
|
514
|
+
}), a.action.type !== "open_form" && r({
|
|
510
515
|
eventName: "user_escalation_indicated",
|
|
511
516
|
properties: {
|
|
512
517
|
escalationType: "contact_us",
|
package/dist/index.d.cts
CHANGED
|
@@ -29,6 +29,7 @@ import { FormHTMLAttributes } from 'react';
|
|
|
29
29
|
import { ForwardRefExoticComponent } from 'react';
|
|
30
30
|
import { GetHelpOption } from '@inkeep/cxkit-types';
|
|
31
31
|
import { HTMLAttributes } from 'react';
|
|
32
|
+
import { IkpChatAction } from '@inkeep/cxkit-types';
|
|
32
33
|
import { ImgHTMLAttributes } from 'react';
|
|
33
34
|
import { InkeepAIChatSettings } from '@inkeep/cxkit-types';
|
|
34
35
|
import { InkeepBaseSettings } from '@inkeep/cxkit-types';
|
|
@@ -403,6 +404,10 @@ export declare type ChatEventsContextValue = {
|
|
|
403
404
|
* Log a conversation.
|
|
404
405
|
*/
|
|
405
406
|
logConversation: (messages: Message[]) => Promise<ConversationResponse | undefined>;
|
|
407
|
+
/**
|
|
408
|
+
* Get the latest conversation state (useful for accessing the conversation after it's been logged).
|
|
409
|
+
*/
|
|
410
|
+
getLatestConversation: () => ConversationResponse;
|
|
406
411
|
};
|
|
407
412
|
|
|
408
413
|
export declare const ChatEventsProvider: React.FC<{
|
|
@@ -4311,7 +4316,7 @@ export declare const useChatForm: () => ChatFormContextValue;
|
|
|
4311
4316
|
|
|
4312
4317
|
export declare function useChatFormState(): {
|
|
4313
4318
|
form: AIChatFormSettings | null;
|
|
4314
|
-
openForm: (formSettings: AIChatFormSettings,
|
|
4319
|
+
openForm: (formSettings: AIChatFormSettings, triggeringAction?: IkpChatAction) => void;
|
|
4315
4320
|
closeForm: () => void;
|
|
4316
4321
|
handleSubmit: (e?: React.BaseSyntheticEvent) => Promise<void>;
|
|
4317
4322
|
isSuccess: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ import { FormHTMLAttributes } from 'react';
|
|
|
29
29
|
import { ForwardRefExoticComponent } from 'react';
|
|
30
30
|
import { GetHelpOption } from '@inkeep/cxkit-types';
|
|
31
31
|
import { HTMLAttributes } from 'react';
|
|
32
|
+
import { IkpChatAction } from '@inkeep/cxkit-types';
|
|
32
33
|
import { ImgHTMLAttributes } from 'react';
|
|
33
34
|
import { InkeepAIChatSettings } from '@inkeep/cxkit-types';
|
|
34
35
|
import { InkeepBaseSettings } from '@inkeep/cxkit-types';
|
|
@@ -403,6 +404,10 @@ export declare type ChatEventsContextValue = {
|
|
|
403
404
|
* Log a conversation.
|
|
404
405
|
*/
|
|
405
406
|
logConversation: (messages: Message[]) => Promise<ConversationResponse | undefined>;
|
|
407
|
+
/**
|
|
408
|
+
* Get the latest conversation state (useful for accessing the conversation after it's been logged).
|
|
409
|
+
*/
|
|
410
|
+
getLatestConversation: () => ConversationResponse;
|
|
406
411
|
};
|
|
407
412
|
|
|
408
413
|
export declare const ChatEventsProvider: React.FC<{
|
|
@@ -4311,7 +4316,7 @@ export declare const useChatForm: () => ChatFormContextValue;
|
|
|
4311
4316
|
|
|
4312
4317
|
export declare function useChatFormState(): {
|
|
4313
4318
|
form: AIChatFormSettings | null;
|
|
4314
|
-
openForm: (formSettings: AIChatFormSettings,
|
|
4319
|
+
openForm: (formSettings: AIChatFormSettings, triggeringAction?: IkpChatAction) => void;
|
|
4315
4320
|
closeForm: () => void;
|
|
4316
4321
|
handleSubmit: (e?: React.BaseSyntheticEvent) => Promise<void>;
|
|
4317
4322
|
isSuccess: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.109",componentType:r,tags:a}),[r,a]),d=!m.optOutAllAnalytics&&g!=="development",P={logEvent:t.useCallback(async n=>{const o={...l,...n.properties,...v},p={eventName:n.eventName,properties:o,userProperties:u},y=["modal_opened","modal_closed"].includes(n.eventName);if(d&&!y){if("conversation"in o&&!o.conversation?.id)return;f.logEvent(p,i,c)}s.onEvent?.(p)},[d,s,i,c,u,l,v])};return B.jsx(E.Provider,{value:P,children:e})},C=()=>{const e=t.useContext(E);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=q;exports.useBaseEvents=C;
|
|
@@ -7,7 +7,7 @@ import { useUser as A } from "./user-provider.js";
|
|
|
7
7
|
const u = B(void 0), $ = ({ children: e }) => {
|
|
8
8
|
const { baseSettings: t, componentType: s } = w(), { apiKey: r, analyticsApiBaseUrl: i, tags: a, privacyPreferences: d, env: E, analyticsProperties: c } = t, { userProperties: v } = A(), p = P(
|
|
9
9
|
() => ({
|
|
10
|
-
widgetLibraryVersion: "0.5.
|
|
10
|
+
widgetLibraryVersion: "0.5.109",
|
|
11
11
|
componentType: s,
|
|
12
12
|
tags: a
|
|
13
13
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react/jsx-runtime"),e=require("react"),O=require("../atoms/api/analytics/conversation.cjs"),m=require("./config-provider.cjs"),B=require("./conversation-provider.cjs"),M=require("./user-provider.cjs"),K=require("./base-events-provider.cjs"),T=require("../utils/generate-uid.cjs"),x=e.createContext(void 0),V=({children:c})=>{const{baseSettings:k,aiChatSettings:w}=m.useInkeepConfig(),{apiKey:p,analyticsApiBaseUrl:E,tags:f,privacyPreferences:{optOutAllAnalytics:a},env:u,analyticsProperties:v}=k,{conversationVisibility:P}=w,{userProperties:b}=M.useUser(),{logEvent:y}=K.useBaseEvents(),{conversation:l,setConversation:I,chatId:d,isSharedChat:C,setExternalChatId:q}=B.useInkeepConversation(),n=e.useRef(l),h=e.useRef(C?d:void 0);e.useEffect(()=>{n.current=l},[l]),e.useEffect(()=>{h.current=C?d:void 0},[d,C]);const g=e.useCallback(async o=>{const t=n.current;h.current&&(t.id="",q(void 0),h.current=void 0);const s=!a&&u!=="development";let r=Object.assign({},t,{messages:o});if(s){const i=await O.logConversation(t.id,{messages:o,tags:f,userProperties:b,properties:v,visibility:P},p,E);i&&(r=i)}else r.id="conv_"+T.generateUid(16);return r},[E,p,f,b,a,u,v,q,P]),S=e.useCallback(async(o,t)=>{let s=n.current;if(t){const i=n.current.messages||[];(t.length!==i.length||t.some((R,U)=>R.id!==i[U]?.id))&&(s=await g(t),I(s),n.current=s)}const r={...o,properties:{conversation:s,...o.properties}};y(r)},[y,g,a,u,v]),j=e.useCallback(()=>n.current,[]),L={logEvent:S,logConversation:g,getLatestConversation:j};return A.jsx(x.Provider,{value:L,children:c})},_=()=>{const c=e.useContext(x);if(!c)throw new Error("useChatEvents must be used within a ChatEventsProvider");return c};exports.ChatEventsProvider=V;exports.useChatEvents=_;
|
|
@@ -1,90 +1,91 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { logConversation as
|
|
5
|
-
import { useInkeepConfig as
|
|
6
|
-
import { useInkeepConversation as
|
|
7
|
-
import { useUser as
|
|
8
|
-
import { useBaseEvents as
|
|
9
|
-
import { generateUid as
|
|
10
|
-
const I =
|
|
11
|
-
const { baseSettings:
|
|
2
|
+
import { jsx as K } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as P, useEffect as w, useCallback as f, createContext as M, useContext as R } from "react";
|
|
4
|
+
import { logConversation as V } from "../atoms/api/analytics/conversation.js";
|
|
5
|
+
import { useInkeepConfig as _ } from "./config-provider.js";
|
|
6
|
+
import { useInkeepConversation as $ } from "./conversation-provider.js";
|
|
7
|
+
import { useUser as q } from "./user-provider.js";
|
|
8
|
+
import { useBaseEvents as z } from "./base-events-provider.js";
|
|
9
|
+
import { generateUid as D } from "../utils/generate-uid.js";
|
|
10
|
+
const I = M(void 0), Y = ({ children: i }) => {
|
|
11
|
+
const { baseSettings: L, aiChatSettings: k } = _(), {
|
|
12
12
|
apiKey: h,
|
|
13
|
-
analyticsApiBaseUrl:
|
|
14
|
-
tags:
|
|
13
|
+
analyticsApiBaseUrl: m,
|
|
14
|
+
tags: g,
|
|
15
15
|
privacyPreferences: { optOutAllAnalytics: a },
|
|
16
16
|
env: c,
|
|
17
17
|
analyticsProperties: v
|
|
18
|
-
} =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}, [u]),
|
|
22
|
-
|
|
23
|
-
}, [l,
|
|
24
|
-
const
|
|
18
|
+
} = L, { conversationVisibility: E } = k, { userProperties: y } = q(), { logEvent: x } = z(), { conversation: u, setConversation: A, chatId: l, isSharedChat: p, setExternalChatId: b } = $(), e = P(u), C = P(p ? l : void 0);
|
|
19
|
+
w(() => {
|
|
20
|
+
e.current = u;
|
|
21
|
+
}, [u]), w(() => {
|
|
22
|
+
C.current = p ? l : void 0;
|
|
23
|
+
}, [l, p]);
|
|
24
|
+
const d = f(
|
|
25
25
|
async (o) => {
|
|
26
|
-
const t =
|
|
27
|
-
|
|
28
|
-
const
|
|
26
|
+
const t = e.current;
|
|
27
|
+
C.current && (t.id = "", b(void 0), C.current = void 0);
|
|
28
|
+
const n = !a && c !== "development";
|
|
29
29
|
let r = Object.assign({}, t, { messages: o });
|
|
30
|
-
if (
|
|
31
|
-
const s = await
|
|
30
|
+
if (n) {
|
|
31
|
+
const s = await V(
|
|
32
32
|
t.id,
|
|
33
33
|
{
|
|
34
34
|
messages: o,
|
|
35
|
-
tags:
|
|
36
|
-
userProperties:
|
|
35
|
+
tags: g,
|
|
36
|
+
userProperties: y,
|
|
37
37
|
properties: v,
|
|
38
|
-
visibility:
|
|
38
|
+
visibility: E
|
|
39
39
|
},
|
|
40
40
|
h,
|
|
41
|
-
|
|
41
|
+
m
|
|
42
42
|
);
|
|
43
43
|
s && (r = s);
|
|
44
44
|
} else
|
|
45
|
-
r.id = "conv_" +
|
|
45
|
+
r.id = "conv_" + D(16);
|
|
46
46
|
return r;
|
|
47
47
|
},
|
|
48
48
|
[
|
|
49
|
-
f,
|
|
50
|
-
h,
|
|
51
49
|
m,
|
|
52
|
-
|
|
50
|
+
h,
|
|
51
|
+
g,
|
|
52
|
+
y,
|
|
53
53
|
a,
|
|
54
54
|
c,
|
|
55
55
|
v,
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
b,
|
|
57
|
+
E
|
|
58
58
|
]
|
|
59
|
-
), S =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
), S = f(
|
|
60
|
+
async (o, t) => {
|
|
61
|
+
let n = e.current;
|
|
62
|
+
if (t) {
|
|
63
|
+
const s = e.current.messages || [];
|
|
64
|
+
(t.length !== s.length || t.some((B, O) => B.id !== s[O]?.id)) && (n = await d(t), A(n), e.current = n);
|
|
65
|
+
}
|
|
66
|
+
const r = {
|
|
67
|
+
...o,
|
|
68
|
+
properties: {
|
|
69
|
+
conversation: n,
|
|
70
|
+
...o.properties
|
|
66
71
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
[y, C, a, c, v]
|
|
77
|
-
),
|
|
78
|
-
logConversation: C
|
|
72
|
+
};
|
|
73
|
+
x(r);
|
|
74
|
+
},
|
|
75
|
+
[x, d, a, c, v]
|
|
76
|
+
), U = f(() => e.current, []), j = {
|
|
77
|
+
logEvent: S,
|
|
78
|
+
logConversation: d,
|
|
79
|
+
getLatestConversation: U
|
|
79
80
|
};
|
|
80
|
-
return /* @__PURE__ */
|
|
81
|
-
},
|
|
82
|
-
const i =
|
|
81
|
+
return /* @__PURE__ */ K(I.Provider, { value: j, children: i });
|
|
82
|
+
}, Z = () => {
|
|
83
|
+
const i = R(I);
|
|
83
84
|
if (!i)
|
|
84
85
|
throw new Error("useChatEvents must be used within a ChatEventsProvider");
|
|
85
86
|
return i;
|
|
86
87
|
};
|
|
87
88
|
export {
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
Y as ChatEventsProvider,
|
|
90
|
+
Z as useChatEvents
|
|
90
91
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),s=require("react"),H=require("react-hook-form"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),s=require("react"),H=require("react-hook-form"),M=require("./conversation-provider.cjs"),O=require("../components/modal/modal-provider.cjs"),A=require("../utils/form.cjs"),N=require("./chat-events-provider.cjs"),T="root.serverError",b=s.createContext(void 0);function C(){const[t,c]=s.useState(null),[a,m]=s.useState(null),[g,d]=s.useState(!1),{conversation:r}=M.useInkeepConversation(),F=O.useModal(),{logEvent:v}=N.useChatEvents(),_=(e,o)=>{c(e),m(o||null)},f=()=>{c(null),m(null),d(!1),t?.buttons.close?.action==="close_modal"&&F?.setOpen(!1)},u=s.useMemo(()=>t?.fields.map(e=>{const o={...e};return"_type"in e&&e._type==="include_chat_session"&&(o.inputType="checkbox",r.id?(o.isHidden=e.isHidden,o.isRequired=e.isRequired):(o.isHidden=!0,o.isRequired=!1)),o}),[t?.fields,r.id]),p=u?.find(e=>"_type"in e&&e._type==="include_chat_session"),n=s.useMemo(()=>A.getFormDefaultValues(u),[u]),{control:E,handleSubmit:q,formState:{errors:h,isSubmitting:y},setError:R,reset:S}=H.useForm({defaultValues:n});s.useEffect(()=>{n&&S(n)},[S,n]);const P=q(async e=>{const l=r.id&&p&&e[p.name]?r:null;try{if(await t?.buttons.submit.onSubmit({values:e,conversation:l}),a){const i="name"in a;v({eventName:"user_escalation_indicated",properties:{escalationType:"support_form",getHelpOptionName:i?a?.name:void 0,toolCallActionLabel:i?void 0:a?.label,conversation:l||r}})}v({eventName:"ai_chat_form_submitted",properties:{conversation:l||r,values:e}}),d(!0),t?.successView||f()}catch(i){R(T,{message:i instanceof Error?i.message:"Something went wrong."})}}),w=h?.root?.serverError;return{form:t,openForm:_,closeForm:f,handleSubmit:P,isSuccess:g,isSubmitting:y,formError:w,fields:u,errors:h,control:E,defaultValues:n}}const V=({children:t})=>{const c=C();return x.jsx(b.Provider,{value:c,children:t})},j=()=>{const t=s.useContext(b);if(!t)throw new Error("useChatForm must be used within a ChatFormProvider");return t};exports.ChatFormProvider=V;exports.useChatForm=j;exports.useChatFormState=C;
|
|
@@ -1,68 +1,79 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { useForm as
|
|
5
|
-
import { useInkeepConversation as
|
|
6
|
-
import { useModal as
|
|
7
|
-
import { getFormDefaultValues as
|
|
8
|
-
import { useChatEvents as
|
|
9
|
-
const I = "root.serverError",
|
|
2
|
+
import { jsx as A } from "react/jsx-runtime";
|
|
3
|
+
import { useState as u, useMemo as S, useEffect as N, createContext as O, useContext as V } from "react";
|
|
4
|
+
import { useForm as q } from "react-hook-form";
|
|
5
|
+
import { useInkeepConversation as M } from "./conversation-provider.js";
|
|
6
|
+
import { useModal as P } from "../components/modal/modal-provider.js";
|
|
7
|
+
import { getFormDefaultValues as T } from "../utils/form.js";
|
|
8
|
+
import { useChatEvents as k } from "./chat-events-provider.js";
|
|
9
|
+
const I = "root.serverError", _ = O(void 0);
|
|
10
10
|
function j() {
|
|
11
|
-
const [t,
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
},
|
|
11
|
+
const [t, i] = u(null), [c, l] = u(null), [g, d] = u(!1), { conversation: s } = M(), C = P(), { logEvent: p } = k(), E = (e, o) => {
|
|
12
|
+
i(e), l(o || null);
|
|
13
|
+
}, f = () => {
|
|
14
|
+
i(null), l(null), d(!1), t?.buttons.close?.action === "close_modal" && C?.setOpen(!1);
|
|
15
|
+
}, a = S(() => t?.fields.map((e) => {
|
|
16
16
|
const o = { ...e };
|
|
17
17
|
return "_type" in e && e._type === "include_chat_session" && (o.inputType = "checkbox", s.id ? (o.isHidden = e.isHidden, o.isRequired = e.isRequired) : (o.isHidden = !0, o.isRequired = !1)), o;
|
|
18
|
-
}), [t?.fields, s.id]),
|
|
19
|
-
control:
|
|
18
|
+
}), [t?.fields, s.id]), h = a?.find((e) => "_type" in e && e._type === "include_chat_session"), n = S(() => T(a), [a]), {
|
|
19
|
+
control: F,
|
|
20
20
|
handleSubmit: y,
|
|
21
|
-
formState: { errors:
|
|
21
|
+
formState: { errors: v, isSubmitting: R },
|
|
22
22
|
setError: w,
|
|
23
|
-
reset:
|
|
24
|
-
} =
|
|
23
|
+
reset: b
|
|
24
|
+
} = q({
|
|
25
25
|
defaultValues: n
|
|
26
26
|
});
|
|
27
|
-
|
|
28
|
-
n &&
|
|
29
|
-
}, [
|
|
27
|
+
N(() => {
|
|
28
|
+
n && b(n);
|
|
29
|
+
}, [b, n]);
|
|
30
30
|
const x = y(async (e) => {
|
|
31
|
-
const
|
|
31
|
+
const m = s.id && h && e[h.name] ? s : null;
|
|
32
32
|
try {
|
|
33
|
-
await t?.buttons.submit.onSubmit({ values: e, conversation:
|
|
34
|
-
|
|
33
|
+
if (await t?.buttons.submit.onSubmit({ values: e, conversation: m }), c) {
|
|
34
|
+
const r = "name" in c;
|
|
35
|
+
p({
|
|
36
|
+
eventName: "user_escalation_indicated",
|
|
37
|
+
properties: {
|
|
38
|
+
escalationType: "support_form",
|
|
39
|
+
getHelpOptionName: r ? c?.name : void 0,
|
|
40
|
+
toolCallActionLabel: r ? void 0 : c?.label,
|
|
41
|
+
conversation: m || s
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
p({
|
|
46
|
+
eventName: "ai_chat_form_submitted",
|
|
35
47
|
properties: {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
conversation: h || s
|
|
48
|
+
conversation: m || s,
|
|
49
|
+
values: e
|
|
39
50
|
}
|
|
40
|
-
}),
|
|
41
|
-
} catch (
|
|
51
|
+
}), d(!0), t?.successView || f();
|
|
52
|
+
} catch (r) {
|
|
42
53
|
w(I, {
|
|
43
|
-
message:
|
|
54
|
+
message: r instanceof Error ? r.message : "Something went wrong."
|
|
44
55
|
});
|
|
45
56
|
}
|
|
46
|
-
}), H =
|
|
57
|
+
}), H = v?.root?.serverError;
|
|
47
58
|
return {
|
|
48
59
|
form: t,
|
|
49
|
-
openForm:
|
|
50
|
-
closeForm:
|
|
60
|
+
openForm: E,
|
|
61
|
+
closeForm: f,
|
|
51
62
|
handleSubmit: x,
|
|
52
|
-
isSuccess:
|
|
63
|
+
isSuccess: g,
|
|
53
64
|
isSubmitting: R,
|
|
54
65
|
formError: H,
|
|
55
|
-
fields:
|
|
56
|
-
errors:
|
|
57
|
-
control:
|
|
66
|
+
fields: a,
|
|
67
|
+
errors: v,
|
|
68
|
+
control: F,
|
|
58
69
|
defaultValues: n
|
|
59
70
|
};
|
|
60
71
|
}
|
|
61
72
|
const U = ({ children: t }) => {
|
|
62
|
-
const
|
|
63
|
-
return /* @__PURE__ */
|
|
73
|
+
const i = j();
|
|
74
|
+
return /* @__PURE__ */ A(_.Provider, { value: i, children: t });
|
|
64
75
|
}, W = () => {
|
|
65
|
-
const t =
|
|
76
|
+
const t = V(_);
|
|
66
77
|
if (!t)
|
|
67
78
|
throw new Error("useChatForm must be used within a ChatFormProvider");
|
|
68
79
|
return t;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/cxkit-primitives",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.109",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Inkeep, Inc. Customer License (IICL) v1.1",
|
|
6
6
|
"homepage": "",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"remark-gfm": "^4.0.1",
|
|
68
68
|
"unist-util-visit": "^5.0.0",
|
|
69
69
|
"use-sync-external-store": "^1.4.0",
|
|
70
|
-
"@inkeep/cxkit-color-mode": "^0.5.
|
|
71
|
-
"@inkeep/cxkit-theme": "0.5.
|
|
72
|
-
"@inkeep/cxkit-types": "0.5.
|
|
70
|
+
"@inkeep/cxkit-color-mode": "^0.5.109",
|
|
71
|
+
"@inkeep/cxkit-theme": "0.5.109",
|
|
72
|
+
"@inkeep/cxkit-types": "0.5.109"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@biomejs/biome": "1.9.4",
|