@progress/kendo-vue-conversational-ui 8.4.0-develop.1 → 8.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.
@@ -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("vue"),require("@progress/kendo-vue-common"),require("@progress/kendo-vue-buttons"),require("@progress/kendo-svg-icons"),require("@progress/kendo-vue-inputs"),require("@progress/kendo-vue-layout"),require("@progress/kendo-vue-intl"),require("@progress/kendo-vue-upload")):"function"==typeof define&&define.amd?define(["exports","vue","@progress/kendo-vue-common","@progress/kendo-vue-buttons","@progress/kendo-svg-icons","@progress/kendo-vue-inputs","@progress/kendo-vue-layout","@progress/kendo-vue-intl","@progress/kendo-vue-upload"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoVueConversationalUi={},e.Vue,e.KendoVueCommon,e.KendoVueButtons,e.KendoSVGIcons,e.KendoVueInputs,e.KendoVueLayout,e.KendoVueIntl,e.KendoVueUpload)}(this,function(e,t,o,n,i,s,l,r,a){"use strict";function u(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const d=t.defineComponent({name:"KendoAIPromptHeader",props:{activeView:String,toolbarItems:Array,onActiveviewchange:Function},methods:{handleClick(e){this.$emit("activeviewchange",e)}},render(){let e;const{activeView:i,toolbarItems:s}=this.$props;return t.createVNode("div",{class:"k-prompt-header"},[t.createVNode(n.Toolbar,{overflow:"none",keyboardNavigation:!1,class:"k-toolbar-flat"},u(e=s.map(function(e){const s=o.getTemplate.call(this,{h:t.h,template:e.content,defaultRendering:null,additionalProps:{item:e}});return e.content?s:t.createVNode(n.Button,{type:"button",key:e.name,class:o.classNames("k-toolbar-item",{"k-selected":i===e.name}),size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>this.handleClick(e.name)},{default:()=>[e.buttonText]})},this))?e:{default:()=>[e]})])}}),c={name:"Output view",buttonText:"Output",buttonIcon:i.commentIcon},p={name:"Commands view",buttonIcon:i.moreHorizontalIcon},h={name:"Prompt view",buttonText:"Ask AI",buttonIcon:i.sparklesIcon},m={name:"@progress/kendo-vue-conversational-ui",productName:"Kendo UI for Vue",productCode:"KENDOUIVUE",productCodes:["KENDOUIVUE"],publishDate:0,version:"8.4.0-develop.1",licensingDocsUrl:"https://www.telerik.com/kendo-vue-ui/my-license/"},g=t.defineComponent({name:"KendoAIPrompt",props:{activeView:{type:String,required:!0},dir:String,toolbarItems:Array,outputs:Array,promptPlaceholder:String,streaming:Boolean,loading:Boolean,suggestionsView:{type:String,default:"classic"}},provide(){return{kendoAIPrompt:this.$data.contextState}},data(){return{showLicenseWatermark:!1,licenseMessage:"",contextState:{activeView:this.$props.activeView,streaming:this.$props.streaming,loading:this.$props.loading,onCancel:this.onCancel,onActiveViewChange:this.onActiveViewChange,onPromptRequest:this.onPromptRequest,onCommandExecute:this.onCommandExecute,onStateAction:this.onStateAction,suggestionsView:this.$props.suggestionsView}}},watch:{activeView(e){this.contextState.activeView=e},streaming(e){this.contextState.streaming=e},loading(e){this.contextState.loading=e}},methods:{onStateAction(e){this.contextState.activeView=e.activeView},onActiveViewChange(e){this.$emit("activeviewchange",e)},onPromptRequest(e,t){this.$emit("promptrequest",e,t)},onCommandExecute(e){this.$emit("commandexecute",e)},onCancel(){this.$emit("cancel")}},render(){o.validatePackage(m),this.showLicenseWatermark=o.shouldShowValidationUI(m),this.licenseMessage=o.getLicenseMessage(m);const e=o.getDefaultSlots(this),{toolbarItems:n,dir:i}=this.$props,s=(n||[h,c]).map(e=>{const t=o.templateRendering.call(this,e.content,o.getListeners.call(this));return{...e,content:t}}),l=this.showLicenseWatermark?t.createVNode(o.WatermarkOverlay,{message:this.licenseMessage},null):null;return t.createVNode("div",{class:"k-prompt",dir:i},[t.createVNode(d,{activeView:this.contextState.activeView,toolbarItems:s,onActiveviewchange:this.onActiveViewChange},null),e,l])}}),f=t.defineComponent({name:"KendoAIPromptFooter",render(){const e=o.getDefaultSlots(this);return t.createVNode("div",{class:"k-prompt-footer"},[t.createVNode("div",{class:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},[e])])}}),v=t.defineComponent({name:"KendoAIPromptContent",props:{onCancel:Function,streaming:Boolean},inject:{kendoAIPrompt:{default:null}},computed:{showFloatingButton(){var e;const t=(null==(e=this.kendoAIPrompt)?void 0:e.activeView)===c.name;return this.streaming&&t}},methods:{handleKeyDown(e){"Escape"===e.key&&this.showFloatingButton&&this.onCancel&&(e.preventDefault(),this.$props.onCancel())}},render(){const e=o.getDefaultSlots(this);return t.createVNode("div",{class:"k-prompt-content",onKeydown:this.handleKeyDown},[this.showFloatingButton&&t.createVNode(n.FloatingActionButton,{onClick:this.onCancel,svgIcon:i.stopSmIcon,size:"small",positionMode:"absolute",class:"k-prompt-stop-fab k-generating"},null),t.createVNode("div",{class:"k-prompt-view"},[e])])}}),k=t.defineComponent({name:"KendoAIPromptViewRender",inheritAttrs:!1,props:{name:String},inject:{kendoAIPrompt:{default:null}},render(){const e=o.getDefaultSlots(this);return this.kendoAIPrompt.activeView===this.$props.name?e:null}});function b(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const V=t.defineComponent({name:"KendoAIPromptExpander",props:{title:String},data:()=>({expanded:!0}),methods:{buttonClick(){this.expanded=!this.expanded}},render(){const e=o.getDefaultSlots(this),{title:s}=this.$props;return t.createVNode("div",{class:"k-prompt-expander"},[t.createVNode(n.Button,{type:"button",fillMode:"flat",svgIcon:this.expanded?i.chevronUpIcon:i.chevronDownIcon,title:s,onClick:this.buttonClick},b(s)?s:{default:()=>[s]}),this.expanded&&t.createVNode("div",{class:"k-prompt-expander-content"},[e])])}}),x=t.defineComponent({name:"KendoSuggestionGroup",props:{suggestions:{type:Array,required:!0},onSuggestionClick:{type:Function,required:!0},suggestionsView:{type:String,default:"classic"}},methods:{handleSuggestionClick(e,t){t.disabled||this.onSuggestionClick(e,t)},handleKeyDown(e,t){("Enter"===e.key||" "===e.key)&&(e.preventDefault(),this.onSuggestionClick(e,t))}},render(){const{suggestions:e,suggestionsView:n}=this.$props,i=()=>e.map(e=>t.createVNode("span",{role:"button",tabindex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:t=>!e.disabled&&this.handleSuggestionClick(t,e),onKeydown:t=>!e.disabled&&this.handleKeyDown(t,e),key:e.id,title:e.description,class:o.classNames("classic"===n?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},[e.text]));return"classic"===n?i():t.createVNode("div",{role:"group",class:"k-suggestion-group"},[i()])}});function y(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const A=t.defineComponent({name:"KendoAIPromptView",props:{promptInput:[Object,String],generateButton:[Object,String],promptValue:String,promptSuggestions:Array,enableSpeechToText:[Boolean,Object]},inject:{kendoAIPrompt:{default:null}},computed:{computedValue(){return void 0!==this.$props.promptValue?this.$props.promptValue:this.value}},data:()=>({value:""}),methods:{handleOnRequest(){this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,this.computedValue),this.value=""},handleSuggestionSelect(e){this.value=e},onTextChange(e){this.value=e.value},onSpeechResult(e){if(e.isFinal&&e.alternatives.length>0){const t=e.alternatives[0].transcript,o=this.value,n=o&&!o.endsWith(" ")&&!o.endsWith("\n");this.value=o+(n?" ":"")+t}},onSpeechStart(){},onSpeechEnd(){},getButtonDisabledState(){const e=void 0!==this.$props.promptValue?this.$props.promptValue:this.value;return!(null!=e&&e.trim())}},render(){const e="Generate",{promptSuggestions:l,enableSpeechToText:r}=this.$props,a=o.templateRendering.call(this,this.$props.promptInput,o.getListeners.call(this)),u=t.createVNode(s.TextArea,{value:this.computedValue,onInput:this.onTextChange,placeholder:"Ask or generate content with AI ...",rows:2,class:"!k-flex-col",inputSuffix:()=>r?t.createVNode(t.Fragment,null,[t.createVNode(s.InputSeparator,{orientation:"horizontal"},null),t.createVNode("div",{class:"k-input-suffix k-input-suffix-horizontal"},[t.createVNode(n.SpeechToTextButton,t.mergeProps({fillMode:"flat",onStart:this.onSpeechStart,onEnd:this.onSpeechEnd,onResult:this.onSpeechResult},"object"==typeof r?r:{}),null)])]):null},null),d=o.getTemplate.call(this,{h:t.h,template:a,defaultRendering:u}),c=o.templateRendering.call(this,this.$props.generateButton,o.getListeners.call(this)),p=t.createVNode(n.Button,{type:"button",themeColor:"primary",fillMode:"solid","aria-hidden":"true",rounded:"full",size:"medium",onClick:this.handleOnRequest,disabled:this.getButtonDisabledState(),title:"Generate",svgIcon:i.sparklesIcon},y(e)?e:{default:()=>[e]}),m=o.getTemplate.call(this,{h:t.h,template:c,defaultRendering:p});return t.createVNode(k,{name:h.name},{default:()=>{var e,o;return[t.createVNode(v,{streaming:null==(e=this.kendoAIPrompt)?void 0:e.streaming,onCancel:null==(o=this.kendoAIPrompt)?void 0:o.onCancel},{default:()=>[d,l&&l.length>0&&t.createVNode(V,{title:"Prompt Suggestions"},{default:()=>{var e;return[t.createVNode(x,{suggestionsView:null==(e=this.kendoAIPrompt)?void 0:e.suggestionsView,suggestions:l.map((e,t)=>({id:t,text:e,description:e})),onSuggestionClick:(e,t)=>this.handleSuggestionSelect(t.text)},null)]}})]}),t.createVNode(f,null,y(m)?m:{default:()=>[m]})]}})}}),C="avatar.alt",S="messageList.ariaLabel",$="aIPrompt.noOutputs",I="promptBox.input",N="promptBox.sendButton",w="promptBox.attachFile",B="promptBox.removeFile",R="promptBox.stopGenerating",P="promptBox.ariaLabel",F={[C]:"Avatar",[S]:"Message list",[$]:"No output from Ai available",[I]:"Prompt",[N]:"Send",[w]:"Attach file",[B]:"Remove file",[R]:"Stop generating",[P]:"Prompt box"};function T(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}let O=function(e){return e.positive="positive",e.negative="negative",e}({});const z=t.defineComponent({name:"KendoAIPromptOutputView",emits:{copy:null,retry:null,rating:null},props:{outputs:Array,outputCard:Object,showOutputRating:Boolean},inject:{kendoAIPrompt:{default:null},kendoLocalizationService:{default:null}},data:()=>({copiedIndex:-1,copyButtonIcon:i.copyIcon,contentRef:null}),methods:{retryPrompt(e){this.$emit("retry",e),this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),this.scrollToTopOutput()},copyToClipboard(e,t){null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),this.copiedIndex=t,this.copyButtonIcon=i.checkIcon,this.$emit("copy",null==e?void 0:e.responseContent),setTimeout(()=>{this.copyButtonIcon=i.copyIcon,this.copiedIndex=-1},1e3)},outputRating(e,t){this.$emit("rating",e,t),this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),this.scrollToTopOutput()},scrollToTopOutput(){var e,t;null==(t=null==(e=this.contentRef)?void 0:e.scrollTo)||t.call(e,{top:0,behavior:"smooth"})}},render(){let e;const{outputs:o,showOutputRating:s,outputCard:a}=this.$props,u=r.provideLocalizationService(this),{header:d,body:p,actions:h}=a||{},m=t.createVNode(l.Card,null,{default:()=>[t.createVNode(l.CardHeader,null,{default:()=>[t.createVNode(l.CardTitle,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}},null)]}),t.createVNode(l.CardSubtitle,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}},null)]})]}),t.createVNode(l.CardBody,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}},null)]}),t.createVNode(l.CardActions,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}},null)]})]}),g=null==o?void 0:o.map((e,o)=>t.createVNode(l.Card,{key:`${e.id}_${o}`,class:e.class},{default:()=>[t.createVNode(l.CardHeader,null,{default:()=>[d?d(e):t.createVNode(t.Fragment,null,[e.title&&t.createVNode(l.CardTitle,null,{default:()=>[e.title]}),e.subTitle&&t.createVNode(l.CardSubtitle,null,{default:()=>[e.subTitle]})])]}),t.createVNode(l.CardBody,null,{default:()=>[p?p(e):e.responseContent]}),t.createVNode(l.CardActions,null,{default:()=>[h?h(e):t.createVNode(t.Fragment,null,[t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:this.copiedIndex===o?this.copyButtonIcon:i.copyIcon,"aria-hidden":"true",onClick:()=>this.copyToClipboard(e,o)},{default:()=>["Copy"]}),t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:i.arrowRotateCwIcon,"aria-hidden":"true",onClick:()=>this.retryPrompt(e)},{default:()=>["Retry"]}),s&&t.createVNode(t.Fragment,null,[t.createVNode("span",{class:"k-spacer"},null),t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:i.thumbUpOutlineIcon,"aria-hidden":"true",onClick:()=>this.outputRating(e,"positive")},null),t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:i.thumbDownOutlineIcon,"aria-hidden":"true",onClick:()=>this.outputRating(e,"negative")},null)])])]})]})),f=t.createVNode(l.Card,null,{default:()=>[t.createVNode(l.CardBody,null,T(e=u.toLanguageString($,F[$]))?e:{default:()=>[e]})]});return t.createVNode(k,{name:c.name},{default:()=>{var e,o;return[t.createVNode(v,{ref:e=>this.contentRef=e,streaming:null==(e=this.kendoAIPrompt)?void 0:e.streaming,onCancel:null==(o=this.kendoAIPrompt)?void 0:o.onCancel},{default:()=>{var e,o;return[t.createVNode("div",{class:"k-card-list"},[(null==(e=this.kendoAIPrompt)?void 0:e.loading)&&m,g,(!g||0===g.length)&&!(null!=(o=this.kendoAIPrompt)&&o.loading)&&f])]}})]}})}}),L=t.defineComponent({name:"KendoAIPromptCommandsView",props:{commands:Array},inject:{kendoAIPrompt:{default:null}},render(){const{commands:e}=this.$props,o=e=>{var t;const o=e.target;(null==(t=o.items)||!t.length)&&this.kendoAIPrompt.onCommandExecute&&(this.$emit("commandexecute",o),this.kendoAIPrompt.onCommandExecute.call(null,o))};return t.createVNode(k,{name:p.name},{default:()=>{var n,i;return[t.createVNode(v,{streaming:null==(n=this.kendoAIPrompt)?void 0:n.streaming,onCancel:null==(i=this.kendoAIPrompt)?void 0:i.onCancel},{default:()=>[t.createVNode("div",{class:"k-prompt-view"},[t.createVNode(l.PanelBar,{onSelect:o,items:e},null)])]})]}})}}),M=t.defineComponent({name:"KendoPromptBoxActionButton",inheritAttrs:!1,render(){return t.createVNode(n.Button,this.$attrs,null)}}),E=t.defineComponent({name:"KendoPromptBoxSpeechToTextButton",inheritAttrs:!1,render(){return t.createVNode(n.SpeechToTextButton,this.$attrs,null)}}),j=t.defineComponent({name:"KendoPromptBoxUploadButton",inheritAttrs:!1,props:{onFilesAdd:Function,files:{type:Array,default:()=>[]},restrictions:Object,multiple:{type:Boolean,default:!0},accept:String,onSelectAttachments:Function,onRemoveAttachment:Function,_registerRemoveCallback:Function},setup(e){const o=t.ref(null);return t.watch(()=>e.onRemoveAttachment,t=>{e._registerRemoveCallback&&t&&e._registerRemoveCallback(t)},{immediate:!0}),t.onUnmounted(()=>{e._registerRemoveCallback&&e.onRemoveAttachment&&e._registerRemoveCallback(void 0)}),{uploadRef:o,handleFilesAdd:t=>{e.onFilesAdd&&e.onFilesAdd(t),e.onSelectAttachments&&e.onSelectAttachments({selectedFiles:t.affectedFiles,allFiles:t.newState})}}},render(){const{onFilesAdd:e,files:o,restrictions:i,multiple:s,accept:l,onSelectAttachments:r,onRemoveAttachment:u,_registerRemoveCallback:d,_uploadRef:c,...p}=this.$attrs;return t.createVNode(t.Fragment,null,[t.createVNode(n.Button,p,null),t.createVNode(a.Upload,{ref:e=>{this.uploadRef=e,c&&(c.value=e)},files:this.files,onAdd:this.handleFilesAdd,autoUpload:!1,restrictions:this.restrictions,multiple:this.multiple,accept:this.accept,class:"k-hidden"},null)])}}),H=e=>"."+(e.split(".").pop()||""),K=e=>{if(null==e)return"";if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${Number.parseFloat((e/Math.pow(1024,t)).toFixed(2))} ${["B","KB","MB","GB","TB"][t]}`},D=t.defineComponent({name:"KendoFileBox",props:{files:{type:Array,required:!0},onRemoveFile:{type:Function,required:!0},header:{type:[Object,Function,String],default:void 0}},inject:{kendoLocalizationService:{default:null}},data:()=>({canScrollRight:!1,canScrollLeft:!1,resizeObserver:null}),watch:{files:{handler(){t.nextTick(()=>{this.setupScrollListeners(),this.updateScrollState()})},deep:!0}},mounted(){t.nextTick(()=>{this.setupScrollListeners(),this.updateScrollState()})},beforeUnmount(){this.cleanupScrollListeners()},methods:{setupScrollListeners(){const e=this.$refs.scrollContainer;e?this._scrollContainer!==e&&(this.cleanupScrollListeners(),e.addEventListener("scroll",this.updateScrollState,{passive:!0}),this.resizeObserver=new ResizeObserver(()=>this.updateScrollState()),this.resizeObserver.observe(e),this._scrollContainer=e):this.cleanupScrollListeners()},cleanupScrollListeners(){this._scrollContainer&&(this._scrollContainer.removeEventListener("scroll",this.updateScrollState),this._scrollContainer=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)},updateScrollState(){const e=this.$refs.scrollContainer;if(!e)return;const{scrollLeft:t,scrollWidth:o,clientWidth:n}=e,i=0===t,s=t+n>=o-1;this.canScrollLeft=!i,this.canScrollRight=!s},handleRemoveFile(e,t){t.stopPropagation(),this.$props.onRemoveFile&&this.$props.onRemoveFile(e)}},render(){const e=r.provideLocalizationService(this),{files:s,header:l}=this.$props;if(0===s.length&&!l)return null;const a=o.getTemplate.call(this,{h:t.h,template:l,defaultRendering:null}),u=e.toLanguageString(B,F[B]),d=s.length>0&&t.createVNode("ul",{class:o.classNames("k-file-box-wrapper",{"k-file-box-wrapper-scrollable-start":this.canScrollRight,"k-file-box-wrapper-scrollable-end":this.canScrollLeft})},[t.createVNode("div",{class:"k-files-scroll",ref:"scrollContainer"},[s.map(e=>t.createVNode("li",{key:e.name,class:"k-file-box"},[t.createVNode(o.Icon,t.mergeProps({size:"xlarge"},o.getFileExtensionIcon(H(e.name))),null),t.createVNode("div",{class:"k-file-info"},[t.createVNode("span",{class:"k-file-name"},[e.name]),t.createVNode("span",{class:"k-file-size"},[K(e.size)])]),t.createVNode(n.Button,{fillMode:"flat",svgIcon:i.xMarkSmOutlineIcon,onClick:t=>this.handleRemoveFile(e.name,t),"aria-label":`${u} ${e.name}`,title:`${u} ${e.name}`},null)]))])]);return t.createVNode("div",{class:"k-prompt-box-header"},[a,d])}}),q="k-prompt-box",U=t.defineComponent({name:"KendoPromptBox",emits:{change:e=>!0,focus:e=>!0,blur:e=>!0,promptaction:e=>!0},props:{value:String,defaultValue:{type:String,default:""},mode:{type:String,default:"auto"},rows:{type:Number,default:1},maxTextAreaHeight:String,title:String,disabled:{type:Boolean,default:!1},readOnly:{type:Boolean,default:!1},placeholder:String,maxLength:Number,inputAttributes:Object,fillMode:String,topAffix:[Object,Function,String],startAffix:[Object,Function,String],endAffix:[Object,Function,String],header:[Object,Function,String],loading:{type:Boolean,default:!1},uploadButtonConfig:{type:[Boolean,Object],default:!1},speechToTextButtonConfig:{type:[Boolean,Object],default:!0},actionButtonConfig:{type:[Boolean,Object],default:!0},attachments:Array},inject:{kendoLocalizationService:{default:null}},created(){o.validatePackage(m),this._uploadRef=t.ref(null)},data(){return{stateValue:this.$props.defaultValue||"",stateFiles:[],hasExpanded:!1,initialHeight:0,minMultiRowHeight:0,isResizing:!1,previousValueLength:0,singleLineWidth:0,resizeObserver:null,resizeTimeout:null,onRemoveAttachmentCallback:null}},computed:{isControlled(){return void 0!==this.$props.value},currentValue(){return this.isControlled?this.$props.value||"":this.stateValue},isFilesControlled(){return void 0!==this.$props.attachments},currentFiles(){return this.isFilesControlled?this.$props.attachments||[]:this.stateFiles},canSendMessage(){var e;return!!(null!=(e=this.currentValue)&&e.trim()||this.currentFiles.length>0)},isMultilineLayout(){return"multi"===this.$props.mode||"auto"===this.$props.mode&&this.hasExpanded},hasBuiltInButtons(){return!1!==this.$props.uploadButtonConfig||!1!==this.$props.speechToTextButtonConfig||!1!==this.$props.actionButtonConfig},hasEndAffixOrButtons(){return!!this.$props.endAffix||this.hasBuiltInButtons},hasStartAffixOrEndAffixOrButtons(){return!!this.$props.startAffix||!!this.$props.endAffix||this.hasBuiltInButtons},effectiveRows(){return"auto"===this.$props.mode?1:this.$props.rows}},watch:{currentValue(e){if("single"===this.$props.mode)return;const t=(null==e?void 0:e.length)||0;requestAnimationFrame(()=>{const e=this.$refs.inputElement;e&&("multi"===this.$props.mode?this.resizeMultiMode(e):"auto"===this.$props.mode&&this.resizeAutoMode(e,t),this.previousValueLength=t)})},rows(){"single"!==this.$props.mode&&(this.captureInitialDimensions(),this.resize())},maxTextAreaHeight(){"single"!==this.$props.mode&&this.resize()},mode(){"single"!==this.$props.mode&&t.nextTick(()=>{this.captureInitialDimensions(),this.resize()})},hasExpanded(e){if("auto"===this.$props.mode&&e&&requestAnimationFrame(()=>{const e=this.$refs.inputElement;e&&(this.updateHeight(e),this.isResizing=!1)}),"auto"===this.$props.mode&&!e){const e=this.$refs.inputElement;e&&(e.style.height="",e.style.overflow="",this.isResizing=!1)}}},mounted(){"single"!==this.$props.mode&&this.captureInitialDimensions(),this.setupResizeObserver()},beforeUnmount(){this.cleanupResizeObserver()},methods:{captureInitialDimensions(){const e=this.$refs.inputElement;if(!e||"single"===this.$props.mode)return;const t=globalThis.getComputedStyle(e),o=Number.parseFloat(t.lineHeight)||20,n=Number.parseFloat(t.paddingTop)||0,i=Number.parseFloat(t.paddingBottom)||0;this.initialHeight=e.offsetHeight||o+n+i,this.minMultiRowHeight=o*this.$props.rows+n+i,"auto"===this.$props.mode&&!this.hasExpanded&&(this.singleLineWidth=e.offsetWidth)},calculateHeight(e){if(this.$props.maxTextAreaHeight){const t=Number.parseInt(this.$props.maxTextAreaHeight,10);if(e>t)return t}return Math.max(this.minMultiRowHeight,e)},resizeMultiMode(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,o=this.calculateHeight(t);e.style.height=`${o}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},updateHeight(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,o=this.$props.maxTextAreaHeight?Math.min(t,Number.parseInt(this.$props.maxTextAreaHeight,10)):t;e.style.height=`${o}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},shouldCollapse(e){if(this.singleLineWidth<=0)return!1;const t=e.style.height,o=e.style.width;e.style.overflow="hidden",e.style.width=`${this.singleLineWidth}px`,e.style.height=`${this.initialHeight}px`;const n=e.scrollWidth<=this.singleLineWidth&&e.scrollHeight<=this.initialHeight;return e.style.overflow="",e.style.width=o||"",e.style.height=t||"",n},resizeAutoMode(e,t){if(!this.isResizing){if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!this.hasExpanded)return this.isResizing=!0,void(this.hasExpanded=!0);if(this.hasExpanded){this.updateHeight(e);t<this.previousValueLength&&this.shouldCollapse(e)&&(e.style.height="",this.isResizing=!0,this.hasExpanded=!1)}}},resize(){var e;if("single"===this.$props.mode)return;const t=this.$refs.inputElement;if(!t)return;const o=(null==(e=t.value)?void 0:e.length)||0;"multi"===this.$props.mode?this.resizeMultiMode(t):"auto"===this.$props.mode&&this.resizeAutoMode(t,o)},setupResizeObserver(){if("single"===this.$props.mode)return;const e=this.$refs.inputElement;e&&(this.resizeObserver=new ResizeObserver(()=>{this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{"auto"===this.$props.mode&&!this.hasExpanded&&this.captureInitialDimensions(),this.resize()},50)}),this.resizeObserver.observe(e))},cleanupResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=null)},handleChange(e){const t=e.target.value;!this.isControlled&&!this.$props.disabled&&(this.stateValue=t),this.$props.disabled||this.$emit("change",{event:e,value:t}),"single"!==this.$props.mode&&this.resize()},handleFocus(e){this.$props.disabled||this.$emit("focus",{event:e})},handleBlur(e){this.$props.disabled||this.$emit("blur",{event:e})},handleButtonMouseDown(e){e.preventDefault()},handleActionButtonClick(e){this.$emit("promptaction",{event:e,value:this.currentValue,attachments:this.currentFiles}),this.isControlled||(this.stateValue=""),this.isFilesControlled||(this.stateFiles=[])},handleKeyDown(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(),this.$props.loading)return;this.canSendMessage&&this.handleActionButtonClick(e)}}},handleSpeechResult(e){var t;const{isFinal:o,alternatives:n}=e;if(n.length>0){const e=n[0];if(o){const t=this.$refs.inputElement,o=(null==t?void 0:t.value)||"",n=(o?`${o} `:"")+e.transcript;if(this.isControlled||(this.stateValue=n),!this.$props.disabled){const e={target:t,currentTarget:t};this.$emit("change",{event:e,value:n})}}}null==(t=this.$refs.inputElement)||t.focus()},handleUploadButtonClick(){const e=this._uploadRef.value;if(null!=e&&e.$el){const t=e.$el.querySelector('input[type="file"]');t&&t.click()}},onFilesSelect(e){var t;const o=Array.from(e.affectedFiles),n=this.$props.uploadButtonConfig,i="object"==typeof n&&n,s=i?i.onSelectAttachments:void 0;this.isFilesControlled||(this.stateFiles=[...this.stateFiles,...o]),s&&s({selectedFiles:e.affectedFiles,allFiles:e.newState}),null==(t=this.$refs.inputElement)||t.focus()},handleRemoveFile(e){this.isFilesControlled||(this.stateFiles=this.stateFiles.filter(t=>t.name!==e));const t=this.$props.uploadButtonConfig,o="object"==typeof t&&t,n=o?o.onRemoveAttachment:void 0;n&&(this.onRemoveAttachmentCallback=n),this.onRemoveAttachmentCallback&&this.onRemoveAttachmentCallback(e)},renderAffix:(e,t)=>e?"function"==typeof e?e(t):e:null},render(){const e=r.provideLocalizationService(this),{mode:n,fillMode:s,maxTextAreaHeight:l,disabled:a,readOnly:u,placeholder:d,title:c,maxLength:p,inputAttributes:h,topAffix:g,startAffix:f,endAffix:v,header:k,loading:b,speechToTextButtonConfig:V,actionButtonConfig:x,uploadButtonConfig:y}=this.$props,A={uploadButtonProps:{fillMode:"flat",svgIcon:i.paperclipOutlineAltRightIcon,size:"small",rounded:"full",onClick:this.handleUploadButtonClick,onFilesAdd:this.onFilesSelect,files:this.currentFiles,_uploadRef:this._uploadRef,"aria-label":e.toLanguageString(w,F[w]),title:e.toLanguageString(w,F[w]),_registerRemoveCallback:e=>{this.onRemoveAttachmentCallback=e||null}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:this.handleSpeechResult},actionButtonProps:{rounded:"full",size:"small",svgIcon:b?i.stopSmIcon:i.arrowUpOutlineIcon,class:b?"k-generating":"",onClick:this.handleActionButtonClick,onMousedown:this.handleButtonMouseDown,disabled:!b&&!this.canSendMessage,"aria-disabled":!b&&!this.canSendMessage,"aria-label":b?e.toLanguageString(R,F[R]):e.toLanguageString(N,F[N]),title:b?e.toLanguageString(R,F[R]):e.toLanguageString(N,F[N]),"aria-live":"polite"}},C=()=>{const e=!1!==V,o=!1!==x,n=!1!==y,i="object"==typeof V?V:void 0,s="object"==typeof y?y:{},{restrictions:l,multiple:r=!0,accept:a,onSelectAttachments:u,onRemoveAttachment:d,...c}=s,p={restrictions:l,multiple:r,accept:a},h="object"==typeof x?x:void 0;return t.createVNode(t.Fragment,null,[n&&t.createVNode(j,t.mergeProps({ref:"uploadButton"},A.uploadButtonProps,{restrictions:p.restrictions,multiple:p.multiple,accept:p.accept},c),null),e&&t.createVNode(E,t.mergeProps(A.speechToTextButtonProps,i),null),o&&t.createVNode(M,t.mergeProps(A.actionButtonProps,h),null)])},S={disabled:a,readOnly:u,placeholder:d,title:c,maxLength:p,"aria-label":e.toLanguageString(I,F[I]),value:this.currentValue,onKeydown:this.handleKeyDown,...h,onInput:this.handleChange,onFocus:this.handleFocus,onBlur:this.handleBlur,ref:"inputElement"};return t.createVNode("div",{"aria-label":e.toLanguageString(P,F[P]),class:o.classNames("k-input",q,{[`k-input-${s}`]:s,"k-disabled":a,"k-prompt-box-singleline":"single"===n,"k-prompt-box-multiline":this.isMultilineLayout})},[t.createVNode(D,{files:this.currentFiles,onRemoveFile:this.handleRemoveFile,header:o.templateRendering.call(this,k,o.getListeners.call(this))},null),"single"===n?(()=>t.createVNode("div",{class:`${q}-content`},[f&&t.createVNode("div",{class:`${q}-affix`},[this.renderAffix(f,A)]),t.createVNode("input",t.mergeProps(S,{class:o.classNames("k-input-inner",`${q}-input`)}),null),this.hasEndAffixOrButtons?t.createVNode("div",{class:`${q}-affix`},[v&&this.renderAffix(v,A),C()]):null]))():(()=>t.createVNode("div",{class:`${q}-content`},["multi"===n&&g&&t.createVNode("div",{class:`${q}-affix`},[this.renderAffix(g,A)]),"auto"===n&&f&&t.createVNode("div",{class:`${q}-affix`,style:{display:this.hasExpanded?"none":void 0}},[this.renderAffix(f,A)]),t.createVNode("textarea",t.mergeProps(S,{class:o.classNames("k-input-inner",`${q}-textarea`),rows:this.effectiveRows,style:l?{maxHeight:l}:{}},this.isMultilineLayout&&{"aria-multiline":"true"}),null),"auto"===n&&this.hasEndAffixOrButtons?t.createVNode("div",{class:`${q}-affix`,style:{display:this.hasExpanded?"none":void 0}},[v&&this.renderAffix(v,A),C()]):null,this.hasStartAffixOrEndAffixOrButtons?t.createVNode("div",{class:`${q}-affix`,style:{display:this.isMultilineLayout?void 0:"none"}},[f&&this.renderAffix(f,A),(f||v)&&t.createVNode("div",{class:"k-spacer"},null),v&&this.renderAffix(v,A),C()]):null]))(),o.shouldShowValidationUI(m)&&t.createVNode(o.WatermarkOverlay,{message:o.getLicenseMessage(m)},null)])}});e.AIPrompt=g,e.AIPromptCommandsView=L,e.AIPromptContent=v,e.AIPromptFooter=f,e.AIPromptHeader=d,e.AIPromptOutputRating=O,e.AIPromptOutputView=z,e.AIPromptView=A,e.AIPromptViewRender=k,e.PromptBox=U,e.PromptBoxActionButton=M,e.PromptBoxSpeechToTextButton=E,e.PromptBoxUploadButton=j,e.SuggestionGroup=x,e.commandsViewDefaults=p,e.outputViewDefaults=c,e.promptViewDefaults=h});
15
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue"),require("@progress/kendo-vue-common"),require("@progress/kendo-vue-buttons"),require("@progress/kendo-svg-icons"),require("@progress/kendo-vue-inputs"),require("@progress/kendo-vue-layout"),require("@progress/kendo-vue-intl"),require("@progress/kendo-vue-upload")):"function"==typeof define&&define.amd?define(["exports","vue","@progress/kendo-vue-common","@progress/kendo-vue-buttons","@progress/kendo-svg-icons","@progress/kendo-vue-inputs","@progress/kendo-vue-layout","@progress/kendo-vue-intl","@progress/kendo-vue-upload"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoVueConversationalUi={},e.Vue,e.KendoVueCommon,e.KendoVueButtons,e.KendoSVGIcons,e.KendoVueInputs,e.KendoVueLayout,e.KendoVueIntl,e.KendoVueUpload)}(this,function(e,t,o,n,i,s,l,r,a){"use strict";function u(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const d=t.defineComponent({name:"KendoAIPromptHeader",props:{activeView:String,toolbarItems:Array,onActiveviewchange:Function},methods:{handleClick(e){this.$emit("activeviewchange",e)}},render(){let e;const{activeView:i,toolbarItems:s}=this.$props;return t.createVNode("div",{class:"k-prompt-header"},[t.createVNode(n.Toolbar,{overflow:"none",keyboardNavigation:!1,class:"k-toolbar-flat"},u(e=s.map(function(e){const s=o.getTemplate.call(this,{h:t.h,template:e.content,defaultRendering:null,additionalProps:{item:e}});return e.content?s:t.createVNode(n.Button,{type:"button",key:e.name,class:o.classNames("k-toolbar-item",{"k-selected":i===e.name}),size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>this.handleClick(e.name)},{default:()=>[e.buttonText]})},this))?e:{default:()=>[e]})])}}),c={name:"Output view",buttonText:"Output",buttonIcon:i.commentIcon},p={name:"Commands view",buttonIcon:i.moreHorizontalIcon},h={name:"Prompt view",buttonText:"Ask AI",buttonIcon:i.sparklesIcon},m={name:"@progress/kendo-vue-conversational-ui",productName:"Kendo UI for Vue",productCode:"KENDOUIVUE",productCodes:["KENDOUIVUE"],publishDate:0,version:"8.4.0-develop.3",licensingDocsUrl:"https://www.telerik.com/kendo-vue-ui/my-license/"},g=t.defineComponent({name:"KendoAIPrompt",props:{activeView:{type:String,required:!0},dir:String,toolbarItems:Array,outputs:Array,promptPlaceholder:String,streaming:Boolean,loading:Boolean,suggestionsView:{type:String,default:"classic"}},provide(){return{kendoAIPrompt:this.$data.contextState}},data(){return{showLicenseWatermark:!1,licenseMessage:"",contextState:{activeView:this.$props.activeView,streaming:this.$props.streaming,loading:this.$props.loading,onCancel:this.onCancel,onActiveViewChange:this.onActiveViewChange,onPromptRequest:this.onPromptRequest,onCommandExecute:this.onCommandExecute,onStateAction:this.onStateAction,suggestionsView:this.$props.suggestionsView}}},watch:{activeView(e){this.contextState.activeView=e},streaming(e){this.contextState.streaming=e},loading(e){this.contextState.loading=e}},methods:{onStateAction(e){this.contextState.activeView=e.activeView},onActiveViewChange(e){this.$emit("activeviewchange",e)},onPromptRequest(e,t){this.$emit("promptrequest",e,t)},onCommandExecute(e){this.$emit("commandexecute",e)},onCancel(){this.$emit("cancel")}},render(){o.validatePackage(m),this.showLicenseWatermark=o.shouldShowValidationUI(m),this.licenseMessage=o.getLicenseMessage(m);const e=o.getDefaultSlots(this),{toolbarItems:n,dir:i}=this.$props,s=(n||[h,c]).map(e=>{const t=o.templateRendering.call(this,e.content,o.getListeners.call(this));return{...e,content:t}}),l=this.showLicenseWatermark?t.createVNode(o.WatermarkOverlay,{message:this.licenseMessage},null):null;return t.createVNode("div",{class:"k-prompt",dir:i},[t.createVNode(d,{activeView:this.contextState.activeView,toolbarItems:s,onActiveviewchange:this.onActiveViewChange},null),e,l])}}),f=t.defineComponent({name:"KendoAIPromptFooter",render(){const e=o.getDefaultSlots(this);return t.createVNode("div",{class:"k-prompt-footer"},[t.createVNode("div",{class:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},[e])])}}),v=t.defineComponent({name:"KendoAIPromptContent",props:{onCancel:Function,streaming:Boolean},inject:{kendoAIPrompt:{default:null}},computed:{showFloatingButton(){var e;const t=(null==(e=this.kendoAIPrompt)?void 0:e.activeView)===c.name;return this.streaming&&t}},methods:{handleKeyDown(e){"Escape"===e.key&&this.showFloatingButton&&this.onCancel&&(e.preventDefault(),this.$props.onCancel())}},render(){const e=o.getDefaultSlots(this);return t.createVNode("div",{class:"k-prompt-content",onKeydown:this.handleKeyDown},[this.showFloatingButton&&t.createVNode(n.FloatingActionButton,{onClick:this.onCancel,svgIcon:i.stopSmIcon,size:"small",positionMode:"absolute",class:"k-prompt-stop-fab k-generating"},null),t.createVNode("div",{class:"k-prompt-view"},[e])])}}),k=t.defineComponent({name:"KendoAIPromptViewRender",inheritAttrs:!1,props:{name:String},inject:{kendoAIPrompt:{default:null}},render(){const e=o.getDefaultSlots(this);return this.kendoAIPrompt.activeView===this.$props.name?e:null}});function b(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const V=t.defineComponent({name:"KendoAIPromptExpander",props:{title:String},data:()=>({expanded:!0}),methods:{buttonClick(){this.expanded=!this.expanded}},render(){const e=o.getDefaultSlots(this),{title:s}=this.$props;return t.createVNode("div",{class:"k-prompt-expander"},[t.createVNode(n.Button,{type:"button",fillMode:"flat",svgIcon:this.expanded?i.chevronUpIcon:i.chevronDownIcon,title:s,onClick:this.buttonClick},b(s)?s:{default:()=>[s]}),this.expanded&&t.createVNode("div",{class:"k-prompt-expander-content"},[e])])}}),x=t.defineComponent({name:"KendoSuggestionGroup",props:{suggestions:{type:Array,required:!0},onSuggestionClick:{type:Function,required:!0},suggestionsView:{type:String,default:"classic"}},methods:{handleSuggestionClick(e,t){t.disabled||this.onSuggestionClick(e,t)},handleKeyDown(e,t){("Enter"===e.key||" "===e.key)&&(e.preventDefault(),this.onSuggestionClick(e,t))}},render(){const{suggestions:e,suggestionsView:n}=this.$props,i=()=>e.map(e=>t.createVNode("span",{role:"button",tabindex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:t=>!e.disabled&&this.handleSuggestionClick(t,e),onKeydown:t=>!e.disabled&&this.handleKeyDown(t,e),key:e.id,title:e.description,class:o.classNames("classic"===n?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},[e.text]));return"classic"===n?i():t.createVNode("div",{role:"group",class:"k-suggestion-group"},[i()])}});function y(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const A=t.defineComponent({name:"KendoAIPromptView",props:{promptInput:[Object,String],generateButton:[Object,String],promptValue:String,promptSuggestions:Array,enableSpeechToText:[Boolean,Object]},inject:{kendoAIPrompt:{default:null}},computed:{computedValue(){return void 0!==this.$props.promptValue?this.$props.promptValue:this.value}},data:()=>({value:""}),methods:{handleOnRequest(){this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,this.computedValue),this.value=""},handleSuggestionSelect(e){this.value=e},onTextChange(e){this.value=e.value},onSpeechResult(e){if(e.isFinal&&e.alternatives.length>0){const t=e.alternatives[0].transcript,o=this.value,n=o&&!o.endsWith(" ")&&!o.endsWith("\n");this.value=o+(n?" ":"")+t}},onSpeechStart(){},onSpeechEnd(){},getButtonDisabledState(){const e=void 0!==this.$props.promptValue?this.$props.promptValue:this.value;return!(null!=e&&e.trim())}},render(){const e="Generate",{promptSuggestions:l,enableSpeechToText:r}=this.$props,a=o.templateRendering.call(this,this.$props.promptInput,o.getListeners.call(this)),u=t.createVNode(s.TextArea,{value:this.computedValue,onInput:this.onTextChange,placeholder:"Ask or generate content with AI ...",rows:2,class:"!k-flex-col",inputSuffix:()=>r?t.createVNode(t.Fragment,null,[t.createVNode(s.InputSeparator,{orientation:"horizontal"},null),t.createVNode("div",{class:"k-input-suffix k-input-suffix-horizontal"},[t.createVNode(n.SpeechToTextButton,t.mergeProps({fillMode:"flat",onStart:this.onSpeechStart,onEnd:this.onSpeechEnd,onResult:this.onSpeechResult},"object"==typeof r?r:{}),null)])]):null},null),d=o.getTemplate.call(this,{h:t.h,template:a,defaultRendering:u}),c=o.templateRendering.call(this,this.$props.generateButton,o.getListeners.call(this)),p=t.createVNode(n.Button,{type:"button",themeColor:"primary",fillMode:"solid","aria-hidden":"true",rounded:"full",size:"medium",onClick:this.handleOnRequest,disabled:this.getButtonDisabledState(),title:"Generate",svgIcon:i.sparklesIcon},y(e)?e:{default:()=>[e]}),m=o.getTemplate.call(this,{h:t.h,template:c,defaultRendering:p});return t.createVNode(k,{name:h.name},{default:()=>{var e,o;return[t.createVNode(v,{streaming:null==(e=this.kendoAIPrompt)?void 0:e.streaming,onCancel:null==(o=this.kendoAIPrompt)?void 0:o.onCancel},{default:()=>[d,l&&l.length>0&&t.createVNode(V,{title:"Prompt Suggestions"},{default:()=>{var e;return[t.createVNode(x,{suggestionsView:null==(e=this.kendoAIPrompt)?void 0:e.suggestionsView,suggestions:l.map((e,t)=>({id:t,text:e,description:e})),onSuggestionClick:(e,t)=>this.handleSuggestionSelect(t.text)},null)]}})]}),t.createVNode(f,null,y(m)?m:{default:()=>[m]})]}})}}),C="avatar.alt",S="messageList.ariaLabel",$="aIPrompt.noOutputs",I="promptBox.input",N="promptBox.sendButton",w="promptBox.attachFile",B="promptBox.removeFile",R="promptBox.stopGenerating",P="promptBox.ariaLabel",F={[C]:"Avatar",[S]:"Message list",[$]:"No output from Ai available",[I]:"Prompt",[N]:"Send",[w]:"Attach file",[B]:"Remove file",[R]:"Stop generating",[P]:"Prompt box"};function T(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}let O=function(e){return e.positive="positive",e.negative="negative",e}({});const z=t.defineComponent({name:"KendoAIPromptOutputView",emits:{copy:null,retry:null,rating:null},props:{outputs:Array,outputCard:Object,showOutputRating:Boolean},inject:{kendoAIPrompt:{default:null},kendoLocalizationService:{default:null}},data:()=>({copiedIndex:-1,copyButtonIcon:i.copyIcon,contentRef:null}),methods:{retryPrompt(e){this.$emit("retry",e),this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),this.scrollToTopOutput()},copyToClipboard(e,t){null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),this.copiedIndex=t,this.copyButtonIcon=i.checkIcon,this.$emit("copy",null==e?void 0:e.responseContent),setTimeout(()=>{this.copyButtonIcon=i.copyIcon,this.copiedIndex=-1},1e3)},outputRating(e,t){this.$emit("rating",e,t),this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),this.scrollToTopOutput()},scrollToTopOutput(){var e,t;null==(t=null==(e=this.contentRef)?void 0:e.scrollTo)||t.call(e,{top:0,behavior:"smooth"})}},render(){let e;const{outputs:o,showOutputRating:s,outputCard:a}=this.$props,u=r.provideLocalizationService(this),{header:d,body:p,actions:h}=a||{},m=t.createVNode(l.Card,null,{default:()=>[t.createVNode(l.CardHeader,null,{default:()=>[t.createVNode(l.CardTitle,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}},null)]}),t.createVNode(l.CardSubtitle,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}},null)]})]}),t.createVNode(l.CardBody,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}},null)]}),t.createVNode(l.CardActions,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}},null)]})]}),g=null==o?void 0:o.map((e,o)=>t.createVNode(l.Card,{key:`${e.id}_${o}`,class:e.class},{default:()=>[t.createVNode(l.CardHeader,null,{default:()=>[d?d(e):t.createVNode(t.Fragment,null,[e.title&&t.createVNode(l.CardTitle,null,{default:()=>[e.title]}),e.subTitle&&t.createVNode(l.CardSubtitle,null,{default:()=>[e.subTitle]})])]}),t.createVNode(l.CardBody,null,{default:()=>[p?p(e):e.responseContent]}),t.createVNode(l.CardActions,null,{default:()=>[h?h(e):t.createVNode(t.Fragment,null,[t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:this.copiedIndex===o?this.copyButtonIcon:i.copyIcon,"aria-hidden":"true",onClick:()=>this.copyToClipboard(e,o)},{default:()=>["Copy"]}),t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:i.arrowRotateCwIcon,"aria-hidden":"true",onClick:()=>this.retryPrompt(e)},{default:()=>["Retry"]}),s&&t.createVNode(t.Fragment,null,[t.createVNode("span",{class:"k-spacer"},null),t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:i.thumbUpOutlineIcon,"aria-hidden":"true",onClick:()=>this.outputRating(e,"positive")},null),t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:i.thumbDownOutlineIcon,"aria-hidden":"true",onClick:()=>this.outputRating(e,"negative")},null)])])]})]})),f=t.createVNode(l.Card,null,{default:()=>[t.createVNode(l.CardBody,null,T(e=u.toLanguageString($,F[$]))?e:{default:()=>[e]})]});return t.createVNode(k,{name:c.name},{default:()=>{var e,o;return[t.createVNode(v,{ref:e=>this.contentRef=e,streaming:null==(e=this.kendoAIPrompt)?void 0:e.streaming,onCancel:null==(o=this.kendoAIPrompt)?void 0:o.onCancel},{default:()=>{var e,o;return[t.createVNode("div",{class:"k-card-list"},[(null==(e=this.kendoAIPrompt)?void 0:e.loading)&&m,g,(!g||0===g.length)&&!(null!=(o=this.kendoAIPrompt)&&o.loading)&&f])]}})]}})}}),L=t.defineComponent({name:"KendoAIPromptCommandsView",props:{commands:Array},inject:{kendoAIPrompt:{default:null}},render(){const{commands:e}=this.$props,o=e=>{var t;const o=e.target;(null==(t=o.items)||!t.length)&&this.kendoAIPrompt.onCommandExecute&&(this.$emit("commandexecute",o),this.kendoAIPrompt.onCommandExecute.call(null,o))};return t.createVNode(k,{name:p.name},{default:()=>{var n,i;return[t.createVNode(v,{streaming:null==(n=this.kendoAIPrompt)?void 0:n.streaming,onCancel:null==(i=this.kendoAIPrompt)?void 0:i.onCancel},{default:()=>[t.createVNode("div",{class:"k-prompt-view"},[t.createVNode(l.PanelBar,{onSelect:o,items:e},null)])]})]}})}}),M=t.defineComponent({name:"KendoPromptBoxActionButton",inheritAttrs:!1,render(){return t.createVNode(n.Button,this.$attrs,null)}}),E=t.defineComponent({name:"KendoPromptBoxSpeechToTextButton",inheritAttrs:!1,render(){return t.createVNode(n.SpeechToTextButton,this.$attrs,null)}}),j=t.defineComponent({name:"KendoPromptBoxUploadButton",inheritAttrs:!1,props:{onFilesAdd:Function,files:{type:Array,default:()=>[]},restrictions:Object,multiple:{type:Boolean,default:!0},accept:String,onSelectAttachments:Function,onRemoveAttachment:Function,_registerRemoveCallback:Function},setup(e){const o=t.ref(null);return t.watch(()=>e.onRemoveAttachment,t=>{e._registerRemoveCallback&&t&&e._registerRemoveCallback(t)},{immediate:!0}),t.onUnmounted(()=>{e._registerRemoveCallback&&e.onRemoveAttachment&&e._registerRemoveCallback(void 0)}),{uploadRef:o,handleFilesAdd:t=>{e.onFilesAdd&&e.onFilesAdd(t),e.onSelectAttachments&&e.onSelectAttachments({selectedFiles:t.affectedFiles,allFiles:t.newState})}}},render(){const{onFilesAdd:e,files:o,restrictions:i,multiple:s,accept:l,onSelectAttachments:r,onRemoveAttachment:u,_registerRemoveCallback:d,_uploadRef:c,...p}=this.$attrs;return t.createVNode(t.Fragment,null,[t.createVNode(n.Button,p,null),t.createVNode(a.Upload,{ref:e=>{this.uploadRef=e,c&&(c.value=e)},files:this.files,onAdd:this.handleFilesAdd,autoUpload:!1,restrictions:this.restrictions,multiple:this.multiple,accept:this.accept,class:"k-hidden"},null)])}}),H=e=>"."+(e.split(".").pop()||""),K=e=>{if(null==e)return"";if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${Number.parseFloat((e/Math.pow(1024,t)).toFixed(2))} ${["B","KB","MB","GB","TB"][t]}`},D=t.defineComponent({name:"KendoFileBox",props:{files:{type:Array,required:!0},onRemoveFile:{type:Function,required:!0},header:{type:[Object,Function,String],default:void 0}},inject:{kendoLocalizationService:{default:null}},data:()=>({canScrollRight:!1,canScrollLeft:!1,resizeObserver:null}),watch:{files:{handler(){t.nextTick(()=>{this.setupScrollListeners(),this.updateScrollState()})},deep:!0}},mounted(){t.nextTick(()=>{this.setupScrollListeners(),this.updateScrollState()})},beforeUnmount(){this.cleanupScrollListeners()},methods:{setupScrollListeners(){const e=this.$refs.scrollContainer;e?this._scrollContainer!==e&&(this.cleanupScrollListeners(),e.addEventListener("scroll",this.updateScrollState,{passive:!0}),this.resizeObserver=new ResizeObserver(()=>this.updateScrollState()),this.resizeObserver.observe(e),this._scrollContainer=e):this.cleanupScrollListeners()},cleanupScrollListeners(){this._scrollContainer&&(this._scrollContainer.removeEventListener("scroll",this.updateScrollState),this._scrollContainer=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)},updateScrollState(){const e=this.$refs.scrollContainer;if(!e)return;const{scrollLeft:t,scrollWidth:o,clientWidth:n}=e,i=0===t,s=t+n>=o-1;this.canScrollLeft=!i,this.canScrollRight=!s},handleRemoveFile(e,t){t.stopPropagation(),this.$props.onRemoveFile&&this.$props.onRemoveFile(e)}},render(){const e=r.provideLocalizationService(this),{files:s,header:l}=this.$props;if(0===s.length&&!l)return null;const a=o.getTemplate.call(this,{h:t.h,template:l,defaultRendering:null}),u=e.toLanguageString(B,F[B]),d=s.length>0&&t.createVNode("ul",{class:o.classNames("k-file-box-wrapper",{"k-file-box-wrapper-scrollable-start":this.canScrollRight,"k-file-box-wrapper-scrollable-end":this.canScrollLeft})},[t.createVNode("div",{class:"k-files-scroll",ref:"scrollContainer"},[s.map(e=>t.createVNode("li",{key:e.name,class:"k-file-box"},[t.createVNode(o.Icon,t.mergeProps({size:"xlarge"},o.getFileExtensionIcon(H(e.name))),null),t.createVNode("div",{class:"k-file-info"},[t.createVNode("span",{class:"k-file-name"},[e.name]),t.createVNode("span",{class:"k-file-size"},[K(e.size)])]),t.createVNode(n.Button,{fillMode:"flat",svgIcon:i.xMarkSmOutlineIcon,onClick:t=>this.handleRemoveFile(e.name,t),"aria-label":`${u} ${e.name}`,title:`${u} ${e.name}`},null)]))])]);return t.createVNode("div",{class:"k-prompt-box-header"},[a,d])}}),q="k-prompt-box",U=t.defineComponent({name:"KendoPromptBox",emits:{change:e=>!0,focus:e=>!0,blur:e=>!0,promptaction:e=>!0},props:{value:String,defaultValue:{type:String,default:""},mode:{type:String,default:"auto"},rows:{type:Number,default:1},maxTextAreaHeight:String,title:String,disabled:{type:Boolean,default:!1},readOnly:{type:Boolean,default:!1},placeholder:String,maxLength:Number,inputAttributes:Object,fillMode:String,topAffix:[Object,Function,String],startAffix:[Object,Function,String],endAffix:[Object,Function,String],header:[Object,Function,String],loading:{type:Boolean,default:!1},uploadButtonConfig:{type:[Boolean,Object],default:!1},speechToTextButtonConfig:{type:[Boolean,Object],default:!0},actionButtonConfig:{type:[Boolean,Object],default:!0},attachments:Array},inject:{kendoLocalizationService:{default:null}},created(){o.validatePackage(m),this._uploadRef=t.ref(null)},data(){return{stateValue:this.$props.defaultValue||"",stateFiles:[],hasExpanded:!1,initialHeight:0,minMultiRowHeight:0,isResizing:!1,previousValueLength:0,singleLineWidth:0,resizeObserver:null,resizeTimeout:null,onRemoveAttachmentCallback:null}},computed:{isControlled(){return void 0!==this.$props.value},currentValue(){return this.isControlled?this.$props.value||"":this.stateValue},isFilesControlled(){return void 0!==this.$props.attachments},currentFiles(){return this.isFilesControlled?this.$props.attachments||[]:this.stateFiles},canSendMessage(){var e;return!!(null!=(e=this.currentValue)&&e.trim()||this.currentFiles.length>0)},isMultilineLayout(){return"multi"===this.$props.mode||"auto"===this.$props.mode&&this.hasExpanded},hasBuiltInButtons(){return!1!==this.$props.uploadButtonConfig||!1!==this.$props.speechToTextButtonConfig||!1!==this.$props.actionButtonConfig},hasEndAffixOrButtons(){return!!this.$props.endAffix||this.hasBuiltInButtons},hasStartAffixOrEndAffixOrButtons(){return!!this.$props.startAffix||!!this.$props.endAffix||this.hasBuiltInButtons},effectiveRows(){return"auto"===this.$props.mode?1:this.$props.rows}},watch:{currentValue(e){if("single"===this.$props.mode)return;const t=(null==e?void 0:e.length)||0;requestAnimationFrame(()=>{const e=this.$refs.inputElement;e&&("multi"===this.$props.mode?this.resizeMultiMode(e):"auto"===this.$props.mode&&this.resizeAutoMode(e,t),this.previousValueLength=t)})},rows(){"single"!==this.$props.mode&&(this.captureInitialDimensions(),this.resize())},maxTextAreaHeight(){"single"!==this.$props.mode&&this.resize()},mode(){"single"!==this.$props.mode&&t.nextTick(()=>{this.captureInitialDimensions(),this.resize()})},hasExpanded(e){if("auto"===this.$props.mode&&e&&requestAnimationFrame(()=>{const e=this.$refs.inputElement;e&&(this.updateHeight(e),this.isResizing=!1)}),"auto"===this.$props.mode&&!e){const e=this.$refs.inputElement;e&&(e.style.height="",e.style.overflow="",this.isResizing=!1)}}},mounted(){"single"!==this.$props.mode&&this.captureInitialDimensions(),this.setupResizeObserver()},beforeUnmount(){this.cleanupResizeObserver()},methods:{captureInitialDimensions(){const e=this.$refs.inputElement;if(!e||"single"===this.$props.mode)return;const t=globalThis.getComputedStyle(e),o=Number.parseFloat(t.lineHeight)||20,n=Number.parseFloat(t.paddingTop)||0,i=Number.parseFloat(t.paddingBottom)||0;this.initialHeight=e.offsetHeight||o+n+i,this.minMultiRowHeight=o*this.$props.rows+n+i,"auto"===this.$props.mode&&!this.hasExpanded&&(this.singleLineWidth=e.offsetWidth)},calculateHeight(e){if(this.$props.maxTextAreaHeight){const t=Number.parseInt(this.$props.maxTextAreaHeight,10);if(e>t)return t}return Math.max(this.minMultiRowHeight,e)},resizeMultiMode(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,o=this.calculateHeight(t);e.style.height=`${o}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},updateHeight(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,o=this.$props.maxTextAreaHeight?Math.min(t,Number.parseInt(this.$props.maxTextAreaHeight,10)):t;e.style.height=`${o}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},shouldCollapse(e){if(this.singleLineWidth<=0)return!1;const t=e.style.height,o=e.style.width;e.style.overflow="hidden",e.style.width=`${this.singleLineWidth}px`,e.style.height=`${this.initialHeight}px`;const n=e.scrollWidth<=this.singleLineWidth&&e.scrollHeight<=this.initialHeight;return e.style.overflow="",e.style.width=o||"",e.style.height=t||"",n},resizeAutoMode(e,t){if(!this.isResizing){if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!this.hasExpanded)return this.isResizing=!0,void(this.hasExpanded=!0);if(this.hasExpanded){this.updateHeight(e);t<this.previousValueLength&&this.shouldCollapse(e)&&(e.style.height="",this.isResizing=!0,this.hasExpanded=!1)}}},resize(){var e;if("single"===this.$props.mode)return;const t=this.$refs.inputElement;if(!t)return;const o=(null==(e=t.value)?void 0:e.length)||0;"multi"===this.$props.mode?this.resizeMultiMode(t):"auto"===this.$props.mode&&this.resizeAutoMode(t,o)},setupResizeObserver(){if("single"===this.$props.mode)return;const e=this.$refs.inputElement;e&&(this.resizeObserver=new ResizeObserver(()=>{this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{"auto"===this.$props.mode&&!this.hasExpanded&&this.captureInitialDimensions(),this.resize()},50)}),this.resizeObserver.observe(e))},cleanupResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=null)},handleChange(e){const t=e.target.value;!this.isControlled&&!this.$props.disabled&&(this.stateValue=t),this.$props.disabled||this.$emit("change",{event:e,value:t}),"single"!==this.$props.mode&&this.resize()},handleFocus(e){this.$props.disabled||this.$emit("focus",{event:e})},handleBlur(e){this.$props.disabled||this.$emit("blur",{event:e})},handleButtonMouseDown(e){e.preventDefault()},handleActionButtonClick(e){this.$emit("promptaction",{event:e,value:this.currentValue,attachments:this.currentFiles}),this.isControlled||(this.stateValue=""),this.isFilesControlled||(this.stateFiles=[])},handleKeyDown(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(),this.$props.loading)return;this.canSendMessage&&this.handleActionButtonClick(e)}}},handleSpeechResult(e){var t;const{isFinal:o,alternatives:n}=e;if(n.length>0){const e=n[0];if(o){const t=this.$refs.inputElement,o=(null==t?void 0:t.value)||"",n=(o?`${o} `:"")+e.transcript;if(this.isControlled||(this.stateValue=n),!this.$props.disabled){const e={target:t,currentTarget:t};this.$emit("change",{event:e,value:n})}}}null==(t=this.$refs.inputElement)||t.focus()},handleUploadButtonClick(){const e=this._uploadRef.value;if(null!=e&&e.$el){const t=e.$el.querySelector('input[type="file"]');t&&t.click()}},onFilesSelect(e){var t;const o=Array.from(e.affectedFiles),n=this.$props.uploadButtonConfig,i="object"==typeof n&&n,s=i?i.onSelectAttachments:void 0;this.isFilesControlled||(this.stateFiles=[...this.stateFiles,...o]),s&&s({selectedFiles:e.affectedFiles,allFiles:e.newState}),null==(t=this.$refs.inputElement)||t.focus()},handleRemoveFile(e){this.isFilesControlled||(this.stateFiles=this.stateFiles.filter(t=>t.name!==e));const t=this.$props.uploadButtonConfig,o="object"==typeof t&&t,n=o?o.onRemoveAttachment:void 0;n&&(this.onRemoveAttachmentCallback=n),this.onRemoveAttachmentCallback&&this.onRemoveAttachmentCallback(e)},renderAffix:(e,t)=>e?"function"==typeof e?e(t):e:null},render(){const e=r.provideLocalizationService(this),{mode:n,fillMode:s,maxTextAreaHeight:l,disabled:a,readOnly:u,placeholder:d,title:c,maxLength:p,inputAttributes:h,topAffix:g,startAffix:f,endAffix:v,header:k,loading:b,speechToTextButtonConfig:V,actionButtonConfig:x,uploadButtonConfig:y}=this.$props,A={uploadButtonProps:{fillMode:"flat",svgIcon:i.paperclipOutlineAltRightIcon,size:"small",rounded:"full",onClick:this.handleUploadButtonClick,onFilesAdd:this.onFilesSelect,files:this.currentFiles,_uploadRef:this._uploadRef,"aria-label":e.toLanguageString(w,F[w]),title:e.toLanguageString(w,F[w]),_registerRemoveCallback:e=>{this.onRemoveAttachmentCallback=e||null}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:this.handleSpeechResult},actionButtonProps:{rounded:"full",size:"small",svgIcon:b?i.stopIcon:i.arrowUpIcon,class:b?"k-generating k-active":"",onClick:this.handleActionButtonClick,onMousedown:this.handleButtonMouseDown,disabled:!b&&!this.canSendMessage,"aria-disabled":!b&&!this.canSendMessage||void 0,"aria-label":b?e.toLanguageString(R,F[R]):e.toLanguageString(N,F[N]),title:b?e.toLanguageString(R,F[R]):e.toLanguageString(N,F[N]),"aria-live":"polite"}},C=()=>{const e=!1!==V,o=!1!==x,n=!1!==y,i="object"==typeof V?V:void 0,s="object"==typeof y?y:{},{restrictions:l,multiple:r=!0,accept:a,onSelectAttachments:u,onRemoveAttachment:d,...c}=s,p={restrictions:l,multiple:r,accept:a},h="object"==typeof x?x:void 0;return t.createVNode(t.Fragment,null,[n&&t.createVNode(j,t.mergeProps({ref:"uploadButton"},A.uploadButtonProps,{restrictions:p.restrictions,multiple:p.multiple,accept:p.accept},c),null),e&&t.createVNode(E,t.mergeProps(A.speechToTextButtonProps,i),null),o&&t.createVNode(M,t.mergeProps(A.actionButtonProps,h),null)])},S={disabled:a,readOnly:u,placeholder:d,title:c,maxLength:p,"aria-label":e.toLanguageString(I,F[I]),value:this.currentValue,onKeydown:this.handleKeyDown,...h,onInput:this.handleChange,onFocus:this.handleFocus,onBlur:this.handleBlur,ref:"inputElement"};return t.createVNode("div",{"aria-label":e.toLanguageString(P,F[P]),class:o.classNames("k-input",q,{[`k-input-${s}`]:s,"k-disabled":a,"k-prompt-box-singleline":"single"===n,"k-prompt-box-multiline":this.isMultilineLayout})},[t.createVNode(D,{files:this.currentFiles,onRemoveFile:this.handleRemoveFile,header:o.templateRendering.call(this,k,o.getListeners.call(this))},null),"single"===n?(()=>t.createVNode("div",{class:`${q}-content`},[f&&t.createVNode("div",{class:`${q}-affix`},[this.renderAffix(f,A)]),t.createVNode("input",t.mergeProps(S,{class:o.classNames("k-input-inner",`${q}-input`)}),null),this.hasEndAffixOrButtons?t.createVNode("div",{class:`${q}-affix`},[v&&this.renderAffix(v,A),C()]):null]))():(()=>t.createVNode("div",{class:`${q}-content`},["multi"===n&&g&&t.createVNode("div",{class:`${q}-affix`},[this.renderAffix(g,A)]),"auto"===n&&f&&t.createVNode("div",{class:`${q}-affix`,style:{display:this.hasExpanded?"none":void 0}},[this.renderAffix(f,A)]),t.createVNode("textarea",t.mergeProps(S,{class:o.classNames("k-input-inner",`${q}-textarea`),rows:this.effectiveRows,style:l?{maxHeight:l}:{}},"single"!==n&&{"aria-multiline":"true"}),null),"auto"===n&&this.hasEndAffixOrButtons?t.createVNode("div",{class:`${q}-affix`,style:{display:this.hasExpanded?"none":void 0}},[v&&this.renderAffix(v,A),C()]):null,this.hasStartAffixOrEndAffixOrButtons?t.createVNode("div",{class:`${q}-affix`,style:{display:this.isMultilineLayout?void 0:"none"}},[f&&this.renderAffix(f,A),(f||v)&&t.createVNode("div",{class:"k-spacer"},null),v&&this.renderAffix(v,A),C()]):null]))(),o.shouldShowValidationUI(m)&&t.createVNode(o.WatermarkOverlay,{message:o.getLicenseMessage(m)},null)])}});e.AIPrompt=g,e.AIPromptCommandsView=L,e.AIPromptContent=v,e.AIPromptFooter=f,e.AIPromptHeader=d,e.AIPromptOutputRating=O,e.AIPromptOutputView=z,e.AIPromptView=A,e.AIPromptViewRender=k,e.PromptBox=U,e.PromptBoxActionButton=M,e.PromptBoxSpeechToTextButton=E,e.PromptBoxUploadButton=j,e.SuggestionGroup=x,e.commandsViewDefaults=p,e.outputViewDefaults=c,e.promptViewDefaults=h});
@@ -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={name:"@progress/kendo-vue-conversational-ui",productName:"Kendo UI for Vue",productCode:"KENDOUIVUE",productCodes:["KENDOUIVUE"],publishDate: 1778509508,version:"8.4.0-develop.1",licensingDocsUrl:"https://www.telerik.com/kendo-vue-ui/my-license/"};exports.packageMetadata=e;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={name:"@progress/kendo-vue-conversational-ui",productName:"Kendo UI for Vue",productCode:"KENDOUIVUE",productCodes:["KENDOUIVUE"],publishDate: 1779097763,version:"8.4.0-develop.3",licensingDocsUrl:"https://www.telerik.com/kendo-vue-ui/my-license/"};exports.packageMetadata=e;
@@ -10,8 +10,8 @@ const e = {
10
10
  productName: "Kendo UI for Vue",
11
11
  productCode: "KENDOUIVUE",
12
12
  productCodes: ["KENDOUIVUE"],
13
- publishDate: 1778509508,
14
- version: "8.4.0-develop.1",
13
+ publishDate: 1779097763,
14
+ version: "8.4.0-develop.3",
15
15
  licensingDocsUrl: "https://www.telerik.com/kendo-vue-ui/my-license/"
16
16
  };
17
17
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progress/kendo-vue-conversational-ui",
3
- "version": "8.4.0-develop.1",
3
+ "version": "8.4.0-develop.3",
4
4
  "description": "TODO",
5
5
  "author": "Progress",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -25,13 +25,13 @@
25
25
  "sideEffects": false,
26
26
  "peerDependencies": {
27
27
  "@progress/kendo-licensing": "^1.7.2",
28
- "@progress/kendo-vue-buttons": "8.4.0-develop.1",
29
- "@progress/kendo-vue-common": "8.4.0-develop.1",
30
- "@progress/kendo-vue-intl": "8.4.0-develop.1",
31
- "@progress/kendo-vue-inputs": "8.4.0-develop.1",
32
- "@progress/kendo-vue-layout": "8.4.0-develop.1",
33
- "@progress/kendo-vue-popup": "8.4.0-develop.1",
34
- "@progress/kendo-vue-upload": "8.4.0-develop.1",
28
+ "@progress/kendo-vue-buttons": "8.4.0-develop.3",
29
+ "@progress/kendo-vue-common": "8.4.0-develop.3",
30
+ "@progress/kendo-vue-intl": "8.4.0-develop.3",
31
+ "@progress/kendo-vue-inputs": "8.4.0-develop.3",
32
+ "@progress/kendo-vue-layout": "8.4.0-develop.3",
33
+ "@progress/kendo-vue-popup": "8.4.0-develop.3",
34
+ "@progress/kendo-vue-upload": "8.4.0-develop.3",
35
35
  "@progress/kendo-svg-icons": "^4.4.0",
36
36
  "vue": "^3.0.2"
37
37
  },
@@ -52,7 +52,7 @@
52
52
  "package": {
53
53
  "productName": "Kendo UI for Vue",
54
54
  "productCode": "KENDOUIVUE",
55
- "publishDate": 1778509508,
55
+ "publishDate": 1779097763,
56
56
  "licensingDocsUrl": "https://www.telerik.com/kendo-vue-ui/my-license/"
57
57
  }
58
58
  },
@@ -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 s=require("vue"),h=require("@progress/kendo-vue-common"),y=require("@progress/kendo-svg-icons"),I=require("./PromptBoxActionButton.js"),j=require("./PromptBoxSpeechToTextButton.js"),_=require("./PromptBoxUploadButton.js"),D=require("./FileBox.js"),S=require("../package-metadata.js"),q=require("@progress/kendo-vue-intl"),o=require("../messages/main.js"),l="k-prompt-box",U=20,W=50,G=s.defineComponent({name:"KendoPromptBox",emits:{change:e=>!0,focus:e=>!0,blur:e=>!0,promptaction:e=>!0},props:{value:String,defaultValue:{type:String,default:""},mode:{type:String,default:"auto"},rows:{type:Number,default:1},maxTextAreaHeight:String,title:String,disabled:{type:Boolean,default:!1},readOnly:{type:Boolean,default:!1},placeholder:String,maxLength:Number,inputAttributes:Object,fillMode:String,topAffix:[Object,Function,String],startAffix:[Object,Function,String],endAffix:[Object,Function,String],header:[Object,Function,String],loading:{type:Boolean,default:!1},uploadButtonConfig:{type:[Boolean,Object],default:!1},speechToTextButtonConfig:{type:[Boolean,Object],default:!0},actionButtonConfig:{type:[Boolean,Object],default:!0},attachments:Array},inject:{kendoLocalizationService:{default:null}},created(){h.validatePackage(S.packageMetadata),this._uploadRef=s.ref(null)},data(){return{stateValue:this.$props.defaultValue||"",stateFiles:[],hasExpanded:!1,initialHeight:0,minMultiRowHeight:0,isResizing:!1,previousValueLength:0,singleLineWidth:0,resizeObserver:null,resizeTimeout:null,onRemoveAttachmentCallback:null}},computed:{isControlled(){return this.$props.value!==void 0},currentValue(){return this.isControlled?this.$props.value||"":this.stateValue},isFilesControlled(){return this.$props.attachments!==void 0},currentFiles(){return this.isFilesControlled?this.$props.attachments||[]:this.stateFiles},canSendMessage(){var e;return!!((e=this.currentValue)!=null&&e.trim()||this.currentFiles.length>0)},isMultilineLayout(){return this.$props.mode==="multi"||this.$props.mode==="auto"&&this.hasExpanded},hasBuiltInButtons(){return this.$props.uploadButtonConfig!==!1||this.$props.speechToTextButtonConfig!==!1||this.$props.actionButtonConfig!==!1},hasEndAffixOrButtons(){return!!this.$props.endAffix||this.hasBuiltInButtons},hasStartAffixOrEndAffixOrButtons(){return!!this.$props.startAffix||!!this.$props.endAffix||this.hasBuiltInButtons},effectiveRows(){return this.$props.mode==="auto"?1:this.$props.rows}},watch:{currentValue(e){if(this.$props.mode==="single")return;const t=(e==null?void 0:e.length)||0;requestAnimationFrame(()=>{const i=this.$refs.inputElement;i&&(this.$props.mode==="multi"?this.resizeMultiMode(i):this.$props.mode==="auto"&&this.resizeAutoMode(i,t),this.previousValueLength=t)})},rows(){this.$props.mode!=="single"&&(this.captureInitialDimensions(),this.resize())},maxTextAreaHeight(){this.$props.mode!=="single"&&this.resize()},mode(){this.$props.mode!=="single"&&s.nextTick(()=>{this.captureInitialDimensions(),this.resize()})},hasExpanded(e){if(this.$props.mode==="auto"&&e&&requestAnimationFrame(()=>{const t=this.$refs.inputElement;t&&(this.updateHeight(t),this.isResizing=!1)}),this.$props.mode==="auto"&&!e){const t=this.$refs.inputElement;t&&(t.style.height="",t.style.overflow="",this.isResizing=!1)}}},mounted(){this.$props.mode!=="single"&&this.captureInitialDimensions(),this.setupResizeObserver()},beforeUnmount(){this.cleanupResizeObserver()},methods:{captureInitialDimensions(){const e=this.$refs.inputElement;if(!e||this.$props.mode==="single")return;const t=globalThis.getComputedStyle(e),i=Number.parseFloat(t.lineHeight)||U,n=Number.parseFloat(t.paddingTop)||0,r=Number.parseFloat(t.paddingBottom)||0;this.initialHeight=e.offsetHeight||i+n+r,this.minMultiRowHeight=i*this.$props.rows+n+r,this.$props.mode==="auto"&&!this.hasExpanded&&(this.singleLineWidth=e.offsetWidth)},calculateHeight(e){if(this.$props.maxTextAreaHeight){const t=Number.parseInt(this.$props.maxTextAreaHeight,10);if(e>t)return t}return Math.max(this.minMultiRowHeight,e)},resizeMultiMode(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,i=this.calculateHeight(t);e.style.height=`${i}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},updateHeight(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,i=this.$props.maxTextAreaHeight?Math.min(t,Number.parseInt(this.$props.maxTextAreaHeight,10)):t;e.style.height=`${i}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},shouldCollapse(e){if(this.singleLineWidth<=0)return!1;const t=e.style.height,i=e.style.width;e.style.overflow="hidden",e.style.width=`${this.singleLineWidth}px`,e.style.height=`${this.initialHeight}px`;const n=e.scrollWidth<=this.singleLineWidth&&e.scrollHeight<=this.initialHeight;return e.style.overflow="",e.style.width=i||"",e.style.height=t||"",n},resizeAutoMode(e,t){if(this.isResizing)return;if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!this.hasExpanded){this.isResizing=!0,this.hasExpanded=!0;return}if(this.hasExpanded){this.updateHeight(e);const n=this.previousValueLength;t<n&&this.shouldCollapse(e)&&(e.style.height="",this.isResizing=!0,this.hasExpanded=!1)}},resize(){var i;if(this.$props.mode==="single")return;const e=this.$refs.inputElement;if(!e)return;const t=((i=e.value)==null?void 0:i.length)||0;this.$props.mode==="multi"?this.resizeMultiMode(e):this.$props.mode==="auto"&&this.resizeAutoMode(e,t)},setupResizeObserver(){if(this.$props.mode==="single")return;const e=this.$refs.inputElement;e&&(this.resizeObserver=new ResizeObserver(()=>{this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{this.$props.mode==="auto"&&!this.hasExpanded&&this.captureInitialDimensions(),this.resize()},W)}),this.resizeObserver.observe(e))},cleanupResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=null)},handleChange(e){const i=e.target.value;!this.isControlled&&!this.$props.disabled&&(this.stateValue=i),this.$props.disabled||this.$emit("change",{event:e,value:i}),this.$props.mode!=="single"&&this.resize()},handleFocus(e){this.$props.disabled||this.$emit("focus",{event:e})},handleBlur(e){this.$props.disabled||this.$emit("blur",{event:e})},handleButtonMouseDown(e){e.preventDefault()},handleActionButtonClick(e){this.$emit("promptaction",{event:e,value:this.currentValue,attachments:this.currentFiles}),this.isControlled||(this.stateValue=""),this.isFilesControlled||(this.stateFiles=[])},handleKeyDown(e){if(!(e.key==="Enter"&&e.shiftKey)){if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.stopPropagation();return}if(e.key==="Enter"){if(e.preventDefault(),this.$props.loading)return;this.canSendMessage&&this.handleActionButtonClick(e)}}},handleSpeechResult(e){var n;const{isFinal:t,alternatives:i}=e;if(i.length>0){const r=i[0];if(t){const a=this.$refs.inputElement,f=(a==null?void 0:a.value)||"",g=(f?`${f} `:"")+r.transcript;if(this.isControlled||(this.stateValue=g),!this.$props.disabled){const m={target:a,currentTarget:a};this.$emit("change",{event:m,value:g})}}}(n=this.$refs.inputElement)==null||n.focus()},handleUploadButtonClick(){const e=this._uploadRef.value;if(e!=null&&e.$el){const t=e.$el.querySelector('input[type="file"]');t&&t.click()}},onFilesSelect(e){var a;const t=Array.from(e.affectedFiles),i=this.$props.uploadButtonConfig,n=typeof i=="object"&&i,r=n?n.onSelectAttachments:void 0;this.isFilesControlled||(this.stateFiles=[...this.stateFiles,...t]),r&&r({selectedFiles:e.affectedFiles,allFiles:e.newState}),(a=this.$refs.inputElement)==null||a.focus()},handleRemoveFile(e){this.isFilesControlled||(this.stateFiles=this.stateFiles.filter(r=>r.name!==e));const t=this.$props.uploadButtonConfig,i=typeof t=="object"&&t,n=i?i.onRemoveAttachment:void 0;n&&(this.onRemoveAttachmentCallback=n),this.onRemoveAttachmentCallback&&this.onRemoveAttachmentCallback(e)},renderAffix(e,t){return e?typeof e=="function"?e(t):e:null}},render(){const e=q.provideLocalizationService(this),{mode:t,fillMode:i,maxTextAreaHeight:n,disabled:r,readOnly:a,placeholder:f,title:g,maxLength:m,inputAttributes:T,topAffix:C,startAffix:p,endAffix:d,header:z,loading:c,speechToTextButtonConfig:x,actionButtonConfig:B,uploadButtonConfig:$}=this.$props,u={uploadButtonProps:{fillMode:"flat",svgIcon:y.paperclipOutlineAltRightIcon,size:"small",rounded:"full",onClick:this.handleUploadButtonClick,onFilesAdd:this.onFilesSelect,files:this.currentFiles,_uploadRef:this._uploadRef,"aria-label":e.toLanguageString(o.promptBoxAttachFile,o.messages[o.promptBoxAttachFile]),title:e.toLanguageString(o.promptBoxAttachFile,o.messages[o.promptBoxAttachFile]),_registerRemoveCallback:A=>{this.onRemoveAttachmentCallback=A||null}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:this.handleSpeechResult},actionButtonProps:{rounded:"full",size:"small",svgIcon:c?y.stopSmIcon:y.arrowUpOutlineIcon,class:c?"k-generating":"",onClick:this.handleActionButtonClick,onMousedown:this.handleButtonMouseDown,disabled:!c&&!this.canSendMessage,"aria-disabled":!c&&!this.canSendMessage,"aria-label":c?e.toLanguageString(o.promptBoxStopGenerating,o.messages[o.promptBoxStopGenerating]):e.toLanguageString(o.promptBoxSendButton,o.messages[o.promptBoxSendButton]),title:c?e.toLanguageString(o.promptBoxStopGenerating,o.messages[o.promptBoxStopGenerating]):e.toLanguageString(o.promptBoxSendButton,o.messages[o.promptBoxSendButton]),"aria-live":"polite"}},v=()=>{const A=x!==!1,k=B!==!1,E=$!==!1,M=typeof x=="object"?x:void 0,O=typeof $=="object"?$:{},{restrictions:L,multiple:w=!0,accept:V,onSelectAttachments:K,onRemoveAttachment:X,...N}=O,b={restrictions:L,multiple:w,accept:V},P=typeof B=="object"?B:void 0;return s.createVNode(s.Fragment,null,[E&&s.createVNode(_.PromptBoxUploadButton,s.mergeProps({ref:"uploadButton"},u.uploadButtonProps,{restrictions:b.restrictions,multiple:b.multiple,accept:b.accept},N),null),A&&s.createVNode(j.PromptBoxSpeechToTextButton,s.mergeProps(u.speechToTextButtonProps,M),null),k&&s.createVNode(I.PromptBoxActionButton,s.mergeProps(u.actionButtonProps,P),null)])},F={disabled:r,readOnly:a,placeholder:f,title:g,maxLength:m,"aria-label":e.toLanguageString(o.promptBoxInput,o.messages[o.promptBoxInput]),value:this.currentValue,onKeydown:this.handleKeyDown,...T,onInput:this.handleChange,onFocus:this.handleFocus,onBlur:this.handleBlur,ref:"inputElement"},H=()=>s.createVNode("div",{class:`${l}-content`},[p&&s.createVNode("div",{class:`${l}-affix`},[this.renderAffix(p,u)]),s.createVNode("input",s.mergeProps(F,{class:h.classNames("k-input-inner",`${l}-input`)}),null),this.hasEndAffixOrButtons?s.createVNode("div",{class:`${l}-affix`},[d&&this.renderAffix(d,u),v()]):null]),R=()=>s.createVNode("div",{class:`${l}-content`},[t==="multi"&&C&&s.createVNode("div",{class:`${l}-affix`},[this.renderAffix(C,u)]),t==="auto"&&p&&s.createVNode("div",{class:`${l}-affix`,style:{display:this.hasExpanded?"none":void 0}},[this.renderAffix(p,u)]),s.createVNode("textarea",s.mergeProps(F,{class:h.classNames("k-input-inner",`${l}-textarea`),rows:this.effectiveRows,style:n?{maxHeight:n}:{}},this.isMultilineLayout&&{"aria-multiline":"true"}),null),t==="auto"&&this.hasEndAffixOrButtons?s.createVNode("div",{class:`${l}-affix`,style:{display:this.hasExpanded?"none":void 0}},[d&&this.renderAffix(d,u),v()]):null,this.hasStartAffixOrEndAffixOrButtons?s.createVNode("div",{class:`${l}-affix`,style:{display:this.isMultilineLayout?void 0:"none"}},[p&&this.renderAffix(p,u),(p||d)&&s.createVNode("div",{class:"k-spacer"},null),d&&this.renderAffix(d,u),v()]):null]);return s.createVNode("div",{"aria-label":e.toLanguageString(o.promptBoxAriaLabel,o.messages[o.promptBoxAriaLabel]),class:h.classNames("k-input",l,{[`k-input-${i}`]:i,"k-disabled":r,"k-prompt-box-singleline":t==="single","k-prompt-box-multiline":this.isMultilineLayout})},[s.createVNode(D.FileBox,{files:this.currentFiles,onRemoveFile:this.handleRemoveFile,header:h.templateRendering.call(this,z,h.getListeners.call(this))},null),t==="single"?H():R(),h.shouldShowValidationUI(S.packageMetadata)&&s.createVNode(h.WatermarkOverlay,{message:h.getLicenseMessage(S.packageMetadata)},null)])}});exports.PromptBox=G;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),h=require("@progress/kendo-vue-common"),y=require("@progress/kendo-svg-icons"),I=require("./PromptBoxActionButton.js"),j=require("./PromptBoxSpeechToTextButton.js"),_=require("./PromptBoxUploadButton.js"),D=require("./FileBox.js"),S=require("../package-metadata.js"),q=require("@progress/kendo-vue-intl"),o=require("../messages/main.js"),l="k-prompt-box",U=20,W=50,G=s.defineComponent({name:"KendoPromptBox",emits:{change:e=>!0,focus:e=>!0,blur:e=>!0,promptaction:e=>!0},props:{value:String,defaultValue:{type:String,default:""},mode:{type:String,default:"auto"},rows:{type:Number,default:1},maxTextAreaHeight:String,title:String,disabled:{type:Boolean,default:!1},readOnly:{type:Boolean,default:!1},placeholder:String,maxLength:Number,inputAttributes:Object,fillMode:String,topAffix:[Object,Function,String],startAffix:[Object,Function,String],endAffix:[Object,Function,String],header:[Object,Function,String],loading:{type:Boolean,default:!1},uploadButtonConfig:{type:[Boolean,Object],default:!1},speechToTextButtonConfig:{type:[Boolean,Object],default:!0},actionButtonConfig:{type:[Boolean,Object],default:!0},attachments:Array},inject:{kendoLocalizationService:{default:null}},created(){h.validatePackage(S.packageMetadata),this._uploadRef=s.ref(null)},data(){return{stateValue:this.$props.defaultValue||"",stateFiles:[],hasExpanded:!1,initialHeight:0,minMultiRowHeight:0,isResizing:!1,previousValueLength:0,singleLineWidth:0,resizeObserver:null,resizeTimeout:null,onRemoveAttachmentCallback:null}},computed:{isControlled(){return this.$props.value!==void 0},currentValue(){return this.isControlled?this.$props.value||"":this.stateValue},isFilesControlled(){return this.$props.attachments!==void 0},currentFiles(){return this.isFilesControlled?this.$props.attachments||[]:this.stateFiles},canSendMessage(){var e;return!!((e=this.currentValue)!=null&&e.trim()||this.currentFiles.length>0)},isMultilineLayout(){return this.$props.mode==="multi"||this.$props.mode==="auto"&&this.hasExpanded},hasBuiltInButtons(){return this.$props.uploadButtonConfig!==!1||this.$props.speechToTextButtonConfig!==!1||this.$props.actionButtonConfig!==!1},hasEndAffixOrButtons(){return!!this.$props.endAffix||this.hasBuiltInButtons},hasStartAffixOrEndAffixOrButtons(){return!!this.$props.startAffix||!!this.$props.endAffix||this.hasBuiltInButtons},effectiveRows(){return this.$props.mode==="auto"?1:this.$props.rows}},watch:{currentValue(e){if(this.$props.mode==="single")return;const t=(e==null?void 0:e.length)||0;requestAnimationFrame(()=>{const i=this.$refs.inputElement;i&&(this.$props.mode==="multi"?this.resizeMultiMode(i):this.$props.mode==="auto"&&this.resizeAutoMode(i,t),this.previousValueLength=t)})},rows(){this.$props.mode!=="single"&&(this.captureInitialDimensions(),this.resize())},maxTextAreaHeight(){this.$props.mode!=="single"&&this.resize()},mode(){this.$props.mode!=="single"&&s.nextTick(()=>{this.captureInitialDimensions(),this.resize()})},hasExpanded(e){if(this.$props.mode==="auto"&&e&&requestAnimationFrame(()=>{const t=this.$refs.inputElement;t&&(this.updateHeight(t),this.isResizing=!1)}),this.$props.mode==="auto"&&!e){const t=this.$refs.inputElement;t&&(t.style.height="",t.style.overflow="",this.isResizing=!1)}}},mounted(){this.$props.mode!=="single"&&this.captureInitialDimensions(),this.setupResizeObserver()},beforeUnmount(){this.cleanupResizeObserver()},methods:{captureInitialDimensions(){const e=this.$refs.inputElement;if(!e||this.$props.mode==="single")return;const t=globalThis.getComputedStyle(e),i=Number.parseFloat(t.lineHeight)||U,n=Number.parseFloat(t.paddingTop)||0,r=Number.parseFloat(t.paddingBottom)||0;this.initialHeight=e.offsetHeight||i+n+r,this.minMultiRowHeight=i*this.$props.rows+n+r,this.$props.mode==="auto"&&!this.hasExpanded&&(this.singleLineWidth=e.offsetWidth)},calculateHeight(e){if(this.$props.maxTextAreaHeight){const t=Number.parseInt(this.$props.maxTextAreaHeight,10);if(e>t)return t}return Math.max(this.minMultiRowHeight,e)},resizeMultiMode(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,i=this.calculateHeight(t);e.style.height=`${i}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},updateHeight(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,i=this.$props.maxTextAreaHeight?Math.min(t,Number.parseInt(this.$props.maxTextAreaHeight,10)):t;e.style.height=`${i}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},shouldCollapse(e){if(this.singleLineWidth<=0)return!1;const t=e.style.height,i=e.style.width;e.style.overflow="hidden",e.style.width=`${this.singleLineWidth}px`,e.style.height=`${this.initialHeight}px`;const n=e.scrollWidth<=this.singleLineWidth&&e.scrollHeight<=this.initialHeight;return e.style.overflow="",e.style.width=i||"",e.style.height=t||"",n},resizeAutoMode(e,t){if(this.isResizing)return;if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!this.hasExpanded){this.isResizing=!0,this.hasExpanded=!0;return}if(this.hasExpanded){this.updateHeight(e);const n=this.previousValueLength;t<n&&this.shouldCollapse(e)&&(e.style.height="",this.isResizing=!0,this.hasExpanded=!1)}},resize(){var i;if(this.$props.mode==="single")return;const e=this.$refs.inputElement;if(!e)return;const t=((i=e.value)==null?void 0:i.length)||0;this.$props.mode==="multi"?this.resizeMultiMode(e):this.$props.mode==="auto"&&this.resizeAutoMode(e,t)},setupResizeObserver(){if(this.$props.mode==="single")return;const e=this.$refs.inputElement;e&&(this.resizeObserver=new ResizeObserver(()=>{this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{this.$props.mode==="auto"&&!this.hasExpanded&&this.captureInitialDimensions(),this.resize()},W)}),this.resizeObserver.observe(e))},cleanupResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=null)},handleChange(e){const i=e.target.value;!this.isControlled&&!this.$props.disabled&&(this.stateValue=i),this.$props.disabled||this.$emit("change",{event:e,value:i}),this.$props.mode!=="single"&&this.resize()},handleFocus(e){this.$props.disabled||this.$emit("focus",{event:e})},handleBlur(e){this.$props.disabled||this.$emit("blur",{event:e})},handleButtonMouseDown(e){e.preventDefault()},handleActionButtonClick(e){this.$emit("promptaction",{event:e,value:this.currentValue,attachments:this.currentFiles}),this.isControlled||(this.stateValue=""),this.isFilesControlled||(this.stateFiles=[])},handleKeyDown(e){if(!(e.key==="Enter"&&e.shiftKey)){if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.stopPropagation();return}if(e.key==="Enter"){if(e.preventDefault(),this.$props.loading)return;this.canSendMessage&&this.handleActionButtonClick(e)}}},handleSpeechResult(e){var n;const{isFinal:t,alternatives:i}=e;if(i.length>0){const r=i[0];if(t){const a=this.$refs.inputElement,f=(a==null?void 0:a.value)||"",g=(f?`${f} `:"")+r.transcript;if(this.isControlled||(this.stateValue=g),!this.$props.disabled){const m={target:a,currentTarget:a};this.$emit("change",{event:m,value:g})}}}(n=this.$refs.inputElement)==null||n.focus()},handleUploadButtonClick(){const e=this._uploadRef.value;if(e!=null&&e.$el){const t=e.$el.querySelector('input[type="file"]');t&&t.click()}},onFilesSelect(e){var a;const t=Array.from(e.affectedFiles),i=this.$props.uploadButtonConfig,n=typeof i=="object"&&i,r=n?n.onSelectAttachments:void 0;this.isFilesControlled||(this.stateFiles=[...this.stateFiles,...t]),r&&r({selectedFiles:e.affectedFiles,allFiles:e.newState}),(a=this.$refs.inputElement)==null||a.focus()},handleRemoveFile(e){this.isFilesControlled||(this.stateFiles=this.stateFiles.filter(r=>r.name!==e));const t=this.$props.uploadButtonConfig,i=typeof t=="object"&&t,n=i?i.onRemoveAttachment:void 0;n&&(this.onRemoveAttachmentCallback=n),this.onRemoveAttachmentCallback&&this.onRemoveAttachmentCallback(e)},renderAffix(e,t){return e?typeof e=="function"?e(t):e:null}},render(){const e=q.provideLocalizationService(this),{mode:t,fillMode:i,maxTextAreaHeight:n,disabled:r,readOnly:a,placeholder:f,title:g,maxLength:m,inputAttributes:T,topAffix:C,startAffix:p,endAffix:d,header:z,loading:c,speechToTextButtonConfig:x,actionButtonConfig:B,uploadButtonConfig:$}=this.$props,u={uploadButtonProps:{fillMode:"flat",svgIcon:y.paperclipOutlineAltRightIcon,size:"small",rounded:"full",onClick:this.handleUploadButtonClick,onFilesAdd:this.onFilesSelect,files:this.currentFiles,_uploadRef:this._uploadRef,"aria-label":e.toLanguageString(o.promptBoxAttachFile,o.messages[o.promptBoxAttachFile]),title:e.toLanguageString(o.promptBoxAttachFile,o.messages[o.promptBoxAttachFile]),_registerRemoveCallback:A=>{this.onRemoveAttachmentCallback=A||null}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:this.handleSpeechResult},actionButtonProps:{rounded:"full",size:"small",svgIcon:c?y.stopIcon:y.arrowUpIcon,class:c?"k-generating k-active":"",onClick:this.handleActionButtonClick,onMousedown:this.handleButtonMouseDown,disabled:!c&&!this.canSendMessage,"aria-disabled":!c&&!this.canSendMessage?!0:void 0,"aria-label":c?e.toLanguageString(o.promptBoxStopGenerating,o.messages[o.promptBoxStopGenerating]):e.toLanguageString(o.promptBoxSendButton,o.messages[o.promptBoxSendButton]),title:c?e.toLanguageString(o.promptBoxStopGenerating,o.messages[o.promptBoxStopGenerating]):e.toLanguageString(o.promptBoxSendButton,o.messages[o.promptBoxSendButton]),"aria-live":"polite"}},v=()=>{const A=x!==!1,k=B!==!1,E=$!==!1,M=typeof x=="object"?x:void 0,O=typeof $=="object"?$:{},{restrictions:L,multiple:w=!0,accept:V,onSelectAttachments:K,onRemoveAttachment:X,...N}=O,b={restrictions:L,multiple:w,accept:V},P=typeof B=="object"?B:void 0;return s.createVNode(s.Fragment,null,[E&&s.createVNode(_.PromptBoxUploadButton,s.mergeProps({ref:"uploadButton"},u.uploadButtonProps,{restrictions:b.restrictions,multiple:b.multiple,accept:b.accept},N),null),A&&s.createVNode(j.PromptBoxSpeechToTextButton,s.mergeProps(u.speechToTextButtonProps,M),null),k&&s.createVNode(I.PromptBoxActionButton,s.mergeProps(u.actionButtonProps,P),null)])},F={disabled:r,readOnly:a,placeholder:f,title:g,maxLength:m,"aria-label":e.toLanguageString(o.promptBoxInput,o.messages[o.promptBoxInput]),value:this.currentValue,onKeydown:this.handleKeyDown,...T,onInput:this.handleChange,onFocus:this.handleFocus,onBlur:this.handleBlur,ref:"inputElement"},H=()=>s.createVNode("div",{class:`${l}-content`},[p&&s.createVNode("div",{class:`${l}-affix`},[this.renderAffix(p,u)]),s.createVNode("input",s.mergeProps(F,{class:h.classNames("k-input-inner",`${l}-input`)}),null),this.hasEndAffixOrButtons?s.createVNode("div",{class:`${l}-affix`},[d&&this.renderAffix(d,u),v()]):null]),R=()=>s.createVNode("div",{class:`${l}-content`},[t==="multi"&&C&&s.createVNode("div",{class:`${l}-affix`},[this.renderAffix(C,u)]),t==="auto"&&p&&s.createVNode("div",{class:`${l}-affix`,style:{display:this.hasExpanded?"none":void 0}},[this.renderAffix(p,u)]),s.createVNode("textarea",s.mergeProps(F,{class:h.classNames("k-input-inner",`${l}-textarea`),rows:this.effectiveRows,style:n?{maxHeight:n}:{}},t!=="single"&&{"aria-multiline":"true"}),null),t==="auto"&&this.hasEndAffixOrButtons?s.createVNode("div",{class:`${l}-affix`,style:{display:this.hasExpanded?"none":void 0}},[d&&this.renderAffix(d,u),v()]):null,this.hasStartAffixOrEndAffixOrButtons?s.createVNode("div",{class:`${l}-affix`,style:{display:this.isMultilineLayout?void 0:"none"}},[p&&this.renderAffix(p,u),(p||d)&&s.createVNode("div",{class:"k-spacer"},null),d&&this.renderAffix(d,u),v()]):null]);return s.createVNode("div",{"aria-label":e.toLanguageString(o.promptBoxAriaLabel,o.messages[o.promptBoxAriaLabel]),class:h.classNames("k-input",l,{[`k-input-${i}`]:i,"k-disabled":r,"k-prompt-box-singleline":t==="single","k-prompt-box-multiline":this.isMultilineLayout})},[s.createVNode(D.FileBox,{files:this.currentFiles,onRemoveFile:this.handleRemoveFile,header:h.templateRendering.call(this,z,h.getListeners.call(this))},null),t==="single"?H():R(),h.shouldShowValidationUI(S.packageMetadata)&&s.createVNode(h.WatermarkOverlay,{message:h.getLicenseMessage(S.packageMetadata)},null)])}});exports.PromptBox=G;
@@ -6,22 +6,22 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  import { defineComponent as U, createVNode as n, nextTick as K, ref as q, mergeProps as f, Fragment as G } from "vue";
9
- import { classNames as S, templateRendering as X, getListeners as Z, shouldShowValidationUI as J, WatermarkOverlay as Q, getLicenseMessage as Y, validatePackage as tt } from "@progress/kendo-vue-common";
10
- import { stopSmIcon as et, arrowUpOutlineIcon as it, paperclipOutlineAltRightIcon as st } from "@progress/kendo-svg-icons";
11
- import { PromptBoxActionButton as nt } from "./PromptBoxActionButton.mjs";
12
- import { PromptBoxSpeechToTextButton as ot } from "./PromptBoxSpeechToTextButton.mjs";
13
- import { PromptBoxUploadButton as lt } from "./PromptBoxUploadButton.mjs";
14
- import { FileBox as rt } from "./FileBox.mjs";
9
+ import { classNames as S, templateRendering as X, getListeners as Z, shouldShowValidationUI as J, WatermarkOverlay as Q, getLicenseMessage as Y, validatePackage as ee } from "@progress/kendo-vue-common";
10
+ import { stopIcon as te, arrowUpIcon as ie, paperclipOutlineAltRightIcon as se } from "@progress/kendo-svg-icons";
11
+ import { PromptBoxActionButton as ne } from "./PromptBoxActionButton.mjs";
12
+ import { PromptBoxSpeechToTextButton as oe } from "./PromptBoxSpeechToTextButton.mjs";
13
+ import { PromptBoxUploadButton as le } from "./PromptBoxUploadButton.mjs";
14
+ import { FileBox as re } from "./FileBox.mjs";
15
15
  import { packageMetadata as T } from "../package-metadata.mjs";
16
- import { provideLocalizationService as at } from "@progress/kendo-vue-intl";
17
- import { promptBoxStopGenerating as g, messages as h, promptBoxSendButton as $, promptBoxAttachFile as x, promptBoxInput as R, promptBoxAriaLabel as E } from "../messages/main.mjs";
18
- const l = "k-prompt-box", ht = 20, ut = 50, yt = /* @__PURE__ */ U({
16
+ import { provideLocalizationService as ae } from "@progress/kendo-vue-intl";
17
+ import { promptBoxStopGenerating as m, messages as h, promptBoxSendButton as $, promptBoxAttachFile as x, promptBoxInput as R, promptBoxAriaLabel as E } from "../messages/main.mjs";
18
+ const l = "k-prompt-box", he = 20, ue = 50, ye = /* @__PURE__ */ U({
19
19
  name: "KendoPromptBox",
20
20
  emits: {
21
- change: (t) => !0,
22
- focus: (t) => !0,
23
- blur: (t) => !0,
24
- promptaction: (t) => !0
21
+ change: (e) => !0,
22
+ focus: (e) => !0,
23
+ blur: (e) => !0,
24
+ promptaction: (e) => !0
25
25
  },
26
26
  props: {
27
27
  value: String,
@@ -79,7 +79,7 @@ const l = "k-prompt-box", ht = 20, ut = 50, yt = /* @__PURE__ */ U({
79
79
  }
80
80
  },
81
81
  created() {
82
- tt(T), this._uploadRef = q(null);
82
+ ee(T), this._uploadRef = q(null);
83
83
  },
84
84
  data() {
85
85
  return {
@@ -110,8 +110,8 @@ const l = "k-prompt-box", ht = 20, ut = 50, yt = /* @__PURE__ */ U({
110
110
  return this.isFilesControlled ? this.$props.attachments || [] : this.stateFiles;
111
111
  },
112
112
  canSendMessage() {
113
- var t;
114
- return !!((t = this.currentValue) != null && t.trim() || this.currentFiles.length > 0);
113
+ var e;
114
+ return !!((e = this.currentValue) != null && e.trim() || this.currentFiles.length > 0);
115
115
  },
116
116
  isMultilineLayout() {
117
117
  return this.$props.mode === "multi" || this.$props.mode === "auto" && this.hasExpanded;
@@ -130,13 +130,13 @@ const l = "k-prompt-box", ht = 20, ut = 50, yt = /* @__PURE__ */ U({
130
130
  }
131
131
  },
132
132
  watch: {
133
- currentValue(t) {
133
+ currentValue(e) {
134
134
  if (this.$props.mode === "single")
135
135
  return;
136
- const e = (t == null ? void 0 : t.length) || 0;
136
+ const t = (e == null ? void 0 : e.length) || 0;
137
137
  requestAnimationFrame(() => {
138
138
  const i = this.$refs.inputElement;
139
- i && (this.$props.mode === "multi" ? this.resizeMultiMode(i) : this.$props.mode === "auto" && this.resizeAutoMode(i, e), this.previousValueLength = e);
139
+ i && (this.$props.mode === "multi" ? this.resizeMultiMode(i) : this.$props.mode === "auto" && this.resizeAutoMode(i, t), this.previousValueLength = t);
140
140
  });
141
141
  },
142
142
  rows() {
@@ -150,13 +150,13 @@ const l = "k-prompt-box", ht = 20, ut = 50, yt = /* @__PURE__ */ U({
150
150
  this.captureInitialDimensions(), this.resize();
151
151
  });
152
152
  },
153
- hasExpanded(t) {
154
- if (this.$props.mode === "auto" && t && requestAnimationFrame(() => {
155
- const e = this.$refs.inputElement;
156
- e && (this.updateHeight(e), this.isResizing = !1);
157
- }), this.$props.mode === "auto" && !t) {
158
- const e = this.$refs.inputElement;
159
- e && (e.style.height = "", e.style.overflow = "", this.isResizing = !1);
153
+ hasExpanded(e) {
154
+ if (this.$props.mode === "auto" && e && requestAnimationFrame(() => {
155
+ const t = this.$refs.inputElement;
156
+ t && (this.updateHeight(t), this.isResizing = !1);
157
+ }), this.$props.mode === "auto" && !e) {
158
+ const t = this.$refs.inputElement;
159
+ t && (t.style.height = "", t.style.overflow = "", this.isResizing = !1);
160
160
  }
161
161
  }
162
162
  },
@@ -168,132 +168,132 @@ const l = "k-prompt-box", ht = 20, ut = 50, yt = /* @__PURE__ */ U({
168
168
  },
169
169
  methods: {
170
170
  captureInitialDimensions() {
171
- const t = this.$refs.inputElement;
172
- if (!t || this.$props.mode === "single")
171
+ const e = this.$refs.inputElement;
172
+ if (!e || this.$props.mode === "single")
173
173
  return;
174
- const e = globalThis.getComputedStyle(t), i = Number.parseFloat(e.lineHeight) || ht, s = Number.parseFloat(e.paddingTop) || 0, o = Number.parseFloat(e.paddingBottom) || 0;
175
- this.initialHeight = t.offsetHeight || i + s + o, this.minMultiRowHeight = i * this.$props.rows + s + o, this.$props.mode === "auto" && !this.hasExpanded && (this.singleLineWidth = t.offsetWidth);
174
+ const t = globalThis.getComputedStyle(e), i = Number.parseFloat(t.lineHeight) || he, s = Number.parseFloat(t.paddingTop) || 0, o = Number.parseFloat(t.paddingBottom) || 0;
175
+ this.initialHeight = e.offsetHeight || i + s + o, this.minMultiRowHeight = i * this.$props.rows + s + o, this.$props.mode === "auto" && !this.hasExpanded && (this.singleLineWidth = e.offsetWidth);
176
176
  },
177
- calculateHeight(t) {
177
+ calculateHeight(e) {
178
178
  if (this.$props.maxTextAreaHeight) {
179
- const e = Number.parseInt(this.$props.maxTextAreaHeight, 10);
180
- if (t > e)
181
- return e;
179
+ const t = Number.parseInt(this.$props.maxTextAreaHeight, 10);
180
+ if (e > t)
181
+ return t;
182
182
  }
183
- return Math.max(this.minMultiRowHeight, t);
183
+ return Math.max(this.minMultiRowHeight, e);
184
184
  },
185
- resizeMultiMode(t) {
186
- t.style.overflow = "hidden", t.style.height = `${this.initialHeight}px`;
187
- const e = t.scrollHeight, i = this.calculateHeight(e);
188
- t.style.height = `${i}px`, this.$props.maxTextAreaHeight && e > Number.parseInt(this.$props.maxTextAreaHeight, 10) && (t.style.overflow = "");
185
+ resizeMultiMode(e) {
186
+ e.style.overflow = "hidden", e.style.height = `${this.initialHeight}px`;
187
+ const t = e.scrollHeight, i = this.calculateHeight(t);
188
+ e.style.height = `${i}px`, this.$props.maxTextAreaHeight && t > Number.parseInt(this.$props.maxTextAreaHeight, 10) && (e.style.overflow = "");
189
189
  },
190
- updateHeight(t) {
191
- t.style.overflow = "hidden", t.style.height = `${this.initialHeight}px`;
192
- const e = t.scrollHeight, i = this.$props.maxTextAreaHeight ? Math.min(e, Number.parseInt(this.$props.maxTextAreaHeight, 10)) : e;
193
- t.style.height = `${i}px`, this.$props.maxTextAreaHeight && e > Number.parseInt(this.$props.maxTextAreaHeight, 10) && (t.style.overflow = "");
190
+ updateHeight(e) {
191
+ e.style.overflow = "hidden", e.style.height = `${this.initialHeight}px`;
192
+ const t = e.scrollHeight, i = this.$props.maxTextAreaHeight ? Math.min(t, Number.parseInt(this.$props.maxTextAreaHeight, 10)) : t;
193
+ e.style.height = `${i}px`, this.$props.maxTextAreaHeight && t > Number.parseInt(this.$props.maxTextAreaHeight, 10) && (e.style.overflow = "");
194
194
  },
195
- shouldCollapse(t) {
195
+ shouldCollapse(e) {
196
196
  if (this.singleLineWidth <= 0)
197
197
  return !1;
198
- const e = t.style.height, i = t.style.width;
199
- t.style.overflow = "hidden", t.style.width = `${this.singleLineWidth}px`, t.style.height = `${this.initialHeight}px`;
200
- const s = t.scrollWidth <= this.singleLineWidth && t.scrollHeight <= this.initialHeight;
201
- return t.style.overflow = "", t.style.width = i || "", t.style.height = e || "", s;
198
+ const t = e.style.height, i = e.style.width;
199
+ e.style.overflow = "hidden", e.style.width = `${this.singleLineWidth}px`, e.style.height = `${this.initialHeight}px`;
200
+ const s = e.scrollWidth <= this.singleLineWidth && e.scrollHeight <= this.initialHeight;
201
+ return e.style.overflow = "", e.style.width = i || "", e.style.height = t || "", s;
202
202
  },
203
- resizeAutoMode(t, e) {
203
+ resizeAutoMode(e, t) {
204
204
  if (this.isResizing)
205
205
  return;
206
- if ((t.scrollWidth > t.clientWidth || t.scrollHeight > t.clientHeight) && !this.hasExpanded) {
206
+ if ((e.scrollWidth > e.clientWidth || e.scrollHeight > e.clientHeight) && !this.hasExpanded) {
207
207
  this.isResizing = !0, this.hasExpanded = !0;
208
208
  return;
209
209
  }
210
210
  if (this.hasExpanded) {
211
- this.updateHeight(t);
211
+ this.updateHeight(e);
212
212
  const s = this.previousValueLength;
213
- e < s && this.shouldCollapse(t) && (t.style.height = "", this.isResizing = !0, this.hasExpanded = !1);
213
+ t < s && this.shouldCollapse(e) && (e.style.height = "", this.isResizing = !0, this.hasExpanded = !1);
214
214
  }
215
215
  },
216
216
  resize() {
217
217
  var i;
218
218
  if (this.$props.mode === "single")
219
219
  return;
220
- const t = this.$refs.inputElement;
221
- if (!t)
220
+ const e = this.$refs.inputElement;
221
+ if (!e)
222
222
  return;
223
- const e = ((i = t.value) == null ? void 0 : i.length) || 0;
224
- this.$props.mode === "multi" ? this.resizeMultiMode(t) : this.$props.mode === "auto" && this.resizeAutoMode(t, e);
223
+ const t = ((i = e.value) == null ? void 0 : i.length) || 0;
224
+ this.$props.mode === "multi" ? this.resizeMultiMode(e) : this.$props.mode === "auto" && this.resizeAutoMode(e, t);
225
225
  },
226
226
  setupResizeObserver() {
227
227
  if (this.$props.mode === "single")
228
228
  return;
229
- const t = this.$refs.inputElement;
230
- t && (this.resizeObserver = new ResizeObserver(() => {
229
+ const e = this.$refs.inputElement;
230
+ e && (this.resizeObserver = new ResizeObserver(() => {
231
231
  this.resizeTimeout && clearTimeout(this.resizeTimeout), this.resizeTimeout = setTimeout(() => {
232
232
  this.$props.mode === "auto" && !this.hasExpanded && this.captureInitialDimensions(), this.resize();
233
- }, ut);
234
- }), this.resizeObserver.observe(t));
233
+ }, ue);
234
+ }), this.resizeObserver.observe(e));
235
235
  },
236
236
  cleanupResizeObserver() {
237
237
  this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null), this.resizeTimeout && (clearTimeout(this.resizeTimeout), this.resizeTimeout = null);
238
238
  },
239
- handleChange(t) {
240
- const i = t.target.value;
239
+ handleChange(e) {
240
+ const i = e.target.value;
241
241
  !this.isControlled && !this.$props.disabled && (this.stateValue = i), this.$props.disabled || this.$emit("change", {
242
- event: t,
242
+ event: e,
243
243
  value: i
244
244
  }), this.$props.mode !== "single" && this.resize();
245
245
  },
246
- handleFocus(t) {
246
+ handleFocus(e) {
247
247
  this.$props.disabled || this.$emit("focus", {
248
- event: t
248
+ event: e
249
249
  });
250
250
  },
251
- handleBlur(t) {
251
+ handleBlur(e) {
252
252
  this.$props.disabled || this.$emit("blur", {
253
- event: t
253
+ event: e
254
254
  });
255
255
  },
256
- handleButtonMouseDown(t) {
257
- t.preventDefault();
256
+ handleButtonMouseDown(e) {
257
+ e.preventDefault();
258
258
  },
259
- handleActionButtonClick(t) {
259
+ handleActionButtonClick(e) {
260
260
  this.$emit("promptaction", {
261
- event: t,
261
+ event: e,
262
262
  value: this.currentValue,
263
263
  attachments: this.currentFiles
264
264
  }), this.isControlled || (this.stateValue = ""), this.isFilesControlled || (this.stateFiles = []);
265
265
  },
266
- handleKeyDown(t) {
267
- if (!(t.key === "Enter" && t.shiftKey)) {
268
- if (t.key === "ArrowUp" || t.key === "ArrowDown") {
269
- t.stopPropagation();
266
+ handleKeyDown(e) {
267
+ if (!(e.key === "Enter" && e.shiftKey)) {
268
+ if (e.key === "ArrowUp" || e.key === "ArrowDown") {
269
+ e.stopPropagation();
270
270
  return;
271
271
  }
272
- if (t.key === "Enter") {
273
- if (t.preventDefault(), this.$props.loading)
272
+ if (e.key === "Enter") {
273
+ if (e.preventDefault(), this.$props.loading)
274
274
  return;
275
- this.canSendMessage && this.handleActionButtonClick(t);
275
+ this.canSendMessage && this.handleActionButtonClick(e);
276
276
  }
277
277
  }
278
278
  },
279
- handleSpeechResult(t) {
279
+ handleSpeechResult(e) {
280
280
  var s;
281
281
  const {
282
- isFinal: e,
282
+ isFinal: t,
283
283
  alternatives: i
284
- } = t;
284
+ } = e;
285
285
  if (i.length > 0) {
286
286
  const o = i[0];
287
- if (e) {
288
- const r = this.$refs.inputElement, c = (r == null ? void 0 : r.value) || "", m = (c ? `${c} ` : "") + o.transcript;
289
- if (this.isControlled || (this.stateValue = m), !this.$props.disabled) {
290
- const B = {
287
+ if (t) {
288
+ const r = this.$refs.inputElement, c = (r == null ? void 0 : r.value) || "", g = (c ? `${c} ` : "") + o.transcript;
289
+ if (this.isControlled || (this.stateValue = g), !this.$props.disabled) {
290
+ const v = {
291
291
  target: r,
292
292
  currentTarget: r
293
293
  };
294
294
  this.$emit("change", {
295
- event: B,
296
- value: m
295
+ event: v,
296
+ value: g
297
297
  });
298
298
  }
299
299
  }
@@ -301,60 +301,60 @@ const l = "k-prompt-box", ht = 20, ut = 50, yt = /* @__PURE__ */ U({
301
301
  (s = this.$refs.inputElement) == null || s.focus();
302
302
  },
303
303
  handleUploadButtonClick() {
304
- const t = this._uploadRef.value;
305
- if (t != null && t.$el) {
306
- const e = t.$el.querySelector('input[type="file"]');
307
- e && e.click();
304
+ const e = this._uploadRef.value;
305
+ if (e != null && e.$el) {
306
+ const t = e.$el.querySelector('input[type="file"]');
307
+ t && t.click();
308
308
  }
309
309
  },
310
- onFilesSelect(t) {
310
+ onFilesSelect(e) {
311
311
  var r;
312
- const e = Array.from(t.affectedFiles), i = this.$props.uploadButtonConfig, s = typeof i == "object" && i, o = s ? s.onSelectAttachments : void 0;
313
- this.isFilesControlled || (this.stateFiles = [...this.stateFiles, ...e]), o && o({
314
- selectedFiles: t.affectedFiles,
315
- allFiles: t.newState
312
+ const t = Array.from(e.affectedFiles), i = this.$props.uploadButtonConfig, s = typeof i == "object" && i, o = s ? s.onSelectAttachments : void 0;
313
+ this.isFilesControlled || (this.stateFiles = [...this.stateFiles, ...t]), o && o({
314
+ selectedFiles: e.affectedFiles,
315
+ allFiles: e.newState
316
316
  }), (r = this.$refs.inputElement) == null || r.focus();
317
317
  },
318
- handleRemoveFile(t) {
319
- this.isFilesControlled || (this.stateFiles = this.stateFiles.filter((o) => o.name !== t));
320
- const e = this.$props.uploadButtonConfig, i = typeof e == "object" && e, s = i ? i.onRemoveAttachment : void 0;
321
- s && (this.onRemoveAttachmentCallback = s), this.onRemoveAttachmentCallback && this.onRemoveAttachmentCallback(t);
318
+ handleRemoveFile(e) {
319
+ this.isFilesControlled || (this.stateFiles = this.stateFiles.filter((o) => o.name !== e));
320
+ const t = this.$props.uploadButtonConfig, i = typeof t == "object" && t, s = i ? i.onRemoveAttachment : void 0;
321
+ s && (this.onRemoveAttachmentCallback = s), this.onRemoveAttachmentCallback && this.onRemoveAttachmentCallback(e);
322
322
  },
323
- renderAffix(t, e) {
324
- return t ? typeof t == "function" ? t(e) : t : null;
323
+ renderAffix(e, t) {
324
+ return e ? typeof e == "function" ? e(t) : e : null;
325
325
  }
326
326
  },
327
327
  render() {
328
- const t = at(this), {
329
- mode: e,
328
+ const e = ae(this), {
329
+ mode: t,
330
330
  fillMode: i,
331
331
  maxTextAreaHeight: s,
332
332
  disabled: o,
333
333
  readOnly: r,
334
334
  placeholder: c,
335
- title: m,
336
- maxLength: B,
335
+ title: g,
336
+ maxLength: v,
337
337
  inputAttributes: O,
338
338
  topAffix: z,
339
339
  startAffix: u,
340
340
  endAffix: p,
341
341
  header: L,
342
342
  loading: d,
343
- speechToTextButtonConfig: v,
343
+ speechToTextButtonConfig: B,
344
344
  actionButtonConfig: b,
345
345
  uploadButtonConfig: A
346
346
  } = this.$props, a = {
347
347
  uploadButtonProps: {
348
348
  fillMode: "flat",
349
- svgIcon: st,
349
+ svgIcon: se,
350
350
  size: "small",
351
351
  rounded: "full",
352
352
  onClick: this.handleUploadButtonClick,
353
353
  onFilesAdd: this.onFilesSelect,
354
354
  files: this.currentFiles,
355
355
  _uploadRef: this._uploadRef,
356
- "aria-label": t.toLanguageString(x, h[x]),
357
- title: t.toLanguageString(x, h[x]),
356
+ "aria-label": e.toLanguageString(x, h[x]),
357
+ title: e.toLanguageString(x, h[x]),
358
358
  _registerRemoveCallback: (C) => {
359
359
  this.onRemoveAttachmentCallback = C || null;
360
360
  }
@@ -368,43 +368,43 @@ const l = "k-prompt-box", ht = 20, ut = 50, yt = /* @__PURE__ */ U({
368
368
  actionButtonProps: {
369
369
  rounded: "full",
370
370
  size: "small",
371
- svgIcon: d ? et : it,
372
- class: d ? "k-generating" : "",
371
+ svgIcon: d ? te : ie,
372
+ class: d ? "k-generating k-active" : "",
373
373
  onClick: this.handleActionButtonClick,
374
374
  onMousedown: this.handleButtonMouseDown,
375
375
  disabled: !d && !this.canSendMessage,
376
- "aria-disabled": !d && !this.canSendMessage,
377
- "aria-label": d ? t.toLanguageString(g, h[g]) : t.toLanguageString($, h[$]),
378
- title: d ? t.toLanguageString(g, h[g]) : t.toLanguageString($, h[$]),
376
+ "aria-disabled": !d && !this.canSendMessage ? !0 : void 0,
377
+ "aria-label": d ? e.toLanguageString(m, h[m]) : e.toLanguageString($, h[$]),
378
+ title: d ? e.toLanguageString(m, h[m]) : e.toLanguageString($, h[$]),
379
379
  "aria-live": "polite"
380
380
  }
381
381
  }, y = () => {
382
- const C = v !== !1, k = b !== !1, I = A !== !1, P = typeof v == "object" ? v : void 0, _ = typeof A == "object" ? A : {}, {
382
+ const C = B !== !1, M = b !== !1, I = A !== !1, P = typeof B == "object" ? B : void 0, _ = typeof A == "object" ? A : {}, {
383
383
  restrictions: j,
384
384
  multiple: V = !0,
385
385
  accept: D,
386
- onSelectAttachments: pt,
387
- onRemoveAttachment: dt,
386
+ onSelectAttachments: pe,
387
+ onRemoveAttachment: de,
388
388
  ...N
389
389
  } = _, F = {
390
390
  restrictions: j,
391
391
  multiple: V,
392
392
  accept: D
393
393
  }, W = typeof b == "object" ? b : void 0;
394
- return n(G, null, [I && n(lt, f({
394
+ return n(G, null, [I && n(le, f({
395
395
  ref: "uploadButton"
396
396
  }, a.uploadButtonProps, {
397
397
  restrictions: F.restrictions,
398
398
  multiple: F.multiple,
399
399
  accept: F.accept
400
- }, N), null), C && n(ot, f(a.speechToTextButtonProps, P), null), k && n(nt, f(a.actionButtonProps, W), null)]);
400
+ }, N), null), C && n(oe, f(a.speechToTextButtonProps, P), null), M && n(ne, f(a.actionButtonProps, W), null)]);
401
401
  }, H = {
402
402
  disabled: o,
403
403
  readOnly: r,
404
404
  placeholder: c,
405
- title: m,
406
- maxLength: B,
407
- "aria-label": t.toLanguageString(R, h[R]),
405
+ title: g,
406
+ maxLength: v,
407
+ "aria-label": e.toLanguageString(R, h[R]),
408
408
  value: this.currentValue,
409
409
  onKeydown: this.handleKeyDown,
410
410
  ...O,
@@ -412,7 +412,7 @@ const l = "k-prompt-box", ht = 20, ut = 50, yt = /* @__PURE__ */ U({
412
412
  onFocus: this.handleFocus,
413
413
  onBlur: this.handleBlur,
414
414
  ref: "inputElement"
415
- }, M = () => n("div", {
415
+ }, k = () => n("div", {
416
416
  class: `${l}-content`
417
417
  }, [u && n("div", {
418
418
  class: `${l}-affix`
@@ -422,9 +422,9 @@ const l = "k-prompt-box", ht = 20, ut = 50, yt = /* @__PURE__ */ U({
422
422
  class: `${l}-affix`
423
423
  }, [p && this.renderAffix(p, a), y()]) : null]), w = () => n("div", {
424
424
  class: `${l}-content`
425
- }, [e === "multi" && z && n("div", {
425
+ }, [t === "multi" && z && n("div", {
426
426
  class: `${l}-affix`
427
- }, [this.renderAffix(z, a)]), e === "auto" && u && n("div", {
427
+ }, [this.renderAffix(z, a)]), t === "auto" && u && n("div", {
428
428
  class: `${l}-affix`,
429
429
  style: {
430
430
  display: this.hasExpanded ? "none" : void 0
@@ -435,9 +435,9 @@ const l = "k-prompt-box", ht = 20, ut = 50, yt = /* @__PURE__ */ U({
435
435
  style: s ? {
436
436
  maxHeight: s
437
437
  } : {}
438
- }, this.isMultilineLayout && {
438
+ }, t !== "single" && {
439
439
  "aria-multiline": "true"
440
- }), null), e === "auto" && this.hasEndAffixOrButtons ? n("div", {
440
+ }), null), t === "auto" && this.hasEndAffixOrButtons ? n("div", {
441
441
  class: `${l}-affix`,
442
442
  style: {
443
443
  display: this.hasExpanded ? "none" : void 0
@@ -451,22 +451,22 @@ const l = "k-prompt-box", ht = 20, ut = 50, yt = /* @__PURE__ */ U({
451
451
  class: "k-spacer"
452
452
  }, null), p && this.renderAffix(p, a), y()]) : null]);
453
453
  return n("div", {
454
- "aria-label": t.toLanguageString(E, h[E]),
454
+ "aria-label": e.toLanguageString(E, h[E]),
455
455
  class: S("k-input", l, {
456
456
  [`k-input-${i}`]: i,
457
457
  "k-disabled": o,
458
- "k-prompt-box-singleline": e === "single",
458
+ "k-prompt-box-singleline": t === "single",
459
459
  "k-prompt-box-multiline": this.isMultilineLayout
460
460
  })
461
- }, [n(rt, {
461
+ }, [n(re, {
462
462
  files: this.currentFiles,
463
463
  onRemoveFile: this.handleRemoveFile,
464
464
  header: X.call(this, L, Z.call(this))
465
- }, null), e === "single" ? M() : w(), J(T) && n(Q, {
465
+ }, null), t === "single" ? k() : w(), J(T) && n(Q, {
466
466
  message: Y(T)
467
467
  }, null)]);
468
468
  }
469
469
  });
470
470
  export {
471
- yt as PromptBox
471
+ ye as PromptBox
472
472
  };