1 line
59 KiB
JavaScript
1 line
59 KiB
JavaScript
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(F){"use strict";var q="CodeMirror-hint-active";function i(e,t){this.cm=e,this.options=t,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 n=this;e.on("cursorActivity",this.activityFunc=function(){n.cursorActivity()})}F.showHint=function(e,t,n){if(!t)return e.showHint(n);n&&n.async&&(t.async=!0);var o={hint:t};if(n)for(var i in n)o[i]=n[i];return e.showHint(o)},F.defineExtension("showHint",function(e){e=function(e,t,n){var o=e.options.hintOptions,i={};for(var r in l)i[r]=l[r];if(o)for(var r in o)void 0!==o[r]&&(i[r]=o[r]);if(n)for(var r in n)void 0!==n[r]&&(i[r]=n[r]);i.hint.resolve&&(i.hint=i.hint.resolve(e,t));return i}(this,this.getCursor("start"),e);var t=this.listSelections();if(!(1<t.length)){if(this.somethingSelected()){if(!e.hint.supportsSelection)return;for(var n=0;n<t.length;n++)if(t[n].head.line!=t[n].anchor.line)return}this.state.completionActive&&this.state.completionActive.close();var o=this.state.completionActive=new i(this,e);o.options.hint&&(F.signal(this,"startCompletion",this),o.update(!0))}}),F.defineExtension("closeHint",function(){this.state.completionActive&&this.state.completionActive.close()});var o=window.requestAnimationFrame||function(e){return setTimeout(e,1e3/60)},r=window.cancelAnimationFrame||clearTimeout;function R(e){return"string"==typeof e?e:e.text}function D(e,t){for(;t&&t!=e;){if("LI"===t.nodeName.toUpperCase()&&t.parentNode==e)return t;t=t.parentNode}}function s(i,e){this.completion=i,this.data=e,this.picked=!1;var n=this,r=i.cm,s=r.getInputField().ownerDocument,a=s.defaultView||s.parentWindow,l=this.hints=s.createElement("ul"),t=i.cm.options.theme;l.className="CodeMirror-hints "+t,this.selectedHint=e.selectedHint||0;for(var o=e.list,c=0;c<o.length;++c){var f=l.appendChild(s.createElement("li")),u=o[c],h="CodeMirror-hint"+(c!=this.selectedHint?"":" "+q);null!=u.className&&(h=u.className+" "+h),f.className=h,u.render?u.render(f,e,u):f.appendChild(s.createTextNode(u.displayText||R(u))),f.hintId=c}var d,p,g,m=i.options.container||s.body,v=r.cursorCoords(i.options.alignWithWord?e.from:null),y=v.left,C=v.bottom,b=!0,x=0,k=0;m!==s.body&&(p=(d=-1!==["absolute","relative","fixed"].indexOf(a.getComputedStyle(m).position)?m:m.offsetParent).getBoundingClientRect(),g=s.body.getBoundingClientRect(),x=p.left-g.left-d.scrollLeft,k=p.top-g.top-d.scrollTop),l.style.left=y-x+"px",l.style.top=C-k+"px";var w=a.innerWidth||Math.max(s.body.offsetWidth,s.documentElement.offsetWidth),T=a.innerHeight||Math.max(s.body.offsetHeight,s.documentElement.offsetHeight);m.appendChild(l);var L,M,O=l.getBoundingClientRect(),A=O.bottom-T,S=l.scrollHeight>l.clientHeight+1,H=r.getScrollInfo();0<A&&(L=O.bottom-O.top,0<v.top-(v.bottom-O.top)-L?(l.style.top=(C=v.top-L-k)+"px",b=!1):T<L&&(l.style.height=T-5+"px",l.style.top=(C=v.bottom-O.top-k)+"px",M=r.getCursor(),e.from.ch!=M.ch&&(v=r.cursorCoords(M),l.style.left=(y=v.left-x)+"px",O=l.getBoundingClientRect())));var N,E=O.right-w;if(0<E&&(O.right-O.left>w&&(l.style.width=w-5+"px",E-=O.right-O.left-w),l.style.left=(y=v.left-E-x)+"px"),S)for(var P=l.firstChild;P;P=P.nextSibling)P.style.paddingRight=r.display.nativeBarWidth+"px";return r.addKeyMap(this.keyMap=function(e,o){var i={Up:function(){o.moveFocus(-1)},Down:function(){o.moveFocus(1)},PageUp:function(){o.moveFocus(1-o.menuSize(),!0)},PageDown:function(){o.moveFocus(o.menuSize()-1,!0)},Home:function(){o.setFocus(0)},End:function(){o.setFocus(o.length-1)},Enter:o.pick,Tab:o.pick,Esc:o.close};/Mac/.test(navigator.platform)&&(i["Ctrl-P"]=function(){o.moveFocus(-1)},i["Ctrl-N"]=function(){o.moveFocus(1)});var t=e.options.customKeys,r=t?{}:i;function n(e,t){var n="string"!=typeof t?function(e){return t(e,o)}:i.hasOwnProperty(t)?i[t]:t;r[e]=n}if(t)for(var s in t)t.hasOwnProperty(s)&&n(s,t[s]);var a=e.options.extraKeys;if(a)for(var s in a)a.hasOwnProperty(s)&&n(s,a[s]);return r}(i,{moveFocus:function(e,t){n.changeActive(n.selectedHint+e,t)},setFocus:function(e){n.changeActive(e)},menuSize:function(){return n.screenAmount()},length:o.length,close:function(){i.close()},pick:function(){n.pick()},data:e})),i.options.closeOnUnfocus&&(r.on("blur",this.onBlur=function(){N=setTimeout(function(){i.close()},100)}),r.on("focus",this.onFocus=function(){clearTimeout(N)})),r.on("scroll",this.onScroll=function(){var e=r.getScrollInfo(),t=r.getWrapperElement().getBoundingClientRect(),n=C+H.top-e.top,o=n-(a.pageYOffset||(s.documentElement||s.body).scrollTop);if(b||(o+=l.offsetHeight),o<=t.top||o>=t.bottom)return i.close();l.style.top=n+"px",l.style.left=y+H.left-e.left+"px"}),F.on(l,"dblclick",function(e){var t=D(l,e.target||e.srcElement);t&&null!=t.hintId&&(n.changeActive(t.hintId),n.pick())}),F.on(l,"click",function(e){var t=D(l,e.target||e.srcElement);t&&null!=t.hintId&&(n.changeActive(t.hintId),i.options.completeOnSingleClick&&n.pick())}),F.on(l,"mousedown",function(){setTimeout(function(){r.focus()},20)}),F.signal(e,"select",o[this.selectedHint],l.childNodes[this.selectedHint]),!0}function a(e,t,n,o){var i;e.async?e(t,o,n):(i=e(t,n))&&i.then?i.then(o):o(i)}i.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.tick=null,this.cm.off("cursorActivity",this.activityFunc),this.widget&&this.data&&F.signal(this.data,"close"),this.widget&&this.widget.close(),F.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(e,t){var n=e.list[t];n.hint?n.hint(this.cm,e,n):this.cm.replaceRange(R(n),n.from||e.from,n.to||e.to,"complete"),F.signal(e,"pick",n),this.close()},cursorActivity:function(){this.debounce&&(r(this.debounce),this.debounce=0);var e,t=this.cm.getCursor(),n=this.cm.getLine(t.line);t.line!=this.startPos.line||n.length-t.ch!=this.startLen-this.startPos.ch||t.ch<this.startPos.ch||this.cm.somethingSelected()||!t.ch||this.options.closeCharacters.test(n.charAt(t.ch-1))?this.close():((e=this).debounce=o(function(){e.update()}),this.widget&&this.widget.disable())},update:function(t){var n,o;null!=this.tick&&(o=++(n=this).tick,a(this.options.hint,this.cm,this.options,function(e){n.tick==o&&n.finishUpdate(e,t)}))},finishUpdate:function(e,t){this.data&&F.signal(this.data,"update");var n=this.widget&&this.widget.picked;this.widget&&this.widget.close(),(this.data=e)&&e.list.length&&(n&&1==e.list.length?this.pick(e,0):(this.widget=new s(this,e),F.signal(e,"shown")))}},s.prototype={close:function(){var e;this.completion.widget==this&&(this.completion.widget=null,this.hints.parentNode.removeChild(this.hints),this.completion.cm.removeKeyMap(this.keyMap),e=this.completion.cm,this.completion.options.closeOnUnfocus&&(e.off("blur",this.onBlur),e.off("focus",this.onFocus)),e.off("scroll",this.onScroll))},disable:function(){this.completion.cm.removeKeyMap(this.keyMap);var e=this;this.keyMap={Enter:function(){e.picked=!0}},this.completion.cm.addKeyMap(this.keyMap)},pick:function(){this.completion.pick(this.data,this.selectedHint)},changeActive:function(e,t){var n;e>=this.data.list.length?e=t?this.data.list.length-1:0:e<0&&(e=t?0:this.data.list.length-1),this.selectedHint!=e&&((n=this.hints.childNodes[this.selectedHint])&&(n.className=n.className.replace(" "+q,"")),(n=this.hints.childNodes[this.selectedHint=e]).className+=" "+q,n.offsetTop<this.hints.scrollTop?this.hints.scrollTop=n.offsetTop-3:n.offsetTop+n.offsetHeight>this.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=n.offsetTop+n.offsetHeight-this.hints.clientHeight+3),F.signal(this.data,"select",this.data.list[this.selectedHint],n))},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},F.registerHelper("hint","auto",{resolve:function(e,t){var n,s=e.getHelpers(t,"hint");if(s.length){var o=function(e,o,i){var r=function(e,t){if(!e.somethingSelected())return t;for(var n=[],o=0;o<t.length;o++)t[o].supportsSelection&&n.push(t[o]);return n}(e,s);!function t(n){if(n==r.length)return o(null);a(r[n],e,i,function(e){e&&0<e.list.length?o(e):t(n+1)})}(0)};return o.async=!0,o.supportsSelection=!0,o}return(n=e.getHelper(e.getCursor(),"hintWords"))?function(e){return F.hint.fromList(e,{words:n})}:F.hint.anyword?function(e,t){return F.hint.anyword(e,t)}:function(){}}}),F.registerHelper("hint","fromList",function(e,t){var n,o=e.getCursor(),i=e.getTokenAt(o),r=F.Pos(o.line,i.start),s=o;i.start<o.ch&&/\w/.test(i.string.charAt(o.ch-i.start-1))?n=i.string.substr(0,o.ch-i.start):(n="",r=o);for(var a=[],l=0;l<t.words.length;l++){var c=t.words[l];c.slice(0,n.length)==n&&a.push(c)}if(a.length)return{list:a,from:r,to:s}}),F.commands.autocomplete=F.showHint;var l={hint:F.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null};F.defineOption("hintOptions",null)}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(u){function h(e,t,n){var o=e.getWrapperElement(),i=o.appendChild(document.createElement("div"));return i.className=n?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof t?i.innerHTML=t:i.appendChild(t),u.addClass(o,"dialog-opened"),i}function d(e,t){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=t}u.defineExtension("openDialog",function(e,t,n){n=n||{},d(this,null);var o=h(this,e,n.bottom),i=!1,r=this;function s(e){if("string"==typeof e)l.value=e;else{if(i)return;i=!0,u.rmClass(o.parentNode,"dialog-opened"),o.parentNode.removeChild(o),r.focus(),n.onClose&&n.onClose(o)}}var a,l=o.getElementsByTagName("input")[0];return l?(l.focus(),n.value&&(l.value=n.value,!1!==n.selectValueOnOpen&&l.select()),n.onInput&&u.on(l,"input",function(e){n.onInput(e,l.value,s)}),n.onKeyUp&&u.on(l,"keyup",function(e){n.onKeyUp(e,l.value,s)}),u.on(l,"keydown",function(e){n&&n.onKeyDown&&n.onKeyDown(e,l.value,s)||((27==e.keyCode||!1!==n.closeOnEnter&&13==e.keyCode)&&(l.blur(),u.e_stop(e),s()),13==e.keyCode&&t(l.value,e))}),!1!==n.closeOnBlur&&u.on(l,"blur",s)):(a=o.getElementsByTagName("button")[0])&&(u.on(a,"click",function(){s(),r.focus()}),!1!==n.closeOnBlur&&u.on(a,"blur",s),a.focus()),s}),u.defineExtension("openConfirm",function(e,t,n){d(this,null);var o=h(this,e,n&&n.bottom),i=o.getElementsByTagName("button"),r=!1,s=this,a=1;function l(){r||(r=!0,u.rmClass(o.parentNode,"dialog-opened"),o.parentNode.removeChild(o),s.focus())}i[0].focus();for(var c=0;c<i.length;++c){var f=i[c];!function(t){u.on(f,"click",function(e){u.e_preventDefault(e),l(),t&&t(s)})}(t[c]),u.on(f,"blur",function(){--a,setTimeout(function(){a<=0&&l()},200)}),u.on(f,"focus",function(){++a})}}),u.defineExtension("openNotification",function(e,t){d(this,s);var n,o=h(this,e,t&&t.bottom),i=!1,r=t&&void 0!==t.duration?t.duration:5e3;function s(){i||(i=!0,clearTimeout(n),u.rmClass(o.parentNode,"dialog-opened"),o.parentNode.removeChild(o))}return u.on(o,"click",function(e){u.e_preventDefault(e),s()}),r&&(n=setTimeout(s,r)),s})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(i){"use strict";var v,y,C=i.Pos;function p(e,t){for(var n,o,i=null!=(o=(n=e).flags)?o:(n.ignoreCase?"i":"")+(n.global?"g":"")+(n.multiline?"m":""),r=i,s=0;s<t.length;s++)-1==r.indexOf(t.charAt(s))&&(r+=t.charAt(s));return i==r?e:new RegExp(e.source,r)}function g(e,t,n){t=p(t,"g");for(var o=n.line,i=n.ch,r=e.lastLine();o<=r;o++,i=0){t.lastIndex=i;var s=e.getLine(o),a=t.exec(s);if(a)return{from:C(o,a.index),to:C(o,a.index+a[0].length),match:a}}}function m(e,t){for(var n,o=0;;){t.lastIndex=o;var i=t.exec(e);if(!i)return n;if((o=(n=i).index+(n[0].length||1))==e.length)return n}}function b(e,t,n,o){if(e.length==t.length)return n;for(var i=0,r=n+Math.max(0,e.length-t.length);;){if(i==r)return i;var s=i+r>>1,a=o(e.slice(0,s)).length;if(a==n)return s;n<a?r=s:i=1+s}}function o(n,o,e,t){var i;this.atOccurrence=!1,this.doc=n,e=e?n.clipPos(e):C(0,0),this.pos={from:e,to:e},"object"==typeof t?i=t.caseFold:(i=t,t=null),"string"==typeof o?(null==i&&(i=!1),this.matches=function(e,t){return(e?function(e,t,n,o){if(!t.length)return null;var i=o?v:y,r=i(t).split(/\r|\n\r?/);e:for(var s=n.line,a=n.ch,l=e.firstLine()-1+r.length;l<=s;s--,a=-1){var c=e.getLine(s);-1<a&&(c=c.slice(0,a));var f=i(c);if(1==r.length){var u=f.lastIndexOf(r[0]);if(-1==u)continue e;return{from:C(s,b(c,f,u,i)),to:C(s,b(c,f,u+r[0].length,i))}}var h=r[r.length-1];if(f.slice(0,h.length)==h){for(var d=1,n=s-r.length+1;d<r.length-1;d++)if(i(e.getLine(n+d))!=r[d])continue e;var p=e.getLine(s+1-r.length),g=i(p);if(g.slice(g.length-r[0].length)==r[0])return{from:C(s+1-r.length,b(p,g,p.length-r[0].length,i)),to:C(s,b(c,f,h.length,i))}}}}:function(e,t,n,o){if(!t.length)return null;var i=o?v:y,r=i(t).split(/\r|\n\r?/);e:for(var s=n.line,a=n.ch,l=e.lastLine()+1-r.length;s<=l;s++,a=0){var c=e.getLine(s).slice(a),f=i(c);if(1==r.length){var u=f.indexOf(r[0]);if(-1==u)continue e;n=b(c,f,u,i)+a;return{from:C(s,b(c,f,u,i)+a),to:C(s,b(c,f,u+r[0].length,i)+a)}}var h=f.length-r[0].length;if(f.slice(h)==r[0]){for(var d=1;d<r.length-1;d++)if(i(e.getLine(s+d))!=r[d])continue e;var p=e.getLine(s+r.length-1),g=i(p),m=r[r.length-1];if(g.slice(0,m.length)==m)return{from:C(s,b(c,f,h,i)+a),to:C(s+r.length-1,b(p,g,m.length,i))}}}})(n,o,t,i)}):(o=p(o,"gm"),t&&!1===t.multiline?this.matches=function(e,t){return(e?function(e,t,n){t=p(t,"g");for(var o=n.line,i=n.ch,r=e.firstLine();r<=o;o--,i=-1){var s=e.getLine(o);-1<i&&(s=s.slice(0,i));var a=m(s,t);if(a)return{from:C(o,a.index),to:C(o,a.index+a[0].length),match:a}}}:g)(n,o,t)}:this.matches=function(e,t){return(e?function(e,t,n){t=p(t,"gm");for(var o=1,i=n.line,r=e.firstLine();r<=i;){for(var s=0;s<o;s++)var a=e.getLine(i--),l=null==l?a.slice(0,n.ch):a+"\n"+l;o*=2;var c=m(l,t);if(c){var f=l.slice(0,c.index).split("\n"),u=c[0].split("\n"),h=i+f.length,d=f[f.length-1].length;return{from:C(h,d),to:C(h+u.length-1,1==u.length?d+u[0].length:u[u.length-1].length),match:c}}}}:function(e,t,n){if(!/\\s|\\n|\n|\\W|\\D|\[\^/.test(t.source))return g(e,t,n);t=p(t,"gm");for(var o=1,i=n.line,r=e.lastLine();i<=r;){for(var s=0;s<o&&!(r<i);s++)var a=e.getLine(i++),l=null==l?a:l+"\n"+a;o*=2,t.lastIndex=n.ch;var c=t.exec(l);if(c){var f=l.slice(0,c.index).split("\n"),u=c[0].split("\n"),h=n.line+f.length-1,d=f[f.length-1].length;return{from:C(h,d),to:C(h+u.length-1,1==u.length?d+u[0].length:u[u.length-1].length),match:c}}}})(n,o,t)})}y=String.prototype.normalize?(v=function(e){return e.normalize("NFD").toLowerCase()},function(e){return e.normalize("NFD")}):(v=function(e){return e.toLowerCase()},function(e){return e}),o.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(e){for(var t=this.matches(e,this.doc.clipPos(e?this.pos.from:this.pos.to));t&&0==i.cmpPos(t.from,t.to);)e?t.from.ch?t.from=C(t.from.line,t.from.ch-1):t=t.from.line==this.doc.firstLine()?null:this.matches(e,this.doc.clipPos(C(t.from.line-1))):t.to.ch<this.doc.getLine(t.to.line).length?t.to=C(t.to.line,t.to.ch+1):t=t.to.line==this.doc.lastLine()?null:this.matches(e,C(t.to.line+1,0));if(t)return this.pos=t,this.atOccurrence=!0,this.pos.match||!0;var n=C(e?this.doc.firstLine():this.doc.lastLine()+1,0);return this.pos={from:n,to:n},this.atOccurrence=!1},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(e,t){var n;this.atOccurrence&&(n=i.splitLines(e),this.doc.replaceRange(n,this.pos.from,this.pos.to,t),this.pos.to=C(this.pos.from.line+n.length-1,n[n.length-1].length+(1==n.length?this.pos.from.ch:0)))}},i.defineExtension("getSearchCursor",function(e,t,n){return new o(this.doc,e,t,n)}),i.defineDocExtension("getSearchCursor",function(e,t,n){return new o(this,e,t,n)}),i.defineExtension("selectMatches",function(e,t){for(var n=[],o=this.getSearchCursor(e,this.getCursor("from"),t);o.findNext()&&!(0<i.cmpPos(o.to(),this.getCursor("to")));)n.push({anchor:o.from(),head:o.to()});n.length&&this.setSelections(n,0)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],e):e(CodeMirror)}(function(d){"use strict";function t(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}function p(e){return e.state.search||(e.state.search=new t)}function g(e){return"string"==typeof e&&e==e.toLowerCase()}function h(e,t,n){return e.getSearchCursor(t,n,{caseFold:g(t),multiline:!0})}function m(e,t,n,o,i){e.openDialog?e.openDialog(t,i,{value:o,selectValueOnOpen:!0}):i(prompt(n,o))}function o(e){return e.replace(/\\(.)/g,function(e,t){return"n"==t?"\n":"r"==t?"\r":t})}function r(e){var t=e.match(/^\/(.*)\/([a-z]*)$/);if(t)try{e=new RegExp(t[1],-1==t[2].indexOf("i")?"":"i")}catch(e){}else e=o(e);return("string"==typeof e?""==e:e.test(""))&&(e=/x^/),e}function v(e,t,n){var o,i;t.queryText=n,t.query=r(n),e.removeOverlay(t.overlay,g(t.query)),t.overlay=(o=t.query,i=g(t.query),"string"==typeof o?o=new RegExp(o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i?"gi":"g"):o.global||(o=new RegExp(o.source,o.ignoreCase?"gi":"g")),{token:function(e){o.lastIndex=e.pos;var t=o.exec(e.string);if(t&&t.index==e.pos)return e.pos+=t[0].length||1,"searching";t?e.pos=t.index:e.skipToEnd()}}),e.addOverlay(t.overlay),e.showMatchesOnScrollbar&&(t.annotate&&(t.annotate.clear(),t.annotate=null),t.annotate=e.showMatchesOnScrollbar(t.query,g(t.query)))}function n(r,t,e,n){var s=p(r);if(s.query)return y(r,t);var a,l,o,i,c,f,u,h=r.getSelection()||s.lastQuery;h instanceof RegExp&&"x^"==h.source&&(h=null),e&&r.openDialog?(a=null,l=function(e,t){d.e_stop(t),e&&(e!=s.queryText&&(v(r,s,e),s.posFrom=s.posTo=r.getCursor()),a&&(a.style.opacity=1),y(r,t.shiftKey,function(e,t){var n,o,i=document.getElementById("CodeMirror-search-count");i&&(t?(n="string"==typeof(n=s.query)?new RegExp(n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g(n)?"gi":"g"):n instanceof RegExp?new RegExp(n.source,n.flags+"g"):null,i.innerText=n?(r.getRange({line:0,ch:0},t).match(n)||[]).length+"/"+(r.getValue().match(n)||[]).length:"0/0"):i.innerText="0/0"),t&&t.line<3&&document.querySelector&&(o=r.display.wrapper.querySelector(".CodeMirror-dialog"))&&o.getBoundingClientRect().bottom-4>r.cursorCoords(t,"window").top&&((a=o).style.opacity=.4)}))},i=b(o=r),c=h,f=l,u=function(e,t){var n=d.keyName(e),o=r.getOption("extraKeys"),i=o&&o[n]||d.keyMap[r.getOption("keyMap")][n];"findNext"==i||"findPrev"==i||"findPersistentNext"==i||"findPersistentPrev"==i?(d.e_stop(e),v(r,p(r),t),r.execCommand(i)):"find"!=i&&"findPersistent"!=i||(d.e_stop(e),l(t,e))},o.openDialog(i,f,{value:c,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){C(o)},onKeyDown:u}),n&&h&&(v(r,s,h),y(r,t))):m(r,b(),"搜索: ",h,function(e){e&&!s.query&&r.operation(function(){v(r,s,e),s.posFrom=s.posTo=r.getCursor(),y(r,t)})})}function y(n,o,i){n.operation(function(){var e=p(n),t=h(n,e.query,o?e.posFrom:e.posTo);if(!t.find(o)&&!(t=h(n,e.query,o?d.Pos(n.lastLine()):d.Pos(n.firstLine(),0))).find(o))return i&&i(null,null);n.setSelection(t.from(),t.to()),n.scrollIntoView({from:t.from(),to:t.to()},20),e.posFrom=t.from(),e.posTo=t.to(),i&&i(t.from(),t.to())})}function C(n){n.operation(function(){var e=document.getElementById("CodeMirror-search-count");e&&(e.innerText="");var t=p(n);t.lastQuery=t.query,t.query&&(t.query=t.queryText=null,n.removeOverlay(t.overlay),t.annotate&&(t.annotate.clear(),t.annotate=null))})}function b(){return'<span class="CodeMirror-search-label">搜索: </span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span class="CodeMirror-search-label" id="CodeMirror-search-count">0/0</span> <span class="CodeMirror-search-hint">使用/re/语法正则搜索</span>'}function x(t,o,i){t.operation(function(){for(var n,e=h(t,o);e.findNext();){"string"!=typeof o?(n=t.getRange(e.from(),e.to()).match(o),e.replace(i.replace(/\$(\d)/g,function(e,t){return n[t]}))):e.replace(i)}})}function i(u,e){var t,n;u.getOption("readOnly")||(t=u.getSelection()||p(u).lastQuery,m(u,(n='<span class="CodeMirror-search-label">'+(e?"全部替换":"替换")+"</span>")+' <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span class="CodeMirror-search-hint">使用/re/语法正则搜索</span>',n,t,function(f){f&&(f=r(f),m(u,'<span class="CodeMirror-search-label">替换为: </span> <input type="text" style="width: 10em" class="CodeMirror-search-field"/>',"替换为: ","",function(s){var a,l,c;s=o(s),e?x(u,f,s):(C(u),a=h(u,f,u.getCursor("from")),l=function(){var e,t,n,o,i,r=a.from();!(e=a.findNext())&&(a=h(u,f),!(e=a.findNext())||r&&a.from().line==r.line&&a.from().ch==r.ch)||(u.setSelection(a.from(),a.to()),u.scrollIntoView({from:a.from(),to:a.to()}),n='<span class="CodeMirror-search-label">确认替换?</span> <button>确定</button> <button>取消</button> <button>全部替换</button> <button>停止搜索</button> ',o="确定替换?",i=[function(){c(e)},l,function(){x(u,f,s)}],(t=u).openConfirm?t.openConfirm(n,i):confirm(o)&&i[0]())},c=function(n){a.replace("string"==typeof f?s:s.replace(/\$(\d)/g,function(e,t){return n[t]})),l()},l())}))}))}d.commands.find=function(e){C(e),n(e)},d.commands.findPersistent=function(e){C(e),n(e,!1,!0)},d.commands.findPersistentNext=function(e){n(e,!1,!0,!0)},d.commands.findPersistentPrev=function(e){n(e,!0,!0,!0)},d.commands.findNext=n,d.commands.findPrev=function(e){n(e,!0)},d.commands.clearSearch=C,d.commands.replace=i,d.commands.replaceAll=function(e){i(e,!0)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(o){var f=/MSIE \d/.test(navigator.userAgent)&&(null==document.documentMode||document.documentMode<8),m=o.Pos,v={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function y(e){return e&&e.bracketRegex||/[(){}[\]]/}function u(e,t,n){var o=e.getLineHandle(t.line),i=t.ch-1,r=n&&n.afterCursor;null==r&&(r=/(^| )cm-fat-cursor($| )/.test(e.getWrapperElement().className));var s=y(n),a=!r&&0<=i&&s.test(o.text.charAt(i))&&v[o.text.charAt(i)]||s.test(o.text.charAt(i+1))&&v[o.text.charAt(++i)];if(!a)return null;var l=">"==a.charAt(1)?1:-1;if(n&&n.strict&&0<l!=(i==t.ch))return null;var c=e.getTokenTypeAt(m(t.line,i+1)),f=h(e,m(t.line,i+(0<l?1:0)),l,c||null,n);return null==f?null:{from:m(t.line,i),to:f&&f.pos,match:f&&f.ch==a.charAt(0),forward:0<l}}function h(e,t,n,o,i){for(var r=i&&i.maxScanLineLength||1e4,s=i&&i.maxScanLines||1e3,a=[],l=y(i),c=0<n?Math.min(t.line+s,e.lastLine()+1):Math.max(e.firstLine()-1,t.line-s),f=t.line;f!=c;f+=n){var u=e.getLine(f);if(u){var h=0<n?0:u.length-1,d=0<n?u.length:-1;if(!(u.length>r))for(f==t.line&&(h=t.ch-(n<0?1:0));h!=d;h+=n){var p=u.charAt(h);if(l.test(p)&&(void 0===o||e.getTokenTypeAt(m(f,h+1))==o)){var g=v[p];if(g&&">"==g.charAt(1)==0<n)a.push(p);else{if(!a.length)return{pos:m(f,h),ch:p};a.pop()}}}}}return f-n!=(0<n?e.lastLine():e.firstLine())&&null}function t(e,t,n){for(var o=e.state.matchBrackets.maxHighlightLineLength||1e3,i=[],r=e.listSelections(),s=0;s<r.length;s++){var a,l=r[s].empty()&&u(e,r[s].head,n);l&&e.getLine(l.from.line).length<=o&&(a=l.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket",i.push(e.markText(l.from,m(l.from.line,l.from.ch+1),{className:a})),l.to&&e.getLine(l.to.line).length<=o&&i.push(e.markText(l.to,m(l.to.line,l.to.ch+1),{className:a})))}if(i.length){f&&e.state.focused&&e.focus();function c(){e.operation(function(){for(var e=0;e<i.length;e++)i[e].clear()})}if(!t)return c;setTimeout(c,800)}}function i(e){e.operation(function(){e.state.matchBrackets.currentlyHighlighted&&(e.state.matchBrackets.currentlyHighlighted(),e.state.matchBrackets.currentlyHighlighted=null),e.state.matchBrackets.currentlyHighlighted=t(e,!1,e.state.matchBrackets)})}o.defineOption("matchBrackets",!1,function(e,t,n){n&&n!=o.Init&&(e.off("cursorActivity",i),e.state.matchBrackets&&e.state.matchBrackets.currentlyHighlighted&&(e.state.matchBrackets.currentlyHighlighted(),e.state.matchBrackets.currentlyHighlighted=null)),t&&(e.state.matchBrackets="object"==typeof t?t:{},e.on("cursorActivity",i))}),o.defineExtension("matchBrackets",function(){t(this,!0)}),o.defineExtension("findMatchingBracket",function(e,t,n){return!n&&"boolean"!=typeof t||(t=n?(n.strict=t,n):t?{strict:!0}:null),u(this,e,t)}),o.defineExtension("scanForBracket",function(e,t,n,o){return h(this,e,t,n,o)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(k){var n={pairs:"()[]{}''\"\"",closeBefore:")]}'\":;>",triples:"",explode:"[]{}"},w=k.Pos;function T(e,t){return"pairs"==t&&"string"==typeof e?e:"object"==typeof e&&null!=e[t]?e[t]:n[t]}k.defineOption("autoCloseBrackets",!1,function(e,t,n){n&&n!=k.Init&&(e.removeKeyMap(i),e.state.closeBrackets=null),t&&(o(T(t,"pairs")),e.state.closeBrackets=t,e.addKeyMap(i))});var i={Backspace:function(e){var t=L(e);if(!t||e.getOption("disableInput"))return k.Pass;for(var n=T(t,"pairs"),o=e.listSelections(),i=0;i<o.length;i++){if(!o[i].empty())return k.Pass;var r=a(e,o[i].head);if(!r||n.indexOf(r)%2!=0)return k.Pass}for(i=o.length-1;0<=i;i--){var s=o[i].head;e.replaceRange("",w(s.line,s.ch-1),w(s.line,s.ch+1),"+delete")}},Enter:function(o){var e=L(o),t=e&&T(e,"explode");if(!t||o.getOption("disableInput"))return k.Pass;for(var i=o.listSelections(),n=0;n<i.length;n++){if(!i[n].empty())return k.Pass;var r=a(o,i[n].head);if(!r||t.indexOf(r)%2!=0)return k.Pass}o.operation(function(){var e=o.lineSeparator()||"\n";o.replaceSelection(e+e,null),o.execCommand("goCharLeft"),i=o.listSelections();for(var t=0;t<i.length;t++){var n=i[t].head.line;o.indentLine(n,null,!0),o.indentLine(n+1,null,!0)}})}};function o(e){for(var t=0;t<e.length;t++){var n=e.charAt(t),o="'"+n+"'";i[o]||(i[o]=r(n))}}function r(t){return function(e){return function(i,e){var t=L(i);if(!t||i.getOption("disableInput"))return k.Pass;var n=T(t,"pairs"),o=n.indexOf(e);if(-1==o)return k.Pass;for(var r,s=T(t,"closeBefore"),a=T(t,"triples"),l=n.charAt(o+1)==e,c=i.listSelections(),f=o%2==0,u=0;u<c.length;u++){var h,d=c[u],p=d.head,g=i.getRange(p,w(p.line,p.ch+1));if(f&&!d.empty())h="surround";else if(!l&&f||g!=e)if(l&&1<p.ch&&0<=a.indexOf(e)&&i.getRange(w(p.line,p.ch-2),p)==e+e){if(2<p.ch&&/\bstring/.test(i.getTokenTypeAt(w(p.line,p.ch-2))))return k.Pass;h="addFour"}else if(l){var m=0==p.ch?" ":i.getRange(w(p.line,p.ch-1),p);if(k.isWordChar(g)||m==e||k.isWordChar(m))return k.Pass;h="both"}else{if(!f||!(0===g.length||/\s/.test(g)||-1<s.indexOf(g)))return k.Pass;h="both"}else h=!l||(y=p,C=(v=i).getTokenAt(w(y.line,y.ch+1)),!/\bstring/.test(C.type)||C.start!=y.ch||0!=y.ch&&/\bstring/.test(v.getTokenTypeAt(y)))?0<=a.indexOf(e)&&i.getRange(p,w(p.line,p.ch+3))==e+e+e?"skipThree":"skip":"both";if(r){if(r!=h)return k.Pass}else r=h}var v,y,C;var b=o%2?n.charAt(o-1):e,x=o%2?e:n.charAt(o+1);i.operation(function(){if("skip"==r)i.execCommand("goCharRight");else if("skipThree"==r)for(var e=0;e<3;e++)i.execCommand("goCharRight");else if("surround"==r){for(var t=i.getSelections(),e=0;e<t.length;e++)t[e]=b+t[e]+x;i.replaceSelections(t,"around"),t=i.listSelections().slice();for(e=0;e<t.length;e++)t[e]=(n=t[e],o=0<k.cmpPos(n.anchor,n.head),{anchor:new w(n.anchor.line,n.anchor.ch+(o?-1:1)),head:new w(n.head.line,n.head.ch+(o?1:-1))});i.setSelections(t)}else"both"==r?(i.replaceSelection(b+x,null),i.triggerElectric(b+x),i.execCommand("goCharLeft")):"addFour"==r&&(i.replaceSelection(b+b+b+b,"before"),i.execCommand("goCharRight"));var n,o})}(e,t)}}function L(e){var t=e.state.closeBrackets;return t&&!t.override&&e.getModeAt(e.getCursor()).closeBrackets||t}function a(e,t){var n=e.getRange(w(t.line,t.ch-1),w(t.line,t.ch+1));return 2==n.length?n:null}o(n.pairs+"`")}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(i){"use strict";var a="CodeMirror-activeline",l="CodeMirror-activeline-background",c="CodeMirror-activeline-gutter";function f(e){for(var t=0;t<e.state.activeLines.length;t++)e.removeLineClass(e.state.activeLines[t],"wrap",a),e.removeLineClass(e.state.activeLines[t],"background",l),e.removeLineClass(e.state.activeLines[t],"gutter",c)}function r(t,e){for(var n=[],o=0;o<e.length;o++){var i,r=e[o],s=t.getOption("styleActiveLine");("object"==typeof s&&s.nonEmpty?r.anchor.line==r.head.line:r.empty())&&(i=t.getLineHandleVisualStart(r.head.line),n[n.length-1]!=i&&n.push(i))}!function(e,t){if(e.length==t.length){for(var n=0;n<e.length;n++)if(e[n]!=t[n])return;return 1}}(t.state.activeLines,n)&&t.operation(function(){f(t);for(var e=0;e<n.length;e++)t.addLineClass(n[e],"wrap",a),t.addLineClass(n[e],"background",l),t.addLineClass(n[e],"gutter",c);t.state.activeLines=n})}function s(e,t){r(e,t.ranges)}i.defineOption("styleActiveLine",!1,function(e,t,n){var o=n!=i.Init&&n;t!=o&&(o&&(e.off("beforeSelectionChange",s),f(e),delete e.state.activeLines),t&&(e.state.activeLines=[],r(e,e.listSelections()),e.on("beforeSelectionChange",s)))})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(v){"use strict";v.TernServer=function(e){var n=this;this.options=e||{};var t=this.options.plugins||(this.options.plugins={});t.doc_comment||(t.doc_comment=!0),this.docs=Object.create(null),this.options.useWorker?this.server=new O(this):this.server=new tern.Server({getFile:function(e,t){return s(n,e,t)},async:!0,defs:this.options.defs||[],plugins:t}),this.trackChange=function(e,t){!function(e,t,n){var o=u(e,t),i=e.cachedArgHints;i&&i.doc==t&&0<=b(i.start,n.to)&&(e.cachedArgHints=null);var r=o.changed;null==r&&(o.changed=r={from:n.from.line,to:n.from.line});var s=n.from.line+(n.text.length-1);n.from.line<r.to&&(r.to=r.to-(n.to.line-s));s>=r.to&&(r.to=s+1);r.from>n.from.line&&(r.from=n.from.line);t.lineCount()>f&&100<n.to-r.from&&setTimeout(function(){o.changed&&100<o.changed.to-o.changed.from&&a(e,o)},200)}(n,e,t)},this.cachedArgHints=null,this.activeArgHints=null,this.jumpStack=[],this.getHint=function(e,t){return h=e,d=t,void(u=n).request(h,{type:"completions",types:!0,docs:!0,urls:!0,caseInsensitive:!0},function(e,t){if(e)return T(u,h,e);var n=[],o="",i=t.start,r=t.end;'["'==h.getRange(y(i.line,i.ch-2),i)&&'"]'!=h.getRange(r,y(r.line,r.ch+2))&&(o='"]');for(var s=0;s<t.completions.length;++s){var a=t.completions[s],l=g(a.type);t.guess&&(l+=" "+p+"guess"),n.push({text:a.name+o,displayText:a.displayName||a.name,className:l,data:a})}var c={from:i,to:r,list:n},f=null;v.on(c,"close",function(){w(f)}),v.on(c,"update",function(){w(f)}),v.on(c,"select",function(e,t){w(f);var n=u.options.completionTip?u.options.completionTip(e.data):m(e.data);n&&((f=k(t.parentNode.getBoundingClientRect().right+window.pageXOffset,t.getBoundingClientRect().top+window.pageYOffset,n)).className+=" "+p+"hint-doc")}),d(c)});var u,h,d},this.getHint.async=!0},v.TernServer.prototype={addDoc:function(e,t){var n={doc:t,name:e,changed:null};return this.server.addFile(e,M(this,n)),v.on(t,"change",this.trackChange),this.docs[e]=n},delDoc:function(e){var t=n(this,e);t&&(v.off(t.doc,"change",this.trackChange),delete this.docs[t.name],this.server.delFile(t.name))},hideDoc:function(e){L(this);var t=n(this,e);t&&t.changed&&a(this,t)},complete:function(e){e.showHint({hint:this.getHint})},showType:function(e,t,n){o(this,e,t,"type",n)},showDocs:function(e,t,n){o(this,e,t,"documentation",n)},updateArgHints:function(e){!function(n,o){if(L(n),o.somethingSelected())return;var e=o.getTokenAt(o.getCursor()).state,t=v.innerMode(o.getMode(),e);if("javascript"!=t.mode.name)return;var i=t.state.lexical;if("call"!=i.info)return;for(var r,s=i.pos||0,a=o.getOption("tabSize"),l=o.getCursor().line,c=Math.max(0,l-9),f=!1;c<=l;--l){for(var u=o.getLine(l),h=0,d=0;;){var p=u.indexOf("\t",d);if(-1==p)break;h+=a-(p+h)%a-1,d=p+1}if(r=i.column-h,"("==u.charAt(r)){f=!0;break}}if(!f)return;var g=y(l,r),m=n.cachedArgHints;if(m&&m.doc==o.getDoc()&&0==b(g,m.start))return C(n,o,s);n.request(o,{type:"type",preferFunction:!0,end:g},function(e,t){!e&&t.type&&/^fn\(/.test(t.type)&&(n.cachedArgHints={start:g,type:function(i){var e=[],r=3;function t(e){for(var t=0,n=r;;){var o=i.charAt(r);if(e.test(o)&&!t)return i.slice(n,r);/[{\[\(]/.test(o)?++t:/[}\]\)]/.test(o)&&--t,++r}}if(")"!=i.charAt(r))for(;;){var n=i.slice(r).match(/^([^, \(\[\{]+): /);if(n&&(r+=n[0].length,n=n[1]),e.push({name:n,type:t(/[\),]/)}),")"==i.charAt(r))break;r+=2}var o=i.slice(r).match(/^\) -> (.*)$/);return{args:e,rettype:o&&o[1]}}(t.type),name:t.exprName||t.name||"fn",guess:t.guess,doc:o.getDoc()},C(n,o,s))})}(this,e)},jumpToDef:function(e){function t(e){var t={type:"definition",variable:e||null},i=u(r,s.getDoc());r.server.request(h(r,i,t),function(e,t){if(e)return T(r,s,e);if(t.file||!t.url){if(t.file){var n,o=r.docs[t.file];if(o&&(n=function(e,t){for(var n=t.context.slice(0,t.contextOffset).split("\n"),o=t.start.line-(n.length-1),i=y(o,(1==n.length?t.start.ch:e.getLine(o).length)-n[0].length),r=e.getLine(o).slice(i.ch),s=1+o;s<e.lineCount()&&r.length<t.context.length;++s)r+="\n"+e.getLine(s);if(r.slice(0,t.context.length)==t.context)return t;var a,l=e.getSearchCursor(t.context,0,!1),c=1/0;for(;l.findNext();){var f=l.from(),u=1e4*Math.abs(f.line-i.line);(u=u||Math.abs(f.ch-i.ch))<c&&(a=f,c=u)}if(!a)return null;1==n.length?a.ch+=n[0].length:a=y(a.line+(n.length-1),n[n.length-1].length);{var h;h=t.start.line==t.end.line?y(a.line,a.ch+(t.end.ch-t.start.ch)):y(a.line+(t.end.line-t.start.line),t.end.ch)}return{start:a,end:h}}(o.doc,t)))return r.jumpStack.push({file:i.name,start:s.getCursor("from"),end:s.getCursor("to")}),void l(r,i,o,n.start,n.end)}T(r,s,"Could not find a definition.")}else window.open(t.url)})}var r,s;r=this,!function(e){var t=e.getCursor("end"),n=e.getTokenAt(t);return!(n.start<t.ch&&"comment"==n.type)&&/[\w)\]]/.test(e.getLine(t.line).slice(Math.max(t.ch-1,0),t.ch+1))}(s=e)?i(s,"跳转到变量: ",function(e){e&&t(e)}):t()},jumpBack:function(e){!function(e,t){var n=e.jumpStack.pop(),o=n&&e.docs[n.file];if(!o)return;l(e,u(e,t.getDoc()),o,n.start,n.end)}(this,e)},rename:function(e){!function(n,o){var e=o.getTokenAt(o.getCursor());if(!/\w/.test(e.string))return T(n,o,"当前不是一个变量");i(o,"重命名 "+e.string,function(e){n.request(o,{type:"rename",newName:e,fullDocs:!0},function(e,t){if(e)return T(n,o,e);!function(e,t){for(var n=Object.create(null),o=0;o<t.length;++o){var i=t[o];(n[i.file]||(n[i.file]=[])).push(i)}for(var r in n){var s=e.docs[r],a=n[r];if(s){a.sort(function(e,t){return b(t.start,e.start)});for(var l="*rename"+ ++c,o=0;o<a.length;++o){i=a[o];s.doc.replaceRange(i.text,i.start,i.end,l)}}}}(n,t.changes)})})}(this,e)},selectName:function(e){var a,l,c;c=u(a=this,(l=e).doc).name,a.request(l,{type:"refs"},function(e,t){if(e)return T(a,l,e);for(var n=[],o=0,i=l.getCursor(),r=0;r<t.refs.length;r++){var s=t.refs[r];s.file==c&&(n.push({anchor:s.start,head:s.end}),0<=b(i,s.start)&&b(i,s.end)<=0&&(o=n.length-1))}l.setSelections(n,o)})},request:function(e,n,o,t){var i=this,r=u(this,e.getDoc()),s=h(this,r,n,t),a=s.query&&this.options.queryOptions&&this.options.queryOptions[s.query.type];if(a)for(var l in a)s.query[l]=a[l];this.server.request(s,function(e,t){!e&&i.options.responseFilter&&(t=i.options.responseFilter(r,n,s,e,t)),o(e,t)})},destroy:function(){L(this),this.worker&&(this.worker.terminate(),this.worker=null)}};var y=v.Pos,p="CodeMirror-Tern-",f=250;function s(e,t,n){var o=e.docs[t];o?n(M(e,o)):e.options.getFile?e.options.getFile(t,n):n(null)}function u(e,t,n){for(var o in e.docs){var i=e.docs[o];if(i.doc==t)return i}if(!n)for(var r=0;;++r)if(o="[doc"+(r||"")+"]",!e.docs[o]){n=o;break}return e.addDoc(n,t)}function n(e,t){return"string"==typeof t?e.docs[t]:(t instanceof v&&(t=t.getDoc()),t instanceof v.Doc?u(e,t):void 0)}function a(e,t){e.server.request({files:[{type:"full",name:t.name,text:M(e,t)}]},function(e){e?window.console.error(e):t.changed=null})}function g(e){var t="?"==e?"unknown":"number"==e||"string"==e||"bool"==e?e:/^fn\(/.test(e)?"fn":/^\[/.test(e)?"array":"object";return p+"completion "+p+"completion-"+t}function o(e,o,t,n,i){e.request(o,n,function(e,t){var n;e||(n=m(t))&&r(o,n),i&&i()},t)}function m(e){if((e=e||{}).type=e.type||"",e.doc=e.doc||"",e.type.startsWith("fn(")||e.doc){var t,n=d("span",null,d("strong",null,e.type||"not found"));return e.doc&&n.appendChild(document.createTextNode("\n"+e.doc.replace(/<br\/?>/g,"\n"))),e.url&&(n.appendChild(document.createTextNode("\n")),(t=n.appendChild(d("a",null,"[文档]"))).href=e.url,t.target="_blank"),n}}function C(e,t,n){L(e);for(var o=e.cachedArgHints,i=o.type,r=d("span",o.guess?p+"fhint-guess":null,d("span",p+"fname",o.name),"("),s=0;s<i.args.length;++s){s&&r.appendChild(document.createTextNode(", "));var a=i.args[s];r.appendChild(d("span",p+"farg"+(s==n?" "+p+"farg-current":""),a.name||"?")),"?"!=a.type&&(r.appendChild(document.createTextNode(": ")),r.appendChild(d("span",p+"type",a.type)))}r.appendChild(document.createTextNode(i.rettype?") -> ":")")),i.rettype&&r.appendChild(d("span",p+"type",i.rettype));var l=t.cursorCoords(null,"page"),c=e.activeArgHints=k(l.right+1,l.bottom,r);setTimeout(function(){c.clear=x(t,function(){e.activeArgHints==c&&L(e)})},20)}function l(e,t,n,o,i){n.doc.setSelection(o,i),t!=n&&e.options.switchToDoc&&(L(e),e.options.switchToDoc(n.name,n.doc))}var c=0;function h(e,t,n,o){var i=[],r=0,s=!n.fullDocs;s||delete n.fullDocs,"string"==typeof n&&(n={type:n}),n.lineCharPositions=!0,null==n.end&&(n.end=o||t.doc.getCursor("end"),t.doc.somethingSelected()&&(n.start=t.doc.getCursor("start")));var a=n.start||n.end;for(var l in t.changed?t.doc.lineCount()>f&&!1!=s&&t.changed.to-t.changed.from<100&&t.changed.from<=a.line&&t.changed.to>n.end.line?(i.push(function(e,t,n){for(var o,i=e.doc,r=null,s=null,a=t.line-1,l=Math.max(0,a-50);l<=a;--a){var c=i.getLine(a);c.search(/\bfunction\b/)<0||(u=v.countColumn(c,null,4),null!=r&&r<=u||(r=u,s=a))}null==s&&(s=l);var f=Math.min(i.lastLine(),n.line+20);if(null==r||r==v.countColumn(i.getLine(t.line),null,4))o=f;else for(o=n.line+1;o<f;++o){var u;if((u=v.countColumn(i.getLine(o),null,4))<=r)break}var h=y(s,0);return{type:"part",name:e.name,offsetLines:h.line,text:i.getRange(h,y(o,n.line==o?null:0))}}(t,a,n.end)),n.file="#0",r=i[0].offsetLines,null!=n.start&&(n.start=y(n.start.line- -r,n.start.ch)),n.end=y(n.end.line-r,n.end.ch)):(i.push({type:"full",name:t.name,text:M(e,t)}),n.file=t.name,t.changed=null):n.file=t.name,e.docs){var c=e.docs[l];c.changed&&c!=t&&(i.push({type:"full",name:c.name,text:M(e,c)}),c.changed=null)}return{query:n,files:i}}var b=v.cmpPos;function d(e,t){var n=document.createElement(e);t&&(n.className=t);for(var o=2;o<arguments.length;++o){var i=arguments[o];"string"==typeof i&&(i=document.createTextNode(i)),n.appendChild(i)}return n}function i(e,t,n){e.openDialog?e.openDialog(t+": <input type=text>",n):n(prompt(t,""))}function r(t,e){t.state.ternTooltip&&w(t.state.ternTooltip);var n=t.cursorCoords(),o=t.state.ternTooltip=k(n.right+1,n.bottom,e);var i=!1;v.on(o,"mousemove",function(){i=!0}),v.on(o,"mouseout",function(e){i=!1});var r=x(t,function e(){if(i)return i=!1,void setTimeout(e,100);t.state.ternTooltip=null,o.parentNode&&w(o),r()})}function x(e,t){return e.on("cursorActivity",t),e.on("blur",t),e.on("scroll",t),e.on("setDoc",t),function(){e.off("cursorActivity",t),e.off("blur",t),e.off("scroll",t),e.off("setDoc",t)}}function k(e,t,n){"string"==typeof n&&(n=n.replace(/<br\/?>/g,"\n"));var o=d("div",p+"tooltip",n);return o.style.left=e+"px",o.style.top=t+"px",document.body.appendChild(o),o}function w(e){var t=e&&e.parentNode;t&&t.removeChild(e)}function T(e,t,n){e.options.showError?e.options.showError(t,n):r(t,String(n))}function L(e){e.activeArgHints&&(e.activeArgHints.clear&&e.activeArgHints.clear(),w(e.activeArgHints),e.activeArgHints=null)}function M(e,t){var n=t.doc.getValue();return e.options.fileFilter&&(n=e.options.fileFilter(n,t.name,t.doc)),n}function O(t){var n=t.worker=new Worker(t.options.workerScript);n.postMessage({type:"init",defs:t.options.defs,plugins:t.options.plugins,scripts:t.options.workerDeps});var o=0,i={};function r(e,t){t&&(e.id=++o,i[o]=t),n.postMessage(e)}n.onmessage=function(e){var n=e.data;"getFile"==n.type?s(t,n.name,function(e,t){r({type:"getFile",err:String(e),text:t,id:n.id})}):"debug"==n.type?window.console.log(n.message):n.id&&i[n.id]&&(i[n.id](n.err,n.body),delete i[n.id])},n.onerror=function(e){for(var t in i)i[t](e);i={}},this.addFile=function(e,t){r({type:"add",name:e,text:t})},this.delFile=function(e){r({type:"del",name:e})},this.request=function(e,t){r({type:"req",body:e},t)}}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(h){"use strict";var p="CodeMirror-lint-markers";function d(e){e.parentNode&&e.parentNode.removeChild(e)}function f(e,t,n,o){var i,r,s,a,l=(i=e,r=t,s=n,(a=document.createElement("div")).className="CodeMirror-lint-tooltip cm-s-"+i.options.theme,a.appendChild(s.cloneNode(!0)),i.state.lint.options.selfContain?i.getWrapperElement().appendChild(a):document.body.appendChild(a),h.on(document,"mousemove",c),c(r),null!=a.style.opacity&&(a.style.opacity=1),a);function c(e){if(!a.parentNode)return h.off(document,"mousemove",c);a.style.top=Math.max(0,e.clientY-a.offsetHeight-5)+"px",a.style.left=e.clientX+5+"px"}function f(){var e;h.off(o,"mouseout",f),l&&((e=l).parentNode&&(null==e.style.opacity&&d(e),e.style.opacity=0,setTimeout(function(){d(e)},600)),l=null)}var u=setInterval(function(){if(l)for(var e=o;;e=e.parentNode){if(e&&11==e.nodeType&&(e=e.host),e==document.body)return;if(!e){f();break}}if(!l)return clearInterval(u)},400);h.on(o,"mouseout",f)}function l(t,e,n){this.marked=[],this.options=e,this.timeout=null,this.hasGutter=n,this.onMouseOver=function(e){!function(e,t){var n=t.target||t.srcElement;if(!/\bCodeMirror-lint-mark-/.test(n.className))return;for(var o=n.getBoundingClientRect(),i=(o.left+o.right)/2,r=(o.top+o.bottom)/2,s=e.findMarksAt(e.coordsChar({left:i,top:r},"client")),a=[],l=0;l<s.length;++l){var c=s[l].__annotation;c&&a.push(c)}a.length&&function(e,t,n){for(var o=n.target||n.srcElement,i=document.createDocumentFragment(),r=0;r<t.length;r++){var s=t[r];i.appendChild(v(s))}f(e,n,i,o)}(e,a,t)}(t,e)},this.waitingFor=0}function g(e){var t=e.state.lint;t.hasGutter&&e.clearGutter(p);for(var n=0;n<t.marked.length;++n)t.marked[n].clear();t.marked.length=0}function m(t,n,e,o,i){var r=document.createElement("div"),s=r;return r.className="CodeMirror-lint-marker-"+e,o&&((s=r.appendChild(document.createElement("div"))).className="CodeMirror-lint-marker-multiple"),0!=i&&h.on(s,"mouseover",function(e){f(t,e,n,s)}),r}function v(e){var t=(t=e.severity)||"error",n=document.createElement("div");return n.className="CodeMirror-lint-message-"+t,void 0!==e.messageHTML?n.innerHTML=e.messageHTML:n.appendChild(document.createTextNode(e.message)),n}function c(t){var n,e,o,i,r,s=t.state.lint.options,a=s.options||s,l=s.getAnnotations||t.getHelper(h.Pos(0,0),"lint");if(l)if(s.async||l.async)e=l,o=a,i=(n=t).state.lint,r=++i.waitingFor,n.on("change",f),e(n.getValue(),function(e,t){n.off("change",f),i.waitingFor==r&&(t&&e instanceof h&&(e=t),n.operation(function(){u(n,e)}))},o,n);else{var c=l(t.getValue(),a,t);if(!c)return;c.then?c.then(function(e){t.operation(function(){u(t,e)})}):t.operation(function(){u(t,c)})}function f(){r=-1,n.off("change",f)}}function u(e,t){g(e);for(var n,o,i=e.state.lint,r=i.options,s=function(e){for(var t=[],n=0;n<e.length;++n){var o=e[n],i=o.from.line;(t[i]||(t[i]=[])).push(o)}return t}(t),a=0;a<s.length;++a){var l=s[a];if(l){for(var c=null,f=i.hasGutter&&document.createDocumentFragment(),u=0;u<l.length;++u){var h=l[u],d=h.severity;o=d=d||"error",c="error"==(n=c)?n:o,r.formatAnnotation&&(h=r.formatAnnotation(h)),i.hasGutter&&f.appendChild(v(h)),h.to&&i.marked.push(e.markText(h.from,h.to,{className:"CodeMirror-lint-mark-"+d,__annotation:h}))}i.hasGutter&&e.setGutterMarker(a,p,m(e,f,c,1<l.length,i.options.tooltips))}}r.onUpdateLinting&&r.onUpdateLinting(t,s,e)}function y(e){var t=e.state.lint;t&&(clearTimeout(t.timeout),t.timeout=setTimeout(function(){c(e)},t.options.delay||500))}h.defineOption("lint",!1,function(e,t,n){if(n&&n!=h.Init&&(g(e),!1!==e.state.lint.options.lintOnChange&&e.off("change",y),h.off(e.getWrapperElement(),"mouseover",e.state.lint.onMouseOver),clearTimeout(e.state.lint.timeout),delete e.state.lint),t){for(var o=e.getOption("gutters"),i=!1,r=0;r<o.length;++r)o[r]==p&&(i=!0);var s=e.state.lint=new l(e,(a=t)instanceof Function?{getAnnotations:a}:(a&&!0!==a||(a={}),a),i);!1!==s.options.lintOnChange&&e.on("change",y),0!=s.options.tooltips&&"gutter"!=s.options.tooltips&&h.on(e.getWrapperElement(),"mouseover",s.onMouseOver),c(e)}var a}),h.defineExtension("performLint",function(){this.state.lint&&c(this)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(l){"use strict";l.registerHelper("lint","javascript",function(e,t){if(!window.JSHINT)return window.console&&window.console.error("Error: window.JSHINT not defined, CodeMirror JavaScript linting cannot run."),[];t.indent||(t.indent=1),t.asi=!0,t.shadow=!0,t.eqnull=!0,t.maxerr=1e3,JSHINT(e,t,t.globals);var n=JSHINT.data().errors,o=[];return n&&function(e,t){for(var n=0;n<e.length;n++){var o=e[n];if(o){if(o.line<=0){window.console&&window.console.warn("Cannot display JSHint error (invalid line "+o.line+")",o);continue}var i,r=o.character-1,s=1+r;!o.evidence||-1<(i=o.evidence.substring(r).search(/.\b/))&&(s+=i);var a={message:o.reason,severity:o.code&&o.code.startsWith("W")?"warning":"error",from:l.Pos(o.line-1,r),to:l.Pos(o.line-1,s)};t.push(a)}}}(n,o),o})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var M={},O=/[^\s\u00a0]/,A=e.Pos;function h(e){var t=e.search(O);return-1==t?0:t}function S(e,t){var n=e.getMode();return!1!==n.useInnerComments&&n.innerMode?e.getModeAt(t):n}e.commands.toggleComment=function(e){e.toggleComment()},e.defineExtension("toggleComment",function(e){e=e||M;for(var t=1/0,n=this.listSelections(),o=null,i=n.length-1;0<=i;i--){var r=n[i].from(),s=n[i].to();r.line>=t||(s.line>=t&&(s=A(t,0)),t=r.line,null==o?o=this.uncomment(r,s,e)?"un":(this.lineComment(r,s,e),"line"):"un"==o?this.uncomment(r,s,e):this.lineComment(r,s,e))}}),e.defineExtension("lineComment",function(r,e,s){s=s||M;var t,n,a,l,c,f,u=this,o=S(u,r),i=u.getLine(r.line);null!=i&&(t=r,n=i,!/\bstring\b/.test(u.getTokenTypeAt(A(t.line,0)))||/^[\'\"\`]/.test(n))&&((a=s.lineComment||o.lineComment)?(l=Math.min(0!=e.ch||e.line==r.line?e.line+1:e.line,u.lastLine()+1),c=null==s.padding?" ":s.padding,f=s.commentBlankLines||r.line==e.line,u.operation(function(){if(s.indent){for(var e=null,t=r.line;t<l;++t){var n=(o=u.getLine(t)).slice(0,h(o));(null==e||e.length>n.length)&&(e=n)}for(t=r.line;t<l;++t){var o=u.getLine(t),i=e.length;(f||O.test(o))&&(o.slice(0,i)!=e&&(i=h(o)),u.replaceRange(e+a+c,A(t,0),A(t,i)))}}else for(t=r.line;t<l;++t)(f||O.test(u.getLine(t)))&&u.replaceRange(a+c,A(t,0))})):(s.blockCommentStart||o.blockCommentStart)&&(s.fullLines=!0,u.blockComment(r,e,s)))}),e.defineExtension("blockComment",function(o,i,r){r=r||M;var s,a,l=this,c=S(l,o),f=r.blockCommentStart||c.blockCommentStart,u=r.blockCommentEnd||c.blockCommentEnd;f&&u?/\bcomment\b/.test(l.getTokenTypeAt(A(o.line,0)))||((s=Math.min(i.line,l.lastLine()))!=o.line&&0==i.ch&&O.test(l.getLine(s))&&--s,a=null==r.padding?" ":r.padding,o.line>s||l.operation(function(){if(0!=r.fullLines){var e=O.test(l.getLine(s));l.replaceRange(a+u,A(s)),l.replaceRange(f+a,A(o.line,0));var t=r.blockCommentLead||c.blockCommentLead;if(null!=t)for(var n=o.line+1;n<=s;++n)n==s&&!e||l.replaceRange(t+a,A(n,0))}else l.replaceRange(u,i),l.replaceRange(f,o)})):(r.lineComment||c.lineComment)&&0!=r.fullLines&&l.lineComment(o,i,r)}),e.defineExtension("uncomment",function(e,t,n){n=n||M;var i,r=this,o=S(r,e),s=Math.min(0!=t.ch||t.line==e.line?t.line:t.line-1,r.lastLine()),a=Math.min(e.line,s),l=n.lineComment||o.lineComment,c=[],f=null==n.padding?" ":n.padding;e:if(l){for(var u=a;u<=s;++u){var h=r.getLine(u),d=h.indexOf(l);if(-1<d&&!/comment/.test(r.getTokenTypeAt(A(u,d+1)))&&(d=-1),-1==d&&O.test(h))break e;if(-1<d&&O.test(h.slice(0,d)))break e;c.push(h)}if(r.operation(function(){for(var e=a;e<=s;++e){var t=c[e-a],n=t.indexOf(l),o=n+l.length;n<0||(t.slice(o,o+f.length)==f&&(o+=f.length),i=!0,r.replaceRange("",A(e,n),A(e,o)))}}),i)return!0}var p=n.blockCommentStart||o.blockCommentStart,g=n.blockCommentEnd||o.blockCommentEnd;if(!p||!g)return!1;var m=n.blockCommentLead||o.blockCommentLead,v=r.getLine(a),y=v.indexOf(p);if(-1==y)return!1;var C=s==a?v:r.getLine(s),b=C.indexOf(g,s==a?y+p.length:0),x=A(a,y+1),k=A(s,b+1);if(-1==b||!/comment/.test(r.getTokenTypeAt(x))||!/comment/.test(r.getTokenTypeAt(k))||-1<r.getRange(x,k,"\n").indexOf(g))return!1;var w=-1==(L=v.lastIndexOf(p,e.ch))?-1:v.slice(0,e.ch).indexOf(g,L+p.length);if(-1!=L&&-1!=w&&w+g.length!=e.ch)return!1;w=C.indexOf(g,t.ch);var T=C.slice(t.ch).lastIndexOf(p,w-t.ch),L=-1==w||-1==T?-1:t.ch+T;return(-1==w||-1==L||L==t.ch)&&(r.operation(function(){r.replaceRange("",A(s,b-(f&&C.slice(b-f.length,b)==f?f.length:0)),A(s,b+g.length));var e=y+p.length;if(f&&v.slice(e,e+f.length)==f&&(e+=f.length),r.replaceRange("",A(a,y),A(a,e)),m)for(var t=a+1;t<=s;++t){var n,o=r.getLine(t),i=o.indexOf(m);-1==i||O.test(o.slice(0,i))||(n=i+m.length,f&&o.slice(n,n+f.length)==f&&(n+=f.length),r.replaceRange("",A(t,i),A(t,n)))}}),!0)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(f){"use strict";function i(i,r,e,s){var a;e&&e.call?(a=e,e=null):a=u(i,e,"rangeFinder"),"number"==typeof r&&(r=f.Pos(r,0));var l=u(i,e,"minFoldSize");function t(e){var t=a(i,r);if(!t||t.to.line-t.from.line<l)return null;for(var n=i.findMarksAt(t.from),o=0;o<n.length;++o)if(n[o].__isFold&&"fold"!==s){if(!e)return null;t.cleared=!0,n[o].clear()}return t}var n,o,c=t(!0);if(u(i,e,"scanUp"))for(;!c&&r.line>i.firstLine();)r=f.Pos(r.line-1,0),c=t(!1);c&&!c.cleared&&"unfold"!==s&&(n=function(e,t,n){var o=u(e,t,"widget");"function"==typeof o&&(o=o(n.from,n.to));{var i;"string"==typeof o?(i=document.createTextNode(o),(o=document.createElement("span")).appendChild(i),o.className="CodeMirror-foldmarker"):o=o&&o.cloneNode(!0)}return o}(i,e,c),f.on(n,"mousedown",function(e){o.clear(),f.e_preventDefault(e)}),(o=i.markText(c.from,c.to,{replacedWith:n,clearOnEnter:u(i,e,"clearOnEnter"),__isFold:!0})).on("clear",function(e,t){f.signal(i,"unfold",i,e,t)}),f.signal(i,"fold",i,c.from,c.to))}f.newFoldFunction=function(n,o){return function(e,t){i(e,t,{rangeFinder:n,widget:o})}},f.defineExtension("foldCode",function(e,t,n){i(this,e,t,n)}),f.defineExtension("isFolded",function(e){for(var t=this.findMarksAt(e),n=0;n<t.length;++n)if(t[n].__isFold)return!0}),f.commands.toggleFold=function(e){e.foldCode(e.getCursor())},f.commands.fold=function(e){e.foldCode(e.getCursor(),null,"fold")},f.commands.unfold=function(e){e.foldCode(e.getCursor(),null,"unfold")},f.commands.foldAll=function(n){n.operation(function(){for(var e=n.firstLine(),t=n.lastLine();e<=t;e++)n.foldCode(f.Pos(e,0),null,"fold")})},f.commands.unfoldAll=function(n){n.operation(function(){for(var e=n.firstLine(),t=n.lastLine();e<=t;e++)n.foldCode(f.Pos(e,0),null,"unfold")})},f.registerHelper("fold","combine",function(){var i=Array.prototype.slice.call(arguments,0);return function(e,t){for(var n=0;n<i.length;++n){var o=i[n](e,t);if(o)return o}}}),f.registerHelper("fold","auto",function(e,t){for(var n=e.getHelpers(t,"fold"),o=0;o<n.length;o++){var i=n[o](e,t);if(i)return i}});var r={rangeFinder:f.fold.auto,widget:"↔",minFoldSize:0,scanUp:!1,clearOnEnter:!0};function u(e,t,n){if(t&&void 0!==t[n])return t[n];var o=e.options.foldOptions;return o&&void 0!==o[n]?o[n]:r[n]}f.defineOption("foldOptions",null),f.defineExtension("foldOption",function(e,t){return u(this,e,t)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./foldcode")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./foldcode"],e):e(CodeMirror)}(function(o){"use strict";o.defineOption("foldGutter",!1,function(e,t,n){n&&n!=o.Init&&(e.clearGutter(e.state.foldGutter.options.gutter),e.state.foldGutter=null,e.off("gutterClick",a),e.off("changes",l),e.off("viewportChange",c),e.off("fold",f),e.off("unfold",f),e.off("swapDoc",l)),t&&(e.state.foldGutter=new i(function(e){!0===e&&(e={});null==e.gutter&&(e.gutter="CodeMirror-foldgutter");null==e.indicatorOpen&&(e.indicatorOpen="CodeMirror-foldgutter-open");null==e.indicatorFolded&&(e.indicatorFolded="CodeMirror-foldgutter-folded");return e}(t)),s(e),e.on("gutterClick",a),e.on("changes",l),e.on("viewportChange",c),e.on("fold",f),e.on("unfold",f),e.on("swapDoc",l))});var h=o.Pos;function i(e){this.options=e,this.from=this.to=0}function d(e,t){for(var n=e.findMarks(h(t,0),h(t+1,0)),o=0;o<n.length;++o)if(n[o].__isFold){var i=n[o].find(-1);if(i&&i.line===t)return n[o]}}function p(e){if("string"!=typeof e)return e.cloneNode(!0);var t=document.createElement("div");return t.className=e+" CodeMirror-guttermarker-subtle",t}function r(r,e,t){var s=r.state.foldGutter.options,a=e-1,l=r.foldOption(s,"minFoldSize"),c=r.foldOption(s,"rangeFinder"),f="string"==typeof s.indicatorFolded&&n(s.indicatorFolded),u="string"==typeof s.indicatorOpen&&n(s.indicatorOpen);r.eachLine(e,t,function(e){++a;var t=null,n=(n=e.gutterMarkers)&&n[s.gutter];if(d(r,a)){if(f&&n&&f.test(n.className))return;t=p(s.indicatorFolded)}else{var o=h(a,0),i=c&&c(r,o);if(i&&i.to.line-i.from.line>=l){if(u&&n&&u.test(n.className))return;t=p(s.indicatorOpen)}}(t||n)&&r.setGutterMarker(e,s.gutter,t)})}function n(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function s(e){var t=e.getViewport(),n=e.state.foldGutter;n&&(e.operation(function(){r(e,t.from,t.to)}),n.from=t.from,n.to=t.to)}function a(e,t,n){var o,i,r=e.state.foldGutter;!r||n==(o=r.options).gutter&&((i=d(e,t))?i.clear():e.foldCode(h(t,0),o))}function l(e){var t,n=e.state.foldGutter;n&&(t=n.options,n.from=n.to=0,clearTimeout(n.changeUpdate),n.changeUpdate=setTimeout(function(){s(e)},t.foldOnChangeTimeSpan||600))}function c(t){var e,n=t.state.foldGutter;n&&(e=n.options,clearTimeout(n.changeUpdate),n.changeUpdate=setTimeout(function(){var e=t.getViewport();n.from==n.to||20<e.from-n.to||20<n.from-e.to?s(t):t.operation(function(){e.from<n.from&&(r(t,e.from,n.from),n.from=e.from),e.to>n.to&&(r(t,n.to,e.to),n.to=e.to)})},e.updateViewportTimeSpan||400))}function f(e,t){var n,o=e.state.foldGutter;!o||(n=t.line)>=o.from&&n<o.to&&r(e,n,n+1)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(y){"use strict";y.registerHelper("fold","brace",function(i,r){var s,a=r.line,l=i.getLine(a);function e(e){for(var t=r.ch,n=0;;){var o=t<=0?-1:l.lastIndexOf(e,t-1);if(-1!=o){if(1==n&&o<r.ch)break;if(s=i.getTokenTypeAt(y.Pos(a,o+1)),!/^(comment|string)/.test(s))return o+1;t=o-1}else{if(1==n)break;n=1,t=l.length}}}var t="{",n="}",o=e("{");if(null==o&&(n="]",o=e(t="[")),null!=o){var c,f,u=1,h=i.lastLine();e:for(var d=a;d<=h;++d)for(var p=i.getLine(d),g=d==a?o:0;;){var m=p.indexOf(t,g),v=p.indexOf(n,g);if(m<0&&(m=p.length),v<0&&(v=p.length),(g=Math.min(m,v))==p.length)break;if(i.getTokenTypeAt(y.Pos(d,g+1))==s)if(g==m)++u;else if(!--u){c=d,f=g;break e}++g}if(null!=c&&a!=c)return{from:y.Pos(a,o),to:y.Pos(c,f)}}}),y.registerHelper("fold","import",function(r,e){function t(e){if(e<r.firstLine()||e>r.lastLine())return null;var t=r.getTokenAt(y.Pos(e,1));if(/\S/.test(t.string)||(t=r.getTokenAt(y.Pos(e,t.end+1))),"keyword"!=t.type||"import"!=t.string)return null;for(var n=e,o=Math.min(r.lastLine(),e+10);n<=o;++n){var i=r.getLine(n).indexOf(";");if(-1!=i)return{startCh:t.end,end:y.Pos(n,i)}}}var n,o=e.line,i=t(o);if(!i||t(o-1)||(n=t(o-2))&&n.end.line==o-1)return null;for(var s=i.end;;){var a=t(s.line+1);if(null==a)break;s=a.end}return{from:r.clipPos(y.Pos(o,i.startCh+1)),to:s}}),y.registerHelper("fold","include",function(n,e){function t(e){if(e<n.firstLine()||e>n.lastLine())return null;var t=n.getTokenAt(y.Pos(e,1));return/\S/.test(t.string)||(t=n.getTokenAt(y.Pos(e,t.end+1))),"meta"==t.type&&"#include"==t.string.slice(0,8)?t.start+8:void 0}var o=e.line,i=t(o);if(null==i||null!=t(o-1))return null;for(var r=o;;){if(null==t(r+1))break;++r}return{from:y.Pos(o,i+1),to:n.clipPos(y.Pos(r))}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./matchesonscrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./matchesonscrollbar"],e):e(CodeMirror)}(function(i){"use strict";var n={style:"matchhighlight",minChars:2,delay:100,wordsOnly:!1,annotateScrollbar:!1,showToken:!1,trim:!0};function r(e){for(var t in this.options={},n)this.options[t]=(e&&e.hasOwnProperty(t)?e:n)[t];this.overlay=this.timeout=null,this.matchesonscroll=null,this.active=!1}function s(e){var t=e.state.matchHighlighter;(t.active||e.hasFocus())&&o(e,t)}function a(e){var t=e.state.matchHighlighter;t.active||(t.active=!0,o(e,t))}function o(e,t){clearTimeout(t.timeout),t.timeout=setTimeout(function(){l(e)},t.options.delay)}function f(e,t,n,o){var i,r,s,a,l=e.state.matchHighlighter;e.addOverlay(l.overlay=(i=t,r=n,s=o,{token:function(e){if(e.match(i)&&(!r||(n=r,!((t=e).start&&n.test(t.string.charAt(t.start-1))||t.pos!=t.string.length&&n.test(t.string.charAt(t.pos))))))return s;var t,n;e.next(),e.skipTo(i.charAt(0))||e.skipToEnd()}})),l.options.annotateScrollbar&&e.showMatchesOnScrollbar&&(a=n?new RegExp((/\w/.test(t.charAt(0))?"\\b":"")+t.replace(/[\\\[.+*?(){|^$]/g,"\\$&")+(/\w/.test(t.charAt(t.length-1))?"\\b":"")):t,l.matchesonscroll=e.showMatchesOnScrollbar(a,!1,{className:"CodeMirror-selection-highlight-scrollbar"}))}function u(e){var t=e.state.matchHighlighter;t.overlay&&(e.removeOverlay(t.overlay),t.overlay=null,t.matchesonscroll&&(t.matchesonscroll.clear(),t.matchesonscroll=null))}function l(c){c.operation(function(){var e=c.state.matchHighlighter;if(u(c),c.somethingSelected()||!e.options.showToken){var t,n=c.getCursor("from"),o=c.getCursor("to");n.line==o.line&&(e.options.wordsOnly&&!function(e,t,n){{if(null===e.getRange(t,n).match(/^\w+$/))return;if(0<t.ch){var o={line:t.line,ch:t.ch-1};if(null===e.getRange(o,t).match(/\W/))return}if(n.ch<e.getLine(t.line).length){o={line:n.line,ch:n.ch+1};if(null===e.getRange(n,o).match(/\W/))return}return 1}}(c,n,o)||(t=c.getRange(n,o),e.options.trim&&(t=t.replace(/^\s+|\s+$/g,"")),t.length>=e.options.minChars&&f(c,t,!1,e.options.style)))}else{for(var i=!0===e.options.showToken?/[\w$]/:e.options.showToken,r=c.getCursor(),s=c.getLine(r.line),a=r.ch,l=a;a&&i.test(s.charAt(a-1));)--a;for(;l<s.length&&i.test(s.charAt(l));)++l;a<l&&f(c,s.slice(a,l),i,e.options.style)}})}i.defineOption("highlightSelectionMatches",!1,function(e,t,n){var o;n&&n!=i.Init&&(u(e),clearTimeout(e.state.matchHighlighter.timeout),e.state.matchHighlighter=null,e.off("cursorActivity",s),e.off("focus",a)),t&&(o=e.state.matchHighlighter=new r(t),e.hasFocus()?(o.active=!0,l(e)):e.on("focus",a),e.on("cursorActivity",s))})}); |