From 5aad217d34dba68f154feb663b7c0639c76b45f2 Mon Sep 17 00:00:00 2001
From: Cheng-Han, Wu
Date: Mon, 8 Feb 2016 22:51:07 -0600
Subject: Support change keymap and indentation type with size in statusbar
---
public/css/index.css | 83 ++++++++++++-
public/js/index.js | 178 +++++++++++++++++++++++++++-
public/vendor/codemirror/codemirror.min.js | 30 +++--
public/vendor/codemirror/compress.sh | 4 +-
public/vendor/codemirror/theme/one-dark.css | 4 +
public/views/statusbar.html | 24 ++++
6 files changed, 301 insertions(+), 22 deletions(-)
create mode 100644 public/views/statusbar.html
(limited to 'public')
diff --git a/public/css/index.css b/public/css/index.css
index 58d708bf..e85c6f71 100644
--- a/public/css/index.css
+++ b/public/css/index.css
@@ -326,7 +326,6 @@ div[contenteditable]:empty:not(:focus):before{
font-size: 11px;
line-height: 25px;
height: 26px;
- overflow: hidden;
}
.status-bar .status-info {
@@ -351,14 +350,90 @@ div[contenteditable]:empty:not(:focus):before{
background: #1c1c1e;
color: #ccc;
position: absolute;
- right: 10px;
+ right: 0;
text-align: right;
white-space: nowrap;
- max-width: 30%;
- overflow: hidden;
text-overflow: ellipsis;
}
+.status-bar .status-indicators > div {
+ float: right;
+ padding: 0 10px;
+ border-left: 1px solid #343434;
+}
+
+.status-bar .status-indicators .status-keymap > a {
+ color: inherit;
+ text-decoration: none;
+}
+
+.status-bar .indent-type, .status-bar .indent-width-label {
+ cursor: pointer;
+/* margin-right: 3px;*/
+}
+
+.status-bar .indent-width-input {
+ font-size: 12px;
+ font-weight: 500;
+ height: 18px;
+ line-height: 1;
+ vertical-align: middle;
+ color: #ccc;
+ margin: 0;
+ padding: 0 0 2px;
+ position: relative;
+ left: 0;
+ top: -1px;
+ width: 18px;
+ transition: .1s linear all;
+ background-color: #555;
+ border: 1px solid #202020;
+ color: #fff;
+ box-shadow: inset 0 1px 0 rgba(0,0,0,0.06);
+ border-radius: 3px;
+ text-align: center;
+}
+
+.status-bar .indent-width-input:focus {
+ border: 1px solid #2893ef;
+}
+
+.status-bar .indent-width-input::-webkit-inner-spin-button,
+.status-bar .indent-width-input::-webkit-outer-spin-button {
+ -webkit-appearance: none;
+ margin: 0;
+}
+
+.status-bar .status-indent > * {
+ display: inline-block;
+}
+
+.status-bar .status-indent > *.hidden {
+ display: none;
+}
+
+.status-bar .status-overwrite:hover, .status-bar .indent-type:hover, .status-bar .indent-width-label:hover {
+ text-decoration: underline;
+}
+
+.status-bar .dropdown-menu {
+ background-color: #000;
+ color: #fff;
+ border: 1px solid rgba(255,255,255,0.09) !important;
+}
+
+.status-bar .dropdown-menu .divider {
+ background-color: #343434;
+}
+
+.status-bar .dropdown-menu > li > a {
+ color: #ccc;
+}
+
+.status-bar .dropdown-menu > li > a:focus, .status-bar .dropdown-menu > li > a:hover {
+ background-color: #212121;
+}
+
@media print {
body {
padding-top: 0 !important;
diff --git a/public/js/index.js b/public/js/index.js
index b2a07ff3..b4e33ae3 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -18,7 +18,33 @@ var defaultExtraKeys = {
"Ctrl-S": function () {
return CodeMirror.PASS
},
- "Enter": "newlineAndIndentContinueMarkdownList"
+ "Enter": "newlineAndIndentContinueMarkdownList",
+ "Tab": function(cm) {
+ var tab = '\t';
+ var spaces = Array(parseInt(cm.getOption("indentUnit")) + 1).join(" ");
+ //auto indent whole line when in list or blockquote
+ var cursor = cm.getCursor();
+ var line = cm.getLine(cursor.line);
+ var regex = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))/;
+ var match;
+ if ((match = regex.exec(line)) !== null) {
+ var ch = match[1].length;
+ var pos = {
+ line: cursor.line,
+ ch: ch
+ };
+ if (editor.getOption('indentWithTabs'))
+ cm.replaceRange(tab, pos, pos, '+input');
+ else
+ cm.replaceRange(spaces, pos, pos, '+input');
+ } else {
+ if (editor.getOption('indentWithTabs'))
+ cm.execCommand('defaultTab');
+ else {
+ cm.replaceSelection(spaces);
+ }
+ }
+ }
};
var idleTime = 300000; //5 mins
@@ -250,20 +276,164 @@ var editor = CodeMirror.fromTextArea(textit, {
var inlineAttach = inlineAttachment.editors.codemirror4.attach(editor);
defaultTextHeight = parseInt($(".CodeMirror").css('line-height'));
+var statusBarTemplate = null;
var statusBar = null;
var statusCursor = null;
var statusFile = null;
var statusIndicators = null;
+var statusLength = null;
+var statusKeymap = null;
+var statusIndent = null;
+
+$.get('/views/statusbar.html', function (template) {
+ statusBarTemplate = template;
+});
function addStatusBar() {
- var element = '
';
- statusBar = $(element);
+ statusBar = $(statusBarTemplate);
statusCursor = statusBar.find('.status-cursor');
statusFile = statusBar.find('.status-file');
statusIndicators = statusBar.find('.status-indicators');
+ statusIndent = statusBar.find('.status-indent');
+ statusKeymap = statusBar.find('.status-keymap');
+ statusLength = statusBar.find('.status-length');
editor.addPanel(statusBar[0], {
position: "bottom"
});
+
+ setIndent();
+ setKeymap();
+}
+
+function setIndent() {
+ var cookieIndentType = Cookies.get('indent_type');
+ var cookieTabSize = parseInt(Cookies.get('tab_size'));
+ var cookieSpaceUnits = parseInt(Cookies.get('space_units'));
+ if (cookieIndentType) {
+ if (cookieIndentType == 'tab') {
+ editor.setOption('indentWithTabs', true);
+ if (cookieTabSize)
+ editor.setOption('indentUnit', cookieTabSize);
+ } else if (cookieIndentType == 'space') {
+ editor.setOption('indentWithTabs', false);
+ if (cookieSpaceUnits)
+ editor.setOption('indentUnit', cookieSpaceUnits);
+ }
+ }
+ if (cookieTabSize)
+ editor.setOption('tabSize', cookieTabSize);
+
+ var type = statusIndicators.find('.indent-type');
+ var widthLabel = statusIndicators.find('.indent-width-label');
+ var widthInput = statusIndicators.find('.indent-width-input');
+
+ function setType() {
+ if (editor.getOption('indentWithTabs')) {
+ Cookies.set('indent_type', 'tab', {
+ expires: 365
+ });
+ type.text('Tab Size:');
+ } else {
+ Cookies.set('indent_type', 'space', {
+ expires: 365
+ });
+ type.text('Spaces:');
+ }
+ }
+ setType();
+
+ function setUnit() {
+ var unit = editor.getOption('indentUnit');
+ if (editor.getOption('indentWithTabs')) {
+ Cookies.set('tab_size', unit, {
+ expires: 365
+ });
+ } else {
+ Cookies.set('space_units', unit, {
+ expires: 365
+ });
+ }
+ widthLabel.text(unit);
+ }
+ setUnit();
+
+ type.click(function() {
+ if (editor.getOption('indentWithTabs')) {
+ editor.setOption('indentWithTabs', false);
+ cookieSpaceUnits = parseInt(Cookies.get('space_units'));
+ if (cookieSpaceUnits)
+ editor.setOption('indentUnit', cookieSpaceUnits)
+ } else {
+ editor.setOption('indentWithTabs', true);
+ cookieTabSize = parseInt(Cookies.get('tab_size'));
+ if (cookieTabSize) {
+ editor.setOption('indentUnit', cookieTabSize);
+ editor.setOption('tabSize', cookieTabSize);
+ }
+ }
+ setType();
+ setUnit();
+ });
+ widthLabel.click(function() {
+ if (widthLabel.is(':visible')) {
+ widthLabel.addClass('hidden');
+ widthInput.removeClass('hidden');
+ widthInput.val(editor.getOption('indentUnit'));
+ widthInput.select();
+ } else {
+ widthLabel.removeClass('hidden');
+ widthInput.addClass('hidden');
+ }
+ });
+ widthInput.on('change', function() {
+ var val = widthInput.val();
+ if (!val) val = editor.getOption('indentUnit');
+ if (val < 1) val = 1;
+ else if (val > 10) val = 10;
+
+ if (editor.getOption('indentWithTabs')) {
+ editor.setOption('tabSize', val);
+ }
+ editor.setOption('indentUnit', val);
+ setUnit();
+ });
+ widthInput.on('blur', function() {
+ widthLabel.removeClass('hidden');
+ widthInput.addClass('hidden');
+ });
+}
+
+function setKeymap() {
+ var cookieKeymap = Cookies.get('keymap');
+ if (cookieKeymap)
+ editor.setOption('keyMap', cookieKeymap);
+
+ var label = statusIndicators.find('.ui-keymap-label');
+ var sublime = statusIndicators.find('.ui-keymap-sublime');
+ var emacs = statusIndicators.find('.ui-keymap-emacs');
+ var vim = statusIndicators.find('.ui-keymap-vim');
+
+ function setKeymapLabel() {
+ var keymap = editor.getOption('keyMap');
+ Cookies.set('keymap', keymap, {
+ expires: 365
+ });
+ label.text(keymap);
+ }
+ setKeymapLabel();
+
+ sublime.click(function() {
+ editor.setOption('keyMap', 'sublime');
+ setKeymapLabel();
+ });
+ emacs.click(function() {
+ editor.setOption('keyMap', 'emacs');
+ setKeymapLabel();
+ });
+ vim.click(function() {
+ editor.setOption('keyMap', 'vim');
+ setKeymapLabel();
+ });
}
var selection = null;
@@ -294,7 +464,7 @@ function updateStatusBar() {
statusCursor.text(cursorText);
var fileText = ' — ' + editor.lineCount() + ' Lines';
statusFile.text(fileText);
- statusIndicators.text('Length ' + editor.getValue().length);
+ statusLength.text('Length ' + editor.getValue().length);
}
//ui vars
diff --git a/public/vendor/codemirror/codemirror.min.js b/public/vendor/codemirror/codemirror.min.js
index a45ab1d6..7cb7736c 100644
--- a/public/vendor/codemirror/codemirror.min.js
+++ b/public/vendor/codemirror/codemirror.min.js
@@ -1,16 +1,20 @@
-!function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);(this||window).CodeMirror=e()}}(function(){"use strict";function e(n,r){if(!(this instanceof e))return new e(n,r);this.options=r=r?ji(r):{},ji(ea,r,!1),p(r);var i=r.value;"string"==typeof i&&(i=new Ca(i,r.mode,null,r.lineSeparator)),this.doc=i;var o=new e.inputStyles[r.inputStyle](this),a=this.display=new t(n,i,o);a.wrapper.CodeMirror=this,c(this),l(this),r.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),r.autofocus&&!zo&&a.input.focus(),v(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 Ei,keySeq:null,specialChars:null};var s=this;xo&&11>ko&&setTimeout(function(){s.display.input.reset(!0)},20),$t(this),Xi(),kt(this),this.curOp.forceUpdate=!0,Yr(this,i),r.autofocus&&!zo||s.hasFocus()?setTimeout(Ri(yn,this),20):bn(this);for(var u in ta)ta.hasOwnProperty(u)&&ta[u](this,r[u],na);_(this),r.finishInit&&r.finishInit(this);for(var d=0;dko&&(r.gutters.style.zIndex=-1,r.scroller.style.paddingRight=0),_o||vo&&zo||(r.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(r.wrapper):e(r.wrapper)),r.viewFrom=r.viewTo=t.first,r.reportedViewFrom=r.reportedViewTo=t.first,r.view=[],r.renderedView=null,r.externalMeasured=null,r.viewOffset=0,r.lastWrapHeight=r.lastWrapWidth=0,r.updateLineNumbers=null,r.nativeBarWidth=r.barHeight=r.barWidth=0,r.scrollbarsClipped=!1,r.lineNumWidth=r.lineNumInnerWidth=r.lineNumChars=null,r.alignWidgets=!1,r.cachedCharWidth=r.cachedTextHeight=r.cachedPaddingH=null,r.maxLine=null,r.maxLineLength=0,r.maxLineChanged=!1,r.wheelDX=r.wheelDY=r.wheelStartX=r.wheelStartY=null,r.shift=!1,r.selForContextMenu=null,r.activeTouch=null,n.init(r)}function n(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),r(t)}function r(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,We(e,100),e.state.modeGen++,e.curOp&&It(e)}function i(e){e.options.lineWrapping?(Qa(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Ya(e.display.wrapper,"CodeMirror-wrap"),f(e)),a(e),It(e),st(e),setTimeout(function(){y(e)},100)}function o(e){var t=bt(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/xt(e.display)-3);return function(i){if(wr(e.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;at.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}function p(e){var t=Ni(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function h(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+Ue(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+Ge(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}function m(e,t,n){this.cm=n;var r=this.vert=$i("div",[$i("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=$i("div",[$i("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(r),e(i),za(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),za(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,xo&&8>ko&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function g(){}function v(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Ya(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),za(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,n){"horizontal"==n?an(t,e):on(t,e)},t),t.display.scrollbars.addClass&&Qa(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=h(e));var n=e.display.barWidth,r=e.display.barHeight;b(e,t);for(var i=0;4>i&&n!=e.display.barWidth||r!=e.display.barHeight;i++)n!=e.display.barWidth&&e.options.lineWrapping&&E(e),b(e,h(e)),n=e.display.barWidth,r=e.display.barHeight}function b(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}function x(e,t,n){var r=n&&null!=n.top?Math.max(0,n.top):e.scroller.scrollTop;r=Math.floor(r-Be(e));var i=n&&null!=n.bottom?n.bottom:r+e.wrapper.clientHeight,o=ri(t,r),a=ri(t,i);if(n&&n.ensure){var l=n.ensure.from.line,s=n.ensure.to.line;o>l?(o=l,a=ri(t,ii(Qr(t,l))+e.wrapper.clientHeight)):Math.min(s,t.lastLine())>=a&&(o=ri(t,ii(Qr(t,s))-e.wrapper.clientHeight),a=s)}return{from:o,to:Math.max(a,o+1)}}function k(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=C(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",a=0;a=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==Ht(e))return!1;_(e)&&(jt(e),t.dims=q(e));var i=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),a=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFroma&&n.viewTo-a<20&&(a=Math.min(i,n.viewTo)),Do&&(o=kr(e.doc,o),a=_r(e.doc,a));var l=o!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;Ft(e,o,a),n.viewOffset=ii(Qr(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var s=Ht(e);if(!l&&0==s&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var c=Vi();return s>4&&(n.lineDiv.style.display="none"),N(e,n.updateLineNumbers,t.dims),s>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,c&&Vi()!=c&&c.offsetHeight&&c.focus(),Bi(n.cursorDiv),Bi(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,l&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,We(e,400)),n.updateLineNumbers=null,!0}function T(e,t){for(var n=t.viewport,r=!0;(r&&e.options.lineWrapping&&t.oldDisplayWidth!=Ke(e)||(n&&null!=n.top&&(n={top:Math.min(e.doc.height+Ue(e.display)-Ze(e),n.top)}),t.visible=x(e.display,e.doc,n),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&L(e,t);r=!1){E(e);var i=h(e);Pe(e),z(e,i),y(e,i)}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function A(e,t){var n=new S(e,t);if(L(e,n)){E(e),T(e,n);var r=h(e);Pe(e),z(e,r),y(e,r),n.finish()}}function z(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";var n=t.docHeight+e.display.barHeight;e.display.heightForcer.style.top=n+"px",e.display.gutters.style.height=Math.max(n+Ge(e),t.clientHeight)+"px"}function E(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;rko){var a=o.node.offsetTop+o.node.offsetHeight;i=a-n,n=a}else{var l=o.node.getBoundingClientRect();i=l.bottom-l.top}var s=o.line.height-i;if(2>i&&(i=bt(t)),(s>.001||-.001>s)&&(ti(o.line,i),O(o.line),o.rest))for(var c=0;c=t&&d.lineNumber;d.changes&&(Ni(d.changes,"gutter")>-1&&(f=!1),P(e,d,c,n)),f&&(Bi(d.lineNumber),d.lineNumber.appendChild(document.createTextNode(w(e.options,c)))),l=d.node.nextSibling}else{var p=B(e,d,c,n);a.insertBefore(p,l)}c+=d.size}for(;l;)l=r(l)}function P(e,t,n,r){for(var i=0;iko&&(e.node.style.zIndex=2)),e.node}function D(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var n=I(e);e.background=n.insertBefore($i("div",null,t),n.firstChild)}}function j(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Rr(e,t)}function R(e,t){var n=t.text.className,r=j(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,W(t)):n&&(t.text.className=n)}function W(e){D(e),e.line.wrapClass?I(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function F(e,t,n,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var i=I(t);t.gutterBackground=$i("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),i.insertBefore(t.gutterBackground,t.text)}var o=t.line.gutterMarkers;if(e.options.lineNumbers||o){var i=I(t),a=t.gutter=$i("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(a),i.insertBefore(a,t.text),t.line.gutterClass&&(a.className+=" "+t.line.gutterClass),!e.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(t.lineNumber=a.appendChild($i("div",w(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),o)for(var l=0;l1)if(Wo&&Wo.join("\n")==t){if(r.ranges.length%Wo.length==0){s=[];for(var c=0;c=0;c--){var u=r.ranges[c],d=u.from(),f=u.to();u.empty()&&(n&&n>0?d=jo(d.line,d.ch-n):e.state.overwrite&&!a&&(f=jo(f.line,Math.min(Qr(o,f.line).text.length,f.ch+qi(l).length))));var p=e.curOp.updateInput,h={from:d,to:f,text:s?s[c%s.length]:l,origin:i||(a?"paste":e.state.cutIncoming?"cut":"+input")};Ln(e.doc,h),Si(e,"inputRead",e,h)}t&&!a&&ee(e,t),Rn(e),e.curOp.updateInput=p,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function J(e,t){var n=e.clipboardData&&e.clipboardData.getData("text/plain");return n?(e.preventDefault(),t.isReadOnly()||t.options.disableInput||zt(t,function(){Q(t,n,0,null,"paste")}),!0):void 0}function ee(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,r=n.ranges.length-1;r>=0;r--){var i=n.ranges[r];if(!(i.head.ch>100||r&&n.ranges[r-1].head.line==i.head.line)){var o=e.getModeAt(i.head),a=!1;if(o.electricChars){for(var l=0;l-1){a=Fn(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Qr(e.doc,i.head.line).text.slice(0,i.head.ch))&&(a=Fn(e,i.head.line,"smart"));a&&Si(e,"electricInput",e,i.head.line)}}}function te(e){for(var t=[],n=[],r=0;ri?c.map:u[i],a=0;ai?e.line:e.rest[i]),d=o[a]+r;return(0>r||l!=t)&&(d=o[a+(r?1:0)]),jo(s,d)}}}var i=e.text.firstChild,o=!1;if(!t||!Ka(i,t))return le(jo(ni(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[n],n=0,!t)){var a=e.rest?qi(e.rest):e.line;return le(jo(ni(a),a.text.length),o)}var l=3==t.nodeType?t:null,s=t;for(l||1!=t.childNodes.length||3!=t.firstChild.nodeType||(l=t.firstChild,n&&(n=l.nodeValue.length));s.parentNode!=i;)s=s.parentNode;var c=e.measure,u=c.maps,d=r(l,s,n);if(d)return le(d,o);for(var f=s.nextSibling,p=l?l.nodeValue.length-n:0;f;f=f.nextSibling){if(d=r(f,f.firstChild,0))return le(jo(d.line,d.ch-p),o);p+=f.textContent.length}for(var h=s.previousSibling,p=n;h;h=h.previousSibling){if(d=r(h,h.firstChild,-1))return le(jo(d.line,d.ch+p),o);p+=f.textContent.length}}function ue(e,t,n,r,i){function o(e){return function(t){return t.id==e}}function a(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(null!=n)return""==n&&(n=t.textContent.replace(/\u200b/g,"")),void(l+=n);var u,d=t.getAttribute("cm-marker");if(d){var f=e.findMarks(jo(r,0),jo(i+1,0),o(+d));return void(f.length&&(u=f[0].find())&&(l+=Jr(e.doc,u.from,u.to).join(c)))}if("false"==t.getAttribute("contenteditable"))return;for(var p=0;p=0){var a=X(o.from(),i.from()),l=Z(o.to(),i.to()),s=o.empty()?i.from()==i.head:o.from()==o.head;t>=r&&--t,e.splice(--r,2,new fe(s?l:a,s?a:l))}}return new de(e,t)}function he(e,t){return new de([new fe(e,t||e)],0)}function me(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function ge(e,t){if(t.linen?jo(n,Qr(e,n).text.length):ve(t,Qr(e,t.line).text.length)}function ve(e,t){var n=e.ch;return null==n||n>t?jo(e.line,t):0>n?jo(e.line,0):e}function ye(e,t){return t>=e.first&&t=t.ch:l.to>t.ch))){if(i&&(qa(s,"beforeCursorEnter"),s.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!s.atomic)continue;if(n){var c,u=s.find(0>r?1:-1);if((0>r?s.inclusiveRight:s.inclusiveLeft)&&(u=Ne(e,u,-r,o)),u&&u.line==t.line&&(c=Ro(u,n))&&(0>r?0>c:c>0))return Oe(e,u,t,r,i)}var d=s.find(0>r?-1:1);return(0>r?s.inclusiveLeft:s.inclusiveRight)&&(d=Ne(e,d,r,o)),d?Oe(e,d,t,r,i):null}}return t}function qe(e,t,n,r,i){var o=r||1,a=Oe(e,t,n,o,i)||!i&&Oe(e,t,n,o,!0)||Oe(e,t,n,-o,i)||!i&&Oe(e,t,n,-o,!0);return a?a:(e.cantEdit=!0,jo(e.first,0))}function Ne(e,t,n,r){return 0>n&&0==t.ch?t.line>e.first?ge(e,jo(t.line-1)):null:n>0&&t.ch==(r||Qr(e,t.line)).text.length?t.linet&&(t=0),t=Math.round(t),r=Math.round(r),l.appendChild($i("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==n?u-e:n)+"px; height: "+(r-t)+"px"))}function i(t,n,i){function o(n,r){return pt(e,jo(t,n),"div",d,r)}var l,s,d=Qr(a,t),f=d.text.length;return to(oi(d),n||0,null==i?f:i,function(e,t,a){var d,p,h,m=o(e,"left");if(e==t)d=m,p=h=m.left;else{if(d=o(t-1,"right"),"rtl"==a){var g=m;m=d,d=g}p=m.left,h=d.right}null==n&&0==e&&(p=c),d.top-m.top>3&&(r(p,m.top,null,m.bottom),p=c,m.bottoms.bottom||d.bottom==s.bottom&&d.right>s.right)&&(s=d),c+1>p&&(p=c),r(p,d.top,h-p,d.bottom)}),{start:l,end:s}}var o=e.display,a=e.doc,l=document.createDocumentFragment(),s=Ve(e.display),c=s.left,u=Math.max(o.sizerWidth,Ke(e)-o.sizer.offsetLeft)-s.right,d=t.from(),f=t.to();if(d.line==f.line)i(d.line,d.ch,f.ch);else{var p=Qr(a,d.line),h=Qr(a,f.line),m=br(p)==br(h),g=i(d.line,d.ch,m?p.text.length+1:null).end,v=i(f.line,m?0:null,f.ch).start;m&&(g.top0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function We(e,t){e.doc.mode.startState&&e.doc.frontier=e.display.viewTo)){var n=+new Date+e.options.workTime,r=sa(t.mode,$e(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var a=o.styles,l=o.text.length>e.options.maxHighlightLength,s=Pr(e,o,l?sa(t.mode,r):r,!0);o.styles=s.styles;var c=o.styleClasses,u=s.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var d=!a||a.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),f=0;!d&&fn?(We(e,e.options.workDelay),!0):void 0}),i.length&&zt(e,function(){for(var t=0;ta;--l){if(l<=o.first)return o.first;var s=Qr(o,l-1);if(s.stateAfter&&(!n||l<=o.frontier))return l;var c=Wa(s.text,null,e.options.tabSize);(null==i||r>c)&&(i=l-1,r=c)}return i}function $e(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return!0;var o=He(e,t,n),a=o>r.first&&Qr(r,o-1).stateAfter;return a=a?sa(r.mode,a):ca(r.mode),r.iter(o,t,function(n){Dr(e,n.text,a);var l=o==t-1||o%5==0||o>=i.viewFrom&&o2&&o.push((s.bottom+c.top)/2-n.top)}}o.push(n.bottom-n.top)}}function Ye(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;rn)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}function Qe(e,t){t=br(t);var n=ni(t),r=e.display.externalMeasured=new Nt(e.doc,t,n);r.lineN=n;var i=r.built=Rr(e,r);return r.text=i.pre,Ui(e.display.lineMeasure,i.pre),r}function Je(e,t,n,r){return nt(e,tt(e,t),n,r)}function et(e,t){if(t>=e.display.viewFrom&&t=n.lineN&&tt?(i=0,o=1,a="left"):c>t?(i=t-s,o=i+1):(l==e.length-3||t==c&&e[l+3]>t)&&(o=c-s,i=o-1,t>=c&&(a="right")),null!=i){if(r=e[l+2],s==c&&n==(r.insertLeft?"left":"right")&&(a=n),"left"==n&&0==i)for(;l&&e[l-2]==e[l-3]&&e[l-1].insertLeft;)r=e[(l-=3)+2],a="left";if("right"==n&&i==c-s)for(;lu;u++){for(;l&&Hi(t.line.text.charAt(o.coverStart+l));)--l;for(;o.coverStart+sko&&0==l&&s==o.coverEnd-o.coverStart)i=a.parentNode.getBoundingClientRect();else if(xo&&e.options.lineWrapping){var d=Ba(a,l,s).getClientRects();i=d.length?d["right"==r?d.length-1:0]:Bo}else i=Ba(a,l,s).getBoundingClientRect()||Bo;if(i.left||i.right||0==l)break;s=l,l-=1,c="right"}xo&&11>ko&&(i=ot(e.display.measure,i))}else{l>0&&(c=r="right");var d;i=e.options.lineWrapping&&(d=a.getClientRects()).length>1?d["right"==r?d.length-1:0]:a.getBoundingClientRect()}if(xo&&9>ko&&!l&&(!i||!i.left&&!i.right)){var f=a.parentNode.getClientRects()[0];i=f?{left:f.left,right:f.left+xt(e.display),top:f.top,bottom:f.bottom}:Bo}for(var p=i.top-t.rect.top,h=i.bottom-t.rect.top,m=(p+h)/2,g=t.view.measure.heights,u=0;un.from?a(e-1):a(e,r)}r=r||Qr(e.doc,t.line),i||(i=tt(e,r));var s=oi(r),c=t.ch;if(!s)return a(c);var u=uo(s,c),d=l(c,u);return null!=al&&(d.other=l(c,al)),d}function mt(e,t){var n=0,t=ge(e.doc,t);e.options.lineWrapping||(n=xt(e.display)*t.ch);var r=Qr(e.doc,t.line),i=ii(r)+Be(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function gt(e,t,n,r){var i=jo(e,t);return i.xRel=r,n&&(i.outside=!0),i}function vt(e,t,n){var r=e.doc;if(n+=e.display.viewOffset,0>n)return gt(r.first,0,!0,-1);var i=ri(r,n),o=r.first+r.size-1;if(i>o)return gt(r.first+r.size-1,Qr(r,o).text.length,!0,1);0>t&&(t=0);for(var a=Qr(r,i);;){var l=yt(e,a,i,t,n),s=vr(a),c=s&&s.find(0,!0);if(!s||!(l.ch>c.from.ch||l.ch==c.from.ch&&l.xRel>0))return l;i=ni(a=c.to.line)}}function yt(e,t,n,r,i){function o(r){var i=ht(e,jo(n,r),"line",t,c);return l=!0,a>i.bottom?i.left-s:ag)return gt(n,p,v,1);for(;;){if(u?p==f||p==po(t,f,1):1>=p-f){for(var y=h>r||g-r>=r-h?f:p,b=r-(y==f?h:g);Hi(t.text.charAt(y));)++y;var x=gt(n,y,y==f?m:v,-1>b?-1:b>1?1:0);return x}var k=Math.ceil(d/2),_=f+k;if(u){_=f;for(var w=0;k>w;++w)_=po(t,_,1)}var C=o(_);C>r?(p=_,g=C,(v=l)&&(g+=1e3),d=k):(f=_,h=C,m=l,d-=k)}}function bt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Fo){Fo=$i("pre");for(var t=0;49>t;++t)Fo.appendChild(document.createTextNode("x")),Fo.appendChild($i("br"));Fo.appendChild(document.createTextNode("x"))}Ui(e.measure,Fo);var n=Fo.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),Bi(e.measure),n||1}function xt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=$i("span","xxxxxxxxxx"),n=$i("pre",[t]);Ui(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function kt(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.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:++Vo},Uo?Uo.ops.push(e.curOp):e.curOp.ownsGroup=Uo={ops:[e.curOp],delayedCallbacks:[]}}function _t(e){var t=e.delayedCallbacks,n=0;do{for(;n=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new S(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Mt(e){e.updatedDisplay=e.mustUpdate&&L(e.cm,e.update)}function Lt(e){var t=e.cm,n=t.display;e.updatedDisplay&&E(t),e.barMeasure=h(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Je(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+Ge(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-Ke(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function Tt(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLefto;o=r){var a=new Nt(e.doc,Qr(e.doc,o),o);r=o+a.size,i.push(a)}return i}function It(e,t,n,r){null==t&&(t=e.doc.first),null==n&&(n=e.doc.first+e.doc.size),r||(r=0);var i=e.display;if(r&&nt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Do&&kr(e.doc,t)i.viewFrom?jt(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)jt(e);else if(t<=i.viewFrom){var o=Wt(e,n,n+r,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=r):jt(e)}else if(n>=i.viewTo){var o=Wt(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):jt(e)}else{var a=Wt(e,t,t,-1),l=Wt(e,n,n+r,1);a&&l?(i.view=i.view.slice(0,a.index).concat(Pt(e,a.lineN,l.lineN)).concat(i.view.slice(l.index)),i.viewTo+=r):jt(e)}var s=i.externalMeasured;s&&(n=i.lineN&&t=r.viewTo)){var o=r.view[Rt(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==Ni(a,n)&&a.push(n)}}}function jt(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Rt(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var n=e.display.view,r=0;rt)return r}function Wt(e,t,n,r){var i,o=Rt(e,t),a=e.display.view;if(!Do||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var l=0,s=e.display.viewFrom;o>l;l++)s+=a[l].size;if(s!=t){if(r>0){if(o==a.length-1)return null;i=s+a[o].size-t,o++}else i=s-t;t+=i,n+=i}for(;kr(e.doc,n)!=n;){if(o==(0>r?0:a.length-1))return null;n+=r*a[o-(0>r?1:0)].size,o+=r}return{index:o,lineN:n}}function Ft(e,t,n){var r=e.display,i=r.view;0==i.length||t>=r.viewTo||n<=r.viewFrom?(r.view=Pt(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=Pt(e,t,r.viewFrom).concat(r.view):r.viewFromn&&(r.view=r.view.slice(0,Rt(e,n)))),r.viewTo=n}function Ht(e){for(var t=e.display.view,n=0,r=0;r400}var i=e.display;za(i.scroller,"mousedown",Et(e,Kt)),xo&&11>ko?za(i.scroller,"dblclick",Et(e,function(t){if(!Li(e,t)){var n=Gt(e,t);if(n&&!Jt(e,t)&&!Vt(e.display,t)){La(t);var r=e.findWordAt(n);ke(e.doc,r.anchor,r.head)}}})):za(i.scroller,"dblclick",function(t){Li(e,t)||La(t)}),Po||za(i.scroller,"contextmenu",function(t){xn(e,t)});var o,a={end:0};za(i.scroller,"touchstart",function(t){if(!Li(e,t)&&!n(t)){clearTimeout(o);var r=+new Date;i.activeTouch={start:r,moved:!1,prev:r-a.end<=300?a:null},1==t.touches.length&&(i.activeTouch.left=t.touches[0].pageX,i.activeTouch.top=t.touches[0].pageY)}}),za(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),za(i.scroller,"touchend",function(n){var o=i.activeTouch;if(o&&!Vt(i,n)&&null!=o.left&&!o.moved&&new Date-o.start<300){var a,l=e.coordsChar(i.activeTouch,"page");a=!o.prev||r(o,o.prev)?new fe(l,l):!o.prev.prev||r(o,o.prev.prev)?e.findWordAt(l):new fe(jo(l.line,0),ge(e.doc,jo(l.line+1,0))),e.setSelection(a.anchor,a.head),e.focus(),La(n)}t()}),za(i.scroller,"touchcancel",t),za(i.scroller,"scroll",function(){i.scroller.clientHeight&&(on(e,i.scroller.scrollTop),an(e,i.scroller.scrollLeft,!0),qa(e,"scroll",e))}),za(i.scroller,"mousewheel",function(t){ln(e,t)}),za(i.scroller,"DOMMouseScroll",function(t){ln(e,t)}),za(i.wrapper,"scroll",function(){i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(t){Li(e,t)||Aa(t)},over:function(t){Li(e,t)||(nn(e,t),Aa(t))},start:function(t){tn(e,t)},drop:Et(e,en),leave:function(){rn(e)}};var l=i.input.getField();za(l,"keyup",function(t){mn.call(e,t)}),za(l,"keydown",Et(e,pn)),za(l,"keypress",Et(e,gn)),za(l,"focus",Ri(yn,e)),za(l,"blur",Ri(bn,e))}function Bt(t,n,r){var i=r&&r!=e.Init;if(!n!=!i){var o=t.display.dragFunctions,a=n?za:Oa;a(t.display.scroller,"dragstart",o.start),a(t.display.scroller,"dragenter",o.enter),a(t.display.scroller,"dragover",o.over),a(t.display.scroller,"dragleave",o.leave),a(t.display.scroller,"drop",o.drop)}}function Ut(e){var t=e.display;(t.lastWrapHeight!=t.wrapper.clientHeight||t.lastWrapWidth!=t.wrapper.clientWidth)&&(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function Vt(e,t){for(var n=_i(t);n!=e.wrapper;n=n.parentNode)if(!n||1==n.nodeType&&"true"==n.getAttribute("cm-ignore-events")||n.parentNode==e.sizer&&n!=e.mover)return!0}function Gt(e,t,n,r){var i=e.display;if(!n&&"true"==_i(t).getAttribute("cm-not-content"))return null;var o,a,l=i.lineSpace.getBoundingClientRect();try{o=t.clientX-l.left,a=t.clientY-l.top}catch(t){return null}var s,c=vt(e,o,a);if(r&&1==c.xRel&&(s=Qr(e.doc,c.line).text).length==c.ch){var u=Wa(s,s.length,e.options.tabSize)-s.length;c=jo(c.line,Math.max(0,Math.round((o-Ve(e.display).left)/xt(e.display))-u))}return c}function Kt(e){var t=this,n=t.display;if(!(Li(t,e)||n.activeTouch&&n.input.supportsTouch())){if(n.shift=e.shiftKey,Vt(n,e))return void(_o||(n.scroller.draggable=!1,setTimeout(function(){n.scroller.draggable=!0},100)));if(!Jt(t,e)){var r=Gt(t,e);switch(window.focus(),wi(e)){case 1:t.state.selectingText?t.state.selectingText(e):r?Zt(t,e,r):_i(e)==n.scroller&&La(e);break;case 2:_o&&(t.state.lastMiddleDown=+new Date),r&&ke(t.doc,r),setTimeout(function(){n.input.focus()},20),La(e);break;case 3:Po?xn(t,e):vn(t)}}}}function Zt(e,t,n){xo?setTimeout(Ri(Y,e),0):e.curOp.focus=Vi();var r,i=+new Date;$o&&$o.time>i-400&&0==Ro($o.pos,n)?r="triple":Ho&&Ho.time>i-400&&0==Ro(Ho.pos,n)?(r="double",$o={time:i,pos:n}):(r="single",Ho={time:i,pos:n});var o,a=e.doc.sel,l=Eo?t.metaKey:t.ctrlKey;e.options.dragDrop&&el&&!e.isReadOnly()&&"single"==r&&(o=a.contains(n))>-1&&(Ro((o=a.ranges[o]).from(),n)<0||n.xRel>0)&&(Ro(o.to(),n)>0||n.xRel<0)?Xt(e,t,n,l):Yt(e,t,n,r,l)}function Xt(e,t,n,r){var i=e.display,o=+new Date,a=Et(e,function(l){_o&&(i.scroller.draggable=!1),e.state.draggingText=!1,Oa(document,"mouseup",a),Oa(i.scroller,"drop",a),Math.abs(t.clientX-l.clientX)+Math.abs(t.clientY-l.clientY)<10&&(La(l),!r&&+new Date-200=h;h++){var v=Qr(c,h).text,y=Fa(v,s,o);s==p?i.push(new fe(jo(h,y),jo(h,y))):v.length>y&&i.push(new fe(jo(h,y),jo(h,Fa(v,p,o))))}i.length||i.push(new fe(n,n)),Le(c,pe(f.ranges.slice(0,d).concat(i),d),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=u,x=b.anchor,k=t;if("single"!=r){if("double"==r)var _=e.findWordAt(t);else var _=new fe(jo(t.line,0),ge(c,jo(t.line+1,0)));Ro(_.anchor,x)>0?(k=_.head,x=X(b.from(),_.anchor)):(k=_.anchor,x=Z(b.to(),_.head))}var i=f.ranges.slice(0);i[d]=new fe(ge(c,x),k),Le(c,pe(i,d),ja)}}function a(t){var n=++y,i=Gt(e,t,!0,"rect"==r);if(i)if(0!=Ro(i,g)){e.curOp.focus=Vi(),o(i);var l=x(s,c);(i.line>=l.to||i.linev.bottom?20:0;u&&setTimeout(Et(e,function(){y==n&&(s.scroller.scrollTop+=u,a(t))}),50)}}function l(t){e.state.selectingText=!1,y=1/0,La(t),s.input.focus(),Oa(document,"mousemove",b),Oa(document,"mouseup",k),c.history.lastSelOrigin=null}var s=e.display,c=e.doc;La(t);var u,d,f=c.sel,p=f.ranges;if(i&&!t.shiftKey?(d=c.sel.contains(n),u=d>-1?p[d]:new fe(n,n)):(u=c.sel.primary(),d=c.sel.primIndex),t.altKey)r="rect",i||(u=new fe(n,n)),n=Gt(e,t,!0,!0),d=-1;else if("double"==r){var h=e.findWordAt(n);u=e.display.shift||c.extend?xe(c,u,h.anchor,h.head):h}else if("triple"==r){var m=new fe(jo(n.line,0),ge(c,jo(n.line+1,0)));u=e.display.shift||c.extend?xe(c,u,m.anchor,m.head):m}else u=xe(c,u,n);i?-1==d?(d=p.length,Le(c,pe(p.concat([u]),d),{scroll:!1,origin:"*mouse"})):p.length>1&&p[d].empty()&&"single"==r&&!t.shiftKey?(Le(c,pe(p.slice(0,d).concat(p.slice(d+1)),0),{scroll:!1,origin:"*mouse"}),f=c.sel):we(c,d,u,ja):(d=0,Le(c,new de([u],0),ja),f=c.sel);var g=n,v=s.wrapper.getBoundingClientRect(),y=0,b=Et(e,function(e){wi(e)?a(e):l(e)}),k=Et(e,l);e.state.selectingText=k,za(document,"mousemove",b),za(document,"mouseup",k)}function Qt(e,t,n,r){try{var i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&La(t);var a=e.display,l=a.lineDiv.getBoundingClientRect();if(o>l.bottom||!Ai(e,n))return ki(t);o-=l.top-a.viewOffset;for(var s=0;s=i){var u=ri(e.doc,o),d=e.options.gutters[s];return qa(e,n,e,u,d,t),ki(t)}}}function Jt(e,t){return Qt(e,t,"gutterClick",!0)}function en(e){var t=this;if(rn(t),!Li(t,e)&&!Vt(t.display,e)){La(e),xo&&(Go=+new Date);var n=Gt(t,e,!0),r=e.dataTransfer.files;if(n&&!t.isReadOnly())if(r&&r.length&&window.FileReader&&window.File)for(var i=r.length,o=Array(i),a=0,l=function(e,r){if(!t.options.allowDropFileTypes||-1!=Ni(t.options.allowDropFileTypes,e.type)){var l=new FileReader;l.onload=Et(t,function(){var e=l.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(e)&&(e=""),o[r]=e,++a==i){n=ge(t.doc,n);var s={from:n,to:n,text:t.doc.splitLines(o.join(t.doc.lineSeparator())),origin:"paste"};Ln(t.doc,s),Me(t.doc,he(n,Jo(s)))}}),l.readAsText(e)}},s=0;i>s;++s)l(r[s],s);else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1)return t.state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(Eo?e.altKey:e.ctrlKey))var c=t.listSelections();if(Te(t.doc,he(n,n)),c)for(var s=0;sa.clientWidth,s=a.scrollHeight>a.clientHeight;if(r&&l||i&&s){if(i&&Eo&&_o)e:for(var c=t.target,u=o.view;c!=a;c=c.parentNode)for(var d=0;df?p=Math.max(0,p+f-50):h=Math.min(e.doc.height,h+f+50),A(e,{top:p,bottom:h})}20>Ko&&(null==o.wheelStartX?(o.wheelStartX=a.scrollLeft,o.wheelStartY=a.scrollTop,o.wheelDX=r,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=a.scrollLeft-o.wheelStartX,t=a.scrollTop-o.wheelStartY,n=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,n&&(Zo=(Zo*Ko+n)/(Ko+1),++Ko)}},200)):(o.wheelDX+=r,o.wheelDY+=i))}}function sn(e,t,n){if("string"==typeof t&&(t=ua[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),i=t(e)!=Ia}finally{e.display.shift=r,e.state.suppressEdits=!1}return i}function cn(e,t,n){for(var r=0;rko&&27==e.keyCode&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=16==n||e.shiftKey;var r=dn(t,e);So&&(Qo=r?n:null,!r&&88==n&&!rl&&(Eo?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=n||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||hn(t)}}function hn(e){function t(e){18!=e.keyCode&&e.altKey||(Ya(n,"CodeMirror-crosshair"),Oa(document,"keyup",t),Oa(document,"mouseover",t))}var n=e.display.lineDiv;Qa(n,"CodeMirror-crosshair"),za(document,"keyup",t),za(document,"mouseover",t)}function mn(e){16==e.keyCode&&(this.doc.sel.shift=!1),Li(this,e)}function gn(e){var t=this;if(!(Vt(t.display,e)||Li(t,e)||e.ctrlKey&&!e.altKey||Eo&&e.metaKey)){var n=e.keyCode,r=e.charCode;if(So&&n==Qo)return Qo=null,void La(e);if(!So||e.which&&!(e.which<10)||!dn(t,e)){var i=String.fromCharCode(null==r?n:r);fn(t,e,i)||t.display.input.onKeyPress(e)}}}function vn(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,bn(e))},100)}function yn(e){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(qa(e,"focus",e),e.state.focused=!0,Qa(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),_o&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Re(e))}function bn(e){e.state.delayingBlurEvent||(e.state.focused&&(qa(e,"blur",e),e.state.focused=!1,Ya(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function xn(e,t){Vt(e.display,t)||kn(e,t)||Li(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function kn(e,t){return Ai(e,"gutterContextMenu")?Qt(e,t,"gutterContextMenu",!1):!1}function _n(e,t){if(Ro(e,t.from)<0)return e;if(Ro(e,t.to)<=0)return Jo(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Jo(t).ch-t.to.ch),jo(n,r)}function wn(e,t){for(var n=[],r=0;r=0;--i)Tn(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text});else Tn(e,t)}}function Tn(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Ro(t.from,t.to)){var n=wn(e,t);ui(e,t,n,e.cm?e.cm.curOp.id:0/0),En(e,t,n,ar(e,t));var r=[];Xr(e,function(e,n){n||-1!=Ni(r,e.history)||(xi(e.history,t),r.push(e.history)),En(e,t,null,ar(e,t))})}}function An(e,t,n){if(!e.cm||!e.cm.state.suppressEdits){for(var r,i=e.history,o=e.sel,a="undo"==t?i.done:i.undone,l="undo"==t?i.undone:i.done,s=0;s=0;--s){var d=r.changes[s];if(d.origin=t,u&&!Mn(e,d,!1))return void(a.length=0);c.push(li(e,d));var f=s?wn(e,d):qi(a);En(e,d,f,sr(e,d)),!s&&e.cm&&e.cm.scrollIntoView({from:d.from,to:Jo(d)});var p=[];Xr(e,function(e,t){t||-1!=Ni(p,e.history)||(xi(e.history,d),p.push(e.history)),En(e,d,null,sr(e,d))})}}}}function zn(e,t){if(0!=t&&(e.first+=t,e.sel=new de(Pi(e.sel.ranges,function(e){return new fe(jo(e.anchor.line+t,e.anchor.ch),jo(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){It(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;re.lastLine())){if(t.from.lineo&&(t={from:t.from,to:jo(o,Qr(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Jr(e,t.from,t.to),n||(n=wn(e,t)),e.cm?On(e.cm,t,r):Gr(e,t,r),Te(e,n,Da)}}function On(e,t,n){var r=e.doc,i=e.display,a=t.from,l=t.to,s=!1,c=a.line;e.options.lineWrapping||(c=ni(br(Qr(r,a.line))),r.iter(c,l.line+1,function(e){return e==i.maxLine?(s=!0,!0):void 0})),r.sel.contains(t.from,t.to)>-1&&Ti(e),Gr(r,t,n,o(e)),e.options.lineWrapping||(r.iter(c,a.line+t.text.length,function(e){var t=d(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),r.frontier=Math.min(r.frontier,a.line),We(e,400);var u=t.text.length-(l.line-a.line)-1;t.full?It(e):a.line!=l.line||1!=t.text.length||Vr(e.doc,t)?It(e,a.line,l.line+1,u):Dt(e,a.line,"text");var f=Ai(e,"changes"),p=Ai(e,"change");if(p||f){var h={from:a,to:l,text:t.text,removed:t.removed,origin:t.origin};p&&Si(e,"change",e,h),f&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function qn(e,t,n,r,i){if(r||(r=n),Ro(r,n)<0){var o=r;r=n,n=o}"string"==typeof t&&(t=e.splitLines(t)),Ln(e,{from:n,to:r,text:t,origin:i})}function Nn(e,t){if(!Li(e,"scrollCursorIntoView")){var n=e.display,r=n.sizer.getBoundingClientRect(),i=null;if(t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!To){var o=$i("div","",null,"position: absolute; top: "+(t.top-n.viewOffset-Be(e.display))+"px; height: "+(t.bottom-t.top+Ge(e)+n.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Pn(e,t,n,r){null==r&&(r=0);for(var i=0;5>i;i++){var o=!1,a=ht(e,t),l=n&&n!=t?ht(e,n):a,s=Dn(e,Math.min(a.left,l.left),Math.min(a.top,l.top)-r,Math.max(a.left,l.left),Math.max(a.bottom,l.bottom)+r),c=e.doc.scrollTop,u=e.doc.scrollLeft;if(null!=s.scrollTop&&(on(e,s.scrollTop),Math.abs(e.doc.scrollTop-c)>1&&(o=!0)),null!=s.scrollLeft&&(an(e,s.scrollLeft),Math.abs(e.doc.scrollLeft-u)>1&&(o=!0)),!o)break}return a}function In(e,t,n,r,i){var o=Dn(e,t,n,r,i);null!=o.scrollTop&&on(e,o.scrollTop),null!=o.scrollLeft&&an(e,o.scrollLeft)}function Dn(e,t,n,r,i){var o=e.display,a=bt(e.display);0>n&&(n=0);var l=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,s=Ze(e),c={};i-n>s&&(i=n+s);var u=e.doc.height+Ue(o),d=a>n,f=i>u-a;if(l>n)c.scrollTop=d?0:n;else if(i>l+s){var p=Math.min(n,(f?u:i)-s);p!=l&&(c.scrollTop=p)}var h=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,m=Ke(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),g=r-t>m;return g&&(r=t+m),10>t?c.scrollLeft=0:h>t?c.scrollLeft=Math.max(0,t-(g?0:10)):r>m+h-3&&(c.scrollLeft=r+(g?0:10)-m),c}function jn(e,t,n){(null!=t||null!=n)&&Wn(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=n&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+n)}function Rn(e){Wn(e);
+!function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);(this||window).CodeMirror=e()}}(function(){"use strict";function e(r,n){if(!(this instanceof e))return new e(r,n);this.options=n=n?Di(n):{},Di(ea,n,!1),p(n);var i=n.value;"string"==typeof i&&(i=new Ca(i,n.mode,null,n.lineSeparator)),this.doc=i;var o=new e.inputStyles[n.inputStyle](this),a=this.display=new t(r,i,o);a.wrapper.CodeMirror=this,c(this),s(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),n.autofocus&&!Eo&&a.input.focus(),v(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 Oi,keySeq:null,specialChars:null};var l=this;ko&&11>xo&&setTimeout(function(){l.display.input.reset(!0)},20),Ht(this),Zi(),xt(this),this.curOp.forceUpdate=!0,Yn(this,i),n.autofocus&&!Eo||l.hasFocus()?setTimeout(ji(vr,this),20):yr(this);for(var u in ta)ta.hasOwnProperty(u)&&ta[u](this,n[u],ra);w(this),n.finishInit&&n.finishInit(this);for(var f=0;fxo&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),wo||vo&&Eo||(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,r.init(n)}function r(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),n(t)}function n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,Be(e,100),e.state.modeGen++,e.curOp&&qt(e)}function i(e){e.options.lineWrapping?(Qa(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Ya(e.display.wrapper,"CodeMirror-wrap"),d(e)),a(e),qt(e),lt(e),setTimeout(function(){y(e)},100)}function o(e){var t=bt(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/kt(e.display)-3);return function(i){if(_n(e.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;at.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function p(e){var t=Ni(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function h(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Ue(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?r:0,docHeight:n,scrollHeight:n+Ve(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function m(e,t,r){this.cm=r;var n=this.vert=Hi("div",[Hi("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=Hi("div",[Hi("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(n),e(i),Ea(n,"scroll",function(){n.clientHeight&&t(n.scrollTop,"vertical")}),Ea(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,ko&&8>xo&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function g(){}function v(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Ya(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),Ea(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,r){"horizontal"==r?or(t,e):ir(t,e)},t),t.display.scrollbars.addClass&&Qa(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=h(e));var r=e.display.barWidth,n=e.display.barHeight;b(e,t);for(var i=0;4>i&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&O(e),b(e,h(e)),r=e.display.barWidth,n=e.display.barHeight}function b(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}function k(e,t,r){var n=r&&null!=r.top?Math.max(0,r.top):e.scroller.scrollTop;n=Math.floor(n-$e(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=ni(t,n),a=ni(t,i);if(r&&r.ensure){var s=r.ensure.from.line,l=r.ensure.to.line;o>s?(o=s,a=ni(t,ii(Qn(t,s))+e.wrapper.clientHeight)):Math.min(l,t.lastLine())>=a&&(o=ni(t,ii(Qn(t,l))-e.wrapper.clientHeight),a=l)}return{from:o,to:Math.max(a,o+1)}}function x(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=C(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",a=0;a=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==Ft(e))return!1;w(e)&&(Dt(e),t.dims=I(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),a=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFroma&&r.viewTo-a<20&&(a=Math.min(i,r.viewTo)),Ro&&(o=xn(e.doc,o),a=wn(e.doc,a));var s=o!=r.viewFrom||a!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;Wt(e,o,a),r.viewOffset=ii(Qn(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var l=Ft(e);if(!s&&0==l&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var c=Ki();return l>4&&(r.lineDiv.style.display="none"),N(e,r.updateLineNumbers,t.dims),l>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,c&&Ki()!=c&&c.offsetHeight&&c.focus(),$i(r.cursorDiv),$i(r.selectionDiv),r.gutters.style.height=r.sizer.style.minHeight=0,s&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,Be(e,400)),r.updateLineNumbers=null,!0}function T(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=Ge(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+Ue(e.display)-Xe(e),r.top)}),t.visible=k(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&L(e,t);n=!1){O(e);var i=h(e);Pe(e),E(e,i),y(e,i)}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function A(e,t){var r=new S(e,t);if(L(e,r)){O(e),T(e,r);var n=h(e);Pe(e),E(e,n),y(e,n),r.finish()}}function E(e,t){e.display.sizer.style.minHeight=t.docHeight+"px";var r=t.docHeight+e.display.barHeight;e.display.heightForcer.style.top=r+"px",e.display.gutters.style.height=Math.max(r+Ve(e),t.clientHeight)+"px"}function O(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;nxo){var a=o.node.offsetTop+o.node.offsetHeight;i=a-r,r=a}else{var s=o.node.getBoundingClientRect();i=s.bottom-s.top}var l=o.line.height-i;if(2>i&&(i=bt(t)),(l>.001||-.001>l)&&(ti(o.line,i),z(o.line),o.rest))for(var c=0;c=t&&f.lineNumber;f.changes&&(Ni(f.changes,"gutter")>-1&&(d=!1),P(e,f,c,r)),d&&($i(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(_(e.options,c)))),s=f.node.nextSibling}else{var p=H(e,f,c,r);a.insertBefore(p,s)}c+=f.size}for(;s;)s=n(s)}function P(e,t,r,n){for(var i=0;ixo&&(e.node.style.zIndex=2)),e.node}function R(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=q(e);e.background=r.insertBefore(Hi("div",null,t),r.firstChild)}}function D(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):jn(e,t)}function j(e,t){var r=t.text.className,n=D(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,B(t)):r&&(t.text.className=r)}function B(e){R(e),e.line.wrapClass?q(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function W(e,t,r,n){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var i=q(t);t.gutterBackground=Hi("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px"),i.insertBefore(t.gutterBackground,t.text)}var o=t.line.gutterMarkers;if(e.options.lineNumbers||o){var i=q(t),a=t.gutter=Hi("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px");if(e.display.input.setUneditable(a),i.insertBefore(a,t.text),t.line.gutterClass&&(a.className+=" "+t.line.gutterClass),!e.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(t.lineNumber=a.appendChild(Hi("div",_(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),o)for(var s=0;s1)if(Bo&&Bo.join("\n")==t){if(n.ranges.length%Bo.length==0){l=[];for(var c=0;c=0;c--){var u=n.ranges[c],f=u.from(),d=u.to();u.empty()&&(r&&r>0?f=Do(f.line,f.ch-r):e.state.overwrite&&!a&&(d=Do(d.line,Math.min(Qn(o,d.line).text.length,d.ch+Ii(s).length))));var p=e.curOp.updateInput,h={from:f,to:d,text:l?l[c%l.length]:s,origin:i||(a?"paste":e.state.cutIncoming?"cut":"+input")};Mr(e.doc,h),Si(e,"inputRead",e,h)}t&&!a&&ee(e,t),Dr(e),e.curOp.updateInput=p,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function J(e,t){var r=e.clipboardData&&e.clipboardData.getData("text/plain");return r?(e.preventDefault(),t.isReadOnly()||t.options.disableInput||Et(t,function(){Q(t,r,0,null,"paste")}),!0):void 0}function ee(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var r=e.doc.sel,n=r.ranges.length-1;n>=0;n--){var i=r.ranges[n];if(!(i.head.ch>100||n&&r.ranges[n-1].head.line==i.head.line)){var o=e.getModeAt(i.head),a=!1;if(o.electricChars){for(var s=0;s-1){a=Br(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Qn(e.doc,i.head.line).text.slice(0,i.head.ch))&&(a=Br(e,i.head.line,"smart"));a&&Si(e,"electricInput",e,i.head.line)}}}function te(e){for(var t=[],r=[],n=0;ni?c.map:u[i],a=0;ai?e.line:e.rest[i]),f=o[a]+n;return(0>n||s!=t)&&(f=o[a+(n?1:0)]),Do(l,f)}}}var i=e.text.firstChild,o=!1;if(!t||!Ga(i,t))return se(Do(ri(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[r],r=0,!t)){var a=e.rest?Ii(e.rest):e.line;return se(Do(ri(a),a.text.length),o)}var s=3==t.nodeType?t:null,l=t;for(s||1!=t.childNodes.length||3!=t.firstChild.nodeType||(s=t.firstChild,r&&(r=s.nodeValue.length));l.parentNode!=i;)l=l.parentNode;var c=e.measure,u=c.maps,f=n(s,l,r);if(f)return se(f,o);for(var d=l.nextSibling,p=s?s.nodeValue.length-r:0;d;d=d.nextSibling){if(f=n(d,d.firstChild,0))return se(Do(f.line,f.ch-p),o);p+=d.textContent.length}for(var h=l.previousSibling,p=r;h;h=h.previousSibling){if(f=n(h,h.firstChild,-1))return se(Do(f.line,f.ch+p),o);p+=d.textContent.length}}function ue(e,t,r,n,i){function o(e){return function(t){return t.id==e}}function a(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(null!=r)return""==r&&(r=t.textContent.replace(/\u200b/g,"")),void(s+=r);var u,f=t.getAttribute("cm-marker");if(f){var d=e.findMarks(Do(n,0),Do(i+1,0),o(+f));return void(d.length&&(u=d[0].find())&&(s+=Jn(e.doc,u.from,u.to).join(c)))}if("false"==t.getAttribute("contenteditable"))return;for(var p=0;p=0){var a=Z(o.from(),i.from()),s=X(o.to(),i.to()),l=o.empty()?i.from()==i.head:o.from()==o.head;t>=n&&--t,e.splice(--n,2,new de(l?s:a,l?a:s))}}return new fe(e,t)}function he(e,t){return new fe([new de(e,t||e)],0)}function me(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function ge(e,t){if(t.liner?Do(r,Qn(e,r).text.length):ve(t,Qn(e,t.line).text.length)}function ve(e,t){var r=e.ch;return null==r||r>t?Do(e.line,t):0>r?Do(e.line,0):e}function ye(e,t){return t>=e.first&&t=t.ch:s.to>t.ch))){if(i&&(Ia(l,"beforeCursorEnter"),l.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!l.atomic)continue;if(r){var c,u=l.find(0>n?1:-1);if((0>n?l.inclusiveRight:l.inclusiveLeft)&&(u=Ne(e,u,-n,o)),u&&u.line==t.line&&(c=jo(u,r))&&(0>n?0>c:c>0))return ze(e,u,t,n,i)}var f=l.find(0>n?-1:1);return(0>n?l.inclusiveLeft:l.inclusiveRight)&&(f=Ne(e,f,n,o)),f?ze(e,f,t,n,i):null}}return t}function Ie(e,t,r,n,i){var o=n||1,a=ze(e,t,r,o,i)||!i&&ze(e,t,r,o,!0)||ze(e,t,r,-o,i)||!i&&ze(e,t,r,-o,!0);return a?a:(e.cantEdit=!0,Do(e.first,0))}function Ne(e,t,r,n){return 0>r&&0==t.ch?t.line>e.first?ge(e,Do(t.line-1)):null:r>0&&t.ch==(n||Qn(e,t.line)).text.length?t.linet&&(t=0),t=Math.round(t),n=Math.round(n),s.appendChild(Hi("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?u-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return pt(e,Do(t,r),"div",f,n)}var s,l,f=Qn(a,t),d=f.text.length;return to(oi(f),r||0,null==i?d:i,function(e,t,a){var f,p,h,m=o(e,"left");if(e==t)f=m,p=h=m.left;else{if(f=o(t-1,"right"),"rtl"==a){var g=m;m=f,f=g}p=m.left,h=f.right}null==r&&0==e&&(p=c),f.top-m.top>3&&(n(p,m.top,null,m.bottom),p=c,m.bottoml.bottom||f.bottom==l.bottom&&f.right>l.right)&&(l=f),c+1>p&&(p=c),n(p,f.top,h-p,f.bottom)}),{start:s,end:l}}var o=e.display,a=e.doc,s=document.createDocumentFragment(),l=Ke(e.display),c=l.left,u=Math.max(o.sizerWidth,Ge(e)-o.sizer.offsetLeft)-l.right,f=t.from(),d=t.to();if(f.line==d.line)i(f.line,f.ch,d.ch);else{var p=Qn(a,f.line),h=Qn(a,d.line),m=bn(p)==bn(h),g=i(f.line,f.ch,m?p.text.length+1:null).end,v=i(d.line,m?0:null,d.ch).start;m&&(g.top0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Be(e,t){e.doc.mode.startState&&e.doc.frontier=e.display.viewTo)){var r=+new Date+e.options.workTime,n=la(t.mode,He(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var a=o.styles,s=o.text.length>e.options.maxHighlightLength,l=Pn(e,o,s?la(t.mode,n):n,!0);o.styles=l.styles;var c=o.styleClasses,u=l.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var f=!a||a.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),d=0;!f&&dr?(Be(e,e.options.workDelay),!0):void 0}),i.length&&Et(e,function(){for(var t=0;ta;--s){if(s<=o.first)return o.first;var l=Qn(o,s-1);if(l.stateAfter&&(!r||s<=o.frontier))return s;var c=Ba(l.text,null,e.options.tabSize);(null==i||n>c)&&(i=s-1,n=c)}return i}function He(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=Fe(e,t,r),a=o>n.first&&Qn(n,o-1).stateAfter;return a=a?la(n.mode,a):ca(n.mode),n.iter(o,t,function(r){Rn(e,r.text,a);var s=o==t-1||o%5==0||o>=i.viewFrom&&o2&&o.push((l.bottom+c.top)/2-r.top)}}o.push(r.bottom-r.top)}}function Ye(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;nr)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Qe(e,t){t=bn(t);var r=ri(t),n=e.display.externalMeasured=new Nt(e.doc,t,r);n.lineN=r;var i=n.built=jn(e,n);return n.text=i.pre,Ui(e.display.lineMeasure,i.pre),n}function Je(e,t,r,n){return rt(e,tt(e,t),r,n)}function et(e,t){if(t>=e.display.viewFrom&&t=r.lineN&&tt?(i=0,o=1,a="left"):c>t?(i=t-l,o=i+1):(s==e.length-3||t==c&&e[s+3]>t)&&(o=c-l,i=o-1,t>=c&&(a="right")),null!=i){if(n=e[s+2],l==c&&r==(n.insertLeft?"left":"right")&&(a=r),"left"==r&&0==i)for(;s&&e[s-2]==e[s-3]&&e[s-1].insertLeft;)n=e[(s-=3)+2],a="left";if("right"==r&&i==c-l)for(;su;u++){for(;s&&Fi(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+lxo&&0==s&&l==o.coverEnd-o.coverStart)i=a.parentNode.getBoundingClientRect();else if(ko&&e.options.lineWrapping){var f=$a(a,s,l).getClientRects();i=f.length?f["right"==n?f.length-1:0]:$o}else i=$a(a,s,l).getBoundingClientRect()||$o;if(i.left||i.right||0==s)break;l=s,s-=1,c="right"}ko&&11>xo&&(i=ot(e.display.measure,i))}else{s>0&&(c=n="right");var f;i=e.options.lineWrapping&&(f=a.getClientRects()).length>1?f["right"==n?f.length-1:0]:a.getBoundingClientRect()}if(ko&&9>xo&&!s&&(!i||!i.left&&!i.right)){var d=a.parentNode.getClientRects()[0];i=d?{left:d.left,right:d.left+kt(e.display),top:d.top,bottom:d.bottom}:$o}for(var p=i.top-t.rect.top,h=i.bottom-t.rect.top,m=(p+h)/2,g=t.view.measure.heights,u=0;ur.from?a(e-1):a(e,n)}n=n||Qn(e.doc,t.line),i||(i=tt(e,n));var l=oi(n),c=t.ch;if(!l)return a(c);var u=uo(l,c),f=s(c,u);return null!=as&&(f.other=s(c,as)),f}function mt(e,t){var r=0,t=ge(e.doc,t);e.options.lineWrapping||(r=kt(e.display)*t.ch);var n=Qn(e.doc,t.line),i=ii(n)+$e(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function gt(e,t,r,n){var i=Do(e,t);return i.xRel=n,r&&(i.outside=!0),i}function vt(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,0>r)return gt(n.first,0,!0,-1);var i=ni(n,r),o=n.first+n.size-1;if(i>o)return gt(n.first+n.size-1,Qn(n,o).text.length,!0,1);0>t&&(t=0);for(var a=Qn(n,i);;){var s=yt(e,a,i,t,r),l=vn(a),c=l&&l.find(0,!0);if(!l||!(s.ch>c.from.ch||s.ch==c.from.ch&&s.xRel>0))return s;i=ri(a=c.to.line)}}function yt(e,t,r,n,i){function o(n){var i=ht(e,Do(r,n),"line",t,c);return s=!0,a>i.bottom?i.left-l:ag)return gt(r,p,v,1);for(;;){if(u?p==d||p==po(t,d,1):1>=p-d){for(var y=h>n||g-n>=n-h?d:p,b=n-(y==d?h:g);Fi(t.text.charAt(y));)++y;var k=gt(r,y,y==d?m:v,-1>b?-1:b>1?1:0);return k}var x=Math.ceil(f/2),w=d+x;if(u){w=d;for(var _=0;x>_;++_)w=po(t,w,1)}var C=o(w);C>n?(p=w,g=C,(v=s)&&(g+=1e3),f=x):(d=w,h=C,m=s,f-=x)}}function bt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Wo){Wo=Hi("pre");for(var t=0;49>t;++t)Wo.appendChild(document.createTextNode("x")),Wo.appendChild(Hi("br"));Wo.appendChild(document.createTextNode("x"))}Ui(e.measure,Wo);var r=Wo.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),$i(e.measure),r||1}function kt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=Hi("span","xxxxxxxxxx"),r=Hi("pre",[t]);Ui(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function xt(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.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:++Ko},Uo?Uo.ops.push(e.curOp):e.curOp.ownsGroup=Uo={ops:[e.curOp],delayedCallbacks:[]}}function wt(e){var t=e.delayedCallbacks,r=0;do{for(;r=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new S(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Mt(e){e.updatedDisplay=e.mustUpdate&&L(e.cm,e.update)}function Lt(e){var t=e.cm,r=t.display;e.updatedDisplay&&O(t),e.barMeasure=h(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Je(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Ve(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-Ge(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Tt(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLefto;o=n){var a=new Nt(e.doc,Qn(e.doc,o),o);n=o+a.size,i.push(a)}return i}function qt(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&rt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Ro&&xn(e.doc,t)i.viewFrom?Dt(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)Dt(e);else if(t<=i.viewFrom){var o=Bt(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):Dt(e)}else if(r>=i.viewTo){var o=Bt(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):Dt(e)}else{var a=Bt(e,t,t,-1),s=Bt(e,r,r+n,1);a&&s?(i.view=i.view.slice(0,a.index).concat(Pt(e,a.lineN,s.lineN)).concat(i.view.slice(s.index)),i.viewTo+=n):Dt(e)}var l=i.externalMeasured;l&&(r=i.lineN&&t=n.viewTo)){var o=n.view[jt(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==Ni(a,r)&&a.push(r)}}}function Dt(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function jt(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var r=e.display.view,n=0;nt)return n}function Bt(e,t,r,n){var i,o=jt(e,t),a=e.display.view;if(!Ro||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=0,l=e.display.viewFrom;o>s;s++)l+=a[s].size;if(l!=t){if(n>0){if(o==a.length-1)return null;i=l+a[o].size-t,o++}else i=l-t;t+=i,r+=i}for(;xn(e.doc,r)!=r;){if(o==(0>n?0:a.length-1))return null;r+=n*a[o-(0>n?1:0)].size,o+=n}return{index:o,lineN:r}}function Wt(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=Pt(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=Pt(e,t,n.viewFrom).concat(n.view):n.viewFromr&&(n.view=n.view.slice(0,jt(e,r)))),n.viewTo=r}function Ft(e){for(var t=e.display.view,r=0,n=0;n400}var i=e.display;Ea(i.scroller,"mousedown",Ot(e,Gt)),ko&&11>xo?Ea(i.scroller,"dblclick",Ot(e,function(t){if(!Li(e,t)){var r=Vt(e,t);if(r&&!Jt(e,t)&&!Kt(e.display,t)){La(t);var n=e.findWordAt(r);xe(e.doc,n.anchor,n.head)}}})):Ea(i.scroller,"dblclick",function(t){Li(e,t)||La(t)}),Po||Ea(i.scroller,"contextmenu",function(t){br(e,t)});var o,a={end:0};Ea(i.scroller,"touchstart",function(t){if(!Li(e,t)&&!r(t)){clearTimeout(o);var n=+new Date;i.activeTouch={start:n,moved:!1,prev:n-a.end<=300?a:null},1==t.touches.length&&(i.activeTouch.left=t.touches[0].pageX,i.activeTouch.top=t.touches[0].pageY)}}),Ea(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),Ea(i.scroller,"touchend",function(r){var o=i.activeTouch;if(o&&!Kt(i,r)&&null!=o.left&&!o.moved&&new Date-o.start<300){var a,s=e.coordsChar(i.activeTouch,"page");a=!o.prev||n(o,o.prev)?new de(s,s):!o.prev.prev||n(o,o.prev.prev)?e.findWordAt(s):new de(Do(s.line,0),ge(e.doc,Do(s.line+1,0))),e.setSelection(a.anchor,a.head),e.focus(),La(r)}t()}),Ea(i.scroller,"touchcancel",t),Ea(i.scroller,"scroll",function(){i.scroller.clientHeight&&(ir(e,i.scroller.scrollTop),or(e,i.scroller.scrollLeft,!0),Ia(e,"scroll",e))}),Ea(i.scroller,"mousewheel",function(t){ar(e,t)}),Ea(i.scroller,"DOMMouseScroll",function(t){ar(e,t)}),Ea(i.wrapper,"scroll",function(){i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(t){Li(e,t)||Aa(t)},over:function(t){Li(e,t)||(rr(e,t),Aa(t))},start:function(t){tr(e,t)},drop:Ot(e,er),leave:function(){nr(e)}};var s=i.input.getField();Ea(s,"keyup",function(t){hr.call(e,t)}),Ea(s,"keydown",Ot(e,dr)),Ea(s,"keypress",Ot(e,mr)),Ea(s,"focus",ji(vr,e)),Ea(s,"blur",ji(yr,e))}function $t(t,r,n){var i=n&&n!=e.Init;if(!r!=!i){var o=t.display.dragFunctions,a=r?Ea:za;a(t.display.scroller,"dragstart",o.start),a(t.display.scroller,"dragenter",o.enter),a(t.display.scroller,"dragover",o.over),a(t.display.scroller,"dragleave",o.leave),a(t.display.scroller,"drop",o.drop)}}function Ut(e){var t=e.display;(t.lastWrapHeight!=t.wrapper.clientHeight||t.lastWrapWidth!=t.wrapper.clientWidth)&&(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function Kt(e,t){for(var r=wi(t);r!=e.wrapper;r=r.parentNode)if(!r||1==r.nodeType&&"true"==r.getAttribute("cm-ignore-events")||r.parentNode==e.sizer&&r!=e.mover)return!0}function Vt(e,t,r,n){var i=e.display;if(!r&&"true"==wi(t).getAttribute("cm-not-content"))return null;var o,a,s=i.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,a=t.clientY-s.top}catch(t){return null}var l,c=vt(e,o,a);if(n&&1==c.xRel&&(l=Qn(e.doc,c.line).text).length==c.ch){var u=Ba(l,l.length,e.options.tabSize)-l.length;c=Do(c.line,Math.max(0,Math.round((o-Ke(e.display).left)/kt(e.display))-u))}return c}function Gt(e){var t=this,r=t.display;if(!(Li(t,e)||r.activeTouch&&r.input.supportsTouch())){if(r.shift=e.shiftKey,Kt(r,e))return void(wo||(r.scroller.draggable=!1,setTimeout(function(){r.scroller.draggable=!0},100)));if(!Jt(t,e)){var n=Vt(t,e);switch(window.focus(),_i(e)){case 1:t.state.selectingText?t.state.selectingText(e):n?Xt(t,e,n):wi(e)==r.scroller&&La(e);break;case 2:wo&&(t.state.lastMiddleDown=+new Date),n&&xe(t.doc,n),setTimeout(function(){r.input.focus()},20),La(e);break;case 3:Po?br(t,e):gr(t)}}}}function Xt(e,t,r){ko?setTimeout(ji(Y,e),0):e.curOp.focus=Ki();var n,i=+new Date;Ho&&Ho.time>i-400&&0==jo(Ho.pos,r)?n="triple":Fo&&Fo.time>i-400&&0==jo(Fo.pos,r)?(n="double",Ho={time:i,pos:r}):(n="single",Fo={time:i,pos:r});var o,a=e.doc.sel,s=Oo?t.metaKey:t.ctrlKey;e.options.dragDrop&&es&&!e.isReadOnly()&&"single"==n&&(o=a.contains(r))>-1&&(jo((o=a.ranges[o]).from(),r)<0||r.xRel>0)&&(jo(o.to(),r)>0||r.xRel<0)?Zt(e,t,r,s):Yt(e,t,r,n,s)}function Zt(e,t,r,n){var i=e.display,o=+new Date,a=Ot(e,function(s){wo&&(i.scroller.draggable=!1),e.state.draggingText=!1,za(document,"mouseup",a),za(i.scroller,"drop",a),Math.abs(t.clientX-s.clientX)+Math.abs(t.clientY-s.clientY)<10&&(La(s),!n&&+new Date-200=h;h++){var v=Qn(c,h).text,y=Wa(v,l,o);l==p?i.push(new de(Do(h,y),Do(h,y))):v.length>y&&i.push(new de(Do(h,y),Do(h,Wa(v,p,o))))}i.length||i.push(new de(r,r)),Le(c,pe(d.ranges.slice(0,f).concat(i),f),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=u,k=b.anchor,x=t;if("single"!=n){if("double"==n)var w=e.findWordAt(t);else var w=new de(Do(t.line,0),ge(c,Do(t.line+1,0)));jo(w.anchor,k)>0?(x=w.head,k=Z(b.from(),w.anchor)):(x=w.anchor,k=X(b.to(),w.head))}var i=d.ranges.slice(0);i[f]=new de(ge(c,k),x),Le(c,pe(i,f),Da)}}function a(t){var r=++y,i=Vt(e,t,!0,"rect"==n);if(i)if(0!=jo(i,g)){e.curOp.focus=Ki(),o(i);var s=k(l,c);(i.line>=s.to||i.linev.bottom?20:0;u&&setTimeout(Ot(e,function(){y==r&&(l.scroller.scrollTop+=u,a(t))}),50)}}function s(t){e.state.selectingText=!1,y=1/0,La(t),l.input.focus(),za(document,"mousemove",b),za(document,"mouseup",x),c.history.lastSelOrigin=null}var l=e.display,c=e.doc;La(t);var u,f,d=c.sel,p=d.ranges;if(i&&!t.shiftKey?(f=c.sel.contains(r),u=f>-1?p[f]:new de(r,r)):(u=c.sel.primary(),f=c.sel.primIndex),t.altKey)n="rect",i||(u=new de(r,r)),r=Vt(e,t,!0,!0),f=-1;else if("double"==n){var h=e.findWordAt(r);u=e.display.shift||c.extend?ke(c,u,h.anchor,h.head):h}else if("triple"==n){var m=new de(Do(r.line,0),ge(c,Do(r.line+1,0)));u=e.display.shift||c.extend?ke(c,u,m.anchor,m.head):m}else u=ke(c,u,r);i?-1==f?(f=p.length,Le(c,pe(p.concat([u]),f),{scroll:!1,origin:"*mouse"})):p.length>1&&p[f].empty()&&"single"==n&&!t.shiftKey?(Le(c,pe(p.slice(0,f).concat(p.slice(f+1)),0),{scroll:!1,origin:"*mouse"}),d=c.sel):_e(c,f,u,Da):(f=0,Le(c,new fe([u],0),Da),d=c.sel);var g=r,v=l.wrapper.getBoundingClientRect(),y=0,b=Ot(e,function(e){_i(e)?a(e):s(e)}),x=Ot(e,s);e.state.selectingText=x,Ea(document,"mousemove",b),Ea(document,"mouseup",x)}function Qt(e,t,r,n){try{var i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&La(t);var a=e.display,s=a.lineDiv.getBoundingClientRect();if(o>s.bottom||!Ai(e,r))return xi(t);o-=s.top-a.viewOffset;for(var l=0;l=i){var u=ni(e.doc,o),f=e.options.gutters[l];return Ia(e,r,e,u,f,t),xi(t)}}}function Jt(e,t){return Qt(e,t,"gutterClick",!0)}function er(e){var t=this;if(nr(t),!Li(t,e)&&!Kt(t.display,e)){La(e),ko&&(Vo=+new Date);var r=Vt(t,e,!0),n=e.dataTransfer.files;if(r&&!t.isReadOnly())if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),a=0,s=function(e,n){if(!t.options.allowDropFileTypes||-1!=Ni(t.options.allowDropFileTypes,e.type)){var s=new FileReader;s.onload=Ot(t,function(){var e=s.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(e)&&(e=""),o[n]=e,++a==i){r=ge(t.doc,r);var l={from:r,to:r,text:t.doc.splitLines(o.join(t.doc.lineSeparator())),origin:"paste"};Mr(t.doc,l),Me(t.doc,he(r,Jo(l)))}}),s.readAsText(e)}},l=0;i>l;++l)s(n[l],l);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(Oo?e.altKey:e.ctrlKey))var c=t.listSelections();if(Te(t.doc,he(r,r)),c)for(var l=0;la.clientWidth,l=a.scrollHeight>a.clientHeight;if(n&&s||i&&l){if(i&&Oo&&wo)e:for(var c=t.target,u=o.view;c!=a;c=c.parentNode)for(var f=0;fd?p=Math.max(0,p+d-50):h=Math.min(e.doc.height,h+d+50),A(e,{top:p,bottom:h})}20>Go&&(null==o.wheelStartX?(o.wheelStartX=a.scrollLeft,o.wheelStartY=a.scrollTop,o.wheelDX=n,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=a.scrollLeft-o.wheelStartX,t=a.scrollTop-o.wheelStartY,r=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,r&&(Xo=(Xo*Go+r)/(Go+1),++Go)}},200)):(o.wheelDX+=n,o.wheelDY+=i))}}function sr(e,t,r){if("string"==typeof t&&(t=ua[t],!t))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=qa}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function lr(e,t,r){for(var n=0;nxo&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=ur(t,e);So&&(Qo=n?r:null,!n&&88==r&&!ns&&(Oo?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||pr(t)}}function pr(e){function t(e){18!=e.keyCode&&e.altKey||(Ya(r,"CodeMirror-crosshair"),za(document,"keyup",t),za(document,"mouseover",t))}var r=e.display.lineDiv;Qa(r,"CodeMirror-crosshair"),Ea(document,"keyup",t),Ea(document,"mouseover",t)}function hr(e){16==e.keyCode&&(this.doc.sel.shift=!1),Li(this,e)}function mr(e){var t=this;if(!(Kt(t.display,e)||Li(t,e)||e.ctrlKey&&!e.altKey||Oo&&e.metaKey)){var r=e.keyCode,n=e.charCode;if(So&&r==Qo)return Qo=null,void La(e);if(!So||e.which&&!(e.which<10)||!ur(t,e)){var i=String.fromCharCode(null==n?r:n);fr(t,e,i)||t.display.input.onKeyPress(e)}}}function gr(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,yr(e))},100)}function vr(e){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Ia(e,"focus",e),e.state.focused=!0,Qa(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),wo&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),je(e))}function yr(e){e.state.delayingBlurEvent||(e.state.focused&&(Ia(e,"blur",e),e.state.focused=!1,Ya(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function br(e,t){Kt(e.display,t)||kr(e,t)||Li(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function kr(e,t){return Ai(e,"gutterContextMenu")?Qt(e,t,"gutterContextMenu",!1):!1}function xr(e,t){if(jo(e,t.from)<0)return e;if(jo(e,t.to)<=0)return Jo(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Jo(t).ch-t.to.ch),Do(r,n)}function wr(e,t){for(var r=[],n=0;n=0;--i)Lr(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else Lr(e,t)}}function Lr(e,t){if(1!=t.text.length||""!=t.text[0]||0!=jo(t.from,t.to)){var r=wr(e,t);ui(e,t,r,e.cm?e.cm.curOp.id:0/0),Er(e,t,r,an(e,t));var n=[];Zn(e,function(e,r){r||-1!=Ni(n,e.history)||(ki(e.history,t),n.push(e.history)),Er(e,t,null,an(e,t))})}}function Tr(e,t,r){if(!e.cm||!e.cm.state.suppressEdits){for(var n,i=e.history,o=e.sel,a="undo"==t?i.done:i.undone,s="undo"==t?i.undone:i.done,l=0;l=0;--l){var f=n.changes[l];if(f.origin=t,u&&!Sr(e,f,!1))return void(a.length=0);c.push(si(e,f));var d=l?wr(e,f):Ii(a);Er(e,f,d,ln(e,f)),!l&&e.cm&&e.cm.scrollIntoView({from:f.from,to:Jo(f)});var p=[];Zn(e,function(e,t){t||-1!=Ni(p,e.history)||(ki(e.history,f),p.push(e.history)),Er(e,f,null,ln(e,f))})}}}}function Ar(e,t){if(0!=t&&(e.first+=t,e.sel=new fe(Pi(e.sel.ranges,function(e){return new de(Do(e.anchor.line+t,e.anchor.ch),Do(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){qt(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;ne.lastLine())){if(t.from.lineo&&(t={from:t.from,to:Do(o,Qn(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Jn(e,t.from,t.to),r||(r=wr(e,t)),e.cm?Or(e.cm,t,n):Vn(e,t,n),Te(e,r,Ra)}}function Or(e,t,r){var n=e.doc,i=e.display,a=t.from,s=t.to,l=!1,c=a.line;e.options.lineWrapping||(c=ri(bn(Qn(n,a.line))),n.iter(c,s.line+1,function(e){return e==i.maxLine?(l=!0,!0):void 0})),n.sel.contains(t.from,t.to)>-1&&Ti(e),Vn(n,t,r,o(e)),e.options.lineWrapping||(n.iter(c,a.line+t.text.length,function(e){var t=f(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,l=!1)}),l&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,a.line),Be(e,400);var u=t.text.length-(s.line-a.line)-1;t.full?qt(e):a.line!=s.line||1!=t.text.length||Kn(e.doc,t)?qt(e,a.line,s.line+1,u):Rt(e,a.line,"text");var d=Ai(e,"changes"),p=Ai(e,"change");if(p||d){var h={from:a,to:s,text:t.text,removed:t.removed,origin:t.origin};p&&Si(e,"change",e,h),d&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function zr(e,t,r,n,i){if(n||(n=r),jo(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=e.splitLines(t)),Mr(e,{from:r,to:n,text:t,origin:i})}function Ir(e,t){if(!Li(e,"scrollCursorIntoView")){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null;if(t.top+n.top<0?i=!0:t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!To){var o=Hi("div","",null,"position: absolute; top: "+(t.top-r.viewOffset-$e(e.display))+"px; height: "+(t.bottom-t.top+Ve(e)+r.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Nr(e,t,r,n){null==n&&(n=0);for(var i=0;5>i;i++){var o=!1,a=ht(e,t),s=r&&r!=t?ht(e,r):a,l=qr(e,Math.min(a.left,s.left),Math.min(a.top,s.top)-n,Math.max(a.left,s.left),Math.max(a.bottom,s.bottom)+n),c=e.doc.scrollTop,u=e.doc.scrollLeft;if(null!=l.scrollTop&&(ir(e,l.scrollTop),Math.abs(e.doc.scrollTop-c)>1&&(o=!0)),null!=l.scrollLeft&&(or(e,l.scrollLeft),Math.abs(e.doc.scrollLeft-u)>1&&(o=!0)),!o)break}return a}function Pr(e,t,r,n,i){var o=qr(e,t,r,n,i);null!=o.scrollTop&&ir(e,o.scrollTop),null!=o.scrollLeft&&or(e,o.scrollLeft)}function qr(e,t,r,n,i){var o=e.display,a=bt(e.display);0>r&&(r=0);var s=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,l=Xe(e),c={};i-r>l&&(i=r+l);var u=e.doc.height+Ue(o),f=a>r,d=i>u-a;if(s>r)c.scrollTop=f?0:r;else if(i>s+l){var p=Math.min(r,(d?u:i)-l);p!=s&&(c.scrollTop=p)}var h=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,m=Ge(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),g=n-t>m;return g&&(n=t+m),10>t?c.scrollLeft=0:h>t?c.scrollLeft=Math.max(0,t-(g?0:10)):n>m+h-3&&(c.scrollLeft=n+(g?0:10)-m),c}function Rr(e,t,r){(null!=t||null!=r)&&jr(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function Dr(e){jr(e);
-var t=e.getCursor(),n=t,r=t;e.options.lineWrapping||(n=t.ch?jo(t.line,t.ch-1):t,r=jo(t.line,t.ch+1)),e.curOp.scrollToPos={from:n,to:r,margin:e.options.cursorScrollMargin,isCursor:!0}}function Wn(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=mt(e,t.from),r=mt(e,t.to),i=Dn(e,Math.min(n.left,r.left),Math.min(n.top,r.top)-t.margin,Math.max(n.right,r.right),Math.max(n.bottom,r.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function Fn(e,t,n,r){var i,o=e.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?i=$e(e,t):n="prev");var a=e.options.tabSize,l=Qr(o,t),s=Wa(l.text,null,a);l.stateAfter&&(l.stateAfter=null);var c,u=l.text.match(/^\s*/)[0];if(r||/\S/.test(l.text)){if("smart"==n&&(c=o.mode.indent(i,l.text.slice(u.length),l.text),c==Ia||c>150)){if(!r)return;n="prev"}}else c=0,n="not";"prev"==n?c=t>o.first?Wa(Qr(o,t-1).text,null,a):0:"add"==n?c=s+e.options.indentUnit:"subtract"==n?c=s-e.options.indentUnit:"number"==typeof n&&(c=s+n),c=Math.max(0,c);var d="",f=0;if(e.options.indentWithTabs)for(var p=Math.floor(c/a);p;--p)f+=a,d+=" ";if(c>f&&(d+=Oi(c-f)),d!=u)return qn(o,d,jo(t,0),jo(t,u.length),"+input"),l.stateAfter=null,!0;for(var p=0;p=0;t--)qn(e.doc,"",r[t].from,r[t].to,"+delete");Rn(e)})}function Bn(e,t,n,r,i){function o(){var t=l+n;return t=e.first+e.size?!1:(l=t,u=Qr(e,t))}function a(e){var t=(i?po:ho)(u,s,n,!0);if(null==t){if(e||!o())return!1;s=i?(0>n?oo:io)(u):0>n?u.text.length:0}else s=t;return!0}var l=t.line,s=t.ch,c=n,u=Qr(e,l);if("char"==r)a();else if("column"==r)a(!0);else if("word"==r||"group"==r)for(var d=null,f="group"==r,p=e.cm&&e.cm.getHelper(t,"wordChars"),h=!0;!(0>n)||a(!h);h=!1){var m=u.text.charAt(s)||"\n",g=Wi(m,p)?"w":f&&"\n"==m?"n":!f||/\s/.test(m)?null:"p";if(!f||h||g||(g="s"),d&&d!=g){0>n&&(n=1,a());break}if(g&&(d=g),n>0&&!a(!h))break}var v=qe(e,jo(l,s),t,c,!0);return Ro(t,v)||(v.hitSide=!0),v}function Un(e,t,n,r){var i,o=e.doc,a=t.left;if("page"==r){var l=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=t.top+n*(l-(0>n?1.5:.5)*bt(e.display))}else"line"==r&&(i=n>0?t.bottom+3:t.top-3);for(;;){var s=vt(e,a,i);if(!s.outside)break;if(0>n?0>=i:i>=o.height){s.hitSide=!0;break}i+=5*n}return s}function Vn(t,n,r,i){e.defaults[t]=n,r&&(ta[t]=i?function(e,t,n){n!=na&&r(e,t,n)}:r)}function Gn(e){for(var t,n,r,i,o=e.split(/-(?!$)/),e=o[o.length-1],a=0;a0||0==a&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=$i("span",[o.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(yr(e,t.line,t,n,o)||t.line!=n.line&&yr(e,n.line,t,n,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Do=!0}o.addToHistory&&ui(e,{from:t,to:n,origin:"markText"},e.sel,0/0);var l,s=t.line,c=e.cm;if(e.iter(s,n.line+1,function(e){c&&o.collapsed&&!c.options.lineWrapping&&br(e)==c.display.maxLine&&(l=!0),o.collapsed&&s!=t.line&&ti(e,0),rr(e,new er(o,s==t.line?t.ch:null,s==n.line?n.ch:null)),++s}),o.collapsed&&e.iter(t.line,n.line+1,function(t){wr(e,t)&&ti(t,0)}),o.clearOnEnter&&za(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(Io=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++ga,o.atomic=!0),c){if(l&&(c.curOp.updateMaxLine=!0),o.collapsed)It(c,t.line,n.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var u=t.line;u<=n.line;u++)Dt(c,u,"text");o.atomic&&ze(c.doc),Si(c,"markerAdded",c,o)}return o}function Xn(e,t,n,r,i){r=ji(r),r.shared=!1;var o=[Zn(e,t,n,r,i)],a=o[0],l=r.widgetNode;return Xr(e,function(e){l&&(r.widgetNode=l.cloneNode(!0)),o.push(Zn(e,ge(e,t),ge(e,n),r,i));for(var s=0;s=t:o.to>t);(r||(r=[])).push(new er(a,o.from,s?null:o.to))}}return r}function or(e,t,n){if(e)for(var r,i=0;i=t:o.to>t);if(l||o.from==t&&"bookmark"==a.type&&(!n||o.marker.insertLeft)){var s=null==o.from||(a.inclusiveLeft?o.from<=t:o.from0&&l)for(var d=0;dd;++d)h.push(m);h.push(s)}return h}function lr(e){for(var t=0;t0)){var u=[s,1],d=Ro(c.from,l.from),f=Ro(c.to,l.to);(0>d||!a.inclusiveLeft&&!d)&&u.push({from:c.from,to:l.from}),(f>0||!a.inclusiveRight&&!f)&&u.push({from:l.to,to:c.to}),i.splice.apply(i,u),s+=u.length-1}}return i}function ur(e){var t=e.markedSpans;if(t){for(var n=0;n=0&&0>=d||0>=u&&d>=0)&&(0>=u&&(Ro(c.to,n)>0||s.marker.inclusiveRight&&i.inclusiveLeft)||u>=0&&(Ro(c.from,r)<0||s.marker.inclusiveLeft&&i.inclusiveRight)))return!0}}}function br(e){for(var t;t=gr(e);)e=t.find(-1,!0).line;return e}function xr(e){for(var t,n;t=vr(e);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function kr(e,t){var n=Qr(e,t),r=br(n);return n==r?t:ni(r)}function _r(e,t){if(t>e.lastLine())return t;var n,r=Qr(e,t);if(!wr(e,r))return t;for(;n=vr(r);)r=n.find(1,!0).line;return ni(r)+1}function wr(e,t){var n=Do&&t.markedSpans;if(n)for(var r,i=0;io;o++){i&&(i[0]=e.innerMode(t,r).mode);var a=t.token(n,r);if(n.pos>n.start)return a}throw new Error("Mode "+t.name+" failed to advance stream.")}function qr(e,t,n,r){function i(e){return{start:d.start,end:d.pos,string:d.current(),type:o||null,state:e?sa(a.mode,u):u}}var o,a=e.doc,l=a.mode;t=ge(a,t);var s,c=Qr(a,t.line),u=$e(e,t.line,n),d=new ma(c.text,e.options.tabSize);for(r&&(s=[]);(r||d.pose.options.maxHighlightLength?(l=!1,a&&Dr(e,t,r,d.pos),d.pos=t.length,s=null):s=zr(Or(n,d,r,f),o),f){var p=f[0].name;p&&(s="m-"+(s?p+" "+s:p))}if(!l||u!=s){for(;cc;){var r=i[s];r>e&&i.splice(s,1,e,i[s+1],r),s+=2,c=Math.min(e,r)}if(t)if(l.opaque)i.splice(n,s-n,e,"cm-overlay "+t),s=n+2;else for(;s>n;n+=2){var o=i[n+1];i[n+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Ir(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=$e(e,ni(t)),i=Pr(e,t,t.text.length>e.options.maxHighlightLength?sa(e.doc.mode,r):r);t.stateAfter=r,t.styles=i.styles,i.classes?t.styleClasses=i.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.frontier&&e.doc.frontier++}return t.styles}function Dr(e,t,n,r){var i=e.doc.mode,o=new ma(t,e.options.tabSize);for(o.start=o.pos=r||0,""==t&&Er(i,n);!o.eol();)Or(i,o,n),o.start=o.pos}function jr(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?_a:ka;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Rr(e,t){var n=$i("span",null,null,_o?"padding-right: .1px":null),r={pre:$i("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,splitSpaces:(xo||_o)&&e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,a=i?t.rest[i-1]:t.line;r.pos=0,r.addToken=Fr,Ji(e.display.measure)&&(o=oi(a))&&(r.addToken=$r(r.addToken,o)),r.map=[];var l=t!=e.display.externalMeasured&&ni(a);Ur(a,r,Ir(e,a,l)),a.styleClasses&&(a.styleClasses.bgClass&&(r.bgClass=Ki(a.styleClasses.bgClass,r.bgClass||"")),a.styleClasses.textClass&&(r.textClass=Ki(a.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(Qi(e.display.measure))),0==i?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return _o&&/\bcm-tab\b/.test(r.content.lastChild.className)&&(r.content.className="cm-tab-wrap-hack"),qa(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=Ki(r.pre.className,r.textClass||"")),r}function Wr(e){var t=$i("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Fr(e,t,n,r,i,o,a){if(t){var l=e.splitSpaces?t.replace(/ {3,}/g,Hr):t,s=e.cm.state.specialChars,c=!1;if(s.test(t))for(var u=document.createDocumentFragment(),d=0;;){s.lastIndex=d;var f=s.exec(t),p=f?f.index-d:t.length-d;if(p){var h=document.createTextNode(l.slice(d,d+p));u.appendChild(xo&&9>ko?$i("span",[h]):h),e.map.push(e.pos,e.pos+p,h),e.col+=p,e.pos+=p}if(!f)break;if(d+=p+1," "==f[0]){var m=e.cm.options.tabSize,g=m-e.col%m,h=u.appendChild($i("span",Oi(g),"cm-tab"));h.setAttribute("role","presentation"),h.setAttribute("cm-text"," "),e.col+=g}else if("\r"==f[0]||"\n"==f[0]){var h=u.appendChild($i("span","\r"==f[0]?"␍":"","cm-invalidchar"));h.setAttribute("cm-text",f[0]),e.col+=1}else{var h=e.cm.options.specialCharPlaceholder(f[0]);h.setAttribute("cm-text",f[0]),u.appendChild(xo&&9>ko?$i("span",[h]):h),e.col+=1}e.map.push(e.pos,e.pos+1,h),e.pos++}else{e.col+=t.length;var u=document.createTextNode(l);e.map.push(e.pos,e.pos+t.length,u),xo&&9>ko&&(c=!0),e.pos+=t.length}if(n||r||i||c||a){var v=n||"";r&&(v+=r),i&&(v+=i);var y=$i("span",[u],v,a);return o&&(y.title=o),e.content.appendChild(y)}e.content.appendChild(u)}}function Hr(e){for(var t=" ",n=0;nc&&f.from<=c)break}if(f.to>=u)return e(n,r,i,o,a,l,s);e(n,r.slice(0,f.to-c),i,o,null,l,s),o=null,r=r.slice(f.to-c),c=f.to}}}function Br(e,t,n,r){var i=!r&&n.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!r&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function Ur(e,t,n){var r=e.markedSpans,i=e.text,o=0;if(r)for(var a,l,s,c,u,d,f,p=i.length,h=0,m=1,g="",v=0;;){if(v==h){s=c=u=d=l="",f=null,v=1/0;for(var y,b=[],x=0;xh||_.collapsed&&k.to==h&&k.from==h)?(null!=k.to&&k.to!=h&&v>k.to&&(v=k.to,c=""),_.className&&(s+=" "+_.className),_.css&&(l=(l?l+";":"")+_.css),_.startStyle&&k.from==h&&(u+=" "+_.startStyle),_.endStyle&&k.to==v&&(y||(y=[])).push(_.endStyle,k.to),_.title&&!d&&(d=_.title),_.collapsed&&(!f||hr(f.marker,_)<0)&&(f=k)):k.from>h&&v>k.from&&(v=k.from)}if(y)for(var x=0;x=p)break;for(var w=Math.min(p,v);;){if(g){var C=h+g.length;if(!f){var S=C>w?g.slice(0,w-h):g;t.addToken(t,S,a?a+s:s,u,h+S.length==v?c:"",d,l)}if(C>=w){g=g.slice(w-h),h=w;break}h=C,u=""}g=i.slice(o,o=n[m++]),a=jr(n[m++],t.cm.options)}}else for(var m=1;mn;++n)o.push(new xa(c[n],i(n),r));return o}var l=t.from,s=t.to,c=t.text,u=Qr(e,l.line),d=Qr(e,s.line),f=qi(c),p=i(c.length-1),h=s.line-l.line;if(t.full)e.insert(0,a(0,c.length)),e.remove(c.length,e.size-c.length);else if(Vr(e,t)){var m=a(0,c.length-1);o(d,d.text,p),h&&e.remove(l.line,h),m.length&&e.insert(l.line,m)}else if(u==d)if(1==c.length)o(u,u.text.slice(0,l.ch)+f+u.text.slice(s.ch),p);else{var m=a(1,c.length-1);m.push(new xa(f+u.text.slice(s.ch),p,r)),o(u,u.text.slice(0,l.ch)+c[0],i(0)),e.insert(l.line+1,m)}else if(1==c.length)o(u,u.text.slice(0,l.ch)+c[0]+d.text.slice(s.ch),i(0)),e.remove(l.line+1,h);else{o(u,u.text.slice(0,l.ch)+c[0],i(0)),o(d,f+d.text.slice(s.ch),p);var m=a(1,c.length-1);h>1&&e.remove(l.line+1,h-1),e.insert(l.line+1,m)}Si(e,"change",e,t)}function Kr(e){this.lines=e,this.parent=null;for(var t=0,n=0;tt||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],o=i.chunkSize();if(o>t){n=i;break}t-=o}return n.lines[t]}function Jr(e,t,n){var r=[],i=t.line;return e.iter(t.line,n.line+1,function(e){var o=e.text;i==n.line&&(o=o.slice(0,n.ch)),i==t.line&&(o=o.slice(t.ch)),r.push(o),++i}),r}function ei(e,t,n){var r=[];return e.iter(t,n,function(e){r.push(e.text)}),r}function ti(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function ni(e){if(null==e.parent)return null;for(var t=e.parent,n=Ni(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var i=0;r.children[i]!=t;++i)n+=r.children[i].chunkSize();return n+t.first}function ri(e,t){var n=e.first;e:do{for(var r=0;rt){e=i;continue e}t-=o,n+=i.chunkSize()}return n}while(!e.lines);for(var r=0;rt)break;t-=l}return n+r}function ii(e){e=br(e);for(var t=0,n=e.parent,r=0;r1&&!e.done[e.done.length-2].ranges?(e.done.pop(),qi(e.done)):void 0}function ui(e,t,n,r){if("ignoreHistory"!=t.origin){var i=e.history;i.undone.length=0;var o,a=+new Date;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>a-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=ci(i,i.lastOp==r))){var l=qi(o.changes);0==Ro(t.from,t.to)&&0==Ro(t.from,l.to)?l.to=Jo(t):o.changes.push(li(e,t))}else{var s=qi(i.done);for(s&&s.ranges||pi(e.sel,i.done),o={changes:[li(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=a,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,l||qa(e,"historyAdded")}}function di(e,t,n,r){var i=t.charAt(0);return"*"==i||"+"==i&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function fi(e,t,n,r){var i=e.history,o=r&&r.origin;n==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||di(e,o,qi(i.done),t))?i.done[i.done.length-1]=t:pi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=n,r&&r.clearRedo!==!1&&si(i.undone)}function pi(e,t){var n=qi(t);n&&n.ranges&&n.equals(e)||t.push(e)}function hi(e,t,n,r){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(n){n.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=n.markedSpans),++o})}function mi(e){if(!e)return null;for(var t,n=0;n-1&&(qi(l)[d]=u[d],delete u[d])}}}return i}function yi(e,t,n,r){n0?r.slice():Ea:r||Ea}function Si(e,t){function n(e){return function(){e.apply(null,o)}}var r=Ci(e,t,!1);if(r.length){var i,o=Array.prototype.slice.call(arguments,2);Uo?i=Uo.delayedCallbacks:Na?i=Na:(i=Na=[],setTimeout(Mi,0));for(var a=0;a0}function zi(e){e.prototype.on=function(e,t){za(this,e,t)},e.prototype.off=function(e,t){Oa(this,e,t)}}function Ei(){this.id=null}function Oi(e){for(;Ha.length<=e;)Ha.push(qi(Ha)+" ");return Ha[e]}function qi(e){return e[e.length-1]}function Ni(e,t){for(var n=0;n-1&&Va(e)?!0:t.test(e):Va(e)}function Fi(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Hi(e){return e.charCodeAt(0)>=768&&Ga.test(e)}function $i(e,t,n,r){var i=document.createElement(e);if(n&&(i.className=n),r&&(i.style.cssText=r),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o0;--t)e.removeChild(e.firstChild);return e}function Ui(e,t){return Bi(e).appendChild(t)}function Vi(){for(var e=document.activeElement;e&&e.root&&e.root.activeElement;)e=e.root.activeElement;return e}function Gi(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function Ki(e,t){for(var n=e.split(" "),r=0;r2&&!(xo&&8>ko))}var n=Za?$i("span",""):$i("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function Ji(e){if(null!=Xa)return Xa;var t=Ui(e,document.createTextNode("AخA")),n=Ba(t,0,1).getBoundingClientRect();if(!n||n.left==n.right)return!1;var r=Ba(t,1,2).getBoundingClientRect();return Xa=r.right-n.right<3}function eo(e){if(null!=il)return il;var t=Ui(e,$i("span","x")),n=t.getBoundingClientRect(),r=Ba(t,0,1).getBoundingClientRect();return il=Math.abs(n.left-r.left)>1}function to(e,t,n,r){if(!e)return r(t,n,"ltr");for(var i=!1,o=0;ot||t==n&&a.to==t)&&(r(Math.max(a.from,t),Math.min(a.to,n),1==a.level?"rtl":"ltr"),i=!0)}i||r(t,n,"ltr")}function no(e){return e.level%2?e.to:e.from}function ro(e){return e.level%2?e.from:e.to}function io(e){var t=oi(e);return t?no(t[0]):0}function oo(e){var t=oi(e);return t?ro(qi(t)):e.text.length}function ao(e,t){var n=Qr(e.doc,t),r=br(n);r!=n&&(t=ni(r));var i=oi(r),o=i?i[0].level%2?oo(r):io(r):0;return jo(t,o)}function lo(e,t){for(var n,r=Qr(e.doc,t);n=vr(r);)r=n.find(1,!0).line,t=null;var i=oi(r),o=i?i[0].level%2?io(r):oo(r):r.text.length;return jo(null==t?ni(r):t,o)}function so(e,t){var n=ao(e,t.line),r=Qr(e.doc,n.line),i=oi(r);if(!i||0==i[0].level){var o=Math.max(0,r.text.search(/\S/)),a=t.line==n.line&&t.ch<=o&&t.ch;return jo(n.line,a?0:o)}return n}function co(e,t,n){var r=e[0].level;return t==r?!0:n==r?!1:n>t}function uo(e,t){al=null;for(var n,r=0;rt)return r;if(i.from==t||i.to==t){if(null!=n)return co(e,i.level,e[n].level)?(i.from!=i.to&&(al=n),r):(i.from!=i.to&&(al=r),n);n=r}}return n}function fo(e,t,n,r){if(!r)return t+n;do t+=n;while(t>0&&Hi(e.text.charAt(t)));return t}function po(e,t,n,r){var i=oi(e);if(!i)return ho(e,t,n,r);for(var o=uo(i,t),a=i[o],l=fo(e,t,a.level%2?-n:n,r);;){if(l>a.from&&l0==a.level%2?a.to:a.from);if(a=i[o+=n],!a)return null;l=n>0==a.level%2?fo(e,a.to,-1,r):fo(e,a.from,1,r)}}function ho(e,t,n,r){var i=t+n;if(r)for(;i>0&&Hi(e.text.charAt(i));)i+=n;return 0>i||i>e.text.length?null:i}var mo=navigator.userAgent,go=navigator.platform,vo=/gecko\/\d/i.test(mo),yo=/MSIE \d/.test(mo),bo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(mo),xo=yo||bo,ko=xo&&(yo?document.documentMode||6:bo[1]),_o=/WebKit\//.test(mo),wo=_o&&/Qt\/\d+\.\d+/.test(mo),Co=/Chrome\//.test(mo),So=/Opera\//.test(mo),Mo=/Apple Computer/.test(navigator.vendor),Lo=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(mo),To=/PhantomJS/.test(mo),Ao=/AppleWebKit/.test(mo)&&/Mobile\/\w+/.test(mo),zo=Ao||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(mo),Eo=Ao||/Mac/.test(go),Oo=/win/i.test(go),qo=So&&mo.match(/Version\/(\d*\.\d*)/);qo&&(qo=Number(qo[1])),qo&&qo>=15&&(So=!1,_o=!0);var No=Eo&&(wo||So&&(null==qo||12.11>qo)),Po=vo||xo&&ko>=9,Io=!1,Do=!1;m.prototype=ji({update:function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==r&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?r:0,bottom:t?r:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert)},zeroWidthHack:function(){var e=Eo&&!Lo?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new Ei,this.disableVert=new Ei},enableZeroWidthBar:function(e,t){function n(){var r=e.getBoundingClientRect(),i=document.elementFromPoint(r.left+1,r.bottom-1);i!=e?e.style.pointerEvents="none":t.set(1e3,n)}e.style.pointerEvents="auto",t.set(1e3,n)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},m.prototype),g.prototype=ji({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},g.prototype),e.scrollbarModel={
-"native":m,"null":g},S.prototype.signal=function(e,t){Ai(e,t)&&this.events.push(arguments)},S.prototype.finish=function(){for(var e=0;e=9&&n.hasSelection&&(n.hasSelection=null),n.poll()}),za(o,"paste",function(e){Li(r,e)||J(e,r)||(r.state.pasteIncoming=!0,n.fastPoll())}),za(o,"cut",t),za(o,"copy",t),za(e.scroller,"paste",function(t){Vt(e,t)||Li(r,t)||(r.state.pasteIncoming=!0,n.focus())}),za(e.lineSpace,"selectstart",function(t){Vt(e,t)||La(t)}),za(o,"compositionstart",function(){var e=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}}),za(o,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},prepareSelection:function(){var e=this.cm,t=e.display,n=e.doc,r=Ie(e);if(e.options.moveInputWithCursor){var i=ht(e,n.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+a.top-o.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+a.left-o.left))}return r},showSelection:function(e){var t=this.cm,n=t.display;Ui(n.cursorDiv,e.cursors),Ui(n.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,n,r=this.cm,i=r.doc;if(r.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=rl&&(o.to().line-o.from().line>100||(n=r.getSelection()).length>1e3);var a=t?"-":n||r.getSelection();this.composing||(this.textarea.value=a),r.state.focused&&$a(this.textarea),xo&&ko>=9&&(this.hasSelection=a)}else e||(this.composing||(this.prevInput=this.textarea.value=""),xo&&ko>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!zo||Vi()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;e.pollingFast||e.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var r=n.poll();r||t?(n.pollingFast=!1,n.slowPoll()):(t=!0,n.polling.set(60,e))}var t=!1,n=this;n.pollingFast=!0,n.polling.set(20,e)},poll:function(){var e=this.cm,t=this.textarea,n=this.prevInput;if(this.contextMenuPending||!e.state.focused||nl(t)&&!n&&!this.composing||e.isReadOnly()||e.options.disableInput||e.state.keySeq)return!1;var r=t.value;if(r==n&&!e.somethingSelected())return!1;if(xo&&ko>=9&&this.hasSelection===r||Eo&&/[\uf700-\uf7ff]/.test(r))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){var i=r.charCodeAt(0);if(8203!=i||n||(n=""),8666==i)return this.reset(),this.cm.execCommand("undo")}for(var o=0,a=Math.min(n.length,r.length);a>o&&n.charCodeAt(o)==r.charCodeAt(o);)++o;var l=this;return zt(e,function(){Q(e,r.slice(o),n.length-o,null,l.composing?"*compose":null),r.length>1e3||r.indexOf("\n")>-1?t.value=l.prevInput="":l.prevInput=r,l.composing&&(l.composing.range.clear(),l.composing.range=e.markText(l.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){xo&&ko>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=a.selectionStart){var e=i.somethingSelected(),t=""+(e?a.value:"");a.value="⇚",a.value=t,r.prevInput=e?"":"",a.selectionStart=1,a.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function n(){if(r.contextMenuPending=!1,r.wrapper.style.position="relative",a.style.cssText=u,xo&&9>ko&&o.scrollbars.setScrollTop(o.scroller.scrollTop=s),null!=a.selectionStart){(!xo||xo&&9>ko)&&t();var e=0,n=function(){o.selForContextMenu==i.doc.sel&&0==a.selectionStart&&a.selectionEnd>0&&""==r.prevInput?Et(i,ua.selectAll)(i):e++<10?o.detectingSelectAll=setTimeout(n,500):o.input.reset()};o.detectingSelectAll=setTimeout(n,200)}}var r=this,i=r.cm,o=i.display,a=r.textarea,l=Gt(i,e),s=o.scroller.scrollTop;if(l&&!So){var c=i.options.resetSelectionOnContextMenu;c&&-1==i.doc.sel.contains(l)&&Et(i,Le)(i.doc,he(l),Da);var u=a.style.cssText;if(r.wrapper.style.position="absolute",a.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+(xo?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",_o)var d=window.scrollY;if(o.input.focus(),_o&&window.scrollTo(null,d),o.input.reset(),i.somethingSelected()||(a.value=r.prevInput=" "),r.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),xo&&ko>=9&&t(),Po){Aa(e);var f=function(){Oa(window,"mouseup",f),setTimeout(n,20)};za(window,"mouseup",f)}else setTimeout(n,50)}},readOnlyChanged:function(e){e||this.reset()},setUneditable:Ii,needsContentAttribute:!1},re.prototype),oe.prototype=ji({init:function(e){function t(e){if(!Li(r,e)){if(r.somethingSelected())Wo=r.getSelections(),"cut"==e.type&&r.replaceSelection("",null,"cut");else{if(!r.options.lineWiseCopyCut)return;var t=te(r);Wo=t.text,"cut"==e.type&&r.operation(function(){r.setSelections(t.ranges,0,Da),r.replaceSelection("",null,"cut")})}if(e.clipboardData&&!Ao)e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/plain",Wo.join("\n"));else{var n=ie(),i=n.firstChild;r.display.lineSpace.insertBefore(n,r.display.lineSpace.firstChild),i.value=Wo.join("\n");var o=document.activeElement;$a(i),setTimeout(function(){r.display.lineSpace.removeChild(n),o.focus()},50)}}}var n=this,r=n.cm,i=n.div=e.lineDiv;ne(i),za(i,"paste",function(e){Li(r,e)||J(e,r)}),za(i,"compositionstart",function(e){var t=e.data;if(n.composing={sel:r.doc.sel,data:t,startData:t},t){var i=r.doc.sel.primary(),o=r.getLine(i.head.line),a=o.indexOf(t,Math.max(0,i.head.ch-t.length));a>-1&&a<=i.head.ch&&(n.composing.sel=he(jo(i.head.line,a),jo(i.head.line,a+t.length)))}}),za(i,"compositionupdate",function(e){n.composing.data=e.data}),za(i,"compositionend",function(e){var t=n.composing;t&&(e.data==t.startData||/\u200b/.test(e.data)||(t.data=e.data),setTimeout(function(){t.handled||n.applyComposition(t),n.composing==t&&(n.composing=null)},50))}),za(i,"touchstart",function(){n.forceCompositionEnd()}),za(i,"input",function(){n.composing||(r.isReadOnly()||!n.pollContent())&&zt(n.cm,function(){It(r)})}),za(i,"copy",t),za(i,"cut",t)},prepareSelection:function(){var e=Ie(this.cm,!1);return e.focus=this.cm.state.focused,e},showSelection:function(e){e&&this.cm.display.view.length&&(e.focus&&this.showPrimarySelection(),this.showMultipleSelections(e))},showPrimarySelection:function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),n=se(this.cm,e.anchorNode,e.anchorOffset),r=se(this.cm,e.focusNode,e.focusOffset);if(!n||n.bad||!r||r.bad||0!=Ro(X(n,r),t.from())||0!=Ro(Z(n,r),t.to())){var i=ae(this.cm,t.from()),o=ae(this.cm,t.to());if(i||o){var a=this.cm.display.view,l=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var s=a[a.length-1].measure,c=s.maps?s.maps[s.maps.length-1]:s.map;o={node:c[c.length-1],offset:c[c.length-2]-c[c.length-3]}}}else i={node:a[0].measure.map[2],offset:0};try{var u=Ba(i.node,i.offset,o.offset,o.node)}catch(d){}u&&(!vo&&this.cm.state.focused?(e.collapse(i.node,i.offset),u.collapsed||e.addRange(u)):(e.removeAllRanges(),e.addRange(u)),l&&null==e.anchorNode?e.addRange(l):vo&&this.startGracePeriod()),this.rememberSelection()}}},startGracePeriod:function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){e.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(e){Ui(this.cm.display.cursorDiv,e.cursors),Ui(this.cm.display.selectionDiv,e.selection)},rememberSelection:function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},selectionInEditor:function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return Ka(this.div,t)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():zt(this.cm,function(){t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},selectionChanged:function(){var e=window.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var e=window.getSelection(),t=this.cm;this.rememberSelection();var n=se(t,e.anchorNode,e.anchorOffset),r=se(t,e.focusNode,e.focusOffset);n&&r&&zt(t,function(){Le(t.doc,he(n,r),Da),(n.bad||r.bad)&&(t.curOp.selectionChanged=!0)})}},pollContent:function(){var e=this.cm,t=e.display,n=e.doc.sel.primary(),r=n.from(),i=n.to();if(r.linet.viewTo-1)return!1;var o;if(r.line==t.viewFrom||0==(o=Rt(e,r.line)))var a=ni(t.view[0].line),l=t.view[0].node;else var a=ni(t.view[o].line),l=t.view[o-1].node.nextSibling;var s=Rt(e,i.line);if(s==t.view.length-1)var c=t.viewTo-1,u=t.lineDiv.lastChild;else var c=ni(t.view[s+1].line)-1,u=t.view[s+1].node.previousSibling;for(var d=e.doc.splitLines(ue(e,l,u,a,c)),f=Jr(e.doc,jo(a,0),jo(c,Qr(e.doc,c).text.length));d.length>1&&f.length>1;)if(qi(d)==qi(f))d.pop(),f.pop(),c--;else{if(d[0]!=f[0])break;d.shift(),f.shift(),a++}for(var p=0,h=0,m=d[0],g=f[0],v=Math.min(m.length,g.length);v>p&&m.charCodeAt(p)==g.charCodeAt(p);)++p;for(var y=qi(d),b=qi(f),x=Math.min(y.length-(1==d.length?p:0),b.length-(1==f.length?p:0));x>h&&y.charCodeAt(y.length-h-1)==b.charCodeAt(b.length-h-1);)++h;d[d.length-1]=y.slice(0,y.length-h),d[0]=d[0].slice(p);var k=jo(a,p),_=jo(c,f.length?qi(f).length-h:0);return d.length>1||d[0]||Ro(k,_)?(qn(e.doc,d,k,_,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(e){this.cm.isReadOnly()?Et(this.cm,It)(this.cm):e.data&&e.data!=e.startData&&Et(this.cm,Q)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.contentEditable="false"},onKeyPress:function(e){e.preventDefault(),this.cm.isReadOnly()||Et(this.cm,Q)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},readOnlyChanged:function(e){this.div.contentEditable=String("nocursor"!=e)},onContextMenu:Ii,resetPosition:Ii,needsContentAttribute:!0},oe.prototype),e.inputStyles={textarea:re,contenteditable:oe},de.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t=0&&Ro(e,r.to())<=0)return n}return-1}},fe.prototype={from:function(){return X(this.anchor,this.head)},to:function(){return Z(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Fo,Ho,$o,Bo={left:0,right:0,top:0,bottom:0},Uo=null,Vo=0,Go=0,Ko=0,Zo=null;xo?Zo=-.53:vo?Zo=15:Co?Zo=-.7:Mo&&(Zo=-1/3);var Xo=function(e){var t=e.wheelDeltaX,n=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==n&&e.detail&&e.axis==e.VERTICAL_AXIS?n=e.detail:null==n&&(n=e.wheelDelta),{x:t,y:n}};e.wheelEventPixels=function(e){var t=Xo(e);return t.x*=Zo,t.y*=Zo,t};var Yo=new Ei,Qo=null,Jo=e.changeEnd=function(e){return e.text?jo(e.from.line+e.text.length-1,qi(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var n=this.options,r=n[e];(n[e]!=t||"mode"==e)&&(n[e]=t,ta.hasOwnProperty(e)&&Et(this,ta[e])(this,t,r))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Kn(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;nn&&(Fn(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&Rn(this));else{var o=i.from(),a=i.to(),l=Math.max(n,o.line);n=Math.min(this.lastLine(),a.line-(a.ch?0:1))+1;for(var s=l;n>s;++s)Fn(this,s,e);var c=this.doc.sel.ranges;0==o.ch&&t.length==c.length&&c[r].from().ch>0&&we(this.doc,r,new fe(o,c[r].to()),Da)}}}),getTokenAt:function(e,t){return qr(this,e,t)},getLineTokens:function(e,t){return qr(this,jo(e),t,!0)},getTokenTypeAt:function(e){e=ge(this.doc,e);var t,n=Ir(this,Qr(this.doc,e.line)),r=0,i=(n.length-1)/2,o=e.ch;if(0==o)t=n[2];else for(;;){var a=r+i>>1;if((a?n[2*a-1]:0)>=o)i=a;else{if(!(n[2*a+1]l?t:0==l?null:t.slice(0,l-1)},getModeAt:function(t){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(t).state).mode:n},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var n=[];if(!la.hasOwnProperty(t))return n;var r=la[t],i=this.getModeAt(e);if("string"==typeof i[t])r[i[t]]&&n.push(r[i[t]]);else if(i[t])for(var o=0;oi&&(e=i,r=!0),n=Qr(this.doc,e)}else n=e;return dt(this,n,{top:0,left:0},t||"page").top+(r?this.doc.height-ii(n):0)},defaultTextHeight:function(){return bt(this.display)},defaultCharWidth:function(){return xt(this.display)},setGutterMarker:Ot(function(e,t,n){return Hn(this.doc,e,"gutter",function(e){var r=e.gutterMarkers||(e.gutterMarkers={});return r[t]=n,!n&&Fi(r)&&(e.gutterMarkers=null),!0})}),clearGutter:Ot(function(e){var t=this,n=t.doc,r=n.first;n.iter(function(n){n.gutterMarkers&&n.gutterMarkers[e]&&(n.gutterMarkers[e]=null,Dt(t,r,"gutter"),Fi(n.gutterMarkers)&&(n.gutterMarkers=null)),++r})}),lineInfo:function(e){if("number"==typeof e){if(!ye(this.doc,e))return null;var t=e;if(e=Qr(this.doc,e),!e)return null}else{var t=ni(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var o=this.display;e=ht(this,ge(this.doc,e));var a=e.bottom,l=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==r)a=e.top;else if("above"==r||"near"==r){var s=Math.max(o.wrapper.clientHeight,this.doc.height),c=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==r||e.bottom+t.offsetHeight>s)&&e.top>t.offsetHeight?a=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=s&&(a=e.bottom),l+t.offsetWidth>c&&(l=c-t.offsetWidth)}t.style.top=a+"px",t.style.left=t.style.right="","right"==i?(l=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?l=0:"middle"==i&&(l=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=l+"px"),n&&In(this,l,a,l+t.offsetWidth,a+t.offsetHeight)},triggerOnKeyDown:Ot(pn),triggerOnKeyPress:Ot(gn),triggerOnKeyUp:mn,execCommand:function(e){return ua.hasOwnProperty(e)?ua[e].call(null,this):void 0},triggerElectric:Ot(function(e){ee(this,e)}),findPosH:function(e,t,n,r){var i=1;0>t&&(i=-1,t=-t);for(var o=0,a=ge(this.doc,e);t>o&&(a=Bn(this.doc,a,i,n,r),!a.hitSide);++o);return a},moveH:Ot(function(e,t){var n=this;n.extendSelectionsBy(function(r){return n.display.shift||n.doc.extend||r.empty()?Bn(n.doc,r.head,e,t,n.options.rtlMoveVisually):0>e?r.from():r.to()},Ra)}),deleteH:Ot(function(e,t){var n=this.doc.sel,r=this.doc;n.somethingSelected()?r.replaceSelection("",null,"+delete"):$n(this,function(n){var i=Bn(r,n.head,e,t,!1);return 0>e?{from:i,to:n.head}:{from:n.head,to:i}})}),findPosV:function(e,t,n,r){var i=1,o=r;0>t&&(i=-1,t=-t);for(var a=0,l=ge(this.doc,e);t>a;++a){var s=ht(this,l,"div");if(null==o?o=s.left:s.left=o,l=Un(this,s,i,n),l.hitSide)break}return l},moveV:Ot(function(e,t){var n=this,r=this.doc,i=[],o=!n.display.shift&&!r.extend&&r.sel.somethingSelected();if(r.extendSelectionsBy(function(a){if(o)return 0>e?a.from():a.to();var l=ht(n,a.head,"div");null!=a.goalColumn&&(l.left=a.goalColumn),i.push(l.left);var s=Un(n,l,e,t);return"page"==t&&a==r.sel.primary()&&jn(n,null,pt(n,s,"div").top-l.top),s},Ra),i.length)for(var a=0;a0&&l(n.charAt(r-1));)--r;for(;i.5)&&a(this),qa(this,"refresh",this)}),swapDoc:Ot(function(e){var t=this.doc;return t.cm=null,Yr(this,e),st(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,Si(this,"swapDoc",this,t),t}),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}},zi(e);var ea=e.defaults={},ta=e.optionHandlers={},na=e.Init={toString:function(){return"CodeMirror.Init"}};Vn("value","",function(e,t){e.setValue(t)},!0),Vn("mode",null,function(e,t){e.doc.modeOption=t,n(e)},!0),Vn("indentUnit",2,n,!0),Vn("indentWithTabs",!1),Vn("smartIndent",!0),Vn("tabSize",4,function(e){r(e),st(e),It(e)},!0),Vn("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var n=[],r=e.doc.first;e.doc.iter(function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(-1==o)break;i=o+t.length,n.push(jo(r,o))}r++});for(var i=n.length-1;i>=0;i--)qn(e.doc,t,n[i],jo(n[i].line,n[i].ch+t.length))}}),Vn("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(t,n,r){t.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),r!=e.Init&&t.refresh()}),Vn("specialCharPlaceholder",Wr,function(e){e.refresh()},!0),Vn("electricChars",!0),Vn("inputStyle",zo?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Vn("rtlMoveVisually",!Oo),Vn("wholeLineUpdateBefore",!0),Vn("theme","default",function(e){l(e),s(e)},!0),Vn("keyMap","default",function(t,n,r){var i=Kn(n),o=r!=e.Init&&Kn(r);o&&o.detach&&o.detach(t,i),i.attach&&i.attach(t,o||null)}),Vn("extraKeys",null),Vn("lineWrapping",!1,i,!0),Vn("gutters",[],function(e){p(e.options),s(e)},!0),Vn("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?C(e.display)+"px":"0",e.refresh()},!0),Vn("coverGutterNextToScrollbar",!1,function(e){y(e)},!0),Vn("scrollbarStyle","native",function(e){v(e),y(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),Vn("lineNumbers",!1,function(e){p(e.options),s(e)},!0),Vn("firstLineNumber",1,s,!0),Vn("lineNumberFormatter",function(e){return e},s,!0),Vn("showCursorWhenSelecting",!1,Pe,!0),Vn("resetSelectionOnContextMenu",!0),Vn("lineWiseCopyCut",!0),Vn("readOnly",!1,function(e,t){"nocursor"==t?(bn(e),e.display.input.blur(),e.display.disabled=!0):e.display.disabled=!1,e.display.input.readOnlyChanged(t)}),Vn("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),Vn("dragDrop",!0,Bt),Vn("allowDropFileTypes",null),Vn("cursorBlinkRate",530),Vn("cursorScrollMargin",0),Vn("cursorHeight",1,Pe,!0),Vn("singleCursorHeightPerLine",!0,Pe,!0),Vn("workTime",100),Vn("workDelay",100),Vn("flattenSpans",!0,r,!0),Vn("addModeClass",!1,r,!0),Vn("pollInterval",100),Vn("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),Vn("historyEventDelay",1250),Vn("viewportMargin",10,function(e){e.refresh()},!0),Vn("maxHighlightLength",1e4,r,!0),Vn("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Vn("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),Vn("autofocus",null);var ra=e.modes={},ia=e.mimeModes={};e.defineMode=function(t,n){e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2&&(n.dependencies=Array.prototype.slice.call(arguments,2)),ra[t]=n},e.defineMIME=function(e,t){ia[e]=t},e.resolveMode=function(t){if("string"==typeof t&&ia.hasOwnProperty(t))t=ia[t];else if(t&&"string"==typeof t.name&&ia.hasOwnProperty(t.name)){var n=ia[t.name];"string"==typeof n&&(n={name:n}),t=Di(n,t),t.name=n.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,n){var n=e.resolveMode(n),r=ra[n.name];if(!r)return e.getMode(t,"text/plain");var i=r(t,n);if(oa.hasOwnProperty(n.name)){var o=oa[n.name];for(var a in o)o.hasOwnProperty(a)&&(i.hasOwnProperty(a)&&(i["_"+a]=i[a]),i[a]=o[a])}if(i.name=n.name,n.helperType&&(i.helperType=n.helperType),n.modeProps)for(var a in n.modeProps)i[a]=n.modeProps[a];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var oa=e.modeExtensions={};e.extendMode=function(e,t){var n=oa.hasOwnProperty(e)?oa[e]:oa[e]={};ji(t,n)},e.defineExtension=function(t,n){e.prototype[t]=n},e.defineDocExtension=function(e,t){Ca.prototype[e]=t},e.defineOption=Vn;var aa=[];e.defineInitHook=function(e){aa.push(e)};var la=e.helpers={};e.registerHelper=function(t,n,r){la.hasOwnProperty(t)||(la[t]=e[t]={_global:[]}),la[t][n]=r},e.registerGlobalHelper=function(t,n,r,i){e.registerHelper(t,n,i),la[t]._global.push({pred:r,val:i})};var sa=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n},ca=e.startState=function(e,t,n){return e.startState?e.startState(t,n):!0};e.innerMode=function(e,t){for(;e.innerMode;){var n=e.innerMode(t);if(!n||n.mode==e)break;t=n.state,e=n.mode}return n||{mode:e,state:t}};var ua=e.commands={selectAll:function(e){e.setSelection(jo(e.firstLine(),0),jo(e.lastLine()),Da)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Da)},killLine:function(e){$n(e,function(t){if(t.empty()){var n=Qr(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line0)i=new jo(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),jo(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var a=Qr(e.doc,i.line-1).text;a&&e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),jo(i.line-1,a.length-1),jo(i.line,1),"+transpose")}n.push(new fe(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){zt(e,function(){for(var t=e.listSelections().length,n=0;t>n;n++){var r=e.listSelections()[n];e.replaceRange(e.doc.lineSeparator(),r.anchor,r.head,"+input"),e.indentLine(r.from().line+1,null,!0)}Rn(e)})},toggleOverwrite:function(e){e.toggleOverwrite()}},da=e.keyMap={};da.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",
-Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},da.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},da.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},da.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},da["default"]=Eo?da.macDefault:da.pcDefault,e.normalizeKeyMap=function(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if("..."==r){delete e[n];continue}for(var i=Pi(n.split(" "),Gn),o=0;o=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.post},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos0?null:(r&&t!==!1&&(this.pos+=r[0].length),r)}var i=function(e){return n?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var ga=0,va=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ga};zi(va),va.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&kt(e),Ai(this,"clear")){var n=this.find();n&&Si(this,"clear",n.from,n.to)}for(var r=null,i=null,o=0;oe.display.maxLineLength&&(e.display.maxLine=s,e.display.maxLineLength=c,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&&It(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&ze(e.doc)),e&&Si(e,"markerCleared",e,this),t&&wt(e),this.parent&&this.parent.clear()}},va.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var n,r,i=0;in;++n){var i=this.lines[n];this.height-=i.height,Ar(i),Si(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;re;++e)if(n(this.lines[e]))return!0}},Zr.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n=0;ne){var o=Math.min(t,i-e),a=r.height;if(r.removeInner(e,o),this.height-=a-r.height,i==o&&(this.children.splice(n--,1),r.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Kr))){var l=[];this.collapse(l),this.children=[new Kr(l)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t=e){if(i.insertInner(e,t,n),i.lines&&i.lines.length>50){for(;i.lines.length>50;){var a=i.lines.splice(i.lines.length-25,25),l=new Kr(a);i.height-=l.height,this.children.splice(r+1,0,l),l.parent=this}this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),n=new Zr(t);if(e.parent){e.size-=n.size,e.height-=n.height;var r=Ni(e.parent.children,e);e.parent.children.splice(r+1,0,n)}else{var i=new Zr(e.children);i.parent=e,e.children=[i,n],e=i}n.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,n){for(var r=0;re){var a=Math.min(t,o-e);if(i.iterN(e,a,n))return!0;if(0==(t-=a))break;e=0}else e-=o}}};var wa=0,Ca=e.Doc=function(e,t,n,r){if(!(this instanceof Ca))return new Ca(e,t,n,r);null==n&&(n=0),Zr.call(this,[new Kr([new xa("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=n;var i=jo(n,0);this.sel=he(i),this.history=new ai(null),this.id=++wa,this.modeOption=t,this.lineSep=r,this.extend=!1,"string"==typeof e&&(e=this.splitLines(e)),Gr(this,{from:i,to:i,text:e}),Le(this,he(i),Da)};Ca.prototype=Di(Zr.prototype,{constructor:Ca,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var n=0,r=0;r=0;o--)Ln(this,r[o]);l?Me(this,l):this.cm&&Rn(this.cm)}),undo:qt(function(){An(this,"undo")}),redo:qt(function(){An(this,"redo")}),undoSelection:qt(function(){An(this,"undo",!0)}),redoSelection:qt(function(){An(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,n=0,r=0;r=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=ge(this,e),t=ge(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var a=o.markedSpans;if(a)for(var l=0;ls.to||null==s.from&&i!=e.line||i==t.line&&s.from>t.ch||n&&!n(s.marker)||r.push(s.marker.parent||s.marker)}++i}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var r=0;re?(t=e,!0):(e-=i,void++n)}),ge(this,jo(n,t))},indexFromPos:function(e){e=ge(this,e);var t=e.ch;return e.linet&&(t=e.from),null!=e.to&&e.tol||l>=t)return a+(t-o);a+=l-o,a+=n-a%n,o=l+1}},Fa=e.findColumn=function(e,t,n){for(var r=0,i=0;;){var o=e.indexOf(" ",r);-1==o&&(o=e.length);var a=o-r;if(o==e.length||i+a>=t)return r+Math.min(a,t-i);if(i+=o-r,i+=n-i%n,r=o+1,i>=t)return r}},Ha=[""],$a=function(e){e.select()};Ao?$a=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:xo&&($a=function(e){try{e.select()}catch(t){}});var Ba,Ua=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Va=e.isWordChar=function(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||Ua.test(e))},Ga=/[\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]/;Ba=document.createRange?function(e,t,n,r){var i=document.createRange();return i.setEnd(r||e,n),i.setStart(e,t),i}:function(e,t,n){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(i){return r}return r.collapse(!0),r.moveEnd("character",n),r.moveStart("character",t),r};var Ka=e.contains=function(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)};xo&&11>ko&&(Vi=function(){try{return document.activeElement}catch(e){return document.body}});var Za,Xa,Ya=e.rmClass=function(e,t){var n=e.className,r=Gi(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}},Qa=e.addClass=function(e,t){var n=e.className;Gi(t).test(n)||(e.className+=(n?" ":"")+t)},Ja=!1,el=function(){if(xo&&9>ko)return!1;var e=$i("div");return"draggable"in e||"dragDrop"in e}(),tl=e.splitLines=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,n=[],r=e.length;r>=t;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),a=o.indexOf("\r");-1!=a?(n.push(o.slice(0,a)),t+=a+1):(n.push(o),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},nl=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(n){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},rl=function(){var e=$i("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),il=null,ol=e.keyNames={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};!function(){for(var e=0;10>e;e++)ol[e+48]=ol[e+96]=String(e);for(var e=65;90>=e;e++)ol[e]=String.fromCharCode(e);for(var e=1;12>=e;e++)ol[e+111]=ol[e+63235]="F"+e}();var al,ll=function(){function e(e){return 247>=e?n.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1773>=e?r.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,n){this.level=e,this.from=t,this.to=n}var n="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",r="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,a=/[LRr]/,l=/[Lb1n]/,s=/[1n]/,c="L";return function(n){if(!i.test(n))return!1;for(var r,u=n.length,d=[],f=0;u>f;++f)d.push(r=e(n.charCodeAt(f)));for(var f=0,p=c;u>f;++f){var r=d[f];"m"==r?d[f]=p:p=r}for(var f=0,h=c;u>f;++f){var r=d[f];"1"==r&&"r"==h?d[f]="n":a.test(r)&&(h=r,"r"==r&&(d[f]="R"))}for(var f=1,p=d[0];u-1>f;++f){var r=d[f];"+"==r&&"1"==p&&"1"==d[f+1]?d[f]="1":","!=r||p!=d[f+1]||"1"!=p&&"n"!=p||(d[f]=p),p=r}for(var f=0;u>f;++f){var r=d[f];if(","==r)d[f]="N";else if("%"==r){for(var m=f+1;u>m&&"%"==d[m];++m);for(var g=f&&"!"==d[f-1]||u>m&&"1"==d[m]?"1":"N",v=f;m>v;++v)d[v]=g;f=m-1}}for(var f=0,h=c;u>f;++f){var r=d[f];"L"==h&&"1"==r?d[f]="L":a.test(r)&&(h=r)}for(var f=0;u>f;++f)if(o.test(d[f])){for(var m=f+1;u>m&&o.test(d[m]);++m);for(var y="L"==(f?d[f-1]:c),b="L"==(u>m?d[m]:c),g=y||b?"L":"R",v=f;m>v;++v)d[v]=g;f=m-1}for(var x,k=[],f=0;u>f;)if(l.test(d[f])){var _=f;for(++f;u>f&&l.test(d[f]);++f);k.push(new t(0,_,f))}else{var w=f,C=k.length;for(++f;u>f&&"L"!=d[f];++f);for(var v=w;f>v;)if(s.test(d[v])){v>w&&k.splice(C,0,new t(1,w,v));var S=v;for(++v;f>v&&s.test(d[v]);++v);k.splice(C,0,new t(2,S,v)),w=v}else++v;f>w&&k.splice(C,0,new t(1,w,f))}return 1==k[0].level&&(x=n.match(/^\s+/))&&(k[0].from=x[0].length,k.unshift(new t(0,0,x[0].length))),1==qi(k).level&&(x=n.match(/\s+$/))&&(qi(k).to-=x[0].length,k.push(new t(0,u-x[0].length,u))),2==k[0].level&&k.unshift(new t(1,k[0].to,k[0].to)),k[0].level!=qi(k).level&&k.push(new t(k[0].level,u,u)),k}}();return e.version="5.10.1",e}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.overlayMode=function(t,n,r){return{startState:function(){return{base:e.startState(t),overlay:e.startState(n),basePos:0,baseCur:null,overlayPos:0,overlayCur:null,streamSeen:null}},copyState:function(r){return{base:e.copyState(t,r.base),overlay:e.copyState(n,r.overlay),basePos:r.basePos,baseCur:null,overlayPos:r.overlayPos,overlayCur:null}},token:function(e,i){return(e!=i.streamSeen||Math.min(i.basePos,i.overlayPos)2){r.pending=[];for(var f=2;f-1)return e.Pass;var a=r.indent.length-1,l=t[r.state];e:for(;;){for(var c=0;ca?0:r.indent[a]}}e.defineSimpleMode=function(t,n){e.defineMode(t,function(t){return e.simpleMode(t,n)})},e.simpleMode=function(n,r){t(r,"start");var a={},l=r.meta||{},s=!1;for(var u in r)if(u!=l&&r.hasOwnProperty(u))for(var d=a[u]=[],f=r[u],p=0;p-1?i+t.length:i}var o=t.exec(n?e.slice(n):e);return o?o.index+n+(r?o[0].length:0):-1}var r=Array.prototype.slice.call(arguments,1);return{startState:function(){return{outer:e.startState(t),innerActive:null,inner:null}},copyState:function(n){return{outer:e.copyState(t,n.outer),innerActive:n.innerActive,inner:n.innerActive&&e.copyState(n.innerActive.mode,n.inner)}},token:function(i,o){if(o.innerActive){var a=o.innerActive,l=i.string;if(!a.close&&i.sol())return o.innerActive=o.inner=null,this.token(i,o);var s=a.close?n(l,a.close,i.pos,a.parseDelimiters):-1;if(s==i.pos&&!a.parseDelimiters)return i.match(a.close),o.innerActive=o.inner=null,a.delimStyle&&a.delimStyle+" "+a.delimStyle+"-close";s>-1&&(i.string=l.slice(0,s));var c=a.mode.token(i,o.inner);return s>-1&&(i.string=l),s==i.pos&&a.parseDelimiters&&(o.innerActive=o.inner=null),a.innerStyle&&(c=c?c+" "+a.innerStyle:a.innerStyle),c}for(var u=1/0,l=i.string,d=0;ds&&(u=s)}u!=1/0&&(i.string=l.slice(0,u));var p=t.token(i,o.outer);return u!=1/0&&(i.string=l),p},indent:function(n,r){var i=n.innerActive?n.innerActive.mode:t;return i.indent?i.indent(n.innerActive?n.inner:n.outer,r):e.Pass},blankLine:function(n){var i=n.innerActive?n.innerActive.mode:t;if(i.blankLine&&i.blankLine(n.innerActive?n.inner:n.outer),n.innerActive)"\n"===n.innerActive.close&&(n.innerActive=n.inner=null);else for(var o=0;o-1)return u=n(s,c,u),{from:r(o.line,u),to:r(o.line,u+a.length)}}else{var s=e.getLine(o.line).slice(o.ch),c=l(s),u=c.indexOf(t);if(u>-1)return u=n(s,c,u)+o.ch,{from:r(o.line,u),to:r(o.line,u+a.length)}}}:function(){};else{var c=a.split("\n");this.matches=function(t,n){var i=s.length-1;if(t){if(n.line-(s.length-1)=1;--u,--a)if(s[u]!=l(e.getLine(a)))return;var d=e.getLine(a),f=d.length-c[0].length;if(l(d.slice(f))!=s[0])return;return{from:r(a,f),to:o}}if(!(n.line+(s.length-1)>e.lastLine())){var d=e.getLine(n.line),f=d.length-c[0].length;if(l(d.slice(f))==s[0]){for(var p=r(n.line,f),a=n.line+1,u=1;i>u;++u,++a)if(s[u]!=l(e.getLine(a)))return;if(l(e.getLine(a).slice(0,c[i].length))==s[i])return{from:p,to:r(a,c[i].length)}}}}}}}function n(e,t,n){if(e.length==t.length)return n;for(var r=Math.min(n,e.length);;){var i=e.slice(0,r).toLowerCase().length;if(n>i)++r;else{if(!(i>n))return r;--r}}}var r=e.Pos;t.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(e){function t(e){var t=r(e,0);return n.pos={from:t,to:t},n.atOccurrence=!1,!1}for(var n=this,i=this.doc.clipPos(e?this.pos.from:this.pos.to);;){if(this.pos=this.matches(e,i))return this.atOccurrence=!0,this.pos.match||!0;if(e){if(!i.line)return t(0);i=r(i.line-1,this.doc.getLine(i.line-1).length)}else{var o=this.doc.lineCount();if(i.line==o-1)return t(o);i=r(i.line+1,0)}}},from:function(){return this.atOccurrence?this.pos.from:void 0},to:function(){return this.atOccurrence?this.pos.to:void 0},replace:function(t,n){if(this.atOccurrence){var i=e.splitLines(t);this.doc.replaceRange(i,this.pos.from,this.pos.to,n),this.pos.to=r(this.pos.from.line+i.length-1,i[i.length-1].length+(1==i.length?this.pos.from.ch:0))}}},e.defineExtension("getSearchCursor",function(e,n,r){return new t(this.doc,e,n,r)}),e.defineDocExtension("getSearchCursor",function(e,n,r){return new t(this,e,n,r)}),e.defineExtension("selectMatches",function(t,n){for(var r=[],i=this.getSearchCursor(t,this.getCursor("from"),n);i.findNext()&&!(e.cmpPos(i.to(),this.getCursor("to"))>0);)r.push({anchor:i.from(),head:i.to()});r.length&&this.setSelections(r,0)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){return"string"==typeof e?e=new RegExp(e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),t?"gi":"g"):e.global||(e=new RegExp(e.source,e.ignoreCase?"gi":"g")),{token:function(t){e.lastIndex=t.pos;var n=e.exec(t.string);return n&&n.index==t.pos?(t.pos+=n[0].length||1,"searching"):void(n?t.pos=n.index:t.skipToEnd())}}}function n(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}function r(e){return e.state.search||(e.state.search=new n)}function i(e){return"string"==typeof e&&e==e.toLowerCase()}function o(e,t,n){return e.getSearchCursor(t,n,i(t))}function a(e,t,n,r){e.openDialog(t,r,{value:n,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){h(e)}})}function l(e,t,n,r,i){e.openDialog?e.openDialog(t,i,{value:r,selectValueOnOpen:!0}):i(prompt(n,r))}function s(e,t,n,r){e.openConfirm?e.openConfirm(t,r):confirm(n)&&r[0]()}function c(e){return e.replace(/\\(.)/g,function(e,t){return"n"==t?"\n":"r"==t?"\r":t})}function u(e){var t=e.match(/^\/(.*)\/([a-z]*)$/);if(t)try{e=new RegExp(t[1],-1==t[2].indexOf("i")?"":"i")}catch(n){}else e=c(e);return("string"==typeof e?""==e:e.test(""))&&(e=/x^/),e}function d(e,n,r){n.queryText=r,n.query=u(r),e.removeOverlay(n.overlay,i(n.query)),n.overlay=t(n.query,i(n.query)),e.addOverlay(n.overlay),e.showMatchesOnScrollbar&&(n.annotate&&(n.annotate.clear(),n.annotate=null),n.annotate=e.showMatchesOnScrollbar(n.query,i(n.query)))}function f(t,n,i){var o=r(t);if(o.query)return p(t,n);var s=t.getSelection()||o.lastQuery;if(i&&t.openDialog){var c=null;a(t,v,s,function(n,r){e.e_stop(r),n&&(n!=o.queryText&&d(t,o,n),c&&(c.style.opacity=1),p(t,r.shiftKey,function(e,n){var r;n.line<3&&document.querySelector&&(r=t.display.wrapper.querySelector(".CodeMirror-dialog"))&&r.getBoundingClientRect().bottom-4>t.cursorCoords(n,"window").top&&((c=r).style.opacity=.4)}))})}else l(t,v,"Search for:",s,function(e){e&&!o.query&&t.operation(function(){d(t,o,e),o.posFrom=o.posTo=t.getCursor(),p(t,n)})})}function p(t,n,i){t.operation(function(){var a=r(t),l=o(t,a.query,n?a.posFrom:a.posTo);(l.find(n)||(l=o(t,a.query,n?e.Pos(t.lastLine()):e.Pos(t.firstLine(),0)),l.find(n)))&&(t.setSelection(l.from(),l.to()),t.scrollIntoView({from:l.from(),to:l.to()},20),a.posFrom=l.from(),a.posTo=l.to(),i&&i(l.from(),l.to()))})}function h(e){e.operation(function(){var t=r(e);t.lastQuery=t.query,t.query&&(t.query=t.queryText=null,e.removeOverlay(t.overlay),t.annotate&&(t.annotate.clear(),t.annotate=null))})}function m(e,t,n){e.operation(function(){for(var r=o(e,t);r.findNext();)if("string"!=typeof t){var i=e.getRange(r.from(),r.to()).match(t);r.replace(n.replace(/\$(\d)/g,function(e,t){return i[t]}))}else r.replace(n)})}function g(e,t){if(!e.getOption("readOnly")){var n=e.getSelection()||r(e).lastQuery,i=t?"Replace all:":"Replace:";l(e,i+y,i,n,function(n){n&&(n=u(n),l(e,b,"Replace with:","",function(r){if(r=c(r),t)m(e,n,r);else{h(e);var i=o(e,n,e.getCursor()),a=function(){var t,c=i.from();!(t=i.findNext())&&(i=o(e,n),!(t=i.findNext())||c&&i.from().line==c.line&&i.from().ch==c.ch)||(e.setSelection(i.from(),i.to()),e.scrollIntoView({from:i.from(),to:i.to()}),s(e,x,"Replace?",[function(){l(t)},a,function(){m(e,n,r)}]))},l=function(e){i.replace("string"==typeof n?r:r.replace(/\$(\d)/g,function(t,n){return e[n]})),a()};a()}}))})}}var v='Search: (Use /re/ syntax for regexp search)',y=' (Use /re/ syntax for regexp search)',b='With: ',x="Replace? ";e.commands.find=function(e){h(e),f(e)},e.commands.findPersistent=function(e){h(e),f(e,!1,!0)},e.commands.findNext=f,e.commands.findPrev=function(e){f(e,!0)},e.commands.clearSearch=h,e.commands.replace=g,e.commands.replaceAll=function(e){g(e,!0)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../dialog/dialog"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t,n,r,i){e.openDialog?e.openDialog(t,i,{value:r,selectValueOnOpen:!0}):i(prompt(n,r))}function n(e,t){var n=Number(t);return/^[-+]/.test(t)?e.getCursor().line+n:n-1}var r='Jump to line: (Use line:column or scroll% syntax)';e.commands.jumpToLine=function(e){var i=e.getCursor();t(e,r,"Jump to line:",i.line+1+":"+i.ch,function(t){if(t){var r;if(r=/^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(t))e.setCursor(n(e,r[1]),Number(r[2]));else if(r=/^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(t)){var o=Math.round(e.lineCount()*Number(r[1])/100);/^[-+]/.test(r[1])&&(o=i.line+o+1),e.setCursor(o-1,i.ch)}else(r=/^\s*\:?\s*([\+\-]?\d+)\s*/.exec(t))&&e.setCursor(n(e,r[1]),i.ch)}})},e.keyMap["default"]["Alt-G"]="jumpToLine"}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t,n,r){this.cm=e,this.options=r;var i={listenForChanges:!1};for(var o in r)i[o]=r[o];i.className||(i.className="CodeMirror-search-match"),this.annotation=e.annotateScrollbar(i),this.query=t,this.caseFold=n,this.gap={from:e.firstLine(),to:e.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var a=this;e.on("change",this.changeHandler=function(e,t){a.onChange(t)})}function n(e,t,n){return t>=e?e:Math.max(t,e+n)}e.defineExtension("showMatchesOnScrollbar",function(e,n,r){return"string"==typeof r&&(r={className:r}),r||(r={}),new t(this,e,n,r)});var r=1e3;t.prototype.findMatches=function(){if(this.gap){for(var t=0;t=this.gap.to)break;n.to.line>=this.gap.from&&this.matches.splice(t--,1)}for(var i=this.cm.getSearchCursor(this.query,e.Pos(this.gap.from,0),this.caseFold),o=this.options&&this.options.maxMatches||r;i.findNext();){var n={from:i.from(),to:i.to()};if(n.from.line>=this.gap.to)break;if(this.matches.splice(t++,0,n),this.matches.length>o)break}this.gap=null}},t.prototype.onChange=function(t){var r=t.from.line,i=e.changeEnd(t).line,o=i-t.to.line;if(this.gap?(this.gap.from=Math.min(n(this.gap.from,r,o),t.from.line),this.gap.to=Math.max(n(this.gap.to,r,o),t.from.line)):this.gap={from:t.from.line,to:i+1},o)for(var a=0;as&&r(e,l.slice(s,c),n,t.style))}var u=e.getCursor("from"),d=e.getCursor("to");if(u.line==d.line&&(!t.wordsOnly||a(e,u,d))){var f=e.getRange(u,d).replace(/^\s+|\s+$/g,"");f.length>=t.minChars&&r(e,f,!1,t.style)}})}function a(e,t,n){var r=e.getRange(t,n);if(null!==r.match(/^\w+$/)){if(t.ch>0){var i={line:t.line,ch:t.ch-1},o=e.getRange(i,t);if(null===o.match(/\W/))return!1}if(n.chr.right?1:0:t.clientYr.bottom?1:0,o.moveTo(o.pos+n*o.screen)}),e.on(this.node,"mousewheel",i),e.on(this.node,"DOMMouseScroll",i)}function n(e,n,r){this.addClass=e,this.horiz=new t(e,"horizontal",r),n(this.horiz.node),this.vert=new t(e,"vertical",r),n(this.vert.node),this.width=null}t.prototype.moveTo=function(e,t){0>e&&(e=0),e>this.total-this.screen&&(e=this.total-this.screen),e!=this.pos&&(this.pos=e,this.inner.style["horizontal"==this.orientation?"left":"top"]=e*(this.size/this.total)+"px",t!==!1&&this.scroll(e,this.orientation))};var r=10;t.prototype.update=function(e,t,n){this.screen=t,this.total=e,this.size=n;var i=this.screen*(this.size/this.total);r>i&&(this.size-=r-i,i=r),this.inner.style["horizontal"==this.orientation?"width":"height"]=i+"px",this.inner.style["horizontal"==this.orientation?"left":"top"]=this.pos*(this.size/this.total)+"px"},n.prototype.update=function(e){if(null==this.width){var t=window.getComputedStyle?window.getComputedStyle(this.horiz.node):this.horiz.node.currentStyle;t&&(this.width=parseInt(t.height))}var n=this.width||0,r=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1;return this.vert.node.style.display=i?"block":"none",this.horiz.node.style.display=r?"block":"none",i&&(this.vert.update(e.scrollHeight,e.clientHeight,e.viewHeight-(r?n:0)),this.vert.node.style.display="block",this.vert.node.style.bottom=r?n+"px":"0"),r&&(this.horiz.update(e.scrollWidth,e.clientWidth,e.viewWidth-(i?n:0)-e.barLeft),this.horiz.node.style.right=i?n+"px":"0",this.horiz.node.style.left=e.barLeft+"px"),{right:i?n:0,bottom:r?n:0}},n.prototype.setScrollTop=function(e){this.vert.moveTo(e,!1)},n.prototype.setScrollLeft=function(e){this.horiz.moveTo(e,!1)},n.prototype.clear=function(){var e=this.horiz.node.parentNode;e.removeChild(this.horiz.node),e.removeChild(this.vert.node)},e.scrollbarModel.simple=function(e,t){return new n("CodeMirror-simplescroll",e,t)},e.scrollbarModel.overlay=function(e,t){return new n("CodeMirror-overlayscroll",e,t)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){function n(e){clearTimeout(r.doRedraw),r.doRedraw=setTimeout(function(){r.redraw()},e)}this.cm=e,this.options=t,this.buttonHeight=t.scrollButtonHeight||e.getOption("scrollButtonHeight"),this.annotations=[],this.doRedraw=this.doUpdate=null,this.div=e.getWrapperElement().appendChild(document.createElement("div")),this.div.style.cssText="position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none",this.computeScale();var r=this;e.on("refresh",this.resizeHandler=function(){clearTimeout(r.doUpdate),r.doUpdate=setTimeout(function(){r.computeScale()&&n(20)},100)}),e.on("markerAdded",this.resizeHandler),e.on("markerCleared",this.resizeHandler),t.listenForChanges!==!1&&e.on("change",this.changeHandler=function(){n(250)})}e.defineExtension("annotateScrollbar",function(e){return"string"==typeof e&&(e={className:e}),new t(this,e)}),e.defineOption("scrollButtonHeight",0),t.prototype.computeScale=function(){var e=this.cm,t=(e.getWrapperElement().clientHeight-e.display.barHeight-2*this.buttonHeight)/e.getScrollerElement().scrollHeight;return t!=this.hScale?(this.hScale=t,!0):void 0},t.prototype.update=function(e){this.annotations=e,this.redraw()},t.prototype.redraw=function(e){function t(e,t){if(s!=e.line&&(s=e.line,c=n.getLineHandle(s)),a&&c.height>l)return n.charCoords(e,"local")[t?"top":"bottom"];var r=n.heightAtLine(c,"local");return r+(t?0:c.height)}e!==!1&&this.computeScale();var n=this.cm,r=this.hScale,i=document.createDocumentFragment(),o=this.annotations,a=n.getOption("lineWrapping"),l=a&&1.5*n.defaultTextHeight(),s=null,c=null;if(n.display.barWidth)for(var u,d=0;dh+.9));)f=o[++d],h=t(f.to,!1)*r;if(h!=p){var m=Math.max(h-p,3),g=i.appendChild(document.createElement("div"));g.style.cssText="position: absolute; right: 0px; width: "+Math.max(1.5*n.display.barWidth,2)+"px; top: "+(p+this.buttonHeight)+"px; height: "+m+"px",g.className=this.options.className,f.id&&g.setAttribute("annotation-id",f.id)}}this.div.textContent="",this.div.appendChild(i)},t.prototype.clear=function(){this.cm.off("refresh",this.resizeHandler),this.cm.off("markerAdded",this.resizeHandler),this.cm.off("markerCleared",this.resizeHandler),this.changeHandler&&this.cm.off("change",this.changeHandler),this.div.parentNode.removeChild(this.div)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t,n,r){this.cm=e,this.node=t,this.options=n,this.height=r,this.cleared=!1}function n(e){var t=e.getWrapperElement(),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r=parseInt(n.height),i=e.state.panels={setHeight:t.style.height,heightLeft:r,panels:0,wrapper:document.createElement("div")};t.parentNode.insertBefore(i.wrapper,t);var o=e.hasFocus();i.wrapper.appendChild(t),o&&e.focus(),e._setSize=e.setSize,null!=r&&(e.setSize=function(t,n){if(null==n)return this._setSize(t,n);if(i.setHeight=n,"number"!=typeof n){var o=/^(\d+\.?\d*)px$/.exec(n);o?n=Number(o[1]):(i.wrapper.style.height=n,n=i.wrapper.offsetHeight,i.wrapper.style.height="")}e._setSize(t,i.heightLeft+=n-r),r=n})}function r(e){var t=e.state.panels;e.state.panels=null;var n=e.getWrapperElement();t.wrapper.parentNode.replaceChild(n,t.wrapper),n.style.height=t.setHeight,e.setSize=e._setSize,e.setSize()}e.defineExtension("addPanel",function(e,r){r=r||{},this.state.panels||n(this);var i=this.state.panels,o=i.wrapper,a=this.getWrapperElement();r.after instanceof t&&!r.after.cleared?o.insertBefore(e,r.before.node.nextSibling):r.before instanceof t&&!r.before.cleared?o.insertBefore(e,r.before.node):r.replace instanceof t&&!r.replace.cleared?(o.insertBefore(e,r.replace.node),r.replace.clear()):"bottom"==r.position?o.appendChild(e):"before-bottom"==r.position?o.insertBefore(e,a.nextSibling):"after-top"==r.position?o.insertBefore(e,a):o.insertBefore(e,o.firstChild);var l=r&&r.height||e.offsetHeight;return this._setSize(null,i.heightLeft-=l),i.panels++,new t(this,e,r,l)}),t.prototype.clear=function(){if(!this.cleared){this.cleared=!0;var e=this.cm.state.panels;this.cm._setSize(null,e.heightLeft+=this.height),e.wrapper.removeChild(this.node),0==--e.panels&&r(this.cm)}},t.prototype.changed=function(e){var t=null==e?this.node.offsetHeight:e,n=this.cm.state.panels;this.cm._setSize(null,n.height+=t-this.height),this.height=t}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e){e.state.placeholder&&(e.state.placeholder.parentNode.removeChild(e.state.placeholder),e.state.placeholder=null)}function n(e){t(e);var n=e.state.placeholder=document.createElement("pre");n.style.cssText="height: 0; overflow: visible",n.className="CodeMirror-placeholder";var r=e.getOption("placeholder");"string"==typeof r&&(r=document.createTextNode(r)),n.appendChild(r),e.display.lineSpace.insertBefore(n,e.display.lineSpace.firstChild)}function r(e){o(e)&&n(e)}function i(e){var r=e.getWrapperElement(),i=o(e);r.className=r.className.replace(" CodeMirror-empty","")+(i?" CodeMirror-empty":""),i?n(e):t(e)}function o(e){return 1===e.lineCount()&&""===e.getLine(0)}e.defineOption("placeholder","",function(n,o,a){var l=a&&a!=e.Init;if(o&&!l)n.on("blur",r),n.on("change",i),i(n);else if(!o&&l){n.off("blur",r),n.off("change",i),t(n);var s=n.getWrapperElement();s.className=s.className.replace(" CodeMirror-empty","")}o&&!n.hasFocus()&&r(n)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e){var t=e.getWrapperElement();e.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:t.style.width,height:t.style.height},t.style.width="",t.style.height="auto",t.className+=" CodeMirror-fullscreen",document.documentElement.style.overflow="hidden",e.refresh()}function n(e){var t=e.getWrapperElement();t.className=t.className.replace(/\s*CodeMirror-fullscreen\b/,""),document.documentElement.style.overflow="";var n=e.state.fullScreenRestore;t.style.width=n.width,t.style.height=n.height,window.scrollTo(n.scrollLeft,n.scrollTop),e.refresh()}e.defineOption("fullScreen",!1,function(r,i,o){o==e.Init&&(o=!1),!o!=!i&&(i?t(r):n(r))})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(t,r){function i(){t.display.wrapper.offsetHeight?(n(t,r),t.display.lastWrapHeight!=t.display.wrapper.clientHeight&&t.refresh()):r.timeout=setTimeout(i,r.delay)}r.timeout=setTimeout(i,r.delay),r.hurry=function(){clearTimeout(r.timeout),r.timeout=setTimeout(i,50)},e.on(window,"mouseup",r.hurry),e.on(window,"keyup",r.hurry)}function n(t,n){clearTimeout(n.timeout),e.off(window,"mouseup",n.hurry),e.off(window,"keyup",n.hurry)}e.defineOption("autoRefresh",!1,function(e,r){e.state.autoRefresh&&(n(e,e.state.autoRefresh),e.state.autoRefresh=null),r&&0==e.display.wrapper.offsetHeight&&t(e,e.state.autoRefresh={delay:r.delay||250})})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t,n){var r,i=e.getWrapperElement();return r=i.appendChild(document.createElement("div")),r.className=n?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof t?r.innerHTML=t:r.appendChild(t),r}function n(e,t){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=t}e.defineExtension("openDialog",function(r,i,o){function a(e){if("string"==typeof e)d.value=e;else{if(c)return;c=!0,s.parentNode.removeChild(s),u.focus(),o.onClose&&o.onClose(s)}}o||(o={}),n(this,null);var l,s=t(this,r,o.bottom),c=!1,u=this,d=s.getElementsByTagName("input")[0];return d?(o.value&&(d.value=o.value,o.selectValueOnOpen!==!1&&d.select()),o.onInput&&e.on(d,"input",function(e){o.onInput(e,d.value,a)}),o.onKeyUp&&e.on(d,"keyup",function(e){o.onKeyUp(e,d.value,a)}),e.on(d,"keydown",function(t){o&&o.onKeyDown&&o.onKeyDown(t,d.value,a)||((27==t.keyCode||o.closeOnEnter!==!1&&13==t.keyCode)&&(d.blur(),e.e_stop(t),a()),13==t.keyCode&&i(d.value,t))}),o.closeOnBlur!==!1&&e.on(d,"blur",a),d.focus()):(l=s.getElementsByTagName("button")[0])&&(e.on(l,"click",function(){a(),u.focus()}),o.closeOnBlur!==!1&&e.on(l,"blur",a),l.focus()),a}),e.defineExtension("openConfirm",function(r,i,o){function a(){c||(c=!0,l.parentNode.removeChild(l),u.focus())}n(this,null);var l=t(this,r,o&&o.bottom),s=l.getElementsByTagName("button"),c=!1,u=this,d=1;s[0].focus();for(var f=0;f=d&&a()},200)}),e.on(p,"focus",function(){++d})}}),e.defineExtension("openNotification",function(r,i){function o(){s||(s=!0,clearTimeout(a),l.parentNode.removeChild(l))}n(this,o);var a,l=t(this,r,i&&i.bottom),s=!1,c=i&&"undefined"!=typeof i.duration?i.duration:5e3;return e.on(l,"click",function(t){e.e_preventDefault(t),o()}),c&&(a=setTimeout(o,c)),o})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t,r,i){var o=e.getLineHandle(t.line),s=t.ch-1,c=s>=0&&l[o.text.charAt(s)]||l[o.text.charAt(++s)];if(!c)return null;var u=">"==c.charAt(1)?1:-1;if(r&&u>0!=(s==t.ch))return null;var d=e.getTokenTypeAt(a(t.line,s+1)),f=n(e,a(t.line,s+(u>0?1:0)),u,d||null,i);return null==f?null:{from:a(t.line,s),to:f&&f.pos,match:f&&f.ch==c.charAt(0),forward:u>0}}function n(e,t,n,r,i){for(var o=i&&i.maxScanLineLength||1e4,s=i&&i.maxScanLines||1e3,c=[],u=i&&i.bracketRegex?i.bracketRegex:/[(){}[\]]/,d=n>0?Math.min(t.line+s,e.lastLine()+1):Math.max(e.firstLine()-1,t.line-s),f=t.line;f!=d;f+=n){var p=e.getLine(f);if(p){var h=n>0?0:p.length-1,m=n>0?p.length:-1;if(!(p.length>o))for(f==t.line&&(h=t.ch-(0>n?1:0));h!=m;h+=n){var g=p.charAt(h);if(u.test(g)&&(void 0===r||e.getTokenTypeAt(a(f,h+1))==r)){var v=l[g];if(">"==v.charAt(1)==n>0)c.push(g);else{if(!c.length)return{pos:a(f,h),ch:g};c.pop()}}}}}return f-n==(n>0?e.lastLine():e.firstLine())?!1:null}function r(e,n,r){for(var i=e.state.matchBrackets.maxHighlightLineLength||1e3,l=[],s=e.listSelections(),c=0;c150)){if(!n)return;r="prev"}}else c=0,r="not";"prev"==r?c=t>o.first?Ba(Qn(o,t-1).text,null,a):0:"add"==r?c=l+e.options.indentUnit:"subtract"==r?c=l-e.options.indentUnit:"number"==typeof r&&(c=l+r),c=Math.max(0,c);var f="",d=0;if(e.options.indentWithTabs)for(var p=Math.floor(c/a);p;--p)d+=a,f+=" ";if(c>d&&(f+=zi(c-d)),f!=u)return zr(o,f,Do(t,0),Do(t,u.length),"+input"),s.stateAfter=null,!0;for(var p=0;p=0;t--)zr(e.doc,"",n[t].from,n[t].to,"+delete");Dr(e)})}function Hr(e,t,r,n,i){function o(){var t=s+r;return t=e.first+e.size?!1:(s=t,u=Qn(e,t))}function a(e){var t=(i?po:ho)(u,l,r,!0);if(null==t){if(e||!o())return!1;l=i?(0>r?oo:io)(u):0>r?u.text.length:0}else l=t;return!0}var s=t.line,l=t.ch,c=r,u=Qn(e,s);if("char"==n)a();else if("column"==n)a(!0);else if("word"==n||"group"==n)for(var f=null,d="group"==n,p=e.cm&&e.cm.getHelper(t,"wordChars"),h=!0;!(0>r)||a(!h);h=!1){var m=u.text.charAt(l)||"\n",g=Bi(m,p)?"w":d&&"\n"==m?"n":!d||/\s/.test(m)?null:"p";if(!d||h||g||(g="s"),f&&f!=g){0>r&&(r=1,a());break}if(g&&(f=g),r>0&&!a(!h))break}var v=Ie(e,Do(s,l),t,c,!0);return jo(t,v)||(v.hitSide=!0),v}function $r(e,t,r,n){var i,o=e.doc,a=t.left;if("page"==n){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=t.top+r*(s-(0>r?1.5:.5)*bt(e.display))}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;;){var l=vt(e,a,i);if(!l.outside)break;if(0>r?0>=i:i>=o.height){l.hitSide=!0;break}i+=5*r}return l}function Ur(t,r,n,i){e.defaults[t]=r,n&&(ta[t]=i?function(e,t,r){r!=ra&&n(e,t,r)}:n)}function Kr(e){for(var t,r,n,i,o=e.split(/-(?!$)/),e=o[o.length-1],a=0;a0||0==a&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=Hi("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(yn(e,t.line,t,r,o)||t.line!=r.line&&yn(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ro=!0}o.addToHistory&&ui(e,{from:t,to:r,origin:"markText"},e.sel,0/0);var s,l=t.line,c=e.cm;if(e.iter(l,r.line+1,function(e){c&&o.collapsed&&!c.options.lineWrapping&&bn(e)==c.display.maxLine&&(s=!0),o.collapsed&&l!=t.line&&ti(e,0),rn(e,new Jr(o,l==t.line?t.ch:null,l==r.line?r.ch:null)),++l}),o.collapsed&&e.iter(t.line,r.line+1,function(t){_n(e,t)&&ti(t,0)}),o.clearOnEnter&&Ea(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(qo=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++ga,o.atomic=!0),c){if(s&&(c.curOp.updateMaxLine=!0),o.collapsed)qt(c,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var u=t.line;u<=r.line;u++)Rt(c,u,"text");o.atomic&&Ee(c.doc),Si(c,"markerAdded",c,o)}return o}function Xr(e,t,r,n,i){n=Di(n),n.shared=!1;var o=[Gr(e,t,r,n,i)],a=o[0],s=n.widgetNode;return Zn(e,function(e){s&&(n.widgetNode=s.cloneNode(!0)),o.push(Gr(e,ge(e,t),ge(e,r),n,i));for(var l=0;l=t:o.to>t);(n||(n=[])).push(new Jr(a,o.from,l?null:o.to))}}return n}function on(e,t,r){if(e)for(var n,i=0;i=t:o.to>t);if(s||o.from==t&&"bookmark"==a.type&&(!r||o.marker.insertLeft)){var l=null==o.from||(a.inclusiveLeft?o.from<=t:o.from0&&s)for(var f=0;ff;++f)h.push(m);h.push(l)}return h}function sn(e){for(var t=0;t0)){var u=[l,1],f=jo(c.from,s.from),d=jo(c.to,s.to);(0>f||!a.inclusiveLeft&&!f)&&u.push({from:c.from,to:s.from}),(d>0||!a.inclusiveRight&&!d)&&u.push({from:s.to,to:c.to}),i.splice.apply(i,u),l+=u.length-1}}return i}function un(e){var t=e.markedSpans;if(t){for(var r=0;r=0&&0>=f||0>=u&&f>=0)&&(0>=u&&(jo(c.to,r)>0||l.marker.inclusiveRight&&i.inclusiveLeft)||u>=0&&(jo(c.from,n)<0||l.marker.inclusiveLeft&&i.inclusiveRight)))return!0}}}function bn(e){for(var t;t=gn(e);)e=t.find(-1,!0).line;return e}function kn(e){for(var t,r;t=vn(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function xn(e,t){var r=Qn(e,t),n=bn(r);return r==n?t:ri(n)}function wn(e,t){if(t>e.lastLine())return t;var r,n=Qn(e,t);if(!_n(e,n))return t;for(;r=vn(n);)n=r.find(1,!0).line;return ri(n)+1}function _n(e,t){var r=Ro&&t.markedSpans;if(r)for(var n,i=0;io;o++){i&&(i[0]=e.innerMode(t,n).mode);var a=t.token(r,n);if(r.pos>r.start)return a}throw new Error("Mode "+t.name+" failed to advance stream.")}function In(e,t,r,n){function i(e){return{start:f.start,end:f.pos,string:f.current(),type:o||null,state:e?la(a.mode,u):u}}var o,a=e.doc,s=a.mode;t=ge(a,t);var l,c=Qn(a,t.line),u=He(e,t.line,r),f=new ma(c.text,e.options.tabSize);for(n&&(l=[]);(n||f.pose.options.maxHighlightLength?(s=!1,a&&Rn(e,t,n,f.pos),f.pos=t.length,l=null):l=En(zn(r,f,n,d),o),d){var p=d[0].name;p&&(l="m-"+(l?p+" "+l:p))}if(!s||u!=l){for(;cc;){var n=i[l];n>e&&i.splice(l,1,e,i[l+1],n),l+=2,c=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,l-r,e,"cm-overlay "+t),l=r+2;else for(;l>r;r+=2){var o=i[r+1];i[r+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function qn(e,t,r){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=He(e,ri(t)),i=Pn(e,t,t.text.length>e.options.maxHighlightLength?la(e.doc.mode,n):n);t.stateAfter=n,t.styles=i.styles,i.classes?t.styleClasses=i.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.frontier&&e.doc.frontier++}return t.styles}function Rn(e,t,r,n){var i=e.doc.mode,o=new ma(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&On(i,r);!o.eol();)zn(i,o,r),o.start=o.pos}function Dn(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?wa:xa;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function jn(e,t){var r=Hi("span",null,null,wo?"padding-right: .1px":null),n={pre:Hi("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:e,splitSpaces:(ko||wo)&&e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,a=i?t.rest[i-1]:t.line;n.pos=0,n.addToken=Wn,Ji(e.display.measure)&&(o=oi(a))&&(n.addToken=Hn(n.addToken,o)),n.map=[];var s=t!=e.display.externalMeasured&&ri(a);Un(a,n,qn(e,a,s)),a.styleClasses&&(a.styleClasses.bgClass&&(n.bgClass=Gi(a.styleClasses.bgClass,n.bgClass||"")),a.styleClasses.textClass&&(n.textClass=Gi(a.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Qi(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return wo&&/\bcm-tab\b/.test(n.content.lastChild.className)&&(n.content.className="cm-tab-wrap-hack"),Ia(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=Gi(n.pre.className,n.textClass||"")),n}function Bn(e){var t=Hi("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Wn(e,t,r,n,i,o,a){if(t){var s=e.splitSpaces?t.replace(/ {3,}/g,Fn):t,l=e.cm.state.specialChars,c=!1;if(l.test(t))for(var u=document.createDocumentFragment(),f=0;;){l.lastIndex=f;var d=l.exec(t),p=d?d.index-f:t.length-f;if(p){var h=document.createTextNode(s.slice(f,f+p));u.appendChild(ko&&9>xo?Hi("span",[h]):h),e.map.push(e.pos,e.pos+p,h),e.col+=p,e.pos+=p}if(!d)break;if(f+=p+1," "==d[0]){var m=e.cm.options.tabSize,g=m-e.col%m,h=u.appendChild(Hi("span",zi(g),"cm-tab"));h.setAttribute("role","presentation"),h.setAttribute("cm-text"," "),e.col+=g}else if("\r"==d[0]||"\n"==d[0]){var h=u.appendChild(Hi("span","\r"==d[0]?"␍":"","cm-invalidchar"));h.setAttribute("cm-text",d[0]),e.col+=1}else{var h=e.cm.options.specialCharPlaceholder(d[0]);h.setAttribute("cm-text",d[0]),u.appendChild(ko&&9>xo?Hi("span",[h]):h),e.col+=1}e.map.push(e.pos,e.pos+1,h),e.pos++}else{e.col+=t.length;var u=document.createTextNode(s);e.map.push(e.pos,e.pos+t.length,u),ko&&9>xo&&(c=!0),e.pos+=t.length}if(r||n||i||c||a){var v=r||"";n&&(v+=n),i&&(v+=i);var y=Hi("span",[u],v,a);return o&&(y.title=o),e.content.appendChild(y)}e.content.appendChild(u)}}function Fn(e){for(var t=" ",r=0;rc&&d.from<=c)break}if(d.to>=u)return e(r,n,i,o,a,s,l);e(r,n.slice(0,d.to-c),i,o,null,s,l),o=null,n=n.slice(d.to-c),c=d.to}}}function $n(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function Un(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var a,s,l,c,u,f,d,p=i.length,h=0,m=1,g="",v=0;;){if(v==h){l=c=u=f=s="",d=null,v=1/0;for(var y,b=[],k=0;kh||w.collapsed&&x.to==h&&x.from==h)?(null!=x.to&&x.to!=h&&v>x.to&&(v=x.to,c=""),w.className&&(l+=" "+w.className),w.css&&(s=(s?s+";":"")+w.css),w.startStyle&&x.from==h&&(u+=" "+w.startStyle),w.endStyle&&x.to==v&&(y||(y=[])).push(w.endStyle,x.to),w.title&&!f&&(f=w.title),w.collapsed&&(!d||hn(d.marker,w)<0)&&(d=x)):x.from>h&&v>x.from&&(v=x.from)}if(y)for(var k=0;k=p)break;for(var _=Math.min(p,v);;){if(g){var C=h+g.length;if(!d){var S=C>_?g.slice(0,_-h):g;t.addToken(t,S,a?a+l:l,u,h+S.length==v?c:"",f,s)}if(C>=_){g=g.slice(_-h),h=_;break}h=C,u=""}g=i.slice(o,o=r[m++]),a=Dn(r[m++],t.cm.options)}}else for(var m=1;mr;++r)o.push(new ka(c[r],i(r),n));return o}var s=t.from,l=t.to,c=t.text,u=Qn(e,s.line),f=Qn(e,l.line),d=Ii(c),p=i(c.length-1),h=l.line-s.line;if(t.full)e.insert(0,a(0,c.length)),e.remove(c.length,e.size-c.length);else if(Kn(e,t)){var m=a(0,c.length-1);o(f,f.text,p),h&&e.remove(s.line,h),m.length&&e.insert(s.line,m)}else if(u==f)if(1==c.length)o(u,u.text.slice(0,s.ch)+d+u.text.slice(l.ch),p);else{var m=a(1,c.length-1);m.push(new ka(d+u.text.slice(l.ch),p,n)),o(u,u.text.slice(0,s.ch)+c[0],i(0)),e.insert(s.line+1,m)}else if(1==c.length)o(u,u.text.slice(0,s.ch)+c[0]+f.text.slice(l.ch),i(0)),e.remove(s.line+1,h);else{o(u,u.text.slice(0,s.ch)+c[0],i(0)),o(f,d+f.text.slice(l.ch),p);var m=a(1,c.length-1);h>1&&e.remove(s.line+1,h-1),e.insert(s.line+1,m)}Si(e,"change",e,t)}function Gn(e){this.lines=e,this.parent=null;for(var t=0,r=0;tt||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(o>t){r=i;break}t-=o}return r.lines[t]}function Jn(e,t,r){var n=[],i=t.line;return e.iter(t.line,r.line+1,function(e){var o=e.text;i==r.line&&(o=o.slice(0,r.ch)),i==t.line&&(o=o.slice(t.ch)),n.push(o),++i}),n}function ei(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function ti(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function ri(e){if(null==e.parent)return null;for(var t=e.parent,r=Ni(t.lines,e),n=t.parent;n;t=n,n=n.parent)for(var i=0;n.children[i]!=t;++i)r+=n.children[i].chunkSize();return r+t.first}function ni(e,t){var r=e.first;e:do{for(var n=0;nt){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var n=0;nt)break;t-=s}return r+n}function ii(e){e=bn(e);for(var t=0,r=e.parent,n=0;n1&&!e.done[e.done.length-2].ranges?(e.done.pop(),Ii(e.done)):void 0}function ui(e,t,r,n){if("ignoreHistory"!=t.origin){var i=e.history;i.undone.length=0;var o,a=+new Date;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>a-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=ci(i,i.lastOp==n))){var s=Ii(o.changes);0==jo(t.from,t.to)&&0==jo(t.from,s.to)?s.to=Jo(t):o.changes.push(si(e,t))}else{var l=Ii(i.done);for(l&&l.ranges||pi(e.sel,i.done),o={changes:[si(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=a,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,s||Ia(e,"historyAdded")}}function fi(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function di(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||fi(e,o,Ii(i.done),t))?i.done[i.done.length-1]=t:pi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&n.clearRedo!==!1&&li(i.undone)}function pi(e,t){var r=Ii(t);r&&r.ranges&&r.equals(e)||t.push(e)}function hi(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function mi(e){if(!e)return null;for(var t,r=0;r-1&&(Ii(s)[f]=u[f],delete u[f])}}}return i}function yi(e,t,r,n){r0?n.slice():Oa:n||Oa}function Si(e,t){function r(e){return function(){e.apply(null,o)}}var n=Ci(e,t,!1);if(n.length){var i,o=Array.prototype.slice.call(arguments,2);Uo?i=Uo.delayedCallbacks:Na?i=Na:(i=Na=[],setTimeout(Mi,0));for(var a=0;a0}function Ei(e){e.prototype.on=function(e,t){Ea(this,e,t)},e.prototype.off=function(e,t){za(this,e,t)}}function Oi(){this.id=null}function zi(e){for(;Fa.length<=e;)Fa.push(Ii(Fa)+" ");return Fa[e]}function Ii(e){return e[e.length-1]}function Ni(e,t){for(var r=0;r-1&&Ka(e)?!0:t.test(e):Ka(e)}function Wi(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Fi(e){return e.charCodeAt(0)>=768&&Va.test(e)}function Hi(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o0;--t)e.removeChild(e.firstChild);return e}function Ui(e,t){return $i(e).appendChild(t)}function Ki(){for(var e=document.activeElement;e&&e.root&&e.root.activeElement;)e=e.root.activeElement;return e}function Vi(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function Gi(e,t){for(var r=e.split(" "),n=0;n2&&!(ko&&8>xo))}var r=Xa?Hi("span",""):Hi("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function Ji(e){if(null!=Za)return Za;var t=Ui(e,document.createTextNode("AخA")),r=$a(t,0,1).getBoundingClientRect();if(!r||r.left==r.right)return!1;var n=$a(t,1,2).getBoundingClientRect();return Za=n.right-r.right<3}function eo(e){if(null!=is)return is;var t=Ui(e,Hi("span","x")),r=t.getBoundingClientRect(),n=$a(t,0,1).getBoundingClientRect();return is=Math.abs(r.left-n.left)>1}function to(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;ot||t==r&&a.to==t)&&(n(Math.max(a.from,t),Math.min(a.to,r),1==a.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function ro(e){return e.level%2?e.to:e.from}function no(e){return e.level%2?e.from:e.to}function io(e){var t=oi(e);return t?ro(t[0]):0}function oo(e){var t=oi(e);return t?no(Ii(t)):e.text.length}function ao(e,t){var r=Qn(e.doc,t),n=bn(r);n!=r&&(t=ri(n));var i=oi(n),o=i?i[0].level%2?oo(n):io(n):0;return Do(t,o)}function so(e,t){for(var r,n=Qn(e.doc,t);r=vn(n);)n=r.find(1,!0).line,t=null;var i=oi(n),o=i?i[0].level%2?io(n):oo(n):n.text.length;return Do(null==t?ri(n):t,o)}function lo(e,t){var r=ao(e,t.line),n=Qn(e.doc,r.line),i=oi(n);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),a=t.line==r.line&&t.ch<=o&&t.ch;return Do(r.line,a?0:o)}return r}function co(e,t,r){var n=e[0].level;return t==n?!0:r==n?!1:r>t}function uo(e,t){as=null;for(var r,n=0;nt)return n;if(i.from==t||i.to==t){if(null!=r)return co(e,i.level,e[r].level)?(i.from!=i.to&&(as=r),n):(i.from!=i.to&&(as=n),r);r=n}}return r}function fo(e,t,r,n){if(!n)return t+r;do t+=r;while(t>0&&Fi(e.text.charAt(t)));return t}function po(e,t,r,n){var i=oi(e);if(!i)return ho(e,t,r,n);for(var o=uo(i,t),a=i[o],s=fo(e,t,a.level%2?-r:r,n);;){if(s>a.from&&s0==a.level%2?a.to:a.from);if(a=i[o+=r],!a)return null;s=r>0==a.level%2?fo(e,a.to,-1,n):fo(e,a.from,1,n)}}function ho(e,t,r,n){var i=t+r;if(n)for(;i>0&&Fi(e.text.charAt(i));)i+=r;return 0>i||i>e.text.length?null:i}var mo=navigator.userAgent,go=navigator.platform,vo=/gecko\/\d/i.test(mo),yo=/MSIE \d/.test(mo),bo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(mo),ko=yo||bo,xo=ko&&(yo?document.documentMode||6:bo[1]),wo=/WebKit\//.test(mo),_o=wo&&/Qt\/\d+\.\d+/.test(mo),Co=/Chrome\//.test(mo),So=/Opera\//.test(mo),Mo=/Apple Computer/.test(navigator.vendor),Lo=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(mo),To=/PhantomJS/.test(mo),Ao=/AppleWebKit/.test(mo)&&/Mobile\/\w+/.test(mo),Eo=Ao||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(mo),Oo=Ao||/Mac/.test(go),zo=/win/i.test(go),Io=So&&mo.match(/Version\/(\d*\.\d*)/);Io&&(Io=Number(Io[1])),Io&&Io>=15&&(So=!1,wo=!0);var No=Oo&&(_o||So&&(null==Io||12.11>Io)),Po=vo||ko&&xo>=9,qo=!1,Ro=!1;m.prototype=Di({update:function(e){var t=e.scrollWidth>e.clientWidth+1,r=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var i=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=r?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(r?n:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==n&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:r?n:0,bottom:t?n:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert)},zeroWidthHack:function(){var e=Oo&&!Lo?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new Oi,this.disableVert=new Oi},enableZeroWidthBar:function(e,t){function r(){var n=e.getBoundingClientRect(),i=document.elementFromPoint(n.left+1,n.bottom-1);i!=e?e.style.pointerEvents="none":t.set(1e3,r)}e.style.pointerEvents="auto",t.set(1e3,r)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},m.prototype),g.prototype=Di({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},g.prototype),e.scrollbarModel={
+"native":m,"null":g},S.prototype.signal=function(e,t){Ai(e,t)&&this.events.push(arguments)},S.prototype.finish=function(){for(var e=0;e=9&&r.hasSelection&&(r.hasSelection=null),r.poll()}),Ea(o,"paste",function(e){Li(n,e)||J(e,n)||(n.state.pasteIncoming=!0,r.fastPoll())}),Ea(o,"cut",t),Ea(o,"copy",t),Ea(e.scroller,"paste",function(t){Kt(e,t)||Li(n,t)||(n.state.pasteIncoming=!0,r.focus())}),Ea(e.lineSpace,"selectstart",function(t){Kt(e,t)||La(t)}),Ea(o,"compositionstart",function(){var e=n.getCursor("from");r.composing&&r.composing.range.clear(),r.composing={start:e,range:n.markText(e,n.getCursor("to"),{className:"CodeMirror-composing"})}}),Ea(o,"compositionend",function(){r.composing&&(r.poll(),r.composing.range.clear(),r.composing=null)})},prepareSelection:function(){var e=this.cm,t=e.display,r=e.doc,n=qe(e);if(e.options.moveInputWithCursor){var i=ht(e,r.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+a.top-o.top)),n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+a.left-o.left))}return n},showSelection:function(e){var t=this.cm,r=t.display;Ui(r.cursorDiv,e.cursors),Ui(r.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,r,n=this.cm,i=n.doc;if(n.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=ns&&(o.to().line-o.from().line>100||(r=n.getSelection()).length>1e3);var a=t?"-":r||n.getSelection();this.composing||(this.textarea.value=a),n.state.focused&&Ha(this.textarea),ko&&xo>=9&&(this.hasSelection=a)}else e||(this.composing||(this.prevInput=this.textarea.value=""),ko&&xo>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!Eo||Ki()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;e.pollingFast||e.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var n=r.poll();n||t?(r.pollingFast=!1,r.slowPoll()):(t=!0,r.polling.set(60,e))}var t=!1,r=this;r.pollingFast=!0,r.polling.set(20,e)},poll:function(){var e=this.cm,t=this.textarea,r=this.prevInput;if(this.contextMenuPending||!e.state.focused||rs(t)&&!r&&!this.composing||e.isReadOnly()||e.options.disableInput||e.state.keySeq)return!1;var n=t.value;if(n==r&&!e.somethingSelected())return!1;if(ko&&xo>=9&&this.hasSelection===n||Oo&&/[\uf700-\uf7ff]/.test(n))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){var i=n.charCodeAt(0);if(8203!=i||r||(r=""),8666==i)return this.reset(),this.cm.execCommand("undo")}for(var o=0,a=Math.min(r.length,n.length);a>o&&r.charCodeAt(o)==n.charCodeAt(o);)++o;var s=this;return Et(e,function(){Q(e,n.slice(o),r.length-o,null,s.composing?"*compose":null),n.length>1e3||n.indexOf("\n")>-1?t.value=s.prevInput="":s.prevInput=n,s.composing&&(s.composing.range.clear(),s.composing.range=e.markText(s.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){ko&&xo>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=a.selectionStart){var e=i.somethingSelected(),t=""+(e?a.value:"");a.value="⇚",a.value=t,n.prevInput=e?"":"",a.selectionStart=1,a.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function r(){if(n.contextMenuPending=!1,n.wrapper.style.position="relative",a.style.cssText=u,ko&&9>xo&&o.scrollbars.setScrollTop(o.scroller.scrollTop=l),null!=a.selectionStart){(!ko||ko&&9>xo)&&t();var e=0,r=function(){o.selForContextMenu==i.doc.sel&&0==a.selectionStart&&a.selectionEnd>0&&""==n.prevInput?Ot(i,ua.selectAll)(i):e++<10?o.detectingSelectAll=setTimeout(r,500):o.input.reset()};o.detectingSelectAll=setTimeout(r,200)}}var n=this,i=n.cm,o=i.display,a=n.textarea,s=Vt(i,e),l=o.scroller.scrollTop;if(s&&!So){var c=i.options.resetSelectionOnContextMenu;c&&-1==i.doc.sel.contains(s)&&Ot(i,Le)(i.doc,he(s),Ra);var u=a.style.cssText;if(n.wrapper.style.position="absolute",a.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+(ko?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",wo)var f=window.scrollY;if(o.input.focus(),wo&&window.scrollTo(null,f),o.input.reset(),i.somethingSelected()||(a.value=n.prevInput=" "),n.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),ko&&xo>=9&&t(),Po){Aa(e);var d=function(){za(window,"mouseup",d),setTimeout(r,20)};Ea(window,"mouseup",d)}else setTimeout(r,50)}},readOnlyChanged:function(e){e||this.reset()},setUneditable:qi,needsContentAttribute:!1},ne.prototype),oe.prototype=Di({init:function(e){function t(e){if(!Li(n,e)){if(n.somethingSelected())Bo=n.getSelections(),"cut"==e.type&&n.replaceSelection("",null,"cut");else{if(!n.options.lineWiseCopyCut)return;var t=te(n);Bo=t.text,"cut"==e.type&&n.operation(function(){n.setSelections(t.ranges,0,Ra),n.replaceSelection("",null,"cut")})}if(e.clipboardData&&!Ao)e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/plain",Bo.join("\n"));else{var r=ie(),i=r.firstChild;n.display.lineSpace.insertBefore(r,n.display.lineSpace.firstChild),i.value=Bo.join("\n");var o=document.activeElement;Ha(i),setTimeout(function(){n.display.lineSpace.removeChild(r),o.focus()},50)}}}var r=this,n=r.cm,i=r.div=e.lineDiv;re(i),Ea(i,"paste",function(e){Li(n,e)||J(e,n)}),Ea(i,"compositionstart",function(e){var t=e.data;if(r.composing={sel:n.doc.sel,data:t,startData:t},t){var i=n.doc.sel.primary(),o=n.getLine(i.head.line),a=o.indexOf(t,Math.max(0,i.head.ch-t.length));a>-1&&a<=i.head.ch&&(r.composing.sel=he(Do(i.head.line,a),Do(i.head.line,a+t.length)))}}),Ea(i,"compositionupdate",function(e){r.composing.data=e.data}),Ea(i,"compositionend",function(e){var t=r.composing;t&&(e.data==t.startData||/\u200b/.test(e.data)||(t.data=e.data),setTimeout(function(){t.handled||r.applyComposition(t),r.composing==t&&(r.composing=null)},50))}),Ea(i,"touchstart",function(){r.forceCompositionEnd()}),Ea(i,"input",function(){r.composing||(n.isReadOnly()||!r.pollContent())&&Et(r.cm,function(){qt(n)})}),Ea(i,"copy",t),Ea(i,"cut",t)},prepareSelection:function(){var e=qe(this.cm,!1);return e.focus=this.cm.state.focused,e},showSelection:function(e){e&&this.cm.display.view.length&&(e.focus&&this.showPrimarySelection(),this.showMultipleSelections(e))},showPrimarySelection:function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),r=le(this.cm,e.anchorNode,e.anchorOffset),n=le(this.cm,e.focusNode,e.focusOffset);if(!r||r.bad||!n||n.bad||0!=jo(Z(r,n),t.from())||0!=jo(X(r,n),t.to())){var i=ae(this.cm,t.from()),o=ae(this.cm,t.to());if(i||o){var a=this.cm.display.view,s=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var l=a[a.length-1].measure,c=l.maps?l.maps[l.maps.length-1]:l.map;o={node:c[c.length-1],offset:c[c.length-2]-c[c.length-3]}}}else i={node:a[0].measure.map[2],offset:0};try{var u=$a(i.node,i.offset,o.offset,o.node)}catch(f){}u&&(!vo&&this.cm.state.focused?(e.collapse(i.node,i.offset),u.collapsed||e.addRange(u)):(e.removeAllRanges(),e.addRange(u)),s&&null==e.anchorNode?e.addRange(s):vo&&this.startGracePeriod()),this.rememberSelection()}}},startGracePeriod:function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){e.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(e){Ui(this.cm.display.cursorDiv,e.cursors),Ui(this.cm.display.selectionDiv,e.selection)},rememberSelection:function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},selectionInEditor:function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return Ga(this.div,t)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():Et(this.cm,function(){t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},selectionChanged:function(){var e=window.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var e=window.getSelection(),t=this.cm;this.rememberSelection();var r=le(t,e.anchorNode,e.anchorOffset),n=le(t,e.focusNode,e.focusOffset);r&&n&&Et(t,function(){Le(t.doc,he(r,n),Ra),(r.bad||n.bad)&&(t.curOp.selectionChanged=!0)})}},pollContent:function(){var e=this.cm,t=e.display,r=e.doc.sel.primary(),n=r.from(),i=r.to();if(n.linet.viewTo-1)return!1;var o;if(n.line==t.viewFrom||0==(o=jt(e,n.line)))var a=ri(t.view[0].line),s=t.view[0].node;else var a=ri(t.view[o].line),s=t.view[o-1].node.nextSibling;var l=jt(e,i.line);if(l==t.view.length-1)var c=t.viewTo-1,u=t.lineDiv.lastChild;else var c=ri(t.view[l+1].line)-1,u=t.view[l+1].node.previousSibling;for(var f=e.doc.splitLines(ue(e,s,u,a,c)),d=Jn(e.doc,Do(a,0),Do(c,Qn(e.doc,c).text.length));f.length>1&&d.length>1;)if(Ii(f)==Ii(d))f.pop(),d.pop(),c--;else{if(f[0]!=d[0])break;f.shift(),d.shift(),a++}for(var p=0,h=0,m=f[0],g=d[0],v=Math.min(m.length,g.length);v>p&&m.charCodeAt(p)==g.charCodeAt(p);)++p;for(var y=Ii(f),b=Ii(d),k=Math.min(y.length-(1==f.length?p:0),b.length-(1==d.length?p:0));k>h&&y.charCodeAt(y.length-h-1)==b.charCodeAt(b.length-h-1);)++h;f[f.length-1]=y.slice(0,y.length-h),f[0]=f[0].slice(p);var x=Do(a,p),w=Do(c,d.length?Ii(d).length-h:0);return f.length>1||f[0]||jo(x,w)?(zr(e.doc,f,x,w,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(e){this.cm.isReadOnly()?Ot(this.cm,qt)(this.cm):e.data&&e.data!=e.startData&&Ot(this.cm,Q)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.contentEditable="false"},onKeyPress:function(e){e.preventDefault(),this.cm.isReadOnly()||Ot(this.cm,Q)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},readOnlyChanged:function(e){this.div.contentEditable=String("nocursor"!=e)},onContextMenu:qi,resetPosition:qi,needsContentAttribute:!0},oe.prototype),e.inputStyles={textarea:ne,contenteditable:oe},fe.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t=0&&jo(e,n.to())<=0)return r}return-1}},de.prototype={from:function(){return Z(this.anchor,this.head)},to:function(){return X(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Wo,Fo,Ho,$o={left:0,right:0,top:0,bottom:0},Uo=null,Ko=0,Vo=0,Go=0,Xo=null;ko?Xo=-.53:vo?Xo=15:Co?Xo=-.7:Mo&&(Xo=-1/3);var Zo=function(e){var t=e.wheelDeltaX,r=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==r&&e.detail&&e.axis==e.VERTICAL_AXIS?r=e.detail:null==r&&(r=e.wheelDelta),{x:t,y:r}};e.wheelEventPixels=function(e){var t=Zo(e);return t.x*=Xo,t.y*=Xo,t};var Yo=new Oi,Qo=null,Jo=e.changeEnd=function(e){return e.text?Do(e.from.line+e.text.length-1,Ii(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var r=this.options,n=r[e];(r[e]!=t||"mode"==e)&&(r[e]=t,ta.hasOwnProperty(e)&&Ot(this,ta[e])(this,t,n))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Vr(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;rr&&(Br(this,i.head.line,e,!0),r=i.head.line,n==this.doc.sel.primIndex&&Dr(this));else{var o=i.from(),a=i.to(),s=Math.max(r,o.line);r=Math.min(this.lastLine(),a.line-(a.ch?0:1))+1;for(var l=s;r>l;++l)Br(this,l,e);var c=this.doc.sel.ranges;0==o.ch&&t.length==c.length&&c[n].from().ch>0&&_e(this.doc,n,new de(o,c[n].to()),Ra)}}}),getTokenAt:function(e,t){return In(this,e,t)},getLineTokens:function(e,t){return In(this,Do(e),t,!0)},getTokenTypeAt:function(e){e=ge(this.doc,e);var t,r=qn(this,Qn(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var a=n+i>>1;if((a?r[2*a-1]:0)>=o)i=a;else{if(!(r[2*a+1]s?t:0==s?null:t.slice(0,s-1)},getModeAt:function(t){var r=this.doc.mode;return r.innerMode?e.innerMode(r,this.getTokenAt(t).state).mode:r},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var r=[];if(!sa.hasOwnProperty(t))return r;var n=sa[t],i=this.getModeAt(e);if("string"==typeof i[t])n[i[t]]&&r.push(n[i[t]]);else if(i[t])for(var o=0;oi&&(e=i,n=!0),r=Qn(this.doc,e)}else r=e;return ft(this,r,{top:0,left:0},t||"page").top+(n?this.doc.height-ii(r):0)},defaultTextHeight:function(){return bt(this.display)},defaultCharWidth:function(){return kt(this.display)},setGutterMarker:zt(function(e,t,r){return Wr(this.doc,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});return n[t]=r,!r&&Wi(n)&&(e.gutterMarkers=null),!0})}),clearGutter:zt(function(e){var t=this,r=t.doc,n=r.first;r.iter(function(r){r.gutterMarkers&&r.gutterMarkers[e]&&(r.gutterMarkers[e]=null,Rt(t,n,"gutter"),Wi(r.gutterMarkers)&&(r.gutterMarkers=null)),++n})}),lineInfo:function(e){if("number"==typeof e){if(!ye(this.doc,e))return null;var t=e;if(e=Qn(this.doc,e),!e)return null}else{var t=ri(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=ht(this,ge(this.doc,e));var a=e.bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==n)a=e.top;else if("above"==n||"near"==n){var l=Math.max(o.wrapper.clientHeight,this.doc.height),c=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>l)&&e.top>t.offsetHeight?a=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=l&&(a=e.bottom),s+t.offsetWidth>c&&(s=c-t.offsetWidth)}t.style.top=a+"px",t.style.left=t.style.right="","right"==i?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?s=0:"middle"==i&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),r&&Pr(this,s,a,s+t.offsetWidth,a+t.offsetHeight)},triggerOnKeyDown:zt(dr),triggerOnKeyPress:zt(mr),triggerOnKeyUp:hr,execCommand:function(e){return ua.hasOwnProperty(e)?ua[e].call(null,this):void 0},triggerElectric:zt(function(e){ee(this,e)}),findPosH:function(e,t,r,n){var i=1;0>t&&(i=-1,t=-t);for(var o=0,a=ge(this.doc,e);t>o&&(a=Hr(this.doc,a,i,r,n),!a.hitSide);++o);return a},moveH:zt(function(e,t){var r=this;r.extendSelectionsBy(function(n){return r.display.shift||r.doc.extend||n.empty()?Hr(r.doc,n.head,e,t,r.options.rtlMoveVisually):0>e?n.from():n.to()},ja)}),deleteH:zt(function(e,t){var r=this.doc.sel,n=this.doc;r.somethingSelected()?n.replaceSelection("",null,"+delete"):Fr(this,function(r){var i=Hr(n,r.head,e,t,!1);return 0>e?{from:i,to:r.head}:{from:r.head,to:i}})}),findPosV:function(e,t,r,n){var i=1,o=n;0>t&&(i=-1,t=-t);for(var a=0,s=ge(this.doc,e);t>a;++a){var l=ht(this,s,"div");if(null==o?o=l.left:l.left=o,s=$r(this,l,i,r),s.hitSide)break}return s},moveV:zt(function(e,t){var r=this,n=this.doc,i=[],o=!r.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(function(a){if(o)return 0>e?a.from():a.to();var s=ht(r,a.head,"div");null!=a.goalColumn&&(s.left=a.goalColumn),i.push(s.left);var l=$r(r,s,e,t);return"page"==t&&a==n.sel.primary()&&Rr(r,null,pt(r,l,"div").top-s.top),l},ja),i.length)for(var a=0;a0&&s(r.charAt(n-1));)--n;for(;i.5)&&a(this),Ia(this,"refresh",this)}),swapDoc:zt(function(e){var t=this.doc;return t.cm=null,Yn(this,e),lt(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,Si(this,"swapDoc",this,t),t}),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}},Ei(e);var ea=e.defaults={},ta=e.optionHandlers={},ra=e.Init={toString:function(){return"CodeMirror.Init"}};Ur("value","",function(e,t){e.setValue(t)},!0),Ur("mode",null,function(e,t){e.doc.modeOption=t,r(e)},!0),Ur("indentUnit",2,r,!0),Ur("indentWithTabs",!1),Ur("smartIndent",!0),Ur("tabSize",4,function(e){n(e),lt(e),qt(e)},!0),Ur("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var r=[],n=e.doc.first;e.doc.iter(function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(-1==o)break;i=o+t.length,r.push(Do(n,o))}n++});for(var i=r.length-1;i>=0;i--)zr(e.doc,t,r[i],Do(r[i].line,r[i].ch+t.length))}}),Ur("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(t,r,n){t.state.specialChars=new RegExp(r.source+(r.test(" ")?"":"| "),"g"),n!=e.Init&&t.refresh()}),Ur("specialCharPlaceholder",Bn,function(e){e.refresh()},!0),Ur("electricChars",!0),Ur("inputStyle",Eo?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Ur("rtlMoveVisually",!zo),Ur("wholeLineUpdateBefore",!0),Ur("theme","default",function(e){s(e),l(e)},!0),Ur("keyMap","default",function(t,r,n){var i=Vr(r),o=n!=e.Init&&Vr(n);o&&o.detach&&o.detach(t,i),i.attach&&i.attach(t,o||null)}),Ur("extraKeys",null),Ur("lineWrapping",!1,i,!0),Ur("gutters",[],function(e){p(e.options),l(e)},!0),Ur("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?C(e.display)+"px":"0",e.refresh()},!0),Ur("coverGutterNextToScrollbar",!1,function(e){y(e)},!0),Ur("scrollbarStyle","native",function(e){v(e),y(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),Ur("lineNumbers",!1,function(e){p(e.options),l(e)},!0),Ur("firstLineNumber",1,l,!0),Ur("lineNumberFormatter",function(e){return e},l,!0),Ur("showCursorWhenSelecting",!1,Pe,!0),Ur("resetSelectionOnContextMenu",!0),Ur("lineWiseCopyCut",!0),Ur("readOnly",!1,function(e,t){"nocursor"==t?(yr(e),e.display.input.blur(),e.display.disabled=!0):e.display.disabled=!1,e.display.input.readOnlyChanged(t)}),Ur("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),Ur("dragDrop",!0,$t),Ur("allowDropFileTypes",null),Ur("cursorBlinkRate",530),Ur("cursorScrollMargin",0),Ur("cursorHeight",1,Pe,!0),Ur("singleCursorHeightPerLine",!0,Pe,!0),Ur("workTime",100),Ur("workDelay",100),Ur("flattenSpans",!0,n,!0),Ur("addModeClass",!1,n,!0),Ur("pollInterval",100),Ur("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),Ur("historyEventDelay",1250),Ur("viewportMargin",10,function(e){e.refresh()},!0),Ur("maxHighlightLength",1e4,n,!0),Ur("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Ur("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),Ur("autofocus",null);var na=e.modes={},ia=e.mimeModes={};e.defineMode=function(t,r){e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2&&(r.dependencies=Array.prototype.slice.call(arguments,2)),na[t]=r},e.defineMIME=function(e,t){ia[e]=t},e.resolveMode=function(t){if("string"==typeof t&&ia.hasOwnProperty(t))t=ia[t];else if(t&&"string"==typeof t.name&&ia.hasOwnProperty(t.name)){var r=ia[t.name];"string"==typeof r&&(r={name:r}),t=Ri(r,t),t.name=r.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,r){var r=e.resolveMode(r),n=na[r.name];if(!n)return e.getMode(t,"text/plain");var i=n(t,r);if(oa.hasOwnProperty(r.name)){var o=oa[r.name];for(var a in o)o.hasOwnProperty(a)&&(i.hasOwnProperty(a)&&(i["_"+a]=i[a]),i[a]=o[a])}if(i.name=r.name,r.helperType&&(i.helperType=r.helperType),r.modeProps)for(var a in r.modeProps)i[a]=r.modeProps[a];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var oa=e.modeExtensions={};e.extendMode=function(e,t){var r=oa.hasOwnProperty(e)?oa[e]:oa[e]={};Di(t,r)},e.defineExtension=function(t,r){e.prototype[t]=r},e.defineDocExtension=function(e,t){Ca.prototype[e]=t},e.defineOption=Ur;var aa=[];e.defineInitHook=function(e){aa.push(e)};var sa=e.helpers={};e.registerHelper=function(t,r,n){sa.hasOwnProperty(t)||(sa[t]=e[t]={_global:[]}),sa[t][r]=n},e.registerGlobalHelper=function(t,r,n,i){e.registerHelper(t,r,i),sa[t]._global.push({pred:n,val:i})};var la=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r},ca=e.startState=function(e,t,r){return e.startState?e.startState(t,r):!0};e.innerMode=function(e,t){for(;e.innerMode;){var r=e.innerMode(t);if(!r||r.mode==e)break;t=r.state,e=r.mode}return r||{mode:e,state:t}};var ua=e.commands={selectAll:function(e){e.setSelection(Do(e.firstLine(),0),Do(e.lastLine()),Ra)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Ra)},killLine:function(e){Fr(e,function(t){if(t.empty()){var r=Qn(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line0)i=new Do(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),Do(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var a=Qn(e.doc,i.line-1).text;a&&e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),Do(i.line-1,a.length-1),Do(i.line,1),"+transpose")}r.push(new de(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){Et(e,function(){for(var t=e.listSelections().length,r=0;t>r;r++){var n=e.listSelections()[r];e.replaceRange(e.doc.lineSeparator(),n.anchor,n.head,"+input"),e.indentLine(n.from().line+1,null,!0)}Dr(e)})},toggleOverwrite:function(e){e.toggleOverwrite()}},fa=e.keyMap={};fa.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",
+Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},fa.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},fa.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},fa.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},fa["default"]=Oo?fa.macDefault:fa.pcDefault,e.normalizeKeyMap=function(e){var t={};for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];if(/^(name|fallthrough|(de|at)tach)$/.test(r))continue;if("..."==n){delete e[r];continue}for(var i=Pi(r.split(" "),Kr),o=0;o=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.post},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var ga=0,va=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ga};Ei(va),va.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&xt(e),Ai(this,"clear")){var r=this.find();r&&Si(this,"clear",r.from,r.to)}for(var n=null,i=null,o=0;oe.display.maxLineLength&&(e.display.maxLine=l,e.display.maxLineLength=c,e.display.maxLineChanged=!0)}null!=n&&e&&this.collapsed&&qt(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Ee(e.doc)),e&&Si(e,"markerCleared",e,this),t&&_t(e),this.parent&&this.parent.clear()}},va.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var r,n,i=0;ir;++r){var i=this.lines[r];this.height-=i.height,An(i),Si(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,r){this.height+=r,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var n=0;ne;++e)if(r(this.lines[e]))return!0}},Xn.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var r=0;re){var o=Math.min(t,i-e),a=n.height;if(n.removeInner(e,o),this.height-=a-n.height,i==o&&(this.children.splice(r--,1),n.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Gn))){var s=[];this.collapse(s),this.children=[new Gn(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t=e){if(i.insertInner(e,t,r),i.lines&&i.lines.length>50){for(;i.lines.length>50;){var a=i.lines.splice(i.lines.length-25,25),s=new Gn(a);i.height-=s.height,this.children.splice(n+1,0,s),s.parent=this}this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),r=new Xn(t);if(e.parent){e.size-=r.size,e.height-=r.height;var n=Ni(e.parent.children,e);e.parent.children.splice(n+1,0,r)}else{var i=new Xn(e.children);i.parent=e,e.children=[i,r],e=i}r.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;ne){var a=Math.min(t,o-e);if(i.iterN(e,a,r))return!0;if(0==(t-=a))break;e=0}else e-=o}}};var _a=0,Ca=e.Doc=function(e,t,r,n){if(!(this instanceof Ca))return new Ca(e,t,r,n);null==r&&(r=0),Xn.call(this,[new Gn([new ka("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var i=Do(r,0);this.sel=he(i),this.history=new ai(null),this.id=++_a,this.modeOption=t,this.lineSep=n,this.extend=!1,"string"==typeof e&&(e=this.splitLines(e)),Vn(this,{from:i,to:i,text:e}),Le(this,he(i),Ra)};Ca.prototype=Ri(Xn.prototype,{constructor:Ca,iter:function(e,t,r){r?this.iterN(e-this.first,t-e,r):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var r=0,n=0;n=0;o--)Mr(this,n[o]);s?Me(this,s):this.cm&&Dr(this.cm)}),undo:It(function(){Tr(this,"undo")}),redo:It(function(){Tr(this,"redo")}),undoSelection:It(function(){Tr(this,"undo",!0)}),redoSelection:It(function(){Tr(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=ge(this,e),t=ge(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var a=o.markedSpans;if(a)for(var s=0;sl.to||null==l.from&&i!=e.line||i==t.line&&l.from>t.ch||r&&!r(l.marker)||n.push(l.marker.parent||l.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;ne?(t=e,!0):(e-=i,void++r)}),ge(this,Do(r,t))},indexFromPos:function(e){e=ge(this,e);var t=e.ch;return e.linet&&(t=e.from),null!=e.to&&e.tos||s>=t)return a+(t-o);a+=s-o,a+=r-a%r,o=s+1}},Wa=e.findColumn=function(e,t,r){for(var n=0,i=0;;){var o=e.indexOf(" ",n);-1==o&&(o=e.length);var a=o-n;if(o==e.length||i+a>=t)return n+Math.min(a,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}},Fa=[""],Ha=function(e){e.select()};Ao?Ha=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:ko&&(Ha=function(e){try{e.select()}catch(t){}});var $a,Ua=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Ka=e.isWordChar=function(e){return/\w/.test(e)||e>""&&(e.toUpperCase()!=e.toLowerCase()||Ua.test(e))},Va=/[\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]/;$a=document.createRange?function(e,t,r,n){var i=document.createRange();return i.setEnd(n||e,r),i.setStart(e,t),i}:function(e,t,r){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(i){return n}return n.collapse(!0),n.moveEnd("character",r),n.moveStart("character",t),n};var Ga=e.contains=function(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)};ko&&11>xo&&(Ki=function(){try{return document.activeElement}catch(e){return document.body}});var Xa,Za,Ya=e.rmClass=function(e,t){var r=e.className,n=Vi(t).exec(r);if(n){var i=r.slice(n.index+n[0].length);e.className=r.slice(0,n.index)+(i?n[1]+i:"")}},Qa=e.addClass=function(e,t){var r=e.className;Vi(t).test(r)||(e.className+=(r?" ":"")+t)},Ja=!1,es=function(){if(ko&&9>xo)return!1;var e=Hi("div");return"draggable"in e||"dragDrop"in e}(),ts=e.splitLines=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;n>=t;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),a=o.indexOf("\r");-1!=a?(r.push(o.slice(0,a)),t+=a+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},rs=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(r){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},ns=function(){var e=Hi("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),is=null,os=e.keyNames={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};!function(){for(var e=0;10>e;e++)os[e+48]=os[e+96]=String(e);for(var e=65;90>=e;e++)os[e]=String.fromCharCode(e);for(var e=1;12>=e;e++)os[e+111]=os[e+63235]="F"+e}();var as,ss=function(){function e(e){return 247>=e?r.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1773>=e?n.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,r){this.level=e,this.from=t,this.to=r}var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",n="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,a=/[LRr]/,s=/[Lb1n]/,l=/[1n]/,c="L";return function(r){if(!i.test(r))return!1;for(var n,u=r.length,f=[],d=0;u>d;++d)f.push(n=e(r.charCodeAt(d)));for(var d=0,p=c;u>d;++d){var n=f[d];"m"==n?f[d]=p:p=n}for(var d=0,h=c;u>d;++d){var n=f[d];"1"==n&&"r"==h?f[d]="n":a.test(n)&&(h=n,"r"==n&&(f[d]="R"))}for(var d=1,p=f[0];u-1>d;++d){var n=f[d];"+"==n&&"1"==p&&"1"==f[d+1]?f[d]="1":","!=n||p!=f[d+1]||"1"!=p&&"n"!=p||(f[d]=p),p=n}for(var d=0;u>d;++d){var n=f[d];if(","==n)f[d]="N";else if("%"==n){for(var m=d+1;u>m&&"%"==f[m];++m);for(var g=d&&"!"==f[d-1]||u>m&&"1"==f[m]?"1":"N",v=d;m>v;++v)f[v]=g;d=m-1}}for(var d=0,h=c;u>d;++d){var n=f[d];"L"==h&&"1"==n?f[d]="L":a.test(n)&&(h=n)}for(var d=0;u>d;++d)if(o.test(f[d])){for(var m=d+1;u>m&&o.test(f[m]);++m);for(var y="L"==(d?f[d-1]:c),b="L"==(u>m?f[m]:c),g=y||b?"L":"R",v=d;m>v;++v)f[v]=g;d=m-1}for(var k,x=[],d=0;u>d;)if(s.test(f[d])){var w=d;for(++d;u>d&&s.test(f[d]);++d);x.push(new t(0,w,d))}else{var _=d,C=x.length;for(++d;u>d&&"L"!=f[d];++d);for(var v=_;d>v;)if(l.test(f[v])){v>_&&x.splice(C,0,new t(1,_,v));var S=v;for(++v;d>v&&l.test(f[v]);++v);x.splice(C,0,new t(2,S,v)),_=v}else++v;d>_&&x.splice(C,0,new t(1,_,d))}return 1==x[0].level&&(k=r.match(/^\s+/))&&(x[0].from=k[0].length,x.unshift(new t(0,0,k[0].length))),1==Ii(x).level&&(k=r.match(/\s+$/))&&(Ii(x).to-=k[0].length,x.push(new t(0,u-k[0].length,u))),2==x[0].level&&x.unshift(new t(1,x[0].to,x[0].to)),x[0].level!=Ii(x).level&&x.push(new t(x[0].level,u,u)),x}}();return e.version="5.10.1",e}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.overlayMode=function(t,r,n){return{startState:function(){return{base:e.startState(t),overlay:e.startState(r),basePos:0,baseCur:null,overlayPos:0,overlayCur:null,streamSeen:null}},copyState:function(n){return{base:e.copyState(t,n.base),overlay:e.copyState(r,n.overlay),basePos:n.basePos,baseCur:null,overlayPos:n.overlayPos,overlayCur:null}},token:function(e,i){return(e!=i.streamSeen||Math.min(i.basePos,i.overlayPos)2){n.pending=[];for(var d=2;d-1)return e.Pass;var a=n.indent.length-1,s=t[n.state];e:for(;;){for(var c=0;ca?0:n.indent[a]}}e.defineSimpleMode=function(t,r){e.defineMode(t,function(t){return e.simpleMode(t,r)})},e.simpleMode=function(r,n){t(n,"start");var a={},s=n.meta||{},l=!1;for(var u in n)if(u!=s&&n.hasOwnProperty(u))for(var f=a[u]=[],d=n[u],p=0;p-1?i+t.length:i}var o=t.exec(r?e.slice(r):e);return o?o.index+r+(n?o[0].length:0):-1}var n=Array.prototype.slice.call(arguments,1);return{startState:function(){return{outer:e.startState(t),innerActive:null,inner:null}},copyState:function(r){return{outer:e.copyState(t,r.outer),innerActive:r.innerActive,inner:r.innerActive&&e.copyState(r.innerActive.mode,r.inner)}},token:function(i,o){if(o.innerActive){var a=o.innerActive,s=i.string;if(!a.close&&i.sol())return o.innerActive=o.inner=null,this.token(i,o);var l=a.close?r(s,a.close,i.pos,a.parseDelimiters):-1;if(l==i.pos&&!a.parseDelimiters)return i.match(a.close),o.innerActive=o.inner=null,a.delimStyle&&a.delimStyle+" "+a.delimStyle+"-close";l>-1&&(i.string=s.slice(0,l));var c=a.mode.token(i,o.inner);return l>-1&&(i.string=s),l==i.pos&&a.parseDelimiters&&(o.innerActive=o.inner=null),a.innerStyle&&(c=c?c+" "+a.innerStyle:a.innerStyle),c}for(var u=1/0,s=i.string,f=0;fl&&(u=l)}u!=1/0&&(i.string=s.slice(0,u));var p=t.token(i,o.outer);return u!=1/0&&(i.string=s),p},indent:function(r,n){var i=r.innerActive?r.innerActive.mode:t;return i.indent?i.indent(r.innerActive?r.inner:r.outer,n):e.Pass},blankLine:function(r){var i=r.innerActive?r.innerActive.mode:t;if(i.blankLine&&i.blankLine(r.innerActive?r.inner:r.outer),r.innerActive)"\n"===r.innerActive.close&&(r.innerActive=r.inner=null);else for(var o=0;o-1)return u=r(l,c,u),{from:n(o.line,u),to:n(o.line,u+a.length)}}else{var l=e.getLine(o.line).slice(o.ch),c=s(l),u=c.indexOf(t);if(u>-1)return u=r(l,c,u)+o.ch,{from:n(o.line,u),to:n(o.line,u+a.length)}}}:function(){};else{var c=a.split("\n");this.matches=function(t,r){var i=l.length-1;if(t){if(r.line-(l.length-1)=1;--u,--a)if(l[u]!=s(e.getLine(a)))return;var f=e.getLine(a),d=f.length-c[0].length;if(s(f.slice(d))!=l[0])return;return{from:n(a,d),to:o}}if(!(r.line+(l.length-1)>e.lastLine())){var f=e.getLine(r.line),d=f.length-c[0].length;if(s(f.slice(d))==l[0]){for(var p=n(r.line,d),a=r.line+1,u=1;i>u;++u,++a)if(l[u]!=s(e.getLine(a)))return;if(s(e.getLine(a).slice(0,c[i].length))==l[i])return{from:p,to:n(a,c[i].length)}}}}}}}function r(e,t,r){if(e.length==t.length)return r;for(var n=Math.min(r,e.length);;){var i=e.slice(0,n).toLowerCase().length;if(r>i)++n;else{if(!(i>r))return n;--n}}}var n=e.Pos;t.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(e){function t(e){var t=n(e,0);return r.pos={from:t,to:t},r.atOccurrence=!1,!1}for(var r=this,i=this.doc.clipPos(e?this.pos.from:this.pos.to);;){if(this.pos=this.matches(e,i))return this.atOccurrence=!0,this.pos.match||!0;if(e){if(!i.line)return t(0);i=n(i.line-1,this.doc.getLine(i.line-1).length)}else{var o=this.doc.lineCount();if(i.line==o-1)return t(o);i=n(i.line+1,0)}}},from:function(){return this.atOccurrence?this.pos.from:void 0},to:function(){return this.atOccurrence?this.pos.to:void 0},replace:function(t,r){if(this.atOccurrence){var i=e.splitLines(t);this.doc.replaceRange(i,this.pos.from,this.pos.to,r),this.pos.to=n(this.pos.from.line+i.length-1,i[i.length-1].length+(1==i.length?this.pos.from.ch:0))}}},e.defineExtension("getSearchCursor",function(e,r,n){return new t(this.doc,e,r,n)}),e.defineDocExtension("getSearchCursor",function(e,r,n){return new t(this,e,r,n)}),e.defineExtension("selectMatches",function(t,r){for(var n=[],i=this.getSearchCursor(t,this.getCursor("from"),r);i.findNext()&&!(e.cmpPos(i.to(),this.getCursor("to"))>0);)n.push({anchor:i.from(),head:i.to()});n.length&&this.setSelections(n,0)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){return"string"==typeof e?e=new RegExp(e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),t?"gi":"g"):e.global||(e=new RegExp(e.source,e.ignoreCase?"gi":"g")),{token:function(t){e.lastIndex=t.pos;var r=e.exec(t.string);return r&&r.index==t.pos?(t.pos+=r[0].length||1,"searching"):void(r?t.pos=r.index:t.skipToEnd())}}}function r(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}function n(e){return e.state.search||(e.state.search=new r)}function i(e){return"string"==typeof e&&e==e.toLowerCase()}function o(e,t,r){return e.getSearchCursor(t,r,i(t))}function a(e,t,r,n){e.openDialog(t,n,{value:r,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){h(e)}})}function s(e,t,r,n,i){e.openDialog?e.openDialog(t,i,{value:n,selectValueOnOpen:!0}):i(prompt(r,n))}function l(e,t,r,n){e.openConfirm?e.openConfirm(t,n):confirm(r)&&n[0]()}function c(e){return e.replace(/\\(.)/g,function(e,t){return"n"==t?"\n":"r"==t?"\r":t})}function u(e){var t=e.match(/^\/(.*)\/([a-z]*)$/);if(t)try{e=new RegExp(t[1],-1==t[2].indexOf("i")?"":"i")}catch(r){}else e=c(e);return("string"==typeof e?""==e:e.test(""))&&(e=/x^/),e}function f(e,r,n){r.queryText=n,r.query=u(n),e.removeOverlay(r.overlay,i(r.query)),r.overlay=t(r.query,i(r.query)),e.addOverlay(r.overlay),e.showMatchesOnScrollbar&&(r.annotate&&(r.annotate.clear(),r.annotate=null),r.annotate=e.showMatchesOnScrollbar(r.query,i(r.query)))}function d(t,r,i){var o=n(t);if(o.query)return p(t,r);var l=t.getSelection()||o.lastQuery;if(i&&t.openDialog){var c=null;a(t,v,l,function(r,n){e.e_stop(n),r&&(r!=o.queryText&&f(t,o,r),c&&(c.style.opacity=1),p(t,n.shiftKey,function(e,r){var n;r.line<3&&document.querySelector&&(n=t.display.wrapper.querySelector(".CodeMirror-dialog"))&&n.getBoundingClientRect().bottom-4>t.cursorCoords(r,"window").top&&((c=n).style.opacity=.4)}))})}else s(t,v,"Search for:",l,function(e){e&&!o.query&&t.operation(function(){f(t,o,e),o.posFrom=o.posTo=t.getCursor(),p(t,r)})})}function p(t,r,i){t.operation(function(){var a=n(t),s=o(t,a.query,r?a.posFrom:a.posTo);(s.find(r)||(s=o(t,a.query,r?e.Pos(t.lastLine()):e.Pos(t.firstLine(),0)),s.find(r)))&&(t.setSelection(s.from(),s.to()),t.scrollIntoView({from:s.from(),to:s.to()},20),a.posFrom=s.from(),a.posTo=s.to(),i&&i(s.from(),s.to()))})}function h(e){e.operation(function(){var t=n(e);t.lastQuery=t.query,t.query&&(t.query=t.queryText=null,e.removeOverlay(t.overlay),t.annotate&&(t.annotate.clear(),t.annotate=null))})}function m(e,t,r){e.operation(function(){for(var n=o(e,t);n.findNext();)if("string"!=typeof t){var i=e.getRange(n.from(),n.to()).match(t);n.replace(r.replace(/\$(\d)/g,function(e,t){return i[t]}))}else n.replace(r)})}function g(e,t){if(!e.getOption("readOnly")){var r=e.getSelection()||n(e).lastQuery,i=t?"Replace all:":"Replace:";s(e,i+y,i,r,function(r){r&&(r=u(r),s(e,b,"Replace with:","",function(n){if(n=c(n),t)m(e,r,n);else{h(e);var i=o(e,r,e.getCursor()),a=function(){var t,c=i.from();!(t=i.findNext())&&(i=o(e,r),!(t=i.findNext())||c&&i.from().line==c.line&&i.from().ch==c.ch)||(e.setSelection(i.from(),i.to()),e.scrollIntoView({from:i.from(),to:i.to()}),l(e,k,"Replace?",[function(){s(t)},a,function(){m(e,r,n)}]))},s=function(e){i.replace("string"==typeof r?n:n.replace(/\$(\d)/g,function(t,r){return e[r]})),a()};a()}}))})}}var v='Search: (Use /re/ syntax for regexp search)',y=' (Use /re/ syntax for regexp search)',b='With: ',k="Replace? ";e.commands.find=function(e){h(e),d(e)},e.commands.findPersistent=function(e){h(e),d(e,!1,!0)},e.commands.findNext=d,e.commands.findPrev=function(e){d(e,!0)},e.commands.clearSearch=h,e.commands.replace=g,e.commands.replaceAll=function(e){g(e,!0)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../dialog/dialog"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t,r,n,i){e.openDialog?e.openDialog(t,i,{value:n,selectValueOnOpen:!0}):i(prompt(r,n))}function r(e,t){var r=Number(t);return/^[-+]/.test(t)?e.getCursor().line+r:r-1}var n='Jump to line: (Use line:column or scroll% syntax)';e.commands.jumpToLine=function(e){var i=e.getCursor();t(e,n,"Jump to line:",i.line+1+":"+i.ch,function(t){if(t){var n;if(n=/^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(t))e.setCursor(r(e,n[1]),Number(n[2]));else if(n=/^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(t)){var o=Math.round(e.lineCount()*Number(n[1])/100);/^[-+]/.test(n[1])&&(o=i.line+o+1),e.setCursor(o-1,i.ch)}else(n=/^\s*\:?\s*([\+\-]?\d+)\s*/.exec(t))&&e.setCursor(r(e,n[1]),i.ch)}})},e.keyMap["default"]["Alt-G"]="jumpToLine"}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t,r,n){this.cm=e,this.options=n;var i={listenForChanges:!1};for(var o in n)i[o]=n[o];i.className||(i.className="CodeMirror-search-match"),this.annotation=e.annotateScrollbar(i),this.query=t,this.caseFold=r,this.gap={from:e.firstLine(),to:e.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var a=this;e.on("change",this.changeHandler=function(e,t){a.onChange(t)})}function r(e,t,r){return t>=e?e:Math.max(t,e+r)}e.defineExtension("showMatchesOnScrollbar",function(e,r,n){return"string"==typeof n&&(n={className:n}),n||(n={}),new t(this,e,r,n)});var n=1e3;t.prototype.findMatches=function(){if(this.gap){for(var t=0;t=this.gap.to)break;r.to.line>=this.gap.from&&this.matches.splice(t--,1)}for(var i=this.cm.getSearchCursor(this.query,e.Pos(this.gap.from,0),this.caseFold),o=this.options&&this.options.maxMatches||n;i.findNext();){var r={from:i.from(),to:i.to()};if(r.from.line>=this.gap.to)break;if(this.matches.splice(t++,0,r),this.matches.length>o)break}this.gap=null}},t.prototype.onChange=function(t){var n=t.from.line,i=e.changeEnd(t).line,o=i-t.to.line;if(this.gap?(this.gap.from=Math.min(r(this.gap.from,n,o),t.from.line),this.gap.to=Math.max(r(this.gap.to,n,o),t.from.line)):this.gap={from:t.from.line,to:i+1},o)for(var a=0;al&&n(e,s.slice(l,c),r,t.style))}var u=e.getCursor("from"),f=e.getCursor("to");if(u.line==f.line&&(!t.wordsOnly||a(e,u,f))){var d=e.getRange(u,f).replace(/^\s+|\s+$/g,"");d.length>=t.minChars&&n(e,d,!1,t.style)}})}function a(e,t,r){var n=e.getRange(t,r);if(null!==n.match(/^\w+$/)){if(t.ch>0){var i={line:t.line,ch:t.ch-1},o=e.getRange(i,t);if(null===o.match(/\W/))return!1}if(r.chn.right?1:0:t.clientYn.bottom?1:0,o.moveTo(o.pos+r*o.screen)}),e.on(this.node,"mousewheel",i),e.on(this.node,"DOMMouseScroll",i)}function r(e,r,n){this.addClass=e,this.horiz=new t(e,"horizontal",n),r(this.horiz.node),this.vert=new t(e,"vertical",n),r(this.vert.node),this.width=null}t.prototype.moveTo=function(e,t){0>e&&(e=0),e>this.total-this.screen&&(e=this.total-this.screen),e!=this.pos&&(this.pos=e,this.inner.style["horizontal"==this.orientation?"left":"top"]=e*(this.size/this.total)+"px",t!==!1&&this.scroll(e,this.orientation))};var n=10;t.prototype.update=function(e,t,r){this.screen=t,this.total=e,this.size=r;var i=this.screen*(this.size/this.total);n>i&&(this.size-=n-i,i=n),this.inner.style["horizontal"==this.orientation?"width":"height"]=i+"px",this.inner.style["horizontal"==this.orientation?"left":"top"]=this.pos*(this.size/this.total)+"px"},r.prototype.update=function(e){if(null==this.width){var t=window.getComputedStyle?window.getComputedStyle(this.horiz.node):this.horiz.node.currentStyle;t&&(this.width=parseInt(t.height))}var r=this.width||0,n=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1;return this.vert.node.style.display=i?"block":"none",this.horiz.node.style.display=n?"block":"none",i&&(this.vert.update(e.scrollHeight,e.clientHeight,e.viewHeight-(n?r:0)),this.vert.node.style.display="block",this.vert.node.style.bottom=n?r+"px":"0"),n&&(this.horiz.update(e.scrollWidth,e.clientWidth,e.viewWidth-(i?r:0)-e.barLeft),this.horiz.node.style.right=i?r+"px":"0",this.horiz.node.style.left=e.barLeft+"px"),{right:i?r:0,bottom:n?r:0}},r.prototype.setScrollTop=function(e){this.vert.moveTo(e,!1)},r.prototype.setScrollLeft=function(e){this.horiz.moveTo(e,!1)},r.prototype.clear=function(){var e=this.horiz.node.parentNode;e.removeChild(this.horiz.node),e.removeChild(this.vert.node)},e.scrollbarModel.simple=function(e,t){return new r("CodeMirror-simplescroll",e,t)},e.scrollbarModel.overlay=function(e,t){return new r("CodeMirror-overlayscroll",e,t)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){function r(e){clearTimeout(n.doRedraw),n.doRedraw=setTimeout(function(){n.redraw()},e)}this.cm=e,this.options=t,this.buttonHeight=t.scrollButtonHeight||e.getOption("scrollButtonHeight"),this.annotations=[],this.doRedraw=this.doUpdate=null,this.div=e.getWrapperElement().appendChild(document.createElement("div")),this.div.style.cssText="position: absolute; right: 0; top: 0; z-index: 7; pointer-events: none",this.computeScale();var n=this;e.on("refresh",this.resizeHandler=function(){clearTimeout(n.doUpdate),n.doUpdate=setTimeout(function(){n.computeScale()&&r(20)},100)}),e.on("markerAdded",this.resizeHandler),e.on("markerCleared",this.resizeHandler),t.listenForChanges!==!1&&e.on("change",this.changeHandler=function(){r(250)})}e.defineExtension("annotateScrollbar",function(e){return"string"==typeof e&&(e={className:e}),new t(this,e)}),e.defineOption("scrollButtonHeight",0),t.prototype.computeScale=function(){var e=this.cm,t=(e.getWrapperElement().clientHeight-e.display.barHeight-2*this.buttonHeight)/e.getScrollerElement().scrollHeight;return t!=this.hScale?(this.hScale=t,!0):void 0},t.prototype.update=function(e){this.annotations=e,this.redraw()},t.prototype.redraw=function(e){function t(e,t){if(l!=e.line&&(l=e.line,c=r.getLineHandle(l)),a&&c.height>s)return r.charCoords(e,"local")[t?"top":"bottom"];var n=r.heightAtLine(c,"local");return n+(t?0:c.height)}e!==!1&&this.computeScale();var r=this.cm,n=this.hScale,i=document.createDocumentFragment(),o=this.annotations,a=r.getOption("lineWrapping"),s=a&&1.5*r.defaultTextHeight(),l=null,c=null;if(r.display.barWidth)for(var u,f=0;fh+.9));)d=o[++f],h=t(d.to,!1)*n;if(h!=p){var m=Math.max(h-p,3),g=i.appendChild(document.createElement("div"));g.style.cssText="position: absolute; right: 0px; width: "+Math.max(1.5*r.display.barWidth,2)+"px; top: "+(p+this.buttonHeight)+"px; height: "+m+"px",g.className=this.options.className,d.id&&g.setAttribute("annotation-id",d.id)}}this.div.textContent="",this.div.appendChild(i)},t.prototype.clear=function(){this.cm.off("refresh",this.resizeHandler),this.cm.off("markerAdded",this.resizeHandler),this.cm.off("markerCleared",this.resizeHandler),this.changeHandler&&this.cm.off("change",this.changeHandler),this.div.parentNode.removeChild(this.div)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t,r,n){this.cm=e,this.node=t,this.options=r,this.height=n,this.cleared=!1}function r(e){var t=e.getWrapperElement(),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,n=parseInt(r.height),i=e.state.panels={setHeight:t.style.height,heightLeft:n,panels:0,wrapper:document.createElement("div")};t.parentNode.insertBefore(i.wrapper,t);var o=e.hasFocus();i.wrapper.appendChild(t),o&&e.focus(),e._setSize=e.setSize,null!=n&&(e.setSize=function(t,r){if(null==r)return this._setSize(t,r);if(i.setHeight=r,"number"!=typeof r){var o=/^(\d+\.?\d*)px$/.exec(r);o?r=Number(o[1]):(i.wrapper.style.height=r,r=i.wrapper.offsetHeight,i.wrapper.style.height="")}e._setSize(t,i.heightLeft+=r-n),n=r})}function n(e){var t=e.state.panels;e.state.panels=null;var r=e.getWrapperElement();t.wrapper.parentNode.replaceChild(r,t.wrapper),r.style.height=t.setHeight,e.setSize=e._setSize,e.setSize()}e.defineExtension("addPanel",function(e,n){n=n||{},this.state.panels||r(this);var i=this.state.panels,o=i.wrapper,a=this.getWrapperElement();n.after instanceof t&&!n.after.cleared?o.insertBefore(e,n.before.node.nextSibling):n.before instanceof t&&!n.before.cleared?o.insertBefore(e,n.before.node):n.replace instanceof t&&!n.replace.cleared?(o.insertBefore(e,n.replace.node),n.replace.clear()):"bottom"==n.position?o.appendChild(e):"before-bottom"==n.position?o.insertBefore(e,a.nextSibling):"after-top"==n.position?o.insertBefore(e,a):o.insertBefore(e,o.firstChild);var s=n&&n.height||e.offsetHeight;return this._setSize(null,i.heightLeft-=s),i.panels++,new t(this,e,n,s)}),t.prototype.clear=function(){if(!this.cleared){this.cleared=!0;var e=this.cm.state.panels;this.cm._setSize(null,e.heightLeft+=this.height),e.wrapper.removeChild(this.node),0==--e.panels&&n(this.cm)}},t.prototype.changed=function(e){var t=null==e?this.node.offsetHeight:e,r=this.cm.state.panels;this.cm._setSize(null,r.height+=t-this.height),this.height=t}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e){e.state.placeholder&&(e.state.placeholder.parentNode.removeChild(e.state.placeholder),e.state.placeholder=null)}function r(e){t(e);var r=e.state.placeholder=document.createElement("pre");r.style.cssText="height: 0; overflow: visible",r.className="CodeMirror-placeholder";var n=e.getOption("placeholder");"string"==typeof n&&(n=document.createTextNode(n)),r.appendChild(n),e.display.lineSpace.insertBefore(r,e.display.lineSpace.firstChild)}function n(e){o(e)&&r(e)}function i(e){var n=e.getWrapperElement(),i=o(e);n.className=n.className.replace(" CodeMirror-empty","")+(i?" CodeMirror-empty":""),i?r(e):t(e)}function o(e){return 1===e.lineCount()&&""===e.getLine(0)}e.defineOption("placeholder","",function(r,o,a){var s=a&&a!=e.Init;if(o&&!s)r.on("blur",n),r.on("change",i),i(r);else if(!o&&s){r.off("blur",n),r.off("change",i),t(r);var l=r.getWrapperElement();l.className=l.className.replace(" CodeMirror-empty","")}o&&!r.hasFocus()&&n(r)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e){var t=e.getWrapperElement();e.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:t.style.width,height:t.style.height},t.style.width="",t.style.height="auto",t.className+=" CodeMirror-fullscreen",document.documentElement.style.overflow="hidden",e.refresh()}function r(e){var t=e.getWrapperElement();t.className=t.className.replace(/\s*CodeMirror-fullscreen\b/,""),document.documentElement.style.overflow="";var r=e.state.fullScreenRestore;t.style.width=r.width,t.style.height=r.height,window.scrollTo(r.scrollLeft,r.scrollTop),e.refresh()}e.defineOption("fullScreen",!1,function(n,i,o){o==e.Init&&(o=!1),!o!=!i&&(i?t(n):r(n))})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(t,n){function i(){t.display.wrapper.offsetHeight?(r(t,n),t.display.lastWrapHeight!=t.display.wrapper.clientHeight&&t.refresh()):n.timeout=setTimeout(i,n.delay)}n.timeout=setTimeout(i,n.delay),n.hurry=function(){clearTimeout(n.timeout),n.timeout=setTimeout(i,50)},e.on(window,"mouseup",n.hurry),e.on(window,"keyup",n.hurry)}function r(t,r){clearTimeout(r.timeout),e.off(window,"mouseup",r.hurry),e.off(window,"keyup",r.hurry)}e.defineOption("autoRefresh",!1,function(e,n){e.state.autoRefresh&&(r(e,e.state.autoRefresh),e.state.autoRefresh=null),n&&0==e.display.wrapper.offsetHeight&&t(e,e.state.autoRefresh={delay:n.delay||250})})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t,r){var n,i=e.getWrapperElement();return n=i.appendChild(document.createElement("div")),n.className=r?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof t?n.innerHTML=t:n.appendChild(t),n}function r(e,t){e.state.currentNotificationClose&&e.state.currentNotificationClose(),e.state.currentNotificationClose=t}e.defineExtension("openDialog",function(n,i,o){function a(e){if("string"==typeof e)f.value=e;else{if(c)return;c=!0,l.parentNode.removeChild(l),u.focus(),o.onClose&&o.onClose(l)}}o||(o={}),r(this,null);var s,l=t(this,n,o.bottom),c=!1,u=this,f=l.getElementsByTagName("input")[0];return f?(o.value&&(f.value=o.value,o.selectValueOnOpen!==!1&&f.select()),o.onInput&&e.on(f,"input",function(e){o.onInput(e,f.value,a)}),o.onKeyUp&&e.on(f,"keyup",function(e){o.onKeyUp(e,f.value,a)}),e.on(f,"keydown",function(t){o&&o.onKeyDown&&o.onKeyDown(t,f.value,a)||((27==t.keyCode||o.closeOnEnter!==!1&&13==t.keyCode)&&(f.blur(),e.e_stop(t),a()),13==t.keyCode&&i(f.value,t))}),o.closeOnBlur!==!1&&e.on(f,"blur",a),f.focus()):(s=l.getElementsByTagName("button")[0])&&(e.on(s,"click",function(){a(),u.focus()}),o.closeOnBlur!==!1&&e.on(s,"blur",a),s.focus()),a}),e.defineExtension("openConfirm",function(n,i,o){function a(){c||(c=!0,s.parentNode.removeChild(s),u.focus())}r(this,null);var s=t(this,n,o&&o.bottom),l=s.getElementsByTagName("button"),c=!1,u=this,f=1;l[0].focus();for(var d=0;d=f&&a()},200)}),e.on(p,"focus",function(){++f})}}),e.defineExtension("openNotification",function(n,i){function o(){l||(l=!0,clearTimeout(a),s.parentNode.removeChild(s))}r(this,o);var a,s=t(this,n,i&&i.bottom),l=!1,c=i&&"undefined"!=typeof i.duration?i.duration:5e3;return e.on(s,"click",function(t){e.e_preventDefault(t),o()}),c&&(a=setTimeout(o,c)),o})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t,n,i){var o=e.getLineHandle(t.line),l=t.ch-1,c=l>=0&&s[o.text.charAt(l)]||s[o.text.charAt(++l)];if(!c)return null;var u=">"==c.charAt(1)?1:-1;if(n&&u>0!=(l==t.ch))return null;var f=e.getTokenTypeAt(a(t.line,l+1)),d=r(e,a(t.line,l+(u>0?1:0)),u,f||null,i);return null==d?null:{from:a(t.line,l),to:d&&d.pos,match:d&&d.ch==c.charAt(0),forward:u>0}}function r(e,t,r,n,i){for(var o=i&&i.maxScanLineLength||1e4,l=i&&i.maxScanLines||1e3,c=[],u=i&&i.bracketRegex?i.bracketRegex:/[(){}[\]]/,f=r>0?Math.min(t.line+l,e.lastLine()+1):Math.max(e.firstLine()-1,t.line-l),d=t.line;d!=f;d+=r){var p=e.getLine(d);if(p){var h=r>0?0:p.length-1,m=r>0?p.length:-1;if(!(p.length>o))for(d==t.line&&(h=t.ch-(0>r?1:0));h!=m;h+=r){var g=p.charAt(h);if(u.test(g)&&(void 0===n||e.getTokenTypeAt(a(d,h+1))==n)){var v=s[g];if(">"==v.charAt(1)==r>0)c.push(g);else{if(!c.length)return{pos:a(d,h),ch:g};c.pop()}}}}}return d-r==(r>0?e.lastLine():e.firstLine())?!1:null}function n(e,r,n){for(var i=e.state.matchBrackets.maxHighlightLineLength||1e3,s=[],l=e.listSelections(),c=0;c",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},s=null;e.defineOption("matchBrackets",!1,function(t,n,r){r&&r!=e.Init&&t.off("cursorActivity",i),n&&(t.state.matchBrackets="object"==typeof n?n:{},t.on("cursorActivity",i))}),e.defineExtension("matchBrackets",function(){r(this,!0)}),e.defineExtension("findMatchingBracket",function(e,n,r){return t(this,e,n,r)}),e.defineExtension("scanForBracket",function(e,t,r,i){return n(this,e,t,r,i)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(e,t){return"pairs"==t&&"string"==typeof e?e:"object"==typeof e&&null!=e[t]?e[t]:d[t]}function n(e){return function(t){return l(t,e)}}function r(e){var t=e.state.closeBrackets;if(!t)return null;var n=e.getModeAt(e.getCursor());return n.closeBrackets||t}function i(n){var i=r(n);if(!i||n.getOption("disableInput"))return e.Pass;for(var o=t(i,"pairs"),a=n.listSelections(),l=0;l=0;l--){var u=a[l].head;n.replaceRange("",f(u.line,u.ch-1),f(u.line,u.ch+1),"+delete")}}function o(n){var i=r(n),o=i&&t(i,"explode");if(!o||n.getOption("disableInput"))return e.Pass;for(var a=n.listSelections(),l=0;l0;return{anchor:new f(t.anchor.line,t.anchor.ch+(n?-1:1)),head:new f(t.head.line,t.head.ch+(n?1:-1))}}function l(n,i){var o=r(n);if(!o||n.getOption("disableInput"))return e.Pass;var l=t(o,"pairs"),c=l.indexOf(i);if(-1==c)return e.Pass;for(var d,p,h=t(o,"triples"),m=l.charAt(c+1)==i,g=n.listSelections(),v=c%2==0,y=0;y1&&h.indexOf(i)>=0&&n.getRange(f(k.line,k.ch-2),k)==i+i&&(k.ch<=2||n.getRange(f(k.line,k.ch-3),f(k.line,k.ch-2))!=i))b="addFour";else if(m){if(e.isWordChar(p)||!u(n,k,i))return e.Pass;b="both"}else{if(!v||n.getLine(k.line).length!=k.ch&&!s(p,l)&&!/\s/.test(p))return e.Pass;b="both"}else b=h.indexOf(i)>=0&&n.getRange(k,f(k.line,k.ch+3))==i+i+i?"skipThree":"skip";if(d){if(d!=b)return e.Pass}else d=b}var _=c%2?l.charAt(c-1):i,w=c%2?i:l.charAt(c+1);n.operation(function(){if("skip"==d)n.execCommand("goCharRight");else if("skipThree"==d)for(var e=0;3>e;e++)n.execCommand("goCharRight");else if("surround"==d){for(var t=n.getSelections(),e=0;e-1&&n%2==1}function c(e,t){var n=e.getRange(f(t.line,t.ch-1),f(t.line,t.ch+1));return 2==n.length?n:null}function u(t,n,r){var i=t.getLine(n.line),o=t.getTokenAt(n);if(/\bstring2?\b/.test(o.type))return!1;var a=new e.StringStream(i.slice(0,n.ch)+r+i.slice(n.ch),4);for(a.pos=a.start=o.start;;){var l=t.getMode().token(a,o.state);if(a.pos>=n.ch+1)return/\bstring2?\b/.test(l);a.start=a.pos}}var d={pairs:"()[]{}''\"\"",triples:"",explode:"[]{}"},f=e.Pos;e.defineOption("autoCloseBrackets",!1,function(t,n,r){r&&r!=e.Init&&(t.removeKeyMap(h),t.state.closeBrackets=null),n&&(t.state.closeBrackets=n,t.addKeyMap(h))});for(var p=d.pairs+"`",h={Backspace:i,Enter:o},m=0;mc.ch&&(v=v.slice(0,v.length-u.end+c.ch));var y=v.toLowerCase();if(!v||"string"==u.type&&(u.end!=c.ch||!/[\"\']/.test(u.string.charAt(u.string.length-1))||1==u.string.length)||"tag"==u.type&&"closeTag"==f.type||u.string.indexOf("/")==u.string.length-1||m&&i(m,y)>-1||o(t,v,c,f,!0))return e.Pass;var b=g&&i(g,y)>-1;r[s]={indent:b,text:">"+(b?"\n\n":"")+""+v+">",newPos:b?e.Pos(c.line+1,0):e.Pos(c.line,c.ch+1)}}for(var s=n.length-1;s>=0;s--){var x=r[s];t.replaceRange(x.text,n[s].head,n[s].anchor,"+insert");var k=t.listSelections().slice(0);k[s]={head:x.newPos,anchor:x.newPos},t.setSelections(k),x.indent&&(t.indentLine(x.newPos.line,null,!0),t.indentLine(x.newPos.line+1,null,!0))}}function n(t,n){for(var r=t.listSelections(),i=[],a=n?"/":"",l=0;l"!=t.getLine(s.line).charAt(c.end)&&(f+=">"),i[l]=f}t.replaceSelections(i),r=t.listSelections();for(var l=0;ln;++n)if(e[n]==t)return n;return-1}function o(t,n,r,i,o){if(!e.scanForClosingTag)return!1;var a=Math.min(t.lastLine()+1,r.line+500),l=e.scanForClosingTag(t,r,null,a);if(!l||l.tag!=n)return!1;for(var s=i.context,c=o?1:0;s&&s.tagName==n;s=s.prev)++c;r=l.to;for(var u=1;c>u;u++){var d=e.scanForClosingTag(t,r,null,a);if(!d||d.tag!=n)return!1;r=d.to}return!0}e.defineOption("autoCloseTags",!1,function(n,i,o){if(o!=e.Init&&o&&n.removeKeyMap("autoCloseTags"),i){var a={name:"autoCloseTags"};("object"!=typeof i||i.whenClosing)&&(a["'/'"]=function(e){return r(e)}),("object"!=typeof i||i.whenOpening)&&(a["'>'"]=function(e){return t(e)}),n.addKeyMap(a)}});var a=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],l=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];e.commands.closeTag=function(e){return n(e)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var t=/^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\[\s\]\s|\[x\]\s|\s*)/,n=/^(\s*)(>[> ]*|[*+-]\s|(\d+)[.)])(\[\s\]\s*|\[x\]\s|\s*)$/,r=/[*+-]\s/;e.commands.newlineAndIndentContinueMarkdownList=function(i){if(i.getOption("disableInput"))return e.Pass;for(var o=i.listSelections(),a=[],l=0;l")>=0?p[2]:parseInt(p[3],10)+1+p[4];a[l]="\n"+h+g+m}}i.replaceSelections(a)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e){var t=e.search(r);return-1==t?0:t}var n={},r=/[^\s\u00a0]/,i=e.Pos;e.commands.toggleComment=function(e){e.toggleComment()},e.defineExtension("toggleComment",function(e){e||(e=n);for(var t=this,r=1/0,o=this.listSelections(),a=null,l=o.length-1;l>=0;l--){var s=o[l].from(),c=o[l].to();s.line>=r||(c.line>=r&&(c=i(r,0)),r=s.line,null==a?t.uncomment(s,c,e)?a="un":(t.lineComment(s,c,e),a="line"):"un"==a?t.uncomment(s,c,e):t.lineComment(s,c,e))}}),e.defineExtension("lineComment",function(e,o,a){a||(a=n);var l=this,s=l.getModeAt(e),c=a.lineComment||s.lineComment;if(!c)return void((a.blockCommentStart||s.blockCommentStart)&&(a.fullLines=!0,l.blockComment(e,o,a)));var u=l.getLine(e.line);if(null!=u){var d=Math.min(0!=o.ch||o.line==e.line?o.line+1:o.line,l.lastLine()+1),f=null==a.padding?" ":a.padding,p=a.commentBlankLines||e.line==o.line;l.operation(function(){if(a.indent){for(var n=null,o=e.line;d>o;++o){var s=l.getLine(o),u=s.slice(0,t(s));(null==n||n.length>u.length)&&(n=u)}for(var o=e.line;d>o;++o){var s=l.getLine(o),h=n.length;(p||r.test(s))&&(s.slice(0,h)!=n&&(h=t(s)),l.replaceRange(n+c+f,i(o,0),i(o,h)))}}else for(var o=e.line;d>o;++o)(p||r.test(l.getLine(o)))&&l.replaceRange(c+f,i(o,0))})}}),e.defineExtension("blockComment",function(e,t,o){o||(o=n);var a=this,l=a.getModeAt(e),s=o.blockCommentStart||l.blockCommentStart,c=o.blockCommentEnd||l.blockCommentEnd;if(!s||!c)return void((o.lineComment||l.lineComment)&&0!=o.fullLines&&a.lineComment(e,t,o));var u=Math.min(t.line,a.lastLine());u!=e.line&&0==t.ch&&r.test(a.getLine(u))&&--u;var d=null==o.padding?" ":o.padding;e.line>u||a.operation(function(){if(0!=o.fullLines){var n=r.test(a.getLine(u));a.replaceRange(d+c,i(u)),a.replaceRange(s+d,i(e.line,0));var f=o.blockCommentLead||l.blockCommentLead;if(null!=f)for(var p=e.line+1;u>=p;++p)(p!=u||n)&&a.replaceRange(f+d,i(p,0))}else a.replaceRange(c,t),a.replaceRange(s,e)})}),e.defineExtension("uncomment",function(e,t,o){o||(o=n);var a,l=this,s=l.getModeAt(e),c=Math.min(0!=t.ch||t.line==e.line?t.line:t.line-1,l.lastLine()),u=Math.min(e.line,c),d=o.lineComment||s.lineComment,f=[],p=null==o.padding?" ":o.padding;e:if(d){for(var h=u;c>=h;++h){var m=l.getLine(h),g=m.indexOf(d);if(g>-1&&!/comment/.test(l.getTokenTypeAt(i(h,g+1)))&&(g=-1),-1==g&&(h!=c||h==u)&&r.test(m))break e;if(g>-1&&r.test(m.slice(0,g)))break e;f.push(m)}if(l.operation(function(){for(var e=u;c>=e;++e){var t=f[e-u],n=t.indexOf(d),r=n+d.length;0>n||(t.slice(r,r+p.length)==p&&(r+=p.length),a=!0,l.replaceRange("",i(e,n),i(e,r)))}}),a)return!0}var v=o.blockCommentStart||s.blockCommentStart,y=o.blockCommentEnd||s.blockCommentEnd;if(!v||!y)return!1;var b=o.blockCommentLead||s.blockCommentLead,x=l.getLine(u),k=c==u?x:l.getLine(c),_=x.indexOf(v),w=k.lastIndexOf(y);if(-1==w&&u!=c&&(k=l.getLine(--c),w=k.lastIndexOf(y)),-1==_||-1==w||!/comment/.test(l.getTokenTypeAt(i(u,_+1)))||!/comment/.test(l.getTokenTypeAt(i(c,w+1))))return!1;var C=x.lastIndexOf(v,e.ch),S=-1==C?-1:x.slice(0,e.ch).indexOf(y,C+v.length);if(-1!=C&&-1!=S&&S+y.length!=e.ch)return!1;S=k.indexOf(y,t.ch);var M=k.slice(t.ch).lastIndexOf(v,S-t.ch);return C=-1==S||-1==M?-1:t.ch+M,-1!=S&&-1!=C&&C!=t.ch?!1:(l.operation(function(){l.replaceRange("",i(c,w-(p&&k.slice(w-p.length,w)==p?p.length:0)),i(c,w+y.length));var e=_+v.length;if(p&&x.slice(e,e+p.length)==p&&(e+=p.length),l.replaceRange("",i(u,_),i(u,e)),b)for(var t=u+1;c>=t;++t){var n=l.getLine(t),o=n.indexOf(b);if(-1!=o&&!r.test(n.slice(0,o))){var a=o+b.length;p&&n.slice(a,a+p.length)==p&&(a+=p.length),l.replaceRange("",i(t,o),i(t,a))}}}),!0)})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function t(t){if(t.getOption("disableInput"))return e.Pass;for(var r,i=t.listSelections(),o=[],a=0;a=f);else if(0==s.string.indexOf(r.blockCommentStart)){if(u=p.slice(0,s.start),!/^\s*$/.test(u)){u="";for(var h=0;hs.start&&/^\s*$/.test(p.slice(0,d))&&(u=p.slice(0,d));null!=u&&(u+=r.blockCommentContinue)}if(null==u&&r.lineComment&&n(t)){var m=t.getLine(l.line),d=m.indexOf(r.lineComment);d>-1&&(u=m.slice(0,d),/\S/.test(u)?u=null:u+=r.lineComment+m.slice(d+r.lineComment.length).match(/^\s*/)[0])}if(null==u)return e.Pass;o[a]="\n"+u}t.operation(function(){for(var e=i.length-1;e>=0;e--)t.replaceRange(o[e],i[e].from(),i[e].to(),"+insert")})}function n(e){var t=e.getOption("continueComments");return t&&"object"==typeof t?t.continueLineComment!==!1:!0}for(var r=["clike","css","javascript"],i=0;io;--i){var a=e.getLine(i);if(r&&r.test(a))break;if(!/\S/.test(a)){++i;break}}for(var l=n.paragraphEnd||e.getHelper(t,"paragraphEnd"),s=t.line+1,c=e.lastLine();c>=s;++s){var a=e.getLine(s);if(l&&l.test(a)){++s;break}if(!/\S/.test(a))break}return{from:i,to:s}}function n(e,t,n,r){for(var i=t;i>0&&!n.test(e.slice(i-1,i+1));--i);for(var o=!0;;o=!1){var a=i;if(r)for(;" "==e.charAt(a-1);)--a;if(0!=a||!o)return{from:a,to:i};i=t}}function r(t,r,o,a){r=t.clipPos(r),o=t.clipPos(o);var l=a.column||80,s=a.wrapOn||/\s\S|-[^\.\d]/,c=a.killTrailingSpace!==!1,u=[],d="",f=r.line,p=t.getRange(r,o,!1);if(!p.length)return null;for(var h=p[0].match(/^[ \t]*/)[0],m=0;ml&&h==b&&n(d,l,s,c);x&&x.from==v&&x.to==v+y?(d=h+g,++f):u.push({text:[y?" ":""],from:i(f,v),to:i(f+1,b.length)})}for(;d.length>l;){var k=n(d,l,s,c);u.push({text:["",h],from:i(f,k.from),to:i(f,k.to)}),d=h+d.slice(k.to),++f}}return u.length&&t.operation(function(){for(var n=0;n=0;a--){var l,s=n[a];if(s.empty()){var c=t(e,s.head,{});l={from:i(c.from,0),to:i(c.to-1)}}else l={from:s.from(),to:s.to()};l.to.line>=o||(o=l.from.line,r(e,l.from,l.to,{}))}})},e.defineExtension("wrapRange",function(e,t,n){return r(this,e,t,n||{})}),e.defineExtension("wrapParagraphsInRange",function(e,n,o){o=o||{};for(var a=this,l=[],s=e.line;s<=n.line;){var c=t(a,i(s,0),o);l.push(c),s=c.to}var u=!1;return l.length&&a.operation(function(){for(var e=l.length-1;e>=0;--e)u=u||r(a,i(l[e].from,0),i(l[e].to-1),o)}),u})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(t,i,o,a){function l(e){var n=s(t,i);if(!n||n.to.line-n.from.linet.firstLine();)i=e.Pos(i.line-1,0),u=l(!1);if(u&&!u.cleared&&"unfold"!==a){var d=n(t,o);e.on(d,"mousedown",function(t){f.clear(),e.e_preventDefault(t)});var f=t.markText(u.from,u.to,{replacedWith:d,clearOnEnter:!0,__isFold:!0});f.on("clear",function(n,r){e.signal(t,"unfold",t,n,r)}),e.signal(t,"fold",t,u.from,u.to)}}function n(e,t){var n=r(e,t,"widget");if("string"==typeof n){var i=document.createTextNode(n);n=document.createElement("span"),n.appendChild(i),n.className="CodeMirror-foldmarker"}return n}function r(e,t,n){if(t&&void 0!==t[n])return t[n];var r=e.options.foldOptions;return r&&void 0!==r[n]?r[n]:i[n]}e.newFoldFunction=function(e,n){return function(r,i){t(r,i,{rangeFinder:e,widget:n})}},e.defineExtension("foldCode",function(e,n,r){t(this,e,n,r)}),e.defineExtension("isFolded",function(e){for(var t=this.findMarksAt(e),n=0;n=n;n++)t.foldCode(e.Pos(n,0),null,"fold")})},e.commands.unfoldAll=function(t){t.operation(function(){for(var n=t.firstLine(),r=t.lastLine();r>=n;n++)t.foldCode(e.Pos(n,0),null,"unfold")})},e.registerHelper("fold","combine",function(){var e=Array.prototype.slice.call(arguments,0);return function(t,n){for(var r=0;r=i?-1:l.lastIndexOf(r,i-1);if(-1!=c){if(1==s&&c=h;++h)for(var m=t.getLine(h),g=h==a?i:0;;){var v=m.indexOf(s,g),y=m.indexOf(c,g);if(0>v&&(v=m.length),0>y&&(y=m.length),g=Math.min(v,y),g==m.length)break;if(t.getTokenTypeAt(e.Pos(h,g+1))==o)if(g==v)++f;else if(!--f){u=h,d=g;break e}++g}if(null!=u&&(a!=u||d!=i))return{from:e.Pos(a,i),to:e.Pos(u,d)}}}),e.registerHelper("fold","import",function(t,n){function r(n){if(nt.lastLine())return null;var r=t.getTokenAt(e.Pos(n,1));if(/\S/.test(r.string)||(r=t.getTokenAt(e.Pos(n,r.end+1))),"keyword"!=r.type||"import"!=r.string)return null;for(var i=n,o=Math.min(t.lastLine(),n+10);o>=i;++i){var a=t.getLine(i),l=a.indexOf(";");if(-1!=l)return{startCh:r.end,end:e.Pos(i,l)}}}var i,n=n.line,o=r(n);if(!o||r(n-1)||(i=r(n-2))&&i.end.line==n-1)return null;for(var a=o.end;;){var l=r(a.line+1);if(null==l)break;a=l.end}return{from:t.clipPos(e.Pos(n,o.startCh+1)),to:a}}),e.registerHelper("fold","include",function(t,n){function r(n){if(nt.lastLine())return null;var r=t.getTokenAt(e.Pos(n,1));return/\S/.test(r.string)||(r=t.getTokenAt(e.Pos(n,r.end+1))),"meta"==r.type&&"#include"==r.string.slice(0,8)?r.start+8:void 0}var n=n.line,i=r(n);if(null==i||null!=r(n-1))return null;for(var o=n;;){var a=r(o+1);if(null==a)break;++o}return{from:e.Pos(n,i+1),to:t.clipPos(e.Pos(o))}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./foldcode")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./foldcode"],e):e(CodeMirror)}(function(e){"use strict";function t(e){this.options=e,this.from=this.to=0}function n(e){return e===!0&&(e={}),null==e.gutter&&(e.gutter="CodeMirror-foldgutter"),null==e.indicatorOpen&&(e.indicatorOpen="CodeMirror-foldgutter-open"),null==e.indicatorFolded&&(e.indicatorFolded="CodeMirror-foldgutter-folded"),e}function r(e,t){for(var n=e.findMarksAt(d(t)),r=0;r=l&&(n=i(o.indicatorOpen))}e.setGutterMarker(t,o.gutter,n),++a})}function a(e){var t=e.getViewport(),n=e.state.foldGutter;n&&(e.operation(function(){o(e,t.from,t.to)}),n.from=t.from,n.to=t.to)}function l(e,t,n){var i=e.state.foldGutter;if(i){var o=i.options;if(n==o.gutter){var a=r(e,t);a?a.clear():e.foldCode(d(t,0),o.rangeFinder)}}}function s(e){var t=e.state.foldGutter;if(t){var n=t.options;t.from=t.to=0,clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){a(e)},n.foldOnChangeTimeSpan||600)}}function c(e){var t=e.state.foldGutter;if(t){var n=t.options;clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout(function(){var n=e.getViewport();t.from==t.to||n.from-t.to>20||t.from-n.to>20?a(e):e.operation(function(){n.fromt.to&&(o(e,t.to,n.to),t.to=n.to)})},n.updateViewportTimeSpan||400)}}function u(e,t){var n=e.state.foldGutter;if(n){var r=t.line;r>=n.from&&ru&&!(i(u+1,l,d)<=s);)++u,l=d,d=t.getLine(u+2);return{from:e.Pos(n.line,a.length),to:e.Pos(u,t.getLine(u).length)}})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t){return e.line-t.line||e.ch-t.ch}function n(e,t,n,r){this.line=t,this.ch=n,this.cm=e,this.text=e.getLine(t),this.min=r?r.from:e.firstLine(),this.max=r?r.to-1:e.lastLine()}function r(e,t){var n=e.cm.getTokenTypeAt(f(e.line,t));return n&&/\btag\b/.test(n)}function i(e){return e.line>=e.max?void 0:(e.ch=0,e.text=e.cm.getLine(++e.line),!0)}function o(e){return e.line<=e.min?void 0:(e.text=e.cm.getLine(--e.line),e.ch=e.text.length,!0)}function a(e){for(;;){var t=e.text.indexOf(">",e.ch);if(-1==t){if(i(e))continue;return}{if(r(e,t+1)){var n=e.text.lastIndexOf("/",t),o=n>-1&&!/\S/.test(e.text.slice(n+1,t));return e.ch=t+1,o?"selfClose":"regular"}e.ch=t+1}}}function l(e){for(;;){var t=e.ch?e.text.lastIndexOf("<",e.ch-1):-1;if(-1==t){if(o(e))continue;return}if(r(e,t+1)){m.lastIndex=t,e.ch=t;var n=m.exec(e.text);if(n&&n.index==t)return n}else e.ch=t}}function s(e){for(;;){m.lastIndex=e.ch;var t=m.exec(e.text);if(!t){if(i(e))continue;return}{if(r(e,t.index+1))return e.ch=t.index+t[0].length,t;e.ch=t.index+1}}}function c(e){for(;;){var t=e.ch?e.text.lastIndexOf(">",e.ch-1):-1;if(-1==t){if(o(e))continue;return}{if(r(e,t+1)){var n=e.text.lastIndexOf("/",t),i=n>-1&&!/\S/.test(e.text.slice(n+1,t));return e.ch=t+1,i?"selfClose":"regular"}e.ch=t}}}function u(e,t){for(var n=[];;){var r,i=s(e),o=e.line,l=e.ch-(i?i[0].length:0);if(!i||!(r=a(e)))return;if("selfClose"!=r)if(i[1]){for(var c=n.length-1;c>=0;--c)if(n[c]==i[2]){n.length=c;break}if(0>c&&(!t||t==i[2]))return{tag:i[2],from:f(o,l),to:f(e.line,e.ch)}}else n.push(i[2])}}function d(e,t){for(var n=[];;){var r=c(e);if(!r)return;if("selfClose"!=r){var i=e.line,o=e.ch,a=l(e);if(!a)return;if(a[1])n.push(a[2]);else{for(var s=n.length-1;s>=0;--s)if(n[s]==a[2]){n.length=s;break}if(0>s&&(!t||t==a[2]))return{tag:a[2],from:f(e.line,e.ch),to:f(i,o)}}}else l(e)}}var f=e.Pos,p="A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",h=p+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",m=new RegExp("<(/?)(["+p+"]["+h+"]*)","g");e.registerHelper("fold","xml",function(e,t){for(var r=new n(e,t.line,0);;){var i,o=s(r);if(!o||r.line!=t.line||!(i=a(r)))return;if(!o[1]&&"selfClose"!=i){var t=f(r.line,r.ch),l=u(r,o[2]);return l&&{from:t,to:l.from}}}}),e.findMatchingTag=function(e,r,i){var o=new n(e,r.line,r.ch,i);if(-1!=o.text.indexOf(">")||-1!=o.text.indexOf("<")){var s=a(o),c=s&&f(o.line,o.ch),p=s&&l(o);if(s&&p&&!(t(o,r)>0)){var h={from:f(o.line,o.ch),to:c,tag:p[2]};return"selfClose"==s?{open:h,close:null,at:"open"}:p[1]?{open:d(o,p[2]),close:h,at:"close"}:(o=new n(e,c.line,c.ch,i),{open:h,close:u(o,p[2]),at:"open"})}}},e.findEnclosingTag=function(e,t,r){for(var i=new n(e,t.line,t.ch,r);;){var o=d(i);if(!o)break;var a=new n(e,t.line,t.ch,r),l=u(a,o.tag);if(l)return{open:o,close:l}}},e.scanForClosingTag=function(e,t,r,i){var o=new n(e,t.line,t.ch,i?{from:0,to:i}:null);return u(o,r)}}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";var t={autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0},n={autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1};e.defineMode("xml",function(r,i){function o(e,t){function n(n){return t.tokenize=n,n(e,t)}var r=e.next();if("<"==r)return e.eat("!")?e.eat("[")?e.match("CDATA[")?n(s("atom","]]>")):null:e.match("--")?n(s("comment","-->")):e.match("DOCTYPE",!0,!0)?(e.eatWhile(/[\w\._\-]/),n(c(1))):null:e.eat("?")?(e.eatWhile(/[\w\._\-]/),t.tokenize=s("meta","?>"),"meta"):(M=e.eat("/")?"closeTag":"openTag",t.tokenize=a,"tag bracket");if("&"==r){var i;return i=e.eat("#")?e.eat("x")?e.eatWhile(/[a-fA-F\d]/)&&e.eat(";"):e.eatWhile(/[\d]/)&&e.eat(";"):e.eatWhile(/[\w\.\-:]/)&&e.eat(";"),i?"atom":"error"}return e.eatWhile(/[^&<]/),null}function a(e,t){var n=e.next();if(">"==n||"/"==n&&e.eat(">"))return t.tokenize=o,M=">"==n?"endTag":"selfcloseTag","tag bracket";if("="==n)return M="equals",null;if("<"==n){t.tokenize=o,t.state=p,t.tagName=t.tagStart=null;var r=t.tokenize(e,t);return r?r+" tag error":"tag error"}return/[\'\"]/.test(n)?(t.tokenize=l(n),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function l(e){var t=function(t,n){for(;!t.eol();)if(t.next()==e){n.tokenize=a;break}return"string"};return t.isInAttribute=!0,t}function s(e,t){return function(n,r){for(;!n.eol();){if(n.match(t)){r.tokenize=o;break}n.next()}return e}}function c(e){return function(t,n){for(var r;null!=(r=t.next());){if("<"==r)return n.tokenize=c(e+1),n.tokenize(t,n);if(">"==r){if(1==e){n.tokenize=o;break}return n.tokenize=c(e-1),n.tokenize(t,n)}}return"meta"}}function u(e,t,n){this.prev=e.context,this.tagName=t,this.indent=e.indented,this.startOfLine=n,(w.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)&&(this.noIndent=!0)}function d(e){e.context&&(e.context=e.context.prev)}function f(e,t){for(var n;;){if(!e.context)return;if(n=e.context.tagName,!w.contextGrabbers.hasOwnProperty(n)||!w.contextGrabbers[n].hasOwnProperty(t))return;d(e)}}function p(e,t,n){return"openTag"==e?(n.tagStart=t.column(),h):"closeTag"==e?m:p}function h(e,t,n){return"word"==e?(n.tagName=t.current(),L="tag",y):(L="error",h)}function m(e,t,n){if("word"==e){var r=t.current();return n.context&&n.context.tagName!=r&&w.implicitlyClosed.hasOwnProperty(n.context.tagName)&&d(n),n.context&&n.context.tagName==r?(L="tag",g):(L="tag error",v)}return L="error",v}function g(e,t,n){return"endTag"!=e?(L="error",g):(d(n),p)}function v(e,t,n){return L="error",g(e,t,n)}function y(e,t,n){
-if("word"==e)return L="attribute",b;if("endTag"==e||"selfcloseTag"==e){var r=n.tagName,i=n.tagStart;return n.tagName=n.tagStart=null,"selfcloseTag"==e||w.autoSelfClosers.hasOwnProperty(r)?f(n,r):(f(n,r),n.context=new u(n,r,i==n.indented)),p}return L="error",y}function b(e,t,n){return"equals"==e?x:(w.allowMissing||(L="error"),y(e,t,n))}function x(e,t,n){return"string"==e?k:"word"==e&&w.allowUnquoted?(L="string",y):(L="error",y(e,t,n))}function k(e,t,n){return"string"==e?k:y(e,t,n)}var _=r.indentUnit,w={},C=i.htmlMode?t:n;for(var S in C)w[S]=C[S];for(var S in i)w[S]=i[S];var M,L;return o.isInText=!0,{startState:function(e){var t={tokenize:o,state:p,indented:e||0,tagName:null,tagStart:null,context:null};return null!=e&&(t.baseIndent=e),t},token:function(e,t){if(!t.tagName&&e.sol()&&(t.indented=e.indentation()),e.eatSpace())return null;M=null;var n=t.tokenize(e,t);return(n||M)&&"comment"!=n&&(L=null,t.state=t.state(M||n,e,t),L&&(n="error"==L?n+" error":L)),n},indent:function(t,n,r){var i=t.context;if(t.tokenize.isInAttribute)return t.tagStart==t.indented?t.stringStartCol+1:t.indented+_;if(i&&i.noIndent)return e.Pass;if(t.tokenize!=a&&t.tokenize!=o)return r?r.match(/^(\s*)/)[0].length:0;if(t.tagName)return w.multilineTagIndentPastTag!==!1?t.tagStart+t.tagName.length+2:t.tagStart+_*(w.multilineTagIndentFactor||1);if(w.alignCDATA&&/$/,blockCommentStart:"",configuration:w.htmlMode?"html":"xml",helperType:w.htmlMode?"html":"xml",skipAttribute:function(e){e.state==x&&(e.state=y)}}}),e.defineMIME("text/xml","xml"),e.defineMIME("application/xml","xml"),e.mimeModes.hasOwnProperty("text/html")||e.defineMIME("text/html",{name:"xml",htmlMode:!0})}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../xml/xml"),require("../meta")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../meta"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("markdown",function(t,n){function r(n){if(e.findModeByName){var r=e.findModeByName(n);r&&(n=r.mime||r.mimes[0])}var i=e.getMode(t,n);return"null"==i.name?null:i}function i(e,t,n){return t.f=t.inline=n,n(e,t)}function o(e,t,n){return t.f=t.block=n,n(e,t)}function a(e){return!e||!/\S/.test(e.string)}function l(e){return e.linkTitle=!1,e.em=!1,e.strong=!1,e.strikethrough=!1,e.quote=0,e.indentedCode=!1,_||e.f!=c||(e.f=h,e.block=s),e.trailingSpace=0,e.trailingSpaceNewLine=!1,e.prevLine=e.thisLine,e.thisLine=null,null}function s(e,t){var o=e.sol(),l=t.list!==!1,s=t.indentedCode;t.indentedCode=!1,l&&(t.indentationDiff>=0?(t.indentationDiff<4&&(t.indentation-=t.indentationDiff),t.list=null):t.indentation>0?(t.list=null,t.listDepth=Math.floor(t.indentation/4)):(t.list=!1,t.listDepth=0));var c=null;if(t.indentationDiff>=4)return e.skipToEnd(),s||a(t.prevLine)?(t.indentation-=4,t.indentedCode=!0,C.code):null;if(e.eatSpace())return null;if((c=e.match(z))&&c[1].length<=6)return t.header=c[1].length,n.highlightFormatting&&(t.formatting="header"),t.f=t.inline,f(t);if(!(a(t.prevLine)||t.quote||l||s)&&(c=e.match(E)))return t.header="="==c[0].charAt(0)?1:2,n.highlightFormatting&&(t.formatting="header"),t.f=t.inline,f(t);if(e.eat(">"))return t.quote=o?1:t.quote+1,n.highlightFormatting&&(t.formatting="quote"),e.eatSpace(),f(t);if("["===e.peek())return i(e,t,y);if(e.match(M,!0))return t.hr=!0,C.hr;if((a(t.prevLine)||l)&&(e.match(L,!1)||e.match(T,!1))){var d=null;return e.match(L,!0)?d="ul":(e.match(T,!0),d="ol"),t.indentation=e.column()+e.current().length,t.list=!0,t.listDepth++,n.taskLists&&e.match(A,!1)&&(t.taskList=!0),t.f=t.inline,n.highlightFormatting&&(t.formatting=["list","list-"+d]),f(t)}return n.fencedCodeBlocks&&(c=e.match(q,!0))?(t.fencedChars=c[1],t.localMode=r(c[2]),t.localMode&&(t.localState=t.localMode.startState()),t.f=t.block=u,n.highlightFormatting&&(t.formatting="code-block"),t.code=-1,f(t)):i(e,t,t.inline)}function c(e,t){var n=w.token(e,t.htmlState);return(_&&null===t.htmlState.tagStart&&!t.htmlState.context&&t.htmlState.tokenize.isInText||t.md_inside&&e.current().indexOf(">")>-1)&&(t.f=h,t.block=s,t.htmlState=null),n}function u(e,t){return t.fencedChars&&e.match(t.fencedChars,!1)?(t.localMode=t.localState=null,t.f=t.block=d,null):t.localMode?t.localMode.token(e,t.localState):(e.skipToEnd(),C.code)}function d(e,t){e.match(t.fencedChars),t.block=s,t.f=h,t.fencedChars=null,n.highlightFormatting&&(t.formatting="code-block"),t.code=1;var r=f(t);return t.code=0,r}function f(e){var t=[];if(e.formatting){t.push(C.formatting),"string"==typeof e.formatting&&(e.formatting=[e.formatting]);for(var r=0;r=e.quote?C.formatting+"-"+e.formatting[r]+"-"+e.quote:"error")}if(e.taskOpen)return t.push("meta"),t.length?t.join(" "):null;if(e.taskClosed)return t.push("property"),t.length?t.join(" "):null;if(e.linkHref?t.push(C.linkHref,"url"):(e.strong&&t.push(C.strong),e.em&&t.push(C.em),e.strikethrough&&t.push(C.strikethrough),e.linkText&&t.push(C.linkText),e.code&&t.push(C.code)),e.header&&t.push(C.header,C.header+"-"+e.header),e.quote&&(t.push(C.quote),t.push(!n.maxBlockquoteDepth||n.maxBlockquoteDepth>=e.quote?C.quote+"-"+e.quote:C.quote+"-"+n.maxBlockquoteDepth)),e.list!==!1){var i=(e.listDepth-1)%3;t.push(i?1===i?C.list2:C.list3:C.list1)}return e.trailingSpaceNewLine?t.push("trailing-space-new-line"):e.trailingSpace&&t.push("trailing-space-"+(e.trailingSpace%2?"a":"b")),t.length?t.join(" "):null}function p(e,t){return e.match(O,!0)?f(t):void 0}function h(t,r){var i=r.text(t,r);if("undefined"!=typeof i)return i;if(r.list)return r.list=null,f(r);if(r.taskList){var a="x"!==t.match(A,!0)[1];return a?r.taskOpen=!0:r.taskClosed=!0,n.highlightFormatting&&(r.formatting="task"),r.taskList=!1,f(r)}if(r.taskOpen=!1,r.taskClosed=!1,r.header&&t.match(/^#+$/,!0))return n.highlightFormatting&&(r.formatting="header"),f(r);var l=t.sol(),s=t.next();if(r.linkTitle){r.linkTitle=!1;var u=s;"("===s&&(u=")"),u=(u+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");var d="^\\s*(?:[^"+u+"\\\\]+|\\\\\\\\|\\\\.)"+u;if(t.match(new RegExp(d),!0))return C.linkHref}if("`"===s){var p=r.formatting;n.highlightFormatting&&(r.formatting="code"),t.eatWhile("`");var h=t.current().length;if(0==r.code)return r.code=h,f(r);if(h==r.code){var v=f(r);return r.code=0,v}return r.formatting=p,f(r)}if(r.code)return f(r);if("\\"===s&&(t.next(),n.highlightFormatting)){var y=f(r),b=C.formatting+"-escape";return y?y+" "+b:b}if("!"===s&&t.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return t.match(/\[[^\]]*\]/),r.inline=r.f=g,C.image;if("["===s&&t.match(/.*\](\(.*\)| ?\[.*\])/,!1))return r.linkText=!0,n.highlightFormatting&&(r.formatting="link"),f(r);if("]"===s&&r.linkText&&t.match(/\(.*\)| ?\[.*\]/,!1)){n.highlightFormatting&&(r.formatting="link");var y=f(r);return r.linkText=!1,r.inline=r.f=g,y}if("<"===s&&t.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){r.f=r.inline=m,n.highlightFormatting&&(r.formatting="link");var y=f(r);return y?y+=" ":y="",y+C.linkInline}if("<"===s&&t.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){r.f=r.inline=m,n.highlightFormatting&&(r.formatting="link");var y=f(r);return y?y+=" ":y="",y+C.linkEmail}if("<"===s&&t.match(/^(!--|\w)/,!1)){var x=t.string.indexOf(">",t.pos);if(-1!=x){var k=t.string.substring(t.start,x);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(k)&&(r.md_inside=!0)}return t.backUp(1),r.htmlState=e.startState(w),o(t,r,c)}if("<"===s&&t.match(/^\/\w*?>/))return r.md_inside=!1,"tag";var _=!1;if(!n.underscoresBreakWords&&"_"===s&&"_"!==t.peek()&&t.match(/(\w)/,!1)){var S=t.pos-2;if(S>=0){var M=t.string.charAt(S);"_"!==M&&M.match(/(\w)/,!1)&&(_=!0)}}if("*"===s||"_"===s&&!_)if(l&&" "===t.peek());else{if(r.strong===s&&t.eat(s)){n.highlightFormatting&&(r.formatting="strong");var v=f(r);return r.strong=!1,v}if(!r.strong&&t.eat(s))return r.strong=s,n.highlightFormatting&&(r.formatting="strong"),f(r);if(r.em===s){n.highlightFormatting&&(r.formatting="em");var v=f(r);return r.em=!1,v}if(!r.em)return r.em=s,n.highlightFormatting&&(r.formatting="em"),f(r)}else if(" "===s&&(t.eat("*")||t.eat("_"))){if(" "===t.peek())return f(r);t.backUp(1)}if(n.strikethrough)if("~"===s&&t.eatWhile(s)){if(r.strikethrough){n.highlightFormatting&&(r.formatting="strikethrough");var v=f(r);return r.strikethrough=!1,v}if(t.match(/^[^\s]/,!1))return r.strikethrough=!0,n.highlightFormatting&&(r.formatting="strikethrough"),f(r)}else if(" "===s&&t.match(/^~~/,!0)){if(" "===t.peek())return f(r);t.backUp(2)}return" "===s&&(t.match(/ +$/,!1)?r.trailingSpace++:r.trailingSpace&&(r.trailingSpaceNewLine=!0)),f(r)}function m(e,t){var r=e.next();if(">"===r){t.f=t.inline=h,n.highlightFormatting&&(t.formatting="link");var i=f(t);return i?i+=" ":i="",i+C.linkInline}return e.match(/^[^>]+/,!0),C.linkInline}function g(e,t){if(e.eatSpace())return null;var r=e.next();return"("===r||"["===r?(t.f=t.inline=v("("===r?")":"]"),n.highlightFormatting&&(t.formatting="link-string"),t.linkHref=!0,f(t)):"error"}function v(e){return function(t,r){var i=t.next();if(i===e){r.f=r.inline=h,n.highlightFormatting&&(r.formatting="link-string");var o=f(r);return r.linkHref=!1,o}return t.match(k(e),!0)&&t.backUp(1),r.linkHref=!0,f(r)}}function y(e,t){return e.match(/^([^\]\\]|\\.)*\]:/,!1)?(t.f=b,e.next(),n.highlightFormatting&&(t.formatting="link"),t.linkText=!0,f(t)):i(e,t,h)}function b(e,t){if(e.match(/^\]:/,!0)){t.f=t.inline=x,n.highlightFormatting&&(t.formatting="link");var r=f(t);return t.linkText=!1,r}return e.match(/^([^\]\\]|\\.)+/,!0),C.linkText}function x(e,t){return e.eatSpace()?null:(e.match(/^[^\s]+/,!0),void 0===e.peek()?t.linkTitle=!0:e.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),t.f=t.inline=h,C.linkHref+" url")}function k(e){return N[e]||(e=(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),N[e]=new RegExp("^(?:[^\\\\]|\\\\.)*?("+e+")")),N[e]}var _=e.modes.hasOwnProperty("xml"),w=e.getMode(t,_?{name:"xml",htmlMode:!0}:"text/plain");void 0===n.highlightFormatting&&(n.highlightFormatting=!1),void 0===n.maxBlockquoteDepth&&(n.maxBlockquoteDepth=0),void 0===n.underscoresBreakWords&&(n.underscoresBreakWords=!0),void 0===n.taskLists&&(n.taskLists=!1),void 0===n.strikethrough&&(n.strikethrough=!1),void 0===n.tokenTypeOverrides&&(n.tokenTypeOverrides={});var C={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"tag",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough"};for(var S in C)C.hasOwnProperty(S)&&n.tokenTypeOverrides[S]&&(C[S]=n.tokenTypeOverrides[S]);var M=/^([*\-_])(?:\s*\1){2,}\s*$/,L=/^[*\-+]\s+/,T=/^[0-9]+([.)])\s+/,A=/^\[(x| )\](?=\s)/,z=n.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,E=/^ *(?:\={1,}|-{1,})\s*$/,O=/^[^#!\[\]*_\\<>` "'(~]+/,q=new RegExp("^("+(n.fencedCodeBlocks===!0?"~~~+|```+":n.fencedCodeBlocks)+")[ \\t]*([\\w+#]*)"),N=[],P={startState:function(){return{f:s,prevLine:null,thisLine:null,block:s,htmlState:null,indentation:0,inline:h,text:p,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,hr:!1,taskList:!1,list:!1,listDepth:0,quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,fencedChars:null}},copyState:function(t){return{f:t.f,prevLine:t.prevLine,thisLine:t.thisLine,block:t.block,htmlState:t.htmlState&&e.copyState(w,t.htmlState),indentation:t.indentation,localMode:t.localMode,localState:t.localMode?e.copyState(t.localMode,t.localState):null,inline:t.inline,text:t.text,formatting:!1,linkTitle:t.linkTitle,code:t.code,em:t.em,strong:t.strong,strikethrough:t.strikethrough,header:t.header,hr:t.hr,taskList:t.taskList,list:t.list,listDepth:t.listDepth,quote:t.quote,indentedCode:t.indentedCode,trailingSpace:t.trailingSpace,trailingSpaceNewLine:t.trailingSpaceNewLine,md_inside:t.md_inside,fencedChars:t.fencedChars}},token:function(e,t){if(t.formatting=!1,e!=t.thisLine){var n=t.header||t.hr;if(t.header=0,t.hr=!1,e.match(/^\s*$/,!0)||n){if(l(t),!n)return null;t.prevLine=null}t.prevLine=t.thisLine,t.thisLine=e,t.taskList=!1,t.trailingSpace=0,t.trailingSpaceNewLine=!1,t.f=t.block;var r=e.match(/^\s*/,!0)[0].replace(/\t/g," ").length,i=4*Math.floor((r-t.indentation)/4);i>4&&(i=4);var o=t.indentation+i;if(t.indentationDiff=o-t.indentation,t.indentation=o,r>0)return null}return t.f(e,t)},innerMode:function(e){return e.block==c?{state:e.htmlState,mode:w}:e.localState?{state:e.localState,mode:e.localMode}:{state:e,mode:P}},blankLine:l,getType:f,fold:"markdown"};return P},"xml"),e.defineMIME("text/x-markdown","markdown")}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../markdown/markdown"),require("../../addon/mode/overlay")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../markdown/markdown","../../addon/mode/overlay"],e):e(CodeMirror)}(function(e){"use strict";var t=/^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i;e.defineMode("gfm",function(n,r){function i(e){return e.code=!1,null}var o=0,a={startState:function(){return{code:!1,codeBlock:!1,ateSpace:!1}},copyState:function(e){return{code:e.code,codeBlock:e.codeBlock,ateSpace:e.ateSpace}},token:function(e,n){if(n.combineTokens=null,n.codeBlock)return e.match(/^```+/)?(n.codeBlock=!1,null):(e.skipToEnd(),null);if(e.sol()&&(n.code=!1),e.sol()&&e.match(/^```+/))return e.skipToEnd(),n.codeBlock=!0,null;if("`"===e.peek()){e.next();var i=e.pos;e.eatWhile("`");var a=1+e.pos-i;return n.code?a===o&&(n.code=!1):(o=a,n.code=!0),null}if(n.code)return e.next(),null;if(e.eatSpace())return n.ateSpace=!0,null;if((e.sol()||n.ateSpace)&&(n.ateSpace=!1,r.gitHubSpice!==!1)){if(e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/))return n.combineTokens=!0,"link";if(e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/))return n.combineTokens=!0,"link"}return e.match(t)&&"]("!=e.string.slice(e.start-2,e.start)&&(0==e.start||/\W/.test(e.string.charAt(e.start-1)))?(n.combineTokens=!0,"link"):(e.next(),null)},blankLine:i},l={underscoresBreakWords:!1,taskLists:!0,fencedCodeBlocks:"```",strikethrough:!0};for(var s in r)l[s]=r[s];return l.name="markdown",e.overlayMode(e.getMode(n,l),a)},"markdown"),e.defineMIME("text/x-gfm","gfm")}),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function t(e,t,n){return/^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(t.lastType)||"quasi"==t.lastType&&/\{\s*$/.test(e.string.slice(0,e.pos-(n||0)))}e.defineMode("javascript",function(n,r){function i(e){for(var t,n=!1,r=!1;null!=(t=e.next());){if(!n){if("/"==t&&!r)return;"["==t?r=!0:r&&"]"==t&&(r=!1)}n=!n&&"\\"==t}}function o(e,t,n){return xe=e,ke=n,t}function a(e,n){var r=e.next();if('"'==r||"'"==r)return n.tokenize=l(r),n.tokenize(e,n);if("."==r&&e.match(/^\d+(?:[eE][+\-]?\d+)?/))return o("number","number");if("."==r&&e.match(".."))return o("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(r))return o(r);if("="==r&&e.eat(">"))return o("=>","operator");if("0"==r&&e.eat(/x/i))return e.eatWhile(/[\da-f]/i),o("number","number");if("0"==r&&e.eat(/o/i))return e.eatWhile(/[0-7]/i),o("number","number");if("0"==r&&e.eat(/b/i))return e.eatWhile(/[01]/i),o("number","number");if(/\d/.test(r))return e.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),o("number","number");if("/"==r)return e.eat("*")?(n.tokenize=s,s(e,n)):e.eat("/")?(e.skipToEnd(),o("comment","comment")):t(e,n,1)?(i(e),e.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/),o("regexp","string-2")):(e.eatWhile(Ae),o("operator","operator",e.current()));if("`"==r)return n.tokenize=c,c(e,n);if("#"==r)return e.skipToEnd(),o("error","error");if(Ae.test(r))return e.eatWhile(Ae),o("operator","operator",e.current());if(Le.test(r)){e.eatWhile(Le);var a=e.current(),u=Te.propertyIsEnumerable(a)&&Te[a];return u&&"."!=n.lastType?o(u.type,u.style,a):o("variable","variable",a)}}function l(e){return function(t,n){var r,i=!1;if(Ce&&"@"==t.peek()&&t.match(ze))return n.tokenize=a,o("jsonld-keyword","meta");for(;null!=(r=t.next())&&(r!=e||i);)i=!i&&"\\"==r;return i||(n.tokenize=a),o("string","string")}}function s(e,t){for(var n,r=!1;n=e.next();){if("/"==n&&r){t.tokenize=a;break}r="*"==n}return o("comment","comment")}function c(e,t){for(var n,r=!1;null!=(n=e.next());){if(!r&&("`"==n||"$"==n&&e.eat("{"))){t.tokenize=a;break}r=!r&&"\\"==n}return o("quasi","string-2",e.current())}function u(e,t){t.fatArrowAt&&(t.fatArrowAt=null);var n=e.string.indexOf("=>",e.start);if(!(0>n)){for(var r=0,i=!1,o=n-1;o>=0;--o){var a=e.string.charAt(o),l=Ee.indexOf(a);if(l>=0&&3>l){if(!r){++o;break}if(0==--r)break}else if(l>=3&&6>l)++r;else if(Le.test(a))i=!0;else{if(/["'\/]/.test(a))return;if(i&&!r){++o;break}}}i&&!r&&(t.fatArrowAt=o)}}function d(e,t,n,r,i,o){this.indented=e,this.column=t,this.type=n,this.prev=i,this.info=o,null!=r&&(this.align=r)}function f(e,t){for(var n=e.localVars;n;n=n.next)if(n.name==t)return!0;for(var r=e.context;r;r=r.prev)for(var n=r.vars;n;n=n.next)if(n.name==t)return!0}function p(e,t,n,r,i){var o=e.cc;for(qe.state=e,qe.stream=i,qe.marked=null,qe.cc=o,qe.style=t,e.lexical.hasOwnProperty("align")||(e.lexical.align=!0);;){var a=o.length?o.pop():Se?w:_;if(a(n,r)){for(;o.length&&o[o.length-1].lex;)o.pop()();return qe.marked?qe.marked:"variable"==n&&f(e,r)?"variable-2":t}}}function h(){for(var e=arguments.length-1;e>=0;e--)qe.cc.push(arguments[e])}function m(){return h.apply(null,arguments),!0}function g(e){function t(t){for(var n=t;n;n=n.next)if(n.name==e)return!0;return!1}var n=qe.state;if(qe.marked="def",n.context){if(t(n.localVars))return;n.localVars={name:e,next:n.localVars}}else{if(t(n.globalVars))return;r.globalVars&&(n.globalVars={name:e,next:n.globalVars})}}function v(){qe.state.context={prev:qe.state.context,vars:qe.state.localVars},qe.state.localVars=Ne}function y(){qe.state.localVars=qe.state.context.vars,qe.state.context=qe.state.context.prev}function b(e,t){var n=function(){var n=qe.state,r=n.indented;if("stat"==n.lexical.type)r=n.lexical.indented;else for(var i=n.lexical;i&&")"==i.type&&i.align;i=i.prev)r=i.indented;n.lexical=new d(r,qe.stream.column(),e,null,n.lexical,t)};return n.lex=!0,n}function x(){var e=qe.state;e.lexical.prev&&(")"==e.lexical.type&&(e.indented=e.lexical.indented),e.lexical=e.lexical.prev)}function k(e){function t(n){return n==e?m():";"==e?h():m(t)}return t}function _(e,t){return"var"==e?m(b("vardef",t.length),K,k(";"),x):"keyword a"==e?m(b("form"),w,_,x):"keyword b"==e?m(b("form"),_,x):"{"==e?m(b("}"),B,x):";"==e?m():"if"==e?("else"==qe.state.lexical.info&&qe.state.cc[qe.state.cc.length-1]==x&&qe.state.cc.pop()(),m(b("form"),w,_,x,J)):"function"==e?m(oe):"for"==e?m(b("form"),ee,_,x):"variable"==e?m(b("stat"),D):"switch"==e?m(b("form"),w,b("}","switch"),k("{"),B,x,x):"case"==e?m(w,k(":")):"default"==e?m(k(":")):"catch"==e?m(b("form"),v,k("("),ae,k(")"),_,x,y):"class"==e?m(b("form"),le,x):"export"==e?m(b("stat"),de,x):"import"==e?m(b("stat"),fe,x):"module"==e?m(b("form"),Z,b("}"),k("{"),B,x,x):h(b("stat"),w,k(";"),x)}function w(e){return S(e,!1)}function C(e){return S(e,!0)}function S(e,t){if(qe.state.fatArrowAt==qe.stream.start){var n=t?q:O;if("("==e)return m(v,b(")"),H(Z,")"),x,k("=>"),n,y);if("variable"==e)return h(v,Z,k("=>"),n,y)}var r=t?A:T;return Oe.hasOwnProperty(e)?m(r):"function"==e?m(oe,r):"keyword c"==e?m(t?L:M):"("==e?m(b(")"),M,ye,k(")"),x,r):"operator"==e||"spread"==e?m(t?C:w):"["==e?m(b("]"),ge,x,r):"{"==e?$(R,"}",null,r):"quasi"==e?h(z,r):"new"==e?m(N(t)):m()}function M(e){return e.match(/[;\}\)\],]/)?h():h(w)}function L(e){return e.match(/[;\}\)\],]/)?h():h(C)}function T(e,t){return","==e?m(w):A(e,t,!1)}function A(e,t,n){var r=0==n?T:A,i=0==n?w:C;return"=>"==e?m(v,n?q:O,y):"operator"==e?/\+\+|--/.test(t)?m(r):"?"==t?m(w,k(":"),i):m(i):"quasi"==e?h(z,r):";"!=e?"("==e?$(C,")","call",r):"."==e?m(j,r):"["==e?m(b("]"),M,k("]"),x,r):void 0:void 0}function z(e,t){return"quasi"!=e?h():"${"!=t.slice(t.length-2)?m(z):m(w,E)}function E(e){return"}"==e?(qe.marked="string-2",qe.state.tokenize=c,m(z)):void 0}function O(e){return u(qe.stream,qe.state),h("{"==e?_:w)}function q(e){return u(qe.stream,qe.state),h("{"==e?_:C)}function N(e){return function(t){return"."==t?m(e?I:P):h(e?C:w)}}function P(e,t){return"target"==t?(qe.marked="keyword",m(T)):void 0}function I(e,t){return"target"==t?(qe.marked="keyword",m(A)):void 0}function D(e){return":"==e?m(x,_):h(T,k(";"),x)}function j(e){return"variable"==e?(qe.marked="property",m()):void 0}function R(e,t){return"variable"==e||"keyword"==qe.style?(qe.marked="property",m("get"==t||"set"==t?W:F)):"number"==e||"string"==e?(qe.marked=Ce?"property":qe.style+" property",m(F)):"jsonld-keyword"==e?m(F):"modifier"==e?m(R):"["==e?m(w,k("]"),F):"spread"==e?m(w):void 0}function W(e){return"variable"!=e?h(F):(qe.marked="property",m(oe))}function F(e){return":"==e?m(C):"("==e?h(oe):void 0}function H(e,t){function n(r){if(","==r){var i=qe.state.lexical;return"call"==i.info&&(i.pos=(i.pos||0)+1),m(e,n)}return r==t?m():m(k(t))}return function(r){return r==t?m():h(e,n)}}function $(e,t,n){for(var r=3;r