this.primereact=this.primereact||{},this.primereact.mention=function(e,t,n,r,i,o,s,l,a){"use strict";function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=u(t),c=u(a);function h(){return h=Object.assign||function(e){for(var t=1;t0?n.DomHandler.addClass(e.target,"p-filled"):n.DomHandler.removeClass(e.target,"p-filled"),this.props.onInput&&this.props.onInput(e)}},{key:"resize",value:function(e){var t=this.elementRef&&this.elementRef.current;t&&n.DomHandler.isVisible(t)&&(this.cachedScrollHeight||(this.cachedScrollHeight=t.scrollHeight,t.style.overflow="hidden"),(this.cachedScrollHeight!==t.scrollHeight||e)&&(t.style.height="",t.style.height=t.scrollHeight+"px",parseFloat(t.style.height)>=parseFloat(t.style.maxHeight)?(t.style.overflowY="scroll",t.style.height=t.style.maxHeight):t.style.overflow="hidden",this.cachedScrollHeight=t.scrollHeight))}},{key:"isFilled",value:function(){return null!=this.props.value&&this.props.value.toString().length>0||null!=this.props.defaultValue&&this.props.defaultValue.toString().length>0||this.elementRef&&this.elementRef.current&&this.elementRef.current.value.toString().length>0}},{key:"updateForwardRef",value:function(){var e=this.props.forwardRef;e&&("function"==typeof e?e(this.elementRef.current):e.current=this.elementRef.current)}},{key:"componentDidMount",value:function(){this.updateForwardRef(),this.props.tooltip&&this.renderTooltip(),this.props.autoResize&&this.resize(!0)}},{key:"componentDidUpdate",value:function(e){e.tooltip===this.props.tooltip&&e.tooltipOptions===this.props.tooltipOptions||(this.tooltip?this.tooltip.update(S({content:this.props.tooltip},this.props.tooltipOptions||{})):this.renderTooltip()),this.props.autoResize&&this.resize(!0)}},{key:"componentWillUnmount",value:function(){this.tooltip&&(this.tooltip.destroy(),this.tooltip=null)}},{key:"renderTooltip",value:function(){this.tooltip=l.tip({target:this.elementRef.current,content:this.props.tooltip,options:this.props.tooltipOptions})}},{key:"render",value:function(){var e=n.classNames("p-inputtextarea p-inputtext p-component",{"p-disabled":this.props.disabled,"p-filled":this.isFilled(),"p-inputtextarea-resizable":this.props.autoResize},this.props.className),t=n.ObjectUtils.findDiffKeys(this.props,s.defaultProps);return p.default.createElement("textarea",h({ref:this.elementRef},t,{className:e,onFocus:this.onFocus,onBlur:this.onBlur,onKeyUp:this.onKeyUp,onInput:this.onInput}))}}]),s}(t.Component);R(C,"defaultProps",{autoResize:!1,tooltip:null,tooltipOptions:null,onInput:null,forwardRef:null});var x=p.default.forwardRef((function(e,t){return p.default.createElement(C,h({forwardRef:t},e))}));function D(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function H(e){for(var t=1;ti)return o}return this.state.trigger}},{key:"getLatestTrigger",value:function(e,t){if(Array.isArray(this.props.trigger)){var n={};return this.props.trigger.forEach((function(r){var i=e.substring(0,t).lastIndexOf(r);-1!==i&&(i>n.index||!n.index)&&(n={key:r,index:-1!==i?i+1:-1})})),n}var r=e.substring(0,t).lastIndexOf(this.props.trigger);return{key:this.props.trigger,index:-1!==r?r+1:-1}}},{key:"onSearch",value:function(e){var t=this;this.timeout&&clearTimeout(this.timeout);var n=e.target,r=n.value,i=n.selectionStart,o=r.substring(i-1,i);if(" "!==o){var s=this.getTrigger(r,o,i);if(s&&s.index>-1){var l=r.substring(s.index,i);this.timeout=setTimeout((function(){t.search(e,l,s)}),this.props.delay)}}else this.hideOverlay()}},{key:"search",value:function(e,t,n){this.props.onSearch&&(this.setState({searching:!0,trigger:n}),this.props.onSearch({originalEvent:e,trigger:n.key,query:t}))}},{key:"selectItem",value:function(e,t){var n=this.inputRef.current.value,r=e.target.selectionStart,i=this.state.trigger,o=n.indexOf(" ",i.index),s=n.substring(i.index,o>-1?o:r),l=this.formatValue(t).replace(/\s+/g,"");if(s.trim()!==l){for(var a=0;a0?n.DomHandler.addClass(this.container,"p-inputwrapper-filled"):n.DomHandler.removeClass(this.container,"p-inputwrapper-filled")}},{key:"onKeyUp",value:function(e){37!==e.which&&39!==e.which||this.onSearch(e)}},{key:"onChange",value:function(e){this.props.onChange&&this.props.onChange(e),this.onSearch(e)}},{key:"onKeyDown",value:function(e){if(this.state.overlayVisible){var t=n.DomHandler.findSingle(this.overlayRef.current,"li.p-highlight");switch(e.which){case 40:if(t){var r=t.nextElementSibling;r&&(n.DomHandler.addClass(r,"p-highlight"),n.DomHandler.removeClass(t,"p-highlight"),n.DomHandler.scrollInView(this.overlayRef.current,r))}else(t=n.DomHandler.findSingle(this.overlayRef.current,"li"))&&n.DomHandler.addClass(t,"p-highlight");e.preventDefault();break;case 38:if(t){var i=t.previousElementSibling;i&&(n.DomHandler.addClass(i,"p-highlight"),n.DomHandler.removeClass(t,"p-highlight"),n.DomHandler.scrollInView(this.overlayRef.current,i))}e.preventDefault();break;case 8:var o=e.target,s=o.selectionStart;o.value.substring(s-1,s)===this.state.trigger.key&&this.hideOverlay();break;case 13:t&&this.selectItem(e,this.props.suggestions[n.DomHandler.index(t)]),e.preventDefault();break;case 27:this.hideOverlay(),e.preventDefault()}}}},{key:"bindDocumentClickListener",value:function(){var e=this;this.documentClickListener||(this.documentClickListener=function(t){3!==t.which&&e.state.overlayVisible&&e.isOutsideClicked(t)&&e.hideOverlay()},document.addEventListener("click",this.documentClickListener))}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"bindScrollListener",value:function(){var e=this;this.scrollHandler||(this.scrollHandler=new n.ConnectedOverlayScrollHandler(this.container,(function(){e.state.overlayVisible&&e.hideOverlay()}))),this.scrollHandler.bindScrollListener()}},{key:"unbindScrollListener",value:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()}},{key:"bindResizeListener",value:function(){var e=this;this.resizeListener||(this.resizeListener=function(){e.state.overlayVisible&&!n.DomHandler.isTouchDevice()&&e.hideOverlay()},window.addEventListener("resize",this.resizeListener))}},{key:"unbindResizeListener",value:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)}},{key:"isOutsideClicked",value:function(e){return this.container&&this.overlayRef&&this.overlayRef.current&&!this.overlayRef.current.contains(e.target)}},{key:"isFilled",value:function(){return null!=this.props.value&&this.props.value.toString().length>0||null!=this.props.defaultValue&&this.props.defaultValue.toString().length>0||this.inputRef&&this.inputRef.current&&this.inputRef.current.value.toString().length>0}},{key:"updateInputRef",value:function(){var e=this.props.inputRef;e&&("function"==typeof e?e(this.inputRef.current):e.current=this.inputRef.current)}},{key:"componentDidMount",value:function(){this.updateInputRef()}},{key:"componentDidUpdate",value:function(e){e.suggestions!==this.props.suggestions&&this.state.searching&&(this.props.suggestions&&this.props.suggestions.length?this.showOverlay():this.hideOverlay(),this.state.overlayVisible&&this.alignOverlay(),this.setState({searching:!1})),!this.isFilled()&&n.DomHandler.hasClass(this.container,"p-inputwrapper-filled")&&n.DomHandler.removeClass(this.container,"p-inputwrapper-filled")}},{key:"componentWillUnmount",value:function(){this.unbindDocumentClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),n.ZIndexUtils.clear(this.overlayRef.current)}},{key:"renderItem",value:function(e,t){var i=this,o=this.props.itemTemplate?n.ObjectUtils.getJSXElement(this.props.itemTemplate,e,{trigger:this.state.trigger?this.state.trigger.key:"",index:t}):this.formatValue(e);return p.default.createElement("li",{key:t+"_item",className:"p-mention-item",onClick:function(t){return i.onItemClick(t,e)}},o,p.default.createElement(r.Ripple,null))}},{key:"renderList",value:function(){var e=this;if(this.props.suggestions){var t=this.props.suggestions.map((function(t,n){return e.renderItem(t,n)}));return p.default.createElement("ul",{ref:function(t){return e.list=t},className:"p-mention-items"},t)}return null}},{key:"renderPanel",value:function(){var e=n.classNames("p-mention-panel p-component",this.props.panelClassName),t=H({maxHeight:this.props.scrollHeight},this.props.panelStyle),r=n.ObjectUtils.getJSXElement(this.props.headerTemplate,this.props),i=n.ObjectUtils.getJSXElement(this.props.footerTemplate,this.props),l=this.renderList();return p.default.createElement(s.Portal,{element:p.default.createElement(o.CSSTransition,{nodeRef:this.overlayRef,classNames:"p-connected-overlay",in:this.state.overlayVisible,timeout:{enter:120,exit:100},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.onOverlayEnter,onEntering:this.onOverlayEntering,onEntered:this.onOverlayEntered,onExit:this.onOverlayExit,onExited:this.onOverlayExited},p.default.createElement("div",{ref:this.overlayRef,className:e,style:t,onClick:this.onPanelClick},r,l,i)),appendTo:"self"})}},{key:"render",value:function(){var e=this,t=n.classNames("p-mention p-component p-inputwrapper",{"p-inputwrapper-filled":this.isFilled(),"p-inputwrapper-focus":this.state.focused},this.props.className),r=n.classNames("p-mention-input",this.props.inputClassName),i=n.ObjectUtils.findDiffKeys(this.props,d.defaultProps),o=this.renderPanel();return p.default.createElement("div",{ref:function(t){return e.container=t},id:this.props.id,className:t,style:this.props.style},p.default.createElement(x,h({ref:this.inputRef,id:this.props.inputId},i,{className:r,style:this.props.inputStyle,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onInput:this.onInput,onKeyUp:this.onKeyUp,onChange:this.onChange})),o)}}]),d}(t.Component);return R(P,"defaultProps",{id:null,inputId:null,inputRef:null,style:null,className:null,trigger:"@",suggestions:null,field:null,inputStyle:null,inputClassName:null,panelClassName:null,panelStyle:null,scrollHeight:"200px",autoHighlight:!0,delay:0,headerTemplate:null,footerTemplate:null,itemTemplate:null,transitionOptions:null,onChange:null,onInput:null,onSearch:null,onSelect:null,onFocus:null,onBlur:null,onShow:null,onHide:null}),e.Mention=P,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils,primereact.ripple,primereact.overlayservice,primereact.csstransition,primereact.portal,primereact.tooltip,primereact.api);