"),t=V(t),t},genSelectTemplate(s){if(typeof s>"u")return`${this.autocompleteTribute.current.collection.trigger}${this.autocompleteTribute.current.mentionText}`;const t=this.userData[s];return t?this.renderComponentHtml(t,gt).replace(/[\n\t]/gmi,"").replace(/>\s+<"):[" ","/",":"].every(e=>!s.includes(e))?`@${s}`:`@"${s}"`},renderComponentHtml(s,t){const e=Z(t,{...s}),i=document.createElement("div");i.style.display="none",document.body.appendChild(i),e.mount(i);const n=i.innerHTML;return e.unmount(),i.remove(),n}}},xt={name:"NcAutoCompleteResult",components:{NcUserStatusIcon:z},props:{label:{type:String,required:!1,default:null},subline:{type:String,default:null},id:{type:String,default:null},icon:{type:String,required:!0},iconUrl:{type:String,default:null},source:{type:String,required:!0},status:{type:[Object,Array],default:()=>({})}},setup(){return{isDarkTheme:q()}},computed:{avatarUrl(){return this.iconUrl?this.iconUrl:this.id&&this.source==="users"?B(this.id,{isDarkTheme:this.isDarkTheme}):null}}},At={class:"autocomplete-result"},Mt={key:0,class:"autocomplete-result__status autocomplete-result__status--icon"},It={class:"autocomplete-result__content"},_t=["title"],Lt={key:0,class:"autocomplete-result__subline"};function kt(s,t,e,i,n,r){const o=Y("NcUserStatusIcon");return E(),A("div",At,[T("div",{class:O([[e.icon,`autocomplete-result__icon--${r.avatarUrl?"with-avatar":""}`],"autocomplete-result__icon"]),style:F(r.avatarUrl?{backgroundImage:`url(${r.avatarUrl})`}:null)},[e.status.icon?(E(),A("span",Mt,k(e.status&&e.status.icon||""),1)):e.status.status&&e.status.status!=="offline"?(E(),X(o,{key:1,class:"autocomplete-result__status",status:e.status.status},null,8,["status"])):W("",!0)],6),T("span",It,[T("span",{class:"autocomplete-result__title",title:e.label},k(e.label),9,_t),e.subline?(E(),A("span",Lt,k(e.subline),1)):W("",!0)])])}const $t=H(xt,[["render",kt],["__scopeId","data-v-ca83b679"]]);G(tt,J);const Nt={"material-design-icon":"_material-design-icon_UrExO","tribute-container":"_tribute-container_aTO5r","tribute-container__item":"_tribute-container__item_EHZ07","tribute-container--focus-visible":"_tribute-container--focus-visible_GHsDW","tribute-container-autocomplete":"_tribute-container-autocomplete_YNk1h","tribute-container-emoji":"_tribute-container-emoji_jWgZX","tribute-container-link":"_tribute-container-link_1b7mc","tribute-item":"_tribute-item_p5sRT","tribute-item__title":"_tribute-item__title_VPcy9","tribute-item__icon":"_tribute-item__icon_aTxCU"},Dt=["d","D","p","P","s","S","x","X",")","(","|","/"],$=[];Dt.forEach(s=>{$.push(":"+s),$.push(":-"+s)});let L=null;const Ot={name:"NcRichContenteditable",mixins:[Et],inheritAttrs:!1,props:{id:{type:String,default:()=>D()},label:{type:String,default:""},modelValue:{type:String,required:!0},placeholder:{type:String,default:P("Write a message …")},autoComplete:{type:Function,default:()=>[]},menuContainer:{type:[String,Element,null],default:null},multiline:{type:Boolean,default:!1},contenteditable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},maxlength:{type:Number,default:null},emojiAutocomplete:{type:Boolean,default:!0},linkAutocomplete:{type:Boolean,default:!0},class:{type:[String,Array,Object],default:""}},emits:["paste","update:modelValue","smartPickerSubmit","submit"],setup(){const s=new Intl.Segmenter;if(L===null)try{document.createElement("div").contentEditable="plaintext-only",L=!0}catch(t){U.debug("[NcRichContenteditable] Unsupported attribute value:",{error:t}),L=!1}return{labelId:D(),tributeId:D(),segmenter:s,tribute:null,tributeStyleMutationObserver:null}},data(){return{localValue:this.modelValue,isComposing:!1,isAutocompleteOpen:!1,autocompleteActiveId:void 0,isTributeIntegrationDone:!1}},computed:{isEmptyValue(){return!this.localValue||this.localValue.trim()===""},isOverMaxlength(){return this.isEmptyValue||!this.maxlength?!1:[...this.segmenter.segment(this.localValue)].length>this.maxlength},tooltipString(){return this.isOverMaxlength?et("Message limit of %n character reached","Message limit of %n characters reached",this.maxlength):null},contenteditableAttributeValue(){return this.contenteditable&&!this.disabled?L?"plaintext-only":"true":"false"},debouncedAutoComplete(){return j(async(s,t)=>{this.autoComplete(s,t)},100)}},watch:{modelValue(){const s=this.$refs.contenteditable.innerHTML;this.modelValue.trim()!==this.parseContent(s).trim()&&this.updateContent(this.modelValue)}},mounted(){this.initializeTribute(),this.updateContent(this.modelValue)},beforeUnmount(){this.tribute&&this.tribute.detach(this.$refs.contenteditable),this.tributeStyleMutationObserver&&this.tributeStyleMutationObserver.disconnect()},methods:{focus(){this.$refs.contenteditable.focus()},initializeTribute(){const s=i=>`
${i}
`,t=[];t.push({fillAttr:"id",lookup:i=>`${i.id} ${i.label??i.title}`,requireLeadingSpace:!0,menuItemTemplate:i=>s(this.renderComponentHtml(i.original,$t)),noMatchTemplate:()=>'
',selectTemplate:i=>this.genSelectTemplate(i?.original?.id),values:this.debouncedAutoComplete,containerClass:`${this.$style["tribute-container"]} ${this.$style["tribute-container-autocomplete"]}`,itemClass:this.$style["tribute-container__item"]}),this.emojiAutocomplete&&t.push({trigger:":",lookup:(i,n)=>n,requireLeadingSpace:!0,menuItemTemplate:i=>$.includes(i.original)?i.original:s(`
${i.original.native} :${i.original.short_name}`),noMatchTemplate:()=>P("No emoji found"),selectTemplate:i=>$.includes(i.original)?i.original:(nt(i.original),i.original.native),values:(i,n)=>{const r=it(i);$.includes(":"+i)&&r.unshift(":"+i),n(r)},containerClass:`${this.$style["tribute-container"]} ${this.$style["tribute-container-emoji"]}`,itemClass:this.$style["tribute-container__item"]}),this.linkAutocomplete&&t.push({trigger:"/",lookup:(i,n)=>n,requireLeadingSpace:!0,menuItemTemplate:i=>s(`
${i.original.title}`),noMatchTemplate:()=>P("No link provider found"),selectTemplate:this.getLink,values:(i,n)=>n(st(i)),containerClass:`${this.$style["tribute-container"]} ${this.$style["tribute-container-link"]}`,itemClass:this.$style["tribute-container__item"]});const e=typeof this.menuContainer=="string"?document.querySelector(this.menuContainer):this.menuContainer;this.tribute=new S({collection:t,allowSpaces:!1,menuContainer:e}),this.tribute.attach(this.$refs.contenteditable),this.$refs.contenteditable.contentEditable=this.contenteditableAttributeValue},getLink(s){return ot(s.original.id).then(t=>{const e=document.getElementById("tmp-smart-picker-result-node"),i={result:t,insertText:!0};if(this.$emit("smartPickerSubmit",i),i.insertText){const n=document.createTextNode(t);e.replaceWith(n),this.setCursorAfter(n),this.updateValue(this.$refs.contenteditable.innerHTML)}else e.remove()}).catch(t=>{U.debug("[NcRichContenteditable] Smart picker promise rejected:",{error:t});const e=document.getElementById("tmp-smart-picker-result-node");this.setCursorAfter(e),e.remove()}),'
'},setCursorAfter(s){const t=document.createRange();t.setEndAfter(s),t.collapse();const e=window.getSelection();e.removeAllRanges(),e.addRange(t)},moveCursorToEnd(){if(!document.createRange||window.getSelection().rangeCount>0&&this.$refs.contenteditable.contains(window.getSelection().getRangeAt(0).commonAncestorContainer))return;const s=document.createRange();s.selectNodeContents(this.$refs.contenteditable),s.collapse(!1);const t=window.getSelection();t.removeAllRanges(),t.addRange(s)},onInput(s){this.updateValue(s.target.innerHTML)},onPaste(s){if(!(!this.contenteditable||this.disabled)){if(L)this.$emit("paste",s);else{s.preventDefault();const t=s.clipboardData;if(this.$emit("paste",s),t.files.length!==0||!Object.values(t.items).find(n=>n?.type.startsWith("text")))return;const e=t.getData("text"),i=window.getSelection().getRangeAt(0);i.deleteContents(),i.insertNode(document.createTextNode(e)),i.collapse(!1)}this.updateValue(this.$refs.contenteditable.innerHTML)}},updateValue(s){const t=this.parseContent(s).replace(/^\n$/,"");this.localValue=t,this.$emit("update:modelValue",t)},updateContent(s){const t=this.renderContent(s);this.$refs.contenteditable.innerHTML=t,this.localValue=s},onEnter(s){this.multiline||this.isOverMaxlength||this.tribute.isActive||this.isComposing||(s.preventDefault(),s.stopPropagation(),this.$emit("submit",s))},onCtrlEnter(s){this.isOverMaxlength||this.$emit("submit",s)},onKeyUp(s){s.stopImmediatePropagation()},onKeyEsc(s){this.tribute&&this.isAutocompleteOpen&&(s.stopImmediatePropagation(),this.tribute.hideMenu())},getTributeContainer(){return this.tribute.menu},getTributeSelectedItem(){return this.getTributeContainer().querySelector('.highlight [id^="nc-rich-contenteditable-tribute-item-"]')},onTributeActive(s){this.isAutocompleteOpen=s,s?(this.getTributeContainer().setAttribute("class",this.tribute.current.collection.containerClass||this.$style["tribute-container"]),this.setupTributeIntegration(),document.removeEventListener("click",this.hideTribute,!0)):(this.debouncedAutoComplete.clear(),this.autocompleteActiveId=void 0,this.setTributeFocusVisible(!1))},onTributeArrowKeyDown(){this.isAutocompleteOpen&&(this.setTributeFocusVisible(!0),this.onTributeSelectedItemWillChange())},onTributeSelectedItemWillChange(){requestAnimationFrame(()=>{this.autocompleteActiveId=this.getTributeSelectedItem()?.id})},setupTributeIntegration(){if(this.isTributeIntegrationDone)return;this.isTributeIntegrationDone=!0;const s=this.getTributeContainer();s.id=this.tributeId,s.setAttribute("role","listbox"),s.children[0].setAttribute("role","presentation"),this.tributeStyleMutationObserver=new MutationObserver(([{target:t}])=>{t.style.display!=="none"&&this.onTributeSelectedItemWillChange()}).observe(s,{attributes:!0,attributeFilter:["style"]}),s.addEventListener("mousemove",()=>{this.setTributeFocusVisible(!1),this.onTributeSelectedItemWillChange()},{passive:!0})},setTributeFocusVisible(s){s?this.getTributeContainer().classList.add(this.$style["tribute-container--focus-visible"]):this.getTributeContainer().classList.remove(this.$style["tribute-container--focus-visible"])},showTribute(s){this.focus();const t=this.tribute.collection.findIndex(e=>e.trigger===s);this.tribute.showMenuForCollection(this.$refs.contenteditable,t),this.updateValue(this.$refs.contenteditable.innerHTML),document.addEventListener("click",this.hideTribute,!0)},hideTribute(){this.tribute.hideMenu(),document.removeEventListener("click",this.hideTribute,!0)}}},Rt=["id","contenteditable","aria-labelledby","aria-placeholder","aria-controls","aria-expanded","aria-activedescendant","title"],Pt=["id"];function Wt(s,t,e,i,n,r){return E(),A("div",{class:O(["rich-contenteditable",s.$props.class])},[T("div",Q({id:e.id,ref:"contenteditable",class:[{"rich-contenteditable__input--empty":r.isEmptyValue,"rich-contenteditable__input--multiline":e.multiline,"rich-contenteditable__input--has-label":e.label,"rich-contenteditable__input--overflow":r.isOverMaxlength,"rich-contenteditable__input--disabled":e.disabled},"rich-contenteditable__input"],contenteditable:r.contenteditableAttributeValue,"aria-labelledby":e.label?i.labelId:void 0,"aria-placeholder":e.placeholder,"aria-multiline":"true",role:"textbox","aria-haspopup":"listbox","aria-autocomplete":"inline","aria-controls":i.tributeId,"aria-expanded":n.isAutocompleteOpen?"true":"false","aria-activedescendant":n.autocompleteActiveId,title:r.tooltipString},s.$attrs,{onFocus:t[0]||(t[0]=(...o)=>r.moveCursorToEnd&&r.moveCursorToEnd(...o)),onInput:t[1]||(t[1]=(...o)=>r.onInput&&r.onInput(...o)),onCompositionstart:t[2]||(t[2]=o=>n.isComposing=!0),onCompositionend:t[3]||(t[3]=o=>n.isComposing=!1),onKeydownCapture:t[4]||(t[4]=_((...o)=>r.onKeyEsc&&r.onKeyEsc(...o),["esc"])),onKeydown:[t[5]||(t[5]=_(I((...o)=>r.onEnter&&r.onEnter(...o),["exact"]),["enter"])),t[6]||(t[6]=_(I((...o)=>r.onCtrlEnter&&r.onCtrlEnter(...o),["ctrl","exact","stop","prevent"]),["enter"])),t[9]||(t[9]=_(I((...o)=>r.onTributeArrowKeyDown&&r.onTributeArrowKeyDown(...o),["exact","stop"]),["up"])),t[10]||(t[10]=_(I((...o)=>r.onTributeArrowKeyDown&&r.onTributeArrowKeyDown(...o),["exact","stop"]),["down"]))],onPaste:t[7]||(t[7]=(...o)=>r.onPaste&&r.onPaste(...o)),onKeyupCapture:t[8]||(t[8]=I((...o)=>r.onKeyUp&&r.onKeyUp(...o),["stop","prevent"])),onTributeActiveTrue:t[11]||(t[11]=o=>r.onTributeActive(!0)),onTributeActiveFalse:t[12]||(t[12]=o=>r.onTributeActive(!1))}),null,16,Rt),e.label?(E(),A("div",{key:0,id:i.labelId,class:"rich-contenteditable__label"},k(e.label),9,Pt)):W("",!0)],2)}const Ht={$style:Nt},ue=H(Ot,[["render",Wt],["__cssModules",Ht],["__scopeId","data-v-9234d45e"]]);export{$t as NcAutoCompleteResult,gt as NcMentionBubble,ue as default};
-//# sourceMappingURL=index-CcOuN-F7.chunk.mjs.map
+//# sourceMappingURL=index-BrbJAHJ3.chunk.mjs.map
diff --git a/dist/index-CcOuN-F7.chunk.mjs.license b/dist/index-BrbJAHJ3.chunk.mjs.license
similarity index 100%
rename from dist/index-CcOuN-F7.chunk.mjs.license
rename to dist/index-BrbJAHJ3.chunk.mjs.license
diff --git a/dist/index-CcOuN-F7.chunk.mjs.map b/dist/index-BrbJAHJ3.chunk.mjs.map
similarity index 99%
rename from dist/index-CcOuN-F7.chunk.mjs.map
rename to dist/index-BrbJAHJ3.chunk.mjs.map
index 9919849e022..224da54380c 100644
--- a/dist/index-CcOuN-F7.chunk.mjs.map
+++ b/dist/index-BrbJAHJ3.chunk.mjs.map
@@ -1 +1 @@
-{"version":3,"file":"index-CcOuN-F7.chunk.mjs","sources":["../node_modules/tributejs/dist/tribute.esm.js","../node_modules/@nextcloud/vue/dist/chunks/NcRichContenteditable-DO3_WniI.mjs"],"sourcesContent":["if (!Array.prototype.find) {\n Array.prototype.find = function(predicate) {\n if (this === null) {\n throw new TypeError('Array.prototype.find called on null or undefined')\n }\n if (typeof predicate !== 'function') {\n throw new TypeError('predicate must be a function')\n }\n var list = Object(this);\n var length = list.length >>> 0;\n var thisArg = arguments[1];\n var value;\n\n for (var i = 0; i < length; i++) {\n value = list[i];\n if (predicate.call(thisArg, value, i, list)) {\n return value\n }\n }\n return undefined\n };\n}\n\nif (window && typeof window.CustomEvent !== \"function\") {\n function CustomEvent$1(event, params) {\n params = params || {\n bubbles: false,\n cancelable: false,\n detail: undefined\n };\n var evt = document.createEvent('CustomEvent');\n evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n return evt\n }\n\n if (typeof window.Event !== 'undefined') {\n CustomEvent$1.prototype = window.Event.prototype;\n }\n\n window.CustomEvent = CustomEvent$1;\n}\n\nclass TributeEvents {\n constructor(tribute) {\n this.tribute = tribute;\n this.tribute.events = this;\n }\n\n static keys() {\n return [\n {\n key: 9,\n value: \"TAB\"\n },\n {\n key: 8,\n value: \"DELETE\"\n },\n {\n key: 13,\n value: \"ENTER\"\n },\n {\n key: 27,\n value: \"ESCAPE\"\n },\n {\n key: 32,\n value: \"SPACE\"\n },\n {\n key: 38,\n value: \"UP\"\n },\n {\n key: 40,\n value: \"DOWN\"\n }\n ];\n }\n\n bind(element) {\n element.boundKeydown = this.keydown.bind(element, this);\n element.boundKeyup = this.keyup.bind(element, this);\n element.boundInput = this.input.bind(element, this);\n\n element.addEventListener(\"keydown\", element.boundKeydown, false);\n element.addEventListener(\"keyup\", element.boundKeyup, false);\n element.addEventListener(\"input\", element.boundInput, false);\n }\n\n unbind(element) {\n element.removeEventListener(\"keydown\", element.boundKeydown, false);\n element.removeEventListener(\"keyup\", element.boundKeyup, false);\n element.removeEventListener(\"input\", element.boundInput, false);\n\n delete element.boundKeydown;\n delete element.boundKeyup;\n delete element.boundInput;\n }\n\n keydown(instance, event) {\n if (instance.shouldDeactivate(event)) {\n instance.tribute.isActive = false;\n instance.tribute.hideMenu();\n }\n\n let element = this;\n instance.commandEvent = false;\n\n TributeEvents.keys().forEach(o => {\n if (o.key === event.keyCode) {\n instance.commandEvent = true;\n instance.callbacks()[o.value.toLowerCase()](event, element);\n }\n });\n }\n\n input(instance, event) {\n instance.inputEvent = true;\n instance.keyup.call(this, instance, event);\n }\n\n click(instance, event) {\n let tribute = instance.tribute;\n if (tribute.menu && tribute.menu.contains(event.target)) {\n let li = event.target;\n event.preventDefault();\n event.stopPropagation();\n while (li.nodeName.toLowerCase() !== \"li\") {\n li = li.parentNode;\n if (!li || li === tribute.menu) {\n throw new Error(\"cannot find the
container for the click\");\n }\n }\n tribute.selectItemAtIndex(li.getAttribute(\"data-index\"), event);\n tribute.hideMenu();\n\n // TODO: should fire with externalTrigger and target is outside of menu\n } else if (tribute.current.element && !tribute.current.externalTrigger) {\n tribute.current.externalTrigger = false;\n setTimeout(() => tribute.hideMenu());\n }\n }\n\n keyup(instance, event) {\n if (instance.inputEvent) {\n instance.inputEvent = false;\n }\n instance.updateSelection(this);\n\n if (event.keyCode === 27) return;\n\n if (!instance.tribute.allowSpaces && instance.tribute.hasTrailingSpace) {\n instance.tribute.hasTrailingSpace = false;\n instance.commandEvent = true;\n instance.callbacks()[\"space\"](event, this);\n return;\n }\n\n if (!instance.tribute.isActive) {\n if (instance.tribute.autocompleteMode) {\n instance.callbacks().triggerChar(event, this, \"\");\n } else {\n let keyCode = instance.getKeyCode(instance, this, event);\n\n if (isNaN(keyCode) || !keyCode) return;\n\n let trigger = instance.tribute.triggers().find(trigger => {\n return trigger.charCodeAt(0) === keyCode;\n });\n\n if (typeof trigger !== \"undefined\") {\n instance.callbacks().triggerChar(event, this, trigger);\n }\n }\n }\n\n if (\n instance.tribute.current.mentionText.length <\n instance.tribute.current.collection.menuShowMinLength\n ) {\n return;\n }\n\n if (\n ((instance.tribute.current.trigger ||\n instance.tribute.autocompleteMode) &&\n instance.commandEvent === false) ||\n (instance.tribute.isActive && event.keyCode === 8)\n ) {\n instance.tribute.showMenuFor(this, true);\n }\n }\n\n shouldDeactivate(event) {\n if (!this.tribute.isActive) return false;\n\n if (this.tribute.current.mentionText.length === 0) {\n let eventKeyPressed = false;\n TributeEvents.keys().forEach(o => {\n if (event.keyCode === o.key) eventKeyPressed = true;\n });\n\n return !eventKeyPressed;\n }\n\n return false;\n }\n\n getKeyCode(instance, el, event) {\n let tribute = instance.tribute;\n let info = tribute.range.getTriggerInfo(\n false,\n tribute.hasTrailingSpace,\n true,\n tribute.allowSpaces,\n tribute.autocompleteMode\n );\n\n if (info) {\n return info.mentionTriggerChar.charCodeAt(0);\n } else {\n return false;\n }\n }\n\n updateSelection(el) {\n this.tribute.current.element = el;\n let info = this.tribute.range.getTriggerInfo(\n false,\n this.tribute.hasTrailingSpace,\n true,\n this.tribute.allowSpaces,\n this.tribute.autocompleteMode\n );\n\n if (info) {\n this.tribute.current.selectedPath = info.mentionSelectedPath;\n this.tribute.current.mentionText = info.mentionText;\n this.tribute.current.selectedOffset = info.mentionSelectedOffset;\n }\n }\n\n callbacks() {\n return {\n triggerChar: (e, el, trigger) => {\n let tribute = this.tribute;\n tribute.current.trigger = trigger;\n\n let collectionItem = tribute.collection.find(item => {\n return item.trigger === trigger;\n });\n\n tribute.current.collection = collectionItem;\n\n if (\n tribute.current.mentionText.length >=\n tribute.current.collection.menuShowMinLength &&\n tribute.inputEvent\n ) {\n tribute.showMenuFor(el, true);\n }\n },\n enter: (e, el) => {\n // choose selection\n if (this.tribute.isActive && this.tribute.current.filteredItems) {\n e.preventDefault();\n e.stopPropagation();\n setTimeout(() => {\n this.tribute.selectItemAtIndex(this.tribute.menuSelected, e);\n this.tribute.hideMenu();\n }, 0);\n }\n },\n escape: (e, el) => {\n if (this.tribute.isActive) {\n e.preventDefault();\n e.stopPropagation();\n this.tribute.isActive = false;\n this.tribute.hideMenu();\n }\n },\n tab: (e, el) => {\n // choose first match\n this.callbacks().enter(e, el);\n },\n space: (e, el) => {\n if (this.tribute.isActive) {\n if (this.tribute.spaceSelectsMatch) {\n this.callbacks().enter(e, el);\n } else if (!this.tribute.allowSpaces) {\n e.stopPropagation();\n setTimeout(() => {\n this.tribute.hideMenu();\n this.tribute.isActive = false;\n }, 0);\n }\n }\n },\n up: (e, el) => {\n // navigate up ul\n if (this.tribute.isActive && this.tribute.current.filteredItems) {\n e.preventDefault();\n e.stopPropagation();\n let count = this.tribute.current.filteredItems.length,\n selected = this.tribute.menuSelected;\n\n if (count > selected && selected > 0) {\n this.tribute.menuSelected--;\n this.setActiveLi();\n } else if (selected === 0) {\n this.tribute.menuSelected = count - 1;\n this.setActiveLi();\n this.tribute.menu.scrollTop = this.tribute.menu.scrollHeight;\n }\n }\n },\n down: (e, el) => {\n // navigate down ul\n if (this.tribute.isActive && this.tribute.current.filteredItems) {\n e.preventDefault();\n e.stopPropagation();\n let count = this.tribute.current.filteredItems.length - 1,\n selected = this.tribute.menuSelected;\n\n if (count > selected) {\n this.tribute.menuSelected++;\n this.setActiveLi();\n } else if (count === selected) {\n this.tribute.menuSelected = 0;\n this.setActiveLi();\n this.tribute.menu.scrollTop = 0;\n }\n }\n },\n delete: (e, el) => {\n if (\n this.tribute.isActive &&\n this.tribute.current.mentionText.length < 1\n ) {\n this.tribute.hideMenu();\n } else if (this.tribute.isActive) {\n this.tribute.showMenuFor(el);\n }\n }\n };\n }\n\n setActiveLi(index) {\n let lis = this.tribute.menu.querySelectorAll(\"li\"),\n length = lis.length >>> 0;\n\n if (index) this.tribute.menuSelected = parseInt(index);\n\n for (let i = 0; i < length; i++) {\n let li = lis[i];\n if (i === this.tribute.menuSelected) {\n li.classList.add(this.tribute.current.collection.selectClass);\n\n let liClientRect = li.getBoundingClientRect();\n let menuClientRect = this.tribute.menu.getBoundingClientRect();\n\n if (liClientRect.bottom > menuClientRect.bottom) {\n let scrollDistance = liClientRect.bottom - menuClientRect.bottom;\n this.tribute.menu.scrollTop += scrollDistance;\n } else if (liClientRect.top < menuClientRect.top) {\n let scrollDistance = menuClientRect.top - liClientRect.top;\n this.tribute.menu.scrollTop -= scrollDistance;\n }\n } else {\n li.classList.remove(this.tribute.current.collection.selectClass);\n }\n }\n }\n\n getFullHeight(elem, includeMargin) {\n let height = elem.getBoundingClientRect().height;\n\n if (includeMargin) {\n let style = elem.currentStyle || window.getComputedStyle(elem);\n return (\n height + parseFloat(style.marginTop) + parseFloat(style.marginBottom)\n );\n }\n\n return height;\n }\n}\n\nclass TributeMenuEvents {\n constructor(tribute) {\n this.tribute = tribute;\n this.tribute.menuEvents = this;\n this.menu = this.tribute.menu;\n }\n\n bind(menu) {\n this.menuClickEvent = this.tribute.events.click.bind(null, this);\n this.menuContainerScrollEvent = this.debounce(\n () => {\n if (this.tribute.isActive) {\n this.tribute.showMenuFor(this.tribute.current.element, false);\n }\n },\n 300,\n false\n );\n this.windowResizeEvent = this.debounce(\n () => {\n if (this.tribute.isActive) {\n this.tribute.range.positionMenuAtCaret(true);\n }\n },\n 300,\n false\n );\n\n // fixes IE11 issues with mousedown\n this.tribute.range\n .getDocument()\n .addEventListener(\"MSPointerDown\", this.menuClickEvent, false);\n this.tribute.range\n .getDocument()\n .addEventListener(\"mousedown\", this.menuClickEvent, false);\n window.addEventListener(\"resize\", this.windowResizeEvent);\n\n if (this.menuContainer) {\n this.menuContainer.addEventListener(\n \"scroll\",\n this.menuContainerScrollEvent,\n false\n );\n } else {\n window.addEventListener(\"scroll\", this.menuContainerScrollEvent);\n }\n }\n\n unbind(menu) {\n this.tribute.range\n .getDocument()\n .removeEventListener(\"mousedown\", this.menuClickEvent, false);\n this.tribute.range\n .getDocument()\n .removeEventListener(\"MSPointerDown\", this.menuClickEvent, false);\n window.removeEventListener(\"resize\", this.windowResizeEvent);\n\n if (this.menuContainer) {\n this.menuContainer.removeEventListener(\n \"scroll\",\n this.menuContainerScrollEvent,\n false\n );\n } else {\n window.removeEventListener(\"scroll\", this.menuContainerScrollEvent);\n }\n }\n\n debounce(func, wait, immediate) {\n var timeout;\n return () => {\n var context = this,\n args = arguments;\n var later = () => {\n timeout = null;\n if (!immediate) func.apply(context, args);\n };\n var callNow = immediate && !timeout;\n clearTimeout(timeout);\n timeout = setTimeout(later, wait);\n if (callNow) func.apply(context, args);\n };\n }\n}\n\n// Thanks to https://github.com/jeff-collins/ment.io\n\nclass TributeRange {\n constructor(tribute) {\n this.tribute = tribute;\n this.tribute.range = this;\n }\n\n getDocument() {\n let iframe;\n if (this.tribute.current.collection) {\n iframe = this.tribute.current.collection.iframe;\n }\n\n if (!iframe) {\n return document\n }\n\n return iframe.contentWindow.document\n }\n\n positionMenuAtCaret(scrollTo) {\n let context = this.tribute.current,\n coordinates;\n\n let info = this.getTriggerInfo(false, this.tribute.hasTrailingSpace, true, this.tribute.allowSpaces, this.tribute.autocompleteMode);\n\n if (typeof info !== 'undefined') {\n\n if(!this.tribute.positionMenu){\n this.tribute.menu.style.cssText = `display: block;`;\n return\n }\n\n if (!this.isContentEditable(context.element)) {\n coordinates = this.getTextAreaOrInputUnderlinePosition(this.tribute.current.element,\n info.mentionPosition);\n }\n else {\n coordinates = this.getContentEditableCaretPosition(info.mentionPosition);\n }\n\n this.tribute.menu.style.cssText = `top: ${coordinates.top}px;\n left: ${coordinates.left}px;\n right: ${coordinates.right}px;\n bottom: ${coordinates.bottom}px;\n position: absolute;\n display: block;`;\n\n if (coordinates.left === 'auto') {\n this.tribute.menu.style.left = 'auto';\n }\n\n if (coordinates.top === 'auto') {\n this.tribute.menu.style.top = 'auto';\n }\n\n if (scrollTo) this.scrollIntoView();\n\n window.setTimeout(() => {\n let menuDimensions = {\n width: this.tribute.menu.offsetWidth,\n height: this.tribute.menu.offsetHeight\n };\n let menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions);\n\n let menuIsOffScreenHorizontally = window.innerWidth > menuDimensions.width && (menuIsOffScreen.left || menuIsOffScreen.right);\n let menuIsOffScreenVertically = window.innerHeight > menuDimensions.height && (menuIsOffScreen.top || menuIsOffScreen.bottom);\n if (menuIsOffScreenHorizontally || menuIsOffScreenVertically) {\n this.tribute.menu.style.cssText = 'display: none';\n this.positionMenuAtCaret(scrollTo);\n }\n }, 0);\n\n } else {\n this.tribute.menu.style.cssText = 'display: none';\n }\n }\n\n get menuContainerIsBody() {\n return this.tribute.menuContainer === document.body || !this.tribute.menuContainer;\n }\n\n\n selectElement(targetElement, path, offset) {\n let range;\n let elem = targetElement;\n\n if (path) {\n for (var i = 0; i < path.length; i++) {\n elem = elem.childNodes[path[i]];\n if (elem === undefined) {\n return\n }\n while (elem.length < offset) {\n offset -= elem.length;\n elem = elem.nextSibling;\n }\n if (elem.childNodes.length === 0 && !elem.length) {\n elem = elem.previousSibling;\n }\n }\n }\n let sel = this.getWindowSelection();\n\n range = this.getDocument().createRange();\n range.setStart(elem, offset);\n range.setEnd(elem, offset);\n range.collapse(true);\n\n try {\n sel.removeAllRanges();\n } catch (error) {}\n\n sel.addRange(range);\n targetElement.focus();\n }\n\n replaceTriggerText(text, requireLeadingSpace, hasTrailingSpace, originalEvent, item) {\n let info = this.getTriggerInfo(true, hasTrailingSpace, requireLeadingSpace, this.tribute.allowSpaces, this.tribute.autocompleteMode);\n\n if (info !== undefined) {\n let context = this.tribute.current;\n let replaceEvent = new CustomEvent('tribute-replaced', {\n detail: {\n item: item,\n instance: context,\n context: info,\n event: originalEvent,\n }\n });\n\n if (!this.isContentEditable(context.element)) {\n let myField = this.tribute.current.element;\n let textSuffix = typeof this.tribute.replaceTextSuffix == 'string'\n ? this.tribute.replaceTextSuffix\n : ' ';\n text += textSuffix;\n let startPos = info.mentionPosition;\n let endPos = info.mentionPosition + info.mentionText.length + textSuffix.length;\n if (!this.tribute.autocompleteMode) {\n endPos += info.mentionTriggerChar.length - 1;\n }\n myField.value = myField.value.substring(0, startPos) + text +\n myField.value.substring(endPos, myField.value.length);\n myField.selectionStart = startPos + text.length;\n myField.selectionEnd = startPos + text.length;\n } else {\n // add a space to the end of the pasted text\n let textSuffix = typeof this.tribute.replaceTextSuffix == 'string'\n ? this.tribute.replaceTextSuffix\n : '\\xA0';\n text += textSuffix;\n let endPos = info.mentionPosition + info.mentionText.length;\n if (!this.tribute.autocompleteMode) {\n endPos += info.mentionTriggerChar.length;\n }\n this.pasteHtml(text, info.mentionPosition, endPos);\n }\n\n context.element.dispatchEvent(new CustomEvent('input', { bubbles: true }));\n context.element.dispatchEvent(replaceEvent);\n }\n }\n\n pasteHtml(html, startPos, endPos) {\n let range, sel;\n sel = this.getWindowSelection();\n range = this.getDocument().createRange();\n range.setStart(sel.anchorNode, startPos);\n range.setEnd(sel.anchorNode, endPos);\n range.deleteContents();\n\n let el = this.getDocument().createElement('div');\n el.innerHTML = html;\n let frag = this.getDocument().createDocumentFragment(),\n node, lastNode;\n while ((node = el.firstChild)) {\n lastNode = frag.appendChild(node);\n }\n range.insertNode(frag);\n\n // Preserve the selection\n if (lastNode) {\n range = range.cloneRange();\n range.setStartAfter(lastNode);\n range.collapse(true);\n sel.removeAllRanges();\n sel.addRange(range);\n }\n }\n\n getWindowSelection() {\n if (this.tribute.collection.iframe) {\n return this.tribute.collection.iframe.contentWindow.getSelection()\n }\n\n return window.getSelection()\n }\n\n getNodePositionInParent(element) {\n if (element.parentNode === null) {\n return 0\n }\n\n for (var i = 0; i < element.parentNode.childNodes.length; i++) {\n let node = element.parentNode.childNodes[i];\n\n if (node === element) {\n return i\n }\n }\n }\n\n getContentEditableSelectedPath(ctx) {\n let sel = this.getWindowSelection();\n let selected = sel.anchorNode;\n let path = [];\n let offset;\n\n if (selected != null) {\n let i;\n let ce = selected.contentEditable;\n while (selected !== null && ce !== 'true') {\n i = this.getNodePositionInParent(selected);\n path.push(i);\n selected = selected.parentNode;\n if (selected !== null) {\n ce = selected.contentEditable;\n }\n }\n path.reverse();\n\n // getRangeAt may not exist, need alternative\n offset = sel.getRangeAt(0).startOffset;\n\n return {\n selected: selected,\n path: path,\n offset: offset\n }\n }\n }\n\n getTextPrecedingCurrentSelection() {\n let context = this.tribute.current,\n text = '';\n\n if (!this.isContentEditable(context.element)) {\n let textComponent = this.tribute.current.element;\n if (textComponent) {\n let startPos = textComponent.selectionStart;\n if (textComponent.value && startPos >= 0) {\n text = textComponent.value.substring(0, startPos);\n }\n }\n\n } else {\n let selectedElem = this.getWindowSelection().anchorNode;\n\n if (selectedElem != null) {\n let workingNodeContent = selectedElem.textContent;\n let selectStartOffset = this.getWindowSelection().getRangeAt(0).startOffset;\n\n if (workingNodeContent && selectStartOffset >= 0) {\n text = workingNodeContent.substring(0, selectStartOffset);\n }\n }\n }\n\n return text\n }\n\n getLastWordInText(text) {\n text = text.replace(/\\u00A0/g, ' '); // https://stackoverflow.com/questions/29850407/how-do-i-replace-unicode-character-u00a0-with-a-space-in-javascript\n let wordsArray = text.split(/\\s+/);\n let worldsCount = wordsArray.length - 1;\n return wordsArray[worldsCount].trim()\n }\n\n getTriggerInfo(menuAlreadyActive, hasTrailingSpace, requireLeadingSpace, allowSpaces, isAutocomplete) {\n let ctx = this.tribute.current;\n let selected, path, offset;\n\n if (!this.isContentEditable(ctx.element)) {\n selected = this.tribute.current.element;\n } else {\n let selectionInfo = this.getContentEditableSelectedPath(ctx);\n\n if (selectionInfo) {\n selected = selectionInfo.selected;\n path = selectionInfo.path;\n offset = selectionInfo.offset;\n }\n }\n\n let effectiveRange = this.getTextPrecedingCurrentSelection();\n let lastWordOfEffectiveRange = this.getLastWordInText(effectiveRange);\n\n if (isAutocomplete) {\n return {\n mentionPosition: effectiveRange.length - lastWordOfEffectiveRange.length,\n mentionText: lastWordOfEffectiveRange,\n mentionSelectedElement: selected,\n mentionSelectedPath: path,\n mentionSelectedOffset: offset\n }\n }\n\n if (effectiveRange !== undefined && effectiveRange !== null) {\n let mostRecentTriggerCharPos = -1;\n let triggerChar;\n\n this.tribute.collection.forEach(config => {\n let c = config.trigger;\n let idx = config.requireLeadingSpace ?\n this.lastIndexWithLeadingSpace(effectiveRange, c) :\n effectiveRange.lastIndexOf(c);\n\n if (idx > mostRecentTriggerCharPos) {\n mostRecentTriggerCharPos = idx;\n triggerChar = c;\n requireLeadingSpace = config.requireLeadingSpace;\n }\n });\n\n if (mostRecentTriggerCharPos >= 0 &&\n (\n mostRecentTriggerCharPos === 0 ||\n !requireLeadingSpace ||\n /[\\xA0\\s]/g.test(\n effectiveRange.substring(\n mostRecentTriggerCharPos - 1,\n mostRecentTriggerCharPos)\n )\n )\n ) {\n let currentTriggerSnippet = effectiveRange.substring(mostRecentTriggerCharPos + triggerChar.length,\n effectiveRange.length);\n\n triggerChar = effectiveRange.substring(mostRecentTriggerCharPos, mostRecentTriggerCharPos + triggerChar.length);\n let firstSnippetChar = currentTriggerSnippet.substring(0, 1);\n let leadingSpace = currentTriggerSnippet.length > 0 &&\n (\n firstSnippetChar === ' ' ||\n firstSnippetChar === '\\xA0'\n );\n if (hasTrailingSpace) {\n currentTriggerSnippet = currentTriggerSnippet.trim();\n }\n\n let regex = allowSpaces ? /[^\\S ]/g : /[\\xA0\\s]/g;\n\n this.tribute.hasTrailingSpace = regex.test(currentTriggerSnippet);\n\n if (!leadingSpace && (menuAlreadyActive || !(regex.test(currentTriggerSnippet)))) {\n return {\n mentionPosition: mostRecentTriggerCharPos,\n mentionText: currentTriggerSnippet,\n mentionSelectedElement: selected,\n mentionSelectedPath: path,\n mentionSelectedOffset: offset,\n mentionTriggerChar: triggerChar\n }\n }\n }\n }\n }\n\n lastIndexWithLeadingSpace (str, trigger) {\n let reversedStr = str.split('').reverse().join('');\n let index = -1;\n\n for (let cidx = 0, len = str.length; cidx < len; cidx++) {\n let firstChar = cidx === str.length - 1;\n let leadingSpace = /\\s/.test(reversedStr[cidx + 1]);\n\n let match = true;\n for (let triggerIdx = trigger.length - 1; triggerIdx >= 0; triggerIdx--) {\n if (trigger[triggerIdx] !== reversedStr[cidx-triggerIdx]) {\n match = false;\n break\n }\n }\n\n if (match && (firstChar || leadingSpace)) {\n index = str.length - 1 - cidx;\n break\n }\n }\n\n return index\n }\n\n isContentEditable(element) {\n return element.nodeName !== 'INPUT' && element.nodeName !== 'TEXTAREA'\n }\n\n isMenuOffScreen(coordinates, menuDimensions) {\n let windowWidth = window.innerWidth;\n let windowHeight = window.innerHeight;\n let doc = document.documentElement;\n let windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);\n let windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);\n\n let menuTop = typeof coordinates.top === 'number' ? coordinates.top : windowTop + windowHeight - coordinates.bottom - menuDimensions.height;\n let menuRight = typeof coordinates.right === 'number' ? coordinates.right : coordinates.left + menuDimensions.width;\n let menuBottom = typeof coordinates.bottom === 'number' ? coordinates.bottom : coordinates.top + menuDimensions.height;\n let menuLeft = typeof coordinates.left === 'number' ? coordinates.left : windowLeft + windowWidth - coordinates.right - menuDimensions.width;\n\n return {\n top: menuTop < Math.floor(windowTop),\n right: menuRight > Math.ceil(windowLeft + windowWidth),\n bottom: menuBottom > Math.ceil(windowTop + windowHeight),\n left: menuLeft < Math.floor(windowLeft)\n }\n }\n\n getMenuDimensions() {\n // Width of the menu depends of its contents and position\n // We must check what its width would be without any obstruction\n // This way, we can achieve good positioning for flipping the menu\n let dimensions = {\n width: null,\n height: null\n };\n\n this.tribute.menu.style.cssText = `top: 0px;\n left: 0px;\n position: fixed;\n display: block;\n visibility; hidden;`;\n dimensions.width = this.tribute.menu.offsetWidth;\n dimensions.height = this.tribute.menu.offsetHeight;\n\n this.tribute.menu.style.cssText = `display: none;`;\n\n return dimensions\n }\n\n getTextAreaOrInputUnderlinePosition(element, position, flipped) {\n let properties = ['direction', 'boxSizing', 'width', 'height', 'overflowX',\n 'overflowY', 'borderTopWidth', 'borderRightWidth',\n 'borderBottomWidth', 'borderLeftWidth', 'paddingTop',\n 'paddingRight', 'paddingBottom', 'paddingLeft',\n 'fontStyle', 'fontVariant', 'fontWeight', 'fontStretch',\n 'fontSize', 'fontSizeAdjust', 'lineHeight', 'fontFamily',\n 'textAlign', 'textTransform', 'textIndent',\n 'textDecoration', 'letterSpacing', 'wordSpacing'\n ];\n\n let isFirefox = (window.mozInnerScreenX !== null);\n\n let div = this.getDocument().createElement('div');\n div.id = 'input-textarea-caret-position-mirror-div';\n this.getDocument().body.appendChild(div);\n\n let style = div.style;\n let computed = window.getComputedStyle ? getComputedStyle(element) : element.currentStyle;\n\n style.whiteSpace = 'pre-wrap';\n if (element.nodeName !== 'INPUT') {\n style.wordWrap = 'break-word';\n }\n\n // position off-screen\n style.position = 'absolute';\n style.visibility = 'hidden';\n\n // transfer the element's properties to the div\n properties.forEach(prop => {\n style[prop] = computed[prop];\n });\n\n if (isFirefox) {\n style.width = `${(parseInt(computed.width) - 2)}px`;\n if (element.scrollHeight > parseInt(computed.height))\n style.overflowY = 'scroll';\n } else {\n style.overflow = 'hidden';\n }\n\n div.textContent = element.value.substring(0, position);\n\n if (element.nodeName === 'INPUT') {\n div.textContent = div.textContent.replace(/\\s/g, ' ');\n }\n\n let span = this.getDocument().createElement('span');\n span.textContent = element.value.substring(position) || '.';\n div.appendChild(span);\n\n let rect = element.getBoundingClientRect();\n let doc = document.documentElement;\n let windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);\n let windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);\n\n let top = 0;\n let left = 0;\n if (this.menuContainerIsBody) {\n top = rect.top;\n left = rect.left;\n }\n\n let coordinates = {\n top: top + windowTop + span.offsetTop + parseInt(computed.borderTopWidth) + parseInt(computed.fontSize) - element.scrollTop,\n left: left + windowLeft + span.offsetLeft + parseInt(computed.borderLeftWidth)\n };\n\n let windowWidth = window.innerWidth;\n let windowHeight = window.innerHeight;\n\n let menuDimensions = this.getMenuDimensions();\n let menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions);\n\n if (menuIsOffScreen.right) {\n coordinates.right = windowWidth - coordinates.left;\n coordinates.left = 'auto';\n }\n\n let parentHeight = this.tribute.menuContainer\n ? this.tribute.menuContainer.offsetHeight\n : this.getDocument().body.offsetHeight;\n\n if (menuIsOffScreen.bottom) {\n let parentRect = this.tribute.menuContainer\n ? this.tribute.menuContainer.getBoundingClientRect()\n : this.getDocument().body.getBoundingClientRect();\n let scrollStillAvailable = parentHeight - (windowHeight - parentRect.top);\n\n coordinates.bottom = scrollStillAvailable + (windowHeight - rect.top - span.offsetTop);\n coordinates.top = 'auto';\n }\n\n menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions);\n if (menuIsOffScreen.left) {\n coordinates.left = windowWidth > menuDimensions.width\n ? windowLeft + windowWidth - menuDimensions.width\n : windowLeft;\n delete coordinates.right;\n }\n if (menuIsOffScreen.top) {\n coordinates.top = windowHeight > menuDimensions.height\n ? windowTop + windowHeight - menuDimensions.height\n : windowTop;\n delete coordinates.bottom;\n }\n\n this.getDocument().body.removeChild(div);\n return coordinates\n }\n\n getContentEditableCaretPosition(selectedNodePosition) {\n let range;\n let sel = this.getWindowSelection();\n\n range = this.getDocument().createRange();\n range.setStart(sel.anchorNode, selectedNodePosition);\n range.setEnd(sel.anchorNode, selectedNodePosition);\n\n range.collapse(false);\n\n let rect = range.getBoundingClientRect();\n let doc = document.documentElement;\n let windowLeft = (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);\n let windowTop = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);\n\n let left = rect.left;\n let top = rect.top;\n\n let coordinates = {\n left: left + windowLeft,\n top: top + rect.height + windowTop\n };\n let windowWidth = window.innerWidth;\n let windowHeight = window.innerHeight;\n\n let menuDimensions = this.getMenuDimensions();\n let menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions);\n\n if (menuIsOffScreen.right) {\n coordinates.left = 'auto';\n coordinates.right = windowWidth - rect.left - windowLeft;\n }\n\n let parentHeight = this.tribute.menuContainer\n ? this.tribute.menuContainer.offsetHeight\n : this.getDocument().body.offsetHeight;\n\n if (menuIsOffScreen.bottom) {\n let parentRect = this.tribute.menuContainer\n ? this.tribute.menuContainer.getBoundingClientRect()\n : this.getDocument().body.getBoundingClientRect();\n let scrollStillAvailable = parentHeight - (windowHeight - parentRect.top);\n\n coordinates.top = 'auto';\n coordinates.bottom = scrollStillAvailable + (windowHeight - rect.top);\n }\n\n menuIsOffScreen = this.isMenuOffScreen(coordinates, menuDimensions);\n if (menuIsOffScreen.left) {\n coordinates.left = windowWidth > menuDimensions.width\n ? windowLeft + windowWidth - menuDimensions.width\n : windowLeft;\n delete coordinates.right;\n }\n if (menuIsOffScreen.top) {\n coordinates.top = windowHeight > menuDimensions.height\n ? windowTop + windowHeight - menuDimensions.height\n : windowTop;\n delete coordinates.bottom;\n }\n\n if (!this.menuContainerIsBody) {\n coordinates.left = coordinates.left ? coordinates.left - this.tribute.menuContainer.offsetLeft : coordinates.left;\n coordinates.top = coordinates.top ? coordinates.top - this.tribute.menuContainer.offsetTop : coordinates.top;\n }\n\n return coordinates\n }\n\n scrollIntoView(elem) {\n let reasonableBuffer = 20,\n clientRect;\n let maxScrollDisplacement = 100;\n let e = this.menu;\n\n if (typeof e === 'undefined') return;\n\n while (clientRect === undefined || clientRect.height === 0) {\n clientRect = e.getBoundingClientRect();\n\n if (clientRect.height === 0) {\n e = e.childNodes[0];\n if (e === undefined || !e.getBoundingClientRect) {\n return\n }\n }\n }\n\n let elemTop = clientRect.top;\n let elemBottom = elemTop + clientRect.height;\n\n if (elemTop < 0) {\n window.scrollTo(0, window.pageYOffset + clientRect.top - reasonableBuffer);\n } else if (elemBottom > window.innerHeight) {\n let maxY = window.pageYOffset + clientRect.top - reasonableBuffer;\n\n if (maxY - window.pageYOffset > maxScrollDisplacement) {\n maxY = window.pageYOffset + maxScrollDisplacement;\n }\n\n let targetY = window.pageYOffset - (window.innerHeight - elemBottom);\n\n if (targetY > maxY) {\n targetY = maxY;\n }\n\n window.scrollTo(0, targetY);\n }\n }\n}\n\n// Thanks to https://github.com/mattyork/fuzzy\nclass TributeSearch {\n constructor(tribute) {\n this.tribute = tribute;\n this.tribute.search = this;\n }\n\n simpleFilter(pattern, array) {\n return array.filter(string => {\n return this.test(pattern, string)\n })\n }\n\n test(pattern, string) {\n return this.match(pattern, string) !== null\n }\n\n match(pattern, string, opts) {\n opts = opts || {};\n let len = string.length,\n pre = opts.pre || '',\n post = opts.post || '',\n compareString = opts.caseSensitive && string || string.toLowerCase();\n\n if (opts.skip) {\n return {rendered: string, score: 0}\n }\n\n pattern = opts.caseSensitive && pattern || pattern.toLowerCase();\n\n let patternCache = this.traverse(compareString, pattern, 0, 0, []);\n if (!patternCache) {\n return null\n }\n return {\n rendered: this.render(string, patternCache.cache, pre, post),\n score: patternCache.score\n }\n }\n\n traverse(string, pattern, stringIndex, patternIndex, patternCache) {\n // if the pattern search at end\n if (pattern.length === patternIndex) {\n\n // calculate score and copy the cache containing the indices where it's found\n return {\n score: this.calculateScore(patternCache),\n cache: patternCache.slice()\n }\n }\n\n // if string at end or remaining pattern > remaining string\n if (string.length === stringIndex || pattern.length - patternIndex > string.length - stringIndex) {\n return undefined\n }\n\n let c = pattern[patternIndex];\n let index = string.indexOf(c, stringIndex);\n let best, temp;\n\n while (index > -1) {\n patternCache.push(index);\n temp = this.traverse(string, pattern, index + 1, patternIndex + 1, patternCache);\n patternCache.pop();\n\n // if downstream traversal failed, return best answer so far\n if (!temp) {\n return best\n }\n\n if (!best || best.score < temp.score) {\n best = temp;\n }\n\n index = string.indexOf(c, index + 1);\n }\n\n return best\n }\n\n calculateScore(patternCache) {\n let score = 0;\n let temp = 1;\n\n patternCache.forEach((index, i) => {\n if (i > 0) {\n if (patternCache[i - 1] + 1 === index) {\n temp += temp + 1;\n }\n else {\n temp = 1;\n }\n }\n\n score += temp;\n });\n\n return score\n }\n\n render(string, indices, pre, post) {\n var rendered = string.substring(0, indices[0]);\n\n indices.forEach((index, i) => {\n rendered += pre + string[index] + post +\n string.substring(index + 1, (indices[i + 1]) ? indices[i + 1] : string.length);\n });\n\n return rendered\n }\n\n filter(pattern, arr, opts) {\n opts = opts || {};\n return arr\n .reduce((prev, element, idx, arr) => {\n let str = element;\n\n if (opts.extract) {\n str = opts.extract(element);\n\n if (!str) { // take care of undefineds / nulls / etc.\n str = '';\n }\n }\n\n let rendered = this.match(pattern, str, opts);\n\n if (rendered != null) {\n prev[prev.length] = {\n string: rendered.rendered,\n score: rendered.score,\n index: idx,\n original: element\n };\n }\n\n return prev\n }, [])\n\n .sort((a, b) => {\n let compare = b.score - a.score;\n if (compare) return compare\n return a.index - b.index\n })\n }\n}\n\nclass Tribute {\n constructor({\n values = null,\n iframe = null,\n selectClass = \"highlight\",\n containerClass = \"tribute-container\",\n itemClass = \"\",\n trigger = \"@\",\n autocompleteMode = false,\n selectTemplate = null,\n menuItemTemplate = null,\n lookup = \"key\",\n fillAttr = \"value\",\n collection = null,\n menuContainer = null,\n noMatchTemplate = null,\n requireLeadingSpace = true,\n allowSpaces = false,\n replaceTextSuffix = null,\n positionMenu = true,\n spaceSelectsMatch = false,\n searchOpts = {},\n menuItemLimit = null,\n menuShowMinLength = 0\n }) {\n this.autocompleteMode = autocompleteMode;\n this.menuSelected = 0;\n this.current = {};\n this.inputEvent = false;\n this.isActive = false;\n this.menuContainer = menuContainer;\n this.allowSpaces = allowSpaces;\n this.replaceTextSuffix = replaceTextSuffix;\n this.positionMenu = positionMenu;\n this.hasTrailingSpace = false;\n this.spaceSelectsMatch = spaceSelectsMatch;\n\n if (this.autocompleteMode) {\n trigger = \"\";\n allowSpaces = false;\n }\n\n if (values) {\n this.collection = [\n {\n // symbol that starts the lookup\n trigger: trigger,\n\n // is it wrapped in an iframe\n iframe: iframe,\n\n // class applied to selected item\n selectClass: selectClass,\n\n // class applied to the Container\n containerClass: containerClass,\n\n // class applied to each item\n itemClass: itemClass,\n\n // function called on select that retuns the content to insert\n selectTemplate: (\n selectTemplate || Tribute.defaultSelectTemplate\n ).bind(this),\n\n // function called that returns content for an item\n menuItemTemplate: (\n menuItemTemplate || Tribute.defaultMenuItemTemplate\n ).bind(this),\n\n // function called when menu is empty, disables hiding of menu.\n noMatchTemplate: (t => {\n if (typeof t === \"string\") {\n if (t.trim() === \"\") return null;\n return t;\n }\n if (typeof t === \"function\") {\n return t.bind(this);\n }\n\n return (\n noMatchTemplate ||\n function() {\n return \"No Match Found!\";\n }.bind(this)\n );\n })(noMatchTemplate),\n\n // column to search against in the object\n lookup: lookup,\n\n // column that contains the content to insert by default\n fillAttr: fillAttr,\n\n // array of objects or a function returning an array of objects\n values: values,\n\n requireLeadingSpace: requireLeadingSpace,\n\n searchOpts: searchOpts,\n\n menuItemLimit: menuItemLimit,\n\n menuShowMinLength: menuShowMinLength\n }\n ];\n } else if (collection) {\n if (this.autocompleteMode)\n console.warn(\n \"Tribute in autocomplete mode does not work for collections\"\n );\n this.collection = collection.map(item => {\n return {\n trigger: item.trigger || trigger,\n iframe: item.iframe || iframe,\n selectClass: item.selectClass || selectClass,\n containerClass: item.containerClass || containerClass,\n itemClass: item.itemClass || itemClass,\n selectTemplate: (\n item.selectTemplate || Tribute.defaultSelectTemplate\n ).bind(this),\n menuItemTemplate: (\n item.menuItemTemplate || Tribute.defaultMenuItemTemplate\n ).bind(this),\n // function called when menu is empty, disables hiding of menu.\n noMatchTemplate: (t => {\n if (typeof t === \"string\") {\n if (t.trim() === \"\") return null;\n return t;\n }\n if (typeof t === \"function\") {\n return t.bind(this);\n }\n\n return (\n noMatchTemplate ||\n function() {\n return \"
No Match Found!\";\n }.bind(this)\n );\n })(noMatchTemplate),\n lookup: item.lookup || lookup,\n fillAttr: item.fillAttr || fillAttr,\n values: item.values,\n requireLeadingSpace: item.requireLeadingSpace,\n searchOpts: item.searchOpts || searchOpts,\n menuItemLimit: item.menuItemLimit || menuItemLimit,\n menuShowMinLength: item.menuShowMinLength || menuShowMinLength\n };\n });\n } else {\n throw new Error(\"[Tribute] No collection specified.\");\n }\n\n new TributeRange(this);\n new TributeEvents(this);\n new TributeMenuEvents(this);\n new TributeSearch(this);\n }\n\n get isActive() {\n return this._isActive;\n }\n\n set isActive(val) {\n if (this._isActive != val) {\n this._isActive = val;\n if (this.current.element) {\n let noMatchEvent = new CustomEvent(`tribute-active-${val}`);\n this.current.element.dispatchEvent(noMatchEvent);\n }\n }\n }\n\n static defaultSelectTemplate(item) {\n if (typeof item === \"undefined\")\n return `${this.current.collection.trigger}${this.current.mentionText}`;\n if (this.range.isContentEditable(this.current.element)) {\n return (\n '
' +\n (this.current.collection.trigger +\n item.original[this.current.collection.fillAttr]) +\n \"\"\n );\n }\n\n return (\n this.current.collection.trigger +\n item.original[this.current.collection.fillAttr]\n );\n }\n\n static defaultMenuItemTemplate(matchItem) {\n return matchItem.string;\n }\n\n static inputTypes() {\n return [\"TEXTAREA\", \"INPUT\"];\n }\n\n triggers() {\n return this.collection.map(config => {\n return config.trigger;\n });\n }\n\n attach(el) {\n if (!el) {\n throw new Error(\"[Tribute] Must pass in a DOM node or NodeList.\");\n }\n\n // Check if it is a jQuery collection\n if (typeof jQuery !== \"undefined\" && el instanceof jQuery) {\n el = el.get();\n }\n\n // Is el an Array/Array-like object?\n if (\n el.constructor === NodeList ||\n el.constructor === HTMLCollection ||\n el.constructor === Array\n ) {\n let length = el.length;\n for (var i = 0; i < length; ++i) {\n this._attach(el[i]);\n }\n } else {\n this._attach(el);\n }\n }\n\n _attach(el) {\n if (el.hasAttribute(\"data-tribute\")) {\n console.warn(\"Tribute was already bound to \" + el.nodeName);\n }\n\n this.ensureEditable(el);\n this.events.bind(el);\n el.setAttribute(\"data-tribute\", true);\n }\n\n ensureEditable(element) {\n if (Tribute.inputTypes().indexOf(element.nodeName) === -1) {\n if (element.contentEditable) {\n element.contentEditable = true;\n } else {\n throw new Error(\"[Tribute] Cannot bind to \" + element.nodeName);\n }\n }\n }\n\n createMenu(containerClass) {\n let wrapper = this.range.getDocument().createElement(\"div\"),\n ul = this.range.getDocument().createElement(\"ul\");\n wrapper.className = containerClass;\n wrapper.appendChild(ul);\n\n if (this.menuContainer) {\n return this.menuContainer.appendChild(wrapper);\n }\n\n return this.range.getDocument().body.appendChild(wrapper);\n }\n\n showMenuFor(element, scrollTo) {\n // Only proceed if menu isn't already shown for the current element & mentionText\n if (\n this.isActive &&\n this.current.element === element &&\n this.current.mentionText === this.currentMentionTextSnapshot\n ) {\n return;\n }\n this.currentMentionTextSnapshot = this.current.mentionText;\n\n // create the menu if it doesn't exist.\n if (!this.menu) {\n this.menu = this.createMenu(this.current.collection.containerClass);\n element.tributeMenu = this.menu;\n this.menuEvents.bind(this.menu);\n }\n\n this.isActive = true;\n this.menuSelected = 0;\n\n if (!this.current.mentionText) {\n this.current.mentionText = \"\";\n }\n\n const processValues = values => {\n // Tribute may not be active any more by the time the value callback returns\n if (!this.isActive) {\n return;\n }\n\n let items = this.search.filter(this.current.mentionText, values, {\n pre: this.current.collection.searchOpts.pre || \"
\",\n post: this.current.collection.searchOpts.post || \"\",\n skip: this.current.collection.searchOpts.skip,\n extract: el => {\n if (typeof this.current.collection.lookup === \"string\") {\n return el[this.current.collection.lookup];\n } else if (typeof this.current.collection.lookup === \"function\") {\n return this.current.collection.lookup(el, this.current.mentionText);\n } else {\n throw new Error(\n \"Invalid lookup attribute, lookup must be string or function.\"\n );\n }\n }\n });\n\n if (this.current.collection.menuItemLimit) {\n items = items.slice(0, this.current.collection.menuItemLimit);\n }\n\n this.current.filteredItems = items;\n\n let ul = this.menu.querySelector(\"ul\");\n\n this.range.positionMenuAtCaret(scrollTo);\n\n if (!items.length) {\n let noMatchEvent = new CustomEvent(\"tribute-no-match\", {\n detail: this.menu\n });\n this.current.element.dispatchEvent(noMatchEvent);\n if (\n (typeof this.current.collection.noMatchTemplate === \"function\" &&\n !this.current.collection.noMatchTemplate()) ||\n !this.current.collection.noMatchTemplate\n ) {\n this.hideMenu();\n } else {\n typeof this.current.collection.noMatchTemplate === \"function\"\n ? (ul.innerHTML = this.current.collection.noMatchTemplate())\n : (ul.innerHTML = this.current.collection.noMatchTemplate);\n }\n\n return;\n }\n\n ul.innerHTML = \"\";\n let fragment = this.range.getDocument().createDocumentFragment();\n\n items.forEach((item, index) => {\n let li = this.range.getDocument().createElement(\"li\");\n li.setAttribute(\"data-index\", index);\n li.className = this.current.collection.itemClass;\n li.addEventListener(\"mousemove\", e => {\n let [li, index] = this._findLiTarget(e.target);\n if (e.movementY !== 0) {\n this.events.setActiveLi(index);\n }\n });\n if (this.menuSelected === index) {\n li.classList.add(this.current.collection.selectClass);\n }\n li.innerHTML = this.current.collection.menuItemTemplate(item);\n fragment.appendChild(li);\n });\n ul.appendChild(fragment);\n };\n\n if (typeof this.current.collection.values === \"function\") {\n this.current.collection.values(this.current.mentionText, processValues);\n } else {\n processValues(this.current.collection.values);\n }\n }\n\n _findLiTarget(el) {\n if (!el) return [];\n const index = el.getAttribute(\"data-index\");\n return !index ? this._findLiTarget(el.parentNode) : [el, index];\n }\n\n showMenuForCollection(element, collectionIndex) {\n if (element !== document.activeElement) {\n this.placeCaretAtEnd(element);\n }\n\n this.current.collection = this.collection[collectionIndex || 0];\n this.current.externalTrigger = true;\n this.current.element = element;\n\n if (element.isContentEditable)\n this.insertTextAtCursor(this.current.collection.trigger);\n else this.insertAtCaret(element, this.current.collection.trigger);\n\n this.showMenuFor(element);\n }\n\n // TODO: make sure this works for inputs/textareas\n placeCaretAtEnd(el) {\n el.focus();\n if (\n typeof window.getSelection != \"undefined\" &&\n typeof document.createRange != \"undefined\"\n ) {\n var range = document.createRange();\n range.selectNodeContents(el);\n range.collapse(false);\n var sel = window.getSelection();\n sel.removeAllRanges();\n sel.addRange(range);\n } else if (typeof document.body.createTextRange != \"undefined\") {\n var textRange = document.body.createTextRange();\n textRange.moveToElementText(el);\n textRange.collapse(false);\n textRange.select();\n }\n }\n\n // for contenteditable\n insertTextAtCursor(text) {\n var sel, range;\n sel = window.getSelection();\n range = sel.getRangeAt(0);\n range.deleteContents();\n var textNode = document.createTextNode(text);\n range.insertNode(textNode);\n range.selectNodeContents(textNode);\n range.collapse(false);\n sel.removeAllRanges();\n sel.addRange(range);\n }\n\n // for regular inputs\n insertAtCaret(textarea, text) {\n var scrollPos = textarea.scrollTop;\n var caretPos = textarea.selectionStart;\n\n var front = textarea.value.substring(0, caretPos);\n var back = textarea.value.substring(\n textarea.selectionEnd,\n textarea.value.length\n );\n textarea.value = front + text + back;\n caretPos = caretPos + text.length;\n textarea.selectionStart = caretPos;\n textarea.selectionEnd = caretPos;\n textarea.focus();\n textarea.scrollTop = scrollPos;\n }\n\n hideMenu() {\n if (this.menu) {\n this.menu.style.cssText = \"display: none;\";\n this.isActive = false;\n this.menuSelected = 0;\n this.current = {};\n }\n }\n\n selectItemAtIndex(index, originalEvent) {\n index = parseInt(index);\n if (typeof index !== \"number\" || isNaN(index)) return;\n let item = this.current.filteredItems[index];\n let content = this.current.collection.selectTemplate(item);\n if (content !== null) this.replaceText(content, originalEvent, item);\n }\n\n replaceText(content, originalEvent, item) {\n this.range.replaceTriggerText(content, true, true, originalEvent, item);\n }\n\n _append(collection, newValues, replace) {\n if (typeof collection.values === \"function\") {\n throw new Error(\"Unable to append to values, as it is a function.\");\n } else if (!replace) {\n collection.values = collection.values.concat(newValues);\n } else {\n collection.values = newValues;\n }\n }\n\n append(collectionIndex, newValues, replace) {\n let index = parseInt(collectionIndex);\n if (typeof index !== \"number\")\n throw new Error(\"please provide an index for the collection to update.\");\n\n let collection = this.collection[index];\n\n this._append(collection, newValues, replace);\n }\n\n appendCurrent(newValues, replace) {\n if (this.isActive) {\n this._append(this.current.collection, newValues, replace);\n } else {\n throw new Error(\n \"No active state. Please use append instead and pass an index.\"\n );\n }\n }\n\n detach(el) {\n if (!el) {\n throw new Error(\"[Tribute] Must pass in a DOM node or NodeList.\");\n }\n\n // Check if it is a jQuery collection\n if (typeof jQuery !== \"undefined\" && el instanceof jQuery) {\n el = el.get();\n }\n\n // Is el an Array/Array-like object?\n if (\n el.constructor === NodeList ||\n el.constructor === HTMLCollection ||\n el.constructor === Array\n ) {\n let length = el.length;\n for (var i = 0; i < length; ++i) {\n this._detach(el[i]);\n }\n } else {\n this._detach(el);\n }\n }\n\n _detach(el) {\n this.events.unbind(el);\n if (el.tributeMenu) {\n this.menuEvents.unbind(el.tributeMenu);\n }\n\n setTimeout(() => {\n el.removeAttribute(\"data-tribute\");\n this.isActive = false;\n if (el.tributeMenu) {\n el.tributeMenu.remove();\n }\n });\n }\n}\n\n/**\n * Tribute.js\n * Native ES6 JavaScript @mention Plugin\n **/\n\nexport default Tribute;\n","import '../assets/NcRichContenteditable-DNABzVif.css';\nimport debounce from \"debounce\";\nimport Tribute from \"tributejs/dist/tribute.esm.js\";\nimport { useIsDarkTheme } from \"../composables/useIsDarkTheme/index.mjs\";\nimport { g as getAvatarUrl } from \"./NcMentionBubble.vue_vue_type_style_index_0_scoped_45238efd_lang-BX_KxRP-.mjs\";\nimport { N as NcUserStatusIcon } from \"./NcUserStatusIcon-DsviB2Cr.mjs\";\nimport { openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, toDisplayString, createApp, resolveComponent, createBlock, createCommentVNode, mergeProps, withModifiers, withKeys } from \"vue\";\nimport { _ as _export_sfc } from \"./_plugin-vue_export-helper-1tPrXgE0.mjs\";\nimport { a as emojiSearch, e as emojiAddRecent } from \"./emoji-C8k9NUlo.mjs\";\nimport { r as register, s as t37, J as t34, a as t, K as n } from \"./_l10n-CG4CuN3H.mjs\";\nimport escapeHTML from \"escape-html\";\nimport stripTags from \"striptags\";\nimport { c as createElementId } from \"./createElementId-DhjFt1I9.mjs\";\nimport { l as logger } from \"./logger-D3RVzcfQ.mjs\";\nimport \"@nextcloud/auth\";\nimport \"@nextcloud/axios\";\nimport \"@nextcloud/router\";\nimport \"@nextcloud/sharing/public\";\nimport \"@vueuse/core\";\nimport \"vue-router\";\nimport \"./legacy-BoqDmOCa.mjs\";\nimport \"./NcButton-QbPBynlU.mjs\";\nimport { g as getLinkWithPicker, s as searchProvider } from \"./referencePickerModal-B4bsiMOy.mjs\";\nimport \"./customPickerElements-Cu7bLbap.mjs\";\nimport \"unist-builder\";\nimport \"unist-util-visit-parents\";\nimport \"./NcRichText-BOBQq7Od.mjs\";\nimport \"./NcEmptyContent-CGAPqk4S.mjs\";\nimport \"./NcHighlight.vue_vue_type_script_lang-DnWQDM_2.mjs\";\nimport \"./NcSelect-BOFzoCwK.mjs\";\nimport \"./NcLoadingIcon-BOVpFVQz.mjs\";\nimport \"./NcTextField.vue_vue_type_script_setup_true_lang-BQHjkK8r.mjs\";\nimport \"dompurify\";\nimport \"./NcIconSvgWrapper-g8ubWhoz.mjs\";\nimport \"./NcInputField-B1bGxYHt.mjs\";\nimport \"@nextcloud/event-bus\";\nimport \"focus-trap\";\nimport \"./NcActions-CUmcZ3C3.mjs\";\nimport \"../composables/useFormatDateTime/index.mjs\";\nimport \"../composables/useHotKey/index.mjs\";\nimport \"../composables/useIsFullscreen/index.mjs\";\nimport \"../composables/useIsMobile/index.mjs\";\nimport \"./NcModal-DUWLRm_F.mjs\";\nimport \"./rtl-v0UOPAM7.mjs\";\nconst _sfc_main$2 = {\n name: \"NcMentionBubble\",\n /* eslint vue/require-prop-comment: warn -- TODO: Add a proper doc block about what this props do */\n props: {\n /**\n * Id of the bubble\n */\n id: {\n type: String,\n required: true\n },\n /**\n * The main text\n */\n label: {\n type: String,\n required: false,\n default: null\n },\n /**\n * Icon to be applied\n */\n icon: {\n type: String,\n required: true\n },\n /**\n * URL of the icon\n */\n iconUrl: {\n type: [String, null],\n default: null\n },\n source: {\n type: String,\n required: true\n },\n /**\n * Is the bubble shown as primary\n */\n primary: {\n type: Boolean,\n default: false\n }\n },\n setup() {\n const isDarkTheme = useIsDarkTheme();\n return {\n isDarkTheme\n };\n },\n computed: {\n avatarUrl() {\n if (this.iconUrl) {\n return this.iconUrl;\n }\n return this.id && this.source === \"users\" ? getAvatarUrl(this.id, { isDarkTheme: this.isDarkTheme }) : null;\n },\n mentionText() {\n return !this.id.includes(\" \") && !this.id.includes(\"/\") ? `@${this.id}` : `@\"${this.id}\"`;\n }\n }\n};\nconst _hoisted_1$2 = { class: \"mention-bubble__wrapper\" };\nconst _hoisted_2$2 = { class: \"mention-bubble__content\" };\nconst _hoisted_3$1 = [\"title\"];\nconst _hoisted_4$1 = {\n role: \"none\",\n class: \"mention-bubble__select\"\n};\nfunction _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {\n return openBlock(), createElementBlock(\"span\", {\n class: normalizeClass([\"mention-bubble\", { \"mention-bubble--primary\": $props.primary }]),\n contenteditable: \"false\"\n }, [\n createElementVNode(\"span\", _hoisted_1$2, [\n createElementVNode(\"span\", _hoisted_2$2, [\n createElementVNode(\"span\", {\n class: normalizeClass([[$props.icon, `mention-bubble__icon--${$options.avatarUrl ? \"with-avatar\" : \"\"}`], \"mention-bubble__icon\"]),\n style: normalizeStyle($options.avatarUrl ? { backgroundImage: `url(${$options.avatarUrl})` } : null)\n }, null, 6),\n createElementVNode(\"span\", {\n role: \"heading\",\n class: \"mention-bubble__title\",\n title: $props.label\n }, null, 8, _hoisted_3$1)\n ]),\n createElementVNode(\"span\", _hoisted_4$1, toDisplayString($options.mentionText), 1)\n ])\n ], 2);\n}\nconst NcMentionBubble = /* @__PURE__ */ _export_sfc(_sfc_main$2, [[\"render\", _sfc_render$2], [\"__scopeId\", \"data-v-45238efd\"]]);\nconst MENTION_START = /(?=[a-z0-9_\\-@.'])\\B/.source;\nconst MENTION_SIMPLE = /(@[a-z0-9_\\-@.']+)/.source;\nconst MENTION_GUEST = /@"(?:guest|email){1}\\/[a-f0-9]+"/.source;\nconst MENTION_PREFIXED = /@"(?:federated_)?(?:group|team|user){1}\\/[a-z0-9_\\-@.' /:]+"/.source;\nconst MENTION_WITH_SPACE = /@"[a-z0-9_\\-@.' ]+"/.source;\nconst MENTION_COMPLEX = `(${MENTION_GUEST}|${MENTION_PREFIXED}|${MENTION_WITH_SPACE})`;\nconst USERID_REGEX = new RegExp(`${MENTION_START}${MENTION_SIMPLE}`, \"gi\");\nconst USERID_REGEX_WITH_SPACE = new RegExp(`${MENTION_START}${MENTION_COMPLEX}`, \"gi\");\nconst richEditor = {\n props: {\n userData: {\n type: Object,\n default: () => ({})\n }\n },\n methods: {\n /**\n * Convert the value string to html for the inner content\n *\n * @param {string} value the content without html\n * @return {string} rendered html\n */\n renderContent(value) {\n const sanitizedValue = escapeHTML(value);\n const splitValue = sanitizedValue.split(USERID_REGEX).map((part) => part.split(USERID_REGEX_WITH_SPACE)).flat();\n return splitValue.map((part) => {\n if (!part.startsWith(\"@\")) {\n return part;\n }\n const id = part.slice(1).replace(/"/gi, \"\");\n return this.genSelectTemplate(id);\n }).join(\"\").replace(/\\n/gmi, \"
\").replace(/&/gmi, \"&\");\n },\n /**\n * Convert the innerHtml content to a string with mentions as text\n *\n * @param {string} content the content without html\n * @return {string}\n */\n parseContent(content) {\n let text = content;\n text = text.replace(/
/gmi, \"\\n\");\n text = text.replace(/ /gmi, \" \");\n text = text.replace(/&/gmi, \"&\");\n text = text.replace(/<\\/div>/gmi, \"\\n\");\n text = stripTags(text, \"
\");\n text = stripTags(text);\n return text;\n },\n /**\n * Generate an autocompletion popup entry template\n *\n * @param {string} value the value to match against the userData\n * @return {string}\n */\n genSelectTemplate(value) {\n if (typeof value === \"undefined\") {\n return `${this.autocompleteTribute.current.collection.trigger}${this.autocompleteTribute.current.mentionText}`;\n }\n const data = this.userData[value];\n if (!data) {\n return [\" \", \"/\", \":\"].every((char) => !value.includes(char)) ? `@${value}` : `@\"${value}\"`;\n }\n return this.renderComponentHtml(data, NcMentionBubble).replace(/[\\n\\t]/gmi, \"\").replace(/>\\s+<\");\n },\n /**\n * Render a component and return its html content\n *\n * @param {object} props the props to pass to the component\n * @param {object} component the component to render\n * @return {string} the rendered html\n */\n renderComponentHtml(props, component) {\n const Item = createApp(component, {\n ...props\n });\n const mount = document.createElement(\"div\");\n mount.style.display = \"none\";\n document.body.appendChild(mount);\n Item.mount(mount);\n const renderedHtml = mount.innerHTML;\n Item.unmount();\n mount.remove();\n return renderedHtml;\n }\n }\n};\nconst _sfc_main$1 = {\n name: \"NcAutoCompleteResult\",\n components: {\n NcUserStatusIcon\n },\n /* eslint vue/require-prop-comment: warn -- TODO: Add a proper doc block about what this props do */\n props: {\n /**\n * The label text\n */\n label: {\n type: String,\n required: false,\n default: null\n },\n /**\n * The secondary line of text if any\n */\n subline: {\n type: String,\n default: null\n },\n /**\n * Unique id\n */\n id: {\n type: String,\n default: null\n },\n /**\n * The icon class\n */\n icon: {\n type: String,\n required: true\n },\n /**\n * Icon as external URL\n */\n iconUrl: {\n type: String,\n default: null\n },\n source: {\n type: String,\n required: true\n },\n status: {\n type: [Object, Array],\n default: () => ({})\n }\n },\n setup() {\n const isDarkTheme = useIsDarkTheme();\n return {\n isDarkTheme\n };\n },\n computed: {\n avatarUrl() {\n if (this.iconUrl) {\n return this.iconUrl;\n }\n return this.id && this.source === \"users\" ? getAvatarUrl(this.id, { isDarkTheme: this.isDarkTheme }) : null;\n }\n }\n};\nconst _hoisted_1$1 = { class: \"autocomplete-result\" };\nconst _hoisted_2$1 = {\n key: 0,\n class: \"autocomplete-result__status autocomplete-result__status--icon\"\n};\nconst _hoisted_3 = { class: \"autocomplete-result__content\" };\nconst _hoisted_4 = [\"title\"];\nconst _hoisted_5 = {\n key: 0,\n class: \"autocomplete-result__subline\"\n};\nfunction _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {\n const _component_NcUserStatusIcon = resolveComponent(\"NcUserStatusIcon\");\n return openBlock(), createElementBlock(\"div\", _hoisted_1$1, [\n createElementVNode(\"div\", {\n class: normalizeClass([[$props.icon, `autocomplete-result__icon--${$options.avatarUrl ? \"with-avatar\" : \"\"}`], \"autocomplete-result__icon\"]),\n style: normalizeStyle($options.avatarUrl ? { backgroundImage: `url(${$options.avatarUrl})` } : null)\n }, [\n $props.status.icon ? (openBlock(), createElementBlock(\"span\", _hoisted_2$1, toDisplayString($props.status && $props.status.icon || \"\"), 1)) : $props.status.status && $props.status.status !== \"offline\" ? (openBlock(), createBlock(_component_NcUserStatusIcon, {\n key: 1,\n class: \"autocomplete-result__status\",\n status: $props.status.status\n }, null, 8, [\"status\"])) : createCommentVNode(\"\", true)\n ], 6),\n createElementVNode(\"span\", _hoisted_3, [\n createElementVNode(\"span\", {\n class: \"autocomplete-result__title\",\n title: $props.label\n }, toDisplayString($props.label), 9, _hoisted_4),\n $props.subline ? (openBlock(), createElementBlock(\"span\", _hoisted_5, toDisplayString($props.subline), 1)) : createCommentVNode(\"\", true)\n ])\n ]);\n}\nconst NcAutoCompleteResult = /* @__PURE__ */ _export_sfc(_sfc_main$1, [[\"render\", _sfc_render$1], [\"__scopeId\", \"data-v-ca83b679\"]]);\nregister(t34, t37);\nconst style1 = {\n \"material-design-icon\": \"_material-design-icon_UrExO\",\n \"tribute-container\": \"_tribute-container_aTO5r\",\n \"tribute-container__item\": \"_tribute-container__item_EHZ07\",\n \"tribute-container--focus-visible\": \"_tribute-container--focus-visible_GHsDW\",\n \"tribute-container-autocomplete\": \"_tribute-container-autocomplete_YNk1h\",\n \"tribute-container-emoji\": \"_tribute-container-emoji_jWgZX\",\n \"tribute-container-link\": \"_tribute-container-link_1b7mc\",\n \"tribute-item\": \"_tribute-item_p5sRT\",\n \"tribute-item__title\": \"_tribute-item__title_VPcy9\",\n \"tribute-item__icon\": \"_tribute-item__icon_aTxCU\"\n};\nconst smilesCharacters = [\"d\", \"D\", \"p\", \"P\", \"s\", \"S\", \"x\", \"X\", \")\", \"(\", \"|\", \"/\"];\nconst textSmiles = [];\nsmilesCharacters.forEach((char) => {\n textSmiles.push(\":\" + char);\n textSmiles.push(\":-\" + char);\n});\nlet isPlaintextOnlySupported = null;\nconst _sfc_main = {\n name: \"NcRichContenteditable\",\n mixins: [richEditor],\n inheritAttrs: false,\n props: {\n /**\n * The ID attribute of the content editable\n */\n id: {\n type: String,\n default: () => createElementId()\n },\n /**\n * Visual label of the contenteditable\n */\n label: {\n type: String,\n default: \"\"\n },\n /**\n * The text content\n */\n modelValue: {\n type: String,\n required: true\n },\n /**\n * Placeholder to be shown if empty\n */\n placeholder: {\n type: String,\n default: t(\"Write a message …\")\n },\n /**\n * Auto complete function\n */\n autoComplete: {\n type: Function,\n default: () => []\n },\n /**\n * The containing element or selector for the tribute (menu popover)\n * Defaults to `body` element\n */\n menuContainer: {\n type: [String, Element, null],\n default: null\n },\n /**\n * Make the contenteditable looks like a textarea or not.\n * Default looks like a single-line input.\n * This also handle the default enter/shift+enter behaviour.\n * if multiline, enter = newline; otherwise enter = submit\n * shift+enter always add a new line. ctrl+enter always submits\n */\n multiline: {\n type: Boolean,\n default: false\n },\n /**\n * Is the content editable ?\n */\n contenteditable: {\n type: Boolean,\n default: true\n },\n /**\n * Disable the editing and show specific disabled design\n */\n disabled: {\n type: Boolean,\n default: false\n },\n /**\n * Max allowed length\n */\n maxlength: {\n type: Number,\n default: null\n },\n /**\n * Enable or disable emoji autocompletion\n */\n emojiAutocomplete: {\n type: Boolean,\n default: true\n },\n /**\n * Enable or disable link autocompletion\n */\n linkAutocomplete: {\n type: Boolean,\n default: true\n },\n /**\n * CSS class to apply to the root element.\n */\n class: {\n type: [String, Array, Object],\n default: \"\"\n }\n },\n emits: [\n \"paste\",\n \"update:modelValue\",\n \"smartPickerSubmit\",\n \"submit\"\n ],\n setup() {\n const segmenter = new Intl.Segmenter();\n if (isPlaintextOnlySupported === null) {\n try {\n document.createElement(\"div\").contentEditable = \"plaintext-only\";\n isPlaintextOnlySupported = true;\n } catch (error) {\n logger.debug(\"[NcRichContenteditable] Unsupported attribute value:\", { error });\n isPlaintextOnlySupported = false;\n }\n }\n return {\n // Constants\n labelId: createElementId(),\n tributeId: createElementId(),\n segmenter,\n /**\n * Non-reactive property to store Tribute instance\n *\n * @type {import('tributejs').default | null}\n */\n tribute: null,\n tributeStyleMutationObserver: null\n };\n },\n data() {\n return {\n // Represent the raw untrimmed text of the contenteditable\n // serves no other purpose than to check whether the\n // content is empty or not\n localValue: this.modelValue,\n // Is in text composition session in IME\n isComposing: false,\n // Tribute autocomplete\n isAutocompleteOpen: false,\n autocompleteActiveId: void 0,\n isTributeIntegrationDone: false\n };\n },\n computed: {\n /**\n * Is the current trimmed value empty?\n *\n * @return {boolean}\n */\n isEmptyValue() {\n return !this.localValue || this.localValue.trim() === \"\";\n },\n /**\n * Is the current value over maxlength?\n *\n * @return {boolean}\n */\n isOverMaxlength() {\n if (this.isEmptyValue || !this.maxlength) {\n return false;\n }\n const length = [...this.segmenter.segment(this.localValue)].length;\n return length > this.maxlength;\n },\n /**\n * Tooltip to show if characters count is over limit\n *\n * @return {string}\n */\n tooltipString() {\n if (!this.isOverMaxlength) {\n return null;\n }\n return n(\"Message limit of %n character reached\", \"Message limit of %n characters reached\", this.maxlength);\n },\n /**\n * Edit is only allowed when contenteditable is:\n * 'true' (all browsers since 2015)\n * 'plaintext-only' (most browsers since 2015, Firefox since 136+)\n *\n * @return {string}\n */\n contenteditableAttributeValue() {\n if (this.contenteditable && !this.disabled) {\n return isPlaintextOnlySupported ? \"plaintext-only\" : \"true\";\n }\n return \"false\";\n },\n /**\n * Compute debounce function for the autocomplete function\n */\n debouncedAutoComplete() {\n return debounce(async (search, callback) => {\n this.autoComplete(search, callback);\n }, 100);\n }\n },\n watch: {\n /**\n * If the parent value change, we compare the plain text rendering\n * If it's different, we render everything and update the main content\n */\n modelValue() {\n const html = this.$refs.contenteditable.innerHTML;\n if (this.modelValue.trim() !== this.parseContent(html).trim()) {\n this.updateContent(this.modelValue);\n }\n }\n },\n mounted() {\n this.initializeTribute();\n this.updateContent(this.modelValue);\n },\n beforeUnmount() {\n if (this.tribute) {\n this.tribute.detach(this.$refs.contenteditable);\n }\n if (this.tributeStyleMutationObserver) {\n this.tributeStyleMutationObserver.disconnect();\n }\n },\n methods: {\n /**\n * Focus the richContenteditable\n *\n * @public\n */\n focus() {\n this.$refs.contenteditable.focus();\n },\n initializeTribute() {\n const renderMenuItem = (content) => `