12 |
- "use strict";(self.webpackChunknextcloud=self.webpackChunknextcloud||[]).push([[6318],{65507:(e,t,i)=>{i.d(t,{default:()=>u});var n=i(25108),r=i(19755);if(Array.prototype.find||(Array.prototype.find=function(e){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var t,i=Object(this),n=i.length>>>0,r=arguments[1],s=0;s<n;s++)if(t=i[s],e.call(r,t,s,i))return t}),window&&"function"!=typeof window.CustomEvent){function d(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),i}void 0!==window.Event&&(d.prototype=window.Event.prototype),window.CustomEvent=d}class s{constructor(e){this.tribute=e,this.tribute.events=this}static keys(){return[{key:9,value:"TAB"},{key:8,value:"DELETE"},{key:13,value:"ENTER"},{key:27,value:"ESCAPE"},{key:32,value:"SPACE"},{key:38,value:"UP"},{key:40,value:"DOWN"}]}bind(e){e.boundKeydown=this.keydown.bind(e,this),e.boundKeyup=this.keyup.bind(e,this),e.boundInput=this.input.bind(e,this),e.addEventListener("keydown",e.boundKeydown,!1),e.addEventListener("keyup",e.boundKeyup,!1),e.addEventListener("input",e.boundInput,!1)}unbind(e){e.removeEventListener("keydown",e.boundKeydown,!1),e.removeEventListener("keyup",e.boundKeyup,!1),e.removeEventListener("input",e.boundInput,!1),delete e.boundKeydown,delete e.boundKeyup,delete e.boundInput}keydown(e,t){e.shouldDeactivate(t)&&(e.tribute.isActive=!1,e.tribute.hideMenu());let i=this;e.commandEvent=!1,s.keys().forEach((n=>{n.key===t.keyCode&&(e.commandEvent=!0,e.callbacks()[n.value.toLowerCase()](t,i))}))}input(e,t){e.inputEvent=!0,e.keyup.call(this,e,t)}click(e,t){let i=e.tribute;if(i.menu&&i.menu.contains(t.target)){let e=t.target;for(t.preventDefault(),t.stopPropagation();"li"!==e.nodeName.toLowerCase();)if(e=e.parentNode,!e||e===i.menu)throw new Error("cannot find the <li> container for the click");i.selectItemAtIndex(e.getAttribute("data-index"),t),i.hideMenu()}else i.current.element&&!i.current.externalTrigger&&(i.current.externalTrigger=!1,setTimeout((()=>i.hideMenu())))}keyup(e,t){if(e.inputEvent&&(e.inputEvent=!1),e.updateSelection(this),27!==t.keyCode){if(!e.tribute.allowSpaces&&e.tribute.hasTrailingSpace)return e.tribute.hasTrailingSpace=!1,e.commandEvent=!0,void e.callbacks().space(t,this);if(!e.tribute.isActive)if(e.tribute.autocompleteMode)e.callbacks().triggerChar(t,this,"");else{let i=e.getKeyCode(e,this,t);if(isNaN(i)||!i)return;let n=e.tribute.triggers().find((e=>e.charCodeAt(0)===i));void 0!==n&&e.callbacks().triggerChar(t,this,n)}e.tribute.current.mentionText.length<e.tribute.current.collection.menuShowMinLength||((e.tribute.current.trigger||e.tribute.autocompleteMode)&&!1===e.commandEvent||e.tribute.isActive&&8===t.keyCode)&&e.tribute.showMenuFor(this,!0)}}shouldDeactivate(e){if(!this.tribute.isActive)return!1;if(0===this.tribute.current.mentionText.length){let t=!1;return s.keys().forEach((i=>{e.keyCode===i.key&&(t=!0)})),!t}return!1}getKeyCode(e,t,i){let n=e.tribute,r=n.range.getTriggerInfo(!1,n.hasTrailingSpace,!0,n.allowSpaces,n.autocompleteMode);return!!r&&r.mentionTriggerChar.charCodeAt(0)}updateSelection(e){this.tribute.current.element=e;let t=this.tribute.range.getTriggerInfo(!1,this.tribute.hasTrailingSpace,!0,this.tribute.allowSpaces,this.tribute.autocompleteMode);t&&(this.tribute.current.selectedPath=t.mentionSelectedPath,this.tribute.current.mentionText=t.mentionText,this.tribute.current.selectedOffset=t.mentionSelectedOffset)}callbacks(){return{triggerChar:(e,t,i)=>{let n=this.tribute;n.current.trigger=i;let r=n.collection.find((e=>e.trigger===i));n.current.collection=r,n.current.mentionText.length>=n.current.collection.menuShowMinLength&&n.inputEvent&&n.showMenuFor(t,!0)},enter:(e,t)=>{this.tribute.isActive&&this.tribute.current.filteredItems&&(e.preventDefault(),e.stopPropagation(),setTimeout((()=>{this.tribute.selectItemAtIndex(this.tribute.menuSelected,e),this.tribute.hideMenu()}),0))},escape:(e,t)=>{this.tribute.isActive&&(e.preventDefault(),e.stopPropagation(),this.tribute.isActive=!1,this.tribute.hideMenu())},tab:(e,t)=>{this.callbacks().enter(e,t)},space:(e,t)=>{this.tribute.isActive&&(this.tribute.spaceSelectsMatch?this.callbacks().enter(e,t):this.tribute.allowSpaces||(e.stopPropagation(),setTimeout((()=>{this.tribute.hideMenu(),this.tribute.isActive=!1}),0)))},up:(e,t)=>{if(this.tribute.isActive&&this.tribute.current.filteredItems){e.preventDefault(),e.stopPropagation();let t=this.tribute.current.filteredItems.length,i=this.tribute.menuSelected;t>i&&i>0?(this.tribute.menuSelected--,this.setActiveLi()):0===i&&(this.tribute.menuSelected=t-1,this.setActiveLi(),this.tribute.menu.scrollTop=this.tribute.menu.scrollHeight)}},down:(e,t)=>{if(this.tribute.isActive&&this.tribute.current.filteredItems){e.preventDefault(),e.stopPropagation();let t=this.tribute.current.filteredItems.length-1,i=this.tribute.menuSelected;t>i?(this.tribute.menuSelected++,this.setActiveLi()):t===i&&(this.tribute.menuSelected=0,this.setActiveLi(),this.tribute.menu.scrollTop=0)}},delete:(e,t)=>{this.tribute.isActive&&this.tribute.current.mentionText.length<1?this.tribute.hideMenu():this.tribute.isActive&&this.tribute.showMenuFor(t)}}}setActiveLi(e){let t=this.tribute.menu.querySelectorAll("li"),i=t.length>>>0;e&&(this.tribute.menuSelected=parseInt(e));for(let e=0;e<i;e++){let i=t[e];if(e===this.tribute.menuSelected){i.classList.add(this.tribute.current.collection.selectClass);let e=i.getBoundingClientRect(),t=this.tribute.menu.getBoundingClientRect();if(e.bottom>t.bottom){let i=e.bottom-t.bottom;this.tribute.menu.scrollTop+=i}else if(e.top<t.top){let i=t.top-e.top;this.tribute.menu.scrollTop-=i}}else i.classList.remove(this.tribute.current.collection.selectClass)}}getFullHeight(e,t){let i=e.getBoundingClientRect().height;if(t){let t=e.currentStyle||window.getComputedStyle(e);return i+parseFloat(t.marginTop)+parseFloat(t.marginBottom)}return i}}class o{constructor(e){this.tribute=e,this.tribute.menuEvents=this,this.menu=this.tribute.menu}bind(e){this.menuClickEvent=this.tribute.events.click.bind(null,this),this.menuContainerScrollEvent=this.debounce((()=>{this.tribute.isActive&&this.tribute.showMenuFor(this.tribute.current.element,!1)}),300,!1),this.windowResizeEvent=this.debounce((()=>{this.tribute.isActive&&this.tribute.range.positionMenuAtCaret(!0)}),300,!1),this.tribute.range.getDocument().addEventListener("MSPointerDown",this.menuClickEvent,!1),this.tribute.range.getDocument().addEventListener("mousedown",this.menuClickEvent,!1),window.addEventListener("resize",this.windowResizeEvent),this.menuContainer?this.menuContainer.addEventListener("scroll",this.menuContainerScrollEvent,!1):window.addEventListener("scroll",this.menuContainerScrollEvent)}unbind(e){this.tribute.range.getDocument().removeEventListener("mousedown",this.menuClickEvent,!1),this.tribute.range.getDocument().removeEventListener("MSPointerDown",this.menuClickEvent,!1),window.removeEventListener("resize",this.windowResizeEvent),this.menuContainer?this.menuContainer.removeEventListener("scroll",this.menuContainerScrollEvent,!1):window.removeEventListener("scroll",this.menuContainerScrollEvent)}debounce(e,t,i){var n;return()=>{var r=this,s=arguments,o=i&&!n;clearTimeout(n),n=setTimeout((()=>{n=null,i||e.apply(r,s)}),t),o&&e.apply(r,s)}}}class l{constructor(e){this.tribute=e,this.tribute.range=this}getDocument(){let e;return this.tribute.current.collection&&(e=this.tribute.current.collection.iframe),e?e.contentWindow.document:document}positionMenuAtCaret(e){let t,i=this.tribute.current,n=this.getTriggerInfo(!1,this.tribute.hasTrailingSpace,!0,this.tribute.allowSpaces,this.tribute.autocompleteMode);if(void 0!==n){if(!this.tribute.positionMenu)return void(this.tribute.menu.style.cssText="display: block;");t=this.isContentEditable(i.element)?this.getContentEditableCaretPosition(n.mentionPosition):this.getTextAreaOrInputUnderlinePosition(this.tribute.current.element,n.mentionPosition),this.tribute.menu.style.cssText=`top: ${t.top}px;\n left: ${t.left}px;\n right: ${t.right}px;\n bottom: ${t.bottom}px;\n position: absolute;\n display: block;`,"auto"===t.left&&(this.tribute.menu.style.left="auto"),"auto"===t.top&&(this.tribute.menu.style.top="auto"),e&&this.scrollIntoView(),window.setTimeout((()=>{let i={width:this.tribute.menu.offsetWidth,height:this.tribute.menu.offsetHeight},n=this.isMenuOffScreen(t,i),r=window.innerWidth>i.width&&(n.left||n.right),s=window.innerHeight>i.height&&(n.top||n.bottom);(r||s)&&(this.tribute.menu.style.cssText="display: none",this.positionMenuAtCaret(e))}),0)}else this.tribute.menu.style.cssText="display: none"}get menuContainerIsBody(){return this.tribute.menuContainer===document.body||!this.tribute.menuContainer}selectElement(e,t,i){let n,r=e;if(t)for(var s=0;s<t.length;s++){if(r=r.childNodes[t[s]],void 0===r)return;for(;r.length<i;)i-=r.length,r=r.nextSibling;0!==r.childNodes.length||r.length||(r=r.previousSibling)}let o=this.getWindowSelection();n=this.getDocument().createRange(),n.setStart(r,i),n.setEnd(r,i),n.collapse(!0);try{o.removeAllRanges()}catch(e){}o.addRange(n),e.focus()}replaceTriggerText(e,t,i,n,r){let s=this.getTriggerInfo(!0,i,t,this.tribute.allowSpaces,this.tribute.autocompleteMode);if(void 0!==s){let t=this.tribute.current,i=new CustomEvent("tribute-replaced",{detail:{item:r,instance:t,context:s,event:n}});if(this.isContentEditable(t.element)){e+="string"==typeof this.tribute.replaceTextSuffix?this.tribute.replaceTextSuffix:" ";let t=s.mentionPosition+s.mentionText.length;this.tribute.autocompleteMode||(t+=s.mentionTriggerChar.length),this.pasteHtml(e,s.mentionPosition,t)}else{let t=this.tribute.current.element,i="string"==typeof this.tribute.replaceTextSuffix?this.tribute.replaceTextSuffix:" ";e+=i;let n=s.mentionPosition,r=s.mentionPosition+s.mentionText.length+i.length;this.tribute.autocompleteMode||(r+=s.mentionTriggerChar.length-1),t.value=t.value.substring(0,n)+e+t.value.substring(r,t.value.length),t.selectionStart=n+e.length,t.selectionEnd=n+e.length}t.element.dispatchEvent(new CustomEvent("input",{bubbles:!0})),t.element.dispatchEvent(i)}}pasteHtml(e,t,i){let n,r;r=this.getWindowSelection(),n=this.getDocument().createRange(),n.setStart(r.anchorNode,t),n.setEnd(r.anchorNode,i),n.deleteContents();let s=this.getDocument().createElement("div");s.innerHTML=e;let o,l,c=this.getDocument().createDocumentFragment();for(;o=s.firstChild;)l=c.appendChild(o);n.insertNode(c),l&&(n=n.cloneRange(),n.setStartAfter(l),n.collapse(!0),r.removeAllRanges(),r.addRange(n))}getWindowSelection(){return this.tribute.collection.iframe?this.tribute.collection.iframe.contentWindow.getSelection():window.getSelection()}getNodePositionInParent(e){if(null===e.parentNode)return 0;for(var t=0;t<e.parentNode.childNodes.length;t++)if(e.parentNode.childNodes[t]===e)return t}getContentEditableSelectedPath(e){let t,i=this.getWindowSelection(),n=i.anchorNode,r=[];if(null!=n){let e,s=n.contentEditable;for(;null!==n&&"true"!==s;)e=this.getNodePositionInParent(n),r.push(e),n=n.parentNode,null!==n&&(s=n.contentEditable);return r.reverse(),t=i.getRangeAt(0).startOffset,{selected:n,path:r,offset:t}}}getTextPrecedingCurrentSelection(){let e=this.tribute.current,t="";if(this.isContentEditable(e.element)){let e=this.getWindowSelection().anchorNode;if(null!=e){let i=e.textContent,n=this.getWindowSelection().getRangeAt(0).startOffset;i&&n>=0&&(t=i.substring(0,n))}}else{let e=this.tribute.current.element;if(e){let i=e.selectionStart;e.value&&i>=0&&(t=e.value.substring(0,i))}}return t}getLastWordInText(e){let t=(e=e.replace(/\u00A0/g," ")).split(/\s+/);return t[t.length-1].trim()}getTriggerInfo(e,t,i,n,r){let s,o,l,c=this.tribute.current;if(this.isContentEditable(c.element)){let e=this.getContentEditableSelectedPath(c);e&&(s=e.selected,o=e.path,l=e.offset)}else s=this.tribute.current.element;let a=this.getTextPrecedingCurrentSelection(),u=this.getLastWordInText(a);if(r)return{mentionPosition:a.length-u.length,mentionText:u,mentionSelectedElement:s,mentionSelectedPath:o,mentionSelectedOffset:l};if(null!=a){let r,c=-1;if(this.tribute.collection.forEach((e=>{let t=e.trigger,n=e.requireLeadingSpace?this.lastIndexWithLeadingSpace(a,t):a.lastIndexOf(t);n>c&&(c=n,r=t,i=e.requireLeadingSpace)})),c>=0&&(0===c||!i||/[\xA0\s]/g.test(a.substring(c-1,c)))){let i=a.substring(c+r.length,a.length);r=a.substring(c,c+r.length);let u=i.substring(0,1),d=i.length>0&&(" "===u||" "===u);t&&(i=i.trim());let h=n?/[^\S ]/g:/[\xA0\s]/g;if(this.tribute.hasTrailingSpace=h.test(i),!d&&(e||!h.test(i)))return{mentionPosition:c,mentionText:i,mentionSelectedElement:s,mentionSelectedPath:o,mentionSelectedOffset:l,mentionTriggerChar:r}}}}lastIndexWithLeadingSpace(e,t){let i=e.split("").reverse().join(""),n=-1;for(let r=0,s=e.length;r<s;r++){let s=r===e.length-1,o=/\s/.test(i[r+1]),l=!0;for(let e=t.length-1;e>=0;e--)if(t[e]!==i[r-e]){l=!1;break}if(l&&(s||o)){n=e.length-1-r;break}}return n}isContentEditable(e){return"INPUT"!==e.nodeName&&"TEXTAREA"!==e.nodeName}isMenuOffScreen(e,t){let i=window.innerWidth,n=window.innerHeight,r=document.documentElement,s=(window.pageXOffset||r.scrollLeft)-(r.clientLeft||0),o=(window.pageYOffset||r.scrollTop)-(r.clientTop||0),l="number"==typeof e.top?e.top:o+n-e.bottom-t.height,c="number"==typeof e.right?e.right:e.left+t.width,a="number"==typeof e.bottom?e.bottom:e.top+t.height,u="number"==typeof e.left?e.left:s+i-e.right-t.width;return{top:l<Math.floor(o),right:c>Math.ceil(s+i),bottom:a>Math.ceil(o+n),left:u<Math.floor(s)}}getMenuDimensions(){let e={width:null,height:null};return this.tribute.menu.style.cssText="top: 0px;\n left: 0px;\n position: fixed;\n display: block;\n visibility; hidden;",e.width=this.tribute.menu.offsetWidth,e.height=this.tribute.menu.offsetHeight,this.tribute.menu.style.cssText="display: none;",e}getTextAreaOrInputUnderlinePosition(e,t,i){let n=null!==window.mozInnerScreenX,r=this.getDocument().createElement("div");r.id="input-textarea-caret-position-mirror-div",this.getDocument().body.appendChild(r);let s=r.style,o=window.getComputedStyle?getComputedStyle(e):e.currentStyle;s.whiteSpace="pre-wrap","INPUT"!==e.nodeName&&(s.wordWrap="break-word"),s.position="absolute",s.visibility="hidden",["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing"].forEach((e=>{s[e]=o[e]})),n?(s.width=parseInt(o.width)-2+"px",e.scrollHeight>parseInt(o.height)&&(s.overflowY="scroll")):s.overflow="hidden",r.textContent=e.value.substring(0,t),"INPUT"===e.nodeName&&(r.textContent=r.textContent.replace(/\s/g," "));let l=this.getDocument().createElement("span");l.textContent=e.value.substring(t)||".",r.appendChild(l);let c=e.getBoundingClientRect(),a=document.documentElement,u=(window.pageXOffset||a.scrollLeft)-(a.clientLeft||0),d=(window.pageYOffset||a.scrollTop)-(a.clientTop||0),h=0,p=0;this.menuContainerIsBody&&(h=c.top,p=c.left);let m={top:h+d+l.offsetTop+parseInt(o.borderTopWidth)+parseInt(o.fontSize)-e.scrollTop,left:p+u+l.offsetLeft+parseInt(o.borderLeftWidth)},f=window.innerWidth,g=window.innerHeight,v=this.getMenuDimensions(),b=this.isMenuOffScreen(m,v);b.right&&(m.right=f-m.left,m.left="auto");let w=this.tribute.menuContainer?this.tribute.menuContainer.offsetHeight:this.getDocument().body.offsetHeight;if(b.bottom){let e=w-(g-(this.tribute.menuContainer?this.tribute.menuContainer.getBoundingClientRect():this.getDocument().body.getBoundingClientRect()).top);m.bottom=e+(g-c.top-l.offsetTop),m.top="auto"}return b=this.isMenuOffScreen(m,v),b.left&&(m.left=f>v.width?u+f-v.width:u,delete m.right),b.top&&(m.top=g>v.height?d+g-v.height:d,delete m.bottom),this.getDocument().body.removeChild(r),m}getContentEditableCaretPosition(e){let t,i=this.getWindowSelection();t=this.getDocument().createRange(),t.setStart(i.anchorNode,e),t.setEnd(i.anchorNode,e),t.collapse(!1);let n=t.getBoundingClientRect(),r=document.documentElement,s=(window.pageXOffset||r.scrollLeft)-(r.clientLeft||0),o=(window.pageYOffset||r.scrollTop)-(r.clientTop||0),l={left:n.left+s,top:n.top+n.height+o},c=window.innerWidth,a=window.innerHeight,u=this.getMenuDimensions(),d=this.isMenuOffScreen(l,u);d.right&&(l.left="auto",l.right=c-n.left-s);let h=this.tribute.menuContainer?this.tribute.menuContainer.offsetHeight:this.getDocument().body.offsetHeight;if(d.bottom){let e=h-(a-(this.tribute.menuContainer?this.tribute.menuContainer.getBoundingClientRect():this.getDocument().body.getBoundingClientRect()).top);l.top="auto",l.bottom=e+(a-n.top)}return d=this.isMenuOffScreen(l,u),d.left&&(l.left=c>u.width?s+c-u.width:s,delete l.right),d.top&&(l.top=a>u.height?o+a-u.height:o,delete l.bottom),this.menuContainerIsBody||(l.left=l.left?l.left-this.tribute.menuContainer.offsetLeft:l.left,l.top=l.top?l.top-this.tribute.menuContainer.offsetTop:l.top),l}scrollIntoView(e){let t,i=this.menu;if(void 0===i)return;for(;void 0===t||0===t.height;)if(t=i.getBoundingClientRect(),0===t.height&&(i=i.childNodes[0],void 0===i||!i.getBoundingClientRect))return;let n=t.top,r=n+t.height;if(n<0)window.scrollTo(0,window.pageYOffset+t.top-20);else if(r>window.innerHeight){let e=window.pageYOffset+t.top-20;e-window.pageYOffset>100&&(e=window.pageYOffset+100);let i=window.pageYOffset-(window.innerHeight-r);i>e&&(i=e),window.scrollTo(0,i)}}}class c{constructor(e){this.tribute=e,this.tribute.search=this}simpleFilter(e,t){return t.filter((t=>this.test(e,t)))}test(e,t){return null!==this.match(e,t)}match(e,t,i){i=i||{},t.length;let n=i.pre||"",r=i.post||"",s=i.caseSensitive&&t||t.toLowerCase();if(i.skip)return{rendered:t,score:0};e=i.caseSensitive&&e||e.toLowerCase();let o=this.traverse(s,e,0,0,[]);return o?{rendered:this.render(t,o.cache,n,r),score:o.score}:null}traverse(e,t,i,n,r){if(t.length===n)return{score:this.calculateScore(r),cache:r.slice()};if(e.length===i||t.length-n>e.length-i)return;let s,o,l=t[n],c=e.indexOf(l,i);for(;c>-1;){if(r.push(c),o=this.traverse(e,t,c+1,n+1,r),r.pop(),!o)return s;(!s||s.score<o.score)&&(s=o),c=e.indexOf(l,c+1)}return s}calculateScore(e){let t=0,i=1;return e.forEach(((n,r)=>{r>0&&(e[r-1]+1===n?i+=i+1:i=1),t+=i})),t}render(e,t,i,n){var r=e.substring(0,t[0]);return t.forEach(((s,o)=>{r+=i+e[s]+n+e.substring(s+1,t[o+1]?t[o+1]:e.length)})),r}filter(e,t,i){return i=i||{},t.reduce(((t,n,r,s)=>{let o=n;i.extract&&(o=i.extract(n),o||(o=""));let l=this.match(e,o,i);return null!=l&&(t[t.length]={string:l.rendered,score:l.score,index:r,original:n}),t}),[]).sort(((e,t)=>t.score-e.score||e.index-t.index))}}class a{constructor({values:e=null,iframe:t=null,selectClass:i="highlight",containerClass:r="tribute-container",itemClass:u="",trigger:d="@",autocompleteMode:h=!1,selectTemplate:p=null,menuItemTemplate:m=null,lookup:f="key",fillAttr:g="value",collection:v=null,menuContainer:b=null,noMatchTemplate:w=null,requireLeadingSpace:C=!0,allowSpaces:y=!1,replaceTextSuffix:_=null,positionMenu:S=!0,spaceSelectsMatch:k=!1,searchOpts:T={},menuItemLimit:E=null,menuShowMinLength:x=0}){if(this.autocompleteMode=h,this.menuSelected=0,this.current={},this.inputEvent=!1,this.isActive=!1,this.menuContainer=b,this.allowSpaces=y,this.replaceTextSuffix=_,this.positionMenu=S,this.hasTrailingSpace=!1,this.spaceSelectsMatch=k,this.autocompleteMode&&(d="",y=!1),e)this.collection=[{trigger:d,iframe:t,selectClass:i,containerClass:r,itemClass:u,selectTemplate:(p||a.defaultSelectTemplate).bind(this),menuItemTemplate:(m||a.defaultMenuItemTemplate).bind(this),noMatchTemplate:(e=>"string"==typeof e?""===e.trim()?null:e:"function"==typeof e?e.bind(this):w||function(){return"<li>No Match Found!</li>"}.bind(this))(w),lookup:f,fillAttr:g,values:e,requireLeadingSpace:C,searchOpts:T,menuItemLimit:E,menuShowMinLength:x}];else{if(!v)throw new Error("[Tribute] No collection specified.");this.autocompleteMode&&n.warn("Tribute in autocomplete mode does not work for collections"),this.collection=v.map((e=>({trigger:e.trigger||d,iframe:e.iframe||t,selectClass:e.selectClass||i,containerClass:e.containerClass||r,itemClass:e.itemClass||u,selectTemplate:(e.selectTemplate||a.defaultSelectTemplate).bind(this),menuItemTemplate:(e.menuItemTemplate||a.defaultMenuItemTemplate).bind(this),noMatchTemplate:(e=>"string"==typeof e?""===e.trim()?null:e:"function"==typeof e?e.bind(this):w||function(){return"<li>No Match Found!</li>"}.bind(this))(w),lookup:e.lookup||f,fillAttr:e.fillAttr||g,values:e.values,requireLeadingSpace:e.requireLeadingSpace,searchOpts:e.searchOpts||T,menuItemLimit:e.menuItemLimit||E,menuShowMinLength:e.menuShowMinLength||x})))}new l(this),new s(this),new o(this),new c(this)}get isActive(){return this._isActive}set isActive(e){if(this._isActive!=e&&(this._isActive=e,this.current.element)){let t=new CustomEvent(`tribute-active-${e}`);this.current.element.dispatchEvent(t)}}static defaultSelectTemplate(e){return void 0===e?`${this.current.collection.trigger}${this.current.mentionText}`:this.range.isContentEditable(this.current.element)?'<span class="tribute-mention">'+(this.current.collection.trigger+e.original[this.current.collection.fillAttr])+"</span>":this.current.collection.trigger+e.original[this.current.collection.fillAttr]}static defaultMenuItemTemplate(e){return e.string}static inputTypes(){return["TEXTAREA","INPUT"]}triggers(){return this.collection.map((e=>e.trigger))}attach(e){if(!e)throw new Error("[Tribute] Must pass in a DOM node or NodeList.");if(void 0!==r&&e instanceof r&&(e=e.get()),e.constructor===NodeList||e.constructor===HTMLCollection||e.constructor===Array){let i=e.length;for(var t=0;t<i;++t)this._attach(e[t])}else this._attach(e)}_attach(e){e.hasAttribute("data-tribute")&&n.warn("Tribute was already bound to "+e.nodeName),this.ensureEditable(e),this.events.bind(e),e.setAttribute("data-tribute",!0)}ensureEditable(e){if(-1===a.inputTypes().indexOf(e.nodeName)){if(!e.contentEditable)throw new Error("[Tribute] Cannot bind to "+e.nodeName);e.contentEditable=!0}}createMenu(e){let t=this.range.getDocument().createElement("div"),i=this.range.getDocument().createElement("ul");return t.className=e,t.appendChild(i),this.menuContainer?this.menuContainer.appendChild(t):this.range.getDocument().body.appendChild(t)}showMenuFor(e,t){if(this.isActive&&this.current.element===e&&this.current.mentionText===this.currentMentionTextSnapshot)return;this.currentMentionTextSnapshot=this.current.mentionText,this.menu||(this.menu=this.createMenu(this.current.collection.containerClass),e.tributeMenu=this.menu,this.menuEvents.bind(this.menu)),this.isActive=!0,this.menuSelected=0,this.current.mentionText||(this.current.mentionText="");const i=e=>{if(!this.isActive)return;let i=this.search.filter(this.current.mentionText,e,{pre:this.current.collection.searchOpts.pre||"<span>",post:this.current.collection.searchOpts.post||"</span>",skip:this.current.collection.searchOpts.skip,extract:e=>{if("string"==typeof this.current.collection.lookup)return e[this.current.collection.lookup];if("function"==typeof this.current.collection.lookup)return this.current.collection.lookup(e,this.current.mentionText);throw new Error("Invalid lookup attribute, lookup must be string or function.")}});this.current.collection.menuItemLimit&&(i=i.slice(0,this.current.collection.menuItemLimit)),this.current.filteredItems=i;let n=this.menu.querySelector("ul");if(this.range.positionMenuAtCaret(t),!i.length){let e=new CustomEvent("tribute-no-match",{detail:this.menu});return this.current.element.dispatchEvent(e),void("function"==typeof this.current.collection.noMatchTemplate&&!this.current.collection.noMatchTemplate()||!this.current.collection.noMatchTemplate?this.hideMenu():"function"==typeof this.current.collection.noMatchTemplate?n.innerHTML=this.current.collection.noMatchTemplate():n.innerHTML=this.current.collection.noMatchTemplate)}n.innerHTML="";let r=this.range.getDocument().createDocumentFragment();i.forEach(((e,t)=>{let i=this.range.getDocument().createElement("li");i.setAttribute("data-index",t),i.className=this.current.collection.itemClass,i.addEventListener("mousemove",(e=>{let[t,i]=this._findLiTarget(e.target);0!==e.movementY&&this.events.setActiveLi(i)})),this.menuSelected===t&&i.classList.add(this.current.collection.selectClass),i.innerHTML=this.current.collection.menuItemTemplate(e),r.appendChild(i)})),n.appendChild(r)};"function"==typeof this.current.collection.values?this.current.collection.values(this.current.mentionText,i):i(this.current.collection.values)}_findLiTarget(e){if(!e)return[];const t=e.getAttribute("data-index");return t?[e,t]:this._findLiTarget(e.parentNode)}showMenuForCollection(e,t){e!==document.activeElement&&this.placeCaretAtEnd(e),this.current.collection=this.collection[t||0],this.current.externalTrigger=!0,this.current.element=e,e.isContentEditable?this.insertTextAtCursor(this.current.collection.trigger):this.insertAtCaret(e,this.current.collection.trigger),this.showMenuFor(e)}placeCaretAtEnd(e){if(e.focus(),void 0!==window.getSelection&&void 0!==document.createRange){var t=document.createRange();t.selectNodeContents(e),t.collapse(!1);var i=window.getSelection();i.removeAllRanges(),i.addRange(t)}else if(void 0!==document.body.createTextRange){var n=document.body.createTextRange();n.moveToElementText(e),n.collapse(!1),n.select()}}insertTextAtCursor(e){var t,i;(i=(t=window.getSelection()).getRangeAt(0)).deleteContents();var n=document.createTextNode(e);i.insertNode(n),i.selectNodeContents(n),i.collapse(!1),t.removeAllRanges(),t.addRange(i)}insertAtCaret(e,t){var i=e.scrollTop,n=e.selectionStart,r=e.value.substring(0,n),s=e.value.substring(e.selectionEnd,e.value.length);e.value=r+t+s,n+=t.length,e.selectionStart=n,e.selectionEnd=n,e.focus(),e.scrollTop=i}hideMenu(){this.menu&&(this.menu.style.cssText="display: none;",this.isActive=!1,this.menuSelected=0,this.current={})}selectItemAtIndex(e,t){if("number"!=typeof(e=parseInt(e))||isNaN(e))return;let i=this.current.filteredItems[e],n=this.current.collection.selectTemplate(i);null!==n&&this.replaceText(n,t,i)}replaceText(e,t,i){this.range.replaceTriggerText(e,!0,!0,t,i)}_append(e,t,i){if("function"==typeof e.values)throw new Error("Unable to append to values, as it is a function.");e.values=i?t:e.values.concat(t)}append(e,t,i){let n=parseInt(e);if("number"!=typeof n)throw new Error("please provide an index for the collection to update.");let r=this.collection[n];this._append(r,t,i)}appendCurrent(e,t){if(!this.isActive)throw new Error("No active state. Please use append instead and pass an index.");this._append(this.current.collection,e,t)}detach(e){if(!e)throw new Error("[Tribute] Must pass in a DOM node or NodeList.");if(void 0!==r&&e instanceof r&&(e=e.get()),e.constructor===NodeList||e.constructor===HTMLCollection||e.constructor===Array){let i=e.length;for(var t=0;t<i;++t)this._detach(e[t])}else this._detach(e)}_detach(e){this.events.unbind(e),e.tributeMenu&&this.menuEvents.unbind(e.tributeMenu),setTimeout((()=>{e.removeAttribute("data-tribute"),this.isActive=!1,e.tributeMenu&&e.tributeMenu.remove()}))}}const u=a},46318:(e,t,i)=>{i.r(t),i.d(t,{NcAutoCompleteResult:()=>v,NcMentionBubble:()=>n.N,default:()=>y}),i(29774);var n=i(22663),r=i(79753),s=i(76311),o=i(36842),l=(i(79845),i(93911)),c=i(94027),a=(i(93664),i(22175),i(19664),i(20435),i(49368),i(62642),i(25475),i(69183),i(65507)),u=i(20296),d=i(8014),h=i(73045),p=i(25108);const m={name:"NcAutoCompleteResult",props:{title:{type:String,required:!0},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:()=>({})}},computed:{avatarUrl(){return this.iconUrl?this.iconUrl:this.id&&"users"===this.source?this.getAvatarUrl(this.id,44):null},haveStatus(){var e,t,i;return(null==(e=this.status)?void 0:e.icon)||(null==(t=this.status)?void 0:t.status)&&"offline"!==(null==(i=this.status)?void 0:i.status)}},methods:{getAvatarUrl:(e,t)=>(0,r.generateUrl)("/avatar/{user}/{size}",{user:e,size:t})}};var f=function(){var e=this,t=e._self._c;return t("div",{staticClass:"autocomplete-result"},[t("div",{staticClass:"autocomplete-result__icon",class:[e.icon,"autocomplete-result__icon--"+(e.avatarUrl?"with-avatar":"")],style:e.avatarUrl?{backgroundImage:`url(${e.avatarUrl})`}:null},[e.haveStatus?t("div",{staticClass:"autocomplete-result__status",class:[`autocomplete-result__status--${e.status&&e.status.icon?"icon":e.status.status}`]},[e._v(" "+e._s(e.status&&e.status.icon||"")+" ")]):e._e()]),t("span",{staticClass:"autocomplete-result__content"},[t("span",{staticClass:"autocomplete-result__title",attrs:{title:e.title}},[e._v(" "+e._s(e.title)+" ")]),e.subline?t("span",{staticClass:"autocomplete-result__subline"},[e._v(" "+e._s(e.subline)+" ")]):e._e()])])},g=[];const v=(0,s.n)(m,f,g,!1,null,"25cf09d8",null,null).exports,b={name:"NcRichContenteditable",directives:{tooltip:h.VTooltip},mixins:[n.r],props:{value:{type:String,default:"",required:!0},placeholder:{type:String,default:(0,o.t)("Write a message …")},autoComplete:{type:Function,default:()=>[]},menuContainer:{type:Element,default:()=>document.body},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}},emits:["submit","paste","update:value","smart-picker-submit"],data(){return{textSmiles:[],tribute:null,autocompleteOptions:{allowSpaces:!0,fillAttr:"id",lookup:e=>`${e.id} ${e.title}`,menuContainer:this.menuContainer,menuItemTemplate:e=>this.renderComponentHtml(e.original,v),noMatchTemplate:()=>'<span class="hidden"></span>',selectTemplate:e=>{var t;return this.genSelectTemplate(null==(t=null==e?void 0:e.original)?void 0:t.id)},values:this.debouncedAutoComplete},emojiOptions:{trigger:":",lookup:(e,t)=>t,menuContainer:this.menuContainer,menuItemTemplate:e=>this.textSmiles.includes(e.original)?e.original:`<span class="tribute-container-emoji__item__emoji">${e.original.native}</span> :${e.original.short_name}`,noMatchTemplate:()=>(0,o.t)("No emoji found"),selectTemplate:e=>this.textSmiles.includes(e.original)?e.original:((0,l.R)(e.original),e.original.native),values:(e,t)=>{const i=(0,l.K)(e);this.textSmiles.includes(":"+e)&&i.unshift(":"+e),t(i)},containerClass:"tribute-container-emoji",itemClass:"tribute-container-emoji__item"},linkOptions:{trigger:"/",lookup:(e,t)=>t,menuContainer:this.menuContainer,menuItemTemplate:e=>`<img class="tribute-container-link__item__icon" src="${e.original.icon_url}"> <span class="tribute-container-link__item__title">${e.original.title}</span>`,noMatchTemplate:()=>(0,o.t)("No link provider found"),selectTemplate:this.getLink,values:(e,t)=>t((0,c.n)(e)),containerClass:"tribute-container-link",itemClass:"tribute-container-link__item"},localValue:this.value,isComposing:!1}},computed:{isEmptyValue(){return!this.localValue||this.localValue&&""===this.localValue.trim()},isFF:()=>!!navigator.userAgent.match(/firefox/i),isOverMaxlength(){return!(this.isEmptyValue||!this.maxlength)&&(0,d.default)(this.localValue)>this.maxlength},tooltipString(){return this.isOverMaxlength?{content:(0,o.t)("Message limit of {count} characters reached",{count:this.maxlength}),shown:!0,trigger:"manual"}:null},canEdit(){return this.contenteditable&&!this.disabled},listeners(){const e={...this.$listeners};return delete e.paste,e}},watch:{value(){const e=this.$refs.contenteditable.innerHTML;this.value.trim()!==this.parseContent(e).trim()&&this.updateContent(this.value)}},mounted(){this.textSmiles=[],["d","D","p","P","s","S","x","X",")","(","|","/"].forEach((e=>{this.textSmiles.push(":"+e),this.textSmiles.push(":-"+e)})),this.autocompleteTribute=new a.default(this.autocompleteOptions),this.autocompleteTribute.attach(this.$el),this.emojiAutocomplete&&(this.emojiTribute=new a.default(this.emojiOptions),this.emojiTribute.attach(this.$el)),this.linkAutocomplete&&(this.linkTribute=new a.default(this.linkOptions),this.linkTribute.attach(this.$el)),this.updateContent(this.value),this.$refs.contenteditable.contentEditable=this.canEdit},beforeDestroy(){this.autocompleteTribute&&this.autocompleteTribute.detach(this.$el),this.emojiTribute&&this.emojiTribute.detach(this.$el),this.linkTribute&&this.linkTribute.detach(this.$el)},methods:{focus(){this.$refs.contenteditable.focus()},getLink(e){return(0,c.j)(e.original.id).then((e=>{const t=document.getElementById("tmp-smart-picker-result-node"),i={result:e,insertText:!0};if(this.$emit("smart-picker-submit",i),i.insertText){const i=document.createTextNode(e);t.replaceWith(i),this.setCursorAfter(i),this.updateValue(this.$refs.contenteditable.innerHTML)}else t.remove()})).catch((e=>{p.debug("Smart picker promise rejected:",e);const t=document.getElementById("tmp-smart-picker-result-node");this.setCursorAfter(t),t.remove()})),'<span id="tmp-smart-picker-result-node"></span>'},setCursorAfter(e){const t=document.createRange();t.setEndAfter(e),t.collapse();const i=window.getSelection();i.removeAllRanges(),i.addRange(t)},onInput(e){this.updateValue(e.target.innerHTML)},onPaste(e){if(!this.canEdit)return;e.preventDefault();const t=e.clipboardData;if(this.$emit("paste",e),0!==t.files.length||!Object.values(t.items).find((e=>null==e?void 0:e.type.startsWith("text"))))return;const i=t.getData("text"),n=window.getSelection();if(!n.rangeCount)return void this.updateValue(i);const r=n.getRangeAt(0);n.deleteFromDocument(),r.insertNode(document.createTextNode(i));const s=document.createRange();s.setStart(e.target,r.endOffset),s.collapse(!0),n.removeAllRanges(),n.addRange(s),this.updateValue(this.$refs.contenteditable.innerHTML)},updateValue(e){const t=this.parseContent(e);this.localValue=t,this.$emit("update:value",t)},updateContent(e){const t=this.renderContent(e);this.$refs.contenteditable.innerHTML=t,this.localValue=e},onDelete(e){if(!this.isFF||!window.getSelection||!this.canEdit)return;const t=window.getSelection(),i=e.target;if(!t.isCollapsed||!t.rangeCount)return;const n=t.getRangeAt(t.rangeCount-1);if(3===n.commonAncestorContainer.nodeType&&n.startOffset>0)return;const r=document.createRange();if(t.anchorNode!==i)r.selectNodeContents(i),r.setEndBefore(t.anchorNode);else{if(!(t.anchorOffset>0))return;r.setEnd(i,t.anchorOffset)}r.setStart(i,r.endOffset-1);const s=r.cloneContents().lastChild;s&&"false"===s.contentEditable&&(r.deleteContents(),e.preventDefault())},onEnter(e){this.multiline||this.isOverMaxlength||this.autocompleteTribute.isActive||this.emojiTribute.isActive||this.linkTribute.isActive||this.isComposing||(e.preventDefault(),e.stopPropagation(),this.$emit("submit",e))},onCtrlEnter(e){this.isOverMaxlength||this.$emit("submit",e)},debouncedAutoComplete:u((async function(e,t){this.autoComplete(e,t)}),100),onKeyUp(e){e.stopImmediatePropagation()}}};var w=function(){var e=this;return(0,e._self._c)("div",e._g({directives:[{name:"tooltip",rawName:"v-tooltip",value:e.tooltipString,expression:"tooltipString"}],ref:"contenteditable",staticClass:"rich-contenteditable__input",class:{"rich-contenteditable__input--empty":e.isEmptyValue,"rich-contenteditable__input--multiline":e.multiline,"rich-contenteditable__input--overflow":e.isOverMaxlength,"rich-contenteditable__input--disabled":e.disabled},attrs:{contenteditable:e.canEdit,placeholder:e.placeholder,"aria-placeholder":e.placeholder,"aria-multiline":"true",role:"textbox"},on:{input:e.onInput,compositionstart:function(t){e.isComposing=!0},compositionend:function(t){e.isComposing=!1},keydown:[function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"delete",[8,46],t.key,["Backspace","Delete","Del"])?null:e.onDelete.apply(null,arguments)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")||t.ctrlKey||t.shiftKey||t.altKey||t.metaKey?null:e.onEnter.apply(null,arguments)},function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")||!t.ctrlKey||t.shiftKey||t.altKey||t.metaKey?null:(t.stopPropagation(),t.preventDefault(),e.onCtrlEnter.apply(null,arguments))}],paste:e.onPaste,"!keyup":function(t){return t.stopPropagation(),t.preventDefault(),e.onKeyUp.apply(null,arguments)}}},e.listeners))},C=[];const y=(0,s.n)(b,w,C,!1,null,"599f92d5",null,null).exports},94027:(e,t,i)=>{i.d(t,{N:()=>k,j:()=>de,n:()=>N}),i(37762);var n=i(76311),r=i(36842),s=i(93664),o=i(43554),l=i(79753),c=i(22175),a=i(40873),u=i(19664),d=i(20435),h=i(49368),p=i(35676),m=i(62642),f=i(25475),g=i(69183),v=i(79033),b=i(60545),w=i(20144),C=i(25108);window._vue_richtext_widgets||(window._vue_richtext_widgets={}),window._registerWidget=(e,t,i=(e=>{}))=>{window._vue_richtext_widgets[e]?C.error("Widget for id "+e+" already registered"):window._vue_richtext_widgets[e]={id:e,callback:t,onDestroy:i}};const y={name:"NcReferenceWidget",props:{reference:{type:Object,required:!0}},data:()=>({compact:3}),computed:{hasCustomWidget(){return e=this.reference.richObjectType,!!window._vue_richtext_widgets[e];var e},noAccess(){return this.reference&&!this.reference.accessible},descriptionStyle(){if(0===this.compact)return{display:"none"};const e=this.compact<4?this.compact:3;return{lineClamp:e,webkitLineClamp:e}},compactLink(){const e=this.reference.openGraphObject.link;return e?e.startsWith("https://")?e.substring(8):e.startsWith("http://")?e.substring(7):e:""}},mounted(){this.renderWidget(),this.observer=new ResizeObserver((e=>{e[0].contentRect.width<450?this.compact=0:e[0].contentRect.width<550?this.compact=1:e[0].contentRect.width<650?this.compact=2:this.compact=3})),this.observer.observe(this.$el)},beforeDestroy(){var e,t;this.observer.disconnect(),e=this.reference.richObjectType,t=this.$el,"open-graph"!==e&&window._vue_richtext_widgets[e]&&window._vue_richtext_widgets[e].onDestroy(t)},methods:{renderWidget(){var e;this.$refs.customWidget&&(this.$refs.customWidget.innerHTML=""),"open-graph"!==(null==(e=null==this?void 0:this.reference)?void 0:e.richObjectType)&&this.$nextTick((()=>{((e,{richObjectType:t,richObject:i,accessible:n})=>{if("open-graph"!==t){if(!window._vue_richtext_widgets[t])return void C.error("Widget for rich object type "+t+" not registered");window._vue_richtext_widgets[t].callback(e,{richObjectType:t,richObject:i,accessible:n})}})(this.$refs.customWidget,this.reference)}))}}};var _=function(){var e=this,t=e._self._c;return t("div",[e.reference&&e.hasCustomWidget?t("div",{staticClass:"widget-custom"},[t("div",{ref:"customWidget"})]):!e.noAccess&&e.reference&&e.reference.openGraphObject&&!e.hasCustomWidget?t("a",{staticClass:"widget-default",attrs:{href:e.reference.openGraphObject.link,rel:"noopener noreferrer",target:"_blank"}},[e.reference.openGraphObject.thumb?t("img",{staticClass:"widget-default--image",attrs:{src:e.reference.openGraphObject.thumb}}):e._e(),t("div",{staticClass:"widget-default--details"},[t("p",{staticClass:"widget-default--name"},[e._v(e._s(e.reference.openGraphObject.name))]),t("p",{staticClass:"widget-default--description",style:e.descriptionStyle},[e._v(e._s(e.reference.openGraphObject.description))]),t("p",{staticClass:"widget-default--link"},[e._v(e._s(e.compactLink))])])]):e._e()])},S=[];const k=(0,n.n)(y,_,S,!1,null,"b1c5a80f",null,null).exports;window._vue_richtext_custom_picker_elements||(window._vue_richtext_custom_picker_elements={});const T=e=>!!window._vue_richtext_custom_picker_elements[e];window._registerCustomPickerElement=(e,t,i=(e=>{}),n="large")=>{window._vue_richtext_custom_picker_elements[e]?C.error("Custom reference picker element for id "+e+" already registered"):window._vue_richtext_custom_picker_elements[e]={id:e,callback:t,onDestroy:i,size:n}};const E={name:"NcCustomPickerElement",props:{provider:{type:Object,required:!0}},emits:["cancel","submit"],data(){return{isRegistered:T(this.provider.id),renderResult:null}},mounted(){this.isRegistered&&this.renderElement()},beforeDestroy(){var e,t,i;this.isRegistered&&(e=this.provider.id,t=this.$el,i=this.renderResult,window._vue_richtext_custom_picker_elements[e]&&window._vue_richtext_custom_picker_elements[e].onDestroy(t,i))},methods:{renderElement(){this.$refs.domElement&&(this.$refs.domElement.innerHTML="");const e=((e,{providerId:t,accessible:i})=>{if(window._vue_richtext_custom_picker_elements[t])return window._vue_richtext_custom_picker_elements[t].callback(e,{providerId:t,accessible:i});C.error("Custom reference picker element for reference provider ID "+t+" not registered")})(this.$refs.domElement,{providerId:this.provider.id,accessible:!1});Promise.resolve(e).then((e=>{var t,i;this.renderResult=e,null!=(t=this.renderResult.object)&&t._isVue&&null!=(i=this.renderResult.object)&&i.$on&&(this.renderResult.object.$on("submit",this.onSubmit),this.renderResult.object.$on("cancel",this.onCancel)),this.renderResult.element.addEventListener("submit",(e=>{this.onSubmit(e.detail)})),this.renderResult.element.addEventListener("cancel",this.onCancel)}))},onSubmit(e){this.$emit("submit",e)},onCancel(){this.$emit("cancel")}}};var x=function(){return(0,this._self._c)("div",{ref:"domElement"})},P=[];const L=(0,n.n)(E,x,P,!1,null,"cf695ff9",null,null).exports,I="any-link",M={id:I,title:(0,r.t)("Any link"),icon_url:(0,l.imagePath)("core","filetypes/link.svg")};function A(){return window._vue_richtext_reference_providers.filter((e=>{const t=!!e.search_providers_ids&&e.search_providers_ids.length>0||T(e.id);return t||C.debug("[smart picker]",e.id,"reference provider is discoverable but does not have any related search provider or custom picker component registered"),t}))}function N(e,t=null){const i=A(),n=e.replace(/[/\-\\^$*+?.()|[\]{}]/g,"\\$&"),r=new RegExp(n,"i"),s=function(e){const t=window._vue_richtext_reference_provider_timestamps;return e.sort(((e,t)=>e.order===t.order?0:e.order>t.order?1:-1)).sort(((e,i)=>{const n=t[e.id],r=t[i.id];return n===r?0:void 0===r?-1:void 0===n?1:n>r?-1:1}))}(i).filter((e=>e.title.match(r))),o=t?s.slice(0,t):s;return(""===e||0===o.length)&&o.push(M),o}window._vue_richtext_reference_providers||(window._vue_richtext_reference_providers=(0,o.j)("core","reference-provider-list",[])),window._vue_richtext_reference_provider_timestamps||(window._vue_richtext_reference_provider_timestamps=(0,o.j)("core","reference-provider-timestamps",{}));let O=0;function R(e,t){return function(){const i=this,n=arguments;clearTimeout(O),O=setTimeout((function(){e.apply(i,n)}),t||0)}}function $(e){try{return!!new URL(e)}catch{return!1}}const D={name:"LinkVariantIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var B=function(){var e=this,t=e._self._c;return t("span",e._b({staticClass:"material-design-icon link-variant-icon",attrs:{"aria-hidden":!e.title,"aria-label":e.title,role:"img"},on:{click:function(t){return e.$emit("click",t)}}},"span",e.$attrs,!1),[t("svg",{staticClass:"material-design-icon__svg",attrs:{fill:e.fillColor,width:e.size,height:e.size,viewBox:"0 0 24 24"}},[t("path",{attrs:{d:"M10.59,13.41C11,13.8 11,14.44 10.59,14.83C10.2,15.22 9.56,15.22 9.17,14.83C7.22,12.88 7.22,9.71 9.17,7.76V7.76L12.71,4.22C14.66,2.27 17.83,2.27 19.78,4.22C21.73,6.17 21.73,9.34 19.78,11.29L18.29,12.78C18.3,11.96 18.17,11.14 17.89,10.36L18.36,9.88C19.54,8.71 19.54,6.81 18.36,5.64C17.19,4.46 15.29,4.46 14.12,5.64L10.59,9.17C9.41,10.34 9.41,12.24 10.59,13.41M13.41,9.17C13.8,8.78 14.44,8.78 14.83,9.17C16.78,11.12 16.78,14.29 14.83,16.24V16.24L11.29,19.78C9.34,21.73 6.17,21.73 4.22,19.78C2.27,17.83 2.27,14.66 4.22,12.71L5.71,11.22C5.7,12.04 5.83,12.86 6.11,13.65L5.64,14.12C4.46,15.29 4.46,17.19 5.64,18.36C6.81,19.54 8.71,19.54 9.88,18.36L13.41,14.83C14.59,13.66 14.59,11.76 13.41,10.59C13,10.2 13,9.56 13.41,9.17Z"}},[e.title?t("title",[e._v(e._s(e.title))]):e._e()])])])},j=[];const W=(0,n.n)(D,B,j,!1,null,null,null,null).exports,V={name:"NcProviderList",components:{NcSelect:u.Z,NcHighlight:a.N,NcEmptyContent:c.Z,LinkVariantIcon:W},emits:["select-provider","submit"],data:()=>({selectedProvider:null,query:"",multiselectPlaceholder:(0,r.t)("Select provider"),providerIconAlt:(0,r.t)("Provider icon")}),computed:{options(){const e=[];return""!==this.query&&$(this.query)&&e.push({id:this.query,title:this.query,isLink:!0}),e.push(...N(this.query)),e}},methods:{focus(){setTimeout((()=>{var e,t,i;null==(i=null==(t=null==(e=this.$refs["provider-select"])?void 0:e.$el)?void 0:t.querySelector("#provider-select-input"))||i.focus()}),300)},onProviderSelected(e){null!==e&&(e.isLink?this.$emit("submit",e.title):this.$emit("select-provider",e),this.selectedProvider=null)},onSearch(e,t){this.query=e}}};var H=function(){var e=this,t=e._self._c;return t("div",{staticClass:"provider-list"},[t("NcSelect",{ref:"provider-select",staticClass:"provider-list--select",attrs:{"input-id":"provider-select-input",label:"title",placeholder:e.multiselectPlaceholder,options:e.options,"append-to-body":!1,"clear-search-on-select":!0,"clear-search-on-blur":()=>!1,filterable:!1},on:{search:e.onSearch,input:e.onProviderSelected},scopedSlots:e._u([{key:"option",fn:function(i){return[i.isLink?t("div",{staticClass:"provider"},[t("LinkVariantIcon",{staticClass:"link-icon",attrs:{size:20}}),t("span",[e._v(e._s(i.title))])],1):t("div",{staticClass:"provider"},[t("img",{staticClass:"provider-icon",attrs:{src:i.icon_url,alt:e.providerIconAlt}}),t("NcHighlight",{staticClass:"option-text",attrs:{search:e.query,text:i.title}})],1)]}}]),model:{value:e.selectedProvider,callback:function(t){e.selectedProvider=t},expression:"selectedProvider"}}),t("NcEmptyContent",{staticClass:"provider-list--empty-content",scopedSlots:e._u([{key:"icon",fn:function(){return[t("LinkVariantIcon")]},proxy:!0}])})],1)},q=[];const U=(0,n.n)(V,H,q,!1,null,"9d850ea5",null,null).exports,z={name:"NcRawLinkInput",components:{LinkVariantIcon:W,NcEmptyContent:c.Z,NcLoadingIcon:d.Z,NcReferenceWidget:k,NcTextField:h.Z},props:{provider:{type:Object,required:!0}},emits:["submit"],data:()=>({inputValue:"",loading:!1,reference:null,abortController:null,inputPlaceholder:(0,r.t)("Enter link")}),computed:{isLinkValid(){return $(this.inputValue)}},methods:{focus(){var e;null==(e=this.$refs["url-input"].$el.getElementsByTagName("input")[0])||e.focus()},onSubmit(e){const t=e.target.value;this.isLinkValid&&this.$emit("submit",t)},onClear(){this.inputValue="",this.reference=null},onInput(){this.reference=null,this.abortController&&this.abortController.abort(),this.isLinkValid&&R((()=>{this.updateReference()}),500)()},updateReference(){this.loading=!0,this.abortController=new AbortController,s.Z.get((0,l.generateOcsUrl)("references/resolve",2)+"?reference="+encodeURIComponent(this.inputValue),{signal:this.abortController.signal}).then((e=>{this.reference=e.data.ocs.data.references[this.inputValue]})).catch((e=>{C.error(e)})).then((()=>{this.loading=!1}))}}};var F=function(){var e=this,t=e._self._c;return t("div",{staticClass:"raw-link"},[t("div",{staticClass:"input-wrapper"},[t("NcTextField",{ref:"url-input",attrs:{value:e.inputValue,"show-trailing-button":""!==e.inputValue,label:e.inputPlaceholder},on:{"update:value":[function(t){e.inputValue=t},e.onInput],"trailing-button-click":e.onClear},nativeOn:{keyup:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.onSubmit.apply(null,arguments)}}},[e.loading?t("NcLoadingIcon",{attrs:{size:16}}):t("LinkVariantIcon",{attrs:{size:16}})],1)],1),null!==e.reference?t("NcReferenceWidget",{staticClass:"reference-widget",attrs:{reference:e.reference}}):t("NcEmptyContent",{staticClass:"raw-link--empty-content",scopedSlots:e._u([{key:"icon",fn:function(){return[e.provider.icon_url?t("img",{staticClass:"provider-icon",attrs:{src:e.provider.icon_url}}):t("LinkVariantIcon")]},proxy:!0}])})],1)},K=[];const Z=(0,n.n)(z,F,K,!1,null,"d0ba247a",null,null).exports,Y={name:"NcSearchResult",components:{NcHighlight:a.N},props:{entry:{type:Object,required:!0},query:{type:String,required:!0}}};var G=function(){var e=this,t=e._self._c;return t("div",{staticClass:"result"},[e.entry.icon?t("div",{staticClass:"result--icon-class",class:{[e.entry.icon]:!0,rounded:e.entry.rounded}}):t("img",{staticClass:"result--image",class:{rounded:e.entry.rounded},attrs:{src:e.entry.thumbnailUrl}}),t("div",{staticClass:"result--content"},[t("span",{staticClass:"result--content--name"},[t("NcHighlight",{attrs:{search:e.query,text:e.entry.title}})],1),t("span",{staticClass:"result--content--subline"},[t("NcHighlight",{attrs:{search:e.query,text:e.entry.subline}})],1)])])},Q=[];const X=(0,n.n)(Y,G,Q,!1,null,"7a394a58",null,null).exports,J={name:"NcSearch",components:{LinkVariantIcon:W,DotsHorizontalIcon:p.D,NcEmptyContent:c.Z,NcSelect:u.Z,NcSearchResult:X},props:{provider:{type:Object,required:!0},showEmptyContent:{type:Boolean,default:!0},searchPlaceholder:{type:String,default:null}},emits:["submit"],data:()=>({searchQuery:"",selectedResult:null,resultsBySearchProvider:{},searching:!1,searchingMoreOf:null,abortController:null,noOptionsText:(0,r.t)("Start typing to search"),providerIconAlt:(0,r.t)("Provider icon")}),computed:{mySearchPlaceholder(){return this.searchPlaceholder||(0,r.t)("Search")},searchProviderIds(){return this.provider.search_providers_ids},options(){if(""===this.searchQuery)return[];const e=[];return $(this.searchQuery)&&e.push(this.rawLinkEntry),e.push(...this.formattedSearchResults),e},rawLinkEntry(){return{id:"rawLinkEntry",resourceUrl:this.searchQuery,isRawLink:!0}},formattedSearchResults(){const e=[];return this.searchProviderIds.forEach((t=>{if(this.resultsBySearchProvider[t].entries.length>0){(this.searchProviderIds.length>1||this.resultsBySearchProvider[t].entries.length>1)&&e.push({id:"groupTitle-"+t,name:this.resultsBySearchProvider[t].name,isCustomGroupTitle:!0,providerId:t});const i=this.resultsBySearchProvider[t].entries.map(((e,i)=>({id:"provider-"+t+"-entry-"+i,...e})));e.push(...i),this.resultsBySearchProvider[t].isPaginated&&e.push({id:"moreOf-"+t,name:this.resultsBySearchProvider[t].name,isMore:!0,providerId:t,isLoading:this.searchingMoreOf===t})}})),e}},mounted(){this.resetResults()},beforeDestroy(){this.cancelSearchRequests()},methods:{t:r.t,resetResults(){const e={};this.searchProviderIds.forEach((t=>{e[t]={entries:[]}})),this.resultsBySearchProvider=e},focus(){setTimeout((()=>{var e,t,i;null==(i=null==(t=null==(e=this.$refs["search-select"])?void 0:e.$el)?void 0:t.querySelector("#search-select-input"))||i.focus()}),300)},cancelSearchRequests(){this.abortController&&this.abortController.abort()},onSearchInput(e,t){this.searchQuery=e,R((()=>{this.updateSearch()}),500)()},onSelectResultSelected(e){null!==e&&(e.resourceUrl?(this.cancelSearchRequests(),this.$emit("submit",e.resourceUrl)):e.isMore&&this.searchMoreOf(e.providerId).then((()=>{this.selectedResult=null})))},searchMoreOf(e){return this.searchingMoreOf=e,this.cancelSearchRequests(),this.searchProviders(e)},updateSearch(){if(this.cancelSearchRequests(),this.resetResults(),""!==this.searchQuery)return this.searchProviders();this.searching=!1},searchProviders(e=null){var t,i;this.abortController=new AbortController,this.searching=!0;const n=null===e?[...this.searchProviderIds].map((e=>this.searchOneProvider(e))):[this.searchOneProvider(e,null!=(i=null==(t=this.resultsBySearchProvider[e])?void 0:t.cursor)?i:null)];return Promise.allSettled(n).then((e=>{e.find((e=>"rejected"===e.status&&("CanceledError"===e.reason.name||"ERR_CANCELED"===e.reason.code)))||(this.searching=!1,this.searchingMoreOf=null)}))},searchOneProvider(e,t=null){const i=null===t?(0,l.generateOcsUrl)("search/providers/{providerId}/search?term={term}&limit={limit}",{providerId:e,term:this.searchQuery,limit:5}):(0,l.generateOcsUrl)("search/providers/{providerId}/search?term={term}&limit={limit}&cursor={cursor}",{providerId:e,term:this.searchQuery,limit:5,cursor:t});return s.Z.get(i,{signal:this.abortController.signal}).then((t=>{const i=t.data.ocs.data;this.resultsBySearchProvider[e].name=i.name,this.resultsBySearchProvider[e].cursor=i.cursor,this.resultsBySearchProvider[e].isPaginated=i.isPaginated,this.resultsBySearchProvider[e].entries.push(...i.entries)}))}}};var ee=function(){var e=this,t=e._self._c;return t("div",{staticClass:"smart-picker-search",class:{"with-empty-content":e.showEmptyContent}},[t("NcSelect",{ref:"search-select",staticClass:"smart-picker-search--select",attrs:{"input-id":"search-select-input",label:"name",placeholder:e.mySearchPlaceholder,options:e.options,"append-to-body":!1,"close-on-select":!1,"clear-search-on-select":!1,"clear-search-on-blur":()=>!1,"reset-focus-on-options-change":!1,filterable:!1,autoscroll:!0,"reset-on-options-change":!1,loading:e.searching},on:{search:e.onSearchInput,input:e.onSelectResultSelected},scopedSlots:e._u([{key:"option",fn:function(i){return[i.isRawLink?t("div",{staticClass:"custom-option"},[t("LinkVariantIcon",{staticClass:"option-simple-icon",attrs:{size:20}}),t("span",{staticClass:"option-text"},[e._v(" "+e._s(e.t("Raw link {options}",{options:i.resourceUrl}))+" ")])],1):i.resourceUrl?t("NcSearchResult",{staticClass:"search-result",attrs:{entry:i,query:e.searchQuery}}):i.isCustomGroupTitle?t("span",{staticClass:"custom-option group-name"},[e.provider.icon_url?t("img",{staticClass:"provider-icon group-name-icon",attrs:{src:e.provider.icon_url}}):e._e(),t("span",{staticClass:"option-text"},[t("strong",[e._v(e._s(i.name))])])]):i.isMore?t("span",{class:{"custom-option":!0}},[i.isLoading?t("span",{staticClass:"option-simple-icon icon-loading-small"}):t("DotsHorizontalIcon",{staticClass:"option-simple-icon",attrs:{size:20}}),t("span",{staticClass:"option-text"},[e._v(" "+e._s(e.t('Load more "{options}"',{options:i.name}))+" ")])],1):e._e()]}},{key:"no-options",fn:function(){return[e._v(" "+e._s(e.noOptionsText)+" ")]},proxy:!0}]),model:{value:e.selectedResult,callback:function(t){e.selectedResult=t},expression:"selectedResult"}}),e.showEmptyContent?t("NcEmptyContent",{staticClass:"smart-picker-search--empty-content",scopedSlots:e._u([{key:"icon",fn:function(){return[e.provider.icon_url?t("img",{staticClass:"provider-icon",attrs:{alt:e.providerIconAlt,src:e.provider.icon_url}}):t("LinkVariantIcon")]},proxy:!0}],null,!1,2922132592)}):e._e()],1)},te=[];const ie=(0,n.n)(J,ee,te,!1,null,"97d196f0",null,null).exports,ne={providerList:1,standardLinkInput:2,searchInput:3,customElement:4},re={name:"NcReferencePicker",components:{NcCustomPickerElement:L,NcProviderList:U,NcRawLinkInput:Z,NcSearch:ie},props:{initialProvider:{type:Object,default:()=>null},width:{type:Number,default:null},focusOnCreate:{type:Boolean,default:!0}},emits:["cancel","cancel-raw-link","cancel-search","provider-selected","submit"],data(){return{MODES:ne,selectedProvider:this.initialProvider}},computed:{mode(){return null===this.selectedProvider?ne.providerList:T(this.selectedProvider.id)?ne.customElement:this.selectedProvider.search_providers_ids?ne.searchInput:ne.standardLinkInput},pickerWrapperStyle(){return{width:this.width?this.width+"px":void 0}}},mounted(){this.focusOnCreate&&(this.initialProvider?setTimeout((()=>{var e;null==(e=this.$refs["url-input"])||e.focus()}),300):this.$nextTick((()=>{var e;null==(e=this.$refs["provider-list"])||e.focus()})))},methods:{onEscapePressed(){null!==this.selectedProvider?this.deselectProvider():this.cancelProviderSelection()},onProviderSelected(e){this.selectedProvider=e,this.$emit("provider-selected",e),this.$nextTick((()=>{var e;null==(e=this.$refs["url-input"])||e.focus()}))},cancelCustomElement(){this.deselectProvider()},cancelSearch(){var e;this.$emit("cancel-search",null==(e=this.selectedProvider)?void 0:e.title),this.deselectProvider()},cancelRawLinkInput(){var e;this.$emit("cancel-raw-link",null==(e=this.selectedProvider)?void 0:e.title),this.deselectProvider()},cancelProviderSelection(){this.$emit("cancel")},submitLink(e){null!==this.selectedProvider&&function(e){const t=Math.floor(Date.now()/1e3),i={timestamp:t},n=(0,l.generateOcsUrl)("references/provider/{providerId}",{providerId:e});s.Z.put(n,i).then((i=>{window._vue_richtext_reference_provider_timestamps[e]=t}))}(this.selectedProvider.id),this.$emit("submit",e),this.deselectProvider()},deselectProvider(){this.selectedProvider=null,this.$emit("provider-selected",null),setTimeout((()=>{var e;null==(e=this.$refs["provider-list"])||e.focus()}),300)}}};var se=function(){var e=this,t=e._self._c;return t("div",{staticClass:"reference-picker",style:e.pickerWrapperStyle,attrs:{tabindex:"-1"},on:{keydown:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"esc",27,t.key,["Esc","Escape"])?null:(t.stopPropagation(),t.preventDefault(),e.onEscapePressed.apply(null,arguments))}}},[e.mode===e.MODES.providerList?t("NcProviderList",{ref:"provider-list",on:{"select-provider":e.onProviderSelected,submit:e.submitLink,cancel:e.cancelProviderSelection}}):e.mode===e.MODES.standardLinkInput?t("NcRawLinkInput",{ref:"url-input",attrs:{provider:e.selectedProvider},on:{submit:e.submitLink,cancel:e.cancelRawLinkInput}}):e.mode===e.MODES.searchInput?t("NcSearch",{ref:"url-input",attrs:{provider:e.selectedProvider},on:{cancel:e.cancelSearch,submit:e.submitLink}}):e.mode===e.MODES.customElement?t("div",{staticClass:"custom-element-wrapper"},[t("NcCustomPickerElement",{attrs:{provider:e.selectedProvider},on:{submit:e.submitLink,cancel:e.cancelCustomElement}})],1):e._e()],1)},oe=[];const le={name:"NcReferencePickerModal",components:{NcReferencePicker:(0,n.n)(re,se,oe,!1,null,"aa77d0d3",null,null).exports,NcModal:f.Z,NcButton:m.Z,ArrowLeftIcon:v.A,CloseIcon:b.C},props:{initialProvider:{type:Object,default:()=>null},focusOnCreate:{type:Boolean,default:!0},isInsideViewer:{type:Boolean,default:!1}},emits:["cancel","submit"],data(){return{show:!0,selectedProvider:this.initialProvider,backButtonTitle:(0,r.t)("Back to provider selection"),closeButtonTitle:(0,r.t)("Close"),closeButtonLabel:(0,r.t)("Close Smart Picker")}},computed:{isProviderSelected(){return null!==this.selectedProvider},showBackButton(){return null===this.initialProvider&&this.isProviderSelected},modalSize(){var e;return this.isProviderSelected&&T(this.selectedProvider.id)?null!=(e=(e=>{var t;const i=null==(t=window._vue_richtext_custom_picker_elements[e])?void 0:t.size;return["small","normal","large","full"].includes(i)?i:null})(this.selectedProvider.id))?e:"large":"normal"},showModalName(){return!this.isProviderSelected||!T(this.selectedProvider.id)},modalName(){return this.isProviderSelected?this.selectedProvider.title:(0,r.t)("Smart Picker")}},mounted(){if(this.isInsideViewer){const e=this.$refs.modal_content;(0,g.j8)("viewer:trapElements:changed",e)}},methods:{onCancel(){this.show=!1,this.$emit("cancel")},onSubmit(e){this.show=!1,this.$emit("submit",e)},onProviderSelect(e){this.selectedProvider=e,null===e&&null!==this.initialProvider&&this.onCancel()},onBackClicked(){this.$refs.referencePicker.deselectProvider()}}};var ce=function(){var e=this,t=e._self._c;return e.show?t("NcModal",{staticClass:"reference-picker-modal",attrs:{size:e.modalSize,"can-close":!1},on:{close:e.onCancel}},[t("div",{ref:"modal_content",staticClass:"reference-picker-modal--content"},[e.showBackButton?t("NcButton",{staticClass:"back-button",attrs:{"aria-label":e.backButtonTitle,title:e.backButtonTitle},on:{click:e.onBackClicked},scopedSlots:e._u([{key:"icon",fn:function(){return[t("ArrowLeftIcon")]},proxy:!0}],null,!1,3001860362)}):e._e(),t("NcButton",{staticClass:"close-button",attrs:{"aria-label":e.closeButtonLabel,title:e.closeButtonTitle,type:"tertiary"},on:{click:e.onCancel},scopedSlots:e._u([{key:"icon",fn:function(){return[t("CloseIcon")]},proxy:!0}],null,!1,2491825086)}),e.showModalName?t("h2",[e._v(" "+e._s(e.modalName)+" ")]):e._e(),t("NcReferencePicker",{ref:"referencePicker",attrs:{"initial-provider":e.initialProvider,"focus-on-create":e.focusOnCreate},on:{"provider-selected":e.onProviderSelect,submit:e.onSubmit,cancel:e.onCancel}})],1)]):e._e()},ae=[];const ue=(0,n.n)(le,ce,ae,!1,null,"3f1a4ac7",null,null).exports;async function de(e=null,t=void 0){return await new Promise(((i,n)=>{var r;const s=document.createElement("div");s.id="referencePickerModal",document.body.append(s);const o=null===e?null:null!=(r=function(e){return e===I?M:A().find((t=>t.id===e))}(e))?r:null,l=new(w.default.extend(ue))({propsData:{initialProvider:o,isInsideViewer:t}}).$mount(s);l.$on("cancel",(()=>{l.$destroy(),n(new Error("User cancellation"))})),l.$on("submit",(e=>{l.$destroy(),i(e)}))}))}},8014:(e,t,i)=>{i.d(t,{default:()=>s});var n=i(42639),r=i(3181);function s(e,{countAnsiEscapeCodes:t=!1}={}){return""===e?0:(t||(e=(0,n.Z)(e)),""===e?0:e.match((0,r.Z)()).length)}}}]);
- //# sourceMappingURL=6318-6318.js.map?v=6ddf32e38096b6251432
|