-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcm-plugins.min.js
More file actions
1 lines (1 loc) · 27 KB
/
cm-plugins.min.js
File metadata and controls
1 lines (1 loc) · 27 KB
1
var isSame;!function(t){"object"==typeof exports&&"object"==typeof module?t(require("codemirror")):"function"==typeof define&&define.amd?define(["codemirror"],mod):t(CodeMirror)}((function(t){"use strict";var e=/[\w?.,%]+/;t.registerHelper("hint","anyword",(function(n,i){for(var o=i&&i.word||e,r=i&&i.range||500,s=i&&i.extraWords||EXTRAWORDS,a=n.getCursor(),c=n.getLine(a.line),l=a.ch,h=l;h&&o.test(c.charAt(h-1));)--h;var u=h!=l&&c.slice(h,l);u&&(u=u.toLowerCase()),isSame=s.some((t=>t.toLowerCase()===u));for(var f=i&&i.list||[],d={},p=new RegExp(o.source,"gi"),m=-1;m<=1;m+=2)for(var g=a.line,v=Math.min(Math.max(g+m*r,n.firstLine()),n.lastLine())+m;g!=v;g+=m){var y,C=n.getLine(g),x=(C=(C=C.replace(/\/{2}.*/g,"")).replace(/(=|-|\+|\*|<|>)\d+/g,"")).match(/\w+(?:,(\S+)){2}/);for(x&&(C=C.replace(x[1]," "+x[1])),C.includes("#")&&(p=new RegExp(/[\w?#.,%]+/,"gi"));y=p.exec(C);)g==a.line&&y[0].toLowerCase()===u||u&&0!=y[0].toLowerCase().lastIndexOf(u,0)||Object.prototype.hasOwnProperty.call(d,y[0])||(d[y[0]]=!0,f.push(y[0]))}f.sort(),f.reverse();let b=new Map(f.map((t=>[t.toLowerCase(),t])));(f=[...b.values()]).sort();var w=s.filter((t=>t.toLowerCase().startsWith(u||"")));w.sort(),f=f.concat(w);let N=new Map(f.map((t=>[t.toLowerCase(),t])));return(f=[...N.values()]).sort((function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())})),{list:f,from:t.Pos(a.line,h),to:t.Pos(a.line,l)}}))})),function(t){"object"==typeof exports&&"object"==typeof module?t(require("codemirror")):"function"==typeof define&&define.amd?define(["codemirror"],mod):t(CodeMirror)}((function(t){"use strict";function e(e,n){if(this.cm=e,this.options=n,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,this.options.updateOnCursorActivity){var i=this;e.on("cursorActivity",this.activityFunc=function(){i.cursorActivity()})}t.signal(this,"startCompletion",this)}t.showHint=function(t,e,n){if(!e)return t.showHint(n);n&&n.async&&(e.async=!0);var i={hint:e};if(n)for(var o in n)i[o]=n[o];return t.showHint(i)},t.defineExtension("showHint",(function(n){n=function(t,e,n){var i=t.options.hintOptions,o={};for(var r in c)o[r]=c[r];if(i)for(var r in i)void 0!==i[r]&&(o[r]=i[r]);if(n)for(var r in n)void 0!==n[r]&&(o[r]=n[r]);o.hint.resolve&&(o.hint=o.hint.resolve(t,e));return o}(this,this.getCursor("start"),n);var i=this.listSelections();if(!(i.length>1)){if(this.somethingSelected()){if(!n.hint.supportsSelection)return;for(var o=0;o<i.length;o++)if(i[o].head.line!=i[o].anchor.line)return}this.state.completionActive&&this.state.completionActive.close();var r=this.state.completionActive=new e(this,n);r.options.hint&&(t.signal(this,"startCompletion",this),r.update(!0))}})),t.defineExtension("closeHint",(function(){this.state.completionActive&&this.state.completionActive.close()}));var n=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},i=window.cancelAnimationFrame||clearTimeout;function o(t){return"string"==typeof t?t:t.text}function r(t,e){for(;e&&e!=t;){if("LI"===e.nodeName.toUpperCase()&&e.parentNode==t)return e;e=e.parentNode}}function s(e,n){this.id="cm-complete-"+Math.floor(Math.random(1e6)),this.completion=e,this.data=n,this.picked=!1;var i=this,s=e.cm,a=s.getInputField().ownerDocument,c=a.defaultView||a.parentWindow,l=this.hints=a.createElement("ul");l.setAttribute("role","listbox"),l.setAttribute("aria-expanded","true"),l.id=this.id;var h=e.cm.options.theme;l.className="CodeMirror-hints "+h,this.selectedHint=n.selectedHint||0;for(var u=n.list,f=0;f<u.length;++f){var d=l.appendChild(a.createElement("li")),p=u[f],m="CodeMirror-hint"+(f!=this.selectedHint?"":" CodeMirror-hint-active");null!=p.className&&(m=p.className+" "+m),d.className=m,f==this.selectedHint&&d.setAttribute("aria-selected","true"),d.id=this.id+"-"+f,d.setAttribute("role","option"),p.render?p.render(d,n,p):d.appendChild(a.createTextNode(p.displayText||o(p))),d.hintId=f}var g=e.options.container||a.body,v=s.cursorCoords(e.options.alignWithWord?n.from:null),y=v.left,C=v.bottom,x=!0,b=0,w=0;if(g!==a.body){var N=-1!==["absolute","relative","fixed"].indexOf(c.getComputedStyle(g).position)?g:g.offsetParent,O=N.getBoundingClientRect(),S=a.body.getBoundingClientRect();b=O.left-S.left-N.scrollLeft,w=O.top-S.top-N.scrollTop}l.style.left=y-b+"px",l.style.top=C-w+"px";var M=c.innerWidth||Math.max(a.body.offsetWidth,a.documentElement.offsetWidth),E=c.innerHeight||Math.max(a.body.offsetHeight,a.documentElement.offsetHeight);g.appendChild(l),s.getInputField().setAttribute("aria-autocomplete","list"),s.getInputField().setAttribute("aria-owns",this.id),s.getInputField().setAttribute("aria-activedescendant",this.id+"-"+this.selectedHint);var H,L=e.options.moveOnOverlap?l.getBoundingClientRect():new DOMRect,T=!!e.options.paddingForScrollbar&&l.scrollHeight>l.clientHeight+1;if(setTimeout((function(){H=s.getScrollInfo()})),L.bottom-E>0){var k=L.bottom-L.top;if(v.top-(v.bottom-L.top)-k>0)l.style.top=(C=v.top-k-w)+"px",x=!1;else if(k>E){l.style.height=E-5+"px",l.style.top=(C=v.bottom-L.top-w)+"px";var A=s.getCursor();n.from.ch!=A.ch&&(v=s.cursorCoords(A),l.style.left=(y=v.left-b)+"px",L=l.getBoundingClientRect())}}var P,F=L.right-M;if(T&&(F+=s.display.nativeBarWidth),F>0&&(L.right-L.left>M&&(l.style.width=M-5+"px",F-=L.right-L.left-M),l.style.left=(y=v.left-F-b)+"px"),T)for(var q=l.firstChild;q;q=q.nextSibling)q.style.paddingRight=s.display.nativeBarWidth+"px";(s.addKeyMap(this.keyMap=function(t,e){var n={Up:function(){e.moveFocus(-1)},Down:function(){e.moveFocus(1)},PageUp:function(){e.moveFocus(1-e.menuSize(),!0)},PageDown:function(){e.moveFocus(e.menuSize()-1,!0)},Home:function(){e.setFocus(0)},End:function(){e.setFocus(e.length-1)},Enter:e.pick,Tab:e.pick,Esc:e.close},i=/Mac/.test(navigator.platform);isSame&&(n.Space=e.pick,n[","]=e.pick),i&&(n["Ctrl-P"]=function(){e.moveFocus(-1)},n["Ctrl-N"]=function(){e.moveFocus(1)});var o=t.options.customKeys,r=o?{}:n;function s(t,i){var o;o="string"!=typeof i?function(t){return i(t,e)}:n.hasOwnProperty(i)?n[i]:i,r[t]=o}if(o)for(var a in o)o.hasOwnProperty(a)&&s(a,o[a]);var c=t.options.extraKeys;if(c)for(var a in c)c.hasOwnProperty(a)&&s(a,c[a]);return r}(e,{moveFocus:function(t,e){i.changeActive(i.selectedHint+t,e)},setFocus:function(t){i.changeActive(t)},menuSize:function(){return i.screenAmount()},length:u.length,close:function(){e.close()},pick:function(){i.pick()},data:n})),e.options.closeOnUnfocus)&&(s.on("blur",this.onBlur=function(){P=setTimeout((function(){e.close()}),100)}),s.on("focus",this.onFocus=function(){clearTimeout(P)}));s.on("scroll",this.onScroll=function(){var t=s.getScrollInfo(),n=s.getWrapperElement().getBoundingClientRect();H||(H=s.getScrollInfo());var i=C+H.top-t.top,o=i-(c.pageYOffset||(a.documentElement||a.body).scrollTop);if(x||(o+=l.offsetHeight),o<=n.top||o>=n.bottom)return e.close();l.style.top=i+"px",l.style.left=y+H.left-t.left+"px"}),t.on(l,"dblclick",(function(t){var e=r(l,t.target||t.srcElement);e&&null!=e.hintId&&(i.changeActive(e.hintId),i.pick())})),t.on(l,"click",(function(t){var n=r(l,t.target||t.srcElement);n&&null!=n.hintId&&(i.changeActive(n.hintId),e.options.completeOnSingleClick&&i.pick())})),t.on(l,"mousedown",(function(){setTimeout((function(){s.focus()}),20)}));var R=this.getSelectedHintRange();return 0===R.from&&0===R.to||this.scrollToActive(),t.signal(n,"select",u[this.selectedHint],l.childNodes[this.selectedHint]),!0}function a(t,e,n,i){if(t.async)t(e,i,n);else{var o=t(e,n);o&&o.then?o.then(i):i(o)}}e.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.tick=null,this.options.updateOnCursorActivity&&this.cm.off("cursorActivity",this.activityFunc),this.widget&&this.data&&t.signal(this.data,"close"),this.widget&&this.widget.close(),t.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(e,n){var i=e.list[n],r=this;this.cm.operation((function(){i.hint?i.hint(r.cm,e,i):r.cm.replaceRange(o(i),i.from||e.from,i.to||e.to,"complete"),t.signal(e,"pick",i),r.cm.scrollIntoView()})),this.options.closeOnPick&&this.close()},cursorActivity:function(){this.debounce&&(i(this.debounce),this.debounce=0);var t=this.startPos;this.data&&(t=this.data.from);var e=this.cm.getCursor(),o=this.cm.getLine(e.line);if(e.line!=this.startPos.line||o.length-e.ch!=this.startLen-this.startPos.ch||e.ch<t.ch||this.cm.somethingSelected()||!e.ch||this.options.closeCharacters.test(o.charAt(e.ch-1)))this.close();else{var r=this;this.debounce=n((function(){r.update()})),this.widget&&this.widget.disable()}},update:function(t){if(null!=this.tick){var e=this,n=++this.tick;a(this.options.hint,this.cm,this.options,(function(i){e.tick==n&&e.finishUpdate(i,t)}))}},finishUpdate:function(e,n){this.data&&t.signal(this.data,"update");var i=this.widget&&this.widget.picked||n&&this.options.completeSingle;this.widget&&this.widget.close(),this.data=e,e&&e.list.length&&(i&&1==e.list.length?this.pick(e,0):(this.widget=new s(this,e),t.signal(e,"shown")))}},s.prototype={close:function(){if(this.completion.widget==this){this.completion.widget=null,this.hints.parentNode&&this.hints.parentNode.removeChild(this.hints),this.completion.cm.removeKeyMap(this.keyMap);var t=this.completion.cm.getInputField();t.removeAttribute("aria-activedescendant"),t.removeAttribute("aria-owns");var 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 t=this;this.keyMap={Enter:function(){t.picked=!0}},this.completion.cm.addKeyMap(this.keyMap)},pick:function(){var t,e,n,i,o;i=rEdit.getCursor().ch,o=rEdit.getCursor().ch-this.data.list[0].length,1===i||0===i?e="":(e=" ".repeat(i-2),n=o>0?" ".repeat(o):""),isSame&&"Space"===nameKey?"If"===this.data.list[0]?this.data.list[0]=this.data.list[0]+" ":"Do"!=this.data.list[0]&&(this.data.list[0]=this.data.list[0]+" ",isSame=!1,t=0):isSame&&"Enter"===nameKey?("If"===this.data.list[0]?(this.data.list[0]=this.data.list[0]+" \n"+e+"Endif",t=1):"On"===this.data.list[0]?(this.data.list[0]=this.data.list[0]+" Do\n\nEndon",t=2):"Do"===this.data.list[0]?(this.data.list[0]=this.data.list[0]+"\n\nEndon",t=2.2):(this.data.list[0]=this.data.list[0]+"\n"+n,t=0),isSame=!1):isSame&&","===nameKey&&(this.data.list[0]=this.data.list[0]+",",t=0,isSame=!1),"LogEntry"===this.data.list[this.selectedHint]&&(this.data.list[this.selectedHint]=this.data.list[this.selectedHint]+",''",t=3),this.completion.pick(this.data,this.selectedHint);var r=rEdit.getCursor().line,s=rEdit.getCursor().ch;if(1===t)rEdit.setCursor({line:r-1});else if(2===t)for(rEdit.setCursor({line:r-1}),rEdit.execCommand("insertSoftTab"),rEdit.setCursor({line:r-2,ch:i+1});rEdit.getCursor().ch>3;)rEdit.execCommand("indentLess");else 2.2===t?(rEdit.setCursor({line:r-1}),rEdit.execCommand("insertSoftTab")):3===t&&rEdit.setCursor({line:r,ch:s-1})},changeActive:function(e,n){if(e>=this.data.list.length?e=n?this.data.list.length-1:0:e<0&&(e=n?0:this.data.list.length-1),this.selectedHint!=e){var i=this.hints.childNodes[this.selectedHint];i&&(i.className=i.className.replace(" CodeMirror-hint-active",""),i.removeAttribute("aria-selected")),(i=this.hints.childNodes[this.selectedHint=e]).className+=" CodeMirror-hint-active",i.setAttribute("aria-selected","true"),this.completion.cm.getInputField().setAttribute("aria-activedescendant",i.id),this.scrollToActive(),t.signal(this.data,"select",this.data.list[this.selectedHint],i)}},scrollToActive:function(){var t=this.getSelectedHintRange(),e=this.hints.childNodes[t.from],n=this.hints.childNodes[t.to],i=this.hints.firstChild;e.offsetTop<this.hints.scrollTop?this.hints.scrollTop=e.offsetTop-i.offsetTop:n.offsetTop+n.offsetHeight>this.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=n.offsetTop+n.offsetHeight-this.hints.clientHeight+i.offsetTop)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1},getSelectedHintRange:function(){var t=this.completion.options.scrollMargin||0;return{from:Math.max(0,this.selectedHint-t),to:Math.min(this.data.list.length-1,this.selectedHint+t)}}},t.registerHelper("hint","auto",{resolve:function(e,n){var i,o=e.getHelpers(n,"hint");if(o.length){var r=function(t,e,n){var i=function(t,e){if(!t.somethingSelected())return e;for(var n=[],i=0;i<e.length;i++)e[i].supportsSelection&&n.push(e[i]);return n}(t,o);!function o(r){if(r==i.length)return e(null);a(i[r],t,n,(function(t){t&&t.list.length>0?e(t):o(r+1)}))}(0)};return r.async=!0,r.supportsSelection=!0,r}return(i=e.getHelper(e.getCursor(),"hintWords"))?function(e){return t.hint.fromList(e,{words:i})}:t.hint.anyword?function(e,n){return t.hint.anyword(e,n)}:function(){}}}),t.registerHelper("hint","fromList",(function(e,n){var i,o=e.getCursor(),r=e.getTokenAt(o),s=t.Pos(o.line,r.start),a=o;r.start<o.ch&&/\w/.test(r.string.charAt(o.ch-r.start-1))?i=r.string.substr(0,o.ch-r.start):(i="",s=o);for(var c=[],l=0;l<n.words.length;l++){var h=n.words[l];h.slice(0,i.length)==i&&c.push(h)}if(c.length)return{list:c,from:s,to:a}})),t.commands.autocomplete=t.showHint;var c={hint:t.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[[\s=+*\-()\[\]{};:>]/,closeOnPick:!0,closeOnUnfocus:!0,updateOnCursorActivity:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null,paddingForScrollbar:!0,moveOnOverlap:!0};t.defineOption("hintOptions",null)})),function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],t):t(CodeMirror)}((function(t){"use strict";function e(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}function n(t){return t.state.search||(t.state.search=new e)}function i(t){return"string"==typeof t&&t==t.toLowerCase()}function o(t,e,n){return t.getSearchCursor(e,n,{caseFold:i(e),multiline:!0})}function r(t,e,n,i,o){t.openDialog?t.openDialog(e,o,{value:i,selectValueOnOpen:!0,bottom:t.options.search.bottom}):o(prompt(n,i))}function s(t){return t.replace(/\\([nrt\\])/g,(function(t,e){return"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"==e?"\\":t}))}function a(t){var e=t.match(/^\/(.*)\/([a-z]*)$/);if(e)try{t=new RegExp(e[1],-1==e[2].indexOf("i")?"":"i")}catch(t){}else t=s(t);return("string"==typeof t?""==t:t.test(""))&&(t=/x^/),t}function c(t,e,n){e.queryText=n,e.query=a(n),t.removeOverlay(e.overlay,i(e.query)),e.overlay=function(t,e){return"string"==typeof t?t=new RegExp(t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),e?"gi":"g"):t.global||(t=new RegExp(t.source,t.ignoreCase?"gi":"g")),{token:function(e){t.lastIndex=e.pos;var n=t.exec(e.string);if(n&&n.index==e.pos)return e.pos+=n[0].length||1,"searching";n?e.pos=n.index:e.skipToEnd()}}}(e.query,i(e.query)),t.addOverlay(e.overlay),t.showMatchesOnScrollbar&&(e.annotate&&(e.annotate.clear(),e.annotate=null),e.annotate=t.showMatchesOnScrollbar(e.query,i(e.query)))}function l(e,i,o,s){var a=n(e);if(a.query)return h(e,i);var l=e.getSelection()||a.lastQuery;if(l instanceof RegExp&&"x^"==l.source&&(l=null),o&&e.openDialog){var f=null,p=function(n,i){t.e_stop(i),n&&(n!=a.queryText&&(c(e,a,n),a.posFrom=a.posTo=e.getCursor()),f&&(f.style.opacity=1),h(e,i.shiftKey,(function(t,n){var i;n.line<3&&document.querySelector&&(i=e.display.wrapper.querySelector(".CodeMirror-dialog"))&&i.getBoundingClientRect().bottom-4>e.cursorCoords(n,"window").top&&((f=i).style.opacity=.4)})))};!function(t,e,n,i,o){t.openDialog(e,i,{value:n,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){u(t)},onKeyUp:o,bottom:t.options.search.bottom})}(e,d(e),l,p,(function(i,o){var r=t.keyName(i);"Enter"!=r&&o!=a.queryText&&(c(e,a,o),e.execCommand("goLineUp"),a.posFrom=a.posTo=e.getCursor(),h(e,i.shiftKey));var s=e.getOption("extraKeys"),l=s&&s[r]||t.keyMap[e.getOption("keyMap")][r];"findNext"==l||"findPrev"==l||"findPersistentNext"==l||"findPersistentPrev"==l?(t.e_stop(i),c(e,n(e),o),e.execCommand(l)):"find"!=l&&"findPersistent"!=l||(t.e_stop(i),p(o,i))})),s&&l&&(c(e,a,l),h(e,i))}else r(e,d(e),"Search for:",l,(function(t){t&&!a.query&&e.operation((function(){c(e,a,t),a.posFrom=a.posTo=e.getCursor(),h(e,i)}))}))}function h(e,i,r){e.operation((function(){const s=n(e);let a=o(e,s.query,i?s.posFrom:s.posTo);var c,l;(a.find(i)||(a=o(e,s.query,i?t.Pos(e.lastLine()):t.Pos(e.firstLine(),0)),a.find(i)))&&(c=a.from(),l=a.to(),e.__searchNextHighlight&&e.__searchNextHighlight.clear(),e.__searchNextHighlight=e.markText(c,l,{className:"search-next-highlight"}),e.setSelection(a.from(),a.to()),e.scrollTo(null,e.charCoords(a.from(),"local").top),s.posFrom=a.from(),s.posTo=a.to(),r&&r(a.from(),a.to()))}))}function u(t){t.operation((function(){var e=n(t);e.lastQuery=e.query,e.query&&(e.query=e.queryText=null,t.removeOverlay(e.overlay),e.annotate&&(e.annotate.clear(),e.annotate=null))}))}function f(t,e){var n=t?document.createElement(t):document.createDocumentFragment();for(var i in e)n[i]=e[i];for(var o=2;o<arguments.length;o++){var r=arguments[o];n.appendChild("string"==typeof r?document.createTextNode(r):r)}return n}function d(t){var e=f("label",{className:"CodeMirror-search-label"},t.phrase("Search:"),f("input",{type:"text",style:"width: 10em",className:"CodeMirror-search-field",id:"CodeMirror-search-field"}));return e.setAttribute("for","CodeMirror-search-field"),f("",null,e," ",f("span",{style:"color: #666",className:"CodeMirror-search-hint"},t.phrase("(Use /re/ syntax for regexp search)")))}function p(t,e,n){t.operation((function(){for(var i=o(t,e);i.findNext();)if("string"!=typeof e){var r=t.getRange(i.from(),i.to()).match(e);i.replace(n.replace(/\$(\d)/g,(function(t,e){return r[e]})))}else i.replace(n)}))}function m(t,e){if(!t.getOption("readOnly")){var i=t.getSelection()||n(t).lastQuery,c=e?t.phrase("Replace all:"):t.phrase("Replace:"),l=f("",null,f("span",{className:"CodeMirror-search-label"},c),function(t){return f("",null," ",f("input",{type:"text",style:"width: 10em",className:"CodeMirror-search-field"})," ",f("span",{style:"color: #666",className:"CodeMirror-search-hint"},t.phrase("(Use /re/ syntax for regexp search)")))}(t));r(t,l,c,i,(function(n){n&&(n=a(n),r(t,function(t){return f("",null,f("span",{className:"CodeMirror-search-label"},t.phrase("With:"))," ",f("input",{type:"text",style:"width: 10em",className:"CodeMirror-search-field"}))}(t),t.phrase("Replace with:"),"",(function(i){if(i=s(i),e)p(t,n,i);else{u(t);var r=o(t,n,t.getCursor("from")),a=function(){var e,s,l,h=r.from();!(e=r.findNext())&&(r=o(t,n),!(e=r.findNext())||h&&r.from().line==h.line&&r.from().ch==h.ch)||(t.setSelection(r.from(),r.to()),t.scrollTo(null,t.charCoords(r.from(),"local").top),s=r.from(),l=r.to(),t.__searchNextHighlight&&t.__searchNextHighlight.clear(),t.__searchNextHighlight=t.markText(s,l,{className:"search-next-highlight"}),function(t,e,n,i){t.openConfirm?t.openConfirm(e,i):confirm(n)&&i[0]()}(t,function(t){return f("",null,f("span",{className:"CodeMirror-search-label"},t.phrase("Replace?"))," ",f("button",{},t.phrase("Yes"))," ",f("button",{},t.phrase("No"))," ",f("button",{},t.phrase("All"))," ",f("button",{},t.phrase("Stop")))}(t),t.phrase("Replace?"),[function(){c(e)},a,function(){p(t,n,i)}]))},c=function(t){r.replace("string"==typeof n?i:i.replace(/\$(\d)/g,(function(e,n){return t[n]}))),a()};a()}})))}))}}t.defineOption("search",{bottom:!1}),t.commands.find=function(t){u(t),l(t)},t.commands.findPersistent=function(t){u(t),l(t,!1,!0)},t.commands.findPersistentNext=function(t){l(t,!1,!0,!0)},t.commands.findPersistentPrev=function(t){l(t,!0,!0,!0)},t.commands.findNext=l,t.commands.findPrev=function(t){l(t,!0)},t.commands.clearSearch=u,t.commands.replace=m,t.commands.replaceAll=function(t){m(t,!0)}})),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";var e,n,i=t.Pos;function o(t,e){for(var n=function(t){var e=t.flags;return null!=e?e:(t.ignoreCase?"i":"")+(t.global?"g":"")+(t.multiline?"m":"")}(t),i=n,o=0;o<e.length;o++)-1==i.indexOf(e.charAt(o))&&(i+=e.charAt(o));return n==i?t:new RegExp(t.source,i)}function r(t){return/\\s|\\n|\n|\\W|\\D|\[\^/.test(t.source)}function s(t,e,n){e=o(e,"g");for(var r=n.line,s=n.ch,a=t.lastLine();r<=a;r++,s=0){e.lastIndex=s;var c=t.getLine(r),l=e.exec(c);if(l)return{from:i(r,l.index),to:i(r,l.index+l[0].length),match:l}}}function a(t,e,n){if(!r(e))return s(t,e,n);e=o(e,"gm");for(var a,c=1,l=n.line,h=t.lastLine();l<=h;){for(var u=0;u<c&&!(l>h);u++){var f=t.getLine(l++);a=null==a?f:a+"\n"+f}c*=2,e.lastIndex=n.ch;var d=e.exec(a);if(d){var p=a.slice(0,d.index).split("\n"),m=d[0].split("\n"),g=n.line+p.length-1,v=p[p.length-1].length;return{from:i(g,v),to:i(g+m.length-1,1==m.length?v+m[0].length:m[m.length-1].length),match:d}}}}function c(t,e,n){for(var i,o=0;o<=t.length;){e.lastIndex=o;var r=e.exec(t);if(!r)break;var s=r.index+r[0].length;if(s>t.length-n)break;(!i||s>i.index+i[0].length)&&(i=r),o=r.index+1}return i}function l(t,e,n){e=o(e,"g");for(var r=n.line,s=n.ch,a=t.firstLine();r>=a;r--,s=-1){var l=t.getLine(r),h=c(l,e,s<0?0:l.length-s);if(h)return{from:i(r,h.index),to:i(r,h.index+h[0].length),match:h}}}function h(t,e,n){if(!r(e))return l(t,e,n);e=o(e,"gm");for(var s,a=1,h=t.getLine(n.line).length-n.ch,u=n.line,f=t.firstLine();u>=f;){for(var d=0;d<a&&u>=f;d++){var p=t.getLine(u--);s=null==s?p:p+"\n"+s}a*=2;var m=c(s,e,h);if(m){var g=s.slice(0,m.index).split("\n"),v=m[0].split("\n"),y=u+g.length,C=g[g.length-1].length;return{from:i(y,C),to:i(y+v.length-1,1==v.length?C+v[0].length:v[v.length-1].length),match:m}}}}function u(t,e,n,i){if(t.length==e.length)return n;for(var o=0,r=n+Math.max(0,t.length-e.length);;){if(o==r)return o;var s=o+r>>1,a=i(t.slice(0,s)).length;if(a==n)return s;a>n?r=s:o=s+1}}function f(t,o,r,s){if(!o.length)return null;var a=s?e:n,c=a(o).split(/\r|\n\r?/);t:for(var l=r.line,h=r.ch,f=t.lastLine()+1-c.length;l<=f;l++,h=0){var d=t.getLine(l).slice(h),p=a(d);if(1==c.length){var m=p.indexOf(c[0]);if(-1==m)continue t;r=u(d,p,m,a)+h;return{from:i(l,u(d,p,m,a)+h),to:i(l,u(d,p,m+c[0].length,a)+h)}}var g=p.length-c[0].length;if(p.slice(g)==c[0]){for(var v=1;v<c.length-1;v++)if(a(t.getLine(l+v))!=c[v])continue t;var y=t.getLine(l+c.length-1),C=a(y),x=c[c.length-1];if(C.slice(0,x.length)==x)return{from:i(l,u(d,p,g,a)+h),to:i(l+c.length-1,u(y,C,x.length,a))}}}}function d(t,o,r,s){if(!o.length)return null;var a=s?e:n,c=a(o).split(/\r|\n\r?/);t:for(var l=r.line,h=r.ch,f=t.firstLine()-1+c.length;l>=f;l--,h=-1){var d=t.getLine(l);h>-1&&(d=d.slice(0,h));var p=a(d);if(1==c.length){var m=p.lastIndexOf(c[0]);if(-1==m)continue t;return{from:i(l,u(d,p,m,a)),to:i(l,u(d,p,m+c[0].length,a))}}var g=c[c.length-1];if(p.slice(0,g.length)==g){var v=1;for(r=l-c.length+1;v<c.length-1;v++)if(a(t.getLine(r+v))!=c[v])continue t;var y=t.getLine(l+1-c.length),C=a(y);if(C.slice(C.length-c[0].length)==c[0])return{from:i(l+1-c.length,u(y,C,y.length-c[0].length,a)),to:i(l,u(d,p,g.length,a))}}}}function p(t,e,n,r){var c;this.atOccurrence=!1,this.afterEmptyMatch=!1,this.doc=t,n=n?t.clipPos(n):i(0,0),this.pos={from:n,to:n},"object"==typeof r?c=r.caseFold:(c=r,r=null),"string"==typeof e?(null==c&&(c=!1),this.matches=function(n,i){return(n?d:f)(t,e,i,c)}):(e=o(e,"gm"),r&&!1===r.multiline?this.matches=function(n,i){return(n?l:s)(t,e,i)}:this.matches=function(n,i){return(n?h:a)(t,e,i)})}String.prototype.normalize?(e=function(t){return t.normalize("NFD").toLowerCase()},n=function(t){return t.normalize("NFD")}):(e=function(t){return t.toLowerCase()},n=function(t){return t}),p.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(e){var n=this.doc.clipPos(e?this.pos.from:this.pos.to);if(this.afterEmptyMatch&&this.atOccurrence&&(n=i(n.line,n.ch),e?(n.ch--,n.ch<0&&(n.line--,n.ch=(this.doc.getLine(n.line)||"").length)):(n.ch++,n.ch>(this.doc.getLine(n.line)||"").length&&(n.ch=0,n.line++)),0!=t.cmpPos(n,this.doc.clipPos(n))))return this.atOccurrence=!1;var o=this.matches(e,n);if(this.afterEmptyMatch=o&&0==t.cmpPos(o.from,o.to),o)return this.pos=o,this.atOccurrence=!0,this.pos.match||!0;var r=i(e?this.doc.firstLine():this.doc.lastLine()+1,0);return this.pos={from:r,to:r},this.atOccurrence=!1},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(e,n){if(this.atOccurrence){var o=t.splitLines(e);this.doc.replaceRange(o,this.pos.from,this.pos.to,n),this.pos.to=i(this.pos.from.line+o.length-1,o[o.length-1].length+(1==o.length?this.pos.from.ch:0))}}},t.defineExtension("getSearchCursor",(function(t,e,n){return new p(this.doc,t,e,n)})),t.defineDocExtension("getSearchCursor",(function(t,e,n){return new p(this,t,e,n)})),t.defineExtension("selectMatches",(function(e,n){for(var i=[],o=this.getSearchCursor(e,this.getCursor("from"),n);o.findNext()&&!(t.cmpPos(o.to(),this.getCursor("to"))>0);)i.push({anchor:o.from(),head:o.to()});i.length&&this.setSelections(i,0)}))})),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){function e(e,n,i){var o,r=document.body;return(o=r.appendChild(document.createElement("div"))).className=i?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof n?o.innerHTML=n:o.appendChild(n),t.addClass(r,"dialog-opened"),o}function n(t,e){t.state.currentNotificationClose&&t.state.currentNotificationClose(),t.state.currentNotificationClose=e}t.defineExtension("openDialog",(function(i,o,r){r||(r={}),n(this,null);var s=e(0,i,r.bottom),a=!1,c=this;function l(e){if("string"==typeof e)u.value=e;else{if(a)return;a=!0,t.rmClass(s.parentNode,"dialog-opened"),s.parentNode.removeChild(s),c.focus(),r.onClose&&r.onClose(s)}}var h,u=s.getElementsByTagName("input")[0];return u?(u.focus(),r.value&&(u.value=r.value,!1!==r.selectValueOnOpen&&u.select()),r.onInput&&t.on(u,"input",(function(t){r.onInput(t,u.value,l)})),r.onKeyUp&&t.on(u,"keyup",(function(t){r.onKeyUp(t,u.value,l)})),t.on(u,"keydown",(function(e){r&&r.onKeyDown&&r.onKeyDown(e,u.value,l)||((27==e.keyCode||!1!==r.closeOnEnter&&13==e.keyCode)&&(u.blur(),t.e_stop(e),l()),13==e.keyCode&&o(u.value,e))})),!1!==r.closeOnBlur&&t.on(s,"focusout",(function(t){null!==t.relatedTarget&&l()}))):(h=s.getElementsByTagName("button")[0])&&(t.on(h,"click",(function(){l(),c.focus()})),!1!==r.closeOnBlur&&t.on(h,"blur",l),h.focus()),l})),t.defineExtension("openConfirm",(function(i,o,r){n(this,null);var s=e(0,i,r&&r.bottom),a=s.getElementsByTagName("button"),c=!1,l=this,h=1;function u(){c||(c=!0,t.rmClass(s.parentNode,"dialog-opened"),s.parentNode.removeChild(s),l.focus())}a[0].focus();for(var f=0;f<a.length;++f){var d=a[f];!function(e){t.on(d,"click",(function(n){t.e_preventDefault(n),u(),e&&e(l)}))}(o[f]),t.on(d,"blur",(function(){--h,setTimeout((function(){h<=0&&u()}),200)})),t.on(d,"focus",(function(){++h}))}})),t.defineExtension("openNotification",(function(i,o){n(this,l);var r,s=e(0,i,o&&o.bottom),a=!1,c=o&&void 0!==o.duration?o.duration:5e3;function l(){a||(a=!0,clearTimeout(r),t.rmClass(s.parentNode,"dialog-opened"),s.parentNode.removeChild(s))}return t.on(s,"click",(function(e){t.e_preventDefault(e),l()})),c&&(r=setTimeout(l,c)),l}))}));