@progress/kendo-react-conversational-ui 13.4.0-develop.1 → 13.4.0-develop.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/api/message.interface.d.ts +87 -9
  2. package/chat/ChatPropsAndState.d.ts +108 -9
  3. package/chat/Events.d.ts +9 -0
  4. package/chat/components/ActionGroup.js +1 -1
  5. package/chat/components/ActionGroup.mjs +58 -48
  6. package/chat/components/Chat.d.ts +1 -1
  7. package/chat/components/Chat.js +1 -1
  8. package/chat/components/Chat.mjs +318 -269
  9. package/chat/components/ChatContext.d.ts +6 -3
  10. package/chat/components/ChatMessage.js +1 -1
  11. package/chat/components/ChatMessage.mjs +237 -177
  12. package/chat/components/Header.js +1 -1
  13. package/chat/components/Header.mjs +3 -3
  14. package/chat/components/NewMessage.d.ts +5 -3
  15. package/chat/components/NewMessage.js +1 -1
  16. package/chat/components/NewMessage.mjs +174 -226
  17. package/chat/components/ScrollButtonsWrapper.js +1 -1
  18. package/chat/components/ScrollButtonsWrapper.mjs +34 -40
  19. package/chat/components/SuggestionsGroup.js +1 -1
  20. package/chat/components/SuggestionsGroup.mjs +40 -39
  21. package/chat/components/elements/FileBox.js +1 -1
  22. package/chat/components/elements/FileBox.mjs +33 -41
  23. package/chat/components/elements/PinnedMessage.js +1 -1
  24. package/chat/components/elements/PinnedMessage.mjs +24 -22
  25. package/chat/hooks/useScrollWithButtons.d.ts +4 -0
  26. package/chat/hooks/useScrollWithButtons.js +1 -1
  27. package/chat/hooks/useScrollWithButtons.mjs +25 -23
  28. package/chat/utils/fieldMapping.d.ts +1 -1
  29. package/chat/utils/fieldMapping.js +1 -1
  30. package/chat/utils/fieldMapping.mjs +37 -34
  31. package/chat/utils/scroll.d.ts +15 -1
  32. package/chat/utils/scroll.js +3 -3
  33. package/chat/utils/scroll.mjs +92 -65
  34. package/chat/utils.d.ts +4 -1
  35. package/chat/utils.js +1 -1
  36. package/chat/utils.mjs +37 -37
  37. package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
  38. package/index.d.mts +6 -0
  39. package/index.d.ts +6 -0
  40. package/index.js +1 -1
  41. package/index.mjs +39 -31
  42. package/messages/index.d.ts +50 -0
  43. package/messages/index.js +1 -1
  44. package/messages/index.mjs +60 -40
  45. package/package-metadata.js +1 -1
  46. package/package-metadata.mjs +1 -1
  47. package/package.json +11 -11
  48. package/prompt-box/Events.d.ts +66 -0
  49. package/prompt-box/FileBox.d.ts +22 -0
  50. package/prompt-box/FileBox.js +8 -0
  51. package/prompt-box/FileBox.mjs +72 -0
  52. package/prompt-box/PromptBox.d.ts +35 -0
  53. package/prompt-box/PromptBox.js +8 -0
  54. package/prompt-box/PromptBox.mjs +424 -0
  55. package/prompt-box/PromptBoxActionButton.d.ts +32 -0
  56. package/prompt-box/PromptBoxActionButton.js +8 -0
  57. package/prompt-box/PromptBoxActionButton.mjs +14 -0
  58. package/prompt-box/PromptBoxSpeechToTextButton.d.ts +32 -0
  59. package/prompt-box/PromptBoxSpeechToTextButton.js +8 -0
  60. package/prompt-box/PromptBoxSpeechToTextButton.mjs +14 -0
  61. package/prompt-box/PromptBoxUploadButton.d.ts +108 -0
  62. package/prompt-box/PromptBoxUploadButton.js +8 -0
  63. package/prompt-box/PromptBoxUploadButton.mjs +54 -0
  64. package/prompt-box/interfaces/PromptBoxProps.d.ts +390 -0
@@ -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-intl"),require("@progress/kendo-react-layout"),require("prop-types"),require("@progress/kendo-react-upload"),require("@progress/kendo-react-inputs"),require("@progress/kendo-react-animation"),require("@progress/kendo-react-notification"),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-intl","@progress/kendo-react-layout","prop-types","@progress/kendo-react-upload","@progress/kendo-react-inputs","@progress/kendo-react-animation","@progress/kendo-react-notification","@progress/kendo-react-popup"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactConversationalUi={},e.React,e.KendoReactCommon,e.KendoReactButtons,e.KendoSvgIcons,e.KendoReactIntl,e.KendoReactLayout,e.PropTypes,e.KendoReactUpload,e.KendoReactInputs,e.KendoReactAnimation,e.KendoReactNotification,e.KendoReactPopup)}(this,function(e,t,a,n,l,s,o,r,i,c,u,m,d){"use strict";function p(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(a){if("default"!==a){var n=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,n.get?n:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,Object.freeze(t)}var g=p(t);const h="newMessage.sendButton",f="newMessage.optionsButton",k="newMessage.messageInput",v="avatar.alt",b="messageList.ariaLabel",y="aIPrompt.noOutputs",C="aIPrompt.cancel",E="chat.senderDeletedMessage",I="chat.receiverDeletedMessage",x="chat.copyNotification",w="chat.downloadAllFiles",T="chat.closeReply",F="chat.collapseMessage",A="chat.expandMessage",S="chat.removeFile",N="chat.fileActions",M="chat.attachFile",R="chat.downloadAll",D="chat.scrollLeft",L="chat.scrollRight",B={[h]:"Send",[f]:"Options",[k]:"Message",[v]:"Avatar",[b]:"Message list",[C]:"Cancel",[y]:"No output from AI available",[E]:"You removed this message",[I]:"The message was removed by its sender",[x]:"Text copied to clipboard",[w]:"Download all files",[T]:"Close reply",[F]:"Collapse message",[A]:"Expand message",[S]:"Remove file",[N]:"File actions for",[M]:"Attach file",[R]:"Download all",[D]:"Scroll left",[L]:"Scroll right"},P=(e,t)=>e&&t.author&&e.id===t.author.id,z=(e,t)=>{const a=t.toLanguageString("chatSender.deletedMessage",B[E]),n=t.toLanguageString("chatReceiver.deletedMessage",B[I]);return e?a:n},O=(e,t)=>{if(!t)return;const a=t.querySelector(`[data-message-id="${e}"]`);if(!a)return;const n=t.querySelector(".k-message-list");if(n){const e=n.getBoundingClientRect().top,t=a.getBoundingClientRect().top,l=n.scrollTop+(t-e);n.scrollTo({top:l,behavior:"smooth"})}else a.scrollIntoView({behavior:"smooth",block:"start"})},K=/(https?:\/\/[^\s]+)/g,q=e=>{if(!e)return[""];const a=e.split(K),n=[];return a.forEach(e=>{e&&K.test(e)?(K.lastIndex=0,n.push(t.createElement("a",{key:e,href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"}},e))):e&&n.push(e)}),n},U=g.createContext(void 0),V=()=>{const e=t.useContext(U);if(void 0===e)throw new Error("useChatContext must be used within a ChatContext.Provider");return e},W=e=>{const{files:t,onFileRemove:o,onFileAction:r,onDownload:i,fileActions:c,renderInTextarea:u=!1}=e,{messageFilesLayout:m="vertical"}=V(),d=s.useLocalization(),p=c||[{id:"download",label:"Download",svgIcon:l.downloadIcon}],h=e=>"."+e.split(".").pop()||"",f=e=>u?g.createElement(n.Button,{fillMode:"flat",themeColor:"base",svgIcon:l.xIcon,onClick:t=>{t.stopPropagation(),null==o||o(e.name)},"aria-label":`${d.toLanguageString(S,B[S])} ${e.name}`}):p.length>0&&g.createElement(n.DropDownButton,{fillMode:"flat",themeColor:"base",svgIcon:l.moreVerticalIcon,onClick:e=>{e.syntheticEvent.stopPropagation()},onItemClick:t=>((e,t)=>{var a,n;null==(n=null==(a=e.syntheticEvent)?void 0:a.stopPropagation)||n.call(a),"download"===e.item.id&&(null==i||i([t])),null==r||r(e.item,e,t)})(t,e),items:p.map(e=>({id:e.id,icon:e.icon,text:e.label,svgIcon:e.svgIcon})),"aria-label":`${d.toLanguageString(N,B[N])} ${e.name}`}),k=g.useCallback(()=>a.classNames("k-chat-file-wrapper",{"k-chat-files-wrap":"wrap"===m,"k-chat-files-horizontal":"horizontal"===m}),[m]);return g.createElement("ul",{className:k()},t.map(e=>g.createElement("li",{key:e.name,className:"k-chat-file"},g.createElement(a.IconWrap,{size:"xlarge",...a.getFileExtensionIcon(h(e.name))}),g.createElement("div",{className:"k-chat-file-info"},g.createElement("span",{className:"k-chat-file-name"},e.name),g.createElement("span",{className:"k-chat-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))),f(e))))},j=g.forwardRef((e,t)=>{const{item:r,template:i,contentTemplate:c,onRequestSelection:u,tabIndex:m=-1,dateFormat:d="g",selected:p,allowMessageCollapse:h,messageToolbarActions:f,messageContextMenuActions:k,fileActions:v,isSender:b}=e,{setReplyToMessage:y,messages:C,user:E,internalScrollContainerRef:I,onToolbarAction:x,onContextMenuAction:T,onFileAction:S,onDownload:N,setShowCopyNotification:M,statusTemplate:D,timestampVisibility:L="onFocus"}=V(),[K,U]=g.useState(!1),[j,$]=g.useState(!1),[H,G]=g.useState(!0),[_,Y]=g.useState(!1),X=s.useLocalization(),J=s.useInternationalization(),Q=g.useRef({left:0,top:0}),Z=g.useCallback(()=>{null!=r&&r.text&&(e=>{navigator.clipboard.writeText(e)})(r.text),M&&(M(!0),setTimeout(()=>{M(!1)},3e3))},[r,M]),ee=g.useCallback(e=>{e.stopPropagation(),G(e=>!e)},[]),te=g.useCallback(()=>{Y(!1)},[]),ae=g.useCallback(e=>{("Tab"===e.key||"Enter"===e.key||" "===e.key||"ArrowUp"===e.key||"ArrowDown"===e.key)&&Y(!0)},[]),ne=g.useRef(null);g.useEffect(()=>{p&&ne.current&&ne.current.focus()},[p]);const le=g.useCallback(e=>{Q.current={left:e.pageX,top:e.pageY},e.preventDefault(),$(!0),U(!0)},[]),se=g.useCallback(()=>{$(!1),U(!1)},[]),oe=g.useCallback((e,t)=>e.isDeleted?z(t,X):e.text?e.text:"",[X]),re=g.useCallback(e=>{var t;null!=(t=e.item)&&t.text&&("copy"!==e.item.data.id||r.isDeleted?"reply"===e.item.data.id&&y(r):Z(),T&&T(e.item.data,e,r)),$(!1),U(!1)},[r,T,y,Z]),ie=g.useCallback(()=>{if(r.replyToId){const e=((e,t)=>e.find(e=>e.id===t))(C,r.replyToId);if(e){const t=t=>{t.preventDefault(),t.stopPropagation();const a=null==I?void 0:I.current;O(e.id,a)};return g.createElement("div",{className:a.classNames("k-message-reference",P(E,e)?"k-message-reference-sender":"k-message-reference-receiver"),onClick:t},g.createElement("div",{className:"k-message-reference-content"},q(oe(e,P(E,e)))))}}return null},[r.replyToId,C,E,oe,I]),ce=g.useCallback(()=>{const e=[{id:"reply",label:"Reply",svgIcon:l.undoIcon},{id:"copy",label:"Copy",svgIcon:l.copyIcon}],t=k?[...e.map(e=>k.find(t=>t.id===e.id)||e),...k.filter(t=>!e.some(e=>e.id===t.id))]:e;return g.createElement(o.ContextMenu,{onSelect:re,onClose:se,vertical:!0,show:K,offset:Q.current},t.map(e=>"delete"!==e.id||b?g.createElement(o.MenuItem,{key:e.id,text:e.label,icon:e.icon,svgIcon:e.svgIcon,data:e}):null))},[k,re,se,K,b]),ue=g.useCallback(()=>r.files&&r.files.length>1?g.createElement("div",{className:"k-chat-download-button-wrapper"},g.createElement(n.Button,{className:"k-chat-download-button",fillMode:"flat",themeColor:"base",svgIcon:l.downloadIcon,onClick:e=>{e.stopPropagation(),N&&N(r.files,r)},"aria-label":X.toLanguageString(w,B[w])},g.createElement("span",{className:"k-button-text"},X.toLanguageString(R,B[R])))):null,[r,N,X]),me=g.useCallback(()=>{if(r.typing)return g.createElement("div",{className:"k-chat-bubble k-bubble"},g.createElement("div",{className:"k-bubble-content"},g.createElement("div",{className:"k-typing-indicator"},g.createElement("span",null),g.createElement("span",null),g.createElement("span",null))));if(i){const e=i;return g.createElement(g.Fragment,null,g.createElement(e,{item:r}),ce())}return r.text||r.files&&r.files.length>0?g.createElement(g.Fragment,null,g.createElement("div",{className:a.classNames("k-chat-bubble","k-bubble",{"k-bubble-expandable":h,"k-expanded":h&&H,"k-selected":p,"k-active":j}),onClick:()=>u(p?void 0:r.selectionIndex),onContextMenu:le},g.createElement("div",{className:"k-bubble-content"},c?g.createElement(c,{item:r}):g.createElement(g.Fragment,null,(r.text||r.isDeleted||r.replyToId)&&g.createElement("span",{className:"k-chat-bubble-text"},!r.isDeleted&&ie(),q(oe(r,P(E,r)))),r.files&&r.files.length>0&&g.createElement(W,{files:r.files,message:r,onFileAction:S,onDownload:e=>null==N?void 0:N(e,r),renderInTextarea:!1,fileActions:v}),ue())),h&&g.createElement("span",{className:"k-bubble-expandable-indicator",onClick:ee,role:"button","aria-label":H?X.toLanguageString(F,B[F]):X.toLanguageString(A,B[A]),tabIndex:0,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),ee(e))}},g.createElement(a.IconWrap,{icon:H?l.chevronUpIcon:l.chevronDownIcon,size:"medium"}))),ce()):null},[r,i,c,h,H,p,j,u,le,ie,oe,E,S,v,ue,ee,X,ce,N]),de=g.useCallback(()=>{let e=null;if(r.timestamp){const t="onFocus"===L&&p;"hidden"===L||(e=g.createElement("time",{className:"k-message-time","aria-hidden":!t},J.formatDate(r.timestamp,d)))}return e},[r.timestamp,p,d,L,J]),pe=g.useCallback(()=>{let e=null;return r.status&&p&&(e=D?g.createElement(D,{item:r}):g.createElement("span",{className:"k-message-status"},g.createElement(a.IconWrap,{icon:l.checkCircleIcon,size:"xsmall"}),r.status)),e},[r,p,D]),ge=g.useCallback(()=>a.classNames({"k-focus":p,"k-message-removed":r.isDeleted},"k-message"),[p,r.isDeleted]),he=g.useCallback(()=>f&&f.length>0&&g.createElement("div",{className:"k-chat-message-toolbar k-toolbar k-toolbar-md k-toolbar-flat"},f.map(e=>"delete"!==e.id||b?g.createElement(n.Button,{key:e.id,fillMode:"flat",className:"k-toolbar-button",themeColor:"base",icon:e.icon,svgIcon:e.svgIcon,onClick:t=>{t.stopPropagation(),"copy"!==e.id||r.isDeleted?"reply"===e.id&&y(r):Z(),x&&x(e,t,r)},onMouseDown:e=>e.preventDefault()}):null)),[Z,b,r,f,x,y]);return g.createElement("div",{"data-message-id":r.id,className:ge(),tabIndex:m,onMouseDown:te,onKeyDown:ae,onFocus:e=>{_&&u(r.selectionIndex)},ref:e=>{ne.current=e,"function"==typeof t?t(e):t&&(t.current=e)},onContextMenu:i?le:void 0},de(),me(),pe(),he())});j.displayName="ChatMessage";const $=e=>e[e.length-1],H=e=>(t,a,n)=>{const l=n===e-1;return((e,t)=>{const a=t.timestamp,n=$(e);if(a&&(!n||((e,t)=>e&&t&&(t.getDate()!==e.getDate()||t.getMonth()!==e.getMonth()||t.getFullYear()!==e.getFullYear()))(a,n.timestamp))){const t={type:"date-marker",timestamp:a,trackBy:a.getTime()};e.push(t)}})(t,a),((e,t,a)=>{const n=$(e);let l;t.typing&&!a||(n&&"message-group"===n.type&&(l=n.messages),l&&P(t.author,$(l))?l.push(t):e.push({type:"message-group",messages:[t],author:t.author,timestamp:t.timestamp,trackBy:t}))})(t,a,l),a.attachments&&a.attachments.length>1&&t.push({type:"attachment-group",attachments:a.attachments,attachmentLayout:a.attachmentLayout,timestamp:a.timestamp,trackBy:a}),a.suggestedActions&&l&&t.push({type:"action-group",actions:a.suggestedActions,timestamp:a.timestamp,trackBy:a}),t};const G=e=>{const{item:t,onActionExecute:n,selected:l}=e,s=g.useRef(null);g.useEffect(()=>{l&&s.current&&s.current.focus()},[l]);const o=g.useCallback(e=>{(e.keyCode===a.Keys.enter||" "===e.key)&&(e.preventDefault(),n(t,e))},[n,t]),r=g.useCallback(()=>a.classNames("k-suggestion k-suggestion-primary",{"k-selected":l},{"k-focus":l}),[l]);return g.createElement("span",{role:"button",className:r(),onClick:e=>n(t,e),ref:s,onKeyDown:o,tabIndex:0,"aria-label":t.title||t.value},t.title||t.value)},_=({visible:e,dir:t,canScrollLeft:a,canScrollRight:o,onScrollLeft:r,onScrollRight:i,children:c})=>{const u=s.useLocalization();if(!e)return c;const m=u.toLanguageString(D,B[D]),d=u.toLanguageString(L,B[L]),p="rtl"!==t?m:d,h="rtl"!==t?d:m;return g.createElement("div",{className:"k-suggestion-scrollwrap"},g.createElement(n.Button,{fillMode:"solid",themeColor:"base",size:"medium",rounded:"medium",svgIcon:"rtl"===t?l.chevronRightIcon:l.chevronLeftIcon,onClick:r,disabled:!a,className:"k-icon-button","aria-label":p,title:p}),c,g.createElement(n.Button,{fillMode:"solid",themeColor:"base",size:"medium",rounded:"medium",svgIcon:"rtl"===t?l.chevronLeftIcon:l.chevronRightIcon,onClick:i,disabled:!o,className:"k-icon-button","aria-label":h,title:h}))},Y=100,X=(e,t)=>{const{enabled:a,dir:n,itemsDependency:l=[],scrollSpeed:s=Y}=t,[o,r]=g.useState(!1),[i,c]=g.useState(!1),u=g.useCallback(()=>{if(e.current&&a){const{scrollLeft:t,scrollWidth:a,clientWidth:l}=e.current,s="rtl"!==n?t+l>=a-1:l-t>=a-1;r(!(0===t)),c(!s)}},[a,n]),m=g.useCallback(()=>{e.current&&a&&e.current.scrollBy({left:"rtl"!==n?-s:s,behavior:"smooth"})},[a,n,s]),d=g.useCallback(()=>{e.current&&a&&e.current.scrollBy({left:"rtl"!==n?s:-s,behavior:"smooth"})},[a,n,s]);return g.useEffect(()=>{const t=e.current;if(t&&a){u(),t.addEventListener("scroll",u);const e=new ResizeObserver(u);return e.observe(t),()=>{t.removeEventListener("scroll",u),e.disconnect()}}},[a,n]),g.useLayoutEffect(()=>{a&&u()},[a,n,l]),{canScrollLeft:o,canScrollRight:i,scrollLeft:m,scrollRight:d}},J=e=>{var t;const{group:n,onActionExecute:l,selected:s,onRequestSelection:o,quickActionsLayout:r="scroll",dir:i}=e,[c,u]=g.useState(null),m=g.useRef(null),{canScrollLeft:d,canScrollRight:p,scrollLeft:h,scrollRight:f}=X(m,{enabled:"scrollbuttons"===r,dir:i,itemsDependency:n.actions});g.useEffect(()=>{s||null===c?s&&null===c&&u(0):u(null)},[s,c]);const k=g.useCallback(()=>n.actions?n.actions.length-1:-1,[n.actions]),v=g.useCallback((e,t=0)=>{let a=null;return e?null===c?a=t:c<k()&&(a=c+1):null===c?a=0:c>0&&(a=c-1),null!==a&&u(a),a},[c,k]),b=g.useCallback(()=>{o(n.selectionIndex)},[o,n.selectionIndex]),y=g.useCallback(e=>{let t=null;const n=a.Keys.left,l=a.Keys.right;e.keyCode===n?t=v(!1):e.keyCode===l&&(t=v(!0)),null!==t&&(e.preventDefault(),e.stopPropagation())},[v]),C=g.useCallback(()=>a.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":"scroll"===r}),[r]),E=g.createElement("div",{className:C(),onClick:b,onKeyDown:y,role:"toolbar",tabIndex:0,"aria-label":"Action group",ref:"scrollbuttons"===r?m:void 0},null==(t=n.actions)?void 0:t.map((e,t)=>g.createElement(G,{item:e,onActionExecute:l,selected:t===c,key:e.value})));return g.createElement(_,{visible:"scrollbuttons"===r,dir:i,canScrollLeft:d,canScrollRight:p,onScrollLeft:h,onScrollRight:f},E)},Q=e=>{const{item:t,template:n,tabbable:l,onClick:s,selected:o}=e,r=g.useRef(null);g.useEffect(()=>{o&&r.current&&r.current.focus()},[o]);const i=g.useCallback(()=>{if(void 0!==l)return l?0:-1},[l]),c=g.useCallback(()=>a.classNames({"k-selected":o},{"k-focus":o}),[o]),u=g.useCallback(()=>t.title?g.createElement("h5",{className:"k-card-title"},t.title):null,[t.title]),m=g.useCallback(()=>t.subtitle?g.createElement("h6",{className:"k-card-subtitle"},t.subtitle):null,[t.subtitle]),d=g.useCallback(()=>0===t.contentType.indexOf("image/")?g.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]),p=n;return g.createElement("div",{className:c(),tabIndex:i(),onClick:s,ref:r},n?g.createElement(p,{item:t}):g.createElement("div",{className:"k-card"},g.createElement("div",{className:"k-card-body"},u(),m(),d())))},Z=e=>{const{group:t,itemTemplate:s,selected:o,isLastGroup:r,onRequestSelection:i}=e,[c,u]=g.useState(null);g.useEffect(()=>{o||null===c?o&&null===c&&u(0):u(null)},[o,c]);const m=g.useCallback(e=>"list"!==e.attachmentLayout,[]),d=g.useCallback(()=>t.attachments?t.attachments.length-1:-1,[t.attachments]),p=g.useCallback(()=>t.attachments.length-1,[t.attachments]),h=g.useCallback((e,t=0)=>{let a=null;return e?null===c?a=t:c<d()&&(a=c+1):null===c?a=0:c>0&&(a=c-1),null!==a&&u(a),a},[c,d]),f=g.useCallback(()=>{i(t.selectionIndex)},[i,t.selectionIndex]),k=g.useCallback(e=>{let n,l,s=null;m(t)?(n=a.Keys.left,l=a.Keys.right):(n=a.Keys.up,l=a.Keys.down),e.keyCode===n?s=h(!1):e.keyCode===l&&(s=h(!0)),null!==s&&(e.preventDefault(),e.stopPropagation())},[h,m,t]),v=g.useCallback(e=>{f(),u(e)},[f]),b=g.useCallback(e=>{f(),h(e,1)},[f,h]),y=g.useCallback(()=>{let e=null;return m(t)&&c&&(e=g.createElement(n.Button,{icon:"chevron-left",onClick:()=>b(!1),svgIcon:l.chevronLeftIcon})),e},[m,t,c,b]),C=g.useCallback(()=>{let e=null;return m(t)&&c!==p()&&(e=g.createElement(n.Button,{icon:"chevron-right",onClick:()=>b(!0),svgIcon:l.chevronRightIcon})),e},[m,t,c,p,b]),E=g.useCallback(()=>a.classNames({"k-card-list":t.attachmentLayout,"k-card-deck":m(t)}),[t.attachmentLayout,t,m]),I=m(t),x=g.createElement("div",{className:E(),onKeyDown:I?void 0:k},t.attachments.map((e,t)=>g.createElement(Q,{item:e,template:s,selected:t===c,tabbable:r&&t===c,onClick:()=>v(t),key:e.content})));return I?g.createElement("div",{className:"k-card-deck-scrollwrap",onKeyDown:k},y(),x,C()):x},ee=({item:e,timestampTemplate:t})=>{const a=s.useInternationalization(),n=t;return g.createElement("div",{className:"k-timestamp"},n?g.createElement(n,{item:e}):a.formatDate(e.timestamp,"D"))},te=e=>{const{group:t,user:n,itemTemplate:l,contentTemplate:r,attachmentTemplate:i,onRequestSelection:c,selectedItemIndex:u,isLastGroup:m,message:d,allowMessageCollapse:p,messageToolbarActions:h,messageContextMenuActions:f,fileActions:k,messageWidthMode:b="standard",showAvatar:y=!0,showUsername:C=!0}=e,{userStatusTemplate:E}=V(),I=s.useLocalization(),x=t.messages.length>0&&P(n,t.messages[0]),{avatarUrl:w,avatarAltText:T,name:F}=t.author,A=g.useMemo(()=>a.classNames("k-message-group",{"k-message-group-sender":x,"k-message-group-receiver":!x,"k-message-group-full-width":"full"===b,"k-no-avatar":!y||!w}),[x,b,y,w]),S=g.useMemo(()=>{const e=t.messages.length-1;return t.messages.map((t,a)=>{const s=[g.createElement(d,{item:t,template:l,contentTemplate:r,selected:t.selectionIndex===u,onRequestSelection:c,tabIndex:a===e&&m?0:-1,key:t.id,allowMessageCollapse:p,messageToolbarActions:h,messageContextMenuActions:f,fileActions:k,isSender:P(n,t)})];return t.attachments&&1===t.attachments.length&&s.push(g.createElement(Q,{item:t.attachments[0],template:i,selected:!1,key:`att-${t.attachments[0].content}`})),s})},[t.messages,d,l,r,u,c,m,p,h,f,k,n,i]),N=void 0!==T?T:I.toLanguageString(v,B[v]);return g.createElement("div",{className:A},(()=>{if(!y||!w)return;const e=g.createElement(o.Avatar,{type:"image"},g.createElement("img",{src:w,alt:N}));if(E){const a=t.messages[t.messages.length-1];return g.createElement("div",{className:"k-chat-user-status-wrapper"},e,g.createElement("div",{className:"k-chat-user-status"},g.createElement(E,{message:"dataItem"in a?a.dataItem:a})))}return e})(),g.createElement("div",{className:"k-message-group-content"},C&&g.createElement("span",{className:"k-message-author"},F),S))},ae=e=>{const{suggestions:t,onSuggestionClick:n,suggestionsView:l,suggestionTemplate:s,suggestionsLayout:o,dir:r}=e,i=g.useRef(null),{canScrollLeft:c,canScrollRight:u,scrollLeft:m,scrollRight:d}=X(i,{enabled:"scrollbuttons"===o,dir:r,itemsDependency:t}),p=g.useCallback((e,t)=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),null==n||n(t))},[n]),h=g.useCallback(()=>t.map(e=>s?g.createElement(s,{key:e.id,suggestion:e,onClick:()=>{null==n||n(e)}}):g.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:()=>!e.disabled&&(null==n?void 0:n(e)),onKeyDown:t=>!e.disabled&&p(t,e),key:e.id,title:e.description,className:a.classNames("classic"===l?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},e.text)),[t,s,n,l,p]);if(!t||0===t.length)return null;if("classic"===l)return h();const f=g.createElement("div",{role:"group",className:a.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":"scroll"===o}),ref:"scrollbuttons"===o?i:void 0},h());return g.createElement(_,{visible:"scrollbuttons"===o,dir:r,canScrollLeft:c,canScrollRight:u,onScrollLeft:m,onScrollRight:d},f)},ne=g.forwardRef((e,t)=>{const{onSendMessage:o,isDirectionRightToLeft:r,placeholder:u,MessageBox:m,suggestions:d,onSuggestionClick:p,inputValue:f,onInputValueChange:v,suggestionTemplate:b,sendButtonConfig:y,onInputClick:C,suggestionsLayout:E,dir:I}=e,{replyToMessage:x,setReplyToMessage:w,user:F,messageListScrollContainerRef:A,speechToTextConfig:S,uploadConfig:N}=V(),[R]=g.useState(!1),[D,L]=g.useState(void 0),[O,K]=g.useState([]),[q,U]=g.useState(!1),j=g.useRef(null),$=g.useRef(null),H=s.useLocalization(),G=g.useCallback(()=>{null!==j.current&&j.current.focus()},[]);g.useEffect(()=>{void 0!==f&&f!==D&&(L(f),G())},[f,D,G]),g.useEffect(()=>{x&&G()},[x,G]),g.useLayoutEffect(()=>{q&&null!=A&&A.current&&(A.current.scrollTop=A.current.scrollHeight-A.current.clientHeight,U(!1))},[q,A]);const _=g.useCallback(e=>{const t=e.value;L(t),v&&v(t)},[v]),Y=g.useMemo(()=>!!(null!=D&&D.trim()||!1!==N&&O.length>0),[D,O.length,N]),X=g.useCallback(e=>{if(e.preventDefault(),o){if(Y){const t={id:"",author:F,text:D||"",timestamp:new Date,replyToId:x?x.id:void 0,files:O.map(e=>({name:e.name,size:e.size,type:e.extension,rawFile:e.getRawFile?e.getRawFile():e}))};w(null),o(t,e),K([]),L(""),v&&v(""),U(!0)}}},[o,D,F,x,O,w,v,Y]),J=g.useCallback(e=>{if("Enter"!==e.key||!e.shiftKey)switch(e.key){case"Enter":return e.preventDefault(),X(e);case"Escape":j.current&&j.current.blur();break;default:return}},[X]);g.useImperativeHandle(t,()=>({focusInput:G}),[G]);const Q=g.useCallback(e=>{K(t=>t.filter(t=>t.name!==e))},[]),Z=g.useCallback(()=>!1===N?null:g.createElement(W,{files:O,onFileRemove:Q,renderInTextarea:!0}),[O,Q,N]),ee=g.useCallback((e,t)=>e.isDeleted?z(t,H):e.text,[H]),te=g.useCallback(()=>{if(x){const e=P(F,x);return g.createElement("div",{className:a.classNames("k-message-reference",e?"k-message-reference-sender":"k-message-reference-receiver")},g.createElement("div",{className:"k-message-reference-content"},ee(x,e)),g.createElement("span",{className:"k-spacer"}),g.createElement(n.Button,{fillMode:"flat",themeColor:"base",svgIcon:l.xIcon,onClick:()=>w(null),"aria-label":H.toLanguageString(T,B[T])}))}return null},[x,F,ee,w,H]),ne=g.useCallback(e=>{try{const t=Array.from(e.newState);K(e=>[...e,...t]),G()}catch{}},[G]),le=g.useCallback(()=>{$.current&&!1!==N&&$.current.actionElement.click()},[N]),se=g.useCallback(e=>{},[]),oe=g.useCallback(e=>{const{isFinal:t,alternatives:a}=e;if(a.length>0){const e=a[0];t&&L(t=>(t?`${t} `:"")+e.transcript)}},[]),re=g.useCallback(()=>g.createElement(g.Fragment,null,O.length>0&&Z(),x&&g.createElement("span",{className:"k-input-prefix k-input-prefix-horizontal"},te())),[O.length,x,Z,te]),ie=g.useCallback(e=>{e.preventDefault()},[]),ce=g.useCallback(e=>{"Escape"===e.key&&e.currentTarget.blur()},[]),ue=g.useMemo(()=>g.createElement(n.Button,{rounded:"full",fillMode:"solid",themeColor:"primary",className:"k-chat-send",icon:"paper-plane",svgIcon:l.paperPlaneIcon,onClick:X,onMouseDown:ie,onKeyDown:ce,"aria-label":H.toLanguageString(h,B[h]),dir:r?"rtl":void 0,disabled:!Y,"aria-disabled":!Y,...y}),[X,ie,ce,H,r,Y,y]),me=g.useCallback(()=>{const e="object"==typeof S?S:void 0,t="object"==typeof N?N:{},{className:s,...o}=t,r=a.classNames("k-hidden",s),u=!1!==N,m=!1!==S;return g.createElement(c.InputSuffix,null,m&&g.createElement(n.SpeechToTextButton,{fillMode:"clear",themeColor:"base",onError:se,onResult:oe,...e}),u&&g.createElement(g.Fragment,null,g.createElement(n.Button,{key:"attach-file",fillMode:"clear",themeColor:"base",svgIcon:l.paperclipIcon,onClick:le,"aria-label":H.toLanguageString(M,B[M])}),g.createElement(i.Upload,{ref:$,files:O,onAdd:ne,multiple:!0,autoUpload:!1,...o,className:r})),g.createElement("span",{className:"k-spacer"}),ue)},[S,N,O,se,oe,le,ne,H,ue]),de=g.useMemo(()=>g.createElement(c.TextArea,{className:a.classNames("k-message-box","!k-flex-col",{"k-focus":R}),resizable:"none",rows:1,placeholder:u,value:D,onChange:_,onKeyDown:J,onClick:C,prefix:re,suffix:me,ref:j,"aria-label":H.toLanguageString(k,B[k])}),[R,u,D,_,J,C,re,me,H]);return g.createElement("div",{className:"k-message-box-wrapper"},d&&d.length>0&&g.createElement(ae,{onSuggestionClick:p,suggestions:d,suggestionTemplate:b,suggestionsLayout:E,dir:I}),m?g.createElement(m,{messageInput:de,sendButton:ue}):de)});ne.displayName="NewMessage";const le=e=>g.createElement(o.AppBar,{className:"k-chat-header",positionMode:"sticky",themeColor:"inherit"},e.children),se=e=>{const{message:t,onUnpin:o,user:r}=e,i=s.useLocalization(),{internalScrollContainerRef:c}=V(),u=g.useCallback(e=>{e.preventDefault(),e.stopPropagation();const a=null==c?void 0:c.current;O(t.id,a)},[t.id,c]);return g.createElement("div",{className:"k-message-reference k-message-reference-receiver k-message-pinned",onClick:u},g.createElement(a.IconWrap,{size:"xlarge",icon:l.pinIcon}),g.createElement("div",{className:"k-message-reference-content"},null!=t&&t.isDeleted?r&&z(P(r,t),i):null==t?void 0:t.text),g.createElement("span",{className:"k-spacer"}),g.createElement(n.Button,{fillMode:"flat",svgIcon:l.xIcon,onClick:e=>{e.stopPropagation(),null==o||o(t)}}))},oe=e=>{const{show:t,text:a}=e;return g.createElement("div",{style:{position:"absolute",top:"90%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e3,pointerEvents:t?"auto":"none"}},g.createElement(u.Fade,null,t&&g.createElement(m.Notification,{type:{style:"dark"},closable:!1},g.createElement("span",null,a))))},re=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"13.4.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"}),ie={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"},ce=(e,t={})=>{const a={...ie,...t};let n,l;n=e.author&&"object"==typeof e.author?{id:e.author.id||e.author[a.authorIdField]||e[a.authorIdField]||"",name:e.author.name||e.author[a.authorNameField]||e[a.authorNameField],avatarUrl:e.author.avatarUrl||e.author[a.authorImageUrlField]||e[a.authorImageUrlField],avatarAltText:e.author.avatarAltText||e.author[a.authorImageAltTextField]||e[a.authorImageAltTextField]}:{id:e[a.authorIdField]||e.authorId||"",name:e[a.authorNameField]||e.authorName,avatarUrl:e[a.authorImageUrlField]||e.authorImageUrl,avatarAltText:e[a.authorImageAltTextField]||e.authorImageAltText},l=e.timestamp?new Date(e.timestamp):e[a.timestampField]?new Date(e[a.timestampField]):new Date;const s={id:void 0!==e.id?e.id:e[a.idField],text:void 0!==e.text?e.text:e[a.textField]||"",author:n,timestamp:l,status:void 0!==e.status?e.status:e[a.statusField],attachments:void 0!==e.attachments?e.attachments:e[a.attachmentsField],attachmentLayout:e.attachmentLayout||"list",suggestedActions:void 0!==e.suggestedActions?e.suggestedActions:e[a.suggestedActionsField],isPinned:void 0!==e.isPinned?e.isPinned:e[a.isPinnedField]||!1,typing:void 0!==e.typing?e.typing:e[a.typingField],files:void 0!==e.files?e.files:e[a.filesField]||[]};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[a.replyToIdField]&&(s.replyToId=e[a.replyToIdField]),void 0!==e.isDeleted?s.isDeleted=e.isDeleted:void 0!==e[a.isDeletedField]&&(s.isDeleted=e[a.isDeletedField]),{...s,dataItem:e}},ue=(e,t={})=>Array.isArray(e)?e.map(e=>ce(e,t)):[],me=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),de=({viewItemsWrapperRef:e,isKeyboardNavigationActiveRef:t,processedMessages:a,suggestions:n})=>{const l=g.useCallback(()=>{e.current&&(e.current.scrollTop=e.current.scrollHeight-e.current.clientHeight)},[e]),s=g.useCallback(()=>{if(!e.current)return!0;const t=e.current,{scrollTop:a,scrollHeight:n,clientHeight:l}=t;return n-a-l<75},[e]),o=g.useCallback(e=>0===e?16:e<=2?32*e:Math.min(50*e,200),[]),r=g.useCallback((t,a)=>{const n=o(t);setTimeout(()=>{!s()&&e.current&&a(t+1)},n)},[o,s,e]),i=g.useCallback(()=>{const e=(t=0)=>{t>5||requestAnimationFrame(()=>{l(),r(t,e)})};e()},[l,r]),c=g.useCallback(()=>{l(),setTimeout(()=>{!s()&&e.current&&l()},50)},[l,s,e]),u=g.useCallback(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(c)})})},[c]),m=g.useCallback(()=>{l(),setTimeout(()=>{!s()&&e.current&&i()},25)},[l,s,e,i]),d=g.useCallback((a=!1)=>{e.current&&!t.current&&s()&&(a?m():u())},[s,m,u,e,t]);g.useEffect(()=>{const e=window.setTimeout(()=>l(),250);return()=>{clearTimeout(e)}},[l]),g.useEffect(()=>{i()},[a.length,i]);const p=g.useRef(new Map);g.useEffect(()=>{const e=new Map;let t=!1;a.forEach(a=>{if(void 0!==a.id){const n=a.id,l=!!a.typing,s=p.current.get(n);e.set(n,l),!0===s&&!1===l&&(t=!0)}}),p.current=e,t&&i()},[a,i]),g.useEffect(()=>{const e=window.setTimeout(()=>{d()},50);return()=>{clearTimeout(e)}},[a,d]),g.useEffect(()=>{if(a.length>0){const e=a[a.length-1],t=(null==e?void 0:e.text)||"";(t.includes("```")||t.includes("\n\n")||t.includes("<pre>")||t.includes("<code>")||t.includes("<table>")||t.length>500)&&d(!0)}},[a,d]),g.useEffect(()=>{if(n&&n.length>0){const e=window.setTimeout(()=>{d()},100);return()=>{clearTimeout(e)}}},[n,d]),g.useEffect(()=>{if(!e.current)return()=>{};let t;const a=new ResizeObserver(()=>{t&&clearTimeout(t),t=window.setTimeout(()=>{d()},50)}),n=e.current.querySelector(".k-message-list-content");return n&&a.observe(n),()=>{a.disconnect()}},[d,e]);const h=g.useCallback(e=>{var t;if("characterData"!==e.type&&"childList"!==e.type)return!1;const a=null!=(t=e.target.textContent)?t:"";return a.includes("```")||a.includes("\n\n")||a.includes("<pre>")||a.includes("<code>")||a.includes("<table>")||e.addedNodes&&e.addedNodes.length>2},[]),f=g.useCallback(e=>{let t=!1,a=!1;return e.forEach(e=>{var n;("childList"===e.type||"characterData"===e.type||"attributes"===e.type&&["class","style"].includes(null!=(n=e.attributeName)?n:""))&&(t=!0,h(e)&&(a=!0))}),{shouldScroll:t,hasSignificantChange:a}},[h]),k=g.useCallback((e,t)=>{t.current&&clearTimeout(t.current),e?d(!0):t.current=window.setTimeout(()=>{d()},50)},[d]);g.useEffect(()=>{if(!e.current)return()=>{};const t={current:void 0};let a=0;const n=new MutationObserver(e=>{const n=Date.now();if(n-a<16)return;a=n;const{shouldScroll:l,hasSignificantChange:o}=f(e);l&&s()&&k(o,t)});return n.observe(e.current,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["class","style"]}),()=>{n.disconnect(),t.current&&clearTimeout(t.current)}},[s,f,k,e])},pe=["allowMessageCollapse","messageWidthMode","showAvatar","showUsername","messageTemplate","messageContentTemplate","messageToolbarActions","messageContextMenuActions","fileActions"];function ge(e,t,a,n,l){const s=((e,t)=>{var a,n;return(null==(a=null==e?void 0:e.author)?void 0:a.id)===t||(null==(n=null==e?void 0:e.author)?void 0:n.id)===String(t)})(e,t)?n:l,o={};return pe.forEach(e=>{var t;o[e]=null!=(t=null==s?void 0:s[e])?t:null==a?void 0:a[e]}),o}const he=g.forwardRef((e,t)=>{const{messages:n=[],messageTemplate:l,messageContentTemplate:o,attachmentTemplate:r,width:i,height:c,onSendMessage:u,onSuggestionClick:m,onInputValueChange:d,onActionExecute:p,dir:h,messageBox:f,placeholder:k,className:v,style:y,message:C=j,authorId:E,suggestions:I,suggestionTemplate:w,suggestionsLayout:T="scroll",quickActionsLayout:F="scroll",inputValue:A,headerTemplate:S,noDataTemplate:N,timestampTemplate:M,statusTemplate:R,userStatusTemplate:D,allowMessageCollapse:L,messageToolbarActions:P,messageContextMenuActions:z,fileActions:O,onUnpin:K,messageWidthMode:q,showAvatar:V,showUsername:W,timestampVisibility:$,authorMessageSettings:G,receiverMessageSettings:_,onToolbarAction:Y,onContextMenuAction:X,onFileAction:Q,onDownload:ae,speechToTextConfig:ie,uploadConfig:ce,sendButtonConfig:pe,messageFilesLayout:he,textField:fe,statusField:ke,authorIdField:ve,authorNameField:be,authorImageUrlField:ye,authorImageAltTextField:Ce,idField:Ee,timestampField:Ie,filesField:xe,attachmentsField:we,replyToIdField:Te,isDeletedField:Fe,isPinnedField:Ae,typingField:Se,suggestedActionsField:Ne,...Me}=e,[Re,De]=g.useState(null),[Le,Be]=g.useState(!1),[Pe,ze]=g.useState(!1),[Oe,Ke]=g.useState(null),[qe,Ue]=g.useState(null),Ve=g.useRef(null),We=g.useRef(null),je=g.useRef(null),$e=g.useRef(null),He=g.useRef(void 0),Ge=g.useRef(!1),_e=g.useRef(null),Ye=g.useRef(""),Xe=g.useMemo(()=>{if(!n||0===n.length)return[];const e={textField:fe,statusField:ke,authorIdField:ve,authorNameField:be,authorImageUrlField:ye,authorImageAltTextField:Ce,idField:Ee,timestampField:Ie,filesField:xe,attachmentsField:we,replyToIdField:Te,isDeletedField:Fe,isPinnedField:Ae,typingField:Se,suggestedActionsField:Ne};return!Object.values(e).some(e=>void 0!==e)&&me(n[0])?n.map(e=>({...e,timestamp:e.timestamp?new Date(e.timestamp):e.timestamp})):ue(n,e)},[n,fe,ke,ve,be,ye,Ce,Ee,Ie,xe,we,Te,Fe,Ae,Se,Ne]);g.useEffect(()=>{if(E===Ye.current&&_e.current)Ue(_e.current);else if(E&&Xe.length>0){const e=Xe.find(e=>e.author&&(e.author.id===E||e.author.id===String(E))),t=(null==e?void 0:e.author)||{id:E};_e.current=t,Ye.current=E,Ue(t)}},[E,Xe]);const Je=g.useMemo(()=>Xe.length>0?(e=>{const t=e.slice().reduce(H(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})(Xe):[],[Xe]),Qe=g.useMemo(()=>!a.validatePackage(re,{component:"Chat"}),[]),Ze=a.getLicenseMessage(re),et=g.useMemo(()=>Xe.find(e=>e.isPinned),[Xe]),tt=s.useLocalization();de({viewItemsWrapperRef:je,isKeyboardNavigationActiveRef:Ge,processedMessages:Xe,suggestions:I});const at=g.useCallback(()=>{clearTimeout(He.current)},[]),nt=g.useCallback(()=>{He.current=window.setTimeout(()=>{De(null)},0)},[]),lt=g.useCallback(e=>{De(e)},[]),st=g.useCallback(e=>{let t=null;const n=null!==Re?Re:Je.lastSelectionIndex;e.keyCode===a.Keys.up?null===n?t=0:n>0&&(t=n-1):e.keyCode===a.Keys.down?null===n?t=0:n<Je.lastSelectionIndex&&(t=n+1):e.keyCode===a.Keys.home?t=0:e.keyCode===a.Keys.end&&(t=Je.lastSelectionIndex),null!==t&&(De(t),Ge.current=!0,e.preventDefault())},[Re,Je]),ot=g.useCallback((e,t,a)=>{var n;if(p&&p({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":u&&u({message:{id:"",author:qe,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==(n=$e.current)||n.focusInput()}},[p,u,qe]),rt=g.useCallback(()=>a.classNames("k-chat",v,{"k-rtl":Le}),[v,Le]),it=g.useCallback(()=>{const e=Je.length-1;return Je.map((t,a)=>{var n;if("date-marker"===t.type)return g.createElement(ee,{item:t,key:t.trackBy,timestampTemplate:M});if("message-group"===t.type){const s={allowMessageCollapse:L,messageWidthMode:q,showAvatar:V,showUsername:W,messageTemplate:l,messageContentTemplate:o,messageToolbarActions:P,messageContextMenuActions:z,fileActions:O},i=ge(null==(n=null==t?void 0:t.messages)?void 0:n[0],E,s,G,_);return g.createElement(te,{group:t,itemTemplate:i.messageTemplate,contentTemplate:i.messageContentTemplate,attachmentTemplate:r,user:qe,selectedItemIndex:Re,onRequestSelection:lt,isLastGroup:a===e,key:t.messages[0].selectionIndex,message:C,allowMessageCollapse:i.allowMessageCollapse,messageToolbarActions:i.messageToolbarActions,messageContextMenuActions:i.messageContextMenuActions,fileActions:i.fileActions,messageWidthMode:i.messageWidthMode,showAvatar:i.showAvatar,showUsername:i.showUsername})}return"attachment-group"===t.type?g.createElement(Z,{group:t,itemTemplate:r,onRequestSelection:lt,selected:t.selectionIndex===Re,isLastGroup:a===e,key:t.selectionIndex}):"action-group"===t.type?g.createElement(J,{group:t,onActionExecute:ot,onRequestSelection:lt,selected:t.selectionIndex===Re,key:t.selectionIndex,quickActionsLayout:F,dir:h}):null})},[Je,M,l,o,r,qe,Re,lt,C,L,P,z,O,q,V,W,E,G,_,ot,F,h]),ct=g.useCallback(()=>S?"function"==typeof S?S():S:null,[S]),ut=g.useCallback(()=>N?"function"==typeof N?N():N:null,[N]);g.useEffect(()=>{const e=void 0!==h?"rtl"===h:Ve.current&&"rtl"===getComputedStyle(Ve.current).direction;Be(!!e)},[h]),g.useEffect(()=>()=>{clearTimeout(He.current)},[]);const mt=g.useMemo(()=>({replyToMessage:Oe,setReplyToMessage:Ke,messages:Xe,user:qe,internalScrollContainerRef:We,messageListScrollContainerRef:je,onToolbarAction:Y,onContextMenuAction:X,onFileAction:Q,setShowCopyNotification:ze,onDownload:ae,fileActions:O,speechToTextConfig:ie,uploadConfig:ce,statusTemplate:R,userStatusTemplate:D,messageFilesLayout:he,timestampVisibility:$}),[Oe,Ke,Xe,qe,Y,X,Q,ze,ae,O,ie,ce,R,D,he,$]);return g.createElement(U.Provider,{value:mt},g.createElement("div",{style:{width:i,height:c,position:"relative",overflow:"hidden",...y},onKeyDown:st,className:rt(),ref:e=>{Ve.current=e,We.current=e,"function"==typeof t?t(e):t&&(t.current=e)},...Me},void 0!==S&&g.createElement(le,null,ct()),et&&g.createElement(se,{message:et,onUnpin:K,user:qe}),g.createElement("div",{className:"k-message-list",onBlur:nt,onFocus:at,role:"log","aria-label":tt.toLanguageString(b,B[b]),"aria-live":"polite",ref:je},g.createElement("div",{className:a.classNames("k-message-list-content",{"k-message-list-content-empty":0===Xe.length})},0===Xe.length&&void 0!==N&&ut(),Xe.length>0&&it())),g.createElement(ne,{onSendMessage:(e,t)=>{u&&u({message:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})},onSuggestionClick:e=>{m&&m(e)},isDirectionRightToLeft:Le,ref:$e,placeholder:k,MessageBox:f,suggestions:I,suggestionTemplate:w,inputValue:A,onInputValueChange:e=>{d&&d(e)},onInputClick:()=>{Ge.current=!1},sendButtonConfig:pe,suggestionsLayout:T,dir:h}),g.createElement(oe,{show:Pe,text:tt.toLanguageString(x,B[x])}),Qe&&g.createElement(a.WatermarkOverlay,{message:Ze})))});he.displayName="Chat",he.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};const fe=e=>{const{activeView:a,toolbarItems:l,activeViewChange:s}=e;return t.createElement("div",{className:"k-prompt-header"},t.createElement(n.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},l.map(e=>t.isValidElement(e)?e:t.createElement(n.Button,{key:e.name,className:a===e.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>(e=>{null==s||s.call(null,e)})(e.name)},e.buttonText))))},ke={name:"Output view",buttonText:"Output",buttonIcon:l.commentIcon},ve={name:"Commands view",buttonIcon:l.moreHorizontalIcon},be={name:"Prompt view",buttonText:"Ask AI",buttonIcon:l.sparklesIcon},ye=t.createContext([{},()=>{}]),Ce=()=>t.useContext(ye),Ee=e=>{const{children:a}=e;return t.createElement("div",{className:"k-prompt-footer"},t.createElement("div",{className:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},a))},Ie=t.forwardRef((e,a)=>{const{children:o,streaming:r,onCancel:i}=e,c=s.useLocalization().toLanguageString(C,B[C]),[u]=Ce(),m=u.activeView===ke.name,d=r&&m,p=t.useCallback(e=>{"Escape"===e.key&&d&&i&&(e.preventDefault(),i())},[d,i]);return t.createElement("div",{className:"k-prompt-content",ref:a,onKeyDown:p},d&&t.createElement(n.FloatingActionButton,{onClick:i,svgIcon:l.stopSmIcon,icon:"stop-sm",size:"medium",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":c,title:c}),t.createElement("div",{className:"k-prompt-view"},o))});Ie.displayName="KendoReactAIPromptContent";const xe=e=>{const[t]=Ce();return t.activeView===e.name?e.children:null},we=e=>{const[a,s]=t.useState(!0),{children:o,title:r}=e;return t.createElement("div",{className:"k-prompt-expander"},t.createElement(n.Button,{"aria-controls":e.id,fillMode:"flat",svgIcon:a?l.chevronUpIcon:l.chevronDownIcon,title:r,onClick:()=>s(!a),"aria-expanded":a},r),a&&t.createElement("div",{id:e.id,className:"k-prompt-expander-content"},o))},Te=e=>null==e?void 0:e.map(e=>t.createElement(o.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&Te(e.children||[]))),Fe=({show:e=!1,anchor:a,onOpen:n,onClose:l,animate:s=!0,appendTo:o,popupOptions:r={},children:i,style:c})=>t.createElement(d.Popup,{show:e,anchor:a,style:c,animate:s,appendTo:o,onOpen:n,onClose:l,...r},i),Ae=({placeholder:e="Ask or generate content with AI...",promptValue:s,onMenuClick:o,promptInput:r=c.TextArea,generateButton:i,enableSpeechToText:u=!1,streaming:m=!1,commands:d,onPromptRequest:p,onPromptCancel:g})=>{const[h,f]=t.useState(s||""),[k,v]=a.useCustomComponent(i),[b,y]=a.useCustomComponent(r),C=r===c.TextArea||b===c.TextArea,E={svgIcon:m?l.stopSmIcon:l.paperPlaneIcon,active:(!!m).toString(),title:"Send Button","aria-label":"Send Button",disabled:!h.trim()&&!m,"aria-disabled":!h.trim()&&!m},I={placeholder:e,className:"!k-flex-row",...C?{autoSize:!0}:{},rows:1},x=d&&d.length>0,w=Object.keys(v).length>0?v:E,T=Object.keys(y).length>0?y:I,F=e=>{const{isFinal:t,alternatives:a}=e;if(t&&a.length>0){const e=a[0].transcript,t=(()=>{const t=h,a=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(a?" ":"")+e})();f(t)}},A=()=>{h.trim()&&p&&p(h.trim())};return t.createElement(b,{value:h,onChange:e=>{const t=e.target.value;f(t)},onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),A())},prefix:x||u?t.createElement(t.Fragment,null,t.createElement(c.InputPrefix,{className:"!k-align-items-start"},x&&t.createElement(n.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:l.menuIcon,onClick:o}),u&&t.createElement(n.SpeechToTextButton,{fillMode:"flat",..."object"==typeof u?{...u,onResult:u.onResult||F}:{onResult:F}})),t.createElement(c.InputSeparator,null)):void 0,suffix:t.createElement(c.InputSuffix,{className:"!k-align-items-start"},t.createElement(k,{className:a.classNames("k-prompt-send",{"k-generating":m,"k-active":m}),fillMode:"flat",onClick:m?g:A,...w})),...T})};e.AIPrompt=e=>{const n=!a.validatePackage(re,{component:"AIPrompt"}),l=a.getLicenseMessage(re),{activeView:s,toolbarItems:o,children:r,onActiveViewChange:i,onPromptRequest:c,onCommandExecute:u,style:m,dir:d,className:p,streaming:g,loading:h,onCancel:f,suggestionsView:k,...v}=e,b=o||[be,ke],[y,C]=t.useState({activeView:s}),E={...y,activeView:s,streaming:g,loading:h,suggestionsView:null!=k?k:"classic",onCancel:f,onActiveViewChange:i,onPromptRequest:c,onCommandExecute:u};return t.createElement(ye.Provider,{value:[E,e=>{C(e)}]},t.createElement("div",{className:a.classNames("k-prompt",p),style:m,dir:d,...v},t.createElement(fe,{activeView:E.activeView,toolbarItems:b,activeViewChange:i}),r,n&&t.createElement(a.WatermarkOverlay,{message:l})))},e.AIPromptCommandsView=e=>{const{commands:a}=e,[n]=Ce();return t.createElement(xe,{name:ve.name},t.createElement(Ie,{streaming:n.streaming,onCancel:n.onCancel},t.createElement("div",{className:"k-prompt-view"},t.createElement(o.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=s.children)&&l.length||n.onCommandExecute&&n.onCommandExecute.call(null,s)},selected:""},Te(null!=a?a:[])))))},e.AIPromptContent=Ie,e.AIPromptFooter=Ee,e.AIPromptOutputView=e=>{const[a,r]=t.useState(""),i=t.useRef(null),[c]=Ce(),{outputs:u,showOutputRating:m,outputCard:d}=e,{header:p,body:g,actions:h}=d||{},f=s.useLocalization(),k=(e,t)=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),v()},v=()=>{i&&i.current&&i.current.scrollTo({top:0,behavior:"smooth"})},b=t.createElement(o.Card,null,t.createElement(o.CardHeader,null,t.createElement(o.CardTitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),t.createElement(o.CardSubtitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),t.createElement(o.CardBody,null,t.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),t.createElement(o.CardActions,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),C=null==u?void 0:u.map((e,s)=>t.createElement(o.Card,{key:`${e.id}_${s}`},t.createElement(o.CardHeader,null,p?p(e):t.createElement(t.Fragment,null,e.title&&t.createElement(o.CardTitle,null,e.title),e.subTitle&&t.createElement(o.CardSubtitle,null,e.subTitle))),t.createElement(o.CardBody,null,g?g(e):e.responseContent),t.createElement(o.CardActions,null,h?h(e):t.createElement(t.Fragment,null,t.createElement(n.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:a===e.id?l.checkIcon:l.copyIcon,onClick:()=>(e=>{null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),r(e.id),setTimeout(()=>{r("")},1e3)})(e)},"Copy"),t.createElement(n.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:l.arrowRotateCwIcon,onClick:()=>(e=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),v()})(e)},"Retry"),m&&t.createElement(t.Fragment,null,t.createElement("span",{className:"k-spacer"}),t.createElement(n.Button,{size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:l.thumbUpOutlineIcon,onClick:()=>k(e,"positive")}),t.createElement(n.Button,{size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:l.thumbDownOutlineIcon,onClick:()=>k(e,"negative")})))))),E=t.createElement(o.Card,null,t.createElement(o.CardBody,null,f.toLanguageString(y,B[y])));return t.createElement(xe,{name:ke.name},t.createElement(Ie,{ref:i,streaming:c.streaming,onCancel:c.onCancel},t.createElement("div",{className:"k-card-list"},c.loading&&b,C,(!C||0===C.length)&&!c.loading&&E)))},e.AIPromptView=e=>{const{promptInput:s=c.TextArea,generateButton:o=n.Button,enableSpeechToText:r=!1,promptValue:i,promptSuggestions:u}=e,[m,d]=t.useState(i||""),[p]=Ce(),[g,h]=a.useCustomComponent(o),[f,k]=a.useCustomComponent(s),v=t.useRef(null);t.useEffect(()=>{var e,t;null!=(t=null==(e=v.current)?void 0:e.element)&&t.current&&requestAnimationFrame(()=>{var e,t;if(null!=(t=null==(e=v.current)?void 0:e.element)&&t.current){const e=v.current.element.current;e.style.height="auto",e.style.height=`${e.scrollHeight}px`}})},[m]);const b={title:"Generate",children:"Generate",svgIcon:l.sparklesIcon},y=Object.keys(h).length>0?h:b,C=Object.keys(k).length>0?k:{placeholder:"Ask or generate content with AI ...",rows:2},E=e=>{const{isFinal:t,alternatives:a}=e;if(t&&a.length>0){const e=a[0].transcript,t=(()=>{const t=m,a=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(a?" ":"")+e})();d(t)}};let I;return r&&(I="object"==typeof r?{...r,onResult:r.onResult||E}:{onResult:E}),t.createElement(xe,{name:be.name},t.createElement(Ie,{streaming:p.streaming,onCancel:p.onCancel},t.createElement(f,{ref:v,value:m,flow:"vertical",textareaStyle:{maxHeight:"110px"},autoSize:!0,suffix:r?t.createElement(t.Fragment,null,t.createElement(c.InputSeparator,{orientation:"horizontal"}),t.createElement(c.InputSuffix,{orientation:"horizontal"},t.createElement(n.SpeechToTextButton,{fillMode:"flat",...I}))):void 0,onChange:e=>{d(e.target.value)},...C}),u&&u.length>0&&t.createElement(we,{title:"Prompt Suggestions"},t.createElement(ae,{suggestionsView:p.suggestionsView,suggestions:u.map((e,t)=>({id:t,text:e,description:e})),onSuggestionClick:e=>{(e=>{d(e)})(e.text)}}))),t.createElement(Ee,null,t.createElement(g,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:()=>{p.onPromptRequest&&p.onPromptRequest.call(null,m),d("")},disabled:!m.trim(),...y},y.children)))},e.AIPromptViewRender=xe,e.Chat=he,e.ChatMessage=j,e.DEFAULT_FIELD_MAPPING=ie,e.HeroCard=e=>{const{imageUrl:t,imageMaxWidth:a,title:l,subtitle:s,actions:o,onActionExecute:r,altText:i}=e,c=g.useCallback((e,t)=>{null==r||r({action:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})},[r]),u=i||l||"";return g.createElement("div",{className:"k-card"},g.createElement("img",{className:"k-card-image",src:t,style:{maxWidth:a},alt:u}),g.createElement("div",{className:"k-card-body"},l&&g.createElement("h5",{className:"k-card-title"},l),s&&g.createElement("h6",{className:"k-card-subtitle"},s)),g.createElement("div",{className:"k-card-actions k-card-actions-vertical"},o.map((e,t)=>g.createElement("span",{className:"k-card-action",key:`action-${t}-${e.title||e.value||t}`},g.createElement(n.Button,{fillMode:"flat",onClick:t=>c(e,t)},e.title)))))},e.InlineAIPrompt=e=>{const s=!a.validatePackage(re,{component:"InlineAIPrompt"}),r=a.getLicenseMessage(re),{outputs:i=[],outputCard:u,promptInput:m=c.TextArea,generateButton:d=n.Button,promptPlaceholder:p="Ask or generate content with AI...",promptValue:g,onPromptRequest:h,onCopy:f,onDiscard:k,outputActions:v,onOutputAction:b,enableSpeechToText:y=!1,streaming:C,onPromptCancel:E,show:I=!1,anchor:x,width:w,height:T,onOpen:F,onClose:A,animate:S=!0,appendTo:N,commands:M,onCommandExecute:R,style:D,className:L,popupOptions:B={},...P}=e,[z,O]=t.useState(""),[K,q]=t.useState(!1),[U,V]=t.useState({left:0,top:0}),W=t.useRef(null),{body:j,actions:$}=u||{},H=v||[{id:"copy",text:"Copy",svgIcon:l.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:l.cancelOutlineIcon,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==f||f(e)})(t);break;case"discard":(e=>{null==k||k(e)})(t);break;default:null==b||b(e,t)}},_=t.useCallback(e=>{"Escape"===e.key&&(C&&E?E():!C&&A&&A({target:null}))},[C,E,A]),Y={...D,...w&&{width:w},...T&&{height:T}},X={...w&&{width:w},...T&&{height:T}},J=t.createElement(t.Fragment,null,t.createElement("div",{className:a.classNames("k-prompt",L),style:Y,onKeyDown:_,...P},t.createElement(Ie,{ref:W},i&&i.length>0&&t.createElement("div",{className:"k-card-list"},i.map((e,a)=>t.createElement(o.Card,{key:`${e.id}_${a}`},t.createElement(o.CardBody,null,j?j(e):e.responseContent),t.createElement(o.CardActions,null,$?$(e):t.createElement(t.Fragment,null,H.map(a=>{var s;return a.spacer?t.createElement("span",{key:a.id,className:"k-spacer"}):t.createElement(n.Button,{key:a.id,size:"medium",themeColor:a.themeColor||"primary",fillMode:"flat",rounded:"medium",title:null!=(s=a.title)?s:a.text,svgIcon:"copy"===a.id&&z===e.id?l.checkIcon:a.svgIcon,onClick:()=>G(a,e)},a.text)})))))),t.createElement(Ae,{promptValue:g,placeholder:p,onPromptRequest:h,onMenuClick:e=>{if(!W.current)return;const t=W.current.getBoundingClientRect();V({left:t.left,top:t.bottom}),q(!0)},onPromptCancel:E,promptInput:m,generateButton:d,enableSpeechToText:y,streaming:C,commands:M}))),s&&t.createElement(a.WatermarkOverlay,{message:r}));return t.createElement(t.Fragment,null,t.createElement(Fe,{show:I,anchor:x,onOpen:F,onClose:A,animate:S,appendTo:N,popupOptions:B,style:X},J),t.createElement(o.ContextMenu,{show:K,offset:U,onClose:()=>{q(!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})))(M),onSelect:e=>{var t,a;const n=null==(t=e.item)?void 0:t.data;n&&(null==(a=n.children)||!a.length)&&(e=>{q(!1),R&&R(e)})(n)}}))},e.PromptHeader=fe,e.SuggestionGroup=ae,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}),e.isStandardMessageFormat=me,e.mapDataArrayToMessages=ue,e.mapDataToMessage=ce,e.mapMessageToCustomFormat=(e,t={})=>{const a={...ie,...t},n={};return void 0!==e.id&&(n[a.idField]=e.id),void 0!==e.text&&(n[a.textField]=e.text),void 0!==e.status&&(n[a.statusField]=e.status),void 0!==e.timestamp&&(n[a.timestampField]=e.timestamp),void 0!==e.attachments&&(n[a.attachmentsField]=e.attachments),void 0!==e.files&&(n[a.filesField]=e.files),void 0!==e.suggestedActions&&(n[a.suggestedActionsField]=e.suggestedActions),void 0!==e.replyToId&&(n[a.replyToIdField]=e.replyToId),void 0!==e.isDeleted&&(n[a.isDeletedField]=e.isDeleted),void 0!==e.isPinned&&(n[a.isPinnedField]=e.isPinned),void 0!==e.typing&&(n[a.typingField]=e.typing),e.author&&(void 0!==e.author.id&&(n[a.authorIdField]=e.author.id),void 0!==e.author.name&&(n[a.authorNameField]=e.author.name),void 0!==e.author.avatarUrl&&(n[a.authorImageUrlField]=e.author.avatarUrl),void 0!==e.author.avatarAltText&&(n[a.authorImageAltTextField]=e.author.avatarAltText)),void 0!==e.pinnedAt&&(n.pinnedAt=e.pinnedAt),void 0!==e.pinnedBy&&(n.pinnedBy=e.pinnedBy),void 0!==e.attachmentLayout&&(n.attachmentLayout=e.attachmentLayout),n},e.outputViewDefaults=ke,e.promptViewDefaults=be});
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-intl"),require("@progress/kendo-react-layout"),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-intl","@progress/kendo-react-layout","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.KendoReactIntl,e.KendoReactLayout,e.PropTypes,e.KendoReactUpload,e.KendoReactAnimation,e.KendoReactNotification,e.KendoReactInputs,e.KendoReactPopup)}(this,function(e,t,n,a,l,o,s,r,i,c,u,m,d){"use strict";function p(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 g=p(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",w="chat.closeReply",F="chat.collapseMessage",S="chat.expandMessage",A="chat.removeFile",N="chat.fileActions",R="chat.attachFile",M="chat.downloadAll",B="chat.scrollLeft",L="chat.scrollRight",D="chat.scrollToBottom",P="chat.messageFailed",O="chat.retryMessage",z="chat.stopGenerating",q="promptBox.input",U="promptBox.sendButton",K="promptBox.attachFile",V="promptBox.removeFile",$="promptBox.stopGenerating",H="promptBox.ariaLabel",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",[w]:"Close reply",[F]:"Collapse message",[S]:"Expand message",[A]:"Remove file",[N]:"File actions for",[P]:"Failed to send",[O]:"Retry",[z]:"Stop generating",[R]:"Attach file",[M]:"Download all",[B]:"Scroll left",[L]:"Scroll right",[D]:"Scroll to bottom",[q]:"Prompt",[U]:"Send",[K]:"Attach file",[V]:"Remove file",[$]:"Stop generating",[H]:"Prompt box"},W=(e,t)=>e&&t.author&&e.id===t.author.id,G=(e,t)=>{const n=t.toLanguageString("chatSender.deletedMessage",j[C]),a=t.toLanguageString("chatReceiver.deletedMessage",j[x]);return e?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,o=l.scrollTop+(t-e)-n;l.scrollTo({top:o,behavior:"smooth"})}else a.scrollIntoView({behavior:"smooth",block:"start"})},Y=/(https?:\/\/[^\s]+)/g,X=e=>{if(!e)return[""];const n=e.split(Y),a=[];return n.forEach(e=>{e&&Y.test(e)?(Y.lastIndex=0,a.push(t.createElement("a",{key:e,href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"}},e))):e&&a.push(e)}),a},J=g.createContext(void 0),Q=()=>{const e=t.useContext(J);if(void 0===e)throw new Error("useChatContext must be used within a ChatContext.Provider");return e},Z=e=>{const{files:t,onFileAction:s,onDownload:r,fileActions:i}=e,{messageFilesLayout:c="vertical"}=Q(),u=o.useLocalization(),m=i||[{id:"download",label:"Download",svgIcon:l.downloadLightIcon}],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]}`},p=e=>"."+e.split(".").pop()||"",f=e=>m.length>0&&g.createElement(a.DropDownButton,{fillMode:"flat",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(N,j[N])} ${e.name}`,title:`${u.toLanguageString(N,j[N])} ${e.name}`}),h=g.useCallback(()=>n.classNames({"k-files-wrap":"wrap"===c,"k-files-vertical":"vertical"===c},"k-file-box-wrapper"),[c]);return g.createElement("ul",{className:h()},"horizontal"===c?g.createElement("div",{className:"k-files-scroll"},t.map(e=>g.createElement("li",{key:e.name,className:"k-file-box"},g.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(p(e.name))}),g.createElement("div",{className:"k-file-info"},g.createElement("span",{className:"k-file-name"},e.name),g.createElement("span",{className:"k-file-size"},d(e.size))),f(e)))):t.map(e=>g.createElement("li",{key:e.name,className:"k-file-box"},g.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(p(e.name))}),g.createElement("div",{className:"k-file-info"},g.createElement("span",{className:"k-file-name"},e.name),g.createElement("span",{className:"k-file-size"},d(e.size))),f(e))))},ee=g.forwardRef((e,t)=>{const{item:r,template:i,contentTemplate:c,onRequestSelection:u,tabIndex:m=-1,dateFormat:d="g",selected:p,allowMessageCollapse:f,messageToolbarActions:h,messageContextMenuActions:v,fileActions:k,isSender:b}=e,{setReplyToMessage:y,messages:E,user:C,internalScrollContainerRef:x,onToolbarAction:I,onContextMenuAction:w,onFileAction:A,onDownload:N,onResendMessage:R,setShowCopyNotification:B,statusTemplate:L,timestampVisibility:D="onFocus"}=Q(),[z,q]=g.useState(!1),[U,K]=g.useState(!1),[V,$]=g.useState(!0),[H,Y]=g.useState(!1),J=o.useLocalization(),ee=o.useInternationalization(),te=g.useRef({left:0,top:0}),ne=g.useCallback(()=>{null!=r&&r.text&&(e=>{navigator.clipboard.writeText(e)})(r.text),B&&(B(!0),setTimeout(()=>{B(!1)},3e3))},[r,B]),ae=g.useCallback(e=>{e.stopPropagation(),$(e=>!e)},[]),le=g.useCallback(()=>{Y(!1)},[]),oe=g.useCallback(e=>{("Tab"===e.key||"Enter"===e.key||" "===e.key||"ArrowUp"===e.key||"ArrowDown"===e.key)&&Y(!0)},[]),se=g.useRef(null);g.useEffect(()=>{p&&se.current&&se.current.focus()},[p]);const re=g.useCallback(e=>{te.current={left:e.pageX,top:e.pageY},e.preventDefault(),K(!0),q(!0)},[]),ie=g.useCallback(()=>{K(!1),q(!1)},[]),ce=g.useCallback((e,t)=>e.isDeleted?G(t,J):e.text?e.text:"",[J]),ue=g.useCallback(e=>{var t;null!=(t=e.item)&&t.text&&("copy"!==e.item.data.id||r.isDeleted?"reply"===e.item.data.id&&y(r):ne(),w&&w(e.item.data,e,r)),K(!1),q(!1)},[r,w,y,ne]),me=g.useCallback(()=>{if(r.replyToId){const e=((e,t)=>e.find(e=>e.id===t))(E,r.replyToId);if(e){const t=t=>{t.preventDefault(),t.stopPropagation();const n=null==x?void 0:x.current;_(e.id,n)};return g.createElement("div",{className:n.classNames("k-message-reference",W(C,e)?"k-message-reference-sender":"k-message-reference-receiver"),onClick:t},g.createElement("div",{className:"k-message-reference-content"},X(ce(e,W(C,e)))))}}return null},[r.replyToId,E,C,ce,x]),de=g.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 g.createElement(s.ContextMenu,{onSelect:ue,onClose:ie,vertical:!0,show:z,offset:te.current},t.map(e=>"delete"!==e.id||b?g.createElement(s.MenuItem,{key:e.id,text:e.label,icon:e.icon,svgIcon:e.svgIcon,data:e}):null))},[v,ue,ie,z,b]),pe=g.useCallback(()=>r.files&&r.files.length>1?g.createElement("div",{className:"k-chat-download-button-wrapper"},g.createElement(a.Button,{className:"k-chat-download-button",fillMode:"flat",svgIcon:l.downloadLightIcon,size:"small",onClick:e=>{e.stopPropagation(),N&&N(r.files,r)},"aria-label":J.toLanguageString(T,j[T])},g.createElement("span",{className:"k-button-text"},J.toLanguageString(M,j[M])))):null,[r,N,J]),ge=g.useCallback(()=>{if(r.typing)return g.createElement("div",{className:"k-chat-bubble k-bubble"},g.createElement("div",{className:"k-bubble-content"},g.createElement("div",{className:"k-typing-indicator"},g.createElement("span",null),g.createElement("span",null),g.createElement("span",null))));if(i){const e=i;return g.createElement(g.Fragment,null,g.createElement(e,{item:r}),de())}return r.text||r.files&&r.files.length>0?g.createElement(g.Fragment,null,g.createElement("div",{className:n.classNames("k-chat-bubble","k-bubble",{"k-bubble-expandable":f,"k-expanded":f&&V,"k-selected":p,"k-active":U}),onClick:()=>u(p?void 0:r.selectionIndex),onContextMenu:re},g.createElement("div",{className:"k-bubble-content"},c?g.createElement(c,{item:r}):g.createElement(g.Fragment,null,(r.text||r.isDeleted||r.replyToId)&&g.createElement("span",{className:"k-chat-bubble-text"},!r.isDeleted&&me(),X(ce(r,W(C,r)))),r.files&&r.files.length>0&&g.createElement(Z,{files:r.files,message:r,onFileAction:A,onDownload:e=>null==N?void 0:N(e,r),renderInTextarea:!1,fileActions:k}),pe())),f&&g.createElement("span",{className:"k-bubble-expandable-indicator",onClick:ae,role:"button","aria-label":V?J.toLanguageString(F,j[F]):J.toLanguageString(S,j[S]),tabIndex:0,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),ae(e))}},g.createElement(n.IconWrap,{icon:V?l.chevronUpIcon:l.chevronDownIcon,size:"medium"}))),de()):null},[r,i,c,f,V,p,U,u,re,me,ce,C,A,k,pe,ae,J,de,N]),fe=g.useCallback(()=>{let e=null;if(r.timestamp){const t="onFocus"===D&&p;"hidden"===D||(e=g.createElement("time",{className:"k-message-time","aria-hidden":!t},ee.formatDate(r.timestamp,d)))}return e},[r.timestamp,p,d,D,ee]),he=g.useCallback(()=>{if(!r.status)return null;let e;if(L)e=g.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 o=null;a?o=g.createElement(n.Icon,{name:a,size:"xsmall"}):l&&(o=g.createElement(n.IconWrap,{icon:l,size:"xsmall"})),e=g.createElement(g.Fragment,null,o,t)}return g.createElement("span",{className:"k-message-status"},e)},[r,L]),ve=g.useCallback(()=>{let e=null;if(r.isFailed){const t=J.toLanguageString(P,j[P]);e=g.createElement("span",{className:"k-message-failed-content"},g.createElement(n.IconWrap,{icon:l.warningTriangleIcon,size:"xsmall"}),g.createElement("span",{className:"k-message-failed-text"},t))}return e},[r,J]),ke=g.useCallback(()=>{let e=null;if(r.isFailed){const t=J.toLanguageString(O,j[O]);e=g.createElement(a.Button,{fillMode:"clear",size:"small",className:"k-resend-button",svgIcon:l.arrowRotateCwOutlineIcon,"aria-label":t,title:t,onClick:e=>{e.stopPropagation(),R&&R({message:r,syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.target})}})}return e},[r,J,R]),be=g.useCallback(()=>n.classNames({"k-focus":p,"k-message-removed":r.isDeleted,"k-message-failed":r.isFailed},"k-message"),[p,r.isDeleted,r.isFailed]),ye=g.useCallback(()=>h&&h.length>0&&g.createElement(a.Toolbar,{className:"k-chat-message-toolbar",fillMode:"flat"},h.map(e=>"delete"!==e.id||b?g.createElement(a.Button,{key:e.id,fillMode:"flat",className:"k-toolbar-button",icon:e.icon,svgIcon:e.svgIcon,onClick:t=>{t.stopPropagation(),"copy"!==e.id||r.isDeleted?"reply"===e.id&&y(r):ne(),I&&I(e,t,r)},onMouseDown:e=>e.preventDefault()}):null)),[ne,b,r,h,I,y]);return g.createElement("div",{"data-message-id":r.id,className:be(),tabIndex:m,onMouseDown:le,onKeyDown:oe,onFocus:e=>{H&&u(r.selectionIndex)},ref:e=>{se.current=e,"function"==typeof t?t(e):t&&(t.current=e)},onContextMenu:i?re:void 0},ke(),ge(),(r.status||r.timestamp&&"hidden"!==D||r.isFailed)&&g.createElement("div",{className:"k-message-info"},he(),fe(),ve()),ye())});ee.displayName="ChatMessage";const te=e=>e[e.length-1],ne=e=>(t,n,a)=>{const l=a===e-1;return((e,t)=>{const n=t.timestamp,a=te(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=te(e);let l;t.typing&&!n||(a&&"message-group"===a.type&&(l=a.messages),l&&W(t.author,te(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 ae=e=>{const{item:t,onActionExecute:a,selected:l}=e,o=g.useRef(null);g.useEffect(()=>{l&&o.current&&o.current.focus()},[l]);const s=g.useCallback(e=>{(e.keyCode===n.Keys.enter||" "===e.key)&&(e.preventDefault(),a(t,e))},[a,t]),r=g.useCallback(()=>n.classNames("k-suggestion k-suggestion-primary",{"k-selected":l},{"k-focus":l}),[l]);return g.createElement("span",{role:"button",className:r(),onClick:e=>a(t,e),ref:o,onKeyDown:s,tabIndex:0,"aria-label":t.title||t.value},t.title||t.value)},le=({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]),p="rtl"!==t?m:d,f="rtl"!==t?d:m;return g.createElement("div",{className:"k-suggestion-scrollwrap"},g.createElement(a.Button,{fillMode:"flat",size:"small",svgIcon:"rtl"===t?l.chevronRightIcon:l.chevronLeftIcon,onClick:r,disabled:!n,"aria-label":p,title:p}),c,g.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,se=(e,t)=>{const{enabled:n,dir:a,mode:l,itemsDependency:o=[],scrollSpeed:s=oe}=t,[r,i]=g.useState(!1),[c,u]=g.useState(!1),m=g.useCallback(()=>{if(e.current&&n){const{scrollLeft:t,scrollWidth:n,clientWidth:l}=e.current,o="rtl"!==a?t+l>=n-1:l-t>=n-1;i(!(0===t)),u(!o)}},[n,a]),d=g.useCallback(()=>{e.current&&n&&e.current.scrollBy({left:"rtl"!==a?-s:s,behavior:"smooth"})},[n,a,s]),p=g.useCallback(()=>{e.current&&n&&e.current.scrollBy({left:"rtl"!==a?s:-s,behavior:"smooth"})},[n,a,s]);return g.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,o.length,l]),g.useLayoutEffect(()=>{n&&m()},[n,a,o]),{canScrollLeft:r,canScrollRight:c,scrollLeft:d,scrollRight:p}},re=e=>{var t,a;const{group:l,onActionExecute:o,selected:s,onRequestSelection:r,quickActionsLayout:i="scroll",dir:c}=e,[u,m]=g.useState(null),d=g.useRef(null),{canScrollLeft:p,canScrollRight:f,scrollLeft:h,scrollRight:v}=se(d,{enabled:"scrollbuttons"===i||"scroll"===i,dir:c,mode:i,itemsDependency:l.actions});g.useEffect(()=>{s||null===u?s&&null===u&&m(0):m(null)},[s,u]);const k=g.useCallback(()=>l.actions?l.actions.length-1:-1,[l.actions]),b=g.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=g.useCallback(()=>{r(l.selectionIndex)},[r,l.selectionIndex]),E=g.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=g.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":p&&("scroll"===i||"scrollbuttons"===i)}),[i,f,p]),x="scroll"===i||"scrollbuttons"===i,I=g.createElement("div",{className:C(),onClick:y,onKeyDown:E,role:"toolbar",tabIndex:0,"aria-label":"Action group"},x?g.createElement("div",{className:"k-suggestions-scroll",ref:d},null==(t=l.actions)?void 0:t.map((e,t)=>g.createElement(ae,{item:e,onActionExecute:o,selected:t===u,key:e.value}))):null==(a=l.actions)?void 0:a.map((e,t)=>g.createElement(ae,{item:e,onActionExecute:o,selected:t===u,key:e.value})));return g.createElement(le,{visible:"scrollbuttons"===i,dir:c,canScrollLeft:p,canScrollRight:f,onScrollLeft:h,onScrollRight:v},I)},ie=e=>{const{item:t,template:a,tabbable:l,onClick:o,selected:s}=e,r=g.useRef(null);g.useEffect(()=>{s&&r.current&&r.current.focus()},[s]);const i=g.useCallback(()=>{if(void 0!==l)return l?0:-1},[l]),c=g.useCallback(()=>n.classNames({"k-selected":s},{"k-focus":s}),[s]),u=g.useCallback(()=>t.title?g.createElement("h5",{className:"k-card-title"},t.title):null,[t.title]),m=g.useCallback(()=>t.subtitle?g.createElement("h6",{className:"k-card-subtitle"},t.subtitle):null,[t.subtitle]),d=g.useCallback(()=>0===t.contentType.indexOf("image/")?g.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]),p=a;return g.createElement("div",{className:c(),tabIndex:i(),onClick:o,ref:r},a?g.createElement(p,{item:t}):g.createElement("div",{className:"k-card"},g.createElement("div",{className:"k-card-body"},u(),m(),d())))},ce=e=>{const{group:t,itemTemplate:o,selected:s,isLastGroup:r,onRequestSelection:i}=e,[c,u]=g.useState(null);g.useEffect(()=>{s||null===c?s&&null===c&&u(0):u(null)},[s,c]);const m=g.useCallback(e=>"list"!==e.attachmentLayout,[]),d=g.useCallback(()=>t.attachments?t.attachments.length-1:-1,[t.attachments]),p=g.useCallback(()=>t.attachments.length-1,[t.attachments]),f=g.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=g.useCallback(()=>{i(t.selectionIndex)},[i,t.selectionIndex]),v=g.useCallback(e=>{let a,l,o=null;m(t)?(a=n.Keys.left,l=n.Keys.right):(a=n.Keys.up,l=n.Keys.down),e.keyCode===a?o=f(!1):e.keyCode===l&&(o=f(!0)),null!==o&&(e.preventDefault(),e.stopPropagation())},[f,m,t]),k=g.useCallback(e=>{h(),u(e)},[h]),b=g.useCallback(e=>{h(),f(e,1)},[h,f]),y=g.useCallback(()=>{let e=null;return m(t)&&c&&(e=g.createElement(a.Button,{icon:"chevron-left",onClick:()=>b(!1),svgIcon:l.chevronLeftIcon})),e},[m,t,c,b]),E=g.useCallback(()=>{let e=null;return m(t)&&c!==p()&&(e=g.createElement(a.Button,{icon:"chevron-right",onClick:()=>b(!0),svgIcon:l.chevronRightIcon})),e},[m,t,c,p,b]),C=g.useCallback(()=>n.classNames({"k-card-list":t.attachmentLayout,"k-card-deck":m(t)}),[t.attachmentLayout,t,m]),x=m(t),I=g.createElement("div",{className:C(),onKeyDown:x?void 0:v},t.attachments.map((e,t)=>g.createElement(ie,{item:e,template:o,selected:t===c,tabbable:r&&t===c,onClick:()=>k(t),key:e.content})));return x?g.createElement("div",{className:"k-card-deck-scrollwrap",onKeyDown:v},y(),I,E()):I},ue=({item:e,timestampTemplate:t})=>{const n=o.useInternationalization(),a=t;return g.createElement("div",{className:"k-timestamp"},a?g.createElement(a,{item:e}):n.formatDate(e.timestamp,"D"))},me=e=>{const{group:t,user:a,itemTemplate:l,contentTemplate:r,attachmentTemplate:i,onRequestSelection:c,selectedItemIndex:u,isLastGroup:m,message:d,allowMessageCollapse:p,messageToolbarActions:f,messageContextMenuActions:h,fileActions:v,messageWidthMode:b="standard",showAvatar:y=!0,showUsername:E=!0}=e,{userStatusTemplate:C}=Q(),x=o.useLocalization(),I=t.messages.length>0&&W(a,t.messages[0]),{avatarUrl:T,avatarAltText:w,name:F}=t.author,S=g.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=g.useMemo(()=>{const e=t.messages.length-1;return t.messages.map((t,n)=>{const o=[g.createElement(d,{item:t,template:l,contentTemplate:r,selected:t.selectionIndex===u,onRequestSelection:c,tabIndex:n===e&&m?0:-1,key:t.id,allowMessageCollapse:p,messageToolbarActions:f,messageContextMenuActions:h,fileActions:v,isSender:W(a,t)})];return t.attachments&&1===t.attachments.length&&o.push(g.createElement(ie,{item:t.attachments[0],template:i,selected:!1,key:`att-${t.attachments[0].content}`})),o})},[t.messages,d,l,r,u,c,m,p,f,h,v,a,i]),N=void 0!==w?w:x.toLanguageString(k,j[k]);return g.createElement("div",{className:S},(()=>{if(!y||!T)return;const e=g.createElement(s.Avatar,{type:"image"},g.createElement("img",{src:T,alt:N}));if(C){const n=t.messages[t.messages.length-1];return g.createElement("div",{className:"k-chat-user-status-wrapper"},e,g.createElement("div",{className:"k-chat-user-status"},g.createElement(C,{message:"dataItem"in n?n.dataItem:n})))}return e})(),g.createElement("div",{className:"k-message-group-content"},E&&g.createElement("span",{className:"k-message-author"},F),A))},de=e=>{const{suggestions:t,onSuggestionClick:a,suggestionsView:l,suggestionTemplate:o,suggestionsLayout:s,dir:r}=e,i=g.useRef(null),{canScrollLeft:c,canScrollRight:u,scrollLeft:m,scrollRight:d}=se(i,{enabled:"scrollbuttons"===s||"scroll"===s,dir:r,mode:s,itemsDependency:t}),p=g.useCallback((e,t)=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),null==a||a(t))},[a]),f=g.useCallback(()=>t.map(e=>o?g.createElement(o,{key:e.id,suggestion:e,onClick:()=>{null==a||a(e)}}):g.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&&p(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,o,a,l,p]);if(!t||0===t.length)return null;if("classic"===l)return f();const h="scroll"===s||"scrollbuttons"===s,v=g.createElement("div",{role:"group",className:n.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":"scroll"===s,"k-suggestion-group-scrollable-start":u&&("scroll"===s||"scrollbuttons"===s),"k-suggestion-group-scrollable-end":c&&("scroll"===s||"scrollbuttons"===s)})},h?g.createElement("div",{className:"k-suggestions-scroll",ref:i},f()):f());return g.createElement(le,{visible:"scrollbuttons"===s,dir:r,canScrollLeft:c,canScrollRight:u,onScrollLeft:m,onScrollRight:d},v)},pe=g.forwardRef(({onFilesAdd:e,files:t=[],restrictions:n,multiple:l=!0,accept:o,uploadRef:s,onSelectAttachments:r,onRemoveAttachment:c,_registerRemoveCallback:u,...m},d)=>{g.useEffect(()=>(u&&c&&u(c),()=>{u&&c&&u(void 0)}),[c,u]);const p=g.useCallback(t=>{e&&e(t),r&&r({selectedFiles:t.affectedFiles,allFiles:t.newState})},[e,r]);return g.createElement(g.Fragment,null,g.createElement(a.Button,{ref:d,...m}),g.createElement(i.Upload,{ref:s,files:t,onAdd:p,autoUpload:!1,restrictions:n,multiple:l,accept:o,className:"k-hidden"}))});pe.displayName="PromptBoxUploadButton";const ge=g.forwardRef((e,t)=>g.createElement(a.Button,{ref:t,...e}));ge.displayName="PromptBoxActionButton";const fe=g.forwardRef((e,t)=>g.createElement(a.SpeechToTextButton,{ref:t,...e}));fe.displayName="PromptBoxSpeechToTextButton";const he=e=>"."+e.split(".").pop()||"",ve=({files:e,onRemoveFile:t,header:s})=>{const r=o.useLocalization(),i=g.useRef(null),[c,u]=g.useState(!1),[m,d]=g.useState(!1),p=g.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(g.useLayoutEffect(()=>{p()},[e,p]),g.useEffect(()=>{const e=i.current;if(!e)return;const t=()=>p(),n=new ResizeObserver(p);return n.observe(e),e.addEventListener("scroll",t,{passive:!0}),()=>{e.removeEventListener("scroll",t),n.disconnect()}},[p,e.length]),0===e.length&&!s)return null;const f=(e=>e?"function"==typeof e?e():e:null)(s),h=e.length>0&&g.createElement("ul",{className:n.classNames("k-file-box-wrapper",{"k-file-box-wrapper-scrollable-start":c,"k-file-box-wrapper-scrollable-end":m})},g.createElement("div",{className:"k-files-scroll",ref:i},e.map(e=>g.createElement("li",{key:e.name,className:"k-file-box"},g.createElement(n.IconWrap,{size:"xlarge",...n.getFileExtensionIcon(he(e.name))}),g.createElement("div",{className:"k-file-info"},g.createElement("span",{className:"k-file-name"},e.name),g.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))),g.createElement(a.Button,{fillMode:"flat",svgIcon:l.xMarkSmOutlineIcon,onClick:n=>{n.stopPropagation(),t(e.name)},"aria-label":`${r.toLanguageString(V,j[V])} ${e.name}`,title:`${r.toLanguageString(V,j[V])} ${e.name}`})))));return g.createElement("div",{className:"k-prompt-box-header"},f,h)},ke=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"13.4.0-develop.3",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"}),be="k-prompt-box",ye={mode:"auto",rows:1,defaultValue:"",disabled:!1,readOnly:!1,loading:!1,uploadButtonConfig:!1,speechToTextButtonConfig:!0,actionButtonConfig:!0},Ee=g.forwardRef((e,t)=>{const a=!n.validatePackage(ke,{component:"PromptBox"}),s=n.getLicenseMessage(ke),r=o.useLocalization(),i={...ye,...e},{mode:c=ye.mode,fillMode:u,rows:m=ye.rows,maxTextAreaHeight:d,value:p,defaultValue:f=ye.defaultValue,disabled:h=ye.disabled,readOnly:v=ye.readOnly,placeholder:k,title:b,maxLength:y,inputAttributes:E,topAffix:C,startAffix:x,endAffix:I,header:T,onChange:w,onFocus:F,onBlur:S,onPromptAction:A,attachments:N,loading:R=ye.loading,uploadButtonConfig:M=ye.uploadButtonConfig,speechToTextButtonConfig:B=ye.speechToTextButtonConfig,actionButtonConfig:L=ye.actionButtonConfig,className:D,style:P,...O}=i,z=g.useRef(null),[V,W]=g.useState(f),[G,_]=g.useState([]),[Y,X]=g.useState(!1),J=g.useRef(null),Q=g.useRef(null),Z=g.useRef(0),ee=g.useRef(0),te=g.useRef(!1),ne=g.useRef(0),ae=g.useRef(0),le=g.useCallback((e,t)=>e?"function"==typeof e?e(t):e:null,[]),oe=void 0!==p,se=oe?p:V,re=void 0!==N,ie=re?N:G,ce=g.useMemo(()=>!!(null!=se&&se.trim()||ie.length>0),[se,ie.length]),ue=g.useCallback(()=>{if(!z.current||"single"===c)return;const e=z.current,t=globalThis.getComputedStyle(e),n=Number.parseFloat(t.lineHeight)||20,a=Number.parseFloat(t.paddingTop)||0,l=Number.parseFloat(t.paddingBottom)||0;Z.current=e.offsetHeight||n+a+l,ee.current=n*m+a+l,"auto"===c&&!Y&&(ae.current=e.offsetWidth)},[c,m,Y]),me=g.useCallback(()=>"auto"===c?1:m,[c,m]),de=g.useCallback(e=>{if(d){const t=Number.parseInt(d,10);if(e>t)return t}return Math.max(ee.current,e)},[d]),he=g.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${Z.current}px`;const t=e.scrollHeight,n=de(t);e.style.height=`${n}px`,d&&t>Number.parseInt(d,10)&&(e.style.overflow="")},[de,d]),Ee=g.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${Z.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]),Ce=g.useCallback(e=>{if(ae.current<=0)return!1;const t=e.style.height,n=e.style.width;e.style.overflow="hidden",e.style.width=`${ae.current}px`,e.style.height=`${Z.current}px`;const a=e.scrollWidth<=ae.current&&e.scrollHeight<=Z.current;return e.style.overflow="",e.style.width=n||"",e.style.height=t||"",a},[]),xe=g.useCallback((e,t)=>{if(!te.current){if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!Y)return te.current=!0,void X(!0);if(Y){Ee(e);t<ne.current&&Ce(e)&&(e.style.height="",te.current=!0,X(!1))}}},[Y,Ee,Ce]),Ie=g.useCallback(()=>{var e;if("single"===c||!z.current)return;const t=z.current,n=(null==(e=t.value)?void 0:e.length)||0;"multi"===c?he(t):"auto"===c&&xe(t,n)},[c,he,xe]);g.useEffect(()=>{"single"!==c&&z.current&&ue()},[c,ue]),g.useEffect(()=>{"single"!==c&&z.current&&(ue(),Ie())},[m,c,ue,Ie]),g.useEffect(()=>{if("single"!==c&&z.current){const e=(null==se?void 0:se.length)||0;requestAnimationFrame(()=>{if(z.current){const t=z.current;"multi"===c?he(t):"auto"===c&&xe(t,e),ne.current=e}})}},[se,c,he,xe]),g.useEffect(()=>{"auto"===c&&Y&&z.current&&requestAnimationFrame(()=>{if(z.current){const e=z.current;Ee(e),te.current=!1}})},[Y,c,Ee]),g.useEffect(()=>{if("auto"===c&&z.current){const e=z.current;Y||(e.style.height="",e.style.overflow="",te.current=!1)}},[c,Y]),g.useEffect(()=>{if("single"===c||!z.current)return;const e=z.current;let t;const n=new ResizeObserver(()=>{clearTimeout(t),t=setTimeout(()=>{z.current&&("auto"===c&&!Y&&ue(),Ie())},50)});return n.observe(e),()=>{n.disconnect(),clearTimeout(t)}},[c,Y,ue,Ie]);const Te=g.useCallback(()=>({focus:()=>{var e;return null==(e=z.current)?void 0:e.focus()},blur:()=>{var e;return null==(e=z.current)?void 0:e.blur()},element:z.current,get value(){return se}}),[se]);g.useImperativeHandle(t,Te);const we=g.useCallback(e=>{const t=e.target.value;!oe&&!h&&W(t),w&&!h&&n.dispatchEvent(w,e,{...Te(),value:t},{value:t}),"single"!==c&&Ie()},[W,w,h,oe,Te,c,Ie]),Fe=g.useCallback(e=>{F&&!h&&n.dispatchEvent(F,e,Te(),void 0)},[F,h,Te]),Se=g.useCallback(e=>{S&&!h&&n.dispatchEvent(S,e,Te(),void 0)},[S,h,Te]),Ae=g.useCallback(e=>{e.preventDefault()},[]),Ne=g.useCallback(e=>{A&&n.dispatchEvent(A,e,Te(),{value:se,attachments:ie}),oe||W(""),re||_([])},[A,Te,se,ie,oe,re]),Re=g.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;ce&&Ne(e)}}},[Ne,R,ce]),Me={disabled:h,readOnly:v,placeholder:k,title:b,maxLength:y,"aria-label":r.toLanguageString(q,j[q]),value:se,onKeyDown:Re,...E,onChange:we,onFocus:Fe,onBlur:Se,ref:z},Be=g.useCallback(e=>{var t,a;const{isFinal:l,alternatives:o}=e;if(o.length>0){const e=o[0];if(l){const a=(null==(t=z.current)?void 0:t.value)||"",l=(a?`${a} `:"")+e.transcript;if(oe||W(l),w&&!h){const e={target:z.current,currentTarget:z.current};n.dispatchEvent(w,e,{...Te(),value:l},{value:l})}}}null==(a=z.current)||a.focus()},[oe,w,h,Te]),Le=g.useCallback(()=>{var e,t;null==(t=null==(e=J.current)?void 0:e.actionElement)||t.click()},[]),De=g.useCallback(e=>{var t;const n=Array.from(e.affectedFiles),a="object"==typeof M&&M.onSelectAttachments;re||_(e=>[...e,...n]),a&&a({selectedFiles:e.affectedFiles,allFiles:e.newState}),null==(t=z.current)||t.focus()},[M,re]),Pe=g.useMemo(()=>({uploadButtonProps:{fillMode:"flat",svgIcon:l.paperclipOutlineAltRightIcon,size:"small",onClick:Le,onFilesAdd:De,files:ie,uploadRef:J,"aria-label":r.toLanguageString(K,j[K]),title:r.toLanguageString(K,j[K]),_registerRemoveCallback:e=>{Q.current=e}},speechToTextButtonProps:{fillMode:"flat",size:"small",onResult:Be},actionButtonProps:{rounded:"full",size:"small",svgIcon:R?l.stopSmIcon:l.arrowUpOutlineIcon,className:R?"k-generating":"",onClick:Ne,onMouseDown:Ae,disabled:!R&&!ce,"aria-disabled":!R&&!ce,"aria-label":R?r.toLanguageString($,j[$]):r.toLanguageString(U,j[U]),title:R?r.toLanguageString($,j[$]):r.toLanguageString(U,j[U]),"aria-live":"polite"}}),[Be,De,ie,Ne,Ae,R,Le,r,ce]),Oe=g.useCallback(e=>{re||_(t=>t.filter(t=>t.name!==e));const t="object"==typeof M&&M.onRemoveAttachment;t&&(Q.current=t),Q.current&&Q.current(e)},[M,re]),ze=()=>{const e=!1!==B,t=!1!==L,n=!1!==M,a="object"==typeof B?B:void 0,l="object"==typeof M?M:{},{restrictions:o,multiple:s=!0,accept:r,onSelectAttachments:i,onRemoveAttachment:c,...u}=l,m={restrictions:o,multiple:s,accept:r},d="object"==typeof L?L:void 0;return g.createElement(g.Fragment,null,n&&g.createElement(pe,{...Pe.uploadButtonProps,restrictions:m.restrictions,multiple:m.multiple,accept:m.accept,...u}),e&&g.createElement(fe,{...Pe.speechToTextButtonProps,...a}),t&&g.createElement(ge,{...Pe.actionButtonProps,...d}))},qe="multi"===c||"auto"===c&&Y,Ue=!1!==M||!1!==B||!1!==L,Ke=I||Ue,Ve=x||I||Ue;return g.createElement("div",{"aria-label":r.toLanguageString(H,j[H]),...O,className:n.classNames(D,"k-input",be,{[`k-input-${u}`]:u,"k-disabled":h,"k-prompt-box-singleline":"single"===c,"k-prompt-box-multiline":qe}),style:P},g.createElement(ve,{files:ie,onRemoveFile:Oe,header:T}),"single"===c?g.createElement("div",{className:`${be}-content`},x&&g.createElement("div",{className:`${be}-affix`},le(x,Pe)),g.createElement("input",{...Me,className:n.classNames("k-input-inner",`${be}-input`)}),Ke?g.createElement("div",{className:`${be}-affix`},I&&le(I,Pe),ze()):null):g.createElement("div",{className:`${be}-content`},"multi"===c&&C&&g.createElement("div",{className:`${be}-affix`},le(C,Pe)),"auto"===c&&!Y&&x&&g.createElement("div",{className:`${be}-affix`},le(x,Pe)),g.createElement("textarea",{...Me,className:n.classNames("k-input-inner",`${be}-textarea`),rows:me(),style:d?{maxHeight:d}:{},...qe&&{"aria-multiline":"true"}}),"auto"===c&&!Y&&Ke?g.createElement("div",{className:`${be}-affix`},I&&le(I,Pe),ze()):null,qe&&Ve?g.createElement("div",{className:`${be}-affix`},x&&le(x,Pe),(x||I)&&g.createElement("div",{className:"k-spacer"}),I&&le(I,Pe),ze()):null),a&&g.createElement(n.WatermarkOverlay,{message:s}))});Ee.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},Ee.displayName="KendoPromptBox";const Ce=g.memo(({affixProps:e,uploadConfig:t,localizationService:n,onFilesSelect:a,onFileRemove:l})=>{const o="object"==typeof t?t:{};return!1!==t?g.createElement(pe,{...e.uploadButtonProps,fillMode:"clear",size:void 0,"aria-label":n.toLanguageString(R,j[R]),title:n.toLanguageString(R,j[R]),...o,onSelectAttachments:a,onRemoveAttachment:l}):null});Ce.displayName="UploadButtonAffix";const xe=g.forwardRef((e,t)=>{const{onSendMessage:s,isDirectionRightToLeft:r,placeholder:i,MessageBox:c,suggestions:u,onSuggestionClick:m,inputValue:d,onInputValueChange:p,suggestionTemplate:h,sendButtonConfig:k,onInputClick:b,suggestionsLayout:y,dir:E,messageBoxSettings:C,loading:x}=e,{replyToMessage:I,setReplyToMessage:T,user:F,messageListScrollContainerRef:S,speechToTextConfig:A,uploadConfig:N}=Q(),[R,M]=g.useState(""),[B,L]=g.useState([]),[D,P]=g.useState(!1),O=g.useRef(null),q=o.useLocalization(),U=void 0!==d,K=U?d:R,V=g.useCallback(()=>{null!==O.current&&O.current.focus()},[]);g.useEffect(()=>{I&&V()},[I,V]),g.useLayoutEffect(()=>{D&&null!=S&&S.current&&(S.current.scrollTop=S.current.scrollHeight-S.current.clientHeight,P(!1))},[D,S]);const $=g.useCallback(e=>{if(e.preventDefault(),s){const t={id:"",author:F,text:K||"",timestamp:new Date,replyToId:I?I.id:void 0,files:B.map(e=>({name:e.name,size:e.size,type:e.extension,rawFile:e.getRawFile?e.getRawFile():e}))};T(null),s(t,e),L([]),U||M(""),p&&p(""),P(!0),V()}},[s,K,F,I,B,T,p,V,U]);g.useImperativeHandle(t,()=>({focusInput:V}),[V]);const H=g.useCallback(e=>{L(t=>t.filter(t=>t.name!==e))},[]),_=g.useCallback((e,t)=>e.isDeleted?G(t,q):e.text,[q]),Y=g.useCallback(()=>{if(I){const e=W(F,I);return g.createElement("div",{className:n.classNames("k-message-reference",e?"k-message-reference-sender":"k-message-reference-receiver")},g.createElement("div",{className:"k-message-reference-content"},_(I,e)),g.createElement("span",{className:"k-spacer"}),g.createElement(a.Button,{fillMode:"flat",svgIcon:l.xMarkSmOutlineIcon,onClick:()=>T(null),"aria-label":q.toLanguageString(w,j[w]),title:q.toLanguageString(w,j[w])}))}return null},[I,F,_,T,q]),X=g.useCallback(e=>{try{const t=Array.from(e.allFiles);L(t)}catch{}},[]);g.useEffect(()=>{V()},[d,V]);const J=g.useCallback(e=>{const t=e.value;U||M(t),p&&p(t||"")},[U,p]),Z=g.useCallback(e=>{$(e.syntheticEvent)},[$]),ee=g.useCallback(e=>g.createElement(Ce,{affixProps:e,uploadConfig:N,localizationService:q,onFilesSelect:X,onFileRemove:H}),[N,q,X,H]),te=g.useMemo(()=>{const e="object"==typeof k?k:{},t=!1!==k&&{"aria-label":x?q.toLanguageString(z,j[z]):q.toLanguageString(f,j[f]),title:x?q.toLanguageString(z,j[z]):q.toLanguageString(f,j[f]),dir:r?"rtl":void 0,...e};return g.createElement(Ee,{header:Y(),ref:O,placeholder:i,value:K,onChange:J,onPromptAction:Z,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:A,actionButtonConfig:t,attachments:B,startAffix:ee,inputAttributes:{onClick:b,"aria-label":q.toLanguageString(v,j[v])}})},[i,K,J,Z,C,x,A,k,B,Y,ee,q,r,b]);return g.createElement("div",{className:"k-message-box-wrapper"},u&&u.length>0&&g.createElement(de,{onSuggestionClick:m,suggestions:u,suggestionTemplate:h,suggestionsLayout:y,dir:E}),c?g.createElement(c,{messageInput:te}):te)});xe.displayName="NewMessage";const Ie=e=>g.createElement(a.Toolbar,{className:"k-chat-header"},e.children),Te=e=>{const{message:t,onUnpin:s,user:r}=e,i=o.useLocalization(),{internalScrollContainerRef:c}=Q(),u=g.useRef(null),m=r&&W(r,t),d=g.useCallback(e=>{var n;e.preventDefault(),e.stopPropagation();const a=null==c?void 0:c.current,l=(null==(n=u.current)?void 0:n.offsetHeight)||0;_(t.id,a,l)},[t.id,c]);return g.createElement("div",{ref:u,className:`k-message-reference ${m?"k-message-reference-sender":"k-message-reference-receiver"} k-message-pinned`,onClick:d},g.createElement(n.IconWrap,{icon:l.pinOutlineIcon}),g.createElement("div",{className:"k-message-reference-content"},null!=t&&t.isDeleted?r&&G(W(r,t),i):null==t?void 0:t.text),g.createElement("span",{className:"k-spacer"}),g.createElement(a.Button,{fillMode:"flat",svgIcon:l.xMarkSmOutlineIcon,onClick:e=>{e.stopPropagation(),null==s||s(t)}}))},we=e=>{const{show:t,text:n}=e;return g.createElement("div",{style:{position:"absolute",top:"90%",left:"50%",transform:"translate(-50%, -50%)",zIndex:1e3,pointerEvents:t?"auto":"none"}},g.createElement(c.Fade,null,t&&g.createElement(u.Notification,{type:{style:"dark"},closable:!1},g.createElement("span",null,n))))},Fe={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"},Se=(e,t={})=>{const n={...Fe,...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 o={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&&(o.pinnedAt=new Date(e.pinnedAt)),e.pinnedBy&&(o.pinnedBy=e.pinnedBy),void 0!==e.replyToId?o.replyToId=e.replyToId:void 0!==e[n.replyToIdField]&&(o.replyToId=e[n.replyToIdField]),void 0!==e.isDeleted?o.isDeleted=e.isDeleted:void 0!==e[n.isDeletedField]&&(o.isDeleted=e[n.isDeletedField]),{...o,dataItem:e}},Ae=(e,t={})=>Array.isArray(e)?e.map(e=>Se(e,t)):[],Ne=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),Re=({viewItemsWrapperRef:e,isKeyboardNavigationActiveRef:t,processedMessages:n,suggestions:a})=>{const l=g.useCallback(()=>{e.current&&(e.current.scrollTop=e.current.scrollHeight-e.current.clientHeight)},[e]),o=g.useCallback(()=>{if(!e.current)return!0;const t=e.current,{scrollTop:n,scrollHeight:a,clientHeight:l}=t;return a-n-l<75},[e]),s=g.useCallback(e=>0===e?16:e<=2?32*e:Math.min(50*e,200),[]),r=g.useCallback((t,n)=>{const a=s(t);setTimeout(()=>{!o()&&e.current&&n(t+1)},a)},[s,o,e]),i=g.useCallback(()=>{const e=(t=0)=>{t>5||requestAnimationFrame(()=>{l(),r(t,e)})};e()},[l,r]),c=g.useCallback(()=>{l(),setTimeout(()=>{!o()&&e.current&&l()},50)},[l,o,e]),u=g.useCallback(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(c)})})},[c]),m=g.useCallback(()=>{l(),setTimeout(()=>{!o()&&e.current&&i()},25)},[l,o,e,i]),d=g.useCallback((n=!1)=>{e.current&&!t.current&&o()&&(n?m():u())},[o,m,u,e,t]);g.useEffect(()=>{const e=window.setTimeout(()=>l(),250);return()=>{clearTimeout(e)}},[l]),g.useEffect(()=>{i()},[n.length,i]);const p=g.useRef(new Map);g.useEffect(()=>{const e=new Map;let t=!1;n.forEach(n=>{if(void 0!==n.id){const a=n.id,l=!!n.typing,o=p.current.get(a);e.set(a,l),!0===o&&!1===l&&(t=!0)}}),p.current=e,t&&i()},[n,i]),g.useEffect(()=>{const e=window.setTimeout(()=>{d()},50);return()=>{clearTimeout(e)}},[n,d]),g.useEffect(()=>{if(n.length>0){const e=n[n.length-1],t=(null==e?void 0:e.text)||"";(t.includes("```")||t.includes("\n\n")||t.includes("<pre>")||t.includes("<code>")||t.includes("<table>")||t.length>500)&&d(!0)}},[n,d]),g.useEffect(()=>{if(a&&a.length>0){const e=window.setTimeout(()=>{d()},100);return()=>{clearTimeout(e)}}},[a,d]),g.useEffect(()=>{if(!e.current)return()=>{};let t;const n=new ResizeObserver(()=>{t&&clearTimeout(t),t=window.setTimeout(()=>{d()},50)}),a=e.current.querySelector(".k-message-list-content");return a&&n.observe(a),()=>{n.disconnect()}},[d,e]);const f=g.useCallback(e=>{var t;if("characterData"!==e.type&&"childList"!==e.type)return!1;const n=null!=(t=e.target.textContent)?t:"";return n.includes("```")||n.includes("\n\n")||n.includes("<pre>")||n.includes("<code>")||n.includes("<table>")||e.addedNodes&&e.addedNodes.length>2},[]),h=g.useCallback(e=>{let t=!1,n=!1;return e.forEach(e=>{var a;("childList"===e.type||"characterData"===e.type||"attributes"===e.type&&["class","style"].includes(null!=(a=e.attributeName)?a:""))&&(t=!0,f(e)&&(n=!0))}),{shouldScroll:t,hasSignificantChange:n}},[f]),v=g.useCallback((e,t)=>{t.current&&clearTimeout(t.current),e?d(!0):t.current=window.setTimeout(()=>{d()},50)},[d]);g.useEffect(()=>{if(!e.current)return()=>{};const t={current:void 0};let n=0;const a=new MutationObserver(e=>{const a=Date.now();if(a-n<16)return;n=a;const{shouldScroll:l,hasSignificantChange:s}=h(e);l&&o()&&v(s,t)});return a.observe(e.current,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["class","style"]}),()=>{a.disconnect(),t.current&&clearTimeout(t.current)}},[o,h,v,e])},Me=["allowMessageCollapse","messageWidthMode","showAvatar","showUsername","messageTemplate","messageContentTemplate","messageToolbarActions","messageContextMenuActions","fileActions"];function Be(e,t,n,a,l){const o=((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,s={};return Me.forEach(e=>{var t;s[e]=null!=(t=null==o?void 0:o[e])?t:null==n?void 0:n[e]}),s}const Le=g.forwardRef((e,t)=>{const{messages:s=[],messageTemplate:r,messageContentTemplate:i,attachmentTemplate:c,width:u,height:m,onSendMessage:d,onSuggestionClick:p,onInputValueChange:f,onActionExecute:h,dir:v,messageBox:k,placeholder:y,className:E,style:C,message:x=ee,authorId:T,suggestions:w,suggestionTemplate:F,suggestionsLayout:S="scroll",quickActionsLayout:A="scroll",inputValue:N,headerTemplate:R,noDataTemplate:M,timestampTemplate:B,statusTemplate:L,userStatusTemplate:P,allowMessageCollapse:O,messageToolbarActions:z,messageContextMenuActions:q,fileActions:U,onUnpin:K,messageWidthMode:V,showAvatar:$,showUsername:H,timestampVisibility:W,authorMessageSettings:G,receiverMessageSettings:_,onToolbarAction:Y,onContextMenuAction:X,onFileAction:Q,onDownload:Z,speechToTextConfig:te,uploadConfig:ae,sendButtonConfig:le,messageFilesLayout:oe,scrollToBottomButton:se=!0,textField:ie,statusField:de,authorIdField:pe,authorNameField:ge,authorImageUrlField:fe,authorImageAltTextField:he,idField:ve,timestampField:be,filesField:ye,attachmentsField:Ee,replyToIdField:Ce,isDeletedField:Fe,isPinnedField:Se,typingField:Me,suggestedActionsField:Le,isFailedField:De,onResendMessage:Pe,messageBoxSettings:Oe,loading:ze,...qe}=e,[Ue,Ke]=g.useState(null),[Ve,$e]=g.useState(!1),[He,je]=g.useState(!1),[We,Ge]=g.useState(null),[_e,Ye]=g.useState(null),[Xe,Je]=g.useState(!1),Qe=g.useRef(null),Ze=g.useRef(null),et=g.useRef(null),tt=g.useRef(null),nt=g.useRef(void 0),at=g.useRef(!1),lt=g.useRef(null),ot=g.useRef(""),st=g.useMemo(()=>{if(!s||0===s.length)return[];const e={textField:ie,statusField:de,authorIdField:pe,authorNameField:ge,authorImageUrlField:fe,authorImageAltTextField:he,idField:ve,timestampField:be,filesField:ye,attachmentsField:Ee,replyToIdField:Ce,isDeletedField:Fe,isPinnedField:Se,typingField:Me,suggestedActionsField:Le,isFailedField:De};return!Object.values(e).some(e=>void 0!==e)&&Ne(s[0])?s.map(e=>({...e,timestamp:e.timestamp?new Date(e.timestamp):e.timestamp})):Ae(s,e)},[s,ie,de,pe,ge,fe,he,ve,be,ye,Ee,Ce,Fe,Se,Me,Le,De]);g.useEffect(()=>{if(T===ot.current&&lt.current)Ye(lt.current);else if(T&&st.length>0){const e=st.find(e=>e.author&&(e.author.id===T||e.author.id===String(T))),t=(null==e?void 0:e.author)||{id:T};lt.current=t,ot.current=T,Ye(t)}},[T,st]);const rt=g.useMemo(()=>st.length>0?(e=>{const t=e.slice().reduce(ne(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})(st):[],[st]),it=g.useMemo(()=>!n.validatePackage(ke,{component:"Chat"}),[]),ct=n.getLicenseMessage(ke),ut=g.useMemo(()=>st.find(e=>e.isPinned),[st]),mt=o.useLocalization();Re({viewItemsWrapperRef:et,isKeyboardNavigationActiveRef:at,processedMessages:st,suggestions:w});const dt=(({elementRef:e})=>{const[t,n]=g.useState(!1);return g.useEffect(()=>{const t=e.current;if(!t)return;const a=()=>{const e=t.scrollHeight>t.clientHeight;n(e)};a();const l=new ResizeObserver(()=>{a()});l.observe(t);const o=new MutationObserver(()=>{requestAnimationFrame(a)});return o.observe(t,{childList:!0,subtree:!0,characterData:!0}),()=>{l.disconnect(),o.disconnect()}},[e]),t})({elementRef:et}),pt=g.useCallback(()=>{clearTimeout(nt.current)},[]),gt=g.useCallback(()=>{nt.current=window.setTimeout(()=>{Ke(null)},0)},[]),ft=g.useCallback(e=>{Ke(e)},[]),ht=g.useCallback(e=>{let t=null;const a=null!==Ue?Ue:rt.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<rt.lastSelectionIndex&&(t=a+1):e.keyCode===n.Keys.home?t=0:e.keyCode===n.Keys.end&&(t=rt.lastSelectionIndex),null!==t&&(Ke(t),at.current=!0,e.preventDefault())},[Ue,rt]),vt=g.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:_e,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=tt.current)||a.focusInput()}},[h,d,_e]),kt=g.useCallback(()=>{et.current&&(et.current.scrollTop=et.current.scrollHeight-et.current.clientHeight,Je(!1))},[]),bt=g.useCallback(()=>n.classNames("k-chat",E,{"k-rtl":Ve}),[E,Ve]),yt=g.useCallback(()=>{const e=rt.length-1;return rt.map((t,n)=>{var a;if("date-marker"===t.type)return g.createElement(ue,{item:t,key:t.trackBy,timestampTemplate:B});if("message-group"===t.type){const l={allowMessageCollapse:O,messageWidthMode:V,showAvatar:$,showUsername:H,messageTemplate:r,messageContentTemplate:i,messageToolbarActions:z,messageContextMenuActions:q,fileActions:U},o=Be(null==(a=null==t?void 0:t.messages)?void 0:a[0],T,l,G,_);return g.createElement(me,{group:t,itemTemplate:o.messageTemplate,contentTemplate:o.messageContentTemplate,attachmentTemplate:c,user:_e,selectedItemIndex:Ue,onRequestSelection:ft,isLastGroup:n===e,key: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?g.createElement(ce,{group:t,itemTemplate:c,onRequestSelection:ft,selected:t.selectionIndex===Ue,isLastGroup:n===e,key:t.selectionIndex}):"action-group"===t.type?g.createElement(re,{group:t,onActionExecute:vt,onRequestSelection:ft,selected:t.selectionIndex===Ue,key:t.selectionIndex,quickActionsLayout:A,dir:v}):null})},[rt,B,r,i,c,_e,Ue,ft,x,O,z,q,U,V,$,H,T,G,_,vt,A,v]),Et=g.useCallback(()=>R?"function"==typeof R?R():R:null,[R]),Ct=g.useCallback(()=>M?"function"==typeof M?M():M:null,[M]);g.useEffect(()=>{const e=void 0!==v?"rtl"===v:Qe.current&&"rtl"===getComputedStyle(Qe.current).direction;$e(!!e)},[v]),g.useEffect(()=>()=>{clearTimeout(nt.current)},[]),g.useEffect(()=>{if(!se||!et.current)return;let e;const t=()=>{clearTimeout(e),e=window.setTimeout(()=>{if(et.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=et.current;Je(!(t-e-n<100))}},150)},n=et.current;return n.addEventListener("scroll",t),()=>{n.removeEventListener("scroll",t),clearTimeout(e)}},[se]);const xt=g.useMemo(()=>({replyToMessage:We,setReplyToMessage:Ge,messages:st,user:_e,internalScrollContainerRef:Ze,messageListScrollContainerRef:et,onToolbarAction:Y,onContextMenuAction:X,onFileAction:Q,setShowCopyNotification:je,onDownload:Z,onResendMessage:Pe,fileActions:U,speechToTextConfig:te,uploadConfig:ae,statusTemplate:L,userStatusTemplate:P,messageFilesLayout:oe,timestampVisibility:W}),[We,Ge,st,_e,Y,X,Q,je,Z,Pe,U,te,ae,L,P,oe,W]);return g.createElement(J.Provider,{value:xt},g.createElement("div",{style:{width:u,height:m,position:"relative",overflow:"hidden",...C},onKeyDown:ht,className:bt(),ref:e=>{Qe.current=e,Ze.current=e,"function"==typeof t?t(e):t&&(t.current=e)},...qe},void 0!==R&&g.createElement(Ie,null,Et()),g.createElement("div",{className:"k-message-list",onBlur:gt,onFocus:pt,role:"log","aria-label":mt.toLanguageString(b,j[b]),"aria-live":"polite",ref:et},ut&&g.createElement(Te,{message:ut,onUnpin:K,user:_e}),g.createElement("div",{className:n.classNames("k-message-list-content",{"k-message-list-content-empty":0===st.length})},0===st.length&&void 0!==M&&Ct(),st.length>0&&yt()),se&&Xe&&g.createElement("div",{className:"k-chat-scroll-to-bottom-container"},g.createElement(a.FloatingActionButton,{svgIcon:l.arrowDownOutlineIcon,size:"small",themeColor:"light",rounded:"full",onClick:kt,"aria-label":mt.toLanguageString(D,j[D]),title:mt.toLanguageString(D,j[D])}))),dt&&g.createElement("div",{className:"k-separator"}),g.createElement(xe,{onSendMessage:(e,t)=>{d&&d({message:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})},onSuggestionClick:e=>{p&&p(e)},isDirectionRightToLeft:Ve,ref:tt,placeholder:y,MessageBox:k,suggestions:w,suggestionTemplate:F,inputValue:N,onInputValueChange:e=>{f&&f(e)},onInputClick:()=>{at.current=!1},sendButtonConfig:le,suggestionsLayout:S,dir:v,messageBoxSettings:Oe,loading:ze}),g.createElement(we,{show:He,text:mt.toLanguageString(I,j[I])}),it&&g.createElement(n.WatermarkOverlay,{message:ct})))});Le.displayName="Chat",Le.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};const De=e=>{const{activeView:n,toolbarItems:l,activeViewChange:o}=e;return t.createElement("div",{className:"k-prompt-header"},t.createElement(a.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},l.map(e=>t.isValidElement(e)?e:t.createElement(a.Button,{key:e.name,className:n===e.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>(e=>{null==o||o.call(null,e)})(e.name)},e.buttonText))))},Pe={name:"Output view",buttonText:"Output",buttonIcon:l.commentIcon},Oe={name:"Commands view",buttonIcon:l.moreHorizontalIcon},ze={name:"Prompt view",buttonText:"Ask AI",buttonIcon:l.sparklesIcon},qe=t.createContext([{},()=>{}]),Ue=()=>t.useContext(qe),Ke=e=>{const{children:n}=e;return t.createElement("div",{className:"k-prompt-footer"},t.createElement("div",{className:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},n))},Ve=t.forwardRef((e,n)=>{const{children:s,streaming:r,onCancel:i}=e,c=o.useLocalization().toLanguageString(E,j[E]),[u]=Ue(),m=u.activeView===Pe.name,d=r&&m,p=t.useCallback(e=>{"Escape"===e.key&&d&&i&&(e.preventDefault(),i())},[d,i]);return t.createElement("div",{className:"k-prompt-content",ref:n,onKeyDown:p},d&&t.createElement(a.FloatingActionButton,{onClick:i,svgIcon:l.stopSmIcon,icon:"stop-sm",size:"medium",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":c,title:c}),t.createElement("div",{className:"k-prompt-view"},s))});Ve.displayName="KendoReactAIPromptContent";const $e=e=>{const[t]=Ue();return t.activeView===e.name?e.children:null},He=e=>{const[n,o]=t.useState(!0),{children:s,title:r}=e;return t.createElement("div",{className:"k-prompt-expander"},t.createElement(a.Button,{"aria-controls":e.id,fillMode:"flat",svgIcon:n?l.chevronUpIcon:l.chevronDownIcon,title:r,onClick:()=>o(!n),"aria-expanded":n},r),n&&t.createElement("div",{id:e.id,className:"k-prompt-expander-content"},s))},je=e=>null==e?void 0:e.map(e=>t.createElement(s.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&je(e.children||[]))),We=({show:e=!1,anchor:n,onOpen:a,onClose:l,animate:o=!0,appendTo:s,popupOptions:r={},children:i,style:c})=>t.createElement(d.Popup,{show:e,anchor:n,style:c,animate:o,appendTo:s,onOpen:a,onClose:l,...r},i),Ge=({placeholder:e="Ask or generate content with AI...",promptValue:o,onMenuClick:s,promptInput:r=m.TextArea,generateButton:i,enableSpeechToText:c=!1,streaming:u=!1,commands:d,onPromptRequest:p,onPromptCancel:g})=>{const[f,h]=t.useState(o||""),[v,k]=n.useCustomComponent(i),[b,y]=n.useCustomComponent(r),E=r===m.TextArea||b===m.TextArea,C={svgIcon:u?l.stopSmIcon:l.paperPlaneIcon,active:(!!u).toString(),title:"Send Button","aria-label":"Send Button",disabled:!f.trim()&&!u,"aria-disabled":!f.trim()&&!u},x={placeholder:e,className:"!k-flex-row",...E?{autoSize:!0}:{},rows:1},I=d&&d.length>0,T=Object.keys(k).length>0?k:C,w=Object.keys(y).length>0?y:x,F=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()&&p&&p(f.trim())};return t.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||c?t.createElement(t.Fragment,null,t.createElement(m.InputPrefix,{className:"!k-align-items-start"},I&&t.createElement(a.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:l.menuIcon,onClick:s}),c&&t.createElement(a.SpeechToTextButton,{fillMode:"flat",..."object"==typeof c?{...c,onResult:c.onResult||F}:{onResult:F}})),t.createElement(m.InputSeparator,null)):void 0,suffix:t.createElement(m.InputSuffix,{className:"!k-align-items-start"},t.createElement(v,{className:n.classNames("k-prompt-send",{"k-generating":u,"k-active":u}),fillMode:"flat",onClick:u?g:S,...T})),...w})};e.AIPrompt=e=>{const a=!n.validatePackage(ke,{component:"AIPrompt"}),l=n.getLicenseMessage(ke),{activeView:o,toolbarItems:s,children:r,onActiveViewChange:i,onPromptRequest:c,onCommandExecute:u,style:m,dir:d,className:p,streaming:g,loading:f,onCancel:h,suggestionsView:v,...k}=e,b=s||[ze,Pe],[y,E]=t.useState({activeView:o}),C={...y,activeView:o,streaming:g,loading:f,suggestionsView:null!=v?v:"classic",onCancel:h,onActiveViewChange:i,onPromptRequest:c,onCommandExecute:u};return t.createElement(qe.Provider,{value:[C,e=>{E(e)}]},t.createElement("div",{className:n.classNames("k-prompt",p),style:m,dir:d,...k},t.createElement(De,{activeView:C.activeView,toolbarItems:b,activeViewChange:i}),r,a&&t.createElement(n.WatermarkOverlay,{message:l})))},e.AIPromptCommandsView=e=>{const{commands:n}=e,[a]=Ue();return t.createElement($e,{name:Oe.name},t.createElement(Ve,{streaming:a.streaming,onCancel:a.onCancel},t.createElement("div",{className:"k-prompt-view"},t.createElement(s.PanelBar,{onSelect:e=>{var t,n,l;const o=null==(n=null==(t=e.target)?void 0:t.props)?void 0:n.data;null!=(l=o.children)&&l.length||a.onCommandExecute&&a.onCommandExecute.call(null,o)},selected:""},je(null!=n?n:[])))))},e.AIPromptContent=Ve,e.AIPromptFooter=Ke,e.AIPromptOutputView=e=>{const[n,r]=t.useState(""),i=t.useRef(null),[c]=Ue(),{outputs:u,showOutputRating:m,outputCard:d}=e,{header:p,body:g,actions:f}=d||{},h=o.useLocalization(),v=(e,t)=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),k()},k=()=>{i&&i.current&&i.current.scrollTo({top:0,behavior:"smooth"})},b=t.createElement(s.Card,null,t.createElement(s.CardHeader,null,t.createElement(s.CardTitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),t.createElement(s.CardSubtitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),t.createElement(s.CardBody,null,t.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),t.createElement(s.CardActions,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),E=null==u?void 0:u.map((e,o)=>t.createElement(s.Card,{key:`${e.id}_${o}`},t.createElement(s.CardHeader,null,p?p(e):t.createElement(t.Fragment,null,e.title&&t.createElement(s.CardTitle,null,e.title),e.subTitle&&t.createElement(s.CardSubtitle,null,e.subTitle))),t.createElement(s.CardBody,null,g?g(e):e.responseContent),t.createElement(s.CardActions,null,f?f(e):t.createElement(t.Fragment,null,t.createElement(a.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:n===e.id?l.checkIcon:l.copyIcon,onClick:()=>(e=>{null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),r(e.id),setTimeout(()=>{r("")},1e3)})(e)},"Copy"),t.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:l.arrowRotateCwIcon,onClick:()=>(e=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),k()})(e)},"Retry"),m&&t.createElement(t.Fragment,null,t.createElement("span",{className:"k-spacer"}),t.createElement(a.Button,{size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:l.thumbUpOutlineIcon,onClick:()=>v(e,"positive")}),t.createElement(a.Button,{size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:l.thumbDownOutlineIcon,onClick:()=>v(e,"negative")})))))),C=t.createElement(s.Card,null,t.createElement(s.CardBody,null,h.toLanguageString(y,j[y])));return t.createElement($e,{name:Pe.name},t.createElement(Ve,{ref:i,streaming:c.streaming,onCancel:c.onCancel},t.createElement("div",{className:"k-card-list"},c.loading&&b,E,(!E||0===E.length)&&!c.loading&&C)))},e.AIPromptView=e=>{const{promptInput:o=m.TextArea,generateButton:s=a.Button,enableSpeechToText:r=!1,promptValue:i,promptSuggestions:c}=e,[u,d]=t.useState(i||""),[p]=Ue(),[g,f]=n.useCustomComponent(s),[h,v]=n.useCustomComponent(o),k=t.useRef(null);t.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`}})},[u]);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=u,n=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(n?" ":"")+e})();d(t)}};let x;return r&&(x="object"==typeof r?{...r,onResult:r.onResult||C}:{onResult:C}),t.createElement($e,{name:ze.name},t.createElement(Ve,{streaming:p.streaming,onCancel:p.onCancel},t.createElement(h,{ref:k,value:u,flow:"vertical",textareaStyle:{maxHeight:"110px"},autoSize:!0,suffix:r?t.createElement(t.Fragment,null,t.createElement(m.InputSeparator,{orientation:"horizontal"}),t.createElement(m.InputSuffix,{orientation:"horizontal"},t.createElement(a.SpeechToTextButton,{fillMode:"flat",...x}))):void 0,onChange:e=>{d(e.target.value)},...E}),c&&c.length>0&&t.createElement(He,{title:"Prompt Suggestions"},t.createElement(de,{suggestionsView:p.suggestionsView,suggestions:c.map((e,t)=>({id:t,text:e,description:e})),onSuggestionClick:e=>{(e=>{d(e)})(e.text)}}))),t.createElement(Ke,null,t.createElement(g,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:()=>{p.onPromptRequest&&p.onPromptRequest.call(null,u),d("")},disabled:!u.trim(),...y},y.children)))},e.AIPromptViewRender=$e,e.Chat=Le,e.ChatMessage=ee,e.DEFAULT_FIELD_MAPPING=Fe,e.HeroCard=e=>{const{imageUrl:t,imageMaxWidth:n,title:l,subtitle:o,actions:s,onActionExecute:r,altText:i}=e,c=g.useCallback((e,t)=>{null==r||r({action:e,syntheticEvent:t,nativeEvent:t.nativeEvent,target:t.currentTarget})},[r]),u=i||l||"";return g.createElement("div",{className:"k-card"},g.createElement("img",{className:"k-card-image",src:t,style:{maxWidth:n},alt:u}),g.createElement("div",{className:"k-card-body"},l&&g.createElement("h5",{className:"k-card-title"},l),o&&g.createElement("h6",{className:"k-card-subtitle"},o)),g.createElement("div",{className:"k-card-actions k-card-actions-vertical"},s.map((e,t)=>g.createElement("span",{className:"k-card-action",key:`action-${t}-${e.title||e.value||t}`},g.createElement(a.Button,{fillMode:"flat",onClick:t=>c(e,t)},e.title)))))},e.InlineAIPrompt=e=>{const o=!n.validatePackage(ke,{component:"InlineAIPrompt"}),r=n.getLicenseMessage(ke),{outputs:i=[],outputCard:c,promptInput:u=m.TextArea,generateButton:d=a.Button,promptPlaceholder:p="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:w,onOpen:F,onClose:S,animate:A=!0,appendTo:N,commands:R,onCommandExecute:M,style:B,className:L,popupOptions:D={},...P}=e,[O,z]=t.useState(""),[q,U]=t.useState(!1),[K,V]=t.useState({left:0,top:0}),$=t.useRef(null),{body:H,actions:j}=c||{},W=k||[{id:"copy",text:"Copy",svgIcon:l.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:l.cancelOutlineIcon,themeColor:"base",title:"Discard"}],G=(e,t)=>{switch(e.id){case"copy":(e=>{e.responseContent&&(navigator.clipboard.writeText(e.responseContent),z(e.id),setTimeout(()=>z(""),1e3)),null==h||h(e)})(t);break;case"discard":(e=>{null==v||v(e)})(t);break;default:null==b||b(e,t)}},_=t.useCallback(e=>{"Escape"===e.key&&(E&&C?C():!E&&S&&S({target:null}))},[E,C,S]),Y={...B,...T&&{width:T},...w&&{height:w}},X={...T&&{width:T},...w&&{height:w}},J=t.createElement(t.Fragment,null,t.createElement("div",{className:n.classNames("k-prompt",L),style:Y,onKeyDown:_,...P},t.createElement(Ve,{ref:$},i&&i.length>0&&t.createElement("div",{className:"k-card-list"},i.map((e,n)=>t.createElement(s.Card,{key:`${e.id}_${n}`},t.createElement(s.CardBody,null,H?H(e):e.responseContent),t.createElement(s.CardActions,null,j?j(e):t.createElement(t.Fragment,null,W.map(n=>{var o;return n.spacer?t.createElement("span",{key:n.id,className:"k-spacer"}):t.createElement(a.Button,{key:n.id,size:"medium",themeColor:n.themeColor||"primary",fillMode:"flat",rounded:"medium",title:null!=(o=n.title)?o:n.text,svgIcon:"copy"===n.id&&O===e.id?l.checkIcon:n.svgIcon,onClick:()=>G(n,e)},n.text)})))))),t.createElement(Ge,{promptValue:g,placeholder:p,onPromptRequest:f,onMenuClick:e=>{if(!$.current)return;const t=$.current.getBoundingClientRect();V({left:t.left,top:t.bottom}),U(!0)},onPromptCancel:C,promptInput:u,generateButton:d,enableSpeechToText:y,streaming:E,commands:R}))),o&&t.createElement(n.WatermarkOverlay,{message:r}));return t.createElement(t.Fragment,null,t.createElement(We,{show:x,anchor:I,onOpen:F,onClose:S,animate:A,appendTo:N,popupOptions:D,style:X},J),t.createElement(s.ContextMenu,{show:q,offset:K,onClose:()=>{U(!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=>{U(!1),M&&M(e)})(a)}}))},e.PromptBox=Ee,e.PromptBoxActionButton=ge,e.PromptBoxSpeechToTextButton=fe,e.PromptBoxUploadButton=pe,e.PromptHeader=De,e.SuggestionGroup=de,e.commandsViewDefaults=Oe,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=Ne,e.mapDataArrayToMessages=Ae,e.mapDataToMessage=Se,e.mapMessageToCustomFormat=(e,t={})=>{const n={...Fe,...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=Pe,e.promptViewDefaults=ze});
package/index.d.mts CHANGED
@@ -27,4 +27,10 @@ export * from './ai-prompt/views/AIPromptCommandsView.js';
27
27
  export * from './ai-prompt/views/AIPromptViewRender.js';
28
28
  export * from './inline-ai-prompt/InlineAIPrompt.js';
29
29
  export * from './ai-prompt/views/constants.js';
30
+ export * from './prompt-box/PromptBox.js';
31
+ export * from './prompt-box/interfaces/PromptBoxProps.js';
32
+ export * from './prompt-box/Events.js';
33
+ export * from './prompt-box/PromptBoxActionButton.js';
34
+ export * from './prompt-box/PromptBoxSpeechToTextButton.js';
35
+ export * from './prompt-box/PromptBoxUploadButton.js';
30
36
  export { MessageModel, ChatMessage, ChatMessageProps, ChatMessageTemplateProps, MessageAction, FileAction };
package/index.d.ts CHANGED
@@ -27,4 +27,10 @@ export * from './ai-prompt/views/AIPromptCommandsView.js';
27
27
  export * from './ai-prompt/views/AIPromptViewRender.js';
28
28
  export * from './inline-ai-prompt/InlineAIPrompt.js';
29
29
  export * from './ai-prompt/views/constants.js';
30
+ export * from './prompt-box/PromptBox.js';
31
+ export * from './prompt-box/interfaces/PromptBoxProps.js';
32
+ export * from './prompt-box/Events.js';
33
+ export * from './prompt-box/PromptBoxActionButton.js';
34
+ export * from './prompt-box/PromptBoxSpeechToTextButton.js';
35
+ export * from './prompt-box/PromptBoxUploadButton.js';
30
36
  export { MessageModel, ChatMessage, ChatMessageProps, ChatMessageTemplateProps, MessageAction, FileAction };
package/index.js CHANGED
@@ -6,4 +6,4 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  "use client";
9
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./chat/components/ChatMessage.js"),o=require("./chat/components/Chat.js"),a=require("./chat/components/SuggestionsGroup.js"),s=require("./chat/components/templates/HeroCard.js"),e=require("./chat/utils/fieldMapping.js"),m=require("./ai-prompt/AIPrompt.js"),p=require("./ai-prompt/AIPromptHeader.js"),i=require("./ai-prompt/AIPromptFooter.js"),n=require("./ai-prompt/AIPromptContent.js"),u=require("./ai-prompt/views/AIPromptView.js"),P=require("./ai-prompt/views/AIPromptOutputView.js"),I=require("./ai-prompt/views/AIPromptCommandsView.js"),A=require("./ai-prompt/views/AIPromptViewRender.js"),d=require("./inline-ai-prompt/InlineAIPrompt.js"),t=require("./ai-prompt/views/constants.js");exports.ChatMessage=r.ChatMessage;exports.Chat=o.Chat;exports.SuggestionGroup=a.SuggestionGroup;exports.HeroCard=s.HeroCard;exports.DEFAULT_FIELD_MAPPING=e.DEFAULT_FIELD_MAPPING;exports.extractFieldMappingFromProps=e.extractFieldMappingFromProps;exports.isStandardMessageFormat=e.isStandardMessageFormat;exports.mapDataArrayToMessages=e.mapDataArrayToMessages;exports.mapDataToMessage=e.mapDataToMessage;exports.mapMessageToCustomFormat=e.mapMessageToCustomFormat;exports.AIPrompt=m.AIPrompt;exports.PromptHeader=p.PromptHeader;exports.AIPromptFooter=i.AIPromptFooter;exports.AIPromptContent=n.AIPromptContent;exports.AIPromptView=u.AIPromptView;exports.AIPromptOutputView=P.AIPromptOutputView;exports.AIPromptCommandsView=I.AIPromptCommandsView;exports.AIPromptViewRender=A.AIPromptViewRender;exports.InlineAIPrompt=d.InlineAIPrompt;exports.commandsViewDefaults=t.commandsViewDefaults;exports.outputViewDefaults=t.outputViewDefaults;exports.promptViewDefaults=t.promptViewDefaults;
9
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chat/components/ChatMessage.js"),r=require("./chat/components/Chat.js"),p=require("./chat/components/SuggestionsGroup.js"),a=require("./chat/components/templates/HeroCard.js"),t=require("./chat/utils/fieldMapping.js"),s=require("./ai-prompt/AIPrompt.js"),m=require("./ai-prompt/AIPromptHeader.js"),n=require("./ai-prompt/AIPromptFooter.js"),i=require("./ai-prompt/AIPromptContent.js"),u=require("./ai-prompt/views/AIPromptView.js"),P=require("./ai-prompt/views/AIPromptOutputView.js"),A=require("./ai-prompt/views/AIPromptCommandsView.js"),c=require("./ai-prompt/views/AIPromptViewRender.js"),I=require("./inline-ai-prompt/InlineAIPrompt.js"),o=require("./ai-prompt/views/constants.js"),d=require("./prompt-box/PromptBox.js"),g=require("./prompt-box/PromptBoxActionButton.js"),B=require("./prompt-box/PromptBoxSpeechToTextButton.js"),q=require("./prompt-box/PromptBoxUploadButton.js");exports.ChatMessage=e.ChatMessage;exports.Chat=r.Chat;exports.SuggestionGroup=p.SuggestionGroup;exports.HeroCard=a.HeroCard;exports.DEFAULT_FIELD_MAPPING=t.DEFAULT_FIELD_MAPPING;exports.extractFieldMappingFromProps=t.extractFieldMappingFromProps;exports.isStandardMessageFormat=t.isStandardMessageFormat;exports.mapDataArrayToMessages=t.mapDataArrayToMessages;exports.mapDataToMessage=t.mapDataToMessage;exports.mapMessageToCustomFormat=t.mapMessageToCustomFormat;exports.AIPrompt=s.AIPrompt;exports.PromptHeader=m.PromptHeader;exports.AIPromptFooter=n.AIPromptFooter;exports.AIPromptContent=i.AIPromptContent;exports.AIPromptView=u.AIPromptView;exports.AIPromptOutputView=P.AIPromptOutputView;exports.AIPromptCommandsView=A.AIPromptCommandsView;exports.AIPromptViewRender=c.AIPromptViewRender;exports.InlineAIPrompt=I.InlineAIPrompt;exports.commandsViewDefaults=o.commandsViewDefaults;exports.outputViewDefaults=o.outputViewDefaults;exports.promptViewDefaults=o.promptViewDefaults;exports.PromptBox=d.PromptBox;exports.PromptBoxActionButton=g.PromptBoxActionButton;exports.PromptBoxSpeechToTextButton=B.PromptBoxSpeechToTextButton;exports.PromptBoxUploadButton=q.PromptBoxUploadButton;
package/index.mjs CHANGED
@@ -6,42 +6,50 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  "use client";
9
- import { ChatMessage as e } from "./chat/components/ChatMessage.mjs";
10
- import { Chat as m } from "./chat/components/Chat.mjs";
9
+ import { ChatMessage as t } from "./chat/components/ChatMessage.mjs";
10
+ import { Chat as p } from "./chat/components/Chat.mjs";
11
11
  import { SuggestionGroup as a } from "./chat/components/SuggestionsGroup.mjs";
12
12
  import { HeroCard as f } from "./chat/components/templates/HeroCard.mjs";
13
- import { DEFAULT_FIELD_MAPPING as i, extractFieldMappingFromProps as P, isStandardMessageFormat as A, mapDataArrayToMessages as I, mapDataToMessage as n, mapMessageToCustomFormat as u } from "./chat/utils/fieldMapping.mjs";
13
+ import { DEFAULT_FIELD_MAPPING as P, extractFieldMappingFromProps as n, isStandardMessageFormat as i, mapDataArrayToMessages as u, mapDataToMessage as A, mapMessageToCustomFormat as I } from "./chat/utils/fieldMapping.mjs";
14
14
  import { AIPrompt as g } from "./ai-prompt/AIPrompt.mjs";
15
- import { PromptHeader as D } from "./ai-prompt/AIPromptHeader.mjs";
16
- import { AIPromptFooter as M } from "./ai-prompt/AIPromptFooter.mjs";
17
- import { AIPromptContent as C } from "./ai-prompt/AIPromptContent.mjs";
18
- import { AIPromptView as T } from "./ai-prompt/views/AIPromptView.mjs";
19
- import { AIPromptOutputView as h } from "./ai-prompt/views/AIPromptOutputView.mjs";
20
- import { AIPromptCommandsView as G } from "./ai-prompt/views/AIPromptCommandsView.mjs";
21
- import { AIPromptViewRender as L } from "./ai-prompt/views/AIPromptViewRender.mjs";
22
- import { InlineAIPrompt as _ } from "./inline-ai-prompt/InlineAIPrompt.mjs";
23
- import { commandsViewDefaults as N, outputViewDefaults as O, promptViewDefaults as R } from "./ai-prompt/views/constants.mjs";
15
+ import { PromptHeader as B } from "./ai-prompt/AIPromptHeader.mjs";
16
+ import { AIPromptFooter as F } from "./ai-prompt/AIPromptFooter.mjs";
17
+ import { AIPromptContent as V } from "./ai-prompt/AIPromptContent.mjs";
18
+ import { AIPromptView as C } from "./ai-prompt/views/AIPromptView.mjs";
19
+ import { AIPromptOutputView as c } from "./ai-prompt/views/AIPromptOutputView.mjs";
20
+ import { AIPromptCommandsView as S } from "./ai-prompt/views/AIPromptCommandsView.mjs";
21
+ import { AIPromptViewRender as G } from "./ai-prompt/views/AIPromptViewRender.mjs";
22
+ import { InlineAIPrompt as L } from "./inline-ai-prompt/InlineAIPrompt.mjs";
23
+ import { commandsViewDefaults as _, outputViewDefaults as y, promptViewDefaults as N } from "./ai-prompt/views/constants.mjs";
24
+ import { PromptBox as R } from "./prompt-box/PromptBox.mjs";
25
+ import { PromptBoxActionButton as j } from "./prompt-box/PromptBoxActionButton.mjs";
26
+ import { PromptBoxSpeechToTextButton as q } from "./prompt-box/PromptBoxSpeechToTextButton.mjs";
27
+ import { PromptBoxUploadButton as z } from "./prompt-box/PromptBoxUploadButton.mjs";
24
28
  export {
25
29
  g as AIPrompt,
26
- G as AIPromptCommandsView,
27
- C as AIPromptContent,
28
- M as AIPromptFooter,
29
- h as AIPromptOutputView,
30
- T as AIPromptView,
31
- L as AIPromptViewRender,
32
- m as Chat,
33
- e as ChatMessage,
34
- i as DEFAULT_FIELD_MAPPING,
30
+ S as AIPromptCommandsView,
31
+ V as AIPromptContent,
32
+ F as AIPromptFooter,
33
+ c as AIPromptOutputView,
34
+ C as AIPromptView,
35
+ G as AIPromptViewRender,
36
+ p as Chat,
37
+ t as ChatMessage,
38
+ P as DEFAULT_FIELD_MAPPING,
35
39
  f as HeroCard,
36
- _ as InlineAIPrompt,
37
- D as PromptHeader,
40
+ L as InlineAIPrompt,
41
+ R as PromptBox,
42
+ j as PromptBoxActionButton,
43
+ q as PromptBoxSpeechToTextButton,
44
+ z as PromptBoxUploadButton,
45
+ B as PromptHeader,
38
46
  a as SuggestionGroup,
39
- N as commandsViewDefaults,
40
- P as extractFieldMappingFromProps,
41
- A as isStandardMessageFormat,
42
- I as mapDataArrayToMessages,
43
- n as mapDataToMessage,
44
- u as mapMessageToCustomFormat,
45
- O as outputViewDefaults,
46
- R as promptViewDefaults
47
+ _ as commandsViewDefaults,
48
+ n as extractFieldMappingFromProps,
49
+ i as isStandardMessageFormat,
50
+ u as mapDataArrayToMessages,
51
+ A as mapDataToMessage,
52
+ I as mapMessageToCustomFormat,
53
+ y as outputViewDefaults,
54
+ N as promptViewDefaults
47
55
  };
@@ -85,6 +85,46 @@ export declare const scrollLeft = "chat.scrollLeft";
85
85
  * @hidden
86
86
  */
87
87
  export declare const scrollRight = "chat.scrollRight";
88
+ /**
89
+ * @hidden
90
+ */
91
+ export declare const scrollToBottom = "chat.scrollToBottom";
92
+ /**
93
+ * @hidden
94
+ */
95
+ export declare const messageFailed = "chat.messageFailed";
96
+ /**
97
+ * @hidden
98
+ */
99
+ export declare const retryMessage = "chat.retryMessage";
100
+ /**
101
+ * @hidden
102
+ */
103
+ export declare const chatStopGenerating = "chat.stopGenerating";
104
+ /**
105
+ * @hidden
106
+ */
107
+ export declare const promptBoxInput = "promptBox.input";
108
+ /**
109
+ * @hidden
110
+ */
111
+ export declare const promptBoxSendButton = "promptBox.sendButton";
112
+ /**
113
+ * @hidden
114
+ */
115
+ export declare const promptBoxAttachFile = "promptBox.attachFile";
116
+ /**
117
+ * @hidden
118
+ */
119
+ export declare const promptBoxRemoveFile = "promptBox.removeFile";
120
+ /**
121
+ * @hidden
122
+ */
123
+ export declare const promptBoxStopGenerating = "promptBox.stopGenerating";
124
+ /**
125
+ * @hidden
126
+ */
127
+ export declare const promptBoxAriaLabel = "promptBox.ariaLabel";
88
128
  /**
89
129
  * @hidden
90
130
  */
@@ -105,8 +145,18 @@ export declare const messages: {
105
145
  "chat.expandMessage": string;
106
146
  "chat.removeFile": string;
107
147
  "chat.fileActions": string;
148
+ "chat.messageFailed": string;
149
+ "chat.retryMessage": string;
150
+ "chat.stopGenerating": string;
108
151
  "chat.attachFile": string;
109
152
  "chat.downloadAll": string;
110
153
  "chat.scrollLeft": string;
111
154
  "chat.scrollRight": string;
155
+ "chat.scrollToBottom": string;
156
+ "promptBox.input": string;
157
+ "promptBox.sendButton": string;
158
+ "promptBox.attachFile": string;
159
+ "promptBox.removeFile": string;
160
+ "promptBox.stopGenerating": string;
161
+ "promptBox.ariaLabel": string;
112
162
  };
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",s="newMessage.optionsButton",t="newMessage.messageInput",a="avatar.alt",o="messageList.ariaLabel",l="aIPrompt.noOutputs",c="aIPrompt.cancel",n="chat.senderDeletedMessage",i="chat.receiverDeletedMessage",r="chat.copyNotification",g="chat.downloadAllFiles",d="chat.closeReply",p="chat.collapseMessage",h="chat.expandMessage",M="chat.removeFile",m="chat.fileActions",u="chat.attachFile",w="chat.downloadAll",f="chat.scrollLeft",v="chat.scrollRight",A={[e]:"Send",[s]:"Options",[t]:"Message",[a]:"Avatar",[o]:"Message list",[c]:"Cancel",[l]:"No output from AI available",[n]:"You removed this message",[i]:"The message was removed by its sender",[r]:"Text copied to clipboard",[g]:"Download all files",[d]:"Close reply",[p]:"Collapse message",[h]:"Expand message",[M]:"Remove file",[m]:"File actions for",[u]:"Attach file",[w]:"Download all",[f]:"Scroll left",[v]:"Scroll right"};exports.aIPromptCancel=c;exports.aIPromptNoOutputs=l;exports.ariaLabelMessageList=o;exports.attachFile=u;exports.avatarAlt=a;exports.chatCopyNotification=r;exports.chatReceiverDeletedMessage=i;exports.chatSenderDeletedMessage=n;exports.closeReply=d;exports.collapseMessage=p;exports.downloadAll=w;exports.downloadAllFiles=g;exports.expandMessage=h;exports.fileActions=m;exports.messages=A;exports.newMessageMessageInput=t;exports.newMessageOptionsButton=s;exports.newMessageSendButton=e;exports.removeFile=M;exports.scrollLeft=f;exports.scrollRight=v;
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",r="chat.receiverDeletedMessage",p="chat.copyNotification",i="chat.downloadAllFiles",g="chat.closeReply",m="chat.collapseMessage",d="chat.expandMessage",h="chat.removeFile",M="chat.fileActions",B="chat.attachFile",u="chat.downloadAll",x="chat.scrollLeft",F="chat.scrollRight",v="chat.scrollToBottom",A="chat.messageFailed",S="chat.retryMessage",f="chat.stopGenerating",w="promptBox.input",y="promptBox.sendButton",b="promptBox.attachFile",R="promptBox.removeFile",I="promptBox.stopGenerating",L="promptBox.ariaLabel",P={[e]:"Send",[t]:"Options",[o]:"Message",[s]:"Avatar",[a]:"Message list",[n]:"Cancel",[l]:"No output from AI available",[c]:"You removed this message",[r]:"The message was removed by its sender",[p]:"Text copied to clipboard",[i]:"Download all files",[g]:"Close reply",[m]:"Collapse message",[d]:"Expand message",[h]:"Remove file",[M]:"File actions for",[A]:"Failed to send",[S]:"Retry",[f]:"Stop generating",[B]:"Attach file",[u]:"Download all",[x]:"Scroll left",[F]:"Scroll right",[v]:"Scroll to bottom",[w]:"Prompt",[y]:"Send",[b]:"Attach file",[R]:"Remove file",[I]:"Stop generating",[L]:"Prompt box"};exports.aIPromptCancel=n;exports.aIPromptNoOutputs=l;exports.ariaLabelMessageList=a;exports.attachFile=B;exports.avatarAlt=s;exports.chatCopyNotification=p;exports.chatReceiverDeletedMessage=r;exports.chatSenderDeletedMessage=c;exports.chatStopGenerating=f;exports.closeReply=g;exports.collapseMessage=m;exports.downloadAll=u;exports.downloadAllFiles=i;exports.expandMessage=d;exports.fileActions=M;exports.messageFailed=A;exports.messages=P;exports.newMessageMessageInput=o;exports.newMessageOptionsButton=t;exports.newMessageSendButton=e;exports.promptBoxAriaLabel=L;exports.promptBoxAttachFile=b;exports.promptBoxInput=w;exports.promptBoxRemoveFile=R;exports.promptBoxSendButton=y;exports.promptBoxStopGenerating=I;exports.removeFile=h;exports.retryMessage=S;exports.scrollLeft=x;exports.scrollRight=F;exports.scrollToBottom=v;