(self.webpackChunknodebb=self.webpackChunknodebb||[]).push([[20056],{7037:p=>{(function(){var r=["direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize","MozTabSize"],c=typeof window<"u",f=c&&window.mozInnerScreenX!=null;function d(a,s,n){if(!c)throw new Error("textarea-caret-position#getCaretCoordinates should only be called in a browser");var e=n&&n.debug||!1;if(e){var t=document.querySelector("#input-textarea-caret-position-mirror-div");t&&t.parentNode.removeChild(t)}var i=document.createElement("div");i.id="input-textarea-caret-position-mirror-div",document.body.appendChild(i);var o=i.style,l=window.getComputedStyle?window.getComputedStyle(a):a.currentStyle,h=a.nodeName==="INPUT";o.whiteSpace="pre-wrap",h||(o.wordWrap="break-word"),o.position="absolute",e||(o.visibility="hidden"),r.forEach(function(u){h&&u==="lineHeight"?o.lineHeight=l.height:o[u]=l[u]}),f?a.scrollHeight>parseInt(l.height)&&(o.overflowY="scroll"):o.overflow="hidden",i.textContent=a.value.substring(0,s),h&&(i.textContent=i.textContent.replace(/\s/g,"\xA0"));var v=document.createElement("span");v.textContent=a.value.substring(s)||".",i.appendChild(v);var g={top:v.offsetTop+parseInt(l.borderTopWidth),left:v.offsetLeft+parseInt(l.borderLeftWidth),height:parseInt(l.lineHeight)};return e?v.style.backgroundColor="#aaa":document.body.removeChild(i),g}typeof p.exports<"u"?p.exports=d:c&&(window.getCaretCoordinates=d)})()},9787:(p,r,c)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.TextareaEditor=void 0;var f=c(48456);Object.defineProperty(r,"TextareaEditor",{enumerable:!0,get:function(){return f.TextareaEditor}})},9794:(p,r,c)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ContenteditableEditor=void 0;const f=c(36e3),d=c(29326);class a extends f.Editor{constructor(n){super(),this.el=n,this.onInput=()=>{this.emitChangeEvent()},this.onKeydown=e=>{const t=this.getCode(e);let i;t==="UP"||t==="DOWN"?i=this.emitMoveEvent(t):t==="ENTER"?i=this.emitEnterEvent():t==="ESC"&&(i=this.emitEscEvent()),i&&i.defaultPrevented&&e.preventDefault()},this.startListening=()=>{this.el.addEventListener("input",this.onInput),this.el.addEventListener("keydown",this.onKeydown)},this.stopListening=()=>{this.el.removeEventListener("input",this.onInput),this.el.removeEventListener("keydown",this.onKeydown)},this.startListening()}destroy(){return super.destroy(),this.stopListening(),this}applySearchResult(n){const e=this.getBeforeCursor(),t=this.getAfterCursor();if(e!=null&&t!=null){const i=n.replace(e,t);if(Array.isArray(i)){let o=i[0];(0,d.isSafari)()&&(o=o.replace(e,""));const l=this.getRange();l.selectNode(l.startContainer),this.el.ownerDocument.execCommand("insertText",!1,o+i[1]),l.detach();const h=this.getRange();h.setStart(h.startContainer,o.length),h.collapse(!0)}}}getCursorOffset(){const n=this.getRange(),e=n.getBoundingClientRect(),t=this.el.ownerDocument.body.getBoundingClientRect(),i=n.startContainer,o=i instanceof Text?i.parentElement:i,l=e.left,h=(0,d.getLineHeightPx)(o),v=e.top-t.top+h;return this.el.dir!=="rtl"?{left:l,lineHeight:h,top:v}:{right:document.documentElement.clientWidth-l,lineHeight:h,top:v}}getBeforeCursor(){const n=this.getRange();return n.collapsed&&n.startContainer instanceof Text?n.startContainer.wholeText.substring(0,n.startOffset):null}getAfterCursor(){const n=this.getRange();return n.collapsed&&n.startContainer instanceof Text?n.startContainer.wholeText.substring(n.startOffset):null}getRange(n){var e;const t=(e=this.el.ownerDocument.defaultView)===null||e===void 0?void 0:e.getSelection();if(t==null)throw new Error("The element does not belong to view");for(let l=0,h=t.rangeCount;l{"use strict";c.r(r),c.d(r,{update:()=>f,wrapCursor:()=>d});function f(a,s,n){const e=a.value,t=s+(n||""),i=document.activeElement;let o=0,l=0;for(;o=0&&t.length-l-1>=0&&e[e.length-l-1]===t[t.length-l-1];)l++;o=Math.min(o,Math.min(e.length,t.length)-l),a.setSelectionRange(o,e.length-l);const h=t.substring(o,t.length-l);if(a.focus(),!document.execCommand("insertText",!1,h)){a.value=t;const v=document.createEvent("Event");v.initEvent("input",!0,!0),a.dispatchEvent(v)}return a.setSelectionRange(s.length,s.length),i.focus(),a}function d(a,s,n){const e=a.selectionEnd,t=a.value.substr(0,a.selectionStart)+s,i=a.value.substring(a.selectionStart,e)+(n||"")+a.value.substr(e);return f(a,t,i),a.selectionEnd=e+s.length,a}},21251:(p,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.calculateElementOffset=void 0;const c=f=>{const d=f.getBoundingClientRect(),a=f.ownerDocument;if(a==null)throw new Error("Given element does not belong to document");const{defaultView:s,documentElement:n}=a;if(s==null)throw new Error("Given element does not belong to window");const e={top:d.top+s.pageYOffset,left:d.left+s.pageXOffset};return n&&(e.top-=n.clientTop,e.left-=n.clientLeft),e};r.calculateElementOffset=c},22615:(p,r,c)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Completer=void 0;const f=c(30228),d=c(59099);class a extends f.EventEmitter{constructor(n){super(),this.handleQueryResult=e=>{this.emit("hit",{searchResults:e})},this.strategies=n.map(e=>new d.Strategy(e))}destroy(){return this.strategies.forEach(n=>n.destroy()),this}run(n){for(const e of this.strategies)if(e.execute(n,this.handleQueryResult))return;this.handleQueryResult([])}}r.Completer=a},29326:function(p,r,c){"use strict";var f=this&&this.__createBinding||(Object.create?function(a,s,n,e){e===void 0&&(e=n);var t=Object.getOwnPropertyDescriptor(s,n);(!t||("get"in t?!s.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return s[n]}}),Object.defineProperty(a,e,t)}:function(a,s,n,e){e===void 0&&(e=n),a[e]=s[n]}),d=this&&this.__exportStar||function(a,s){for(var n in a)n!=="default"&&!Object.prototype.hasOwnProperty.call(s,n)&&f(s,a,n)};Object.defineProperty(r,"__esModule",{value:!0}),d(c(21251),r),d(c(68675),r),d(c(81960),r)},30228:p=>{"use strict";var r=Object.prototype.hasOwnProperty,c="~";function f(){}Object.create&&(f.prototype=Object.create(null),new f().__proto__||(c=!1));function d(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function a(e,t,i,o,l){if(typeof i!="function")throw new TypeError("The listener must be a function");var h=new d(i,o||e,l),v=c?c+t:t;return e._events[v]?e._events[v].fn?e._events[v]=[e._events[v],h]:e._events[v].push(h):(e._events[v]=h,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new f:delete e._events[t]}function n(){this._events=new f,this._eventsCount=0}n.prototype.eventNames=function(){var t=[],i,o;if(this._eventsCount===0)return t;for(o in i=this._events)r.call(i,o)&&t.push(c?o.slice(1):o);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(i)):t},n.prototype.listeners=function(t){var i=c?c+t:t,o=this._events[i];if(!o)return[];if(o.fn)return[o.fn];for(var l=0,h=o.length,v=new Array(h);l{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.createCustomEvent=void 0;const c=typeof window<"u"&&!!window.CustomEvent,f=(d,a)=>{if(c)return new CustomEvent(d,a);const s=document.createEvent("CustomEvent");return s.initCustomEvent(d,!1,a?.cancelable||!1,a?.detail||void 0),s};r.createCustomEvent=f},35786:function(p,r,c){"use strict";var f=this&&this.__createBinding||(Object.create?function(a,s,n,e){e===void 0&&(e=n);var t=Object.getOwnPropertyDescriptor(s,n);(!t||("get"in t?!s.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return s[n]}}),Object.defineProperty(a,e,t)}:function(a,s,n,e){e===void 0&&(e=n),a[e]=s[n]}),d=this&&this.__exportStar||function(a,s){for(var n in a)n!=="default"&&!Object.prototype.hasOwnProperty.call(s,n)&&f(s,a,n)};Object.defineProperty(r,"__esModule",{value:!0}),d(c(9794),r)},36e3:function(p,r,c){"use strict";var f=this&&this.__createBinding||(Object.create?function(a,s,n,e){e===void 0&&(e=n);var t=Object.getOwnPropertyDescriptor(s,n);(!t||("get"in t?!s.__esModule:t.writable||t.configurable))&&(t={enumerable:!0,get:function(){return s[n]}}),Object.defineProperty(a,e,t)}:function(a,s,n,e){e===void 0&&(e=n),a[e]=s[n]}),d=this&&this.__exportStar||function(a,s){for(var n in a)n!=="default"&&!Object.prototype.hasOwnProperty.call(s,n)&&f(s,a,n)};Object.defineProperty(r,"__esModule",{value:!0}),d(c(22615),r),d(c(44871),r),d(c(83271),r),d(c(83103),r),d(c(59099),r),d(c(88638),r),d(c(32665),r)},44871:(p,r,c)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Dropdown=r.DEFAULT_DROPDOWN_ITEM_ACTIVE_CLASS_NAME=r.DEFAULT_DROPDOWN_ITEM_CLASS_NAME=r.DEFAULT_DROPDOWN_CLASS_NAME=r.DEFAULT_DROPDOWN_PLACEMENT=r.DEFAULT_DROPDOWN_MAX_COUNT=void 0;const f=c(30228),d=c(32665);r.DEFAULT_DROPDOWN_MAX_COUNT=10,r.DEFAULT_DROPDOWN_PLACEMENT="auto",r.DEFAULT_DROPDOWN_CLASS_NAME="dropdown-menu textcomplete-dropdown",r.DEFAULT_DROPDOWN_ITEM_CLASS_NAME="textcomplete-item",r.DEFAULT_DROPDOWN_ITEM_ACTIVE_CLASS_NAME=`${r.DEFAULT_DROPDOWN_ITEM_CLASS_NAME} active`;class a extends f.EventEmitter{static create(e){const t=document.createElement("ul");t.className=e.className||r.DEFAULT_DROPDOWN_CLASS_NAME,Object.assign(t.style,{display:"none",position:"absolute",zIndex:"1000"},e.style);const i=e.parent||document.body;return i?.appendChild(t),new a(t,e)}constructor(e,t){super(),this.el=e,this.option=t,this.shown=!1,this.items=[],this.activeIndex=null}render(e,t){const i=(0,d.createCustomEvent)("render",{cancelable:!0});return this.emit("render",i),i.defaultPrevented?this:(this.clear(),e.length===0?this.hide():(this.items=e.slice(0,this.option.maxCount||r.DEFAULT_DROPDOWN_MAX_COUNT).map((o,l)=>{var h;return new s(this,l,o,((h=this.option)===null||h===void 0?void 0:h.item)||{})}),this.setStrategyId(e[0]).renderEdge(e,"header").renderItems().renderEdge(e,"footer").show().setOffset(t).activate(0),this.emit("rendered",(0,d.createCustomEvent)("rendered")),this))}destroy(){var e;return this.clear(),(e=this.el.parentNode)===null||e===void 0||e.removeChild(this.el),this}select(e){const t={searchResult:e.searchResult},i=(0,d.createCustomEvent)("select",{cancelable:!0,detail:t});return this.emit("select",i),i.defaultPrevented?this:(this.hide(),this.emit("selected",(0,d.createCustomEvent)("selected",{detail:t})),this)}show(){if(!this.shown){const e=(0,d.createCustomEvent)("show",{cancelable:!0});if(this.emit("show",e),e.defaultPrevented)return this;this.el.style.display="block",this.shown=!0,this.emit("shown",(0,d.createCustomEvent)("shown"))}return this}hide(){if(this.shown){const e=(0,d.createCustomEvent)("hide",{cancelable:!0});if(this.emit("hide",e),e.defaultPrevented)return this;this.el.style.display="none",this.shown=!1,this.clear(),this.emit("hidden",(0,d.createCustomEvent)("hidden"))}return this}clear(){return this.items.forEach(e=>e.destroy()),this.items=[],this.el.innerHTML="",this.activeIndex=null,this}up(e){return this.shown?this.moveActiveItem("prev",e):this}down(e){return this.shown?this.moveActiveItem("next",e):this}moveActiveItem(e,t){if(this.activeIndex!=null){const i=e==="next"?this.getNextActiveIndex():this.getPrevActiveIndex();i!=null&&(this.activate(i),t.preventDefault())}return this}activate(e){return this.activeIndex!==e&&(this.activeIndex!=null&&this.items[this.activeIndex].deactivate(),this.activeIndex=e,this.items[e].activate()),this}isShown(){return this.shown}getActiveItem(){return this.activeIndex!=null?this.items[this.activeIndex]:null}setOffset(e){const t=document.documentElement;if(t){const i=this.el.offsetWidth;if(e.left){const h=this.option.dynamicWidth?t.scrollWidth:t.clientWidth;e.left+i>h&&(e.left=h-i),this.el.style.left=`${e.left}px`}else e.right&&(e.right-i<0&&(e.right=0),this.el.style.right=`${e.right}px`);let o=!1;const l=this.option.placement||r.DEFAULT_DROPDOWN_PLACEMENT;if(l==="auto"){const h=this.items.length*e.lineHeight;o=e.clientTop!=null&&e.clientTop+h>t.clientHeight}l==="top"||o?(this.el.style.bottom=`${t.clientHeight-e.top+e.lineHeight}px`,this.el.style.top="auto"):(this.el.style.top=`${e.top}px`,this.el.style.bottom="auto")}return this}getNextActiveIndex(){if(this.activeIndex==null)throw new Error;return this.activeIndexl.data)):i||"",this.el.appendChild(o),this}}r.Dropdown=a;class s{constructor(e,t,i,o){this.dropdown=e,this.index=t,this.searchResult=i,this.props=o,this.active=!1,this.onClick=v=>{v.preventDefault(),this.dropdown.select(this)},this.className=this.props.className||r.DEFAULT_DROPDOWN_ITEM_CLASS_NAME,this.activeClassName=this.props.activeClassName||r.DEFAULT_DROPDOWN_ITEM_ACTIVE_CLASS_NAME;const l=document.createElement("li");l.className=this.active?this.activeClassName:this.className;const h=document.createElement("span");h.tabIndex=-1,h.innerHTML=this.searchResult.render(),l.appendChild(h),l.addEventListener("click",this.onClick),this.el=l}destroy(){var e;const t=this.el;return(e=t.parentNode)===null||e===void 0||e.removeChild(t),t.removeEventListener("click",this.onClick,!1),this}activate(){return this.active||(this.active=!0,this.el.className=this.activeClassName,this.dropdown.el.scrollTop=this.el.offsetTop),this}deactivate(){return this.active&&(this.active=!1,this.el.className=this.className),this}}},48456:function(p,r,c){"use strict";var f=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(r,"__esModule",{value:!0}),r.TextareaEditor=void 0;const d=c(12531),a=f(c(7037)),s=c(36e3),n=c(29326);class e extends s.Editor{constructor(i){super(),this.el=i,this.onInput=()=>{this.emitChangeEvent()},this.onKeydown=o=>{const l=this.getCode(o);let h;l==="UP"||l==="DOWN"?h=this.emitMoveEvent(l):l==="ENTER"?h=this.emitEnterEvent():l==="ESC"&&(h=this.emitEscEvent()),h&&h.defaultPrevented&&o.preventDefault()},this.startListening()}destroy(){return super.destroy(),this.stopListening(),this}applySearchResult(i){const o=this.getBeforeCursor();if(o!=null){const l=i.replace(o,this.getAfterCursor());this.el.focus(),Array.isArray(l)&&((0,d.update)(this.el,l[0],l[1]),this.el&&this.el.dispatchEvent((0,s.createCustomEvent)("input")))}}getCursorOffset(){const i=(0,n.calculateElementOffset)(this.el),o=this.getElScroll(),l=this.getCursorPosition(),h=(0,n.getLineHeightPx)(this.el),v=i.top-o.top+l.top+h,g=i.left-o.left+l.left,u=this.el.getBoundingClientRect().top;if(this.el.dir!=="rtl")return{top:v,left:g,lineHeight:h,clientTop:u};{const E=document.documentElement?document.documentElement.clientWidth-g:0;return{top:v,right:E,lineHeight:h,clientTop:u}}}getBeforeCursor(){return this.el.selectionStart!==this.el.selectionEnd?null:this.el.value.substring(0,this.el.selectionEnd)}getAfterCursor(){return this.el.value.substring(this.el.selectionEnd)}getElScroll(){return{top:this.el.scrollTop,left:this.el.scrollLeft}}getCursorPosition(){return(0,a.default)(this.el,this.el.selectionEnd)}startListening(){this.el.addEventListener("input",this.onInput),this.el.addEventListener("keydown",this.onKeydown)}stopListening(){this.el.removeEventListener("input",this.onInput),this.el.removeEventListener("keydown",this.onKeydown)}}r.TextareaEditor=e},59099:(p,r,c)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Strategy=r.DEFAULT_INDEX=void 0;const f=c(83103);r.DEFAULT_INDEX=1;class d{constructor(s){this.props=s,this.cache={}}destroy(){return this.cache={},this}replace(s){return this.props.replace(s)}execute(s,n){var e;const t=this.matchWithContext(s);if(!t)return!1;const i=t[(e=this.props.index)!==null&&e!==void 0?e:r.DEFAULT_INDEX];return this.search(i,o=>{n(o.map(l=>new f.SearchResult(l,i,this)))},t),!0}renderTemplate(s,n){if(this.props.template)return this.props.template(s,n);if(typeof s=="string")return s;throw new Error(`Unexpected render data type: ${typeof s}. Please implement template parameter by yourself`)}getId(){return this.props.id||null}match(s){return typeof this.props.match=="function"?this.props.match(s):s.match(this.props.match)}search(s,n,e){this.props.cache?this.searchWithCach(s,n,e):this.props.search(s,n,e)}matchWithContext(s){const n=this.context(s);return n===!1?null:this.match(n===!0?s:n)}context(s){return this.props.context?this.props.context(s):!0}searchWithCach(s,n,e){this.cache[s]!=null?n(this.cache[s]):this.props.search(s,t=>{this.cache[s]=t,n(t)},e)}}r.Strategy=d},68675:(p,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getLineHeightPx=void 0;const c=48,f=57,d=n=>c<=n&&n<=f,a=n=>{const e=getComputedStyle(n),t=e.lineHeight;if(d(t.charCodeAt(0))){const i=parseFloat(t);return d(t.charCodeAt(t.length-1))?i*parseFloat(e.fontSize):i}return s(n.nodeName,e)};r.getLineHeightPx=a;const s=(n,e)=>{const t=document.body;if(!t)return 0;const i=document.createElement(n);i.innerHTML=" ",Object.assign(i.style,{fontSize:e.fontSize,fontFamily:e.fontFamily,padding:"0"}),t.appendChild(i),i instanceof HTMLTextAreaElement&&(i.rows=1);const o=i.offsetHeight;return t.removeChild(i),o}},81960:(p,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isSafari=void 0;const c=()=>/^((?!chrome|android).)*safari/i.test(navigator.userAgent);r.isSafari=c},83103:(p,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.SearchResult=void 0;const c=/\$&/g,f=/\$(\d)/g;class d{constructor(s,n,e){this.data=s,this.term=n,this.strategy=e}getReplacementData(s){let n=this.strategy.replace(this.data);if(n==null)return null;let e="";Array.isArray(n)&&(e=n[1],n=n[0]);const t=this.strategy.match(s);if(t==null||t.index==null)return null;const i=n.replace(c,t[0]).replace(f,(o,l)=>t[parseInt(l)]);return{start:t.index,end:t.index+t[0].length,beforeCursor:i,afterCursor:e}}replace(s,n){const e=this.getReplacementData(s);if(e!==null)return n=e.afterCursor+n,[[s.slice(0,e.start),e.beforeCursor,s.slice(e.end)].join(""),n]}render(){return this.strategy.renderTemplate(this.data,this.term)}getStrategyId(){return this.strategy.getId()}}r.SearchResult=d},83271:(p,r,c)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Editor=void 0;const f=c(30228),d=c(32665);class a extends f.EventEmitter{destroy(){return this}applySearchResult(n){throw new Error("Not implemented.")}getCursorOffset(){throw new Error("Not implemented.")}getBeforeCursor(){throw new Error("Not implemented.")}emitMoveEvent(n){const e=(0,d.createCustomEvent)("move",{cancelable:!0,detail:{code:n}});return this.emit("move",e),e}emitEnterEvent(){const n=(0,d.createCustomEvent)("enter",{cancelable:!0});return this.emit("enter",n),n}emitChangeEvent(){const n=(0,d.createCustomEvent)("change",{detail:{beforeCursor:this.getBeforeCursor()}});return this.emit("change",n),n}emitEscEvent(){const n=(0,d.createCustomEvent)("esc",{cancelable:!0});return this.emit("esc",n),n}getCode(n){switch(n.keyCode){case 9:case 13:return"ENTER";case 27:return"ESC";case 38:return"UP";case 40:return"DOWN";case 78:if(n.ctrlKey)return"DOWN";break;case 80:if(n.ctrlKey)return"UP";break}return"OTHER"}}r.Editor=a},88638:(p,r,c)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Textcomplete=void 0;const f=c(30228),d=c(44871),a=c(22615),s=["show","shown","render","rendered","selected","hidden","hide"];class n extends f.EventEmitter{constructor(t,i,o){super(),this.editor=t,this.isQueryInFlight=!1,this.nextPendingQuery=null,this.handleHit=({searchResults:l})=>{l.length?this.dropdown.render(l,this.editor.getCursorOffset()):this.dropdown.hide(),this.isQueryInFlight=!1,this.nextPendingQuery!==null&&this.trigger(this.nextPendingQuery)},this.handleMove=l=>{l.detail.code==="UP"?this.dropdown.up(l):this.dropdown.down(l)},this.handleEnter=l=>{const h=this.dropdown.getActiveItem();h?(this.dropdown.select(h),l.preventDefault()):this.dropdown.hide()},this.handleEsc=l=>{this.dropdown.isShown()&&(this.dropdown.hide(),l.preventDefault())},this.handleChange=l=>{l.detail.beforeCursor!=null?this.trigger(l.detail.beforeCursor):this.dropdown.hide()},this.handleSelect=l=>{this.emit("select",l),l.defaultPrevented||this.editor.applySearchResult(l.detail.searchResult)},this.handleResize=()=>{this.dropdown.isShown()&&this.dropdown.setOffset(this.editor.getCursorOffset())},this.completer=new a.Completer(i),this.dropdown=d.Dropdown.create(o?.dropdown||{}),this.startListening()}destroy(t=!0){return this.completer.destroy(),this.dropdown.destroy(),t&&this.editor.destroy(),this.stopListening(),this}isShown(){return this.dropdown.isShown()}hide(){return this.dropdown.hide(),this}trigger(t){return this.isQueryInFlight?this.nextPendingQuery=t:(this.isQueryInFlight=!0,this.nextPendingQuery=null,this.completer.run(t)),this}startListening(){var t;this.editor.on("move",this.handleMove).on("enter",this.handleEnter).on("esc",this.handleEsc).on("change",this.handleChange),this.dropdown.on("select",this.handleSelect);for(const i of s)this.dropdown.on(i,o=>this.emit(i,o));this.completer.on("hit",this.handleHit),(t=this.dropdown.el.ownerDocument.defaultView)===null||t===void 0||t.addEventListener("resize",this.handleResize)}stopListening(){var t;(t=this.dropdown.el.ownerDocument.defaultView)===null||t===void 0||t.removeEventListener("resize",this.handleResize),this.completer.removeAllListeners(),this.dropdown.removeAllListeners(),this.editor.removeListener("move",this.handleMove).removeListener("enter",this.handleEnter).removeListener("esc",this.handleEsc).removeListener("change",this.handleChange)}}r.Textcomplete=n}}]);