@inkeep/agents-ui 0.0.0-dev-20260408203717 → 0.0.0-dev-20260408223123

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),w=require("react"),f=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"),n=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 p={h1:({children:r})=>e.jsx(n.MarkdownH1,{children:r}),h2:({children:r})=>e.jsx(n.MarkdownH2,{children:r}),p:({children:r})=>e.jsx(n.MarkdownP,{children:r}),li:({children:r})=>e.jsx(n.MarkdownLi,{children:r}),ul:({children:r})=>e.jsx(n.MarkdownUl,{children:r}),hr:()=>e.jsx(n.MarkdownHr,{}),input:({type:r,checked:s,disabled:t,readOnly:o,required:i,value:a})=>e.jsx(n.MarkdownInput,{type:r,checked:s,disabled:t,readOnly:o,required:i,value:a}),ol:({children:r,node:s})=>{const t=s?.properties?.start,o=typeof t=="number"?t:void 0;return e.jsx(n.MarkdownOl,{style:{"--start":t?.toString()??"0"},start:o,children:r})},a:({children:r,href:s})=>{const t=w.Children.toArray(r),o=t[0],i=typeof o=="string"&&/^\(\d+\)$/.test(o)&&t.length===1,a=i?o.match(/\d+/):r,u=e.jsx(n.MarkdownLink,{isExternal:d,href:s,onClick:()=>{l?.(s,a?.toString())},children:a});return i?e.jsx(n.MarkdownSourceLink,{children:u}):u},img:({src:r,alt:s})=>e.jsx(n.MarkdownImg,{src:r,alt:s}),table:({children:r})=>e.jsx(n.MarkdownTable,{children:r}),th:({children:r,isHeader:s})=>s?e.jsx(n.MarkdownTh,{children:r}):e.jsx(n.MarkdownTd,{children:r}),pre:({children:r})=>e.jsx("pre",{children:r}),code:({children:r,inline:s,className:t})=>s?e.jsx(n.MarkdownCode,{children:r}):e.jsx(S.CodeBlock,{className:t,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 s=x?.find(t=>(t.data?.artifactSummary?.title||t.data?.name)===r);if(s){const t=s.data,o=t?.artifactSummary?.url,i=t?.artifactSummary?.title||t?.name||r;return o?e.jsx(n.MarkdownSup,{children:e.jsx(n.MarkdownLink,{href:o,isExternal:d,onClick:()=>l?.(o,i),children:e.jsx("span",{children:i})})}):e.jsx(n.MarkdownSup,{children:e.jsx("span",{children:i})})}}return e.jsx("sup",{children:r})}},k=e.jsx(f,{remarkPlugins:[[y,{singleTilde:!1}],g],rehypePlugins:[M,q.rehypeInlineCodeProperty],components:p,disallowedElements:P,children:c.toString(),...j});return e.jsx(b.ChatMarkdownProvider,{componentStyles:h,children:k})},P=["script","iframe","frame","embed","meta","base","form","style","object"];exports.Markdown=C;
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 y, Fragment as g } from "react/jsx-runtime";
2
- import b from "react";
3
- import S from "react-markdown";
4
- import C from "rehype-raw";
5
- import x from "remark-gfm";
6
- import P from "remark-supersub";
7
- import { ChatMarkdownProvider as j } from "../../providers/markdown-provider.js";
8
- import { CodeBlock as E } from "../codeblock/index.js";
9
- import { MarkdownSup as m, MarkdownLink as h, 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";
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: u,
14
- shouldOpenLinksInNewTab: c,
15
- onLinkClick: l,
16
- onCodeCopy: p,
13
+ componentStyles: h,
14
+ shouldOpenLinksInNewTab: l,
15
+ onLinkClick: c,
16
+ onCodeCopy: u,
17
17
  artifacts: f,
18
- ...k
18
+ ...p
19
19
  }) => {
20
20
  if (!d) return null;
21
- const w = {
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: i, value: a }) => /* @__PURE__ */ t(
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: i,
36
- value: a
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 = b.Children.toArray(r), o = n[0], i = typeof o == "string" && /^\(\d+\)$/.test(o) && n.length === 1, a = i ? o.match(/\d+/) : r, s = /* @__PURE__ */ t(
54
- h,
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: c,
56
+ isExternal: l,
57
57
  href: e,
58
58
  onClick: () => {
59
- l?.(e, a?.toString());
59
+ c?.(e, i?.toString());
60
60
  },
61
- children: a
61
+ children: i
62
62
  }
63
63
  );
64
- return i ? /* @__PURE__ */ t(I, { children: s }) : s;
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(E, { className: n, onCopy: p, children: r }),
71
- sub: ({ children: r }) => typeof r == "string" && (r.startsWith(" ") || r.endsWith(" ")) ? /* @__PURE__ */ y(g, { children: [
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, i = n?.artifactSummary?.title || n?.name || r;
83
- return o ? /* @__PURE__ */ t(m, { children: /* @__PURE__ */ t(
84
- h,
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: c,
88
- onClick: () => l?.(o, i),
89
+ isExternal: l,
90
+ onClick: () => c?.(o, i),
89
91
  children: /* @__PURE__ */ t("span", { children: i })
90
92
  }
91
- ) }) : /* @__PURE__ */ t(m, { children: /* @__PURE__ */ t("span", { children: i }) });
93
+ ) });
92
94
  }
93
95
  }
94
96
  return /* @__PURE__ */ t("sup", { children: r });
95
97
  }
96
- }, M = /* @__PURE__ */ t(
97
- S,
98
+ }, w = /* @__PURE__ */ t(
99
+ b,
98
100
  {
99
- remarkPlugins: [[x, { singleTilde: !1 }], P],
100
- rehypePlugins: [C, V],
101
- components: w,
101
+ remarkPlugins: [[C, { singleTilde: !1 }], x],
102
+ rehypePlugins: [S, V],
103
+ components: k,
102
104
  disallowedElements: $,
103
105
  children: d.toString(),
104
- ...k
106
+ ...p
105
107
  }
106
108
  );
107
- return /* @__PURE__ */ t(j, { componentStyles: u, children: M });
109
+ return /* @__PURE__ */ t(P, { componentStyles: h, children: w });
108
110
  }, $ = [
109
111
  "script",
110
112
  "iframe",
@@ -2,7 +2,7 @@
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?`,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).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(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}
6
6
 
7
7
  ${D}`}).join(`
8
8
 
@@ -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,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})`:n(e)}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=`
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 u = (
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 i(t) {
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 (i(n)) {
27
+ if (s(n)) {
28
28
  const a = n.data?.artifactSummary?.url;
29
- return a ? `[${e(n)}](${a})` : e(n);
29
+ return a ? `[${e(n)}](${a})` : null;
30
30
  }
31
31
  return null;
32
- }).join("") ?? "", o = /* @__PURE__ */ new Set(), s = t.parts?.filter(i).filter((n) => {
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 (!s.length) return r;
37
- const c = `
36
+ if (!i.length) return r;
37
+ const u = `
38
38
 
39
39
  **Sources:**
40
- ` + s.map((n) => {
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 + c;
45
+ return r + u;
46
46
  };
47
47
  export {
48
- u as callAll,
48
+ c as callAll,
49
49
  m as dataAttr,
50
50
  d as getInitials,
51
51
  g as getMessageContent,
52
- i as isCitationArtifact,
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 P, useRef as T, useEffect as $, useMemo as A, useCallback as E } from "react";
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 = T(d);
66
+ const l = A(d);
67
67
  l.current = d;
68
- const m = T(c);
68
+ const m = A(c);
69
69
  m.current = c;
70
- const p = T(n);
70
+ const p = A(n);
71
71
  p.current = n;
72
- const h = E(
73
- async (L = !0) => {
74
- s && (p.current({ partCount: u }), m.current({ id: s, approved: L }), await l.current(void 0, { body: { conversationId: f } }));
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 = A(() => ({ tool: t, approve: h, renderMarkdown: i }), [t]);
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] = P(s < 1), c = a !== null && typeof a == "object" && !Array.isArray(a), d = Array.isArray(a);
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] = P(d), h = n ? Ae[n] ?? n : "tool";
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: L }
278
- } = de(), Q = L?.["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] = P(null), [re, j] = P(!1), g = T(null);
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
- j(!1), g.current && (clearTimeout(g.current), g.current = null);
281
+ I(!1), g.current && (clearTimeout(g.current), g.current = null);
282
282
  return;
283
283
  }
284
- return j(!1), g.current && clearTimeout(g.current), g.current = window.setTimeout(() => {
285
- j(!0);
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 = A(
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 = E(
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 = E(
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
- ), I = E(
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 = A(
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 : I(r.text || "") }, x);
350
+ return /* @__PURE__ */ e(D, { ...k, children: O ? r.text : _(r.text || "") }, x);
354
351
  case "data-component": {
355
- const { type: b } = r.data;
356
- switch (b) {
352
+ const { type: w } = r.data;
353
+ switch (w) {
357
354
  case "text":
358
- return /* @__PURE__ */ e("div", { ...k, children: I(r.data.text || "") }, x);
355
+ return /* @__PURE__ */ e("div", { ...k, children: _(r.data.text || "") }, x);
359
356
  default: {
360
- const N = r.data, { name: w, props: _ } = N, S = v?.[w];
361
- return /* @__PURE__ */ e(D, { ...k, children: /* @__PURE__ */ e(S ? M : je, { name: w, props: _, componentDef: S }) }, `${w}-${x}`);
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 b = r.data, { name: N, type: w, artifactSummary: _ } = b, S = R?.[w];
367
- return /* @__PURE__ */ e(D, { ...k, children: /* @__PURE__ */ e(S ? M : Ie, { name: w, props: _, componentDef: S }) }, `${N}-${x}`);
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 b = ee.get(r.groupKey) || {
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: b.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 b = r, N = r.approval?.id;
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: b,
387
+ tool: w,
389
388
  componentDef: v?.IkpTool,
390
- renderText: I,
389
+ renderText: _,
391
390
  approvalId: N,
392
391
  messagePartsLength: n.parts.length,
393
392
  setApprovalDelayPending: z,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-ui",
3
- "version": "0.0.0-dev-20260408203717",
3
+ "version": "0.0.0-dev-20260408223123",
4
4
  "description": "",
5
5
  "homepage": "",
6
6
  "repository": {