@progress/kendo-react-conversational-ui 14.4.1 → 14.5.0-develop.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/ai-prompt/AIPromptContent.js +1 -1
  2. package/ai-prompt/AIPromptContent.mjs +5 -5
  3. package/ai-prompt/views/AIPromptOutputView.js +1 -1
  4. package/ai-prompt/views/AIPromptOutputView.mjs +6 -6
  5. package/chat/ChatPropsAndState.d.ts +5 -3
  6. package/chat/Events.d.ts +3 -3
  7. package/chat/components/Chat.js +1 -1
  8. package/chat/components/Chat.mjs +17 -17
  9. package/chat/components/ChatMessage.js +1 -1
  10. package/chat/components/ChatMessage.mjs +56 -55
  11. package/chat/components/Header.js +1 -1
  12. package/chat/components/Header.mjs +1 -1
  13. package/chat/components/NewMessage.js +1 -1
  14. package/chat/components/NewMessage.mjs +49 -48
  15. package/chat/components/Notification.js +1 -1
  16. package/chat/components/Notification.mjs +1 -1
  17. package/chat/components/elements/FileBox.js +1 -1
  18. package/chat/components/elements/FileBox.mjs +10 -9
  19. package/chat/components/elements/PinnedMessage.js +1 -1
  20. package/chat/components/elements/PinnedMessage.mjs +14 -13
  21. package/chat/hooks/useEndlessScroll.d.ts +1 -1
  22. package/chat/hooks/useEndlessScroll.js +1 -1
  23. package/chat/hooks/useEndlessScroll.mjs +160 -160
  24. package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
  25. package/inline-ai-prompt/InlineAIPrompt.js +1 -1
  26. package/inline-ai-prompt/InlineAIPrompt.mjs +10 -10
  27. package/inline-ai-prompt/InlineAIPromptInput.js +1 -1
  28. package/inline-ai-prompt/InlineAIPromptInput.mjs +1 -1
  29. package/package-metadata.js +1 -1
  30. package/package-metadata.mjs +2 -2
  31. package/package.json +17 -12
  32. package/prompt-box/FileBox.js +1 -1
  33. package/prompt-box/FileBox.mjs +21 -20
  34. package/prompt-box/PromptBox.js +1 -1
  35. package/prompt-box/PromptBox.mjs +30 -30
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react"),f=require("@progress/kendo-svg-icons"),b=require("@progress/kendo-react-buttons"),r=require("../messages/index.js"),k=require("@progress/kendo-react-intl"),I=require("./AIPromptContext.js"),C=require("./views/constants.js");function P(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const a=P(g),l=a.forwardRef((e,o)=>{const{children:t,streaming:n,onCancel:c}=e,s=k.useLocalization().toLanguageString(r.aIPromptCancel,r.messages[r.aIPromptCancel]),[u]=I.useAIPromptContext(),m=u.activeView===C.outputViewDefaults.name,p=n&&!m,d=a.useCallback(i=>{i.key==="Escape"&&n&&c&&(i.preventDefault(),c())},[n,c]);return a.createElement("div",{className:"k-prompt-content",ref:o,onKeyDown:d},p&&a.createElement(b.FloatingActionButton,{onClick:c,svgIcon:f.stopSmIcon,icon:"stop-sm",size:"medium",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":s,title:s}),a.createElement("div",{className:"k-prompt-view"},t))});l.displayName="KendoReactAIPromptContent";exports.AIPromptContent=l;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react"),f=require("@progress/kendo-svg-icons"),b=require("@progress/kendo-react-buttons"),r=require("../messages/index.js"),k=require("@progress/kendo-react-intl"),I=require("./AIPromptContext.js"),C=require("./views/constants.js");function P(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const a=P(g),l=a.forwardRef((e,o)=>{const{children:t,streaming:n,onCancel:c}=e,s=k.useLocalization().toLanguageString(r.aIPromptCancel,r.messages[r.aIPromptCancel]),[u]=I.useAIPromptContext(),p=u.activeView===C.outputViewDefaults.name,m=n&&!p,d=a.useCallback(i=>{i.key==="Escape"&&n&&c&&(i.preventDefault(),c())},[n,c]);return a.createElement("div",{className:"k-prompt-content",ref:o,onKeyDown:d},m&&a.createElement(b.FloatingActionButton,{onClick:c,svgIcon:f.stopIcon,icon:"stop",size:"medium",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":s,title:s}),a.createElement("div",{className:"k-prompt-view"},t))});l.displayName="KendoReactAIPromptContent";exports.AIPromptContent=l;
@@ -6,25 +6,25 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  import * as t from "react";
9
- import { stopSmIcon as f } from "@progress/kendo-svg-icons";
9
+ import { stopIcon as f } from "@progress/kendo-svg-icons";
10
10
  import { FloatingActionButton as g } from "@progress/kendo-react-buttons";
11
11
  import { aIPromptCancel as i, messages as d } from "../messages/index.mjs";
12
12
  import { useLocalization as w } from "@progress/kendo-react-intl";
13
13
  import { useAIPromptContext as k } from "./AIPromptContext.mjs";
14
14
  import { outputViewDefaults as C } from "./views/constants.mjs";
15
- const I = t.forwardRef((m, r) => {
16
- const { children: s, streaming: e, onCancel: o } = m, n = w().toLanguageString(i, d[i]), [c] = k(), l = c.activeView === C.name, p = e && !l, u = t.useCallback(
15
+ const I = t.forwardRef((r, c) => {
16
+ const { children: s, streaming: e, onCancel: o } = r, n = w().toLanguageString(i, d[i]), [m] = k(), l = m.activeView === C.name, p = e && !l, u = t.useCallback(
17
17
  (a) => {
18
18
  a.key === "Escape" && e && o && (a.preventDefault(), o());
19
19
  },
20
20
  [e, o]
21
21
  );
22
- return /* @__PURE__ */ t.createElement("div", { className: "k-prompt-content", ref: r, onKeyDown: u }, p && /* @__PURE__ */ t.createElement(
22
+ return /* @__PURE__ */ t.createElement("div", { className: "k-prompt-content", ref: c, onKeyDown: u }, p && /* @__PURE__ */ t.createElement(
23
23
  g,
24
24
  {
25
25
  onClick: o,
26
26
  svgIcon: f,
27
- icon: "stop-sm",
27
+ icon: "stop",
28
28
  size: "medium",
29
29
  positionMode: "absolute",
30
30
  className: "k-prompt-stop-fab k-generating",
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react"),S=require("../AIPromptContent.js"),A=require("../AIPromptContext.js"),i=require("../../messages/index.js"),B=require("./AIPromptViewRender.js"),o=require("@progress/kendo-react-layout"),s=require("@progress/kendo-svg-icons"),m=require("@progress/kendo-react-buttons"),x=require("@progress/kendo-react-intl"),z=require("./constants.js");function N(l){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const r in l)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(l,r);Object.defineProperty(d,r,a.get?a:{enumerable:!0,get:()=>l[r]})}}return d.default=l,Object.freeze(d)}const e=N(q),M=l=>{const[d,r]=e.useState(""),a=e.useRef(null),[n]=A.useAIPromptContext(),{outputs:p,showOutputRating:b,outputCard:R}=l,{header:g,body:k,actions:E}=R||{},f=x.useLocalization(),u=f.toLanguageString(i.aIPromptCancel,i.messages[i.aIPromptCancel]),P=t=>{n.onPromptRequest&&n.onPromptRequest.call(null,t.prompt,{...t,isRetry:!0}),I()},h=t=>{t!=null&&t.responseContent&&navigator.clipboard.writeText(t.responseContent),r(t.id),setTimeout(()=>{r("")},1e3)},y=(t,c)=>{n.onPromptRequest&&n.onPromptRequest.call(null,t.prompt,{...t,ratingType:c,isRetry:!1}),I()},I=()=>{a&&a.current&&a.current.scrollTo({top:0,behavior:"smooth"})},v=e.createElement(o.Card,null,e.createElement(o.CardHeader,null,e.createElement(o.CardTitle,null,e.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),e.createElement(o.CardSubtitle,null,e.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),e.createElement(o.CardBody,null,e.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),e.createElement(o.CardActions,null,n.streaming&&n.onCancel?e.createElement(m.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:s.stopSmIcon,title:u,onClick:n.onCancel},u):e.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),T=(t,c)=>E?E(t):c&&n.onCancel?e.createElement(m.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:s.stopSmIcon,title:u,onClick:n.onCancel},u):e.createElement(e.Fragment,null,e.createElement(m.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:d===t.id?s.checkIcon:s.copyIcon,onClick:()=>h(t)},"Copy"),e.createElement(m.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:s.arrowRotateCwIcon,onClick:()=>P(t)},"Retry"),b&&e.createElement(e.Fragment,null,e.createElement("span",{className:"k-spacer"}),e.createElement(m.Button,{size:"medium",themeColor:t.ratingType==="positive"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:s.thumbUpOutlineIcon,onClick:()=>y(t,"positive")}),e.createElement(m.Button,{size:"medium",themeColor:t.ratingType==="negative"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:s.thumbDownOutlineIcon,onClick:()=>y(t,"negative")}))),C=p==null?void 0:p.map((t,c)=>{const O=!!(n.streaming&&!n.loading&&c===0);return e.createElement(o.Card,{key:`${t.id}_${c}`},e.createElement(o.CardHeader,null,g?g(t):e.createElement(e.Fragment,null,t.title&&e.createElement(o.CardTitle,null,t.title),t.subTitle&&e.createElement(o.CardSubtitle,null,t.subTitle))),e.createElement(o.CardBody,null,k?k(t):t.responseContent),e.createElement(o.CardActions,null,T(t,O)))}),w=e.createElement(o.Card,null,e.createElement(o.CardBody,null,f.toLanguageString(i.aIPromptNoOutputs,i.messages[i.aIPromptNoOutputs])));return e.createElement(B.AIPromptViewRender,{name:z.outputViewDefaults.name},e.createElement(S.AIPromptContent,{ref:a,streaming:n.streaming,onCancel:n.onCancel},e.createElement("div",{className:"k-card-list"},n.loading&&v,C,(!C||C.length===0)&&!n.loading&&w)))};exports.AIPromptOutputView=M;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react"),A=require("../AIPromptContent.js"),B=require("../AIPromptContext.js"),i=require("../../messages/index.js"),S=require("./AIPromptViewRender.js"),o=require("@progress/kendo-react-layout"),s=require("@progress/kendo-svg-icons"),m=require("@progress/kendo-react-buttons"),x=require("@progress/kendo-react-intl"),z=require("./constants.js");function N(r){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const l in r)if(l!=="default"){const a=Object.getOwnPropertyDescriptor(r,l);Object.defineProperty(d,l,a.get?a:{enumerable:!0,get:()=>r[l]})}}return d.default=r,Object.freeze(d)}const e=N(O),M=r=>{const[d,l]=e.useState(""),a=e.useRef(null),[n]=B.useAIPromptContext(),{outputs:p,showOutputRating:b,outputCard:R}=r,{header:g,body:k,actions:E}=R||{},f=x.useLocalization(),u=f.toLanguageString(i.aIPromptCancel,i.messages[i.aIPromptCancel]),P=t=>{n.onPromptRequest&&n.onPromptRequest.call(null,t.prompt,{...t,isRetry:!0}),I()},h=t=>{t!=null&&t.responseContent&&navigator.clipboard.writeText(t.responseContent),l(t.id),setTimeout(()=>{l("")},1e3)},y=(t,c)=>{n.onPromptRequest&&n.onPromptRequest.call(null,t.prompt,{...t,ratingType:c,isRetry:!1}),I()},I=()=>{a&&a.current&&a.current.scrollTo({top:0,behavior:"smooth"})},v=e.createElement(o.Card,null,e.createElement(o.CardHeader,null,e.createElement(o.CardTitle,null,e.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),e.createElement(o.CardSubtitle,null,e.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),e.createElement(o.CardBody,null,e.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),e.createElement(o.CardActions,null,n.streaming&&n.onCancel?e.createElement(m.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:s.stopIcon,title:u,onClick:n.onCancel},u):e.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),T=(t,c)=>E?E(t):c&&n.onCancel?e.createElement(m.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:s.stopIcon,title:u,onClick:n.onCancel},u):e.createElement(e.Fragment,null,e.createElement(m.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:d===t.id?s.checkIcon:s.copyIcon,onClick:()=>h(t)},"Copy"),e.createElement(m.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:s.arrowRotateCwIcon,onClick:()=>P(t)},"Retry"),b&&e.createElement(e.Fragment,null,e.createElement("span",{className:"k-spacer"}),e.createElement(m.Button,{size:"medium",themeColor:t.ratingType==="positive"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:s.thumbUpIcon,onClick:()=>y(t,"positive")}),e.createElement(m.Button,{size:"medium",themeColor:t.ratingType==="negative"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:s.thumbDownIcon,onClick:()=>y(t,"negative")}))),C=p==null?void 0:p.map((t,c)=>{const q=!!(n.streaming&&!n.loading&&c===0);return e.createElement(o.Card,{key:`${t.id}_${c}`},e.createElement(o.CardHeader,null,g?g(t):e.createElement(e.Fragment,null,t.title&&e.createElement(o.CardTitle,null,t.title),t.subTitle&&e.createElement(o.CardSubtitle,null,t.subTitle))),e.createElement(o.CardBody,null,k?k(t):t.responseContent),e.createElement(o.CardActions,null,T(t,q)))}),w=e.createElement(o.Card,null,e.createElement(o.CardBody,null,f.toLanguageString(i.aIPromptNoOutputs,i.messages[i.aIPromptNoOutputs])));return e.createElement(S.AIPromptViewRender,{name:z.outputViewDefaults.name},e.createElement(A.AIPromptContent,{ref:a,streaming:n.streaming,onCancel:n.onCancel},e.createElement("div",{className:"k-card-list"},n.loading&&v,C,(!C||C.length===0)&&!n.loading&&w)))};exports.AIPromptOutputView=M;
@@ -11,12 +11,12 @@ import { useAIPromptContext as F } from "../AIPromptContext.mjs";
11
11
  import { aIPromptCancel as f, messages as y, aIPromptNoOutputs as R } from "../../messages/index.mjs";
12
12
  import { AIPromptViewRender as L } from "./AIPromptViewRender.mjs";
13
13
  import { Card as i, CardHeader as h, CardTitle as I, CardSubtitle as b, CardBody as c, CardActions as v } from "@progress/kendo-react-layout";
14
- import { stopSmIcon as T, checkIcon as V, copyIcon as D, arrowRotateCwIcon as $, thumbUpOutlineIcon as H, thumbDownOutlineIcon as U } from "@progress/kendo-svg-icons";
14
+ import { stopIcon as T, checkIcon as V, copyIcon as D, arrowRotateCwIcon as $, thumbUpIcon as H, thumbDownIcon as U } from "@progress/kendo-svg-icons";
15
15
  import { Button as o } from "@progress/kendo-react-buttons";
16
16
  import { useLocalization as _ } from "@progress/kendo-react-intl";
17
17
  import { outputViewDefaults as j } from "./constants.mjs";
18
18
  const te = (w) => {
19
- const [P, d] = e.useState(""), r = e.useRef(null), [n] = F(), { outputs: m, showOutputRating: x, outputCard: z } = w, { header: p, body: u, actions: C } = z || {}, g = _(), a = g.toLanguageString(f, y[f]), A = (t) => {
19
+ const [P, d] = e.useState(""), r = e.useRef(null), [n] = F(), { outputs: m, showOutputRating: x, outputCard: z } = w, { header: p, body: C, actions: u } = z || {}, g = _(), a = g.toLanguageString(f, y[f]), A = (t) => {
20
20
  n.onPromptRequest && n.onPromptRequest.call(null, t.prompt, { ...t, isRetry: !0 }), E();
21
21
  }, N = (t) => {
22
22
  t != null && t.responseContent && navigator.clipboard.writeText(t.responseContent), d(t.id), setTimeout(() => {
@@ -26,7 +26,7 @@ const te = (w) => {
26
26
  n.onPromptRequest && n.onPromptRequest.call(null, t.prompt, { ...t, ratingType: l, isRetry: !1 }), E();
27
27
  }, E = () => {
28
28
  r && r.current && r.current.scrollTo({ top: 0, behavior: "smooth" });
29
- }, O = /* @__PURE__ */ e.createElement(i, null, /* @__PURE__ */ e.createElement(h, null, /* @__PURE__ */ e.createElement(I, null, /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-text k-skeleton-pulse", style: { width: "200px" } })), /* @__PURE__ */ e.createElement(b, null, /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-text k-skeleton-pulse", style: { width: "100%" } }))), /* @__PURE__ */ e.createElement(c, null, /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-rect k-skeleton-pulse", style: { height: "80px" } })), /* @__PURE__ */ e.createElement(v, null, n.streaming && n.onCancel ? /* @__PURE__ */ e.createElement(
29
+ }, M = /* @__PURE__ */ e.createElement(i, null, /* @__PURE__ */ e.createElement(h, null, /* @__PURE__ */ e.createElement(I, null, /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-text k-skeleton-pulse", style: { width: "200px" } })), /* @__PURE__ */ e.createElement(b, null, /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-text k-skeleton-pulse", style: { width: "100%" } }))), /* @__PURE__ */ e.createElement(c, null, /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-rect k-skeleton-pulse", style: { height: "80px" } })), /* @__PURE__ */ e.createElement(v, null, n.streaming && n.onCancel ? /* @__PURE__ */ e.createElement(
30
30
  o,
31
31
  {
32
32
  size: "medium",
@@ -38,7 +38,7 @@ const te = (w) => {
38
38
  onClick: n.onCancel
39
39
  },
40
40
  a
41
- ) : /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-text k-skeleton-pulse", style: { width: "100%" } }))), M = (t, l) => C ? C(t) : l && n.onCancel ? /* @__PURE__ */ e.createElement(
41
+ ) : /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-text k-skeleton-pulse", style: { width: "100%" } }))), O = (t, l) => u ? u(t) : l && n.onCancel ? /* @__PURE__ */ e.createElement(
42
42
  o,
43
43
  {
44
44
  size: "medium",
@@ -98,9 +98,9 @@ const te = (w) => {
98
98
  }
99
99
  ))), s = m == null ? void 0 : m.map((t, l) => {
100
100
  const q = !!(n.streaming && !n.loading && l === 0);
101
- return /* @__PURE__ */ e.createElement(i, { key: `${t.id}_${l}` }, /* @__PURE__ */ e.createElement(h, null, p ? p(t) : /* @__PURE__ */ e.createElement(e.Fragment, null, t.title && /* @__PURE__ */ e.createElement(I, null, t.title), t.subTitle && /* @__PURE__ */ e.createElement(b, null, t.subTitle))), /* @__PURE__ */ e.createElement(c, null, u ? u(t) : t.responseContent), /* @__PURE__ */ e.createElement(v, null, M(t, q)));
101
+ return /* @__PURE__ */ e.createElement(i, { key: `${t.id}_${l}` }, /* @__PURE__ */ e.createElement(h, null, p ? p(t) : /* @__PURE__ */ e.createElement(e.Fragment, null, t.title && /* @__PURE__ */ e.createElement(I, null, t.title), t.subTitle && /* @__PURE__ */ e.createElement(b, null, t.subTitle))), /* @__PURE__ */ e.createElement(c, null, C ? C(t) : t.responseContent), /* @__PURE__ */ e.createElement(v, null, O(t, q)));
102
102
  }), S = /* @__PURE__ */ e.createElement(i, null, /* @__PURE__ */ e.createElement(c, null, g.toLanguageString(R, y[R])));
103
- return /* @__PURE__ */ e.createElement(L, { name: j.name }, /* @__PURE__ */ e.createElement(B, { ref: r, streaming: n.streaming, onCancel: n.onCancel }, /* @__PURE__ */ e.createElement("div", { className: "k-card-list" }, n.loading && O, s, (!s || s.length === 0) && !n.loading && S)));
103
+ return /* @__PURE__ */ e.createElement(L, { name: j.name }, /* @__PURE__ */ e.createElement(B, { ref: r, streaming: n.streaming, onCancel: n.onCancel }, /* @__PURE__ */ e.createElement("div", { className: "k-card-list" }, n.loading && M, s, (!s || s.length === 0) && !n.loading && S)));
104
104
  };
105
105
  export {
106
106
  te as AIPromptOutputView
@@ -666,8 +666,7 @@ export interface ChatProps extends FieldMappingConfig {
666
666
  /**
667
667
  * The total number of messages in the conversation.
668
668
  * Used to determine the mode: when `messages.length === total`, the Chat manages rendering
669
- * internally (built-in mode); when `messages.length < total`, the Chat fires `onLoadMoreMessages`
670
- * for the consumer to fetch data (remote mode).
669
+ * internally (built-in mode); when `messages.length < total`, the consumer manages data (remote mode).
671
670
  */
672
671
  total?: number;
673
672
  /**
@@ -687,8 +686,11 @@ export interface ChatProps extends FieldMappingConfig {
687
686
  */
688
687
  endIndex?: number;
689
688
  /**
690
- * Fires only in remote mode (`messages.length < total`) when the user scrolls near the edge
689
+ * Fires in both built-in and remote endless scroll modes when the user scrolls near the edge
691
690
  * of the rendered message window.
691
+ * In built-in mode, the Chat manages rendering internally and this callback is informational.
692
+ * In remote mode (`messages.length < total`), the consumer must provide the requested range.
693
+ * The event contains the full range that should be rendered (not just the delta).
692
694
  */
693
695
  onLoadMoreMessages?: (event: ChatLoadMoreMessagesEvent) => void;
694
696
  /**
package/chat/Events.d.ts CHANGED
@@ -59,13 +59,13 @@ export interface ChatToolbarActionExecuteEvent extends BaseEvent<React.Component
59
59
  }
60
60
  /**
61
61
  * Arguments for the `onLoadMoreMessages` event of the Chat.
62
- * Fires in remote mode (`messages.length < total`) when the user scrolls near the edge
62
+ * Fires in endless scroll mode when the user scrolls near the edge
63
63
  * of the rendered message window.
64
64
  */
65
65
  export interface ChatLoadMoreMessagesEvent {
66
- /** The start index of the requested message range (inclusive). */
66
+ /** The start index of the full message range that should be rendered (inclusive). */
67
67
  startIndex: number;
68
- /** The end index of the requested message range (exclusive). */
68
+ /** The end index of the full message range that should be rendered (exclusive). */
69
69
  endIndex: number;
70
70
  }
71
71
  /**
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@progress/kendo-react-common"),n=require("prop-types"),Bt=require("react"),It=require("@progress/kendo-react-buttons"),Nt=require("@progress/kendo-svg-icons"),Ot=require("../ViewItem.js"),Dt=require("./ActionGroup.js"),Pt=require("./AttachmentGroup.js"),jt=require("./DateMarker.js"),Ut=require("./MessageGroup.js"),Vt=require("./NewMessage.js"),zt=require("./Header.js"),Kt=require("./elements/PinnedMessage.js"),Wt=require("./Notification.js"),Gt=require("./ChatContext.js"),Ht=require("./ChatMessage.js"),Ge=require("../../package-metadata.js"),a=require("../../messages/index.js"),_t=require("@progress/kendo-react-intl"),He=require("../utils/fieldMapping.js"),_e=require("../utils/scroll.js"),$t=require("../utils/messageSettings.js"),Jt=require("../hooks/useEndlessScroll.js");function Qt(f){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const r in f)if(r!=="default"){const k=Object.getOwnPropertyDescriptor(f,r);Object.defineProperty(d,r,k.get?k:{enumerable:!0,get:()=>f[r]})}}return d.default=f,Object.freeze(d)}const t=Qt(Bt),W=t.forwardRef((f,d)=>{const{messages:r=[],messageTemplate:k,messageContentTemplate:G,attachmentTemplate:B,width:$e,height:Je,onSendMessage:v,onSuggestionClick:H,onInputValueChange:_,onActionExecute:I,dir:S,messageBox:Qe,placeholder:Xe,className:$,style:Ye,message:J=Ht.ChatMessage,authorId:l,suggestions:Ze,suggestionTemplate:et,suggestionsLayout:tt="scroll",quickActionsLayout:Q="scroll",inputValue:st,headerTemplate:C,noDataTemplate:T,timestampTemplate:X,statusTemplate:Y,userStatusTemplate:Z,allowMessageCollapse:ee,messageToolbarActions:te,messageContextMenuActions:se,fileActions:A,onUnpin:nt,messageWidthMode:ne,showAvatar:oe,showUsername:ae,timestampVisibility:re,authorMessageSettings:le,receiverMessageSettings:ie,onToolbarAction:ce,onContextMenuAction:ue,onFileAction:de,onDownload:ge,speechToTextConfig:me,uploadConfig:fe,sendButtonConfig:ot,messageFilesLayout:pe,scrollToBottomButton:N=!0,autoScrollThreshold:at,textField:he,statusField:Me,authorIdField:ye,authorNameField:Se,authorImageUrlField:Ce,authorImageAltTextField:Te,idField:be,timestampField:ke,filesField:ve,attachmentsField:Ee,replyToIdField:Re,isDeletedField:xe,isPinnedField:Ae,typingField:qe,suggestedActionsField:Le,isFailedField:Fe,onResendMessage:we,messageBoxSettings:rt,loading:lt,scrollMode:it,total:ct,pageSize:ut,startIndex:dt,endIndex:gt,onLoadMoreMessages:mt,pinnedMessages:O,repliedToMessages:Be,onReferencedMessageClick:ft,...pt}=f,[p,D]=t.useState(null),[P,ht]=t.useState(!1),[Mt,Ie]=t.useState(!1),[Ne,Oe]=t.useState(null),[h,De]=t.useState(null),[yt,Pe]=t.useState(!1),j=t.useRef(null),je=t.useRef(null),g=t.useRef(null),Ue=t.useRef(null),U=t.useRef(void 0),V=t.useRef(!1),z=t.useRef(null),Ve=t.useRef(""),m=t.useMemo(()=>{if(!r||r.length===0)return[];const s={textField:he,statusField:Me,authorIdField:ye,authorNameField:Se,authorImageUrlField:Ce,authorImageAltTextField:Te,idField:be,timestampField:ke,filesField:ve,attachmentsField:Ee,replyToIdField:Re,isDeletedField:xe,isPinnedField:Ae,typingField:qe,suggestedActionsField:Le,isFailedField:Fe};return!Object.values(s).some(o=>o!==void 0)&&He.isStandardMessageFormat(r[0])?r.map(o=>({...o,timestamp:o.timestamp?new Date(o.timestamp):o.timestamp})):He.mapDataArrayToMessages(r,s)},[r,he,Me,ye,Se,Ce,Te,be,ke,ve,Ee,Re,xe,Ae,qe,Le,Fe]);t.useEffect(()=>{if(l===Ve.current&&z.current){De(z.current);return}if(l&&m.length>0){const s=m.find(o=>o.author&&(o.author.id===l||o.author.id===String(l))),e=(s==null?void 0:s.author)||{id:l};z.current=e,Ve.current=l,De(e)}},[l,m]);const{renderedMessages:M,handleScrollToBottom:St,handleReferencedMessageClick:K,isEndless:Ct,isOnLastBatch:ze,skipAutoScrollRef:Tt}=Jt.useEndlessScroll({scrollMode:it,processedMessages:m,total:ct,pageSize:ut,startIndex:dt,endIndex:gt,onLoadMoreMessages:mt,onReferencedMessageClick:ft,viewItemsWrapperRef:g,authorId:l}),y=t.useMemo(()=>M.length>0?Ot.convertMsgsToViewItems(M):[],[M]),bt=t.useMemo(()=>!u.validatePackage(Ge.packageMetadata,{component:"Chat"}),[]),kt=u.getLicenseMessage(Ge.packageMetadata),Ke=t.useMemo(()=>{if(O)return O.find(e=>e.isPinned);const s=m.find(e=>e.isPinned);if(s)return s},[m,O]),q=_t.useLocalization();_e.useMessageAutoScroll({viewItemsWrapperRef:g,isKeyboardNavigationActiveRef:V,processedMessages:M,authorId:l,autoScrollThreshold:at,isEndless:Ct,isOnLastBatch:ze,skipAutoScrollRef:Tt});const vt=_e.useHasScrollbar({elementRef:g}),Et=t.useCallback(()=>{clearTimeout(U.current)},[]),Rt=t.useCallback(()=>{U.current=window.setTimeout(()=>{D(null)},0)},[]),L=t.useCallback(s=>{D(s)},[]),xt=t.useCallback(s=>{let e=null;const o=p!==null?p:y.lastSelectionIndex;s.keyCode===u.Keys.up?o===null?e=0:o>0&&(e=o-1):s.keyCode===u.Keys.down?o===null?e=0:o<y.lastSelectionIndex&&(e=o+1):s.keyCode===u.Keys.home?e=0:s.keyCode===u.Keys.end&&(e=y.lastSelectionIndex),e!==null&&(D(e),V.current=!0,s.preventDefault())},[p,y]),We=t.useCallback((s,e,o)=>{var c;if(I&&I({action:{value:s.value,title:s.title,type:s.type},syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.currentTarget}),!e.isDefaultPrevented()){switch(s.type){case"reply":v&&v({message:{id:"",author:h,text:s.value,timestamp:new Date},syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.currentTarget});break;case"call":window.open("tel:"+s.value);break;case"openUrl":window.open(s.value);break}(c=Ue.current)==null||c.focusInput()}},[I,v,h]),At=t.useCallback(()=>u.classNames("k-chat",$,{"k-rtl":P}),[$,P]),qt=t.useCallback(()=>{const s=y.length-1;return y.map((e,o)=>{var c,b,E,R,x,F;if(e.type==="date-marker")return t.createElement(jt,{item:e,key:e.trackBy,timestampTemplate:X});if(e.type==="message-group"){const w={allowMessageCollapse:ee,messageWidthMode:ne,showAvatar:oe,showUsername:ae,messageTemplate:k,messageContentTemplate:G,messageToolbarActions:te,messageContextMenuActions:se,fileActions:A},i=$t.resolveMessageSettings((c=e==null?void 0:e.messages)==null?void 0:c[0],l,w,le,ie);return t.createElement(Ut,{group:e,itemTemplate:i.messageTemplate,contentTemplate:i.messageContentTemplate,attachmentTemplate:B,user:h,selectedItemIndex:p,onRequestSelection:L,isLastGroup:o===s,key:(b=e.messages[0].id)!=null?b:e.messages[0].selectionIndex,message:J,allowMessageCollapse:i.allowMessageCollapse,messageToolbarActions:i.messageToolbarActions,messageContextMenuActions:i.messageContextMenuActions,fileActions:i.fileActions,messageWidthMode:i.messageWidthMode,showAvatar:i.showAvatar,showUsername:i.showUsername})}else{if(e.type==="attachment-group")return t.createElement(Pt,{group:e,itemTemplate:B,onRequestSelection:L,selected:e.selectionIndex===p,isLastGroup:o===s,key:`att-${(R=(E=e.trackBy)==null?void 0:E.id)!=null?R:e.selectionIndex}`});if(e.type==="action-group")return t.createElement(Dt,{group:e,onActionExecute:We,onRequestSelection:L,selected:e.selectionIndex===p,key:`act-${(F=(x=e.trackBy)==null?void 0:x.id)!=null?F:e.selectionIndex}`,quickActionsLayout:Q,dir:S})}return null})},[y,X,k,G,B,h,p,L,J,ee,te,se,A,ne,oe,ae,l,le,ie,We,Q,S]),Lt=t.useCallback(()=>C?typeof C=="function"?C():C:null,[C]),Ft=t.useCallback(()=>T?typeof T=="function"?T():T:null,[T]);t.useEffect(()=>{const s=S!==void 0?S==="rtl":j.current&&getComputedStyle(j.current).direction==="rtl";ht(!!s)},[S]),t.useEffect(()=>()=>{clearTimeout(U.current)},[]),t.useEffect(()=>{if(!N||!g.current)return;let s,e;const o=()=>{s=void 0;const R=g.current;if(!R)return;const{scrollHeight:x,scrollTop:F,clientHeight:w}=R;!(x>w)||x-F-w<=100?(e!==void 0&&(clearTimeout(e),e=void 0),Pe(!1)):e!=null||(e=setTimeout(()=>{e=void 0,Pe(!0)},300))},c=()=>{s===void 0&&(s=requestAnimationFrame(o))},b=g.current;b.addEventListener("scroll",c,{passive:!0});const E=new MutationObserver(c);return E.observe(b,{childList:!0,subtree:!0,characterData:!0}),()=>{b.removeEventListener("scroll",c),E.disconnect(),s!==void 0&&cancelAnimationFrame(s),e!==void 0&&clearTimeout(e)}},[N]);const wt=t.useMemo(()=>({replyToMessage:Ne,setReplyToMessage:Oe,messages:m,repliedToMessages:Be,user:h,internalScrollContainerRef:je,messageListScrollContainerRef:g,onToolbarAction:ce,onContextMenuAction:ue,onFileAction:de,setShowCopyNotification:Ie,onDownload:ge,onResendMessage:we,fileActions:A,speechToTextConfig:me,uploadConfig:fe,statusTemplate:Y,userStatusTemplate:Z,messageFilesLayout:pe,timestampVisibility:re,onReferencedMessageClick:K}),[Ne,Oe,m,Be,h,ce,ue,de,Ie,ge,we,A,me,fe,Y,Z,pe,re,K]);return t.createElement(Gt.default.Provider,{value:wt},t.createElement("div",{style:{width:$e,height:Je,position:"relative",overflow:"hidden",...Ye},onKeyDown:xt,className:At(),ref:s=>{j.current=s,je.current=s,typeof d=="function"?d(s):d&&(d.current=s)},...pt},C!==void 0&&t.createElement(zt,null,Lt()),t.createElement("div",{className:"k-message-list",onBlur:Rt,onFocus:Et,role:"log","aria-label":q.toLanguageString(a.ariaLabelMessageList,a.messages[a.ariaLabelMessageList]),"aria-live":"polite",ref:g,style:{scrollBehavior:"auto"}},Ke&&t.createElement(Kt,{message:Ke,onUnpin:nt,user:h,onReferencedMessageClick:K}),t.createElement("div",{className:u.classNames("k-message-list-content",{"k-message-list-content-empty":M.length===0})},M.length===0&&T!==void 0&&Ft(),M.length>0&&qt()),N&&(yt||!ze)&&t.createElement("div",{className:"k-chat-scroll-to-bottom-container"},t.createElement(It.FloatingActionButton,{svgIcon:Nt.arrowDownOutlineIcon,size:"small",themeColor:"light",rounded:"full",onClick:St,"aria-label":q.toLanguageString(a.scrollToBottom,a.messages[a.scrollToBottom]),title:q.toLanguageString(a.scrollToBottom,a.messages[a.scrollToBottom])}))),vt&&t.createElement("div",{className:"k-separator"}),t.createElement(Vt,{onSendMessage:(s,e)=>{v&&v({message:s,syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.currentTarget})},onSuggestionClick:s=>{H&&H(s)},isDirectionRightToLeft:P,ref:Ue,placeholder:Xe,MessageBox:Qe,suggestions:Ze,suggestionTemplate:et,inputValue:st,onInputValueChange:s=>{_&&_(s)},onInputClick:()=>{V.current=!1},sendButtonConfig:ot,suggestionsLayout:tt,dir:S,messageBoxSettings:rt,loading:lt}),t.createElement(Wt,{show:Mt,text:q.toLanguageString(a.chatCopyNotification,a.messages[a.chatCopyNotification])}),bt&&t.createElement(u.WatermarkOverlay,{message:kt})))});W.displayName="Chat";W.propTypes={messages:n.arrayOf(n.object),user:n.object,messageTemplate:n.any,messageContentTemplate:n.any,attachmentTemplate:n.any,width:n.oneOfType([n.string,n.number]),style:n.object,onSendMessage:n.func,onActionExecute:n.func,dir:n.string,messageBox:n.any,noDataTemplate:n.oneOfType([n.element,n.func]),suggestionsLayout:n.oneOf(["scroll","wrap","scrollbuttons"]),quickActionsLayout:n.oneOf(["scroll","wrap","scrollbuttons"]),userStatusTemplate:n.elementType,messageFilesLayout:n.oneOf(["vertical","wrap","horizontal"]),showAvatar:n.bool,showUsername:n.bool,authorMessageSettings:n.object,receiverMessageSettings:n.object,scrollMode:n.oneOf(["scrollable","endless"]),total:n.number,pageSize:n.number,startIndex:n.number,endIndex:n.number,onLoadMoreMessages:n.func,pinnedMessages:n.arrayOf(n.object),repliedToMessages:n.arrayOf(n.object),onReferencedMessageClick:n.func};exports.Chat=W;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@progress/kendo-react-common"),n=require("prop-types"),Bt=require("react"),It=require("@progress/kendo-react-buttons"),Nt=require("@progress/kendo-svg-icons"),Ot=require("../ViewItem.js"),Dt=require("./ActionGroup.js"),Pt=require("./AttachmentGroup.js"),jt=require("./DateMarker.js"),Ut=require("./MessageGroup.js"),Vt=require("./NewMessage.js"),zt=require("./Header.js"),Kt=require("./elements/PinnedMessage.js"),Wt=require("./Notification.js"),Gt=require("./ChatContext.js"),Ht=require("./ChatMessage.js"),Ge=require("../../package-metadata.js"),a=require("../../messages/index.js"),_t=require("@progress/kendo-react-intl"),He=require("../utils/fieldMapping.js"),_e=require("../utils/scroll.js"),$t=require("../utils/messageSettings.js"),Jt=require("../hooks/useEndlessScroll.js");function Qt(f){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const r in f)if(r!=="default"){const k=Object.getOwnPropertyDescriptor(f,r);Object.defineProperty(d,r,k.get?k:{enumerable:!0,get:()=>f[r]})}}return d.default=f,Object.freeze(d)}const t=Qt(Bt),W=t.forwardRef((f,d)=>{const{messages:r=[],messageTemplate:k,messageContentTemplate:G,attachmentTemplate:B,width:$e,height:Je,onSendMessage:v,onSuggestionClick:H,onInputValueChange:_,onActionExecute:I,dir:S,messageBox:Qe,placeholder:Xe,className:$,style:Ye,message:J=Ht.ChatMessage,authorId:l,suggestions:Ze,suggestionTemplate:et,suggestionsLayout:tt="scroll",quickActionsLayout:Q="scroll",inputValue:st,headerTemplate:C,noDataTemplate:T,timestampTemplate:X,statusTemplate:Y,userStatusTemplate:Z,allowMessageCollapse:ee,messageToolbarActions:te,messageContextMenuActions:se,fileActions:A,onUnpin:nt,messageWidthMode:ne,showAvatar:oe,showUsername:ae,timestampVisibility:re,authorMessageSettings:le,receiverMessageSettings:ie,onToolbarAction:ce,onContextMenuAction:ue,onFileAction:de,onDownload:ge,speechToTextConfig:me,uploadConfig:fe,sendButtonConfig:ot,messageFilesLayout:pe,scrollToBottomButton:N=!0,autoScrollThreshold:at,textField:he,statusField:Me,authorIdField:ye,authorNameField:Se,authorImageUrlField:Ce,authorImageAltTextField:Te,idField:be,timestampField:ke,filesField:ve,attachmentsField:Ee,replyToIdField:Re,isDeletedField:xe,isPinnedField:Ae,typingField:qe,suggestedActionsField:Le,isFailedField:Fe,onResendMessage:we,messageBoxSettings:rt,loading:lt,scrollMode:it,total:ct,pageSize:ut,startIndex:dt,endIndex:gt,onLoadMoreMessages:mt,pinnedMessages:O,repliedToMessages:Be,onReferencedMessageClick:ft,...pt}=f,[p,D]=t.useState(null),[P,ht]=t.useState(!1),[Mt,Ie]=t.useState(!1),[Ne,Oe]=t.useState(null),[h,De]=t.useState(null),[yt,Pe]=t.useState(!1),j=t.useRef(null),je=t.useRef(null),g=t.useRef(null),Ue=t.useRef(null),U=t.useRef(void 0),V=t.useRef(!1),z=t.useRef(null),Ve=t.useRef(""),m=t.useMemo(()=>{if(!r||r.length===0)return[];const s={textField:he,statusField:Me,authorIdField:ye,authorNameField:Se,authorImageUrlField:Ce,authorImageAltTextField:Te,idField:be,timestampField:ke,filesField:ve,attachmentsField:Ee,replyToIdField:Re,isDeletedField:xe,isPinnedField:Ae,typingField:qe,suggestedActionsField:Le,isFailedField:Fe};return!Object.values(s).some(o=>o!==void 0)&&He.isStandardMessageFormat(r[0])?r.map(o=>({...o,timestamp:o.timestamp?new Date(o.timestamp):o.timestamp})):He.mapDataArrayToMessages(r,s)},[r,he,Me,ye,Se,Ce,Te,be,ke,ve,Ee,Re,xe,Ae,qe,Le,Fe]);t.useEffect(()=>{if(l===Ve.current&&z.current){De(z.current);return}if(l&&m.length>0){const s=m.find(o=>o.author&&(o.author.id===l||o.author.id===String(l))),e=(s==null?void 0:s.author)||{id:l};z.current=e,Ve.current=l,De(e)}},[l,m]);const{renderedMessages:M,handleScrollToBottom:St,handleReferencedMessageClick:K,isEndless:Ct,isOnLastBatch:ze,skipAutoScrollRef:Tt}=Jt.useEndlessScroll({scrollMode:it,processedMessages:m,total:ct,pageSize:ut,startIndex:dt,endIndex:gt,onLoadMoreMessages:mt,onReferencedMessageClick:ft,viewItemsWrapperRef:g,authorId:l}),y=t.useMemo(()=>M.length>0?Ot.convertMsgsToViewItems(M):[],[M]),bt=t.useMemo(()=>!u.validatePackage(Ge.packageMetadata,{component:"Chat"}),[]),kt=u.getLicenseMessage(Ge.packageMetadata),Ke=t.useMemo(()=>{if(O)return O.find(e=>e.isPinned);const s=m.find(e=>e.isPinned);if(s)return s},[m,O]),q=_t.useLocalization();_e.useMessageAutoScroll({viewItemsWrapperRef:g,isKeyboardNavigationActiveRef:V,processedMessages:M,authorId:l,autoScrollThreshold:at,isEndless:Ct,isOnLastBatch:ze,skipAutoScrollRef:Tt});const vt=_e.useHasScrollbar({elementRef:g}),Et=t.useCallback(()=>{clearTimeout(U.current)},[]),Rt=t.useCallback(()=>{U.current=window.setTimeout(()=>{D(null)},0)},[]),L=t.useCallback(s=>{D(s)},[]),xt=t.useCallback(s=>{let e=null;const o=p!==null?p:y.lastSelectionIndex;s.keyCode===u.Keys.up?o===null?e=0:o>0&&(e=o-1):s.keyCode===u.Keys.down?o===null?e=0:o<y.lastSelectionIndex&&(e=o+1):s.keyCode===u.Keys.home?e=0:s.keyCode===u.Keys.end&&(e=y.lastSelectionIndex),e!==null&&(D(e),V.current=!0,s.preventDefault())},[p,y]),We=t.useCallback((s,e,o)=>{var c;if(I&&I({action:{value:s.value,title:s.title,type:s.type},syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.currentTarget}),!e.isDefaultPrevented()){switch(s.type){case"reply":v&&v({message:{id:"",author:h,text:s.value,timestamp:new Date},syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.currentTarget});break;case"call":window.open("tel:"+s.value);break;case"openUrl":window.open(s.value);break}(c=Ue.current)==null||c.focusInput()}},[I,v,h]),At=t.useCallback(()=>u.classNames("k-chat",$,{"k-rtl":P}),[$,P]),qt=t.useCallback(()=>{const s=y.length-1;return y.map((e,o)=>{var c,b,E,R,x,F;if(e.type==="date-marker")return t.createElement(jt,{item:e,key:e.trackBy,timestampTemplate:X});if(e.type==="message-group"){const w={allowMessageCollapse:ee,messageWidthMode:ne,showAvatar:oe,showUsername:ae,messageTemplate:k,messageContentTemplate:G,messageToolbarActions:te,messageContextMenuActions:se,fileActions:A},i=$t.resolveMessageSettings((c=e==null?void 0:e.messages)==null?void 0:c[0],l,w,le,ie);return t.createElement(Ut,{group:e,itemTemplate:i.messageTemplate,contentTemplate:i.messageContentTemplate,attachmentTemplate:B,user:h,selectedItemIndex:p,onRequestSelection:L,isLastGroup:o===s,key:(b=e.messages[0].id)!=null?b:e.messages[0].selectionIndex,message:J,allowMessageCollapse:i.allowMessageCollapse,messageToolbarActions:i.messageToolbarActions,messageContextMenuActions:i.messageContextMenuActions,fileActions:i.fileActions,messageWidthMode:i.messageWidthMode,showAvatar:i.showAvatar,showUsername:i.showUsername})}else{if(e.type==="attachment-group")return t.createElement(Pt,{group:e,itemTemplate:B,onRequestSelection:L,selected:e.selectionIndex===p,isLastGroup:o===s,key:`att-${(R=(E=e.trackBy)==null?void 0:E.id)!=null?R:e.selectionIndex}`});if(e.type==="action-group")return t.createElement(Dt,{group:e,onActionExecute:We,onRequestSelection:L,selected:e.selectionIndex===p,key:`act-${(F=(x=e.trackBy)==null?void 0:x.id)!=null?F:e.selectionIndex}`,quickActionsLayout:Q,dir:S})}return null})},[y,X,k,G,B,h,p,L,J,ee,te,se,A,ne,oe,ae,l,le,ie,We,Q,S]),Lt=t.useCallback(()=>C?typeof C=="function"?C():C:null,[C]),Ft=t.useCallback(()=>T?typeof T=="function"?T():T:null,[T]);t.useEffect(()=>{const s=S!==void 0?S==="rtl":j.current&&getComputedStyle(j.current).direction==="rtl";ht(!!s)},[S]),t.useEffect(()=>()=>{clearTimeout(U.current)},[]),t.useEffect(()=>{if(!N||!g.current)return;let s,e;const o=()=>{s=void 0;const R=g.current;if(!R)return;const{scrollHeight:x,scrollTop:F,clientHeight:w}=R;!(x>w)||x-F-w<=100?(e!==void 0&&(clearTimeout(e),e=void 0),Pe(!1)):e!=null||(e=setTimeout(()=>{e=void 0,Pe(!0)},300))},c=()=>{s===void 0&&(s=requestAnimationFrame(o))},b=g.current;b.addEventListener("scroll",c,{passive:!0});const E=new MutationObserver(c);return E.observe(b,{childList:!0,subtree:!0,characterData:!0}),()=>{b.removeEventListener("scroll",c),E.disconnect(),s!==void 0&&cancelAnimationFrame(s),e!==void 0&&clearTimeout(e)}},[N]);const wt=t.useMemo(()=>({replyToMessage:Ne,setReplyToMessage:Oe,messages:m,repliedToMessages:Be,user:h,internalScrollContainerRef:je,messageListScrollContainerRef:g,onToolbarAction:ce,onContextMenuAction:ue,onFileAction:de,setShowCopyNotification:Ie,onDownload:ge,onResendMessage:we,fileActions:A,speechToTextConfig:me,uploadConfig:fe,statusTemplate:Y,userStatusTemplate:Z,messageFilesLayout:pe,timestampVisibility:re,onReferencedMessageClick:K}),[Ne,Oe,m,Be,h,ce,ue,de,Ie,ge,we,A,me,fe,Y,Z,pe,re,K]);return t.createElement(Gt.default.Provider,{value:wt},t.createElement("div",{style:{width:$e,height:Je,position:"relative",overflow:"hidden",...Ye},onKeyDown:xt,className:At(),ref:s=>{j.current=s,je.current=s,typeof d=="function"?d(s):d&&(d.current=s)},...pt},C!==void 0&&t.createElement(zt,null,Lt()),t.createElement("div",{className:"k-message-list",onBlur:Rt,onFocus:Et,role:"log","aria-label":q.toLanguageString(a.ariaLabelMessageList,a.messages[a.ariaLabelMessageList]),"aria-live":"polite",ref:g,style:{scrollBehavior:"auto"}},Ke&&t.createElement(Kt,{message:Ke,onUnpin:nt,user:h,onReferencedMessageClick:K}),t.createElement("div",{className:u.classNames("k-message-list-content",{"k-message-list-content-empty":M.length===0})},M.length===0&&T!==void 0&&Ft(),M.length>0&&qt()),N&&(yt||!ze)&&t.createElement("div",{className:"k-chat-scroll-to-bottom-container"},t.createElement(It.FloatingActionButton,{svgIcon:Nt.arrowDownIcon,size:"small",themeColor:"base",rounded:"full",onClick:St,"aria-label":q.toLanguageString(a.scrollToBottom,a.messages[a.scrollToBottom]),title:q.toLanguageString(a.scrollToBottom,a.messages[a.scrollToBottom])}))),vt&&t.createElement("div",{className:"k-separator"}),t.createElement(Vt,{onSendMessage:(s,e)=>{v&&v({message:s,syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.currentTarget})},onSuggestionClick:s=>{H&&H(s)},isDirectionRightToLeft:P,ref:Ue,placeholder:Xe,MessageBox:Qe,suggestions:Ze,suggestionTemplate:et,inputValue:st,onInputValueChange:s=>{_&&_(s)},onInputClick:()=>{V.current=!1},sendButtonConfig:ot,suggestionsLayout:tt,dir:S,messageBoxSettings:rt,loading:lt}),t.createElement(Wt,{show:Mt,text:q.toLanguageString(a.chatCopyNotification,a.messages[a.chatCopyNotification])}),bt&&t.createElement(u.WatermarkOverlay,{message:kt})))});W.displayName="Chat";W.propTypes={messages:n.arrayOf(n.object),user:n.object,messageTemplate:n.any,messageContentTemplate:n.any,attachmentTemplate:n.any,width:n.oneOfType([n.string,n.number]),style:n.object,onSendMessage:n.func,onActionExecute:n.func,dir:n.string,messageBox:n.any,noDataTemplate:n.oneOfType([n.element,n.func]),suggestionsLayout:n.oneOf(["scroll","wrap","scrollbuttons"]),quickActionsLayout:n.oneOf(["scroll","wrap","scrollbuttons"]),userStatusTemplate:n.elementType,messageFilesLayout:n.oneOf(["vertical","wrap","horizontal"]),showAvatar:n.bool,showUsername:n.bool,authorMessageSettings:n.object,receiverMessageSettings:n.object,scrollMode:n.oneOf(["scrollable","endless"]),total:n.number,pageSize:n.number,startIndex:n.number,endIndex:n.number,onLoadMoreMessages:n.func,pinnedMessages:n.arrayOf(n.object),repliedToMessages:n.arrayOf(n.object),onReferencedMessageClick:n.func};exports.Chat=W;
@@ -9,7 +9,7 @@ import { validatePackage as Dt, getLicenseMessage as Ot, Keys as F, classNames a
9
9
  import o from "prop-types";
10
10
  import * as t from "react";
11
11
  import { FloatingActionButton as Ut } from "@progress/kendo-react-buttons";
12
- import { arrowDownOutlineIcon as jt } from "@progress/kendo-svg-icons";
12
+ import { arrowDownIcon as jt } from "@progress/kendo-svg-icons";
13
13
  import { convertMsgsToViewItems as Vt } from "../ViewItem.mjs";
14
14
  import qt from "./ActionGroup.mjs";
15
15
  import zt from "./AttachmentGroup.mjs";
@@ -28,7 +28,7 @@ import { isStandardMessageFormat as Zt, mapDataArrayToMessages as _t } from "../
28
28
  import { useMessageAutoScroll as es, useHasScrollbar as ts } from "../utils/scroll.mjs";
29
29
  import { resolveMessageSettings as ss } from "../utils/messageSettings.mjs";
30
30
  import { useEndlessScroll as os } from "../hooks/useEndlessScroll.mjs";
31
- const Je = t.forwardRef((Qe, b) => {
31
+ const Je = t.forwardRef((Qe, k) => {
32
32
  const {
33
33
  messages: f = [],
34
34
  messageTemplate: W,
@@ -85,8 +85,8 @@ const Je = t.forwardRef((Qe, b) => {
85
85
  authorImageUrlField: Ce,
86
86
  authorImageAltTextField: Se,
87
87
  idField: Te,
88
- timestampField: ke,
89
- filesField: be,
88
+ timestampField: be,
89
+ filesField: ke,
90
90
  attachmentsField: ve,
91
91
  replyToIdField: Ee,
92
92
  isDeletedField: xe,
@@ -118,8 +118,8 @@ const Je = t.forwardRef((Qe, b) => {
118
118
  authorImageUrlField: Ce,
119
119
  authorImageAltTextField: Se,
120
120
  idField: Te,
121
- timestampField: ke,
122
- filesField: be,
121
+ timestampField: be,
122
+ filesField: ke,
123
123
  attachmentsField: ve,
124
124
  replyToIdField: Ee,
125
125
  isDeletedField: xe,
@@ -141,8 +141,8 @@ const Je = t.forwardRef((Qe, b) => {
141
141
  Ce,
142
142
  Se,
143
143
  Te,
144
- ke,
145
144
  be,
145
+ ke,
146
146
  ve,
147
147
  Ee,
148
148
  xe,
@@ -167,9 +167,9 @@ const Je = t.forwardRef((Qe, b) => {
167
167
  renderedMessages: d,
168
168
  handleScrollToBottom: Tt,
169
169
  handleReferencedMessageClick: z,
170
- isEndless: kt,
170
+ isEndless: bt,
171
171
  isOnLastBatch: qe,
172
- skipAutoScrollRef: bt
172
+ skipAutoScrollRef: kt
173
173
  } = os({
174
174
  scrollMode: ut,
175
175
  processedMessages: c,
@@ -194,9 +194,9 @@ const Je = t.forwardRef((Qe, b) => {
194
194
  processedMessages: d,
195
195
  authorId: a,
196
196
  autoScrollThreshold: lt,
197
- isEndless: kt,
197
+ isEndless: bt,
198
198
  isOnLastBatch: qe,
199
- skipAutoScrollRef: bt
199
+ skipAutoScrollRef: kt
200
200
  });
201
201
  const xt = ts({ elementRef: i }), Rt = t.useCallback(() => {
202
202
  clearTimeout(j.current);
@@ -250,7 +250,7 @@ const Je = t.forwardRef((Qe, b) => {
250
250
  ), Lt = t.useCallback(() => Ge("k-chat", $, { "k-rtl": P }), [$, P]), wt = t.useCallback(() => {
251
251
  const s = g.length - 1;
252
252
  return g.map((e, n) => {
253
- var l, y, S, T, k, R;
253
+ var l, y, S, T, b, R;
254
254
  if (e.type === "date-marker")
255
255
  return /* @__PURE__ */ t.createElement(Wt, { item: e, key: e.trackBy, timestampTemplate: X });
256
256
  if (e.type === "message-group") {
@@ -314,7 +314,7 @@ const Je = t.forwardRef((Qe, b) => {
314
314
  onActionExecute: We,
315
315
  onRequestSelection: x,
316
316
  selected: e.selectionIndex === u,
317
- key: `act-${(R = (k = e.trackBy) == null ? void 0 : k.id) != null ? R : e.selectionIndex}`,
317
+ key: `act-${(R = (b = e.trackBy) == null ? void 0 : b.id) != null ? R : e.selectionIndex}`,
318
318
  quickActionsLayout: Q,
319
319
  dir: p
320
320
  }
@@ -360,8 +360,8 @@ const Je = t.forwardRef((Qe, b) => {
360
360
  const T = i.current;
361
361
  if (!T)
362
362
  return;
363
- const { scrollHeight: k, scrollTop: R, clientHeight: A } = T;
364
- !(k > A) || k - R - A <= 100 ? (e !== void 0 && (clearTimeout(e), e = void 0), Pe(!1)) : e != null || (e = setTimeout(() => {
363
+ const { scrollHeight: b, scrollTop: R, clientHeight: A } = T;
364
+ !(b > A) || b - R - A <= 100 ? (e !== void 0 && (clearTimeout(e), e = void 0), Pe(!1)) : e != null || (e = setTimeout(() => {
365
365
  e = void 0, Pe(!0);
366
366
  }, 300));
367
367
  }, l = () => {
@@ -429,7 +429,7 @@ const Je = t.forwardRef((Qe, b) => {
429
429
  onKeyDown: Ft,
430
430
  className: Lt(),
431
431
  ref: (s) => {
432
- U.current = s, Ue.current = s, typeof b == "function" ? b(s) : b && (b.current = s);
432
+ U.current = s, Ue.current = s, typeof k == "function" ? k(s) : k && (k.current = s);
433
433
  },
434
434
  ...Mt
435
435
  },
@@ -475,7 +475,7 @@ const Je = t.forwardRef((Qe, b) => {
475
475
  {
476
476
  svgIcon: jt,
477
477
  size: "small",
478
- themeColor: "light",
478
+ themeColor: "base",
479
479
  rounded: "full",
480
480
  onClick: Tt,
481
481
  "aria-label": E.toLanguageString(
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ye=require("react"),g=require("@progress/kendo-react-common"),D=require("@progress/kendo-react-buttons"),f=require("@progress/kendo-svg-icons"),ne=require("@progress/kendo-react-layout"),i=require("../utils.js"),Ee=require("./ChatContext.js"),xe=require("./elements/FileBox.js"),le=require("@progress/kendo-react-intl"),l=require("../../messages/index.js");function Ie(u){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const e in u)if(e!=="default"){const d=Object.getOwnPropertyDescriptor(u,e);Object.defineProperty(r,e,d.get?d:{enumerable:!0,get:()=>u[e]})}}return r.default=u,Object.freeze(r)}const s=Ie(ye),oe=s.forwardRef((u,r)=>{const{item:e,template:d,contentTemplate:F,onRequestSelection:C,tabIndex:ce=-1,dateFormat:H="g",selected:c,allowMessageCollapse:y,messageToolbarActions:E,messageContextMenuActions:x,fileActions:U,isSender:I}=u,{setReplyToMessage:w,messages:X,repliedToMessages:A,user:b,onToolbarAction:R,onContextMenuAction:L,onFileAction:Y,onDownload:m,onResendMessage:q,setShowCopyNotification:M,statusTemplate:O,timestampVisibility:h="onFocus",onReferencedMessageClick:v}=Ee.useChatContext(),[G,V]=s.useState(!1),[J,z]=s.useState(!1),[T,ie]=s.useState(!0),[re,Q]=s.useState(!1),o=le.useLocalization(),Z=le.useInternationalization(),$=s.useRef({left:0,top:0}),N=s.useCallback(()=>{e!=null&&e.text&&i.copyToClipboard(e.text),M&&(M(!0),setTimeout(()=>{M(!1)},3e3))},[e,M]),j=s.useCallback(t=>{t.stopPropagation(),ie(a=>!a)},[]),ue=s.useCallback(()=>{Q(!1)},[]),de=s.useCallback(t=>{(t.key==="Tab"||t.key==="Enter"||t.key===" "||t.key==="ArrowUp"||t.key==="ArrowDown")&&Q(!0)},[]),B=s.useRef(null);s.useEffect(()=>{c&&B.current&&B.current.focus()},[c]);const P=s.useCallback(t=>{$.current={left:t.pageX,top:t.pageY},t.preventDefault(),z(!0),V(!0)},[]),ee=s.useCallback(()=>{z(!1),V(!1)},[]),S=s.useCallback((t,a)=>t.isDeleted?i.getDeletedMessageText(a,o):t.text?t.text:"",[o]),te=s.useCallback(t=>{var a;(a=t.item)!=null&&a.text&&(t.item.data.id==="copy"&&!e.isDeleted?N():t.item.data.id==="reply"&&w(e),L&&L(t.item.data,t,e)),z(!1),V(!1)},[e,L,w,N]),se=s.useCallback(()=>{if(e.replyToId){const t=i.getMessageById(X,e.replyToId)||(A?i.getMessageById(A,e.replyToId):void 0);if(t){const a=n=>{n.preventDefault(),n.stopPropagation(),v==null||v(t.id)};return s.createElement("div",{className:g.classNames("k-message-reference",i.isAuthor(b,t)?"k-message-reference-sender":"k-message-reference-receiver"),onClick:a},s.createElement("div",{className:"k-message-reference-content"},i.convertTextToLinkedContent(S(t,i.isAuthor(b,t)))))}}return null},[e.replyToId,X,A,b,S,v]),K=s.useCallback(()=>{const t=[{id:"reply",label:"Reply",svgIcon:f.undoIcon},{id:"copy",label:"Copy",svgIcon:f.copyIcon}],a=x?[...t.map(n=>x.find(k=>k.id===n.id)||n),...x.filter(n=>!t.some(p=>p.id===n.id))]:t;return s.createElement(ne.ContextMenu,{onSelect:te,onClose:ee,vertical:!0,show:G,offset:$.current},a.map(n=>n.id==="delete"&&!I?null:s.createElement(ne.MenuItem,{key:n.id,text:n.label,icon:n.icon,svgIcon:n.svgIcon,data:n})))},[x,te,ee,G,I]),ae=s.useCallback(()=>e.files&&e.files.length>1?s.createElement("div",{className:"k-chat-download-button-wrapper"},s.createElement(D.Button,{className:"k-chat-download-button",fillMode:"flat",svgIcon:f.downloadLightIcon,size:"small",onClick:t=>{t.stopPropagation(),m&&m(e.files,e)},"aria-label":o.toLanguageString(l.downloadAllFiles,l.messages[l.downloadAllFiles])},s.createElement("span",{className:"k-button-text"},o.toLanguageString(l.downloadAll,l.messages[l.downloadAll])))):null,[e,m,o]),me=s.useCallback(()=>{if(e.typing)return s.createElement("div",{className:"k-chat-bubble k-bubble"},s.createElement("div",{className:"k-bubble-content"},s.createElement("div",{className:"k-typing-indicator"},s.createElement("span",null),s.createElement("span",null),s.createElement("span",null))));if(d){const t=d;return s.createElement(s.Fragment,null,s.createElement(t,{item:e}),K())}else if(e.text||e.files&&e.files.length>0)return s.createElement(s.Fragment,null,s.createElement("div",{className:g.classNames("k-chat-bubble","k-bubble",{"k-bubble-expandable":y,"k-expanded":y&&T,"k-selected":c,"k-active":J}),onClick:()=>C(c?void 0:e.selectionIndex),onContextMenu:P},s.createElement("div",{className:"k-bubble-content"},F?s.createElement(F,{item:e}):s.createElement(s.Fragment,null,(e.text||e.isDeleted||e.replyToId)&&s.createElement("span",{className:"k-chat-bubble-text"},!e.isDeleted&&se(),i.convertTextToLinkedContent(S(e,i.isAuthor(b,e)))),e.files&&e.files.length>0&&s.createElement(xe,{files:e.files,message:e,onFileAction:Y,onDownload:t=>m==null?void 0:m(t,e),renderInTextarea:!1,fileActions:U}),ae())),y&&s.createElement("span",{className:"k-bubble-expandable-indicator",onClick:j,role:"button","aria-label":T?o.toLanguageString(l.collapseMessage,l.messages[l.collapseMessage]):o.toLanguageString(l.expandMessage,l.messages[l.expandMessage]),tabIndex:0,onKeyDown:t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),j(t))}},s.createElement(g.IconWrap,{icon:T?f.chevronUpIcon:f.chevronDownIcon,size:"medium"}))),K());return null},[e,d,F,y,T,c,J,C,P,se,S,b,Y,U,ae,j,o,K,m]),ge=s.useCallback(()=>{let t=null;if(e.timestamp){const a=h==="onFocus"&&c;h==="hidden"||(t=s.createElement("time",{className:"k-message-time","aria-hidden":!a},Z.formatDate(e.timestamp,H)))}return t},[e.timestamp,c,H,h,Z]),fe=s.useCallback(()=>{if(!e.status)return null;let t;if(O)t=s.createElement(O,{item:e});else{const a=typeof e.status=="object"&&e.status!==null;let n,p,k;if(a){const _=e.status;n=_.text,p=_.icon,k=_.svgIcon}else n=e.status;let W=null;p?W=s.createElement(g.Icon,{name:p,size:"xsmall"}):k&&(W=s.createElement(g.IconWrap,{icon:k,size:"xsmall"})),t=s.createElement(s.Fragment,null,W,n)}return s.createElement("span",{className:"k-message-status"},t)},[e,O]),pe=s.useCallback(()=>{let t=null;if(e.isFailed){const a=o.toLanguageString(l.messageFailed,l.messages[l.messageFailed]);t=s.createElement("span",{className:"k-message-failed-content"},s.createElement(g.IconWrap,{icon:f.warningTriangleIcon,size:"xsmall"}),s.createElement("span",{className:"k-message-failed-text"},a))}return t},[e,o]),be=s.useCallback(()=>{let t=null;if(e.isFailed){const a=o.toLanguageString(l.retryMessage,l.messages[l.retryMessage]);t=s.createElement(D.Button,{fillMode:"clear",size:"small",className:"k-resend-button",svgIcon:f.arrowRotateCwOutlineIcon,"aria-label":a,title:a,onClick:n=>{n.stopPropagation(),q&&q({message:e,syntheticEvent:n,nativeEvent:n.nativeEvent,target:n.target})}})}return t},[e,o,q]),ke=s.useCallback(()=>g.classNames({"k-focus":c,"k-message-removed":e.isDeleted,"k-message-failed":e.isFailed},"k-message"),[c,e.isDeleted,e.isFailed]),Ce=s.useCallback(()=>E&&E.length>0&&s.createElement(D.Toolbar,{className:"k-chat-message-toolbar",fillMode:"flat"},E.map(t=>t.id==="delete"&&!I?null:s.createElement(D.Button,{key:t.id,fillMode:"flat",className:"k-toolbar-button",icon:t.icon,svgIcon:t.svgIcon,onClick:a=>{a.stopPropagation(),t.id==="copy"&&!e.isDeleted?N():t.id==="reply"&&w(e),R&&R(t,a,e)},onMouseDown:a=>a.preventDefault()}))),[N,I,e,E,R,w]);return s.createElement("div",{key:e.id,"data-message-id":e.id,className:ke(),tabIndex:ce,onMouseDown:ue,onKeyDown:de,onFocus:t=>{re&&C(e.selectionIndex)},ref:t=>{B.current=t,typeof r=="function"?r(t):r&&(r.current=t)},onContextMenu:d?P:void 0},be(),me(),(e.status||e.timestamp&&h!=="hidden"||e.isFailed)&&s.createElement("div",{className:"k-message-info"},fe(),ge(),pe()),Ce())});oe.displayName="ChatMessage";exports.ChatMessage=oe;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ye=require("react"),g=require("@progress/kendo-react-common"),D=require("@progress/kendo-react-buttons"),f=require("@progress/kendo-svg-icons"),ne=require("@progress/kendo-react-layout"),i=require("../utils.js"),xe=require("./ChatContext.js"),Ee=require("./elements/FileBox.js"),le=require("@progress/kendo-react-intl"),l=require("../../messages/index.js");function Ie(u){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const e in u)if(e!=="default"){const d=Object.getOwnPropertyDescriptor(u,e);Object.defineProperty(r,e,d.get?d:{enumerable:!0,get:()=>u[e]})}}return r.default=u,Object.freeze(r)}const s=Ie(ye),oe=s.forwardRef((u,r)=>{const{item:e,template:d,contentTemplate:F,onRequestSelection:C,tabIndex:ce=-1,dateFormat:H="g",selected:c,allowMessageCollapse:y,messageToolbarActions:x,messageContextMenuActions:E,fileActions:U,isSender:I}=u,{setReplyToMessage:w,messages:X,repliedToMessages:A,user:b,onToolbarAction:R,onContextMenuAction:z,onFileAction:Y,onDownload:m,onResendMessage:q,setShowCopyNotification:M,statusTemplate:L,timestampVisibility:v="onFocus",onReferencedMessageClick:T}=xe.useChatContext(),[G,V]=s.useState(!1),[J,O]=s.useState(!1),[h,ie]=s.useState(!0),[re,Q]=s.useState(!1),o=le.useLocalization(),Z=le.useInternationalization(),$=s.useRef({left:0,top:0}),N=s.useCallback(()=>{e!=null&&e.text&&i.copyToClipboard(e.text),M&&(M(!0),setTimeout(()=>{M(!1)},3e3))},[e,M]),j=s.useCallback(t=>{t.stopPropagation(),ie(a=>!a)},[]),ue=s.useCallback(()=>{Q(!1)},[]),de=s.useCallback(t=>{(t.key==="Tab"||t.key==="Enter"||t.key===" "||t.key==="ArrowUp"||t.key==="ArrowDown")&&Q(!0)},[]),B=s.useRef(null);s.useEffect(()=>{c&&B.current&&B.current.focus()},[c]);const P=s.useCallback(t=>{$.current={left:t.pageX,top:t.pageY},t.preventDefault(),O(!0),V(!0)},[]),ee=s.useCallback(()=>{O(!1),V(!1)},[]),S=s.useCallback((t,a)=>t.isDeleted?i.getDeletedMessageText(a,o):t.text?t.text:"",[o]),te=s.useCallback(t=>{var a;(a=t.item)!=null&&a.text&&(t.item.data.id==="copy"&&!e.isDeleted?N():t.item.data.id==="reply"&&w(e),z&&z(t.item.data,t,e)),O(!1),V(!1)},[e,z,w,N]),se=s.useCallback(()=>{if(e.replyToId){const t=i.getMessageById(X,e.replyToId)||(A?i.getMessageById(A,e.replyToId):void 0);if(t){const a=n=>{n.preventDefault(),n.stopPropagation(),T==null||T(t.id)};return s.createElement("div",{className:g.classNames("k-message-reference",i.isAuthor(b,t)?"k-message-reference-sender":"k-message-reference-receiver"),onClick:a},s.createElement("div",{className:"k-message-reference-content"},i.convertTextToLinkedContent(S(t,i.isAuthor(b,t)))))}}return null},[e.replyToId,X,A,b,S,T]),K=s.useCallback(()=>{const t=[{id:"reply",label:"Reply",svgIcon:f.undoIcon},{id:"copy",label:"Copy",svgIcon:f.copyIcon}],a=E?[...t.map(n=>E.find(k=>k.id===n.id)||n),...E.filter(n=>!t.some(p=>p.id===n.id))]:t;return s.createElement(ne.ContextMenu,{onSelect:te,onClose:ee,vertical:!0,show:G,offset:$.current},a.map(n=>n.id==="delete"&&!I?null:s.createElement(ne.MenuItem,{key:n.id,text:n.label,icon:n.icon,svgIcon:n.svgIcon,data:n})))},[E,te,ee,G,I]),ae=s.useCallback(()=>e.files&&e.files.length>1?s.createElement("div",{className:"k-chat-download-button-wrapper"},s.createElement(D.Button,{className:"k-chat-download-button",fillMode:"flat",svgIcon:f.downloadIcon,size:"small",onClick:t=>{t.stopPropagation(),m&&m(e.files,e)},"aria-label":o.toLanguageString(l.downloadAllFiles,l.messages[l.downloadAllFiles])},s.createElement("span",{className:"k-button-text"},o.toLanguageString(l.downloadAll,l.messages[l.downloadAll])))):null,[e,m,o]),me=s.useCallback(()=>{if(e.typing)return s.createElement("div",{className:"k-chat-bubble k-bubble"},s.createElement("div",{className:"k-bubble-content"},s.createElement("div",{className:"k-typing-indicator"},s.createElement("span",null),s.createElement("span",null),s.createElement("span",null))));if(d){const t=d;return s.createElement(s.Fragment,null,s.createElement(t,{item:e}),K())}else if(e.text||e.files&&e.files.length>0)return s.createElement(s.Fragment,null,s.createElement("div",{className:g.classNames("k-chat-bubble","k-bubble",{"k-bubble-expandable":y,"k-expanded":y&&h,"k-selected":c,"k-active":J}),onClick:()=>C(c?void 0:e.selectionIndex),onContextMenu:P},s.createElement("div",{className:"k-bubble-content"},F?s.createElement(F,{item:e}):s.createElement(s.Fragment,null,(e.text||e.isDeleted||e.replyToId)&&s.createElement("span",{className:"k-chat-bubble-text"},!e.isDeleted&&se(),i.convertTextToLinkedContent(S(e,i.isAuthor(b,e)))),e.files&&e.files.length>0&&s.createElement(Ee,{files:e.files,message:e,onFileAction:Y,onDownload:t=>m==null?void 0:m(t,e),renderInTextarea:!1,fileActions:U}),ae())),y&&s.createElement("span",{className:"k-bubble-expandable-indicator",onClick:j,role:"button","aria-label":h?o.toLanguageString(l.collapseMessage,l.messages[l.collapseMessage]):o.toLanguageString(l.expandMessage,l.messages[l.expandMessage]),tabIndex:0,onKeyDown:t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),j(t))}},s.createElement(g.IconWrap,{icon:h?f.chevronUpIcon:f.chevronDownIcon,size:"medium"}))),K());return null},[e,d,F,y,h,c,J,C,P,se,S,b,Y,U,ae,j,o,K,m]),ge=s.useCallback(()=>{let t=null;if(e.timestamp){const a=v==="onFocus"&&c;v==="hidden"||(t=s.createElement("time",{className:"k-message-time","aria-hidden":!a},Z.formatDate(e.timestamp,H)))}return t},[e.timestamp,c,H,v,Z]),fe=s.useCallback(()=>{if(!e.status)return null;let t;if(L)t=s.createElement(L,{item:e});else{const a=typeof e.status=="object"&&e.status!==null;let n,p,k;if(a){const _=e.status;n=_.text,p=_.icon,k=_.svgIcon}else n=e.status;let W=null;p?W=s.createElement(g.Icon,{name:p,size:"xsmall"}):k&&(W=s.createElement(g.IconWrap,{icon:k,size:"xsmall"})),t=s.createElement(s.Fragment,null,W,n)}return s.createElement("span",{className:"k-message-status"},t)},[e,L]),pe=s.useCallback(()=>{let t=null;if(e.isFailed){const a=o.toLanguageString(l.messageFailed,l.messages[l.messageFailed]);t=s.createElement("span",{className:"k-message-failed-content"},s.createElement(g.IconWrap,{icon:f.warningTriangleIcon,size:"xsmall"}),s.createElement("span",{className:"k-message-failed-text"},a))}return t},[e,o]),be=s.useCallback(()=>{let t=null;if(e.isFailed){const a=o.toLanguageString(l.retryMessage,l.messages[l.retryMessage]);t=s.createElement(D.Button,{fillMode:"clear",size:"xs",className:"k-resend-button",svgIcon:f.arrowRotateCwIcon,"aria-label":a,title:a,onClick:n=>{n.stopPropagation(),q&&q({message:e,syntheticEvent:n,nativeEvent:n.nativeEvent,target:n.target})}})}return t},[e,o,q]),ke=s.useCallback(()=>g.classNames({"k-focus":c,"k-message-removed":e.isDeleted,"k-message-failed":e.isFailed},"k-message"),[c,e.isDeleted,e.isFailed]),Ce=s.useCallback(()=>x&&x.length>0&&s.createElement(D.Toolbar,{className:"k-chat-message-toolbar",fillMode:"flat",size:"small"},x.map(t=>t.id==="delete"&&!I?null:s.createElement(D.Button,{key:t.id,fillMode:"flat",size:"xs",className:"k-toolbar-button",icon:t.icon,svgIcon:t.svgIcon,onClick:a=>{a.stopPropagation(),t.id==="copy"&&!e.isDeleted?N():t.id==="reply"&&w(e),R&&R(t,a,e)},onMouseDown:a=>a.preventDefault()}))),[N,I,e,x,R,w]);return s.createElement("div",{key:e.id,"data-message-id":e.id,className:ke(),tabIndex:ce,onMouseDown:ue,onKeyDown:de,onFocus:t=>{re&&C(e.selectionIndex)},ref:t=>{B.current=t,typeof r=="function"?r(t):r&&(r.current=t)},onContextMenu:d?P:void 0},be(),me(),(e.status||e.timestamp&&v!=="hidden"||e.isFailed)&&s.createElement("div",{className:"k-message-info"},fe(),ge(),pe()),Ce())});oe.displayName="ChatMessage";exports.ChatMessage=oe;