diff --git a/media/editors/codemirror/addon/dialog/dialog.js b/media/editors/codemirror/addon/dialog/dialog.js index f10bb5bf190be..f61e447660a2b 100644 --- a/media/editors/codemirror/addon/dialog/dialog.js +++ b/media/editors/codemirror/addon/dialog/dialog.js @@ -25,6 +25,7 @@ } else { // Assuming it's a detached DOM element. dialog.appendChild(template); } + CodeMirror.addClass(wrap, 'dialog-opened'); return dialog; } @@ -47,6 +48,7 @@ } else { if (closed) return; closed = true; + CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); dialog.parentNode.removeChild(dialog); me.focus(); @@ -102,6 +104,7 @@ function close() { if (closed) return; closed = true; + CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); dialog.parentNode.removeChild(dialog); me.focus(); } @@ -141,6 +144,7 @@ if (closed) return; closed = true; clearTimeout(doneTimer); + CodeMirror.rmClass(dialog.parentNode, 'dialog-opened'); dialog.parentNode.removeChild(dialog); } diff --git a/media/editors/codemirror/addon/dialog/dialog.min.js b/media/editors/codemirror/addon/dialog/dialog.min.js index ae1d46430436a..da45989c4ae54 100644 --- a/media/editors/codemirror/addon/dialog/dialog.min.js +++ b/media/editors/codemirror/addon/dialog/dialog.min.js @@ -1 +1 @@ -!(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})((function(a){function b(a,b,c){var d,e=a.getWrapperElement();return d=e.appendChild(document.createElement("div")),c?d.className="CodeMirror-dialog CodeMirror-dialog-bottom":d.className="CodeMirror-dialog CodeMirror-dialog-top","string"==typeof b?d.innerHTML=b:d.appendChild(b),d}function c(a,b){a.state.currentNotificationClose&&a.state.currentNotificationClose(),a.state.currentNotificationClose=b}a.defineExtension("openDialog",(function(d,e,f){function g(a){if("string"==typeof a)l.value=a;else{if(j)return;j=!0,i.parentNode.removeChild(i),k.focus(),f.onClose&&f.onClose(i)}}f||(f={}),c(this,null);var h,i=b(this,d,f.bottom),j=!1,k=this,l=i.getElementsByTagName("input")[0];return l?(l.focus(),f.value&&(l.value=f.value,f.selectValueOnOpen!==!1&&l.select()),f.onInput&&a.on(l,"input",(function(a){f.onInput(a,l.value,g)})),f.onKeyUp&&a.on(l,"keyup",(function(a){f.onKeyUp(a,l.value,g)})),a.on(l,"keydown",(function(b){f&&f.onKeyDown&&f.onKeyDown(b,l.value,g)||((27==b.keyCode||f.closeOnEnter!==!1&&13==b.keyCode)&&(l.blur(),a.e_stop(b),g()),13==b.keyCode&&e(l.value,b))})),f.closeOnBlur!==!1&&a.on(l,"blur",g)):(h=i.getElementsByTagName("button")[0])&&(a.on(h,"click",(function(){g(),k.focus()})),f.closeOnBlur!==!1&&a.on(h,"blur",g),h.focus()),g})),a.defineExtension("openConfirm",(function(d,e,f){function g(){j||(j=!0,h.parentNode.removeChild(h),k.focus())}c(this,null);var h=b(this,d,f&&f.bottom),i=h.getElementsByTagName("button"),j=!1,k=this,l=1;i[0].focus();for(var m=0;mi.clientHeight+1,z=h.getScrollInfo();if(x>0){var A=w.bottom-w.top,B=q.top-(q.bottom-w.top);if(B-A>0)i.style.top=(s=q.top-A)+"px",t=!1;else if(A>v){i.style.height=v-5+"px",i.style.top=(s=q.bottom-w.top)+"px";var C=h.getCursor();c.from.ch!=C.ch&&(q=h.cursorCoords(C),i.style.left=(r=q.left)+"px",w=i.getBoundingClientRect())}}var D=w.right-u;if(D>0&&(w.right-w.left>u&&(i.style.width=u-5+"px",D-=w.right-w.left-u),i.style.left=(r=q.left-D)+"px"),y)for(var E=i.firstChild;E;E=E.nextSibling)E.style.paddingRight=h.display.nativeBarWidth+"px";if(h.addKeyMap(this.keyMap=e(b,{moveFocus:function(a,b){g.changeActive(g.selectedHint+a,b)},setFocus:function(a){g.changeActive(a)},menuSize:function(){return g.screenAmount()},length:j.length,close:function(){b.close()},pick:function(){g.pick()},data:c})),b.options.closeOnUnfocus){var F;h.on("blur",this.onBlur=function(){F=setTimeout((function(){b.close()}),100)}),h.on("focus",this.onFocus=function(){clearTimeout(F)})}return h.on("scroll",this.onScroll=function(){var a=h.getScrollInfo(),c=h.getWrapperElement().getBoundingClientRect(),d=s+z.top-a.top,e=d-(window.pageYOffset||(document.documentElement||document.body).scrollTop);return t||(e+=i.offsetHeight),e<=c.top||e>=c.bottom?b.close():(i.style.top=d+"px",void(i.style.left=r+z.left-a.left+"px"))}),a.on(i,"dblclick",(function(a){var b=f(i,a.target||a.srcElement);b&&null!=b.hintId&&(g.changeActive(b.hintId),g.pick())})),a.on(i,"click",(function(a){var c=f(i,a.target||a.srcElement);c&&null!=c.hintId&&(g.changeActive(c.hintId),b.options.completeOnSingleClick&&g.pick())})),a.on(i,"mousedown",(function(){setTimeout((function(){h.focus()}),20)})),a.signal(c,"select",j[this.selectedHint],i.childNodes[this.selectedHint]),!0}function h(a,b){if(!a.somethingSelected())return b;for(var c=[],d=0;d0?b(a):d(e+1)}))}var f=h(a,e);d(0)};return f.async=!0,f.supportsSelection=!0,f}return(d=b.getHelper(b.getCursor(),"hintWords"))?function(b){return a.hint.fromList(b,{words:d})}:a.hint.anyword?function(b,c){return a.hint.anyword(b,c)}:function(){}}var k="CodeMirror-hint",l="CodeMirror-hint-active";a.showHint=function(a,b,c){if(!b)return a.showHint(c);c&&c.async&&(b.async=!0);var d={hint:b};if(c)for(var e in c)d[e]=c[e];return a.showHint(d)},a.defineExtension("showHint",(function(d){d=c(this,this.getCursor("start"),d);var e=this.listSelections();if(!(e.length>1)){if(this.somethingSelected()){if(!d.hint.supportsSelection)return;for(var f=0;f=this.data.list.length?b=c?this.data.list.length-1:0:b<0&&(b=c?0:this.data.list.length-1),this.selectedHint!=b){var d=this.hints.childNodes[this.selectedHint];d.className=d.className.replace(" "+l,""),d=this.hints.childNodes[this.selectedHint=b],d.className+=" "+l,d.offsetTopthis.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=d.offsetTop+d.offsetHeight-this.hints.clientHeight+3),a.signal(this.data,"select",this.data.list[this.selectedHint],d)}},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},a.registerHelper("hint","auto",{resolve:j}),a.registerHelper("hint","fromList",(function(b,c){var d,e=b.getCursor(),f=b.getTokenAt(e),g=a.Pos(e.line,f.start),h=e;f.start,]/,closeOnUnfocus:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null};a.defineOption("hintOptions",null)})); \ No newline at end of file +!(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})((function(a){"use strict";function b(a,b){this.cm=a,this.options=b,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 c=this;a.on("cursorActivity",this.activityFunc=function(){c.cursorActivity()})}function c(a,b,c){var d=a.options.hintOptions,e={};for(var f in o)e[f]=o[f];if(d)for(var f in d)void 0!==d[f]&&(e[f]=d[f]);if(c)for(var f in c)void 0!==c[f]&&(e[f]=c[f]);return e.hint.resolve&&(e.hint=e.hint.resolve(a,b)),e}function d(a){return"string"==typeof a?a:a.text}function e(a,b){function c(a,c){var e;e="string"!=typeof c?function(a){return c(a,b)}:d.hasOwnProperty(c)?d[c]:c,f[a]=e}var d={Up:function(){b.moveFocus(-1)},Down:function(){b.moveFocus(1)},PageUp:function(){b.moveFocus(-b.menuSize()+1,!0)},PageDown:function(){b.moveFocus(b.menuSize()-1,!0)},Home:function(){b.setFocus(0)},End:function(){b.setFocus(b.length-1)},Enter:b.pick,Tab:b.pick,Esc:b.close},e=a.options.customKeys,f=e?{}:d;if(e)for(var g in e)e.hasOwnProperty(g)&&c(g,e[g]);var h=a.options.extraKeys;if(h)for(var g in h)h.hasOwnProperty(g)&&c(g,h[g]);return f}function f(a,b){for(;b&&b!=a;){if("LI"===b.nodeName.toUpperCase()&&b.parentNode==a)return b;b=b.parentNode}}function g(b,c){this.completion=b,this.data=c,this.picked=!1;var g=this,h=b.cm,i=this.hints=document.createElement("ul");i.className="CodeMirror-hints",this.selectedHint=c.selectedHint||0;for(var j=c.list,m=0;mi.clientHeight+1,z=h.getScrollInfo();if(x>0){var A=w.bottom-w.top,B=q.top-(q.bottom-w.top);if(B-A>0)i.style.top=(s=q.top-A)+"px",t=!1;else if(A>v){i.style.height=v-5+"px",i.style.top=(s=q.bottom-w.top)+"px";var C=h.getCursor();c.from.ch!=C.ch&&(q=h.cursorCoords(C),i.style.left=(r=q.left)+"px",w=i.getBoundingClientRect())}}var D=w.right-u;if(D>0&&(w.right-w.left>u&&(i.style.width=u-5+"px",D-=w.right-w.left-u),i.style.left=(r=q.left-D)+"px"),y)for(var E=i.firstChild;E;E=E.nextSibling)E.style.paddingRight=h.display.nativeBarWidth+"px";if(h.addKeyMap(this.keyMap=e(b,{moveFocus:function(a,b){g.changeActive(g.selectedHint+a,b)},setFocus:function(a){g.changeActive(a)},menuSize:function(){return g.screenAmount()},length:j.length,close:function(){b.close()},pick:function(){g.pick()},data:c})),b.options.closeOnUnfocus){var F;h.on("blur",this.onBlur=function(){F=setTimeout((function(){b.close()}),100)}),h.on("focus",this.onFocus=function(){clearTimeout(F)})}return h.on("scroll",this.onScroll=function(){var a=h.getScrollInfo(),c=h.getWrapperElement().getBoundingClientRect(),d=s+z.top-a.top,e=d-(window.pageYOffset||(document.documentElement||document.body).scrollTop);return t||(e+=i.offsetHeight),e<=c.top||e>=c.bottom?b.close():(i.style.top=d+"px",void(i.style.left=r+z.left-a.left+"px"))}),a.on(i,"dblclick",(function(a){var b=f(i,a.target||a.srcElement);b&&null!=b.hintId&&(g.changeActive(b.hintId),g.pick())})),a.on(i,"click",(function(a){var c=f(i,a.target||a.srcElement);c&&null!=c.hintId&&(g.changeActive(c.hintId),b.options.completeOnSingleClick&&g.pick())})),a.on(i,"mousedown",(function(){setTimeout((function(){h.focus()}),20)})),a.signal(c,"select",j[this.selectedHint],i.childNodes[this.selectedHint]),!0}function h(a,b){if(!a.somethingSelected())return b;for(var c=[],d=0;d0?b(a):d(e+1)}))}var f=h(a,e);d(0)};return f.async=!0,f.supportsSelection=!0,f}return(d=b.getHelper(b.getCursor(),"hintWords"))?function(b){return a.hint.fromList(b,{words:d})}:a.hint.anyword?function(b,c){return a.hint.anyword(b,c)}:function(){}}var k="CodeMirror-hint",l="CodeMirror-hint-active";a.showHint=function(a,b,c){if(!b)return a.showHint(c);c&&c.async&&(b.async=!0);var d={hint:b};if(c)for(var e in c)d[e]=c[e];return a.showHint(d)},a.defineExtension("showHint",(function(d){d=c(this,this.getCursor("start"),d);var e=this.listSelections();if(!(e.length>1)){if(this.somethingSelected()){if(!d.hint.supportsSelection)return;for(var f=0;f=this.data.list.length?b=c?this.data.list.length-1:0:b<0&&(b=c?0:this.data.list.length-1),this.selectedHint!=b){var d=this.hints.childNodes[this.selectedHint];d&&(d.className=d.className.replace(" "+l,"")),d=this.hints.childNodes[this.selectedHint=b],d.className+=" "+l,d.offsetTopthis.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=d.offsetTop+d.offsetHeight-this.hints.clientHeight+3),a.signal(this.data,"select",this.data.list[this.selectedHint],d)}},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},a.registerHelper("hint","auto",{resolve:j}),a.registerHelper("hint","fromList",(function(b,c){var d,e=b.getCursor(),f=b.getTokenAt(e),g=a.Pos(e.line,f.start),h=e;f.start,]/,closeOnUnfocus:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null};a.defineOption("hintOptions",null)})); \ No newline at end of file diff --git a/media/editors/codemirror/addon/lint/json-lint.js b/media/editors/codemirror/addon/lint/json-lint.js index 849641ee5e1c9..63e70c45955f9 100644 --- a/media/editors/codemirror/addon/lint/json-lint.js +++ b/media/editors/codemirror/addon/lint/json-lint.js @@ -23,6 +23,9 @@ CodeMirror.registerHelper("lint", "json", function(text) { } return found; } + // for jsonlint's web dist jsonlint is exported as an object with a single property parser, of which parseError + // is a subproperty + var jsonlint = window.jsonlint.parser || window.jsonlint jsonlint.parseError = function(str, hash) { var loc = hash.loc; found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column), diff --git a/media/editors/codemirror/addon/lint/json-lint.min.js b/media/editors/codemirror/addon/lint/json-lint.min.js index 8b29b49c845ed..c5c71e596133d 100644 --- a/media/editors/codemirror/addon/lint/json-lint.min.js +++ b/media/editors/codemirror/addon/lint/json-lint.min.js @@ -1 +1 @@ -!(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})((function(a){"use strict";a.registerHelper("lint","json",(function(b){var c=[];if(!window.jsonlint)return window.console&&window.console.error("Error: window.jsonlint not defined, CodeMirror JSON linting cannot run."),c;jsonlint.parseError=function(b,d){var e=d.loc;c.push({from:a.Pos(e.first_line-1,e.first_column),to:a.Pos(e.last_line-1,e.last_column),message:b})};try{jsonlint.parse(b)}catch(a){}return c}))})); \ No newline at end of file +!(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})((function(a){"use strict";a.registerHelper("lint","json",(function(b){var c=[];if(!window.jsonlint)return window.console&&window.console.error("Error: window.jsonlint not defined, CodeMirror JSON linting cannot run."),c;var d=window.jsonlint.parser||window.jsonlint;d.parseError=function(b,d){var e=d.loc;c.push({from:a.Pos(e.first_line-1,e.first_column),to:a.Pos(e.last_line-1,e.last_column),message:b})};try{d.parse(b)}catch(a){}return c}))})); \ No newline at end of file diff --git a/media/editors/codemirror/lib/codemirror.js b/media/editors/codemirror/lib/codemirror.js index 14e4bdebfda82..211af64f6b033 100644 --- a/media/editors/codemirror/lib/codemirror.js +++ b/media/editors/codemirror/lib/codemirror.js @@ -746,6 +746,16 @@ function collapsedSpanAtSide(line, start) { function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) } function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) } +function collapsedSpanAround(line, ch) { + var sps = sawCollapsedSpans && line.markedSpans, found; + if (sps) { for (var i = 0; i < sps.length; ++i) { + var sp = sps[i]; + if (sp.marker.collapsed && (sp.from == null || sp.from < ch) && (sp.to == null || sp.to > ch) && + (!found || compareCollapsedMarkers(found, sp.marker) < 0)) { found = sp.marker; } + } } + return found +} + // Test whether there exists a collapsed span that partially // overlaps (covers the start or end, but not both) of a new span. // Such overlap is not allowed. @@ -2780,12 +2790,11 @@ function coordsChar(cm, x, y) { var lineObj = getLine(doc, lineN); for (;;) { var found = coordsCharInner(cm, lineObj, lineN, x, y); - var merged = collapsedSpanAtEnd(lineObj); - var mergedPos = merged && merged.find(0, true); - if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0)) - { lineN = lineNo(lineObj = mergedPos.to.line); } - else - { return found } + var collapsed = collapsedSpanAround(lineObj, found.ch + (found.xRel > 0 ? 1 : 0)); + if (!collapsed) { return found } + var rangeEnd = collapsed.find(1); + if (rangeEnd.line == lineN) { return rangeEnd } + lineObj = getLine(doc, lineN = rangeEnd.line); } } @@ -3545,6 +3554,7 @@ var NativeScrollbars = function(place, scroll, cm) { this.cm = cm; var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar"); var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar"); + vert.tabIndex = horiz.tabIndex = -1; place(vert); place(horiz); on(vert, "scroll", function () { @@ -7488,7 +7498,7 @@ function leftButtonSelect(cm, event, start, behavior) { } var move = operation(cm, function (e) { - if (!e_button(e)) { done(e); } + if (e.buttons === 0 || !e_button(e)) { done(e); } else { extend(e); } }); var up = operation(cm, done); @@ -8767,8 +8777,12 @@ ContentEditableInput.prototype.showSelection = function (info, takeFocus) { this.showMultipleSelections(info); }; +ContentEditableInput.prototype.getSelection = function () { + return this.cm.display.wrapper.ownerDocument.getSelection() +}; + ContentEditableInput.prototype.showPrimarySelection = function () { - var sel = window.getSelection(), cm = this.cm, prim = cm.doc.sel.primary(); + var sel = this.getSelection(), cm = this.cm, prim = cm.doc.sel.primary(); var from = prim.from(), to = prim.to(); if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) { @@ -8835,13 +8849,13 @@ ContentEditableInput.prototype.showMultipleSelections = function (info) { }; ContentEditableInput.prototype.rememberSelection = function () { - var sel = window.getSelection(); + var sel = this.getSelection(); this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset; this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset; }; ContentEditableInput.prototype.selectionInEditor = function () { - var sel = window.getSelection(); + var sel = this.getSelection(); if (!sel.rangeCount) { return false } var node = sel.getRangeAt(0).commonAncestorContainer; return contains(this.div, node) @@ -8876,14 +8890,14 @@ ContentEditableInput.prototype.receivedFocus = function () { }; ContentEditableInput.prototype.selectionChanged = function () { - var sel = window.getSelection(); + var sel = this.getSelection(); return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset }; ContentEditableInput.prototype.pollSelection = function () { if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) { return } - var sel = window.getSelection(), cm = this.cm; + var sel = this.getSelection(), cm = this.cm; // On Android Chrome (version 56, at least), backspacing into an // uneditable block element will put the cursor in that element, // and then, because it's not editable, hide the virtual keyboard. @@ -9057,12 +9071,13 @@ function isInGutter(node) { function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos } function domTextBetween(cm, from, to, fromLine, toLine) { - var text = "", closing = false, lineSep = cm.doc.lineSeparator(); + var text = "", closing = false, lineSep = cm.doc.lineSeparator(), extraLinebreak = false; function recognizeMarker(id) { return function (marker) { return marker.id == id; } } function close() { if (closing) { text += lineSep; - closing = false; + if (extraLinebreak) { text += lineSep; } + closing = extraLinebreak = false; } } function addText(str) { @@ -9074,8 +9089,8 @@ function domTextBetween(cm, from, to, fromLine, toLine) { function walk(node) { if (node.nodeType == 1) { var cmText = node.getAttribute("cm-text"); - if (cmText != null) { - addText(cmText || node.textContent.replace(/\u200b/g, "")); + if (cmText) { + addText(cmText); return } var markerID = node.getAttribute("cm-marker"), range$$1; @@ -9086,19 +9101,24 @@ function domTextBetween(cm, from, to, fromLine, toLine) { return } if (node.getAttribute("contenteditable") == "false") { return } - var isBlock = /^(pre|div|p)$/i.test(node.nodeName); + var isBlock = /^(pre|div|p|li|table|br)$/i.test(node.nodeName); + if (!/^br$/i.test(node.nodeName) && node.textContent.length == 0) { return } + if (isBlock) { close(); } for (var i = 0; i < node.childNodes.length; i++) { walk(node.childNodes[i]); } + + if (/^(pre|p)$/i.test(node.nodeName)) { extraLinebreak = true; } if (isBlock) { closing = true; } } else if (node.nodeType == 3) { - addText(node.nodeValue); + addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " ")); } } for (;;) { walk(from); if (from == to) { break } from = from.nextSibling; + extraLinebreak = false; } return text } @@ -9670,7 +9690,7 @@ CodeMirror$1.fromTextArea = fromTextArea; addLegacyProps(CodeMirror$1); -CodeMirror$1.version = "5.37.0"; +CodeMirror$1.version = "5.38.0"; return CodeMirror$1; diff --git a/media/editors/codemirror/lib/codemirror.min.js b/media/editors/codemirror/lib/codemirror.min.js index a82889408a380..fa243f53ccbb5 100644 --- a/media/editors/codemirror/lib/codemirror.min.js +++ b/media/editors/codemirror/lib/codemirror.min.js @@ -1,6 +1,6 @@ -!(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.CodeMirror=b()})(this,(function(){"use strict";function a(a){return new RegExp("(^|\\s)"+a+"(?:$|\\s)\\s*")}function b(a){for(var b=a.childNodes.length;b>0;--b)a.removeChild(a.firstChild);return a}function c(a,c){return b(a).appendChild(c)}function d(a,b,c,d){var e=document.createElement(a);if(c&&(e.className=c),d&&(e.style.cssText=d),"string"==typeof b)e.appendChild(document.createTextNode(b));else if(b)for(var f=0;f=b)return g+(b-f);g+=h-f,g+=c-g%c,f=h+1}}function m(a,b){for(var c=0;c=b)return d+Math.min(g,b-e);if(e+=f-d,e+=c-e%c,d=f+1,e>=b)return d}}function o(a){for(;Wg.length<=a;)Wg.push(p(Wg)+" ");return Wg[a]}function p(a){return a[a.length-1]}function q(a,b){for(var c=[],d=0;d"€"&&(a.toUpperCase()!=a.toLowerCase()||Xg.test(a))}function v(a,b){return b?!!(b.source.indexOf("\\w")>-1&&u(a))||b.test(a):u(a)}function w(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function x(a){return a.charCodeAt(0)>=768&&Yg.test(a)}function y(a,b,c){for(;(c<0?b>0:bc?-1:1;;){if(b==c)return b;var e=(b+c)/2,f=d<0?Math.ceil(e):Math.floor(e);if(f==b)return a(f)?b:c;a(f)?c=f:b=f+d}}function A(a,b,c){var f=this;this.input=c,f.scrollbarFiller=d("div",null,"CodeMirror-scrollbar-filler"),f.scrollbarFiller.setAttribute("cm-not-content","true"),f.gutterFiller=d("div",null,"CodeMirror-gutter-filler"),f.gutterFiller.setAttribute("cm-not-content","true"),f.lineDiv=e("div",null,"CodeMirror-code"),f.selectionDiv=d("div",null,null,"position: relative; z-index: 1"),f.cursorDiv=d("div",null,"CodeMirror-cursors"),f.measure=d("div",null,"CodeMirror-measure"),f.lineMeasure=d("div",null,"CodeMirror-measure"),f.lineSpace=e("div",[f.measure,f.lineMeasure,f.selectionDiv,f.cursorDiv,f.lineDiv],null,"position: relative; outline: none");var g=e("div",[f.lineSpace],"CodeMirror-lines");f.mover=d("div",[g],null,"position: relative"),f.sizer=d("div",[f.mover],"CodeMirror-sizer"),f.sizerWidth=null,f.heightForcer=d("div",null,null,"position: absolute; height: "+Rg+"px; width: 1px;"),f.gutters=d("div",null,"CodeMirror-gutters"),f.lineGutter=null,f.scroller=d("div",[f.sizer,f.heightForcer,f.gutters],"CodeMirror-scroll"),f.scroller.setAttribute("tabIndex","-1"),f.wrapper=d("div",[f.scrollbarFiller,f.gutterFiller,f.scroller],"CodeMirror"),tg&&ug<8&&(f.gutters.style.zIndex=-1,f.scroller.style.paddingRight=0),vg||pg&&Eg||(f.scroller.draggable=!0),a&&(a.appendChild?a.appendChild(f.wrapper):a(f.wrapper)),f.viewFrom=f.viewTo=b.first,f.reportedViewFrom=f.reportedViewTo=b.first,f.view=[],f.renderedView=null,f.externalMeasured=null,f.viewOffset=0,f.lastWrapHeight=f.lastWrapWidth=0,f.updateLineNumbers=null,f.nativeBarWidth=f.barHeight=f.barWidth=0,f.scrollbarsClipped=!1,f.lineNumWidth=f.lineNumInnerWidth=f.lineNumChars=null,f.alignWidgets=!1,f.cachedCharWidth=f.cachedTextHeight=f.cachedPaddingH=null,f.maxLine=null,f.maxLineLength=0,f.maxLineChanged=!1,f.wheelDX=f.wheelDY=f.wheelStartX=f.wheelStartY=null,f.shift=!1,f.selForContextMenu=null,f.activeTouch=null,c.init(f)}function B(a,b){if(b-=a.first,b<0||b>=a.size)throw new Error("There is no line "+(b+a.first)+" in the document.");for(var c=a;!c.lines;)for(var d=0;;++d){var e=c.children[d],f=e.chunkSize();if(b=a.first&&bc?J(c,B(a,c).text.length):R(b,B(a,b.line).text.length)}function R(a,b){var c=a.ch;return null==c||c>b?J(a.line,b):c<0?J(a.line,0):a}function S(a,b){for(var c=[],d=0;d=b:f.to>b);(d||(d=[])).push(new V(g,f.from,i?null:f.to))}}return d}function $(a,b,c){var d;if(a)for(var e=0;e=b:f.to>b);if(h||f.from==b&&"bookmark"==g.type&&(!c||f.marker.insertLeft)){var i=null==f.from||(g.inclusiveLeft?f.from<=b:f.from0&&h)for(var v=0;v0)){var k=[i,1],l=K(j.from,h.from),n=K(j.to,h.to);(l<0||!g.inclusiveLeft&&!l)&&k.push({from:j.from,to:h.from}),(n>0||!g.inclusiveRight&&!n)&&k.push({from:h.to,to:j.to}),e.splice.apply(e,k),i+=k.length-3}}return e}function ca(a){var b=a.markedSpans;if(b){for(var c=0;c=0&&l<=0||k<=0&&l>=0)&&(k<=0&&(i.marker.inclusiveRight&&e.inclusiveLeft?K(j.to,c)>=0:K(j.to,c)>0)||k>=0&&(i.marker.inclusiveRight&&e.inclusiveLeft?K(j.from,d)<=0:K(j.from,d)<0)))return!0}}}function la(a){for(var b;b=ia(a);)a=b.find(-1,!0).line;return a}function ma(a){for(var b;b=ja(a);)a=b.find(1,!0).line;return a}function na(a){for(var b,c;b=ja(a);)a=b.find(1,!0).line,(c||(c=[])).push(a);return c}function oa(a,b){var c=B(a,b),d=la(c);return c==d?b:F(d)}function pa(a,b){if(b>a.lastLine())return b;var c,d=B(a,b);if(!qa(a,d))return b;for(;c=ja(d);)d=c.find(1,!0).line;return F(d)+1}function qa(a,b){var c=$g&&b.markedSpans;if(c)for(var d=void 0,e=0;eb.maxLineLength&&(b.maxLineLength=c,b.maxLine=a)}))}function va(a,b,c,d){if(!a)return d(b,c,"ltr",0);for(var e=!1,f=0;fb||b==c&&g.to==b)&&(d(Math.max(g.from,b),Math.min(g.to,c),1==g.level?"rtl":"ltr",f),e=!0)}e||d(b,c,"ltr")}function wa(a,b,c){var d;_g=null;for(var e=0;eb)return e;f.to==b&&(f.from!=f.to&&"before"==c?d=e:_g=e),f.from==b&&(f.from!=f.to&&"before"!=c?d=e:_g=e)}return null!=d?d:_g}function xa(a,b){var c=a.order;return null==c&&(c=a.order=ah(a.text,b)),c}function ya(a,b){return a._handlers&&a._handlers[b]||bh}function za(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,!1);else if(a.detachEvent)a.detachEvent("on"+b,c);else{var d=a._handlers,e=d&&d[b];if(e){var f=m(e,c);f>-1&&(d[b]=e.slice(0,f).concat(e.slice(f+1)))}}}function Aa(a,b){var c=ya(a,b);if(c.length)for(var d=Array.prototype.slice.call(arguments,2),e=0;e0}function Ea(a){a.prototype.on=function(a,b){ch(this,a,b)},a.prototype.off=function(a,b){za(this,a,b)}}function Fa(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function Ga(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}function Ha(a){return null!=a.defaultPrevented?a.defaultPrevented:0==a.returnValue}function Ia(a){Fa(a),Ga(a)}function Ja(a){return a.target||a.srcElement}function Ka(a){var b=a.which;return null==b&&(1&a.button?b=1:2&a.button?b=3:4&a.button&&(b=2)),Fg&&a.ctrlKey&&1==b&&(b=3),b}function La(a){if(null==Pg){var b=d("span","​");c(a,d("span",[b,document.createTextNode("x")])),0!=a.firstChild.offsetHeight&&(Pg=b.offsetWidth<=1&&b.offsetHeight>2&&!(tg&&ug<8))}var e=Pg?d("span","​"):d("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return e.setAttribute("cm-text",""),e}function Ma(a){if(null!=Qg)return Qg;var d=c(a,document.createTextNode("AخA")),e=Jg(d,0,1).getBoundingClientRect(),f=Jg(d,1,2).getBoundingClientRect();return b(a),!(!e||e.left==e.right)&&(Qg=f.right-e.right<3)}function Na(a){if(null!=hh)return hh;var b=c(a,d("span","x")),e=b.getBoundingClientRect(),f=Jg(b,0,1).getBoundingClientRect();return hh=Math.abs(e.left-f.left)>1}function Oa(a,b){arguments.length>2&&(b.dependencies=Array.prototype.slice.call(arguments,2)),ih[a]=b}function Pa(a,b){jh[a]=b}function Qa(a){if("string"==typeof a&&jh.hasOwnProperty(a))a=jh[a];else if(a&&"string"==typeof a.name&&jh.hasOwnProperty(a.name)){var b=jh[a.name];"string"==typeof b&&(b={name:b}),a=t(b,a),a.name=b.name}else{if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return Qa("application/xml");if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+json$/.test(a))return Qa("application/json")}return"string"==typeof a?{name:a}:a||{name:"null"}}function Ra(a,b){b=Qa(b);var c=ih[b.name];if(!c)return Ra(a,"text/plain");var d=c(a,b);if(kh.hasOwnProperty(b.name)){var e=kh[b.name];for(var f in e)e.hasOwnProperty(f)&&(d.hasOwnProperty(f)&&(d["_"+f]=d[f]),d[f]=e[f])}if(d.name=b.name,b.helperType&&(d.helperType=b.helperType),b.modeProps)for(var g in b.modeProps)d[g]=b.modeProps[g];return d}function Sa(a,b){var c=kh.hasOwnProperty(a)?kh[a]:kh[a]={};k(b,c)}function Ta(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c}function Ua(a,b){for(var c;a.innerMode&&(c=a.innerMode(b),c&&c.mode!=a);)b=c.state,a=c.mode;return c||{mode:a,state:b}}function Va(a,b,c){return!a.startState||a.startState(b,c)}function Wa(a,b,c,d){var e=[a.state.modeGen],f={};cb(a,b.text,a.doc.mode,c,(function(a,b){return e.push(a,b)}),f,d);for(var g=c.state,h=function(d){c.baseTokens=e;var h=a.state.overlays[d],i=1,j=0;c.state=!0,cb(a,b.text,h.mode,c,(function(a,b){for(var c=i;ja&&e.splice(i,1,a,e[i+1],d),i+=2,j=Math.min(a,d)}if(b)if(h.opaque)e.splice(c,i-c,a,"overlay "+b),i=c+2;else for(;ca.options.maxHighlightLength&&Ta(a.doc.mode,d.state),f=Wa(a,b,d);e&&(d.state=e),b.stateAfter=d.save(!e),b.styles=f.styles,f.classes?b.styleClasses=f.classes:b.styleClasses&&(b.styleClasses=null),c===a.doc.highlightFrontier&&(a.doc.modeFrontier=Math.max(a.doc.modeFrontier,++a.doc.highlightFrontier))}return b.styles}function Ya(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState)return new nh(d,!0,b);var f=db(a,b,c),g=f>d.first&&B(d,f-1).stateAfter,h=g?nh.fromSaved(d,g,f):new nh(d,Va(d.mode),f);return d.iter(f,b,(function(c){Za(a,c.text,h);var d=h.line;c.stateAfter=d==b-1||d%5==0||d>=e.viewFrom&&db.start)return f}throw new Error("Mode "+a.name+" failed to advance stream.")}function ab(a,b,c,d){var e,f=a.doc,g=f.mode;b=Q(f,b);var h,i=B(f,b.line),j=Ya(a,b.line,c),k=new lh(i.text,a.options.tabSize,j);for(d&&(h=[]);(d||k.posa.options.maxHighlightLength?(h=!1,g&&Za(a,b,d,l.pos),l.pos=b.length,i=null):i=bb(_a(c,l,d.state,m),f),m){var n=m[0].name;n&&(i="m-"+(i?n+" "+i:n))}if(!h||k!=i){for(;jg;--h){if(h<=f.first)return f.first;var i=B(f,h-1),j=i.stateAfter;if(j&&(!c||h+(j instanceof mh?j.lookAhead:0)<=f.modeFrontier))return h;var k=l(i.text,null,a.options.tabSize);(null==e||d>k)&&(e=h-1,d=k)}return e}function eb(a,b){if(a.modeFrontier=Math.min(a.modeFrontier,b),!(a.highlightFrontierc;d--){var e=B(a,d).stateAfter;if(e&&(!(e instanceof mh)||d+e.lookAhead1&&!/ /.test(a))return a;for(var c=b,d="",e=0;ej&&l.from<=j));m++);if(l.to>=k)return a(c,d,e,f,g,h,i);a(c,d.slice(0,l.to-j),e,f,null,h,i),f=null,d=d.slice(l.to-j),j=l.to}}}function nb(a,b,c,d){var e=!d&&c.widgetNode;e&&a.map.push(a.pos,a.pos+b,e),!d&&a.cm.display.input.needsContentAttribute&&(e||(e=a.content.appendChild(document.createElement("span"))),e.setAttribute("cm-marker",c.id)),e&&(a.cm.display.input.setUneditable(e),a.content.appendChild(e)),a.pos+=b,a.trailingSpace=!1}function ob(a,b,c){var d=a.markedSpans,e=a.text,f=0;if(d)for(var g,h,i,j,k,l,m,n=e.length,o=0,p=1,q="",r=0;;){if(r==o){i=j=k=l=h="",m=null,r=1/0;for(var s=[],t=void 0,u=0;uo||w.collapsed&&v.to==o&&v.from==o)?(null!=v.to&&v.to!=o&&r>v.to&&(r=v.to,j=""),w.className&&(i+=" "+w.className),w.css&&(h=(h?h+";":"")+w.css),w.startStyle&&v.from==o&&(k+=" "+w.startStyle),w.endStyle&&v.to==r&&(t||(t=[])).push(w.endStyle,v.to),w.title&&!l&&(l=w.title),w.collapsed&&(!m||ga(m.marker,w)<0)&&(m=v)):v.from>o&&r>v.from&&(r=v.from)}if(t)for(var x=0;x=n)break;for(var z=Math.min(n,r);;){if(q){var A=o+q.length;if(!m){var B=A>z?q.slice(0,z-o):q;b.addToken(b,B,g?g+i:i,k,o+B.length==r?j:"",l,h)}if(A>=z){q=q.slice(z-o),o=z;break}o=A,k=""}q=e.slice(f,f=c[p++]),g=hb(c[p++],b.cm.options)}}else for(var C=1;C2&&f.push((i.bottom+j.top)/2-c.top)}}f.push(c.bottom-c.top)}}function Rb(a,b,c){if(a.line==b)return{map:a.measure.map,cache:a.measure.cache};for(var d=0;dc)return{map:a.measure.maps[e],cache:a.measure.caches[e],before:!0}}function Sb(a,b){b=la(b);var d=F(b),e=a.display.externalMeasured=new pb(a.doc,b,d);e.lineN=d;var f=e.built=ib(a,e);return e.text=f.pre,c(a.display.lineMeasure,f.pre),e}function Tb(a,b,c,d){return Wb(a,Vb(a,b),c,d)}function Ub(a,b){if(b>=a.display.viewFrom&&b=c.lineN&&bb)&&(f=i-h,e=f-1,b>=i&&(g="right")),null!=e){if(d=a[j+2],h==i&&c==(d.insertLeft?"left":"right")&&(g=c),"left"==c&&0==e)for(;j&&a[j-2]==a[j-3]&&a[j-1].insertLeft;)d=a[(j-=3)+2],g="left";if("right"==c&&e==i-h)for(;j=0&&(c=a[e]).left==c.right;e--);return c}function Zb(a,b,c,d){var e,f=Xb(b.map,c,d),g=f.node,h=f.start,i=f.end,j=f.collapse; -if(3==g.nodeType){for(var k=0;k<4;k++){for(;h&&x(b.line.text.charAt(f.coverStart+h));)--h;for(;f.coverStart+i0&&(j=d="right");var l;e=a.options.lineWrapping&&(l=g.getClientRects()).length>1?l["right"==d?l.length-1:0]:g.getBoundingClientRect()}if(tg&&ug<9&&!h&&(!e||!e.left&&!e.right)){var m=g.parentNode.getClientRects()[0];e=m?{left:m.left,right:m.left+tc(a.display),top:m.top,bottom:m.bottom}:vh}for(var n=e.top-b.rect.top,o=e.bottom-b.rect.top,p=(n+o)/2,q=b.view.measure.heights,r=0;r=d.text.length?(j=d.text.length,k="before"):j<=0&&(j=0,k="after"),!i)return g("before"==k?j-1:j,"before"==k);var l=wa(i,j,k),m=_g,n=h(j,l,"before"==k);return null!=m&&(n.other=h(j,m,"before"!=k)),n}function jc(a,b){var c=0;b=Q(a.doc,b),a.options.lineWrapping||(c=tc(a.display)*b.ch);var d=B(a.doc,b.line),e=sa(d)+Kb(a.display);return{left:c,right:c,top:e,bottom:e+d.height}}function kc(a,b,c,d,e){var f=J(a,b,c);return f.xRel=e,d&&(f.outside=!0),f}function lc(a,b,c){var d=a.doc;if(c+=a.display.viewOffset,c<0)return kc(d.first,0,null,!0,-1);var e=G(d,c),f=d.first+d.size-1;if(e>f)return kc(d.first+d.size-1,B(d,f).text.length,null,!0,1);b<0&&(b=0);for(var g=B(d,e);;){var h=pc(a,g,e,b,c),i=ja(g),j=i&&i.find(0,!0);if(!i||!(h.ch>j.from.ch||h.ch==j.from.ch&&h.xRel>0))return h;e=F(g=j.to.line)}}function mc(a,b,c,d){d-=ec(b);var e=b.text.length,f=z((function(b){return Wb(a,c,b-1).bottom<=d}),e,0);return e=z((function(b){return Wb(a,c,b).top>d}),f,e),{begin:f,end:e}}function nc(a,b,c,d){c||(c=Vb(a,b));var e=fc(a,b,Wb(a,c,d),"line").top;return mc(a,b,c,e)}function oc(a,b,c,d){return!(a.bottom<=c)&&(a.top>c||(d?a.left:a.right)>b)}function pc(a,b,c,d,e){e-=sa(b);var f=Vb(a,b),g=ec(b),h=0,i=b.text.length,j=!0,k=xa(b,a.doc.direction);if(k){var l=(a.options.lineWrapping?rc:qc)(a,b,c,f,k,d,e);j=1!=l.level,h=j?l.from:l.to-1,i=j?l.to:l.from-1}var m,n,o=null,p=null,q=z((function(b){var c=Wb(a,f,b);return c.top+=g,c.bottom+=g,!!oc(c,d,e,!1)&&(c.top<=e&&c.left<=d&&(o=b,p=c),!0)}),h,i),r=!1;if(p){var s=d-p.left=u.bottom}return q=y(b.text,q,1),kc(c,q,n,r,d-m)}function qc(a,b,c,d,e,f,g){var h=z((function(h){var i=e[h],j=1!=i.level;return oc(ic(a,J(c,j?i.to:i.from,j?"before":"after"),"line",b,d),f,g,!0)}),0,e.length-1),i=e[h];if(h>0){var j=1!=i.level,k=ic(a,J(c,j?i.from:i.to,j?"after":"before"),"line",b,d);oc(k,f,g,!0)&&k.top>g&&(i=e[h-1])}return i}function rc(a,b,c,d,e,f,g){var h=mc(a,b,d,g),i=h.begin,j=h.end;/\s/.test(b.text.charAt(j-1))&&j--;for(var k=null,l=null,m=0;m=j||n.to<=i)){var o=1!=n.level,p=Wb(a,d,o?Math.min(j,n.to)-1:Math.max(i,n.from)).right,q=pq)&&(k=n,l=q)}}return k||(k=e[e.length-1]),k.fromj&&(k={from:k.from,to:j,level:k.level}),k}function sc(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==qh){qh=d("pre");for(var e=0;e<49;++e)qh.appendChild(document.createTextNode("x")),qh.appendChild(d("br"));qh.appendChild(document.createTextNode("x"))}c(a.measure,qh);var f=qh.offsetHeight/50;return f>3&&(a.cachedTextHeight=f),b(a.measure),f||1}function tc(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=d("span","xxxxxxxxxx"),e=d("pre",[b]);c(a.measure,e);var f=b.getBoundingClientRect(),g=(f.right-f.left)/10;return g>2&&(a.cachedCharWidth=g),g||10}function uc(a){for(var b=a.display,c={},d={},e=b.gutters.clientLeft,f=b.gutters.firstChild,g=0;f;f=f.nextSibling,++g)c[a.options.gutters[g]]=f.offsetLeft+f.clientLeft+e,d[a.options.gutters[g]]=f.clientWidth;return{fixedPos:vc(b),gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,wrapperWidth:b.wrapper.clientWidth}}function vc(a){return a.scroller.getBoundingClientRect().left-a.sizer.getBoundingClientRect().left}function wc(a){var b=sc(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/tc(a.display)-3);return function(e){if(qa(a.doc,e))return 0;var f=0;if(e.widgets)for(var g=0;g=a.display.viewTo)return null;if(b-=a.display.viewFrom,b<0)return null;for(var c=a.display.view,d=0;d=a.display.viewTo||h.to().line0?b.blinker=setInterval((function(){return b.cursorDiv.style.visibility=(c=!c)?"":"hidden"}),a.options.cursorBlinkRate):a.options.cursorBlinkRate<0&&(b.cursorDiv.style.visibility="hidden")}}function Gc(a){a.state.focused||(a.display.input.focus(),Ic(a))}function Hc(a){a.state.delayingBlurEvent=!0,setTimeout((function(){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1,Jc(a))}),100)}function Ic(a,b){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1),"nocursor"!=a.options.readOnly&&(a.state.focused||(Aa(a,"focus",a,b),a.state.focused=!0,h(a.display.wrapper,"CodeMirror-focused"),a.curOp||a.display.selForContextMenu==a.doc.sel||(a.display.input.reset(),vg&&setTimeout((function(){return a.display.input.reset(!0)}),20)),a.display.input.receivedFocus()),Fc(a))}function Jc(a,b){a.state.delayingBlurEvent||(a.state.focused&&(Aa(a,"blur",a,b),a.state.focused=!1,Mg(a.display.wrapper,"CodeMirror-focused")),clearInterval(a.display.blinker),setTimeout((function(){a.state.focused||(a.display.shift=!1)}),150))}function Kc(a){for(var b=a.display,c=b.lineDiv.offsetTop,d=0;d.005||i<-.005)&&(E(e.line,f),Lc(e.line),e.rest))for(var j=0;j=g&&(f=G(b,sa(B(b,i))-a.wrapper.clientHeight),g=i)}return{from:f,to:Math.max(g,f+1)}}function Nc(a){var b=a.display,c=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var d=vc(b)-b.scroller.scrollLeft+a.doc.scrollLeft,e=b.gutters.offsetWidth,f=d+"px",g=0;g(window.innerHeight||document.documentElement.clientHeight)&&(f=!1),null!=f&&!Bg){var g=d("div","​",null,"position: absolute;\n top: "+(b.top-c.viewOffset-Kb(a.display))+"px;\n height: "+(b.bottom-b.top+Nb(a)+c.barHeight)+"px;\n left: "+b.left+"px; width: "+Math.max(2,b.right-b.left)+"px;");a.display.lineSpace.appendChild(g),g.scrollIntoView(f),a.display.lineSpace.removeChild(g)}}}function Qc(a,b,c,d){null==d&&(d=0);var e;a.options.lineWrapping||b!=c||(b=b.ch?J(b.line,"before"==b.sticky?b.ch-1:b.ch,"after"):b,c="before"==b.sticky?J(b.line,b.ch+1,"before"):b);for(var f=0;f<5;f++){var g=!1,h=ic(a,b),i=c&&c!=b?ic(a,c):h;e={left:Math.min(h.left,i.left),top:Math.min(h.top,i.top)-d,right:Math.max(h.left,i.left),bottom:Math.max(h.bottom,i.bottom)+d};var j=Sc(a,e),k=a.doc.scrollTop,l=a.doc.scrollLeft;if(null!=j.scrollTop&&(Zc(a,j.scrollTop),Math.abs(a.doc.scrollTop-k)>1&&(g=!0)),null!=j.scrollLeft&&(_c(a,j.scrollLeft),Math.abs(a.doc.scrollLeft-l)>1&&(g=!0)),!g)break}return e}function Rc(a,b){var c=Sc(a,b);null!=c.scrollTop&&Zc(a,c.scrollTop),null!=c.scrollLeft&&_c(a,c.scrollLeft)}function Sc(a,b){var c=a.display,d=sc(a.display);b.top<0&&(b.top=0);var e=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:c.scroller.scrollTop,f=Pb(a),g={};b.bottom-b.top>f&&(b.bottom=b.top+f);var h=a.doc.height+Lb(c),i=b.toph-d;if(b.tope+f){var k=Math.min(b.top,(j?h:b.bottom)-f);k!=e&&(g.scrollTop=k)}var l=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft:c.scroller.scrollLeft,m=Ob(a)-(a.options.fixedGutter?c.gutters.offsetWidth:0),n=b.right-b.left>m;return n&&(b.right=b.left+m),b.left<10?g.scrollLeft=0:b.leftm+l-3&&(g.scrollLeft=b.right+(n?0:10)-m),g}function Tc(a,b){null!=b&&(Xc(a),a.curOp.scrollTop=(null==a.curOp.scrollTop?a.doc.scrollTop:a.curOp.scrollTop)+b)}function Uc(a){Xc(a);var b=a.getCursor();a.curOp.scrollToPos={from:b,to:b,margin:a.options.cursorScrollMargin}}function Vc(a,b,c){null==b&&null==c||Xc(a),null!=b&&(a.curOp.scrollLeft=b),null!=c&&(a.curOp.scrollTop=c)}function Wc(a,b){Xc(a),a.curOp.scrollToPos=b}function Xc(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=jc(a,b.from),d=jc(a,b.to);Yc(a,c,d,b.margin)}}function Yc(a,b,c,d){var e=Sc(a,{left:Math.min(b.left,c.left),top:Math.min(b.top,c.top)-d,right:Math.max(b.right,c.right),bottom:Math.max(b.bottom,c.bottom)+d});Vc(a,e.scrollLeft,e.scrollTop)}function Zc(a,b){Math.abs(a.doc.scrollTop-b)<2||(pg||Dd(a,{top:b}),$c(a,b,!0),pg&&Dd(a),wd(a,100))}function $c(a,b,c){b=Math.min(a.display.scroller.scrollHeight-a.display.scroller.clientHeight,b),(a.display.scroller.scrollTop!=b||c)&&(a.doc.scrollTop=b,a.display.scrollbars.setScrollTop(b),a.display.scroller.scrollTop!=b&&(a.display.scroller.scrollTop=b))}function _c(a,b,c,d){b=Math.min(b,a.display.scroller.scrollWidth-a.display.scroller.clientWidth),(c?b==a.doc.scrollLeft:Math.abs(a.doc.scrollLeft-b)<2)&&!d||(a.doc.scrollLeft=b,Nc(a),a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft=b),a.display.scrollbars.setScrollLeft(b))}function ad(a){var b=a.display,c=b.gutters.offsetWidth,d=Math.round(a.doc.height+Lb(a.display));return{clientHeight:b.scroller.clientHeight,viewHeight:b.wrapper.clientHeight,scrollWidth:b.scroller.scrollWidth,clientWidth:b.scroller.clientWidth,viewWidth:b.wrapper.clientWidth,barLeft:a.options.fixedGutter?c:0,docHeight:d,scrollHeight:d+Nb(a)+b.barHeight,nativeBarWidth:b.nativeBarWidth,gutterWidth:c}}function bd(a,b){b||(b=ad(a));var c=a.display.barWidth,d=a.display.barHeight;cd(a,b);for(var e=0;e<4&&c!=a.display.barWidth||d!=a.display.barHeight;e++)c!=a.display.barWidth&&a.options.lineWrapping&&Kc(a),cd(a,ad(a)),c=a.display.barWidth,d=a.display.barHeight}function cd(a,b){var c=a.display,d=c.scrollbars.update(b);c.sizer.style.paddingRight=(c.barWidth=d.right)+"px",c.sizer.style.paddingBottom=(c.barHeight=d.bottom)+"px",c.heightForcer.style.borderBottom=d.bottom+"px solid transparent",d.right&&d.bottom?(c.scrollbarFiller.style.display="block",c.scrollbarFiller.style.height=d.bottom+"px",c.scrollbarFiller.style.width=d.right+"px"):c.scrollbarFiller.style.display="",d.bottom&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(c.gutterFiller.style.display="block",c.gutterFiller.style.height=d.bottom+"px",c.gutterFiller.style.width=b.gutterWidth+"px"):c.gutterFiller.style.display=""}function dd(a){a.display.scrollbars&&(a.display.scrollbars.clear(),a.display.scrollbars.addClass&&Mg(a.display.wrapper,a.display.scrollbars.addClass)),a.display.scrollbars=new yh[a.options.scrollbarStyle](function(b){a.display.wrapper.insertBefore(b,a.display.scrollbarFiller),ch(b,"mousedown",(function(){a.state.focused&&setTimeout((function(){return a.display.input.focus()}),0)})),b.setAttribute("cm-not-content","true")},function(b,c){"horizontal"==c?_c(a,b):Zc(a,b)},a),a.display.scrollbars.addClass&&h(a.display.wrapper,a.display.scrollbars.addClass)}function ed(a){a.curOp={cm:a,viewChanged:!1,startHeight:a.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++zh},rb(a.curOp)}function fd(a){var b=a.curOp;tb(b,(function(a){for(var b=0;b=c.viewTo)||c.maxLineChanged&&b.options.lineWrapping,a.update=a.mustUpdate&&new Ah(b,a.mustUpdate&&{top:a.scrollTop,ensure:a.scrollToPos},a.forceUpdate)}function id(a){a.updatedDisplay=a.mustUpdate&&Bd(a.cm,a.update)}function jd(a){var b=a.cm,c=b.display;a.updatedDisplay&&Kc(b),a.barMeasure=ad(b),c.maxLineChanged&&!b.options.lineWrapping&&(a.adjustWidthTo=Tb(b,c.maxLine,c.maxLine.text.length).left+3,b.display.sizerWidth=a.adjustWidthTo,a.barMeasure.scrollWidth=Math.max(c.scroller.clientWidth,c.sizer.offsetLeft+a.adjustWidthTo+Nb(b)+b.display.barWidth),a.maxScrollLeft=Math.max(0,c.sizer.offsetLeft+a.adjustWidthTo-Ob(b))),(a.updatedDisplay||a.selectionChanged)&&(a.preparedSelection=c.input.prepareSelection())}function kd(a){var b=a.cm;null!=a.adjustWidthTo&&(b.display.sizer.style.minWidth=a.adjustWidthTo+"px",a.maxScrollLeftb)&&(e.updateLineNumbers=b),a.curOp.viewChanged=!0,b>=e.viewTo)$g&&oa(a.doc,b)e.viewFrom?sd(a):(e.viewFrom+=d,e.viewTo+=d);else if(b<=e.viewFrom&&c>=e.viewTo)sd(a);else if(b<=e.viewFrom){var f=td(a,c,c+d,1);f?(e.view=e.view.slice(f.index),e.viewFrom=f.lineN,e.viewTo+=d):sd(a)}else if(c>=e.viewTo){var g=td(a,b,b,-1);g?(e.view=e.view.slice(0,g.index),e.viewTo=g.lineN):sd(a)}else{var h=td(a,b,b,-1),i=td(a,c,c+d,1);h&&i?(e.view=e.view.slice(0,h.index).concat(qb(a,h.lineN,i.lineN)).concat(e.view.slice(i.index)),e.viewTo+=d):sd(a)}var j=e.externalMeasured;j&&(c=e.lineN&&b=d.viewTo)){var f=d.view[zc(a,b)];if(null!=f.node){var g=f.changes||(f.changes=[]);m(g,c)==-1&&g.push(c)}}}function sd(a){a.display.viewFrom=a.display.viewTo=a.doc.first,a.display.view=[],a.display.viewOffset=0}function td(a,b,c,d){var e,f=zc(a,b),g=a.display.view;if(!$g||c==a.doc.first+a.doc.size)return{index:f,lineN:c};for(var h=a.display.viewFrom,i=0;i0){if(f==g.length-1)return null;e=h+g[f].size-b,f++}else e=h-b;b+=e,c+=e}for(;oa(a.doc,c)!=c;){if(f==(d<0?0:g.length-1))return null;c+=d*g[f-(d<0?1:0)].size,f+=d}return{index:f,lineN:c}}function ud(a,b,c){var d=a.display,e=d.view;0==e.length||b>=d.viewTo||c<=d.viewFrom?(d.view=qb(a,b,c),d.viewFrom=b):(d.viewFrom>b?d.view=qb(a,b,d.viewFrom).concat(d.view):d.viewFromc&&(d.view=d.view.slice(0,zc(a,c)))),d.viewTo=c}function vd(a){for(var b=a.display.view,c=0,d=0;d=a.display.viewTo)){var c=+new Date+a.options.workTime,d=Ya(a,b.highlightFrontier),e=[];b.iter(d.line,Math.min(b.first+b.size,a.display.viewTo+500),(function(f){if(d.line>=a.display.viewFrom){var g=f.styles,h=f.text.length>a.options.maxHighlightLength?Ta(b.mode,d.state):null,i=Wa(a,f,d,!0);h&&(d.state=h),f.styles=i.styles;var j=f.styleClasses,k=i.classes;k?f.styleClasses=k:j&&(f.styleClasses=null);for(var l=!g||g.length!=f.styles.length||j!=k&&(!j||!k||j.bgClass!=k.bgClass||j.textClass!=k.textClass),m=0;!l&&mc)return wd(a,a.options.workDelay),!0})),b.highlightFrontier=d.line,b.modeFrontier=Math.max(b.modeFrontier,d.line),e.length&&md(a,(function(){for(var b=0;b=d.viewFrom&&c.visible.to<=d.viewTo&&(null==d.updateLineNumbers||d.updateLineNumbers>=d.viewTo)&&d.renderedView==d.view&&0==vd(a))return!1;Oc(a)&&(sd(a),c.dims=uc(a));var f=e.first+e.size,g=Math.max(c.visible.from-a.options.viewportMargin,e.first),h=Math.min(f,c.visible.to+a.options.viewportMargin);d.viewFromh&&d.viewTo-h<20&&(h=Math.min(f,d.viewTo)),$g&&(g=oa(a.doc,g),h=pa(a.doc,h));var i=g!=d.viewFrom||h!=d.viewTo||d.lastWrapHeight!=c.wrapperHeight||d.lastWrapWidth!=c.wrapperWidth;ud(a,g,h),d.viewOffset=sa(B(a.doc,d.viewFrom)),a.display.mover.style.top=d.viewOffset+"px";var j=vd(a);if(!i&&0==j&&!c.force&&d.renderedView==d.view&&(null==d.updateLineNumbers||d.updateLineNumbers>=d.viewTo))return!1;var k=zd(a);return j>4&&(d.lineDiv.style.display="none"),Ed(a,d.updateLineNumbers,c.dims),j>4&&(d.lineDiv.style.display=""),d.renderedView=d.view,Ad(k),b(d.cursorDiv),b(d.selectionDiv),d.gutters.style.height=d.sizer.style.minHeight=0,i&&(d.lastWrapHeight=c.wrapperHeight,d.lastWrapWidth=c.wrapperWidth,wd(a,400)),d.updateLineNumbers=null,!0}function Cd(a,b){for(var c=b.viewport,d=!0;(d&&a.options.lineWrapping&&b.oldDisplayWidth!=Ob(a)||(c&&null!=c.top&&(c={top:Math.min(a.doc.height+Lb(a.display)-Pb(a),c.top)}),b.visible=Mc(a.display,a.doc,c),!(b.visible.from>=a.display.viewFrom&&b.visible.to<=a.display.viewTo)))&&Bd(a,b);d=!1){Kc(a);var e=ad(a);Ac(a),bd(a,e),Gd(a,e),b.force=!1}b.signal(a,"update",a),a.display.viewFrom==a.display.reportedViewFrom&&a.display.viewTo==a.display.reportedViewTo||(b.signal(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo),a.display.reportedViewFrom=a.display.viewFrom,a.display.reportedViewTo=a.display.viewTo)}function Dd(a,b){var c=new Ah(a,b);if(Bd(a,c)){Kc(a),Cd(a,c);var d=ad(a);Ac(a),bd(a,d),Gd(a,d),c.finish()}}function Ed(a,c,d){function e(b){var c=b.nextSibling;return vg&&Fg&&a.display.currentWheelTarget==b?b.style.display="none":b.parentNode.removeChild(b),c}for(var f=a.display,g=a.options.lineNumbers,h=f.lineDiv,i=h.firstChild,j=f.view,k=f.viewFrom,l=0;l-1&&(o=!1),wb(a,n,k,d)),o&&(b(n.lineNumber),n.lineNumber.appendChild(document.createTextNode(I(a.options,k)))),i=n.node.nextSibling}else{var p=Eb(a,n,k,d);h.insertBefore(p,i)}k+=n.size}for(;i;)i=e(i)}function Fd(a){var b=a.display.gutters.offsetWidth;a.display.sizer.style.marginLeft=b+"px"}function Gd(a,b){a.display.sizer.style.minHeight=b.docHeight+"px",a.display.heightForcer.style.top=b.docHeight+"px",a.display.gutters.style.height=b.docHeight+a.display.barHeight+Nb(a)+"px"}function Hd(a){var c=a.display.gutters,e=a.options.gutters;b(c);for(var f=0;f-1&&!a.lineNumbers&&(a.gutters=a.gutters.slice(0),a.gutters.splice(b,1))}function Jd(a){var b=a.wheelDeltaX,c=a.wheelDeltaY;return null==b&&a.detail&&a.axis==a.HORIZONTAL_AXIS&&(b=a.detail),null==c&&a.detail&&a.axis==a.VERTICAL_AXIS?c=a.detail:null==c&&(c=a.wheelDelta),{x:b,y:c}}function Kd(a){var b=Jd(a);return b.x*=Ch,b.y*=Ch,b}function Ld(a,b){var c=Jd(b),d=c.x,e=c.y,f=a.display,g=f.scroller,h=g.scrollWidth>g.clientWidth,i=g.scrollHeight>g.clientHeight;if(d&&h||e&&i){if(e&&Fg&&vg)a:for(var j=b.target,k=f.view;j!=g;j=j.parentNode)for(var l=0;l=0){var g=O(f.from(),e.from()),h=N(f.to(),e.to()),i=f.empty()?e.from()==e.head:f.from()==f.head;d<=b&&--b,a.splice(--d,2,new Eh(i?h:g,i?g:h))}}return new Dh(a,b)}function Nd(a,b){return new Dh([new Eh(a,b||a)],0)}function Od(a){return a.text?J(a.from.line+a.text.length-1,p(a.text).length+(1==a.text.length?a.from.ch:0)):a.to}function Pd(a,b){if(K(a,b.from)<0)return a;if(K(a,b.to)<=0)return Od(b);var c=a.line+b.text.length-(b.to.line-b.from.line)-1,d=a.ch;return a.line==b.to.line&&(d+=Od(b).ch-b.to.ch),J(c,d)}function Qd(a,b){for(var c=[],d=0;d1&&a.remove(h.line+1,o-1),a.insert(h.line+1,s)}ub(a,"change",a,b)}function Xd(a,b,c){function d(a,e,f){if(a.linked)for(var g=0;g1&&!a.done[a.done.length-2].ranges?(a.done.pop(),p(a.done)):void 0}function de(a,b,c,d){var e=a.history;e.undone.length=0;var f,g,h=+new Date;if((e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&e.lastModTime>h-(a.cm?a.cm.options.historyEventDelay:500)||"*"==b.origin.charAt(0)))&&(f=ce(e,e.lastOp==d)))g=p(f.changes),0==K(b.from,b.to)&&0==K(b.from,g.to)?g.to=Od(b):f.changes.push(ae(a,b));else{var i=p(e.done);for(i&&i.ranges||ge(a.sel,e.done),f={changes:[ae(a,b)],generation:e.generation},e.done.push(f);e.done.length>e.undoDepth;)e.done.shift(),e.done[0].ranges||e.done.shift()}e.done.push(c),e.generation=++e.maxGeneration,e.lastModTime=e.lastSelTime=h,e.lastOp=e.lastSelOp=d,e.lastOrigin=e.lastSelOrigin=b.origin,g||Aa(a,"historyAdded")}function ee(a,b,c,d){var e=b.charAt(0);return"*"==e||"+"==e&&c.ranges.length==d.ranges.length&&c.somethingSelected()==d.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}function fe(a,b,c,d){var e=a.history,f=d&&d.origin;c==e.lastSelOp||f&&e.lastSelOrigin==f&&(e.lastModTime==e.lastSelTime&&e.lastOrigin==f||ee(a,f,p(e.done),b))?e.done[e.done.length-1]=b:ge(b,e.done),e.lastSelTime=+new Date,e.lastSelOrigin=f,e.lastSelOp=c,d&&d.clearRedo!==!1&&be(e.undone)}function ge(a,b){var c=p(b);c&&c.ranges&&c.equals(a)||b.push(a)}function he(a,b,c,d){var e=b["spans_"+a.id],f=0;a.iter(Math.max(a.first,c),Math.min(a.first+a.size,d),(function(c){c.markedSpans&&((e||(e=b["spans_"+a.id]={}))[f]=c.markedSpans),++f}))}function ie(a){if(!a)return null;for(var b,c=0;c-1&&(p(h)[l]=j[l],delete j[l])}}}return d}function me(a,b,c,d){if(d){var e=a.anchor;if(c){var f=K(b,e)<0;f!=K(c,e)<0?(e=b,b=c):f!=K(b,c)<0&&(b=c)}return new Eh(e,b)}return new Eh(c||b,b)}function ne(a,b,c,d,e){null==e&&(e=a.cm&&(a.cm.display.shift||a.extend)),te(a,new Dh([me(a.sel.primary(),b,c,e)],0),d)}function oe(a,b,c){for(var d=[],e=a.cm&&(a.cm.display.shift||a.extend),f=0;f=b.ch:h.to>b.ch))){if(e&&(Aa(i,"beforeCursorEnter"),i.explicitlyCleared)){if(f.markedSpans){--g;continue}break}if(!i.atomic)continue;if(c){var j=i.find(d<0?1:-1),k=void 0;if((d<0?i.inclusiveRight:i.inclusiveLeft)&&(j=Ae(a,j,-d,j&&j.line==b.line?f:null)),j&&j.line==b.line&&(k=K(j,c))&&(d<0?k<0:k>0))return ye(a,j,b,d,e)}var l=i.find(d<0?-1:1);return(d<0?i.inclusiveLeft:i.inclusiveRight)&&(l=Ae(a,l,d,l.line==b.line?f:null)),l?ye(a,l,b,d,e):null}}return b}function ze(a,b,c,d,e){var f=d||1,g=ye(a,b,c,f,e)||!e&&ye(a,b,c,f,!0)||ye(a,b,c,-f,e)||!e&&ye(a,b,c,-f,!0);return g?g:(a.cantEdit=!0,J(a.first,0))}function Ae(a,b,c,d){return c<0&&0==b.ch?b.line>a.first?Q(a,J(b.line-1)):null:c>0&&b.ch==(d||B(a,b.line)).text.length?b.line=0;--e)Ee(a,{from:d[e].from,to:d[e].to,text:e?[""]:b.text,origin:b.origin});else Ee(a,b)}}function Ee(a,b){if(1!=b.text.length||""!=b.text[0]||0!=K(b.from,b.to)){var c=Qd(a,b);de(a,b,c,a.cm?a.cm.curOp.id:NaN),He(a,b,c,_(a,b));var d=[];Xd(a,(function(a,c){c||m(d,a.history)!=-1||(Me(a.history,b),d.push(a.history)),He(a,b,null,_(a,b))}))}}function Fe(a,b,c){var d=a.cm&&a.cm.state.suppressEdits;if(!d||c){for(var e,f=a.history,g=a.sel,h="undo"==b?f.done:f.undone,i="undo"==b?f.undone:f.done,j=0;j=0;--o){var q=n(o);if(q)return q.v}}}}function Ge(a,b){if(0!=b&&(a.first+=b,a.sel=new Dh(q(a.sel.ranges,(function(a){return new Eh(J(a.anchor.line+b,a.anchor.ch),J(a.head.line+b,a.head.ch))})),a.sel.primIndex),a.cm)){qd(a.cm,a.first,a.first-b,b);for(var c=a.cm.display,d=c.viewFrom;da.lastLine())){if(b.from.linef&&(b={from:b.from,to:J(f,B(a,f).text.length),text:[b.text[0]],origin:b.origin}),b.removed=C(a,b.from,b.to),c||(c=Qd(a,b)),a.cm?Ie(a.cm,b,d):Wd(a,b,d),ue(a,c,Tg)}}function Ie(a,b,c){var d=a.doc,e=a.display,f=b.from,g=b.to,h=!1,i=f.line;a.options.lineWrapping||(i=F(la(B(d,f.line))),d.iter(i,g.line+1,(function(a){if(a==e.maxLine)return h=!0,!0}))),d.sel.contains(b.from,b.to)>-1&&Ca(a),Wd(d,b,c,wc(a)),a.options.lineWrapping||(d.iter(i,f.line+b.text.length,(function(a){var b=ta(a);b>e.maxLineLength&&(e.maxLine=a,e.maxLineLength=b,e.maxLineChanged=!0,h=!1)})),h&&(a.curOp.updateMaxLine=!0)),eb(d,f.line),wd(a,400);var j=b.text.length-(g.line-f.line)-1;b.full?qd(a):f.line!=g.line||1!=b.text.length||Vd(a.doc,b)?qd(a,f.line,g.line+1,j):rd(a,f.line,"text");var k=Da(a,"changes"),l=Da(a,"change");if(l||k){var m={from:f,to:g,text:b.text,removed:b.removed,origin:b.origin};l&&ub(a,"change",a,m),k&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(m)}a.display.selForContextMenu=null}function Je(a,b,c,d,e){if(d||(d=c),K(d,c)<0){var f;f=[d,c],c=f[0],d=f[1]}"string"==typeof b&&(b=a.splitLines(b)),De(a,{from:c,to:d,text:b,origin:e})}function Ke(a,b,c,d){c0||0==h&&g.clearWhenEmpty!==!1)return g;if(g.replacedWith&&(g.collapsed=!0,g.widgetNode=e("span",[g.replacedWith],"CodeMirror-widget"),d.handleMouseEvents||g.widgetNode.setAttribute("cm-ignore-events","true"),d.insertLeft&&(g.widgetNode.insertLeft=!0)),g.collapsed){if(ka(a,b.line,b,c,g)||b.line!=c.line&&ka(a,c.line,b,c,g))throw new Error("Inserting collapsed marker partially overlapping an existing one");U()}g.addToHistory&&de(a,{from:b,to:c,origin:"markText"},a.sel,NaN);var i,j=b.line,l=a.cm;if(a.iter(j,c.line+1,(function(a){l&&g.collapsed&&!l.options.lineWrapping&&la(a)==l.display.maxLine&&(i=!0),g.collapsed&&j!=b.line&&E(a,0),Y(a,new V(g,j==b.line?b.ch:null,j==c.line?c.ch:null)),++j})),g.collapsed&&a.iter(b.line,c.line+1,(function(b){qa(a,b)&&E(b,0)})),g.clearOnEnter&&ch(g,"beforeCursorEnter",(function(){return g.clear()})),g.readOnly&&(T(),(a.history.done.length||a.history.undone.length)&&a.clearHistory()),g.collapsed&&(g.id=++Gh,g.atomic=!0),l){if(i&&(l.curOp.updateMaxLine=!0),g.collapsed)qd(l,b.line,c.line+1);else if(g.className||g.title||g.startStyle||g.endStyle||g.css)for(var m=b.line;m<=c.line;m++)rd(l,m,"text");g.atomic&&we(l.doc),ub(l,"markerAdded",l,g)}return g}function Te(a,b,c,d,e){d=k(d),d.shared=!1;var f=[Se(a,b,c,d,e)],g=f[0],h=d.widgetNode;return Xd(a,(function(a){h&&(d.widgetNode=h.cloneNode(!0)),f.push(Se(a,Q(a,b),Q(a,c),d,e));for(var i=0;i-1)return b.state.draggingText(a),void setTimeout((function(){return b.display.input.focus()}),20);try{var j=a.dataTransfer.getData("Text");if(j){var k;if(b.state.draggingText&&!b.state.draggingText.copy&&(k=b.listSelections()),ue(b.doc,Nd(c,c)),k)for(var l=0;l=0;b--)Je(a.doc,"",d[b].from,d[b].to,"+delete");Uc(a)}))}function mf(a,b,c){var d=y(a.text,b+c,c);return d<0||d>a.text.length?null:d}function nf(a,b,c){var d=mf(a,b.ch,c);return null==d?null:new J(b.line,d,c<0?"after":"before")}function of(a,b,c,d,e){if(a){var f=xa(c,b.doc.direction);if(f){var g,h=e<0?p(f):f[0],i=e<0==(1==h.level),j=i?"after":"before";if(h.level>0||"rtl"==b.doc.direction){var k=Vb(b,c);g=e<0?c.text.length-1:0;var l=Wb(b,k,g).top;g=z((function(a){return Wb(b,k,a).top==l}),e<0==(1==h.level)?h.from:h.to-1,g),"before"==j&&(g=mf(c,g,1))}else g=e<0?h.to:h.from;return new J(d,g,j)}}return new J(d,e<0?c.text.length:0,e<0?"before":"after")}function pf(a,b,c,d){var e=xa(b,a.doc.direction);if(!e)return nf(b,c,d);c.ch>=b.text.length?(c.ch=b.text.length,c.sticky="before"):c.ch<=0&&(c.ch=0,c.sticky="after");var f=wa(e,c.ch,c.sticky),g=e[f];if("ltr"==a.doc.direction&&g.level%2==0&&(d>0?g.to>c.ch:g.from=g.from&&m>=k.begin)){var n=l?"before":"after";return new J(c.line,m,n)}}var o=function(a,b,d){for(var f=function(a,b){return b?new J(c.line,i(a,1),"before"):new J(c.line,a,"after")};a>=0&&a0==(1!=g.level),j=h?d.begin:i(d.end,-1);if(g.from<=j&&j0?k.end:i(k.begin,-1);return null==q||d>0&&q==b.text.length||!(p=o(d>0?0:e.length-1,d,j(q)))?null:p}function qf(a,b){var c=B(a.doc,b),d=la(c);return d!=c&&(b=F(d)),of(!0,a,d,b,1)}function rf(a,b){var c=B(a.doc,b),d=ma(c);return d!=c&&(b=F(d)),of(!0,a,c,b,-1)}function sf(a,b){var c=qf(a,b.line),d=B(a.doc,c.line),e=xa(d,a.doc.direction);if(!e||0==e[0].level){var f=Math.max(0,d.text.search(/\S/)),g=b.line==c.line&&b.ch<=f&&b.ch;return J(c.line,g?0:f,c.sticky)}return c}function tf(a,b,c){if("string"==typeof b&&(b=Sh[b],!b))return!1;a.display.input.ensurePolled();var d=a.display.shift,e=!1;try{a.isReadOnly()&&(a.state.suppressEdits=!0),c&&(a.display.shift=!1),e=b(a)!=Sg}finally{a.display.shift=d,a.state.suppressEdits=!1}return e}function uf(a,b,c){for(var d=0;d-1&&(K((e=h.ranges[e]).from(),b)<0||b.xRel>0)&&(K(e.to(),b)>0||b.xRel<0)?If(a,d,b,f):Kf(a,d,b,f)}function If(a,b,c,d){var e=a.display,f=!1,g=nd(a,(function(b){vg&&(e.scroller.draggable=!1),a.state.draggingText=!1,za(e.wrapper.ownerDocument,"mouseup",g),za(e.wrapper.ownerDocument,"mousemove",h),za(e.scroller,"dragstart",i),za(e.scroller,"drop",g),f||(Fa(b),d.addNew||ne(a.doc,c,null,null,d.extend),vg||tg&&9==ug?setTimeout((function(){e.wrapper.ownerDocument.body.focus(),e.input.focus()}),20):e.input.focus())})),h=function(a){f=f||Math.abs(b.clientX-a.clientX)+Math.abs(b.clientY-a.clientY)>=10},i=function(){return f=!0};vg&&(e.scroller.draggable=!0),a.state.draggingText=g,g.copy=!d.moveOnDrag,e.scroller.dragDrop&&e.scroller.dragDrop(),ch(e.wrapper.ownerDocument,"mouseup",g),ch(e.wrapper.ownerDocument,"mousemove",h),ch(e.scroller,"dragstart",i),ch(e.scroller,"drop",g),Hc(a),setTimeout((function(){return e.input.focus()}),20)}function Jf(a,b,c){if("char"==c)return new Eh(b,b);if("word"==c)return a.findWordAt(b);if("line"==c)return new Eh(J(b.line,0),Q(a.doc,J(b.line+1,0)));var d=c(a,b);return new Eh(d.from,d.to)}function Kf(a,b,c,d){function e(b){if(0!=K(r,b))if(r=b,"rectangle"==d.unit){for(var e=[],f=a.options.tabSize,g=l(B(j,c.line).text,c.ch,f),h=l(B(j,b.line).text,b.ch,f),i=Math.min(g,h),p=Math.max(g,h),q=Math.min(c.line,b.line),s=Math.min(a.lastLine(),Math.max(c.line,b.line));q<=s;q++){var t=B(j,q).text,u=n(t,i,f);i==p?e.push(new Eh(J(q,u),J(q,u))):t.length>u&&e.push(new Eh(J(q,u),J(q,n(t,p,f))))}e.length||e.push(new Eh(c,c)),te(j,Md(o.ranges.slice(0,m).concat(e),m),{origin:"*mouse",scroll:!1}),a.scrollIntoView(b)}else{var v,w=k,x=Jf(a,b,d.unit),y=w.anchor;K(x.anchor,y)>0?(v=x.head,y=O(w.from(),x.anchor)):(v=x.anchor,y=N(w.to(),x.head));var z=o.ranges.slice(0);z[m]=Lf(a,new Eh(Q(j,y),v)),te(j,Md(z,m),Ug)}}function f(b){var c=++t,h=yc(a,b,!0,"rectangle"==d.unit);if(h)if(0!=K(h,r)){a.curOp.focus=g(),e(h);var k=Mc(i,j);(h.line>=k.to||h.lines.bottom?20:0;l&&setTimeout(nd(a,(function(){t==c&&(i.scroller.scrollTop+=l,f(b))})),50)}}function h(b){a.state.selectingText=!1,t=1/0,Fa(b),i.input.focus(),za(i.wrapper.ownerDocument,"mousemove",u),za(i.wrapper.ownerDocument,"mouseup",v),j.history.lastSelOrigin=null}var i=a.display,j=a.doc;Fa(b);var k,m,o=j.sel,p=o.ranges;if(d.addNew&&!d.extend?(m=j.sel.contains(c),k=m>-1?p[m]:new Eh(c,c)):(k=j.sel.primary(),m=j.sel.primIndex),"rectangle"==d.unit)d.addNew||(k=new Eh(c,c)),c=yc(a,b,!0,!0),m=-1;else{var q=Jf(a,c,d.unit);k=d.extend?me(k,q.anchor,q.head,d.extend):q}d.addNew?m==-1?(m=p.length,te(j,Md(p.concat([k]),m),{scroll:!1,origin:"*mouse"})):p.length>1&&p[m].empty()&&"char"==d.unit&&!d.extend?(te(j,Md(p.slice(0,m).concat(p.slice(m+1)),0),{scroll:!1,origin:"*mouse"}),o=j.sel):pe(j,m,k,Ug):(m=0,te(j,new Dh([k],0),Ug),o=j.sel);var r=c,s=i.wrapper.getBoundingClientRect(),t=0,u=nd(a,(function(a){Ka(a)?f(a):h(a)})),v=nd(a,h);a.state.selectingText=v,ch(i.wrapper.ownerDocument,"mousemove",u),ch(i.wrapper.ownerDocument,"mouseup",v)}function Lf(a,b){var c=b.anchor,d=b.head,e=B(a.doc,c.line);if(0==K(c,d)&&c.sticky==d.sticky)return b;var f=xa(e);if(!f)return b;var g=wa(f,c.ch,c.sticky),h=f[g];if(h.from!=c.ch&&h.to!=c.ch)return b;var i=g+(h.from==c.ch==(1!=h.level)?0:1);if(0==i||i==f.length)return b;var j;if(d.line!=c.line)j=(d.line-c.line)*("ltr"==a.doc.direction?1:-1)>0;else{var k=wa(f,d.ch,d.sticky),l=k-g||(d.ch-c.ch)*(1==h.level?-1:1);j=k==i-1||k==i?l<0:l>0}var m=f[i+(j?-1:0)],n=j==(1==m.level),o=n?m.from:m.to,p=n?"after":"before";return c.ch==o&&c.sticky==p?b:new Eh(new J(c.line,o,p),d)}function Mf(a,b,c,d){var e,f;if(b.touches)e=b.touches[0].clientX,f=b.touches[0].clientY;else try{e=b.clientX,f=b.clientY}catch(a){return!1}if(e>=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;d&&Fa(b);var g=a.display,h=g.lineDiv.getBoundingClientRect();if(f>h.bottom||!Da(a,c))return Ha(b);f-=h.top-g.viewOffset;for(var i=0;i=e){var k=G(a.doc,f),l=a.options.gutters[i];return Aa(a,c,a,k,l,b),Ha(b)}}}function Nf(a,b){return Mf(a,b,"gutterClick",!0)}function Of(a,b){Jb(a.display,b)||Pf(a,b)||Ba(a,b,"contextmenu")||a.display.input.onContextMenu(b)}function Pf(a,b){return!!Da(a,"gutterContextMenu")&&Mf(a,b,"gutterContextMenu",!1)}function Qf(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-"),bc(a)}function Rf(a){function b(b,d,e,f){a.defaults[b]=d,e&&(c[b]=f?function(a,b,c){c!=Zh&&e(a,b,c)}:e)}var c=a.optionHandlers;a.defineOption=b,a.Init=Zh,b("value","",(function(a,b){return a.setValue(b)}),!0),b("mode",null,(function(a,b){a.doc.modeOption=b,Td(a)}),!0),b("indentUnit",2,Td,!0),b("indentWithTabs",!1),b("smartIndent",!0),b("tabSize",4,(function(a){Ud(a),bc(a),qd(a)}),!0),b("lineSeparator",null,(function(a,b){if(a.doc.lineSep=b,b){var c=[],d=a.doc.first;a.doc.iter((function(a){for(var e=0;;){var f=a.text.indexOf(b,e);if(f==-1)break;e=f+b.length,c.push(J(d,f))}d++}));for(var e=c.length-1;e>=0;e--)Je(a.doc,b,c[e],J(c[e].line,c[e].ch+b.length))}})),b("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,(function(a,b,c){a.state.specialChars=new RegExp(b.source+(b.test("\t")?"":"|\t"),"g"),c!=Zh&&a.refresh()})),b("specialCharPlaceholder",jb,(function(a){return a.refresh()}),!0),b("electricChars",!0),b("inputStyle",Eg?"contenteditable":"textarea",(function(){throw new Error("inputStyle can not (yet) be changed in a running editor")}),!0),b("spellcheck",!1,(function(a,b){return a.getInputField().spellcheck=b}),!0),b("rtlMoveVisually",!Hg),b("wholeLineUpdateBefore",!0),b("theme","default",(function(a){Qf(a),Sf(a)}),!0),b("keyMap","default",(function(a,b,c){var d=kf(b),e=c!=Zh&&kf(c);e&&e.detach&&e.detach(a,d),d.attach&&d.attach(a,e||null)})),b("extraKeys",null),b("configureMouse",null),b("lineWrapping",!1,Uf,!0),b("gutters",[],(function(a){Id(a.options),Sf(a)}),!0),b("fixedGutter",!0,(function(a,b){a.display.gutters.style.left=b?vc(a.display)+"px":"0",a.refresh()}),!0),b("coverGutterNextToScrollbar",!1,(function(a){return bd(a)}),!0),b("scrollbarStyle","native",(function(a){dd(a),bd(a),a.display.scrollbars.setScrollTop(a.doc.scrollTop),a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)}),!0),b("lineNumbers",!1,(function(a){Id(a.options),Sf(a)}),!0),b("firstLineNumber",1,Sf,!0),b("lineNumberFormatter",(function(a){return a}),Sf,!0),b("showCursorWhenSelecting",!1,Ac,!0),b("resetSelectionOnContextMenu",!0),b("lineWiseCopyCut",!0),b("pasteLinesPerSelection",!0),b("readOnly",!1,(function(a,b){"nocursor"==b&&(Jc(a),a.display.input.blur()),a.display.input.readOnlyChanged(b)})),b("disableInput",!1,(function(a,b){b||a.display.input.reset()}),!0),b("dragDrop",!0,Tf),b("allowDropFileTypes",null),b("cursorBlinkRate",530),b("cursorScrollMargin",0),b("cursorHeight",1,Ac,!0),b("singleCursorHeightPerLine",!0,Ac,!0),b("workTime",100),b("workDelay",100),b("flattenSpans",!0,Ud,!0), -b("addModeClass",!1,Ud,!0),b("pollInterval",100),b("undoDepth",200,(function(a,b){return a.doc.history.undoDepth=b})),b("historyEventDelay",1250),b("viewportMargin",10,(function(a){return a.refresh()}),!0),b("maxHighlightLength",1e4,Ud,!0),b("moveInputWithCursor",!0,(function(a,b){b||a.display.input.resetPosition()})),b("tabindex",null,(function(a,b){return a.display.input.getField().tabIndex=b||""})),b("autofocus",null),b("direction","ltr",(function(a,b){return a.doc.setDirection(b)}),!0)}function Sf(a){Hd(a),qd(a),Nc(a)}function Tf(a,b,c){var d=c&&c!=Zh;if(!b!=!d){var e=a.display.dragFunctions,f=b?ch:za;f(a.display.scroller,"dragstart",e.start),f(a.display.scroller,"dragenter",e.enter),f(a.display.scroller,"dragover",e.over),f(a.display.scroller,"dragleave",e.leave),f(a.display.scroller,"drop",e.drop)}}function Uf(a){a.options.lineWrapping?(h(a.display.wrapper,"CodeMirror-wrap"),a.display.sizer.style.minWidth="",a.display.sizerWidth=null):(Mg(a.display.wrapper,"CodeMirror-wrap"),ua(a)),xc(a),qd(a),bc(a),setTimeout((function(){return bd(a)}),100)}function Vf(a,b){var c=this;if(!(this instanceof Vf))return new Vf(a,b);this.options=b=b?k(b):{},k($h,b,!1),Id(b);var d=b.value;"string"==typeof d&&(d=new Kh(d,b.mode,null,b.lineSeparator,b.direction)),this.doc=d;var e=new Vf.inputStyles[b.inputStyle](this),f=this.display=new A(a,d,e);f.wrapper.CodeMirror=this,Hd(this),Qf(this),b.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),dd(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Og,keySeq:null,specialChars:null},b.autofocus&&!Eg&&f.input.focus(),tg&&ug<11&&setTimeout((function(){return c.display.input.reset(!0)}),20),Wf(this),af(),ed(this),this.curOp.forceUpdate=!0,Yd(this,d),b.autofocus&&!Eg||this.hasFocus()?setTimeout(j(Ic,this),20):Jc(this);for(var g in _h)_h.hasOwnProperty(g)&&_h[g](c,b[g],Zh);Oc(this),b.finishInit&&b.finishInit(this);for(var h=0;h400}var e=a.display;ch(e.scroller,"mousedown",nd(a,Ef)),tg&&ug<11?ch(e.scroller,"dblclick",nd(a,(function(b){if(!Ba(a,b)){var c=yc(a,b);if(c&&!Nf(a,b)&&!Jb(a.display,b)){Fa(b);var d=a.findWordAt(c);ne(a.doc,d.anchor,d.head)}}}))):ch(e.scroller,"dblclick",(function(b){return Ba(a,b)||Fa(b)})),Lg||ch(e.scroller,"contextmenu",(function(b){return Of(a,b)}));var f,g={end:0};ch(e.scroller,"touchstart",(function(b){if(!Ba(a,b)&&!c(b)&&!Nf(a,b)){e.input.ensurePolled(),clearTimeout(f);var d=+new Date;e.activeTouch={start:d,moved:!1,prev:d-g.end<=300?g:null},1==b.touches.length&&(e.activeTouch.left=b.touches[0].pageX,e.activeTouch.top=b.touches[0].pageY)}})),ch(e.scroller,"touchmove",(function(){e.activeTouch&&(e.activeTouch.moved=!0)})),ch(e.scroller,"touchend",(function(c){var f=e.activeTouch;if(f&&!Jb(e,c)&&null!=f.left&&!f.moved&&new Date-f.start<300){var g,h=a.coordsChar(e.activeTouch,"page");g=!f.prev||d(f,f.prev)?new Eh(h,h):!f.prev.prev||d(f,f.prev.prev)?a.findWordAt(h):new Eh(J(h.line,0),Q(a.doc,J(h.line+1,0))),a.setSelection(g.anchor,g.head),a.focus(),Fa(c)}b()})),ch(e.scroller,"touchcancel",b),ch(e.scroller,"scroll",(function(){e.scroller.clientHeight&&(Zc(a,e.scroller.scrollTop),_c(a,e.scroller.scrollLeft,!0),Aa(a,"scroll",a))})),ch(e.scroller,"mousewheel",(function(b){return Ld(a,b)})),ch(e.scroller,"DOMMouseScroll",(function(b){return Ld(a,b)})),ch(e.wrapper,"scroll",(function(){return e.wrapper.scrollTop=e.wrapper.scrollLeft=0})),e.dragFunctions={enter:function(b){Ba(a,b)||Ia(b)},over:function(b){Ba(a,b)||(Ze(a,b),Ia(b))},start:function(b){return Ye(a,b)},drop:nd(a,Xe),leave:function(b){Ba(a,b)||$e(a)}};var h=e.input.getField();ch(h,"keyup",(function(b){return Bf.call(a,b)})),ch(h,"keydown",nd(a,zf)),ch(h,"keypress",nd(a,Cf)),ch(h,"focus",(function(b){return Ic(a,b)})),ch(h,"blur",(function(b){return Jc(a,b)}))}function Xf(a,b,c,d){var e,f=a.doc;null==c&&(c="add"),"smart"==c&&(f.mode.indent?e=Ya(a,b).state:c="prev");var g=a.options.tabSize,h=B(f,b),i=l(h.text,null,g);h.stateAfter&&(h.stateAfter=null);var j,k=h.text.match(/^\s*/)[0];if(d||/\S/.test(h.text)){if("smart"==c&&(j=f.mode.indent(e,h.text.slice(k.length),h.text),j==Sg||j>150)){if(!d)return;c="prev"}}else j=0,c="not";"prev"==c?j=b>f.first?l(B(f,b-1).text,null,g):0:"add"==c?j=i+a.options.indentUnit:"subtract"==c?j=i-a.options.indentUnit:"number"==typeof c&&(j=i+c),j=Math.max(0,j);var m="",n=0;if(a.options.indentWithTabs)for(var p=Math.floor(j/g);p;--p)n+=g,m+="\t";if(n1)if(bi&&bi.text.join("\n")==b){if(d.ranges.length%bi.text.length==0){i=[];for(var j=0;j=0;l--){var m=d.ranges[l],n=m.from(),o=m.to();m.empty()&&(c&&c>0?n=J(n.line,n.ch-c):a.state.overwrite&&!g?o=J(o.line,Math.min(B(f,o.line).text.length,o.ch+p(h).length)):bi&&bi.lineWise&&bi.text.join("\n")==b&&(n=o=J(n.line,0))),k=a.curOp.updateInput;var r={from:n,to:o,text:i?i[l%i.length]:h,origin:e||(g?"paste":a.state.cutIncoming?"cut":"+input")};De(a.doc,r),ub(a,"inputRead",a,r)}b&&!g&&_f(a,b),Uc(a),a.curOp.updateInput=k,a.curOp.typing=!0,a.state.pasteIncoming=a.state.cutIncoming=!1}function $f(a,b){var c=a.clipboardData&&a.clipboardData.getData("Text");if(c)return a.preventDefault(),b.isReadOnly()||b.options.disableInput||md(b,(function(){return Zf(b,c,0,null,"paste")})),!0}function _f(a,b){if(a.options.electricChars&&a.options.smartIndent)for(var c=a.doc.sel,d=c.ranges.length-1;d>=0;d--){var e=c.ranges[d];if(!(e.head.ch>100||d&&c.ranges[d-1].head.line==e.head.line)){var f=a.getModeAt(e.head),g=!1;if(f.electricChars){for(var h=0;h-1){g=Xf(a,e.head.line,"smart");break}}else f.electricInput&&f.electricInput.test(B(a.doc,e.head.line).text.slice(0,e.head.ch))&&(g=Xf(a,e.head.line,"smart"));g&&ub(a,"electricInput",a,e.head.line)}}}function ag(a){for(var b=[],c=[],d=0;d=a.first+a.size)&&(b=new J(d,b.ch,b.sticky),j=B(a,d))}function g(d){var g;if(g=e?pf(a.cm,j,b,c):nf(j,b,c),null==g){if(d||!f())return!1;b=of(e,a.cm,j,b.line,c)}else b=g;return!0}var h=b,i=c,j=B(a,b.line);if("char"==d)g();else if("column"==d)g(!0);else if("word"==d||"group"==d)for(var k=null,l="group"==d,m=a.cm&&a.cm.getHelper(b,"wordChars"),n=!0;!(c<0)||g(!n);n=!1){var o=j.text.charAt(b.ch)||"\n",p=v(o,m)?"w":l&&"\n"==o?"n":!l||/\s/.test(o)?null:"p";if(!l||n||p||(p="s"),k&&k!=p){c<0&&(c=1,g(),b.sticky="after");break}if(p&&(k=p),c>0&&!g(!n))break}var q=ze(a,b,h,i,!0);return L(h,q)&&(q.hitSide=!0),q}function eg(a,b,c,d){var e,f=a.doc,g=b.left;if("page"==d){var h=Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),i=Math.max(h-.5*sc(a.display),3);e=(c>0?b.bottom:b.top)+c*i}else"line"==d&&(e=c>0?b.bottom+3:b.top-3);for(var j;j=lc(a,g,e),j.outside;){if(c<0?e<=0:e>=f.height){j.hitSide=!0;break}e+=5*c}return j}function fg(a,b){var c=Ub(a,b.line);if(!c||c.hidden)return null;var d=B(a.doc,b.line),e=Rb(c,d,b.line),f=xa(d,a.doc.direction),g="left";if(f){var h=wa(f,b.ch);g=h%2?"right":"left"}var i=Xb(e.map,b.ch,g);return i.offset="right"==i.collapse?i.end:i.start,i}function gg(a){for(var b=a;b;b=b.parentNode)if(/CodeMirror-gutter-wrapper/.test(b.className))return!0;return!1}function hg(a,b){return b&&(a.bad=!0),a}function ig(a,b,c,d,e){function f(a){return function(b){return b.id==a}}function g(){k&&(j+=l,k=!1)}function h(a){a&&(g(),j+=a)}function i(b){if(1==b.nodeType){var c=b.getAttribute("cm-text");if(null!=c)return void h(c||b.textContent.replace(/\u200b/g,""));var j,m=b.getAttribute("cm-marker");if(m){var n=a.findMarks(J(d,0),J(e+1,0),f(+m));return void(n.length&&(j=n[0].find(0))&&h(C(a.doc,j.from,j.to).join(l)))}if("false"==b.getAttribute("contenteditable"))return;var o=/^(pre|div|p)$/i.test(b.nodeName);o&&g();for(var p=0;p=15&&(yg=!1,vg=!0);var Jg,Kg=Fg&&(wg||yg&&(null==Ig||Ig<12.11)),Lg=pg||tg&&ug>=9,Mg=function(b,c){var d=b.className,e=a(c).exec(d);if(e){var f=d.slice(e.index+e[0].length);b.className=d.slice(0,e.index)+(f?e[1]+f:"")}};Jg=document.createRange?function(a,b,c,d){var e=document.createRange();return e.setEnd(d||a,c),e.setStart(a,b),e}:function(a,b,c){var d=document.body.createTextRange();try{d.moveToElementText(a.parentNode)}catch(a){return d}return d.collapse(!0),d.moveEnd("character",c),d.moveStart("character",b),d};var Ng=function(a){a.select()};Cg?Ng=function(a){a.selectionStart=0,a.selectionEnd=a.value.length}:tg&&(Ng=function(a){try{a.select()}catch(a){}});var Og=function(){this.id=null};Og.prototype.set=function(a,b){clearTimeout(this.id),this.id=setTimeout(b,a)};var Pg,Qg,Rg=30,Sg={toString:function(){return"CodeMirror.Pass"}},Tg={scroll:!1},Ug={origin:"*mouse"},Vg={origin:"+move"},Wg=[""],Xg=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Yg=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,Zg=!1,$g=!1,_g=null,ah=(function(){function a(a){return a<=247?c.charAt(a):1424<=a&&a<=1524?"R":1536<=a&&a<=1785?d.charAt(a-1536):1774<=a&&a<=2220?"r":8192<=a&&a<=8203?"w":8204==a?"b":"L"}function b(a,b,c){this.level=a,this.from=b,this.to=c}var c="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",d="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,f=/[stwN]/,g=/[LRr]/,h=/[Lb1n]/,i=/[1n]/;return function(c,d){var j="ltr"==d?"L":"R";if(0==c.length||"ltr"==d&&!e.test(c))return!1;for(var k=c.length,l=[],m=0;m=this.string.length},lh.prototype.sol=function(){return this.pos==this.lineStart},lh.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},lh.prototype.next=function(){if(this.posb},lh.prototype.eatSpace=function(){for(var a=this,b=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++a.pos;return this.pos>b},lh.prototype.skipToEnd=function(){this.pos=this.string.length},lh.prototype.skipTo=function(a){var b=this.string.indexOf(a,this.pos);if(b>-1)return this.pos=b,!0},lh.prototype.backUp=function(a){this.pos-=a},lh.prototype.column=function(){return this.lastColumnPos0?null:(d&&b!==!1&&(this.pos+=d[0].length),d)}var e=function(a){return c?a.toLowerCase():a},f=this.string.substr(this.pos,a.length);if(e(f)==e(a))return b!==!1&&(this.pos+=a.length),!0},lh.prototype.current=function(){return this.string.slice(this.start,this.pos)},lh.prototype.hideFirstChars=function(a,b){this.lineStart+=a;try{return b()}finally{this.lineStart-=a}},lh.prototype.lookAhead=function(a){var b=this.lineOracle;return b&&b.lookAhead(a)},lh.prototype.baseToken=function(){var a=this.lineOracle;return a&&a.baseToken(this.pos)};var mh=function(a,b){this.state=a,this.lookAhead=b},nh=function(a,b,c,d){this.state=b,this.doc=a,this.line=c,this.maxLookAhead=d||0,this.baseTokens=null,this.baseTokenPos=1};nh.prototype.lookAhead=function(a){var b=this.doc.getLine(this.line+a);return null!=b&&a>this.maxLookAhead&&(this.maxLookAhead=a),b},nh.prototype.baseToken=function(a){var b=this;if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=a;)b.baseTokenPos+=2;var c=this.baseTokens[this.baseTokenPos+1];return{type:c&&c.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-a}},nh.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},nh.fromSaved=function(a,b,c){return b instanceof mh?new nh(a,Ta(a.mode,b.state),c,b.lookAhead):new nh(a,Ta(a.mode,b),c)},nh.prototype.save=function(a){var b=a!==!1?Ta(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new mh(b,this.maxLookAhead):b};var oh=function(a,b,c){this.start=a.start,this.end=a.pos,this.string=a.current(),this.type=b||null,this.state=c},ph=function(a,b,c){this.text=a,da(this,b),this.height=c?c(this):1};ph.prototype.lineNo=function(){return F(this)},Ea(ph);var qh,rh={},sh={},th=null,uh=null,vh={left:0,right:0,top:0,bottom:0},wh=function(a,b,c){this.cm=c;var e=this.vert=d("div",[d("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),f=this.horiz=d("div",[d("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");a(e),a(f),ch(e,"scroll",(function(){e.clientHeight&&b(e.scrollTop,"vertical")})),ch(f,"scroll",(function(){f.clientWidth&&b(f.scrollLeft,"horizontal")})),this.checkedZeroWidth=!1,tg&&ug<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};wh.prototype.update=function(a){var b=a.scrollWidth>a.clientWidth+1,c=a.scrollHeight>a.clientHeight+1,d=a.nativeBarWidth;if(c){this.vert.style.display="block",this.vert.style.bottom=b?d+"px":"0";var e=a.viewHeight-(b?d:0);this.vert.firstChild.style.height=Math.max(0,a.scrollHeight-a.clientHeight+e)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(b){this.horiz.style.display="block",this.horiz.style.right=c?d+"px":"0",this.horiz.style.left=a.barLeft+"px";var f=a.viewWidth-a.barLeft-(c?d:0);this.horiz.firstChild.style.width=Math.max(0,a.scrollWidth-a.clientWidth+f)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&a.clientHeight>0&&(0==d&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:c?d:0,bottom:b?d:0}},wh.prototype.setScrollLeft=function(a){this.horiz.scrollLeft!=a&&(this.horiz.scrollLeft=a),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},wh.prototype.setScrollTop=function(a){this.vert.scrollTop!=a&&(this.vert.scrollTop=a),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},wh.prototype.zeroWidthHack=function(){var a=Fg&&!Ag?"12px":"18px";this.horiz.style.height=this.vert.style.width=a,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new Og,this.disableVert=new Og},wh.prototype.enableZeroWidthBar=function(a,b,c){function d(){var e=a.getBoundingClientRect(),f="vert"==c?document.elementFromPoint(e.right-1,(e.top+e.bottom)/2):document.elementFromPoint((e.right+e.left)/2,e.bottom-1);f!=a?a.style.pointerEvents="none":b.set(1e3,d)}a.style.pointerEvents="auto",b.set(1e3,d)},wh.prototype.clear=function(){var a=this.horiz.parentNode;a.removeChild(this.horiz),a.removeChild(this.vert)};var xh=function(){};xh.prototype.update=function(){return{bottom:0,right:0}},xh.prototype.setScrollLeft=function(){},xh.prototype.setScrollTop=function(){},xh.prototype.clear=function(){};var yh={native:wh,null:xh},zh=0,Ah=function(a,b,c){var d=a.display;this.viewport=b,this.visible=Mc(d,a.doc,b),this.editorIsHidden=!d.wrapper.offsetWidth,this.wrapperHeight=d.wrapper.clientHeight,this.wrapperWidth=d.wrapper.clientWidth,this.oldDisplayWidth=Ob(a),this.force=c,this.dims=uc(a),this.events=[]};Ah.prototype.signal=function(a,b){Da(a,b)&&this.events.push(arguments)},Ah.prototype.finish=function(){for(var a=this,b=0;b=0&&K(a,e.to())<=0)return d}return-1};var Eh=function(a,b){this.anchor=a,this.head=b};Eh.prototype.from=function(){return O(this.anchor,this.head)},Eh.prototype.to=function(){return N(this.anchor,this.head)},Eh.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},Oe.prototype={chunkSize:function(){return this.lines.length},removeInner:function(a,b){for(var c=this,d=a,e=a+b;d1||!(this.children[0]instanceof Oe))){var i=[];this.collapse(i),this.children=[new Oe(i)],this.children[0].parent=this}},collapse:function(a){for(var b=this,c=0;c50){for(var h=f.lines.length%25+25,i=h;i10);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=this,e=0;eb.display.maxLineLength&&(b.display.maxLine=k,b.display.maxLineLength=l,b.display.maxLineChanged=!0)}null!=e&&b&&this.collapsed&&qd(b,e,f+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,b&&we(b.doc)),b&&ub(b,"markerCleared",b,this,e,f),c&&fd(b),this.parent&&this.parent.clear()}},Hh.prototype.find=function(a,b){var c=this;null==a&&"bookmark"==this.type&&(a=1);for(var d,e,f=0;f=0;j--)De(d,e[j]);i?se(this,i):this.cm&&Uc(this.cm)})),undo:pd((function(){Fe(this,"undo")})),redo:pd((function(){Fe(this,"redo")})),undoSelection:pd((function(){Fe(this,"undo",!0)})),redoSelection:pd((function(){Fe(this,"redo",!0)})),setExtending:function(a){this.extend=a},getExtending:function(){return this.extend},historySize:function(){for(var a=this.history,b=0,c=0,d=0;d=a.ch)&&b.push(e.marker.parent||e.marker)}return b},findMarks:function(a,b,c){a=Q(this,a),b=Q(this,b);var d=[],e=a.line;return this.iter(a.line,b.line+1,(function(f){var g=f.markedSpans;if(g)for(var h=0;h=i.to||null==i.from&&e!=a.line||null!=i.from&&e==b.line&&i.from>=b.ch||c&&!c(i.marker)||d.push(i.marker.parent||i.marker)}++e})),d},getAllMarks:function(){var a=[];return this.iter((function(b){var c=b.markedSpans;if(c)for(var d=0;da?(b=a,!0):(a-=f,void++c)})),Q(this,J(c,b))},indexFromPos:function(a){a=Q(this,a);var b=a.ch;if(a.lineb&&(b=a.from),null!=a.to&&a.to0)e=new J(e.line,e.ch+1),a.replaceRange(f.charAt(e.ch-1)+f.charAt(e.ch-2),J(e.line,e.ch-2),e,"+transpose");else if(e.line>a.doc.first){var g=B(a.doc,e.line-1).text;g&&(e=new J(e.line,1),a.replaceRange(f.charAt(0)+a.doc.lineSeparator()+g.charAt(g.length-1),J(e.line-1,g.length-1),e,"+transpose"))}c.push(new Eh(e,e))}a.setSelections(c)}))},newlineAndIndent:function(a){return md(a,(function(){for(var b=a.listSelections(),c=b.length-1;c>=0;c--)a.replaceRange(a.doc.lineSeparator(),b[c].anchor,b[c].head,"+input");b=a.listSelections();for(var d=0;da&&0==K(b,this.pos)&&c==this.button};var Xh,Yh,Zh={toString:function(){return"CodeMirror.Init"}},$h={},_h={};Vf.defaults=$h,Vf.optionHandlers=_h;var ai=[];Vf.defineInitHook=function(a){return ai.push(a)};var bi=null,ci=function(a){var b=a.optionHandlers,c=a.helpers={};a.prototype={constructor:a,focus:function(){window.focus(),this.display.input.focus()},setOption:function(a,c){var d=this.options,e=d[a];d[a]==c&&"mode"!=a||(d[a]=c,b.hasOwnProperty(a)&&nd(this,b[a])(this,c,e),Aa(this,"optionChange",this,a))},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](kf(a))},removeKeyMap:function(a){for(var b=this.state.keyMaps,c=0;cd&&(Xf(b,f.head.line,a,!0),d=f.head.line,e==b.doc.sel.primIndex&&Uc(b));else{var g=f.from(),h=f.to(),i=Math.max(d,g.line);d=Math.min(b.lastLine(),h.line-(h.ch?0:1))+1;for(var j=i;j0&&pe(b.doc,e,new Eh(g,k[e].to()),Tg)}}})),getTokenAt:function(a,b){return ab(this,a,b)},getLineTokens:function(a,b){return ab(this,J(a),b,!0)},getTokenTypeAt:function(a){a=Q(this.doc,a);var b,c=Xa(this,B(this.doc,a.line)),d=0,e=(c.length-1)/2,f=a.ch;if(0==f)b=c[2];else for(;;){var g=d+e>>1;if((g?c[2*g-1]:0)>=f)e=g;else{if(!(c[2*g+1]f&&(a=f,e=!0),d=B(this.doc,a)}else d=a;return fc(this,d,{top:0,left:0},b||"page",c||e).top+(e?this.doc.height-sa(d):0)},defaultTextHeight:function(){return sc(this.display)},defaultCharWidth:function(){return tc(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(a,b,c,d,e){var f=this.display;a=ic(this,Q(this.doc,a));var g=a.bottom,h=a.left;if(b.style.position="absolute",b.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(b),f.sizer.appendChild(b),"over"==d)g=a.top;else if("above"==d||"near"==d){var i=Math.max(f.wrapper.clientHeight,this.doc.height),j=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);("above"==d||a.bottom+b.offsetHeight>i)&&a.top>b.offsetHeight?g=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=i&&(g=a.bottom),h+b.offsetWidth>j&&(h=j-b.offsetWidth)}b.style.top=g+"px",b.style.left=b.style.right="","right"==e?(h=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?h=0:"middle"==e&&(h=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=h+"px"),c&&Rc(this,{left:h,top:g,right:h+b.offsetWidth,bottom:g+b.offsetHeight})},triggerOnKeyDown:od(zf),triggerOnKeyPress:od(Cf),triggerOnKeyUp:Bf,triggerOnMouseDown:od(Ef),execCommand:function(a){if(Sh.hasOwnProperty(a))return Sh[a].call(null,this)},triggerElectric:od((function(a){_f(this,a)})),findPosH:function(a,b,c,d){var e=this,f=1;b<0&&(f=-1,b=-b);for(var g=Q(this.doc,a),h=0;h0&&h(c.charAt(d-1));)--d;for(;e.5)&&xc(this),Aa(this,"refresh",this)})),swapDoc:od((function(a){var b=this.doc;return b.cm=null,Yd(this,a),bc(this),this.display.input.reset(),Vc(this,a.scrollLeft,a.scrollTop),this.curOp.forceScroll=!0,ub(this,"swapDoc",this,b),b})),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Ea(a),a.registerHelper=function(b,d,e){c.hasOwnProperty(b)||(c[b]=a[b]={_global:[]}),c[b][d]=e},a.registerGlobalHelper=function(b,d,e,f){a.registerHelper(b,d,f),c[b]._global.push({pred:e,val:f})}},di=function(a){this.cm=a,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Og,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};di.prototype.init=function(a){function b(a){if(!Ba(e,a)){if(e.somethingSelected())Yf({lineWise:!1,text:e.getSelections()}),"cut"==a.type&&e.replaceSelection("",null,"cut");else{if(!e.options.lineWiseCopyCut)return;var b=ag(e);Yf({lineWise:!0,text:b.text}),"cut"==a.type&&e.operation((function(){e.setSelections(b.ranges,0,Tg),e.replaceSelection("",null,"cut")}))}if(a.clipboardData){a.clipboardData.clearData();var c=bi.text.join("\n");if(a.clipboardData.setData("Text",c),a.clipboardData.getData("Text")==c)return void a.preventDefault()}var g=cg(),h=g.firstChild;e.display.lineSpace.insertBefore(g,e.display.lineSpace.firstChild),h.value=bi.text.join("\n");var i=document.activeElement;Ng(h),setTimeout((function(){e.display.lineSpace.removeChild(g),i.focus(),i==f&&d.showPrimarySelection()}),50)}}var c=this,d=this,e=d.cm,f=d.div=a.lineDiv;bg(f,e.options.spellcheck),ch(f,"paste",(function(a){Ba(e,a)||$f(a,e)||ug<=11&&setTimeout(nd(e,(function(){return c.updateFromDOM()})),20)})),ch(f,"compositionstart",(function(a){c.composing={data:a.data,done:!1}})),ch(f,"compositionupdate",(function(a){c.composing||(c.composing={data:a.data,done:!1})})),ch(f,"compositionend",(function(a){c.composing&&(a.data!=c.composing.data&&c.readFromDOMSoon(),c.composing.done=!0)})),ch(f,"touchstart",(function(){return d.forceCompositionEnd()})),ch(f,"input",(function(){c.composing||c.readFromDOMSoon()})),ch(f,"copy",b),ch(f,"cut",b)},di.prototype.prepareSelection=function(){var a=Bc(this.cm,!1);return a.focus=this.cm.state.focused,a},di.prototype.showSelection=function(a,b){a&&this.cm.display.view.length&&((a.focus||b)&&this.showPrimarySelection(),this.showMultipleSelections(a))},di.prototype.showPrimarySelection=function(){var a=window.getSelection(),b=this.cm,c=b.doc.sel.primary(),d=c.from(),e=c.to();if(b.display.viewTo==b.display.viewFrom||d.line>=b.display.viewTo||e.line=b.display.viewFrom&&fg(b,d)||{node:h[0].measure.map[2],offset:0},j=e.linea.firstLine()&&(d=J(d.line-1,B(a.doc,d.line-1).length)),e.ch==B(a.doc,e.line).text.length&&e.lineb.viewTo-1)return!1;var f,g,h;d.line==b.viewFrom||0==(f=zc(a,d.line))?(g=F(b.view[0].line),h=b.view[0].node):(g=F(b.view[f].line),h=b.view[f-1].node.nextSibling);var i,j,k=zc(a,e.line);if(k==b.view.length-1?(i=b.viewTo-1,j=b.lineDiv.lastChild):(i=F(b.view[k+1].line)-1,j=b.view[k+1].node.previousSibling),!h)return!1;for(var l=a.doc.splitLines(ig(a,h,j,g,i)),m=C(a.doc,J(g,0),J(i,B(a.doc,i).text.length));l.length>1&&m.length>1;)if(p(l)==p(m))l.pop(),m.pop(),i--;else{if(l[0]!=m[0])break;l.shift(),m.shift(),g++}for(var n=0,o=0,q=l[0],r=m[0],s=Math.min(q.length,r.length);nd.ch&&t.charCodeAt(t.length-o-1)==u.charCodeAt(u.length-o-1);)n--,o++;l[l.length-1]=t.slice(0,t.length-o).replace(/^\u200b+/,""),l[0]=l[0].slice(n).replace(/\u200b+$/,"");var w=J(g,n),x=J(i,m.length?p(m).length-o:0);return l.length>1||l[0]||K(w,x)?(Je(a.doc,l,w,x,"+input"),!0):void 0},di.prototype.ensurePolled=function(){this.forceCompositionEnd()},di.prototype.reset=function(){this.forceCompositionEnd()},di.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},di.prototype.readFromDOMSoon=function(){ -var a=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout((function(){if(a.readDOMTimeout=null,a.composing){if(!a.composing.done)return;a.composing=null}a.updateFromDOM()}),80))},di.prototype.updateFromDOM=function(){var a=this;!this.cm.isReadOnly()&&this.pollContent()||md(this.cm,(function(){return qd(a.cm)}))},di.prototype.setUneditable=function(a){a.contentEditable="false"},di.prototype.onKeyPress=function(a){0==a.charCode||this.composing||(a.preventDefault(),this.cm.isReadOnly()||nd(this.cm,Zf)(this.cm,String.fromCharCode(null==a.charCode?a.keyCode:a.charCode),0))},di.prototype.readOnlyChanged=function(a){this.div.contentEditable=String("nocursor"!=a)},di.prototype.onContextMenu=function(){},di.prototype.resetPosition=function(){},di.prototype.needsContentAttribute=!0;var ei=function(a){this.cm=a,this.prevInput="",this.pollingFast=!1,this.polling=new Og,this.hasSelection=!1,this.composing=null};ei.prototype.init=function(a){function b(a){if(!Ba(e,a)){if(e.somethingSelected())Yf({lineWise:!1,text:e.getSelections()});else{if(!e.options.lineWiseCopyCut)return;var b=ag(e);Yf({lineWise:!0,text:b.text}),"cut"==a.type?e.setSelections(b.ranges,null,Tg):(d.prevInput="",f.value=b.text.join("\n"),Ng(f))}"cut"==a.type&&(e.state.cutIncoming=!0)}}var c=this,d=this,e=this.cm;this.createField(a);var f=this.textarea;a.wrapper.insertBefore(this.wrapper,a.wrapper.firstChild),Cg&&(f.style.width="0px"),ch(f,"input",(function(){tg&&ug>=9&&c.hasSelection&&(c.hasSelection=null),d.poll()})),ch(f,"paste",(function(a){Ba(e,a)||$f(a,e)||(e.state.pasteIncoming=!0,d.fastPoll())})),ch(f,"cut",b),ch(f,"copy",b),ch(a.scroller,"paste",(function(b){Jb(a,b)||Ba(e,b)||(e.state.pasteIncoming=!0,d.focus())})),ch(a.lineSpace,"selectstart",(function(b){Jb(a,b)||Fa(b)})),ch(f,"compositionstart",(function(){var a=e.getCursor("from");d.composing&&d.composing.range.clear(),d.composing={start:a,range:e.markText(a,e.getCursor("to"),{className:"CodeMirror-composing"})}})),ch(f,"compositionend",(function(){d.composing&&(d.poll(),d.composing.range.clear(),d.composing=null)}))},ei.prototype.createField=function(a){this.wrapper=cg(),this.textarea=this.wrapper.firstChild},ei.prototype.prepareSelection=function(){var a=this.cm,b=a.display,c=a.doc,d=Bc(a);if(a.options.moveInputWithCursor){var e=ic(a,c.sel.primary().head,"div"),f=b.wrapper.getBoundingClientRect(),g=b.lineDiv.getBoundingClientRect();d.teTop=Math.max(0,Math.min(b.wrapper.clientHeight-10,e.top+g.top-f.top)),d.teLeft=Math.max(0,Math.min(b.wrapper.clientWidth-10,e.left+g.left-f.left))}return d},ei.prototype.showSelection=function(a){var b=this.cm,d=b.display;c(d.cursorDiv,a.cursors),c(d.selectionDiv,a.selection),null!=a.teTop&&(this.wrapper.style.top=a.teTop+"px",this.wrapper.style.left=a.teLeft+"px")},ei.prototype.reset=function(a){if(!this.contextMenuPending&&!this.composing){var b=this.cm;if(b.somethingSelected()){this.prevInput="";var c=b.getSelection();this.textarea.value=c,b.state.focused&&Ng(this.textarea),tg&&ug>=9&&(this.hasSelection=c)}else a||(this.prevInput=this.textarea.value="",tg&&ug>=9&&(this.hasSelection=null))}},ei.prototype.getField=function(){return this.textarea},ei.prototype.supportsTouch=function(){return!1},ei.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!Eg||g()!=this.textarea))try{this.textarea.focus()}catch(a){}},ei.prototype.blur=function(){this.textarea.blur()},ei.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},ei.prototype.receivedFocus=function(){this.slowPoll()},ei.prototype.slowPoll=function(){var a=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,(function(){a.poll(),a.cm.state.focused&&a.slowPoll()}))},ei.prototype.fastPoll=function(){function a(){var d=c.poll();d||b?(c.pollingFast=!1,c.slowPoll()):(b=!0,c.polling.set(60,a))}var b=!1,c=this;c.pollingFast=!0,c.polling.set(20,a)},ei.prototype.poll=function(){var a=this,b=this.cm,c=this.textarea,d=this.prevInput;if(this.contextMenuPending||!b.state.focused||fh(c)&&!d&&!this.composing||b.isReadOnly()||b.options.disableInput||b.state.keySeq)return!1;var e=c.value;if(e==d&&!b.somethingSelected())return!1;if(tg&&ug>=9&&this.hasSelection===e||Fg&&/[\uf700-\uf7ff]/.test(e))return b.display.input.reset(),!1;if(b.doc.sel==b.display.selForContextMenu){var f=e.charCodeAt(0);if(8203!=f||d||(d="​"),8666==f)return this.reset(),this.cm.execCommand("undo")}for(var g=0,h=Math.min(d.length,e.length);g1e3||e.indexOf("\n")>-1?c.value=a.prevInput="":a.prevInput=e,a.composing&&(a.composing.range.clear(),a.composing.range=b.markText(a.composing.start,b.getCursor("to"),{className:"CodeMirror-composing"}))})),!0},ei.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},ei.prototype.onKeyPress=function(){tg&&ug>=9&&(this.hasSelection=null),this.fastPoll()},ei.prototype.onContextMenu=function(a){function b(){if(null!=g.selectionStart){var a=e.somethingSelected(),b="​"+(a?g.value:"");g.value="⇚",g.value=b,d.prevInput=a?"":"​",g.selectionStart=1,g.selectionEnd=b.length,f.selForContextMenu=e.doc.sel}}function c(){if(d.contextMenuPending=!1,d.wrapper.style.cssText=l,g.style.cssText=k,tg&&ug<9&&f.scrollbars.setScrollTop(f.scroller.scrollTop=i),null!=g.selectionStart){(!tg||tg&&ug<9)&&b();var a=0,c=function(){f.selForContextMenu==e.doc.sel&&0==g.selectionStart&&g.selectionEnd>0&&"​"==d.prevInput?nd(e,Be)(e):a++<10?f.detectingSelectAll=setTimeout(c,500):(f.selForContextMenu=null,f.input.reset())};f.detectingSelectAll=setTimeout(c,200)}}var d=this,e=d.cm,f=e.display,g=d.textarea,h=yc(e,a),i=f.scroller.scrollTop;if(h&&!yg){var j=e.options.resetSelectionOnContextMenu;j&&e.doc.sel.contains(h)==-1&&nd(e,te)(e.doc,Nd(h),Tg);var k=g.style.cssText,l=d.wrapper.style.cssText;d.wrapper.style.cssText="position: absolute";var m=d.wrapper.getBoundingClientRect();g.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(a.clientY-m.top-5)+"px; left: "+(a.clientX-m.left-5)+"px;\n z-index: 1000; background: "+(tg?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var n;if(vg&&(n=window.scrollY),f.input.focus(),vg&&window.scrollTo(null,n),f.input.reset(),e.somethingSelected()||(g.value=d.prevInput=" "),d.contextMenuPending=!0,f.selForContextMenu=e.doc.sel,clearTimeout(f.detectingSelectAll),tg&&ug>=9&&b(),Lg){Ia(a);var o=function(){za(window,"mouseup",o),setTimeout(c,20)};ch(window,"mouseup",o)}else setTimeout(c,50)}},ei.prototype.readOnlyChanged=function(a){a||this.reset(),this.textarea.disabled="nocursor"==a},ei.prototype.setUneditable=function(){},ei.prototype.needsContentAttribute=!1,Rf(Vf),ci(Vf);var fi="iter insert remove copy getEditor constructor".split(" ");for(var gi in Kh.prototype)Kh.prototype.hasOwnProperty(gi)&&m(fi,gi)<0&&(Vf.prototype[gi]=(function(a){return function(){return a.apply(this.doc,arguments)}})(Kh.prototype[gi]));return Ea(Kh),Vf.inputStyles={textarea:ei,contenteditable:di},Vf.defineMode=function(a){Vf.defaults.mode||"null"==a||(Vf.defaults.mode=a),Oa.apply(this,arguments)},Vf.defineMIME=Pa,Vf.defineMode("null",(function(){return{token:function(a){return a.skipToEnd()}}})),Vf.defineMIME("text/plain","null"),Vf.defineExtension=function(a,b){Vf.prototype[a]=b},Vf.defineDocExtension=function(a,b){Kh.prototype[a]=b},Vf.fromTextArea=lg,mg(Vf),Vf.version="5.37.0",Vf})); \ No newline at end of file +!(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.CodeMirror=b()})(this,(function(){"use strict";function a(a){return new RegExp("(^|\\s)"+a+"(?:$|\\s)\\s*")}function b(a){for(var b=a.childNodes.length;b>0;--b)a.removeChild(a.firstChild);return a}function c(a,c){return b(a).appendChild(c)}function d(a,b,c,d){var e=document.createElement(a);if(c&&(e.className=c),d&&(e.style.cssText=d),"string"==typeof b)e.appendChild(document.createTextNode(b));else if(b)for(var f=0;f=b)return g+(b-f);g+=h-f,g+=c-g%c,f=h+1}}function m(a,b){for(var c=0;c=b)return d+Math.min(g,b-e);if(e+=f-d,e+=c-e%c,d=f+1,e>=b)return d}}function o(a){for(;Xg.length<=a;)Xg.push(p(Xg)+" ");return Xg[a]}function p(a){return a[a.length-1]}function q(a,b){for(var c=[],d=0;d"€"&&(a.toUpperCase()!=a.toLowerCase()||Yg.test(a))}function v(a,b){return b?!!(b.source.indexOf("\\w")>-1&&u(a))||b.test(a):u(a)}function w(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function x(a){return a.charCodeAt(0)>=768&&Zg.test(a)}function y(a,b,c){for(;(c<0?b>0:bc?-1:1;;){if(b==c)return b;var e=(b+c)/2,f=d<0?Math.ceil(e):Math.floor(e);if(f==b)return a(f)?b:c;a(f)?c=f:b=f+d}}function A(a,b,c){var f=this;this.input=c,f.scrollbarFiller=d("div",null,"CodeMirror-scrollbar-filler"),f.scrollbarFiller.setAttribute("cm-not-content","true"),f.gutterFiller=d("div",null,"CodeMirror-gutter-filler"),f.gutterFiller.setAttribute("cm-not-content","true"),f.lineDiv=e("div",null,"CodeMirror-code"),f.selectionDiv=d("div",null,null,"position: relative; z-index: 1"),f.cursorDiv=d("div",null,"CodeMirror-cursors"),f.measure=d("div",null,"CodeMirror-measure"),f.lineMeasure=d("div",null,"CodeMirror-measure"),f.lineSpace=e("div",[f.measure,f.lineMeasure,f.selectionDiv,f.cursorDiv,f.lineDiv],null,"position: relative; outline: none");var g=e("div",[f.lineSpace],"CodeMirror-lines");f.mover=d("div",[g],null,"position: relative"),f.sizer=d("div",[f.mover],"CodeMirror-sizer"),f.sizerWidth=null,f.heightForcer=d("div",null,null,"position: absolute; height: "+Sg+"px; width: 1px;"),f.gutters=d("div",null,"CodeMirror-gutters"),f.lineGutter=null,f.scroller=d("div",[f.sizer,f.heightForcer,f.gutters],"CodeMirror-scroll"),f.scroller.setAttribute("tabIndex","-1"),f.wrapper=d("div",[f.scrollbarFiller,f.gutterFiller,f.scroller],"CodeMirror"),ug&&vg<8&&(f.gutters.style.zIndex=-1,f.scroller.style.paddingRight=0),wg||qg&&Fg||(f.scroller.draggable=!0),a&&(a.appendChild?a.appendChild(f.wrapper):a(f.wrapper)),f.viewFrom=f.viewTo=b.first,f.reportedViewFrom=f.reportedViewTo=b.first,f.view=[],f.renderedView=null,f.externalMeasured=null,f.viewOffset=0,f.lastWrapHeight=f.lastWrapWidth=0,f.updateLineNumbers=null,f.nativeBarWidth=f.barHeight=f.barWidth=0,f.scrollbarsClipped=!1,f.lineNumWidth=f.lineNumInnerWidth=f.lineNumChars=null,f.alignWidgets=!1,f.cachedCharWidth=f.cachedTextHeight=f.cachedPaddingH=null,f.maxLine=null,f.maxLineLength=0,f.maxLineChanged=!1,f.wheelDX=f.wheelDY=f.wheelStartX=f.wheelStartY=null,f.shift=!1,f.selForContextMenu=null,f.activeTouch=null,c.init(f)}function B(a,b){if(b-=a.first,b<0||b>=a.size)throw new Error("There is no line "+(b+a.first)+" in the document.");for(var c=a;!c.lines;)for(var d=0;;++d){var e=c.children[d],f=e.chunkSize();if(b=a.first&&bc?J(c,B(a,c).text.length):R(b,B(a,b.line).text.length)}function R(a,b){var c=a.ch;return null==c||c>b?J(a.line,b):c<0?J(a.line,0):a}function S(a,b){for(var c=[],d=0;d=b:f.to>b);(d||(d=[])).push(new V(g,f.from,i?null:f.to))}}return d}function $(a,b,c){var d;if(a)for(var e=0;e=b:f.to>b);if(h||f.from==b&&"bookmark"==g.type&&(!c||f.marker.insertLeft)){var i=null==f.from||(g.inclusiveLeft?f.from<=b:f.from0&&h)for(var v=0;v0)){var k=[i,1],l=K(j.from,h.from),n=K(j.to,h.to);(l<0||!g.inclusiveLeft&&!l)&&k.push({from:j.from,to:h.from}),(n>0||!g.inclusiveRight&&!n)&&k.push({from:h.to,to:j.to}),e.splice.apply(e,k),i+=k.length-3}}return e}function ca(a){var b=a.markedSpans;if(b){for(var c=0;cb)&&(!c||ga(c,f.marker)<0)&&(c=f.marker)}return c}function la(a,b,c,d,e){var f=B(a,b),g=_g&&f.markedSpans;if(g)for(var h=0;h=0&&l<=0||k<=0&&l>=0)&&(k<=0&&(i.marker.inclusiveRight&&e.inclusiveLeft?K(j.to,c)>=0:K(j.to,c)>0)||k>=0&&(i.marker.inclusiveRight&&e.inclusiveLeft?K(j.from,d)<=0:K(j.from,d)<0)))return!0}}}function ma(a){for(var b;b=ia(a);)a=b.find(-1,!0).line;return a}function na(a){for(var b;b=ja(a);)a=b.find(1,!0).line;return a}function oa(a){for(var b,c;b=ja(a);)a=b.find(1,!0).line,(c||(c=[])).push(a);return c}function pa(a,b){var c=B(a,b),d=ma(c);return c==d?b:F(d)}function qa(a,b){if(b>a.lastLine())return b;var c,d=B(a,b);if(!ra(a,d))return b;for(;c=ja(d);)d=c.find(1,!0).line;return F(d)+1}function ra(a,b){var c=_g&&b.markedSpans;if(c)for(var d=void 0,e=0;eb.maxLineLength&&(b.maxLineLength=c,b.maxLine=a)}))}function wa(a,b,c,d){if(!a)return d(b,c,"ltr",0);for(var e=!1,f=0;fb||b==c&&g.to==b)&&(d(Math.max(g.from,b),Math.min(g.to,c),1==g.level?"rtl":"ltr",f),e=!0)}e||d(b,c,"ltr")}function xa(a,b,c){var d;ah=null;for(var e=0;eb)return e;f.to==b&&(f.from!=f.to&&"before"==c?d=e:ah=e),f.from==b&&(f.from!=f.to&&"before"!=c?d=e:ah=e)}return null!=d?d:ah}function ya(a,b){var c=a.order;return null==c&&(c=a.order=bh(a.text,b)),c}function za(a,b){return a._handlers&&a._handlers[b]||ch}function Aa(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,!1);else if(a.detachEvent)a.detachEvent("on"+b,c);else{var d=a._handlers,e=d&&d[b];if(e){var f=m(e,c);f>-1&&(d[b]=e.slice(0,f).concat(e.slice(f+1)))}}}function Ba(a,b){var c=za(a,b);if(c.length)for(var d=Array.prototype.slice.call(arguments,2),e=0;e0}function Fa(a){a.prototype.on=function(a,b){dh(this,a,b)},a.prototype.off=function(a,b){Aa(this,a,b)}}function Ga(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function Ha(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}function Ia(a){return null!=a.defaultPrevented?a.defaultPrevented:0==a.returnValue}function Ja(a){Ga(a),Ha(a)}function Ka(a){return a.target||a.srcElement}function La(a){var b=a.which;return null==b&&(1&a.button?b=1:2&a.button?b=3:4&a.button&&(b=2)),Gg&&a.ctrlKey&&1==b&&(b=3),b}function Ma(a){if(null==Qg){var b=d("span","​");c(a,d("span",[b,document.createTextNode("x")])),0!=a.firstChild.offsetHeight&&(Qg=b.offsetWidth<=1&&b.offsetHeight>2&&!(ug&&vg<8))}var e=Qg?d("span","​"):d("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return e.setAttribute("cm-text",""),e}function Na(a){if(null!=Rg)return Rg;var d=c(a,document.createTextNode("AخA")),e=Kg(d,0,1).getBoundingClientRect(),f=Kg(d,1,2).getBoundingClientRect();return b(a),!(!e||e.left==e.right)&&(Rg=f.right-e.right<3)}function Oa(a){if(null!=ih)return ih;var b=c(a,d("span","x")),e=b.getBoundingClientRect(),f=Kg(b,0,1).getBoundingClientRect();return ih=Math.abs(e.left-f.left)>1}function Pa(a,b){arguments.length>2&&(b.dependencies=Array.prototype.slice.call(arguments,2)),jh[a]=b}function Qa(a,b){kh[a]=b}function Ra(a){if("string"==typeof a&&kh.hasOwnProperty(a))a=kh[a];else if(a&&"string"==typeof a.name&&kh.hasOwnProperty(a.name)){var b=kh[a.name];"string"==typeof b&&(b={name:b}),a=t(b,a),a.name=b.name}else{if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return Ra("application/xml");if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+json$/.test(a))return Ra("application/json")}return"string"==typeof a?{name:a}:a||{name:"null"}}function Sa(a,b){b=Ra(b);var c=jh[b.name];if(!c)return Sa(a,"text/plain");var d=c(a,b);if(lh.hasOwnProperty(b.name)){var e=lh[b.name];for(var f in e)e.hasOwnProperty(f)&&(d.hasOwnProperty(f)&&(d["_"+f]=d[f]),d[f]=e[f])}if(d.name=b.name,b.helperType&&(d.helperType=b.helperType),b.modeProps)for(var g in b.modeProps)d[g]=b.modeProps[g];return d}function Ta(a,b){var c=lh.hasOwnProperty(a)?lh[a]:lh[a]={};k(b,c)}function Ua(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c}function Va(a,b){for(var c;a.innerMode&&(c=a.innerMode(b),c&&c.mode!=a);)b=c.state,a=c.mode;return c||{mode:a,state:b}}function Wa(a,b,c){return!a.startState||a.startState(b,c)}function Xa(a,b,c,d){var e=[a.state.modeGen],f={};db(a,b.text,a.doc.mode,c,(function(a,b){return e.push(a,b)}),f,d);for(var g=c.state,h=function(d){c.baseTokens=e;var h=a.state.overlays[d],i=1,j=0;c.state=!0,db(a,b.text,h.mode,c,(function(a,b){for(var c=i;ja&&e.splice(i,1,a,e[i+1],d),i+=2,j=Math.min(a,d)}if(b)if(h.opaque)e.splice(c,i-c,a,"overlay "+b),i=c+2;else for(;ca.options.maxHighlightLength&&Ua(a.doc.mode,d.state),f=Xa(a,b,d);e&&(d.state=e),b.stateAfter=d.save(!e),b.styles=f.styles,f.classes?b.styleClasses=f.classes:b.styleClasses&&(b.styleClasses=null),c===a.doc.highlightFrontier&&(a.doc.modeFrontier=Math.max(a.doc.modeFrontier,++a.doc.highlightFrontier))}return b.styles}function Za(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState)return new oh(d,!0,b);var f=eb(a,b,c),g=f>d.first&&B(d,f-1).stateAfter,h=g?oh.fromSaved(d,g,f):new oh(d,Wa(d.mode),f);return d.iter(f,b,(function(c){$a(a,c.text,h);var d=h.line;c.stateAfter=d==b-1||d%5==0||d>=e.viewFrom&&db.start)return f}throw new Error("Mode "+a.name+" failed to advance stream.")}function bb(a,b,c,d){var e,f=a.doc,g=f.mode;b=Q(f,b);var h,i=B(f,b.line),j=Za(a,b.line,c),k=new mh(i.text,a.options.tabSize,j);for(d&&(h=[]);(d||k.posa.options.maxHighlightLength?(h=!1,g&&$a(a,b,d,l.pos),l.pos=b.length,i=null):i=cb(ab(c,l,d.state,m),f),m){var n=m[0].name;n&&(i="m-"+(i?n+" "+i:n))}if(!h||k!=i){for(;jg;--h){if(h<=f.first)return f.first;var i=B(f,h-1),j=i.stateAfter;if(j&&(!c||h+(j instanceof nh?j.lookAhead:0)<=f.modeFrontier))return h;var k=l(i.text,null,a.options.tabSize);(null==e||d>k)&&(e=h-1,d=k)}return e}function fb(a,b){if(a.modeFrontier=Math.min(a.modeFrontier,b),!(a.highlightFrontierc;d--){var e=B(a,d).stateAfter;if(e&&(!(e instanceof nh)||d+e.lookAhead1&&!/ /.test(a))return a;for(var c=b,d="",e=0;ej&&l.from<=j));m++);if(l.to>=k)return a(c,d,e,f,g,h,i);a(c,d.slice(0,l.to-j),e,f,null,h,i),f=null,d=d.slice(l.to-j),j=l.to}}}function ob(a,b,c,d){var e=!d&&c.widgetNode;e&&a.map.push(a.pos,a.pos+b,e),!d&&a.cm.display.input.needsContentAttribute&&(e||(e=a.content.appendChild(document.createElement("span"))),e.setAttribute("cm-marker",c.id)),e&&(a.cm.display.input.setUneditable(e),a.content.appendChild(e)),a.pos+=b,a.trailingSpace=!1}function pb(a,b,c){var d=a.markedSpans,e=a.text,f=0;if(d)for(var g,h,i,j,k,l,m,n=e.length,o=0,p=1,q="",r=0;;){if(r==o){i=j=k=l=h="",m=null,r=1/0;for(var s=[],t=void 0,u=0;uo||w.collapsed&&v.to==o&&v.from==o)?(null!=v.to&&v.to!=o&&r>v.to&&(r=v.to,j=""),w.className&&(i+=" "+w.className),w.css&&(h=(h?h+";":"")+w.css),w.startStyle&&v.from==o&&(k+=" "+w.startStyle),w.endStyle&&v.to==r&&(t||(t=[])).push(w.endStyle,v.to),w.title&&!l&&(l=w.title),w.collapsed&&(!m||ga(m.marker,w)<0)&&(m=v)):v.from>o&&r>v.from&&(r=v.from)}if(t)for(var x=0;x=n)break;for(var z=Math.min(n,r);;){if(q){var A=o+q.length;if(!m){var B=A>z?q.slice(0,z-o):q;b.addToken(b,B,g?g+i:i,k,o+B.length==r?j:"",l,h)}if(A>=z){q=q.slice(z-o),o=z;break}o=A,k=""}q=e.slice(f,f=c[p++]),g=ib(c[p++],b.cm.options)}}else for(var C=1;C2&&f.push((i.bottom+j.top)/2-c.top)}}f.push(c.bottom-c.top)}}function Sb(a,b,c){if(a.line==b)return{map:a.measure.map,cache:a.measure.cache};for(var d=0;dc)return{map:a.measure.maps[e],cache:a.measure.caches[e],before:!0}}function Tb(a,b){b=ma(b);var d=F(b),e=a.display.externalMeasured=new qb(a.doc,b,d);e.lineN=d;var f=e.built=jb(a,e);return e.text=f.pre,c(a.display.lineMeasure,f.pre),e}function Ub(a,b,c,d){return Xb(a,Wb(a,b),c,d)}function Vb(a,b){if(b>=a.display.viewFrom&&b=c.lineN&&bb)&&(f=i-h,e=f-1,b>=i&&(g="right")),null!=e){if(d=a[j+2],h==i&&c==(d.insertLeft?"left":"right")&&(g=c),"left"==c&&0==e)for(;j&&a[j-2]==a[j-3]&&a[j-1].insertLeft;)d=a[(j-=3)+2],g="left";if("right"==c&&e==i-h)for(;j=0&&(c=a[e]).left==c.right;e--);return c}function $b(a,b,c,d){var e,f=Yb(b.map,c,d),g=f.node,h=f.start,i=f.end,j=f.collapse;if(3==g.nodeType){for(var k=0;k<4;k++){for(;h&&x(b.line.text.charAt(f.coverStart+h));)--h;for(;f.coverStart+i0&&(j=d="right");var l;e=a.options.lineWrapping&&(l=g.getClientRects()).length>1?l["right"==d?l.length-1:0]:g.getBoundingClientRect()}if(ug&&vg<9&&!h&&(!e||!e.left&&!e.right)){var m=g.parentNode.getClientRects()[0];e=m?{left:m.left,right:m.left+uc(a.display),top:m.top,bottom:m.bottom}:wh}for(var n=e.top-b.rect.top,o=e.bottom-b.rect.top,p=(n+o)/2,q=b.view.measure.heights,r=0;r=d.text.length?(j=d.text.length,k="before"):j<=0&&(j=0,k="after"),!i)return g("before"==k?j-1:j,"before"==k);var l=xa(i,j,k),m=ah,n=h(j,l,"before"==k);return null!=m&&(n.other=h(j,m,"before"!=k)),n}function kc(a,b){var c=0;b=Q(a.doc,b),a.options.lineWrapping||(c=uc(a.display)*b.ch);var d=B(a.doc,b.line),e=ta(d)+Lb(a.display);return{left:c,right:c,top:e,bottom:e+d.height}}function lc(a,b,c,d,e){var f=J(a,b,c);return f.xRel=e,d&&(f.outside=!0),f}function mc(a,b,c){var d=a.doc;if(c+=a.display.viewOffset,c<0)return lc(d.first,0,null,!0,-1);var e=G(d,c),f=d.first+d.size-1;if(e>f)return lc(d.first+d.size-1,B(d,f).text.length,null,!0,1);b<0&&(b=0);for(var g=B(d,e);;){var h=qc(a,g,e,b,c),i=ka(g,h.ch+(h.xRel>0?1:0));if(!i)return h;var j=i.find(1);if(j.line==e)return j;g=B(d,e=j.line)}}function nc(a,b,c,d){d-=fc(b);var e=b.text.length,f=z((function(b){return Xb(a,c,b-1).bottom<=d}),e,0);return e=z((function(b){return Xb(a,c,b).top>d}),f,e),{begin:f,end:e}}function oc(a,b,c,d){c||(c=Wb(a,b));var e=gc(a,b,Xb(a,c,d),"line").top;return nc(a,b,c,e)}function pc(a,b,c,d){return!(a.bottom<=c)&&(a.top>c||(d?a.left:a.right)>b)}function qc(a,b,c,d,e){e-=ta(b);var f=Wb(a,b),g=fc(b),h=0,i=b.text.length,j=!0,k=ya(b,a.doc.direction);if(k){var l=(a.options.lineWrapping?sc:rc)(a,b,c,f,k,d,e);j=1!=l.level,h=j?l.from:l.to-1,i=j?l.to:l.from-1}var m,n,o=null,p=null,q=z((function(b){var c=Xb(a,f,b);return c.top+=g,c.bottom+=g,!!pc(c,d,e,!1)&&(c.top<=e&&c.left<=d&&(o=b,p=c),!0)}),h,i),r=!1;if(p){var s=d-p.left=u.bottom}return q=y(b.text,q,1),lc(c,q,n,r,d-m)}function rc(a,b,c,d,e,f,g){var h=z((function(h){var i=e[h],j=1!=i.level;return pc(jc(a,J(c,j?i.to:i.from,j?"before":"after"),"line",b,d),f,g,!0)}),0,e.length-1),i=e[h];if(h>0){var j=1!=i.level,k=jc(a,J(c,j?i.from:i.to,j?"after":"before"),"line",b,d);pc(k,f,g,!0)&&k.top>g&&(i=e[h-1])}return i}function sc(a,b,c,d,e,f,g){var h=nc(a,b,d,g),i=h.begin,j=h.end;/\s/.test(b.text.charAt(j-1))&&j--;for(var k=null,l=null,m=0;m=j||n.to<=i)){var o=1!=n.level,p=Xb(a,d,o?Math.min(j,n.to)-1:Math.max(i,n.from)).right,q=pq)&&(k=n,l=q)}}return k||(k=e[e.length-1]),k.fromj&&(k={from:k.from,to:j,level:k.level}),k}function tc(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==rh){rh=d("pre");for(var e=0;e<49;++e)rh.appendChild(document.createTextNode("x")),rh.appendChild(d("br"));rh.appendChild(document.createTextNode("x"))}c(a.measure,rh);var f=rh.offsetHeight/50;return f>3&&(a.cachedTextHeight=f),b(a.measure),f||1}function uc(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=d("span","xxxxxxxxxx"),e=d("pre",[b]);c(a.measure,e);var f=b.getBoundingClientRect(),g=(f.right-f.left)/10;return g>2&&(a.cachedCharWidth=g),g||10}function vc(a){for(var b=a.display,c={},d={},e=b.gutters.clientLeft,f=b.gutters.firstChild,g=0;f;f=f.nextSibling,++g)c[a.options.gutters[g]]=f.offsetLeft+f.clientLeft+e,d[a.options.gutters[g]]=f.clientWidth;return{fixedPos:wc(b),gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,wrapperWidth:b.wrapper.clientWidth}}function wc(a){return a.scroller.getBoundingClientRect().left-a.sizer.getBoundingClientRect().left}function xc(a){var b=tc(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/uc(a.display)-3);return function(e){if(ra(a.doc,e))return 0;var f=0;if(e.widgets)for(var g=0;g=a.display.viewTo)return null;if(b-=a.display.viewFrom,b<0)return null;for(var c=a.display.view,d=0;d=a.display.viewTo||h.to().line0?b.blinker=setInterval((function(){return b.cursorDiv.style.visibility=(c=!c)?"":"hidden"}),a.options.cursorBlinkRate):a.options.cursorBlinkRate<0&&(b.cursorDiv.style.visibility="hidden")}}function Hc(a){a.state.focused||(a.display.input.focus(),Jc(a))}function Ic(a){a.state.delayingBlurEvent=!0,setTimeout((function(){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1,Kc(a))}),100)}function Jc(a,b){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1),"nocursor"!=a.options.readOnly&&(a.state.focused||(Ba(a,"focus",a,b),a.state.focused=!0,h(a.display.wrapper,"CodeMirror-focused"),a.curOp||a.display.selForContextMenu==a.doc.sel||(a.display.input.reset(),wg&&setTimeout((function(){return a.display.input.reset(!0)}),20)),a.display.input.receivedFocus()),Gc(a))}function Kc(a,b){a.state.delayingBlurEvent||(a.state.focused&&(Ba(a,"blur",a,b),a.state.focused=!1,Ng(a.display.wrapper,"CodeMirror-focused")),clearInterval(a.display.blinker),setTimeout((function(){a.state.focused||(a.display.shift=!1)}),150))}function Lc(a){for(var b=a.display,c=b.lineDiv.offsetTop,d=0;d.005||i<-.005)&&(E(e.line,f),Mc(e.line),e.rest))for(var j=0;j=g&&(f=G(b,ta(B(b,i))-a.wrapper.clientHeight),g=i)}return{from:f,to:Math.max(g,f+1)}}function Oc(a){var b=a.display,c=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var d=wc(b)-b.scroller.scrollLeft+a.doc.scrollLeft,e=b.gutters.offsetWidth,f=d+"px",g=0;g(window.innerHeight||document.documentElement.clientHeight)&&(f=!1),null!=f&&!Cg){var g=d("div","​",null,"position: absolute;\n top: "+(b.top-c.viewOffset-Lb(a.display))+"px;\n height: "+(b.bottom-b.top+Ob(a)+c.barHeight)+"px;\n left: "+b.left+"px; width: "+Math.max(2,b.right-b.left)+"px;");a.display.lineSpace.appendChild(g),g.scrollIntoView(f),a.display.lineSpace.removeChild(g)}}}function Rc(a,b,c,d){null==d&&(d=0);var e;a.options.lineWrapping||b!=c||(b=b.ch?J(b.line,"before"==b.sticky?b.ch-1:b.ch,"after"):b,c="before"==b.sticky?J(b.line,b.ch+1,"before"):b);for(var f=0;f<5;f++){var g=!1,h=jc(a,b),i=c&&c!=b?jc(a,c):h;e={left:Math.min(h.left,i.left),top:Math.min(h.top,i.top)-d,right:Math.max(h.left,i.left),bottom:Math.max(h.bottom,i.bottom)+d};var j=Tc(a,e),k=a.doc.scrollTop,l=a.doc.scrollLeft;if(null!=j.scrollTop&&($c(a,j.scrollTop),Math.abs(a.doc.scrollTop-k)>1&&(g=!0)),null!=j.scrollLeft&&(ad(a,j.scrollLeft),Math.abs(a.doc.scrollLeft-l)>1&&(g=!0)),!g)break}return e}function Sc(a,b){var c=Tc(a,b);null!=c.scrollTop&&$c(a,c.scrollTop),null!=c.scrollLeft&&ad(a,c.scrollLeft)}function Tc(a,b){var c=a.display,d=tc(a.display);b.top<0&&(b.top=0);var e=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:c.scroller.scrollTop,f=Qb(a),g={};b.bottom-b.top>f&&(b.bottom=b.top+f);var h=a.doc.height+Mb(c),i=b.toph-d;if(b.tope+f){var k=Math.min(b.top,(j?h:b.bottom)-f);k!=e&&(g.scrollTop=k)}var l=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft:c.scroller.scrollLeft,m=Pb(a)-(a.options.fixedGutter?c.gutters.offsetWidth:0),n=b.right-b.left>m;return n&&(b.right=b.left+m),b.left<10?g.scrollLeft=0:b.leftm+l-3&&(g.scrollLeft=b.right+(n?0:10)-m),g}function Uc(a,b){null!=b&&(Yc(a),a.curOp.scrollTop=(null==a.curOp.scrollTop?a.doc.scrollTop:a.curOp.scrollTop)+b)}function Vc(a){Yc(a);var b=a.getCursor();a.curOp.scrollToPos={from:b,to:b,margin:a.options.cursorScrollMargin}}function Wc(a,b,c){null==b&&null==c||Yc(a),null!=b&&(a.curOp.scrollLeft=b),null!=c&&(a.curOp.scrollTop=c)}function Xc(a,b){Yc(a),a.curOp.scrollToPos=b}function Yc(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=kc(a,b.from),d=kc(a,b.to);Zc(a,c,d,b.margin)}}function Zc(a,b,c,d){var e=Tc(a,{left:Math.min(b.left,c.left),top:Math.min(b.top,c.top)-d,right:Math.max(b.right,c.right),bottom:Math.max(b.bottom,c.bottom)+d});Wc(a,e.scrollLeft,e.scrollTop)}function $c(a,b){Math.abs(a.doc.scrollTop-b)<2||(qg||Ed(a,{top:b}),_c(a,b,!0),qg&&Ed(a),xd(a,100))}function _c(a,b,c){b=Math.min(a.display.scroller.scrollHeight-a.display.scroller.clientHeight,b),(a.display.scroller.scrollTop!=b||c)&&(a.doc.scrollTop=b,a.display.scrollbars.setScrollTop(b),a.display.scroller.scrollTop!=b&&(a.display.scroller.scrollTop=b))}function ad(a,b,c,d){b=Math.min(b,a.display.scroller.scrollWidth-a.display.scroller.clientWidth),(c?b==a.doc.scrollLeft:Math.abs(a.doc.scrollLeft-b)<2)&&!d||(a.doc.scrollLeft=b,Oc(a),a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft=b),a.display.scrollbars.setScrollLeft(b))}function bd(a){var b=a.display,c=b.gutters.offsetWidth,d=Math.round(a.doc.height+Mb(a.display));return{clientHeight:b.scroller.clientHeight,viewHeight:b.wrapper.clientHeight,scrollWidth:b.scroller.scrollWidth,clientWidth:b.scroller.clientWidth,viewWidth:b.wrapper.clientWidth,barLeft:a.options.fixedGutter?c:0,docHeight:d,scrollHeight:d+Ob(a)+b.barHeight,nativeBarWidth:b.nativeBarWidth,gutterWidth:c}}function cd(a,b){b||(b=bd(a));var c=a.display.barWidth,d=a.display.barHeight;dd(a,b);for(var e=0;e<4&&c!=a.display.barWidth||d!=a.display.barHeight;e++)c!=a.display.barWidth&&a.options.lineWrapping&&Lc(a),dd(a,bd(a)),c=a.display.barWidth,d=a.display.barHeight}function dd(a,b){var c=a.display,d=c.scrollbars.update(b);c.sizer.style.paddingRight=(c.barWidth=d.right)+"px",c.sizer.style.paddingBottom=(c.barHeight=d.bottom)+"px",c.heightForcer.style.borderBottom=d.bottom+"px solid transparent",d.right&&d.bottom?(c.scrollbarFiller.style.display="block",c.scrollbarFiller.style.height=d.bottom+"px",c.scrollbarFiller.style.width=d.right+"px"):c.scrollbarFiller.style.display="",d.bottom&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(c.gutterFiller.style.display="block",c.gutterFiller.style.height=d.bottom+"px",c.gutterFiller.style.width=b.gutterWidth+"px"):c.gutterFiller.style.display=""}function ed(a){a.display.scrollbars&&(a.display.scrollbars.clear(),a.display.scrollbars.addClass&&Ng(a.display.wrapper,a.display.scrollbars.addClass)),a.display.scrollbars=new zh[a.options.scrollbarStyle](function(b){a.display.wrapper.insertBefore(b,a.display.scrollbarFiller),dh(b,"mousedown",(function(){a.state.focused&&setTimeout((function(){return a.display.input.focus()}),0)})),b.setAttribute("cm-not-content","true")},function(b,c){"horizontal"==c?ad(a,b):$c(a,b)},a),a.display.scrollbars.addClass&&h(a.display.wrapper,a.display.scrollbars.addClass)}function fd(a){a.curOp={cm:a,viewChanged:!1,startHeight:a.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Ah},sb(a.curOp)}function gd(a){var b=a.curOp;ub(b,(function(a){for(var b=0;b=c.viewTo)||c.maxLineChanged&&b.options.lineWrapping,a.update=a.mustUpdate&&new Bh(b,a.mustUpdate&&{top:a.scrollTop,ensure:a.scrollToPos},a.forceUpdate)}function jd(a){a.updatedDisplay=a.mustUpdate&&Cd(a.cm,a.update)}function kd(a){var b=a.cm,c=b.display;a.updatedDisplay&&Lc(b),a.barMeasure=bd(b),c.maxLineChanged&&!b.options.lineWrapping&&(a.adjustWidthTo=Ub(b,c.maxLine,c.maxLine.text.length).left+3,b.display.sizerWidth=a.adjustWidthTo,a.barMeasure.scrollWidth=Math.max(c.scroller.clientWidth,c.sizer.offsetLeft+a.adjustWidthTo+Ob(b)+b.display.barWidth),a.maxScrollLeft=Math.max(0,c.sizer.offsetLeft+a.adjustWidthTo-Pb(b))),(a.updatedDisplay||a.selectionChanged)&&(a.preparedSelection=c.input.prepareSelection())}function ld(a){var b=a.cm;null!=a.adjustWidthTo&&(b.display.sizer.style.minWidth=a.adjustWidthTo+"px",a.maxScrollLeftb)&&(e.updateLineNumbers=b),a.curOp.viewChanged=!0,b>=e.viewTo)_g&&pa(a.doc,b)e.viewFrom?td(a):(e.viewFrom+=d,e.viewTo+=d);else if(b<=e.viewFrom&&c>=e.viewTo)td(a);else if(b<=e.viewFrom){var f=ud(a,c,c+d,1);f?(e.view=e.view.slice(f.index),e.viewFrom=f.lineN,e.viewTo+=d):td(a)}else if(c>=e.viewTo){var g=ud(a,b,b,-1);g?(e.view=e.view.slice(0,g.index),e.viewTo=g.lineN):td(a)}else{var h=ud(a,b,b,-1),i=ud(a,c,c+d,1);h&&i?(e.view=e.view.slice(0,h.index).concat(rb(a,h.lineN,i.lineN)).concat(e.view.slice(i.index)),e.viewTo+=d):td(a)}var j=e.externalMeasured;j&&(c=e.lineN&&b=d.viewTo)){var f=d.view[Ac(a,b)];if(null!=f.node){var g=f.changes||(f.changes=[]);m(g,c)==-1&&g.push(c)}}}function td(a){a.display.viewFrom=a.display.viewTo=a.doc.first,a.display.view=[],a.display.viewOffset=0}function ud(a,b,c,d){var e,f=Ac(a,b),g=a.display.view;if(!_g||c==a.doc.first+a.doc.size)return{index:f,lineN:c};for(var h=a.display.viewFrom,i=0;i0){if(f==g.length-1)return null;e=h+g[f].size-b,f++}else e=h-b;b+=e,c+=e}for(;pa(a.doc,c)!=c;){if(f==(d<0?0:g.length-1))return null;c+=d*g[f-(d<0?1:0)].size,f+=d}return{index:f,lineN:c}}function vd(a,b,c){var d=a.display,e=d.view;0==e.length||b>=d.viewTo||c<=d.viewFrom?(d.view=rb(a,b,c),d.viewFrom=b):(d.viewFrom>b?d.view=rb(a,b,d.viewFrom).concat(d.view):d.viewFromc&&(d.view=d.view.slice(0,Ac(a,c)))),d.viewTo=c}function wd(a){for(var b=a.display.view,c=0,d=0;d=a.display.viewTo)){var c=+new Date+a.options.workTime,d=Za(a,b.highlightFrontier),e=[];b.iter(d.line,Math.min(b.first+b.size,a.display.viewTo+500),(function(f){if(d.line>=a.display.viewFrom){var g=f.styles,h=f.text.length>a.options.maxHighlightLength?Ua(b.mode,d.state):null,i=Xa(a,f,d,!0);h&&(d.state=h),f.styles=i.styles;var j=f.styleClasses,k=i.classes;k?f.styleClasses=k:j&&(f.styleClasses=null);for(var l=!g||g.length!=f.styles.length||j!=k&&(!j||!k||j.bgClass!=k.bgClass||j.textClass!=k.textClass),m=0;!l&&mc)return xd(a,a.options.workDelay),!0})),b.highlightFrontier=d.line,b.modeFrontier=Math.max(b.modeFrontier,d.line),e.length&&nd(a,(function(){for(var b=0;b=d.viewFrom&&c.visible.to<=d.viewTo&&(null==d.updateLineNumbers||d.updateLineNumbers>=d.viewTo)&&d.renderedView==d.view&&0==wd(a))return!1;Pc(a)&&(td(a),c.dims=vc(a));var f=e.first+e.size,g=Math.max(c.visible.from-a.options.viewportMargin,e.first),h=Math.min(f,c.visible.to+a.options.viewportMargin);d.viewFromh&&d.viewTo-h<20&&(h=Math.min(f,d.viewTo)),_g&&(g=pa(a.doc,g),h=qa(a.doc,h));var i=g!=d.viewFrom||h!=d.viewTo||d.lastWrapHeight!=c.wrapperHeight||d.lastWrapWidth!=c.wrapperWidth;vd(a,g,h),d.viewOffset=ta(B(a.doc,d.viewFrom)),a.display.mover.style.top=d.viewOffset+"px";var j=wd(a);if(!i&&0==j&&!c.force&&d.renderedView==d.view&&(null==d.updateLineNumbers||d.updateLineNumbers>=d.viewTo))return!1;var k=Ad(a);return j>4&&(d.lineDiv.style.display="none"),Fd(a,d.updateLineNumbers,c.dims),j>4&&(d.lineDiv.style.display=""),d.renderedView=d.view,Bd(k),b(d.cursorDiv),b(d.selectionDiv),d.gutters.style.height=d.sizer.style.minHeight=0,i&&(d.lastWrapHeight=c.wrapperHeight,d.lastWrapWidth=c.wrapperWidth,xd(a,400)),d.updateLineNumbers=null,!0}function Dd(a,b){for(var c=b.viewport,d=!0;(d&&a.options.lineWrapping&&b.oldDisplayWidth!=Pb(a)||(c&&null!=c.top&&(c={top:Math.min(a.doc.height+Mb(a.display)-Qb(a),c.top)}),b.visible=Nc(a.display,a.doc,c),!(b.visible.from>=a.display.viewFrom&&b.visible.to<=a.display.viewTo)))&&Cd(a,b);d=!1){Lc(a);var e=bd(a);Bc(a),cd(a,e),Hd(a,e),b.force=!1}b.signal(a,"update",a),a.display.viewFrom==a.display.reportedViewFrom&&a.display.viewTo==a.display.reportedViewTo||(b.signal(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo),a.display.reportedViewFrom=a.display.viewFrom,a.display.reportedViewTo=a.display.viewTo)}function Ed(a,b){var c=new Bh(a,b);if(Cd(a,c)){Lc(a),Dd(a,c);var d=bd(a);Bc(a),cd(a,d),Hd(a,d),c.finish()}}function Fd(a,c,d){function e(b){var c=b.nextSibling;return wg&&Gg&&a.display.currentWheelTarget==b?b.style.display="none":b.parentNode.removeChild(b),c}for(var f=a.display,g=a.options.lineNumbers,h=f.lineDiv,i=h.firstChild,j=f.view,k=f.viewFrom,l=0;l-1&&(o=!1),xb(a,n,k,d)),o&&(b(n.lineNumber),n.lineNumber.appendChild(document.createTextNode(I(a.options,k)))),i=n.node.nextSibling}else{var p=Fb(a,n,k,d);h.insertBefore(p,i)}k+=n.size}for(;i;)i=e(i)}function Gd(a){var b=a.display.gutters.offsetWidth;a.display.sizer.style.marginLeft=b+"px"}function Hd(a,b){a.display.sizer.style.minHeight=b.docHeight+"px",a.display.heightForcer.style.top=b.docHeight+"px",a.display.gutters.style.height=b.docHeight+a.display.barHeight+Ob(a)+"px"}function Id(a){var c=a.display.gutters,e=a.options.gutters;b(c);for(var f=0;f-1&&!a.lineNumbers&&(a.gutters=a.gutters.slice(0),a.gutters.splice(b,1))}function Kd(a){var b=a.wheelDeltaX,c=a.wheelDeltaY;return null==b&&a.detail&&a.axis==a.HORIZONTAL_AXIS&&(b=a.detail),null==c&&a.detail&&a.axis==a.VERTICAL_AXIS?c=a.detail:null==c&&(c=a.wheelDelta),{x:b,y:c}}function Ld(a){var b=Kd(a);return b.x*=Dh,b.y*=Dh,b}function Md(a,b){var c=Kd(b),d=c.x,e=c.y,f=a.display,g=f.scroller,h=g.scrollWidth>g.clientWidth,i=g.scrollHeight>g.clientHeight;if(d&&h||e&&i){if(e&&Gg&&wg)a:for(var j=b.target,k=f.view;j!=g;j=j.parentNode)for(var l=0;l=0){var g=O(f.from(),e.from()),h=N(f.to(),e.to()),i=f.empty()?e.from()==e.head:f.from()==f.head;d<=b&&--b,a.splice(--d,2,new Fh(i?h:g,i?g:h))}}return new Eh(a,b)}function Od(a,b){return new Eh([new Fh(a,b||a)],0)}function Pd(a){return a.text?J(a.from.line+a.text.length-1,p(a.text).length+(1==a.text.length?a.from.ch:0)):a.to}function Qd(a,b){if(K(a,b.from)<0)return a;if(K(a,b.to)<=0)return Pd(b);var c=a.line+b.text.length-(b.to.line-b.from.line)-1,d=a.ch;return a.line==b.to.line&&(d+=Pd(b).ch-b.to.ch),J(c,d)}function Rd(a,b){for(var c=[],d=0;d1&&a.remove(h.line+1,o-1),a.insert(h.line+1,s)}vb(a,"change",a,b)}function Yd(a,b,c){function d(a,e,f){if(a.linked)for(var g=0;g1&&!a.done[a.done.length-2].ranges?(a.done.pop(),p(a.done)):void 0}function ee(a,b,c,d){var e=a.history;e.undone.length=0;var f,g,h=+new Date;if((e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&e.lastModTime>h-(a.cm?a.cm.options.historyEventDelay:500)||"*"==b.origin.charAt(0)))&&(f=de(e,e.lastOp==d)))g=p(f.changes),0==K(b.from,b.to)&&0==K(b.from,g.to)?g.to=Pd(b):f.changes.push(be(a,b));else{var i=p(e.done);for(i&&i.ranges||he(a.sel,e.done),f={changes:[be(a,b)],generation:e.generation},e.done.push(f);e.done.length>e.undoDepth;)e.done.shift(),e.done[0].ranges||e.done.shift()}e.done.push(c),e.generation=++e.maxGeneration,e.lastModTime=e.lastSelTime=h,e.lastOp=e.lastSelOp=d,e.lastOrigin=e.lastSelOrigin=b.origin,g||Ba(a,"historyAdded")}function fe(a,b,c,d){var e=b.charAt(0);return"*"==e||"+"==e&&c.ranges.length==d.ranges.length&&c.somethingSelected()==d.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}function ge(a,b,c,d){var e=a.history,f=d&&d.origin;c==e.lastSelOp||f&&e.lastSelOrigin==f&&(e.lastModTime==e.lastSelTime&&e.lastOrigin==f||fe(a,f,p(e.done),b))?e.done[e.done.length-1]=b:he(b,e.done),e.lastSelTime=+new Date,e.lastSelOrigin=f,e.lastSelOp=c,d&&d.clearRedo!==!1&&ce(e.undone)}function he(a,b){var c=p(b);c&&c.ranges&&c.equals(a)||b.push(a)}function ie(a,b,c,d){var e=b["spans_"+a.id],f=0;a.iter(Math.max(a.first,c),Math.min(a.first+a.size,d),(function(c){c.markedSpans&&((e||(e=b["spans_"+a.id]={}))[f]=c.markedSpans),++f}))}function je(a){if(!a)return null;for(var b,c=0;c-1&&(p(h)[l]=j[l],delete j[l])}}}return d}function ne(a,b,c,d){if(d){var e=a.anchor;if(c){var f=K(b,e)<0;f!=K(c,e)<0?(e=b,b=c):f!=K(b,c)<0&&(b=c)}return new Fh(e,b)}return new Fh(c||b,b)}function oe(a,b,c,d,e){null==e&&(e=a.cm&&(a.cm.display.shift||a.extend)),ue(a,new Eh([ne(a.sel.primary(),b,c,e)],0),d)}function pe(a,b,c){for(var d=[],e=a.cm&&(a.cm.display.shift||a.extend),f=0;f=b.ch:h.to>b.ch))){if(e&&(Ba(i,"beforeCursorEnter"),i.explicitlyCleared)){if(f.markedSpans){--g;continue}break}if(!i.atomic)continue;if(c){var j=i.find(d<0?1:-1),k=void 0;if((d<0?i.inclusiveRight:i.inclusiveLeft)&&(j=Be(a,j,-d,j&&j.line==b.line?f:null)),j&&j.line==b.line&&(k=K(j,c))&&(d<0?k<0:k>0))return ze(a,j,b,d,e)}var l=i.find(d<0?-1:1);return(d<0?i.inclusiveLeft:i.inclusiveRight)&&(l=Be(a,l,d,l.line==b.line?f:null)),l?ze(a,l,b,d,e):null}}return b}function Ae(a,b,c,d,e){var f=d||1,g=ze(a,b,c,f,e)||!e&&ze(a,b,c,f,!0)||ze(a,b,c,-f,e)||!e&&ze(a,b,c,-f,!0);return g?g:(a.cantEdit=!0,J(a.first,0))}function Be(a,b,c,d){return c<0&&0==b.ch?b.line>a.first?Q(a,J(b.line-1)):null:c>0&&b.ch==(d||B(a,b.line)).text.length?b.line=0;--e)Fe(a,{from:d[e].from,to:d[e].to,text:e?[""]:b.text,origin:b.origin});else Fe(a,b)}}function Fe(a,b){if(1!=b.text.length||""!=b.text[0]||0!=K(b.from,b.to)){var c=Rd(a,b);ee(a,b,c,a.cm?a.cm.curOp.id:NaN),Ie(a,b,c,_(a,b));var d=[];Yd(a,(function(a,c){c||m(d,a.history)!=-1||(Ne(a.history,b),d.push(a.history)),Ie(a,b,null,_(a,b))}))}}function Ge(a,b,c){var d=a.cm&&a.cm.state.suppressEdits;if(!d||c){for(var e,f=a.history,g=a.sel,h="undo"==b?f.done:f.undone,i="undo"==b?f.undone:f.done,j=0;j=0;--o){var q=n(o);if(q)return q.v}}}}function He(a,b){if(0!=b&&(a.first+=b,a.sel=new Eh(q(a.sel.ranges,(function(a){return new Fh(J(a.anchor.line+b,a.anchor.ch),J(a.head.line+b,a.head.ch))})),a.sel.primIndex),a.cm)){rd(a.cm,a.first,a.first-b,b);for(var c=a.cm.display,d=c.viewFrom;da.lastLine())){if(b.from.linef&&(b={from:b.from,to:J(f,B(a,f).text.length),text:[b.text[0]],origin:b.origin}),b.removed=C(a,b.from,b.to),c||(c=Rd(a,b)),a.cm?Je(a.cm,b,d):Xd(a,b,d),ve(a,c,Ug)}}function Je(a,b,c){var d=a.doc,e=a.display,f=b.from,g=b.to,h=!1,i=f.line;a.options.lineWrapping||(i=F(ma(B(d,f.line))),d.iter(i,g.line+1,(function(a){if(a==e.maxLine)return h=!0,!0}))),d.sel.contains(b.from,b.to)>-1&&Da(a),Xd(d,b,c,xc(a)),a.options.lineWrapping||(d.iter(i,f.line+b.text.length,(function(a){var b=ua(a);b>e.maxLineLength&&(e.maxLine=a,e.maxLineLength=b,e.maxLineChanged=!0,h=!1)})),h&&(a.curOp.updateMaxLine=!0)),fb(d,f.line),xd(a,400);var j=b.text.length-(g.line-f.line)-1;b.full?rd(a):f.line!=g.line||1!=b.text.length||Wd(a.doc,b)?rd(a,f.line,g.line+1,j):sd(a,f.line,"text");var k=Ea(a,"changes"),l=Ea(a,"change");if(l||k){var m={from:f,to:g,text:b.text,removed:b.removed,origin:b.origin};l&&vb(a,"change",a,m),k&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(m)}a.display.selForContextMenu=null}function Ke(a,b,c,d,e){if(d||(d=c),K(d,c)<0){var f;f=[d,c],c=f[0],d=f[1]}"string"==typeof b&&(b=a.splitLines(b)),Ee(a,{from:c,to:d,text:b,origin:e})}function Le(a,b,c,d){c0||0==h&&g.clearWhenEmpty!==!1)return g;if(g.replacedWith&&(g.collapsed=!0,g.widgetNode=e("span",[g.replacedWith],"CodeMirror-widget"),d.handleMouseEvents||g.widgetNode.setAttribute("cm-ignore-events","true"),d.insertLeft&&(g.widgetNode.insertLeft=!0)),g.collapsed){if(la(a,b.line,b,c,g)||b.line!=c.line&&la(a,c.line,b,c,g))throw new Error("Inserting collapsed marker partially overlapping an existing one");U()}g.addToHistory&&ee(a,{from:b,to:c,origin:"markText"},a.sel,NaN);var i,j=b.line,l=a.cm;if(a.iter(j,c.line+1,(function(a){l&&g.collapsed&&!l.options.lineWrapping&&ma(a)==l.display.maxLine&&(i=!0),g.collapsed&&j!=b.line&&E(a,0),Y(a,new V(g,j==b.line?b.ch:null,j==c.line?c.ch:null)),++j})),g.collapsed&&a.iter(b.line,c.line+1,(function(b){ra(a,b)&&E(b,0)})),g.clearOnEnter&&dh(g,"beforeCursorEnter",(function(){return g.clear()})),g.readOnly&&(T(),(a.history.done.length||a.history.undone.length)&&a.clearHistory()),g.collapsed&&(g.id=++Hh,g.atomic=!0),l){if(i&&(l.curOp.updateMaxLine=!0),g.collapsed)rd(l,b.line,c.line+1);else if(g.className||g.title||g.startStyle||g.endStyle||g.css)for(var m=b.line;m<=c.line;m++)sd(l,m,"text");g.atomic&&xe(l.doc),vb(l,"markerAdded",l,g)}return g}function Ue(a,b,c,d,e){d=k(d),d.shared=!1;var f=[Te(a,b,c,d,e)],g=f[0],h=d.widgetNode;return Yd(a,(function(a){h&&(d.widgetNode=h.cloneNode(!0)),f.push(Te(a,Q(a,b),Q(a,c),d,e));for(var i=0;i-1)return b.state.draggingText(a),void setTimeout((function(){return b.display.input.focus()}),20);try{var j=a.dataTransfer.getData("Text");if(j){var k;if(b.state.draggingText&&!b.state.draggingText.copy&&(k=b.listSelections()),ve(b.doc,Od(c,c)),k)for(var l=0;l=0;b--)Ke(a.doc,"",d[b].from,d[b].to,"+delete");Vc(a)}))}function nf(a,b,c){var d=y(a.text,b+c,c);return d<0||d>a.text.length?null:d}function of(a,b,c){var d=nf(a,b.ch,c);return null==d?null:new J(b.line,d,c<0?"after":"before")}function pf(a,b,c,d,e){if(a){var f=ya(c,b.doc.direction);if(f){var g,h=e<0?p(f):f[0],i=e<0==(1==h.level),j=i?"after":"before";if(h.level>0||"rtl"==b.doc.direction){var k=Wb(b,c);g=e<0?c.text.length-1:0;var l=Xb(b,k,g).top;g=z((function(a){return Xb(b,k,a).top==l}),e<0==(1==h.level)?h.from:h.to-1,g),"before"==j&&(g=nf(c,g,1))}else g=e<0?h.to:h.from;return new J(d,g,j)}}return new J(d,e<0?c.text.length:0,e<0?"before":"after")}function qf(a,b,c,d){var e=ya(b,a.doc.direction);if(!e)return of(b,c,d);c.ch>=b.text.length?(c.ch=b.text.length,c.sticky="before"):c.ch<=0&&(c.ch=0,c.sticky="after");var f=xa(e,c.ch,c.sticky),g=e[f];if("ltr"==a.doc.direction&&g.level%2==0&&(d>0?g.to>c.ch:g.from=g.from&&m>=k.begin)){var n=l?"before":"after";return new J(c.line,m,n)}}var o=function(a,b,d){for(var f=function(a,b){return b?new J(c.line,i(a,1),"before"):new J(c.line,a,"after")};a>=0&&a0==(1!=g.level),j=h?d.begin:i(d.end,-1);if(g.from<=j&&j0?k.end:i(k.begin,-1);return null==q||d>0&&q==b.text.length||!(p=o(d>0?0:e.length-1,d,j(q)))?null:p}function rf(a,b){var c=B(a.doc,b),d=ma(c);return d!=c&&(b=F(d)),pf(!0,a,d,b,1)}function sf(a,b){var c=B(a.doc,b),d=na(c);return d!=c&&(b=F(d)),pf(!0,a,c,b,-1)}function tf(a,b){var c=rf(a,b.line),d=B(a.doc,c.line),e=ya(d,a.doc.direction);if(!e||0==e[0].level){var f=Math.max(0,d.text.search(/\S/)),g=b.line==c.line&&b.ch<=f&&b.ch;return J(c.line,g?0:f,c.sticky)}return c}function uf(a,b,c){if("string"==typeof b&&(b=Th[b],!b))return!1;a.display.input.ensurePolled();var d=a.display.shift,e=!1;try{a.isReadOnly()&&(a.state.suppressEdits=!0),c&&(a.display.shift=!1),e=b(a)!=Tg}finally{a.display.shift=d,a.state.suppressEdits=!1}return e}function vf(a,b,c){for(var d=0;d-1&&(K((e=h.ranges[e]).from(),b)<0||b.xRel>0)&&(K(e.to(),b)>0||b.xRel<0)?Jf(a,d,b,f):Lf(a,d,b,f)}function Jf(a,b,c,d){var e=a.display,f=!1,g=od(a,(function(b){wg&&(e.scroller.draggable=!1),a.state.draggingText=!1,Aa(e.wrapper.ownerDocument,"mouseup",g),Aa(e.wrapper.ownerDocument,"mousemove",h),Aa(e.scroller,"dragstart",i),Aa(e.scroller,"drop",g),f||(Ga(b),d.addNew||oe(a.doc,c,null,null,d.extend),wg||ug&&9==vg?setTimeout((function(){e.wrapper.ownerDocument.body.focus(),e.input.focus()}),20):e.input.focus())})),h=function(a){f=f||Math.abs(b.clientX-a.clientX)+Math.abs(b.clientY-a.clientY)>=10},i=function(){return f=!0};wg&&(e.scroller.draggable=!0),a.state.draggingText=g,g.copy=!d.moveOnDrag,e.scroller.dragDrop&&e.scroller.dragDrop(),dh(e.wrapper.ownerDocument,"mouseup",g),dh(e.wrapper.ownerDocument,"mousemove",h),dh(e.scroller,"dragstart",i),dh(e.scroller,"drop",g),Ic(a),setTimeout((function(){return e.input.focus()}),20)}function Kf(a,b,c){if("char"==c)return new Fh(b,b);if("word"==c)return a.findWordAt(b);if("line"==c)return new Fh(J(b.line,0),Q(a.doc,J(b.line+1,0)));var d=c(a,b);return new Fh(d.from,d.to)}function Lf(a,b,c,d){function e(b){if(0!=K(r,b))if(r=b,"rectangle"==d.unit){for(var e=[],f=a.options.tabSize,g=l(B(j,c.line).text,c.ch,f),h=l(B(j,b.line).text,b.ch,f),i=Math.min(g,h),p=Math.max(g,h),q=Math.min(c.line,b.line),s=Math.min(a.lastLine(),Math.max(c.line,b.line));q<=s;q++){var t=B(j,q).text,u=n(t,i,f);i==p?e.push(new Fh(J(q,u),J(q,u))):t.length>u&&e.push(new Fh(J(q,u),J(q,n(t,p,f))))}e.length||e.push(new Fh(c,c)),ue(j,Nd(o.ranges.slice(0,m).concat(e),m),{origin:"*mouse",scroll:!1}),a.scrollIntoView(b)}else{var v,w=k,x=Kf(a,b,d.unit),y=w.anchor;K(x.anchor,y)>0?(v=x.head,y=O(w.from(),x.anchor)):(v=x.anchor,y=N(w.to(),x.head));var z=o.ranges.slice(0);z[m]=Mf(a,new Fh(Q(j,y),v)),ue(j,Nd(z,m),Vg)}}function f(b){var c=++t,h=zc(a,b,!0,"rectangle"==d.unit);if(h)if(0!=K(h,r)){a.curOp.focus=g(),e(h);var k=Nc(i,j);(h.line>=k.to||h.lines.bottom?20:0;l&&setTimeout(od(a,(function(){t==c&&(i.scroller.scrollTop+=l,f(b))})),50)}}function h(b){a.state.selectingText=!1,t=1/0,Ga(b),i.input.focus(),Aa(i.wrapper.ownerDocument,"mousemove",u),Aa(i.wrapper.ownerDocument,"mouseup",v),j.history.lastSelOrigin=null}var i=a.display,j=a.doc;Ga(b);var k,m,o=j.sel,p=o.ranges;if(d.addNew&&!d.extend?(m=j.sel.contains(c),k=m>-1?p[m]:new Fh(c,c)):(k=j.sel.primary(),m=j.sel.primIndex),"rectangle"==d.unit)d.addNew||(k=new Fh(c,c)),c=zc(a,b,!0,!0),m=-1;else{var q=Kf(a,c,d.unit);k=d.extend?ne(k,q.anchor,q.head,d.extend):q}d.addNew?m==-1?(m=p.length,ue(j,Nd(p.concat([k]),m),{scroll:!1,origin:"*mouse"})):p.length>1&&p[m].empty()&&"char"==d.unit&&!d.extend?(ue(j,Nd(p.slice(0,m).concat(p.slice(m+1)),0),{scroll:!1,origin:"*mouse"}),o=j.sel):qe(j,m,k,Vg):(m=0,ue(j,new Eh([k],0),Vg),o=j.sel);var r=c,s=i.wrapper.getBoundingClientRect(),t=0,u=od(a,(function(a){0!==a.buttons&&La(a)?f(a):h(a)})),v=od(a,h);a.state.selectingText=v,dh(i.wrapper.ownerDocument,"mousemove",u),dh(i.wrapper.ownerDocument,"mouseup",v)}function Mf(a,b){var c=b.anchor,d=b.head,e=B(a.doc,c.line);if(0==K(c,d)&&c.sticky==d.sticky)return b;var f=ya(e);if(!f)return b;var g=xa(f,c.ch,c.sticky),h=f[g];if(h.from!=c.ch&&h.to!=c.ch)return b;var i=g+(h.from==c.ch==(1!=h.level)?0:1);if(0==i||i==f.length)return b;var j;if(d.line!=c.line)j=(d.line-c.line)*("ltr"==a.doc.direction?1:-1)>0;else{var k=xa(f,d.ch,d.sticky),l=k-g||(d.ch-c.ch)*(1==h.level?-1:1);j=k==i-1||k==i?l<0:l>0}var m=f[i+(j?-1:0)],n=j==(1==m.level),o=n?m.from:m.to,p=n?"after":"before";return c.ch==o&&c.sticky==p?b:new Fh(new J(c.line,o,p),d)}function Nf(a,b,c,d){var e,f;if(b.touches)e=b.touches[0].clientX,f=b.touches[0].clientY;else try{e=b.clientX,f=b.clientY}catch(a){return!1}if(e>=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;d&&Ga(b);var g=a.display,h=g.lineDiv.getBoundingClientRect();if(f>h.bottom||!Ea(a,c))return Ia(b);f-=h.top-g.viewOffset;for(var i=0;i=e){var k=G(a.doc,f),l=a.options.gutters[i];return Ba(a,c,a,k,l,b),Ia(b)}}}function Of(a,b){return Nf(a,b,"gutterClick",!0)}function Pf(a,b){Kb(a.display,b)||Qf(a,b)||Ca(a,b,"contextmenu")||a.display.input.onContextMenu(b)}function Qf(a,b){return!!Ea(a,"gutterContextMenu")&&Nf(a,b,"gutterContextMenu",!1)}function Rf(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-"),cc(a)}function Sf(a){function b(b,d,e,f){a.defaults[b]=d,e&&(c[b]=f?function(a,b,c){c!=$h&&e(a,b,c)}:e)}var c=a.optionHandlers;a.defineOption=b,a.Init=$h,b("value","",(function(a,b){return a.setValue(b)}),!0),b("mode",null,(function(a,b){a.doc.modeOption=b,Ud(a)}),!0),b("indentUnit",2,Ud,!0),b("indentWithTabs",!1),b("smartIndent",!0),b("tabSize",4,(function(a){Vd(a),cc(a),rd(a)}),!0),b("lineSeparator",null,(function(a,b){if(a.doc.lineSep=b,b){var c=[],d=a.doc.first;a.doc.iter((function(a){for(var e=0;;){var f=a.text.indexOf(b,e);if(f==-1)break;e=f+b.length,c.push(J(d,f))}d++}));for(var e=c.length-1;e>=0;e--)Ke(a.doc,b,c[e],J(c[e].line,c[e].ch+b.length))}})),b("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,(function(a,b,c){a.state.specialChars=new RegExp(b.source+(b.test("\t")?"":"|\t"),"g"),c!=$h&&a.refresh()})),b("specialCharPlaceholder",kb,(function(a){return a.refresh()}),!0),b("electricChars",!0),b("inputStyle",Fg?"contenteditable":"textarea",(function(){throw new Error("inputStyle can not (yet) be changed in a running editor")}),!0),b("spellcheck",!1,(function(a,b){return a.getInputField().spellcheck=b}),!0),b("rtlMoveVisually",!Ig),b("wholeLineUpdateBefore",!0),b("theme","default",(function(a){Rf(a),Tf(a)}),!0),b("keyMap","default",(function(a,b,c){var d=lf(b),e=c!=$h&&lf(c);e&&e.detach&&e.detach(a,d),d.attach&&d.attach(a,e||null)})),b("extraKeys",null),b("configureMouse",null),b("lineWrapping",!1,Vf,!0),b("gutters",[],(function(a){Jd(a.options),Tf(a)}),!0),b("fixedGutter",!0,(function(a,b){a.display.gutters.style.left=b?wc(a.display)+"px":"0",a.refresh()}),!0),b("coverGutterNextToScrollbar",!1,(function(a){return cd(a)}),!0),b("scrollbarStyle","native",(function(a){ed(a),cd(a),a.display.scrollbars.setScrollTop(a.doc.scrollTop),a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)}),!0),b("lineNumbers",!1,(function(a){Jd(a.options),Tf(a)}),!0),b("firstLineNumber",1,Tf,!0),b("lineNumberFormatter",(function(a){return a}),Tf,!0),b("showCursorWhenSelecting",!1,Bc,!0),b("resetSelectionOnContextMenu",!0),b("lineWiseCopyCut",!0),b("pasteLinesPerSelection",!0),b("readOnly",!1,(function(a,b){"nocursor"==b&&(Kc(a),a.display.input.blur()),a.display.input.readOnlyChanged(b)})),b("disableInput",!1,(function(a,b){b||a.display.input.reset(); +}),!0),b("dragDrop",!0,Uf),b("allowDropFileTypes",null),b("cursorBlinkRate",530),b("cursorScrollMargin",0),b("cursorHeight",1,Bc,!0),b("singleCursorHeightPerLine",!0,Bc,!0),b("workTime",100),b("workDelay",100),b("flattenSpans",!0,Vd,!0),b("addModeClass",!1,Vd,!0),b("pollInterval",100),b("undoDepth",200,(function(a,b){return a.doc.history.undoDepth=b})),b("historyEventDelay",1250),b("viewportMargin",10,(function(a){return a.refresh()}),!0),b("maxHighlightLength",1e4,Vd,!0),b("moveInputWithCursor",!0,(function(a,b){b||a.display.input.resetPosition()})),b("tabindex",null,(function(a,b){return a.display.input.getField().tabIndex=b||""})),b("autofocus",null),b("direction","ltr",(function(a,b){return a.doc.setDirection(b)}),!0)}function Tf(a){Id(a),rd(a),Oc(a)}function Uf(a,b,c){var d=c&&c!=$h;if(!b!=!d){var e=a.display.dragFunctions,f=b?dh:Aa;f(a.display.scroller,"dragstart",e.start),f(a.display.scroller,"dragenter",e.enter),f(a.display.scroller,"dragover",e.over),f(a.display.scroller,"dragleave",e.leave),f(a.display.scroller,"drop",e.drop)}}function Vf(a){a.options.lineWrapping?(h(a.display.wrapper,"CodeMirror-wrap"),a.display.sizer.style.minWidth="",a.display.sizerWidth=null):(Ng(a.display.wrapper,"CodeMirror-wrap"),va(a)),yc(a),rd(a),cc(a),setTimeout((function(){return cd(a)}),100)}function Wf(a,b){var c=this;if(!(this instanceof Wf))return new Wf(a,b);this.options=b=b?k(b):{},k(_h,b,!1),Jd(b);var d=b.value;"string"==typeof d&&(d=new Lh(d,b.mode,null,b.lineSeparator,b.direction)),this.doc=d;var e=new Wf.inputStyles[b.inputStyle](this),f=this.display=new A(a,d,e);f.wrapper.CodeMirror=this,Id(this),Rf(this),b.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),ed(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Pg,keySeq:null,specialChars:null},b.autofocus&&!Fg&&f.input.focus(),ug&&vg<11&&setTimeout((function(){return c.display.input.reset(!0)}),20),Xf(this),bf(),fd(this),this.curOp.forceUpdate=!0,Zd(this,d),b.autofocus&&!Fg||this.hasFocus()?setTimeout(j(Jc,this),20):Kc(this);for(var g in ai)ai.hasOwnProperty(g)&&ai[g](c,b[g],$h);Pc(this),b.finishInit&&b.finishInit(this);for(var h=0;h400}var e=a.display;dh(e.scroller,"mousedown",od(a,Ff)),ug&&vg<11?dh(e.scroller,"dblclick",od(a,(function(b){if(!Ca(a,b)){var c=zc(a,b);if(c&&!Of(a,b)&&!Kb(a.display,b)){Ga(b);var d=a.findWordAt(c);oe(a.doc,d.anchor,d.head)}}}))):dh(e.scroller,"dblclick",(function(b){return Ca(a,b)||Ga(b)})),Mg||dh(e.scroller,"contextmenu",(function(b){return Pf(a,b)}));var f,g={end:0};dh(e.scroller,"touchstart",(function(b){if(!Ca(a,b)&&!c(b)&&!Of(a,b)){e.input.ensurePolled(),clearTimeout(f);var d=+new Date;e.activeTouch={start:d,moved:!1,prev:d-g.end<=300?g:null},1==b.touches.length&&(e.activeTouch.left=b.touches[0].pageX,e.activeTouch.top=b.touches[0].pageY)}})),dh(e.scroller,"touchmove",(function(){e.activeTouch&&(e.activeTouch.moved=!0)})),dh(e.scroller,"touchend",(function(c){var f=e.activeTouch;if(f&&!Kb(e,c)&&null!=f.left&&!f.moved&&new Date-f.start<300){var g,h=a.coordsChar(e.activeTouch,"page");g=!f.prev||d(f,f.prev)?new Fh(h,h):!f.prev.prev||d(f,f.prev.prev)?a.findWordAt(h):new Fh(J(h.line,0),Q(a.doc,J(h.line+1,0))),a.setSelection(g.anchor,g.head),a.focus(),Ga(c)}b()})),dh(e.scroller,"touchcancel",b),dh(e.scroller,"scroll",(function(){e.scroller.clientHeight&&($c(a,e.scroller.scrollTop),ad(a,e.scroller.scrollLeft,!0),Ba(a,"scroll",a))})),dh(e.scroller,"mousewheel",(function(b){return Md(a,b)})),dh(e.scroller,"DOMMouseScroll",(function(b){return Md(a,b)})),dh(e.wrapper,"scroll",(function(){return e.wrapper.scrollTop=e.wrapper.scrollLeft=0})),e.dragFunctions={enter:function(b){Ca(a,b)||Ja(b)},over:function(b){Ca(a,b)||($e(a,b),Ja(b))},start:function(b){return Ze(a,b)},drop:od(a,Ye),leave:function(b){Ca(a,b)||_e(a)}};var h=e.input.getField();dh(h,"keyup",(function(b){return Cf.call(a,b)})),dh(h,"keydown",od(a,Af)),dh(h,"keypress",od(a,Df)),dh(h,"focus",(function(b){return Jc(a,b)})),dh(h,"blur",(function(b){return Kc(a,b)}))}function Yf(a,b,c,d){var e,f=a.doc;null==c&&(c="add"),"smart"==c&&(f.mode.indent?e=Za(a,b).state:c="prev");var g=a.options.tabSize,h=B(f,b),i=l(h.text,null,g);h.stateAfter&&(h.stateAfter=null);var j,k=h.text.match(/^\s*/)[0];if(d||/\S/.test(h.text)){if("smart"==c&&(j=f.mode.indent(e,h.text.slice(k.length),h.text),j==Tg||j>150)){if(!d)return;c="prev"}}else j=0,c="not";"prev"==c?j=b>f.first?l(B(f,b-1).text,null,g):0:"add"==c?j=i+a.options.indentUnit:"subtract"==c?j=i-a.options.indentUnit:"number"==typeof c&&(j=i+c),j=Math.max(0,j);var m="",n=0;if(a.options.indentWithTabs)for(var p=Math.floor(j/g);p;--p)n+=g,m+="\t";if(n1)if(ci&&ci.text.join("\n")==b){if(d.ranges.length%ci.text.length==0){i=[];for(var j=0;j=0;l--){var m=d.ranges[l],n=m.from(),o=m.to();m.empty()&&(c&&c>0?n=J(n.line,n.ch-c):a.state.overwrite&&!g?o=J(o.line,Math.min(B(f,o.line).text.length,o.ch+p(h).length)):ci&&ci.lineWise&&ci.text.join("\n")==b&&(n=o=J(n.line,0))),k=a.curOp.updateInput;var r={from:n,to:o,text:i?i[l%i.length]:h,origin:e||(g?"paste":a.state.cutIncoming?"cut":"+input")};Ee(a.doc,r),vb(a,"inputRead",a,r)}b&&!g&&ag(a,b),Vc(a),a.curOp.updateInput=k,a.curOp.typing=!0,a.state.pasteIncoming=a.state.cutIncoming=!1}function _f(a,b){var c=a.clipboardData&&a.clipboardData.getData("Text");if(c)return a.preventDefault(),b.isReadOnly()||b.options.disableInput||nd(b,(function(){return $f(b,c,0,null,"paste")})),!0}function ag(a,b){if(a.options.electricChars&&a.options.smartIndent)for(var c=a.doc.sel,d=c.ranges.length-1;d>=0;d--){var e=c.ranges[d];if(!(e.head.ch>100||d&&c.ranges[d-1].head.line==e.head.line)){var f=a.getModeAt(e.head),g=!1;if(f.electricChars){for(var h=0;h-1){g=Yf(a,e.head.line,"smart");break}}else f.electricInput&&f.electricInput.test(B(a.doc,e.head.line).text.slice(0,e.head.ch))&&(g=Yf(a,e.head.line,"smart"));g&&vb(a,"electricInput",a,e.head.line)}}}function bg(a){for(var b=[],c=[],d=0;d=a.first+a.size)&&(b=new J(d,b.ch,b.sticky),j=B(a,d))}function g(d){var g;if(g=e?qf(a.cm,j,b,c):of(j,b,c),null==g){if(d||!f())return!1;b=pf(e,a.cm,j,b.line,c)}else b=g;return!0}var h=b,i=c,j=B(a,b.line);if("char"==d)g();else if("column"==d)g(!0);else if("word"==d||"group"==d)for(var k=null,l="group"==d,m=a.cm&&a.cm.getHelper(b,"wordChars"),n=!0;!(c<0)||g(!n);n=!1){var o=j.text.charAt(b.ch)||"\n",p=v(o,m)?"w":l&&"\n"==o?"n":!l||/\s/.test(o)?null:"p";if(!l||n||p||(p="s"),k&&k!=p){c<0&&(c=1,g(),b.sticky="after");break}if(p&&(k=p),c>0&&!g(!n))break}var q=Ae(a,b,h,i,!0);return L(h,q)&&(q.hitSide=!0),q}function fg(a,b,c,d){var e,f=a.doc,g=b.left;if("page"==d){var h=Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),i=Math.max(h-.5*tc(a.display),3);e=(c>0?b.bottom:b.top)+c*i}else"line"==d&&(e=c>0?b.bottom+3:b.top-3);for(var j;j=mc(a,g,e),j.outside;){if(c<0?e<=0:e>=f.height){j.hitSide=!0;break}e+=5*c}return j}function gg(a,b){var c=Vb(a,b.line);if(!c||c.hidden)return null;var d=B(a.doc,b.line),e=Sb(c,d,b.line),f=ya(d,a.doc.direction),g="left";if(f){var h=xa(f,b.ch);g=h%2?"right":"left"}var i=Yb(e.map,b.ch,g);return i.offset="right"==i.collapse?i.end:i.start,i}function hg(a){for(var b=a;b;b=b.parentNode)if(/CodeMirror-gutter-wrapper/.test(b.className))return!0;return!1}function ig(a,b){return b&&(a.bad=!0),a}function jg(a,b,c,d,e){function f(a){return function(b){return b.id==a}}function g(){k&&(j+=l,m&&(j+=l),k=m=!1)}function h(a){a&&(g(),j+=a)}function i(b){if(1==b.nodeType){var c=b.getAttribute("cm-text");if(c)return void h(c);var j,n=b.getAttribute("cm-marker");if(n){var o=a.findMarks(J(d,0),J(e+1,0),f(+n));return void(o.length&&(j=o[0].find(0))&&h(C(a.doc,j.from,j.to).join(l)))}if("false"==b.getAttribute("contenteditable"))return;var p=/^(pre|div|p|li|table|br)$/i.test(b.nodeName);if(!/^br$/i.test(b.nodeName)&&0==b.textContent.length)return;p&&g();for(var q=0;q=15&&(zg=!1,wg=!0);var Kg,Lg=Gg&&(xg||zg&&(null==Jg||Jg<12.11)),Mg=qg||ug&&vg>=9,Ng=function(b,c){var d=b.className,e=a(c).exec(d);if(e){var f=d.slice(e.index+e[0].length);b.className=d.slice(0,e.index)+(f?e[1]+f:"")}};Kg=document.createRange?function(a,b,c,d){var e=document.createRange();return e.setEnd(d||a,c),e.setStart(a,b),e}:function(a,b,c){var d=document.body.createTextRange();try{d.moveToElementText(a.parentNode)}catch(a){return d}return d.collapse(!0),d.moveEnd("character",c),d.moveStart("character",b),d};var Og=function(a){a.select()};Dg?Og=function(a){a.selectionStart=0,a.selectionEnd=a.value.length}:ug&&(Og=function(a){try{a.select()}catch(a){}});var Pg=function(){this.id=null};Pg.prototype.set=function(a,b){clearTimeout(this.id),this.id=setTimeout(b,a)};var Qg,Rg,Sg=30,Tg={toString:function(){return"CodeMirror.Pass"}},Ug={scroll:!1},Vg={origin:"*mouse"},Wg={origin:"+move"},Xg=[""],Yg=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Zg=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,$g=!1,_g=!1,ah=null,bh=(function(){function a(a){return a<=247?c.charAt(a):1424<=a&&a<=1524?"R":1536<=a&&a<=1785?d.charAt(a-1536):1774<=a&&a<=2220?"r":8192<=a&&a<=8203?"w":8204==a?"b":"L"}function b(a,b,c){this.level=a,this.from=b,this.to=c}var c="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",d="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,f=/[stwN]/,g=/[LRr]/,h=/[Lb1n]/,i=/[1n]/;return function(c,d){var j="ltr"==d?"L":"R";if(0==c.length||"ltr"==d&&!e.test(c))return!1;for(var k=c.length,l=[],m=0;m=this.string.length},mh.prototype.sol=function(){return this.pos==this.lineStart},mh.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},mh.prototype.next=function(){if(this.posb},mh.prototype.eatSpace=function(){for(var a=this,b=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++a.pos;return this.pos>b},mh.prototype.skipToEnd=function(){this.pos=this.string.length},mh.prototype.skipTo=function(a){var b=this.string.indexOf(a,this.pos);if(b>-1)return this.pos=b,!0},mh.prototype.backUp=function(a){this.pos-=a},mh.prototype.column=function(){return this.lastColumnPos0?null:(d&&b!==!1&&(this.pos+=d[0].length),d)}var e=function(a){return c?a.toLowerCase():a},f=this.string.substr(this.pos,a.length);if(e(f)==e(a))return b!==!1&&(this.pos+=a.length),!0},mh.prototype.current=function(){return this.string.slice(this.start,this.pos)},mh.prototype.hideFirstChars=function(a,b){this.lineStart+=a;try{return b()}finally{this.lineStart-=a}},mh.prototype.lookAhead=function(a){var b=this.lineOracle;return b&&b.lookAhead(a)},mh.prototype.baseToken=function(){var a=this.lineOracle;return a&&a.baseToken(this.pos)};var nh=function(a,b){this.state=a,this.lookAhead=b},oh=function(a,b,c,d){this.state=b,this.doc=a,this.line=c,this.maxLookAhead=d||0,this.baseTokens=null,this.baseTokenPos=1};oh.prototype.lookAhead=function(a){var b=this.doc.getLine(this.line+a);return null!=b&&a>this.maxLookAhead&&(this.maxLookAhead=a),b},oh.prototype.baseToken=function(a){var b=this;if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=a;)b.baseTokenPos+=2;var c=this.baseTokens[this.baseTokenPos+1];return{type:c&&c.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-a}},oh.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},oh.fromSaved=function(a,b,c){return b instanceof nh?new oh(a,Ua(a.mode,b.state),c,b.lookAhead):new oh(a,Ua(a.mode,b),c)},oh.prototype.save=function(a){var b=a!==!1?Ua(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new nh(b,this.maxLookAhead):b};var ph=function(a,b,c){this.start=a.start,this.end=a.pos,this.string=a.current(),this.type=b||null,this.state=c},qh=function(a,b,c){this.text=a,da(this,b),this.height=c?c(this):1};qh.prototype.lineNo=function(){return F(this)},Fa(qh);var rh,sh={},th={},uh=null,vh=null,wh={left:0,right:0,top:0,bottom:0},xh=function(a,b,c){this.cm=c;var e=this.vert=d("div",[d("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),f=this.horiz=d("div",[d("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e.tabIndex=f.tabIndex=-1,a(e),a(f),dh(e,"scroll",(function(){e.clientHeight&&b(e.scrollTop,"vertical")})),dh(f,"scroll",(function(){f.clientWidth&&b(f.scrollLeft,"horizontal")})),this.checkedZeroWidth=!1,ug&&vg<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};xh.prototype.update=function(a){var b=a.scrollWidth>a.clientWidth+1,c=a.scrollHeight>a.clientHeight+1,d=a.nativeBarWidth;if(c){this.vert.style.display="block",this.vert.style.bottom=b?d+"px":"0";var e=a.viewHeight-(b?d:0);this.vert.firstChild.style.height=Math.max(0,a.scrollHeight-a.clientHeight+e)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(b){this.horiz.style.display="block",this.horiz.style.right=c?d+"px":"0",this.horiz.style.left=a.barLeft+"px";var f=a.viewWidth-a.barLeft-(c?d:0);this.horiz.firstChild.style.width=Math.max(0,a.scrollWidth-a.clientWidth+f)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&a.clientHeight>0&&(0==d&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:c?d:0,bottom:b?d:0}},xh.prototype.setScrollLeft=function(a){this.horiz.scrollLeft!=a&&(this.horiz.scrollLeft=a),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},xh.prototype.setScrollTop=function(a){this.vert.scrollTop!=a&&(this.vert.scrollTop=a),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},xh.prototype.zeroWidthHack=function(){var a=Gg&&!Bg?"12px":"18px";this.horiz.style.height=this.vert.style.width=a,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new Pg,this.disableVert=new Pg},xh.prototype.enableZeroWidthBar=function(a,b,c){function d(){var e=a.getBoundingClientRect(),f="vert"==c?document.elementFromPoint(e.right-1,(e.top+e.bottom)/2):document.elementFromPoint((e.right+e.left)/2,e.bottom-1);f!=a?a.style.pointerEvents="none":b.set(1e3,d)}a.style.pointerEvents="auto",b.set(1e3,d)},xh.prototype.clear=function(){var a=this.horiz.parentNode;a.removeChild(this.horiz),a.removeChild(this.vert)};var yh=function(){};yh.prototype.update=function(){return{bottom:0,right:0}},yh.prototype.setScrollLeft=function(){},yh.prototype.setScrollTop=function(){},yh.prototype.clear=function(){};var zh={native:xh,null:yh},Ah=0,Bh=function(a,b,c){var d=a.display;this.viewport=b,this.visible=Nc(d,a.doc,b),this.editorIsHidden=!d.wrapper.offsetWidth,this.wrapperHeight=d.wrapper.clientHeight,this.wrapperWidth=d.wrapper.clientWidth,this.oldDisplayWidth=Pb(a),this.force=c,this.dims=vc(a),this.events=[]};Bh.prototype.signal=function(a,b){Ea(a,b)&&this.events.push(arguments)},Bh.prototype.finish=function(){for(var a=this,b=0;b=0&&K(a,e.to())<=0)return d}return-1};var Fh=function(a,b){this.anchor=a,this.head=b};Fh.prototype.from=function(){return O(this.anchor,this.head)},Fh.prototype.to=function(){return N(this.anchor,this.head)},Fh.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},Pe.prototype={chunkSize:function(){return this.lines.length},removeInner:function(a,b){for(var c=this,d=a,e=a+b;d1||!(this.children[0]instanceof Pe))){var i=[];this.collapse(i),this.children=[new Pe(i)],this.children[0].parent=this}},collapse:function(a){for(var b=this,c=0;c50){for(var h=f.lines.length%25+25,i=h;i10);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=this,e=0;eb.display.maxLineLength&&(b.display.maxLine=k,b.display.maxLineLength=l,b.display.maxLineChanged=!0)}null!=e&&b&&this.collapsed&&rd(b,e,f+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,b&&xe(b.doc)),b&&vb(b,"markerCleared",b,this,e,f),c&&gd(b),this.parent&&this.parent.clear()}},Ih.prototype.find=function(a,b){var c=this;null==a&&"bookmark"==this.type&&(a=1);for(var d,e,f=0;f=0;j--)Ee(d,e[j]);i?te(this,i):this.cm&&Vc(this.cm)})),undo:qd((function(){Ge(this,"undo")})),redo:qd((function(){Ge(this,"redo")})),undoSelection:qd((function(){Ge(this,"undo",!0)})),redoSelection:qd((function(){Ge(this,"redo",!0)})),setExtending:function(a){this.extend=a},getExtending:function(){return this.extend},historySize:function(){for(var a=this.history,b=0,c=0,d=0;d=a.ch)&&b.push(e.marker.parent||e.marker)}return b},findMarks:function(a,b,c){a=Q(this,a),b=Q(this,b);var d=[],e=a.line;return this.iter(a.line,b.line+1,(function(f){var g=f.markedSpans;if(g)for(var h=0;h=i.to||null==i.from&&e!=a.line||null!=i.from&&e==b.line&&i.from>=b.ch||c&&!c(i.marker)||d.push(i.marker.parent||i.marker)}++e})),d},getAllMarks:function(){var a=[];return this.iter((function(b){var c=b.markedSpans;if(c)for(var d=0;da?(b=a,!0):(a-=f,void++c)})),Q(this,J(c,b))},indexFromPos:function(a){a=Q(this,a);var b=a.ch;if(a.lineb&&(b=a.from),null!=a.to&&a.to0)e=new J(e.line,e.ch+1),a.replaceRange(f.charAt(e.ch-1)+f.charAt(e.ch-2),J(e.line,e.ch-2),e,"+transpose");else if(e.line>a.doc.first){var g=B(a.doc,e.line-1).text;g&&(e=new J(e.line,1),a.replaceRange(f.charAt(0)+a.doc.lineSeparator()+g.charAt(g.length-1),J(e.line-1,g.length-1),e,"+transpose"))}c.push(new Fh(e,e))}a.setSelections(c)}))},newlineAndIndent:function(a){return nd(a,(function(){for(var b=a.listSelections(),c=b.length-1;c>=0;c--)a.replaceRange(a.doc.lineSeparator(),b[c].anchor,b[c].head,"+input");b=a.listSelections();for(var d=0;da&&0==K(b,this.pos)&&c==this.button};var Yh,Zh,$h={toString:function(){return"CodeMirror.Init"}},_h={},ai={};Wf.defaults=_h,Wf.optionHandlers=ai;var bi=[];Wf.defineInitHook=function(a){return bi.push(a)};var ci=null,di=function(a){var b=a.optionHandlers,c=a.helpers={};a.prototype={constructor:a,focus:function(){window.focus(),this.display.input.focus()},setOption:function(a,c){var d=this.options,e=d[a];d[a]==c&&"mode"!=a||(d[a]=c,b.hasOwnProperty(a)&&od(this,b[a])(this,c,e),Ba(this,"optionChange",this,a))},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](lf(a))},removeKeyMap:function(a){for(var b=this.state.keyMaps,c=0;cd&&(Yf(b,f.head.line,a,!0),d=f.head.line,e==b.doc.sel.primIndex&&Vc(b));else{var g=f.from(),h=f.to(),i=Math.max(d,g.line);d=Math.min(b.lastLine(),h.line-(h.ch?0:1))+1;for(var j=i;j0&&qe(b.doc,e,new Fh(g,k[e].to()),Ug)}}})),getTokenAt:function(a,b){return bb(this,a,b)},getLineTokens:function(a,b){return bb(this,J(a),b,!0)},getTokenTypeAt:function(a){a=Q(this.doc,a);var b,c=Ya(this,B(this.doc,a.line)),d=0,e=(c.length-1)/2,f=a.ch;if(0==f)b=c[2];else for(;;){var g=d+e>>1;if((g?c[2*g-1]:0)>=f)e=g;else{if(!(c[2*g+1]f&&(a=f,e=!0),d=B(this.doc,a)}else d=a;return gc(this,d,{top:0,left:0},b||"page",c||e).top+(e?this.doc.height-ta(d):0)},defaultTextHeight:function(){return tc(this.display)},defaultCharWidth:function(){return uc(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(a,b,c,d,e){var f=this.display;a=jc(this,Q(this.doc,a));var g=a.bottom,h=a.left;if(b.style.position="absolute",b.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(b),f.sizer.appendChild(b),"over"==d)g=a.top;else if("above"==d||"near"==d){var i=Math.max(f.wrapper.clientHeight,this.doc.height),j=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);("above"==d||a.bottom+b.offsetHeight>i)&&a.top>b.offsetHeight?g=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=i&&(g=a.bottom),h+b.offsetWidth>j&&(h=j-b.offsetWidth)}b.style.top=g+"px",b.style.left=b.style.right="","right"==e?(h=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?h=0:"middle"==e&&(h=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=h+"px"),c&&Sc(this,{left:h,top:g,right:h+b.offsetWidth,bottom:g+b.offsetHeight})},triggerOnKeyDown:pd(Af),triggerOnKeyPress:pd(Df),triggerOnKeyUp:Cf,triggerOnMouseDown:pd(Ff),execCommand:function(a){if(Th.hasOwnProperty(a))return Th[a].call(null,this)},triggerElectric:pd((function(a){ag(this,a)})),findPosH:function(a,b,c,d){var e=this,f=1;b<0&&(f=-1,b=-b);for(var g=Q(this.doc,a),h=0;h0&&h(c.charAt(d-1));)--d;for(;e.5)&&yc(this),Ba(this,"refresh",this)})),swapDoc:pd((function(a){var b=this.doc;return b.cm=null,Zd(this,a),cc(this),this.display.input.reset(),Wc(this,a.scrollLeft,a.scrollTop),this.curOp.forceScroll=!0,vb(this,"swapDoc",this,b),b})),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Fa(a),a.registerHelper=function(b,d,e){c.hasOwnProperty(b)||(c[b]=a[b]={_global:[]}),c[b][d]=e},a.registerGlobalHelper=function(b,d,e,f){a.registerHelper(b,d,f),c[b]._global.push({pred:e,val:f})}},ei=function(a){this.cm=a,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Pg,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};ei.prototype.init=function(a){function b(a){if(!Ca(e,a)){if(e.somethingSelected())Zf({lineWise:!1,text:e.getSelections()}),"cut"==a.type&&e.replaceSelection("",null,"cut");else{if(!e.options.lineWiseCopyCut)return;var b=bg(e);Zf({lineWise:!0,text:b.text}),"cut"==a.type&&e.operation((function(){e.setSelections(b.ranges,0,Ug),e.replaceSelection("",null,"cut")}))}if(a.clipboardData){a.clipboardData.clearData();var c=ci.text.join("\n");if(a.clipboardData.setData("Text",c),a.clipboardData.getData("Text")==c)return void a.preventDefault()}var g=dg(),h=g.firstChild;e.display.lineSpace.insertBefore(g,e.display.lineSpace.firstChild),h.value=ci.text.join("\n");var i=document.activeElement;Og(h),setTimeout((function(){e.display.lineSpace.removeChild(g),i.focus(),i==f&&d.showPrimarySelection()}),50)}}var c=this,d=this,e=d.cm,f=d.div=a.lineDiv;cg(f,e.options.spellcheck),dh(f,"paste",(function(a){Ca(e,a)||_f(a,e)||vg<=11&&setTimeout(od(e,(function(){return c.updateFromDOM()})),20)})),dh(f,"compositionstart",(function(a){c.composing={data:a.data,done:!1}})),dh(f,"compositionupdate",(function(a){c.composing||(c.composing={data:a.data,done:!1})})),dh(f,"compositionend",(function(a){c.composing&&(a.data!=c.composing.data&&c.readFromDOMSoon(),c.composing.done=!0)})),dh(f,"touchstart",(function(){return d.forceCompositionEnd()})),dh(f,"input",(function(){c.composing||c.readFromDOMSoon()})),dh(f,"copy",b),dh(f,"cut",b)},ei.prototype.prepareSelection=function(){var a=Cc(this.cm,!1);return a.focus=this.cm.state.focused,a},ei.prototype.showSelection=function(a,b){a&&this.cm.display.view.length&&((a.focus||b)&&this.showPrimarySelection(),this.showMultipleSelections(a))},ei.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},ei.prototype.showPrimarySelection=function(){var a=this.getSelection(),b=this.cm,c=b.doc.sel.primary(),d=c.from(),e=c.to();if(b.display.viewTo==b.display.viewFrom||d.line>=b.display.viewTo||e.line=b.display.viewFrom&&gg(b,d)||{node:h[0].measure.map[2],offset:0},j=e.linea.firstLine()&&(d=J(d.line-1,B(a.doc,d.line-1).length)),e.ch==B(a.doc,e.line).text.length&&e.lineb.viewTo-1)return!1;var f,g,h;d.line==b.viewFrom||0==(f=Ac(a,d.line))?(g=F(b.view[0].line),h=b.view[0].node):(g=F(b.view[f].line),h=b.view[f-1].node.nextSibling);var i,j,k=Ac(a,e.line);if(k==b.view.length-1?(i=b.viewTo-1,j=b.lineDiv.lastChild):(i=F(b.view[k+1].line)-1,j=b.view[k+1].node.previousSibling),!h)return!1;for(var l=a.doc.splitLines(jg(a,h,j,g,i)),m=C(a.doc,J(g,0),J(i,B(a.doc,i).text.length));l.length>1&&m.length>1;)if(p(l)==p(m))l.pop(),m.pop(),i--;else{if(l[0]!=m[0])break;l.shift(),m.shift(),g++}for(var n=0,o=0,q=l[0],r=m[0],s=Math.min(q.length,r.length);nd.ch&&t.charCodeAt(t.length-o-1)==u.charCodeAt(u.length-o-1);)n--,o++;l[l.length-1]=t.slice(0,t.length-o).replace(/^\u200b+/,""), +l[0]=l[0].slice(n).replace(/\u200b+$/,"");var w=J(g,n),x=J(i,m.length?p(m).length-o:0);return l.length>1||l[0]||K(w,x)?(Ke(a.doc,l,w,x,"+input"),!0):void 0},ei.prototype.ensurePolled=function(){this.forceCompositionEnd()},ei.prototype.reset=function(){this.forceCompositionEnd()},ei.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},ei.prototype.readFromDOMSoon=function(){var a=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout((function(){if(a.readDOMTimeout=null,a.composing){if(!a.composing.done)return;a.composing=null}a.updateFromDOM()}),80))},ei.prototype.updateFromDOM=function(){var a=this;!this.cm.isReadOnly()&&this.pollContent()||nd(this.cm,(function(){return rd(a.cm)}))},ei.prototype.setUneditable=function(a){a.contentEditable="false"},ei.prototype.onKeyPress=function(a){0==a.charCode||this.composing||(a.preventDefault(),this.cm.isReadOnly()||od(this.cm,$f)(this.cm,String.fromCharCode(null==a.charCode?a.keyCode:a.charCode),0))},ei.prototype.readOnlyChanged=function(a){this.div.contentEditable=String("nocursor"!=a)},ei.prototype.onContextMenu=function(){},ei.prototype.resetPosition=function(){},ei.prototype.needsContentAttribute=!0;var fi=function(a){this.cm=a,this.prevInput="",this.pollingFast=!1,this.polling=new Pg,this.hasSelection=!1,this.composing=null};fi.prototype.init=function(a){function b(a){if(!Ca(e,a)){if(e.somethingSelected())Zf({lineWise:!1,text:e.getSelections()});else{if(!e.options.lineWiseCopyCut)return;var b=bg(e);Zf({lineWise:!0,text:b.text}),"cut"==a.type?e.setSelections(b.ranges,null,Ug):(d.prevInput="",f.value=b.text.join("\n"),Og(f))}"cut"==a.type&&(e.state.cutIncoming=!0)}}var c=this,d=this,e=this.cm;this.createField(a);var f=this.textarea;a.wrapper.insertBefore(this.wrapper,a.wrapper.firstChild),Dg&&(f.style.width="0px"),dh(f,"input",(function(){ug&&vg>=9&&c.hasSelection&&(c.hasSelection=null),d.poll()})),dh(f,"paste",(function(a){Ca(e,a)||_f(a,e)||(e.state.pasteIncoming=!0,d.fastPoll())})),dh(f,"cut",b),dh(f,"copy",b),dh(a.scroller,"paste",(function(b){Kb(a,b)||Ca(e,b)||(e.state.pasteIncoming=!0,d.focus())})),dh(a.lineSpace,"selectstart",(function(b){Kb(a,b)||Ga(b)})),dh(f,"compositionstart",(function(){var a=e.getCursor("from");d.composing&&d.composing.range.clear(),d.composing={start:a,range:e.markText(a,e.getCursor("to"),{className:"CodeMirror-composing"})}})),dh(f,"compositionend",(function(){d.composing&&(d.poll(),d.composing.range.clear(),d.composing=null)}))},fi.prototype.createField=function(a){this.wrapper=dg(),this.textarea=this.wrapper.firstChild},fi.prototype.prepareSelection=function(){var a=this.cm,b=a.display,c=a.doc,d=Cc(a);if(a.options.moveInputWithCursor){var e=jc(a,c.sel.primary().head,"div"),f=b.wrapper.getBoundingClientRect(),g=b.lineDiv.getBoundingClientRect();d.teTop=Math.max(0,Math.min(b.wrapper.clientHeight-10,e.top+g.top-f.top)),d.teLeft=Math.max(0,Math.min(b.wrapper.clientWidth-10,e.left+g.left-f.left))}return d},fi.prototype.showSelection=function(a){var b=this.cm,d=b.display;c(d.cursorDiv,a.cursors),c(d.selectionDiv,a.selection),null!=a.teTop&&(this.wrapper.style.top=a.teTop+"px",this.wrapper.style.left=a.teLeft+"px")},fi.prototype.reset=function(a){if(!this.contextMenuPending&&!this.composing){var b=this.cm;if(b.somethingSelected()){this.prevInput="";var c=b.getSelection();this.textarea.value=c,b.state.focused&&Og(this.textarea),ug&&vg>=9&&(this.hasSelection=c)}else a||(this.prevInput=this.textarea.value="",ug&&vg>=9&&(this.hasSelection=null))}},fi.prototype.getField=function(){return this.textarea},fi.prototype.supportsTouch=function(){return!1},fi.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!Fg||g()!=this.textarea))try{this.textarea.focus()}catch(a){}},fi.prototype.blur=function(){this.textarea.blur()},fi.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},fi.prototype.receivedFocus=function(){this.slowPoll()},fi.prototype.slowPoll=function(){var a=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,(function(){a.poll(),a.cm.state.focused&&a.slowPoll()}))},fi.prototype.fastPoll=function(){function a(){var d=c.poll();d||b?(c.pollingFast=!1,c.slowPoll()):(b=!0,c.polling.set(60,a))}var b=!1,c=this;c.pollingFast=!0,c.polling.set(20,a)},fi.prototype.poll=function(){var a=this,b=this.cm,c=this.textarea,d=this.prevInput;if(this.contextMenuPending||!b.state.focused||gh(c)&&!d&&!this.composing||b.isReadOnly()||b.options.disableInput||b.state.keySeq)return!1;var e=c.value;if(e==d&&!b.somethingSelected())return!1;if(ug&&vg>=9&&this.hasSelection===e||Gg&&/[\uf700-\uf7ff]/.test(e))return b.display.input.reset(),!1;if(b.doc.sel==b.display.selForContextMenu){var f=e.charCodeAt(0);if(8203!=f||d||(d="​"),8666==f)return this.reset(),this.cm.execCommand("undo")}for(var g=0,h=Math.min(d.length,e.length);g1e3||e.indexOf("\n")>-1?c.value=a.prevInput="":a.prevInput=e,a.composing&&(a.composing.range.clear(),a.composing.range=b.markText(a.composing.start,b.getCursor("to"),{className:"CodeMirror-composing"}))})),!0},fi.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},fi.prototype.onKeyPress=function(){ug&&vg>=9&&(this.hasSelection=null),this.fastPoll()},fi.prototype.onContextMenu=function(a){function b(){if(null!=g.selectionStart){var a=e.somethingSelected(),b="​"+(a?g.value:"");g.value="⇚",g.value=b,d.prevInput=a?"":"​",g.selectionStart=1,g.selectionEnd=b.length,f.selForContextMenu=e.doc.sel}}function c(){if(d.contextMenuPending=!1,d.wrapper.style.cssText=l,g.style.cssText=k,ug&&vg<9&&f.scrollbars.setScrollTop(f.scroller.scrollTop=i),null!=g.selectionStart){(!ug||ug&&vg<9)&&b();var a=0,c=function(){f.selForContextMenu==e.doc.sel&&0==g.selectionStart&&g.selectionEnd>0&&"​"==d.prevInput?od(e,Ce)(e):a++<10?f.detectingSelectAll=setTimeout(c,500):(f.selForContextMenu=null,f.input.reset())};f.detectingSelectAll=setTimeout(c,200)}}var d=this,e=d.cm,f=e.display,g=d.textarea,h=zc(e,a),i=f.scroller.scrollTop;if(h&&!zg){var j=e.options.resetSelectionOnContextMenu;j&&e.doc.sel.contains(h)==-1&&od(e,ue)(e.doc,Od(h),Ug);var k=g.style.cssText,l=d.wrapper.style.cssText;d.wrapper.style.cssText="position: absolute";var m=d.wrapper.getBoundingClientRect();g.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(a.clientY-m.top-5)+"px; left: "+(a.clientX-m.left-5)+"px;\n z-index: 1000; background: "+(ug?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var n;if(wg&&(n=window.scrollY),f.input.focus(),wg&&window.scrollTo(null,n),f.input.reset(),e.somethingSelected()||(g.value=d.prevInput=" "),d.contextMenuPending=!0,f.selForContextMenu=e.doc.sel,clearTimeout(f.detectingSelectAll),ug&&vg>=9&&b(),Mg){Ja(a);var o=function(){Aa(window,"mouseup",o),setTimeout(c,20)};dh(window,"mouseup",o)}else setTimeout(c,50)}},fi.prototype.readOnlyChanged=function(a){a||this.reset(),this.textarea.disabled="nocursor"==a},fi.prototype.setUneditable=function(){},fi.prototype.needsContentAttribute=!1,Sf(Wf),di(Wf);var gi="iter insert remove copy getEditor constructor".split(" ");for(var hi in Lh.prototype)Lh.prototype.hasOwnProperty(hi)&&m(gi,hi)<0&&(Wf.prototype[hi]=(function(a){return function(){return a.apply(this.doc,arguments)}})(Lh.prototype[hi]));return Fa(Lh),Wf.inputStyles={textarea:fi,contenteditable:ei},Wf.defineMode=function(a){Wf.defaults.mode||"null"==a||(Wf.defaults.mode=a),Pa.apply(this,arguments)},Wf.defineMIME=Qa,Wf.defineMode("null",(function(){return{token:function(a){return a.skipToEnd()}}})),Wf.defineMIME("text/plain","null"),Wf.defineExtension=function(a,b){Wf.prototype[a]=b},Wf.defineDocExtension=function(a,b){Lh.prototype[a]=b},Wf.fromTextArea=mg,ng(Wf),Wf.version="5.38.0",Wf})); \ No newline at end of file diff --git a/media/editors/codemirror/mode/javascript/javascript.js b/media/editors/codemirror/mode/javascript/javascript.js index c4a709c624972..097c0bbe6d665 100644 --- a/media/editors/codemirror/mode/javascript/javascript.js +++ b/media/editors/codemirror/mode/javascript/javascript.js @@ -75,17 +75,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return ret(ch); } else if (ch == "=" && stream.eat(">")) { return ret("=>", "operator"); - } else if (ch == "0" && stream.eat(/x/i)) { - stream.eatWhile(/[\da-f]/i); - return ret("number", "number"); - } else if (ch == "0" && stream.eat(/o/i)) { - stream.eatWhile(/[0-7]/i); - return ret("number", "number"); - } else if (ch == "0" && stream.eat(/b/i)) { - stream.eatWhile(/[01]/i); + } else if (ch == "0" && stream.match(/^(?:x[\da-f]+|o[0-7]+|b[01]+)n?/i)) { return ret("number", "number"); } else if (/\d/.test(ch)) { - stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/); + stream.match(/^\d*(?:n|(?:\.\d*)?(?:[eE][+\-]?\d+)?)?/); return ret("number", "number"); } else if (ch == "/") { if (stream.eat("*")) { @@ -96,7 +89,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return ret("comment", "comment"); } else if (expressionAllowed(stream, state, 1)) { readRegexp(stream); - stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/); + stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/); return ret("regexp", "string-2"); } else { stream.eat("="); @@ -265,21 +258,42 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { pass.apply(null, arguments); return true; } + function inList(name, list) { + for (var v = list; v; v = v.next) if (v.name == name) return true + return false; + } function register(varname) { - function inList(list) { - for (var v = list; v; v = v.next) - if (v.name == varname) return true; - return false; - } var state = cx.state; cx.marked = "def"; if (state.context) { - if (inList(state.localVars)) return; - state.localVars = {name: varname, next: state.localVars}; + if (state.lexical.info == "var" && state.context && state.context.block) { + // FIXME function decls are also not block scoped + var newContext = registerVarScoped(varname, state.context) + if (newContext != null) { + state.context = newContext + return + } + } else if (!inList(varname, state.localVars)) { + state.localVars = new Var(varname, state.localVars) + return + } + } + // Fall through means this is global + if (parserConfig.globalVars && !inList(varname, state.globalVars)) + state.globalVars = new Var(varname, state.globalVars) + } + function registerVarScoped(varname, context) { + if (!context) { + return null + } else if (context.block) { + var inner = registerVarScoped(varname, context.prev) + if (!inner) return null + if (inner == context.prev) return context + return new Context(inner, context.vars, true) + } else if (inList(varname, context.vars)) { + return context } else { - if (inList(state.globalVars)) return; - if (parserConfig.globalVars) - state.globalVars = {name: varname, next: state.globalVars}; + return new Context(context.prev, new Var(varname, context.vars), false) } } @@ -289,15 +303,23 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { // Combinators - var defaultVars = {name: "this", next: {name: "arguments"}}; + function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block } + function Var(name, next) { this.name = name; this.next = next } + + var defaultVars = new Var("this", new Var("arguments", null)) function pushcontext() { - cx.state.context = {prev: cx.state.context, vars: cx.state.localVars}; - cx.state.localVars = defaultVars; + cx.state.context = new Context(cx.state.context, cx.state.localVars, false) + cx.state.localVars = defaultVars + } + function pushblockcontext() { + cx.state.context = new Context(cx.state.context, cx.state.localVars, true) + cx.state.localVars = null } function popcontext() { - cx.state.localVars = cx.state.context.vars; - cx.state.context = cx.state.context.prev; + cx.state.localVars = cx.state.context.vars + cx.state.context = cx.state.context.prev } + popcontext.lex = true function pushlex(type, info) { var result = function() { var state = cx.state, indent = state.indented; @@ -329,12 +351,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { } function statement(type, value) { - if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex); + if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex); if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex); if (type == "keyword b") return cont(pushlex("form"), statement, poplex); if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex); if (type == "debugger") return cont(expect(";")); - if (type == "{") return cont(pushlex("}"), block, poplex); + if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext); if (type == ";") return cont(); if (type == "if") { if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex) @@ -363,18 +385,20 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { return cont(pushlex("stat"), maybelabel); } } - if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), - block, poplex, poplex); + if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext, + block, poplex, poplex, popcontext); if (type == "case") return cont(expression, expect(":")); if (type == "default") return cont(expect(":")); - if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"), - statement, poplex, popcontext); + if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext); if (type == "export") return cont(pushlex("stat"), afterExport, poplex); if (type == "import") return cont(pushlex("stat"), afterImport, poplex); if (type == "async") return cont(statement) if (value == "@") return cont(expression, statement) return pass(pushlex("stat"), expression, expect(";"), poplex); } + function maybeCatchBinding(type) { + if (type == "(") return cont(funarg, expect(")")) + } function expression(type, value) { return expressionInner(type, value, false); } @@ -783,7 +807,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { cc: [], lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false), localVars: parserConfig.localVars, - context: parserConfig.localVars && {vars: parserConfig.localVars}, + context: parserConfig.localVars && new Context(null, null, false), indented: basecolumn || 0 }; if (parserConfig.globalVars && typeof parserConfig.globalVars == "object") @@ -824,7 +848,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { lexical = lexical.prev; var type = lexical.type, closing = firstChar == type; - if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0); + if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0); else if (type == "form" && firstChar == "{") return lexical.indented; else if (type == "form") return lexical.indented + indentUnit; else if (type == "stat") diff --git a/media/editors/codemirror/mode/javascript/javascript.min.js b/media/editors/codemirror/mode/javascript/javascript.min.js index 2c7636b9649c8..a41beec69bcb2 100644 --- a/media/editors/codemirror/mode/javascript/javascript.min.js +++ b/media/editors/codemirror/mode/javascript/javascript.min.js @@ -1 +1 @@ -!(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})((function(a){"use strict";a.defineMode("javascript",(function(b,c){function d(a){for(var b,c=!1,d=!1;null!=(b=a.next());){if(!c){if("/"==b&&!d)return;"["==b?d=!0:d&&"]"==b&&(d=!1)}c=!c&&"\\"==b}}function e(a,b,c){return Ga=a,Ha=c,b}function f(a,b){var c=a.next();if('"'==c||"'"==c)return b.tokenize=g(c),b.tokenize(a,b);if("."==c&&a.match(/^\d+(?:[eE][+\-]?\d+)?/))return e("number","number");if("."==c&&a.match(".."))return e("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(c))return e(c);if("="==c&&a.eat(">"))return e("=>","operator");if("0"==c&&a.eat(/x/i))return a.eatWhile(/[\da-f]/i),e("number","number");if("0"==c&&a.eat(/o/i))return a.eatWhile(/[0-7]/i),e("number","number");if("0"==c&&a.eat(/b/i))return a.eatWhile(/[01]/i),e("number","number");if(/\d/.test(c))return a.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),e("number","number");if("/"==c)return a.eat("*")?(b.tokenize=h,h(a,b)):a.eat("/")?(a.skipToEnd(),e("comment","comment")):Fa(a,b,1)?(d(a),a.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/),e("regexp","string-2")):(a.eat("="),e("operator","operator",a.current()));if("`"==c)return b.tokenize=i,i(a,b);if("#"==c)return a.skipToEnd(),e("error","error");if(Pa.test(c))return">"==c&&b.lexical&&">"==b.lexical.type||(a.eat("=")?"!"!=c&&"="!=c||a.eat("="):/[<>*+\-]/.test(c)&&(a.eat(c),">"==c&&a.eat(c))),e("operator","operator",a.current());if(Na.test(c)){a.eatWhile(Na);var f=a.current();if("."!=b.lastType){if(Oa.propertyIsEnumerable(f)){var j=Oa[f];return e(j.type,j.style,f)}if("async"==f&&a.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/,!1))return e("async","keyword",f)}return e("variable","variable",f)}}function g(a){return function(b,c){var d,g=!1;if(Ka&&"@"==b.peek()&&b.match(Qa))return c.tokenize=f,e("jsonld-keyword","meta");for(;null!=(d=b.next())&&(d!=a||g);)g=!g&&"\\"==d;return g||(c.tokenize=f),e("string","string")}}function h(a,b){for(var c,d=!1;c=a.next();){if("/"==c&&d){b.tokenize=f;break}d="*"==c}return e("comment","comment")}function i(a,b){for(var c,d=!1;null!=(c=a.next());){if(!d&&("`"==c||"$"==c&&a.eat("{"))){b.tokenize=f;break}d=!d&&"\\"==c}return e("quasi","string-2",a.current())}function j(a,b){b.fatArrowAt&&(b.fatArrowAt=null);var c=a.string.indexOf("=>",a.start);if(!(c<0)){if(Ma){var d=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(a.string.slice(a.start,c));d&&(c=d.index)}for(var e=0,f=!1,g=c-1;g>=0;--g){var h=a.string.charAt(g),i=Ra.indexOf(h);if(i>=0&&i<3){if(!e){++g;break}if(0==--e){"("==h&&(f=!0);break}}else if(i>=3&&i<6)++e;else if(Na.test(h))f=!0;else{if(/["'\/]/.test(h))return;if(f&&!e){++g;break}}}f&&!e&&(b.fatArrowAt=g)}}function k(a,b,c,d,e,f){this.indented=a,this.column=b,this.type=c,this.prev=e,this.info=f,null!=d&&(this.align=d)}function l(a,b){for(var c=a.localVars;c;c=c.next)if(c.name==b)return!0;for(var d=a.context;d;d=d.prev)for(var c=d.vars;c;c=c.next)if(c.name==b)return!0}function m(a,b,c,d,e){var f=a.cc;for(Ta.state=a,Ta.stream=e,Ta.marked=null,Ta.cc=f,Ta.style=b,a.lexical.hasOwnProperty("align")||(a.lexical.align=!0);;){var g=f.length?f.pop():La?x:w;if(g(c,d)){for(;f.length&&f[f.length-1].lex;)f.pop()();return Ta.marked?Ta.marked:"variable"==c&&l(a,d)?"variable-2":b}}}function n(){for(var a=arguments.length-1;a>=0;a--)Ta.cc.push(arguments[a])}function o(){return n.apply(null,arguments),!0}function p(a){function b(b){for(var c=b;c;c=c.next)if(c.name==a)return!0;return!1}var d=Ta.state;if(Ta.marked="def",d.context){if(b(d.localVars))return;d.localVars={name:a,next:d.localVars}}else{if(b(d.globalVars))return;c.globalVars&&(d.globalVars={name:a,next:d.globalVars})}}function q(a){return"public"==a||"private"==a||"protected"==a||"abstract"==a||"readonly"==a}function r(){Ta.state.context={prev:Ta.state.context,vars:Ta.state.localVars},Ta.state.localVars=Ua}function s(){Ta.state.localVars=Ta.state.context.vars,Ta.state.context=Ta.state.context.prev}function t(a,b){var c=function(){var c=Ta.state,d=c.indented;if("stat"==c.lexical.type)d=c.lexical.indented;else for(var e=c.lexical;e&&")"==e.type&&e.align;e=e.prev)d=e.indented;c.lexical=new k(d,Ta.stream.column(),a,null,c.lexical,b)};return c.lex=!0,c}function u(){var a=Ta.state;a.lexical.prev&&(")"==a.lexical.type&&(a.indented=a.lexical.indented),a.lexical=a.lexical.prev)}function v(a){function b(c){return c==a?o():";"==a?n():o(b)}return b}function w(a,b){return"var"==a?o(t("vardef",b.length),ca,v(";"),u):"keyword a"==a?o(t("form"),z,w,u):"keyword b"==a?o(t("form"),w,u):"keyword d"==a?Ta.stream.match(/^\s*$/,!1)?o():o(t("stat"),B,v(";"),u):"debugger"==a?o(v(";")):"{"==a?o(t("}"),S,u):";"==a?o():"if"==a?("else"==Ta.state.lexical.info&&Ta.state.cc[Ta.state.cc.length-1]==u&&Ta.state.cc.pop()(),o(t("form"),z,w,u,ha)):"function"==a?o(na):"for"==a?o(t("form"),ia,w,u):"class"==a||Ma&&"interface"==b?(Ta.marked="keyword",o(t("form"),qa,u)):"variable"==a?Ma&&"declare"==b?(Ta.marked="keyword",o(w)):Ma&&("module"==b||"enum"==b||"type"==b)&&Ta.stream.match(/^\s*\w/,!1)?(Ta.marked="keyword","enum"==b?o(Ca):"type"==b?o(W,v("operator"),W,v(";")):o(t("form"),da,v("{"),t("}"),S,u,u)):Ma&&"namespace"==b?(Ta.marked="keyword",o(t("form"),x,S,u)):Ma&&"abstract"==b?(Ta.marked="keyword",o(w)):o(t("stat"),L):"switch"==a?o(t("form"),z,v("{"),t("}","switch"),S,u,u):"case"==a?o(x,v(":")):"default"==a?o(v(":")):"catch"==a?o(t("form"),r,v("("),oa,v(")"),w,u,s):"export"==a?o(t("stat"),ua,u):"import"==a?o(t("stat"),wa,u):"async"==a?o(w):"@"==b?o(x,w):n(t("stat"),x,v(";"),u)}function x(a,b){return A(a,b,!1)}function y(a,b){return A(a,b,!0)}function z(a){return"("!=a?n():o(t(")"),x,v(")"),u)}function A(a,b,c){if(Ta.state.fatArrowAt==Ta.stream.start){var d=c?H:G;if("("==a)return o(r,t(")"),Q(oa,")"),u,v("=>"),d,s);if("variable"==a)return n(r,da,v("=>"),d,s)}var e=c?D:C;return Sa.hasOwnProperty(a)?o(e):"function"==a?o(na,e):"class"==a||Ma&&"interface"==b?(Ta.marked="keyword",o(t("form"),pa,u)):"keyword c"==a||"async"==a?o(c?y:x):"("==a?o(t(")"),B,v(")"),u,e):"operator"==a||"spread"==a?o(c?y:x):"["==a?o(t("]"),Ba,u,e):"{"==a?R(N,"}",null,e):"quasi"==a?n(E,e):"new"==a?o(I(c)):"import"==a?o(x):o()}function B(a){return a.match(/[;\}\)\],]/)?n():n(x)}function C(a,b){return","==a?o(x):D(a,b,!1)}function D(a,b,c){var d=0==c?C:D,e=0==c?x:y;return"=>"==a?o(r,c?H:G,s):"operator"==a?/\+\+|--/.test(b)||Ma&&"!"==b?o(d):Ma&&"<"==b&&Ta.stream.match(/^([^>]|<.*?>)*>\s*\(/,!1)?o(t(">"),Q(W,">"),u,d):"?"==b?o(x,v(":"),e):o(e):"quasi"==a?n(E,d):";"!=a?"("==a?R(y,")","call",d):"."==a?o(M,d):"["==a?o(t("]"),B,v("]"),u,d):Ma&&"as"==b?(Ta.marked="keyword",o(W,d)):"regexp"==a?(Ta.state.lastType=Ta.marked="operator",Ta.stream.backUp(Ta.stream.pos-Ta.stream.start-1),o(e)):void 0:void 0}function E(a,b){return"quasi"!=a?n():"${"!=b.slice(b.length-2)?o(E):o(x,F)}function F(a){if("}"==a)return Ta.marked="string-2",Ta.state.tokenize=i,o(E)}function G(a){return j(Ta.stream,Ta.state),n("{"==a?w:x)}function H(a){return j(Ta.stream,Ta.state),n("{"==a?w:y)}function I(a){return function(b){return"."==b?o(a?K:J):"variable"==b&&Ma?o(_,a?D:C):n(a?y:x)}}function J(a,b){if("target"==b)return Ta.marked="keyword",o(C)}function K(a,b){if("target"==b)return Ta.marked="keyword",o(D)}function L(a){return":"==a?o(u,w):n(C,v(";"),u)}function M(a){if("variable"==a)return Ta.marked="property",o()}function N(a,b){if("async"==a)return Ta.marked="property",o(N);if("variable"==a||"keyword"==Ta.style){if(Ta.marked="property","get"==b||"set"==b)return o(O);var c;return Ma&&Ta.state.fatArrowAt==Ta.stream.start&&(c=Ta.stream.match(/^\s*:\s*/,!1))&&(Ta.state.fatArrowAt=Ta.stream.pos+c[0].length),o(P)}return"number"==a||"string"==a?(Ta.marked=Ka?"property":Ta.style+" property",o(P)):"jsonld-keyword"==a?o(P):Ma&&q(b)?(Ta.marked="keyword",o(N)):"["==a?o(x,T,v("]"),P):"spread"==a?o(y,P):"*"==b?(Ta.marked="keyword",o(N)):":"==a?n(P):void 0}function O(a){return"variable"!=a?n(P):(Ta.marked="property",o(na))}function P(a){return":"==a?o(y):"("==a?n(na):void 0}function Q(a,b,c){function d(e,f){if(c?c.indexOf(e)>-1:","==e){var g=Ta.state.lexical;return"call"==g.info&&(g.pos=(g.pos||0)+1),o((function(c,d){return c==b||d==b?n():n(a)}),d)}return e==b||f==b?o():o(v(b))}return function(c,e){return c==b||e==b?o():n(a,d)}}function R(a,b,c){for(var d=3;d"),W):void 0}function X(a){if("=>"==a)return o(W)}function Y(a,b){return"variable"==a||"keyword"==Ta.style?(Ta.marked="property",o(Y)):"?"==b?o(Y):":"==a?o(W):"["==a?o(x,T,v("]"),Y):void 0}function Z(a,b){return"variable"==a&&Ta.stream.match(/^\s*[?:]/,!1)||"?"==b?o(Z):":"==a?o(W):n(W)}function $(a,b){return"<"==b?o(t(">"),Q(W,">"),u,$):"|"==b||"."==a||"&"==b?o(W):"["==a?o(v("]"),$):"extends"==b||"implements"==b?(Ta.marked="keyword",o(W)):void 0}function _(a,b){if("<"==b)return o(t(">"),Q(W,">"),u,$)}function aa(){return n(W,ba)}function ba(a,b){if("="==b)return o(W)}function ca(a,b){return"enum"==b?(Ta.marked="keyword",o(Ca)):n(da,T,fa,ga)}function da(a,b){return Ma&&q(b)?(Ta.marked="keyword",o(da)):"variable"==a?(p(b),o()):"spread"==a?o(da):"["==a?R(da,"]"):"{"==a?R(ea,"}"):void 0}function ea(a,b){return"variable"!=a||Ta.stream.match(/^\s*:/,!1)?("variable"==a&&(Ta.marked="property"),"spread"==a?o(da):"}"==a?n():o(v(":"),da,fa)):(p(b),o(fa))}function fa(a,b){if("="==b)return o(y)}function ga(a){if(","==a)return o(ca)}function ha(a,b){if("keyword b"==a&&"else"==b)return o(t("form","else"),w,u)}function ia(a,b){return"await"==b?o(ia):"("==a?o(t(")"),ja,v(")"),u):void 0}function ja(a){return"var"==a?o(ca,v(";"),la):";"==a?o(la):"variable"==a?o(ka):n(x,v(";"),la)}function ka(a,b){return"in"==b||"of"==b?(Ta.marked="keyword",o(x)):o(C,la)}function la(a,b){return";"==a?o(ma):"in"==b||"of"==b?(Ta.marked="keyword",o(x)):n(x,v(";"),ma)}function ma(a){")"!=a&&o(x)}function na(a,b){return"*"==b?(Ta.marked="keyword",o(na)):"variable"==a?(p(b),o(na)):"("==a?o(r,t(")"),Q(oa,")"),u,U,w,s):Ma&&"<"==b?o(t(">"),Q(aa,">"),u,na):void 0}function oa(a,b){return"@"==b&&o(x,oa),"spread"==a?o(oa):Ma&&q(b)?(Ta.marked="keyword",o(oa)):n(da,T,fa)}function pa(a,b){return"variable"==a?qa(a,b):ra(a,b)}function qa(a,b){if("variable"==a)return p(b),o(ra)}function ra(a,b){return"<"==b?o(t(">"),Q(aa,">"),u,ra):"extends"==b||"implements"==b||Ma&&","==a?("implements"==b&&(Ta.marked="keyword"),o(Ma?W:x,ra)):"{"==a?o(t("}"),sa,u):void 0}function sa(a,b){return"async"==a||"variable"==a&&("static"==b||"get"==b||"set"==b||Ma&&q(b))&&Ta.stream.match(/^\s+[\w$\xa1-\uffff]/,!1)?(Ta.marked="keyword",o(sa)):"variable"==a||"keyword"==Ta.style?(Ta.marked="property",o(Ma?ta:na,sa)):"["==a?o(x,T,v("]"),Ma?ta:na,sa):"*"==b?(Ta.marked="keyword",o(sa)):";"==a?o(sa):"}"==a?o():"@"==b?o(x,sa):void 0}function ta(a,b){return"?"==b?o(ta):":"==a?o(W,fa):"="==b?o(y):n(na)}function ua(a,b){return"*"==b?(Ta.marked="keyword",o(Aa,v(";"))):"default"==b?(Ta.marked="keyword",o(x,v(";"))):"{"==a?o(Q(va,"}"),Aa,v(";")):n(w)}function va(a,b){return"as"==b?(Ta.marked="keyword",o(v("variable"))):"variable"==a?n(y,va):void 0}function wa(a){return"string"==a?o():"("==a?n(x):n(xa,ya,Aa)}function xa(a,b){return"{"==a?R(xa,"}"):("variable"==a&&p(b),"*"==b&&(Ta.marked="keyword"),o(za))}function ya(a){if(","==a)return o(xa,ya)}function za(a,b){if("as"==b)return Ta.marked="keyword",o(xa)}function Aa(a,b){if("from"==b)return Ta.marked="keyword",o(x)}function Ba(a){return"]"==a?o():n(Q(y,"]"))}function Ca(){return n(t("form"),da,v("{"),t("}"),Q(Da,"}"),u,u)}function Da(){return n(da,fa)}function Ea(a,b){return"operator"==a.lastType||","==a.lastType||Pa.test(b.charAt(0))||/[,.]/.test(b.charAt(0))}function Fa(a,b,c){return b.tokenize==f&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(b.lastType)||"quasi"==b.lastType&&/\{\s*$/.test(a.string.slice(0,a.pos-(c||0)))}var Ga,Ha,Ia=b.indentUnit,Ja=c.statementIndent,Ka=c.jsonld,La=c.json||Ka,Ma=c.typescript,Na=c.wordCharacters||/[\w$\xa1-\uffff]/,Oa=(function(){function a(a){return{type:a,style:"keyword"}}var b=a("keyword a"),c=a("keyword b"),d=a("keyword c"),e=a("keyword d"),f=a("operator"),g={type:"atom",style:"atom"};return{if:a("if"),while:b,with:b,else:c,do:c,try:c,finally:c,return:e,break:e,continue:e,new:a("new"),delete:d,void:d,throw:d,debugger:a("debugger"),var:a("var"),const:a("var"),let:a("var"),function:a("function"),catch:a("catch"),for:a("for"),switch:a("switch"),case:a("case"),default:a("default"),in:f,typeof:f,instanceof:f,true:g,false:g,null:g,undefined:g,NaN:g,Infinity:g,this:a("this"),class:a("class"),super:a("atom"),yield:d,export:a("export"),import:a("import"),extends:d,await:d}})(),Pa=/[+\-*&%=<>!?|~^@]/,Qa=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,Ra="([{}])",Sa={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,"jsonld-keyword":!0},Ta={state:null,column:null,marked:null,cc:null},Ua={name:"this",next:{name:"arguments"}};return u.lex=!0,{startState:function(a){var b={tokenize:f,lastType:"sof",cc:[],lexical:new k((a||0)-Ia,0,"block",!1),localVars:c.localVars,context:c.localVars&&{vars:c.localVars},indented:a||0};return c.globalVars&&"object"==typeof c.globalVars&&(b.globalVars=c.globalVars),b},token:function(a,b){if(a.sol()&&(b.lexical.hasOwnProperty("align")||(b.lexical.align=!1),b.indented=a.indentation(),j(a,b)),b.tokenize!=h&&a.eatSpace())return null;var c=b.tokenize(a,b);return"comment"==Ga?c:(b.lastType="operator"!=Ga||"++"!=Ha&&"--"!=Ha?Ga:"incdec",m(b,c,Ga,Ha,a))},indent:function(b,d){if(b.tokenize==h)return a.Pass;if(b.tokenize!=f)return 0;var e,g=d&&d.charAt(0),i=b.lexical;if(!/^\s*else\b/.test(d))for(var j=b.cc.length-1;j>=0;--j){var k=b.cc[j];if(k==u)i=i.prev;else if(k!=ha)break}for(;("stat"==i.type||"form"==i.type)&&("}"==g||(e=b.cc[b.cc.length-1])&&(e==C||e==D)&&!/^[,\.=+\-*:?[\(]/.test(d));)i=i.prev;Ja&&")"==i.type&&"stat"==i.prev.type&&(i=i.prev);var l=i.type,m=g==l;return"vardef"==l?i.indented+("operator"==b.lastType||","==b.lastType?i.info+1:0):"form"==l&&"{"==g?i.indented:"form"==l?i.indented+Ia:"stat"==l?i.indented+(Ea(b,d)?Ja||Ia:0):"switch"!=i.info||m||0==c.doubleIndentSwitch?i.align?i.column+(m?0:1):i.indented+(m?0:Ia):i.indented+(/^(?:case|default)\b/.test(d)?Ia:2*Ia)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:La?null:"/*",blockCommentEnd:La?null:"*/",blockCommentContinue:La?null:" * ",lineComment:La?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:La?"json":"javascript",jsonldMode:Ka,jsonMode:La,expressionAllowed:Fa,skipExpression:function(a){var b=a.cc[a.cc.length-1];b!=x&&b!=y||a.cc.pop()}}})),a.registerHelper("wordChars","javascript",/[\w$]/),a.defineMIME("text/javascript","javascript"),a.defineMIME("text/ecmascript","javascript"),a.defineMIME("application/javascript","javascript"),a.defineMIME("application/x-javascript","javascript"),a.defineMIME("application/ecmascript","javascript"),a.defineMIME("application/json",{name:"javascript",json:!0}),a.defineMIME("application/x-json",{name:"javascript",json:!0}),a.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),a.defineMIME("text/typescript",{name:"javascript",typescript:!0}),a.defineMIME("application/typescript",{name:"javascript",typescript:!0})})); \ No newline at end of file +!(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})((function(a){"use strict";a.defineMode("javascript",(function(b,c){function d(a){for(var b,c=!1,d=!1;null!=(b=a.next());){if(!c){if("/"==b&&!d)return;"["==b?d=!0:d&&"]"==b&&(d=!1)}c=!c&&"\\"==b}}function e(a,b,c){return Ma=a,Na=c,b}function f(a,b){var c=a.next();if('"'==c||"'"==c)return b.tokenize=g(c),b.tokenize(a,b);if("."==c&&a.match(/^\d+(?:[eE][+\-]?\d+)?/))return e("number","number");if("."==c&&a.match(".."))return e("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(c))return e(c);if("="==c&&a.eat(">"))return e("=>","operator");if("0"==c&&a.match(/^(?:x[\da-f]+|o[0-7]+|b[01]+)n?/i))return e("number","number");if(/\d/.test(c))return a.match(/^\d*(?:n|(?:\.\d*)?(?:[eE][+\-]?\d+)?)?/),e("number","number");if("/"==c)return a.eat("*")?(b.tokenize=h,h(a,b)):a.eat("/")?(a.skipToEnd(),e("comment","comment")):La(a,b,1)?(d(a),a.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/),e("regexp","string-2")):(a.eat("="),e("operator","operator",a.current()));if("`"==c)return b.tokenize=i,i(a,b);if("#"==c)return a.skipToEnd(),e("error","error");if(Va.test(c))return">"==c&&b.lexical&&">"==b.lexical.type||(a.eat("=")?"!"!=c&&"="!=c||a.eat("="):/[<>*+\-]/.test(c)&&(a.eat(c),">"==c&&a.eat(c))),e("operator","operator",a.current());if(Ta.test(c)){a.eatWhile(Ta);var f=a.current();if("."!=b.lastType){if(Ua.propertyIsEnumerable(f)){var j=Ua[f];return e(j.type,j.style,f)}if("async"==f&&a.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/,!1))return e("async","keyword",f)}return e("variable","variable",f)}}function g(a){return function(b,c){var d,g=!1;if(Qa&&"@"==b.peek()&&b.match(Wa))return c.tokenize=f,e("jsonld-keyword","meta");for(;null!=(d=b.next())&&(d!=a||g);)g=!g&&"\\"==d;return g||(c.tokenize=f),e("string","string")}}function h(a,b){for(var c,d=!1;c=a.next();){if("/"==c&&d){b.tokenize=f;break}d="*"==c}return e("comment","comment")}function i(a,b){for(var c,d=!1;null!=(c=a.next());){if(!d&&("`"==c||"$"==c&&a.eat("{"))){b.tokenize=f;break}d=!d&&"\\"==c}return e("quasi","string-2",a.current())}function j(a,b){b.fatArrowAt&&(b.fatArrowAt=null);var c=a.string.indexOf("=>",a.start);if(!(c<0)){if(Sa){var d=/:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(a.string.slice(a.start,c));d&&(c=d.index)}for(var e=0,f=!1,g=c-1;g>=0;--g){var h=a.string.charAt(g),i=Xa.indexOf(h);if(i>=0&&i<3){if(!e){++g;break}if(0==--e){"("==h&&(f=!0);break}}else if(i>=3&&i<6)++e;else if(Ta.test(h))f=!0;else{if(/["'\/]/.test(h))return;if(f&&!e){++g;break}}}f&&!e&&(b.fatArrowAt=g)}}function k(a,b,c,d,e,f){this.indented=a,this.column=b,this.type=c,this.prev=e,this.info=f,null!=d&&(this.align=d)}function l(a,b){for(var c=a.localVars;c;c=c.next)if(c.name==b)return!0;for(var d=a.context;d;d=d.prev)for(var c=d.vars;c;c=c.next)if(c.name==b)return!0}function m(a,b,c,d,e){var f=a.cc;for(Za.state=a,Za.stream=e,Za.marked=null,Za.cc=f,Za.style=b,a.lexical.hasOwnProperty("align")||(a.lexical.align=!0);;){var g=f.length?f.pop():Ra?D:B;if(g(c,d)){for(;f.length&&f[f.length-1].lex;)f.pop()();return Za.marked?Za.marked:"variable"==c&&l(a,d)?"variable-2":b}}}function n(){for(var a=arguments.length-1;a>=0;a--)Za.cc.push(arguments[a])}function o(){return n.apply(null,arguments),!0}function p(a,b){for(var c=b;c;c=c.next)if(c.name==a)return!0;return!1}function q(a){var b=Za.state;if(Za.marked="def",b.context)if("var"==b.lexical.info&&b.context&&b.context.block){var d=r(a,b.context);if(null!=d)return void(b.context=d)}else if(!p(a,b.localVars))return void(b.localVars=new u(a,b.localVars));c.globalVars&&!p(a,b.globalVars)&&(b.globalVars=new u(a,b.globalVars))}function r(a,b){if(b){if(b.block){var c=r(a,b.prev);return c?c==b.prev?b:new t(c,b.vars,!0):null}return p(a,b.vars)?b:new t(b.prev,new u(a,b.vars),!1)}return null}function s(a){return"public"==a||"private"==a||"protected"==a||"abstract"==a||"readonly"==a}function t(a,b,c){this.prev=a,this.vars=b,this.block=c}function u(a,b){this.name=a,this.next=b}function v(){Za.state.context=new t(Za.state.context,Za.state.localVars,!1),Za.state.localVars=$a}function w(){Za.state.context=new t(Za.state.context,Za.state.localVars,!0),Za.state.localVars=null}function x(){Za.state.localVars=Za.state.context.vars,Za.state.context=Za.state.context.prev}function y(a,b){var c=function(){var c=Za.state,d=c.indented;if("stat"==c.lexical.type)d=c.lexical.indented;else for(var e=c.lexical;e&&")"==e.type&&e.align;e=e.prev)d=e.indented;c.lexical=new k(d,Za.stream.column(),a,null,c.lexical,b)};return c.lex=!0,c}function z(){var a=Za.state;a.lexical.prev&&(")"==a.lexical.type&&(a.indented=a.lexical.indented),a.lexical=a.lexical.prev)}function A(a){function b(c){return c==a?o():";"==a?n():o(b)}return b}function B(a,b){return"var"==a?o(y("vardef",b),ia,A(";"),z):"keyword a"==a?o(y("form"),F,B,z):"keyword b"==a?o(y("form"),B,z):"keyword d"==a?Za.stream.match(/^\s*$/,!1)?o():o(y("stat"),H,A(";"),z):"debugger"==a?o(A(";")):"{"==a?o(y("}"),w,Y,z,x):";"==a?o():"if"==a?("else"==Za.state.lexical.info&&Za.state.cc[Za.state.cc.length-1]==z&&Za.state.cc.pop()(),o(y("form"),F,B,z,na)):"function"==a?o(ta):"for"==a?o(y("form"),oa,B,z):"class"==a||Sa&&"interface"==b?(Za.marked="keyword",o(y("form"),wa,z)):"variable"==a?Sa&&"declare"==b?(Za.marked="keyword",o(B)):Sa&&("module"==b||"enum"==b||"type"==b)&&Za.stream.match(/^\s*\w/,!1)?(Za.marked="keyword","enum"==b?o(Ia):"type"==b?o(aa,A("operator"),aa,A(";")):o(y("form"),ja,A("{"),y("}"),Y,z,z)):Sa&&"namespace"==b?(Za.marked="keyword",o(y("form"),D,Y,z)):Sa&&"abstract"==b?(Za.marked="keyword",o(B)):o(y("stat"),R):"switch"==a?o(y("form"),F,A("{"),y("}","switch"),w,Y,z,z,x):"case"==a?o(D,A(":")):"default"==a?o(A(":")):"catch"==a?o(y("form"),v,C,B,z,x):"export"==a?o(y("stat"),Aa,z):"import"==a?o(y("stat"),Ca,z):"async"==a?o(B):"@"==b?o(D,B):n(y("stat"),D,A(";"),z)}function C(a){if("("==a)return o(ua,A(")"))}function D(a,b){return G(a,b,!1)}function E(a,b){return G(a,b,!0)}function F(a){return"("!=a?n():o(y(")"),D,A(")"),z)}function G(a,b,c){if(Za.state.fatArrowAt==Za.stream.start){var d=c?N:M;if("("==a)return o(v,y(")"),W(ua,")"),z,A("=>"),d,x);if("variable"==a)return n(v,ja,A("=>"),d,x)}var e=c?J:I;return Ya.hasOwnProperty(a)?o(e):"function"==a?o(ta,e):"class"==a||Sa&&"interface"==b?(Za.marked="keyword",o(y("form"),va,z)):"keyword c"==a||"async"==a?o(c?E:D):"("==a?o(y(")"),H,A(")"),z,e):"operator"==a||"spread"==a?o(c?E:D):"["==a?o(y("]"),Ha,z,e):"{"==a?X(T,"}",null,e):"quasi"==a?n(K,e):"new"==a?o(O(c)):"import"==a?o(D):o()}function H(a){return a.match(/[;\}\)\],]/)?n():n(D)}function I(a,b){return","==a?o(D):J(a,b,!1)}function J(a,b,c){var d=0==c?I:J,e=0==c?D:E;return"=>"==a?o(v,c?N:M,x):"operator"==a?/\+\+|--/.test(b)||Sa&&"!"==b?o(d):Sa&&"<"==b&&Za.stream.match(/^([^>]|<.*?>)*>\s*\(/,!1)?o(y(">"),W(aa,">"),z,d):"?"==b?o(D,A(":"),e):o(e):"quasi"==a?n(K,d):";"!=a?"("==a?X(E,")","call",d):"."==a?o(S,d):"["==a?o(y("]"),H,A("]"),z,d):Sa&&"as"==b?(Za.marked="keyword",o(aa,d)):"regexp"==a?(Za.state.lastType=Za.marked="operator",Za.stream.backUp(Za.stream.pos-Za.stream.start-1),o(e)):void 0:void 0}function K(a,b){return"quasi"!=a?n():"${"!=b.slice(b.length-2)?o(K):o(D,L)}function L(a){if("}"==a)return Za.marked="string-2",Za.state.tokenize=i,o(K)}function M(a){return j(Za.stream,Za.state),n("{"==a?B:D)}function N(a){return j(Za.stream,Za.state),n("{"==a?B:E)}function O(a){return function(b){return"."==b?o(a?Q:P):"variable"==b&&Sa?o(fa,a?J:I):n(a?E:D)}}function P(a,b){if("target"==b)return Za.marked="keyword",o(I)}function Q(a,b){if("target"==b)return Za.marked="keyword",o(J)}function R(a){return":"==a?o(z,B):n(I,A(";"),z)}function S(a){if("variable"==a)return Za.marked="property",o()}function T(a,b){if("async"==a)return Za.marked="property",o(T);if("variable"==a||"keyword"==Za.style){if(Za.marked="property","get"==b||"set"==b)return o(U);var c;return Sa&&Za.state.fatArrowAt==Za.stream.start&&(c=Za.stream.match(/^\s*:\s*/,!1))&&(Za.state.fatArrowAt=Za.stream.pos+c[0].length),o(V)}return"number"==a||"string"==a?(Za.marked=Qa?"property":Za.style+" property",o(V)):"jsonld-keyword"==a?o(V):Sa&&s(b)?(Za.marked="keyword",o(T)):"["==a?o(D,Z,A("]"),V):"spread"==a?o(E,V):"*"==b?(Za.marked="keyword",o(T)):":"==a?n(V):void 0}function U(a){return"variable"!=a?n(V):(Za.marked="property",o(ta))}function V(a){return":"==a?o(E):"("==a?n(ta):void 0}function W(a,b,c){function d(e,f){if(c?c.indexOf(e)>-1:","==e){var g=Za.state.lexical;return"call"==g.info&&(g.pos=(g.pos||0)+1),o((function(c,d){return c==b||d==b?n():n(a)}),d)}return e==b||f==b?o():o(A(b))}return function(c,e){return c==b||e==b?o():n(a,d)}}function X(a,b,c){for(var d=3;d"),aa):void 0}function ba(a){if("=>"==a)return o(aa)}function ca(a,b){return"variable"==a||"keyword"==Za.style?(Za.marked="property",o(ca)):"?"==b?o(ca):":"==a?o(aa):"["==a?o(D,Z,A("]"),ca):void 0}function da(a,b){return"variable"==a&&Za.stream.match(/^\s*[?:]/,!1)||"?"==b?o(da):":"==a?o(aa):n(aa)}function ea(a,b){return"<"==b?o(y(">"),W(aa,">"),z,ea):"|"==b||"."==a||"&"==b?o(aa):"["==a?o(A("]"),ea):"extends"==b||"implements"==b?(Za.marked="keyword",o(aa)):void 0}function fa(a,b){if("<"==b)return o(y(">"),W(aa,">"),z,ea)}function ga(){return n(aa,ha)}function ha(a,b){if("="==b)return o(aa)}function ia(a,b){return"enum"==b?(Za.marked="keyword",o(Ia)):n(ja,Z,la,ma)}function ja(a,b){return Sa&&s(b)?(Za.marked="keyword",o(ja)):"variable"==a?(q(b),o()):"spread"==a?o(ja):"["==a?X(ja,"]"):"{"==a?X(ka,"}"):void 0}function ka(a,b){return"variable"!=a||Za.stream.match(/^\s*:/,!1)?("variable"==a&&(Za.marked="property"),"spread"==a?o(ja):"}"==a?n():o(A(":"),ja,la)):(q(b),o(la))}function la(a,b){if("="==b)return o(E)}function ma(a){if(","==a)return o(ia)}function na(a,b){if("keyword b"==a&&"else"==b)return o(y("form","else"),B,z)}function oa(a,b){return"await"==b?o(oa):"("==a?o(y(")"),pa,A(")"),z):void 0}function pa(a){return"var"==a?o(ia,A(";"),ra):";"==a?o(ra):"variable"==a?o(qa):n(D,A(";"),ra)}function qa(a,b){return"in"==b||"of"==b?(Za.marked="keyword",o(D)):o(I,ra)}function ra(a,b){return";"==a?o(sa):"in"==b||"of"==b?(Za.marked="keyword",o(D)):n(D,A(";"),sa)}function sa(a){")"!=a&&o(D)}function ta(a,b){return"*"==b?(Za.marked="keyword",o(ta)):"variable"==a?(q(b),o(ta)):"("==a?o(v,y(")"),W(ua,")"),z,$,B,x):Sa&&"<"==b?o(y(">"),W(ga,">"),z,ta):void 0}function ua(a,b){return"@"==b&&o(D,ua),"spread"==a?o(ua):Sa&&s(b)?(Za.marked="keyword",o(ua)):n(ja,Z,la)}function va(a,b){return"variable"==a?wa(a,b):xa(a,b)}function wa(a,b){if("variable"==a)return q(b),o(xa)}function xa(a,b){return"<"==b?o(y(">"),W(ga,">"),z,xa):"extends"==b||"implements"==b||Sa&&","==a?("implements"==b&&(Za.marked="keyword"),o(Sa?aa:D,xa)):"{"==a?o(y("}"),ya,z):void 0}function ya(a,b){return"async"==a||"variable"==a&&("static"==b||"get"==b||"set"==b||Sa&&s(b))&&Za.stream.match(/^\s+[\w$\xa1-\uffff]/,!1)?(Za.marked="keyword",o(ya)):"variable"==a||"keyword"==Za.style?(Za.marked="property",o(Sa?za:ta,ya)):"["==a?o(D,Z,A("]"),Sa?za:ta,ya):"*"==b?(Za.marked="keyword",o(ya)):";"==a?o(ya):"}"==a?o():"@"==b?o(D,ya):void 0}function za(a,b){return"?"==b?o(za):":"==a?o(aa,la):"="==b?o(E):n(ta)}function Aa(a,b){return"*"==b?(Za.marked="keyword",o(Ga,A(";"))):"default"==b?(Za.marked="keyword",o(D,A(";"))):"{"==a?o(W(Ba,"}"),Ga,A(";")):n(B)}function Ba(a,b){return"as"==b?(Za.marked="keyword",o(A("variable"))):"variable"==a?n(E,Ba):void 0}function Ca(a){return"string"==a?o():"("==a?n(D):n(Da,Ea,Ga)}function Da(a,b){return"{"==a?X(Da,"}"):("variable"==a&&q(b),"*"==b&&(Za.marked="keyword"),o(Fa))}function Ea(a){if(","==a)return o(Da,Ea)}function Fa(a,b){if("as"==b)return Za.marked="keyword",o(Da)}function Ga(a,b){if("from"==b)return Za.marked="keyword",o(D)}function Ha(a){return"]"==a?o():n(W(E,"]"))}function Ia(){return n(y("form"),ja,A("{"),y("}"),W(Ja,"}"),z,z)}function Ja(){return n(ja,la)}function Ka(a,b){return"operator"==a.lastType||","==a.lastType||Va.test(b.charAt(0))||/[,.]/.test(b.charAt(0))}function La(a,b,c){return b.tokenize==f&&/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(b.lastType)||"quasi"==b.lastType&&/\{\s*$/.test(a.string.slice(0,a.pos-(c||0)))}var Ma,Na,Oa=b.indentUnit,Pa=c.statementIndent,Qa=c.jsonld,Ra=c.json||Qa,Sa=c.typescript,Ta=c.wordCharacters||/[\w$\xa1-\uffff]/,Ua=(function(){function a(a){return{type:a,style:"keyword"}}var b=a("keyword a"),c=a("keyword b"),d=a("keyword c"),e=a("keyword d"),f=a("operator"),g={type:"atom",style:"atom"};return{if:a("if"),while:b,with:b,else:c,do:c,try:c,finally:c,return:e,break:e,continue:e,new:a("new"),delete:d,void:d,throw:d,debugger:a("debugger"),var:a("var"),const:a("var"),let:a("var"),function:a("function"),catch:a("catch"),for:a("for"),switch:a("switch"),case:a("case"),default:a("default"),in:f,typeof:f,instanceof:f,true:g,false:g,null:g,undefined:g,NaN:g,Infinity:g,this:a("this"),class:a("class"),super:a("atom"),yield:d,export:a("export"),import:a("import"),extends:d,await:d}})(),Va=/[+\-*&%=<>!?|~^@]/,Wa=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,Xa="([{}])",Ya={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,this:!0,"jsonld-keyword":!0},Za={state:null,column:null,marked:null,cc:null},$a=new u("this",new u("arguments",null));return x.lex=!0,z.lex=!0,{startState:function(a){var b={tokenize:f,lastType:"sof",cc:[],lexical:new k((a||0)-Oa,0,"block",!1),localVars:c.localVars,context:c.localVars&&new t(null,null,!1),indented:a||0};return c.globalVars&&"object"==typeof c.globalVars&&(b.globalVars=c.globalVars),b},token:function(a,b){if(a.sol()&&(b.lexical.hasOwnProperty("align")||(b.lexical.align=!1),b.indented=a.indentation(),j(a,b)),b.tokenize!=h&&a.eatSpace())return null;var c=b.tokenize(a,b);return"comment"==Ma?c:(b.lastType="operator"!=Ma||"++"!=Na&&"--"!=Na?Ma:"incdec",m(b,c,Ma,Na,a))},indent:function(b,d){if(b.tokenize==h)return a.Pass;if(b.tokenize!=f)return 0;var e,g=d&&d.charAt(0),i=b.lexical;if(!/^\s*else\b/.test(d))for(var j=b.cc.length-1;j>=0;--j){var k=b.cc[j];if(k==z)i=i.prev;else if(k!=na)break}for(;("stat"==i.type||"form"==i.type)&&("}"==g||(e=b.cc[b.cc.length-1])&&(e==I||e==J)&&!/^[,\.=+\-*:?[\(]/.test(d));)i=i.prev;Pa&&")"==i.type&&"stat"==i.prev.type&&(i=i.prev);var l=i.type,m=g==l;return"vardef"==l?i.indented+("operator"==b.lastType||","==b.lastType?i.info.length+1:0):"form"==l&&"{"==g?i.indented:"form"==l?i.indented+Oa:"stat"==l?i.indented+(Ka(b,d)?Pa||Oa:0):"switch"!=i.info||m||0==c.doubleIndentSwitch?i.align?i.column+(m?0:1):i.indented+(m?0:Oa):i.indented+(/^(?:case|default)\b/.test(d)?Oa:2*Oa)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:Ra?null:"/*",blockCommentEnd:Ra?null:"*/",blockCommentContinue:Ra?null:" * ",lineComment:Ra?null:"//",fold:"brace",closeBrackets:"()[]{}''\"\"``",helperType:Ra?"json":"javascript",jsonldMode:Qa,jsonMode:Ra,expressionAllowed:La,skipExpression:function(a){var b=a.cc[a.cc.length-1];b!=D&&b!=E||a.cc.pop()}}})),a.registerHelper("wordChars","javascript",/[\w$]/),a.defineMIME("text/javascript","javascript"),a.defineMIME("text/ecmascript","javascript"),a.defineMIME("application/javascript","javascript"),a.defineMIME("application/x-javascript","javascript"),a.defineMIME("application/ecmascript","javascript"),a.defineMIME("application/json",{name:"javascript",json:!0}),a.defineMIME("application/x-json",{name:"javascript",json:!0}),a.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),a.defineMIME("text/typescript",{name:"javascript",typescript:!0}),a.defineMIME("application/typescript",{name:"javascript",typescript:!0})})); \ No newline at end of file diff --git a/media/editors/codemirror/mode/markdown/markdown.js b/media/editors/codemirror/mode/markdown/markdown.js index 72dfd5b8cd5c3..88ecc57c86041 100644 --- a/media/editors/codemirror/mode/markdown/markdown.js +++ b/media/editors/codemirror/mode/markdown/markdown.js @@ -619,7 +619,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) { } if (ch === ' ') { - if (stream.match(/ +$/, false)) { + if (stream.match(/^ +$/, false)) { state.trailingSpace++; } else if (state.trailingSpace) { state.trailingSpaceNewLine = true; diff --git a/media/editors/codemirror/mode/markdown/markdown.min.js b/media/editors/codemirror/mode/markdown/markdown.min.js index de01baa48ddb7..67f4666a9326f 100644 --- a/media/editors/codemirror/mode/markdown/markdown.min.js +++ b/media/editors/codemirror/mode/markdown/markdown.min.js @@ -1 +1 @@ -!(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../xml/xml"),require("../meta")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../meta"],a):a(CodeMirror)})((function(a){"use strict";a.defineMode("markdown",(function(b,c){function d(c){if(a.findModeByName){var d=a.findModeByName(c);d&&(c=d.mime||d.mimes[0])}var e=a.getMode(b,c);return"null"==e.name?null:e}function e(a,b,c){return b.f=b.inline=c,c(a,b)}function f(a,b,c){return b.f=b.block=c,c(a,b)}function g(a){return!a||!/\S/.test(a.string)}function h(a){return a.linkTitle=!1,a.linkHref=!1,a.linkText=!1,a.em=!1,a.strong=!1,a.strikethrough=!1,a.quote=0,a.indentedCode=!1,a.f==j&&(a.f=n,a.block=i),a.trailingSpace=0,a.trailingSpaceNewLine=!1,a.prevLine=a.thisLine,a.thisLine={stream:null},null}function i(b,f){var h=b.column()===f.indentation,i=g(f.prevLine.stream),j=f.indentedCode,m=f.prevLine.hr,n=f.list!==!1,o=(f.listStack[f.listStack.length-1]||0)+3;f.indentedCode=!1;var p=f.indentation;if(null===f.indentationDiff&&(f.indentationDiff=f.indentation,n)){for(f.em=!1,f.strong=!1,f.code=!1,f.strikethrough=!1,f.list=null;p=4&&(j||f.prevLine.fencedCodeEnd||f.prevLine.header||i))return b.skipToEnd(),f.indentedCode=!0,w.code;if(b.eatSpace())return null;if(h&&f.indentation<=o&&(t=b.match(B))&&t[1].length<=6)return f.quote=0,f.header=t[1].length,f.thisLine.header=!0,c.highlightFormatting&&(f.formatting="header"),f.f=f.inline,l(f);if(f.indentation<=o&&b.eat(">"))return f.quote=h?1:f.quote+1,c.highlightFormatting&&(f.formatting="quote"),b.eatSpace(),l(f);if(!s&&!f.setext&&h&&f.indentation<=o&&(t=b.match(z))){var u=t[1]?"ol":"ul";return f.indentation=p+b.current().length,f.list=!0,f.quote=0,f.listStack.push(f.indentation),c.taskLists&&b.match(A,!1)&&(f.taskList=!0),f.f=f.inline,c.highlightFormatting&&(f.formatting=["list","list-"+u]),l(f)}return h&&f.indentation<=o&&(t=b.match(E,!0))?(f.quote=0,f.fencedEndRE=new RegExp(t[1]+"+ *$"),f.localMode=c.fencedCodeBlockHighlighting&&d(t[2]),f.localMode&&(f.localState=a.startState(f.localMode)),f.f=f.block=k,c.highlightFormatting&&(f.formatting="code-block"),f.code=-1,l(f)):f.setext||!(q&&n||f.quote||f.list!==!1||f.code||s||F.test(b.string))&&(t=b.lookAhead(1))&&(t=t.match(C))?(f.setext?(f.header=f.setext,f.setext=0,b.skipToEnd(),c.highlightFormatting&&(f.formatting="header")):(f.header="="==t[0].charAt(0)?1:2,f.setext=f.header),f.thisLine.header=!0,f.f=f.inline,l(f)):s?(b.skipToEnd(),f.hr=!0,f.thisLine.hr=!0,w.hr):"["===b.peek()?e(b,f,r):e(b,f,f.inline)}function j(b,c){var d=u.token(b,c.htmlState);if(!v){var e=a.innerMode(u,c.htmlState);("xml"==e.mode.name&&null===e.state.tagStart&&!e.state.context&&e.state.tokenize.isInText||c.md_inside&&b.current().indexOf(">")>-1)&&(c.f=n,c.block=i,c.htmlState=null)}return d}function k(a,b){var d=b.listStack[b.listStack.length-1]||0,e=b.indentation=a.quote?b.push(w.formatting+"-"+a.formatting[d]+"-"+a.quote):b.push("error"))}if(a.taskOpen)return b.push("meta"),b.length?b.join(" "):null;if(a.taskClosed)return b.push("property"),b.length?b.join(" "):null;if(a.linkHref?b.push(w.linkHref,"url"):(a.strong&&b.push(w.strong),a.em&&b.push(w.em),a.strikethrough&&b.push(w.strikethrough),a.emoji&&b.push(w.emoji),a.linkText&&b.push(w.linkText),a.code&&b.push(w.code),a.image&&b.push(w.image),a.imageAltText&&b.push(w.imageAltText,"link"),a.imageMarker&&b.push(w.imageMarker)),a.header&&b.push(w.header,w.header+"-"+a.header),a.quote&&(b.push(w.quote),!c.maxBlockquoteDepth||c.maxBlockquoteDepth>=a.quote?b.push(w.quote+"-"+a.quote):b.push(w.quote+"-"+c.maxBlockquoteDepth)),a.list!==!1){var e=(a.listStack.length-1)%3;e?1===e?b.push(w.list2):b.push(w.list3):b.push(w.list1)}return a.trailingSpaceNewLine?b.push("trailing-space-new-line"):a.trailingSpace&&b.push("trailing-space-"+(a.trailingSpace%2?"a":"b")),b.length?b.join(" "):null}function m(a,b){if(a.match(D,!0))return l(b)}function n(b,d){var e=d.text(b,d);if("undefined"!=typeof e)return e;if(d.list)return d.list=null,l(d);if(d.taskList){var g=" "===b.match(A,!0)[1];return g?d.taskOpen=!0:d.taskClosed=!0,c.highlightFormatting&&(d.formatting="task"),d.taskList=!1,l(d)}if(d.taskOpen=!1,d.taskClosed=!1,d.header&&b.match(/^#+$/,!0))return c.highlightFormatting&&(d.formatting="header"),l(d);var h=b.next();if(d.linkTitle){d.linkTitle=!1;var i=h;"("===h&&(i=")"),i=(i+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var k="^\\s*(?:[^"+i+"\\\\]+|\\\\\\\\|\\\\.)"+i;if(b.match(new RegExp(k),!0))return w.linkHref}if("`"===h){var m=d.formatting;c.highlightFormatting&&(d.formatting="code"),b.eatWhile("`");var q=b.current().length;if(0!=d.code||d.quote&&1!=q){if(q==d.code){var r=l(d);return d.code=0,r}return d.formatting=m,l(d)}return d.code=q,l(d)}if(d.code)return l(d);if("\\"===h&&(b.next(),c.highlightFormatting)){var s=l(d),t=w.formatting+"-escape";return s?s+" "+t:t}if("!"===h&&b.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return d.imageMarker=!0,d.image=!0,c.highlightFormatting&&(d.formatting="image"),l(d);if("["===h&&d.imageMarker&&b.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return d.imageMarker=!1,d.imageAltText=!0,c.highlightFormatting&&(d.formatting="image"),l(d);if("]"===h&&d.imageAltText){c.highlightFormatting&&(d.formatting="image");var s=l(d);return d.imageAltText=!1,d.image=!1,d.inline=d.f=p,s}if("["===h&&!d.image)return d.linkText=!0,c.highlightFormatting&&(d.formatting="link"),l(d);if("]"===h&&d.linkText){c.highlightFormatting&&(d.formatting="link");var s=l(d);return d.linkText=!1,d.inline=d.f=b.match(/\(.*?\)| ?\[.*?\]/,!1)?p:n,s}if("<"===h&&b.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){d.f=d.inline=o,c.highlightFormatting&&(d.formatting="link");var s=l(d);return s?s+=" ":s="",s+w.linkInline}if("<"===h&&b.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){d.f=d.inline=o,c.highlightFormatting&&(d.formatting="link");var s=l(d);return s?s+=" ":s="",s+w.linkEmail}if(c.xml&&"<"===h&&b.match(/^(!--|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*>)/i,!1)){var v=b.string.indexOf(">",b.pos);if(v!=-1){var x=b.string.substring(b.start,v);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(x)&&(d.md_inside=!0)}return b.backUp(1),d.htmlState=a.startState(u),f(b,d,j)}if(c.xml&&"<"===h&&b.match(/^\/\w*?>/))return d.md_inside=!1,"tag";if("*"===h||"_"===h){for(var y=1,z=1==b.pos?" ":b.string.charAt(b.pos-2);y<3&&b.eat(h);)y++;var B=b.peek()||" ",C=!/\s/.test(B)&&(!G.test(B)||/\s/.test(z)||G.test(z)),D=!/\s/.test(z)&&(!G.test(z)||/\s/.test(B)||G.test(B)),E=null,F=null;if(y%2&&(d.em||!C||"*"!==h&&D&&!G.test(z)?d.em!=h||!D||"*"!==h&&C&&!G.test(B)||(E=!1):E=!0),y>1&&(d.strong||!C||"*"!==h&&D&&!G.test(z)?d.strong!=h||!D||"*"!==h&&C&&!G.test(B)||(F=!1):F=!0),null!=F||null!=E){c.highlightFormatting&&(d.formatting=null==E?"strong":null==F?"em":"strong em"),E===!0&&(d.em=h),F===!0&&(d.strong=h);var r=l(d);return E===!1&&(d.em=!1),F===!1&&(d.strong=!1),r}}else if(" "===h&&(b.eat("*")||b.eat("_"))){if(" "===b.peek())return l(d);b.backUp(1)}if(c.strikethrough)if("~"===h&&b.eatWhile(h)){if(d.strikethrough){c.highlightFormatting&&(d.formatting="strikethrough");var r=l(d);return d.strikethrough=!1,r}if(b.match(/^[^\s]/,!1))return d.strikethrough=!0,c.highlightFormatting&&(d.formatting="strikethrough"),l(d)}else if(" "===h&&b.match(/^~~/,!0)){if(" "===b.peek())return l(d);b.backUp(2)}if(c.emoji&&":"===h&&b.match(/^[a-z_\d+-]+:/)){d.emoji=!0,c.highlightFormatting&&(d.formatting="emoji");var H=l(d);return d.emoji=!1,H}return" "===h&&(b.match(/ +$/,!1)?d.trailingSpace++:d.trailingSpace&&(d.trailingSpaceNewLine=!0)),l(d)}function o(a,b){var d=a.next();if(">"===d){b.f=b.inline=n,c.highlightFormatting&&(b.formatting="link");var e=l(b);return e?e+=" ":e="",e+w.linkInline}return a.match(/^[^>]+/,!0),w.linkInline}function p(a,b){if(a.eatSpace())return null;var d=a.next();return"("===d||"["===d?(b.f=b.inline=q("("===d?")":"]"),c.highlightFormatting&&(b.formatting="link-string"),b.linkHref=!0,l(b)):"error"}function q(a){return function(b,d){var e=b.next();if(e===a){d.f=d.inline=n,c.highlightFormatting&&(d.formatting="link-string");var f=l(d);return d.linkHref=!1,f}return b.match(I[a]),d.linkHref=!0,l(d)}}function r(a,b){return a.match(/^([^\]\\]|\\.)*\]:/,!1)?(b.f=s,a.next(),c.highlightFormatting&&(b.formatting="link"),b.linkText=!0,l(b)):e(a,b,n)}function s(a,b){if(a.match(/^\]:/,!0)){b.f=b.inline=t,c.highlightFormatting&&(b.formatting="link");var d=l(b);return b.linkText=!1,d}return a.match(/^([^\]\\]|\\.)+/,!0),w.linkText}function t(a,b){return a.eatSpace()?null:(a.match(/^[^\s]+/,!0),void 0===a.peek()?b.linkTitle=!0:a.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),b.f=b.inline=n,w.linkHref+" url")}var u=a.getMode(b,"text/html"),v="null"==u.name;void 0===c.highlightFormatting&&(c.highlightFormatting=!1),void 0===c.maxBlockquoteDepth&&(c.maxBlockquoteDepth=0),void 0===c.taskLists&&(c.taskLists=!1),void 0===c.strikethrough&&(c.strikethrough=!1),void 0===c.emoji&&(c.emoji=!1),void 0===c.fencedCodeBlockHighlighting&&(c.fencedCodeBlockHighlighting=!0),void 0===c.xml&&(c.xml=!0),void 0===c.tokenTypeOverrides&&(c.tokenTypeOverrides={});var w={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(var x in w)w.hasOwnProperty(x)&&c.tokenTypeOverrides[x]&&(w[x]=c.tokenTypeOverrides[x]);var y=/^([*\-_])(?:\s*\1){2,}\s*$/,z=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,A=/^\[(x| )\](?=\s)/i,B=c.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,C=/^ *(?:\={1,}|-{1,})\s*$/,D=/^[^#!\[\]*_\\<>` "'(~:]+/,E=/^(~~~+|```+)[ \t]*([\w+#-]*)[^\n`]*$/,F=/^\s*\[[^\]]+?\]:.*$/,G=/[!\"#$%&\'()*+,\-\.\/:;<=>?@\[\\\]^_`{|}~—]/,H=" ",I={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/},J={startState:function(){return{f:i,prevLine:{stream:null},thisLine:{stream:null},block:i,htmlState:null,indentation:0,inline:n,text:m,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(b){return{f:b.f,prevLine:b.prevLine,thisLine:b.thisLine,block:b.block,htmlState:b.htmlState&&a.copyState(u,b.htmlState),indentation:b.indentation,localMode:b.localMode,localState:b.localMode?a.copyState(b.localMode,b.localState):null,inline:b.inline,text:b.text,formatting:!1,linkText:b.linkText,linkTitle:b.linkTitle,linkHref:b.linkHref,code:b.code,em:b.em,strong:b.strong,strikethrough:b.strikethrough,emoji:b.emoji,header:b.header,setext:b.setext,hr:b.hr,taskList:b.taskList,list:b.list,listStack:b.listStack.slice(0),quote:b.quote,indentedCode:b.indentedCode,trailingSpace:b.trailingSpace,trailingSpaceNewLine:b.trailingSpaceNewLine,md_inside:b.md_inside,fencedEndRE:b.fencedEndRE}},token:function(a,b){if(b.formatting=!1,a!=b.thisLine.stream){if(b.header=0,b.hr=!1,a.match(/^\s*$/,!0))return h(b),null;if(b.prevLine=b.thisLine,b.thisLine={stream:a},b.taskList=!1,b.trailingSpace=0,b.trailingSpaceNewLine=!1,!b.localState&&(b.f=b.block,b.f!=j)){var c=a.match(/^\s*/,!0)[0].replace(/\t/g,H).length;if(b.indentation=c,b.indentationDiff=null,c>0)return null}}return b.f(a,b)},innerMode:function(a){return a.block==j?{state:a.htmlState,mode:u}:a.localState?{state:a.localState,mode:a.localMode}:{state:a,mode:J}},indent:function(b,c,d){return b.block==j&&u.indent?u.indent(b.htmlState,c,d):b.localState&&b.localMode.indent?b.localMode.indent(b.localState,c,d):a.Pass},blankLine:h,getType:l,closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return J}),"xml"),a.defineMIME("text/markdown","markdown"),a.defineMIME("text/x-markdown","markdown")})); \ No newline at end of file +!(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../xml/xml"),require("../meta")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../meta"],a):a(CodeMirror)})((function(a){"use strict";a.defineMode("markdown",(function(b,c){function d(c){if(a.findModeByName){var d=a.findModeByName(c);d&&(c=d.mime||d.mimes[0])}var e=a.getMode(b,c);return"null"==e.name?null:e}function e(a,b,c){return b.f=b.inline=c,c(a,b)}function f(a,b,c){return b.f=b.block=c,c(a,b)}function g(a){return!a||!/\S/.test(a.string)}function h(a){return a.linkTitle=!1,a.linkHref=!1,a.linkText=!1,a.em=!1,a.strong=!1,a.strikethrough=!1,a.quote=0,a.indentedCode=!1,a.f==j&&(a.f=n,a.block=i),a.trailingSpace=0,a.trailingSpaceNewLine=!1,a.prevLine=a.thisLine,a.thisLine={stream:null},null}function i(b,f){var h=b.column()===f.indentation,i=g(f.prevLine.stream),j=f.indentedCode,m=f.prevLine.hr,n=f.list!==!1,o=(f.listStack[f.listStack.length-1]||0)+3;f.indentedCode=!1;var p=f.indentation;if(null===f.indentationDiff&&(f.indentationDiff=f.indentation,n)){for(f.em=!1,f.strong=!1,f.code=!1,f.strikethrough=!1,f.list=null;p=4&&(j||f.prevLine.fencedCodeEnd||f.prevLine.header||i))return b.skipToEnd(),f.indentedCode=!0,w.code;if(b.eatSpace())return null;if(h&&f.indentation<=o&&(t=b.match(B))&&t[1].length<=6)return f.quote=0,f.header=t[1].length,f.thisLine.header=!0,c.highlightFormatting&&(f.formatting="header"),f.f=f.inline,l(f);if(f.indentation<=o&&b.eat(">"))return f.quote=h?1:f.quote+1,c.highlightFormatting&&(f.formatting="quote"),b.eatSpace(),l(f);if(!s&&!f.setext&&h&&f.indentation<=o&&(t=b.match(z))){var u=t[1]?"ol":"ul";return f.indentation=p+b.current().length,f.list=!0,f.quote=0,f.listStack.push(f.indentation),c.taskLists&&b.match(A,!1)&&(f.taskList=!0),f.f=f.inline,c.highlightFormatting&&(f.formatting=["list","list-"+u]),l(f)}return h&&f.indentation<=o&&(t=b.match(E,!0))?(f.quote=0,f.fencedEndRE=new RegExp(t[1]+"+ *$"),f.localMode=c.fencedCodeBlockHighlighting&&d(t[2]),f.localMode&&(f.localState=a.startState(f.localMode)),f.f=f.block=k,c.highlightFormatting&&(f.formatting="code-block"),f.code=-1,l(f)):f.setext||!(q&&n||f.quote||f.list!==!1||f.code||s||F.test(b.string))&&(t=b.lookAhead(1))&&(t=t.match(C))?(f.setext?(f.header=f.setext,f.setext=0,b.skipToEnd(),c.highlightFormatting&&(f.formatting="header")):(f.header="="==t[0].charAt(0)?1:2,f.setext=f.header),f.thisLine.header=!0,f.f=f.inline,l(f)):s?(b.skipToEnd(),f.hr=!0,f.thisLine.hr=!0,w.hr):"["===b.peek()?e(b,f,r):e(b,f,f.inline)}function j(b,c){var d=u.token(b,c.htmlState);if(!v){var e=a.innerMode(u,c.htmlState);("xml"==e.mode.name&&null===e.state.tagStart&&!e.state.context&&e.state.tokenize.isInText||c.md_inside&&b.current().indexOf(">")>-1)&&(c.f=n,c.block=i,c.htmlState=null)}return d}function k(a,b){var d=b.listStack[b.listStack.length-1]||0,e=b.indentation=a.quote?b.push(w.formatting+"-"+a.formatting[d]+"-"+a.quote):b.push("error"))}if(a.taskOpen)return b.push("meta"),b.length?b.join(" "):null;if(a.taskClosed)return b.push("property"),b.length?b.join(" "):null;if(a.linkHref?b.push(w.linkHref,"url"):(a.strong&&b.push(w.strong),a.em&&b.push(w.em),a.strikethrough&&b.push(w.strikethrough),a.emoji&&b.push(w.emoji),a.linkText&&b.push(w.linkText),a.code&&b.push(w.code),a.image&&b.push(w.image),a.imageAltText&&b.push(w.imageAltText,"link"),a.imageMarker&&b.push(w.imageMarker)),a.header&&b.push(w.header,w.header+"-"+a.header),a.quote&&(b.push(w.quote),!c.maxBlockquoteDepth||c.maxBlockquoteDepth>=a.quote?b.push(w.quote+"-"+a.quote):b.push(w.quote+"-"+c.maxBlockquoteDepth)),a.list!==!1){var e=(a.listStack.length-1)%3;e?1===e?b.push(w.list2):b.push(w.list3):b.push(w.list1)}return a.trailingSpaceNewLine?b.push("trailing-space-new-line"):a.trailingSpace&&b.push("trailing-space-"+(a.trailingSpace%2?"a":"b")),b.length?b.join(" "):null}function m(a,b){if(a.match(D,!0))return l(b)}function n(b,d){var e=d.text(b,d);if("undefined"!=typeof e)return e;if(d.list)return d.list=null,l(d);if(d.taskList){var g=" "===b.match(A,!0)[1];return g?d.taskOpen=!0:d.taskClosed=!0,c.highlightFormatting&&(d.formatting="task"),d.taskList=!1,l(d)}if(d.taskOpen=!1,d.taskClosed=!1,d.header&&b.match(/^#+$/,!0))return c.highlightFormatting&&(d.formatting="header"),l(d);var h=b.next();if(d.linkTitle){d.linkTitle=!1;var i=h;"("===h&&(i=")"),i=(i+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var k="^\\s*(?:[^"+i+"\\\\]+|\\\\\\\\|\\\\.)"+i;if(b.match(new RegExp(k),!0))return w.linkHref}if("`"===h){var m=d.formatting;c.highlightFormatting&&(d.formatting="code"),b.eatWhile("`");var q=b.current().length;if(0!=d.code||d.quote&&1!=q){if(q==d.code){var r=l(d);return d.code=0,r}return d.formatting=m,l(d)}return d.code=q,l(d)}if(d.code)return l(d);if("\\"===h&&(b.next(),c.highlightFormatting)){var s=l(d),t=w.formatting+"-escape";return s?s+" "+t:t}if("!"===h&&b.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return d.imageMarker=!0,d.image=!0,c.highlightFormatting&&(d.formatting="image"),l(d);if("["===h&&d.imageMarker&&b.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return d.imageMarker=!1,d.imageAltText=!0,c.highlightFormatting&&(d.formatting="image"),l(d);if("]"===h&&d.imageAltText){c.highlightFormatting&&(d.formatting="image");var s=l(d);return d.imageAltText=!1,d.image=!1,d.inline=d.f=p,s}if("["===h&&!d.image)return d.linkText=!0,c.highlightFormatting&&(d.formatting="link"),l(d);if("]"===h&&d.linkText){c.highlightFormatting&&(d.formatting="link");var s=l(d);return d.linkText=!1,d.inline=d.f=b.match(/\(.*?\)| ?\[.*?\]/,!1)?p:n,s}if("<"===h&&b.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){d.f=d.inline=o,c.highlightFormatting&&(d.formatting="link");var s=l(d);return s?s+=" ":s="",s+w.linkInline}if("<"===h&&b.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){d.f=d.inline=o,c.highlightFormatting&&(d.formatting="link");var s=l(d);return s?s+=" ":s="",s+w.linkEmail}if(c.xml&&"<"===h&&b.match(/^(!--|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*>)/i,!1)){var v=b.string.indexOf(">",b.pos);if(v!=-1){var x=b.string.substring(b.start,v);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(x)&&(d.md_inside=!0)}return b.backUp(1),d.htmlState=a.startState(u),f(b,d,j)}if(c.xml&&"<"===h&&b.match(/^\/\w*?>/))return d.md_inside=!1,"tag";if("*"===h||"_"===h){for(var y=1,z=1==b.pos?" ":b.string.charAt(b.pos-2);y<3&&b.eat(h);)y++;var B=b.peek()||" ",C=!/\s/.test(B)&&(!G.test(B)||/\s/.test(z)||G.test(z)),D=!/\s/.test(z)&&(!G.test(z)||/\s/.test(B)||G.test(B)),E=null,F=null;if(y%2&&(d.em||!C||"*"!==h&&D&&!G.test(z)?d.em!=h||!D||"*"!==h&&C&&!G.test(B)||(E=!1):E=!0),y>1&&(d.strong||!C||"*"!==h&&D&&!G.test(z)?d.strong!=h||!D||"*"!==h&&C&&!G.test(B)||(F=!1):F=!0),null!=F||null!=E){c.highlightFormatting&&(d.formatting=null==E?"strong":null==F?"em":"strong em"),E===!0&&(d.em=h),F===!0&&(d.strong=h);var r=l(d);return E===!1&&(d.em=!1),F===!1&&(d.strong=!1),r}}else if(" "===h&&(b.eat("*")||b.eat("_"))){if(" "===b.peek())return l(d);b.backUp(1)}if(c.strikethrough)if("~"===h&&b.eatWhile(h)){if(d.strikethrough){c.highlightFormatting&&(d.formatting="strikethrough");var r=l(d);return d.strikethrough=!1,r}if(b.match(/^[^\s]/,!1))return d.strikethrough=!0,c.highlightFormatting&&(d.formatting="strikethrough"),l(d)}else if(" "===h&&b.match(/^~~/,!0)){if(" "===b.peek())return l(d);b.backUp(2)}if(c.emoji&&":"===h&&b.match(/^[a-z_\d+-]+:/)){d.emoji=!0,c.highlightFormatting&&(d.formatting="emoji");var H=l(d);return d.emoji=!1,H}return" "===h&&(b.match(/^ +$/,!1)?d.trailingSpace++:d.trailingSpace&&(d.trailingSpaceNewLine=!0)),l(d)}function o(a,b){var d=a.next();if(">"===d){b.f=b.inline=n,c.highlightFormatting&&(b.formatting="link");var e=l(b);return e?e+=" ":e="",e+w.linkInline}return a.match(/^[^>]+/,!0),w.linkInline}function p(a,b){if(a.eatSpace())return null;var d=a.next();return"("===d||"["===d?(b.f=b.inline=q("("===d?")":"]"),c.highlightFormatting&&(b.formatting="link-string"),b.linkHref=!0,l(b)):"error"}function q(a){return function(b,d){var e=b.next();if(e===a){d.f=d.inline=n,c.highlightFormatting&&(d.formatting="link-string");var f=l(d);return d.linkHref=!1,f}return b.match(I[a]),d.linkHref=!0,l(d)}}function r(a,b){return a.match(/^([^\]\\]|\\.)*\]:/,!1)?(b.f=s,a.next(),c.highlightFormatting&&(b.formatting="link"),b.linkText=!0,l(b)):e(a,b,n)}function s(a,b){if(a.match(/^\]:/,!0)){b.f=b.inline=t,c.highlightFormatting&&(b.formatting="link");var d=l(b);return b.linkText=!1,d}return a.match(/^([^\]\\]|\\.)+/,!0),w.linkText}function t(a,b){return a.eatSpace()?null:(a.match(/^[^\s]+/,!0),void 0===a.peek()?b.linkTitle=!0:a.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),b.f=b.inline=n,w.linkHref+" url")}var u=a.getMode(b,"text/html"),v="null"==u.name;void 0===c.highlightFormatting&&(c.highlightFormatting=!1),void 0===c.maxBlockquoteDepth&&(c.maxBlockquoteDepth=0),void 0===c.taskLists&&(c.taskLists=!1),void 0===c.strikethrough&&(c.strikethrough=!1),void 0===c.emoji&&(c.emoji=!1),void 0===c.fencedCodeBlockHighlighting&&(c.fencedCodeBlockHighlighting=!0),void 0===c.xml&&(c.xml=!0),void 0===c.tokenTypeOverrides&&(c.tokenTypeOverrides={});var w={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(var x in w)w.hasOwnProperty(x)&&c.tokenTypeOverrides[x]&&(w[x]=c.tokenTypeOverrides[x]);var y=/^([*\-_])(?:\s*\1){2,}\s*$/,z=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,A=/^\[(x| )\](?=\s)/i,B=c.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,C=/^ *(?:\={1,}|-{1,})\s*$/,D=/^[^#!\[\]*_\\<>` "'(~:]+/,E=/^(~~~+|```+)[ \t]*([\w+#-]*)[^\n`]*$/,F=/^\s*\[[^\]]+?\]:.*$/,G=/[!\"#$%&\'()*+,\-\.\/:;<=>?@\[\\\]^_`{|}~—]/,H=" ",I={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/},J={startState:function(){return{f:i,prevLine:{stream:null},thisLine:{stream:null},block:i,htmlState:null,indentation:0,inline:n,text:m,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(b){return{f:b.f,prevLine:b.prevLine,thisLine:b.thisLine,block:b.block,htmlState:b.htmlState&&a.copyState(u,b.htmlState),indentation:b.indentation,localMode:b.localMode,localState:b.localMode?a.copyState(b.localMode,b.localState):null,inline:b.inline,text:b.text,formatting:!1,linkText:b.linkText,linkTitle:b.linkTitle,linkHref:b.linkHref,code:b.code,em:b.em,strong:b.strong,strikethrough:b.strikethrough,emoji:b.emoji,header:b.header,setext:b.setext,hr:b.hr,taskList:b.taskList,list:b.list,listStack:b.listStack.slice(0),quote:b.quote,indentedCode:b.indentedCode,trailingSpace:b.trailingSpace,trailingSpaceNewLine:b.trailingSpaceNewLine,md_inside:b.md_inside,fencedEndRE:b.fencedEndRE}},token:function(a,b){if(b.formatting=!1,a!=b.thisLine.stream){if(b.header=0,b.hr=!1,a.match(/^\s*$/,!0))return h(b),null;if(b.prevLine=b.thisLine,b.thisLine={stream:a},b.taskList=!1,b.trailingSpace=0,b.trailingSpaceNewLine=!1,!b.localState&&(b.f=b.block,b.f!=j)){var c=a.match(/^\s*/,!0)[0].replace(/\t/g,H).length;if(b.indentation=c,b.indentationDiff=null,c>0)return null}}return b.f(a,b)},innerMode:function(a){return a.block==j?{state:a.htmlState,mode:u}:a.localState?{state:a.localState,mode:a.localMode}:{state:a,mode:J}},indent:function(b,c,d){return b.block==j&&u.indent?u.indent(b.htmlState,c,d):b.localState&&b.localMode.indent?b.localMode.indent(b.localState,c,d):a.Pass},blankLine:h,getType:l,closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return J}),"xml"),a.defineMIME("text/markdown","markdown"),a.defineMIME("text/x-markdown","markdown")})); \ No newline at end of file diff --git a/media/editors/codemirror/theme/darcula.css b/media/editors/codemirror/theme/darcula.css new file mode 100644 index 0000000000000..c789459116d9b --- /dev/null +++ b/media/editors/codemirror/theme/darcula.css @@ -0,0 +1,34 @@ +/** + Name: IntelliJ IDEA darcula theme + From IntelliJ IDEA by JetBrains + */ + +.cm-s-darcula span.cm-meta { color: #BBB529; } +.cm-s-darcula span.cm-number { color: #6897BB; } +.cm-s-darcula span.cm-keyword { line-height: 1em; font-weight: bold; color: #CC7832; } +.cm-s-darcula span.cm-def { color: #FFC66D; } +.cm-s-darcula span.cm-variable { color: #A9B7C6; } +.cm-s-darcula span.cm-variable-2 { color: #A9B7C6; } +.cm-s-darcula span.cm-variable-3, .cm-s-darcula span.cm-type { color: #A9B7C6; } +.cm-s-darcula span.cm-property { color: #A9B7C6; } +.cm-s-darcula span.cm-operator { color: #A9B7C6; } +.cm-s-darcula span.cm-string { color: #6A8759; } +.cm-s-darcula span.cm-string-2 { color: #6A8759; } +.cm-s-darcula span.cm-comment { color: #808080; } +.cm-s-darcula span.cm-link { color: #287BDE; } +.cm-s-darcula span.cm-atom { font-weight: bold; color: #CC7832; } +.cm-s-darcula span.cm-error { color: #BC3F3C; } +.cm-s-darcula span.cm-tag { color: #CC7832; } +.cm-s-darcula span.cm-attribute { color: #6A8759; } +.cm-s-darcula span.cm-qualifier { color: #6A8759; } +.cm-s-darcula span.cm-bracket { color: #A9B7C6; } +.cm-s-darcula.CodeMirror { background: #2B2B2B; color: #A9B7C6; } + + +.cm-s-darcula .CodeMirror-activeline-background { background: #3A3A3A; } +.cm-s-darcula div.CodeMirror-selected { background: #085a9c; } +.cm-s-darcula .CodeMirror-gutters { background: rgb(72, 72, 72); border-right: 1px solid grey; color: #606366 } + +.cm-s-darcula span.cm-builtin { color: #A9B7C6; } +.cm-s-darcula { font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;} +.cm-s-darcula .CodeMirror-matchingbracket { outline:1px solid #A9B7C6; color: yellow !important; } \ No newline at end of file diff --git a/media/editors/codemirror/theme/lesser-dark.css b/media/editors/codemirror/theme/lesser-dark.css index b2ec418fdbc4c..4b347db081bef 100644 --- a/media/editors/codemirror/theme/lesser-dark.css +++ b/media/editors/codemirror/theme/lesser-dark.css @@ -38,7 +38,7 @@ Ported to CodeMirror by Peter Kroon .cm-s-lesser-dark span.cm-builtin { color: #ff9e59; } .cm-s-lesser-dark span.cm-bracket { color: #EBEFE7; } .cm-s-lesser-dark span.cm-tag { color: #669199; } -.cm-s-lesser-dark span.cm-attribute { color: #00c; } +.cm-s-lesser-dark span.cm-attribute { color: #81a4d5; } .cm-s-lesser-dark span.cm-hr { color: #999; } .cm-s-lesser-dark span.cm-link { color: #00c; } .cm-s-lesser-dark span.cm-error { color: #9d1e15; } diff --git a/media/editors/codemirror/theme/monokai.css b/media/editors/codemirror/theme/monokai.css index b5edd13fe68af..cd4cd5572092d 100644 --- a/media/editors/codemirror/theme/monokai.css +++ b/media/editors/codemirror/theme/monokai.css @@ -14,6 +14,11 @@ .cm-s-monokai span.cm-atom { color: #ae81ff; } .cm-s-monokai span.cm-number { color: #ae81ff; } +.cm-s-monokai span.cm-comment.cm-attribute { color: #97b757; } +.cm-s-monokai span.cm-comment.cm-def { color: #bc9262; } +.cm-s-monokai span.cm-comment.cm-tag { color: #bc6283; } +.cm-s-monokai span.cm-comment.cm-type { color: #5998a6; } + .cm-s-monokai span.cm-property, .cm-s-monokai span.cm-attribute { color: #a6e22e; } .cm-s-monokai span.cm-keyword { color: #f92672; } .cm-s-monokai span.cm-builtin { color: #66d9ef; } diff --git a/plugins/editors/codemirror/codemirror.xml b/plugins/editors/codemirror/codemirror.xml index 9012124b1725c..00c6625934767 100644 --- a/plugins/editors/codemirror/codemirror.xml +++ b/plugins/editors/codemirror/codemirror.xml @@ -1,7 +1,7 @@ plg_editors_codemirror - 5.37.0 + 5.38.0 28 March 2011 Marijn Haverbeke marijnh@gmail.com