@inkeep/agents-ui 0.0.0-dev-20260408203717 → 0.0.0-dev-20260409023209
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/atoms/markdown/index.cjs +1 -1
- package/dist/primitives/atoms/markdown/index.js +41 -39
- package/dist/primitives/components/embedded-chat.cjs +3 -3
- package/dist/primitives/components/embedded-chat.js +6 -6
- package/dist/primitives/hooks/use-simple-scroll.cjs +1 -1
- package/dist/primitives/hooks/use-simple-scroll.d.ts +6 -0
- package/dist/primitives/hooks/use-simple-scroll.js +28 -28
- package/dist/primitives/utils/default-settings.cjs +1 -1
- package/dist/primitives/utils/default-settings.d.ts +1 -0
- package/dist/primitives/utils/default-settings.js +6 -5
- package/dist/primitives/utils/misc.cjs +1 -1
- package/dist/primitives/utils/misc.js +11 -11
- package/dist/styled/components/message.cjs +1 -1
- package/dist/styled/components/message.js +36 -37
- package/dist/types/config/ai.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),f=require("react"),w=require("react-markdown"),M=require("rehype-raw"),y=require("remark-gfm"),g=require("remark-supersub"),b=require("../../providers/markdown-provider.cjs"),S=require("../codeblock/index.cjs"),t=require("./components.cjs"),q=require("./rehype-inline-code-property.cjs");const C=({children:c,componentStyles:h,shouldOpenLinksInNewTab:d,onLinkClick:l,onCodeCopy:m,artifacts:x,...j})=>{if(!c)return null;const k={h1:({children:r})=>e.jsx(t.MarkdownH1,{children:r}),h2:({children:r})=>e.jsx(t.MarkdownH2,{children:r}),p:({children:r})=>e.jsx(t.MarkdownP,{children:r}),li:({children:r})=>e.jsx(t.MarkdownLi,{children:r}),ul:({children:r})=>e.jsx(t.MarkdownUl,{children:r}),hr:()=>e.jsx(t.MarkdownHr,{}),input:({type:r,checked:o,disabled:n,readOnly:s,required:a,value:i})=>e.jsx(t.MarkdownInput,{type:r,checked:o,disabled:n,readOnly:s,required:a,value:i}),ol:({children:r,node:o})=>{const n=o?.properties?.start,s=typeof n=="number"?n:void 0;return e.jsx(t.MarkdownOl,{style:{"--start":n?.toString()??"0"},start:s,children:r})},a:({children:r,href:o})=>{const n=f.Children.toArray(r),s=n[0],a=typeof s=="string"&&/^\(\d+\)$/.test(s)&&n.length===1,i=a?s.match(/\d+/):r,u=e.jsx(t.MarkdownLink,{isExternal:d,href:o,onClick:()=>{l?.(o,i?.toString())},children:i});return a?e.jsx(t.MarkdownSourceLink,{children:u}):u},img:({src:r,alt:o})=>e.jsx(t.MarkdownImg,{src:r,alt:o}),table:({children:r})=>e.jsx(t.MarkdownTable,{children:r}),th:({children:r,isHeader:o})=>o?e.jsx(t.MarkdownTh,{children:r}):e.jsx(t.MarkdownTd,{children:r}),pre:({children:r})=>e.jsx("pre",{children:r}),code:({children:r,inline:o,className:n})=>o?e.jsx(t.MarkdownCode,{children:r}):e.jsx(S.CodeBlock,{className:n,onCopy:m,children:r}),sub:({children:r})=>typeof r=="string"&&(r.startsWith(" ")||r.endsWith(" "))?e.jsxs(e.Fragment,{children:["~",r,"~"]}):e.jsx("sub",{children:r}),sup:({children:r})=>{if(r&&typeof r=="string"){const o=x?.find(n=>(n.data?.artifactSummary?.title||n.data?.name)===r);if(o){const n=o.data,s=n?.artifactSummary?.url,a=n?.artifactSummary?.title;if(!s)return null;const i=a||n?.name||r;return e.jsx(t.MarkdownSup,{children:e.jsx(t.MarkdownLink,{href:s,isExternal:d,onClick:()=>l?.(s,i),children:e.jsx("span",{children:i})})})}}return e.jsx("sup",{children:r})}},p=e.jsx(w,{remarkPlugins:[[y,{singleTilde:!1}],g],rehypePlugins:[M,q.rehypeInlineCodeProperty],components:k,disallowedElements:P,children:c.toString(),...j});return e.jsx(b.ChatMarkdownProvider,{componentStyles:h,children:p})},P=["script","iframe","frame","embed","meta","base","form","style","object"];exports.Markdown=C;
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { ChatMarkdownProvider as
|
|
8
|
-
import { CodeBlock as
|
|
9
|
-
import { MarkdownSup as
|
|
1
|
+
import { jsx as t, jsxs as M, Fragment as y } from "react/jsx-runtime";
|
|
2
|
+
import g from "react";
|
|
3
|
+
import b from "react-markdown";
|
|
4
|
+
import S from "rehype-raw";
|
|
5
|
+
import C from "remark-gfm";
|
|
6
|
+
import x from "remark-supersub";
|
|
7
|
+
import { ChatMarkdownProvider as P } from "../../providers/markdown-provider.js";
|
|
8
|
+
import { CodeBlock as j } from "../codeblock/index.js";
|
|
9
|
+
import { MarkdownSup as E, MarkdownLink as m, MarkdownCode as H, MarkdownTh as R, MarkdownTd as T, MarkdownTable as v, MarkdownImg as A, MarkdownSourceLink as I, MarkdownOl as W, MarkdownInput as _, MarkdownHr as B, MarkdownUl as D, MarkdownLi as F, MarkdownP as G, MarkdownH2 as L, MarkdownH1 as U } from "./components.js";
|
|
10
10
|
import { rehypeInlineCodeProperty as V } from "./rehype-inline-code-property.js";
|
|
11
11
|
const rr = ({
|
|
12
12
|
children: d,
|
|
13
|
-
componentStyles:
|
|
14
|
-
shouldOpenLinksInNewTab:
|
|
15
|
-
onLinkClick:
|
|
16
|
-
onCodeCopy:
|
|
13
|
+
componentStyles: h,
|
|
14
|
+
shouldOpenLinksInNewTab: l,
|
|
15
|
+
onLinkClick: c,
|
|
16
|
+
onCodeCopy: u,
|
|
17
17
|
artifacts: f,
|
|
18
|
-
...
|
|
18
|
+
...p
|
|
19
19
|
}) => {
|
|
20
20
|
if (!d) return null;
|
|
21
|
-
const
|
|
21
|
+
const k = {
|
|
22
22
|
h1: ({ children: r }) => /* @__PURE__ */ t(U, { children: r }),
|
|
23
23
|
h2: ({ children: r }) => /* @__PURE__ */ t(L, { children: r }),
|
|
24
24
|
p: ({ children: r }) => /* @__PURE__ */ t(G, { children: r }),
|
|
25
25
|
li: ({ children: r }) => /* @__PURE__ */ t(F, { children: r }),
|
|
26
26
|
ul: ({ children: r }) => /* @__PURE__ */ t(D, { children: r }),
|
|
27
27
|
hr: () => /* @__PURE__ */ t(B, {}),
|
|
28
|
-
input: ({ type: r, checked: e, disabled: n, readOnly: o, required:
|
|
28
|
+
input: ({ type: r, checked: e, disabled: n, readOnly: o, required: a, value: i }) => /* @__PURE__ */ t(
|
|
29
29
|
_,
|
|
30
30
|
{
|
|
31
31
|
type: r,
|
|
32
32
|
checked: e,
|
|
33
33
|
disabled: n,
|
|
34
34
|
readOnly: o,
|
|
35
|
-
required:
|
|
36
|
-
value:
|
|
35
|
+
required: a,
|
|
36
|
+
value: i
|
|
37
37
|
}
|
|
38
38
|
),
|
|
39
39
|
ol: ({ children: r, node: e }) => {
|
|
@@ -50,25 +50,25 @@ const rr = ({
|
|
|
50
50
|
);
|
|
51
51
|
},
|
|
52
52
|
a: ({ children: r, href: e }) => {
|
|
53
|
-
const n =
|
|
54
|
-
|
|
53
|
+
const n = g.Children.toArray(r), o = n[0], a = typeof o == "string" && /^\(\d+\)$/.test(o) && n.length === 1, i = a ? o.match(/\d+/) : r, s = /* @__PURE__ */ t(
|
|
54
|
+
m,
|
|
55
55
|
{
|
|
56
|
-
isExternal:
|
|
56
|
+
isExternal: l,
|
|
57
57
|
href: e,
|
|
58
58
|
onClick: () => {
|
|
59
|
-
|
|
59
|
+
c?.(e, i?.toString());
|
|
60
60
|
},
|
|
61
|
-
children:
|
|
61
|
+
children: i
|
|
62
62
|
}
|
|
63
63
|
);
|
|
64
|
-
return
|
|
64
|
+
return a ? /* @__PURE__ */ t(I, { children: s }) : s;
|
|
65
65
|
},
|
|
66
66
|
img: ({ src: r, alt: e }) => /* @__PURE__ */ t(A, { src: r, alt: e }),
|
|
67
67
|
table: ({ children: r }) => /* @__PURE__ */ t(v, { children: r }),
|
|
68
68
|
th: ({ children: r, isHeader: e }) => e ? /* @__PURE__ */ t(R, { children: r }) : /* @__PURE__ */ t(T, { children: r }),
|
|
69
69
|
pre: ({ children: r }) => /* @__PURE__ */ t("pre", { children: r }),
|
|
70
|
-
code: ({ children: r, inline: e, className: n }) => e ? /* @__PURE__ */ t(H, { children: r }) : /* @__PURE__ */ t(
|
|
71
|
-
sub: ({ children: r }) => typeof r == "string" && (r.startsWith(" ") || r.endsWith(" ")) ? /* @__PURE__ */ y
|
|
70
|
+
code: ({ children: r, inline: e, className: n }) => e ? /* @__PURE__ */ t(H, { children: r }) : /* @__PURE__ */ t(j, { className: n, onCopy: u, children: r }),
|
|
71
|
+
sub: ({ children: r }) => typeof r == "string" && (r.startsWith(" ") || r.endsWith(" ")) ? /* @__PURE__ */ M(y, { children: [
|
|
72
72
|
"~",
|
|
73
73
|
r,
|
|
74
74
|
"~"
|
|
@@ -79,32 +79,34 @@ const rr = ({
|
|
|
79
79
|
(n) => (n.data?.artifactSummary?.title || n.data?.name) === r
|
|
80
80
|
);
|
|
81
81
|
if (e) {
|
|
82
|
-
const n = e.data, o = n?.artifactSummary?.url,
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
const n = e.data, o = n?.artifactSummary?.url, a = n?.artifactSummary?.title;
|
|
83
|
+
if (!o) return null;
|
|
84
|
+
const i = a || n?.name || r;
|
|
85
|
+
return /* @__PURE__ */ t(E, { children: /* @__PURE__ */ t(
|
|
86
|
+
m,
|
|
85
87
|
{
|
|
86
88
|
href: o,
|
|
87
|
-
isExternal:
|
|
88
|
-
onClick: () =>
|
|
89
|
+
isExternal: l,
|
|
90
|
+
onClick: () => c?.(o, i),
|
|
89
91
|
children: /* @__PURE__ */ t("span", { children: i })
|
|
90
92
|
}
|
|
91
|
-
) })
|
|
93
|
+
) });
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
return /* @__PURE__ */ t("sup", { children: r });
|
|
95
97
|
}
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
+
}, w = /* @__PURE__ */ t(
|
|
99
|
+
b,
|
|
98
100
|
{
|
|
99
|
-
remarkPlugins: [[
|
|
100
|
-
rehypePlugins: [
|
|
101
|
-
components:
|
|
101
|
+
remarkPlugins: [[C, { singleTilde: !1 }], x],
|
|
102
|
+
rehypePlugins: [S, V],
|
|
103
|
+
components: k,
|
|
102
104
|
disallowedElements: $,
|
|
103
105
|
children: d.toString(),
|
|
104
|
-
...
|
|
106
|
+
...p
|
|
105
107
|
}
|
|
106
108
|
);
|
|
107
|
-
return /* @__PURE__ */ t(
|
|
109
|
+
return /* @__PURE__ */ t(P, { componentStyles: h, children: w });
|
|
108
110
|
}, $ = [
|
|
109
111
|
"script",
|
|
110
112
|
"iframe",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),u=require("react"),yi=require("react-dom/client"),se=require("react-textarea-autosize"),Ti=require("@radix-ui/react-avatar"),Hi=require("@radix-ui/react-checkbox"),ji=require("@radix-ui/react-popover"),wi=require("@radix-ui/react-tooltip"),Li=require("@radix-ui/react-scroll-area"),H=require("../atoms/select.cjs"),x=require("../atoms/combobox.cjs"),Q=require("../atoms/dialog.cjs"),Di=require("../atoms/avatars/ai.cjs"),Ri=require("../atoms/avatars/user.cjs"),A=require("../atoms/icons/custom-icon.cjs"),N=require("../atoms/icons/built-in-icon-renderer.cjs"),Bi=require("../atoms/link.cjs"),$=require("../atoms/markdown/index.cjs"),B=require("../providers/source-item-provider.cjs"),F=require("../providers/config-provider.cjs"),J=require("../providers/feedback-provider.cjs"),I=require("../providers/message-provider.cjs"),qi=require("../atoms/icons/checkbox-icon.cjs"),Y=require("../hooks/use-copy-to-clipboard.cjs"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),u=require("react"),yi=require("react-dom/client"),se=require("react-textarea-autosize"),Ti=require("@radix-ui/react-avatar"),Hi=require("@radix-ui/react-checkbox"),ji=require("@radix-ui/react-popover"),wi=require("@radix-ui/react-tooltip"),Li=require("@radix-ui/react-scroll-area"),H=require("../atoms/select.cjs"),x=require("../atoms/combobox.cjs"),Q=require("../atoms/dialog.cjs"),Di=require("../atoms/avatars/ai.cjs"),Ri=require("../atoms/avatars/user.cjs"),A=require("../atoms/icons/custom-icon.cjs"),N=require("../atoms/icons/built-in-icon-renderer.cjs"),Bi=require("../atoms/link.cjs"),$=require("../atoms/markdown/index.cjs"),B=require("../providers/source-item-provider.cjs"),F=require("../providers/config-provider.cjs"),J=require("../providers/feedback-provider.cjs"),I=require("../providers/message-provider.cjs"),qi=require("../atoms/icons/checkbox-icon.cjs"),Y=require("../hooks/use-copy-to-clipboard.cjs"),h=require("../utils/misc.cjs"),i=require("./factory.cjs"),E=require("./embedded-chat/chat-provider.cjs"),Ni=require("../hooks/use-settle-action.cjs"),Oi=require("../hooks/use-container-size.cjs"),X=require("./embedded-chat/use-chat-action.cjs"),Z=require("../providers/help-menu-provider.cjs"),k=require("../providers/chat-form-provider.cjs"),y=require("../providers/form-field-provider.cjs"),Vi=require("react-hook-form"),Wi=require("../utils/highlight-emphasis.cjs"),Qi=require("./modal/modal-provider.cjs"),Ui=require("../../color-mode/index.cjs"),ee=require("../utils/compose-refs.cjs"),v=require("../utils/compose-event-handlers.cjs"),$i=require("../hooks/use-simple-scroll.cjs"),Ki=require("../hooks/use-debounce.cjs"),te=require("../providers/hover-popover-provider.cjs"),zi=require("./modal/widget-auto-focus.cjs"),ie=require("../providers/base-events-provider.cjs"),Gi=require("../atoms/shadow/context.cjs"),Yi=require("../utils/get-source-icon.cjs"),Zi=require("../providers/chat-history-provider.cjs"),g=require("./embedded-chat/file-upload-input.cjs"),O=require("./embedded-chat/image-preview-modal.cjs");function W(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const a=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,a.get?a:{enumerable:!0,get:()=>t[o]})}}return e.default=t,Object.freeze(e)}const Ji=W(yi),oe=W(Ti),de=W(Hi),q=W(ji),K=W(wi),U=W(Li),Xi="__intro__",eo=767,to=i.ikp("div",{_id:"aiChatWrapper"}),ce=u.forwardRef(({chatHistoryLayout:t,isChatHistoryOpen:e,setChatHistoryOpen:o,isChatHistoryButtonVisible:a,children:n,...s},d)=>{u.useEffect(()=>{t==="stack"?o(!1):t==="sidepane"&&a&&o(!0)},[t,a,o]);const c=t==="stack"&&e;return r.jsx(to,{ref:d,"data-chat-history-layout":t,"data-chat-history-open":h.dataAttr(e),"data-stack-history-open":h.dataAttr(c),...s,children:n})});ce.displayName="EmbeddedChatWrapperInner";const me=u.forwardRef((t,e)=>{const{children:o,...a}=t,{isHidden:n,isMobile:s}=E.useChat(),{aiChatSettings:d}=F.useInkeepConfig(),{isChatHistoryButtonVisible:c}=d,[m,l]=Oi.useContainerSize(),C=ee.useComposedRefs(e,m),p=l?.width?l.width>580:!0,b=Qi.useModal(),P=(l?.width??0)>eo?"sidepane":"stack";return r.jsx(Zi.ChatHistoryProvider,{layout:P,children:({isOpen:_,setIsOpen:f})=>r.jsx(ce,{ref:C,chatHistoryLayout:P,isChatHistoryOpen:_,setChatHistoryOpen:f,isChatHistoryButtonVisible:!!c,"data-widget-md":h.dataAttr(p),"data-hidden":h.dataAttr(n),"data-in-modal":h.dataAttr(!!b),"data-mobile":h.dataAttr(s),...a,children:o})})}),io=i.ikp("div",{_id:"aiChatRoot"}),le=t=>{const{isHidden:e}=E.useChat(),{form:o}=k.useChatForm();return o?null:r.jsx(io,{"data-hidden":h.dataAttr(e),...t})},oo=i.ikp("div",{_id:"aiChatHeader"}),ue=i.ikp("div",{_id:"aiChatHeader__Toolbar"}),Ce=i.ikp("div",{_id:"aiChatHeader__ToolbarHeaderWrapper"}),ro=i.ikp(A.CustomIcon,{_id:"aiChatHeader__ChatHistoryButtonIcon"}),he=u.memo(t=>r.jsx(ro,{...t})),be=i.ikp("button",{_id:"aiChatHeader__ChatHistoryButton"}),ao=i.ikp("div",{_id:"aiChatHeader__ToolbarHeader"}),pe=u.memo(t=>{const{aiChatSettings:e}=F.useInkeepConfig(),o=`Ask ${e.aiAssistantName||"AI"}`;return r.jsx(ao,{...t,children:o})}),ve=i.ikp("div",{_id:"aiChatContent"}),Fe=i.ikp(U.Root,{_id:"aiChatContentScrollArea"}),no=i.ikp(U.Viewport,{_id:"aiChatContentScrollArea__Viewport"}),ge=u.forwardRef(({children:t,...e},o)=>{const{messages:a,isStreaming:n}=E.useChat(),{aiChatSettings:{shouldAutoScroll:s=!0}}=F.useInkeepConfig(),{containerRef:d,scrollToBottom:c,handleScroll:m,enableAutoScroll:l}=$i.useSimpleScroll({isStreaming:n,enabled:s}),C=ee.useComposedRefs(o,d);return u.useEffect(()=>{a.length>0&&(l(),c())},[a.length,c,l]),r.jsx(no,{ref:C,tabIndex:-1,onScroll:m,style:{outline:"none"},children:r.jsx("div",{"data-part":"grid",tabIndex:-1,style:{display:"grid",outline:"none"},children:t}),...e})}),Pe=i.ikp(U.ScrollAreaScrollbar,{_id:"aiChatContentScrollArea__Scrollbar"}),Ee=i.ikp(U.ScrollAreaThumb,{_id:"aiChatContentScrollArea__Thumb"}),_e=i.ikp(U.Corner,{_id:"aiChatContentScrollArea__Corner"}),so=i.ikp("div",{_id:"aiChatMessages"}),Ie=t=>{const e=E.useChat(),{children:o,...a}=t;return r.jsx(so,{children:h.maybeRender(o,e),...a})},co=i.ikp("div",{_id:"aiChatDisclaimer"}),ke=u.memo(t=>{const{aiChatSettings:e}=F.useInkeepConfig(),[o,a]=u.useState(!1),n=Ki.useDebounce(o,100);return e.disclaimerSettings?.isEnabled?r.jsx(te.HoverPopoverProvider,{open:o,setOpen:a,children:r.jsx(q.Root,{open:n,onOpenChange:a,children:r.jsx(co,{...t})})}):null}),mo=i.ikp("span",{_id:"aiChatDisclaimerLabel"}),Se=u.memo(t=>{const{aiChatSettings:e}=F.useInkeepConfig(),o=e.disclaimerSettings;return r.jsx(mo,{children:o?.label,...t})}),lo=i.ikp(q.Trigger,{_id:"aiChatDisclaimerTrigger",children:r.jsx(A.CustomIcon,{iconKey:"info"})}),Me=u.memo(t=>{const{setOpen:e}=te.useHoverPopover(),o=()=>e(!0),a=()=>e(!1);return r.jsx(lo,{onMouseEnter:o,onMouseLeave:a,...t})}),uo=i.ikp(q.Content,{_id:"aiChatDisclaimerContent"}),xe=t=>{const{setOpen:e}=te.useHoverPopover(),o=()=>e(!0),a=()=>e(!1);return r.jsx(uo,{onMouseEnter:o,onMouseLeave:a,side:"top",sideOffset:8,align:"end",alignOffset:-10,...t})},Co=i.ikp($.Markdown,{_id:"aiChatDisclaimerText"}),fe=u.memo(t=>{const{aiChatSettings:e}=F.useInkeepConfig(),o=e.aiAssistantName,n=e.disclaimerSettings?.tooltip||`Information provided by ${o||"this AI assistant"} is not guaranteed to be accurate or comprehensive.`;return r.jsx(Co,{shouldOpenLinksInNewTab:!0,children:n,...t})}),Ae=i.ikp(q.Arrow,{_id:"aiChatDisclaimerArrow"}),ho=i.ikp("div",{_id:"aiChatExampleQuestions"}),ye=t=>{const{aiChatSettings:e}=F.useInkeepConfig(),{messages:o}=E.useChat();return!e.exampleQuestions?.length||o.length?null:r.jsx(ho,{...t})},bo=i.ikp("h3",{_id:"aiChatExampleQuestionsLabel"}),Te=u.memo(t=>{const{aiChatSettings:e}=F.useInkeepConfig();return r.jsx(bo,{children:e.exampleQuestionsLabel,...t})}),po=i.ikp("div",{_id:"aiChatExampleQuestionsList"}),He=u.memo(t=>{const{aiChatSettings:e}=F.useInkeepConfig(),o=e.exampleQuestions,{children:a,...n}=t;return r.jsx(po,{children:h.maybeRender(a,o),...n})}),vo=i.ikp("div",{_id:"aiChatExampleQuestion"}),je=u.forwardRef((t,e)=>{const{aiChatSettings:o}=F.useInkeepConfig(),a=o.isFirstExampleQuestionHighlighted;return r.jsx(vo,{ref:e,"data-highlight":h.dataAttr(a),...t})}),Fo=i.ikp("button",{_id:"aiChatExampleQuestionButton"}),we=t=>{const{question:e,onClick:o,...a}=t,n=typeof e=="object"?e.value:e,s=typeof e=="object"?e.label:e,{handleSubmit:d}=E.useChat();return r.jsx(Fo,{onClick:v.composeEventHandlers(o,()=>d(n)),children:s,...a})},go=i.ikp("div",{_id:"aiChatMessageWrapper"}),re=t=>{const{message:e,...o}=t;return e.role==="system"?null:r.jsx(I.MessageProvider,{message:e,children:r.jsx(go,{"data-role":e.role,...o})})},Le=u.memo(t=>{const{message:e,...o}=t,{aiChatSettings:a,baseSettings:n}=F.useInkeepConfig(),s=a.aiAssistantName,d=s?`Hi, I'm ${s}!`:"Hi!",c=a.chatSubjectName??n.organizationDisplayName,m=c?`
|
|
2
2
|
|
|
3
3
|
Ask me anything about \`${c}\`.`:`
|
|
4
4
|
|
|
5
|
-
How can I help?`,h={parts:[{type:"text",text:a.introMessage??`${d}${m}`}],id:Xi,...e,role:"assistant"};return r.jsx(re,{message:h,...o})}),Po=i.ikp("div",{_id:"aiChatMessageHeader"}),De=t=>{const{message:e}=I.useMessage();return r.jsx(Po,{"data-role":e.role,...t})},Eo=i.ikp("div",{_id:"aiChatMessageLoading",children:"Thinking..."}),Re=t=>r.jsx(Eo,{...t}),_o=i.ikp("div",{_id:"aiChatMessageAvatar"}),Be=t=>{const{message:e}=I.useMessage();return r.jsx(_o,{"data-role":e.role,...t})},Io=i.ikp(oe.Root,{_id:"aiChatMessageAvatarContent"}),qe=t=>{const{message:e}=I.useMessage(),{baseSettings:o}=F.useInkeepConfig();return r.jsx(Io,{"data-username":C.dataAttr(e.role==="user"&&!!o.userProperties.name),"data-role":e.role,...t})},ko=i.ikp(oe.Fallback,{_id:"aiChatMessageAvatarFallback"}),Ne=u.memo(t=>{const{baseSettings:e}=F.useInkeepConfig(),{message:o}=I.useMessage();return e.userProperties.name?r.jsx(ko,{"data-role":o.role,children:C.getInitials(e.userProperties.name),...t}):null}),ne=i.ikp(oe.Image,{_id:"aiChatMessageAvatarImage"}),Oe=u.memo(t=>{const{onLoadingStatusChange:e,...o}=t,{aiChatSettings:a,baseSettings:{userProperties:n}}=F.useInkeepConfig(),{message:s}=I.useMessage(),{aiAssistantAvatar:d}=a??{},c=typeof d=="string"?d:d?.light,m=(typeof d=="string"?d:d?.dark)??c,l=Ui.useColorModeValue(c,m),[h,p]=u.useState(l);u.useEffect(()=>{p(l)},[l]);const b=P=>{P==="error"&&p(null)};return s.role==="user"?n.name?null:a.userAvatar?r.jsx(ne,{"data-type":"image",alt:"User avatar","data-role":s.role,src:a.userAvatar,...t}):r.jsx(Ri.default,{"data-type":"icon","data-role":s.role,...t}):h?r.jsx(ne,{src:h,alt:"AI assistant avatar","data-type":"image","data-role":s.role,onLoadingStatusChange:v.composeEventHandlers(e,b),...o}):r.jsx(Di.default,{"data-type":"icon","data-role":s.role,...t})}),So=i.ikp("span",{_id:"aiChatMessageName"}),Ve=t=>{const{message:e}=I.useMessage(),{aiChatSettings:o}=F.useInkeepConfig(),{aiAssistantName:a}=o;return r.jsx(So,{"data-role":e.role,children:e.role==="user"?"You":a||"AI assistant",...t})},Mo=i.ikp("div",{_id:"aiChatMessageContentWrapper"}),We=t=>{const{message:e}=I.useMessage();return r.jsx(Mo,{"data-role":e.role,...t})},xo=i.ikp("div",{_id:"aiChatMessageContent"}),Qe=t=>{const{message:e}=I.useMessage();return r.jsx(xo,{"data-role":e.role,...t})},Ue=t=>{const{text:e,componentStyles:o,...a}=t,{aiChatSettings:n}=F.useInkeepConfig(),{shouldOpenLinksInNewTab:s}=n;return r.jsx($.Markdown,{children:e,componentStyles:o,shouldOpenLinksInNewTab:s,...a})},$e=({name:t,props:e,componentDef:o})=>{const n=Gi.useShadow()?.shadowHost,s=u.useRef(void 0),d=u.useRef(null),c=u.useRef(null),m=u.useRef(!1),[l,h]=u.useState(!1),[p,b]=u.useState(!1),P=u.useRef(o);u.useMemo(()=>{o!==P.current&&(typeof o=="function"&&typeof P.current=="function"?o.toString()!==P.current.toString()&&(P.current=o):P.current=o)},[o]);const _=P.current,f=u.useRef(e);f.current=e;const S=u.useRef(null),j=u.useRef(_);j.current!==_&&(S.current=null,j.current=_),u.useEffect(()=>{s.current||(s.current=`dyn:${t}:${crypto.randomUUID()}`,h(!0))},[t]),u.useLayoutEffect(()=>{if(!_||!n||!l||!s.current)return;const w=s.current,M=document.createElement("div");return M.setAttribute("data-ikp-component",""),M.setAttribute("data-component",t),M.setAttribute("slot",w),d.current=M,m.current=!1,n.appendChild(M),b(!0),()=>{m.current=!0,b(!1),queueMicrotask(()=>{try{c.current&&(c.current.unmount(),c.current=null)}catch(L){console.debug("Ignoring unmount error:",L)}M.parentNode===n&&M.remove(),d.current=null})}},[_,n,l,t]);const V=w=>{const M=d.current;if(!M||m.current)return;const L=R=>{if(S.current!==null)return S.current;if(typeof R!="function"||R.length>1)return S.current=!1,!1;try{if(R.constructor===Function){const Ai=R({});return S.current=u.isValidElement(Ai),S.current}return S.current=!1,!1}catch{return S.current=!0,!0}};let T;const D=P.current;if(L(D))try{T=u.createElement(D,w||{})}catch(R){console.error("Error creating React element from component:",R);return}else if(typeof D=="function")T=D(w||{},M,null);else{console.error("Invalid component definition");return}if(u.isValidElement(T)||typeof T=="string"){if(m.current)return;c.current||(c.current=Ji.createRoot(M)),!m.current&&c.current&&c.current.render(T);return}c.current&&!m.current&&c.current.render(null)};return u.useEffect(()=>{V(f.current)},[_,p]),u.useEffect(()=>{!c.current||m.current||V(e)},[e]),r.jsx("slot",{name:s.current})},fo=i.ikp("div",{_id:"aiChatMessagePart"}),Ao=i.ikp("div",{_id:"aiChatMessageToolbar"}),Ke=t=>{const{isLoading:e,messages:o}=E.useChat(),{message:a}=I.useMessage();return o.at(-1)?.id===a?.id&&e||a.role==="user"?null:r.jsx(Ao,{...t})},yo=i.ikp("div",{_id:"aiChatMessageCustomActions"}),ze=t=>{const{children:e,...o}=t,{aiChatSettings:a}=F.useInkeepConfig(),{message:n}=I.useMessage(),{isStreaming:s,messages:d}=E.useChat(),c=d.at(-1)?.id===n?.id,m=n.role==="assistant",l=a.messageActions||[];return c&&s||!m?null:r.jsx(yo,{children:C.maybeRender(e,l),...o})},To=i.ikp("a",{_id:"aiChatMessageCustomAction"}),Ho=i.ikp("button",{_id:"aiChatMessageCustomAction"}),Ge=t=>{const{onClick:e,action:o,...a}=t,{message:n}=I.useMessage(),{handleAction:s}=X.useChatAction(o,n.id),{logEvent:d}=ie.useBaseEvents(),{conversationId:c}=E.useChat(),m=()=>{s(),d({eventName:"user_escalation_indicated",properties:{escalationType:"contact_us",conversationId:c}})},l=o.label,h=r.jsxs(r.Fragment,{children:[o.icon&&r.jsx(N.BuiltInIconRenderer,{iconSettings:o.icon}),l]});return o.action.type==="open_link"?r.jsx(To,{href:o.action.url,target:"_blank",rel:"noopener","data-type":o.action.type,onClick:v.composeEventHandlers(e,m),children:h,...a}):r.jsx(Ho,{"data-type":o.action.type,onClick:v.composeEventHandlers(e,m),children:h,...a})},jo=i.ikp("button",{_id:"aiChatMessageAction"}),Ye=t=>{const{action:e,onClick:o,className:a,...n}=t,{conversationId:s}=E.useChat(),{message:d}=I.useMessage(),{isStreaming:c,messages:m}=E.useChat(),[l,h]=Y.useCopyToClipboard(),{feedback:p,submitPositiveFeedback:b,setCurrentFeedback:P,currentFeedback:_}=J.useMessageFeedback(),{logEvent:f}=ie.useBaseEvents(),[S,j]=Ni.useSettleAction(),V=m.at(-1)?.id===d?.id,w=d.role==="assistant";if(V&&c||!w)return null;const L={copy(){h(C.getMessageContent(d)),f({eventName:"assistant_message_copied",properties:{conversationId:s}})},upvote(){b(d.id).then(()=>{j()})},downvote(){P(d.id)}},T={copy:"Copy Message",upvote:"Upvote Message",downvote:"Downvote Message"},D={copy:r.jsx(A.CustomIcon,{iconKey:l?"messageCopied":"messageCopy"}),upvote:r.jsx(A.CustomIcon,{iconKey:S?"messageCopied":"thumbsUp"}),downvote:r.jsx(A.CustomIcon,{iconKey:"thumbsDown"})},R={copy:{"data-copied":C.dataAttr(l)},upvote:{"data-upvoted":C.dataAttr(p[d.id]?.type==="positive")},downvote:{"data-downvoted":C.dataAttr(p[d.id]?.type==="negative"),"data-state":_===null?"closed":"open"}};return r.jsx(jo,{"data-action":e,...R[e],children:D[e],"aria-label":T[e],className:`${a} ${e}`,onClick:v.composeEventHandlers(o,L[e]),...n})},wo=i.ikp("div",{_id:"aiChatMessageSources"}),Ze=t=>{const{message:e}=I.useMessage();return e.role!=="assistant"||!e.parts.filter(C.isCitationArtifact)?.length?null:r.jsx(wo,{...t})},Lo=i.ikp("div",{_id:"aiChatMessageSources__Header"}),Je=t=>r.jsx(Lo,{children:"Sources",...t}),Do=i.ikp("div",{_id:"aiChatMessageSources__List"}),Xe=t=>{const{message:e}=I.useMessage(),{children:o,...a}=t,{baseSettings:{transformSource:n,organizationDisplayName:s},aiChatSettings:{shouldOpenLinksInNewTab:d},searchSettings:{tabs:c}}=F.useInkeepConfig();if(e.role!=="assistant")return null;const m=e.parts.filter(C.isCitationArtifact);if(!m?.length)return null;const l=new Map,h=m.filter(p=>{const b=p.data.artifactSummary.url;return!b||l.has(b)?!1:(l.set(b,!0),!0)}).map(p=>{const b=p.data,P={id:b?.artifactId,title:b?.artifactSummary?.title||b?.name,url:b?.artifactSummary?.url||"",description:"",breadcrumbs:[],type:b?.artifactSummary?.record_type,contentType:b?.artifactType,tag:b?.artifactType},f=(n??(j=>({...j,shouldOpenInNewTab:d,icon:Yi.getIcon(j)})))(P,"chatSourceItem",{organizationDisplayName:s,tabs:c}),S=f.shouldOpenInNewTab!==void 0?f.shouldOpenInNewTab:d;return{...f,isExternal:S}});return r.jsx(Do,{children:C.maybeRender(o,h),...a})},Ro=i.ikp(Bi.LinkWithQueryParams,{_id:"aiChatMessageSourceItem"}),et=t=>{const{source:e,onClick:o,...a}=t,{logEvent:n}=ie.useBaseEvents(),{conversationId:s}=E.useChat(),d=()=>{n({eventName:"assistant_source_item_clicked",properties:{conversationId:s,link:e}})};return r.jsx(B.SourceItemProvider,{source:e,children:r.jsx(Ro,{"data-type":e.type,appendToUrl:e.appendToUrl,isExternal:e.isExternal,"data-breadcrumbs":!!e.breadcrumbs?.length,onClick:v.composeEventHandlers(o,d),...a})})},Bo=i.ikp("div",{_id:"aiChatMessageSourceItem__Breadcrumbs"}),tt=t=>{const{source:e}=B.useSourceItem();return e.breadcrumbs?.length?r.jsx(Bo,{"data-type":e.type,...t}):null},qo=i.ikp(A.CustomIcon,{_id:"aiChatMessageSourceItem__BreadcrumbIcon",iconKey:"breadcrumbSeparator"}),No=i.ikp(N.BuiltInIconRenderer,{_id:"aiChatMessageSourceItem__Icon"}),it=t=>{const{source:e}=B.useSourceItem();return r.jsx(No,{iconSettings:e.icon,"data-type":e.type,...t})},Oo=i.ikp("span",{_id:"aiChatMessageSourceItem__Title"}),ot=t=>{const{source:e}=B.useSourceItem();return r.jsx(Oo,{"data-type":e.type,children:e.title,...t})},Vo=i.ikp("span",{_id:"aiChatMessageSourceItem__Tag"}),rt=t=>{const{source:e}=B.useSourceItem();return r.jsx(Vo,{"data-type":e.type,...t})},Wo=i.ikp("span",{_id:"aiChatMessageSourceItem__Description"}),at=t=>{const{source:e}=B.useSourceItem(),{children:o,...a}=t,n=u.useMemo(()=>e.description?Wi.highlightEmphasis(e.description):[],[e.description]);return n.length?r.jsx(Wo,{"data-type":e.type,children:C.maybeRender(o,n),...a}):null},Qo=i.ikp("span",{_id:"aiChatMessageSourceItem__DescriptionPart"}),nt=t=>{const{part:e,...o}=t,{source:a}=B.useSourceItem();return typeof e=="string"?e:r.jsx(Qo,{"data-type":a.type,children:e.content,"data-highlighted":C.dataAttr(e.highlighted),...o})},Uo=i.ikp(A.CustomIcon,{_id:"aiChatMessageSourceItem__Indicator"}),st=t=>{const{source:e}=B.useSourceItem();return r.jsx(Uo,{iconKey:e.isExternal?"openLinkInNewTab":"openLinkInSameTab",...t})},dt=i.ikp("div",{_id:"aiChatFooter"}),ct=i.ikp("div",{_id:"aiChatInput__Group"}),$o=i.ikp("textarea",{_id:"aiChatInput"}),mt=u.forwardRef(({onChange:t,onKeyDown:e,...o},a)=>{const{handleInputChange:n,handleInputKeyDown:s,input:d,error:c,shouldAutoFocusInput:m,inputRef:l}=E.useChat(),{aiChatSettings:h}=F.useInkeepConfig(),p=ee.useComposedRefs(a,l);return zi.useWidgetAutoFocus("chat",l,m),r.jsx($o,{asChild:!0,ref:p,maxLength:99999,placeholder:h.placeholder,value:d,onChange:v.composeEventHandlers(t,n),onKeyDown:v.composeEventHandlers(e,s),disabled:!!c||h.isViewOnly,...o,children:r.jsx(se,{})})}),Ko=i.ikp("button",{_id:"aiChatInput__SendButton"}),lt=t=>{const{handleSubmit:e,isSubmitDisabled:o,error:a}=E.useChat(),{aiChatSettings:n}=F.useInkeepConfig(),{onClick:s,...d}=t;return r.jsx(Ko,{onClick:v.composeEventHandlers(s,()=>e()),"aria-label":"Send message",disabled:o||!!a||n.isViewOnly,...d})},ut=i.ikp(A.CustomIcon,{_id:"aiChatInput__SendButtonIcon",iconKey:"chatSubmit"}),Ct=i.ikp("div",{_id:"aiChatActionBar"}),ht=i.ikp("div",{_id:"aiChat__ChatActions"}),bt=i.ikp("div",{_id:"aiChatTagline__Container"}),pt=i.ikp("span",{_id:"aiChatTagline__Text",children:"Powered by"}),vt=i.ikp("a",{_id:"aiChatTagline__Logo",href:"https://www.inkeep.com/",target:"_blank",rel:"noopener noreferrer","aria-label":"Inkeep"}),zo=i.ikp(K.Trigger,{_id:"aiChat__ChatAction"}),z=t=>{const{action:e,onClick:o,className:a,...n}=t,{clear:s,stop:d,isBusy:c,messages:m}=E.useChat(),{conversationId:l}=E.useChat(),{aiChatSettings:h}=F.useInkeepConfig(),[p,b]=Y.useCopyToClipboard(),[P]=Y.useCopyToClipboard(),_=m.length>0;if({help:!1,copy:!_||!h.isCopyChatButtonVisible||c,share:!_||!h.isShareButtonVisible||!l||c,clear:!_||h.isViewOnly||c,stop:!c}[e])return null;const V={help:()=>{},copy:()=>{const M=m.map(L=>{const T=`**${L.role==="assistant"?"AI Assistant":"User"}**`,D=C.getMessageContent(L);return`${T}
|
|
5
|
+
How can I help?`,C={parts:[{type:"text",text:a.introMessage??`${d}${m}`}],id:Xi,...e,role:"assistant"};return r.jsx(re,{message:C,...o})}),Po=i.ikp("div",{_id:"aiChatMessageHeader"}),De=t=>{const{message:e}=I.useMessage();return r.jsx(Po,{"data-role":e.role,...t})},Eo=i.ikp("div",{_id:"aiChatMessageLoading",children:"Thinking..."}),Re=t=>r.jsx(Eo,{...t}),_o=i.ikp("div",{_id:"aiChatMessageAvatar"}),Be=t=>{const{message:e}=I.useMessage();return r.jsx(_o,{"data-role":e.role,...t})},Io=i.ikp(oe.Root,{_id:"aiChatMessageAvatarContent"}),qe=t=>{const{message:e}=I.useMessage(),{baseSettings:o}=F.useInkeepConfig();return r.jsx(Io,{"data-username":h.dataAttr(e.role==="user"&&!!o.userProperties.name),"data-role":e.role,...t})},ko=i.ikp(oe.Fallback,{_id:"aiChatMessageAvatarFallback"}),Ne=u.memo(t=>{const{baseSettings:e}=F.useInkeepConfig(),{message:o}=I.useMessage();return e.userProperties.name?r.jsx(ko,{"data-role":o.role,children:h.getInitials(e.userProperties.name),...t}):null}),ne=i.ikp(oe.Image,{_id:"aiChatMessageAvatarImage"}),Oe=u.memo(t=>{const{onLoadingStatusChange:e,...o}=t,{aiChatSettings:a,baseSettings:{userProperties:n}}=F.useInkeepConfig(),{message:s}=I.useMessage(),{aiAssistantAvatar:d}=a??{},c=typeof d=="string"?d:d?.light,m=(typeof d=="string"?d:d?.dark)??c,l=Ui.useColorModeValue(c,m),[C,p]=u.useState(l);u.useEffect(()=>{p(l)},[l]);const b=P=>{P==="error"&&p(null)};return s.role==="user"?n.name?null:a.userAvatar?r.jsx(ne,{"data-type":"image",alt:"User avatar","data-role":s.role,src:a.userAvatar,...t}):r.jsx(Ri.default,{"data-type":"icon","data-role":s.role,...t}):C?r.jsx(ne,{src:C,alt:"AI assistant avatar","data-type":"image","data-role":s.role,onLoadingStatusChange:v.composeEventHandlers(e,b),...o}):r.jsx(Di.default,{"data-type":"icon","data-role":s.role,...t})}),So=i.ikp("span",{_id:"aiChatMessageName"}),Ve=t=>{const{message:e}=I.useMessage(),{aiChatSettings:o}=F.useInkeepConfig(),{aiAssistantName:a}=o;return r.jsx(So,{"data-role":e.role,children:e.role==="user"?"You":a||"AI assistant",...t})},Mo=i.ikp("div",{_id:"aiChatMessageContentWrapper"}),We=t=>{const{message:e}=I.useMessage();return r.jsx(Mo,{"data-role":e.role,...t})},xo=i.ikp("div",{_id:"aiChatMessageContent"}),Qe=t=>{const{message:e}=I.useMessage();return r.jsx(xo,{"data-role":e.role,...t})},Ue=t=>{const{text:e,componentStyles:o,...a}=t,{aiChatSettings:n}=F.useInkeepConfig(),{shouldOpenLinksInNewTab:s}=n;return r.jsx($.Markdown,{children:e,componentStyles:o,shouldOpenLinksInNewTab:s,...a})},$e=({name:t,props:e,componentDef:o})=>{const n=Gi.useShadow()?.shadowHost,s=u.useRef(void 0),d=u.useRef(null),c=u.useRef(null),m=u.useRef(!1),[l,C]=u.useState(!1),[p,b]=u.useState(!1),P=u.useRef(o);u.useMemo(()=>{o!==P.current&&(typeof o=="function"&&typeof P.current=="function"?o.toString()!==P.current.toString()&&(P.current=o):P.current=o)},[o]);const _=P.current,f=u.useRef(e);f.current=e;const S=u.useRef(null),j=u.useRef(_);j.current!==_&&(S.current=null,j.current=_),u.useEffect(()=>{s.current||(s.current=`dyn:${t}:${crypto.randomUUID()}`,C(!0))},[t]),u.useLayoutEffect(()=>{if(!_||!n||!l||!s.current)return;const w=s.current,M=document.createElement("div");return M.setAttribute("data-ikp-component",""),M.setAttribute("data-component",t),M.setAttribute("slot",w),d.current=M,m.current=!1,n.appendChild(M),b(!0),()=>{m.current=!0,b(!1),queueMicrotask(()=>{try{c.current&&(c.current.unmount(),c.current=null)}catch(L){console.debug("Ignoring unmount error:",L)}M.parentNode===n&&M.remove(),d.current=null})}},[_,n,l,t]);const V=w=>{const M=d.current;if(!M||m.current)return;const L=R=>{if(S.current!==null)return S.current;if(typeof R!="function"||R.length>1)return S.current=!1,!1;try{if(R.constructor===Function){const Ai=R({});return S.current=u.isValidElement(Ai),S.current}return S.current=!1,!1}catch{return S.current=!0,!0}};let T;const D=P.current;if(L(D))try{T=u.createElement(D,w||{})}catch(R){console.error("Error creating React element from component:",R);return}else if(typeof D=="function")T=D(w||{},M,null);else{console.error("Invalid component definition");return}if(u.isValidElement(T)||typeof T=="string"){if(m.current)return;c.current||(c.current=Ji.createRoot(M)),!m.current&&c.current&&c.current.render(T);return}c.current&&!m.current&&c.current.render(null)};return u.useEffect(()=>{V(f.current)},[_,p]),u.useEffect(()=>{!c.current||m.current||V(e)},[e]),r.jsx("slot",{name:s.current})},fo=i.ikp("div",{_id:"aiChatMessagePart"}),Ao=i.ikp("div",{_id:"aiChatMessageToolbar"}),Ke=t=>{const{isLoading:e,messages:o}=E.useChat(),{message:a}=I.useMessage();return o.at(-1)?.id===a?.id&&e||a.role==="user"?null:r.jsx(Ao,{...t})},yo=i.ikp("div",{_id:"aiChatMessageCustomActions"}),ze=t=>{const{children:e,...o}=t,{aiChatSettings:a}=F.useInkeepConfig(),{message:n}=I.useMessage(),{isStreaming:s,messages:d}=E.useChat(),c=d.at(-1)?.id===n?.id,m=n.role==="assistant",l=a.messageActions||[];return c&&s||!m?null:r.jsx(yo,{children:h.maybeRender(e,l),...o})},To=i.ikp("a",{_id:"aiChatMessageCustomAction"}),Ho=i.ikp("button",{_id:"aiChatMessageCustomAction"}),Ge=t=>{const{onClick:e,action:o,...a}=t,{message:n}=I.useMessage(),{handleAction:s}=X.useChatAction(o,n.id),{logEvent:d}=ie.useBaseEvents(),{conversationId:c}=E.useChat(),m=()=>{s(),d({eventName:"user_escalation_indicated",properties:{escalationType:"contact_us",conversationId:c}})},l=o.label,C=r.jsxs(r.Fragment,{children:[o.icon&&r.jsx(N.BuiltInIconRenderer,{iconSettings:o.icon}),l]});return o.action.type==="open_link"?r.jsx(To,{href:o.action.url,target:"_blank",rel:"noopener","data-type":o.action.type,onClick:v.composeEventHandlers(e,m),children:C,...a}):r.jsx(Ho,{"data-type":o.action.type,onClick:v.composeEventHandlers(e,m),children:C,...a})},jo=i.ikp("button",{_id:"aiChatMessageAction"}),Ye=t=>{const{action:e,onClick:o,className:a,...n}=t,{conversationId:s}=E.useChat(),{message:d}=I.useMessage(),{isStreaming:c,messages:m}=E.useChat(),[l,C]=Y.useCopyToClipboard(),{feedback:p,submitPositiveFeedback:b,setCurrentFeedback:P,currentFeedback:_}=J.useMessageFeedback(),{logEvent:f}=ie.useBaseEvents(),[S,j]=Ni.useSettleAction(),V=m.at(-1)?.id===d?.id,w=d.role==="assistant";if(V&&c||!w)return null;const L={copy(){C(h.getMessageContent(d)),f({eventName:"assistant_message_copied",properties:{conversationId:s}})},upvote(){b(d.id).then(()=>{j()})},downvote(){P(d.id)}},T={copy:"Copy Message",upvote:"Upvote Message",downvote:"Downvote Message"},D={copy:r.jsx(A.CustomIcon,{iconKey:l?"messageCopied":"messageCopy"}),upvote:r.jsx(A.CustomIcon,{iconKey:S?"messageCopied":"thumbsUp"}),downvote:r.jsx(A.CustomIcon,{iconKey:"thumbsDown"})},R={copy:{"data-copied":h.dataAttr(l)},upvote:{"data-upvoted":h.dataAttr(p[d.id]?.type==="positive")},downvote:{"data-downvoted":h.dataAttr(p[d.id]?.type==="negative"),"data-state":_===null?"closed":"open"}};return r.jsx(jo,{"data-action":e,...R[e],children:D[e],"aria-label":T[e],className:`${a} ${e}`,onClick:v.composeEventHandlers(o,L[e]),...n})},wo=i.ikp("div",{_id:"aiChatMessageSources"}),Ze=t=>{const{message:e}=I.useMessage();return e.role!=="assistant"||!e.parts.filter(h.isCitationArtifact).filter(a=>!!a.data?.artifactSummary?.url)?.length?null:r.jsx(wo,{...t})},Lo=i.ikp("div",{_id:"aiChatMessageSources__Header"}),Je=t=>r.jsx(Lo,{children:"Sources",...t}),Do=i.ikp("div",{_id:"aiChatMessageSources__List"}),Xe=t=>{const{message:e}=I.useMessage(),{children:o,...a}=t,{baseSettings:{transformSource:n,organizationDisplayName:s},aiChatSettings:{shouldOpenLinksInNewTab:d},searchSettings:{tabs:c}}=F.useInkeepConfig();if(e.role!=="assistant")return null;const m=e.parts.filter(h.isCitationArtifact);if(!m?.length)return null;const l=new Map,C=m.filter(p=>{const b=p.data.artifactSummary.url;return!b||l.has(b)?!1:(l.set(b,!0),!0)}).map(p=>{const b=p.data,P={id:b?.artifactId,title:b?.artifactSummary?.title||b?.name,url:b?.artifactSummary?.url||"",description:"",breadcrumbs:[],type:b?.artifactSummary?.record_type,contentType:b?.artifactType,tag:b?.artifactType},f=(n??(j=>({...j,shouldOpenInNewTab:d,icon:Yi.getIcon(j)})))(P,"chatSourceItem",{organizationDisplayName:s,tabs:c}),S=f.shouldOpenInNewTab!==void 0?f.shouldOpenInNewTab:d;return{...f,isExternal:S}});return r.jsx(Do,{children:h.maybeRender(o,C),...a})},Ro=i.ikp(Bi.LinkWithQueryParams,{_id:"aiChatMessageSourceItem"}),et=t=>{const{source:e,onClick:o,...a}=t,{logEvent:n}=ie.useBaseEvents(),{conversationId:s}=E.useChat(),d=()=>{n({eventName:"assistant_source_item_clicked",properties:{conversationId:s,link:e}})};return r.jsx(B.SourceItemProvider,{source:e,children:r.jsx(Ro,{"data-type":e.type,appendToUrl:e.appendToUrl,isExternal:e.isExternal,"data-breadcrumbs":!!e.breadcrumbs?.length,onClick:v.composeEventHandlers(o,d),...a})})},Bo=i.ikp("div",{_id:"aiChatMessageSourceItem__Breadcrumbs"}),tt=t=>{const{source:e}=B.useSourceItem();return e.breadcrumbs?.length?r.jsx(Bo,{"data-type":e.type,...t}):null},qo=i.ikp(A.CustomIcon,{_id:"aiChatMessageSourceItem__BreadcrumbIcon",iconKey:"breadcrumbSeparator"}),No=i.ikp(N.BuiltInIconRenderer,{_id:"aiChatMessageSourceItem__Icon"}),it=t=>{const{source:e}=B.useSourceItem();return r.jsx(No,{iconSettings:e.icon,"data-type":e.type,...t})},Oo=i.ikp("span",{_id:"aiChatMessageSourceItem__Title"}),ot=t=>{const{source:e}=B.useSourceItem();return r.jsx(Oo,{"data-type":e.type,children:e.title,...t})},Vo=i.ikp("span",{_id:"aiChatMessageSourceItem__Tag"}),rt=t=>{const{source:e}=B.useSourceItem();return r.jsx(Vo,{"data-type":e.type,...t})},Wo=i.ikp("span",{_id:"aiChatMessageSourceItem__Description"}),at=t=>{const{source:e}=B.useSourceItem(),{children:o,...a}=t,n=u.useMemo(()=>e.description?Wi.highlightEmphasis(e.description):[],[e.description]);return n.length?r.jsx(Wo,{"data-type":e.type,children:h.maybeRender(o,n),...a}):null},Qo=i.ikp("span",{_id:"aiChatMessageSourceItem__DescriptionPart"}),nt=t=>{const{part:e,...o}=t,{source:a}=B.useSourceItem();return typeof e=="string"?e:r.jsx(Qo,{"data-type":a.type,children:e.content,"data-highlighted":h.dataAttr(e.highlighted),...o})},Uo=i.ikp(A.CustomIcon,{_id:"aiChatMessageSourceItem__Indicator"}),st=t=>{const{source:e}=B.useSourceItem();return r.jsx(Uo,{iconKey:e.isExternal?"openLinkInNewTab":"openLinkInSameTab",...t})},dt=i.ikp("div",{_id:"aiChatFooter"}),ct=i.ikp("div",{_id:"aiChatInput__Group"}),$o=i.ikp("textarea",{_id:"aiChatInput"}),mt=u.forwardRef(({onChange:t,onKeyDown:e,...o},a)=>{const{handleInputChange:n,handleInputKeyDown:s,input:d,error:c,shouldAutoFocusInput:m,inputRef:l}=E.useChat(),{aiChatSettings:C}=F.useInkeepConfig(),p=ee.useComposedRefs(a,l);return zi.useWidgetAutoFocus("chat",l,m),r.jsx($o,{asChild:!0,ref:p,maxLength:99999,placeholder:C.placeholder,value:d,onChange:v.composeEventHandlers(t,n),onKeyDown:v.composeEventHandlers(e,s),disabled:!!c||C.isViewOnly,...o,children:r.jsx(se,{})})}),Ko=i.ikp("button",{_id:"aiChatInput__SendButton"}),lt=t=>{const{handleSubmit:e,isSubmitDisabled:o,error:a}=E.useChat(),{aiChatSettings:n}=F.useInkeepConfig(),{onClick:s,...d}=t;return r.jsx(Ko,{onClick:v.composeEventHandlers(s,()=>e()),"aria-label":"Send message",disabled:o||!!a||n.isViewOnly,...d})},ut=i.ikp(A.CustomIcon,{_id:"aiChatInput__SendButtonIcon",iconKey:"chatSubmit"}),Ct=i.ikp("div",{_id:"aiChatActionBar"}),ht=i.ikp("div",{_id:"aiChat__ChatActions"}),bt=i.ikp("div",{_id:"aiChatTagline__Container"}),pt=i.ikp("span",{_id:"aiChatTagline__Text",children:"Powered by"}),vt=i.ikp("a",{_id:"aiChatTagline__Logo",href:"https://www.inkeep.com/",target:"_blank",rel:"noopener noreferrer","aria-label":"Inkeep"}),zo=i.ikp(K.Trigger,{_id:"aiChat__ChatAction"}),z=t=>{const{action:e,onClick:o,className:a,...n}=t,{clear:s,stop:d,isBusy:c,messages:m}=E.useChat(),{conversationId:l}=E.useChat(),{aiChatSettings:C}=F.useInkeepConfig(),[p,b]=Y.useCopyToClipboard(),[P]=Y.useCopyToClipboard(),_=m.length>0;if({help:!1,copy:!_||!C.isCopyChatButtonVisible||c,share:!_||!C.isShareButtonVisible||!l||c,clear:!_||C.isViewOnly||c,stop:!c}[e])return null;const V={help:()=>{},copy:()=>{const M=m.map(L=>{const T=`**${L.role==="assistant"?"AI Assistant":"User"}**`,D=h.getMessageContent(L);return`${T}
|
|
6
6
|
|
|
7
7
|
${D}`}).join(`
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
`);b(M)},share:async()=>{},clear:s,stop:d},w={copy:p,share:P};return r.jsx(K.Tooltip,{delayDuration:0,open:w[e],children:r.jsx(zo,{"data-type":e,"data-copied":C.dataAttr(p||P),className:`${a} ${e}`,children:r.jsx(ae,{action:e}),onClick:v.composeEventHandlers(o,V[e]),...n})})},Go=i.ikp("span",{_id:"aiChat__ChatActionLabel"}),ae=t=>{const{action:e,...o}=t,{aiChatSettings:a}=F.useInkeepConfig(),n=a.toolbarButtonLabels??{},s={help:n.getHelp??"Get Help",copy:n.copyChat??"Copy",share:n.share??"Share",clear:n.clear??"Clear",stop:n.stop??"Stop"};return r.jsx(Go,{children:s[e],...o})},Yo=i.ikp(K.TooltipContent,{_id:"aiChat__ChatActionFeeback"}),Ft=t=>{const{action:e,children:o,...a}=t,n={copy:"Copied!",share:"Link copied!"};return r.jsxs(Yo,{sideOffset:5,...a,children:[r.jsx(K.Arrow,{}),o||n[e]]})},Zo=i.ikp(q.Root,{_id:"aiChatHelpActions"}),gt=t=>{const{children:e,...o}=t,{aiChatSettings:a}=F.useInkeepConfig(),{getHelpOptions:n}=a;if(!n||(n??[]).length===0)return null;const{_pinned:s,_unpinned:d}=n.reduce((h,p)=>{const b=p.isPinnedToToolbar?"_pinned":"_unpinned";return{...h,[b]:[...h[b],p]}},{_pinned:[],_unpinned:[]}),c=d.length===1?[...s,d[0]]:s,m=d.length===1?[]:d,l=Z.useHelpMenuState();return r.jsx(Z.HelpMenuProvider,{value:l,children:r.jsx(Zo,{open:l.open,onOpenChange:l.setOpen,children:C.maybeRender(e,{pinned:c,unpinned:m}),...o})})},Jo=i.ikp(z,{_id:"aiChatHelpAction",action:"help"}),Xo=i.ikp("a",{_id:"aiChatHelpAction",target:"_blank",rel:"noreferrer"}),Pt=t=>{const{action:e,onClick:o,...a}=t,{handleAction:n,logHelpAction:s}=X.useChatAction(e),d=e.action.type,c={"aria-label":e.name,"data-name":e.name,children:e.name,onClick:v.composeEventHandlers(o,()=>{n(),s()}),...a};return d==="open_link"?r.jsx(Xo,{href:e.action.url,...c}):r.jsx(Jo,{...c})},er=i.ikp(q.Trigger,{_id:"aiChatHelpActions__Trigger"}),Et=u.memo(t=>{const{aiChatSettings:e}=F.useInkeepConfig();return r.jsx(z,{action:"help",...t,asChild:!0,children:r.jsx(er,{children:e.toolbarButtonLabels?.getHelp??"Get Help"})})}),tr=i.ikp(q.Content,{_id:"aiChatHelpActions__Menu"}),_t=t=>r.jsx(tr,{side:"top",sideOffset:8,align:"center",alignOffset:-10,...t}),It=i.ikp(q.Arrow,{_id:"aiChatHelpActions__MenuArrow"}),kt=t=>{const{action:e,onClick:o,...a}=t,{handleAction:n,logHelpAction:s}=X.useChatAction(e),{setOpen:d}=Z.useHelpMenu(),c=()=>{n({onOpenForm:()=>d(!1)}),s()},m=e.action.type,l=i.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:v.composeEventHandlers(o,c)});return r.jsx(l,{...a})},ir=i.ikp(N.BuiltInIconRenderer,{_id:"aiChatHelpActions_MenuItemIcon"}),St=t=>{const{action:e,...o}=t;return e.icon?r.jsx(ir,{iconSettings:e.icon,...o}):null},or=i.ikp(Q.Root,{_id:"aiChatFeedbackModal"}),Mt=t=>{const{onOpenChange:e,...o}=t,{currentFeedback:a,setCurrentFeedback:n}=J.useMessageFeedback();return r.jsx(or,{open:a!==null,onOpenChange:v.composeEventHandlers(e,()=>n(null)),...o})},xt=i.ikp(Q.Overlay,{_id:"aiChatFeedbackModal__Overlay"}),ft=i.ikp(Q.Content,{_id:"aiChatFeedbackModal__Content","aria-describedby":void 0}),At=i.ikp(Q.Title,{_id:"aiChatFeedbackModal__Header",children:"Feedback"}),yt=i.ikp(Q.Close,{_id:"aiChatFeedbackModal__Close",children:r.jsx(A.CustomIcon,{iconKey:"close"})}),Tt=i.ikp("div",{_id:"aiChatFeedbackModal__Body"}),rr=i.ikp("form",{_id:"aiChatFeedbackForm"}),Ht=t=>{const{onSubmit:e,...o}=t,{submitNegativeFeedback:a,currentFeedback:n,setCurrentFeedback:s}=J.useMessageFeedback(),d=c=>{c.preventDefault();const m=c.target,h=new FormData(m).get("details");n&&(a(n,h??void 0),s(null))};return r.jsx(rr,{onSubmit:v.composeEventHandlers(e,d),...o})},jt=i.ikp("div",{_id:"aiChatFeedbackForm__Field"}),wt=i.ikp("label",{_id:"aiChatFeedbackItem__Label",children:"Please provide details",htmlFor:"feedback-details"}),Lt=i.ikp("textarea",{_id:"aiChatFeedbackItem__Description",placeholder:"What didn't you like about this response?",name:"details",id:"feedback-details",autoFocus:!0}),Dt=i.ikp("button",{_id:"aiChatFeedbackForm__SubmitButton",children:"Submit",type:"submit"}),ar=i.ikp("div",{_id:"aiChatForm__Wrapper"}),Rt=t=>{const{form:e}=k.useChatForm();return e?r.jsx(ar,{...t}):null},nr=i.ikp("form",{_id:"aiChatForm"}),Bt=t=>{const{onSubmit:e,...o}=t,{conversationId:a,messages:n}=E.useChat(),{handleSubmit:s,isSuccess:d}=k.useChatForm();return d?null:r.jsx(nr,{onSubmit:v.composeEventHandlers(e,c=>s(c,{id:a,messages:n})),...o})},sr=i.ikp("button",{_id:"aiChatForm__Close",children:r.jsx(A.CustomIcon,{iconKey:"close"})}),qt=t=>{const{onClick:e,...o}=t,{closeForm:a}=k.useChatForm();return r.jsx(sr,{onClick:v.composeEventHandlers(e,a),...o})},Nt=i.ikp("div",{_id:"aiChatForm__Header"}),dr=i.ikp("h2",{_id:"aiChatForm__Heading"}),Ot=t=>{const{form:e}=k.useChatForm();return e?.heading?r.jsx(dr,{children:e.heading,...t}):null},cr=i.ikp($.Markdown,{_id:"aiChatForm__Description"}),Vt=t=>{const{form:e}=k.useChatForm();return e?.description?r.jsx(cr,{shouldOpenLinksInNewTab:!0,children:e.description,...t}):null},mr=i.ikp("div",{_id:"aiChatForm__Content"}),Wt=t=>{const{children:e,...o}=t,{getFields:a}=k.useChatForm(),{conversationId:n}=E.useChat(),s=a(n)||[];return r.jsx(mr,{children:C.maybeRender(e,s),...o})},lr=i.ikp("div",{_id:"aiChatForm__Field"}),Qt=t=>{const{field:e,autoFocus:o,...a}=t,{control:n,errors:s}=k.useChatForm();return r.jsx(Vi.Controller,{name:e.name,control:n,rules:{required:e.isRequired?`${e.label} is required.`:void 0},render:({field:d})=>{const c=d.value!==void 0||e.inputType==="file";return r.jsx(y.FormFieldProvider,{"data-invalid":C.dataAttr(!!s[e.name]),field:e,fieldProps:d,autoFocus:o,children:c&&r.jsx(lr,{"data-input-type":e.inputType,"data-hidden":C.dataAttr(e.isHidden),...a})})}})},ur=i.ikp("label",{_id:"aiChatForm__FieldLabel"}),Ut=t=>{const{field:e}=y.useFormField();return r.jsx(ur,{"data-required":C.dataAttr(e.isRequired),htmlFor:e.name,children:e.label,...t})},Cr=i.ikp("input",{_id:"aiChatForm__FieldText",type:"text"}),G=t=>{const{field:e,error:o,fieldProps:{onChange:a,onBlur:n,...s},autoFocus:d}=y.useFormField(),{onChange:c,onBlur:m,...l}=t;return r.jsx(Cr,{id:e.name,autoFocus:d,placeholder:"placeholder"in e?e.placeholder:void 0,"data-invalid":C.dataAttr(!!o),onChange:v.composeEventHandlers(c,a),onBlur:v.composeEventHandlers(m,n),...s,...l})},$t=i.ikp(G,{_id:"aiChatForm__FieldEmail",type:"email"}),hr=i.ikp("input",{_id:"aiChatForm__FieldFile",type:"file",multiple:!0}),Kt=t=>{const{field:e,error:o,fieldProps:{value:a,onChange:n,onBlur:s,...d},autoFocus:c}=y.useFormField(),{onChange:m,onBlur:l,...h}=t,p=b=>{const P=b.target.files;n(P)};return r.jsx(hr,{id:e.name,autoFocus:c,"data-value":a,"data-invalid":C.dataAttr(!!o),...h,...d,onChange:v.composeEventHandlers(m,p),onBlur:v.composeEventHandlers(l,s)})},zt=i.ikp(G,{_id:"aiChatForm__FieldTextArea",type:"textarea",asChild:!0,children:r.jsx(se,{maxRows:8})}),br=i.ikp(de.Root,{_id:"aiChatForm__FieldCheckbox"}),Gt=t=>{const{field:e,error:o,fieldProps:a,autoFocus:n}=y.useFormField(),{onCheckedChange:s,...d}=t;return r.jsx(br,{id:e.name,name:e.name,autoFocus:n,"data-invalid":C.dataAttr(!!o),checked:a.value,onCheckedChange:v.composeEventHandlers(s,a.onChange),...d})},Yt=i.ikp(de.Indicator,{_id:"aiChatForm__FieldCheckboxIndicator",children:r.jsx(qi.CheckboxIcon,{})}),pr=i.ikp(H.Root,{_id:"aiChatForm__FieldSelect"}),Zt=t=>{const{field:e,error:o,fieldProps:a}=y.useFormField(),{onValueChange:n,...s}=t;return r.jsx(pr,{name:e.name,"data-invalid":C.dataAttr(!!o),value:a.value,onValueChange:v.composeEventHandlers(n,a.onChange),...s})},Jt=i.ikp(H.Trigger,{_id:"aiChatForm__FieldSelect__Trigger"}),vr=i.ikp(H.Value,{_id:"aiChatForm__FieldSelect__Value"}),Xt=t=>{const{field:e}=y.useFormField();return r.jsx(vr,{placeholder:"placeholder"in e?e.placeholder:void 0,...t})},ei=i.ikp(H.Icon,{_id:"aiChatForm__FieldSelect__Icon",asChild:!0,children:r.jsx(N.BuiltInIconRenderer,{iconSettings:{builtIn:"LuChevronDown"}})}),ti=i.ikp(H.Content,{_id:"aiChatForm__FieldSelect__Content",position:"popper"}),ii=i.ikp(H.Viewport,{_id:"aiChatForm__FieldSelect__Viewport"}),oi=i.ikp(H.Item,{_id:"aiChatForm__FieldSelect__Item"}),ri=i.ikp(H.ItemText,{_id:"aiChatForm__FieldSelect__ItemText"}),ai=i.ikp(H.ItemIndicator,{_id:"aiChatForm__FieldSelect__ItemIndicator",asChild:!0,children:r.jsx(N.BuiltInIconRenderer,{iconSettings:{builtIn:"LuCheck"}})}),ni=t=>{const{field:e,error:o,fieldProps:a}=y.useFormField(),{onValueChange:n,...s}=t;if(e.inputType!=="combobox")return null;const d=e,{items:c,placeholder:m,multiple:l}=d,h=Array.isArray(a.value)?a.value:[],p={name:e.name,"data-invalid":C.dataAttr(!!o)||void 0,items:c,defaultValue:h,multiple:l??!1,placeholder:m,onValueChange:v.composeEventHandlers(n,b=>a.onChange(b.value)),...s};return r.jsx(x.ComboboxRoot,{...p})},Fr={_id:"aiChatForm__FieldCombobox__Control"},si=i.ikp(x.ComboboxControl,Fr),gr={_id:"aiChatForm__FieldCombobox__Input"},di=i.ikp(x.ComboboxInput,gr),Pr={_id:"aiChatForm__FieldCombobox__Trigger",children:r.jsx(N.BuiltInIconRenderer,{iconSettings:{builtIn:"LuChevronDown"}})},ci=i.ikp(x.ComboboxTrigger,Pr),Er={_id:"aiChatForm__FieldCombobox__SelectedTags"},mi=i.ikp(x.ComboboxSelectedTags,Er),_r={_id:"aiChatForm__FieldCombobox__Content"},li=i.ikp(x.ComboboxContent,_r),Ir={_id:"aiChatForm__FieldCombobox__Positioner"},ui=i.ikp(x.ComboboxPositioner,Ir),kr={_id:"aiChatForm__FieldCombobox__List"},Ci=i.ikp(x.ComboboxList,kr),hi=i.ikp(x.ComboboxItem,{_id:"aiChatForm__FieldCombobox__Item"}),bi=i.ikp(x.ComboboxItemText,{_id:"aiChatForm__FieldCombobox__ItemText"}),pi=i.ikp(x.ComboboxItemIndicator,{_id:"aiChatForm__FieldCombobox__ItemIndicator"}),vi=x.ComboboxListItems,Fi=i.ikp(x.ComboboxListEmpty,{_id:"aiChatForm__FieldCombobox__ListEmpty"}),Sr=i.ikp("p",{_id:"aiChatForm__FieldDescription"}),gi=t=>{const{field:e}=y.useFormField();return e.description?r.jsx(Sr,{children:e.description,...t}):null},Mr=i.ikp("span",{_id:"aiChatForm__FieldError"}),Pi=t=>{const{error:e}=y.useFormField();return e?r.jsx(Mr,{children:e.message?.toString(),...t}):null},xr=i.ikp("span",{_id:"aiChatForm__Error"}),Ei=t=>{const{formError:e}=k.useChatForm();return e?r.jsx(xr,{children:e.message,...t}):null},_i=i.ikp("div",{_id:"aiChatForm__Footer"}),fr=i.ikp("button",{_id:"aiChatForm__Cancel",children:"Cancel",type:"button"}),Ii=t=>{const{onClick:e,...o}=t,{closeForm:a}=k.useChatForm();return r.jsx(fr,{onClick:v.composeEventHandlers(e,a),...o})},Ar=i.ikp("button",{_id:"aiChatForm__Submit",children:"Submit",type:"submit"}),ki=t=>{const{onClick:e,...o}=t,{isSubmitting:a,form:n}=k.useChatForm(),s=n?.buttons.submit.label||"Submit";return r.jsx(Ar,{disabled:a,...o,children:s})},yr=i.ikp("div",{_id:"aiChatForm__Success"}),Si=t=>{const{isSuccess:e}=k.useChatForm();return e?r.jsx(yr,{...t}):null},Tr=i.ikp("h2",{_id:"aiChatForm__SuccessHeading"}),Mi=t=>{const{form:e}=k.useChatForm();return r.jsx(Tr,{children:e?.successView?.heading,...t})},Hr=i.ikp($.Markdown,{_id:"aiChatForm__SuccessMessage"}),xi=t=>{const{form:e}=k.useChatForm();return r.jsx(Hr,{shouldOpenLinksInNewTab:!0,children:e?.successView?.message,...t})},jr=i.ikp("button",{_id:"aiChatForm__SuccessButton"}),fi=t=>{const{onClick:e,...o}=t,{form:a,closeForm:n}=k.useChatForm(),s=a?.successView?.doneButton;if(!s)return null;const d=s.icon&&r.jsx(N.BuiltInIconRenderer,{iconSettings:s.icon}),c=s.label;return r.jsx(jr,{onClick:v.composeEventHandlers(e,n),children:r.jsxs(r.Fragment,{children:[d,c]}),...o})};exports.Provider=E.ChatProvider;exports.DropZone=g.EmbeddedChatPrimitiveDropZone;exports.FileContent=g.EmbeddedChatPrimitiveFileContent;exports.FileInput=g.EmbeddedChatPrimitiveFileInput;exports.FileItem=g.EmbeddedChatPrimitiveFileItem;exports.FileList=g.EmbeddedChatPrimitiveFileList;exports.FileName=g.EmbeddedChatPrimitiveFileName;exports.FilePreviewTrigger=g.EmbeddedChatPrimitiveFilePreviewTrigger;exports.FileRemove=g.EmbeddedChatPrimitiveFileRemove;exports.FileRemoveIcon=g.EmbeddedChatPrimitiveFileRemoveIcon;exports.FileThumbnail=g.EmbeddedChatPrimitiveFileThumbnail;exports.FileTypeIcon=g.EmbeddedChatPrimitiveFileTypeIcon;exports.FileUploadButton=g.EmbeddedChatPrimitiveFileUploadButton;exports.FileUploadButtonIcon=g.EmbeddedChatPrimitiveFileUploadButtonIcon;exports.InputFieldset=g.EmbeddedChatPrimitiveInputFieldset;exports.InputNotification=g.EmbeddedChatPrimitiveInputNotification;exports.InputNotificationClose=g.EmbeddedChatPrimitiveInputNotificationClose;exports.InputNotificationContent=g.EmbeddedChatPrimitiveInputNotificationContent;exports.InputNotificationHeader=g.EmbeddedChatPrimitiveInputNotificationHeader;exports.InputNotificationMessage=g.EmbeddedChatPrimitiveInputNotificationMessage;exports.InputNotificationTitle=g.EmbeddedChatPrimitiveInputNotificationTitle;exports.MessageFile=g.EmbeddedChatPrimitiveMessageFile;exports.MessageFiles=g.EmbeddedChatPrimitiveMessageFiles;exports.ImagePreviewModal=O.EmbeddedChatPrimitiveImagePreviewModal;exports.ImagePreviewModalClose=O.EmbeddedChatPrimitiveImagePreviewModalClose;exports.ImagePreviewModalContent=O.EmbeddedChatPrimitiveImagePreviewModalContent;exports.ImagePreviewModalFileName=O.EmbeddedChatPrimitiveImagePreviewModalFileName;exports.ImagePreviewModalFooter=O.EmbeddedChatPrimitiveImagePreviewModalFooter;exports.ImagePreviewModalImage=O.EmbeddedChatPrimitiveImagePreviewModalImage;exports.ImagePreviewModalOverlay=O.EmbeddedChatPrimitiveImagePreviewModalOverlay;exports.ActionBar=Ct;exports.Actions=ht;exports.ChatAction=z;exports.ChatActionFeedback=Ft;exports.ChatActionLabel=ae;exports.ChatHelpAction=Pt;exports.ChatHistoryButton=be;exports.ChatHistoryButtonIcon=he;exports.Content=ve;exports.ContentScrollArea=Fe;exports.ContentScrollAreaCorner=_e;exports.ContentScrollAreaScrollbar=Pe;exports.ContentScrollAreaThumb=Ee;exports.ContentScrollAreaViewport=ge;exports.Disclaimer=ke;exports.DisclaimerArrow=Ae;exports.DisclaimerContent=xe;exports.DisclaimerLabel=Se;exports.DisclaimerText=fe;exports.DisclaimerTrigger=Me;exports.DynamicComponent=$e;exports.EmbeddedChatPrimitiveActionBar=Ct;exports.EmbeddedChatPrimitiveActions=ht;exports.EmbeddedChatPrimitiveChatAction=z;exports.EmbeddedChatPrimitiveChatActionFeedback=Ft;exports.EmbeddedChatPrimitiveChatActionLabel=ae;exports.EmbeddedChatPrimitiveChatHelpAction=Pt;exports.EmbeddedChatPrimitiveChatHistoryButton=be;exports.EmbeddedChatPrimitiveChatHistoryButtonIcon=he;exports.EmbeddedChatPrimitiveContent=ve;exports.EmbeddedChatPrimitiveContentScrollArea=Fe;exports.EmbeddedChatPrimitiveContentScrollAreaCorner=_e;exports.EmbeddedChatPrimitiveContentScrollAreaScrollbar=Pe;exports.EmbeddedChatPrimitiveContentScrollAreaThumb=Ee;exports.EmbeddedChatPrimitiveContentScrollAreaViewport=ge;exports.EmbeddedChatPrimitiveDisclaimer=ke;exports.EmbeddedChatPrimitiveDisclaimerArrow=Ae;exports.EmbeddedChatPrimitiveDisclaimerContent=xe;exports.EmbeddedChatPrimitiveDisclaimerLabel=Se;exports.EmbeddedChatPrimitiveDisclaimerText=fe;exports.EmbeddedChatPrimitiveDisclaimerTrigger=Me;exports.EmbeddedChatPrimitiveDynamicComponent=$e;exports.EmbeddedChatPrimitiveExampleQuestion=je;exports.EmbeddedChatPrimitiveExampleQuestionButton=we;exports.EmbeddedChatPrimitiveExampleQuestions=ye;exports.EmbeddedChatPrimitiveExampleQuestionsLabel=Te;exports.EmbeddedChatPrimitiveExampleQuestionsList=He;exports.EmbeddedChatPrimitiveFeedbackField=jt;exports.EmbeddedChatPrimitiveFeedbackForm=Ht;exports.EmbeddedChatPrimitiveFeedbackItemDescription=Lt;exports.EmbeddedChatPrimitiveFeedbackItemLabel=wt;exports.EmbeddedChatPrimitiveFeedbackModal=Mt;exports.EmbeddedChatPrimitiveFeedbackModalBody=Tt;exports.EmbeddedChatPrimitiveFeedbackModalClose=yt;exports.EmbeddedChatPrimitiveFeedbackModalContent=ft;exports.EmbeddedChatPrimitiveFeedbackModalHeader=At;exports.EmbeddedChatPrimitiveFeedbackModalOverlay=xt;exports.EmbeddedChatPrimitiveFeedbackSubmitButton=Dt;exports.EmbeddedChatPrimitiveFooter=dt;exports.EmbeddedChatPrimitiveForm=Bt;exports.EmbeddedChatPrimitiveFormCancel=Ii;exports.EmbeddedChatPrimitiveFormClose=qt;exports.EmbeddedChatPrimitiveFormContent=Wt;exports.EmbeddedChatPrimitiveFormDescription=Vt;exports.EmbeddedChatPrimitiveFormError=Ei;exports.EmbeddedChatPrimitiveFormField=Qt;exports.EmbeddedChatPrimitiveFormFieldCheckbox=Gt;exports.EmbeddedChatPrimitiveFormFieldCheckboxIndicator=Yt;exports.EmbeddedChatPrimitiveFormFieldCombobox=ni;exports.EmbeddedChatPrimitiveFormFieldComboboxContent=li;exports.EmbeddedChatPrimitiveFormFieldComboboxControl=si;exports.EmbeddedChatPrimitiveFormFieldComboboxInput=di;exports.EmbeddedChatPrimitiveFormFieldComboboxItem=hi;exports.EmbeddedChatPrimitiveFormFieldComboboxItemIndicator=pi;exports.EmbeddedChatPrimitiveFormFieldComboboxItemText=bi;exports.EmbeddedChatPrimitiveFormFieldComboboxList=Ci;exports.EmbeddedChatPrimitiveFormFieldComboboxListEmpty=Fi;exports.EmbeddedChatPrimitiveFormFieldComboboxListItems=vi;exports.EmbeddedChatPrimitiveFormFieldComboboxPositioner=ui;exports.EmbeddedChatPrimitiveFormFieldComboboxSelectedTags=mi;exports.EmbeddedChatPrimitiveFormFieldComboboxTrigger=ci;exports.EmbeddedChatPrimitiveFormFieldDescription=gi;exports.EmbeddedChatPrimitiveFormFieldEmail=$t;exports.EmbeddedChatPrimitiveFormFieldError=Pi;exports.EmbeddedChatPrimitiveFormFieldFile=Kt;exports.EmbeddedChatPrimitiveFormFieldLabel=Ut;exports.EmbeddedChatPrimitiveFormFieldSelect=Zt;exports.EmbeddedChatPrimitiveFormFieldSelectContent=ti;exports.EmbeddedChatPrimitiveFormFieldSelectIcon=ei;exports.EmbeddedChatPrimitiveFormFieldSelectItem=oi;exports.EmbeddedChatPrimitiveFormFieldSelectItemIndicator=ai;exports.EmbeddedChatPrimitiveFormFieldSelectItemText=ri;exports.EmbeddedChatPrimitiveFormFieldSelectTrigger=Jt;exports.EmbeddedChatPrimitiveFormFieldSelectValue=Xt;exports.EmbeddedChatPrimitiveFormFieldSelectViewport=ii;exports.EmbeddedChatPrimitiveFormFieldText=G;exports.EmbeddedChatPrimitiveFormFieldTextArea=zt;exports.EmbeddedChatPrimitiveFormFooter=_i;exports.EmbeddedChatPrimitiveFormHeader=Nt;exports.EmbeddedChatPrimitiveFormHeading=Ot;exports.EmbeddedChatPrimitiveFormSubmit=ki;exports.EmbeddedChatPrimitiveFormSuccess=Si;exports.EmbeddedChatPrimitiveFormSuccessButton=fi;exports.EmbeddedChatPrimitiveFormSuccessHeading=Mi;exports.EmbeddedChatPrimitiveFormSuccessMessage=xi;exports.EmbeddedChatPrimitiveFormWrapper=Rt;exports.EmbeddedChatPrimitiveHeaderToolbar=ue;exports.EmbeddedChatPrimitiveHelpActions=gt;exports.EmbeddedChatPrimitiveHelpActionsMenu=_t;exports.EmbeddedChatPrimitiveHelpActionsMenuArrow=It;exports.EmbeddedChatPrimitiveHelpActionsMenuItem=kt;exports.EmbeddedChatPrimitiveHelpActionsMenuItemIcon=St;exports.EmbeddedChatPrimitiveHelpActionsTrigger=Et;exports.EmbeddedChatPrimitiveInput=mt;exports.EmbeddedChatPrimitiveInputGroup=ct;exports.EmbeddedChatPrimitiveIntroMessageWrapper=Le;exports.EmbeddedChatPrimitiveMarkdown=Ue;exports.EmbeddedChatPrimitiveMessageAction=Ye;exports.EmbeddedChatPrimitiveMessageAvatar=Be;exports.EmbeddedChatPrimitiveMessageAvatarContent=qe;exports.EmbeddedChatPrimitiveMessageAvatarFallback=Ne;exports.EmbeddedChatPrimitiveMessageAvatarImage=Oe;exports.EmbeddedChatPrimitiveMessageContent=Qe;exports.EmbeddedChatPrimitiveMessageContentWrapper=We;exports.EmbeddedChatPrimitiveMessageCustomAction=Ge;exports.EmbeddedChatPrimitiveMessageCustomActions=ze;exports.EmbeddedChatPrimitiveMessageHeader=De;exports.EmbeddedChatPrimitiveMessageLoading=Re;exports.EmbeddedChatPrimitiveMessageName=Ve;exports.EmbeddedChatPrimitiveMessageSourceItem=et;exports.EmbeddedChatPrimitiveMessageSourceItemBreadcrumbs=tt;exports.EmbeddedChatPrimitiveMessageSourceItemDescription=at;exports.EmbeddedChatPrimitiveMessageSourceItemDescriptionPart=nt;exports.EmbeddedChatPrimitiveMessageSourceItemIcon=it;exports.EmbeddedChatPrimitiveMessageSourceItemIndicator=st;exports.EmbeddedChatPrimitiveMessageSourceItemTag=rt;exports.EmbeddedChatPrimitiveMessageSourceItemTitle=ot;exports.EmbeddedChatPrimitiveMessageSources=Ze;exports.EmbeddedChatPrimitiveMessageSourcesHeader=Je;exports.EmbeddedChatPrimitiveMessageSourcesList=Xe;exports.EmbeddedChatPrimitiveMessageToolbar=Ke;exports.EmbeddedChatPrimitiveMessageWrapper=re;exports.EmbeddedChatPrimitiveMessages=Ie;exports.EmbeddedChatPrimitiveRoot=le;exports.EmbeddedChatPrimitiveSendButton=lt;exports.EmbeddedChatPrimitiveSendButtonIcon=ut;exports.EmbeddedChatPrimitiveTaglineContainer=bt;exports.EmbeddedChatPrimitiveTaglineLogo=vt;exports.EmbeddedChatPrimitiveTaglineText=pt;exports.EmbeddedChatPrimitiveToolbarHeader=pe;exports.EmbeddedChatPrimitiveToolbarHeaderWrapper=Ce;exports.EmbeddedChatPrimitiveWrapper=me;exports.ExampleQuestion=je;exports.ExampleQuestionButton=we;exports.ExampleQuestions=ye;exports.ExampleQuestionsLabel=Te;exports.ExampleQuestionsList=He;exports.FeedbackField=jt;exports.FeedbackForm=Ht;exports.FeedbackItemDescription=Lt;exports.FeedbackItemLabel=wt;exports.FeedbackModal=Mt;exports.FeedbackModalBody=Tt;exports.FeedbackModalClose=yt;exports.FeedbackModalContent=ft;exports.FeedbackModalHeader=At;exports.FeedbackModalOverlay=xt;exports.FeedbackSubmitButton=Dt;exports.Footer=dt;exports.Form=Bt;exports.FormCancel=Ii;exports.FormClose=qt;exports.FormContent=Wt;exports.FormDescription=Vt;exports.FormError=Ei;exports.FormField=Qt;exports.FormFieldCheckbox=Gt;exports.FormFieldCheckboxIndicator=Yt;exports.FormFieldCombobox=ni;exports.FormFieldComboboxContent=li;exports.FormFieldComboboxControl=si;exports.FormFieldComboboxInput=di;exports.FormFieldComboboxItem=hi;exports.FormFieldComboboxItemIndicator=pi;exports.FormFieldComboboxItemText=bi;exports.FormFieldComboboxList=Ci;exports.FormFieldComboboxListEmpty=Fi;exports.FormFieldComboboxListItems=vi;exports.FormFieldComboboxPositioner=ui;exports.FormFieldComboboxSelectedTags=mi;exports.FormFieldComboboxTrigger=ci;exports.FormFieldDescription=gi;exports.FormFieldEmail=$t;exports.FormFieldError=Pi;exports.FormFieldFile=Kt;exports.FormFieldLabel=Ut;exports.FormFieldSelect=Zt;exports.FormFieldSelectContent=ti;exports.FormFieldSelectIcon=ei;exports.FormFieldSelectItem=oi;exports.FormFieldSelectItemIndicator=ai;exports.FormFieldSelectItemText=ri;exports.FormFieldSelectTrigger=Jt;exports.FormFieldSelectValue=Xt;exports.FormFieldSelectViewport=ii;exports.FormFieldText=G;exports.FormFieldTextArea=zt;exports.FormFooter=_i;exports.FormHeader=Nt;exports.FormHeading=Ot;exports.FormSubmit=ki;exports.FormSuccess=Si;exports.FormSuccessButton=fi;exports.FormSuccessHeading=Mi;exports.FormSuccessMessage=xi;exports.FormWrapper=Rt;exports.Header=oo;exports.HeaderToolbar=ue;exports.HeaderToolbarWrapper=Ce;exports.HelpActions=gt;exports.HelpActionsMenu=_t;exports.HelpActionsMenuArrow=It;exports.HelpActionsMenuItem=kt;exports.HelpActionsMenuItemIcon=St;exports.HelpActionsTrigger=Et;exports.Input=mt;exports.InputGroup=ct;exports.IntroMessageWrapper=Le;exports.Markdown=Ue;exports.MessageAction=Ye;exports.MessageAvatar=Be;exports.MessageAvatarContent=qe;exports.MessageAvatarFallback=Ne;exports.MessageAvatarImage=Oe;exports.MessageContent=Qe;exports.MessageContentWrapper=We;exports.MessageCustomAction=Ge;exports.MessageCustomActions=ze;exports.MessageHeader=De;exports.MessageLoading=Re;exports.MessageName=Ve;exports.MessageSourceItem=et;exports.MessageSourceItemBreadcrumbIcon=qo;exports.MessageSourceItemBreadcrumbs=tt;exports.MessageSourceItemDescription=at;exports.MessageSourceItemDescriptionPart=nt;exports.MessageSourceItemIcon=it;exports.MessageSourceItemIndicator=st;exports.MessageSourceItemTag=rt;exports.MessageSourceItemTitle=ot;exports.MessageSources=Ze;exports.MessageSourcesHeader=Je;exports.MessageSourcesList=Xe;exports.MessageToolbar=Ke;exports.MessageWrapper=re;exports.Messages=Ie;exports.PrimitiveMessagePart=fo;exports.Root=le;exports.SendButton=lt;exports.SendButtonIcon=ut;exports.TaglineContainer=bt;exports.TaglineLogo=vt;exports.TaglineText=pt;exports.ToolbarHeader=pe;exports.Wrapper=me;
|
|
11
|
+
`);b(M)},share:async()=>{},clear:s,stop:d},w={copy:p,share:P};return r.jsx(K.Tooltip,{delayDuration:0,open:w[e],children:r.jsx(zo,{"data-type":e,"data-copied":h.dataAttr(p||P),className:`${a} ${e}`,children:r.jsx(ae,{action:e}),onClick:v.composeEventHandlers(o,V[e]),...n})})},Go=i.ikp("span",{_id:"aiChat__ChatActionLabel"}),ae=t=>{const{action:e,...o}=t,{aiChatSettings:a}=F.useInkeepConfig(),n=a.toolbarButtonLabels??{},s={help:n.getHelp??"Get Help",copy:n.copyChat??"Copy",share:n.share??"Share",clear:n.clear??"Clear",stop:n.stop??"Stop"};return r.jsx(Go,{children:s[e],...o})},Yo=i.ikp(K.TooltipContent,{_id:"aiChat__ChatActionFeeback"}),Ft=t=>{const{action:e,children:o,...a}=t,n={copy:"Copied!",share:"Link copied!"};return r.jsxs(Yo,{sideOffset:5,...a,children:[r.jsx(K.Arrow,{}),o||n[e]]})},Zo=i.ikp(q.Root,{_id:"aiChatHelpActions"}),gt=t=>{const{children:e,...o}=t,{aiChatSettings:a}=F.useInkeepConfig(),{getHelpOptions:n}=a;if(!n||(n??[]).length===0)return null;const{_pinned:s,_unpinned:d}=n.reduce((C,p)=>{const b=p.isPinnedToToolbar?"_pinned":"_unpinned";return{...C,[b]:[...C[b],p]}},{_pinned:[],_unpinned:[]}),c=d.length===1?[...s,d[0]]:s,m=d.length===1?[]:d,l=Z.useHelpMenuState();return r.jsx(Z.HelpMenuProvider,{value:l,children:r.jsx(Zo,{open:l.open,onOpenChange:l.setOpen,children:h.maybeRender(e,{pinned:c,unpinned:m}),...o})})},Jo=i.ikp(z,{_id:"aiChatHelpAction",action:"help"}),Xo=i.ikp("a",{_id:"aiChatHelpAction",target:"_blank",rel:"noreferrer"}),Pt=t=>{const{action:e,onClick:o,...a}=t,{handleAction:n,logHelpAction:s}=X.useChatAction(e),d=e.action.type,c={"aria-label":e.name,"data-name":e.name,children:e.name,onClick:v.composeEventHandlers(o,()=>{n(),s()}),...a};return d==="open_link"?r.jsx(Xo,{href:e.action.url,...c}):r.jsx(Jo,{...c})},er=i.ikp(q.Trigger,{_id:"aiChatHelpActions__Trigger"}),Et=u.memo(t=>{const{aiChatSettings:e}=F.useInkeepConfig();return r.jsx(z,{action:"help",...t,asChild:!0,children:r.jsx(er,{children:e.toolbarButtonLabels?.getHelp??"Get Help"})})}),tr=i.ikp(q.Content,{_id:"aiChatHelpActions__Menu"}),_t=t=>r.jsx(tr,{side:"top",sideOffset:8,align:"center",alignOffset:-10,...t}),It=i.ikp(q.Arrow,{_id:"aiChatHelpActions__MenuArrow"}),kt=t=>{const{action:e,onClick:o,...a}=t,{handleAction:n,logHelpAction:s}=X.useChatAction(e),{setOpen:d}=Z.useHelpMenu(),c=()=>{n({onOpenForm:()=>d(!1)}),s()},m=e.action.type,l=i.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:v.composeEventHandlers(o,c)});return r.jsx(l,{...a})},ir=i.ikp(N.BuiltInIconRenderer,{_id:"aiChatHelpActions_MenuItemIcon"}),St=t=>{const{action:e,...o}=t;return e.icon?r.jsx(ir,{iconSettings:e.icon,...o}):null},or=i.ikp(Q.Root,{_id:"aiChatFeedbackModal"}),Mt=t=>{const{onOpenChange:e,...o}=t,{currentFeedback:a,setCurrentFeedback:n}=J.useMessageFeedback();return r.jsx(or,{open:a!==null,onOpenChange:v.composeEventHandlers(e,()=>n(null)),...o})},xt=i.ikp(Q.Overlay,{_id:"aiChatFeedbackModal__Overlay"}),ft=i.ikp(Q.Content,{_id:"aiChatFeedbackModal__Content","aria-describedby":void 0}),At=i.ikp(Q.Title,{_id:"aiChatFeedbackModal__Header",children:"Feedback"}),yt=i.ikp(Q.Close,{_id:"aiChatFeedbackModal__Close",children:r.jsx(A.CustomIcon,{iconKey:"close"})}),Tt=i.ikp("div",{_id:"aiChatFeedbackModal__Body"}),rr=i.ikp("form",{_id:"aiChatFeedbackForm"}),Ht=t=>{const{onSubmit:e,...o}=t,{submitNegativeFeedback:a,currentFeedback:n,setCurrentFeedback:s}=J.useMessageFeedback(),d=c=>{c.preventDefault();const m=c.target,C=new FormData(m).get("details");n&&(a(n,C??void 0),s(null))};return r.jsx(rr,{onSubmit:v.composeEventHandlers(e,d),...o})},jt=i.ikp("div",{_id:"aiChatFeedbackForm__Field"}),wt=i.ikp("label",{_id:"aiChatFeedbackItem__Label",children:"Please provide details",htmlFor:"feedback-details"}),Lt=i.ikp("textarea",{_id:"aiChatFeedbackItem__Description",placeholder:"What didn't you like about this response?",name:"details",id:"feedback-details",autoFocus:!0}),Dt=i.ikp("button",{_id:"aiChatFeedbackForm__SubmitButton",children:"Submit",type:"submit"}),ar=i.ikp("div",{_id:"aiChatForm__Wrapper"}),Rt=t=>{const{form:e}=k.useChatForm();return e?r.jsx(ar,{...t}):null},nr=i.ikp("form",{_id:"aiChatForm"}),Bt=t=>{const{onSubmit:e,...o}=t,{conversationId:a,messages:n}=E.useChat(),{handleSubmit:s,isSuccess:d}=k.useChatForm();return d?null:r.jsx(nr,{onSubmit:v.composeEventHandlers(e,c=>s(c,{id:a,messages:n})),...o})},sr=i.ikp("button",{_id:"aiChatForm__Close",children:r.jsx(A.CustomIcon,{iconKey:"close"})}),qt=t=>{const{onClick:e,...o}=t,{closeForm:a}=k.useChatForm();return r.jsx(sr,{onClick:v.composeEventHandlers(e,a),...o})},Nt=i.ikp("div",{_id:"aiChatForm__Header"}),dr=i.ikp("h2",{_id:"aiChatForm__Heading"}),Ot=t=>{const{form:e}=k.useChatForm();return e?.heading?r.jsx(dr,{children:e.heading,...t}):null},cr=i.ikp($.Markdown,{_id:"aiChatForm__Description"}),Vt=t=>{const{form:e}=k.useChatForm();return e?.description?r.jsx(cr,{shouldOpenLinksInNewTab:!0,children:e.description,...t}):null},mr=i.ikp("div",{_id:"aiChatForm__Content"}),Wt=t=>{const{children:e,...o}=t,{getFields:a}=k.useChatForm(),{conversationId:n}=E.useChat(),s=a(n)||[];return r.jsx(mr,{children:h.maybeRender(e,s),...o})},lr=i.ikp("div",{_id:"aiChatForm__Field"}),Qt=t=>{const{field:e,autoFocus:o,...a}=t,{control:n,errors:s}=k.useChatForm();return r.jsx(Vi.Controller,{name:e.name,control:n,rules:{required:e.isRequired?`${e.label} is required.`:void 0},render:({field:d})=>{const c=d.value!==void 0||e.inputType==="file";return r.jsx(y.FormFieldProvider,{"data-invalid":h.dataAttr(!!s[e.name]),field:e,fieldProps:d,autoFocus:o,children:c&&r.jsx(lr,{"data-input-type":e.inputType,"data-hidden":h.dataAttr(e.isHidden),...a})})}})},ur=i.ikp("label",{_id:"aiChatForm__FieldLabel"}),Ut=t=>{const{field:e}=y.useFormField();return r.jsx(ur,{"data-required":h.dataAttr(e.isRequired),htmlFor:e.name,children:e.label,...t})},Cr=i.ikp("input",{_id:"aiChatForm__FieldText",type:"text"}),G=t=>{const{field:e,error:o,fieldProps:{onChange:a,onBlur:n,...s},autoFocus:d}=y.useFormField(),{onChange:c,onBlur:m,...l}=t;return r.jsx(Cr,{id:e.name,autoFocus:d,placeholder:"placeholder"in e?e.placeholder:void 0,"data-invalid":h.dataAttr(!!o),onChange:v.composeEventHandlers(c,a),onBlur:v.composeEventHandlers(m,n),...s,...l})},$t=i.ikp(G,{_id:"aiChatForm__FieldEmail",type:"email"}),hr=i.ikp("input",{_id:"aiChatForm__FieldFile",type:"file",multiple:!0}),Kt=t=>{const{field:e,error:o,fieldProps:{value:a,onChange:n,onBlur:s,...d},autoFocus:c}=y.useFormField(),{onChange:m,onBlur:l,...C}=t,p=b=>{const P=b.target.files;n(P)};return r.jsx(hr,{id:e.name,autoFocus:c,"data-value":a,"data-invalid":h.dataAttr(!!o),...C,...d,onChange:v.composeEventHandlers(m,p),onBlur:v.composeEventHandlers(l,s)})},zt=i.ikp(G,{_id:"aiChatForm__FieldTextArea",type:"textarea",asChild:!0,children:r.jsx(se,{maxRows:8})}),br=i.ikp(de.Root,{_id:"aiChatForm__FieldCheckbox"}),Gt=t=>{const{field:e,error:o,fieldProps:a,autoFocus:n}=y.useFormField(),{onCheckedChange:s,...d}=t;return r.jsx(br,{id:e.name,name:e.name,autoFocus:n,"data-invalid":h.dataAttr(!!o),checked:a.value,onCheckedChange:v.composeEventHandlers(s,a.onChange),...d})},Yt=i.ikp(de.Indicator,{_id:"aiChatForm__FieldCheckboxIndicator",children:r.jsx(qi.CheckboxIcon,{})}),pr=i.ikp(H.Root,{_id:"aiChatForm__FieldSelect"}),Zt=t=>{const{field:e,error:o,fieldProps:a}=y.useFormField(),{onValueChange:n,...s}=t;return r.jsx(pr,{name:e.name,"data-invalid":h.dataAttr(!!o),value:a.value,onValueChange:v.composeEventHandlers(n,a.onChange),...s})},Jt=i.ikp(H.Trigger,{_id:"aiChatForm__FieldSelect__Trigger"}),vr=i.ikp(H.Value,{_id:"aiChatForm__FieldSelect__Value"}),Xt=t=>{const{field:e}=y.useFormField();return r.jsx(vr,{placeholder:"placeholder"in e?e.placeholder:void 0,...t})},ei=i.ikp(H.Icon,{_id:"aiChatForm__FieldSelect__Icon",asChild:!0,children:r.jsx(N.BuiltInIconRenderer,{iconSettings:{builtIn:"LuChevronDown"}})}),ti=i.ikp(H.Content,{_id:"aiChatForm__FieldSelect__Content",position:"popper"}),ii=i.ikp(H.Viewport,{_id:"aiChatForm__FieldSelect__Viewport"}),oi=i.ikp(H.Item,{_id:"aiChatForm__FieldSelect__Item"}),ri=i.ikp(H.ItemText,{_id:"aiChatForm__FieldSelect__ItemText"}),ai=i.ikp(H.ItemIndicator,{_id:"aiChatForm__FieldSelect__ItemIndicator",asChild:!0,children:r.jsx(N.BuiltInIconRenderer,{iconSettings:{builtIn:"LuCheck"}})}),ni=t=>{const{field:e,error:o,fieldProps:a}=y.useFormField(),{onValueChange:n,...s}=t;if(e.inputType!=="combobox")return null;const d=e,{items:c,placeholder:m,multiple:l}=d,C=Array.isArray(a.value)?a.value:[],p={name:e.name,"data-invalid":h.dataAttr(!!o)||void 0,items:c,defaultValue:C,multiple:l??!1,placeholder:m,onValueChange:v.composeEventHandlers(n,b=>a.onChange(b.value)),...s};return r.jsx(x.ComboboxRoot,{...p})},Fr={_id:"aiChatForm__FieldCombobox__Control"},si=i.ikp(x.ComboboxControl,Fr),gr={_id:"aiChatForm__FieldCombobox__Input"},di=i.ikp(x.ComboboxInput,gr),Pr={_id:"aiChatForm__FieldCombobox__Trigger",children:r.jsx(N.BuiltInIconRenderer,{iconSettings:{builtIn:"LuChevronDown"}})},ci=i.ikp(x.ComboboxTrigger,Pr),Er={_id:"aiChatForm__FieldCombobox__SelectedTags"},mi=i.ikp(x.ComboboxSelectedTags,Er),_r={_id:"aiChatForm__FieldCombobox__Content"},li=i.ikp(x.ComboboxContent,_r),Ir={_id:"aiChatForm__FieldCombobox__Positioner"},ui=i.ikp(x.ComboboxPositioner,Ir),kr={_id:"aiChatForm__FieldCombobox__List"},Ci=i.ikp(x.ComboboxList,kr),hi=i.ikp(x.ComboboxItem,{_id:"aiChatForm__FieldCombobox__Item"}),bi=i.ikp(x.ComboboxItemText,{_id:"aiChatForm__FieldCombobox__ItemText"}),pi=i.ikp(x.ComboboxItemIndicator,{_id:"aiChatForm__FieldCombobox__ItemIndicator"}),vi=x.ComboboxListItems,Fi=i.ikp(x.ComboboxListEmpty,{_id:"aiChatForm__FieldCombobox__ListEmpty"}),Sr=i.ikp("p",{_id:"aiChatForm__FieldDescription"}),gi=t=>{const{field:e}=y.useFormField();return e.description?r.jsx(Sr,{children:e.description,...t}):null},Mr=i.ikp("span",{_id:"aiChatForm__FieldError"}),Pi=t=>{const{error:e}=y.useFormField();return e?r.jsx(Mr,{children:e.message?.toString(),...t}):null},xr=i.ikp("span",{_id:"aiChatForm__Error"}),Ei=t=>{const{formError:e}=k.useChatForm();return e?r.jsx(xr,{children:e.message,...t}):null},_i=i.ikp("div",{_id:"aiChatForm__Footer"}),fr=i.ikp("button",{_id:"aiChatForm__Cancel",children:"Cancel",type:"button"}),Ii=t=>{const{onClick:e,...o}=t,{closeForm:a}=k.useChatForm();return r.jsx(fr,{onClick:v.composeEventHandlers(e,a),...o})},Ar=i.ikp("button",{_id:"aiChatForm__Submit",children:"Submit",type:"submit"}),ki=t=>{const{onClick:e,...o}=t,{isSubmitting:a,form:n}=k.useChatForm(),s=n?.buttons.submit.label||"Submit";return r.jsx(Ar,{disabled:a,...o,children:s})},yr=i.ikp("div",{_id:"aiChatForm__Success"}),Si=t=>{const{isSuccess:e}=k.useChatForm();return e?r.jsx(yr,{...t}):null},Tr=i.ikp("h2",{_id:"aiChatForm__SuccessHeading"}),Mi=t=>{const{form:e}=k.useChatForm();return r.jsx(Tr,{children:e?.successView?.heading,...t})},Hr=i.ikp($.Markdown,{_id:"aiChatForm__SuccessMessage"}),xi=t=>{const{form:e}=k.useChatForm();return r.jsx(Hr,{shouldOpenLinksInNewTab:!0,children:e?.successView?.message,...t})},jr=i.ikp("button",{_id:"aiChatForm__SuccessButton"}),fi=t=>{const{onClick:e,...o}=t,{form:a,closeForm:n}=k.useChatForm(),s=a?.successView?.doneButton;if(!s)return null;const d=s.icon&&r.jsx(N.BuiltInIconRenderer,{iconSettings:s.icon}),c=s.label;return r.jsx(jr,{onClick:v.composeEventHandlers(e,n),children:r.jsxs(r.Fragment,{children:[d,c]}),...o})};exports.Provider=E.ChatProvider;exports.DropZone=g.EmbeddedChatPrimitiveDropZone;exports.FileContent=g.EmbeddedChatPrimitiveFileContent;exports.FileInput=g.EmbeddedChatPrimitiveFileInput;exports.FileItem=g.EmbeddedChatPrimitiveFileItem;exports.FileList=g.EmbeddedChatPrimitiveFileList;exports.FileName=g.EmbeddedChatPrimitiveFileName;exports.FilePreviewTrigger=g.EmbeddedChatPrimitiveFilePreviewTrigger;exports.FileRemove=g.EmbeddedChatPrimitiveFileRemove;exports.FileRemoveIcon=g.EmbeddedChatPrimitiveFileRemoveIcon;exports.FileThumbnail=g.EmbeddedChatPrimitiveFileThumbnail;exports.FileTypeIcon=g.EmbeddedChatPrimitiveFileTypeIcon;exports.FileUploadButton=g.EmbeddedChatPrimitiveFileUploadButton;exports.FileUploadButtonIcon=g.EmbeddedChatPrimitiveFileUploadButtonIcon;exports.InputFieldset=g.EmbeddedChatPrimitiveInputFieldset;exports.InputNotification=g.EmbeddedChatPrimitiveInputNotification;exports.InputNotificationClose=g.EmbeddedChatPrimitiveInputNotificationClose;exports.InputNotificationContent=g.EmbeddedChatPrimitiveInputNotificationContent;exports.InputNotificationHeader=g.EmbeddedChatPrimitiveInputNotificationHeader;exports.InputNotificationMessage=g.EmbeddedChatPrimitiveInputNotificationMessage;exports.InputNotificationTitle=g.EmbeddedChatPrimitiveInputNotificationTitle;exports.MessageFile=g.EmbeddedChatPrimitiveMessageFile;exports.MessageFiles=g.EmbeddedChatPrimitiveMessageFiles;exports.ImagePreviewModal=O.EmbeddedChatPrimitiveImagePreviewModal;exports.ImagePreviewModalClose=O.EmbeddedChatPrimitiveImagePreviewModalClose;exports.ImagePreviewModalContent=O.EmbeddedChatPrimitiveImagePreviewModalContent;exports.ImagePreviewModalFileName=O.EmbeddedChatPrimitiveImagePreviewModalFileName;exports.ImagePreviewModalFooter=O.EmbeddedChatPrimitiveImagePreviewModalFooter;exports.ImagePreviewModalImage=O.EmbeddedChatPrimitiveImagePreviewModalImage;exports.ImagePreviewModalOverlay=O.EmbeddedChatPrimitiveImagePreviewModalOverlay;exports.ActionBar=Ct;exports.Actions=ht;exports.ChatAction=z;exports.ChatActionFeedback=Ft;exports.ChatActionLabel=ae;exports.ChatHelpAction=Pt;exports.ChatHistoryButton=be;exports.ChatHistoryButtonIcon=he;exports.Content=ve;exports.ContentScrollArea=Fe;exports.ContentScrollAreaCorner=_e;exports.ContentScrollAreaScrollbar=Pe;exports.ContentScrollAreaThumb=Ee;exports.ContentScrollAreaViewport=ge;exports.Disclaimer=ke;exports.DisclaimerArrow=Ae;exports.DisclaimerContent=xe;exports.DisclaimerLabel=Se;exports.DisclaimerText=fe;exports.DisclaimerTrigger=Me;exports.DynamicComponent=$e;exports.EmbeddedChatPrimitiveActionBar=Ct;exports.EmbeddedChatPrimitiveActions=ht;exports.EmbeddedChatPrimitiveChatAction=z;exports.EmbeddedChatPrimitiveChatActionFeedback=Ft;exports.EmbeddedChatPrimitiveChatActionLabel=ae;exports.EmbeddedChatPrimitiveChatHelpAction=Pt;exports.EmbeddedChatPrimitiveChatHistoryButton=be;exports.EmbeddedChatPrimitiveChatHistoryButtonIcon=he;exports.EmbeddedChatPrimitiveContent=ve;exports.EmbeddedChatPrimitiveContentScrollArea=Fe;exports.EmbeddedChatPrimitiveContentScrollAreaCorner=_e;exports.EmbeddedChatPrimitiveContentScrollAreaScrollbar=Pe;exports.EmbeddedChatPrimitiveContentScrollAreaThumb=Ee;exports.EmbeddedChatPrimitiveContentScrollAreaViewport=ge;exports.EmbeddedChatPrimitiveDisclaimer=ke;exports.EmbeddedChatPrimitiveDisclaimerArrow=Ae;exports.EmbeddedChatPrimitiveDisclaimerContent=xe;exports.EmbeddedChatPrimitiveDisclaimerLabel=Se;exports.EmbeddedChatPrimitiveDisclaimerText=fe;exports.EmbeddedChatPrimitiveDisclaimerTrigger=Me;exports.EmbeddedChatPrimitiveDynamicComponent=$e;exports.EmbeddedChatPrimitiveExampleQuestion=je;exports.EmbeddedChatPrimitiveExampleQuestionButton=we;exports.EmbeddedChatPrimitiveExampleQuestions=ye;exports.EmbeddedChatPrimitiveExampleQuestionsLabel=Te;exports.EmbeddedChatPrimitiveExampleQuestionsList=He;exports.EmbeddedChatPrimitiveFeedbackField=jt;exports.EmbeddedChatPrimitiveFeedbackForm=Ht;exports.EmbeddedChatPrimitiveFeedbackItemDescription=Lt;exports.EmbeddedChatPrimitiveFeedbackItemLabel=wt;exports.EmbeddedChatPrimitiveFeedbackModal=Mt;exports.EmbeddedChatPrimitiveFeedbackModalBody=Tt;exports.EmbeddedChatPrimitiveFeedbackModalClose=yt;exports.EmbeddedChatPrimitiveFeedbackModalContent=ft;exports.EmbeddedChatPrimitiveFeedbackModalHeader=At;exports.EmbeddedChatPrimitiveFeedbackModalOverlay=xt;exports.EmbeddedChatPrimitiveFeedbackSubmitButton=Dt;exports.EmbeddedChatPrimitiveFooter=dt;exports.EmbeddedChatPrimitiveForm=Bt;exports.EmbeddedChatPrimitiveFormCancel=Ii;exports.EmbeddedChatPrimitiveFormClose=qt;exports.EmbeddedChatPrimitiveFormContent=Wt;exports.EmbeddedChatPrimitiveFormDescription=Vt;exports.EmbeddedChatPrimitiveFormError=Ei;exports.EmbeddedChatPrimitiveFormField=Qt;exports.EmbeddedChatPrimitiveFormFieldCheckbox=Gt;exports.EmbeddedChatPrimitiveFormFieldCheckboxIndicator=Yt;exports.EmbeddedChatPrimitiveFormFieldCombobox=ni;exports.EmbeddedChatPrimitiveFormFieldComboboxContent=li;exports.EmbeddedChatPrimitiveFormFieldComboboxControl=si;exports.EmbeddedChatPrimitiveFormFieldComboboxInput=di;exports.EmbeddedChatPrimitiveFormFieldComboboxItem=hi;exports.EmbeddedChatPrimitiveFormFieldComboboxItemIndicator=pi;exports.EmbeddedChatPrimitiveFormFieldComboboxItemText=bi;exports.EmbeddedChatPrimitiveFormFieldComboboxList=Ci;exports.EmbeddedChatPrimitiveFormFieldComboboxListEmpty=Fi;exports.EmbeddedChatPrimitiveFormFieldComboboxListItems=vi;exports.EmbeddedChatPrimitiveFormFieldComboboxPositioner=ui;exports.EmbeddedChatPrimitiveFormFieldComboboxSelectedTags=mi;exports.EmbeddedChatPrimitiveFormFieldComboboxTrigger=ci;exports.EmbeddedChatPrimitiveFormFieldDescription=gi;exports.EmbeddedChatPrimitiveFormFieldEmail=$t;exports.EmbeddedChatPrimitiveFormFieldError=Pi;exports.EmbeddedChatPrimitiveFormFieldFile=Kt;exports.EmbeddedChatPrimitiveFormFieldLabel=Ut;exports.EmbeddedChatPrimitiveFormFieldSelect=Zt;exports.EmbeddedChatPrimitiveFormFieldSelectContent=ti;exports.EmbeddedChatPrimitiveFormFieldSelectIcon=ei;exports.EmbeddedChatPrimitiveFormFieldSelectItem=oi;exports.EmbeddedChatPrimitiveFormFieldSelectItemIndicator=ai;exports.EmbeddedChatPrimitiveFormFieldSelectItemText=ri;exports.EmbeddedChatPrimitiveFormFieldSelectTrigger=Jt;exports.EmbeddedChatPrimitiveFormFieldSelectValue=Xt;exports.EmbeddedChatPrimitiveFormFieldSelectViewport=ii;exports.EmbeddedChatPrimitiveFormFieldText=G;exports.EmbeddedChatPrimitiveFormFieldTextArea=zt;exports.EmbeddedChatPrimitiveFormFooter=_i;exports.EmbeddedChatPrimitiveFormHeader=Nt;exports.EmbeddedChatPrimitiveFormHeading=Ot;exports.EmbeddedChatPrimitiveFormSubmit=ki;exports.EmbeddedChatPrimitiveFormSuccess=Si;exports.EmbeddedChatPrimitiveFormSuccessButton=fi;exports.EmbeddedChatPrimitiveFormSuccessHeading=Mi;exports.EmbeddedChatPrimitiveFormSuccessMessage=xi;exports.EmbeddedChatPrimitiveFormWrapper=Rt;exports.EmbeddedChatPrimitiveHeaderToolbar=ue;exports.EmbeddedChatPrimitiveHelpActions=gt;exports.EmbeddedChatPrimitiveHelpActionsMenu=_t;exports.EmbeddedChatPrimitiveHelpActionsMenuArrow=It;exports.EmbeddedChatPrimitiveHelpActionsMenuItem=kt;exports.EmbeddedChatPrimitiveHelpActionsMenuItemIcon=St;exports.EmbeddedChatPrimitiveHelpActionsTrigger=Et;exports.EmbeddedChatPrimitiveInput=mt;exports.EmbeddedChatPrimitiveInputGroup=ct;exports.EmbeddedChatPrimitiveIntroMessageWrapper=Le;exports.EmbeddedChatPrimitiveMarkdown=Ue;exports.EmbeddedChatPrimitiveMessageAction=Ye;exports.EmbeddedChatPrimitiveMessageAvatar=Be;exports.EmbeddedChatPrimitiveMessageAvatarContent=qe;exports.EmbeddedChatPrimitiveMessageAvatarFallback=Ne;exports.EmbeddedChatPrimitiveMessageAvatarImage=Oe;exports.EmbeddedChatPrimitiveMessageContent=Qe;exports.EmbeddedChatPrimitiveMessageContentWrapper=We;exports.EmbeddedChatPrimitiveMessageCustomAction=Ge;exports.EmbeddedChatPrimitiveMessageCustomActions=ze;exports.EmbeddedChatPrimitiveMessageHeader=De;exports.EmbeddedChatPrimitiveMessageLoading=Re;exports.EmbeddedChatPrimitiveMessageName=Ve;exports.EmbeddedChatPrimitiveMessageSourceItem=et;exports.EmbeddedChatPrimitiveMessageSourceItemBreadcrumbs=tt;exports.EmbeddedChatPrimitiveMessageSourceItemDescription=at;exports.EmbeddedChatPrimitiveMessageSourceItemDescriptionPart=nt;exports.EmbeddedChatPrimitiveMessageSourceItemIcon=it;exports.EmbeddedChatPrimitiveMessageSourceItemIndicator=st;exports.EmbeddedChatPrimitiveMessageSourceItemTag=rt;exports.EmbeddedChatPrimitiveMessageSourceItemTitle=ot;exports.EmbeddedChatPrimitiveMessageSources=Ze;exports.EmbeddedChatPrimitiveMessageSourcesHeader=Je;exports.EmbeddedChatPrimitiveMessageSourcesList=Xe;exports.EmbeddedChatPrimitiveMessageToolbar=Ke;exports.EmbeddedChatPrimitiveMessageWrapper=re;exports.EmbeddedChatPrimitiveMessages=Ie;exports.EmbeddedChatPrimitiveRoot=le;exports.EmbeddedChatPrimitiveSendButton=lt;exports.EmbeddedChatPrimitiveSendButtonIcon=ut;exports.EmbeddedChatPrimitiveTaglineContainer=bt;exports.EmbeddedChatPrimitiveTaglineLogo=vt;exports.EmbeddedChatPrimitiveTaglineText=pt;exports.EmbeddedChatPrimitiveToolbarHeader=pe;exports.EmbeddedChatPrimitiveToolbarHeaderWrapper=Ce;exports.EmbeddedChatPrimitiveWrapper=me;exports.ExampleQuestion=je;exports.ExampleQuestionButton=we;exports.ExampleQuestions=ye;exports.ExampleQuestionsLabel=Te;exports.ExampleQuestionsList=He;exports.FeedbackField=jt;exports.FeedbackForm=Ht;exports.FeedbackItemDescription=Lt;exports.FeedbackItemLabel=wt;exports.FeedbackModal=Mt;exports.FeedbackModalBody=Tt;exports.FeedbackModalClose=yt;exports.FeedbackModalContent=ft;exports.FeedbackModalHeader=At;exports.FeedbackModalOverlay=xt;exports.FeedbackSubmitButton=Dt;exports.Footer=dt;exports.Form=Bt;exports.FormCancel=Ii;exports.FormClose=qt;exports.FormContent=Wt;exports.FormDescription=Vt;exports.FormError=Ei;exports.FormField=Qt;exports.FormFieldCheckbox=Gt;exports.FormFieldCheckboxIndicator=Yt;exports.FormFieldCombobox=ni;exports.FormFieldComboboxContent=li;exports.FormFieldComboboxControl=si;exports.FormFieldComboboxInput=di;exports.FormFieldComboboxItem=hi;exports.FormFieldComboboxItemIndicator=pi;exports.FormFieldComboboxItemText=bi;exports.FormFieldComboboxList=Ci;exports.FormFieldComboboxListEmpty=Fi;exports.FormFieldComboboxListItems=vi;exports.FormFieldComboboxPositioner=ui;exports.FormFieldComboboxSelectedTags=mi;exports.FormFieldComboboxTrigger=ci;exports.FormFieldDescription=gi;exports.FormFieldEmail=$t;exports.FormFieldError=Pi;exports.FormFieldFile=Kt;exports.FormFieldLabel=Ut;exports.FormFieldSelect=Zt;exports.FormFieldSelectContent=ti;exports.FormFieldSelectIcon=ei;exports.FormFieldSelectItem=oi;exports.FormFieldSelectItemIndicator=ai;exports.FormFieldSelectItemText=ri;exports.FormFieldSelectTrigger=Jt;exports.FormFieldSelectValue=Xt;exports.FormFieldSelectViewport=ii;exports.FormFieldText=G;exports.FormFieldTextArea=zt;exports.FormFooter=_i;exports.FormHeader=Nt;exports.FormHeading=Ot;exports.FormSubmit=ki;exports.FormSuccess=Si;exports.FormSuccessButton=fi;exports.FormSuccessHeading=Mi;exports.FormSuccessMessage=xi;exports.FormWrapper=Rt;exports.Header=oo;exports.HeaderToolbar=ue;exports.HeaderToolbarWrapper=Ce;exports.HelpActions=gt;exports.HelpActionsMenu=_t;exports.HelpActionsMenuArrow=It;exports.HelpActionsMenuItem=kt;exports.HelpActionsMenuItemIcon=St;exports.HelpActionsTrigger=Et;exports.Input=mt;exports.InputGroup=ct;exports.IntroMessageWrapper=Le;exports.Markdown=Ue;exports.MessageAction=Ye;exports.MessageAvatar=Be;exports.MessageAvatarContent=qe;exports.MessageAvatarFallback=Ne;exports.MessageAvatarImage=Oe;exports.MessageContent=Qe;exports.MessageContentWrapper=We;exports.MessageCustomAction=Ge;exports.MessageCustomActions=ze;exports.MessageHeader=De;exports.MessageLoading=Re;exports.MessageName=Ve;exports.MessageSourceItem=et;exports.MessageSourceItemBreadcrumbIcon=qo;exports.MessageSourceItemBreadcrumbs=tt;exports.MessageSourceItemDescription=at;exports.MessageSourceItemDescriptionPart=nt;exports.MessageSourceItemIcon=it;exports.MessageSourceItemIndicator=st;exports.MessageSourceItemTag=rt;exports.MessageSourceItemTitle=ot;exports.MessageSources=Ze;exports.MessageSourcesHeader=Je;exports.MessageSourcesList=Xe;exports.MessageToolbar=Ke;exports.MessageWrapper=re;exports.Messages=Ie;exports.PrimitiveMessagePart=fo;exports.Root=le;exports.SendButton=lt;exports.SendButtonIcon=ut;exports.TaglineContainer=bt;exports.TaglineLogo=vt;exports.TaglineText=pt;exports.ToolbarHeader=pe;exports.Wrapper=me;
|
|
@@ -127,15 +127,15 @@ const Lo = Q((t, e) => {
|
|
|
127
127
|
}), vt = i(U.Viewport, {
|
|
128
128
|
_id: "aiChatContentScrollArea__Viewport"
|
|
129
129
|
}), Uo = Q(({ children: t, ...e }, o) => {
|
|
130
|
-
const { messages: r, isStreaming: n } = F(), {
|
|
130
|
+
const { messages: r, isStreaming: n } = F(), { aiChatSettings: { shouldAutoScroll: s = !0 } } = p(), { containerRef: d, scrollToBottom: c, handleScroll: m, enableAutoScroll: l } = rt({ isStreaming: n, enabled: s }), u = X(o, d);
|
|
131
131
|
return W(() => {
|
|
132
|
-
r.length > 0 && (
|
|
133
|
-
}, [r.length,
|
|
132
|
+
r.length > 0 && (l(), c());
|
|
133
|
+
}, [r.length, c, l]), /* @__PURE__ */ a(
|
|
134
134
|
vt,
|
|
135
135
|
{
|
|
136
|
-
ref:
|
|
136
|
+
ref: u,
|
|
137
137
|
tabIndex: -1,
|
|
138
|
-
onScroll:
|
|
138
|
+
onScroll: m,
|
|
139
139
|
style: { outline: "none" },
|
|
140
140
|
children: (
|
|
141
141
|
/* added this to fix an overflow issue see https://github.com/radix-ui/primitives/issues/926 */
|
|
@@ -575,7 +575,7 @@ const Lo = Q((t, e) => {
|
|
|
575
575
|
_id: "aiChatMessageSources"
|
|
576
576
|
}), fa = (t) => {
|
|
577
577
|
const { message: e } = E();
|
|
578
|
-
return e.role !== "assistant" || !e.parts.filter(ne)?.length ? null : /* @__PURE__ */ a(Kt, { ...t });
|
|
578
|
+
return e.role !== "assistant" || !e.parts.filter(ne).filter((r) => !!r.data?.artifactSummary?.url)?.length ? null : /* @__PURE__ */ a(Kt, { ...t });
|
|
579
579
|
}, qt = i("div", {
|
|
580
580
|
_id: "aiChatMessageSources__Header"
|
|
581
581
|
}), Sa = (t) => /* @__PURE__ */ a(qt, { children: "Sources", ...t }), jt = i("div", {
|
|
@@ -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"),h=10;function T(f={}){const{isStreaming:r=!1,enabled:a=!0}=f,o=e.useRef(null),n=e.useRef(!0),s=e.useRef(!1),l=e.useRef(null),u=e.useCallback(()=>{const t=o.current;if(!t)return!0;const{scrollTop:c,scrollHeight:m,clientHeight:R}=t;return m-c-R<=h},[]),i=e.useCallback((t=!0)=>{const c=o.current;c&&(s.current||!n.current||c.scrollTo({top:c.scrollHeight,behavior:t?"smooth":"auto"}))},[]),S=e.useCallback(()=>{o.current&&(s.current=!0,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{s.current=!1,r&&u()&&(n.current=!0)},150),r&&!u()&&(n.current=!1))},[r,u]);e.useEffect(()=>{if(!a||!r)return;const t=o.current;if(!t)return;const c=new MutationObserver(()=>{n.current&&!s.current&&r&&i(!1)});return c.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>c.disconnect()},[r,i,a]),e.useEffect(()=>{r&&(n.current=u())},[r,u]),e.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]);const b=e.useCallback(()=>{n.current=!0},[]);return{containerRef:o,scrollToBottom:i,handleScroll:S,isAtBottom:u,enableAutoScroll:b,shouldAutoScroll:()=>n.current}}exports.useSimpleScroll=T;
|
|
@@ -5,6 +5,12 @@ export interface UseSimpleScrollOptions {
|
|
|
5
5
|
* When true, auto-scroll behavior is enabled.
|
|
6
6
|
*/
|
|
7
7
|
isStreaming?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether auto-scroll is enabled at all.
|
|
10
|
+
* When false, all auto-scroll behavior is disabled.
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
enabled?: boolean;
|
|
8
14
|
}
|
|
9
15
|
export declare function useSimpleScroll(options?: UseSimpleScrollOptions): {
|
|
10
16
|
containerRef: RefObject<HTMLDivElement | null>;
|
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRef as s, useCallback as i, useEffect as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
const { isStreaming: r = !1 } =
|
|
6
|
-
const t = o.current;
|
|
7
|
-
if (!t) return !0;
|
|
8
|
-
const { scrollTop: e, scrollHeight: T, clientHeight: b } = t;
|
|
9
|
-
return T - e - b <= R;
|
|
10
|
-
}, []), f = i((t = !0) => {
|
|
2
|
+
import { useRef as s, useCallback as i, useEffect as f } from "react";
|
|
3
|
+
const d = 10;
|
|
4
|
+
function p(S = {}) {
|
|
5
|
+
const { isStreaming: r = !1, enabled: m = !0 } = S, o = s(null), n = s(!0), l = s(!1), u = s(null), c = i(() => {
|
|
11
6
|
const e = o.current;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
if (!e) return !0;
|
|
8
|
+
const { scrollTop: t, scrollHeight: T, clientHeight: R } = e;
|
|
9
|
+
return T - t - R <= d;
|
|
10
|
+
}, []), a = i((e = !0) => {
|
|
11
|
+
const t = o.current;
|
|
12
|
+
t && (l.current || !n.current || t.scrollTo({
|
|
13
|
+
top: t.scrollHeight,
|
|
14
|
+
behavior: e ? "smooth" : "auto"
|
|
15
15
|
}));
|
|
16
|
-
}, []),
|
|
16
|
+
}, []), h = i(() => {
|
|
17
17
|
o.current && (l.current = !0, u.current && clearTimeout(u.current), u.current = setTimeout(() => {
|
|
18
18
|
l.current = !1, r && c() && (n.current = !0);
|
|
19
19
|
}, 150), r && !c() && (n.current = !1));
|
|
20
20
|
}, [r, c]);
|
|
21
|
-
|
|
22
|
-
if (!r)
|
|
21
|
+
f(() => {
|
|
22
|
+
if (!m || !r)
|
|
23
23
|
return;
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
26
|
-
const
|
|
27
|
-
n.current && !l.current && r &&
|
|
24
|
+
const e = o.current;
|
|
25
|
+
if (!e) return;
|
|
26
|
+
const t = new MutationObserver(() => {
|
|
27
|
+
n.current && !l.current && r && a(!1);
|
|
28
28
|
});
|
|
29
|
-
return
|
|
29
|
+
return t.observe(e, {
|
|
30
30
|
childList: !0,
|
|
31
31
|
subtree: !0,
|
|
32
32
|
characterData: !0
|
|
33
|
-
}), () =>
|
|
34
|
-
}, [r,
|
|
33
|
+
}), () => t.disconnect();
|
|
34
|
+
}, [r, a, m]), f(() => {
|
|
35
35
|
r && (n.current = c());
|
|
36
|
-
}, [r, c]),
|
|
36
|
+
}, [r, c]), f(() => () => {
|
|
37
37
|
u.current && clearTimeout(u.current);
|
|
38
38
|
}, []);
|
|
39
|
-
const
|
|
39
|
+
const b = i(() => {
|
|
40
40
|
n.current = !0;
|
|
41
41
|
}, []);
|
|
42
42
|
return {
|
|
43
43
|
containerRef: o,
|
|
44
|
-
scrollToBottom:
|
|
45
|
-
handleScroll:
|
|
44
|
+
scrollToBottom: a,
|
|
45
|
+
handleScroll: h,
|
|
46
46
|
isAtBottom: c,
|
|
47
|
-
enableAutoScroll:
|
|
47
|
+
enableAutoScroll: b,
|
|
48
48
|
/** Whether auto-scroll is currently active (not hijacked by user) */
|
|
49
49
|
shouldAutoScroll: () => n.current
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
export {
|
|
53
|
-
|
|
53
|
+
p as useSimpleScroll
|
|
54
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../theme/index.cjs"),t=require("../../theme/colors.cjs"),s={baseUrl:"https://api.agents.inkeep.com",placeholder:"How do I get started?",aiAssistantName:void 0,shouldOpenLinksInNewTab:!0,disclaimerSettings:{isEnabled:!1,label:"Usage policy"},isShareButtonVisible:!1,isViewOnly:!1,isChatHistoryButtonVisible:!0,exampleQuestionsLabel:"Example questions",exampleQuestions:[],isFirstExampleQuestionHighlighted:!0,isCopyChatButtonVisible:!1,getHelpOptions:[],toolbarButtonLabels:{clear:"Clear",share:"Share",getHelp:"Get help",stop:"Stop",copyChat:"Copy"},context:{}},a={shouldBypassCaptcha:!1,tags:[],userProperties:{},primaryBrandColor:t.DEFAULT_PRIMARY_BRAND_COLOR,theme:{varsClassName:"inkeep-widget-vars",...e.theme}},
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../theme/index.cjs"),t=require("../../theme/colors.cjs"),s={baseUrl:"https://api.agents.inkeep.com",placeholder:"How do I get started?",aiAssistantName:void 0,shouldOpenLinksInNewTab:!0,disclaimerSettings:{isEnabled:!1,label:"Usage policy"},isShareButtonVisible:!1,isViewOnly:!1,isChatHistoryButtonVisible:!0,exampleQuestionsLabel:"Example questions",exampleQuestions:[],isFirstExampleQuestionHighlighted:!0,isCopyChatButtonVisible:!1,getHelpOptions:[],toolbarButtonLabels:{clear:"Clear",share:"Share",getHelp:"Get help",stop:"Stop",copyChat:"Copy"},context:{},shouldAutoScroll:!0},a={shouldBypassCaptcha:!1,tags:[],userProperties:{},primaryBrandColor:t.DEFAULT_PRIMARY_BRAND_COLOR,theme:{varsClassName:"inkeep-widget-vars",...e.theme}},l={shouldOpenLinksInNewTab:!1,defaultQuery:"",debounceTimeMs:0,tabs:["All","Publications","PDFs","GitHub","Forums","Discord","Slack","StackOverflow"],placeholder:"Search for anything...",view:"single-pane"};exports.defaultInkeepAIChatSettings=s;exports.defaultInkeepBaseSettings=a;exports.defaultInkeepSearchSettings=l;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { theme as e } from "../../theme/index.js";
|
|
3
3
|
import { DEFAULT_PRIMARY_BRAND_COLOR as t } from "../../theme/colors.js";
|
|
4
|
-
const
|
|
4
|
+
const l = {
|
|
5
5
|
baseUrl: "https://api.agents.inkeep.com",
|
|
6
6
|
placeholder: "How do I get started?",
|
|
7
7
|
aiAssistantName: void 0,
|
|
@@ -25,8 +25,9 @@ const i = {
|
|
|
25
25
|
stop: "Stop",
|
|
26
26
|
copyChat: "Copy"
|
|
27
27
|
},
|
|
28
|
-
context: {}
|
|
29
|
-
|
|
28
|
+
context: {},
|
|
29
|
+
shouldAutoScroll: !0
|
|
30
|
+
}, i = {
|
|
30
31
|
shouldBypassCaptcha: !1,
|
|
31
32
|
tags: [],
|
|
32
33
|
userProperties: {},
|
|
@@ -44,7 +45,7 @@ const i = {
|
|
|
44
45
|
view: "single-pane"
|
|
45
46
|
};
|
|
46
47
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
l as defaultInkeepAIChatSettings,
|
|
49
|
+
i as defaultInkeepBaseSettings,
|
|
49
50
|
o as defaultInkeepSearchSettings
|
|
50
51
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=(...t)=>(...n)=>{for(const a of t)a?.(...n)},l=t=>typeof t=="string";function f(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/__/g,"__").toLowerCase()}const g=t=>t?"":void 0;function d(t){const n=t.split(" "),a=n[0]??"",o=n.length>1?n[n.length-1]:"";return a&&o?`${a.charAt(0)}${o.charAt(0)}`:a.charAt(0)}function m(t,n){return typeof t=="function"?t(n):t}function i(t){return t.type==="data-artifact"&&t.data?.type?.toLowerCase()==="citation"}const y=t=>{const n=e=>e.data?.artifactSummary?.title||e.data?.name||"Source",a=t.parts?.map(e=>{if(e.type==="text")return e.text;if(e.type==="data-component")return JSON.stringify(e.data);if(i(e)){const r=e.data?.artifactSummary?.url;return r?`[${n(e)}](${r})`:
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=(...t)=>(...n)=>{for(const a of t)a?.(...n)},l=t=>typeof t=="string";function f(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/__/g,"__").toLowerCase()}const g=t=>t?"":void 0;function d(t){const n=t.split(" "),a=n[0]??"",o=n.length>1?n[n.length-1]:"";return a&&o?`${a.charAt(0)}${o.charAt(0)}`:a.charAt(0)}function m(t,n){return typeof t=="function"?t(n):t}function i(t){return t.type==="data-artifact"&&t.data?.type?.toLowerCase()==="citation"}const y=t=>{const n=e=>e.data?.artifactSummary?.title||e.data?.name||"Source",a=t.parts?.map(e=>{if(e.type==="text")return e.text;if(e.type==="data-component")return JSON.stringify(e.data);if(i(e)){const r=e.data?.artifactSummary?.url;return r?`[${n(e)}](${r})`:null}return null}).join("")??"",o=new Set,s=t.parts?.filter(i).filter(e=>{const r=e.data?.artifactSummary?.url;return!r||o.has(r)?!1:(o.add(r),!0)})??[];if(!s.length)return a;const c=`
|
|
2
2
|
|
|
3
3
|
**Sources:**
|
|
4
4
|
`+s.map(e=>{const r=e.data?.artifactSummary?.url;return`- [${n(e)}](${r})`}).join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const
|
|
2
|
+
const c = (
|
|
3
3
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
4
4
|
(...t) => (...e) => {
|
|
5
5
|
for (const r of t)
|
|
@@ -17,39 +17,39 @@ function d(t) {
|
|
|
17
17
|
function y(t, e) {
|
|
18
18
|
return typeof t == "function" ? t(e) : t;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function s(t) {
|
|
21
21
|
return t.type === "data-artifact" && t.data?.type?.toLowerCase() === "citation";
|
|
22
22
|
}
|
|
23
23
|
const g = (t) => {
|
|
24
24
|
const e = (n) => n.data?.artifactSummary?.title || n.data?.name || "Source", r = t.parts?.map((n) => {
|
|
25
25
|
if (n.type === "text") return n.text;
|
|
26
26
|
if (n.type === "data-component") return JSON.stringify(n.data);
|
|
27
|
-
if (
|
|
27
|
+
if (s(n)) {
|
|
28
28
|
const a = n.data?.artifactSummary?.url;
|
|
29
|
-
return a ? `[${e(n)}](${a})` :
|
|
29
|
+
return a ? `[${e(n)}](${a})` : null;
|
|
30
30
|
}
|
|
31
31
|
return null;
|
|
32
|
-
}).join("") ?? "", o = /* @__PURE__ */ new Set(),
|
|
32
|
+
}).join("") ?? "", o = /* @__PURE__ */ new Set(), i = t.parts?.filter(s).filter((n) => {
|
|
33
33
|
const a = n.data?.artifactSummary?.url;
|
|
34
34
|
return !a || o.has(a) ? !1 : (o.add(a), !0);
|
|
35
35
|
}) ?? [];
|
|
36
|
-
if (!
|
|
37
|
-
const
|
|
36
|
+
if (!i.length) return r;
|
|
37
|
+
const u = `
|
|
38
38
|
|
|
39
39
|
**Sources:**
|
|
40
|
-
` +
|
|
40
|
+
` + i.map((n) => {
|
|
41
41
|
const a = n.data?.artifactSummary?.url;
|
|
42
42
|
return `- [${e(n)}](${a})`;
|
|
43
43
|
}).join(`
|
|
44
44
|
`);
|
|
45
|
-
return r +
|
|
45
|
+
return r + u;
|
|
46
46
|
};
|
|
47
47
|
export {
|
|
48
|
-
|
|
48
|
+
c as callAll,
|
|
49
49
|
m as dataAttr,
|
|
50
50
|
d as getInitials,
|
|
51
51
|
g as getMessageContent,
|
|
52
|
-
|
|
52
|
+
s as isCitationArtifact,
|
|
53
53
|
l as isString,
|
|
54
54
|
y as maybeRender,
|
|
55
55
|
f as toKebabCase
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),te=require("../../primitives/providers/base-events-provider.cjs"),ae=require("../../primitives/providers/config-provider.cjs"),re=require("../../primitives/providers/message-provider.cjs"),C=require("../../primitives/components/embedded-chat.cjs"),se=require("../../primitives/components/embedded-chat/chat-provider.cjs"),ne=require("../../primitives/utils/misc.cjs"),oe=require("merge-anything"),b=require("../utils.cjs"),ie=require("./ui/markdown-styles.cjs"),le=require("../../primitives/components/embedded-chat/use-stream-processor.cjs"),de=require("./data-summary-group.cjs"),o=require("react"),D=require("./embedded-chat.cjs"),d=require("lucide-react"),U=require("./ui/recipes/button.cjs"),ce={"input-streaming":"Pending","input-available":"Running","approval-requested":"Awaiting Approval","approval-responded":"Responded","output-available":"Completed","output-error":"Error","output-denied":"Denied"};function pe(t){if(!t||typeof t!="object")return!1;const a=t;return typeof a.type=="string"&&a.type.startsWith("tool-")}const ue=t=>{if(!t||typeof t!="object"||!("status"in t))return;const a=t.status;return typeof a=="string"?a:void 0},xe=()=>e.jsx("div",{className:"flex space-x-1",children:[0,1,2].map(t=>e.jsx("span",{className:"animate-bounce-dot opacity-30",style:{animationDelay:`${t*.2}s`},children:"."},t))}),V=({name:t,Icon:a,props:i,componentType:n})=>e.jsxs("div",{className:"border rounded-lg bg-gray-50 dark:bg-gray-dark-800 mb-3",children:[e.jsxs("div",{className:"flex justify-between px-4 py-2 text-xs",children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(a,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:t})]}),e.jsx("div",{className:"flex items-center px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-200 dark:bg-white-alpha-200 font-medium text-gray-700 dark:text-white-alpha-700 font-mono",children:n})]}),e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono px-4 py-2",children:JSON.stringify(i,null,2)})]}),me=({name:t,props:a})=>e.jsx(V,{name:t,Icon:d.ComponentIcon,props:a,componentType:"component"}),he=({name:t,props:a})=>e.jsx(V,{name:t,Icon:d.Library,props:a,componentType:"artifact"}),fe=({tool:t,componentDef:a,renderText:i,approvalId:n,messagePartsLength:m,setApprovalDelayPending:s,addToolApprovalResponse:u,sendMessage:c,conversationId:g})=>{const l=o.useRef(c);l.current=c;const x=o.useRef(u);x.current=u;const p=o.useRef(s);p.current=s;const h=o.useCallback(async(A=!0)=>{n&&(p.current({partCount:m}),x.current({id:n,approved:A}),await l.current(void 0,{body:{conversationId:g}}))},[n,m,g]),k=o.useMemo(()=>({tool:t,approve:h,renderMarkdown:i}),[t]),T=a?D.DynamicComponent:G;return e.jsx(T,{name:t.type,props:k,componentDef:a})};function B(t){return t===null?e.jsx("span",{className:"text-gray-500 dark:text-white-alpha-500 font-mono font-medium text-1xs",children:"null"}):t===void 0?e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 italic text-xs font-medium",children:"undefined"}):typeof t=="boolean"?e.jsx("span",{className:b.cn("inline-flex font-mono font-semibold items-center px-1 py-0.5 text-1xs rounded-md border",t?"bg-inkeep-expanded-primary-50 border-inkeep-expanded-primary-200 text-inkeep-expanded-primary-600 dark:bg-inkeep-expanded-primary-950 dark:border-inkeep-expanded-primary-600 dark:text-inkeep-expanded-primary-200":"bg-gray-100 dark:bg-white-alpha-50 text-gray-700 dark:text-white-alpha-700"),children:t?"true":"false"}):typeof t=="number"?e.jsx("span",{className:"tabular-nums font-medium text-inkeep-expanded-primary-600 dark:text-inkeep-expanded-primary-200",children:t.toLocaleString()}):typeof t=="string"?e.jsx("span",{className:"text-gray-800 dark:text-white-alpha-800 break-words",children:t}):e.jsx("span",{children:String(t)})}const F=({name:t,value:a,isArrayIndex:i,depth:n=0})=>{const[m,s]=o.useState(n<1),u=a!==null&&typeof a=="object"&&!Array.isArray(a),c=Array.isArray(a);if(!(u||c))return e.jsxs("div",{className:"flex items-baseline gap-2 py-1 text-xs",children:[e.jsx("span",{className:b.cn("font-medium shrink-0",i?"text-gray-300 dark:text-white-alpha-300":"text-gray-500 dark:text-white-alpha-500"),children:i?"—":t}),e.jsx("span",{children:B(a)})]});const l=c?a.map((p,h)=>[String(h),p]):Object.entries(a);return l.length===0?e.jsxs("div",{className:"flex items-baseline gap-2 py-1 text-xs",children:[e.jsx("span",{className:"font-medium text-gray-500 dark:text-white-alpha-500 shrink-0",children:t}),e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 italic",children:c?"empty list":"empty"})]}):e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:p=>{p.stopPropagation(),s(!m)},className:"flex items-center gap-1.5 py-1 text-xs hover:bg-gray-50 dark:hover:bg-white-alpha-50 -mx-1.5 px-1.5 rounded transition-colors w-full text-left",children:[e.jsx(d.ChevronDown,{className:b.cn("h-3.5 w-3.5 text-gray-400 dark:text-white-alpha-400 shrink-0 transition-transform",!m&&"-rotate-90")}),e.jsx("span",{className:"font-medium text-gray-500 dark:text-white-alpha-500",children:t}),!m&&e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 text-1xs ml-1",children:c?`${l.length} item${l.length!==1?"s":""}`:`${l.length} field${l.length!==1?"s":""}`})]}),m&&e.jsx("div",{className:"border-l-2 border-gray-200 dark:border-white-alpha-200 ml-1.5 pl-3",children:l.map(([p,h])=>e.jsx(F,{name:p,value:h,isArrayIndex:c,depth:n+1},p))})]})},ge=({value:t})=>{if(t==null||typeof t!="object")return e.jsx("span",{className:"text-xs",children:B(t)});const a=Array.isArray(t)?t.map((i,n)=>[String(n),i]):Object.entries(t);return a.length===0?e.jsx("div",{className:"text-xs text-gray-400 dark:text-white-alpha-400 italic",children:"No arguments"}):e.jsx("div",{className:"space-y-1",children:a.map(([i,n])=>e.jsx(F,{name:i,value:n,isArrayIndex:Array.isArray(t)},i))})},G=({props:t})=>{const{tool:a,approve:i}=t,n=a.type,m=n.startsWith("tool-")?n.slice(5):n,s=a.state,u=a.approval?.id,c=!!u,g=s==="approval-requested",l=ue(a.output),[x,p]=o.useState(c),h=s?ce[s]??s:"tool";o.useEffect(()=>{g&&p(!0)},[g]);const k=()=>{switch(s){case"input-streaming":return e.jsx(d.Circle,{className:"w-3 h-3"});case"input-available":return e.jsx(d.Loader2,{className:"w-3 h-3 animate-spin"});case"approval-requested":return e.jsx(d.Clock,{className:"w-3 h-3"});case"approval-responded":return e.jsx(d.CheckCircle,{className:"w-3 h-3"});case"output-available":return e.jsx(d.CheckCircle,{className:"w-3 h-3"});case"output-error":return e.jsx(d.TriangleAlert,{className:"w-3 h-3"});case"output-denied":return e.jsx(d.XCircle,{className:"w-3 h-3"});default:return null}};return e.jsxs("div",{className:"border rounded-lg mb-3 overflow-hidden",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center group gap-2 text-xs text-gray-700 dark:text-white-alpha-700 hover:text-gray-800 dark:hover:text-white-alpha-800 transition-colors cursor-pointer w-full justify-between px-4 py-2 data-[expanded=true]:border-b",onClick:()=>p(!x),"aria-expanded":x,"data-expanded":x,children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(d.Hammer,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:m})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-100 dark:bg-white-alpha-100 font-medium text-gray-700 dark:text-white-alpha-700 font-mono",children:[k(),h]}),e.jsx(d.ChevronDown,{className:"w-3.5 h-3.5 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform rotate-0 group-data-[expanded=true]:rotate-180"})]})]}),e.jsxs("div",{"data-expanded":x,className:b.cn("overflow-hidden transition-all duration-300 ease-in-out data-[expanded=true]:opacity-100 data-[expanded=false]:max-h-0 data-[expanded=false]:opacity-0 max-w-full"),children:[e.jsx("div",{"data-expanded":x,className:b.cn("relative",'before:content-[""] before:absolute before:inset-x-0 before:top-0 before:h-3 before:pointer-events-none before:z-10','after:content-[""] after:absolute after:inset-x-0 after:bottom-0 after:h-3 after:pointer-events-none after:z-10',"before:bg-[linear-gradient(white,_transparent)] after:bg-[linear-gradient(transparent,_white)]","dark:before:bg-[linear-gradient(var(--ikp-color-gray-dark-950),_transparent)] dark:after:bg-[linear-gradient(transparent,_var(--ikp-color-gray-dark-950))]","data-[expanded=false]:before:opacity-0 data-[expanded=false]:after:opacity-0"),children:e.jsx("div",{"data-expanded":x,className:b.cn("[scrollbar-width:thin] px-4","data-[expanded=true]:max-h-48 data-[expanded=true]:overflow-y-auto"),children:a.input!=null&&e.jsx("div",{className:"text-xs py-2",children:e.jsx(ge,{value:a.input})})})}),g&&u&&e.jsxs("div",{className:"flex justify-end gap-2 pt-1 pb-3 px-4",children:[e.jsx("button",{type:"button",className:b.cn(U.button({size:"xs",variant:"outline"}),"px-2 py-1 rounded-md text-xs text-gray-700 dark:text-white-alpha-700"),onClick:()=>i(!1),children:"Deny"}),e.jsxs("button",{type:"button",className:b.cn(U.button({size:"xs",variant:"primaryFilled"}),"px-2 py-1 rounded-md text-xs gap-1"),onClick:()=>i(!0),children:[e.jsx(d.Check,{className:"w-3 h-3"}),"Approve"]})]}),s==="output-available"&&l&&a.output!=null&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize pb-3 px-4",children:[l==="approved"&&e.jsx(d.Check,{className:"w-3 h-3"}),l]}),s==="output-denied"&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize pb-3 px-4",children:[e.jsx(d.X,{className:"w-3 h-3"}),h]})]})]})},ye=({className:t,componentStyles:a,children:i,isLast:n,...m})=>{const{message:s}=re.useMessage(),{logEvent:u}=te.useBaseEvents(),{conversationId:c,isStreaming:g,isLoading:l,setError:x,addToolApprovalResponse:p,sendMessage:h}=se.useChat(),{aiChatSettings:{components:k,artifacts:T,headers:A}}=ae.useInkeepConfig(),K=A?.["x-emit-operations"]==="true",L=s.role==="user",W=(g||l)&&n&&s.role==="assistant",{processedParts:X,summaryTimings:H,shouldShowInitialLoading:J,shouldShowStreamDelayLoading:Q}=le.useStreamProcessor(s.parts,W,x),[S,$]=o.useState(null),[Y,E]=o.useState(!1),y=o.useRef(null);o.useEffect(()=>{if(!S){E(!1),y.current&&(clearTimeout(y.current),y.current=null);return}return E(!1),y.current&&clearTimeout(y.current),y.current=window.setTimeout(()=>{E(!0)},1e3),()=>{y.current&&(clearTimeout(y.current),y.current=null)}},[S]),o.useEffect(()=>{S&&(!n||s.parts.length>S.partCount)&&$(null)},[S,n,s.parts.length]);const _=o.useMemo(()=>s.parts.filter(ne.isCitationArtifact),[s.parts]),I=o.useMemo(()=>oe.merge(ie.markdownStyles,a??{}),[a]),O=o.useCallback((r,f)=>{u({eventName:"assistant_message_inline_link_opened",properties:{title:f?.toString(),url:r}})},[u]),z=o.useCallback((r,f)=>{u({eventName:"assistant_code_block_copied",properties:{conversationId:c,language:r,code:f}})},[u,c]),q=o.useCallback(r=>e.jsx(C.EmbeddedChatPrimitiveMarkdown,{text:r,componentStyles:I,onLinkClick:O,onCodeCopy:z,artifacts:_}),[I,O,z,_]),Z=o.useMemo(()=>b.cn("data-[role=user]:whitespace-pre-wrap mb-3 data-[role=user]:mb-0 [&[data-role=user]>p]:mb-0 max-w-full",t),[t]),ee=!L||s.parts.some(r=>r.type==="text"&&r.text?.trim());return e.jsxs(e.Fragment,{children:[!ee&&e.jsx("span",{className:"text-gray-500 dark:text-white-alpha-500",children:"No message content"}),X.map((r,f)=>{const v={"data-role":s.role,"data-type":r?.type==="data-component"?r.data.type:r?.type,...m,className:Z};switch(r?.type){case"text":return e.jsx(C.PrimitiveMessagePart,{...v,children:L?r.text:q(r.text||"")},f);case"data-component":{const{type:j}=r.data;switch(j){case"text":return e.jsx("div",{...v,children:q(r.data.text||"")},f);default:{const N=r.data,{name:w,props:M}=N,P=k?.[w],R=P?D.DynamicComponent:me;return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(R,{name:w,props:M,componentDef:P})},`${w}-${f}`)}}}case"data-artifact":{const j=r.data,{name:N,type:w,artifactSummary:M}=j,P=T?.[w],R=P?D.DynamicComponent:he;return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(R,{name:w,props:M,componentDef:P})},`${N}-${f}`)}case"summary-group":{const j=H.get(r.groupKey)||{isCompleted:!1};return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(de.DataSummaryGroup,{summaries:r.summaries||[],isCompleted:j.isCompleted})},`${r.groupKey}-${f}`)}default:{if(!pe(r))return null;const j=r,N=r.approval?.id;return K||N?e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(fe,{tool:j,componentDef:k?.IkpTool,renderText:q,approvalId:N,messagePartsLength:s.parts.length,setApprovalDelayPending:$,addToolApprovalResponse:p,sendMessage:h,conversationId:c})},r.toolCallId??`${r.type}-${f}`):null}}}),J&&e.jsx(D.MessageLoading,{}),(Q||Y)&&e.jsx(xe,{})]})};exports.DefaultToolComponent=G;exports.EmbeddedChatMessagePart=ye;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),te=require("../../primitives/providers/base-events-provider.cjs"),ae=require("../../primitives/providers/config-provider.cjs"),re=require("../../primitives/providers/message-provider.cjs"),C=require("../../primitives/components/embedded-chat.cjs"),se=require("../../primitives/components/embedded-chat/chat-provider.cjs"),ne=require("../../primitives/utils/misc.cjs"),oe=require("merge-anything"),b=require("../utils.cjs"),ie=require("./ui/markdown-styles.cjs"),le=require("../../primitives/components/embedded-chat/use-stream-processor.cjs"),ce=require("./data-summary-group.cjs"),o=require("react"),T=require("./embedded-chat.cjs"),c=require("lucide-react"),U=require("./ui/recipes/button.cjs"),de={"input-streaming":"Pending","input-available":"Running","approval-requested":"Awaiting Approval","approval-responded":"Responded","output-available":"Completed","output-error":"Error","output-denied":"Denied"};function pe(t){if(!t||typeof t!="object")return!1;const a=t;return typeof a.type=="string"&&a.type.startsWith("tool-")}const ue=t=>{if(!t||typeof t!="object"||!("status"in t))return;const a=t.status;return typeof a=="string"?a:void 0},xe=()=>e.jsx("div",{className:"flex space-x-1",children:[0,1,2].map(t=>e.jsx("span",{className:"animate-bounce-dot opacity-30",style:{animationDelay:`${t*.2}s`},children:"."},t))}),V=({name:t,Icon:a,props:i,componentType:n})=>e.jsxs("div",{className:"border rounded-lg bg-gray-50 dark:bg-gray-dark-800 mb-3",children:[e.jsxs("div",{className:"flex justify-between px-4 py-2 text-xs",children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(a,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:t})]}),e.jsx("div",{className:"flex items-center px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-200 dark:bg-white-alpha-200 font-medium text-gray-700 dark:text-white-alpha-700 font-mono",children:n})]}),e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono px-4 py-2",children:JSON.stringify(i,null,2)})]}),me=({name:t,props:a})=>e.jsx(V,{name:t,Icon:c.ComponentIcon,props:a,componentType:"component"}),he=({name:t,props:a})=>e.jsx(V,{name:t,Icon:c.Library,props:a,componentType:"artifact"}),fe=({tool:t,componentDef:a,renderText:i,approvalId:n,messagePartsLength:m,setApprovalDelayPending:s,addToolApprovalResponse:u,sendMessage:d,conversationId:g})=>{const l=o.useRef(d);l.current=d;const x=o.useRef(u);x.current=u;const p=o.useRef(s);p.current=s;const h=o.useCallback(async(E=!0)=>{n&&(p.current({partCount:m}),x.current({id:n,approved:E}),await l.current(void 0,{body:{conversationId:g}}))},[n,m,g]),k=o.useMemo(()=>({tool:t,approve:h,renderMarkdown:i}),[t]),A=a?T.DynamicComponent:G;return e.jsx(A,{name:t.type,props:k,componentDef:a})};function B(t){return t===null?e.jsx("span",{className:"text-gray-500 dark:text-white-alpha-500 font-mono font-medium text-1xs",children:"null"}):t===void 0?e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 italic text-xs font-medium",children:"undefined"}):typeof t=="boolean"?e.jsx("span",{className:b.cn("inline-flex font-mono font-semibold items-center px-1 py-0.5 text-1xs rounded-md border",t?"bg-inkeep-expanded-primary-50 border-inkeep-expanded-primary-200 text-inkeep-expanded-primary-600 dark:bg-inkeep-expanded-primary-950 dark:border-inkeep-expanded-primary-600 dark:text-inkeep-expanded-primary-200":"bg-gray-100 dark:bg-white-alpha-50 text-gray-700 dark:text-white-alpha-700"),children:t?"true":"false"}):typeof t=="number"?e.jsx("span",{className:"tabular-nums font-medium text-inkeep-expanded-primary-600 dark:text-inkeep-expanded-primary-200",children:t.toLocaleString()}):typeof t=="string"?e.jsx("span",{className:"text-gray-800 dark:text-white-alpha-800 break-words",children:t}):e.jsx("span",{children:String(t)})}const F=({name:t,value:a,isArrayIndex:i,depth:n=0})=>{const[m,s]=o.useState(n<1),u=a!==null&&typeof a=="object"&&!Array.isArray(a),d=Array.isArray(a);if(!(u||d))return e.jsxs("div",{className:"flex items-baseline gap-2 py-1 text-xs",children:[e.jsx("span",{className:b.cn("font-medium shrink-0",i?"text-gray-300 dark:text-white-alpha-300":"text-gray-500 dark:text-white-alpha-500"),children:i?"—":t}),e.jsx("span",{className:"min-w-0",children:B(a)})]});const l=d?a.map((p,h)=>[String(h),p]):Object.entries(a);return l.length===0?e.jsxs("div",{className:"flex items-baseline gap-2 py-1 text-xs",children:[e.jsx("span",{className:"font-medium text-gray-500 dark:text-white-alpha-500 shrink-0",children:t}),e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 italic",children:d?"empty list":"empty"})]}):e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:p=>{p.stopPropagation(),s(!m)},className:"flex items-center gap-1.5 py-1 text-xs hover:bg-gray-50 dark:hover:bg-white-alpha-50 -mx-1.5 px-1.5 rounded transition-colors w-full text-left",children:[e.jsx(c.ChevronDown,{className:b.cn("h-3.5 w-3.5 text-gray-400 dark:text-white-alpha-400 shrink-0 transition-transform",!m&&"-rotate-90")}),e.jsx("span",{className:"font-medium text-gray-500 dark:text-white-alpha-500",children:t}),!m&&e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 text-1xs ml-1",children:d?`${l.length} item${l.length!==1?"s":""}`:`${l.length} field${l.length!==1?"s":""}`})]}),m&&e.jsx("div",{className:"border-l-2 border-gray-200 dark:border-white-alpha-200 ml-1.5 pl-3",children:l.map(([p,h])=>e.jsx(F,{name:p,value:h,isArrayIndex:d,depth:n+1},p))})]})},ge=({value:t})=>{if(t==null||typeof t!="object")return e.jsx("span",{className:"text-xs",children:B(t)});const a=Array.isArray(t)?t.map((i,n)=>[String(n),i]):Object.entries(t);return a.length===0?e.jsx("div",{className:"text-xs text-gray-400 dark:text-white-alpha-400 italic",children:"No arguments"}):e.jsx("div",{className:"space-y-1",children:a.map(([i,n])=>e.jsx(F,{name:i,value:n,isArrayIndex:Array.isArray(t)},i))})},G=({props:t})=>{const{tool:a,approve:i}=t,n=a.type,m=n.startsWith("tool-")?n.slice(5):n,s=a.state,u=a.approval?.id,d=!!u,g=s==="approval-requested",l=ue(a.output),[x,p]=o.useState(d),h=s?de[s]??s:"tool";o.useEffect(()=>{g&&p(!0)},[g]);const k=()=>{switch(s){case"input-streaming":return e.jsx(c.Circle,{className:"w-3 h-3"});case"input-available":return e.jsx(c.Loader2,{className:"w-3 h-3 animate-spin"});case"approval-requested":return e.jsx(c.Clock,{className:"w-3 h-3"});case"approval-responded":return e.jsx(c.CheckCircle,{className:"w-3 h-3"});case"output-available":return e.jsx(c.CheckCircle,{className:"w-3 h-3"});case"output-error":return e.jsx(c.TriangleAlert,{className:"w-3 h-3"});case"output-denied":return e.jsx(c.XCircle,{className:"w-3 h-3"});default:return null}};return e.jsxs("div",{className:"border rounded-lg mb-3 overflow-hidden",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center group gap-2 text-xs text-gray-700 dark:text-white-alpha-700 hover:text-gray-800 dark:hover:text-white-alpha-800 transition-colors cursor-pointer w-full justify-between px-4 py-2 data-[expanded=true]:border-b",onClick:()=>p(!x),"aria-expanded":x,"data-expanded":x,children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(c.Hammer,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:m})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-100 dark:bg-white-alpha-100 font-medium text-gray-700 dark:text-white-alpha-700 font-mono",children:[k(),h]}),e.jsx(c.ChevronDown,{className:"w-3.5 h-3.5 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform rotate-0 group-data-[expanded=true]:rotate-180"})]})]}),e.jsxs("div",{"data-expanded":x,className:b.cn("overflow-hidden transition-all duration-300 ease-in-out data-[expanded=true]:opacity-100 data-[expanded=false]:max-h-0 data-[expanded=false]:opacity-0 max-w-full"),children:[e.jsx("div",{"data-expanded":x,className:b.cn("relative",'before:content-[""] before:absolute before:inset-x-0 before:top-0 before:h-3 before:pointer-events-none before:z-10','after:content-[""] after:absolute after:inset-x-0 after:bottom-0 after:h-3 after:pointer-events-none after:z-10',"before:bg-[linear-gradient(white,_transparent)] after:bg-[linear-gradient(transparent,_white)]","dark:before:bg-[linear-gradient(var(--ikp-color-gray-dark-950),_transparent)] dark:after:bg-[linear-gradient(transparent,_var(--ikp-color-gray-dark-950))]","data-[expanded=false]:before:opacity-0 data-[expanded=false]:after:opacity-0"),children:e.jsx("div",{"data-expanded":x,className:b.cn("[scrollbar-width:thin] px-4","data-[expanded=true]:max-h-48 data-[expanded=true]:overflow-y-auto"),children:a.input!=null&&e.jsx("div",{className:"text-xs py-2",children:e.jsx(ge,{value:a.input})})})}),g&&u&&e.jsxs("div",{className:"flex justify-end gap-2 pt-1 pb-3 px-4",children:[e.jsx("button",{type:"button",className:b.cn(U.button({size:"xs",variant:"outline"}),"px-2 py-1 rounded-md text-xs text-gray-700 dark:text-white-alpha-700"),onClick:()=>i(!1),children:"Deny"}),e.jsxs("button",{type:"button",className:b.cn(U.button({size:"xs",variant:"primaryFilled"}),"px-2 py-1 rounded-md text-xs gap-1"),onClick:()=>i(!0),children:[e.jsx(c.Check,{className:"w-3 h-3"}),"Approve"]})]}),s==="output-available"&&l&&a.output!=null&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize pb-3 px-4",children:[l==="approved"&&e.jsx(c.Check,{className:"w-3 h-3"}),l]}),s==="output-denied"&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize pb-3 px-4",children:[e.jsx(c.X,{className:"w-3 h-3"}),h]})]})]})},ye=({className:t,componentStyles:a,children:i,isLast:n,...m})=>{const{message:s}=re.useMessage(),{logEvent:u}=te.useBaseEvents(),{conversationId:d,isStreaming:g,isLoading:l,setError:x,addToolApprovalResponse:p,sendMessage:h}=se.useChat(),{aiChatSettings:{components:k,artifacts:A,headers:E}}=ae.useInkeepConfig(),K=E?.["x-emit-operations"]==="true",L=s.role==="user",W=(g||l)&&n&&s.role==="assistant",{processedParts:X,summaryTimings:H,shouldShowInitialLoading:J,shouldShowStreamDelayLoading:Q}=le.useStreamProcessor(s.parts,W,x),[S,$]=o.useState(null),[Y,q]=o.useState(!1),y=o.useRef(null);o.useEffect(()=>{if(!S){q(!1),y.current&&(clearTimeout(y.current),y.current=null);return}return q(!1),y.current&&clearTimeout(y.current),y.current=window.setTimeout(()=>{q(!0)},1e3),()=>{y.current&&(clearTimeout(y.current),y.current=null)}},[S]),o.useEffect(()=>{S&&(!n||s.parts.length>S.partCount)&&$(null)},[S,n,s.parts.length]);const _=o.useMemo(()=>s.parts.filter(ne.isCitationArtifact),[s.parts]),I=o.useMemo(()=>oe.merge(ie.markdownStyles,a??{}),[a]),O=o.useCallback((r,f)=>{u({eventName:"assistant_message_inline_link_opened",properties:{title:f?.toString(),url:r}})},[u]),z=o.useCallback((r,f)=>{u({eventName:"assistant_code_block_copied",properties:{conversationId:d,language:r,code:f}})},[u,d]),M=o.useCallback(r=>e.jsx(C.EmbeddedChatPrimitiveMarkdown,{text:r,componentStyles:I,onLinkClick:O,onCodeCopy:z,artifacts:_}),[I,O,z,_]),Z=o.useMemo(()=>b.cn("data-[role=user]:whitespace-pre-wrap mb-3 data-[role=user]:mb-0 [&[data-role=user]>p]:mb-0 max-w-full",t),[t]),ee=!L||s.parts.some(r=>r.type==="text"&&r.text?.trim());return e.jsxs(e.Fragment,{children:[!ee&&e.jsx("span",{className:"text-gray-500 dark:text-white-alpha-500",children:"No message content"}),X.map((r,f)=>{const v={"data-role":s.role,"data-type":r?.type==="data-component"?r.data.type:r?.type,...m,className:Z};switch(r?.type){case"text":return e.jsx(C.PrimitiveMessagePart,{...v,children:L?r.text:M(r.text||"")},f);case"data-component":{const{type:w}=r.data;switch(w){case"text":return e.jsx("div",{...v,children:M(r.data.text||"")},f);default:{const N=r.data,{name:j,props:D}=N,P=k?.[j],R=P?T.DynamicComponent:me;return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(R,{name:j,props:D,componentDef:P})},`${j}-${f}`)}}}case"data-artifact":{const w=r.data,{name:N,type:j,artifactSummary:D}=w;if(j==="citation"&&!D?.url)return null;const P=A?.[j],R=P?T.DynamicComponent:he;return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(R,{name:j,props:D,componentDef:P})},`${N}-${f}`)}case"summary-group":{const w=H.get(r.groupKey)||{isCompleted:!1};return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(ce.DataSummaryGroup,{summaries:r.summaries||[],isCompleted:w.isCompleted})},`${r.groupKey}-${f}`)}default:{if(!pe(r))return null;const w=r,N=r.approval?.id;return K||N?e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(fe,{tool:w,componentDef:k?.IkpTool,renderText:M,approvalId:N,messagePartsLength:s.parts.length,setApprovalDelayPending:$,addToolApprovalResponse:p,sendMessage:h,conversationId:d})},r.toolCallId??`${r.type}-${f}`):null}}}),J&&e.jsx(T.MessageLoading,{}),(Q||Y)&&e.jsx(xe,{})]})};exports.DefaultToolComponent=G;exports.EmbeddedChatMessagePart=ye;
|
|
@@ -11,7 +11,7 @@ import { cn as y } from "../utils.js";
|
|
|
11
11
|
import { markdownStyles as xe } from "./ui/markdown-styles.js";
|
|
12
12
|
import { useStreamProcessor as fe } from "../../primitives/components/embedded-chat/use-stream-processor.js";
|
|
13
13
|
import { DataSummaryGroup as ge } from "./data-summary-group.js";
|
|
14
|
-
import { useState as
|
|
14
|
+
import { useState as L, useRef as A, useEffect as $, useMemo as E, useCallback as P } from "react";
|
|
15
15
|
import { DynamicComponent as M, MessageLoading as ye } from "./embedded-chat.js";
|
|
16
16
|
import { Hammer as be, ChevronDown as X, Check as F, X as we, Library as ke, ComponentIcon as Ne, XCircle as ve, TriangleAlert as Ce, CheckCircle as K, Clock as Se, Loader2 as De, Circle as Te } from "lucide-react";
|
|
17
17
|
import { button as W } from "./ui/recipes/button.js";
|
|
@@ -63,18 +63,18 @@ const Pe = (t) => {
|
|
|
63
63
|
sendMessage: d,
|
|
64
64
|
conversationId: f
|
|
65
65
|
}) => {
|
|
66
|
-
const l =
|
|
66
|
+
const l = A(d);
|
|
67
67
|
l.current = d;
|
|
68
|
-
const m =
|
|
68
|
+
const m = A(c);
|
|
69
69
|
m.current = c;
|
|
70
|
-
const p =
|
|
70
|
+
const p = A(n);
|
|
71
71
|
p.current = n;
|
|
72
|
-
const h =
|
|
73
|
-
async (
|
|
74
|
-
s && (p.current({ partCount: u }), m.current({ id: s, approved:
|
|
72
|
+
const h = P(
|
|
73
|
+
async (j = !0) => {
|
|
74
|
+
s && (p.current({ partCount: u }), m.current({ id: s, approved: j }), await l.current(void 0, { body: { conversationId: f } }));
|
|
75
75
|
},
|
|
76
76
|
[s, u, f]
|
|
77
|
-
), v =
|
|
77
|
+
), v = E(() => ({ tool: t, approve: h, renderMarkdown: i }), [t]);
|
|
78
78
|
return /* @__PURE__ */ e(a ? M : Me, { name: t.type, props: v, componentDef: a });
|
|
79
79
|
};
|
|
80
80
|
function H(t) {
|
|
@@ -95,7 +95,7 @@ const J = ({
|
|
|
95
95
|
isArrayIndex: i,
|
|
96
96
|
depth: s = 0
|
|
97
97
|
}) => {
|
|
98
|
-
const [u, n] =
|
|
98
|
+
const [u, n] = L(s < 1), c = a !== null && typeof a == "object" && !Array.isArray(a), d = Array.isArray(a);
|
|
99
99
|
if (!(c || d))
|
|
100
100
|
return /* @__PURE__ */ o("div", { className: "flex items-baseline gap-2 py-1 text-xs", children: [
|
|
101
101
|
/* @__PURE__ */ e(
|
|
@@ -108,7 +108,7 @@ const J = ({
|
|
|
108
108
|
children: i ? "—" : t
|
|
109
109
|
}
|
|
110
110
|
),
|
|
111
|
-
/* @__PURE__ */ e("span", { children: H(a) })
|
|
111
|
+
/* @__PURE__ */ e("span", { className: "min-w-0", children: H(a) })
|
|
112
112
|
] });
|
|
113
113
|
const l = d ? a.map((p, h) => [String(h), p]) : Object.entries(a);
|
|
114
114
|
return l.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-baseline gap-2 py-1 text-xs", children: [
|
|
@@ -146,7 +146,7 @@ const J = ({
|
|
|
146
146
|
const a = Array.isArray(t) ? t.map((i, s) => [String(s), i]) : Object.entries(t);
|
|
147
147
|
return a.length === 0 ? /* @__PURE__ */ e("div", { className: "text-xs text-gray-400 dark:text-white-alpha-400 italic", children: "No arguments" }) : /* @__PURE__ */ e("div", { className: "space-y-1", children: a.map(([i, s]) => /* @__PURE__ */ e(J, { name: i, value: s, isArrayIndex: Array.isArray(t) }, i)) });
|
|
148
148
|
}, Me = ({ props: t }) => {
|
|
149
|
-
const { tool: a, approve: i } = t, s = a.type, u = s.startsWith("tool-") ? s.slice(5) : s, n = a.state, c = a.approval?.id, d = !!c, f = n === "approval-requested", l = Pe(a.output), [m, p] =
|
|
149
|
+
const { tool: a, approve: i } = t, s = a.type, u = s.startsWith("tool-") ? s.slice(5) : s, n = a.state, c = a.approval?.id, d = !!c, f = n === "approval-requested", l = Pe(a.output), [m, p] = L(d), h = n ? Ae[n] ?? n : "tool";
|
|
150
150
|
return $(() => {
|
|
151
151
|
f && p(!0);
|
|
152
152
|
}, [f]), /* @__PURE__ */ o("div", { className: "border rounded-lg mb-3 overflow-hidden", children: [
|
|
@@ -274,28 +274,25 @@ const J = ({
|
|
|
274
274
|
...u
|
|
275
275
|
}) => {
|
|
276
276
|
const { message: n } = pe(), { logEvent: c } = le(), { conversationId: d, isStreaming: f, isLoading: l, setError: m, addToolApprovalResponse: p, sendMessage: h } = me(), {
|
|
277
|
-
aiChatSettings: { components: v, artifacts: R, headers:
|
|
278
|
-
} = de(), Q =
|
|
277
|
+
aiChatSettings: { components: v, artifacts: R, headers: j }
|
|
278
|
+
} = de(), Q = j?.["x-emit-operations"] === "true", O = n.role === "user", Y = (f || l) && s && n.role === "assistant", { processedParts: Z, summaryTimings: ee, shouldShowInitialLoading: te, shouldShowStreamDelayLoading: ae } = fe(n.parts, Y, m), [C, z] = L(null), [re, I] = L(!1), g = A(null);
|
|
279
279
|
$(() => {
|
|
280
280
|
if (!C) {
|
|
281
|
-
|
|
281
|
+
I(!1), g.current && (clearTimeout(g.current), g.current = null);
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
|
-
return
|
|
285
|
-
|
|
284
|
+
return I(!1), g.current && clearTimeout(g.current), g.current = window.setTimeout(() => {
|
|
285
|
+
I(!0);
|
|
286
286
|
}, 1e3), () => {
|
|
287
287
|
g.current && (clearTimeout(g.current), g.current = null);
|
|
288
288
|
};
|
|
289
289
|
}, [C]), $(() => {
|
|
290
290
|
C && (!s || n.parts.length > C.partCount) && z(null);
|
|
291
291
|
}, [C, s, n.parts.length]);
|
|
292
|
-
const q =
|
|
293
|
-
() => n.parts.filter(ue),
|
|
294
|
-
[n.parts]
|
|
295
|
-
), U = A(
|
|
292
|
+
const q = E(() => n.parts.filter(ue), [n.parts]), U = E(
|
|
296
293
|
() => he(xe, a ?? {}),
|
|
297
294
|
[a]
|
|
298
|
-
), V =
|
|
295
|
+
), V = P(
|
|
299
296
|
(r, x) => {
|
|
300
297
|
c({
|
|
301
298
|
eventName: "assistant_message_inline_link_opened",
|
|
@@ -306,7 +303,7 @@ const J = ({
|
|
|
306
303
|
});
|
|
307
304
|
},
|
|
308
305
|
[c]
|
|
309
|
-
), B =
|
|
306
|
+
), B = P(
|
|
310
307
|
(r, x) => {
|
|
311
308
|
c({
|
|
312
309
|
eventName: "assistant_code_block_copied",
|
|
@@ -318,7 +315,7 @@ const J = ({
|
|
|
318
315
|
});
|
|
319
316
|
},
|
|
320
317
|
[c, d]
|
|
321
|
-
),
|
|
318
|
+
), _ = P(
|
|
322
319
|
(r) => /* @__PURE__ */ e(
|
|
323
320
|
ce,
|
|
324
321
|
{
|
|
@@ -330,7 +327,7 @@ const J = ({
|
|
|
330
327
|
}
|
|
331
328
|
),
|
|
332
329
|
[U, V, B, q]
|
|
333
|
-
), ne =
|
|
330
|
+
), ne = E(
|
|
334
331
|
() => y(
|
|
335
332
|
"data-[role=user]:whitespace-pre-wrap mb-3 data-[role=user]:mb-0 [&[data-role=user]>p]:mb-0 max-w-full",
|
|
336
333
|
t
|
|
@@ -350,44 +347,46 @@ const J = ({
|
|
|
350
347
|
};
|
|
351
348
|
switch (r?.type) {
|
|
352
349
|
case "text":
|
|
353
|
-
return /* @__PURE__ */ e(D, { ...k, children: O ? r.text :
|
|
350
|
+
return /* @__PURE__ */ e(D, { ...k, children: O ? r.text : _(r.text || "") }, x);
|
|
354
351
|
case "data-component": {
|
|
355
|
-
const { type:
|
|
356
|
-
switch (
|
|
352
|
+
const { type: w } = r.data;
|
|
353
|
+
switch (w) {
|
|
357
354
|
case "text":
|
|
358
|
-
return /* @__PURE__ */ e("div", { ...k, children:
|
|
355
|
+
return /* @__PURE__ */ e("div", { ...k, children: _(r.data.text || "") }, x);
|
|
359
356
|
default: {
|
|
360
|
-
const N = r.data, { name:
|
|
361
|
-
return /* @__PURE__ */ e(D, { ...k, children: /* @__PURE__ */ e(S ? M : je, { name:
|
|
357
|
+
const N = r.data, { name: b, props: T } = N, S = v?.[b];
|
|
358
|
+
return /* @__PURE__ */ e(D, { ...k, children: /* @__PURE__ */ e(S ? M : je, { name: b, props: T, componentDef: S }) }, `${b}-${x}`);
|
|
362
359
|
}
|
|
363
360
|
}
|
|
364
361
|
}
|
|
365
362
|
case "data-artifact": {
|
|
366
|
-
const
|
|
367
|
-
|
|
363
|
+
const w = r.data, { name: N, type: b, artifactSummary: T } = w;
|
|
364
|
+
if (b === "citation" && !T?.url) return null;
|
|
365
|
+
const S = R?.[b];
|
|
366
|
+
return /* @__PURE__ */ e(D, { ...k, children: /* @__PURE__ */ e(S ? M : Ie, { name: b, props: T, componentDef: S }) }, `${N}-${x}`);
|
|
368
367
|
}
|
|
369
368
|
case "summary-group": {
|
|
370
|
-
const
|
|
369
|
+
const w = ee.get(r.groupKey) || {
|
|
371
370
|
isCompleted: !1
|
|
372
371
|
};
|
|
373
372
|
return /* @__PURE__ */ e(D, { ...k, children: /* @__PURE__ */ e(
|
|
374
373
|
ge,
|
|
375
374
|
{
|
|
376
375
|
summaries: r.summaries || [],
|
|
377
|
-
isCompleted:
|
|
376
|
+
isCompleted: w.isCompleted
|
|
378
377
|
}
|
|
379
378
|
) }, `${r.groupKey}-${x}`);
|
|
380
379
|
}
|
|
381
380
|
default: {
|
|
382
381
|
if (!Ee(r))
|
|
383
382
|
return null;
|
|
384
|
-
const
|
|
383
|
+
const w = r, N = r.approval?.id;
|
|
385
384
|
return Q || N ? /* @__PURE__ */ e(D, { ...k, children: /* @__PURE__ */ e(
|
|
386
385
|
_e,
|
|
387
386
|
{
|
|
388
|
-
tool:
|
|
387
|
+
tool: w,
|
|
389
388
|
componentDef: v?.IkpTool,
|
|
390
|
-
renderText:
|
|
389
|
+
renderText: _,
|
|
391
390
|
approvalId: N,
|
|
392
391
|
messagePartsLength: n.parts.length,
|
|
393
392
|
setApprovalDelayPending: z,
|
|
@@ -195,6 +195,13 @@ export interface InkeepAIChatSettings {
|
|
|
195
195
|
*/
|
|
196
196
|
components?: ComponentsConfig<any>;
|
|
197
197
|
artifacts?: ComponentsConfig<any>;
|
|
198
|
+
/**
|
|
199
|
+
* Controls whether the chat automatically scrolls to the bottom
|
|
200
|
+
* during streaming. When false, streaming auto-scroll is disabled
|
|
201
|
+
* but the chat still scrolls to bottom when the user sends a new message.
|
|
202
|
+
* @default true
|
|
203
|
+
*/
|
|
204
|
+
shouldAutoScroll?: boolean;
|
|
198
205
|
}
|
|
199
206
|
export interface AIChatDisclaimerSettings {
|
|
200
207
|
/**
|