@progress/kendo-react-conversational-ui 15.2.0-develop.1 → 15.2.0-develop.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chat/components/ChatMessage.js +1 -1
- package/chat/components/ChatMessage.mjs +1 -1
- package/chat/components/ScrollButtonsWrapper.js +1 -1
- package/chat/components/ScrollButtonsWrapper.mjs +6 -6
- package/chat/components/elements/FileBox.js +1 -1
- package/chat/components/elements/FileBox.mjs +62 -29
- package/chat/components/elements/PinnedMessage.js +1 -1
- package/chat/components/elements/PinnedMessage.mjs +20 -18
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/messages/index.d.ts +15 -0
- package/messages/index.js +1 -1
- package/messages/index.mjs +36 -30
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +11 -11
- package/prompt-box/FileBox.js +1 -1
- package/prompt-box/FileBox.mjs +52 -38
- package/prompt-box/PromptBox.js +1 -1
- package/prompt-box/PromptBox.mjs +1 -1
|
@@ -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"),S=require("@progress/kendo-react-buttons"),f=require("@progress/kendo-svg-icons"),ne=require("@progress/kendo-react-layout"),c=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(i){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const e in i)if(e!=="default"){const u=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(r,e,u.get?u:{enumerable:!0,get:()=>i[e]})}}return r.default=i,Object.freeze(r)}const a=Ie(ye),oe=a.forwardRef((i,r)=>{const{item:e,template:u,contentTemplate:D,onRequestSelection:C,tabIndex:ce=-1,dateFormat:H="g",selected:d,allowMessageCollapse:y,messageToolbarActions:E,messageContextMenuActions:x,fileActions:U,isSender:I}=i,{setReplyToMessage:M,messages:X,repliedToMessages:A,user:b,onToolbarAction:F,onContextMenuAction:R,onFileAction:Y,onDownload:m,onResendMessage:L,setShowCopyNotification:w,statusTemplate:q,timestampVisibility:
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ye=require("react"),g=require("@progress/kendo-react-common"),S=require("@progress/kendo-react-buttons"),f=require("@progress/kendo-svg-icons"),ne=require("@progress/kendo-react-layout"),c=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(i){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const e in i)if(e!=="default"){const u=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(r,e,u.get?u:{enumerable:!0,get:()=>i[e]})}}return r.default=i,Object.freeze(r)}const a=Ie(ye),oe=a.forwardRef((i,r)=>{const{item:e,template:u,contentTemplate:D,onRequestSelection:C,tabIndex:ce=-1,dateFormat:H="g",selected:d,allowMessageCollapse:y,messageToolbarActions:E,messageContextMenuActions:x,fileActions:U,isSender:I}=i,{setReplyToMessage:M,messages:X,repliedToMessages:A,user:b,onToolbarAction:F,onContextMenuAction:R,onFileAction:Y,onDownload:m,onResendMessage:L,setShowCopyNotification:w,statusTemplate:q,timestampVisibility:O="onFocus",onReferencedMessageClick:T}=Ee.useChatContext(),[G,V]=a.useState(!1),[J,z]=a.useState(!1),[h,re]=a.useState(!0),[ie,Q]=a.useState(!1),o=le.useLocalization(),Z=le.useInternationalization(),$=a.useRef({left:0,top:0}),v=a.useCallback(()=>{e!=null&&e.text&&c.copyToClipboard(e.text),w&&(w(!0),setTimeout(()=>{w(!1)},3e3))},[e,w]),j=a.useCallback(t=>{t.stopPropagation(),re(s=>!s)},[]),ue=a.useCallback(()=>{Q(!1)},[]),de=a.useCallback(t=>{(t.key==="Tab"||t.key==="Enter"||t.key===" "||t.key==="ArrowUp"||t.key==="ArrowDown")&&Q(!0)},[]),B=a.useRef(null);a.useEffect(()=>{d&&B.current&&B.current.focus()},[d]);const P=a.useCallback(t=>{$.current={left:t.pageX,top:t.pageY},t.preventDefault(),z(!0),V(!0)},[]),ee=a.useCallback(()=>{z(!1),V(!1)},[]),N=a.useCallback((t,s)=>t.isDeleted?c.getDeletedMessageText(s,o):t.text?t.text:"",[o]),te=a.useCallback(t=>{var s;(s=t.item)!=null&&s.text&&(t.item.data.id==="copy"&&!e.isDeleted?v():t.item.data.id==="reply"&&M(e),R&&R(t.item.data,t,e)),z(!1),V(!1)},[e,R,M,v]),ae=a.useCallback(()=>{if(e.replyToId){const t=c.getMessageById(X,e.replyToId)||(A?c.getMessageById(A,e.replyToId):void 0);if(t){const s=n=>{n.preventDefault(),n.stopPropagation(),T==null||T(t.id)};return a.createElement("div",{className:g.classNames("k-message-reference",c.isAuthor(b,t)?"k-message-reference-sender":"k-message-reference-receiver"),onClick:s},a.createElement("div",{className:"k-message-reference-content"},c.convertTextToLinkedContent(N(t,c.isAuthor(b,t)))))}}return null},[e.replyToId,X,A,b,N,T]),K=a.useCallback(()=>{const t=[{id:"reply",label:"Reply",svgIcon:f.undoIcon},{id:"copy",label:"Copy",svgIcon:f.copyIcon}],s=x?[...t.map(n=>x.find(k=>k.id===n.id)||n),...x.filter(n=>!t.some(p=>p.id===n.id))]:t;return a.createElement(ne.ContextMenu,{onSelect:te,onClose:ee,vertical:!0,show:G,offset:$.current},s.map(n=>n.id==="delete"&&!I?null:a.createElement(ne.MenuItem,{key:n.id,text:n.label,icon:n.icon,svgIcon:n.svgIcon,data:n})))},[x,te,ee,G,I]),se=a.useCallback(()=>e.files&&e.files.length>1?a.createElement("div",{className:"k-chat-download-button-wrapper"},a.createElement(S.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])},a.createElement("span",{className:"k-button-text"},o.toLanguageString(l.downloadAll,l.messages[l.downloadAll])))):null,[e,m,o]),me=a.useCallback(()=>{if(e.typing)return a.createElement("div",{className:"k-chat-bubble k-bubble"},a.createElement("div",{className:"k-bubble-content"},a.createElement("div",{className:"k-typing-indicator"},a.createElement("span",null),a.createElement("span",null),a.createElement("span",null))));if(u){const t=u;return a.createElement(a.Fragment,null,a.createElement(t,{item:e}),K())}else if(e.text||e.files&&e.files.length>0)return a.createElement(a.Fragment,null,a.createElement("div",{className:g.classNames("k-chat-bubble","k-bubble",{"k-bubble-expandable":y,"k-expanded":y&&h,"k-selected":d,"k-active":J}),onClick:()=>C(d?void 0:e.selectionIndex),onContextMenu:P},a.createElement("div",{className:"k-bubble-content"},D?a.createElement(D,{item:e}):a.createElement(a.Fragment,null,(e.text||e.isDeleted||e.replyToId)&&a.createElement("span",{className:"k-chat-bubble-text"},!e.isDeleted&&ae(),c.convertTextToLinkedContent(N(e,c.isAuthor(b,e)))),e.files&&e.files.length>0&&a.createElement(xe,{files:e.files,message:e,onFileAction:Y,onDownload:t=>m==null?void 0:m(t,e),renderInTextarea:!1,fileActions:U}),se())),y&&a.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))}},a.createElement(g.IconWrap,{icon:h?f.chevronUpIcon:f.chevronDownIcon}))),K());return null},[e,u,D,y,h,d,J,C,P,ae,N,b,Y,U,se,j,o,K,m]),ge=a.useCallback(()=>{let t=null;return e.timestamp&&(O==="hidden"||(t=a.createElement("time",{className:"k-message-time"},Z.formatDate(e.timestamp,H)))),t},[e.timestamp,H,O,Z]),fe=a.useCallback(()=>{if(!e.status)return null;let t;if(q)t=a.createElement(q,{item:e});else{const s=typeof e.status=="object"&&e.status!==null;let n,p,k;if(s){const _=e.status;n=_.text,p=_.icon,k=_.svgIcon}else n=e.status;let W=null;p?W=a.createElement(g.Icon,{name:p,size:"xsmall"}):k&&(W=a.createElement(g.IconWrap,{icon:k,size:"xsmall"})),t=a.createElement(a.Fragment,null,W,n)}return a.createElement("span",{className:"k-message-status"},t)},[e,q]),pe=a.useCallback(()=>{let t=null;if(e.isFailed){const s=o.toLanguageString(l.messageFailed,l.messages[l.messageFailed]);t=a.createElement("span",{className:"k-message-failed-content"},a.createElement(g.IconWrap,{icon:f.warningTriangleIcon,size:"xsmall"}),a.createElement("span",{className:"k-message-failed-text"},s))}return t},[e,o]),be=a.useCallback(()=>{let t=null;if(e.isFailed){const s=o.toLanguageString(l.retryMessage,l.messages[l.retryMessage]);t=a.createElement(S.Button,{fillMode:"clear",size:"xs",className:"k-resend-button",svgIcon:f.arrowRotateCwIcon,"aria-label":s,title:s,onClick:n=>{n.stopPropagation(),L&&L({message:e,syntheticEvent:n,nativeEvent:n.nativeEvent,target:n.target})}})}return t},[e,o,L]),ke=a.useCallback(()=>g.classNames({"k-focus":d,"k-message-removed":e.isDeleted,"k-message-failed":e.isFailed},"k-message"),[d,e.isDeleted,e.isFailed]),Ce=a.useCallback(()=>E&&E.length>0&&a.createElement(S.Toolbar,{className:"k-chat-message-toolbar",fillMode:"flat",ariaLabel:o.toLanguageString(l.chatMessageToolbar,l.messages[l.chatMessageToolbar])},E.map(t=>t.id==="delete"&&!I?null:a.createElement(S.Button,{key:t.id,fillMode:"flat",className:"k-toolbar-button",icon:t.icon,svgIcon:t.svgIcon,"aria-label":t.label,onClick:s=>{s.stopPropagation(),t.id==="copy"&&!e.isDeleted?v():t.id==="reply"&&M(e),F&&F(t,s,e)},onMouseDown:s=>s.preventDefault()}))),[v,I,e,o,E,F,M]);return a.createElement("div",{key:e.id,"data-message-id":e.id,className:ke(),tabIndex:ce,onMouseDown:ue,onKeyDown:de,onFocus:t=>{ie&&C(e.selectionIndex)},ref:t=>{B.current=t,typeof r=="function"?r(t):r&&(r.current=t)},onContextMenu:u?P:void 0},be(),me(),(e.status||e.timestamp&&O!=="hidden"||e.isFailed)&&a.createElement("div",{className:"k-message-info"},fe(),ge(),pe()),Ce())});oe.displayName="ChatMessage";exports.ChatMessage=oe;
|
|
@@ -202,7 +202,7 @@ const We = t.forwardRef(
|
|
|
202
202
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), L(e));
|
|
203
203
|
}
|
|
204
204
|
},
|
|
205
|
-
/* @__PURE__ */ t.createElement(j, { icon: I ? Se : Fe
|
|
205
|
+
/* @__PURE__ */ t.createElement(j, { icon: I ? Se : Fe })
|
|
206
206
|
)
|
|
207
207
|
), K());
|
|
208
208
|
return null;
|
|
@@ -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
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react"),b=require("@progress/kendo-react-buttons"),r=require("@progress/kendo-svg-icons"),L=require("@progress/kendo-react-intl"),n=require("../../messages/index.js");function m(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,l.get?l:{enumerable:!0,get:()=>t[o]})}}return e.default=t,Object.freeze(e)}const c=m(v),S=({visible:t,dir:e,canScrollLeft:o,canScrollRight:l,onScrollLeft:d,onScrollRight:p,children:s})=>{const a=L.useLocalization();if(!t)return s;const i=a.toLanguageString(n.scrollLeft,n.messages[n.scrollLeft]),u=a.toLanguageString(n.scrollRight,n.messages[n.scrollRight]),g=e!=="rtl"?i:u,f=e!=="rtl"?u:i;return c.createElement("div",{className:"k-suggestion-scrollwrap"},c.createElement(b.Button,{fillMode:"flat",size:"xs",svgIcon:e==="rtl"?r.chevronRightIcon:r.chevronLeftIcon,onClick:d,disabled:!o,"aria-label":g,title:g}),s,c.createElement(b.Button,{fillMode:"flat",size:"xs",svgIcon:e==="rtl"?r.chevronLeftIcon:r.chevronRightIcon,onClick:p,disabled:!l,"aria-label":f,title:f}))};exports.ScrollButtonsWrapper=S;
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
import * as e from "react";
|
|
9
9
|
import { Button as c } from "@progress/kendo-react-buttons";
|
|
10
10
|
import { chevronRightIcon as i, chevronLeftIcon as m } from "@progress/kendo-svg-icons";
|
|
11
|
-
import { useLocalization as
|
|
11
|
+
import { useLocalization as x } from "@progress/kendo-react-intl";
|
|
12
12
|
import { scrollLeft as g, messages as f, scrollRight as p } from "../../messages/index.mjs";
|
|
13
|
-
const
|
|
13
|
+
const d = ({
|
|
14
14
|
visible: L,
|
|
15
15
|
dir: t,
|
|
16
16
|
canScrollLeft: b,
|
|
@@ -19,7 +19,7 @@ const k = ({
|
|
|
19
19
|
onScrollRight: h,
|
|
20
20
|
children: l
|
|
21
21
|
}) => {
|
|
22
|
-
const o =
|
|
22
|
+
const o = x();
|
|
23
23
|
if (!L)
|
|
24
24
|
return l;
|
|
25
25
|
const r = o.toLanguageString(g, f[g]), a = o.toLanguageString(p, f[p]), s = t !== "rtl" ? r : a, n = t !== "rtl" ? a : r;
|
|
@@ -27,7 +27,7 @@ const k = ({
|
|
|
27
27
|
c,
|
|
28
28
|
{
|
|
29
29
|
fillMode: "flat",
|
|
30
|
-
size: "
|
|
30
|
+
size: "xs",
|
|
31
31
|
svgIcon: t === "rtl" ? i : m,
|
|
32
32
|
onClick: v,
|
|
33
33
|
disabled: !b,
|
|
@@ -38,7 +38,7 @@ const k = ({
|
|
|
38
38
|
c,
|
|
39
39
|
{
|
|
40
40
|
fillMode: "flat",
|
|
41
|
-
size: "
|
|
41
|
+
size: "xs",
|
|
42
42
|
svgIcon: t === "rtl" ? m : i,
|
|
43
43
|
onClick: h,
|
|
44
44
|
disabled: !u,
|
|
@@ -48,5 +48,5 @@ const k = ({
|
|
|
48
48
|
));
|
|
49
49
|
};
|
|
50
50
|
export {
|
|
51
|
-
|
|
51
|
+
d as ScrollButtonsWrapper
|
|
52
52
|
};
|
|
@@ -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";const
|
|
8
|
+
"use strict";const I=require("react"),m=require("@progress/kendo-react-common"),N=require("@progress/kendo-react-buttons"),E=require("@progress/kendo-svg-icons"),b=require("@progress/kendo-react-intl"),n=require("../../../messages/index.js"),B=require("../ChatContext.js");function C(s){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const o in s)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(s,o);Object.defineProperty(i,o,l.get?l:{enumerable:!0,get:()=>s[o]})}}return i.default=s,Object.freeze(i)}const a=C(I),F=s=>{const{files:i,onFileAction:o,onDownload:l,fileActions:x}=s,{messageFilesLayout:u="vertical"}=B.useChatContext(),d=b.useLocalization(),v=[{id:"download",label:"Download",svgIcon:E.downloadIcon}],p=x||v,g=e=>{if(e==null)return"";if(e===0)return"0 B";const t=1024,c=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,r)).toFixed(2))} ${c[r]}`},f=e=>"."+e.split(".").pop()||"",z=(e,t)=>{var c,r;(r=(c=e.syntheticEvent)==null?void 0:c.stopPropagation)==null||r.call(c),e.item.id==="download"&&(l==null||l([t])),o==null||o(e.item,e,t)},k=e=>p.length>0&&a.createElement(N.DropDownButton,{fillMode:"flat",size:"xs",svgIcon:E.moreVerticalIcon,onClick:t=>{t.syntheticEvent.stopPropagation()},onItemClick:t=>z(t,e),items:p.map(t=>({id:t.id,icon:t.icon,text:t.label,svgIcon:t.svgIcon})),"aria-label":`${d.toLanguageString(n.fileActions,n.messages[n.fileActions])} ${e.name}`,title:`${d.toLanguageString(n.fileActions,n.messages[n.fileActions])} ${e.name}`}),h=a.useCallback(()=>m.classNames({"k-files-wrap":u==="wrap","k-files-vertical":u==="vertical"},"k-file-box-wrapper"),[u]);return a.createElement("ul",{role:"list","aria-label":d.toLanguageString(n.chatMessageAttachedFiles,n.messages[n.chatMessageAttachedFiles]),className:h()},u==="horizontal"?a.createElement("div",{className:"k-files-scroll",role:"presentation"},i.map(e=>a.createElement("li",{key:e.name,className:"k-file-box",role:"listitem","aria-label":[e.name,g(e.size)].filter(Boolean).join(" ")||void 0},a.createElement(m.IconWrap,{size:"xlarge",...m.getFileExtensionIcon(f(e.name))}),a.createElement("div",{className:"k-file-info"},a.createElement("span",{className:"k-file-name"},e.name),a.createElement("span",{className:"k-file-size"},g(e.size))),k(e)))):i.map(e=>a.createElement("li",{key:e.name,className:"k-file-box",role:"listitem","aria-label":[e.name,g(e.size)].filter(Boolean).join(" ")||void 0},a.createElement(m.IconWrap,{size:"xlarge",...m.getFileExtensionIcon(f(e.name))}),a.createElement("div",{className:"k-file-info"},a.createElement("span",{className:"k-file-name"},e.name),a.createElement("span",{className:"k-file-size"},g(e.size))),k(e))))};module.exports=F;
|
|
@@ -5,54 +5,87 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
9
|
-
import { classNames as
|
|
10
|
-
import { DropDownButton as
|
|
11
|
-
import { downloadIcon as
|
|
12
|
-
import { useLocalization as
|
|
13
|
-
import {
|
|
14
|
-
import { useChatContext as
|
|
15
|
-
const P = (
|
|
16
|
-
const { files:
|
|
8
|
+
import * as t from "react";
|
|
9
|
+
import { classNames as B, IconWrap as k, getFileExtensionIcon as E } from "@progress/kendo-react-common";
|
|
10
|
+
import { DropDownButton as I } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { downloadIcon as F, moreVerticalIcon as w } from "@progress/kendo-svg-icons";
|
|
12
|
+
import { useLocalization as C } from "@progress/kendo-react-intl";
|
|
13
|
+
import { chatMessageAttachedFiles as z, messages as p, fileActions as i } from "../../../messages/index.mjs";
|
|
14
|
+
import { useChatContext as M } from "../ChatContext.mjs";
|
|
15
|
+
const P = (v) => {
|
|
16
|
+
const { files: g, onFileAction: r, onDownload: c, fileActions: x } = v, { messageFilesLayout: s = "vertical" } = M(), m = C(), d = x || [{ id: "download", label: "Download", svgIcon: F }], l = (e) => {
|
|
17
17
|
if (e == null)
|
|
18
18
|
return "";
|
|
19
19
|
if (e === 0)
|
|
20
20
|
return "0 B";
|
|
21
|
-
const
|
|
22
|
-
return `${parseFloat((e / Math.pow(
|
|
23
|
-
},
|
|
21
|
+
const a = 1024, o = ["B", "KB", "MB", "GB", "TB"], n = Math.floor(Math.log(e) / Math.log(a));
|
|
22
|
+
return `${parseFloat((e / Math.pow(a, n)).toFixed(2))} ${o[n]}`;
|
|
23
|
+
}, f = (e) => "." + e.split(".").pop() || "", N = (e, a) => {
|
|
24
24
|
var o, n;
|
|
25
|
-
(n = (o = e.syntheticEvent) == null ? void 0 : o.stopPropagation) == null || n.call(o), e.item.id === "download" && (
|
|
26
|
-
},
|
|
27
|
-
|
|
25
|
+
(n = (o = e.syntheticEvent) == null ? void 0 : o.stopPropagation) == null || n.call(o), e.item.id === "download" && (c == null || c([a])), r == null || r(e.item, e, a);
|
|
26
|
+
}, u = (e) => d.length > 0 && /* @__PURE__ */ t.createElement(
|
|
27
|
+
I,
|
|
28
28
|
{
|
|
29
29
|
fillMode: "flat",
|
|
30
|
-
size: "
|
|
30
|
+
size: "xs",
|
|
31
31
|
svgIcon: w,
|
|
32
|
-
onClick: (
|
|
33
|
-
|
|
32
|
+
onClick: (a) => {
|
|
33
|
+
a.syntheticEvent.stopPropagation();
|
|
34
34
|
},
|
|
35
|
-
onItemClick: (
|
|
36
|
-
items:
|
|
37
|
-
id:
|
|
38
|
-
icon:
|
|
39
|
-
text:
|
|
40
|
-
svgIcon:
|
|
35
|
+
onItemClick: (a) => N(a, e),
|
|
36
|
+
items: d.map((a) => ({
|
|
37
|
+
id: a.id,
|
|
38
|
+
icon: a.icon,
|
|
39
|
+
text: a.label,
|
|
40
|
+
svgIcon: a.svgIcon
|
|
41
41
|
})),
|
|
42
42
|
"aria-label": `${m.toLanguageString(
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
i,
|
|
44
|
+
p[i]
|
|
45
45
|
)} ${e.name}`,
|
|
46
|
-
title: `${m.toLanguageString(
|
|
46
|
+
title: `${m.toLanguageString(i, p[i])} ${e.name}`
|
|
47
47
|
}
|
|
48
|
-
),
|
|
48
|
+
), h = t.useCallback(() => B(
|
|
49
49
|
{
|
|
50
50
|
"k-files-wrap": s === "wrap",
|
|
51
51
|
"k-files-vertical": s === "vertical"
|
|
52
52
|
},
|
|
53
53
|
"k-file-box-wrapper"
|
|
54
54
|
), [s]);
|
|
55
|
-
return /* @__PURE__ */
|
|
55
|
+
return /* @__PURE__ */ t.createElement(
|
|
56
|
+
"ul",
|
|
57
|
+
{
|
|
58
|
+
role: "list",
|
|
59
|
+
"aria-label": m.toLanguageString(
|
|
60
|
+
z,
|
|
61
|
+
p[z]
|
|
62
|
+
),
|
|
63
|
+
className: h()
|
|
64
|
+
},
|
|
65
|
+
s === "horizontal" ? /* @__PURE__ */ t.createElement("div", { className: "k-files-scroll", role: "presentation" }, g.map((e) => /* @__PURE__ */ t.createElement(
|
|
66
|
+
"li",
|
|
67
|
+
{
|
|
68
|
+
key: e.name,
|
|
69
|
+
className: "k-file-box",
|
|
70
|
+
role: "listitem",
|
|
71
|
+
"aria-label": [e.name, l(e.size)].filter(Boolean).join(" ") || void 0
|
|
72
|
+
},
|
|
73
|
+
/* @__PURE__ */ t.createElement(k, { size: "xlarge", ...E(f(e.name)) }),
|
|
74
|
+
/* @__PURE__ */ t.createElement("div", { className: "k-file-info" }, /* @__PURE__ */ t.createElement("span", { className: "k-file-name" }, e.name), /* @__PURE__ */ t.createElement("span", { className: "k-file-size" }, l(e.size))),
|
|
75
|
+
u(e)
|
|
76
|
+
))) : g.map((e) => /* @__PURE__ */ t.createElement(
|
|
77
|
+
"li",
|
|
78
|
+
{
|
|
79
|
+
key: e.name,
|
|
80
|
+
className: "k-file-box",
|
|
81
|
+
role: "listitem",
|
|
82
|
+
"aria-label": [e.name, l(e.size)].filter(Boolean).join(" ") || void 0
|
|
83
|
+
},
|
|
84
|
+
/* @__PURE__ */ t.createElement(k, { size: "xlarge", ...E(f(e.name)) }),
|
|
85
|
+
/* @__PURE__ */ t.createElement("div", { className: "k-file-info" }, /* @__PURE__ */ t.createElement("span", { className: "k-file-name" }, e.name), /* @__PURE__ */ t.createElement("span", { className: "k-file-size" }, l(e.size))),
|
|
86
|
+
u(e)
|
|
87
|
+
))
|
|
88
|
+
);
|
|
56
89
|
};
|
|
57
90
|
export {
|
|
58
91
|
P as default
|
|
@@ -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";const
|
|
8
|
+
"use strict";const m=require("react"),p=require("@progress/kendo-react-common"),f=require("@progress/kendo-react-buttons"),l=require("@progress/kendo-svg-icons"),k=require("@progress/kendo-react-intl"),o=require("../../utils.js"),b=require("../../../messages/index.js");function v(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const a=v(m),q=n=>{const{message:e,onUnpin:t,user:s,onReferencedMessageClick:r}=n,i=k.useLocalization(),u=a.useRef(null),g=s&&o.isAuthor(s,e),d=a.useCallback(c=>{c.preventDefault(),c.stopPropagation(),r==null||r(e.id)},[e.id,r]);return a.createElement("div",{ref:u,className:`k-message-reference ${g?"k-message-reference-sender":"k-message-reference-receiver"} k-message-pinned`,onClick:d},a.createElement(p.IconWrap,{icon:l.pinIcon}),a.createElement("div",{className:"k-message-reference-content"},e.isDeleted?s&&o.getDeletedMessageText(o.isAuthor(s,e),i):e.text),a.createElement("span",{className:"k-spacer"}),a.createElement(f.Button,{fillMode:"flat",size:"xs",svgIcon:l.xCircleIcon,onClick:c=>{c.stopPropagation(),t==null||t(e)},"aria-label":i.toLanguageString("chat.unpinMessage",b.messages["chat.unpinMessage"])}))};module.exports=q;
|
|
@@ -6,41 +6,43 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as s from "react";
|
|
9
|
-
import { IconWrap as
|
|
10
|
-
import { Button as
|
|
11
|
-
import { pinIcon as
|
|
9
|
+
import { IconWrap as g } from "@progress/kendo-react-common";
|
|
10
|
+
import { Button as f } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { pinIcon as d, xCircleIcon as u } from "@progress/kendo-svg-icons";
|
|
12
12
|
import { useLocalization as k } from "@progress/kendo-react-intl";
|
|
13
|
-
import { isAuthor as
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
import { isAuthor as i, getDeletedMessageText as v } from "../../utils.mjs";
|
|
14
|
+
import { messages as M } from "../../../messages/index.mjs";
|
|
15
|
+
const z = (c) => {
|
|
16
|
+
const { message: e, onUnpin: r, user: t, onReferencedMessageClick: a } = c, o = k(), m = s.useRef(null), l = t && i(t, e), p = s.useCallback(
|
|
17
|
+
(n) => {
|
|
18
|
+
n.preventDefault(), n.stopPropagation(), a == null || a(e.id);
|
|
18
19
|
},
|
|
19
|
-
[e.id,
|
|
20
|
+
[e.id, a]
|
|
20
21
|
);
|
|
21
22
|
return /* @__PURE__ */ s.createElement(
|
|
22
23
|
"div",
|
|
23
24
|
{
|
|
24
|
-
ref:
|
|
25
|
-
className: `k-message-reference ${
|
|
25
|
+
ref: m,
|
|
26
|
+
className: `k-message-reference ${l ? "k-message-reference-sender" : "k-message-reference-receiver"} k-message-pinned`,
|
|
26
27
|
onClick: p
|
|
27
28
|
},
|
|
28
|
-
/* @__PURE__ */ s.createElement(
|
|
29
|
-
/* @__PURE__ */ s.createElement("div", { className: "k-message-reference-content" }, e.isDeleted ? t && v(
|
|
29
|
+
/* @__PURE__ */ s.createElement(g, { icon: d }),
|
|
30
|
+
/* @__PURE__ */ s.createElement("div", { className: "k-message-reference-content" }, e.isDeleted ? t && v(i(t, e), o) : e.text),
|
|
30
31
|
/* @__PURE__ */ s.createElement("span", { className: "k-spacer" }),
|
|
31
32
|
/* @__PURE__ */ s.createElement(
|
|
32
|
-
|
|
33
|
+
f,
|
|
33
34
|
{
|
|
34
35
|
fillMode: "flat",
|
|
35
36
|
size: "xs",
|
|
36
37
|
svgIcon: u,
|
|
37
|
-
onClick: (
|
|
38
|
-
|
|
39
|
-
}
|
|
38
|
+
onClick: (n) => {
|
|
39
|
+
n.stopPropagation(), r == null || r(e);
|
|
40
|
+
},
|
|
41
|
+
"aria-label": o.toLanguageString("chat.unpinMessage", M["chat.unpinMessage"])
|
|
40
42
|
}
|
|
41
43
|
)
|
|
42
44
|
);
|
|
43
45
|
};
|
|
44
46
|
export {
|
|
45
|
-
|
|
47
|
+
z as default
|
|
46
48
|
};
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
13
13
|
*-------------------------------------------------------------------------------------------
|
|
14
14
|
*/
|
|
15
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@progress/kendo-react-common"),require("@progress/kendo-react-buttons"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-layout"),require("@progress/kendo-react-intl"),require("prop-types"),require("@progress/kendo-react-upload"),require("@progress/kendo-react-animation"),require("@progress/kendo-react-notification"),require("@progress/kendo-react-inputs"),require("@progress/kendo-react-popup")):"function"==typeof define&&define.amd?define(["exports","react","@progress/kendo-react-common","@progress/kendo-react-buttons","@progress/kendo-svg-icons","@progress/kendo-react-layout","@progress/kendo-react-intl","prop-types","@progress/kendo-react-upload","@progress/kendo-react-animation","@progress/kendo-react-notification","@progress/kendo-react-inputs","@progress/kendo-react-popup"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactConversationalUi={},e.React,e.KendoReactCommon,e.KendoReactButtons,e.KendoSvgIcons,e.KendoReactLayout,e.KendoReactIntl,e.PropTypes,e.KendoReactUpload,e.KendoReactAnimation,e.KendoReactNotification,e.KendoReactInputs,e.KendoReactPopup)}(this,function(e,t,n,a,l,s,o,r,i,c,u,m,d){"use strict";function g(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var p=g(t);const f="newMessage.sendButton",h="newMessage.optionsButton",v="newMessage.messageInput",k="avatar.alt",b="messageList.ariaLabel",y="aIPrompt.noOutputs",E="aIPrompt.cancel",C="chat.senderDeletedMessage",x="chat.receiverDeletedMessage",I="chat.copyNotification",T="chat.downloadAllFiles",F="chat.closeReply",w="chat.collapseMessage",S="chat.expandMessage",A="chat.removeFile",M="chat.fileActions",R="chat.attachFile",N="chat.downloadAll",B="chat.scrollLeft",L="chat.scrollRight",D="chat.scrollToBottom",P="chat.messageFailed",z="chat.retryMessage",O="chat.stopGenerating",q="promptBox.input",H="promptBox.sendButton",$="promptBox.attachFile",U="promptBox.removeFile",K="promptBox.stopGenerating",V="promptBox.ariaLabel",W="chat.messageToolbar",j={[f]:"Send",[h]:"Options",[v]:"Message",[k]:"Avatar",[b]:"Message list",[E]:"Cancel",[y]:"No output from AI available",[C]:"You removed this message",[x]:"The message was removed by its sender",[I]:"Text copied to clipboard",[T]:"Download all files",[F]:"Close reply",[w]:"Collapse message",[S]:"Expand message",[A]:"Remove file",[M]:"File actions for",[P]:"Failed to send",[z]:"Retry",[O]:"Stop generating",[R]:"Attach file",[N]:"Download all",[B]:"Scroll left",[L]:"Scroll right",[D]:"Scroll to bottom",[q]:"Prompt",[H]:"Send",[$]:"Attach file",[U]:"Remove file",[K]:"Stop generating",[V]:"Prompt box",[W]:"Toolbar"},G=(e,t)=>e&&t.author&&e.id===t.author.id,_=(e,t)=>{const n=t.toLanguageString("chatSender.deletedMessage",j[C]),a=t.toLanguageString("chatReceiver.deletedMessage",j[x]);return e?n:a},Y=(e,t)=>e.find(e=>e.id===t),X=/(https?:\/\/[^\s]+)/g,J=e=>{if(!e)return[""];const t=e.split(X),n=[];return t.forEach(e=>{e&&X.test(e)?(X.lastIndex=0,n.push(p.createElement("a",{key:e,href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"}},e))):e&&n.push(e)}),n},Q=p.createContext(void 0),Z=()=>{const e=t.useContext(Q);if(void 0===e)throw new Error("useChatContext must be used within a ChatContext.Provider");return e},ee=e=>{const{files:t,onFileAction:s,onDownload:r,fileActions:i}=e,{messageFilesLayout:c="vertical"}=Z(),u=o.useLocalization(),m=i||[{id:"download",label:"Download",svgIcon:l.downloadIcon}],d=e=>{if(null==e)return"";if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,t)).toFixed(2))} ${["B","KB","MB","GB","TB"][t]}`},g=e=>"."+e.split(".").pop()||"",f=e=>m.length>0&&p.createElement(a.DropDownButton,{fillMode:"flat",size:"small",svgIcon:l.moreVerticalIcon,onClick:e=>{e.syntheticEvent.stopPropagation()},onItemClick:t=>((e,t)=>{var n,a;null==(a=null==(n=e.syntheticEvent)?void 0:n.stopPropagation)||a.call(n),"download"===e.item.id&&(null==r||r([t])),null==s||s(e.item,e,t)})(t,e),items:m.map(e=>({id:e.id,icon:e.icon,text:e.label,svgIcon:e.svgIcon})),"aria-label":`${u.toLanguageString(M,j[M])} ${e.name}`,title:`${u.toLanguageString(M,j[M])} ${e.name}`}),h=p.useCallback(()=>n.classNames({"k-files-wrap":"wrap"===c,"k-files-vertical":"vertical"===c},"k-file-box-wrapper"),[c]);return p.createElement("ul",{className:h()},"horizontal"===c?p.createElement("div",{className:"k-files-scroll"},t.map(e=>p.createElement("li",{key:e.name,className:"k-file-box"},p.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(g(e.name))}),p.createElement("div",{className:"k-file-info"},p.createElement("span",{className:"k-file-name"},e.name),p.createElement("span",{className:"k-file-size"},d(e.size))),f(e)))):t.map(e=>p.createElement("li",{key:e.name,className:"k-file-box"},p.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(g(e.name))}),p.createElement("div",{className:"k-file-info"},p.createElement("span",{className:"k-file-name"},e.name),p.createElement("span",{className:"k-file-size"},d(e.size))),f(e))))},te=p.forwardRef((e,t)=>{const{item:r,template:i,contentTemplate:c,onRequestSelection:u,tabIndex:m=-1,dateFormat:d="g",selected:g,allowMessageCollapse:f,messageToolbarActions:h,messageContextMenuActions:v,fileActions:k,isSender:b}=e,{setReplyToMessage:y,messages:E,repliedToMessages:C,user:x,onToolbarAction:I,onContextMenuAction:F,onFileAction:A,onDownload:M,onResendMessage:R,setShowCopyNotification:B,statusTemplate:L,timestampVisibility:D="onFocus",onReferencedMessageClick:O}=Z(),[q,H]=p.useState(!1),[$,U]=p.useState(!1),[K,V]=p.useState(!0),[X,Q]=p.useState(!1),te=o.useLocalization(),ne=o.useInternationalization(),ae=p.useRef({left:0,top:0}),le=p.useCallback(()=>{null!=r&&r.text&&(e=>{navigator.clipboard.writeText(e)})(r.text),B&&(B(!0),setTimeout(()=>{B(!1)},3e3))},[r,B]),se=p.useCallback(e=>{e.stopPropagation(),V(e=>!e)},[]),oe=p.useCallback(()=>{Q(!1)},[]),re=p.useCallback(e=>{("Tab"===e.key||"Enter"===e.key||" "===e.key||"ArrowUp"===e.key||"ArrowDown"===e.key)&&Q(!0)},[]),ie=p.useRef(null);p.useEffect(()=>{g&&ie.current&&ie.current.focus()},[g]);const ce=p.useCallback(e=>{ae.current={left:e.pageX,top:e.pageY},e.preventDefault(),U(!0),H(!0)},[]),ue=p.useCallback(()=>{U(!1),H(!1)},[]),me=p.useCallback((e,t)=>e.isDeleted?_(t,te):e.text?e.text:"",[te]),de=p.useCallback(e=>{var t;null!=(t=e.item)&&t.text&&("copy"!==e.item.data.id||r.isDeleted?"reply"===e.item.data.id&&y(r):le(),F&&F(e.item.data,e,r)),U(!1),H(!1)},[r,F,y,le]),ge=p.useCallback(()=>{if(r.replyToId){const e=Y(E,r.replyToId)||(C?Y(C,r.replyToId):void 0);if(e){const t=t=>{t.preventDefault(),t.stopPropagation(),null==O||O(e.id)};return p.createElement("div",{className:n.classNames("k-message-reference",G(x,e)?"k-message-reference-sender":"k-message-reference-receiver"),onClick:t},p.createElement("div",{className:"k-message-reference-content"},J(me(e,G(x,e)))))}}return null},[r.replyToId,E,C,x,me,O]),pe=p.useCallback(()=>{const e=[{id:"reply",label:"Reply",svgIcon:l.undoIcon},{id:"copy",label:"Copy",svgIcon:l.copyIcon}],t=v?[...e.map(e=>v.find(t=>t.id===e.id)||e),...v.filter(t=>!e.some(e=>e.id===t.id))]:e;return p.createElement(s.ContextMenu,{onSelect:de,onClose:ue,vertical:!0,show:q,offset:ae.current},t.map(e=>"delete"!==e.id||b?p.createElement(s.MenuItem,{key:e.id,text:e.label,icon:e.icon,svgIcon:e.svgIcon,data:e}):null))},[v,de,ue,q,b]),fe=p.useCallback(()=>r.files&&r.files.length>1?p.createElement("div",{className:"k-chat-download-button-wrapper"},p.createElement(a.Button,{className:"k-chat-download-button",fillMode:"flat",svgIcon:l.downloadIcon,size:"small",onClick:e=>{e.stopPropagation(),M&&M(r.files,r)},"aria-label":te.toLanguageString(T,j[T])},p.createElement("span",{className:"k-button-text"},te.toLanguageString(N,j[N])))):null,[r,M,te]),he=p.useCallback(()=>{if(r.typing)return p.createElement("div",{className:"k-chat-bubble k-bubble"},p.createElement("div",{className:"k-bubble-content"},p.createElement("div",{className:"k-typing-indicator"},p.createElement("span",null),p.createElement("span",null),p.createElement("span",null))));if(i){const e=i;return p.createElement(p.Fragment,null,p.createElement(e,{item:r}),pe())}return r.text||r.files&&r.files.length>0?p.createElement(p.Fragment,null,p.createElement("div",{className:n.classNames("k-chat-bubble","k-bubble",{"k-bubble-expandable":f,"k-expanded":f&&K,"k-selected":g,"k-active":$}),onClick:()=>u(g?void 0:r.selectionIndex),onContextMenu:ce},p.createElement("div",{className:"k-bubble-content"},c?p.createElement(c,{item:r}):p.createElement(p.Fragment,null,(r.text||r.isDeleted||r.replyToId)&&p.createElement("span",{className:"k-chat-bubble-text"},!r.isDeleted&&ge(),J(me(r,G(x,r)))),r.files&&r.files.length>0&&p.createElement(ee,{files:r.files,message:r,onFileAction:A,onDownload:e=>null==M?void 0:M(e,r),renderInTextarea:!1,fileActions:k}),fe())),f&&p.createElement("span",{className:"k-bubble-expandable-indicator",onClick:se,role:"button","aria-label":K?te.toLanguageString(w,j[w]):te.toLanguageString(S,j[S]),tabIndex:0,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),se(e))}},p.createElement(n.IconWrap,{icon:K?l.chevronUpIcon:l.chevronDownIcon,size:"medium"}))),pe()):null},[r,i,c,f,K,g,$,u,ce,ge,me,x,A,k,fe,se,te,pe,M]),ve=p.useCallback(()=>{let e=null;return r.timestamp&&("hidden"===D||(e=p.createElement("time",{className:"k-message-time"},ne.formatDate(r.timestamp,d)))),e},[r.timestamp,d,D,ne]),ke=p.useCallback(()=>{if(!r.status)return null;let e;if(L)e=p.createElement(L,{item:r});else{let t,a,l;if("object"==typeof r.status&&null!==r.status){const e=r.status;t=e.text,a=e.icon,l=e.svgIcon}else t=r.status;let s=null;a?s=p.createElement(n.Icon,{name:a,size:"xsmall"}):l&&(s=p.createElement(n.IconWrap,{icon:l,size:"xsmall"})),e=p.createElement(p.Fragment,null,s,t)}return p.createElement("span",{className:"k-message-status"},e)},[r,L]),be=p.useCallback(()=>{let e=null;if(r.isFailed){const t=te.toLanguageString(P,j[P]);e=p.createElement("span",{className:"k-message-failed-content"},p.createElement(n.IconWrap,{icon:l.warningTriangleIcon,size:"xsmall"}),p.createElement("span",{className:"k-message-failed-text"},t))}return e},[r,te]),ye=p.useCallback(()=>{let e=null;if(r.isFailed){const t=te.toLanguageString(z,j[z]);e=p.createElement(a.Button,{fillMode:"clear",size:"xs",className:"k-resend-button",svgIcon:l.arrowRotateCwIcon,"aria-label":t,title:t,onClick:e=>{e.stopPropagation(),R&&R({message:r,syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.target})}})}return e},[r,te,R]),Ee=p.useCallback(()=>n.classNames({"k-focus":g,"k-message-removed":r.isDeleted,"k-message-failed":r.isFailed},"k-message"),[g,r.isDeleted,r.isFailed]),Ce=p.useCallback(()=>h&&h.length>0&&p.createElement(a.Toolbar,{className:"k-chat-message-toolbar",fillMode:"flat",ariaLabel:te.toLanguageString(W,j[W])},h.map(e=>"delete"!==e.id||b?p.createElement(a.Button,{key:e.id,fillMode:"flat",className:"k-toolbar-button",icon:e.icon,svgIcon:e.svgIcon,"aria-label":e.label,onClick:t=>{t.stopPropagation(),"copy"!==e.id||r.isDeleted?"reply"===e.id&&y(r):le(),I&&I(e,t,r)},onMouseDown:e=>e.preventDefault()}):null)),[le,b,r,te,h,I,y]);return p.createElement("div",{key:r.id,"data-message-id":r.id,className:Ee(),tabIndex:m,onMouseDown:oe,onKeyDown:re,onFocus:e=>{X&&u(r.selectionIndex)},ref:e=>{ie.current=e,"function"==typeof t?t(e):t&&(t.current=e)},onContextMenu:i?ce:void 0},ye(),he(),(r.status||r.timestamp&&"hidden"!==D||r.isFailed)&&p.createElement("div",{className:"k-message-info"},ke(),ve(),be()),Ce())});te.displayName="ChatMessage";const ne=e=>e[e.length-1],ae=e=>(t,n,a)=>{const l=a===e-1;return((e,t)=>{const n=t.timestamp,a=ne(e);if(n&&(!a||((e,t)=>e&&t&&(t.getDate()!==e.getDate()||t.getMonth()!==e.getMonth()||t.getFullYear()!==e.getFullYear()))(n,a.timestamp))){const t={type:"date-marker",timestamp:n,trackBy:n.getTime()};e.push(t)}})(t,n),((e,t,n)=>{const a=ne(e);let l;t.typing&&!n||(a&&"message-group"===a.type&&(l=a.messages),l&&G(t.author,ne(l))?l.push(t):e.push({type:"message-group",messages:[t],author:t.author,timestamp:t.timestamp,trackBy:t}))})(t,n,l),n.attachments&&n.attachments.length>1&&t.push({type:"attachment-group",attachments:n.attachments,attachmentLayout:n.attachmentLayout,timestamp:n.timestamp,trackBy:n}),n.suggestedActions&&l&&t.push({type:"action-group",actions:n.suggestedActions,timestamp:n.timestamp,trackBy:n}),t};const le=e=>{const{item:t,onActionExecute:a,selected:l}=e,s=p.useRef(null);p.useEffect(()=>{l&&s.current&&s.current.focus()},[l]);const o=p.useCallback(e=>{(e.keyCode===n.Keys.enter||" "===e.key)&&(e.preventDefault(),a(t,e))},[a,t]),r=p.useCallback(()=>n.classNames("k-suggestion k-suggestion-primary",{"k-selected":l},{"k-focus":l}),[l]);return p.createElement("span",{role:"button",className:r(),onClick:e=>a(t,e),ref:s,onKeyDown:o,tabIndex:0,"aria-label":t.title||t.value},t.title||t.value)},se=({visible:e,dir:t,canScrollLeft:n,canScrollRight:s,onScrollLeft:r,onScrollRight:i,children:c})=>{const u=o.useLocalization();if(!e)return c;const m=u.toLanguageString(B,j[B]),d=u.toLanguageString(L,j[L]),g="rtl"!==t?m:d,f="rtl"!==t?d:m;return p.createElement("div",{className:"k-suggestion-scrollwrap"},p.createElement(a.Button,{fillMode:"flat",size:"small",svgIcon:"rtl"===t?l.chevronRightIcon:l.chevronLeftIcon,onClick:r,disabled:!n,"aria-label":g,title:g}),c,p.createElement(a.Button,{fillMode:"flat",size:"small",svgIcon:"rtl"===t?l.chevronLeftIcon:l.chevronRightIcon,onClick:i,disabled:!s,"aria-label":f,title:f}))},oe=100,re=(e,t)=>{const{enabled:n,dir:a,mode:l,itemsDependency:s=[],scrollSpeed:o=oe}=t,[r,i]=p.useState(!1),[c,u]=p.useState(!1),m=p.useCallback(()=>{if(e.current&&n){const{scrollLeft:t,scrollWidth:n,clientWidth:l}=e.current,s="rtl"!==a?t+l>=n-1:l-t>=n-1;i(!(0===t)),u(!s)}},[n,a]),d=p.useCallback(()=>{e.current&&n&&e.current.scrollBy({left:"rtl"!==a?-o:o,behavior:"smooth"})},[n,a,o]),g=p.useCallback(()=>{e.current&&n&&e.current.scrollBy({left:"rtl"!==a?o:-o,behavior:"smooth"})},[n,a,o]);return p.useEffect(()=>{const t=e.current;if(!t||!n)return;m();const a=()=>m();t.addEventListener("scroll",a,{passive:!0});const l=new ResizeObserver(m);return l.observe(t),()=>{t.removeEventListener("scroll",a),l.disconnect()}},[n,m,s.length,l]),p.useLayoutEffect(()=>{n&&m()},[n,a,s]),{canScrollLeft:r,canScrollRight:c,scrollLeft:d,scrollRight:g}},ie=e=>{var t,a;const{group:l,onActionExecute:s,selected:o,onRequestSelection:r,quickActionsLayout:i="scroll",dir:c}=e,[u,m]=p.useState(null),d=p.useRef(null),{canScrollLeft:g,canScrollRight:f,scrollLeft:h,scrollRight:v}=re(d,{enabled:"scrollbuttons"===i||"scroll"===i,dir:c,mode:i,itemsDependency:l.actions});p.useEffect(()=>{o||null===u?o&&null===u&&m(0):m(null)},[o,u]);const k=p.useCallback(()=>l.actions?l.actions.length-1:-1,[l.actions]),b=p.useCallback((e,t=0)=>{let n=null;return e?null===u?n=t:u<k()&&(n=u+1):null===u?n=0:u>0&&(n=u-1),null!==n&&m(n),n},[u,k]),y=p.useCallback(()=>{r(l.selectionIndex)},[r,l.selectionIndex]),E=p.useCallback(e=>{let t=null;const a=n.Keys.left,l=n.Keys.right;e.keyCode===a?t=b(!1):e.keyCode===l&&(t=b(!0)),null!==t&&(e.preventDefault(),e.stopPropagation())},[b]),C=p.useCallback(()=>n.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":"scroll"===i,"k-suggestion-group-scrollable-start":f&&("scroll"===i||"scrollbuttons"===i),"k-suggestion-group-scrollable-end":g&&("scroll"===i||"scrollbuttons"===i)}),[i,f,g]),x="scroll"===i||"scrollbuttons"===i,I=p.createElement("div",{className:C(),onClick:y,onKeyDown:E,role:"toolbar",tabIndex:0,"aria-label":"Action group"},x?p.createElement("div",{className:"k-suggestions-scroll",ref:d},null==(t=l.actions)?void 0:t.map((e,t)=>p.createElement(le,{item:e,onActionExecute:s,selected:t===u,key:e.value}))):null==(a=l.actions)?void 0:a.map((e,t)=>p.createElement(le,{item:e,onActionExecute:s,selected:t===u,key:e.value})));return p.createElement(se,{visible:"scrollbuttons"===i,dir:c,canScrollLeft:g,canScrollRight:f,onScrollLeft:h,onScrollRight:v},I)},ce=e=>{const{item:t,template:a,tabbable:l,onClick:s,selected:o}=e,r=p.useRef(null);p.useEffect(()=>{o&&r.current&&r.current.focus()},[o]);const i=p.useCallback(()=>{if(void 0!==l)return l?0:-1},[l]),c=p.useCallback(()=>n.classNames({"k-selected":o},{"k-focus":o}),[o]),u=p.useCallback(()=>t.title?p.createElement("h5",{className:"k-card-title"},t.title):null,[t.title]),m=p.useCallback(()=>t.subtitle?p.createElement("h6",{className:"k-card-subtitle"},t.subtitle):null,[t.subtitle]),d=p.useCallback(()=>0===t.contentType.indexOf("image/")?p.createElement("img",{src:t.content,alt:t.title||"Attachment",style:{maxHeight:"200px",height:"auto",maxWidth:"200px",width:"auto"}}):t.content,[t.contentType,t.content,t.title]),g=a;return p.createElement("div",{className:c(),tabIndex:i(),onClick:s,ref:r},a?p.createElement(g,{item:t}):p.createElement("div",{className:"k-card"},p.createElement("div",{className:"k-card-body"},u(),m(),d())))},ue=e=>{const{group:t,itemTemplate:s,selected:o,isLastGroup:r,onRequestSelection:i}=e,[c,u]=p.useState(null);p.useEffect(()=>{o||null===c?o&&null===c&&u(0):u(null)},[o,c]);const m=p.useCallback(e=>"list"!==e.attachmentLayout,[]),d=p.useCallback(()=>t.attachments?t.attachments.length-1:-1,[t.attachments]),g=p.useCallback(()=>t.attachments.length-1,[t.attachments]),f=p.useCallback((e,t=0)=>{let n=null;return e?null===c?n=t:c<d()&&(n=c+1):null===c?n=0:c>0&&(n=c-1),null!==n&&u(n),n},[c,d]),h=p.useCallback(()=>{i(t.selectionIndex)},[i,t.selectionIndex]),v=p.useCallback(e=>{let a,l,s=null;m(t)?(a=n.Keys.left,l=n.Keys.right):(a=n.Keys.up,l=n.Keys.down),e.keyCode===a?s=f(!1):e.keyCode===l&&(s=f(!0)),null!==s&&(e.preventDefault(),e.stopPropagation())},[f,m,t]),k=p.useCallback(e=>{h(),u(e)},[h]),b=p.useCallback(e=>{h(),f(e,1)},[h,f]),y=p.useCallback(()=>{let e=null;return m(t)&&c&&(e=p.createElement(a.Button,{icon:"chevron-left",onClick:()=>b(!1),svgIcon:l.chevronLeftIcon})),e},[m,t,c,b]),E=p.useCallback(()=>{let e=null;return m(t)&&c!==g()&&(e=p.createElement(a.Button,{icon:"chevron-right",onClick:()=>b(!0),svgIcon:l.chevronRightIcon})),e},[m,t,c,g,b]),C=p.useCallback(()=>n.classNames({"k-card-list":t.attachmentLayout,"k-card-deck":m(t)}),[t.attachmentLayout,t,m]),x=m(t),I=p.createElement("div",{className:C(),onKeyDown:x?void 0:v},t.attachments.map((e,t)=>p.createElement(ce,{item:e,template:s,selected:t===c,tabbable:r&&t===c,onClick:()=>k(t),key:e.content})));return x?p.createElement("div",{className:"k-card-deck-scrollwrap",onKeyDown:v},y(),I,E()):I},me=({item:e,timestampTemplate:t})=>{const n=o.useInternationalization(),a=t;return p.createElement("div",{className:"k-timestamp"},a?p.createElement(a,{item:e}):n.formatDate(e.timestamp,"D"))},de=e=>{const{group:t,user:a,itemTemplate:l,contentTemplate:r,attachmentTemplate:i,onRequestSelection:c,selectedItemIndex:u,isLastGroup:m,message:d,allowMessageCollapse:g,messageToolbarActions:f,messageContextMenuActions:h,fileActions:v,messageWidthMode:b="standard",showAvatar:y=!0,showUsername:E=!0}=e,{userStatusTemplate:C}=Z(),x=o.useLocalization(),I=t.messages.length>0&&G(a,t.messages[0]),{avatarUrl:T,avatarAltText:F,name:w}=t.author,S=p.useMemo(()=>n.classNames("k-message-group",{"k-message-group-sender":I,"k-message-group-receiver":!I,"k-message-group-full-width":"full"===b,"k-no-avatar":!y||!T}),[I,b,y,T]),A=p.useMemo(()=>{const e=t.messages.length-1;return t.messages.map((t,n)=>{const s=[p.createElement(d,{item:t,template:l,contentTemplate:r,selected:t.selectionIndex===u,onRequestSelection:c,tabIndex:n===e&&m?0:-1,key:t.id,allowMessageCollapse:g,messageToolbarActions:f,messageContextMenuActions:h,fileActions:v,isSender:G(a,t)})];return t.attachments&&1===t.attachments.length&&s.push(p.createElement(ce,{item:t.attachments[0],template:i,selected:!1,key:`att-${t.attachments[0].content}`})),s})},[t.messages,d,l,r,u,c,m,g,f,h,v,a,i]),M=void 0!==F?F:x.toLanguageString(k,j[k]);return p.createElement("div",{className:S},(()=>{if(!y||!T)return;const e=p.createElement(s.Avatar,{type:"image"},p.createElement("img",{src:T,alt:M}));if(C){const n=t.messages[t.messages.length-1];return p.createElement("div",{className:"k-chat-user-status-wrapper"},e,p.createElement("div",{className:"k-chat-user-status"},p.createElement(C,{message:"dataItem"in n?n.dataItem:n})))}return e})(),p.createElement("div",{className:"k-message-group-content"},E&&p.createElement("span",{className:"k-message-author"},w),A))},ge=e=>{const{suggestions:t,onSuggestionClick:a,suggestionsView:l,suggestionTemplate:s,suggestionsLayout:o,dir:r}=e,i=p.useRef(null),{canScrollLeft:c,canScrollRight:u,scrollLeft:m,scrollRight:d}=re(i,{enabled:"scrollbuttons"===o||"scroll"===o,dir:r,mode:o,itemsDependency:t}),g=p.useCallback((e,t)=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),null==a||a(t))},[a]),f=p.useCallback(()=>t.map(e=>s?p.createElement(s,{key:e.id,suggestion:e,onClick:()=>{null==a||a(e)}}):p.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:()=>!e.disabled&&(null==a?void 0:a(e)),onKeyDown:t=>!e.disabled&&g(t,e),key:e.id,title:e.description,className:n.classNames("classic"===l?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},e.text)),[t,s,a,l,g]);if(!t||0===t.length)return null;if("classic"===l)return f();const h="scroll"===o||"scrollbuttons"===o,v=p.createElement("div",{role:"group",className:n.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":"scroll"===o,"k-suggestion-group-scrollable-start":u&&("scroll"===o||"scrollbuttons"===o),"k-suggestion-group-scrollable-end":c&&("scroll"===o||"scrollbuttons"===o)})},h?p.createElement("div",{className:"k-suggestions-scroll",ref:i},f()):f());return p.createElement(se,{visible:"scrollbuttons"===o,dir:r,canScrollLeft:c,canScrollRight:u,onScrollLeft:m,onScrollRight:d},v)},pe=p.forwardRef(({onFilesAdd:e,files:t=[],restrictions:n,multiple:l=!0,accept:s,uploadRef:o,onSelectAttachments:r,onRemoveAttachment:c,_registerRemoveCallback:u,...m},d)=>{p.useEffect(()=>(u&&c&&u(c),()=>{u&&c&&u(void 0)}),[c,u]);const g=p.useCallback(t=>{e&&e(t),r&&r({selectedFiles:t.affectedFiles,allFiles:t.newState})},[e,r]);return p.createElement(p.Fragment,null,p.createElement(a.Button,{ref:d,...m}),p.createElement(i.Upload,{ref:o,files:t,onAdd:g,autoUpload:!1,restrictions:n,multiple:l,accept:s,className:"k-hidden"}))});pe.displayName="PromptBoxUploadButton";const fe=p.forwardRef((e,t)=>p.createElement(a.Button,{ref:t,...e}));fe.displayName="PromptBoxActionButton";const he=p.forwardRef((e,t)=>p.createElement(a.SpeechToTextButton,{ref:t,...e}));he.displayName="PromptBoxSpeechToTextButton";const ve=e=>"."+e.split(".").pop()||"",ke=({files:e,onRemoveFile:t,header:s})=>{const r=o.useLocalization(),i=p.useRef(null),[c,u]=p.useState(!1),[m,d]=p.useState(!1),g=p.useCallback(()=>{const e=i.current;if(!e)return;const{scrollLeft:t,scrollWidth:n,clientWidth:a}=e,l=t+a>=n-1;d(!(0===t)),u(!l)},[]);if(p.useLayoutEffect(()=>{g()},[e,g]),p.useEffect(()=>{const e=i.current;if(!e)return;const t=()=>g(),n=new ResizeObserver(g);return n.observe(e),e.addEventListener("scroll",t,{passive:!0}),()=>{e.removeEventListener("scroll",t),n.disconnect()}},[g,e.length]),0===e.length&&!s)return null;const f=(e=>e?"function"==typeof e?e():e:null)(s),h=e.length>0&&p.createElement("ul",{className:n.classNames("k-file-box-wrapper",{"k-file-box-wrapper-scrollable-start":c,"k-file-box-wrapper-scrollable-end":m})},p.createElement("div",{className:"k-files-scroll",ref:i},e.map(e=>p.createElement("li",{key:e.name,className:"k-file-box"},p.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(ve(e.name))}),p.createElement("div",{className:"k-file-info"},p.createElement("span",{className:"k-file-name"},e.name),p.createElement("span",{className:"k-file-size"},(e=>{if(null==e)return"";if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,t)).toFixed(2))} ${["B","KB","MB","GB","TB"][t]}`})(e.size))),p.createElement(a.Button,{fillMode:"flat",size:"xs",svgIcon:l.xCircleIcon,onClick:n=>{n.stopPropagation(),t(e.name)},"aria-label":`${r.toLanguageString(U,j[U])} ${e.name}`,title:`${r.toLanguageString(U,j[U])} ${e.name}`})))));return p.createElement("div",{className:"k-prompt-box-header"},f,h)},be=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"15.2.0-develop.1",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning"}),ye="k-prompt-box",Ee={mode:"auto",rows:1,defaultValue:"",disabled:!1,readOnly:!1,loading:!1,uploadButtonConfig:!1,speechToTextButtonConfig:!0,actionButtonConfig:!0},Ce=p.forwardRef((e,t)=>{const a=!n.validatePackage(be,{component:"PromptBox"}),s=n.getLicenseMessage(be),r=o.useLocalization(),i={...Ee,...e},{mode:c=Ee.mode,fillMode:u,rows:m=Ee.rows,maxTextAreaHeight:d,value:g,defaultValue:f=Ee.defaultValue,disabled:h=Ee.disabled,readOnly:v=Ee.readOnly,placeholder:k,title:b,maxLength:y,inputAttributes:E,topAffix:C,startAffix:x,endAffix:I,header:T,onChange:F,onFocus:w,onBlur:S,onPromptAction:A,attachments:M,loading:R=Ee.loading,uploadButtonConfig:N=Ee.uploadButtonConfig,speechToTextButtonConfig:B=Ee.speechToTextButtonConfig,actionButtonConfig:L=Ee.actionButtonConfig,className:D,style:P,...z}=i,O=p.useRef(null),[U,V]=p.useState(f),[W,G]=p.useState([]),[_,Y]=p.useState(!1),X=p.useRef(null),J=p.useRef(null),Q=p.useRef(0),Z=p.useRef(0),ee=p.useRef(!1),te=p.useRef(0),ne=p.useRef(0),ae=p.useCallback((e,t)=>e?"function"==typeof e?e(t):e:null,[]),le=void 0!==g,se=le?g:U,oe=void 0!==M,re=oe?M:W,ie=p.useMemo(()=>!!(null!=se&&se.trim()||re.length>0),[se,re.length]),ce=p.useCallback(()=>{if(!O.current||"single"===c)return;const e=O.current,t=globalThis.getComputedStyle(e),n=Number.parseFloat(t.lineHeight)||20,a=Number.parseFloat(t.paddingTop)||0,l=Number.parseFloat(t.paddingBottom)||0;Q.current=e.offsetHeight||n+a+l,Z.current=n*m+a+l,"auto"===c&&!_&&(ne.current=e.offsetWidth)},[c,m,_]),ue=p.useCallback(()=>"auto"===c?1:m,[c,m]),me=p.useCallback(e=>{if(d){const t=Number.parseInt(d,10);if(e>t)return t}return Math.max(Z.current,e)},[d]),de=p.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${Q.current}px`;const t=e.scrollHeight,n=me(t);e.style.height=`${n}px`,d&&t>Number.parseInt(d,10)&&(e.style.overflow="")},[me,d]),ge=p.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${Q.current}px`;const t=e.scrollHeight,n=d?Math.min(t,Number.parseInt(d,10)):t;e.style.height=`${n}px`,d&&t>Number.parseInt(d,10)&&(e.style.overflow="")},[d]),ve=p.useCallback(e=>{if(ne.current<=0)return!1;const t=e.style.height,n=e.style.width;e.style.overflow="hidden",e.style.width=`${ne.current}px`,e.style.height=`${Q.current}px`;const a=e.scrollWidth<=ne.current&&e.scrollHeight<=Q.current;return e.style.overflow="",e.style.width=n||"",e.style.height=t||"",a},[]),Ce=p.useCallback((e,t)=>{if(!ee.current){if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!_)return ee.current=!0,void Y(!0);if(_){ge(e);t<te.current&&ve(e)&&(e.style.height="",ee.current=!0,Y(!1))}}},[_,ge,ve]),xe=p.useCallback(()=>{var e;if("single"===c||!O.current)return;const t=O.current,n=(null==(e=t.value)?void 0:e.length)||0;"multi"===c?de(t):"auto"===c&&Ce(t,n)},[c,de,Ce]);p.useEffect(()=>{"single"!==c&&O.current&&ce()},[c,ce]),p.useEffect(()=>{"single"!==c&&O.current&&(ce(),xe())},[m,c,ce,xe]),p.useEffect(()=>{if("single"!==c&&O.current){const e=(null==se?void 0:se.length)||0;requestAnimationFrame(()=>{if(O.current){const t=O.current;"multi"===c?de(t):"auto"===c&&Ce(t,e),te.current=e}})}},[se,c,de,Ce]),p.useEffect(()=>{"auto"===c&&_&&O.current&&requestAnimationFrame(()=>{if(O.current){const e=O.current;ge(e),ee.current=!1}})},[_,c,ge]),p.useEffect(()=>{if("auto"===c&&O.current){const e=O.current;_||(e.style.height="",e.style.overflow="",ee.current=!1)}},[c,_]),p.useEffect(()=>{if("single"===c||!O.current)return;const e=O.current;let t;const n=new ResizeObserver(()=>{clearTimeout(t),t=setTimeout(()=>{O.current&&("auto"===c&&!_&&ce(),xe())},50)});return n.observe(e),()=>{n.disconnect(),clearTimeout(t)}},[c,_,ce,xe]);const Ie=p.useCallback(()=>({focus:()=>{var e;return null==(e=O.current)?void 0:e.focus()},blur:()=>{var e;return null==(e=O.current)?void 0:e.blur()},element:O.current,get value(){return se}}),[se]);p.useImperativeHandle(t,Ie);const Te=p.useCallback(e=>{const t=e.target.value;!le&&!h&&V(t),F&&!h&&n.dispatchEvent(F,e,{...Ie(),value:t},{value:t}),"single"!==c&&xe()},[V,F,h,le,Ie,c,xe]),Fe=p.useCallback(e=>{w&&!h&&n.dispatchEvent(w,e,Ie(),void 0)},[w,h,Ie]),we=p.useCallback(e=>{S&&!h&&n.dispatchEvent(S,e,Ie(),void 0)},[S,h,Ie]),Se=p.useCallback(e=>{e.preventDefault()},[]),Ae=p.useCallback(e=>{A&&n.dispatchEvent(A,e,Ie(),{value:se,attachments:re}),le||V(""),oe||G([])},[A,Ie,se,re,le,oe]),Me=p.useCallback(e=>{if("Enter"!==e.key||!e.shiftKey){if("ArrowUp"===e.key||"ArrowDown"===e.key)return void e.stopPropagation();if("Enter"===e.key){if(e.preventDefault(),R)return;ie&&Ae(e)}}},[Ae,R,ie]),Re={disabled:h,readOnly:v,placeholder:k,title:b,maxLength:y,"aria-label":r.toLanguageString(q,j[q]),value:se,onKeyDown:Me,...E,onChange:Te,onFocus:Fe,onBlur:we,ref:O},Ne=p.useCallback(e=>{var t,a;const{isFinal:l,alternatives:s}=e;if(s.length>0){const e=s[0];if(l){const a=(null==(t=O.current)?void 0:t.value)||"",l=(a?`${a} `:"")+e.transcript;if(le||V(l),F&&!h){const e={target:O.current,currentTarget:O.current};n.dispatchEvent(F,e,{...Ie(),value:l},{value:l})}}}null==(a=O.current)||a.focus()},[le,F,h,Ie]),Be=p.useCallback(()=>{var e,t;null==(t=null==(e=X.current)?void 0:e.actionElement)||t.click()},[]),Le=p.useCallback(e=>{var t;const n=Array.from(e.affectedFiles),a="object"==typeof N&&N.onSelectAttachments;oe||G(e=>[...e,...n]),a&&a({selectedFiles:e.affectedFiles,allFiles:e.newState}),null==(t=O.current)||t.focus()},[N,oe]),De=p.useMemo(()=>({uploadButtonProps:{fillMode:"flat",svgIcon:l.paperclipIcon,size:"small",rounded:"full",onClick:Be,onFilesAdd:Le,files:re,uploadRef:X,"aria-label":r.toLanguageString($,j[$]),title:r.toLanguageString($,j[$]),_registerRemoveCallback:e=>{J.current=e}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:Ne},actionButtonProps:{rounded:"full",size:"small",svgIcon:R?l.stopIcon:l.arrowUpIcon,className:R?"k-generating":"",onClick:Ae,onMouseDown:Se,disabled:!R&&!ie,"aria-label":R?r.toLanguageString(K,j[K]):r.toLanguageString(H,j[H]),title:R?r.toLanguageString(K,j[K]):r.toLanguageString(H,j[H]),"aria-live":"polite"}}),[Ne,Le,re,Ae,Se,R,Be,r,ie]),Pe=p.useCallback(e=>{oe||G(t=>t.filter(t=>t.name!==e));const t="object"==typeof N&&N.onRemoveAttachment;t&&(J.current=t),J.current&&J.current(e)},[N,oe]),ze=()=>{const e=!1!==B,t=!1!==L,n=!1!==N,a="object"==typeof B?B:void 0,l="object"==typeof N?N:{},{restrictions:s,multiple:o=!0,accept:r,onSelectAttachments:i,onRemoveAttachment:c,...u}=l,m={restrictions:s,multiple:o,accept:r},d="object"==typeof L?L:void 0;return p.createElement(p.Fragment,null,n&&p.createElement(pe,{...De.uploadButtonProps,restrictions:m.restrictions,multiple:m.multiple,accept:m.accept,...u}),e&&p.createElement(he,{...De.speechToTextButtonProps,...a}),t&&p.createElement(fe,{...De.actionButtonProps,...d}))},Oe="multi"===c||"auto"===c&&_,qe=!1!==N||!1!==B||!1!==L,He=I||qe,$e=x||I||qe;return p.createElement("div",{...z,className:n.classNames(D,"k-input",ye,{[`k-input-${u}`]:u,"k-disabled":h,"k-prompt-box-singleline":"single"===c,"k-prompt-box-multiline":Oe}),style:P},p.createElement(ke,{files:re,onRemoveFile:Pe,header:T}),"single"===c?p.createElement("div",{className:`${ye}-content`},x&&p.createElement("div",{className:`${ye}-affix`},ae(x,De)),p.createElement("input",{...Re,className:n.classNames("k-input-inner",`${ye}-input`)}),He?p.createElement("div",{className:`${ye}-affix`},I&&ae(I,De),ze()):null):p.createElement("div",{className:`${ye}-content`},"multi"===c&&C&&p.createElement("div",{className:`${ye}-affix`},ae(C,De)),"auto"===c&&!_&&x&&p.createElement("div",{className:`${ye}-affix`},ae(x,De)),p.createElement("textarea",{...Re,className:n.classNames("k-input-inner",`${ye}-textarea`),rows:ue(),style:d?{maxHeight:d}:{},"aria-multiline":"true"}),"auto"===c&&!_&&He?p.createElement("div",{className:`${ye}-affix`},I&&ae(I,De),ze()):null,Oe&&$e?p.createElement("div",{className:`${ye}-affix`},x&&ae(x,De),(x||I)&&p.createElement("div",{className:"k-spacer"}),I&&ae(I,De),ze()):null),a&&p.createElement(n.WatermarkOverlay,{message:s}))});Ce.propTypes={value:r.string,defaultValue:r.string,mode:r.oneOf(["single","multi","auto"]),rows:r.number,maxTextAreaHeight:r.string,title:r.string,disabled:r.bool,readOnly:r.bool,placeholder:r.string,maxLength:r.number,inputAttributes:r.object,fillMode:r.oneOf(["solid","flat","outline"]),topAffix:r.oneOfType([r.func,r.element,r.string]),startAffix:r.oneOfType([r.func,r.element,r.string]),endAffix:r.oneOfType([r.func,r.element,r.string]),header:r.oneOfType([r.func,r.element,r.string]),onChange:r.func,onFocus:r.func,onBlur:r.func,loading:r.bool,uploadButtonConfig:r.oneOfType([r.bool,r.object]),speechToTextButtonConfig:r.oneOfType([r.bool,r.object]),actionButtonConfig:r.oneOfType([r.bool,r.object]),attachments:r.array,onPromptAction:r.func,className:r.string,style:r.object},Ce.displayName="KendoPromptBox";const xe=p.memo(({affixProps:e,uploadConfig:t,localizationService:n,onFilesSelect:a,onFileRemove:l})=>{const s="object"==typeof t?t:{};return!1!==t?p.createElement(pe,{...e.uploadButtonProps,fillMode:"clear","aria-label":n.toLanguageString(R,j[R]),title:n.toLanguageString(R,j[R]),...s,onSelectAttachments:a,onRemoveAttachment:l}):null});xe.displayName="UploadButtonAffix";const Ie=p.forwardRef((e,t)=>{const{onSendMessage:s,isDirectionRightToLeft:r,placeholder:i,MessageBox:c,suggestions:u,onSuggestionClick:m,inputValue:d,onInputValueChange:g,suggestionTemplate:h,sendButtonConfig:k,onInputClick:b,suggestionsLayout:y,dir:E,messageBoxSettings:C,loading:x}=e,{replyToMessage:I,setReplyToMessage:T,user:w,speechToTextConfig:S,uploadConfig:A}=Z(),[M,R]=p.useState(""),[N,B]=p.useState([]),L=p.useRef(null),D=o.useLocalization(),P=void 0!==d,z=P?d:M,q=p.useCallback(()=>{null!==L.current&&L.current.focus()},[]);p.useEffect(()=>{I&&q()},[I,q]);const H=p.useCallback(e=>{if(e.preventDefault(),s){const t={id:"",author:w,text:z||"",timestamp:new Date,replyToId:I?I.id:void 0,files:N.map(e=>({name:e.name,size:e.size,type:e.extension,rawFile:e.getRawFile?e.getRawFile():e}))};T(null),s(t,e),B([]),P||R(""),g&&g(""),q()}},[s,z,w,I,N,T,g,q,P]);p.useImperativeHandle(t,()=>({focusInput:q}),[q]);const $=p.useCallback(e=>{B(t=>t.filter(t=>t.name!==e))},[]),U=p.useCallback((e,t)=>e.isDeleted?_(t,D):e.text,[D]),K=p.useCallback(()=>{if(I){const e=G(w,I);return p.createElement("div",{className:n.classNames("k-message-reference",e?"k-message-reference-sender":"k-message-reference-receiver")},p.createElement("div",{className:"k-message-reference-content"},U(I,e)),p.createElement("span",{className:"k-spacer"}),p.createElement(a.Button,{fillMode:"flat",size:"xs",svgIcon:l.xCircleIcon,onClick:()=>T(null),"aria-label":D.toLanguageString(F,j[F]),title:D.toLanguageString(F,j[F])}))}return null},[I,w,U,T,D]),V=p.useCallback(e=>{try{const t=Array.from(e.allFiles);B(t)}catch{}},[]),W=p.useCallback(e=>{const t=e.value;P||R(t),g&&g(t||"")},[P,g]),Y=p.useCallback(e=>{H(e.syntheticEvent)},[H]),X=p.useCallback(e=>e?"function"==typeof e?e():e:null,[]),J=p.useCallback(e=>p.createElement(p.Fragment,null,p.createElement(xe,{affixProps:e,uploadConfig:A,localizationService:D,onFilesSelect:V,onFileRemove:$}),X(null==C?void 0:C.startAffix)),[A,D,V,$,null==C?void 0:C.startAffix,X]),Q=p.useCallback(()=>X(null==C?void 0:C.endAffix),[null==C?void 0:C.endAffix,X]),ee=p.useCallback(()=>X(null==C?void 0:C.topAffix),[null==C?void 0:C.topAffix,X]),te=p.useMemo(()=>{const e="object"==typeof k?k:{},t=!1!==k&&{"aria-label":x?D.toLanguageString(O,j[O]):D.toLanguageString(f,j[f]),title:x?D.toLanguageString(O,j[O]):D.toLanguageString(f,j[f]),dir:r?"rtl":void 0,...e};return p.createElement(Ce,{header:K(),ref:L,placeholder:i,value:z,onChange:W,onPromptAction:Y,mode:(null==C?void 0:C.mode)||"multi",rows:(null==C?void 0:C.rows)||2,maxTextAreaHeight:(null==C?void 0:C.maxTextAreaHeight)||"110",loading:x,speechToTextButtonConfig:S,actionButtonConfig:t,attachments:N,startAffix:J,endAffix:null!=C&&C.endAffix?Q:void 0,topAffix:null!=C&&C.topAffix?ee:void 0,inputAttributes:{onClick:b,"aria-label":D.toLanguageString(v,j[v])}})},[i,z,W,Y,C,x,S,k,N,K,J,Q,ee,D,r,b]);return p.createElement("div",{className:"k-message-box-wrapper"},u&&u.length>0&&p.createElement(ge,{onSuggestionClick:m,suggestions:u,suggestionTemplate:h,suggestionsLayout:y,dir:E}),c?p.createElement(c,{messageInput:te}):te)});Ie.displayName="NewMessage";const Te=e=>p.createElement(a.Toolbar,{className:"k-chat-header",size:"small"},e.children),Fe=e=>{const{message:t,onUnpin:s,user:r,onReferencedMessageClick:i}=e,c=o.useLocalization(),u=p.useRef(null),m=r&&G(r,t),d=p.useCallback(e=>{e.preventDefault(),e.stopPropagation(),null==i||i(t.id)},[t.id,i]);return p.createElement("div",{ref:u,className:`k-message-reference ${m?"k-message-reference-sender":"k-message-reference-receiver"} k-message-pinned`,onClick:d},p.createElement(n.IconWrap,{icon:l.pinIcon}),p.createElement("div",{className:"k-message-reference-content"},t.isDeleted?r&&_(G(r,t),c):t.text),p.createElement("span",{className:"k-spacer"}),p.createElement(a.Button,{fillMode:"flat",size:"xs",svgIcon:l.xCircleIcon,onClick:e=>{e.stopPropagation(),null==s||s(t)}}))},we=e=>{const{show:t,text:n}=e;return p.createElement("div",{style:{position:"absolute",top:"90%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e3,pointerEvents:t?"auto":"none"}},p.createElement(c.Fade,null,t&&p.createElement(u.Notification,{type:{style:"inverse"},closable:!1},p.createElement("span",null,n))))},Se={textField:"text",statusField:"status",authorIdField:"authorId",authorNameField:"authorName",authorImageUrlField:"authorImageUrl",authorImageAltTextField:"authorImageAltText",idField:"id",timestampField:"timestamp",filesField:"files",attachmentsField:"attachments",replyToIdField:"replyToId",isDeletedField:"isDeleted",isPinnedField:"isPinned",typingField:"typing",suggestedActionsField:"suggestedActions",isFailedField:"isFailed"},Ae=(e,t={})=>{const n={...Se,...t};let a,l;a=e.author&&"object"==typeof e.author?{id:e.author.id||e.author[n.authorIdField]||e[n.authorIdField]||"",name:e.author.name||e.author[n.authorNameField]||e[n.authorNameField],avatarUrl:e.author.avatarUrl||e.author[n.authorImageUrlField]||e[n.authorImageUrlField],avatarAltText:e.author.avatarAltText||e.author[n.authorImageAltTextField]||e[n.authorImageAltTextField]}:{id:e[n.authorIdField]||e.authorId||"",name:e[n.authorNameField]||e.authorName,avatarUrl:e[n.authorImageUrlField]||e.authorImageUrl,avatarAltText:e[n.authorImageAltTextField]||e.authorImageAltText},l=e.timestamp?new Date(e.timestamp):e[n.timestampField]?new Date(e[n.timestampField]):new Date;const s={id:void 0!==e.id?e.id:e[n.idField],text:void 0!==e.text?e.text:e[n.textField]||"",author:a,timestamp:l,status:void 0!==e.status?e.status:e[n.statusField],attachments:void 0!==e.attachments?e.attachments:e[n.attachmentsField],attachmentLayout:e.attachmentLayout||"list",suggestedActions:void 0!==e.suggestedActions?e.suggestedActions:e[n.suggestedActionsField],isPinned:void 0!==e.isPinned?e.isPinned:e[n.isPinnedField]||!1,typing:void 0!==e.typing?e.typing:e[n.typingField],files:void 0!==e.files?e.files:e[n.filesField]||[],isFailed:void 0!==e.isFailed?e.isFailed:e[n.isFailedField]||!1};return e.pinnedAt&&(s.pinnedAt=new Date(e.pinnedAt)),e.pinnedBy&&(s.pinnedBy=e.pinnedBy),void 0!==e.replyToId?s.replyToId=e.replyToId:void 0!==e[n.replyToIdField]&&(s.replyToId=e[n.replyToIdField]),void 0!==e.isDeleted?s.isDeleted=e.isDeleted:void 0!==e[n.isDeletedField]&&(s.isDeleted=e[n.isDeletedField]),{...s,dataItem:e}},Me=(e,t={})=>Array.isArray(e)?e.map(e=>Ae(e,t)):[],Re=e=>e&&void 0!==e.id&&"string"==typeof e.text&&e.author&&"object"==typeof e.author&&void 0!==e.author.id&&(e.timestamp instanceof Date||"string"==typeof e.timestamp||"number"==typeof e.timestamp),Ne=e=>{e.scrollTop=e.scrollHeight-e.clientHeight},Be=({viewItemsWrapperRef:e,isKeyboardNavigationActiveRef:t,processedMessages:n,authorId:a,autoScrollThreshold:l,isEndless:s=!1,isOnLastBatch:o=!0,skipAutoScrollRef:r})=>{var i;const c=p.useRef(a),u=p.useRef(l),m=p.useRef(s),d=p.useRef(o);p.useEffect(()=>{c.current=a,u.current=l,m.current=s,d.current=o});const g=p.useRef(!1);p.useEffect(()=>{s||!e.current||0===n.length||g.current||(Ne(e.current),g.current=!0)},[e,s,n.length]);const f=p.useRef(void 0),h=p.useRef(0),v=p.useRef(!0),k=p.useRef(!0),b=p.useRef(!1),y=p.useRef(null),E=(n.length>0?null==(i=n.at(-1))?void 0:i.id:void 0)!==f.current,C=n.length>h.current;if(E||C){const t=e.current;k.current=!t||(e=>{const{scrollHeight:t,scrollTop:n,clientHeight:a}=e;return!(t>a)||t-n-a<=100})(t)}p.useEffect(()=>{var a,l;const s=n.length,o=s>0?null==(a=n[s-1])?void 0:a.id:void 0,i=f.current,g=h.current,p=v.current;if(f.current=o,h.current=s,v.current=!1,0===s)return;const E=e.current;if(!E||t.current)return;if(p||o===i)return void(!m.current&&(p||s>g)&&(Ne(E),b.current=!1,y.current=null));if(m.current&&!d.current)return;if(null!=r&&r.current)return void(r.current=!1);const C=n[s-1];if(void 0!==c.current&&void 0!==(null==(l=null==C?void 0:C.author)?void 0:l.id)&&String(C.author.id)===String(c.current))return E.scrollTo({top:E.scrollHeight-E.clientHeight,behavior:"smooth"}),b.current=!1,void(y.current=null);if(!k.current)return b.current=!1,void(y.current=null);const x=(e=>{const t=e.querySelectorAll(".k-message");return t.length>0?t[t.length-1]:null})(E);if(!x)return;const I=(e=>{const t=e.querySelector(".k-message-pinned");return t?t.offsetHeight:0})(E),T=Math.max(0,E.clientHeight-I),F=((e,t)=>{const n=null!=e?e:"20%";let a;if("number"==typeof n)a=n;else{const e=/^(-?\d+(?:\.\d+)?)%$/.exec(String(n));if(e)a=Number.parseFloat(e[1])/100*t;else{const e=Number.parseFloat(String(n));a=Number.isNaN(e)?.2*t:e}}return Math.min(a,t)})(u.current,T),w=x.getBoundingClientRect().top-E.getBoundingClientRect().top+E.scrollTop,S=Math.max(0,w-F-I),A=Math.max(0,E.scrollHeight-E.clientHeight),M=Math.min(S,A);M>E.scrollTop&&E.scrollTo({top:M,behavior:"smooth"}),y.current=S,b.current=!0},[n,e,t]),p.useEffect(()=>{const n=e.current;if(!n)return;let a=n.querySelectorAll(".k-message").length,l=n.scrollHeight,s=n.scrollTop;const o=()=>{const e=n.scrollTop;b.current&&e<s&&(b.current=!1,y.current=null),s=e},r=new MutationObserver(()=>{if(t.current)return;const e=n.querySelectorAll(".k-message").length,o=n.scrollHeight;if(e===a&&o>l&&b.current){const e=o-n.clientHeight,t=y.current,a=null===t?e:Math.min(e,t);a>n.scrollTop&&(n.scrollTop=a),s=n.scrollTop}a=e,l=o});return r.observe(n,{childList:!0,subtree:!0,characterData:!0}),n.addEventListener("scroll",o,{passive:!0}),()=>{r.disconnect(),n.removeEventListener("scroll",o)}},[e,t])},Le=["allowMessageCollapse","messageWidthMode","showAvatar","showUsername","messageTemplate","messageContentTemplate","messageToolbarActions","messageContextMenuActions","fileActions"];function De(e,t,n,a,l){const s=((e,t)=>{var n,a;return(null==(n=null==e?void 0:e.author)?void 0:n.id)===t||(null==(a=null==e?void 0:e.author)?void 0:a.id)===String(t)})(e,t)?a:l,o={};return Le.forEach(e=>{var t;o[e]=null!=(t=null==s?void 0:s[e])?t:null==n?void 0:n[e]}),o}const Pe=({scrollMode:e,processedMessages:t,total:n,pageSize:a=50,startIndex:l,endIndex:s,onLoadMoreMessages:o,onReferencedMessageClick:r,viewItemsWrapperRef:i,authorId:c})=>{const u=p.useRef(!1),m="endless"===e,d=null!=n?n:t.length,g=m&&t.length===d&&!u.current,f=m&&(t.length<d||u.current);f&&(u.current=!0);const[h,v]=p.useState(-1),[k,b]=p.useState(-1),y=p.useRef(h),E=p.useRef(k);y.current=h,E.current=k;const C=p.useRef(!1),x=p.useRef(0),I=p.useRef(0),T=p.useRef(0),F=p.useRef(!1),w=p.useRef(d),S=p.useRef(c);S.current=c;const A=p.useRef(!1),M=p.useRef(null),R=p.useRef(!1),N=p.useRef(!1),B=p.useRef(!0),L=p.useRef(d);p.useEffect(()=>{if(g){if(u.current)return void((-1===h||-1===k)&&(v(0),b(t.length)));if(-1===h||-1===k){const e=Math.max(0,t.length-a),n=t.length;v(e),b(n)}else if(k<t.length){const e=w.current;if(E.current>=e)b(t.length);else if(t.length>e&&t.slice(e).some(e=>{var t;return void 0!==(null==(t=e.author)?void 0:t.id)&&String(e.author.id)===String(S.current)})){const e=Math.max(0,t.length-a);v(e),b(t.length),R.current=!0}}w.current=d}},[g,t.length,a,h,k,d]);const D=null!=l?l:0,P=null!=s?s:t.length,z=p.useCallback(()=>{const e=i.current;e&&(x.current=e.scrollHeight,I.current=e.scrollTop,T.current=e.querySelectorAll("[data-message-id]").length)},[i]),O=p.useCallback(e=>{var t,n,a;((e,t,n=0)=>{if(!t)return;const a=t.querySelector(`[data-message-id="${e}"]`);if(!a)return;const l=t.querySelector(".k-message-list");if(l){const e=l.getBoundingClientRect().top,t=a.getBoundingClientRect().top,s=l.scrollTop+(t-e)-n;l.scrollTo({top:s,behavior:"smooth"})}else a.scrollIntoView({behavior:"smooth",block:"start"})})(e,null==(t=i.current)?void 0:t.closest(".k-chat"),(null==(a=null==(n=i.current)?void 0:n.querySelector(".k-message-pinned"))?void 0:a.offsetHeight)||0)},[i]);p.useLayoutEffect(()=>{if(!F.current)return;const e=i.current;if(!e)return void(F.current=!1);if(e.querySelectorAll("[data-message-id]").length<=T.current)return;const t=e.scrollHeight-x.current;t>0&&(e.scrollTop=I.current+t),F.current=!1,C.current=!1}),p.useLayoutEffect(()=>{if(!R.current)return;const e=i.current;e?k>=t.length&&k>0&&(R.current=!1,e.scrollTop=e.scrollHeight-e.clientHeight):R.current=!1});const q=p.useRef(!1);p.useLayoutEffect(()=>{if(!m||q.current)return;const e=i.current;e&&e.querySelector("[data-message-id]")&&(e.scrollTop=e.scrollHeight-e.clientHeight,q.current=!0)}),p.useEffect(()=>{if(!m)return;const e=i.current;if(!e)return;let n=e.scrollTop;const l=()=>{const{scrollTop:l,scrollHeight:s,clientHeight:r}=e,i=l<n,c=l>n;if(n=l,!C.current){if(i&&l<=100)if(g){const e=y.current;if(e>0){const t=Math.max(0,e-a);F.current=!0,z(),v(t),null==o||o({startIndex:t,endIndex:E.current})}}else if(f&&D>0){C.current=!0;const e=Math.max(0,D-a);F.current=!0,z(),null==o||o({startIndex:e,endIndex:P})}if(c&&s-l-r<=100)if(g){const e=E.current;if(e<t.length){const n=Math.min(t.length,e+a);N.current=!0,b(n),null==o||o({startIndex:y.current,endIndex:n})}}else if(f&&P<d){C.current=!0,N.current=!0;const e=Math.min(d,P+a);null==o||o({startIndex:D,endIndex:e})}}};return e.addEventListener("scroll",l,{passive:!0}),()=>e.removeEventListener("scroll",l)},[m,g,f,i,a,t.length,D,P,d,o]),p.useEffect(()=>{var e;const n=P>=d;if(!f)return L.current=d,void(B.current=n);const a=L.current,l=B.current;if(L.current=d,B.current=n,d>a&&!l&&n){const n=t[t.length-1];void 0!==S.current&&void 0!==(null==(e=null==n?void 0:n.author)?void 0:e.id)&&String(n.author.id)===String(S.current)&&(A.current=!0,N.current=!0)}},[f,d,P,t]),p.useEffect(()=>{!f||!A.current||(A.current=!1,C.current=!1,requestAnimationFrame(()=>{const e=i.current;e&&(e.scrollTop=e.scrollHeight-e.clientHeight)}))},[f,t,i]),p.useEffect(()=>{if(!f||null===M.current)return;const e=M.current,t=i.current;t&&t.querySelector(`[data-message-id="${e}"]`)&&(M.current=null,C.current=!1,requestAnimationFrame(()=>{O(e)}))},[f,t,i,O]),p.useEffect(()=>{f&&C.current&&!F.current&&(C.current=!1)},[f,D,P]);const H=p.useMemo(()=>{if(g){const e=Math.max(0,h),n=Math.min(t.length,k);if(e>=n){const e=Math.max(0,t.length-a);return t.slice(e)}return t.slice(e,n)}return t},[g,t,h,k,a]),$=p.useMemo(()=>!m||(g?k>=t.length:P>=d),[m,g,k,t.length,P,d]),U=p.useCallback(()=>{if(!m||$){const e=i.current;return void(e&&e.scrollTo({top:e.scrollHeight-e.clientHeight,behavior:"smooth"}))}if(!C.current)if(g){const e=Math.max(0,t.length-a);v(e),b(t.length),null==o||o({startIndex:e,endIndex:t.length}),requestAnimationFrame(()=>{const e=i.current;e&&(e.scrollTop=e.scrollHeight-e.clientHeight)})}else if(f){A.current=!0,F.current=!1,C.current=!0;const e=Math.max(0,d-a);null==o||o({startIndex:e,endIndex:d})}},[m,g,f,$,t.length,a,d,o,i]),K=p.useCallback(e=>{if(m){if(g){const n=i.current;if(null==n?void 0:n.querySelector(`[data-message-id="${e}"]`))O(e);else{if(C.current)return;const n=t.findIndex(t=>t.id===e||String(t.id)===String(e));if(n>=0){const l=Math.floor(a/2),s=Math.max(0,n-l),o=Math.min(t.length,s+a);C.current=!0,v(s),b(o),requestAnimationFrame(()=>{requestAnimationFrame(()=>{O(e),C.current=!1})})}}}else if(f){const t=i.current;if(null==t?void 0:t.querySelector(`[data-message-id="${e}"]`))O(e);else{if(C.current)return;M.current=e,F.current=!1,C.current=!0}}}else O(e);null==r||r({id:e})},[m,g,f,i,t,a,r,O]);return{renderedMessages:H,handleScrollToBottom:U,handleReferencedMessageClick:K,isEndless:m,isOnLastBatch:$,skipAutoScrollRef:N}},ze=p.forwardRef((e,t)=>{const{messages:s=[],messageTemplate:r,messageContentTemplate:i,attachmentTemplate:c,width:u,height:m,onSendMessage:d,onSuggestionClick:g,onInputValueChange:f,onActionExecute:h,dir:v,messageBox:k,placeholder:y,className:E,style:C,message:x=te,authorId:T,suggestions:F,suggestionTemplate:w,suggestionsLayout:S="scroll",quickActionsLayout:A="scroll",inputValue:M,headerTemplate:R,noDataTemplate:N,timestampTemplate:B,statusTemplate:L,userStatusTemplate:P,allowMessageCollapse:z,messageToolbarActions:O,messageContextMenuActions:q,fileActions:H,onUnpin:$,messageWidthMode:U,showAvatar:K,showUsername:V,timestampVisibility:W,authorMessageSettings:G,receiverMessageSettings:_,onToolbarAction:Y,onContextMenuAction:X,onFileAction:J,onDownload:Z,speechToTextConfig:ee,uploadConfig:ne,sendButtonConfig:le,messageFilesLayout:se,scrollToBottomButton:oe=!0,autoScrollThreshold:re,textField:ce,statusField:ge,authorIdField:pe,authorNameField:fe,authorImageUrlField:he,authorImageAltTextField:ve,idField:ke,timestampField:ye,filesField:Ee,attachmentsField:Ce,replyToIdField:xe,isDeletedField:Se,isPinnedField:Ae,typingField:Ne,suggestedActionsField:Le,isFailedField:ze,onResendMessage:Oe,messageBoxSettings:qe,loading:He,scrollMode:$e,total:Ue,pageSize:Ke,startIndex:Ve,endIndex:We,onLoadMoreMessages:je,pinnedMessages:Ge,repliedToMessages:_e,onReferencedMessageClick:Ye,...Xe}=e,Je=p.useRef(null);n.useWebMcpRegister("chat",Je,e,e.webMcp);const[Qe,Ze]=p.useState(null),[et,tt]=p.useState(!1),[nt,at]=p.useState(!1),[lt,st]=p.useState(null),[ot,rt]=p.useState(null),[it,ct]=p.useState(!1),ut=p.useRef(null),mt=p.useRef(null),dt=p.useRef(null),gt=p.useRef(null),pt=p.useRef(void 0),ft=p.useRef(!1),ht=p.useRef(null),vt=p.useRef(""),kt=p.useMemo(()=>{if(!s||0===s.length)return[];const e={textField:ce,statusField:ge,authorIdField:pe,authorNameField:fe,authorImageUrlField:he,authorImageAltTextField:ve,idField:ke,timestampField:ye,filesField:Ee,attachmentsField:Ce,replyToIdField:xe,isDeletedField:Se,isPinnedField:Ae,typingField:Ne,suggestedActionsField:Le,isFailedField:ze};return!Object.values(e).some(e=>void 0!==e)&&Re(s[0])?s.map(e=>({...e,timestamp:e.timestamp?new Date(e.timestamp):e.timestamp})):Me(s,e)},[s,ce,ge,pe,fe,he,ve,ke,ye,Ee,Ce,xe,Se,Ae,Ne,Le,ze]);p.useEffect(()=>{if(T===vt.current&&ht.current)rt(ht.current);else if(T&&kt.length>0){const e=kt.find(e=>e.author&&(e.author.id===T||e.author.id===String(T))),t=(null==e?void 0:e.author)||{id:T};ht.current=t,vt.current=T,rt(t)}},[T,kt]);const{renderedMessages:bt,handleScrollToBottom:yt,handleReferencedMessageClick:Et,isEndless:Ct,isOnLastBatch:xt,skipAutoScrollRef:It}=Pe({scrollMode:$e,processedMessages:kt,total:Ue,pageSize:Ke,startIndex:Ve,endIndex:We,onLoadMoreMessages:je,onReferencedMessageClick:Ye,viewItemsWrapperRef:dt,authorId:T}),Tt=p.useMemo(()=>bt.length>0?(e=>{const t=e.slice().reduce(ae(e.length),[]);return function(e){let t=0;e.forEach(e=>{"message-group"===e.type?e.messages.forEach(e=>{e.selectionIndex=t++}):("attachment-group"===e.type||"action-group"===e.type)&&(e.selectionIndex=t++)}),e.lastSelectionIndex=t-1}(t),t})(bt):[],[bt]),Ft=p.useMemo(()=>!n.validatePackage(be,{component:"Chat"}),[]),wt=n.getLicenseMessage(be),St=p.useMemo(()=>{if(Ge)return Ge.find(e=>e.isPinned);const e=kt.find(e=>e.isPinned);return e||void 0},[kt,Ge]),At=o.useLocalization();Be({viewItemsWrapperRef:dt,isKeyboardNavigationActiveRef:ft,processedMessages:bt,authorId:T,autoScrollThreshold:re,isEndless:Ct,isOnLastBatch:xt,skipAutoScrollRef:It});const Mt=(({elementRef:e})=>{const[t,n]=p.useState(!1);return p.useEffect(()=>{const t=e.current;if(!t)return;const a=()=>{n(t.scrollHeight>t.clientHeight)};a();const l=new ResizeObserver(a);l.observe(t);const s=new MutationObserver(()=>{requestAnimationFrame(a)});return s.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{l.disconnect(),s.disconnect()}},[e]),t})({elementRef:dt}),Rt=p.useCallback(()=>{clearTimeout(pt.current)},[]),Nt=p.useCallback(()=>{pt.current=window.setTimeout(()=>{Ze(null)},0)},[]),Bt=p.useCallback(e=>{Ze(e)},[]),Lt=p.useCallback(e=>{let t=null;const a=null!==Qe?Qe:Tt.lastSelectionIndex;e.keyCode===n.Keys.up?null===a?t=0:a>0&&(t=a-1):e.keyCode===n.Keys.down?null===a?t=0:a<Tt.lastSelectionIndex&&(t=a+1):e.keyCode===n.Keys.home?t=0:e.keyCode===n.Keys.end&&(t=Tt.lastSelectionIndex),null!==t&&(Ze(t),ft.current=!0,e.preventDefault())},[Qe,Tt]),Dt=p.useCallback((e,t,n)=>{var a;if(h&&h({action:{value:e.value,title:e.title,type:e.type},syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget}),!t.isDefaultPrevented()){switch(e.type){case"reply":d&&d({message:{id:"",author:ot,text:e.value,timestamp:new Date},syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget});break;case"call":window.open("tel:"+e.value);break;case"openUrl":window.open(e.value)}null==(a=gt.current)||a.focusInput()}},[h,d,ot]),Pt=p.useCallback(()=>n.classNames("k-chat",E,{"k-rtl":et}),[E,et]),zt=p.useCallback(()=>{const e=Tt.length-1;return Tt.map((t,n)=>{var a,l,s,o,u,m;if("date-marker"===t.type)return p.createElement(me,{item:t,key:t.trackBy,timestampTemplate:B});if("message-group"===t.type){const s={allowMessageCollapse:z,messageWidthMode:U,showAvatar:K,showUsername:V,messageTemplate:r,messageContentTemplate:i,messageToolbarActions:O,messageContextMenuActions:q,fileActions:H},o=De(null==(a=t.messages)?void 0:a[0],T,s,G,_);return p.createElement(de,{group:t,itemTemplate:o.messageTemplate,contentTemplate:o.messageContentTemplate,attachmentTemplate:c,user:ot,selectedItemIndex:Qe,onRequestSelection:Bt,isLastGroup:n===e,key:null!=(l=t.messages[0].id)?l:t.messages[0].selectionIndex,message:x,allowMessageCollapse:o.allowMessageCollapse,messageToolbarActions:o.messageToolbarActions,messageContextMenuActions:o.messageContextMenuActions,fileActions:o.fileActions,messageWidthMode:o.messageWidthMode,showAvatar:o.showAvatar,showUsername:o.showUsername})}return"attachment-group"===t.type?p.createElement(ue,{group:t,itemTemplate:c,onRequestSelection:Bt,selected:t.selectionIndex===Qe,isLastGroup:n===e,key:`att-${null!=(o=null==(s=t.trackBy)?void 0:s.id)?o:t.selectionIndex}`}):"action-group"===t.type?p.createElement(ie,{group:t,onActionExecute:Dt,onRequestSelection:Bt,selected:t.selectionIndex===Qe,key:`act-${null!=(m=null==(u=t.trackBy)?void 0:u.id)?m:t.selectionIndex}`,quickActionsLayout:A,dir:v}):null})},[Tt,B,r,i,c,ot,Qe,Bt,x,z,O,q,H,U,K,V,T,G,_,Dt,A,v]),Ot=p.useCallback(()=>R?"function"==typeof R?R():R:null,[R]),qt=p.useCallback(()=>N?"function"==typeof N?N():N:null,[N]);p.useEffect(()=>{const e=void 0!==v?"rtl"===v:ut.current&&"rtl"===getComputedStyle(ut.current).direction;tt(!!e)},[v]),p.useEffect(()=>()=>{clearTimeout(pt.current)},[]),p.useEffect(()=>{if(!oe||!dt.current)return;let e,t;const n=()=>{e=void 0;const n=dt.current;if(!n)return;const{scrollHeight:a,scrollTop:l,clientHeight:s}=n;!(a>s)||a-l-s<=100?(void 0!==t&&(clearTimeout(t),t=void 0),ct(!1)):null!=t||(t=setTimeout(()=>{t=void 0,ct(!0)},300))},a=()=>{void 0===e&&(e=requestAnimationFrame(n))},l=dt.current;l.addEventListener("scroll",a,{passive:!0});const s=new MutationObserver(a);return s.observe(l,{childList:!0,subtree:!0,characterData:!0}),()=>{l.removeEventListener("scroll",a),s.disconnect(),void 0!==e&&cancelAnimationFrame(e),void 0!==t&&clearTimeout(t)}},[oe]);const Ht=p.useMemo(()=>({replyToMessage:lt,setReplyToMessage:st,messages:kt,repliedToMessages:_e,user:ot,internalScrollContainerRef:mt,messageListScrollContainerRef:dt,onToolbarAction:Y,onContextMenuAction:X,onFileAction:J,setShowCopyNotification:at,onDownload:Z,onResendMessage:Oe,fileActions:H,speechToTextConfig:ee,uploadConfig:ne,statusTemplate:L,userStatusTemplate:P,messageFilesLayout:se,timestampVisibility:W,onReferencedMessageClick:Et}),[lt,st,kt,_e,ot,Y,X,J,at,Z,Oe,H,ee,ne,L,P,se,W,Et]);return p.createElement(Q.Provider,{value:Ht},p.createElement("div",{style:{width:u,height:m,position:"relative",overflow:"hidden",...C},onKeyDown:Lt,className:Pt(),ref:e=>{ut.current=e,mt.current=e,"function"==typeof t?t(e):t&&(t.current=e)},...Xe},void 0!==R&&p.createElement(Te,null,Ot()),p.createElement("div",{className:"k-message-list",onBlur:Nt,onFocus:Rt,role:"log","aria-label":At.toLanguageString(b,j[b]),"aria-live":"polite",ref:dt,style:{scrollBehavior:"auto"}},St&&p.createElement(Fe,{message:St,onUnpin:$,user:ot,onReferencedMessageClick:Et}),p.createElement("div",{className:n.classNames("k-message-list-content",{"k-message-list-content-empty":0===bt.length})},0===bt.length&&void 0!==N&&qt(),bt.length>0&&zt()),oe&&(it||!xt)&&p.createElement("div",{className:"k-chat-scroll-to-bottom-container"},p.createElement(a.FloatingActionButton,{svgIcon:l.arrowDownIcon,size:"small",themeColor:"base",rounded:"full",onClick:yt,"aria-label":At.toLanguageString(D,j[D]),title:At.toLanguageString(D,j[D])}))),Mt&&p.createElement("div",{className:"k-separator"}),p.createElement(Ie,{onSendMessage:(e,t)=>{d&&d({message:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})},onSuggestionClick:e=>{g&&g(e)},isDirectionRightToLeft:et,ref:gt,placeholder:y,MessageBox:k,suggestions:F,suggestionTemplate:w,inputValue:M,onInputValueChange:e=>{f&&f(e)},onInputClick:()=>{ft.current=!1},sendButtonConfig:le,suggestionsLayout:S,dir:v,messageBoxSettings:qe,loading:He}),p.createElement(we,{show:nt,text:At.toLanguageString(I,j[I])}),Ft&&p.createElement(n.WatermarkOverlay,{message:wt})))});ze.displayName="Chat",ze.propTypes={messages:r.arrayOf(r.object),user:r.object,messageTemplate:r.any,messageContentTemplate:r.any,attachmentTemplate:r.any,width:r.oneOfType([r.string,r.number]),style:r.object,onSendMessage:r.func,onActionExecute:r.func,dir:r.string,messageBox:r.any,noDataTemplate:r.oneOfType([r.element,r.func]),suggestionsLayout:r.oneOf(["scroll","wrap","scrollbuttons"]),quickActionsLayout:r.oneOf(["scroll","wrap","scrollbuttons"]),userStatusTemplate:r.elementType,messageFilesLayout:r.oneOf(["vertical","wrap","horizontal"]),showAvatar:r.bool,showUsername:r.bool,authorMessageSettings:r.object,receiverMessageSettings:r.object,scrollMode:r.oneOf(["scrollable","endless"]),total:r.number,pageSize:r.number,startIndex:r.number,endIndex:r.number,onLoadMoreMessages:r.func,pinnedMessages:r.arrayOf(r.object),repliedToMessages:r.arrayOf(r.object),onReferencedMessageClick:r.func};const Oe=e=>{const{activeView:t,toolbarItems:n,activeViewChange:l}=e;return p.createElement("div",{className:"k-prompt-header"},p.createElement(a.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},n.map(e=>p.isValidElement(e)?e:p.createElement(a.Button,{key:e.name,className:t===e.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>(e=>{null==l||l.call(null,e)})(e.name)},e.buttonText))))},qe={name:"Output view",buttonText:"Output",buttonIcon:l.commentIcon},He={name:"Commands view",buttonIcon:l.moreHorizontalIcon},$e={name:"Prompt view",buttonText:"Ask AI",buttonIcon:l.sparklesIcon},Ue=p.createContext([{},()=>{}]),Ke=()=>p.useContext(Ue),Ve=e=>{const{children:t}=e;return p.createElement("div",{className:"k-prompt-footer"},p.createElement("div",{className:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},t))},We=p.forwardRef((e,t)=>{const{children:n,streaming:s,onCancel:r}=e,i=o.useLocalization().toLanguageString(E,j[E]),[c]=Ke(),u=c.activeView===qe.name,m=s&&!u,d=p.useCallback(e=>{"Escape"===e.key&&s&&r&&(e.preventDefault(),r())},[s,r]);return p.createElement("div",{className:"k-prompt-content",ref:t,onKeyDown:d},m&&p.createElement(a.FloatingActionButton,{onClick:r,svgIcon:l.stopIcon,icon:"stop",size:"medium",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":i,title:i}),p.createElement("div",{className:"k-prompt-view"},n))});We.displayName="KendoReactAIPromptContent";const je=e=>{const[t]=Ke();return t.activeView===e.name?e.children:null},Ge=e=>{const[t,n]=p.useState(!0),{children:s,title:o}=e;return p.createElement("div",{className:"k-prompt-expander"},p.createElement(a.Button,{"aria-controls":e.id,fillMode:"flat",svgIcon:t?l.chevronUpIcon:l.chevronDownIcon,title:o,onClick:()=>n(!t),"aria-expanded":t},o),t&&p.createElement("div",{id:e.id,className:"k-prompt-expander-content"},s))},_e=e=>null==e?void 0:e.map(e=>p.createElement(s.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&_e(e.children))),Ye=({show:e=!1,anchor:t,onOpen:n,onClose:a,animate:l=!0,appendTo:s,popupOptions:o={},children:r,style:i})=>p.createElement(d.Popup,{show:e,anchor:t,style:i,animate:l,appendTo:s,onOpen:n,onClose:a,...o},r),Xe=({placeholder:e="Ask or generate content with AI...",promptValue:t,onMenuClick:s,promptInput:o=m.TextArea,generateButton:r,enableSpeechToText:i=!1,streaming:c=!1,commands:u,onPromptRequest:d,onPromptCancel:g})=>{const[f,h]=p.useState(t||""),[v,k]=n.useCustomComponent(r),[b,y]=n.useCustomComponent(o),E=o===m.TextArea||b===m.TextArea,C={svgIcon:c?l.stopIcon:l.paperPlaneIcon,active:(!!c).toString(),title:"Send Button","aria-label":"Send Button",disabled:!f.trim()&&!c,"aria-disabled":!f.trim()&&!c},x={placeholder:e,className:"!k-flex-row",...E?{autoSize:!0}:{},rows:1},I=u&&u.length>0,T=Object.keys(k).length>0?k:C,F=Object.keys(y).length>0?y:x,w=e=>{const{isFinal:t,alternatives:n}=e;if(t&&n.length>0){const e=n[0].transcript,t=(()=>{const t=f,n=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(n?" ":"")+e})();h(t)}},S=()=>{f.trim()&&d&&d(f.trim())};return p.createElement(b,{value:f,onChange:e=>{const t=e.target.value;h(t)},onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),S())},prefix:I||i?p.createElement(p.Fragment,null,p.createElement(m.InputPrefix,{className:"!k-align-items-start"},I&&p.createElement(a.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:l.menuIcon,onClick:s}),i&&p.createElement(a.SpeechToTextButton,{fillMode:"flat",..."object"==typeof i?{...i,onResult:i.onResult||w}:{onResult:w}})),p.createElement(m.InputSeparator,null)):void 0,suffix:p.createElement(m.InputSuffix,{className:"!k-align-items-start"},p.createElement(v,{className:n.classNames("k-prompt-send",{"k-generating":c,"k-active":c}),fillMode:"flat",onClick:c?g:S,...T})),...F})};e.AIPrompt=e=>{const t=p.useRef(null);n.useWebMcpRegister("aiprompt",t,e,e.webMcp);const a=!n.validatePackage(be,{component:"AIPrompt"}),l=n.getLicenseMessage(be),{activeView:s,toolbarItems:o,children:r,onActiveViewChange:i,onPromptRequest:c,onCommandExecute:u,style:m,dir:d,className:g,streaming:f,loading:h,onCancel:v,suggestionsView:k,...b}=e,y=o||[$e,qe],[E,C]=p.useState({activeView:s}),x={...E,activeView:s,streaming:f,loading:h,suggestionsView:null!=k?k:"classic",onCancel:v,onActiveViewChange:i,onPromptRequest:c,onCommandExecute:u};return p.createElement(Ue.Provider,{value:[x,e=>{C(e)}]},p.createElement("div",{className:n.classNames("k-prompt",g),style:m,dir:d,...b},p.createElement(Oe,{activeView:x.activeView,toolbarItems:y,activeViewChange:i}),r,a&&p.createElement(n.WatermarkOverlay,{message:l})))},e.AIPromptCommandsView=e=>{const{commands:t}=e,[n]=Ke();return p.createElement(je,{name:He.name},p.createElement(We,{streaming:n.streaming,onCancel:n.onCancel},p.createElement("div",{className:"k-prompt-view"},p.createElement(s.PanelBar,{onSelect:e=>{var t,a,l;const s=null==(a=null==(t=e.target)?void 0:t.props)?void 0:a.data;null!=(l=null==s?void 0:s.children)&&l.length||n.onCommandExecute&&n.onCommandExecute.call(null,s)},selected:""},_e(null!=t?t:[])))))},e.AIPromptContent=We,e.AIPromptFooter=Ve,e.AIPromptOutputView=e=>{const[t,n]=p.useState(""),r=p.useRef(null),[i]=Ke(),{outputs:c,showOutputRating:u,outputCard:m}=e,{header:d,body:g,actions:f}=m||{},h=o.useLocalization(),v=h.toLanguageString(E,j[E]),k=(e,t)=>{i.onPromptRequest&&i.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),b()},b=()=>{r&&r.current&&r.current.scrollTo({top:0,behavior:"smooth"})},C=p.createElement(s.Card,null,p.createElement(s.CardHeader,null,p.createElement(s.CardTitle,null,p.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),p.createElement(s.CardSubtitle,null,p.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),p.createElement(s.CardBody,null,p.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),p.createElement(s.CardActions,null,i.streaming&&i.onCancel?p.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:l.stopIcon,title:v,onClick:i.onCancel},v):p.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),x=(e,s)=>f?f(e):s&&i.onCancel?p.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:l.stopIcon,title:v,onClick:i.onCancel},v):p.createElement(p.Fragment,null,p.createElement(a.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:t===e.id?l.checkIcon:l.copyIcon,onClick:()=>(e=>{e.responseContent&&navigator.clipboard.writeText(e.responseContent),n(e.id),setTimeout(()=>{n("")},1e3)})(e)},"Copy"),p.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:l.arrowRotateCwIcon,onClick:()=>(e=>{i.onPromptRequest&&i.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),b()})(e)},"Retry"),u&&p.createElement(p.Fragment,null,p.createElement("span",{className:"k-spacer"}),p.createElement(a.Button,{size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:l.thumbUpIcon,onClick:()=>k(e,"positive")}),p.createElement(a.Button,{size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:l.thumbDownIcon,onClick:()=>k(e,"negative")}))),I=null==c?void 0:c.map((e,t)=>{const n=!(!i.streaming||i.loading||0!==t);return p.createElement(s.Card,{key:`${e.id}_${t}`},p.createElement(s.CardHeader,null,d?d(e):p.createElement(p.Fragment,null,e.title&&p.createElement(s.CardTitle,null,e.title),e.subTitle&&p.createElement(s.CardSubtitle,null,e.subTitle))),p.createElement(s.CardBody,null,g?g(e):e.responseContent),p.createElement(s.CardActions,null,x(e,n)))}),T=p.createElement(s.Card,null,p.createElement(s.CardBody,null,h.toLanguageString(y,j[y])));return p.createElement(je,{name:qe.name},p.createElement(We,{ref:r,streaming:i.streaming,onCancel:i.onCancel},p.createElement("div",{className:"k-card-list"},i.loading&&C,I,(!I||0===I.length)&&!i.loading&&T)))},e.AIPromptView=e=>{const{promptInput:t=m.TextArea,generateButton:s=a.Button,enableSpeechToText:o=!1,promptValue:r,promptSuggestions:i}=e,[c,u]=p.useState(r||""),[d]=Ke(),[g,f]=n.useCustomComponent(s),[h,v]=n.useCustomComponent(t),k=p.useRef(null);p.useEffect(()=>{var e,t;null!=(t=null==(e=k.current)?void 0:e.element)&&t.current&&requestAnimationFrame(()=>{var e,t;if(null!=(t=null==(e=k.current)?void 0:e.element)&&t.current){const e=k.current.element.current;e.style.height="auto",e.style.height=`${e.scrollHeight}px`}})},[c]);const b={title:"Generate",children:"Generate",svgIcon:l.sparklesIcon},y=Object.keys(f).length>0?f:b,E=Object.keys(v).length>0?v:{placeholder:"Ask or generate content with AI ...",rows:2},C=e=>{const{isFinal:t,alternatives:n}=e;if(t&&n.length>0){const e=n[0].transcript,t=(()=>{const t=c,n=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(n?" ":"")+e})();u(t)}};let x;return o&&(x="object"==typeof o?{...o,onResult:o.onResult||C}:{onResult:C}),p.createElement(je,{name:$e.name},p.createElement(We,{streaming:d.streaming,onCancel:d.onCancel},p.createElement(h,{ref:k,value:c,flow:"vertical",textareaStyle:{maxHeight:"110px"},autoSize:!0,suffix:o?p.createElement(p.Fragment,null,p.createElement(m.InputSeparator,{orientation:"horizontal"}),p.createElement(m.InputSuffix,{orientation:"horizontal"},p.createElement(a.SpeechToTextButton,{fillMode:"flat",...x}))):void 0,onChange:e=>{u(e.target.value)},...E}),i&&i.length>0&&p.createElement(Ge,{title:"Prompt Suggestions"},p.createElement(ge,{suggestionsView:d.suggestionsView,suggestions:i.map((e,t)=>({id:t,text:e,description:e})),onSuggestionClick:e=>{(e=>{u(e)})(e.text)}}))),p.createElement(Ve,null,p.createElement(g,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:()=>{d.onPromptRequest&&d.onPromptRequest.call(null,c),u("")},disabled:!c.trim(),...y},y.children)))},e.AIPromptViewRender=je,e.Chat=ze,e.ChatMessage=te,e.DEFAULT_FIELD_MAPPING=Se,e.HeroCard=e=>{const{imageUrl:t,imageMaxWidth:n,title:l,subtitle:s,actions:o,onActionExecute:r,altText:i}=e,c=p.useCallback((e,t)=>{null==r||r({action:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})},[r]),u=i||l||"";return p.createElement("div",{className:"k-card"},p.createElement("img",{className:"k-card-image",src:t,style:{maxWidth:n},alt:u}),p.createElement("div",{className:"k-card-body"},l&&p.createElement("h5",{className:"k-card-title"},l),s&&p.createElement("h6",{className:"k-card-subtitle"},s)),p.createElement("div",{className:"k-card-actions k-card-actions-vertical"},o.map((e,t)=>p.createElement("span",{className:"k-card-action",key:`action-${t}-${e.title||e.value||t}`},p.createElement(a.Button,{fillMode:"flat",onClick:t=>c(e,t)},e.title)))))},e.InlineAIPrompt=e=>{const t=!n.validatePackage(be,{component:"InlineAIPrompt"}),o=n.getLicenseMessage(be),{outputs:r=[],outputCard:i,promptInput:c=m.TextArea,generateButton:u=a.Button,promptPlaceholder:d="Ask or generate content with AI...",promptValue:g,onPromptRequest:f,onCopy:h,onDiscard:v,outputActions:k,onOutputAction:b,enableSpeechToText:y=!1,streaming:E,onPromptCancel:C,show:x=!1,anchor:I,width:T,height:F,onOpen:w,onClose:S,animate:A=!0,appendTo:M,commands:R,onCommandExecute:N,style:B,className:L,popupOptions:D={},...P}=e,[z,O]=p.useState(""),[q,H]=p.useState(!1),[$,U]=p.useState({left:0,top:0}),K=p.useRef(null),{body:V,actions:W}=i||{},j=k||[{id:"copy",text:"Copy",svgIcon:l.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:l.cancelIcon,themeColor:"base",title:"Discard"}],G=(e,t)=>{switch(e.id){case"copy":(e=>{e.responseContent&&(navigator.clipboard.writeText(e.responseContent),O(e.id),setTimeout(()=>O(""),1e3)),null==h||h(e)})(t);break;case"discard":(e=>{null==v||v(e)})(t);break;default:null==b||b(e,t)}},_=p.useCallback(e=>{"Escape"===e.key&&(E&&C?C():!E&&S&&S({target:null}))},[E,C,S]),Y={...B,...T&&{width:T},...F&&{height:F}},X={...T&&{width:T},...F&&{height:F}},J=p.createElement(p.Fragment,null,p.createElement("div",{className:n.classNames("k-prompt",L),style:Y,onKeyDown:_,...P},p.createElement(We,{ref:K},r&&r.length>0&&p.createElement("div",{className:"k-card-list"},r.map((e,t)=>p.createElement(s.Card,{key:`${e.id}_${t}`},p.createElement(s.CardBody,null,V?V(e):e.responseContent),p.createElement(s.CardActions,null,W?W(e):p.createElement(p.Fragment,null,j.map(t=>{var n;return t.spacer?p.createElement("span",{key:t.id,className:"k-spacer"}):p.createElement(a.Button,{key:t.id,size:"medium",themeColor:t.themeColor||"primary",fillMode:"flat",rounded:"medium",title:null!=(n=t.title)?n:t.text,svgIcon:"copy"===t.id&&z===e.id?l.checkIcon:t.svgIcon,onClick:()=>G(t,e)},t.text)})))))),p.createElement(Xe,{promptValue:g,placeholder:d,onPromptRequest:f,onMenuClick:e=>{if(!K.current)return;const t=K.current.getBoundingClientRect();U({left:t.left,top:t.bottom}),H(!0)},onPromptCancel:C,promptInput:c,generateButton:u,enableSpeechToText:y,streaming:E,commands:R}))),t&&p.createElement(n.WatermarkOverlay,{message:o}));return p.createElement(p.Fragment,null,p.createElement(Ye,{show:x,anchor:I,onOpen:w,onClose:S,animate:A,appendTo:M,popupOptions:D,style:X},J),p.createElement(s.ContextMenu,{show:q,offset:$,onClose:()=>{H(!1)},items:(e=>null==e?void 0:e.map(e=>({text:e.text,svgIcon:e.svgIcon,data:e,items:e.children?e.children.map(e=>({text:e.text,data:e})):void 0})))(R),onSelect:e=>{var t,n;const a=null==(t=e.item)?void 0:t.data;a&&(null==(n=a.children)||!n.length)&&(e=>{H(!1),N&&N(e)})(a)}}))},e.PromptBox=Ce,e.PromptBoxActionButton=fe,e.PromptBoxSpeechToTextButton=he,e.PromptBoxUploadButton=pe,e.PromptHeader=Oe,e.SuggestionGroup=ge,e.commandsViewDefaults=He,e.extractFieldMappingFromProps=e=>({textField:e.textField,statusField:e.statusField,authorIdField:e.authorIdField,authorNameField:e.authorNameField,authorImageUrlField:e.authorImageUrlField,authorImageAltTextField:e.authorImageAltTextField,idField:e.idField,timestampField:e.timestampField,filesField:e.filesField,attachmentsField:e.attachmentsField,replyToIdField:e.replyToIdField,isDeletedField:e.isDeletedField,isPinnedField:e.isPinnedField,typingField:e.typingField,suggestedActionsField:e.suggestedActionsField,isFailedField:e.isFailedField}),e.isStandardMessageFormat=Re,e.mapDataArrayToMessages=Me,e.mapDataToMessage=Ae,e.mapMessageToCustomFormat=(e,t={})=>{const n={...Se,...t},a={};return void 0!==e.id&&(a[n.idField]=e.id),void 0!==e.text&&(a[n.textField]=e.text),void 0!==e.status&&(a[n.statusField]=e.status),void 0!==e.isFailed&&(a[n.isFailedField]=e.isFailed),void 0!==e.timestamp&&(a[n.timestampField]=e.timestamp),void 0!==e.attachments&&(a[n.attachmentsField]=e.attachments),void 0!==e.files&&(a[n.filesField]=e.files),void 0!==e.suggestedActions&&(a[n.suggestedActionsField]=e.suggestedActions),void 0!==e.replyToId&&(a[n.replyToIdField]=e.replyToId),void 0!==e.isDeleted&&(a[n.isDeletedField]=e.isDeleted),void 0!==e.isPinned&&(a[n.isPinnedField]=e.isPinned),void 0!==e.typing&&(a[n.typingField]=e.typing),e.author&&(void 0!==e.author.id&&(a[n.authorIdField]=e.author.id),void 0!==e.author.name&&(a[n.authorNameField]=e.author.name),void 0!==e.author.avatarUrl&&(a[n.authorImageUrlField]=e.author.avatarUrl),void 0!==e.author.avatarAltText&&(a[n.authorImageAltTextField]=e.author.avatarAltText)),void 0!==e.pinnedAt&&(a.pinnedAt=e.pinnedAt),void 0!==e.pinnedBy&&(a.pinnedBy=e.pinnedBy),void 0!==e.attachmentLayout&&(a.attachmentLayout=e.attachmentLayout),a},e.outputViewDefaults=qe,e.promptViewDefaults=$e});
|
|
15
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@progress/kendo-react-common"),require("@progress/kendo-react-buttons"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-layout"),require("@progress/kendo-react-intl"),require("prop-types"),require("@progress/kendo-react-upload"),require("@progress/kendo-react-animation"),require("@progress/kendo-react-notification"),require("@progress/kendo-react-inputs"),require("@progress/kendo-react-popup")):"function"==typeof define&&define.amd?define(["exports","react","@progress/kendo-react-common","@progress/kendo-react-buttons","@progress/kendo-svg-icons","@progress/kendo-react-layout","@progress/kendo-react-intl","prop-types","@progress/kendo-react-upload","@progress/kendo-react-animation","@progress/kendo-react-notification","@progress/kendo-react-inputs","@progress/kendo-react-popup"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactConversationalUi={},e.React,e.KendoReactCommon,e.KendoReactButtons,e.KendoSvgIcons,e.KendoReactLayout,e.KendoReactIntl,e.PropTypes,e.KendoReactUpload,e.KendoReactAnimation,e.KendoReactNotification,e.KendoReactInputs,e.KendoReactPopup)}(this,function(e,t,n,a,l,s,o,r,i,c,u,m,d){"use strict";function g(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var p=g(t);const f="newMessage.sendButton",h="newMessage.optionsButton",v="newMessage.messageInput",k="avatar.alt",b="messageList.ariaLabel",y="aIPrompt.noOutputs",E="aIPrompt.cancel",C="chat.senderDeletedMessage",x="chat.receiverDeletedMessage",I="chat.copyNotification",T="chat.downloadAllFiles",F="chat.closeReply",w="chat.collapseMessage",S="chat.expandMessage",A="chat.removeFile",M="chat.fileActions",R="chat.attachFile",N="chat.downloadAll",B="chat.scrollLeft",L="chat.scrollRight",D="chat.scrollToBottom",P="chat.messageFailed",z="chat.retryMessage",O="chat.stopGenerating",q="promptBox.input",H="promptBox.sendButton",U="promptBox.attachFile",$="promptBox.removeFile",K="promptBox.stopGenerating",V="promptBox.ariaLabel",j="promptBox.attachedFiles",W="chat.messageToolbar",G="chat.unpinMessage",_="chat.messageAttachedFiles",Y={[f]:"Send",[h]:"Options",[v]:"Message",[k]:"Avatar",[b]:"Message list",[E]:"Cancel",[y]:"No output from AI available",[C]:"You removed this message",[x]:"The message was removed by its sender",[I]:"Text copied to clipboard",[T]:"Download all files",[F]:"Close reply",[w]:"Collapse message",[S]:"Expand message",[A]:"Remove file",[M]:"File actions for",[P]:"Failed to send",[z]:"Retry",[O]:"Stop generating",[R]:"Attach file",[N]:"Download all",[B]:"Scroll left",[L]:"Scroll right",[D]:"Scroll to bottom",[q]:"Prompt",[H]:"Send",[U]:"Attach file",[$]:"Remove file",[K]:"Stop generating",[V]:"Prompt box",[j]:"Attached files",[W]:"Toolbar",[G]:"Unpin message",[_]:"Attached files"},X=(e,t)=>e&&t.author&&e.id===t.author.id,J=(e,t)=>{const n=t.toLanguageString("chatSender.deletedMessage",Y[C]),a=t.toLanguageString("chatReceiver.deletedMessage",Y[x]);return e?n:a},Q=(e,t)=>e.find(e=>e.id===t),Z=/(https?:\/\/[^\s]+)/g,ee=e=>{if(!e)return[""];const t=e.split(Z),n=[];return t.forEach(e=>{e&&Z.test(e)?(Z.lastIndex=0,n.push(p.createElement("a",{key:e,href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"}},e))):e&&n.push(e)}),n},te=p.createContext(void 0),ne=()=>{const e=t.useContext(te);if(void 0===e)throw new Error("useChatContext must be used within a ChatContext.Provider");return e},ae=e=>{const{files:t,onFileAction:s,onDownload:r,fileActions:i}=e,{messageFilesLayout:c="vertical"}=ne(),u=o.useLocalization(),m=i||[{id:"download",label:"Download",svgIcon:l.downloadIcon}],d=e=>{if(null==e)return"";if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,t)).toFixed(2))} ${["B","KB","MB","GB","TB"][t]}`},g=e=>"."+e.split(".").pop()||"",f=e=>m.length>0&&p.createElement(a.DropDownButton,{fillMode:"flat",size:"xs",svgIcon:l.moreVerticalIcon,onClick:e=>{e.syntheticEvent.stopPropagation()},onItemClick:t=>((e,t)=>{var n,a;null==(a=null==(n=e.syntheticEvent)?void 0:n.stopPropagation)||a.call(n),"download"===e.item.id&&(null==r||r([t])),null==s||s(e.item,e,t)})(t,e),items:m.map(e=>({id:e.id,icon:e.icon,text:e.label,svgIcon:e.svgIcon})),"aria-label":`${u.toLanguageString(M,Y[M])} ${e.name}`,title:`${u.toLanguageString(M,Y[M])} ${e.name}`}),h=p.useCallback(()=>n.classNames({"k-files-wrap":"wrap"===c,"k-files-vertical":"vertical"===c},"k-file-box-wrapper"),[c]);return p.createElement("ul",{role:"list","aria-label":u.toLanguageString(_,Y[_]),className:h()},"horizontal"===c?p.createElement("div",{className:"k-files-scroll",role:"presentation"},t.map(e=>p.createElement("li",{key:e.name,className:"k-file-box",role:"listitem","aria-label":[e.name,d(e.size)].filter(Boolean).join(" ")||void 0},p.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(g(e.name))}),p.createElement("div",{className:"k-file-info"},p.createElement("span",{className:"k-file-name"},e.name),p.createElement("span",{className:"k-file-size"},d(e.size))),f(e)))):t.map(e=>p.createElement("li",{key:e.name,className:"k-file-box",role:"listitem","aria-label":[e.name,d(e.size)].filter(Boolean).join(" ")||void 0},p.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(g(e.name))}),p.createElement("div",{className:"k-file-info"},p.createElement("span",{className:"k-file-name"},e.name),p.createElement("span",{className:"k-file-size"},d(e.size))),f(e))))},le=p.forwardRef((e,t)=>{const{item:r,template:i,contentTemplate:c,onRequestSelection:u,tabIndex:m=-1,dateFormat:d="g",selected:g,allowMessageCollapse:f,messageToolbarActions:h,messageContextMenuActions:v,fileActions:k,isSender:b}=e,{setReplyToMessage:y,messages:E,repliedToMessages:C,user:x,onToolbarAction:I,onContextMenuAction:F,onFileAction:A,onDownload:M,onResendMessage:R,setShowCopyNotification:B,statusTemplate:L,timestampVisibility:D="onFocus",onReferencedMessageClick:O}=ne(),[q,H]=p.useState(!1),[U,$]=p.useState(!1),[K,V]=p.useState(!0),[j,G]=p.useState(!1),_=o.useLocalization(),Z=o.useInternationalization(),te=p.useRef({left:0,top:0}),le=p.useCallback(()=>{null!=r&&r.text&&(e=>{navigator.clipboard.writeText(e)})(r.text),B&&(B(!0),setTimeout(()=>{B(!1)},3e3))},[r,B]),se=p.useCallback(e=>{e.stopPropagation(),V(e=>!e)},[]),oe=p.useCallback(()=>{G(!1)},[]),re=p.useCallback(e=>{("Tab"===e.key||"Enter"===e.key||" "===e.key||"ArrowUp"===e.key||"ArrowDown"===e.key)&&G(!0)},[]),ie=p.useRef(null);p.useEffect(()=>{g&&ie.current&&ie.current.focus()},[g]);const ce=p.useCallback(e=>{te.current={left:e.pageX,top:e.pageY},e.preventDefault(),$(!0),H(!0)},[]),ue=p.useCallback(()=>{$(!1),H(!1)},[]),me=p.useCallback((e,t)=>e.isDeleted?J(t,_):e.text?e.text:"",[_]),de=p.useCallback(e=>{var t;null!=(t=e.item)&&t.text&&("copy"!==e.item.data.id||r.isDeleted?"reply"===e.item.data.id&&y(r):le(),F&&F(e.item.data,e,r)),$(!1),H(!1)},[r,F,y,le]),ge=p.useCallback(()=>{if(r.replyToId){const e=Q(E,r.replyToId)||(C?Q(C,r.replyToId):void 0);if(e){const t=t=>{t.preventDefault(),t.stopPropagation(),null==O||O(e.id)};return p.createElement("div",{className:n.classNames("k-message-reference",X(x,e)?"k-message-reference-sender":"k-message-reference-receiver"),onClick:t},p.createElement("div",{className:"k-message-reference-content"},ee(me(e,X(x,e)))))}}return null},[r.replyToId,E,C,x,me,O]),pe=p.useCallback(()=>{const e=[{id:"reply",label:"Reply",svgIcon:l.undoIcon},{id:"copy",label:"Copy",svgIcon:l.copyIcon}],t=v?[...e.map(e=>v.find(t=>t.id===e.id)||e),...v.filter(t=>!e.some(e=>e.id===t.id))]:e;return p.createElement(s.ContextMenu,{onSelect:de,onClose:ue,vertical:!0,show:q,offset:te.current},t.map(e=>"delete"!==e.id||b?p.createElement(s.MenuItem,{key:e.id,text:e.label,icon:e.icon,svgIcon:e.svgIcon,data:e}):null))},[v,de,ue,q,b]),fe=p.useCallback(()=>r.files&&r.files.length>1?p.createElement("div",{className:"k-chat-download-button-wrapper"},p.createElement(a.Button,{className:"k-chat-download-button",fillMode:"flat",svgIcon:l.downloadIcon,size:"small",onClick:e=>{e.stopPropagation(),M&&M(r.files,r)},"aria-label":_.toLanguageString(T,Y[T])},p.createElement("span",{className:"k-button-text"},_.toLanguageString(N,Y[N])))):null,[r,M,_]),he=p.useCallback(()=>{if(r.typing)return p.createElement("div",{className:"k-chat-bubble k-bubble"},p.createElement("div",{className:"k-bubble-content"},p.createElement("div",{className:"k-typing-indicator"},p.createElement("span",null),p.createElement("span",null),p.createElement("span",null))));if(i){const e=i;return p.createElement(p.Fragment,null,p.createElement(e,{item:r}),pe())}return r.text||r.files&&r.files.length>0?p.createElement(p.Fragment,null,p.createElement("div",{className:n.classNames("k-chat-bubble","k-bubble",{"k-bubble-expandable":f,"k-expanded":f&&K,"k-selected":g,"k-active":U}),onClick:()=>u(g?void 0:r.selectionIndex),onContextMenu:ce},p.createElement("div",{className:"k-bubble-content"},c?p.createElement(c,{item:r}):p.createElement(p.Fragment,null,(r.text||r.isDeleted||r.replyToId)&&p.createElement("span",{className:"k-chat-bubble-text"},!r.isDeleted&&ge(),ee(me(r,X(x,r)))),r.files&&r.files.length>0&&p.createElement(ae,{files:r.files,message:r,onFileAction:A,onDownload:e=>null==M?void 0:M(e,r),renderInTextarea:!1,fileActions:k}),fe())),f&&p.createElement("span",{className:"k-bubble-expandable-indicator",onClick:se,role:"button","aria-label":K?_.toLanguageString(w,Y[w]):_.toLanguageString(S,Y[S]),tabIndex:0,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),se(e))}},p.createElement(n.IconWrap,{icon:K?l.chevronUpIcon:l.chevronDownIcon}))),pe()):null},[r,i,c,f,K,g,U,u,ce,ge,me,x,A,k,fe,se,_,pe,M]),ve=p.useCallback(()=>{let e=null;return r.timestamp&&("hidden"===D||(e=p.createElement("time",{className:"k-message-time"},Z.formatDate(r.timestamp,d)))),e},[r.timestamp,d,D,Z]),ke=p.useCallback(()=>{if(!r.status)return null;let e;if(L)e=p.createElement(L,{item:r});else{let t,a,l;if("object"==typeof r.status&&null!==r.status){const e=r.status;t=e.text,a=e.icon,l=e.svgIcon}else t=r.status;let s=null;a?s=p.createElement(n.Icon,{name:a,size:"xsmall"}):l&&(s=p.createElement(n.IconWrap,{icon:l,size:"xsmall"})),e=p.createElement(p.Fragment,null,s,t)}return p.createElement("span",{className:"k-message-status"},e)},[r,L]),be=p.useCallback(()=>{let e=null;if(r.isFailed){const t=_.toLanguageString(P,Y[P]);e=p.createElement("span",{className:"k-message-failed-content"},p.createElement(n.IconWrap,{icon:l.warningTriangleIcon,size:"xsmall"}),p.createElement("span",{className:"k-message-failed-text"},t))}return e},[r,_]),ye=p.useCallback(()=>{let e=null;if(r.isFailed){const t=_.toLanguageString(z,Y[z]);e=p.createElement(a.Button,{fillMode:"clear",size:"xs",className:"k-resend-button",svgIcon:l.arrowRotateCwIcon,"aria-label":t,title:t,onClick:e=>{e.stopPropagation(),R&&R({message:r,syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.target})}})}return e},[r,_,R]),Ee=p.useCallback(()=>n.classNames({"k-focus":g,"k-message-removed":r.isDeleted,"k-message-failed":r.isFailed},"k-message"),[g,r.isDeleted,r.isFailed]),Ce=p.useCallback(()=>h&&h.length>0&&p.createElement(a.Toolbar,{className:"k-chat-message-toolbar",fillMode:"flat",ariaLabel:_.toLanguageString(W,Y[W])},h.map(e=>"delete"!==e.id||b?p.createElement(a.Button,{key:e.id,fillMode:"flat",className:"k-toolbar-button",icon:e.icon,svgIcon:e.svgIcon,"aria-label":e.label,onClick:t=>{t.stopPropagation(),"copy"!==e.id||r.isDeleted?"reply"===e.id&&y(r):le(),I&&I(e,t,r)},onMouseDown:e=>e.preventDefault()}):null)),[le,b,r,_,h,I,y]);return p.createElement("div",{key:r.id,"data-message-id":r.id,className:Ee(),tabIndex:m,onMouseDown:oe,onKeyDown:re,onFocus:e=>{j&&u(r.selectionIndex)},ref:e=>{ie.current=e,"function"==typeof t?t(e):t&&(t.current=e)},onContextMenu:i?ce:void 0},ye(),he(),(r.status||r.timestamp&&"hidden"!==D||r.isFailed)&&p.createElement("div",{className:"k-message-info"},ke(),ve(),be()),Ce())});le.displayName="ChatMessage";const se=e=>e[e.length-1],oe=e=>(t,n,a)=>{const l=a===e-1;return((e,t)=>{const n=t.timestamp,a=se(e);if(n&&(!a||((e,t)=>e&&t&&(t.getDate()!==e.getDate()||t.getMonth()!==e.getMonth()||t.getFullYear()!==e.getFullYear()))(n,a.timestamp))){const t={type:"date-marker",timestamp:n,trackBy:n.getTime()};e.push(t)}})(t,n),((e,t,n)=>{const a=se(e);let l;t.typing&&!n||(a&&"message-group"===a.type&&(l=a.messages),l&&X(t.author,se(l))?l.push(t):e.push({type:"message-group",messages:[t],author:t.author,timestamp:t.timestamp,trackBy:t}))})(t,n,l),n.attachments&&n.attachments.length>1&&t.push({type:"attachment-group",attachments:n.attachments,attachmentLayout:n.attachmentLayout,timestamp:n.timestamp,trackBy:n}),n.suggestedActions&&l&&t.push({type:"action-group",actions:n.suggestedActions,timestamp:n.timestamp,trackBy:n}),t};const re=e=>{const{item:t,onActionExecute:a,selected:l}=e,s=p.useRef(null);p.useEffect(()=>{l&&s.current&&s.current.focus()},[l]);const o=p.useCallback(e=>{(e.keyCode===n.Keys.enter||" "===e.key)&&(e.preventDefault(),a(t,e))},[a,t]),r=p.useCallback(()=>n.classNames("k-suggestion k-suggestion-primary",{"k-selected":l},{"k-focus":l}),[l]);return p.createElement("span",{role:"button",className:r(),onClick:e=>a(t,e),ref:s,onKeyDown:o,tabIndex:0,"aria-label":t.title||t.value},t.title||t.value)},ie=({visible:e,dir:t,canScrollLeft:n,canScrollRight:s,onScrollLeft:r,onScrollRight:i,children:c})=>{const u=o.useLocalization();if(!e)return c;const m=u.toLanguageString(B,Y[B]),d=u.toLanguageString(L,Y[L]),g="rtl"!==t?m:d,f="rtl"!==t?d:m;return p.createElement("div",{className:"k-suggestion-scrollwrap"},p.createElement(a.Button,{fillMode:"flat",size:"xs",svgIcon:"rtl"===t?l.chevronRightIcon:l.chevronLeftIcon,onClick:r,disabled:!n,"aria-label":g,title:g}),c,p.createElement(a.Button,{fillMode:"flat",size:"xs",svgIcon:"rtl"===t?l.chevronLeftIcon:l.chevronRightIcon,onClick:i,disabled:!s,"aria-label":f,title:f}))},ce=100,ue=(e,t)=>{const{enabled:n,dir:a,mode:l,itemsDependency:s=[],scrollSpeed:o=ce}=t,[r,i]=p.useState(!1),[c,u]=p.useState(!1),m=p.useCallback(()=>{if(e.current&&n){const{scrollLeft:t,scrollWidth:n,clientWidth:l}=e.current,s="rtl"!==a?t+l>=n-1:l-t>=n-1;i(!(0===t)),u(!s)}},[n,a]),d=p.useCallback(()=>{e.current&&n&&e.current.scrollBy({left:"rtl"!==a?-o:o,behavior:"smooth"})},[n,a,o]),g=p.useCallback(()=>{e.current&&n&&e.current.scrollBy({left:"rtl"!==a?o:-o,behavior:"smooth"})},[n,a,o]);return p.useEffect(()=>{const t=e.current;if(!t||!n)return;m();const a=()=>m();t.addEventListener("scroll",a,{passive:!0});const l=new ResizeObserver(m);return l.observe(t),()=>{t.removeEventListener("scroll",a),l.disconnect()}},[n,m,s.length,l]),p.useLayoutEffect(()=>{n&&m()},[n,a,s]),{canScrollLeft:r,canScrollRight:c,scrollLeft:d,scrollRight:g}},me=e=>{var t,a;const{group:l,onActionExecute:s,selected:o,onRequestSelection:r,quickActionsLayout:i="scroll",dir:c}=e,[u,m]=p.useState(null),d=p.useRef(null),{canScrollLeft:g,canScrollRight:f,scrollLeft:h,scrollRight:v}=ue(d,{enabled:"scrollbuttons"===i||"scroll"===i,dir:c,mode:i,itemsDependency:l.actions});p.useEffect(()=>{o||null===u?o&&null===u&&m(0):m(null)},[o,u]);const k=p.useCallback(()=>l.actions?l.actions.length-1:-1,[l.actions]),b=p.useCallback((e,t=0)=>{let n=null;return e?null===u?n=t:u<k()&&(n=u+1):null===u?n=0:u>0&&(n=u-1),null!==n&&m(n),n},[u,k]),y=p.useCallback(()=>{r(l.selectionIndex)},[r,l.selectionIndex]),E=p.useCallback(e=>{let t=null;const a=n.Keys.left,l=n.Keys.right;e.keyCode===a?t=b(!1):e.keyCode===l&&(t=b(!0)),null!==t&&(e.preventDefault(),e.stopPropagation())},[b]),C=p.useCallback(()=>n.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":"scroll"===i,"k-suggestion-group-scrollable-start":f&&("scroll"===i||"scrollbuttons"===i),"k-suggestion-group-scrollable-end":g&&("scroll"===i||"scrollbuttons"===i)}),[i,f,g]),x="scroll"===i||"scrollbuttons"===i,I=p.createElement("div",{className:C(),onClick:y,onKeyDown:E,role:"toolbar",tabIndex:0,"aria-label":"Action group"},x?p.createElement("div",{className:"k-suggestions-scroll",ref:d},null==(t=l.actions)?void 0:t.map((e,t)=>p.createElement(re,{item:e,onActionExecute:s,selected:t===u,key:e.value}))):null==(a=l.actions)?void 0:a.map((e,t)=>p.createElement(re,{item:e,onActionExecute:s,selected:t===u,key:e.value})));return p.createElement(ie,{visible:"scrollbuttons"===i,dir:c,canScrollLeft:g,canScrollRight:f,onScrollLeft:h,onScrollRight:v},I)},de=e=>{const{item:t,template:a,tabbable:l,onClick:s,selected:o}=e,r=p.useRef(null);p.useEffect(()=>{o&&r.current&&r.current.focus()},[o]);const i=p.useCallback(()=>{if(void 0!==l)return l?0:-1},[l]),c=p.useCallback(()=>n.classNames({"k-selected":o},{"k-focus":o}),[o]),u=p.useCallback(()=>t.title?p.createElement("h5",{className:"k-card-title"},t.title):null,[t.title]),m=p.useCallback(()=>t.subtitle?p.createElement("h6",{className:"k-card-subtitle"},t.subtitle):null,[t.subtitle]),d=p.useCallback(()=>0===t.contentType.indexOf("image/")?p.createElement("img",{src:t.content,alt:t.title||"Attachment",style:{maxHeight:"200px",height:"auto",maxWidth:"200px",width:"auto"}}):t.content,[t.contentType,t.content,t.title]),g=a;return p.createElement("div",{className:c(),tabIndex:i(),onClick:s,ref:r},a?p.createElement(g,{item:t}):p.createElement("div",{className:"k-card"},p.createElement("div",{className:"k-card-body"},u(),m(),d())))},ge=e=>{const{group:t,itemTemplate:s,selected:o,isLastGroup:r,onRequestSelection:i}=e,[c,u]=p.useState(null);p.useEffect(()=>{o||null===c?o&&null===c&&u(0):u(null)},[o,c]);const m=p.useCallback(e=>"list"!==e.attachmentLayout,[]),d=p.useCallback(()=>t.attachments?t.attachments.length-1:-1,[t.attachments]),g=p.useCallback(()=>t.attachments.length-1,[t.attachments]),f=p.useCallback((e,t=0)=>{let n=null;return e?null===c?n=t:c<d()&&(n=c+1):null===c?n=0:c>0&&(n=c-1),null!==n&&u(n),n},[c,d]),h=p.useCallback(()=>{i(t.selectionIndex)},[i,t.selectionIndex]),v=p.useCallback(e=>{let a,l,s=null;m(t)?(a=n.Keys.left,l=n.Keys.right):(a=n.Keys.up,l=n.Keys.down),e.keyCode===a?s=f(!1):e.keyCode===l&&(s=f(!0)),null!==s&&(e.preventDefault(),e.stopPropagation())},[f,m,t]),k=p.useCallback(e=>{h(),u(e)},[h]),b=p.useCallback(e=>{h(),f(e,1)},[h,f]),y=p.useCallback(()=>{let e=null;return m(t)&&c&&(e=p.createElement(a.Button,{icon:"chevron-left",onClick:()=>b(!1),svgIcon:l.chevronLeftIcon})),e},[m,t,c,b]),E=p.useCallback(()=>{let e=null;return m(t)&&c!==g()&&(e=p.createElement(a.Button,{icon:"chevron-right",onClick:()=>b(!0),svgIcon:l.chevronRightIcon})),e},[m,t,c,g,b]),C=p.useCallback(()=>n.classNames({"k-card-list":t.attachmentLayout,"k-card-deck":m(t)}),[t.attachmentLayout,t,m]),x=m(t),I=p.createElement("div",{className:C(),onKeyDown:x?void 0:v},t.attachments.map((e,t)=>p.createElement(de,{item:e,template:s,selected:t===c,tabbable:r&&t===c,onClick:()=>k(t),key:e.content})));return x?p.createElement("div",{className:"k-card-deck-scrollwrap",onKeyDown:v},y(),I,E()):I},pe=({item:e,timestampTemplate:t})=>{const n=o.useInternationalization(),a=t;return p.createElement("div",{className:"k-timestamp"},a?p.createElement(a,{item:e}):n.formatDate(e.timestamp,"D"))},fe=e=>{const{group:t,user:a,itemTemplate:l,contentTemplate:r,attachmentTemplate:i,onRequestSelection:c,selectedItemIndex:u,isLastGroup:m,message:d,allowMessageCollapse:g,messageToolbarActions:f,messageContextMenuActions:h,fileActions:v,messageWidthMode:b="standard",showAvatar:y=!0,showUsername:E=!0}=e,{userStatusTemplate:C}=ne(),x=o.useLocalization(),I=t.messages.length>0&&X(a,t.messages[0]),{avatarUrl:T,avatarAltText:F,name:w}=t.author,S=p.useMemo(()=>n.classNames("k-message-group",{"k-message-group-sender":I,"k-message-group-receiver":!I,"k-message-group-full-width":"full"===b,"k-no-avatar":!y||!T}),[I,b,y,T]),A=p.useMemo(()=>{const e=t.messages.length-1;return t.messages.map((t,n)=>{const s=[p.createElement(d,{item:t,template:l,contentTemplate:r,selected:t.selectionIndex===u,onRequestSelection:c,tabIndex:n===e&&m?0:-1,key:t.id,allowMessageCollapse:g,messageToolbarActions:f,messageContextMenuActions:h,fileActions:v,isSender:X(a,t)})];return t.attachments&&1===t.attachments.length&&s.push(p.createElement(de,{item:t.attachments[0],template:i,selected:!1,key:`att-${t.attachments[0].content}`})),s})},[t.messages,d,l,r,u,c,m,g,f,h,v,a,i]),M=void 0!==F?F:x.toLanguageString(k,Y[k]);return p.createElement("div",{className:S},(()=>{if(!y||!T)return;const e=p.createElement(s.Avatar,{type:"image"},p.createElement("img",{src:T,alt:M}));if(C){const n=t.messages[t.messages.length-1];return p.createElement("div",{className:"k-chat-user-status-wrapper"},e,p.createElement("div",{className:"k-chat-user-status"},p.createElement(C,{message:"dataItem"in n?n.dataItem:n})))}return e})(),p.createElement("div",{className:"k-message-group-content"},E&&p.createElement("span",{className:"k-message-author"},w),A))},he=e=>{const{suggestions:t,onSuggestionClick:a,suggestionsView:l,suggestionTemplate:s,suggestionsLayout:o,dir:r}=e,i=p.useRef(null),{canScrollLeft:c,canScrollRight:u,scrollLeft:m,scrollRight:d}=ue(i,{enabled:"scrollbuttons"===o||"scroll"===o,dir:r,mode:o,itemsDependency:t}),g=p.useCallback((e,t)=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),null==a||a(t))},[a]),f=p.useCallback(()=>t.map(e=>s?p.createElement(s,{key:e.id,suggestion:e,onClick:()=>{null==a||a(e)}}):p.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:()=>!e.disabled&&(null==a?void 0:a(e)),onKeyDown:t=>!e.disabled&&g(t,e),key:e.id,title:e.description,className:n.classNames("classic"===l?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},e.text)),[t,s,a,l,g]);if(!t||0===t.length)return null;if("classic"===l)return f();const h="scroll"===o||"scrollbuttons"===o,v=p.createElement("div",{role:"group",className:n.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":"scroll"===o,"k-suggestion-group-scrollable-start":u&&("scroll"===o||"scrollbuttons"===o),"k-suggestion-group-scrollable-end":c&&("scroll"===o||"scrollbuttons"===o)})},h?p.createElement("div",{className:"k-suggestions-scroll",ref:i},f()):f());return p.createElement(ie,{visible:"scrollbuttons"===o,dir:r,canScrollLeft:c,canScrollRight:u,onScrollLeft:m,onScrollRight:d},v)},ve=p.forwardRef(({onFilesAdd:e,files:t=[],restrictions:n,multiple:l=!0,accept:s,uploadRef:o,onSelectAttachments:r,onRemoveAttachment:c,_registerRemoveCallback:u,...m},d)=>{p.useEffect(()=>(u&&c&&u(c),()=>{u&&c&&u(void 0)}),[c,u]);const g=p.useCallback(t=>{e&&e(t),r&&r({selectedFiles:t.affectedFiles,allFiles:t.newState})},[e,r]);return p.createElement(p.Fragment,null,p.createElement(a.Button,{ref:d,...m}),p.createElement(i.Upload,{ref:o,files:t,onAdd:g,autoUpload:!1,restrictions:n,multiple:l,accept:s,className:"k-hidden"}))});ve.displayName="PromptBoxUploadButton";const ke=p.forwardRef((e,t)=>p.createElement(a.Button,{ref:t,...e}));ke.displayName="PromptBoxActionButton";const be=p.forwardRef((e,t)=>p.createElement(a.SpeechToTextButton,{ref:t,...e}));be.displayName="PromptBoxSpeechToTextButton";const ye=e=>"."+e.split(".").pop()||"",Ee=e=>{if(null==e)return"";if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,t)).toFixed(2))} ${["B","KB","MB","GB","TB"][t]}`},Ce=({files:e,onRemoveFile:t,header:s})=>{const r=o.useLocalization(),i=p.useRef(null),[c,u]=p.useState(!1),[m,d]=p.useState(!1),g=p.useCallback(()=>{const e=i.current;if(!e)return;const{scrollLeft:t,scrollWidth:n,clientWidth:a}=e,l=t+a>=n-1;d(!(0===t)),u(!l)},[]);if(p.useLayoutEffect(()=>{g()},[e,g]),p.useEffect(()=>{const e=i.current;if(!e)return;const t=()=>g(),n=new ResizeObserver(g);return n.observe(e),e.addEventListener("scroll",t,{passive:!0}),()=>{e.removeEventListener("scroll",t),n.disconnect()}},[g,e.length]),0===e.length&&!s)return null;const f=(e=>e?"function"==typeof e?e():e:null)(s),h=e.length>0&&p.createElement("ul",{role:"list","aria-label":r.toLanguageString(j,Y[j]),className:n.classNames("k-file-box-wrapper",{"k-file-box-wrapper-scrollable-start":c,"k-file-box-wrapper-scrollable-end":m})},p.createElement("div",{className:"k-files-scroll",role:"presentation",ref:i},e.map((e,s)=>p.createElement("li",{key:e.name,className:"k-file-box",role:"listitem",tabIndex:0===s?0:-1,"aria-label":[e.name,Ee(e.size)].filter(Boolean).join(" ")||void 0},p.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(ye(e.name))}),p.createElement("div",{className:"k-file-info"},p.createElement("span",{className:"k-file-name"},e.name),p.createElement("span",{className:"k-file-size"},Ee(e.size))),p.createElement(a.Button,{fillMode:"flat",size:"xs",svgIcon:l.xCircleIcon,onClick:n=>{n.stopPropagation(),t(e.name)},"aria-label":`${r.toLanguageString($,Y[$])} ${e.name}`,title:`${r.toLanguageString($,Y[$])} ${e.name}`})))));return p.createElement("div",{className:"k-prompt-box-header"},f,h)},xe=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"15.2.0-develop.2",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning"}),Ie="k-prompt-box",Te={mode:"auto",rows:1,defaultValue:"",disabled:!1,readOnly:!1,loading:!1,uploadButtonConfig:!1,speechToTextButtonConfig:!0,actionButtonConfig:!0},Fe=p.forwardRef((e,t)=>{const a=!n.validatePackage(xe,{component:"PromptBox"}),s=n.getLicenseMessage(xe),r=o.useLocalization(),i={...Te,...e},{mode:c=Te.mode,fillMode:u,rows:m=Te.rows,maxTextAreaHeight:d,value:g,defaultValue:f=Te.defaultValue,disabled:h=Te.disabled,readOnly:v=Te.readOnly,placeholder:k,title:b,maxLength:y,inputAttributes:E,topAffix:C,startAffix:x,endAffix:I,header:T,onChange:F,onFocus:w,onBlur:S,onPromptAction:A,attachments:M,loading:R=Te.loading,uploadButtonConfig:N=Te.uploadButtonConfig,speechToTextButtonConfig:B=Te.speechToTextButtonConfig,actionButtonConfig:L=Te.actionButtonConfig,className:D,style:P,...z}=i,O=p.useRef(null),[$,V]=p.useState(f),[j,W]=p.useState([]),[G,_]=p.useState(!1),X=p.useRef(null),J=p.useRef(null),Q=p.useRef(0),Z=p.useRef(0),ee=p.useRef(!1),te=p.useRef(0),ne=p.useRef(0),ae=p.useCallback((e,t)=>e?"function"==typeof e?e(t):e:null,[]),le=void 0!==g,se=le?g:$,oe=void 0!==M,re=oe?M:j,ie=p.useMemo(()=>!!(null!=se&&se.trim()||re.length>0),[se,re.length]),ce=p.useCallback(()=>{if(!O.current||"single"===c)return;const e=O.current,t=globalThis.getComputedStyle(e),n=Number.parseFloat(t.lineHeight)||20,a=Number.parseFloat(t.paddingTop)||0,l=Number.parseFloat(t.paddingBottom)||0;Q.current=e.offsetHeight||n+a+l,Z.current=n*m+a+l,"auto"===c&&!G&&(ne.current=e.offsetWidth)},[c,m,G]),ue=p.useCallback(()=>"auto"===c?1:m,[c,m]),me=p.useCallback(e=>{if(d){const t=Number.parseInt(d,10);if(e>t)return t}return Math.max(Z.current,e)},[d]),de=p.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${Q.current}px`;const t=e.scrollHeight,n=me(t);e.style.height=`${n}px`,d&&t>Number.parseInt(d,10)&&(e.style.overflow="")},[me,d]),ge=p.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${Q.current}px`;const t=e.scrollHeight,n=d?Math.min(t,Number.parseInt(d,10)):t;e.style.height=`${n}px`,d&&t>Number.parseInt(d,10)&&(e.style.overflow="")},[d]),pe=p.useCallback(e=>{if(ne.current<=0)return!1;const t=e.style.height,n=e.style.width;e.style.overflow="hidden",e.style.width=`${ne.current}px`,e.style.height=`${Q.current}px`;const a=e.scrollWidth<=ne.current&&e.scrollHeight<=Q.current;return e.style.overflow="",e.style.width=n||"",e.style.height=t||"",a},[]),fe=p.useCallback((e,t)=>{if(!ee.current){if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!G)return ee.current=!0,void _(!0);if(G){ge(e);t<te.current&&pe(e)&&(e.style.height="",ee.current=!0,_(!1))}}},[G,ge,pe]),he=p.useCallback(()=>{var e;if("single"===c||!O.current)return;const t=O.current,n=(null==(e=t.value)?void 0:e.length)||0;"multi"===c?de(t):"auto"===c&&fe(t,n)},[c,de,fe]);p.useEffect(()=>{"single"!==c&&O.current&&ce()},[c,ce]),p.useEffect(()=>{"single"!==c&&O.current&&(ce(),he())},[m,c,ce,he]),p.useEffect(()=>{if("single"!==c&&O.current){const e=(null==se?void 0:se.length)||0;requestAnimationFrame(()=>{if(O.current){const t=O.current;"multi"===c?de(t):"auto"===c&&fe(t,e),te.current=e}})}},[se,c,de,fe]),p.useEffect(()=>{"auto"===c&&G&&O.current&&requestAnimationFrame(()=>{if(O.current){const e=O.current;ge(e),ee.current=!1}})},[G,c,ge]),p.useEffect(()=>{if("auto"===c&&O.current){const e=O.current;G||(e.style.height="",e.style.overflow="",ee.current=!1)}},[c,G]),p.useEffect(()=>{if("single"===c||!O.current)return;const e=O.current;let t;const n=new ResizeObserver(()=>{clearTimeout(t),t=setTimeout(()=>{O.current&&("auto"===c&&!G&&ce(),he())},50)});return n.observe(e),()=>{n.disconnect(),clearTimeout(t)}},[c,G,ce,he]);const ye=p.useCallback(()=>({focus:()=>{var e;return null==(e=O.current)?void 0:e.focus()},blur:()=>{var e;return null==(e=O.current)?void 0:e.blur()},element:O.current,get value(){return se}}),[se]);p.useImperativeHandle(t,ye);const Ee=p.useCallback(e=>{const t=e.target.value;!le&&!h&&V(t),F&&!h&&n.dispatchEvent(F,e,{...ye(),value:t},{value:t}),"single"!==c&&he()},[V,F,h,le,ye,c,he]),Fe=p.useCallback(e=>{w&&!h&&n.dispatchEvent(w,e,ye(),void 0)},[w,h,ye]),we=p.useCallback(e=>{S&&!h&&n.dispatchEvent(S,e,ye(),void 0)},[S,h,ye]),Se=p.useCallback(e=>{e.preventDefault()},[]),Ae=p.useCallback(e=>{A&&n.dispatchEvent(A,e,ye(),{value:se,attachments:re}),le||V(""),oe||W([])},[A,ye,se,re,le,oe]),Me=p.useCallback(e=>{if("Enter"!==e.key||!e.shiftKey){if("ArrowUp"===e.key||"ArrowDown"===e.key)return void e.stopPropagation();if("Enter"===e.key){if(e.preventDefault(),R)return;ie&&Ae(e)}}},[Ae,R,ie]),Re={disabled:h,readOnly:v,placeholder:k,title:b,maxLength:y,"aria-label":r.toLanguageString(q,Y[q]),value:se,onKeyDown:Me,...E,onChange:Ee,onFocus:Fe,onBlur:we,ref:O},Ne=p.useCallback(e=>{var t,a;const{isFinal:l,alternatives:s}=e;if(s.length>0){const e=s[0];if(l){const a=(null==(t=O.current)?void 0:t.value)||"",l=(a?`${a} `:"")+e.transcript;if(le||V(l),F&&!h){const e={target:O.current,currentTarget:O.current};n.dispatchEvent(F,e,{...ye(),value:l},{value:l})}}}null==(a=O.current)||a.focus()},[le,F,h,ye]),Be=p.useCallback(()=>{var e,t;null==(t=null==(e=X.current)?void 0:e.actionElement)||t.click()},[]),Le=p.useCallback(e=>{var t;const n=Array.from(e.affectedFiles),a="object"==typeof N&&N.onSelectAttachments;oe||W(e=>[...e,...n]),a&&a({selectedFiles:e.affectedFiles,allFiles:e.newState}),null==(t=O.current)||t.focus()},[N,oe]),De=p.useMemo(()=>({uploadButtonProps:{fillMode:"flat",svgIcon:l.paperclipIcon,size:"small",rounded:"full",onClick:Be,onFilesAdd:Le,files:re,uploadRef:X,"aria-label":r.toLanguageString(U,Y[U]),title:r.toLanguageString(U,Y[U]),_registerRemoveCallback:e=>{J.current=e}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:Ne},actionButtonProps:{rounded:"full",size:"small",svgIcon:R?l.stopIcon:l.arrowUpIcon,className:R?"k-generating k-active":"",onClick:Ae,onMouseDown:Se,disabled:!R&&!ie,"aria-label":R?r.toLanguageString(K,Y[K]):r.toLanguageString(H,Y[H]),title:R?r.toLanguageString(K,Y[K]):r.toLanguageString(H,Y[H]),"aria-live":"polite"}}),[Ne,Le,re,Ae,Se,R,Be,r,ie]),Pe=p.useCallback(e=>{oe||W(t=>t.filter(t=>t.name!==e));const t="object"==typeof N&&N.onRemoveAttachment;t&&(J.current=t),J.current&&J.current(e)},[N,oe]),ze=()=>{const e=!1!==B,t=!1!==L,n=!1!==N,a="object"==typeof B?B:void 0,l="object"==typeof N?N:{},{restrictions:s,multiple:o=!0,accept:r,onSelectAttachments:i,onRemoveAttachment:c,...u}=l,m={restrictions:s,multiple:o,accept:r},d="object"==typeof L?L:void 0;return p.createElement(p.Fragment,null,n&&p.createElement(ve,{...De.uploadButtonProps,restrictions:m.restrictions,multiple:m.multiple,accept:m.accept,...u}),e&&p.createElement(be,{...De.speechToTextButtonProps,...a}),t&&p.createElement(ke,{...De.actionButtonProps,...d}))},Oe="multi"===c||"auto"===c&&G,qe=!1!==N||!1!==B||!1!==L,He=I||qe,Ue=x||I||qe;return p.createElement("div",{...z,className:n.classNames(D,"k-input",Ie,{[`k-input-${u}`]:u,"k-disabled":h,"k-prompt-box-singleline":"single"===c,"k-prompt-box-multiline":Oe}),style:P},p.createElement(Ce,{files:re,onRemoveFile:Pe,header:T}),"single"===c?p.createElement("div",{className:`${Ie}-content`},x&&p.createElement("div",{className:`${Ie}-affix`},ae(x,De)),p.createElement("input",{...Re,className:n.classNames("k-input-inner",`${Ie}-input`)}),He?p.createElement("div",{className:`${Ie}-affix`},I&&ae(I,De),ze()):null):p.createElement("div",{className:`${Ie}-content`},"multi"===c&&C&&p.createElement("div",{className:`${Ie}-affix`},ae(C,De)),"auto"===c&&!G&&x&&p.createElement("div",{className:`${Ie}-affix`},ae(x,De)),p.createElement("textarea",{...Re,className:n.classNames("k-input-inner",`${Ie}-textarea`),rows:ue(),style:d?{maxHeight:d}:{},"aria-multiline":"true"}),"auto"===c&&!G&&He?p.createElement("div",{className:`${Ie}-affix`},I&&ae(I,De),ze()):null,Oe&&Ue?p.createElement("div",{className:`${Ie}-affix`},x&&ae(x,De),(x||I)&&p.createElement("div",{className:"k-spacer"}),I&&ae(I,De),ze()):null),a&&p.createElement(n.WatermarkOverlay,{message:s}))});Fe.propTypes={value:r.string,defaultValue:r.string,mode:r.oneOf(["single","multi","auto"]),rows:r.number,maxTextAreaHeight:r.string,title:r.string,disabled:r.bool,readOnly:r.bool,placeholder:r.string,maxLength:r.number,inputAttributes:r.object,fillMode:r.oneOf(["solid","flat","outline"]),topAffix:r.oneOfType([r.func,r.element,r.string]),startAffix:r.oneOfType([r.func,r.element,r.string]),endAffix:r.oneOfType([r.func,r.element,r.string]),header:r.oneOfType([r.func,r.element,r.string]),onChange:r.func,onFocus:r.func,onBlur:r.func,loading:r.bool,uploadButtonConfig:r.oneOfType([r.bool,r.object]),speechToTextButtonConfig:r.oneOfType([r.bool,r.object]),actionButtonConfig:r.oneOfType([r.bool,r.object]),attachments:r.array,onPromptAction:r.func,className:r.string,style:r.object},Fe.displayName="KendoPromptBox";const we=p.memo(({affixProps:e,uploadConfig:t,localizationService:n,onFilesSelect:a,onFileRemove:l})=>{const s="object"==typeof t?t:{};return!1!==t?p.createElement(ve,{...e.uploadButtonProps,fillMode:"clear","aria-label":n.toLanguageString(R,Y[R]),title:n.toLanguageString(R,Y[R]),...s,onSelectAttachments:a,onRemoveAttachment:l}):null});we.displayName="UploadButtonAffix";const Se=p.forwardRef((e,t)=>{const{onSendMessage:s,isDirectionRightToLeft:r,placeholder:i,MessageBox:c,suggestions:u,onSuggestionClick:m,inputValue:d,onInputValueChange:g,suggestionTemplate:h,sendButtonConfig:k,onInputClick:b,suggestionsLayout:y,dir:E,messageBoxSettings:C,loading:x}=e,{replyToMessage:I,setReplyToMessage:T,user:w,speechToTextConfig:S,uploadConfig:A}=ne(),[M,R]=p.useState(""),[N,B]=p.useState([]),L=p.useRef(null),D=o.useLocalization(),P=void 0!==d,z=P?d:M,q=p.useCallback(()=>{null!==L.current&&L.current.focus()},[]);p.useEffect(()=>{I&&q()},[I,q]);const H=p.useCallback(e=>{if(e.preventDefault(),s){const t={id:"",author:w,text:z||"",timestamp:new Date,replyToId:I?I.id:void 0,files:N.map(e=>({name:e.name,size:e.size,type:e.extension,rawFile:e.getRawFile?e.getRawFile():e}))};T(null),s(t,e),B([]),P||R(""),g&&g(""),q()}},[s,z,w,I,N,T,g,q,P]);p.useImperativeHandle(t,()=>({focusInput:q}),[q]);const U=p.useCallback(e=>{B(t=>t.filter(t=>t.name!==e))},[]),$=p.useCallback((e,t)=>e.isDeleted?J(t,D):e.text,[D]),K=p.useCallback(()=>{if(I){const e=X(w,I);return p.createElement("div",{className:n.classNames("k-message-reference",e?"k-message-reference-sender":"k-message-reference-receiver")},p.createElement("div",{className:"k-message-reference-content"},$(I,e)),p.createElement("span",{className:"k-spacer"}),p.createElement(a.Button,{fillMode:"flat",size:"xs",svgIcon:l.xCircleIcon,onClick:()=>T(null),"aria-label":D.toLanguageString(F,Y[F]),title:D.toLanguageString(F,Y[F])}))}return null},[I,w,$,T,D]),V=p.useCallback(e=>{try{const t=Array.from(e.allFiles);B(t)}catch{}},[]),j=p.useCallback(e=>{const t=e.value;P||R(t),g&&g(t||"")},[P,g]),W=p.useCallback(e=>{H(e.syntheticEvent)},[H]),G=p.useCallback(e=>e?"function"==typeof e?e():e:null,[]),_=p.useCallback(e=>p.createElement(p.Fragment,null,p.createElement(we,{affixProps:e,uploadConfig:A,localizationService:D,onFilesSelect:V,onFileRemove:U}),G(null==C?void 0:C.startAffix)),[A,D,V,U,null==C?void 0:C.startAffix,G]),Q=p.useCallback(()=>G(null==C?void 0:C.endAffix),[null==C?void 0:C.endAffix,G]),Z=p.useCallback(()=>G(null==C?void 0:C.topAffix),[null==C?void 0:C.topAffix,G]),ee=p.useMemo(()=>{const e="object"==typeof k?k:{},t=!1!==k&&{"aria-label":x?D.toLanguageString(O,Y[O]):D.toLanguageString(f,Y[f]),title:x?D.toLanguageString(O,Y[O]):D.toLanguageString(f,Y[f]),dir:r?"rtl":void 0,...e};return p.createElement(Fe,{header:K(),ref:L,placeholder:i,value:z,onChange:j,onPromptAction:W,mode:(null==C?void 0:C.mode)||"multi",rows:(null==C?void 0:C.rows)||2,maxTextAreaHeight:(null==C?void 0:C.maxTextAreaHeight)||"110",loading:x,speechToTextButtonConfig:S,actionButtonConfig:t,attachments:N,startAffix:_,endAffix:null!=C&&C.endAffix?Q:void 0,topAffix:null!=C&&C.topAffix?Z:void 0,inputAttributes:{onClick:b,"aria-label":D.toLanguageString(v,Y[v])}})},[i,z,j,W,C,x,S,k,N,K,_,Q,Z,D,r,b]);return p.createElement("div",{className:"k-message-box-wrapper"},u&&u.length>0&&p.createElement(he,{onSuggestionClick:m,suggestions:u,suggestionTemplate:h,suggestionsLayout:y,dir:E}),c?p.createElement(c,{messageInput:ee}):ee)});Se.displayName="NewMessage";const Ae=e=>p.createElement(a.Toolbar,{className:"k-chat-header",size:"small"},e.children),Me=e=>{const{message:t,onUnpin:s,user:r,onReferencedMessageClick:i}=e,c=o.useLocalization(),u=p.useRef(null),m=r&&X(r,t),d=p.useCallback(e=>{e.preventDefault(),e.stopPropagation(),null==i||i(t.id)},[t.id,i]);return p.createElement("div",{ref:u,className:`k-message-reference ${m?"k-message-reference-sender":"k-message-reference-receiver"} k-message-pinned`,onClick:d},p.createElement(n.IconWrap,{icon:l.pinIcon}),p.createElement("div",{className:"k-message-reference-content"},t.isDeleted?r&&J(X(r,t),c):t.text),p.createElement("span",{className:"k-spacer"}),p.createElement(a.Button,{fillMode:"flat",size:"xs",svgIcon:l.xCircleIcon,onClick:e=>{e.stopPropagation(),null==s||s(t)},"aria-label":c.toLanguageString("chat.unpinMessage",Y["chat.unpinMessage"])}))},Re=e=>{const{show:t,text:n}=e;return p.createElement("div",{style:{position:"absolute",top:"90%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e3,pointerEvents:t?"auto":"none"}},p.createElement(c.Fade,null,t&&p.createElement(u.Notification,{type:{style:"inverse"},closable:!1},p.createElement("span",null,n))))},Ne={textField:"text",statusField:"status",authorIdField:"authorId",authorNameField:"authorName",authorImageUrlField:"authorImageUrl",authorImageAltTextField:"authorImageAltText",idField:"id",timestampField:"timestamp",filesField:"files",attachmentsField:"attachments",replyToIdField:"replyToId",isDeletedField:"isDeleted",isPinnedField:"isPinned",typingField:"typing",suggestedActionsField:"suggestedActions",isFailedField:"isFailed"},Be=(e,t={})=>{const n={...Ne,...t};let a,l;a=e.author&&"object"==typeof e.author?{id:e.author.id||e.author[n.authorIdField]||e[n.authorIdField]||"",name:e.author.name||e.author[n.authorNameField]||e[n.authorNameField],avatarUrl:e.author.avatarUrl||e.author[n.authorImageUrlField]||e[n.authorImageUrlField],avatarAltText:e.author.avatarAltText||e.author[n.authorImageAltTextField]||e[n.authorImageAltTextField]}:{id:e[n.authorIdField]||e.authorId||"",name:e[n.authorNameField]||e.authorName,avatarUrl:e[n.authorImageUrlField]||e.authorImageUrl,avatarAltText:e[n.authorImageAltTextField]||e.authorImageAltText},l=e.timestamp?new Date(e.timestamp):e[n.timestampField]?new Date(e[n.timestampField]):new Date;const s={id:void 0!==e.id?e.id:e[n.idField],text:void 0!==e.text?e.text:e[n.textField]||"",author:a,timestamp:l,status:void 0!==e.status?e.status:e[n.statusField],attachments:void 0!==e.attachments?e.attachments:e[n.attachmentsField],attachmentLayout:e.attachmentLayout||"list",suggestedActions:void 0!==e.suggestedActions?e.suggestedActions:e[n.suggestedActionsField],isPinned:void 0!==e.isPinned?e.isPinned:e[n.isPinnedField]||!1,typing:void 0!==e.typing?e.typing:e[n.typingField],files:void 0!==e.files?e.files:e[n.filesField]||[],isFailed:void 0!==e.isFailed?e.isFailed:e[n.isFailedField]||!1};return e.pinnedAt&&(s.pinnedAt=new Date(e.pinnedAt)),e.pinnedBy&&(s.pinnedBy=e.pinnedBy),void 0!==e.replyToId?s.replyToId=e.replyToId:void 0!==e[n.replyToIdField]&&(s.replyToId=e[n.replyToIdField]),void 0!==e.isDeleted?s.isDeleted=e.isDeleted:void 0!==e[n.isDeletedField]&&(s.isDeleted=e[n.isDeletedField]),{...s,dataItem:e}},Le=(e,t={})=>Array.isArray(e)?e.map(e=>Be(e,t)):[],De=e=>e&&void 0!==e.id&&"string"==typeof e.text&&e.author&&"object"==typeof e.author&&void 0!==e.author.id&&(e.timestamp instanceof Date||"string"==typeof e.timestamp||"number"==typeof e.timestamp),Pe=e=>{e.scrollTop=e.scrollHeight-e.clientHeight},ze=({viewItemsWrapperRef:e,isKeyboardNavigationActiveRef:t,processedMessages:n,authorId:a,autoScrollThreshold:l,isEndless:s=!1,isOnLastBatch:o=!0,skipAutoScrollRef:r})=>{var i;const c=p.useRef(a),u=p.useRef(l),m=p.useRef(s),d=p.useRef(o);p.useEffect(()=>{c.current=a,u.current=l,m.current=s,d.current=o});const g=p.useRef(!1);p.useEffect(()=>{s||!e.current||0===n.length||g.current||(Pe(e.current),g.current=!0)},[e,s,n.length]);const f=p.useRef(void 0),h=p.useRef(0),v=p.useRef(!0),k=p.useRef(!0),b=p.useRef(!1),y=p.useRef(null),E=(n.length>0?null==(i=n.at(-1))?void 0:i.id:void 0)!==f.current,C=n.length>h.current;if(E||C){const t=e.current;k.current=!t||(e=>{const{scrollHeight:t,scrollTop:n,clientHeight:a}=e;return!(t>a)||t-n-a<=100})(t)}p.useEffect(()=>{var a,l;const s=n.length,o=s>0?null==(a=n[s-1])?void 0:a.id:void 0,i=f.current,g=h.current,p=v.current;if(f.current=o,h.current=s,v.current=!1,0===s)return;const E=e.current;if(!E||t.current)return;if(p||o===i)return void(!m.current&&(p||s>g)&&(Pe(E),b.current=!1,y.current=null));if(m.current&&!d.current)return;if(null!=r&&r.current)return void(r.current=!1);const C=n[s-1];if(void 0!==c.current&&void 0!==(null==(l=null==C?void 0:C.author)?void 0:l.id)&&String(C.author.id)===String(c.current))return E.scrollTo({top:E.scrollHeight-E.clientHeight,behavior:"smooth"}),b.current=!1,void(y.current=null);if(!k.current)return b.current=!1,void(y.current=null);const x=(e=>{const t=e.querySelectorAll(".k-message");return t.length>0?t[t.length-1]:null})(E);if(!x)return;const I=(e=>{const t=e.querySelector(".k-message-pinned");return t?t.offsetHeight:0})(E),T=Math.max(0,E.clientHeight-I),F=((e,t)=>{const n=null!=e?e:"20%";let a;if("number"==typeof n)a=n;else{const e=/^(-?\d+(?:\.\d+)?)%$/.exec(String(n));if(e)a=Number.parseFloat(e[1])/100*t;else{const e=Number.parseFloat(String(n));a=Number.isNaN(e)?.2*t:e}}return Math.min(a,t)})(u.current,T),w=x.getBoundingClientRect().top-E.getBoundingClientRect().top+E.scrollTop,S=Math.max(0,w-F-I),A=Math.max(0,E.scrollHeight-E.clientHeight),M=Math.min(S,A);M>E.scrollTop&&E.scrollTo({top:M,behavior:"smooth"}),y.current=S,b.current=!0},[n,e,t]),p.useEffect(()=>{const n=e.current;if(!n)return;let a=n.querySelectorAll(".k-message").length,l=n.scrollHeight,s=n.scrollTop;const o=()=>{const e=n.scrollTop;b.current&&e<s&&(b.current=!1,y.current=null),s=e},r=new MutationObserver(()=>{if(t.current)return;const e=n.querySelectorAll(".k-message").length,o=n.scrollHeight;if(e===a&&o>l&&b.current){const e=o-n.clientHeight,t=y.current,a=null===t?e:Math.min(e,t);a>n.scrollTop&&(n.scrollTop=a),s=n.scrollTop}a=e,l=o});return r.observe(n,{childList:!0,subtree:!0,characterData:!0}),n.addEventListener("scroll",o,{passive:!0}),()=>{r.disconnect(),n.removeEventListener("scroll",o)}},[e,t])},Oe=["allowMessageCollapse","messageWidthMode","showAvatar","showUsername","messageTemplate","messageContentTemplate","messageToolbarActions","messageContextMenuActions","fileActions"];function qe(e,t,n,a,l){const s=((e,t)=>{var n,a;return(null==(n=null==e?void 0:e.author)?void 0:n.id)===t||(null==(a=null==e?void 0:e.author)?void 0:a.id)===String(t)})(e,t)?a:l,o={};return Oe.forEach(e=>{var t;o[e]=null!=(t=null==s?void 0:s[e])?t:null==n?void 0:n[e]}),o}const He=({scrollMode:e,processedMessages:t,total:n,pageSize:a=50,startIndex:l,endIndex:s,onLoadMoreMessages:o,onReferencedMessageClick:r,viewItemsWrapperRef:i,authorId:c})=>{const u=p.useRef(!1),m="endless"===e,d=null!=n?n:t.length,g=m&&t.length===d&&!u.current,f=m&&(t.length<d||u.current);f&&(u.current=!0);const[h,v]=p.useState(-1),[k,b]=p.useState(-1),y=p.useRef(h),E=p.useRef(k);y.current=h,E.current=k;const C=p.useRef(!1),x=p.useRef(0),I=p.useRef(0),T=p.useRef(0),F=p.useRef(!1),w=p.useRef(d),S=p.useRef(c);S.current=c;const A=p.useRef(!1),M=p.useRef(null),R=p.useRef(!1),N=p.useRef(!1),B=p.useRef(!0),L=p.useRef(d);p.useEffect(()=>{if(g){if(u.current)return void((-1===h||-1===k)&&(v(0),b(t.length)));if(-1===h||-1===k){const e=Math.max(0,t.length-a),n=t.length;v(e),b(n)}else if(k<t.length){const e=w.current;if(E.current>=e)b(t.length);else if(t.length>e&&t.slice(e).some(e=>{var t;return void 0!==(null==(t=e.author)?void 0:t.id)&&String(e.author.id)===String(S.current)})){const e=Math.max(0,t.length-a);v(e),b(t.length),R.current=!0}}w.current=d}},[g,t.length,a,h,k,d]);const D=null!=l?l:0,P=null!=s?s:t.length,z=p.useCallback(()=>{const e=i.current;e&&(x.current=e.scrollHeight,I.current=e.scrollTop,T.current=e.querySelectorAll("[data-message-id]").length)},[i]),O=p.useCallback(e=>{var t,n,a;((e,t,n=0)=>{if(!t)return;const a=t.querySelector(`[data-message-id="${e}"]`);if(!a)return;const l=t.querySelector(".k-message-list");if(l){const e=l.getBoundingClientRect().top,t=a.getBoundingClientRect().top,s=l.scrollTop+(t-e)-n;l.scrollTo({top:s,behavior:"smooth"})}else a.scrollIntoView({behavior:"smooth",block:"start"})})(e,null==(t=i.current)?void 0:t.closest(".k-chat"),(null==(a=null==(n=i.current)?void 0:n.querySelector(".k-message-pinned"))?void 0:a.offsetHeight)||0)},[i]);p.useLayoutEffect(()=>{if(!F.current)return;const e=i.current;if(!e)return void(F.current=!1);if(e.querySelectorAll("[data-message-id]").length<=T.current)return;const t=e.scrollHeight-x.current;t>0&&(e.scrollTop=I.current+t),F.current=!1,C.current=!1}),p.useLayoutEffect(()=>{if(!R.current)return;const e=i.current;e?k>=t.length&&k>0&&(R.current=!1,e.scrollTop=e.scrollHeight-e.clientHeight):R.current=!1});const q=p.useRef(!1);p.useLayoutEffect(()=>{if(!m||q.current)return;const e=i.current;e&&e.querySelector("[data-message-id]")&&(e.scrollTop=e.scrollHeight-e.clientHeight,q.current=!0)}),p.useEffect(()=>{if(!m)return;const e=i.current;if(!e)return;let n=e.scrollTop;const l=()=>{const{scrollTop:l,scrollHeight:s,clientHeight:r}=e,i=l<n,c=l>n;if(n=l,!C.current){if(i&&l<=100)if(g){const e=y.current;if(e>0){const t=Math.max(0,e-a);F.current=!0,z(),v(t),null==o||o({startIndex:t,endIndex:E.current})}}else if(f&&D>0){C.current=!0;const e=Math.max(0,D-a);F.current=!0,z(),null==o||o({startIndex:e,endIndex:P})}if(c&&s-l-r<=100)if(g){const e=E.current;if(e<t.length){const n=Math.min(t.length,e+a);N.current=!0,b(n),null==o||o({startIndex:y.current,endIndex:n})}}else if(f&&P<d){C.current=!0,N.current=!0;const e=Math.min(d,P+a);null==o||o({startIndex:D,endIndex:e})}}};return e.addEventListener("scroll",l,{passive:!0}),()=>e.removeEventListener("scroll",l)},[m,g,f,i,a,t.length,D,P,d,o]),p.useEffect(()=>{var e;const n=P>=d;if(!f)return L.current=d,void(B.current=n);const a=L.current,l=B.current;if(L.current=d,B.current=n,d>a&&!l&&n){const n=t[t.length-1];void 0!==S.current&&void 0!==(null==(e=null==n?void 0:n.author)?void 0:e.id)&&String(n.author.id)===String(S.current)&&(A.current=!0,N.current=!0)}},[f,d,P,t]),p.useEffect(()=>{!f||!A.current||(A.current=!1,C.current=!1,requestAnimationFrame(()=>{const e=i.current;e&&(e.scrollTop=e.scrollHeight-e.clientHeight)}))},[f,t,i]),p.useEffect(()=>{if(!f||null===M.current)return;const e=M.current,t=i.current;t&&t.querySelector(`[data-message-id="${e}"]`)&&(M.current=null,C.current=!1,requestAnimationFrame(()=>{O(e)}))},[f,t,i,O]),p.useEffect(()=>{f&&C.current&&!F.current&&(C.current=!1)},[f,D,P]);const H=p.useMemo(()=>{if(g){const e=Math.max(0,h),n=Math.min(t.length,k);if(e>=n){const e=Math.max(0,t.length-a);return t.slice(e)}return t.slice(e,n)}return t},[g,t,h,k,a]),U=p.useMemo(()=>!m||(g?k>=t.length:P>=d),[m,g,k,t.length,P,d]),$=p.useCallback(()=>{if(!m||U){const e=i.current;return void(e&&e.scrollTo({top:e.scrollHeight-e.clientHeight,behavior:"smooth"}))}if(!C.current)if(g){const e=Math.max(0,t.length-a);v(e),b(t.length),null==o||o({startIndex:e,endIndex:t.length}),requestAnimationFrame(()=>{const e=i.current;e&&(e.scrollTop=e.scrollHeight-e.clientHeight)})}else if(f){A.current=!0,F.current=!1,C.current=!0;const e=Math.max(0,d-a);null==o||o({startIndex:e,endIndex:d})}},[m,g,f,U,t.length,a,d,o,i]),K=p.useCallback(e=>{if(m){if(g){const n=i.current;if(null==n?void 0:n.querySelector(`[data-message-id="${e}"]`))O(e);else{if(C.current)return;const n=t.findIndex(t=>t.id===e||String(t.id)===String(e));if(n>=0){const l=Math.floor(a/2),s=Math.max(0,n-l),o=Math.min(t.length,s+a);C.current=!0,v(s),b(o),requestAnimationFrame(()=>{requestAnimationFrame(()=>{O(e),C.current=!1})})}}}else if(f){const t=i.current;if(null==t?void 0:t.querySelector(`[data-message-id="${e}"]`))O(e);else{if(C.current)return;M.current=e,F.current=!1,C.current=!0}}}else O(e);null==r||r({id:e})},[m,g,f,i,t,a,r,O]);return{renderedMessages:H,handleScrollToBottom:$,handleReferencedMessageClick:K,isEndless:m,isOnLastBatch:U,skipAutoScrollRef:N}},Ue=p.forwardRef((e,t)=>{const{messages:s=[],messageTemplate:r,messageContentTemplate:i,attachmentTemplate:c,width:u,height:m,onSendMessage:d,onSuggestionClick:g,onInputValueChange:f,onActionExecute:h,dir:v,messageBox:k,placeholder:y,className:E,style:C,message:x=le,authorId:T,suggestions:F,suggestionTemplate:w,suggestionsLayout:S="scroll",quickActionsLayout:A="scroll",inputValue:M,headerTemplate:R,noDataTemplate:N,timestampTemplate:B,statusTemplate:L,userStatusTemplate:P,allowMessageCollapse:z,messageToolbarActions:O,messageContextMenuActions:q,fileActions:H,onUnpin:U,messageWidthMode:$,showAvatar:K,showUsername:V,timestampVisibility:j,authorMessageSettings:W,receiverMessageSettings:G,onToolbarAction:_,onContextMenuAction:X,onFileAction:J,onDownload:Q,speechToTextConfig:Z,uploadConfig:ee,sendButtonConfig:ne,messageFilesLayout:ae,scrollToBottomButton:se=!0,autoScrollThreshold:re,textField:ie,statusField:ce,authorIdField:ue,authorNameField:de,authorImageUrlField:he,authorImageAltTextField:ve,idField:ke,timestampField:be,filesField:ye,attachmentsField:Ee,replyToIdField:Ce,isDeletedField:Ie,isPinnedField:Te,typingField:Fe,suggestedActionsField:we,isFailedField:Ne,onResendMessage:Be,messageBoxSettings:Pe,loading:Oe,scrollMode:Ue,total:$e,pageSize:Ke,startIndex:Ve,endIndex:je,onLoadMoreMessages:We,pinnedMessages:Ge,repliedToMessages:_e,onReferencedMessageClick:Ye,...Xe}=e,Je=p.useRef(null);n.useWebMcpRegister("chat",Je,e,e.webMcp);const[Qe,Ze]=p.useState(null),[et,tt]=p.useState(!1),[nt,at]=p.useState(!1),[lt,st]=p.useState(null),[ot,rt]=p.useState(null),[it,ct]=p.useState(!1),ut=p.useRef(null),mt=p.useRef(null),dt=p.useRef(null),gt=p.useRef(null),pt=p.useRef(void 0),ft=p.useRef(!1),ht=p.useRef(null),vt=p.useRef(""),kt=p.useMemo(()=>{if(!s||0===s.length)return[];const e={textField:ie,statusField:ce,authorIdField:ue,authorNameField:de,authorImageUrlField:he,authorImageAltTextField:ve,idField:ke,timestampField:be,filesField:ye,attachmentsField:Ee,replyToIdField:Ce,isDeletedField:Ie,isPinnedField:Te,typingField:Fe,suggestedActionsField:we,isFailedField:Ne};return!Object.values(e).some(e=>void 0!==e)&&De(s[0])?s.map(e=>({...e,timestamp:e.timestamp?new Date(e.timestamp):e.timestamp})):Le(s,e)},[s,ie,ce,ue,de,he,ve,ke,be,ye,Ee,Ce,Ie,Te,Fe,we,Ne]);p.useEffect(()=>{if(T===vt.current&&ht.current)rt(ht.current);else if(T&&kt.length>0){const e=kt.find(e=>e.author&&(e.author.id===T||e.author.id===String(T))),t=(null==e?void 0:e.author)||{id:T};ht.current=t,vt.current=T,rt(t)}},[T,kt]);const{renderedMessages:bt,handleScrollToBottom:yt,handleReferencedMessageClick:Et,isEndless:Ct,isOnLastBatch:xt,skipAutoScrollRef:It}=He({scrollMode:Ue,processedMessages:kt,total:$e,pageSize:Ke,startIndex:Ve,endIndex:je,onLoadMoreMessages:We,onReferencedMessageClick:Ye,viewItemsWrapperRef:dt,authorId:T}),Tt=p.useMemo(()=>bt.length>0?(e=>{const t=e.slice().reduce(oe(e.length),[]);return function(e){let t=0;e.forEach(e=>{"message-group"===e.type?e.messages.forEach(e=>{e.selectionIndex=t++}):("attachment-group"===e.type||"action-group"===e.type)&&(e.selectionIndex=t++)}),e.lastSelectionIndex=t-1}(t),t})(bt):[],[bt]),Ft=p.useMemo(()=>!n.validatePackage(xe,{component:"Chat"}),[]),wt=n.getLicenseMessage(xe),St=p.useMemo(()=>{if(Ge)return Ge.find(e=>e.isPinned);const e=kt.find(e=>e.isPinned);return e||void 0},[kt,Ge]),At=o.useLocalization();ze({viewItemsWrapperRef:dt,isKeyboardNavigationActiveRef:ft,processedMessages:bt,authorId:T,autoScrollThreshold:re,isEndless:Ct,isOnLastBatch:xt,skipAutoScrollRef:It});const Mt=(({elementRef:e})=>{const[t,n]=p.useState(!1);return p.useEffect(()=>{const t=e.current;if(!t)return;const a=()=>{n(t.scrollHeight>t.clientHeight)};a();const l=new ResizeObserver(a);l.observe(t);const s=new MutationObserver(()=>{requestAnimationFrame(a)});return s.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{l.disconnect(),s.disconnect()}},[e]),t})({elementRef:dt}),Rt=p.useCallback(()=>{clearTimeout(pt.current)},[]),Nt=p.useCallback(()=>{pt.current=window.setTimeout(()=>{Ze(null)},0)},[]),Bt=p.useCallback(e=>{Ze(e)},[]),Lt=p.useCallback(e=>{let t=null;const a=null!==Qe?Qe:Tt.lastSelectionIndex;e.keyCode===n.Keys.up?null===a?t=0:a>0&&(t=a-1):e.keyCode===n.Keys.down?null===a?t=0:a<Tt.lastSelectionIndex&&(t=a+1):e.keyCode===n.Keys.home?t=0:e.keyCode===n.Keys.end&&(t=Tt.lastSelectionIndex),null!==t&&(Ze(t),ft.current=!0,e.preventDefault())},[Qe,Tt]),Dt=p.useCallback((e,t,n)=>{var a;if(h&&h({action:{value:e.value,title:e.title,type:e.type},syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget}),!t.isDefaultPrevented()){switch(e.type){case"reply":d&&d({message:{id:"",author:ot,text:e.value,timestamp:new Date},syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget});break;case"call":window.open("tel:"+e.value);break;case"openUrl":window.open(e.value)}null==(a=gt.current)||a.focusInput()}},[h,d,ot]),Pt=p.useCallback(()=>n.classNames("k-chat",E,{"k-rtl":et}),[E,et]),zt=p.useCallback(()=>{const e=Tt.length-1;return Tt.map((t,n)=>{var a,l,s,o,u,m;if("date-marker"===t.type)return p.createElement(pe,{item:t,key:t.trackBy,timestampTemplate:B});if("message-group"===t.type){const s={allowMessageCollapse:z,messageWidthMode:$,showAvatar:K,showUsername:V,messageTemplate:r,messageContentTemplate:i,messageToolbarActions:O,messageContextMenuActions:q,fileActions:H},o=qe(null==(a=t.messages)?void 0:a[0],T,s,W,G);return p.createElement(fe,{group:t,itemTemplate:o.messageTemplate,contentTemplate:o.messageContentTemplate,attachmentTemplate:c,user:ot,selectedItemIndex:Qe,onRequestSelection:Bt,isLastGroup:n===e,key:null!=(l=t.messages[0].id)?l:t.messages[0].selectionIndex,message:x,allowMessageCollapse:o.allowMessageCollapse,messageToolbarActions:o.messageToolbarActions,messageContextMenuActions:o.messageContextMenuActions,fileActions:o.fileActions,messageWidthMode:o.messageWidthMode,showAvatar:o.showAvatar,showUsername:o.showUsername})}return"attachment-group"===t.type?p.createElement(ge,{group:t,itemTemplate:c,onRequestSelection:Bt,selected:t.selectionIndex===Qe,isLastGroup:n===e,key:`att-${null!=(o=null==(s=t.trackBy)?void 0:s.id)?o:t.selectionIndex}`}):"action-group"===t.type?p.createElement(me,{group:t,onActionExecute:Dt,onRequestSelection:Bt,selected:t.selectionIndex===Qe,key:`act-${null!=(m=null==(u=t.trackBy)?void 0:u.id)?m:t.selectionIndex}`,quickActionsLayout:A,dir:v}):null})},[Tt,B,r,i,c,ot,Qe,Bt,x,z,O,q,H,$,K,V,T,W,G,Dt,A,v]),Ot=p.useCallback(()=>R?"function"==typeof R?R():R:null,[R]),qt=p.useCallback(()=>N?"function"==typeof N?N():N:null,[N]);p.useEffect(()=>{const e=void 0!==v?"rtl"===v:ut.current&&"rtl"===getComputedStyle(ut.current).direction;tt(!!e)},[v]),p.useEffect(()=>()=>{clearTimeout(pt.current)},[]),p.useEffect(()=>{if(!se||!dt.current)return;let e,t;const n=()=>{e=void 0;const n=dt.current;if(!n)return;const{scrollHeight:a,scrollTop:l,clientHeight:s}=n;!(a>s)||a-l-s<=100?(void 0!==t&&(clearTimeout(t),t=void 0),ct(!1)):null!=t||(t=setTimeout(()=>{t=void 0,ct(!0)},300))},a=()=>{void 0===e&&(e=requestAnimationFrame(n))},l=dt.current;l.addEventListener("scroll",a,{passive:!0});const s=new MutationObserver(a);return s.observe(l,{childList:!0,subtree:!0,characterData:!0}),()=>{l.removeEventListener("scroll",a),s.disconnect(),void 0!==e&&cancelAnimationFrame(e),void 0!==t&&clearTimeout(t)}},[se]);const Ht=p.useMemo(()=>({replyToMessage:lt,setReplyToMessage:st,messages:kt,repliedToMessages:_e,user:ot,internalScrollContainerRef:mt,messageListScrollContainerRef:dt,onToolbarAction:_,onContextMenuAction:X,onFileAction:J,setShowCopyNotification:at,onDownload:Q,onResendMessage:Be,fileActions:H,speechToTextConfig:Z,uploadConfig:ee,statusTemplate:L,userStatusTemplate:P,messageFilesLayout:ae,timestampVisibility:j,onReferencedMessageClick:Et}),[lt,st,kt,_e,ot,_,X,J,at,Q,Be,H,Z,ee,L,P,ae,j,Et]);return p.createElement(te.Provider,{value:Ht},p.createElement("div",{style:{width:u,height:m,position:"relative",overflow:"hidden",...C},onKeyDown:Lt,className:Pt(),ref:e=>{ut.current=e,mt.current=e,"function"==typeof t?t(e):t&&(t.current=e)},...Xe},void 0!==R&&p.createElement(Ae,null,Ot()),p.createElement("div",{className:"k-message-list",onBlur:Nt,onFocus:Rt,role:"log","aria-label":At.toLanguageString(b,Y[b]),"aria-live":"polite",ref:dt,style:{scrollBehavior:"auto"}},St&&p.createElement(Me,{message:St,onUnpin:U,user:ot,onReferencedMessageClick:Et}),p.createElement("div",{className:n.classNames("k-message-list-content",{"k-message-list-content-empty":0===bt.length})},0===bt.length&&void 0!==N&&qt(),bt.length>0&&zt()),se&&(it||!xt)&&p.createElement("div",{className:"k-chat-scroll-to-bottom-container"},p.createElement(a.FloatingActionButton,{svgIcon:l.arrowDownIcon,size:"small",themeColor:"base",rounded:"full",onClick:yt,"aria-label":At.toLanguageString(D,Y[D]),title:At.toLanguageString(D,Y[D])}))),Mt&&p.createElement("div",{className:"k-separator"}),p.createElement(Se,{onSendMessage:(e,t)=>{d&&d({message:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})},onSuggestionClick:e=>{g&&g(e)},isDirectionRightToLeft:et,ref:gt,placeholder:y,MessageBox:k,suggestions:F,suggestionTemplate:w,inputValue:M,onInputValueChange:e=>{f&&f(e)},onInputClick:()=>{ft.current=!1},sendButtonConfig:ne,suggestionsLayout:S,dir:v,messageBoxSettings:Pe,loading:Oe}),p.createElement(Re,{show:nt,text:At.toLanguageString(I,Y[I])}),Ft&&p.createElement(n.WatermarkOverlay,{message:wt})))});Ue.displayName="Chat",Ue.propTypes={messages:r.arrayOf(r.object),user:r.object,messageTemplate:r.any,messageContentTemplate:r.any,attachmentTemplate:r.any,width:r.oneOfType([r.string,r.number]),style:r.object,onSendMessage:r.func,onActionExecute:r.func,dir:r.string,messageBox:r.any,noDataTemplate:r.oneOfType([r.element,r.func]),suggestionsLayout:r.oneOf(["scroll","wrap","scrollbuttons"]),quickActionsLayout:r.oneOf(["scroll","wrap","scrollbuttons"]),userStatusTemplate:r.elementType,messageFilesLayout:r.oneOf(["vertical","wrap","horizontal"]),showAvatar:r.bool,showUsername:r.bool,authorMessageSettings:r.object,receiverMessageSettings:r.object,scrollMode:r.oneOf(["scrollable","endless"]),total:r.number,pageSize:r.number,startIndex:r.number,endIndex:r.number,onLoadMoreMessages:r.func,pinnedMessages:r.arrayOf(r.object),repliedToMessages:r.arrayOf(r.object),onReferencedMessageClick:r.func};const $e=e=>{const{activeView:t,toolbarItems:n,activeViewChange:l}=e;return p.createElement("div",{className:"k-prompt-header"},p.createElement(a.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},n.map(e=>p.isValidElement(e)?e:p.createElement(a.Button,{key:e.name,className:t===e.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>(e=>{null==l||l.call(null,e)})(e.name)},e.buttonText))))},Ke={name:"Output view",buttonText:"Output",buttonIcon:l.commentIcon},Ve={name:"Commands view",buttonIcon:l.moreHorizontalIcon},je={name:"Prompt view",buttonText:"Ask AI",buttonIcon:l.sparklesIcon},We=p.createContext([{},()=>{}]),Ge=()=>p.useContext(We),_e=e=>{const{children:t}=e;return p.createElement("div",{className:"k-prompt-footer"},p.createElement("div",{className:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},t))},Ye=p.forwardRef((e,t)=>{const{children:n,streaming:s,onCancel:r}=e,i=o.useLocalization().toLanguageString(E,Y[E]),[c]=Ge(),u=c.activeView===Ke.name,m=s&&!u,d=p.useCallback(e=>{"Escape"===e.key&&s&&r&&(e.preventDefault(),r())},[s,r]);return p.createElement("div",{className:"k-prompt-content",ref:t,onKeyDown:d},m&&p.createElement(a.FloatingActionButton,{onClick:r,svgIcon:l.stopIcon,icon:"stop",size:"medium",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":i,title:i}),p.createElement("div",{className:"k-prompt-view"},n))});Ye.displayName="KendoReactAIPromptContent";const Xe=e=>{const[t]=Ge();return t.activeView===e.name?e.children:null},Je=e=>{const[t,n]=p.useState(!0),{children:s,title:o}=e;return p.createElement("div",{className:"k-prompt-expander"},p.createElement(a.Button,{"aria-controls":e.id,fillMode:"flat",svgIcon:t?l.chevronUpIcon:l.chevronDownIcon,title:o,onClick:()=>n(!t),"aria-expanded":t},o),t&&p.createElement("div",{id:e.id,className:"k-prompt-expander-content"},s))},Qe=e=>null==e?void 0:e.map(e=>p.createElement(s.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&Qe(e.children))),Ze=({show:e=!1,anchor:t,onOpen:n,onClose:a,animate:l=!0,appendTo:s,popupOptions:o={},children:r,style:i})=>p.createElement(d.Popup,{show:e,anchor:t,style:i,animate:l,appendTo:s,onOpen:n,onClose:a,...o},r),et=({placeholder:e="Ask or generate content with AI...",promptValue:t,onMenuClick:s,promptInput:o=m.TextArea,generateButton:r,enableSpeechToText:i=!1,streaming:c=!1,commands:u,onPromptRequest:d,onPromptCancel:g})=>{const[f,h]=p.useState(t||""),[v,k]=n.useCustomComponent(r),[b,y]=n.useCustomComponent(o),E=o===m.TextArea||b===m.TextArea,C={svgIcon:c?l.stopIcon:l.paperPlaneIcon,active:(!!c).toString(),title:"Send Button","aria-label":"Send Button",disabled:!f.trim()&&!c,"aria-disabled":!f.trim()&&!c},x={placeholder:e,className:"!k-flex-row",...E?{autoSize:!0}:{},rows:1},I=u&&u.length>0,T=Object.keys(k).length>0?k:C,F=Object.keys(y).length>0?y:x,w=e=>{const{isFinal:t,alternatives:n}=e;if(t&&n.length>0){const e=n[0].transcript,t=(()=>{const t=f,n=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(n?" ":"")+e})();h(t)}},S=()=>{f.trim()&&d&&d(f.trim())};return p.createElement(b,{value:f,onChange:e=>{const t=e.target.value;h(t)},onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),S())},prefix:I||i?p.createElement(p.Fragment,null,p.createElement(m.InputPrefix,{className:"!k-align-items-start"},I&&p.createElement(a.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:l.menuIcon,onClick:s}),i&&p.createElement(a.SpeechToTextButton,{fillMode:"flat",..."object"==typeof i?{...i,onResult:i.onResult||w}:{onResult:w}})),p.createElement(m.InputSeparator,null)):void 0,suffix:p.createElement(m.InputSuffix,{className:"!k-align-items-start"},p.createElement(v,{className:n.classNames("k-prompt-send",{"k-generating":c,"k-active":c}),fillMode:"flat",onClick:c?g:S,...T})),...F})};e.AIPrompt=e=>{const t=p.useRef(null);n.useWebMcpRegister("aiprompt",t,e,e.webMcp);const a=!n.validatePackage(xe,{component:"AIPrompt"}),l=n.getLicenseMessage(xe),{activeView:s,toolbarItems:o,children:r,onActiveViewChange:i,onPromptRequest:c,onCommandExecute:u,style:m,dir:d,className:g,streaming:f,loading:h,onCancel:v,suggestionsView:k,...b}=e,y=o||[je,Ke],[E,C]=p.useState({activeView:s}),x={...E,activeView:s,streaming:f,loading:h,suggestionsView:null!=k?k:"classic",onCancel:v,onActiveViewChange:i,onPromptRequest:c,onCommandExecute:u};return p.createElement(We.Provider,{value:[x,e=>{C(e)}]},p.createElement("div",{className:n.classNames("k-prompt",g),style:m,dir:d,...b},p.createElement($e,{activeView:x.activeView,toolbarItems:y,activeViewChange:i}),r,a&&p.createElement(n.WatermarkOverlay,{message:l})))},e.AIPromptCommandsView=e=>{const{commands:t}=e,[n]=Ge();return p.createElement(Xe,{name:Ve.name},p.createElement(Ye,{streaming:n.streaming,onCancel:n.onCancel},p.createElement("div",{className:"k-prompt-view"},p.createElement(s.PanelBar,{onSelect:e=>{var t,a,l;const s=null==(a=null==(t=e.target)?void 0:t.props)?void 0:a.data;null!=(l=null==s?void 0:s.children)&&l.length||n.onCommandExecute&&n.onCommandExecute.call(null,s)},selected:""},Qe(null!=t?t:[])))))},e.AIPromptContent=Ye,e.AIPromptFooter=_e,e.AIPromptOutputView=e=>{const[t,n]=p.useState(""),r=p.useRef(null),[i]=Ge(),{outputs:c,showOutputRating:u,outputCard:m}=e,{header:d,body:g,actions:f}=m||{},h=o.useLocalization(),v=h.toLanguageString(E,Y[E]),k=(e,t)=>{i.onPromptRequest&&i.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),b()},b=()=>{r&&r.current&&r.current.scrollTo({top:0,behavior:"smooth"})},C=p.createElement(s.Card,null,p.createElement(s.CardHeader,null,p.createElement(s.CardTitle,null,p.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),p.createElement(s.CardSubtitle,null,p.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),p.createElement(s.CardBody,null,p.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),p.createElement(s.CardActions,null,i.streaming&&i.onCancel?p.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:l.stopIcon,title:v,onClick:i.onCancel},v):p.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),x=(e,s)=>f?f(e):s&&i.onCancel?p.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:l.stopIcon,title:v,onClick:i.onCancel},v):p.createElement(p.Fragment,null,p.createElement(a.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:t===e.id?l.checkIcon:l.copyIcon,onClick:()=>(e=>{e.responseContent&&navigator.clipboard.writeText(e.responseContent),n(e.id),setTimeout(()=>{n("")},1e3)})(e)},"Copy"),p.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:l.arrowRotateCwIcon,onClick:()=>(e=>{i.onPromptRequest&&i.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),b()})(e)},"Retry"),u&&p.createElement(p.Fragment,null,p.createElement("span",{className:"k-spacer"}),p.createElement(a.Button,{size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:l.thumbUpIcon,onClick:()=>k(e,"positive")}),p.createElement(a.Button,{size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:l.thumbDownIcon,onClick:()=>k(e,"negative")}))),I=null==c?void 0:c.map((e,t)=>{const n=!(!i.streaming||i.loading||0!==t);return p.createElement(s.Card,{key:`${e.id}_${t}`},p.createElement(s.CardHeader,null,d?d(e):p.createElement(p.Fragment,null,e.title&&p.createElement(s.CardTitle,null,e.title),e.subTitle&&p.createElement(s.CardSubtitle,null,e.subTitle))),p.createElement(s.CardBody,null,g?g(e):e.responseContent),p.createElement(s.CardActions,null,x(e,n)))}),T=p.createElement(s.Card,null,p.createElement(s.CardBody,null,h.toLanguageString(y,Y[y])));return p.createElement(Xe,{name:Ke.name},p.createElement(Ye,{ref:r,streaming:i.streaming,onCancel:i.onCancel},p.createElement("div",{className:"k-card-list"},i.loading&&C,I,(!I||0===I.length)&&!i.loading&&T)))},e.AIPromptView=e=>{const{promptInput:t=m.TextArea,generateButton:s=a.Button,enableSpeechToText:o=!1,promptValue:r,promptSuggestions:i}=e,[c,u]=p.useState(r||""),[d]=Ge(),[g,f]=n.useCustomComponent(s),[h,v]=n.useCustomComponent(t),k=p.useRef(null);p.useEffect(()=>{var e,t;null!=(t=null==(e=k.current)?void 0:e.element)&&t.current&&requestAnimationFrame(()=>{var e,t;if(null!=(t=null==(e=k.current)?void 0:e.element)&&t.current){const e=k.current.element.current;e.style.height="auto",e.style.height=`${e.scrollHeight}px`}})},[c]);const b={title:"Generate",children:"Generate",svgIcon:l.sparklesIcon},y=Object.keys(f).length>0?f:b,E=Object.keys(v).length>0?v:{placeholder:"Ask or generate content with AI ...",rows:2},C=e=>{const{isFinal:t,alternatives:n}=e;if(t&&n.length>0){const e=n[0].transcript,t=(()=>{const t=c,n=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(n?" ":"")+e})();u(t)}};let x;return o&&(x="object"==typeof o?{...o,onResult:o.onResult||C}:{onResult:C}),p.createElement(Xe,{name:je.name},p.createElement(Ye,{streaming:d.streaming,onCancel:d.onCancel},p.createElement(h,{ref:k,value:c,flow:"vertical",textareaStyle:{maxHeight:"110px"},autoSize:!0,suffix:o?p.createElement(p.Fragment,null,p.createElement(m.InputSeparator,{orientation:"horizontal"}),p.createElement(m.InputSuffix,{orientation:"horizontal"},p.createElement(a.SpeechToTextButton,{fillMode:"flat",...x}))):void 0,onChange:e=>{u(e.target.value)},...E}),i&&i.length>0&&p.createElement(Je,{title:"Prompt Suggestions"},p.createElement(he,{suggestionsView:d.suggestionsView,suggestions:i.map((e,t)=>({id:t,text:e,description:e})),onSuggestionClick:e=>{(e=>{u(e)})(e.text)}}))),p.createElement(_e,null,p.createElement(g,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:()=>{d.onPromptRequest&&d.onPromptRequest.call(null,c),u("")},disabled:!c.trim(),...y},y.children)))},e.AIPromptViewRender=Xe,e.Chat=Ue,e.ChatMessage=le,e.DEFAULT_FIELD_MAPPING=Ne,e.HeroCard=e=>{const{imageUrl:t,imageMaxWidth:n,title:l,subtitle:s,actions:o,onActionExecute:r,altText:i}=e,c=p.useCallback((e,t)=>{null==r||r({action:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})},[r]),u=i||l||"";return p.createElement("div",{className:"k-card"},p.createElement("img",{className:"k-card-image",src:t,style:{maxWidth:n},alt:u}),p.createElement("div",{className:"k-card-body"},l&&p.createElement("h5",{className:"k-card-title"},l),s&&p.createElement("h6",{className:"k-card-subtitle"},s)),p.createElement("div",{className:"k-card-actions k-card-actions-vertical"},o.map((e,t)=>p.createElement("span",{className:"k-card-action",key:`action-${t}-${e.title||e.value||t}`},p.createElement(a.Button,{fillMode:"flat",onClick:t=>c(e,t)},e.title)))))},e.InlineAIPrompt=e=>{const t=!n.validatePackage(xe,{component:"InlineAIPrompt"}),o=n.getLicenseMessage(xe),{outputs:r=[],outputCard:i,promptInput:c=m.TextArea,generateButton:u=a.Button,promptPlaceholder:d="Ask or generate content with AI...",promptValue:g,onPromptRequest:f,onCopy:h,onDiscard:v,outputActions:k,onOutputAction:b,enableSpeechToText:y=!1,streaming:E,onPromptCancel:C,show:x=!1,anchor:I,width:T,height:F,onOpen:w,onClose:S,animate:A=!0,appendTo:M,commands:R,onCommandExecute:N,style:B,className:L,popupOptions:D={},...P}=e,[z,O]=p.useState(""),[q,H]=p.useState(!1),[U,$]=p.useState({left:0,top:0}),K=p.useRef(null),{body:V,actions:j}=i||{},W=k||[{id:"copy",text:"Copy",svgIcon:l.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:l.cancelIcon,themeColor:"base",title:"Discard"}],G=(e,t)=>{switch(e.id){case"copy":(e=>{e.responseContent&&(navigator.clipboard.writeText(e.responseContent),O(e.id),setTimeout(()=>O(""),1e3)),null==h||h(e)})(t);break;case"discard":(e=>{null==v||v(e)})(t);break;default:null==b||b(e,t)}},_=p.useCallback(e=>{"Escape"===e.key&&(E&&C?C():!E&&S&&S({target:null}))},[E,C,S]),Y={...B,...T&&{width:T},...F&&{height:F}},X={...T&&{width:T},...F&&{height:F}},J=p.createElement(p.Fragment,null,p.createElement("div",{className:n.classNames("k-prompt",L),style:Y,onKeyDown:_,...P},p.createElement(Ye,{ref:K},r&&r.length>0&&p.createElement("div",{className:"k-card-list"},r.map((e,t)=>p.createElement(s.Card,{key:`${e.id}_${t}`},p.createElement(s.CardBody,null,V?V(e):e.responseContent),p.createElement(s.CardActions,null,j?j(e):p.createElement(p.Fragment,null,W.map(t=>{var n;return t.spacer?p.createElement("span",{key:t.id,className:"k-spacer"}):p.createElement(a.Button,{key:t.id,size:"medium",themeColor:t.themeColor||"primary",fillMode:"flat",rounded:"medium",title:null!=(n=t.title)?n:t.text,svgIcon:"copy"===t.id&&z===e.id?l.checkIcon:t.svgIcon,onClick:()=>G(t,e)},t.text)})))))),p.createElement(et,{promptValue:g,placeholder:d,onPromptRequest:f,onMenuClick:e=>{if(!K.current)return;const t=K.current.getBoundingClientRect();$({left:t.left,top:t.bottom}),H(!0)},onPromptCancel:C,promptInput:c,generateButton:u,enableSpeechToText:y,streaming:E,commands:R}))),t&&p.createElement(n.WatermarkOverlay,{message:o}));return p.createElement(p.Fragment,null,p.createElement(Ze,{show:x,anchor:I,onOpen:w,onClose:S,animate:A,appendTo:M,popupOptions:D,style:X},J),p.createElement(s.ContextMenu,{show:q,offset:U,onClose:()=>{H(!1)},items:(e=>null==e?void 0:e.map(e=>({text:e.text,svgIcon:e.svgIcon,data:e,items:e.children?e.children.map(e=>({text:e.text,data:e})):void 0})))(R),onSelect:e=>{var t,n;const a=null==(t=e.item)?void 0:t.data;a&&(null==(n=a.children)||!n.length)&&(e=>{H(!1),N&&N(e)})(a)}}))},e.PromptBox=Fe,e.PromptBoxActionButton=ke,e.PromptBoxSpeechToTextButton=be,e.PromptBoxUploadButton=ve,e.PromptHeader=$e,e.SuggestionGroup=he,e.commandsViewDefaults=Ve,e.extractFieldMappingFromProps=e=>({textField:e.textField,statusField:e.statusField,authorIdField:e.authorIdField,authorNameField:e.authorNameField,authorImageUrlField:e.authorImageUrlField,authorImageAltTextField:e.authorImageAltTextField,idField:e.idField,timestampField:e.timestampField,filesField:e.filesField,attachmentsField:e.attachmentsField,replyToIdField:e.replyToIdField,isDeletedField:e.isDeletedField,isPinnedField:e.isPinnedField,typingField:e.typingField,suggestedActionsField:e.suggestedActionsField,isFailedField:e.isFailedField}),e.isStandardMessageFormat=De,e.mapDataArrayToMessages=Le,e.mapDataToMessage=Be,e.mapMessageToCustomFormat=(e,t={})=>{const n={...Ne,...t},a={};return void 0!==e.id&&(a[n.idField]=e.id),void 0!==e.text&&(a[n.textField]=e.text),void 0!==e.status&&(a[n.statusField]=e.status),void 0!==e.isFailed&&(a[n.isFailedField]=e.isFailed),void 0!==e.timestamp&&(a[n.timestampField]=e.timestamp),void 0!==e.attachments&&(a[n.attachmentsField]=e.attachments),void 0!==e.files&&(a[n.filesField]=e.files),void 0!==e.suggestedActions&&(a[n.suggestedActionsField]=e.suggestedActions),void 0!==e.replyToId&&(a[n.replyToIdField]=e.replyToId),void 0!==e.isDeleted&&(a[n.isDeletedField]=e.isDeleted),void 0!==e.isPinned&&(a[n.isPinnedField]=e.isPinned),void 0!==e.typing&&(a[n.typingField]=e.typing),e.author&&(void 0!==e.author.id&&(a[n.authorIdField]=e.author.id),void 0!==e.author.name&&(a[n.authorNameField]=e.author.name),void 0!==e.author.avatarUrl&&(a[n.authorImageUrlField]=e.author.avatarUrl),void 0!==e.author.avatarAltText&&(a[n.authorImageAltTextField]=e.author.avatarAltText)),void 0!==e.pinnedAt&&(a.pinnedAt=e.pinnedAt),void 0!==e.pinnedBy&&(a.pinnedBy=e.pinnedBy),void 0!==e.attachmentLayout&&(a.attachmentLayout=e.attachmentLayout),a},e.outputViewDefaults=Ke,e.promptViewDefaults=je});
|
package/messages/index.d.ts
CHANGED
|
@@ -125,10 +125,22 @@ export declare const promptBoxStopGenerating = "promptBox.stopGenerating";
|
|
|
125
125
|
* @hidden
|
|
126
126
|
*/
|
|
127
127
|
export declare const promptBoxAriaLabel = "promptBox.ariaLabel";
|
|
128
|
+
/**
|
|
129
|
+
* @hidden
|
|
130
|
+
*/
|
|
131
|
+
export declare const promptBoxAttachedFiles = "promptBox.attachedFiles";
|
|
128
132
|
/**
|
|
129
133
|
* @hidden
|
|
130
134
|
*/
|
|
131
135
|
export declare const chatMessageToolbar = "chat.messageToolbar";
|
|
136
|
+
/**
|
|
137
|
+
* @hidden
|
|
138
|
+
*/
|
|
139
|
+
export declare const chatUnpinMessage = "chat.unpinMessage";
|
|
140
|
+
/**
|
|
141
|
+
* @hidden
|
|
142
|
+
*/
|
|
143
|
+
export declare const chatMessageAttachedFiles = "chat.messageAttachedFiles";
|
|
132
144
|
/**
|
|
133
145
|
* @hidden
|
|
134
146
|
*/
|
|
@@ -163,5 +175,8 @@ export declare const messages: {
|
|
|
163
175
|
"promptBox.removeFile": string;
|
|
164
176
|
"promptBox.stopGenerating": string;
|
|
165
177
|
"promptBox.ariaLabel": string;
|
|
178
|
+
"promptBox.attachedFiles": string;
|
|
166
179
|
"chat.messageToolbar": string;
|
|
180
|
+
"chat.unpinMessage": string;
|
|
181
|
+
"chat.messageAttachedFiles": string;
|
|
167
182
|
};
|
package/messages/index.js
CHANGED
|
@@ -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 e="newMessage.sendButton",t="newMessage.optionsButton",o="newMessage.messageInput",s="avatar.alt",a="messageList.ariaLabel",l="aIPrompt.noOutputs",n="aIPrompt.cancel",c="chat.senderDeletedMessage",
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="newMessage.sendButton",t="newMessage.optionsButton",o="newMessage.messageInput",s="avatar.alt",a="messageList.ariaLabel",l="aIPrompt.noOutputs",n="aIPrompt.cancel",c="chat.senderDeletedMessage",p="chat.receiverDeletedMessage",r="chat.copyNotification",i="chat.downloadAllFiles",g="chat.closeReply",m="chat.collapseMessage",h="chat.expandMessage",d="chat.removeFile",M="chat.fileActions",B="chat.attachFile",u="chat.downloadAll",x="chat.scrollLeft",A="chat.scrollRight",F="chat.scrollToBottom",f="chat.messageFailed",v="chat.retryMessage",S="chat.stopGenerating",w="promptBox.input",b="promptBox.sendButton",y="promptBox.attachFile",R="promptBox.removeFile",I="promptBox.stopGenerating",L="promptBox.ariaLabel",T="promptBox.attachedFiles",P="chat.messageToolbar",D="chat.unpinMessage",C="chat.messageAttachedFiles",O={[e]:"Send",[t]:"Options",[o]:"Message",[s]:"Avatar",[a]:"Message list",[n]:"Cancel",[l]:"No output from AI available",[c]:"You removed this message",[p]:"The message was removed by its sender",[r]:"Text copied to clipboard",[i]:"Download all files",[g]:"Close reply",[m]:"Collapse message",[h]:"Expand message",[d]:"Remove file",[M]:"File actions for",[f]:"Failed to send",[v]:"Retry",[S]:"Stop generating",[B]:"Attach file",[u]:"Download all",[x]:"Scroll left",[A]:"Scroll right",[F]:"Scroll to bottom",[w]:"Prompt",[b]:"Send",[y]:"Attach file",[R]:"Remove file",[I]:"Stop generating",[L]:"Prompt box",[T]:"Attached files",[P]:"Toolbar",[D]:"Unpin message",[C]:"Attached files"};exports.aIPromptCancel=n;exports.aIPromptNoOutputs=l;exports.ariaLabelMessageList=a;exports.attachFile=B;exports.avatarAlt=s;exports.chatCopyNotification=r;exports.chatMessageAttachedFiles=C;exports.chatMessageToolbar=P;exports.chatReceiverDeletedMessage=p;exports.chatSenderDeletedMessage=c;exports.chatStopGenerating=S;exports.chatUnpinMessage=D;exports.closeReply=g;exports.collapseMessage=m;exports.downloadAll=u;exports.downloadAllFiles=i;exports.expandMessage=h;exports.fileActions=M;exports.messageFailed=f;exports.messages=O;exports.newMessageMessageInput=o;exports.newMessageOptionsButton=t;exports.newMessageSendButton=e;exports.promptBoxAriaLabel=L;exports.promptBoxAttachFile=y;exports.promptBoxAttachedFiles=T;exports.promptBoxInput=w;exports.promptBoxRemoveFile=R;exports.promptBoxSendButton=b;exports.promptBoxStopGenerating=I;exports.removeFile=d;exports.retryMessage=v;exports.scrollLeft=x;exports.scrollRight=A;exports.scrollToBottom=F;
|
package/messages/index.mjs
CHANGED
|
@@ -5,70 +5,76 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
const e = "newMessage.sendButton", t = "newMessage.optionsButton", o = "newMessage.messageInput", s = "avatar.alt", a = "messageList.ariaLabel",
|
|
8
|
+
const e = "newMessage.sendButton", t = "newMessage.optionsButton", o = "newMessage.messageInput", s = "avatar.alt", a = "messageList.ariaLabel", c = "aIPrompt.noOutputs", n = "aIPrompt.cancel", l = "chat.senderDeletedMessage", p = "chat.receiverDeletedMessage", r = "chat.copyNotification", i = "chat.downloadAllFiles", g = "chat.closeReply", h = "chat.collapseMessage", m = "chat.expandMessage", d = "chat.removeFile", M = "chat.fileActions", B = "chat.attachFile", x = "chat.downloadAll", u = "chat.scrollLeft", A = "chat.scrollRight", F = "chat.scrollToBottom", f = "chat.messageFailed", v = "chat.retryMessage", w = "chat.stopGenerating", b = "promptBox.input", S = "promptBox.sendButton", y = "promptBox.attachFile", R = "promptBox.removeFile", I = "promptBox.stopGenerating", L = "promptBox.ariaLabel", T = "promptBox.attachedFiles", D = "chat.messageToolbar", P = "chat.unpinMessage", C = "chat.messageAttachedFiles", G = {
|
|
9
9
|
[e]: "Send",
|
|
10
10
|
[t]: "Options",
|
|
11
11
|
[o]: "Message",
|
|
12
12
|
[s]: "Avatar",
|
|
13
13
|
[a]: "Message list",
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
14
|
+
[n]: "Cancel",
|
|
15
|
+
[c]: "No output from AI available",
|
|
16
|
+
[l]: "You removed this message",
|
|
17
|
+
[p]: "The message was removed by its sender",
|
|
18
|
+
[r]: "Text copied to clipboard",
|
|
19
19
|
[i]: "Download all files",
|
|
20
20
|
[g]: "Close reply",
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
21
|
+
[h]: "Collapse message",
|
|
22
|
+
[m]: "Expand message",
|
|
23
|
+
[d]: "Remove file",
|
|
24
24
|
[M]: "File actions for",
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
25
|
+
[f]: "Failed to send",
|
|
26
|
+
[v]: "Retry",
|
|
27
|
+
[w]: "Stop generating",
|
|
28
28
|
[B]: "Attach file",
|
|
29
29
|
[x]: "Download all",
|
|
30
30
|
[u]: "Scroll left",
|
|
31
|
-
[
|
|
32
|
-
[
|
|
31
|
+
[A]: "Scroll right",
|
|
32
|
+
[F]: "Scroll to bottom",
|
|
33
33
|
[b]: "Prompt",
|
|
34
34
|
[S]: "Send",
|
|
35
35
|
[y]: "Attach file",
|
|
36
36
|
[R]: "Remove file",
|
|
37
37
|
[I]: "Stop generating",
|
|
38
38
|
[L]: "Prompt box",
|
|
39
|
-
[T]: "
|
|
39
|
+
[T]: "Attached files",
|
|
40
|
+
[D]: "Toolbar",
|
|
41
|
+
[P]: "Unpin message",
|
|
42
|
+
[C]: "Attached files"
|
|
40
43
|
};
|
|
41
44
|
export {
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
n as aIPromptCancel,
|
|
46
|
+
c as aIPromptNoOutputs,
|
|
44
47
|
a as ariaLabelMessageList,
|
|
45
48
|
B as attachFile,
|
|
46
49
|
s as avatarAlt,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
r as chatCopyNotification,
|
|
51
|
+
C as chatMessageAttachedFiles,
|
|
52
|
+
D as chatMessageToolbar,
|
|
53
|
+
p as chatReceiverDeletedMessage,
|
|
54
|
+
l as chatSenderDeletedMessage,
|
|
55
|
+
w as chatStopGenerating,
|
|
56
|
+
P as chatUnpinMessage,
|
|
52
57
|
g as closeReply,
|
|
53
|
-
|
|
58
|
+
h as collapseMessage,
|
|
54
59
|
x as downloadAll,
|
|
55
60
|
i as downloadAllFiles,
|
|
56
|
-
|
|
61
|
+
m as expandMessage,
|
|
57
62
|
M as fileActions,
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
f as messageFailed,
|
|
64
|
+
G as messages,
|
|
60
65
|
o as newMessageMessageInput,
|
|
61
66
|
t as newMessageOptionsButton,
|
|
62
67
|
e as newMessageSendButton,
|
|
63
68
|
L as promptBoxAriaLabel,
|
|
64
69
|
y as promptBoxAttachFile,
|
|
70
|
+
T as promptBoxAttachedFiles,
|
|
65
71
|
b as promptBoxInput,
|
|
66
72
|
R as promptBoxRemoveFile,
|
|
67
73
|
S as promptBoxSendButton,
|
|
68
74
|
I as promptBoxStopGenerating,
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
d as removeFile,
|
|
76
|
+
v as retryMessage,
|
|
71
77
|
u as scrollLeft,
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
A as scrollRight,
|
|
79
|
+
F as scrollToBottom
|
|
74
80
|
};
|
package/package-metadata.js
CHANGED
|
@@ -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 e=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate: 1785412174,version:"15.2.0-develop.2",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning"});exports.packageMetadata=e;
|
package/package-metadata.mjs
CHANGED
|
@@ -7,8 +7,8 @@ export const packageMetadata = Object.freeze({
|
|
|
7
7
|
productName: 'KendoReact',
|
|
8
8
|
productCode: 'KENDOUIREACT',
|
|
9
9
|
productCodes: ['KENDOUIREACT'],
|
|
10
|
-
publishDate:
|
|
11
|
-
version: '15.2.0-develop.
|
|
10
|
+
publishDate: 1785412174,
|
|
11
|
+
version: '15.2.0-develop.2',
|
|
12
12
|
licensingDocsUrl:
|
|
13
13
|
'https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
|
|
14
14
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-conversational-ui",
|
|
3
|
-
"version": "15.2.0-develop.
|
|
3
|
+
"version": "15.2.0-develop.2",
|
|
4
4
|
"description": "React Chat component allows the user to participate in chat sessions with users or chat bots. KendoReact Conversational UI components",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@progress/kendo-licensing": "^1.7.2",
|
|
29
|
-
"@progress/kendo-react-animation": "15.2.0-develop.
|
|
30
|
-
"@progress/kendo-react-buttons": "15.2.0-develop.
|
|
31
|
-
"@progress/kendo-react-common": "15.2.0-develop.
|
|
32
|
-
"@progress/kendo-react-intl": "15.2.0-develop.
|
|
33
|
-
"@progress/kendo-react-inputs": "15.2.0-develop.
|
|
34
|
-
"@progress/kendo-react-layout": "15.2.0-develop.
|
|
35
|
-
"@progress/kendo-react-notification": "15.2.0-develop.
|
|
36
|
-
"@progress/kendo-react-popup": "15.2.0-develop.
|
|
37
|
-
"@progress/kendo-react-upload": "15.2.0-develop.
|
|
29
|
+
"@progress/kendo-react-animation": "15.2.0-develop.2",
|
|
30
|
+
"@progress/kendo-react-buttons": "15.2.0-develop.2",
|
|
31
|
+
"@progress/kendo-react-common": "15.2.0-develop.2",
|
|
32
|
+
"@progress/kendo-react-intl": "15.2.0-develop.2",
|
|
33
|
+
"@progress/kendo-react-inputs": "15.2.0-develop.2",
|
|
34
|
+
"@progress/kendo-react-layout": "15.2.0-develop.2",
|
|
35
|
+
"@progress/kendo-react-notification": "15.2.0-develop.2",
|
|
36
|
+
"@progress/kendo-react-popup": "15.2.0-develop.2",
|
|
37
|
+
"@progress/kendo-react-upload": "15.2.0-develop.2",
|
|
38
38
|
"@progress/kendo-svg-icons": "^4.9.0 || ^5.0.0",
|
|
39
39
|
"react": "^18.0.0 || ^19.0.0",
|
|
40
40
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"package": {
|
|
121
121
|
"productName": "KendoReact",
|
|
122
122
|
"productCode": "KENDOUIREACT",
|
|
123
|
-
"publishDate":
|
|
123
|
+
"publishDate": 1785412174,
|
|
124
124
|
"licensingDocsUrl": "https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning"
|
|
125
125
|
}
|
|
126
126
|
},
|
package/prompt-box/FileBox.js
CHANGED
|
@@ -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
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),R=require("@progress/kendo-react-buttons"),m=require("@progress/kendo-react-common"),F=require("@progress/kendo-svg-icons"),L=require("@progress/kendo-react-intl"),a=require("../messages/index.js");function z(e){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(l,o,r.get?r:{enumerable:!0,get:()=>e[o]})}}return l.default=e,Object.freeze(l)}const n=z(B),O="k-prompt-box",h=1,N=e=>"."+e.split(".").pop()||"",p=e=>{if(e==null)return"";if(e===0)return"0 B";const l=1024,o=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(e)/Math.log(l));return`${parseFloat((e/Math.pow(l,r)).toFixed(2))} ${o[r]}`},C=e=>e?typeof e=="function"?e():e:null,M=({files:e,onRemoveFile:l,header:o})=>{const r=L.useLocalization(),u=n.useRef(null),[d,f]=n.useState(!1),[g,S]=n.useState(!1),i=n.useCallback(()=>{const t=u.current;if(!t)return;const{scrollLeft:s,scrollWidth:c,clientWidth:b}=t,E=s===0,k=s+b>=c-h;S(!E),f(!k)},[]);if(n.useLayoutEffect(()=>{i()},[e,i]),n.useEffect(()=>{const t=u.current;if(!t)return;const s=()=>i(),c=new ResizeObserver(i);return c.observe(t),t.addEventListener("scroll",s,{passive:!0}),()=>{t.removeEventListener("scroll",s),c.disconnect()}},[i,e.length]),e.length===0&&!o)return null;const v=C(o),x=e.length>0&&n.createElement("ul",{role:"list","aria-label":r.toLanguageString(a.promptBoxAttachedFiles,a.messages[a.promptBoxAttachedFiles]),className:m.classNames("k-file-box-wrapper",{"k-file-box-wrapper-scrollable-start":d,"k-file-box-wrapper-scrollable-end":g})},n.createElement("div",{className:"k-files-scroll",role:"presentation",ref:u},e.map((t,s)=>n.createElement("li",{key:t.name,className:"k-file-box",role:"listitem",tabIndex:s===0?0:-1,"aria-label":[t.name,p(t.size)].filter(Boolean).join(" ")||void 0},n.createElement(m.IconWrap,{size:"xlarge",...m.getFileExtensionIcon(N(t.name))}),n.createElement("div",{className:"k-file-info"},n.createElement("span",{className:"k-file-name"},t.name),n.createElement("span",{className:"k-file-size"},p(t.size))),n.createElement(R.Button,{fillMode:"flat",size:"xs",svgIcon:F.xCircleIcon,onClick:c=>{c.stopPropagation(),l(t.name)},"aria-label":`${r.toLanguageString(a.promptBoxRemoveFile,a.messages[a.promptBoxRemoveFile])} ${t.name}`,title:`${r.toLanguageString(a.promptBoxRemoveFile,a.messages[a.promptBoxRemoveFile])} ${t.name}`})))));return n.createElement("div",{className:`${O}-header`},v,x)};exports.FileBox=M;
|
package/prompt-box/FileBox.mjs
CHANGED
|
@@ -6,25 +6,25 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as n from "react";
|
|
9
|
-
import { Button as
|
|
10
|
-
import { classNames as z, IconWrap as
|
|
9
|
+
import { Button as b } from "@progress/kendo-react-buttons";
|
|
10
|
+
import { classNames as z, IconWrap as h, getFileExtensionIcon as N } from "@progress/kendo-react-common";
|
|
11
11
|
import { xCircleIcon as R } from "@progress/kendo-svg-icons";
|
|
12
|
-
import { useLocalization as
|
|
13
|
-
import {
|
|
14
|
-
const
|
|
12
|
+
import { useLocalization as C } from "@progress/kendo-react-intl";
|
|
13
|
+
import { promptBoxAttachedFiles as u, messages as p, promptBoxRemoveFile as i } from "../messages/index.mjs";
|
|
14
|
+
const F = "k-prompt-box", M = 1, $ = (e) => "." + e.split(".").pop() || "", f = (e) => {
|
|
15
15
|
if (e == null)
|
|
16
16
|
return "";
|
|
17
17
|
if (e === 0)
|
|
18
18
|
return "0 B";
|
|
19
|
-
const
|
|
20
|
-
return `${parseFloat((e / Math.pow(
|
|
21
|
-
},
|
|
22
|
-
const o =
|
|
19
|
+
const s = 1024, c = ["B", "KB", "MB", "GB", "TB"], o = Math.floor(Math.log(e) / Math.log(s));
|
|
20
|
+
return `${parseFloat((e / Math.pow(s, o)).toFixed(2))} ${c[o]}`;
|
|
21
|
+
}, A = (e) => e ? typeof e == "function" ? e() : e : null, W = ({ files: e, onRemoveFile: s, header: c }) => {
|
|
22
|
+
const o = C(), m = n.useRef(null), [d, g] = n.useState(!1), [E, S] = n.useState(!1), l = n.useCallback(() => {
|
|
23
23
|
const t = m.current;
|
|
24
24
|
if (!t)
|
|
25
25
|
return;
|
|
26
|
-
const { scrollLeft: r, scrollWidth:
|
|
27
|
-
|
|
26
|
+
const { scrollLeft: r, scrollWidth: a, clientWidth: L } = t, k = r === 0, B = r + L >= a - M;
|
|
27
|
+
S(!k), g(!B);
|
|
28
28
|
}, []);
|
|
29
29
|
if (n.useLayoutEffect(() => {
|
|
30
30
|
l();
|
|
@@ -32,42 +32,56 @@ const C = "k-prompt-box", b = 1, F = (e) => "." + e.split(".").pop() || "", M =
|
|
|
32
32
|
const t = m.current;
|
|
33
33
|
if (!t)
|
|
34
34
|
return;
|
|
35
|
-
const r = () => l(),
|
|
36
|
-
return
|
|
37
|
-
t.removeEventListener("scroll", r),
|
|
35
|
+
const r = () => l(), a = new ResizeObserver(l);
|
|
36
|
+
return a.observe(t), t.addEventListener("scroll", r, { passive: !0 }), () => {
|
|
37
|
+
t.removeEventListener("scroll", r), a.disconnect();
|
|
38
38
|
};
|
|
39
|
-
}, [l, e.length]), e.length === 0 && !
|
|
39
|
+
}, [l, e.length]), e.length === 0 && !c)
|
|
40
40
|
return null;
|
|
41
|
-
const
|
|
41
|
+
const x = A(c), v = e.length > 0 && /* @__PURE__ */ n.createElement(
|
|
42
42
|
"ul",
|
|
43
43
|
{
|
|
44
|
+
role: "list",
|
|
45
|
+
"aria-label": o.toLanguageString(u, p[u]),
|
|
44
46
|
className: z("k-file-box-wrapper", {
|
|
45
|
-
"k-file-box-wrapper-scrollable-start":
|
|
46
|
-
"k-file-box-wrapper-scrollable-end":
|
|
47
|
+
"k-file-box-wrapper-scrollable-start": d,
|
|
48
|
+
"k-file-box-wrapper-scrollable-end": E
|
|
47
49
|
})
|
|
48
50
|
},
|
|
49
|
-
/* @__PURE__ */ n.createElement("div", { className: "k-files-scroll",
|
|
50
|
-
|
|
51
|
+
/* @__PURE__ */ n.createElement("div", { className: "k-files-scroll", role: "presentation", ref: m }, e.map((t, r) => /* @__PURE__ */ n.createElement(
|
|
52
|
+
"li",
|
|
51
53
|
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
key: t.name,
|
|
55
|
+
className: "k-file-box",
|
|
56
|
+
role: "listitem",
|
|
57
|
+
tabIndex: r === 0 ? 0 : -1,
|
|
58
|
+
"aria-label": [t.name, f(t.size)].filter(Boolean).join(" ") || void 0
|
|
59
|
+
},
|
|
60
|
+
/* @__PURE__ */ n.createElement(h, { size: "xlarge", ...N($(t.name)) }),
|
|
61
|
+
/* @__PURE__ */ n.createElement("div", { className: "k-file-info" }, /* @__PURE__ */ n.createElement("span", { className: "k-file-name" }, t.name), /* @__PURE__ */ n.createElement("span", { className: "k-file-size" }, f(t.size))),
|
|
62
|
+
/* @__PURE__ */ n.createElement(
|
|
63
|
+
b,
|
|
64
|
+
{
|
|
65
|
+
fillMode: "flat",
|
|
66
|
+
size: "xs",
|
|
67
|
+
svgIcon: R,
|
|
68
|
+
onClick: (a) => {
|
|
69
|
+
a.stopPropagation(), s(t.name);
|
|
70
|
+
},
|
|
71
|
+
"aria-label": `${o.toLanguageString(
|
|
72
|
+
i,
|
|
73
|
+
p[i]
|
|
74
|
+
)} ${t.name}`,
|
|
75
|
+
title: `${o.toLanguageString(
|
|
76
|
+
i,
|
|
77
|
+
p[i]
|
|
78
|
+
)} ${t.name}`
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
)))
|
|
68
82
|
);
|
|
69
|
-
return /* @__PURE__ */ n.createElement("div", { className: `${
|
|
83
|
+
return /* @__PURE__ */ n.createElement("div", { className: `${F}-header` }, x, v);
|
|
70
84
|
};
|
|
71
85
|
export {
|
|
72
|
-
|
|
86
|
+
W as FileBox
|
|
73
87
|
};
|
package/prompt-box/PromptBox.js
CHANGED
|
@@ -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 Ge=require("react"),o=require("prop-types"),d=require("@progress/kendo-react-common"),oe=require("@progress/kendo-svg-icons"),Ke=require("./PromptBoxActionButton.js"),Xe=require("./PromptBoxSpeechToTextButton.js"),Ze=require("./PromptBoxUploadButton.js"),Je=require("./FileBox.js"),Ee=require("../package-metadata.js"),Qe=require("@progress/kendo-react-intl"),i=require("../messages/index.js");function Ye(E){const O=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(E){for(const F in E)if(F!=="default"){const $=Object.getOwnPropertyDescriptor(E,F);Object.defineProperty(O,F,$.get?$:{enumerable:!0,get:()=>E[F]})}}return O.default=E,Object.freeze(O)}const t=Ye(Ge),g="k-prompt-box",et=20,tt=50,y={mode:"auto",rows:1,defaultValue:"",disabled:!1,readOnly:!1,loading:!1,uploadButtonConfig:!1,speechToTextButtonConfig:!0,actionButtonConfig:!0},se=t.forwardRef((E,O)=>{const F=!d.validatePackage(Ee.packageMetadata,{component:"PromptBox"}),$=d.getLicenseMessage(Ee.packageMetadata),x=Qe.useLocalization(),Te={...y,...E},{mode:s=y.mode,fillMode:re,rows:M=y.rows,maxTextAreaHeight:u,value:le,defaultValue:Se=y.defaultValue,disabled:p=y.disabled,readOnly:Ae=y.readOnly,placeholder:Re,title:Fe,maxLength:we,inputAttributes:Pe,topAffix:ie,startAffix:C,endAffix:v,header:Ne,onChange:w,onFocus:Z,onBlur:J,onPromptAction:Q,attachments:ae,loading:k=y.loading,uploadButtonConfig:h=y.uploadButtonConfig,speechToTextButtonConfig:j=y.speechToTextButtonConfig,actionButtonConfig:z=y.actionButtonConfig,className:Oe,style:Me,...He}=Te,r=t.useRef(null),[Le,q]=t.useState(Se),[Ie,Y]=t.useState([]),[c,ce]=t.useState(!1),ue=t.useRef(null),_=t.useRef(null),H=t.useRef(0),fe=t.useRef(0),L=t.useRef(!1),pe=t.useRef(0),D=t.useRef(0),T=t.useCallback((e,n)=>e?typeof e=="function"?e(n):e:null,[]),S=le!==void 0,f=S?le:Le,A=ae!==void 0,R=A?ae:Ie,U=t.useMemo(()=>!!(f!=null&&f.trim()||R.length>0),[f,R.length]),P=t.useCallback(()=>{if(!r.current||s==="single")return;const e=r.current,n=globalThis.getComputedStyle(e),l=Number.parseFloat(n.lineHeight)||et,a=Number.parseFloat(n.paddingTop)||0,B=Number.parseFloat(n.paddingBottom)||0;H.current=e.offsetHeight||l+a+B,fe.current=l*M+a+B,s==="auto"&&!c&&(D.current=e.offsetWidth)},[s,M,c]),$e=t.useCallback(()=>s==="auto"?1:M,[s,M]),me=t.useCallback(e=>{if(u){const n=Number.parseInt(u,10);if(e>n)return n}return Math.max(fe.current,e)},[u]),W=t.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${H.current}px`;const n=e.scrollHeight,l=me(n);e.style.height=`${l}px`,u&&n>Number.parseInt(u,10)&&(e.style.overflow="")},[me,u]),V=t.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${H.current}px`;const n=e.scrollHeight,l=u?Math.min(n,Number.parseInt(u,10)):n;e.style.height=`${l}px`,u&&n>Number.parseInt(u,10)&&(e.style.overflow="")},[u]),de=t.useCallback(e=>{if(D.current<=0)return!1;const n=e.style.height,l=e.style.width;e.style.overflow="hidden",e.style.width=`${D.current}px`,e.style.height=`${H.current}px`;const a=e.scrollWidth<=D.current&&e.scrollHeight<=H.current;return e.style.overflow="",l?e.style.width=l:e.style.width="",n?e.style.height=n:e.style.height="",a},[]),G=t.useCallback((e,n)=>{if(L.current)return;if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!c){L.current=!0,ce(!0);return}if(c){V(e);const a=pe.current;n<a&&de(e)&&(e.style.height="",L.current=!0,ce(!1))}},[c,V,de]),N=t.useCallback(()=>{var l;if(s==="single"||!r.current)return;const e=r.current,n=((l=e.value)==null?void 0:l.length)||0;s==="multi"?W(e):s==="auto"&&G(e,n)},[s,W,G]);t.useEffect(()=>{s!=="single"&&r.current&&P()},[s,P]),t.useEffect(()=>{s!=="single"&&r.current&&(P(),N())},[M,s,P,N]),t.useEffect(()=>{if(s!=="single"&&r.current){const e=(f==null?void 0:f.length)||0;requestAnimationFrame(()=>{if(r.current){const n=r.current;s==="multi"?W(n):s==="auto"&&G(n,e),pe.current=e}})}},[f,s,W,G]),t.useEffect(()=>{s==="auto"&&c&&r.current&&requestAnimationFrame(()=>{if(r.current){const e=r.current;V(e),L.current=!1}})},[c,s,V]),t.useEffect(()=>{if(s==="auto"&&r.current){const e=r.current;c||(e.style.height="",e.style.overflow="",L.current=!1)}},[s,c]),t.useEffect(()=>{if(s==="single"||!r.current)return;const e=r.current;let n;const l=()=>{clearTimeout(n),n=setTimeout(()=>{r.current&&(s==="auto"&&!c&&P(),N())},tt)},a=new ResizeObserver(l);return a.observe(e),()=>{a.disconnect(),clearTimeout(n)}},[s,c,P,N]);const m=t.useCallback(()=>({focus:()=>{var e;return(e=r.current)==null?void 0:e.focus()},blur:()=>{var e;return(e=r.current)==null?void 0:e.blur()},element:r.current,get value(){return f}}),[f]);t.useImperativeHandle(O,m);const je=t.useCallback(e=>{const n=e.target.value;!S&&!p&&q(n),w&&!p&&d.dispatchEvent(w,e,{...m(),value:n},{value:n}),s!=="single"&&N()},[q,w,p,S,m,s,N]),ze=t.useCallback(e=>{Z&&!p&&d.dispatchEvent(Z,e,m(),void 0)},[Z,p,m]),qe=t.useCallback(e=>{J&&!p&&d.dispatchEvent(J,e,m(),void 0)},[J,p,m]),ge=t.useCallback(e=>{e.preventDefault()},[]),K=t.useCallback(e=>{Q&&d.dispatchEvent(Q,e,m(),{value:f,attachments:R}),S||q(""),A||Y([])},[Q,m,f,R,S,A]),_e=t.useCallback(e=>{if(!(e.key==="Enter"&&e.shiftKey)){if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.stopPropagation();return}if(e.key==="Enter"){if(e.preventDefault(),k)return;U&&K(e)}}},[K,k,U]),he={disabled:p,readOnly:Ae,placeholder:Re,title:Fe,maxLength:we,"aria-label":x.toLanguageString(i.promptBoxInput,i.messages[i.promptBoxInput]),value:f,onKeyDown:_e,...Pe,onChange:je,onFocus:ze,onBlur:qe,ref:r},be=t.useCallback(e=>{var a,B;const{isFinal:n,alternatives:l}=e;if(l.length>0){const te=l[0];if(n){const X=((a=r.current)==null?void 0:a.value)||"",I=(X?`${X} `:"")+te.transcript;if(S||q(I),w&&!p){const ke={target:r.current,currentTarget:r.current};d.dispatchEvent(w,ke,{...m(),value:I},{value:I})}}}(B=r.current)==null||B.focus()},[S,w,p,m]),Be=t.useCallback(()=>{var e,n;(n=(e=ue.current)==null?void 0:e.actionElement)==null||n.click()},[]),ye=t.useCallback(e=>{var a;const n=Array.from(e.affectedFiles),l=typeof h=="object"&&h.onSelectAttachments;A||Y(B=>[...B,...n]),l&&l({selectedFiles:e.affectedFiles,allFiles:e.newState}),(a=r.current)==null||a.focus()},[h,A]),b=t.useMemo(()=>({uploadButtonProps:{fillMode:"flat",svgIcon:oe.paperclipIcon,size:"small",rounded:"full",onClick:Be,onFilesAdd:ye,files:R,uploadRef:ue,"aria-label":x.toLanguageString(i.promptBoxAttachFile,i.messages[i.promptBoxAttachFile]),title:x.toLanguageString(i.promptBoxAttachFile,i.messages[i.promptBoxAttachFile]),_registerRemoveCallback:e=>{_.current=e}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:be},actionButtonProps:{rounded:"full",size:"small",svgIcon:k?oe.stopIcon:oe.arrowUpIcon,className:k?"k-generating":"",onClick:K,onMouseDown:ge,disabled:!k&&!U,"aria-label":k?x.toLanguageString(i.promptBoxStopGenerating,i.messages[i.promptBoxStopGenerating]):x.toLanguageString(i.promptBoxSendButton,i.messages[i.promptBoxSendButton]),title:k?x.toLanguageString(i.promptBoxStopGenerating,i.messages[i.promptBoxStopGenerating]):x.toLanguageString(i.promptBoxSendButton,i.messages[i.promptBoxSendButton]),"aria-live":"polite"}}),[be,ye,R,K,ge,k,Be,x,U]),De=t.useCallback(e=>{A||Y(l=>l.filter(a=>a.name!==e));const n=typeof h=="object"&&h.onRemoveAttachment;n&&(_.current=n),_.current&&_.current(e)},[h,A]),ee=()=>{const e=j!==!1,n=z!==!1,l=h!==!1,a=typeof j=="object"?j:void 0,B=typeof h=="object"?h:{},{restrictions:te,multiple:X=!0,accept:I,onSelectAttachments:ke,onRemoveAttachment:nt,...We}=B,ne={restrictions:te,multiple:X,accept:I},Ve=typeof z=="object"?z:void 0;return t.createElement(t.Fragment,null,l&&t.createElement(Ze.PromptBoxUploadButton,{...b.uploadButtonProps,restrictions:ne.restrictions,multiple:ne.multiple,accept:ne.accept,...We}),e&&t.createElement(Xe.PromptBoxSpeechToTextButton,{...b.speechToTextButtonProps,...a}),n&&t.createElement(Ke.PromptBoxActionButton,{...b.actionButtonProps,...Ve}))},ve=s==="multi"||s==="auto"&&c,xe=h!==!1||j!==!1||z!==!1,Ce=v||xe,Ue=C||v||xe;return t.createElement("div",{...He,className:d.classNames(Oe,"k-input",g,{[`k-input-${re}`]:re,"k-disabled":p,"k-prompt-box-singleline":s==="single","k-prompt-box-multiline":ve}),style:Me},t.createElement(Je.FileBox,{files:R,onRemoveFile:De,header:Ne}),s==="single"?t.createElement("div",{className:`${g}-content`},C&&t.createElement("div",{className:`${g}-affix`},T(C,b)),t.createElement("input",{...he,className:d.classNames("k-input-inner",`${g}-input`)}),Ce?t.createElement("div",{className:`${g}-affix`},v&&T(v,b),ee()):null):t.createElement("div",{className:`${g}-content`},s==="multi"&&ie&&t.createElement("div",{className:`${g}-affix`},T(ie,b)),s==="auto"&&!c&&C&&t.createElement("div",{className:`${g}-affix`},T(C,b)),t.createElement("textarea",{...he,className:d.classNames("k-input-inner",`${g}-textarea`),rows:$e(),style:u?{maxHeight:u}:{},"aria-multiline":"true"}),s==="auto"&&!c&&Ce?t.createElement("div",{className:`${g}-affix`},v&&T(v,b),ee()):null,ve&&Ue?t.createElement("div",{className:`${g}-affix`},C&&T(C,b),(C||v)&&t.createElement("div",{className:"k-spacer"}),v&&T(v,b),ee()):null),F&&t.createElement(d.WatermarkOverlay,{message:$}))});se.propTypes={value:o.string,defaultValue:o.string,mode:o.oneOf(["single","multi","auto"]),rows:o.number,maxTextAreaHeight:o.string,title:o.string,disabled:o.bool,readOnly:o.bool,placeholder:o.string,maxLength:o.number,inputAttributes:o.object,fillMode:o.oneOf(["solid","flat","outline"]),topAffix:o.oneOfType([o.func,o.element,o.string]),startAffix:o.oneOfType([o.func,o.element,o.string]),endAffix:o.oneOfType([o.func,o.element,o.string]),header:o.oneOfType([o.func,o.element,o.string]),onChange:o.func,onFocus:o.func,onBlur:o.func,loading:o.bool,uploadButtonConfig:o.oneOfType([o.bool,o.object]),speechToTextButtonConfig:o.oneOfType([o.bool,o.object]),actionButtonConfig:o.oneOfType([o.bool,o.object]),attachments:o.array,onPromptAction:o.func,className:o.string,style:o.object};se.displayName="KendoPromptBox";exports.PromptBox=se;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ge=require("react"),o=require("prop-types"),d=require("@progress/kendo-react-common"),oe=require("@progress/kendo-svg-icons"),Ke=require("./PromptBoxActionButton.js"),Xe=require("./PromptBoxSpeechToTextButton.js"),Ze=require("./PromptBoxUploadButton.js"),Je=require("./FileBox.js"),Ee=require("../package-metadata.js"),Qe=require("@progress/kendo-react-intl"),i=require("../messages/index.js");function Ye(E){const O=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(E){for(const F in E)if(F!=="default"){const $=Object.getOwnPropertyDescriptor(E,F);Object.defineProperty(O,F,$.get?$:{enumerable:!0,get:()=>E[F]})}}return O.default=E,Object.freeze(O)}const t=Ye(Ge),g="k-prompt-box",et=20,tt=50,v={mode:"auto",rows:1,defaultValue:"",disabled:!1,readOnly:!1,loading:!1,uploadButtonConfig:!1,speechToTextButtonConfig:!0,actionButtonConfig:!0},se=t.forwardRef((E,O)=>{const F=!d.validatePackage(Ee.packageMetadata,{component:"PromptBox"}),$=d.getLicenseMessage(Ee.packageMetadata),x=Qe.useLocalization(),Te={...v,...E},{mode:s=v.mode,fillMode:re,rows:M=v.rows,maxTextAreaHeight:u,value:le,defaultValue:Se=v.defaultValue,disabled:p=v.disabled,readOnly:Ae=v.readOnly,placeholder:Re,title:Fe,maxLength:we,inputAttributes:Pe,topAffix:ie,startAffix:C,endAffix:y,header:Ne,onChange:w,onFocus:Z,onBlur:J,onPromptAction:Q,attachments:ae,loading:k=v.loading,uploadButtonConfig:h=v.uploadButtonConfig,speechToTextButtonConfig:j=v.speechToTextButtonConfig,actionButtonConfig:z=v.actionButtonConfig,className:Oe,style:Me,...He}=Te,r=t.useRef(null),[Le,q]=t.useState(Se),[Ie,Y]=t.useState([]),[c,ce]=t.useState(!1),ue=t.useRef(null),_=t.useRef(null),H=t.useRef(0),fe=t.useRef(0),L=t.useRef(!1),pe=t.useRef(0),D=t.useRef(0),T=t.useCallback((e,n)=>e?typeof e=="function"?e(n):e:null,[]),S=le!==void 0,f=S?le:Le,A=ae!==void 0,R=A?ae:Ie,U=t.useMemo(()=>!!(f!=null&&f.trim()||R.length>0),[f,R.length]),P=t.useCallback(()=>{if(!r.current||s==="single")return;const e=r.current,n=globalThis.getComputedStyle(e),l=Number.parseFloat(n.lineHeight)||et,a=Number.parseFloat(n.paddingTop)||0,B=Number.parseFloat(n.paddingBottom)||0;H.current=e.offsetHeight||l+a+B,fe.current=l*M+a+B,s==="auto"&&!c&&(D.current=e.offsetWidth)},[s,M,c]),$e=t.useCallback(()=>s==="auto"?1:M,[s,M]),me=t.useCallback(e=>{if(u){const n=Number.parseInt(u,10);if(e>n)return n}return Math.max(fe.current,e)},[u]),W=t.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${H.current}px`;const n=e.scrollHeight,l=me(n);e.style.height=`${l}px`,u&&n>Number.parseInt(u,10)&&(e.style.overflow="")},[me,u]),V=t.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${H.current}px`;const n=e.scrollHeight,l=u?Math.min(n,Number.parseInt(u,10)):n;e.style.height=`${l}px`,u&&n>Number.parseInt(u,10)&&(e.style.overflow="")},[u]),de=t.useCallback(e=>{if(D.current<=0)return!1;const n=e.style.height,l=e.style.width;e.style.overflow="hidden",e.style.width=`${D.current}px`,e.style.height=`${H.current}px`;const a=e.scrollWidth<=D.current&&e.scrollHeight<=H.current;return e.style.overflow="",l?e.style.width=l:e.style.width="",n?e.style.height=n:e.style.height="",a},[]),G=t.useCallback((e,n)=>{if(L.current)return;if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!c){L.current=!0,ce(!0);return}if(c){V(e);const a=pe.current;n<a&&de(e)&&(e.style.height="",L.current=!0,ce(!1))}},[c,V,de]),N=t.useCallback(()=>{var l;if(s==="single"||!r.current)return;const e=r.current,n=((l=e.value)==null?void 0:l.length)||0;s==="multi"?W(e):s==="auto"&&G(e,n)},[s,W,G]);t.useEffect(()=>{s!=="single"&&r.current&&P()},[s,P]),t.useEffect(()=>{s!=="single"&&r.current&&(P(),N())},[M,s,P,N]),t.useEffect(()=>{if(s!=="single"&&r.current){const e=(f==null?void 0:f.length)||0;requestAnimationFrame(()=>{if(r.current){const n=r.current;s==="multi"?W(n):s==="auto"&&G(n,e),pe.current=e}})}},[f,s,W,G]),t.useEffect(()=>{s==="auto"&&c&&r.current&&requestAnimationFrame(()=>{if(r.current){const e=r.current;V(e),L.current=!1}})},[c,s,V]),t.useEffect(()=>{if(s==="auto"&&r.current){const e=r.current;c||(e.style.height="",e.style.overflow="",L.current=!1)}},[s,c]),t.useEffect(()=>{if(s==="single"||!r.current)return;const e=r.current;let n;const l=()=>{clearTimeout(n),n=setTimeout(()=>{r.current&&(s==="auto"&&!c&&P(),N())},tt)},a=new ResizeObserver(l);return a.observe(e),()=>{a.disconnect(),clearTimeout(n)}},[s,c,P,N]);const m=t.useCallback(()=>({focus:()=>{var e;return(e=r.current)==null?void 0:e.focus()},blur:()=>{var e;return(e=r.current)==null?void 0:e.blur()},element:r.current,get value(){return f}}),[f]);t.useImperativeHandle(O,m);const je=t.useCallback(e=>{const n=e.target.value;!S&&!p&&q(n),w&&!p&&d.dispatchEvent(w,e,{...m(),value:n},{value:n}),s!=="single"&&N()},[q,w,p,S,m,s,N]),ze=t.useCallback(e=>{Z&&!p&&d.dispatchEvent(Z,e,m(),void 0)},[Z,p,m]),qe=t.useCallback(e=>{J&&!p&&d.dispatchEvent(J,e,m(),void 0)},[J,p,m]),ge=t.useCallback(e=>{e.preventDefault()},[]),K=t.useCallback(e=>{Q&&d.dispatchEvent(Q,e,m(),{value:f,attachments:R}),S||q(""),A||Y([])},[Q,m,f,R,S,A]),_e=t.useCallback(e=>{if(!(e.key==="Enter"&&e.shiftKey)){if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.stopPropagation();return}if(e.key==="Enter"){if(e.preventDefault(),k)return;U&&K(e)}}},[K,k,U]),he={disabled:p,readOnly:Ae,placeholder:Re,title:Fe,maxLength:we,"aria-label":x.toLanguageString(i.promptBoxInput,i.messages[i.promptBoxInput]),value:f,onKeyDown:_e,...Pe,onChange:je,onFocus:ze,onBlur:qe,ref:r},be=t.useCallback(e=>{var a,B;const{isFinal:n,alternatives:l}=e;if(l.length>0){const te=l[0];if(n){const X=((a=r.current)==null?void 0:a.value)||"",I=(X?`${X} `:"")+te.transcript;if(S||q(I),w&&!p){const ke={target:r.current,currentTarget:r.current};d.dispatchEvent(w,ke,{...m(),value:I},{value:I})}}}(B=r.current)==null||B.focus()},[S,w,p,m]),Be=t.useCallback(()=>{var e,n;(n=(e=ue.current)==null?void 0:e.actionElement)==null||n.click()},[]),ve=t.useCallback(e=>{var a;const n=Array.from(e.affectedFiles),l=typeof h=="object"&&h.onSelectAttachments;A||Y(B=>[...B,...n]),l&&l({selectedFiles:e.affectedFiles,allFiles:e.newState}),(a=r.current)==null||a.focus()},[h,A]),b=t.useMemo(()=>({uploadButtonProps:{fillMode:"flat",svgIcon:oe.paperclipIcon,size:"small",rounded:"full",onClick:Be,onFilesAdd:ve,files:R,uploadRef:ue,"aria-label":x.toLanguageString(i.promptBoxAttachFile,i.messages[i.promptBoxAttachFile]),title:x.toLanguageString(i.promptBoxAttachFile,i.messages[i.promptBoxAttachFile]),_registerRemoveCallback:e=>{_.current=e}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:be},actionButtonProps:{rounded:"full",size:"small",svgIcon:k?oe.stopIcon:oe.arrowUpIcon,className:k?"k-generating k-active":"",onClick:K,onMouseDown:ge,disabled:!k&&!U,"aria-label":k?x.toLanguageString(i.promptBoxStopGenerating,i.messages[i.promptBoxStopGenerating]):x.toLanguageString(i.promptBoxSendButton,i.messages[i.promptBoxSendButton]),title:k?x.toLanguageString(i.promptBoxStopGenerating,i.messages[i.promptBoxStopGenerating]):x.toLanguageString(i.promptBoxSendButton,i.messages[i.promptBoxSendButton]),"aria-live":"polite"}}),[be,ve,R,K,ge,k,Be,x,U]),De=t.useCallback(e=>{A||Y(l=>l.filter(a=>a.name!==e));const n=typeof h=="object"&&h.onRemoveAttachment;n&&(_.current=n),_.current&&_.current(e)},[h,A]),ee=()=>{const e=j!==!1,n=z!==!1,l=h!==!1,a=typeof j=="object"?j:void 0,B=typeof h=="object"?h:{},{restrictions:te,multiple:X=!0,accept:I,onSelectAttachments:ke,onRemoveAttachment:nt,...We}=B,ne={restrictions:te,multiple:X,accept:I},Ve=typeof z=="object"?z:void 0;return t.createElement(t.Fragment,null,l&&t.createElement(Ze.PromptBoxUploadButton,{...b.uploadButtonProps,restrictions:ne.restrictions,multiple:ne.multiple,accept:ne.accept,...We}),e&&t.createElement(Xe.PromptBoxSpeechToTextButton,{...b.speechToTextButtonProps,...a}),n&&t.createElement(Ke.PromptBoxActionButton,{...b.actionButtonProps,...Ve}))},ye=s==="multi"||s==="auto"&&c,xe=h!==!1||j!==!1||z!==!1,Ce=y||xe,Ue=C||y||xe;return t.createElement("div",{...He,className:d.classNames(Oe,"k-input",g,{[`k-input-${re}`]:re,"k-disabled":p,"k-prompt-box-singleline":s==="single","k-prompt-box-multiline":ye}),style:Me},t.createElement(Je.FileBox,{files:R,onRemoveFile:De,header:Ne}),s==="single"?t.createElement("div",{className:`${g}-content`},C&&t.createElement("div",{className:`${g}-affix`},T(C,b)),t.createElement("input",{...he,className:d.classNames("k-input-inner",`${g}-input`)}),Ce?t.createElement("div",{className:`${g}-affix`},y&&T(y,b),ee()):null):t.createElement("div",{className:`${g}-content`},s==="multi"&&ie&&t.createElement("div",{className:`${g}-affix`},T(ie,b)),s==="auto"&&!c&&C&&t.createElement("div",{className:`${g}-affix`},T(C,b)),t.createElement("textarea",{...he,className:d.classNames("k-input-inner",`${g}-textarea`),rows:$e(),style:u?{maxHeight:u}:{},"aria-multiline":"true"}),s==="auto"&&!c&&Ce?t.createElement("div",{className:`${g}-affix`},y&&T(y,b),ee()):null,ye&&Ue?t.createElement("div",{className:`${g}-affix`},C&&T(C,b),(C||y)&&t.createElement("div",{className:"k-spacer"}),y&&T(y,b),ee()):null),F&&t.createElement(d.WatermarkOverlay,{message:$}))});se.propTypes={value:o.string,defaultValue:o.string,mode:o.oneOf(["single","multi","auto"]),rows:o.number,maxTextAreaHeight:o.string,title:o.string,disabled:o.bool,readOnly:o.bool,placeholder:o.string,maxLength:o.number,inputAttributes:o.object,fillMode:o.oneOf(["solid","flat","outline"]),topAffix:o.oneOfType([o.func,o.element,o.string]),startAffix:o.oneOfType([o.func,o.element,o.string]),endAffix:o.oneOfType([o.func,o.element,o.string]),header:o.oneOfType([o.func,o.element,o.string]),onChange:o.func,onFocus:o.func,onBlur:o.func,loading:o.bool,uploadButtonConfig:o.oneOfType([o.bool,o.object]),speechToTextButtonConfig:o.oneOfType([o.bool,o.object]),actionButtonConfig:o.oneOfType([o.bool,o.object]),attachments:o.array,onPromptAction:o.func,className:o.string,style:o.object};se.displayName="KendoPromptBox";exports.PromptBox=se;
|
package/prompt-box/PromptBox.mjs
CHANGED
|
@@ -312,7 +312,7 @@ const p = "k-prompt-box", at = 20, ct = 50, b = {
|
|
|
312
312
|
rounded: "full",
|
|
313
313
|
size: "small",
|
|
314
314
|
svgIcon: C ? et : tt,
|
|
315
|
-
className: C ? "k-generating" : "",
|
|
315
|
+
className: C ? "k-generating k-active" : "",
|
|
316
316
|
onClick: U,
|
|
317
317
|
onMouseDown: pe,
|
|
318
318
|
disabled: !C && !j,
|