!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";function i(t,i){this.cm=t,this.options=i,this.widget=null,this.debounce=0,this.tick=0,this.startPos=this.cm.getCursor("start"),this.startLen=this.cm.getLine(this.startPos.line).length-this.cm.getSelection().length;var e=this;t.on("cursorActivity",this.activityFunc=function(){e.cursorActivity()})}function e(t){return"string"==typeof t?t:t.text}function n(t,i){for(;i&&i!=t;){if("LI"===i.nodeName.toUpperCase()&&i.parentNode==t)return i;i=i.parentNode}}function o(i,o){this.completion=i,this.data=o,this.picked=!1;var s=this,l=i.cm,h=l.getInputField().ownerDocument,a=h.defaultView||h.parentWindow,f=this.hints=h.createElement("ul"),u=i.cm.options.theme;f.className="CodeMirror-hints "+u,this.selectedHint=o.selectedHint||0;for(var p=o.list,d=0;d
f.clientHeight+1,P=l.getScrollInfo();if(E>0){var W=F.bottom-F.top;if(w.top-(w.bottom-F.top)-W>0)f.style.top=(C=w.top-W-A)+"px",b=!1;else if(W>N){f.style.height=N-5+"px",f.style.top=(C=w.bottom-F.top-A)+"px";var I=l.getCursor();o.from.ch!=I.ch&&(w=l.cursorCoords(I),f.style.left=(H=w.left-k)+"px",F=f.getBoundingClientRect())}}var B=F.right-M;if(B>0&&(F.right-F.left>M&&(f.style.width=M-5+"px",B-=F.right-F.left-M),f.style.left=(H=w.left-B-k)+"px"),O)for(var K=f.firstChild;K;K=K.nextSibling)K.style.paddingRight=l.display.nativeBarWidth+"px";if(l.addKeyMap(this.keyMap=function(t,i){function e(t,e){var o;o="string"!=typeof e?function(t){return e(t,i)}:n.hasOwnProperty(e)?n[e]:e,s[t]=o}var n={Up:function(){i.moveFocus(-1)},Down:function(){i.moveFocus(1)},PageUp:function(){i.moveFocus(1-i.menuSize(),!0)},PageDown:function(){i.moveFocus(i.menuSize()-1,!0)},Home:function(){i.setFocus(0)},End:function(){i.setFocus(i.length-1)},Enter:i.pick,Tab:i.pick,Esc:i.close};/Mac/.test(navigator.platform)&&(n["Ctrl-P"]=function(){i.moveFocus(-1)},n["Ctrl-N"]=function(){i.moveFocus(1)});var o=t.options.customKeys,s=o?{}:n;if(o)for(var c in o)o.hasOwnProperty(c)&&e(c,o[c]);var r=t.options.extraKeys;if(r)for(var c in r)r.hasOwnProperty(c)&&e(c,r[c]);return s}(i,{moveFocus:function(t,i){s.changeActive(s.selectedHint+t,i)},setFocus:function(t){s.changeActive(t)},menuSize:function(){return s.screenAmount()},length:p.length,close:function(){i.close()},pick:function(){s.pick()},data:o})),i.options.closeOnUnfocus){var L;l.on("blur",this.onBlur=function(){L=setTimeout(function(){i.close()},100)}),l.on("focus",this.onFocus=function(){clearTimeout(L)})}return l.on("scroll",this.onScroll=function(){var t=l.getScrollInfo(),e=l.getWrapperElement().getBoundingClientRect(),n=C+P.top-t.top,o=n-(a.pageYOffset||(h.documentElement||h.body).scrollTop);if(b||(o+=f.offsetHeight),o<=e.top||o>=e.bottom)return i.close();f.style.top=n+"px",f.style.left=H+P.left-t.left+"px"}),t.on(f,"dblclick",function(t){var i=n(f,t.target||t.srcElement);i&&null!=i.hintId&&(s.changeActive(i.hintId),s.pick())}),t.on(f,"click",function(t){var e=n(f,t.target||t.srcElement);e&&null!=e.hintId&&(s.changeActive(e.hintId),i.options.completeOnSingleClick&&s.pick())}),t.on(f,"mousedown",function(){setTimeout(function(){l.focus()},20)}),this.scrollToActive(),t.signal(o,"select",p[this.selectedHint],f.childNodes[this.selectedHint]),!0}function s(t,i,e,n){if(t.async)t(i,n,e);else{var o=t(i,e);o&&o.then?o.then(n):n(o)}}var c="CodeMirror-hint",r="CodeMirror-hint-active";t.showHint=function(t,i,e){if(!i)return t.showHint(e);e&&e.async&&(i.async=!0);var n={hint:i};if(e)for(var o in e)n[o]=e[o];return t.showHint(n)},t.defineExtension("showHint",function(e){e=function(t,i,e){var n=t.options.hintOptions,o={};for(var s in a)o[s]=a[s];if(n)for(var s in n)void 0!==n[s]&&(o[s]=n[s]);if(e)for(var s in e)void 0!==e[s]&&(o[s]=e[s]);return o.hint.resolve&&(o.hint=o.hint.resolve(t,i)),o}(this,this.getCursor("start"),e);var n=this.listSelections();if(!(n.length>1)){if(this.somethingSelected()){if(!e.hint.supportsSelection)return;for(var o=0;o=this.data.list.length?i=e?this.data.list.length-1:0:i<0&&(i=e?0:this.data.list.length-1),this.selectedHint!=i){var n=this.hints.childNodes[this.selectedHint];n&&(n.className=n.className.replace(" "+r,"")),(n=this.hints.childNodes[this.selectedHint=i]).className+=" "+r,this.scrollToActive(),t.signal(this.data,"select",this.data.list[this.selectedHint],n)}},scrollToActive:function(){var t=this.completion.options.scrollMargin||0,i=this.hints.childNodes[Math.max(0,this.selectedHint-t)],e=this.hints.childNodes[Math.min(this.data.list.length-1,this.selectedHint+t)],n=this.hints.firstChild;i.offsetTopthis.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=e.offsetTop+e.offsetHeight-this.hints.clientHeight+n.offsetTop)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},t.registerHelper("hint","auto",{resolve:function(i,e){var n,o=i.getHelpers(e,"hint");if(o.length){var c=function(t,i,e){function n(o){if(o==c.length)return i(null);s(c[o],t,e,function(t){t&&t.list.length>0?i(t):n(o+1)})}var c=function(t,i){if(!t.somethingSelected())return i;for(var e=[],n=0;n,]/,closeOnUnfocus:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null};t.defineOption("hintOptions",null)});