@inkeep/agents-ui 0.15.16 → 0.15.17
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/primitives/hooks/use-anonymous-session.cjs +1 -1
- package/dist/primitives/hooks/use-anonymous-session.js +67 -42
- package/dist/primitives/providers/base-events-provider.cjs +1 -1
- package/dist/primitives/providers/base-events-provider.js +1 -1
- package/dist/primitives/providers/chat-history-provider.cjs +1 -1
- package/dist/primitives/providers/chat-history-provider.js +32 -32
- package/dist/primitives/providers/config-provider.cjs +1 -1
- package/dist/primitives/providers/config-provider.js +21 -18
- package/dist/react/embedded-chat.cjs +1 -1
- package/dist/react/embedded-chat.js +265 -262
- package/dist/styled/components/chat-history.cjs +1 -1
- package/dist/styled/components/chat-history.js +1 -1
- package/dist/styled/components/embedded-chat/session-loading.js +1 -4
- package/dist/styled/inkeep.css.cjs +5 -3
- package/dist/styled/inkeep.css.js +5 -3
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),b=require("./use-local-storage.cjs"),_=require("./use-inkeep-api-client.cjs"),M=30*1e3,$=2147483647,D=()=>{},F=async()=>({});function C(n){return new Date(n.expiresAt).getTime()-M<=Date.now()}const L=({baseUrl:n,appId:t,getCaptchaHeader:d,invalidateCaptcha:g,optOutAllAnalytics:p})=>{const w=t&&!p?`inkeep_session_${t}`:null,[u,R]=b.useLocalStorage(w),{fetchWithAuth:k}=_.useInkeepApiClient({appId:t,authToken:void 0,getCaptchaHeader:d??F,invalidateCaptcha:g??D}),l=e.useRef(n);l.current=n;const h=e.useRef(t);h.current=t;const c=e.useRef(u);c.current=u;const S=e.useRef(R);S.current=R;const T=e.useRef(k);T.current=k;const f=e.useRef(null),s=e.useCallback(async r=>{if(!l.current||!h.current)return null;if(!r&&f.current)return f.current;const o=`${l.current}/run/auth/apps/${h.current}/anonymous-session`,a=(async()=>{try{const i={"Content-Type":"application/json"},v=c.current?.token;v&&(i.Authorization=`Bearer ${v}`);const A=await T.current(o,{method:"POST",headers:i,signal:r});if(!A.ok)throw new Error(`Failed to fetch anonymous session: ${A.status}`);const y=await A.json();return S.current({token:y.token,expiresAt:y.expiresAt}),y.token}catch(i){return i instanceof Error&&i.name==="AbortError"||console.error("[anonymous-session] fetch failed",i),null}finally{r||(f.current=null)}})();return r||(f.current=a),a},[]),E=e.useRef(!1);e.useEffect(()=>{if(!n||!t)return;const r=!E.current;if(E.current=!0,!r&&c.current&&!C(c.current)||f.current)return;const o=new AbortController;return s(o.signal),()=>o.abort()},[n,t,s]),e.useEffect(()=>{if(!n||!t||!u?.expiresAt)return;const m=new Date(u.expiresAt).getTime()-M-Date.now();if(m<=0)return;const a=setTimeout(()=>s(),Math.min(m,$));return()=>clearTimeout(a)},[n,t,u?.expiresAt,s]),e.useEffect(()=>{if(!n||!t)return;const r=()=>{if(document.visibilityState!=="visible")return;const o=c.current;(!o||C(o))&&s()};return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)},[n,t,s]);const x=e.useCallback(()=>s(),[s]);return{sessionToken:u?.token??null,refreshSession:x}};exports.useAnonymousSession=L;
|
|
@@ -1,57 +1,82 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useLocalStorage as
|
|
4
|
-
import { useInkeepApiClient as
|
|
5
|
-
const
|
|
6
|
-
},
|
|
7
|
-
|
|
2
|
+
import { useRef as s, useCallback as E, useEffect as k } from "react";
|
|
3
|
+
import { useLocalStorage as D } from "./use-local-storage.js";
|
|
4
|
+
import { useInkeepApiClient as F } from "./use-inkeep-api-client.js";
|
|
5
|
+
const M = 30 * 1e3, b = 2147483647, L = () => {
|
|
6
|
+
}, j = async () => ({});
|
|
7
|
+
function w(t) {
|
|
8
|
+
return new Date(t.expiresAt).getTime() - M <= Date.now();
|
|
9
|
+
}
|
|
10
|
+
const X = ({
|
|
11
|
+
baseUrl: t,
|
|
8
12
|
appId: e,
|
|
9
|
-
getCaptchaHeader:
|
|
10
|
-
invalidateCaptcha:
|
|
11
|
-
optOutAllAnalytics:
|
|
13
|
+
getCaptchaHeader: C,
|
|
14
|
+
invalidateCaptcha: d,
|
|
15
|
+
optOutAllAnalytics: g
|
|
12
16
|
}) => {
|
|
13
|
-
const
|
|
17
|
+
const _ = e && !g ? `inkeep_session_${e}` : null, [i, T] = D(_), { fetchWithAuth: R } = F({
|
|
14
18
|
appId: e,
|
|
15
19
|
authToken: void 0,
|
|
16
|
-
getCaptchaHeader:
|
|
17
|
-
invalidateCaptcha:
|
|
18
|
-
}),
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
getCaptchaHeader: C ?? j,
|
|
21
|
+
invalidateCaptcha: d ?? L
|
|
22
|
+
}), l = s(t);
|
|
23
|
+
l.current = t;
|
|
24
|
+
const h = s(e);
|
|
25
|
+
h.current = e;
|
|
26
|
+
const u = s(i);
|
|
27
|
+
u.current = i;
|
|
28
|
+
const S = s(T);
|
|
29
|
+
S.current = T;
|
|
30
|
+
const p = s(R);
|
|
31
|
+
p.current = R;
|
|
32
|
+
const f = s(null), r = E(async (n) => {
|
|
33
|
+
if (!l.current || !h.current) return null;
|
|
34
|
+
if (!n && f.current)
|
|
35
|
+
return f.current;
|
|
36
|
+
const o = `${l.current}/run/auth/apps/${h.current}/anonymous-session`, a = (async () => {
|
|
30
37
|
try {
|
|
31
|
-
const
|
|
38
|
+
const c = { "Content-Type": "application/json" }, x = u.current?.token;
|
|
39
|
+
x && (c.Authorization = `Bearer ${x}`);
|
|
40
|
+
const A = await p.current(o, {
|
|
32
41
|
method: "POST",
|
|
33
|
-
headers:
|
|
42
|
+
headers: c,
|
|
34
43
|
signal: n
|
|
35
44
|
});
|
|
36
|
-
if (!
|
|
37
|
-
const
|
|
38
|
-
return
|
|
39
|
-
} catch (
|
|
40
|
-
return
|
|
45
|
+
if (!A.ok) throw new Error(`Failed to fetch anonymous session: ${A.status}`);
|
|
46
|
+
const y = await A.json();
|
|
47
|
+
return S.current({ token: y.token, expiresAt: y.expiresAt }), y.token;
|
|
48
|
+
} catch (c) {
|
|
49
|
+
return c instanceof Error && c.name === "AbortError" || console.error("[anonymous-session] fetch failed", c), null;
|
|
41
50
|
} finally {
|
|
42
|
-
n || (
|
|
51
|
+
n || (f.current = null);
|
|
43
52
|
}
|
|
44
53
|
})();
|
|
45
|
-
return n || (
|
|
46
|
-
}, []);
|
|
47
|
-
|
|
48
|
-
if (!
|
|
49
|
-
const n =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
return n || (f.current = a), a;
|
|
55
|
+
}, []), v = s(!1);
|
|
56
|
+
k(() => {
|
|
57
|
+
if (!t || !e) return;
|
|
58
|
+
const n = !v.current;
|
|
59
|
+
if (v.current = !0, !n && u.current && !w(u.current) || f.current) return;
|
|
60
|
+
const o = new AbortController();
|
|
61
|
+
return r(o.signal), () => o.abort();
|
|
62
|
+
}, [t, e, r]), k(() => {
|
|
63
|
+
if (!t || !e || !i?.expiresAt) return;
|
|
64
|
+
const m = new Date(i.expiresAt).getTime() - M - Date.now();
|
|
65
|
+
if (m <= 0) return;
|
|
66
|
+
const a = setTimeout(() => r(), Math.min(m, b));
|
|
67
|
+
return () => clearTimeout(a);
|
|
68
|
+
}, [t, e, i?.expiresAt, r]), k(() => {
|
|
69
|
+
if (!t || !e) return;
|
|
70
|
+
const n = () => {
|
|
71
|
+
if (document.visibilityState !== "visible") return;
|
|
72
|
+
const o = u.current;
|
|
73
|
+
(!o || w(o)) && r();
|
|
74
|
+
};
|
|
75
|
+
return document.addEventListener("visibilitychange", n), () => document.removeEventListener("visibilitychange", n);
|
|
76
|
+
}, [t, e, r]);
|
|
77
|
+
const $ = E(() => r(), [r]);
|
|
78
|
+
return { sessionToken: i?.token ?? null, refreshSession: $ };
|
|
54
79
|
};
|
|
55
80
|
export {
|
|
56
|
-
|
|
81
|
+
X as useAnonymousSession
|
|
57
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react/jsx-runtime"),t=require("react"),l=require("./config-provider.cjs"),a=t.createContext(void 0),p=({children:e})=>{const{baseSettings:s,componentType:n}=l.useInkeepConfig(),{tags:o,analyticsProperties:r}=s,i=t.useMemo(()=>({widgetLibraryVersion:"0.15.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react/jsx-runtime"),t=require("react"),l=require("./config-provider.cjs"),a=t.createContext(void 0),p=({children:e})=>{const{baseSettings:s,componentType:n}=l.useInkeepConfig(),{tags:o,analyticsProperties:r}=s,i=t.useMemo(()=>({widgetLibraryVersion:"0.15.17",componentType:n,tags:o}),[n,o]),u={logEvent:t.useCallback(async c=>{const v={...i,...c.properties,...r},d={eventName:c.eventName,properties:v};return s.onEvent?.(d)},[s,i,r])};return E.jsx(a.Provider,{value:u,children:e})},g=()=>{const e=t.useContext(a);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=p;exports.useBaseEvents=g;
|
|
@@ -5,7 +5,7 @@ import { useInkeepConfig as g } from "./config-provider.js";
|
|
|
5
5
|
const a = d(void 0), P = ({ children: e }) => {
|
|
6
6
|
const { baseSettings: t, componentType: o } = g(), { tags: s, analyticsProperties: n } = t, r = u(
|
|
7
7
|
() => ({
|
|
8
|
-
widgetLibraryVersion: "0.15.
|
|
8
|
+
widgetLibraryVersion: "0.15.17",
|
|
9
9
|
componentType: o,
|
|
10
10
|
tags: s
|
|
11
11
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("react/jsx-runtime"),e=require("react"),Y=require("../components/embedded-chat/chat-provider.cjs"),N=require("./config-provider.cjs"),ee=require("../hooks/use-inkeep-api-client.cjs"),F=e.createContext(void 0),D=25;function te(t){const{stop:a,clear:c,conversationId:u,isStreaming:H,loadAndRestoreSession:P,sessionToken:f,refreshSession:W,getCaptchaHeader:G,invalidateCaptcha:K}=Y.useChat(),{aiChatSettings:U}=N.useInkeepConfig(),{baseUrl:h,appId:k,apiKey:Z}=U,
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("react/jsx-runtime"),e=require("react"),Y=require("../components/embedded-chat/chat-provider.cjs"),N=require("./config-provider.cjs"),ee=require("../hooks/use-inkeep-api-client.cjs"),F=e.createContext(void 0),D=25;function te(t){const{stop:a,clear:c,conversationId:u,isStreaming:H,loadAndRestoreSession:P,sessionToken:f,refreshSession:W,getCaptchaHeader:G,invalidateCaptcha:K}=Y.useChat(),{aiChatSettings:U}=N.useInkeepConfig(),{baseUrl:h,appId:k,apiKey:Z}=U,o=!Z&&!!k,C=f,{fetchWithAuth:I}=ee.useInkeepApiClient({appId:k,authToken:C,getCaptchaHeader:G,invalidateCaptcha:K,refreshSession:W}),[p,S]=e.useState(!1),[R,E]=e.useState([]),[g,x]=e.useState(!1),[m,_]=e.useState(0),[v,z]=e.useState(!1),b=e.useRef(!1),q=e.useRef(null),j=e.useRef([]);j.current=R;const M=e.useRef(I);M.current=I;const i=e.useCallback(async(s,n=!1)=>{if(!(!h||!C||!o)){n||x(!0);try{const w=`${h}/run/v1/conversations?page=${s+1}&limit=${D}`,y=await M.current(w);if(!y.ok)throw new Error(`Failed to fetch conversations: ${y.status}`);const L=await y.json(),d=(L.data??[]).map(r=>({id:r.id,title:r.title??"",createdAt:new Date(r.createdAt),updatedAt:new Date(r.updatedAt)}));E(r=>{if(s===0&&!n)return d;if(s===0&&n){const l=new Set(d.map(A=>A.id));return[...d,...r.slice(D).filter(A=>!l.has(A.id))]}const V=new Set(r.map(l=>l.id));return[...r,...d.filter(l=>!V.has(l.id))]});const{page:O,pages:T}=L.pagination??{};z(O!=null&&T!=null?O<T:!1),n||_(s)}catch(w){console.error("[useChatHistory] Failed to load conversations:",w)}finally{x(!1)}}},[h,C,o]);e.useEffect(()=>{!p||!f||!o||(t==="stack"?(E([]),i(0)):b.current||(b.current=!0,i(0)))},[p,f,o,t,i]);const $=e.useRef("");e.useEffect(()=>{o&&t==="sidepane"&&(!u||!H||b.current&&$.current!==u&&(j.current.some(s=>s.id===u)||($.current=u,i(0,!0))))},[u,o,t,i,H]);const B=e.useCallback(()=>{!g&&v&&i(m+1)},[g,v,m,i]),J=e.useCallback(()=>{a(),c(),t!=="sidepane"&&S(!1)},[t,a,c]),Q=e.useCallback(async s=>{q.current?.abort();const n=new AbortController;q.current=n,await P(s,n.signal),!n.signal.aborted&&t!=="sidepane"&&S(!1)},[t,P]);return{isEnabled:o,isOpen:p,setIsOpen:S,sessions:R,isLoading:g,hasMore:v,loadMore:B,startNewConversation:J,loadSession:Q}}const se=({layout:t,children:a})=>{const c=te(t);return X.jsx(F.Provider,{value:c,children:typeof a=="function"?a(c):a})},ne=()=>{const t=e.useContext(F);if(!t)throw new Error("useChatHistory must be used within a ChatHistoryProvider");return t};exports.ChatHistoryProvider=se;exports.useChatHistory=ne;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as tt } from "react/jsx-runtime";
|
|
3
|
-
import { createContext as et, useContext as st, useState as
|
|
3
|
+
import { createContext as et, useContext as st, useState as f, useRef as d, useCallback as h, useEffect as G } from "react";
|
|
4
4
|
import { useChat as nt } from "../components/embedded-chat/chat-provider.js";
|
|
5
5
|
import { useInkeepConfig as rt } from "./config-provider.js";
|
|
6
6
|
import { useInkeepApiClient as ot } from "../hooks/use-inkeep-api-client.js";
|
|
@@ -16,70 +16,70 @@ function it(t) {
|
|
|
16
16
|
refreshSession: Z,
|
|
17
17
|
getCaptchaHeader: _,
|
|
18
18
|
invalidateCaptcha: q
|
|
19
|
-
} = nt(), { aiChatSettings: z } = rt(), { baseUrl: C, appId: k, apiKey: B } = z,
|
|
19
|
+
} = nt(), { aiChatSettings: z } = rt(), { baseUrl: C, appId: k, apiKey: B } = z, r = !B && !!k, g = p, { fetchWithAuth: x } = ot({
|
|
20
20
|
appId: k,
|
|
21
21
|
authToken: g,
|
|
22
22
|
getCaptchaHeader: _,
|
|
23
23
|
invalidateCaptcha: q,
|
|
24
24
|
refreshSession: Z
|
|
25
|
-
}), [w, m] =
|
|
25
|
+
}), [w, m] = f(!1), [E, $] = f([]), [S, L] = f(!1), [M, J] = f(0), [v, Q] = f(!1), A = d(!1), R = d(null), j = d([]);
|
|
26
26
|
j.current = E;
|
|
27
27
|
const D = d(x);
|
|
28
28
|
D.current = x;
|
|
29
|
-
const
|
|
30
|
-
async (e,
|
|
31
|
-
if (!(!C || !g || !
|
|
32
|
-
|
|
29
|
+
const o = h(
|
|
30
|
+
async (e, s = !1) => {
|
|
31
|
+
if (!(!C || !g || !r)) {
|
|
32
|
+
s || L(!0);
|
|
33
33
|
try {
|
|
34
34
|
const b = `${C}/run/v1/conversations?page=${e + 1}&limit=${K}`, H = await D.current(b);
|
|
35
35
|
if (!H.ok) throw new Error(`Failed to fetch conversations: ${H.status}`);
|
|
36
|
-
const O = await H.json(), l = (O.data ?? []).map((
|
|
37
|
-
id:
|
|
38
|
-
title:
|
|
39
|
-
createdAt: new Date(
|
|
40
|
-
updatedAt: new Date(
|
|
36
|
+
const O = await H.json(), l = (O.data ?? []).map((n) => ({
|
|
37
|
+
id: n.id,
|
|
38
|
+
title: n.title ?? "",
|
|
39
|
+
createdAt: new Date(n.createdAt),
|
|
40
|
+
updatedAt: new Date(n.updatedAt)
|
|
41
41
|
}));
|
|
42
|
-
|
|
43
|
-
if (e === 0 && !
|
|
44
|
-
if (e === 0 &&
|
|
45
|
-
const
|
|
46
|
-
return [...l, ...
|
|
42
|
+
$((n) => {
|
|
43
|
+
if (e === 0 && !s) return l;
|
|
44
|
+
if (e === 0 && s) {
|
|
45
|
+
const u = new Set(l.map((I) => I.id));
|
|
46
|
+
return [...l, ...n.slice(K).filter((I) => !u.has(I.id))];
|
|
47
47
|
}
|
|
48
|
-
const N = new Set(
|
|
49
|
-
return [...
|
|
48
|
+
const N = new Set(n.map((u) => u.id));
|
|
49
|
+
return [...n, ...l.filter((u) => !N.has(u.id))];
|
|
50
50
|
});
|
|
51
51
|
const { page: T, pages: W } = O.pagination ?? {};
|
|
52
|
-
Q(T != null && W != null ? T < W : !1),
|
|
52
|
+
Q(T != null && W != null ? T < W : !1), s || J(e);
|
|
53
53
|
} catch (b) {
|
|
54
54
|
console.error("[useChatHistory] Failed to load conversations:", b);
|
|
55
55
|
} finally {
|
|
56
|
-
|
|
56
|
+
L(!1);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
-
[C, g,
|
|
60
|
+
[C, g, r]
|
|
61
61
|
);
|
|
62
62
|
G(() => {
|
|
63
|
-
!w || !p || !
|
|
64
|
-
}, [w, p,
|
|
63
|
+
!w || !p || !r || (t === "stack" ? ($([]), o(0)) : A.current || (A.current = !0, o(0)));
|
|
64
|
+
}, [w, p, r, t, o]);
|
|
65
65
|
const F = d("");
|
|
66
66
|
G(() => {
|
|
67
|
-
|
|
68
|
-
}, [c,
|
|
67
|
+
r && t === "sidepane" && (!c || !y || A.current && F.current !== c && (j.current.some((e) => e.id === c) || (F.current = c, o(0, !0))));
|
|
68
|
+
}, [c, r, t, o, y]);
|
|
69
69
|
const V = h(() => {
|
|
70
|
-
!S && v &&
|
|
71
|
-
}, [S, v,
|
|
70
|
+
!S && v && o(M + 1);
|
|
71
|
+
}, [S, v, M, o]), X = h(() => {
|
|
72
72
|
i(), a(), t !== "sidepane" && m(!1);
|
|
73
73
|
}, [t, i, a]), Y = h(
|
|
74
74
|
async (e) => {
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
75
|
+
R.current?.abort();
|
|
76
|
+
const s = new AbortController();
|
|
77
|
+
R.current = s, await P(e, s.signal), !s.signal.aborted && t !== "sidepane" && m(!1);
|
|
78
78
|
},
|
|
79
79
|
[t, P]
|
|
80
80
|
);
|
|
81
81
|
return {
|
|
82
|
-
isEnabled:
|
|
82
|
+
isEnabled: r,
|
|
83
83
|
isOpen: w,
|
|
84
84
|
setIsOpen: m,
|
|
85
85
|
sessions: E,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime"),b=require("merge-anything"),r=require("react"),n=require("../utils/default-settings.cjs"),f=require("../atoms/shadow/context.cjs"),s={ChatButton:"ChatButton",CustomTrigger:"CustomTrigger",SearchBar:"SearchBar",EmbeddedChat:"EmbeddedChat",EmbeddedSearch:"EmbeddedSearch",EmbeddedSearchAndChat:"EmbeddedSearchAndChat",SidebarChat:"SidebarChat"},o={prefix:"ikp",aiChatSettings:n.defaultInkeepAIChatSettings,baseSettings:n.defaultInkeepBaseSettings,searchSettings:n.defaultInkeepSearchSettings,componentType:s.EmbeddedChat},d=r.createContext(o),p=({children:t,value:i})=>{const c=f.useShadow(),g=(e,a,C)=>["baseSettings","searchSettings","aiChatSettings"].includes(C)&&!a?e:a,u={baseSettings:c??{}},h=r.useMemo(()=>{const e=b.mergeAndCompare(g,o,u,i??{});return e.aiChatSettings?.baseUrl&&(e.aiChatSettings.baseUrl=e.aiChatSettings.baseUrl.replace(/\/+$/,"")),e},[i]);return S.jsx(d.Provider,{value:h,children:t})},m=()=>{const t=r.useContext(d);if(!t)throw new Error("useInkeepConfig must be used within a ConfigProvider");return t};exports.InkeepConfigProvider=p;exports.WebWidgetInteractionType=s;exports.useInkeepConfig=m;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { mergeAndCompare as
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import { defaultInkeepSearchSettings as
|
|
6
|
-
import { useShadow as
|
|
7
|
-
const
|
|
2
|
+
import { jsx as C } from "react/jsx-runtime";
|
|
3
|
+
import { mergeAndCompare as g } from "merge-anything";
|
|
4
|
+
import { useMemo as m, createContext as S, useContext as u } from "react";
|
|
5
|
+
import { defaultInkeepSearchSettings as f, defaultInkeepBaseSettings as p, defaultInkeepAIChatSettings as b } from "../utils/default-settings.js";
|
|
6
|
+
import { useShadow as l } from "../atoms/shadow/context.js";
|
|
7
|
+
const I = {
|
|
8
8
|
ChatButton: "ChatButton",
|
|
9
9
|
CustomTrigger: "CustomTrigger",
|
|
10
10
|
SearchBar: "SearchBar",
|
|
@@ -12,26 +12,29 @@ const k = {
|
|
|
12
12
|
EmbeddedSearch: "EmbeddedSearch",
|
|
13
13
|
EmbeddedSearchAndChat: "EmbeddedSearchAndChat",
|
|
14
14
|
SidebarChat: "SidebarChat"
|
|
15
|
-
},
|
|
15
|
+
}, a = {
|
|
16
16
|
prefix: "ikp",
|
|
17
17
|
// Default prefix
|
|
18
18
|
aiChatSettings: b,
|
|
19
|
-
baseSettings:
|
|
20
|
-
searchSettings:
|
|
21
|
-
componentType:
|
|
22
|
-
},
|
|
23
|
-
const i =
|
|
19
|
+
baseSettings: p,
|
|
20
|
+
searchSettings: f,
|
|
21
|
+
componentType: I.EmbeddedChat
|
|
22
|
+
}, o = S(a), A = ({ children: t, value: n }) => {
|
|
23
|
+
const i = l(), s = (e, r, h) => ["baseSettings", "searchSettings", "aiChatSettings"].includes(h) && !r ? e : r, d = {
|
|
24
24
|
baseSettings: i ?? {}
|
|
25
|
-
}, c =
|
|
26
|
-
|
|
25
|
+
}, c = m(() => {
|
|
26
|
+
const e = g(s, a, d, n ?? {});
|
|
27
|
+
return e.aiChatSettings?.baseUrl && (e.aiChatSettings.baseUrl = e.aiChatSettings.baseUrl.replace(/\/+$/, "")), e;
|
|
28
|
+
}, [n]);
|
|
29
|
+
return /* @__PURE__ */ C(o.Provider, { value: c, children: t });
|
|
27
30
|
}, T = () => {
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
31
|
+
const t = u(o);
|
|
32
|
+
if (!t)
|
|
30
33
|
throw new Error("useInkeepConfig must be used within a ConfigProvider");
|
|
31
|
-
return
|
|
34
|
+
return t;
|
|
32
35
|
};
|
|
33
36
|
export {
|
|
34
37
|
A as InkeepConfigProvider,
|
|
35
|
-
|
|
38
|
+
I as WebWidgetInteractionType,
|
|
36
39
|
T as useInkeepConfig
|
|
37
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),m=require("react"),t=require("../styled/components/embedded-chat.cjs"),c=require("../styled/components/chat-history.cjs"),j=require("../styled/components/modal.cjs"),k=require("../styled/components/shadow.cjs"),b=require("../styled/components/message.cjs"),T=require("../primitives/providers/chat-history-provider.cjs"),u=require("../primitives/providers/config-provider.cjs"),B=require("../primitives/providers/root-provider.cjs"),y=require("../primitives/providers/widget-provider.cjs"),C=require("../primitives/components/embedded-chat/chat-provider.cjs"),S=require("../primitives/components/modal/modal-provider.cjs"),h=require("../primitives/utils/misc.cjs"),F=require("../primitives/atoms/portal-with-theme.cjs"),H=require("../primitives/atoms/error-boundary.cjs"),E=require("./modal.cjs"),v=require("./widget-toggle.cjs");function w(r){const{baseSettings:s,aiChatSettings:n}=r;return e.jsx(H.ErrorBoundary,{children:e.jsx(k.Shadow,{wrapperStyles:{height:"inherit",width:"inherit"},children:e.jsx(B.RootProvider,{config:{baseSettings:s,aiChatSettings:n},componentType:u.WebWidgetInteractionType.EmbeddedChat,children:e.jsx(A,{...r})})})})}function I(r){const{children:s,onToggleView:n,isHidden:o,shouldAutoFocusInput:i=!n}=r;return e.jsx(t.Provider,{isHidden:o,shouldAutoFocusInput:i,children:s})}function A(r){return e.jsx(I,{...r,children:e.jsx(M,{...r})})}function M(r){const{onToggleView:s,variant:n,header:o=f}=r,i=S.useModal(),d=y.useWidget(),a=i&&!d?E.ModalContent:m.Fragment;return e.jsx(a,{children:e.jsxs(t.Wrapper,{variant:n??(s?"no-shadow":"container-with-shadow"),"data-composite":h.dataAttr(!!r.onToggleView||i?.isOpen),children:[e.jsx(Q,{}),e.jsxs(t.Root,{children:[o&&e.jsx(o,{...r}),e.jsx(L,{}),e.jsx(V,{})]}),e.jsx(R,{}),e.jsx($,{})]})})}const f=r=>{const{onToggleView:s,askAILabel:n,searchLabel:o}=r,{aiChatSettings:i}=u.useInkeepConfig(),d=i.isChatHistoryButtonVisible,a=!!s||d;return e.jsx(t.Header,{"data-show-toolbar":h.dataAttr(a),children:a?e.jsxs(t.HeaderToolbar,{"data-show-widget-toggle":h.dataAttr(!!s),children:[e.jsx(t.HeaderToolbarWrapper,{children:d&&e.jsx(t.ChatHistoryTrigger,{})}),s&&e.jsx(v.WidgetToggle,{onToggleView:s,askAILabel:n,searchLabel:o,view:"chat"}),e.jsx(j.Close,{})]}):e.jsx(j.Close,{})})};function L(){const{isSessionLoading:r}=C.useChat();return e.jsx(t.Content,{children:e.jsxs(t.ContentScrollArea,{children:[e.jsx(t.ContentScrollAreaViewport,{children:r?e.jsx(t.MessagesSessionLoading,{}):e.jsx(P,{})}),e.jsx(t.ContentScrollAreaScrollbar,{children:e.jsx(t.ContentScrollAreaThumb,{})}),e.jsx(t.ContentScrollAreaCorner,{})]})})}function P(){const{aiChatSettings:{components:r}}=u.useInkeepConfig();return e.jsx(t.Messages,{children:({messages:s,isLoading:n})=>{const o=s.at(-1),i=(a,g)=>{const l=r?.[a];if(!l)return console.warn(`Component "${a}" not found in components config`),null;try{if(typeof l=="function"&&l.length<=1)return m.createElement(l,g);const x=l(g,document.createElement("div"),null);return m.isValidElement(x)||typeof x=="string"?x:null}catch(x){return console.error(`🔍 [renderComponent] Error rendering component "${a}":`,x),null}},d=a=>e.jsx(t.Markdown,{text:a});return e.jsxs(e.Fragment,{children:[e.jsx(D,{}),s.map(a=>e.jsxs(t.MessageWrapper,{message:a,children:[e.jsx(p,{}),e.jsxs(t.MessageContentWrapper,{children:[e.jsx(t.MessageContent,{children:r?.IkpMessage?e.jsx(t.DynamicComponent,{name:"IkpMessage",props:{message:a,renderComponent:i,renderMarkdown:d},componentDef:r.IkpMessage}):e.jsxs(e.Fragment,{children:[e.jsx(b.EmbeddedChatMessagePart,{isLast:o?.id===a.id}),e.jsx(_,{})]})}),e.jsx(W,{}),e.jsx(q,{})]})]},a.id)),n&&o?.parts.length&&e.jsxs(t.MessageWrapper,{message:{id:"___loader___",role:"assistant",parts:[{type:"text",text:"Thinking..."}]},children:[e.jsx(p,{}),e.jsx(t.MessageLoading,{})]})]})}})}function D(){return e.jsxs(t.IntroMessageWrapper,{children:[e.jsxs(t.MessageHeader,{children:[e.jsx(t.MessageAvatar,{children:e.jsx(t.MessageAvatarContent,{children:e.jsx(t.MessageAvatarImage,{})})}),e.jsx(t.MessageName,{})]}),e.jsxs(t.MessageContentWrapper,{children:[e.jsx(t.MessageContent,{children:e.jsx(b.EmbeddedChatMessagePart,{isLast:!1})}),e.jsxs(t.Disclaimer,{children:[e.jsx(t.DisclaimerLabel,{}),e.jsx(t.DisclaimerTrigger,{}),e.jsxs(t.DisclaimerContent,{children:[e.jsx(t.DisclaimerText,{}),e.jsx(t.DisclaimerArrow,{})]})]}),e.jsxs(t.ExampleQuestions,{children:[e.jsx(t.ExampleQuestionsLabel,{}),e.jsx(t.ExampleQuestionsList,{children:r=>r.map(s=>e.jsx(t.ExampleQuestion,{children:e.jsx(t.ExampleQuestionButton,{question:s})},typeof s=="object"?s.label:s))})]})]})]})}function p(){return e.jsxs(t.MessageHeader,{children:[e.jsx(t.MessageAvatar,{children:e.jsx(t.MessageAvatarContent,{children:e.jsx(t.MessageAvatarImage,{})})}),e.jsx(t.MessageName,{})]})}function W(){return e.jsxs(t.MessageAttachments,{children:[e.jsx(t.MessageAttachmentsList,{children:r=>r.map(s=>e.jsxs(t.MessageAttachmentsItem,{attachment:s,children:[e.jsx(t.MessageAttachmentsItemIcon,{}),e.jsx(t.MessageAttachmentsItemTitle,{})]},s.id))}),e.jsx(t.MessageAttachmentsPreview,{children:e.jsx(F.PortalWithTheme,{children:e.jsx(t.MessageAttachmentsPreviewOverlay,{children:e.jsxs(t.MessageAttachmentsPreviewContent,{children:[e.jsx(t.MessageAttachmentsPreviewHeader,{}),e.jsx(t.MessageAttachmentsPreviewClose,{}),e.jsx(t.MessageAttachmentsPreviewBody,{})]})})})})]})}function q(){return e.jsxs(t.MessageToolbar,{children:[e.jsx(t.MessageCustomActions,{children:r=>r.map((s,n)=>e.jsx(t.MessageCustomAction,{action:s},`action-${n}`))}),e.jsx(t.MessageAction,{action:"copy"}),e.jsx(t.MessageAction,{action:"upvote"}),e.jsx(t.MessageAction,{action:"downvote"})]})}function _(){return e.jsxs(t.MessageSources,{children:[e.jsx(t.MessageSourcesHeader,{}),e.jsx(t.MessageSourcesList,{children:r=>r.map((s,n)=>e.jsxs(t.MessageSourceItem,{href:s.url,source:s,children:[e.jsx(t.MessageSourceItemBreadcrumbs,{children:s.breadcrumbs?.map(o=>e.jsxs(m.Fragment,{children:[o,e.jsx(t.MessageSourceItemBreadcrumbIcon,{})]},o))}),e.jsx(t.MessageSourceItemIcon,{}),e.jsx(t.MessageSourceItemTitle,{}),e.jsx(t.MessageSourceItemTag,{}),e.jsx(t.MessageSourceItemDescription,{children:o=>o.map((i,d)=>e.jsx(t.MessageSourceItemDescriptionPart,{part:i},`part-${d}`))}),e.jsx(t.MessageSourceItemIndicator,{})]},n))})]})}function V(){return e.jsxs(t.Footer,{children:[e.jsx(N,{}),e.jsx(O,{})]})}function N(){return e.jsxs(t.InputFieldset,{children:[e.jsxs(t.InputGroup,{children:[e.jsx(t.Input,{}),e.jsx(t.SendButton,{children:e.jsx(t.SendButtonIcon,{})})]}),e.jsxs(t.AttachmentsBar,{children:[e.jsx(t.AttachmentsBarList,{children:r=>r.map(s=>e.jsxs(t.AttachmentsBarAttachment,{attachment:s,children:[e.jsx(t.AttachmentsBarAttachmentIcon,{}),e.jsx(t.AttachmentsBarAttachmentTitle,{}),e.jsx(t.AttachmentsBarAttachmentDelete,{})]},s.id))}),e.jsxs(t.AttachmentsBarActions,{children:[e.jsxs(t.AttachmentsBarInfoTip,{children:[e.jsx(t.AttachmentsBarInfoTipIcon,{}),e.jsx(t.AttachmentsBarInfoTipText,{})]}),e.jsx(t.AttachmentsBarInputs,{children:r=>r.map(s=>e.jsx(t.AttachmentsBarInput,{input:s,children:s.displayName},s.id))})]}),e.jsx(F.PortalWithTheme,{children:e.jsx(t.AttachmentsBarModal,{children:e.jsx(t.AttachmentsBarModalOverlay,{children:e.jsxs(t.AttachmentsBarModalContent,{children:[e.jsxs(t.AttachmentsBarModalHeader,{children:[e.jsx(t.AttachmentsBarModalHeading,{}),e.jsx(t.AttachmentsBarModalDescription,{}),e.jsx(t.AttachmentsBarModalHelp,{})]}),e.jsx(t.AttachmentsBarModalClose,{}),e.jsx(t.AttachmentsBarModalBody,{children:e.jsxs(t.AttachmentsBarForm,{children:[e.jsxs(t.AttachmentsBarFormTitle,{children:[e.jsx(t.AttachmentsBarFormTitleLabel,{}),e.jsx(t.AttachmentsBarFormTitleInput,{}),e.jsx(t.AttachmentsBarFormTitleError,{})]}),e.jsxs(t.AttachmentsBarFormContent,{children:[e.jsx(t.AttachmentsBarFormContentLabel,{}),e.jsx(t.AttachmentsBarFormContentInput,{}),e.jsx(t.AttachmentsBarFormContentError,{})]}),e.jsx(t.AttachmentsBarFormSubmitButton,{})]})})]})})})})]})]})}function O(){return e.jsxs(t.ActionBar,{children:[e.jsxs(t.TaglineContainer,{children:[e.jsx(t.TaglineText,{}),e.jsx(t.TaglineLogo,{}),e.jsx(t.TaglineBrandName,{})]}),e.jsxs(t.Actions,{children:[e.jsx(t.HelpActions,{children:({pinned:r,unpinned:s})=>e.jsxs(e.Fragment,{children:[r.map(n=>e.jsx(t.HelpAction,{action:n},n.name)),s.length>0&&e.jsx(t.HelpActionsTrigger,{}),e.jsxs(t.HelpActionsMenu,{children:[e.jsx(t.HelpActionsMenuArrow,{}),s.map(n=>e.jsxs(t.HelpActionsMenuItem,{action:n,children:[e.jsx(t.HelpActionsMenuItemIcon,{action:n}),n.name]},n.name))]})]})}),e.jsxs(t.ChatAction,{action:"copy",children:[e.jsx(t.ChatActionLabel,{action:"copy"}),e.jsx(t.ChatActionFeedback,{action:"copy"})]}),e.jsx(t.ChatAction,{action:"clear"}),e.jsx(t.ChatAction,{action:"stop"})]})]})}function Q(){const{sessions:r}=T.useChatHistory(),{conversationId:s}=C.useChat();return e.jsxs(c.EmbeddedChatHistoryRoot,{children:[e.jsxs(c.EmbeddedChatHistoryHeader,{children:[e.jsxs(c.EmbeddedChatHistoryBackButton,{children:[e.jsx(c.EmbeddedChatHistoryBackButtonIcon,{iconKey:"backToChat"}),"Back to chat"]}),e.jsx(c.EmbeddedChatHistoryTitle,{}),e.jsx(j.Close,{})]}),e.jsxs(c.EmbeddedChatHistoryList,{children:[r.map(n=>e.jsxs(c.EmbeddedChatHistoryItem,{sessionId:n.id,"data-active":h.dataAttr(n.id===s),children:[e.jsx(c.EmbeddedChatHistoryItemTitle,{children:n.title}),e.jsx(c.EmbeddedChatHistoryItemDate,{children:c.formatSessionDate(n.updatedAt)})]},n.id)),e.jsx(c.EmbeddedChatHistoryEmptyState,{}),e.jsx(c.EmbeddedChatHistoryLoadingState,{})]}),e.jsx(c.EmbeddedChatHistoryFooter,{children:e.jsx(c.EmbeddedChatHistoryNewConversationButton,{})})]})}function R(){return e.jsx(F.PortalWithTheme,{children:e.jsx(t.FeedbackModal,{children:e.jsx(t.FeedbackModalOverlay,{children:e.jsxs(t.FeedbackModalContent,{children:[e.jsx(t.FeedbackModalHeader,{}),e.jsx(t.FeedbackModalClose,{}),e.jsx(t.FeedbackModalBody,{children:e.jsxs(t.FeedbackForm,{children:[e.jsxs(t.FeedbackItem,{name:"unrelated_response",children:[e.jsx(t.FeedbackItemCheckbox,{children:e.jsx(t.FeedbackItemCheckboxIndicator,{})}),e.jsx(t.FeedbackItemLabel,{}),e.jsx(t.FeedbackItemDescription,{})]}),e.jsxs(t.FeedbackItem,{name:"inaccurate_statement",children:[e.jsx(t.FeedbackItemCheckbox,{children:e.jsx(t.FeedbackItemCheckboxIndicator,{})}),e.jsx(t.FeedbackItemLabel,{}),e.jsx(t.FeedbackItemDescription,{})]}),e.jsxs(t.FeedbackItem,{name:"inaccurate_code_snippet",children:[e.jsx(t.FeedbackItemCheckbox,{children:e.jsx(t.FeedbackItemCheckboxIndicator,{})}),e.jsx(t.FeedbackItemLabel,{}),e.jsx(t.FeedbackItemDescription,{})]}),e.jsxs(t.FeedbackItem,{name:"irrelevant_citations",children:[e.jsx(t.FeedbackItemCheckbox,{children:e.jsx(t.FeedbackItemCheckboxIndicator,{})}),e.jsx(t.FeedbackItemLabel,{})]}),e.jsx(t.FeedbackSubmitButton,{})]})})]})})})})}function $(){return e.jsxs(t.FormWrapper,{children:[e.jsx(t.FormClose,{}),e.jsxs(t.Form,{children:[e.jsxs(t.FormHeader,{children:[e.jsx(t.FormHeading,{}),e.jsx(t.FormDescription,{})]}),e.jsx(t.FormContent,{children:r=>e.jsxs(e.Fragment,{children:[r.map((s,n)=>e.jsxs(t.FormField,{field:s,autoFocus:n===0,children:[e.jsx(t.FormFieldLabel,{}),s.inputType==="text"&&e.jsx(t.FormFieldText,{}),s.inputType==="email"&&e.jsx(t.FormFieldEmail,{}),s.inputType==="file"&&e.jsx(t.FormFieldFile,{}),s.inputType==="textarea"&&e.jsx(t.FormFieldTextArea,{}),s.inputType==="checkbox"&&e.jsx(t.FormFieldCheckbox,{children:e.jsx(t.FormFieldCheckboxIndicator,{})}),s.inputType==="select"&&e.jsxs(t.FormFieldSelect,{children:[e.jsxs(t.FormFieldSelectTrigger,{children:[e.jsx(t.FormFieldSelectValue,{}),e.jsx(t.FormFieldSelectIcon,{})]}),e.jsx(t.FormFieldSelectContent,{children:e.jsx(t.FormFieldSelectViewport,{children:s.items.map(o=>e.jsxs(t.FormFieldSelectItem,{value:o.value,children:[e.jsx(t.FormFieldSelectItemText,{children:o.label}),e.jsx(t.FormFieldSelectItemIndicator,{})]},o.value))})})]}),s.inputType==="combobox"&&e.jsxs(t.FormFieldCombobox,{children:[e.jsxs(t.FormFieldComboboxControl,{children:["multiple"in s&&s.multiple&&e.jsx(t.FormFieldComboboxSelectedTags,{}),e.jsx(t.FormFieldComboboxInput,{}),e.jsx(t.FormFieldComboboxTrigger,{})]}),e.jsx(t.FormFieldComboboxPositioner,{children:e.jsx(t.FormFieldComboboxContent,{children:e.jsx(t.FormFieldComboboxList,{children:e.jsx(t.FormFieldComboboxListItems,{children:o=>o.length===0?e.jsx(t.FormFieldComboboxListEmpty,{}):o.map(i=>e.jsxs(t.FormFieldComboboxItem,{item:i,children:[e.jsx(t.FormFieldComboboxItemText,{children:i.label}),e.jsx(t.FormFieldComboboxItemIndicator,{})]},i.value))})})})})]}),e.jsx(t.FormFieldDescription,{}),e.jsx(t.FormFieldError,{})]},s.name)),e.jsx(t.FormError,{})]})}),e.jsxs(t.FormFooter,{children:[e.jsx(t.FormCancel,{}),e.jsx(t.FormSubmit,{})]})]}),e.jsxs(t.FormSuccess,{children:[e.jsx(t.FormSuccessHeading,{}),e.jsx(t.FormSuccessMessage,{}),e.jsx(t.FormSuccessButton,{})]})]})}exports.InkeepEmbeddedChat=w;exports.InkeepEmbeddedChatImpl=A;exports.InkeepEmbeddedChatImplContent=M;exports.InkeepEmbeddedChatProvider=I;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("react"),t=require("../styled/components/embedded-chat.cjs"),i=require("../styled/components/chat-history.cjs"),F=require("../styled/components/modal.cjs"),T=require("../styled/components/shadow.cjs"),C=require("../styled/components/message.cjs"),B=require("../primitives/providers/chat-history-provider.cjs"),g=require("../primitives/providers/config-provider.cjs"),y=require("../primitives/providers/root-provider.cjs"),S=require("../primitives/providers/widget-provider.cjs"),I=require("../primitives/components/embedded-chat/chat-provider.cjs"),H=require("../primitives/components/modal/modal-provider.cjs"),u=require("../primitives/utils/misc.cjs"),p=require("../primitives/atoms/portal-with-theme.cjs"),E=require("../primitives/atoms/error-boundary.cjs"),v=require("./modal.cjs"),w=require("./widget-toggle.cjs");function f(r){const{baseSettings:s,aiChatSettings:n}=r;return e.jsx(E.ErrorBoundary,{children:e.jsx(T.Shadow,{wrapperStyles:{height:"inherit",width:"inherit"},children:e.jsx(y.RootProvider,{config:{baseSettings:s,aiChatSettings:n},componentType:g.WebWidgetInteractionType.EmbeddedChat,children:e.jsx(M,{...r})})})})}function A(r){const{children:s,onToggleView:n,isHidden:o,shouldAutoFocusInput:a=!n}=r;return e.jsx(t.Provider,{isHidden:o,shouldAutoFocusInput:a,children:s})}function M(r){return e.jsx(A,{...r,children:e.jsx(k,{...r})})}function k(r){const{onToggleView:s,variant:n,header:o=L}=r,a=H.useModal(),d=S.useWidget(),l=a&&!d?v.ModalContent:j.Fragment;return e.jsx(l,{children:e.jsxs(t.Wrapper,{variant:n??(s?"no-shadow":"container-with-shadow"),"data-composite":u.dataAttr(!!r.onToggleView||a?.isOpen),children:[e.jsx(R,{}),e.jsxs(t.Root,{children:[o&&e.jsx(o,{...r}),e.jsx(P,{}),e.jsx(N,{})]}),e.jsx($,{}),e.jsx(G,{})]})})}const L=r=>{const{onToggleView:s,askAILabel:n,searchLabel:o}=r,{aiChatSettings:a}=g.useInkeepConfig(),d=a.isChatHistoryButtonVisible,l=!!s||d;return e.jsx(t.Header,{"data-show-toolbar":u.dataAttr(l),children:l?e.jsxs(t.HeaderToolbar,{"data-show-widget-toggle":u.dataAttr(!!s),children:[e.jsx(t.HeaderToolbarWrapper,{children:d&&e.jsx(t.ChatHistoryTrigger,{})}),s&&e.jsx(w.WidgetToggle,{onToggleView:s,askAILabel:n,searchLabel:o,view:"chat"}),e.jsx(F.Close,{})]}):e.jsx(F.Close,{})})};function P(){const{isSessionLoading:r}=I.useChat();return e.jsx(t.Content,{children:e.jsxs(t.ContentScrollArea,{children:[e.jsx(t.ContentScrollAreaViewport,{children:r?e.jsx(t.MessagesSessionLoading,{}):e.jsx(D,{})}),e.jsx(t.ContentScrollAreaScrollbar,{children:e.jsx(t.ContentScrollAreaThumb,{})}),e.jsx(t.ContentScrollAreaCorner,{})]})})}function D(){const{aiChatSettings:{components:r}}=g.useInkeepConfig();return e.jsx(t.Messages,{children:({messages:s,isLoading:n,isStreaming:o})=>{const a=s.at(-1),d=(c,x)=>{const m=r?.[c];if(!m)return console.warn(`Component "${c}" not found in components config`),null;try{if(typeof m=="function"&&m.length<=1)return j.createElement(m,x);const h=m(x,document.createElement("div"),null);return j.isValidElement(h)||typeof h=="string"?h:null}catch(h){return console.error(`🔍 [renderComponent] Error rendering component "${c}":`,h),null}},l=c=>e.jsx(t.Markdown,{text:c});return e.jsxs(e.Fragment,{children:[e.jsx(W,{}),s.map(c=>{const x=a?.id===c.id;return e.jsxs(t.MessageWrapper,{message:c,children:[e.jsx(b,{}),e.jsxs(t.MessageContentWrapper,{children:[e.jsx(t.MessageContent,{children:r?.IkpMessage?e.jsx(t.DynamicComponent,{name:"IkpMessage",props:{message:c,renderComponent:d,renderMarkdown:l},componentDef:r.IkpMessage}):e.jsxs(e.Fragment,{children:[e.jsx(C.EmbeddedChatMessagePart,{isLast:x}),(!o||!x)&&e.jsx(V,{})]})}),e.jsx(q,{}),e.jsx(_,{})]})]},c.id)}),n&&a?.parts.length&&e.jsxs(t.MessageWrapper,{message:{id:"___loader___",role:"assistant",parts:[{type:"text",text:"Thinking..."}]},children:[e.jsx(b,{}),e.jsx(t.MessageLoading,{})]})]})}})}function W(){return e.jsxs(t.IntroMessageWrapper,{children:[e.jsxs(t.MessageHeader,{children:[e.jsx(t.MessageAvatar,{children:e.jsx(t.MessageAvatarContent,{children:e.jsx(t.MessageAvatarImage,{})})}),e.jsx(t.MessageName,{})]}),e.jsxs(t.MessageContentWrapper,{children:[e.jsx(t.MessageContent,{children:e.jsx(C.EmbeddedChatMessagePart,{isLast:!1})}),e.jsxs(t.Disclaimer,{children:[e.jsx(t.DisclaimerLabel,{}),e.jsx(t.DisclaimerTrigger,{}),e.jsxs(t.DisclaimerContent,{children:[e.jsx(t.DisclaimerText,{}),e.jsx(t.DisclaimerArrow,{})]})]}),e.jsxs(t.ExampleQuestions,{children:[e.jsx(t.ExampleQuestionsLabel,{}),e.jsx(t.ExampleQuestionsList,{children:r=>r.map(s=>e.jsx(t.ExampleQuestion,{children:e.jsx(t.ExampleQuestionButton,{question:s})},typeof s=="object"?s.label:s))})]})]})]})}function b(){return e.jsxs(t.MessageHeader,{children:[e.jsx(t.MessageAvatar,{children:e.jsx(t.MessageAvatarContent,{children:e.jsx(t.MessageAvatarImage,{})})}),e.jsx(t.MessageName,{})]})}function q(){return e.jsxs(t.MessageAttachments,{children:[e.jsx(t.MessageAttachmentsList,{children:r=>r.map(s=>e.jsxs(t.MessageAttachmentsItem,{attachment:s,children:[e.jsx(t.MessageAttachmentsItemIcon,{}),e.jsx(t.MessageAttachmentsItemTitle,{})]},s.id))}),e.jsx(t.MessageAttachmentsPreview,{children:e.jsx(p.PortalWithTheme,{children:e.jsx(t.MessageAttachmentsPreviewOverlay,{children:e.jsxs(t.MessageAttachmentsPreviewContent,{children:[e.jsx(t.MessageAttachmentsPreviewHeader,{}),e.jsx(t.MessageAttachmentsPreviewClose,{}),e.jsx(t.MessageAttachmentsPreviewBody,{})]})})})})]})}function _(){return e.jsxs(t.MessageToolbar,{children:[e.jsx(t.MessageCustomActions,{children:r=>r.map((s,n)=>e.jsx(t.MessageCustomAction,{action:s},`action-${n}`))}),e.jsx(t.MessageAction,{action:"copy"}),e.jsx(t.MessageAction,{action:"upvote"}),e.jsx(t.MessageAction,{action:"downvote"})]})}function V(){return e.jsxs(t.MessageSources,{children:[e.jsx(t.MessageSourcesHeader,{}),e.jsx(t.MessageSourcesList,{children:r=>r.map((s,n)=>e.jsxs(t.MessageSourceItem,{href:s.url,source:s,children:[e.jsx(t.MessageSourceItemBreadcrumbs,{children:s.breadcrumbs?.map(o=>e.jsxs(j.Fragment,{children:[o,e.jsx(t.MessageSourceItemBreadcrumbIcon,{})]},o))}),e.jsx(t.MessageSourceItemIcon,{}),e.jsx(t.MessageSourceItemTitle,{}),e.jsx(t.MessageSourceItemTag,{}),e.jsx(t.MessageSourceItemDescription,{children:o=>o.map((a,d)=>e.jsx(t.MessageSourceItemDescriptionPart,{part:a},`part-${d}`))}),e.jsx(t.MessageSourceItemIndicator,{})]},n))})]})}function N(){return e.jsxs(t.Footer,{children:[e.jsx(O,{}),e.jsx(Q,{})]})}function O(){return e.jsxs(t.InputFieldset,{children:[e.jsxs(t.InputGroup,{children:[e.jsx(t.Input,{}),e.jsx(t.SendButton,{children:e.jsx(t.SendButtonIcon,{})})]}),e.jsxs(t.AttachmentsBar,{children:[e.jsx(t.AttachmentsBarList,{children:r=>r.map(s=>e.jsxs(t.AttachmentsBarAttachment,{attachment:s,children:[e.jsx(t.AttachmentsBarAttachmentIcon,{}),e.jsx(t.AttachmentsBarAttachmentTitle,{}),e.jsx(t.AttachmentsBarAttachmentDelete,{})]},s.id))}),e.jsxs(t.AttachmentsBarActions,{children:[e.jsxs(t.AttachmentsBarInfoTip,{children:[e.jsx(t.AttachmentsBarInfoTipIcon,{}),e.jsx(t.AttachmentsBarInfoTipText,{})]}),e.jsx(t.AttachmentsBarInputs,{children:r=>r.map(s=>e.jsx(t.AttachmentsBarInput,{input:s,children:s.displayName},s.id))})]}),e.jsx(p.PortalWithTheme,{children:e.jsx(t.AttachmentsBarModal,{children:e.jsx(t.AttachmentsBarModalOverlay,{children:e.jsxs(t.AttachmentsBarModalContent,{children:[e.jsxs(t.AttachmentsBarModalHeader,{children:[e.jsx(t.AttachmentsBarModalHeading,{}),e.jsx(t.AttachmentsBarModalDescription,{}),e.jsx(t.AttachmentsBarModalHelp,{})]}),e.jsx(t.AttachmentsBarModalClose,{}),e.jsx(t.AttachmentsBarModalBody,{children:e.jsxs(t.AttachmentsBarForm,{children:[e.jsxs(t.AttachmentsBarFormTitle,{children:[e.jsx(t.AttachmentsBarFormTitleLabel,{}),e.jsx(t.AttachmentsBarFormTitleInput,{}),e.jsx(t.AttachmentsBarFormTitleError,{})]}),e.jsxs(t.AttachmentsBarFormContent,{children:[e.jsx(t.AttachmentsBarFormContentLabel,{}),e.jsx(t.AttachmentsBarFormContentInput,{}),e.jsx(t.AttachmentsBarFormContentError,{})]}),e.jsx(t.AttachmentsBarFormSubmitButton,{})]})})]})})})})]})]})}function Q(){return e.jsxs(t.ActionBar,{children:[e.jsxs(t.TaglineContainer,{children:[e.jsx(t.TaglineText,{}),e.jsx(t.TaglineLogo,{}),e.jsx(t.TaglineBrandName,{})]}),e.jsxs(t.Actions,{children:[e.jsx(t.HelpActions,{children:({pinned:r,unpinned:s})=>e.jsxs(e.Fragment,{children:[r.map(n=>e.jsx(t.HelpAction,{action:n},n.name)),s.length>0&&e.jsx(t.HelpActionsTrigger,{}),e.jsxs(t.HelpActionsMenu,{children:[e.jsx(t.HelpActionsMenuArrow,{}),s.map(n=>e.jsxs(t.HelpActionsMenuItem,{action:n,children:[e.jsx(t.HelpActionsMenuItemIcon,{action:n}),n.name]},n.name))]})]})}),e.jsxs(t.ChatAction,{action:"copy",children:[e.jsx(t.ChatActionLabel,{action:"copy"}),e.jsx(t.ChatActionFeedback,{action:"copy"})]}),e.jsx(t.ChatAction,{action:"clear"}),e.jsx(t.ChatAction,{action:"stop"})]})]})}function R(){const{sessions:r}=B.useChatHistory(),{conversationId:s}=I.useChat();return e.jsxs(i.EmbeddedChatHistoryRoot,{children:[e.jsxs(i.EmbeddedChatHistoryHeader,{children:[e.jsxs(i.EmbeddedChatHistoryBackButton,{children:[e.jsx(i.EmbeddedChatHistoryBackButtonIcon,{iconKey:"backToChat"}),"Back to chat"]}),e.jsx(i.EmbeddedChatHistoryTitle,{}),e.jsx(F.Close,{})]}),e.jsxs(i.EmbeddedChatHistoryList,{children:[r.map(n=>e.jsxs(i.EmbeddedChatHistoryItem,{sessionId:n.id,"data-active":u.dataAttr(n.id===s),children:[e.jsx(i.EmbeddedChatHistoryItemTitle,{children:n.title}),e.jsx(i.EmbeddedChatHistoryItemDate,{children:i.formatSessionDate(n.updatedAt)})]},n.id)),e.jsx(i.EmbeddedChatHistoryEmptyState,{}),e.jsx(i.EmbeddedChatHistoryLoadingState,{})]}),e.jsx(i.EmbeddedChatHistoryFooter,{children:e.jsx(i.EmbeddedChatHistoryNewConversationButton,{})})]})}function $(){return e.jsx(p.PortalWithTheme,{children:e.jsx(t.FeedbackModal,{children:e.jsx(t.FeedbackModalOverlay,{children:e.jsxs(t.FeedbackModalContent,{children:[e.jsx(t.FeedbackModalHeader,{}),e.jsx(t.FeedbackModalClose,{}),e.jsx(t.FeedbackModalBody,{children:e.jsxs(t.FeedbackForm,{children:[e.jsxs(t.FeedbackItem,{name:"unrelated_response",children:[e.jsx(t.FeedbackItemCheckbox,{children:e.jsx(t.FeedbackItemCheckboxIndicator,{})}),e.jsx(t.FeedbackItemLabel,{}),e.jsx(t.FeedbackItemDescription,{})]}),e.jsxs(t.FeedbackItem,{name:"inaccurate_statement",children:[e.jsx(t.FeedbackItemCheckbox,{children:e.jsx(t.FeedbackItemCheckboxIndicator,{})}),e.jsx(t.FeedbackItemLabel,{}),e.jsx(t.FeedbackItemDescription,{})]}),e.jsxs(t.FeedbackItem,{name:"inaccurate_code_snippet",children:[e.jsx(t.FeedbackItemCheckbox,{children:e.jsx(t.FeedbackItemCheckboxIndicator,{})}),e.jsx(t.FeedbackItemLabel,{}),e.jsx(t.FeedbackItemDescription,{})]}),e.jsxs(t.FeedbackItem,{name:"irrelevant_citations",children:[e.jsx(t.FeedbackItemCheckbox,{children:e.jsx(t.FeedbackItemCheckboxIndicator,{})}),e.jsx(t.FeedbackItemLabel,{})]}),e.jsx(t.FeedbackSubmitButton,{})]})})]})})})})}function G(){return e.jsxs(t.FormWrapper,{children:[e.jsx(t.FormClose,{}),e.jsxs(t.Form,{children:[e.jsxs(t.FormHeader,{children:[e.jsx(t.FormHeading,{}),e.jsx(t.FormDescription,{})]}),e.jsx(t.FormContent,{children:r=>e.jsxs(e.Fragment,{children:[r.map((s,n)=>e.jsxs(t.FormField,{field:s,autoFocus:n===0,children:[e.jsx(t.FormFieldLabel,{}),s.inputType==="text"&&e.jsx(t.FormFieldText,{}),s.inputType==="email"&&e.jsx(t.FormFieldEmail,{}),s.inputType==="file"&&e.jsx(t.FormFieldFile,{}),s.inputType==="textarea"&&e.jsx(t.FormFieldTextArea,{}),s.inputType==="checkbox"&&e.jsx(t.FormFieldCheckbox,{children:e.jsx(t.FormFieldCheckboxIndicator,{})}),s.inputType==="select"&&e.jsxs(t.FormFieldSelect,{children:[e.jsxs(t.FormFieldSelectTrigger,{children:[e.jsx(t.FormFieldSelectValue,{}),e.jsx(t.FormFieldSelectIcon,{})]}),e.jsx(t.FormFieldSelectContent,{children:e.jsx(t.FormFieldSelectViewport,{children:s.items.map(o=>e.jsxs(t.FormFieldSelectItem,{value:o.value,children:[e.jsx(t.FormFieldSelectItemText,{children:o.label}),e.jsx(t.FormFieldSelectItemIndicator,{})]},o.value))})})]}),s.inputType==="combobox"&&e.jsxs(t.FormFieldCombobox,{children:[e.jsxs(t.FormFieldComboboxControl,{children:["multiple"in s&&s.multiple&&e.jsx(t.FormFieldComboboxSelectedTags,{}),e.jsx(t.FormFieldComboboxInput,{}),e.jsx(t.FormFieldComboboxTrigger,{})]}),e.jsx(t.FormFieldComboboxPositioner,{children:e.jsx(t.FormFieldComboboxContent,{children:e.jsx(t.FormFieldComboboxList,{children:e.jsx(t.FormFieldComboboxListItems,{children:o=>o.length===0?e.jsx(t.FormFieldComboboxListEmpty,{}):o.map(a=>e.jsxs(t.FormFieldComboboxItem,{item:a,children:[e.jsx(t.FormFieldComboboxItemText,{children:a.label}),e.jsx(t.FormFieldComboboxItemIndicator,{})]},a.value))})})})})]}),e.jsx(t.FormFieldDescription,{}),e.jsx(t.FormFieldError,{})]},s.name)),e.jsx(t.FormError,{})]})}),e.jsxs(t.FormFooter,{children:[e.jsx(t.FormCancel,{}),e.jsx(t.FormSubmit,{})]})]}),e.jsxs(t.FormSuccess,{children:[e.jsx(t.FormSuccessHeading,{}),e.jsx(t.FormSuccessMessage,{}),e.jsx(t.FormSuccessButton,{})]})]})}exports.InkeepEmbeddedChat=f;exports.InkeepEmbeddedChatImpl=M;exports.InkeepEmbeddedChatImplContent=k;exports.InkeepEmbeddedChatProvider=A;
|