/*! * SimpleMDE v1.2.0 (https://github.com/NextStepWebs/simplemde-markdown-editor) * Copyright Next Step Webs, Inc. * Licensed under the MIT license */ function fixShortcut(e){return e=isMac?e.replace("Ctrl","Cmd"):e.replace("Cmd","Ctrl")}function createIcon(e,t){t=t||{};var n=document.createElement("a"),r=t.shortcut||shortcuts[e];return r&&(r=fixShortcut(r),n.title=r,n.title=n.title.replace("Cmd","⌘"),isMac&&(n.title=n.title.replace("Alt","⌥"))),n.className=t.className||"icon-"+e,n}function createSep(){return el=document.createElement("i"),el.className="separator",el.innerHTML="|",el}function getState(e,t){t=t||e.getCursor("start");var n=e.getTokenAt(t);if(!n.type)return{};for(var r,i,o=n.type.split(" "),l={},s=0;s\s+/,"unordered-list":/^(\s*)(\*|\-|\+)\s+/,"ordered-list":/^(\s*)\d+\.\s+/},l={quote:"> ","unordered-list":"* ","ordered-list":"1. "},s=r.line;s<=i.line;s++)!function(r){var i=e.getLine(r);i=n[t]?i.replace(o[t],"$1"):l[t]+i,e.replaceRange(i,{line:r,ch:0},{line:r,ch:99999999999999})}(s);e.focus()}}function _toggleBlock(e,t,n,r){if(!/editor-preview-active/.test(e.codemirror.getWrapperElement().lastChild.className)){r="undefined"==typeof r?n:r;var i,o=e.codemirror,l=getState(o),s=n,a=r,u=o.getCursor("start"),c=o.getCursor("end");l[t]?(i=o.getLine(u.line),s=i.slice(0,u.ch),a=i.slice(u.ch),"bold"==t?(s=s.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/,""),a=a.replace(/(\*\*|__)/,"")):"italic"==t&&(s=s.replace(/(\*|_)(?![\s\S]*(\*|_))/,""),a=a.replace(/(\*|_)/,"")),o.replaceRange(s+a,{line:u.line,ch:0},{line:u.line,ch:99999999999999}),"bold"==t?(u.ch-=2,c.ch-=2):"italic"==t&&(u.ch-=1,c.ch-=1)):(i=o.getSelection(),"bold"==t?(i=i.split("**").join(""),i=i.split("__").join("")):"italic"==t&&(i=i.split("*").join(""),i=i.split("_").join("")),o.replaceSelection(s+i+a),u.ch+=n.length,c.ch=u.ch+i.length),o.setSelection(u,c),o.focus()}}function wordCount(e){var t=/[a-zA-Z0-9_\u0392-\u03c9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g,n=e.match(t),r=0;if(null===n)return r;for(var i=0;i=19968?n[i].length:1;return r}function SimpleMDE(e){e=e||{},e.element&&(this.element=e.element),e.toolbar=e.toolbar===!1?!1:e.toolbar||SimpleMDE.toolbar,e.hasOwnProperty("status")||(e.status=["autosave","lines","words","cursor"]),this.options=e,this.render()}!function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);this.CodeMirror=e()}}(function(){"use strict";function e(n,r){if(!(this instanceof e))return new e(n,r);this.options=r=r?Io(r):{},Io(Kl,r,!1),d(r);var i=r.value;"string"==typeof i&&(i=new ys(i,r.mode)),this.doc=i;var o=new e.inputStyles[r.inputStyle](this),l=this.display=new t(n,i,o);l.wrapper.CodeMirror=this,u(this),s(this),r.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),r.autofocus&&!Sl&&l.input.focus(),v(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new To,keySeq:null,specialChars:null};var a=this;pl&&11>gl&&setTimeout(function(){a.display.input.reset(!0)},20),qn(this),Vo(),xn(this),this.curOp.forceUpdate=!0,Vi(this,i),r.autofocus&&!Sl||a.hasFocus()?setTimeout(Fo(pr,this),20):gr(this);for(var c in Xl)Xl.hasOwnProperty(c)&&Xl[c](this,r[c],Yl);C(this),r.finishInit&&r.finishInit(this);for(var h=0;hgl&&(r.gutters.style.zIndex=-1,r.scroller.style.paddingRight=0),ml||hl&&Sl||(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,Pt(e,100),e.state.modeGen++,e.curOp&&In(e)}function i(e){e.options.lineWrapping?(Gs(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Us(e.display.wrapper,"CodeMirror-wrap"),f(e)),l(e),In(e),sn(e),setTimeout(function(){y(e)},100)}function o(e){var t=yn(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/bn(e.display)-3);return function(i){if(bi(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;lt.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}function d(e){var t=Do(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 p(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+Ut(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+$t(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}function g(e,t,n){this.cm=n;var r=this.vert=_o("div",[_o("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=_o("div",[_o("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(r),e(i),Ss(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Ss(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedOverlay=!1,pl&&8>gl&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function m(){}function v(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Us(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),Ss(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,n){"horizontal"==n?nr(t,e):tr(t,e)},t),t.display.scrollbars.addClass&&Gs(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(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&&D(e),b(e,p(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-qt(e));var i=n&&null!=n.bottom?n.bottom:r+e.wrapper.clientHeight,o=Ji(t,r),l=Ji(t,i);if(n&&n.ensure){var s=n.ensure.from.line,a=n.ensure.to.line;o>s?(o=s,l=Ji(t,eo(Ki(t,s))+e.wrapper.clientHeight)):Math.min(a,t.lastLine())>=l&&(o=Ji(t,eo(Ki(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function w(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=S(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",l=0;l=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==Rn(e))return!1;C(e)&&(zn(e),t.dims=H(e));var i=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFroml&&n.viewTo-l<20&&(l=Math.min(i,n.viewTo)),Dl&&(o=vi(e.doc,o),l=yi(e.doc,l));var s=o!=n.viewFrom||l!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;_n(e,o,l),n.viewOffset=eo(Ki(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var a=Rn(e);if(!s&&0==a&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var u=Uo();return a>4&&(n.lineDiv.style.display="none"),E(e,n.updateLineNumbers,t.dims),a>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,u&&Uo()!=u&&u.offsetHeight&&u.focus(),Ro(n.cursorDiv),Ro(n.selectionDiv),n.gutters.style.height=0,s&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,Pt(e,400)),n.updateLineNumbers=null,!0}function N(e,t){for(var n=t.viewport,r=!0;(r&&e.options.lineWrapping&&t.oldDisplayWidth!=jt(e)||(n&&null!=n.top&&(n={top:Math.min(e.doc.height+Ut(e.display)-Vt(e),n.top)}),t.visible=x(e.display,e.doc,n),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&T(e,t);r=!1){D(e);var i=p(e);Ht(e),O(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 L(e,t);if(T(e,n)){D(e),N(e,n);var r=p(e);Ht(e),O(e,r),y(e,r),n.finish()}}function O(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+$t(e),t.clientHeight)+"px"}function D(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;rgl){var l=o.node.offsetTop+o.node.offsetHeight;i=l-n,n=l}else{var s=o.node.getBoundingClientRect();i=s.bottom-s.top}var a=o.line.height-i;if(2>i&&(i=yn(t)),(a>.001||-.001>a)&&(Zi(o.line,i),W(o.line),o.rest))for(var u=0;u=t&&h.lineNumber;h.changes&&(Do(h.changes,"gutter")>-1&&(f=!1),I(e,h,u,n)),f&&(Ro(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(k(e.options,u)))),s=h.node.nextSibling}else{var d=U(e,h,u,n);l.insertBefore(d,s)}u+=h.size}for(;s;)s=r(s)}function I(e,t,n,r){for(var i=0;igl&&(e.node.style.zIndex=2)),e.node}function z(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=F(e);e.background=n.insertBefore(_o("div",null,t),n.firstChild)}}function P(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Ii(e,t)}function B(e,t){var n=t.text.className,r=P(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,_(t)):n&&(t.text.className=n)}function _(e){z(e),e.line.wrapClass?F(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 R(e,t,n,r){t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null);var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var o=F(t),l=t.gutter=_o("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px");if(e.display.input.setUneditable(l),o.insertBefore(l,t.text),t.line.gutterClass&&(l.className+=" "+t.line.gutterClass),!e.options.lineNumbers||i&&i["CodeMirror-linenumbers"]||(t.lineNumber=l.appendChild(_o("div",k(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),i)for(var s=0;s1&&(El&&El.join("\n")==t?a=r.ranges.length%El.length==0&&Wo(El,Vs):s.length==r.ranges.length&&(a=Wo(s,function(e){return[e]})));for(var u=r.ranges.length-1;u>=0;u--){var c=r.ranges[u],h=c.from(),f=c.to();c.empty()&&(n&&n>0?h=Wl(h.line,h.ch-n):e.state.overwrite&&!l&&(f=Wl(f.line,Math.min(Ki(o,f.line).text.length,f.ch+Oo(s).length))));var d=e.curOp.updateInput,p={from:h,to:f,text:a?a[u%a.length]:s,origin:i||(l?"paste":e.state.cutIncoming?"cut":"+input")};kr(e.doc,p),wo(e,"inputRead",e,p)}t&&!l&&et(e,t),Ir(e),e.curOp.updateInput=d,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(),An(t,function(){Q(t,n,0,null,"paste")}),!0):void 0}function et(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),l=!1;if(o.electricChars){for(var s=0;s-1){l=zr(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Ki(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=zr(e,i.head.line,"smart"));l&&wo(e,"electricInput",e,i.head.line)}}}function tt(e){for(var t=[],n=[],r=0;ri?u.map:c[i],l=0;li?e.line:e.rest[i]),h=o[l]+r;return(0>r||s!=t)&&(h=o[l+(r?1:0)]),Wl(a,h)}}}var i=e.text.firstChild,o=!1;if(!t||!_s(i,t))return st(Wl(Qi(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[n],n=0,!t)){var l=e.rest?Oo(e.rest):e.line;return st(Wl(Qi(l),l.text.length),o)}var s=3==t.nodeType?t:null,a=t;for(s||1!=t.childNodes.length||3!=t.firstChild.nodeType||(s=t.firstChild,n&&(n=s.nodeValue.length));a.parentNode!=i;)a=a.parentNode;var u=e.measure,c=u.maps,h=r(s,a,n);if(h)return st(h,o);for(var f=a.nextSibling,d=s?s.nodeValue.length-n:0;f;f=f.nextSibling){if(h=r(f,f.firstChild,0))return st(Wl(h.line,h.ch-d),o);d+=f.textContent.length}for(var p=a.previousSibling,d=n;p;p=p.previousSibling){if(h=r(p,p.firstChild,-1))return st(Wl(h.line,h.ch+d),o);d+=f.textContent.length}}function ct(e,t,n,r,i){function o(e){return function(t){return t.id==e}}function l(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(null!=n)return""==n&&(n=t.textContent.replace(/\u200b/g,"")),void(s+=n);var u,c=t.getAttribute("cm-marker");if(c){var h=e.findMarks(Wl(r,0),Wl(i+1,0),o(+c));return void(h.length&&(u=h[0].find())&&(s+=Xi(e.doc,u.from,u.to).join("\n")))}if("false"==t.getAttribute("contenteditable"))return;for(var f=0;f=0){var l=X(o.from(),i.from()),s=K(o.to(),i.to()),a=o.empty()?i.from()==i.head:o.from()==o.head;t>=r&&--t,e.splice(--r,2,new ft(a?s:l,a?l:s))}}return new ht(e,t)}function pt(e,t){return new ht([new ft(e,t||e)],0)}function gt(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function mt(e,t){if(t.linen?Wl(n,Ki(e,n).text.length):vt(t,Ki(e,t.line).text.length)}function vt(e,t){var n=e.ch;return null==n||n>t?Wl(e.line,t):0>n?Wl(e.line,0):e}function yt(e,t){return t>=e.first&&t=o.ch:u.to>o.ch))){if(r&&(Ms(c,"beforeCursorEnter"),c.explicitlyCleared)){if(s.markedSpans){--a;continue}break}if(!c.atomic)continue;var h=c.find(0>l?-1:1);if(0==Hl(h,o)&&(h.ch+=l,h.ch<0?h=h.line>e.first?mt(e,Wl(h.line-1)):null:h.ch>s.text.length&&(h=h.linet&&(t=0),t=Math.round(t),r=Math.round(r),s.appendChild(_o("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==n?c-e:n)+"px; height: "+(r-t)+"px"))}function i(t,n,i){function o(n,r){return fn(e,Wl(t,n),"div",h,r)}var s,a,h=Ki(l,t),f=h.text.length;return Qo(to(h),n||0,null==i?f:i,function(e,t,l){var h,d,p,g=o(e,"left");if(e==t)h=g,d=p=g.left;else{if(h=o(t-1,"right"),"rtl"==l){var m=g;g=h,h=m}d=g.left,p=h.right}null==n&&0==e&&(d=u),h.top-g.top>3&&(r(d,g.top,null,g.bottom),d=u,g.bottoma.bottom||h.bottom==a.bottom&&h.right>a.right)&&(a=h),u+1>d&&(d=u),r(d,h.top,p-d,h.bottom)}),{start:s,end:a}}var o=e.display,l=e.doc,s=document.createDocumentFragment(),a=Gt(e.display),u=a.left,c=Math.max(o.sizerWidth,jt(e)-o.sizer.offsetLeft)-a.right,h=t.from(),f=t.to();if(h.line==f.line)i(h.line,h.ch,f.ch);else{var d=Ki(l,h.line),p=Ki(l,f.line),g=gi(d)==gi(p),m=i(h.line,h.ch,g?d.text.length+1:null).end,v=i(f.line,g?0:null,f.ch).start;g&&(m.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 Pt(e,t){e.doc.mode.startState&&e.doc.frontier=e.display.viewTo)){var n=+new Date+e.options.workTime,r=ns(t.mode,Rt(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 l=o.styles,s=Di(e,o,r,!0);o.styles=s.styles;var a=o.styleClasses,u=s.classes;u?o.styleClasses=u:a&&(o.styleClasses=null);for(var c=!l||l.length!=o.styles.length||a!=u&&(!a||!u||a.bgClass!=u.bgClass||a.textClass!=u.textClass),h=0;!c&&hn?(Pt(e,e.options.workDelay),!0):void 0}),i.length&&An(e,function(){for(var t=0;tl;--s){if(s<=o.first)return o.first;var a=Ki(o,s-1);if(a.stateAfter&&(!n||s<=o.frontier))return s;var u=Hs(a.text,null,e.options.tabSize);(null==i||r>u)&&(i=s-1,r=u)}return i}function Rt(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return!0;var o=_t(e,t,n),l=o>r.first&&Ki(r,o-1).stateAfter;return l=l?ns(r.mode,l):rs(r.mode),r.iter(o,t,function(n){Hi(e,n.text,l);var s=o==t-1||o%5==0||o>=i.viewFrom&&o2&&o.push((a.bottom+u.top)/2-n.top)}}o.push(n.bottom-n.top)}}function Xt(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 Yt(e,t){t=gi(t);var n=Qi(t),r=e.display.externalMeasured=new Hn(e.doc,t,n);r.lineN=n;var i=r.built=Ii(e,r);return r.text=i.pre,qo(e.display.lineMeasure,i.pre),r}function Zt(e,t,n,r){return en(e,Jt(e,t),n,r)}function Qt(e,t){if(t>=e.display.viewFrom&&t=n.lineN&&tt?(i=0,o=1,l="left"):u>t?(i=t-a,o=i+1):(s==e.length-3||t==u&&e[s+3]>t)&&(o=u-a,i=o-1,t>=u&&(l="right")),null!=i){if(r=e[s+2],a==u&&n==(r.insertLeft?"left":"right")&&(l=n),"left"==n&&0==i)for(;s&&e[s-2]==e[s-3]&&e[s-1].insertLeft;)r=e[(s-=3)+2],l="left";if("right"==n&&i==u-a)for(;sc;c++){for(;s&&Bo(t.line.text.charAt(o.coverStart+s));)--s;for(;o.coverStart+agl&&0==s&&a==o.coverEnd-o.coverStart)i=l.parentNode.getBoundingClientRect();else if(pl&&e.options.lineWrapping){var h=Fs(l,s,a).getClientRects();i=h.length?h["right"==r?h.length-1:0]:Pl}else i=Fs(l,s,a).getBoundingClientRect()||Pl;if(i.left||i.right||0==s)break;a=s,s-=1,u="right"}pl&&11>gl&&(i=rn(e.display.measure,i))}else{s>0&&(u=r="right");var h;i=e.options.lineWrapping&&(h=l.getClientRects()).length>1?h["right"==r?h.length-1:0]:l.getBoundingClientRect()}if(pl&&9>gl&&!s&&(!i||!i.left&&!i.right)){var f=l.parentNode.getClientRects()[0];i=f?{left:f.left,right:f.left+bn(e.display),top:f.top,bottom:f.bottom}:Pl}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+p)/2,m=t.view.measure.heights,c=0;cn.from?l(e-1):l(e,r)}r=r||Ki(e.doc,t.line),i||(i=Jt(e,r));var a=to(r),u=t.ch;if(!a)return l(u);var c=sl(a,u),h=s(u,c);return null!=Qs&&(h.other=s(u,Qs)),h}function pn(e,t){var n=0,t=mt(e.doc,t);e.options.lineWrapping||(n=bn(e.display)*t.ch);var r=Ki(e.doc,t.line),i=eo(r)+qt(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function gn(e,t,n,r){var i=Wl(e,t);return i.xRel=r,n&&(i.outside=!0),i}function mn(e,t,n){var r=e.doc;if(n+=e.display.viewOffset,0>n)return gn(r.first,0,!0,-1);var i=Ji(r,n),o=r.first+r.size-1;if(i>o)return gn(r.first+r.size-1,Ki(r,o).text.length,!0,1);0>t&&(t=0);for(var l=Ki(r,i);;){var s=vn(e,l,i,t,n),a=di(l),u=a&&a.find(0,!0);if(!a||!(s.ch>u.from.ch||s.ch==u.from.ch&&s.xRel>0))return s;i=Qi(l=u.to.line)}}function vn(e,t,n,r,i){function o(r){var i=dn(e,Wl(n,r),"line",t,u);return s=!0,l>i.bottom?i.left-a:lm)return gn(n,d,v,1);for(;;){if(c?d==f||d==ul(t,f,1):1>=d-f){for(var y=p>r||m-r>=r-p?f:d,b=r-(y==f?p:m);Bo(t.text.charAt(y));)++y;var x=gn(n,y,y==f?g:v,-1>b?-1:b>1?1:0);return x}var w=Math.ceil(h/2),C=f+w;if(c){C=f;for(var k=0;w>k;++k)C=ul(t,C,1)}var S=o(C);S>r?(d=C,m=S,(v=s)&&(m+=1e3),h=w):(f=C,p=S,g=s,h-=w)}}function yn(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Il){Il=_o("pre");for(var t=0;49>t;++t)Il.appendChild(document.createTextNode("x")),Il.appendChild(_o("br"));Il.appendChild(document.createTextNode("x"))}qo(e.measure,Il);var n=Il.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),Ro(e.measure),n||1}function bn(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=_o("span","xxxxxxxxxx"),n=_o("pre",[t]);qo(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function xn(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:++_l},Bl?Bl.ops.push(e.curOp):e.curOp.ownsGroup=Bl={ops:[e.curOp],delayedCallbacks:[]}}function wn(e){var t=e.delayedCallbacks,n=0;do{for(;n=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new L(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Ln(e){e.updatedDisplay=e.mustUpdate&&T(e.cm,e.update)}function Mn(e){var t=e.cm,n=t.display;e.updatedDisplay&&D(t),e.barMeasure=p(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Zt(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+$t(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-jt(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function Tn(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLefto;o=r){var l=new Hn(e.doc,Ki(e.doc,o),o);r=o+l.size,i.push(l)}return i}function In(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)Dl&&vi(e.doc,t)i.viewFrom?zn(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)zn(e);else if(t<=i.viewFrom){var o=Bn(e,n,n+r,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=r):zn(e)}else if(n>=i.viewTo){var o=Bn(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):zn(e)}else{var l=Bn(e,t,t,-1),s=Bn(e,n,n+r,1);l&&s?(i.view=i.view.slice(0,l.index).concat(En(e,l.lineN,s.lineN)).concat(i.view.slice(s.index)),i.viewTo+=r):zn(e)}var a=i.externalMeasured;a&&(n=i.lineN&&t=r.viewTo)){var o=r.view[Pn(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==Do(l,n)&&l.push(n)}}}function zn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Pn(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 Bn(e,t,n,r){var i,o=Pn(e,t),l=e.display.view;if(!Dl||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var s=0,a=e.display.viewFrom;o>s;s++)a+=l[s].size;if(a!=t){if(r>0){if(o==l.length-1)return null;i=a+l[o].size-t,o++}else i=a-t;t+=i,n+=i}for(;vi(e.doc,n)!=n;){if(o==(0>r?0:l.length-1))return null;n+=r*l[o-(0>r?1:0)].size,o+=r}return{index:o,lineN:n}}function _n(e,t,n){var r=e.display,i=r.view;0==i.length||t>=r.viewTo||n<=r.viewFrom?(r.view=En(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=En(e,t,r.viewFrom).concat(r.view):r.viewFromn&&(r.view=r.view.slice(0,Pn(e,n)))),r.viewTo=n}function Rn(e){for(var t=e.display.view,n=0,r=0;r400}var i=e.display;Ss(i.scroller,"mousedown",On(e,Vn)),pl&&11>gl?Ss(i.scroller,"dblclick",On(e,function(t){if(!ko(e,t)){var n=jn(e,t);if(n&&!Qn(e,t)&&!$n(e.display,t)){ws(t);var r=e.findWordAt(n);wt(e.doc,r.anchor,r.head)}}})):Ss(i.scroller,"dblclick",function(t){ko(e,t)||ws(t)}),Al||Ss(i.scroller,"contextmenu",function(t){mr(e,t)});var o,l={end:0};Ss(i.scroller,"touchstart",function(e){if(!n(e)){clearTimeout(o);var t=+new Date;i.activeTouch={start:t,moved:!1,prev:t-l.end<=300?l:null},1==e.touches.length&&(i.activeTouch.left=e.touches[0].pageX,i.activeTouch.top=e.touches[0].pageY)}}),Ss(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),Ss(i.scroller,"touchend",function(n){var o=i.activeTouch;if(o&&!$n(i,n)&&null!=o.left&&!o.moved&&new Date-o.start<300){var l,s=e.coordsChar(i.activeTouch,"page");l=!o.prev||r(o,o.prev)?new ft(s,s):!o.prev.prev||r(o,o.prev.prev)?e.findWordAt(s):new ft(Wl(s.line,0),mt(e.doc,Wl(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),ws(n)}t()}),Ss(i.scroller,"touchcancel",t),Ss(i.scroller,"scroll",function(){i.scroller.clientHeight&&(tr(e,i.scroller.scrollTop),nr(e,i.scroller.scrollLeft,!0),Ms(e,"scroll",e))}),Ss(i.scroller,"mousewheel",function(t){rr(e,t)}),Ss(i.scroller,"DOMMouseScroll",function(t){rr(e,t)}),Ss(i.wrapper,"scroll",function(){i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={simple:function(t){ko(e,t)||ks(t)},start:function(t){er(e,t)},drop:On(e,Jn)};var s=i.input.getField();Ss(s,"keyup",function(t){hr.call(e,t)}),Ss(s,"keydown",On(e,ur)),Ss(s,"keypress",On(e,fr)),Ss(s,"focus",Fo(pr,e)),Ss(s,"blur",Fo(gr,e))}function Un(t,n,r){var i=r&&r!=e.Init;if(!n!=!i){var o=t.display.dragFunctions,l=n?Ss:Ls;l(t.display.scroller,"dragstart",o.start),l(t.display.scroller,"dragenter",o.simple),l(t.display.scroller,"dragover",o.simple),l(t.display.scroller,"drop",o.drop)}}function Gn(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 $n(e,t){for(var n=bo(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 jn(e,t,n,r){var i=e.display;if(!n&&"true"==bo(t).getAttribute("cm-not-content"))return null;var o,l,s=i.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,l=t.clientY-s.top}catch(t){return null}var a,u=mn(e,o,l);if(r&&1==u.xRel&&(a=Ki(e.doc,u.line).text).length==u.ch){var c=Hs(a,a.length,e.options.tabSize)-a.length;u=Wl(u.line,Math.max(0,Math.round((o-Gt(e.display).left)/bn(e.display))-c))}return u}function Vn(e){var t=this,n=t.display;if(!(n.activeTouch&&n.input.supportsTouch()||ko(t,e))){if(n.shift=e.shiftKey,$n(n,e))return void(ml||(n.scroller.draggable=!1,setTimeout(function(){n.scroller.draggable=!0},100)));if(!Qn(t,e)){var r=jn(t,e);switch(window.focus(),xo(e)){case 1:r?Kn(t,e,r):bo(e)==n.scroller&&ws(e);break;case 2:ml&&(t.state.lastMiddleDown=+new Date),r&&wt(t.doc,r),setTimeout(function(){n.input.focus()},20),ws(e);break;case 3:Al?mr(t,e):dr(t)}}}}function Kn(e,t,n){pl?setTimeout(Fo(Y,e),0):e.curOp.focus=Uo();var r,i=+new Date;zl&&zl.time>i-400&&0==Hl(zl.pos,n)?r="triple":Fl&&Fl.time>i-400&&0==Hl(Fl.pos,n)?(r="double",zl={time:i,pos:n}):(r="single",Fl={time:i,pos:n});var o,l=e.doc.sel,s=Ll?t.metaKey:t.ctrlKey;e.options.dragDrop&&js&&!Z(e)&&"single"==r&&(o=l.contains(n))>-1&&(Hl((o=l.ranges[o]).from(),n)<0||n.xRel>0)&&(Hl(o.to(),n)>0||n.xRel<0)?Xn(e,t,n,s):Yn(e,t,n,r,s)}function Xn(e,t,n,r){var i=e.display,o=+new Date,l=On(e,function(s){ml&&(i.scroller.draggable=!1),e.state.draggingText=!1,Ls(document,"mouseup",l),Ls(i.scroller,"drop",l),Math.abs(t.clientX-s.clientX)+Math.abs(t.clientY-s.clientY)<10&&(ws(s),!r&&+new Date-200=p;p++){var v=Ki(u,p).text,y=No(v,a,o);a==d?i.push(new ft(Wl(p,y),Wl(p,y))):v.length>y&&i.push(new ft(Wl(p,y),Wl(p,No(v,d,o))))}i.length||i.push(new ft(n,n)),Tt(u,dt(f.ranges.slice(0,h).concat(i),h),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=c,x=b.anchor,w=t;if("single"!=r){if("double"==r)var C=e.findWordAt(t);else var C=new ft(Wl(t.line,0),mt(u,Wl(t.line+1,0)));Hl(C.anchor,x)>0?(w=C.head,x=X(b.from(),C.anchor)):(w=C.anchor,x=K(b.to(),C.head))}var i=f.ranges.slice(0);i[h]=new ft(mt(u,x),w),Tt(u,dt(i,h),Ds)}}function l(t){var n=++y,i=jn(e,t,!0,"rect"==r);if(i)if(0!=Hl(i,m)){e.curOp.focus=Uo(),o(i);var s=x(a,u);(i.line>=s.to||i.linev.bottom?20:0;c&&setTimeout(On(e,function(){y==n&&(a.scroller.scrollTop+=c,l(t))}),50)}}function s(e){y=1/0,ws(e),a.input.focus(),Ls(document,"mousemove",b),Ls(document,"mouseup",w),u.history.lastSelOrigin=null}var a=e.display,u=e.doc;ws(t);var c,h,f=u.sel,d=f.ranges;if(i&&!t.shiftKey?(h=u.sel.contains(n),c=h>-1?d[h]:new ft(n,n)):(c=u.sel.primary(),h=u.sel.primIndex),t.altKey)r="rect",i||(c=new ft(n,n)),n=jn(e,t,!0,!0),h=-1;else if("double"==r){var p=e.findWordAt(n);c=e.display.shift||u.extend?xt(u,c,p.anchor,p.head):p}else if("triple"==r){var g=new ft(Wl(n.line,0),mt(u,Wl(n.line+1,0)));c=e.display.shift||u.extend?xt(u,c,g.anchor,g.head):g}else c=xt(u,c,n);i?-1==h?(h=d.length,Tt(u,dt(d.concat([c]),h),{scroll:!1,origin:"*mouse"})):d.length>1&&d[h].empty()&&"single"==r&&!t.shiftKey?(Tt(u,dt(d.slice(0,h).concat(d.slice(h+1)),0)),f=u.sel):kt(u,h,c,Ds):(h=0,Tt(u,new ht([c],0),Ds),f=u.sel);var m=n,v=a.wrapper.getBoundingClientRect(),y=0,b=On(e,function(e){xo(e)?l(e):s(e)}),w=On(e,s);Ss(document,"mousemove",b),Ss(document,"mouseup",w)}function Zn(e,t,n,r,i){try{var o=t.clientX,l=t.clientY}catch(t){return!1}if(o>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&ws(t);var s=e.display,a=s.lineDiv.getBoundingClientRect();if(l>a.bottom||!Lo(e,n))return yo(t);l-=a.top-s.viewOffset;for(var u=0;u=o){var h=Ji(e.doc,l),f=e.options.gutters[u];return i(e,n,e,h,f,t),yo(t)}}}function Qn(e,t){return Zn(e,t,"gutterClick",!0,wo)}function Jn(e){var t=this;if(!ko(t,e)&&!$n(t.display,e)){ws(e),pl&&(Rl=+new Date);var n=jn(t,e,!0),r=e.dataTransfer.files;if(n&&!Z(t))if(r&&r.length&&window.FileReader&&window.File)for(var i=r.length,o=Array(i),l=0,s=function(e,r){var s=new FileReader;s.onload=On(t,function(){if(o[r]=s.result,++l==i){n=mt(t.doc,n);var e={from:n,to:n,text:Vs(o.join("\n")),origin:"paste"};kr(t.doc,e),Mt(t.doc,pt(n,Vl(e)))}}),s.readAsText(e)},a=0;i>a;++a)s(r[a],a);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&&!(Ll?e.altKey:e.ctrlKey))var u=t.listSelections();if(Nt(t.doc,pt(n,n)),u)for(var a=0;al.clientWidth||i&&l.scrollHeight>l.clientHeight){if(i&&Ll&&ml)e:for(var s=t.target,a=o.view;s!=l;s=s.parentNode)for(var u=0;uc?h=Math.max(0,h+c-50):f=Math.min(e.doc.height,f+c+50),A(e,{top:h,bottom:f})}20>ql&&(null==o.wheelStartX?(o.wheelStartX=l.scrollLeft,o.wheelStartY=l.scrollTop,o.wheelDX=r,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=l.scrollLeft-o.wheelStartX,t=l.scrollTop-o.wheelStartY,n=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,n&&(Ul=(Ul*ql+n)/(ql+1),++ql)}},200)):(o.wheelDX+=r,o.wheelDY+=i))}}function ir(e,t,n){if("string"==typeof t&&(t=is[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,i=!1;try{Z(e)&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),i=t(e)!=As}finally{e.display.shift=r,e.state.suppressEdits=!1}return i}function or(e,t,n){for(var r=0;rgl&&27==e.keyCode&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=16==n||e.shiftKey;var r=sr(t,e);bl&&(jl=r?n:null,!r&&88==n&&!Xs&&(Ll?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=n||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||cr(t)}}function cr(e){function t(e){18!=e.keyCode&&e.altKey||(Us(n,"CodeMirror-crosshair"),Ls(document,"keyup",t),Ls(document,"mouseover",t))}var n=e.display.lineDiv;Gs(n,"CodeMirror-crosshair"),Ss(document,"keyup",t),Ss(document,"mouseover",t)}function hr(e){16==e.keyCode&&(this.doc.sel.shift=!1),ko(this,e)}function fr(e){var t=this;if(!($n(t.display,e)||ko(t,e)||e.ctrlKey&&!e.altKey||Ll&&e.metaKey)){var n=e.keyCode,r=e.charCode;if(bl&&n==jl)return jl=null,void ws(e);if(!bl||e.which&&!(e.which<10)||!sr(t,e)){var i=String.fromCharCode(null==r?n:r);ar(t,e,i)||t.display.input.onKeyPress(e)}}}function dr(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,gr(e))},100)}function pr(e){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Ms(e,"focus",e),e.state.focused=!0,Gs(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),ml&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),zt(e))}function gr(e){e.state.delayingBlurEvent||(e.state.focused&&(Ms(e,"blur",e),e.state.focused=!1,Us(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function mr(e,t){$n(e.display,t)||vr(e,t)||e.display.input.onContextMenu(t)}function vr(e,t){return Lo(e,"gutterContextMenu")?Zn(e,t,"gutterContextMenu",!1,Ms):!1}function yr(e,t){if(Hl(e,t.from)<0)return e;if(Hl(e,t.to)<=0)return Vl(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+=Vl(t).ch-t.to.ch),Wl(n,r)}function br(e,t){for(var n=[],r=0;r=0;--i)Sr(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text});else Sr(e,t)}}function Sr(e,t){if(1!=t.text.length||""!=t.text[0]||0!=Hl(t.from,t.to)){var n=br(e,t);lo(e,t,n,e.cm?e.cm.curOp.id:0/0),Tr(e,t,n,ni(e,t));var r=[];ji(e,function(e,n){n||-1!=Do(r,e.history)||(vo(e.history,t),r.push(e.history)),Tr(e,t,null,ni(e,t))})}}function Lr(e,t,n){if(!e.cm||!e.cm.state.suppressEdits){for(var r,i=e.history,o=e.sel,l="undo"==t?i.done:i.undone,s="undo"==t?i.undone:i.done,a=0;a=0;--a){var h=r.changes[a];if(h.origin=t,c&&!Cr(e,h,!1))return void(l.length=0);u.push(ro(e,h));var f=a?br(e,h):Oo(l);Tr(e,h,f,ii(e,h)),!a&&e.cm&&e.cm.scrollIntoView({from:h.from,to:Vl(h)});var d=[];ji(e,function(e,t){t||-1!=Do(d,e.history)||(vo(e.history,h),d.push(e.history)),Tr(e,h,null,ii(e,h))})}}}}function Mr(e,t){if(0!=t&&(e.first+=t,e.sel=new ht(Wo(e.sel.ranges,function(e){return new ft(Wl(e.anchor.line+t,e.anchor.ch),Wl(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){In(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:Wl(o,Ki(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Xi(e,t.from,t.to),n||(n=br(e,t)),e.cm?Nr(e.cm,t,r):Ui(e,t,r),Nt(e,n,Os)}}function Nr(e,t,n){var r=e.doc,i=e.display,l=t.from,s=t.to,a=!1,u=l.line;e.options.lineWrapping||(u=Qi(gi(Ki(r,l.line))),r.iter(u,s.line+1,function(e){return e==i.maxLine?(a=!0,!0):void 0})),r.sel.contains(t.from,t.to)>-1&&So(e),Ui(r,t,n,o(e)),e.options.lineWrapping||(r.iter(u,l.line+t.text.length,function(e){var t=h(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,a=!1) }),a&&(e.curOp.updateMaxLine=!0)),r.frontier=Math.min(r.frontier,l.line),Pt(e,400);var c=t.text.length-(s.line-l.line)-1;t.full?In(e):l.line!=s.line||1!=t.text.length||qi(e.doc,t)?In(e,l.line,s.line+1,c):Fn(e,l.line,"text");var f=Lo(e,"changes"),d=Lo(e,"change");if(d||f){var p={from:l,to:s,text:t.text,removed:t.removed,origin:t.origin};d&&wo(e,"change",e,p),f&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function Ar(e,t,n,r,i){if(r||(r=n),Hl(r,n)<0){var o=r;r=n,n=o}"string"==typeof t&&(t=Vs(t)),kr(e,{from:n,to:r,text:t,origin:i})}function Or(e,t){if(!ko(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&&!Cl){var o=_o("div","​",null,"position: absolute; top: "+(t.top-n.viewOffset-qt(e.display))+"px; height: "+(t.bottom-t.top+$t(e)+n.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Dr(e,t,n,r){null==r&&(r=0);for(var i=0;5>i;i++){var o=!1,l=dn(e,t),s=n&&n!=t?dn(e,n):l,a=Hr(e,Math.min(l.left,s.left),Math.min(l.top,s.top)-r,Math.max(l.left,s.left),Math.max(l.bottom,s.bottom)+r),u=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop&&(tr(e,a.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(o=!0)),null!=a.scrollLeft&&(nr(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-c)>1&&(o=!0)),!o)break}return l}function Wr(e,t,n,r,i){var o=Hr(e,t,n,r,i);null!=o.scrollTop&&tr(e,o.scrollTop),null!=o.scrollLeft&&nr(e,o.scrollLeft)}function Hr(e,t,n,r,i){var o=e.display,l=yn(e.display);0>n&&(n=0);var s=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,a=Vt(e),u={};i-n>a&&(i=n+a);var c=e.doc.height+Ut(o),h=l>n,f=i>c-l;if(s>n)u.scrollTop=h?0:n;else if(i>s+a){var d=Math.min(n,(f?c:i)-a);d!=s&&(u.scrollTop=d)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,g=jt(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),m=r-t>g;return m&&(r=t+g),10>t?u.scrollLeft=0:p>t?u.scrollLeft=Math.max(0,t-(m?0:10)):r>g+p-3&&(u.scrollLeft=r+(m?0:10)-g),u}function Er(e,t,n){(null!=t||null!=n)&&Fr(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 Ir(e){Fr(e);var t=e.getCursor(),n=t,r=t;e.options.lineWrapping||(n=t.ch?Wl(t.line,t.ch-1):t,r=Wl(t.line,t.ch+1)),e.curOp.scrollToPos={from:n,to:r,margin:e.options.cursorScrollMargin,isCursor:!0}}function Fr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=pn(e,t.from),r=pn(e,t.to),i=Hr(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 zr(e,t,n,r){var i,o=e.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?i=Rt(e,t):n="prev");var l=e.options.tabSize,s=Ki(o,t),a=Hs(s.text,null,l);s.stateAfter&&(s.stateAfter=null);var u,c=s.text.match(/^\s*/)[0];if(r||/\S/.test(s.text)){if("smart"==n&&(u=o.mode.indent(i,s.text.slice(c.length),s.text),u==As||u>150)){if(!r)return;n="prev"}}else u=0,n="not";"prev"==n?u=t>o.first?Hs(Ki(o,t-1).text,null,l):0:"add"==n?u=a+e.options.indentUnit:"subtract"==n?u=a-e.options.indentUnit:"number"==typeof n&&(u=a+n),u=Math.max(0,u);var h="",f=0;if(e.options.indentWithTabs)for(var d=Math.floor(u/l);d;--d)f+=l,h+=" ";if(u>f&&(h+=Ao(u-f)),h!=c)return Ar(o,h,Wl(t,0),Wl(t,c.length),"+input"),s.stateAfter=null,!0;for(var d=0;d=0;t--)Ar(e.doc,"",r[t].from,r[t].to,"+delete");Ir(e)})}function _r(e,t,n,r,i){function o(){var t=s+n;return t=e.first+e.size?h=!1:(s=t,c=Ki(e,t))}function l(e){var t=(i?ul:cl)(c,a,n,!0);if(null==t){if(e||!o())return h=!1;a=i?(0>n?nl:tl)(c):0>n?c.text.length:0}else a=t;return!0}var s=t.line,a=t.ch,u=n,c=Ki(e,s),h=!0;if("char"==r)l();else if("column"==r)l(!0);else if("word"==r||"group"==r)for(var f=null,d="group"==r,p=e.cm&&e.cm.getHelper(t,"wordChars"),g=!0;!(0>n)||l(!g);g=!1){var m=c.text.charAt(a)||"\n",v=zo(m,p)?"w":d&&"\n"==m?"n":!d||/\s/.test(m)?null:"p";if(!d||g||v||(v="s"),f&&f!=v){0>n&&(n=1,l());break}if(v&&(f=v),n>0&&!l(!g))break}var y=Wt(e,Wl(s,a),u,!0);return h||(y.hitSide=!0),y}function Rr(e,t,n,r){var i,o=e.doc,l=t.left;if("page"==r){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=t.top+n*(s-(0>n?1.5:.5)*yn(e.display))}else"line"==r&&(i=n>0?t.bottom+3:t.top-3);for(;;){var a=mn(e,l,i);if(!a.outside)break;if(0>n?0>=i:i>=o.height){a.hitSide=!0;break}i+=5*n}return a}function qr(t,n,r,i){e.defaults[t]=n,r&&(Xl[t]=i?function(e,t,n){n!=Yl&&r(e,t,n)}:r)}function Ur(e){for(var t,n,r,i,o=e.split(/-(?!$)/),e=o[o.length-1],l=0;l0||0==l&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=_o("span",[o.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(pi(e,t.line,t,n,o)||t.line!=n.line&&pi(e,n.line,t,n,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Dl=!0}o.addToHistory&&lo(e,{from:t,to:n,origin:"markText"},e.sel,0/0);var s,a=t.line,u=e.cm;if(e.iter(a,n.line+1,function(e){u&&o.collapsed&&!u.options.lineWrapping&&gi(e)==u.display.maxLine&&(s=!0),o.collapsed&&a!=t.line&&Zi(e,0),Jr(e,new Yr(o,a==t.line?t.ch:null,a==n.line?n.ch:null)),++a}),o.collapsed&&e.iter(t.line,n.line+1,function(t){bi(e,t)&&Zi(t,0)}),o.clearOnEnter&&Ss(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(Ol=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++cs,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)In(u,t.line,n.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var c=t.line;c<=n.line;c++)Fn(u,c,"text");o.atomic&&Ot(u.doc),wo(u,"markerAdded",u,o)}return o}function jr(e,t,n,r,i){r=Io(r),r.shared=!1;var o=[$r(e,t,n,r,i)],l=o[0],s=r.widgetNode;return ji(e,function(e){s&&(r.widgetNode=s.cloneNode(!0)),o.push($r(e,mt(e,t),mt(e,n),r,i));for(var a=0;a=t:o.to>t);(r||(r=[])).push(new Yr(l,o.from,a?null:o.to))}}return r}function ti(e,t,n){if(e)for(var r,i=0;i=t:o.to>t);if(s||o.from==t&&"bookmark"==l.type&&(!n||o.marker.insertLeft)){var a=null==o.from||(l.inclusiveLeft?o.from<=t:o.from0&&s)for(var h=0;hh;++h)p.push(g);p.push(a)}return p}function ri(e){for(var t=0;t0)){var c=[a,1],h=Hl(u.from,s.from),f=Hl(u.to,s.to);(0>h||!l.inclusiveLeft&&!h)&&c.push({from:u.from,to:s.from}),(f>0||!l.inclusiveRight&&!f)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-1}}return i}function li(e){var t=e.markedSpans;if(t){for(var n=0;n=0&&0>=h||0>=c&&h>=0)&&(0>=c&&(Hl(u.to,n)>0||a.marker.inclusiveRight&&i.inclusiveLeft)||c>=0&&(Hl(u.from,r)<0||a.marker.inclusiveLeft&&i.inclusiveRight)))return!0}}}function gi(e){for(var t;t=fi(e);)e=t.find(-1,!0).line;return e}function mi(e){for(var t,n;t=di(e);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function vi(e,t){var n=Ki(e,t),r=gi(n);return n==r?t:Qi(r)}function yi(e,t){if(t>e.lastLine())return t;var n,r=Ki(e,t);if(!bi(e,r))return t;for(;n=di(r);)r=n.find(1,!0).line;return Qi(r)+1}function bi(e,t){var n=Dl&&t.markedSpans;if(n)for(var r,i=0;io;o++){i&&(i[0]=e.innerMode(t,r).mode);var l=t.token(n,r);if(n.pos>n.start)return l}throw new Error("Mode "+t.name+" failed to advance stream.")}function Ai(e,t,n,r){function i(e){return{start:h.start,end:h.pos,string:h.current(),type:o||null,state:e?ns(l.mode,c):c}}var o,l=e.doc,s=l.mode;t=mt(l,t);var a,u=Ki(l,t.line),c=Rt(e,t.line,n),h=new us(u.text,e.options.tabSize);for(r&&(a=[]);(r||h.pose.options.maxHighlightLength?(s=!1,l&&Hi(e,t,r,h.pos),h.pos=t.length,a=null):a=Mi(Ni(n,h,r,f),o),f){var d=f[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;uu;){var r=i[a];r>e&&i.splice(a,1,e,i[a+1],r),a+=2,u=Math.min(e,r)}if(t)if(s.opaque)i.splice(n,a-n,e,"cm-overlay "+t),a=n+2;else for(;a>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 Wi(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=Di(e,t,t.stateAfter=Rt(e,Qi(t)));t.styles=r.styles,r.classes?t.styleClasses=r.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.frontier&&e.doc.frontier++}return t.styles}function Hi(e,t,n,r){var i=e.doc.mode,o=new us(t,e.options.tabSize);for(o.start=o.pos=r||0,""==t&&Ti(i,n);!o.eol()&&o.pos<=e.options.maxHighlightLength;)Ni(i,o,n),o.start=o.pos}function Ei(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?ms:gs;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Ii(e,t){var n=_o("span",null,null,ml?"padding-right: .1px":null),r={pre:_o("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,splitSpaces:(pl||ml)&&e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,l=i?t.rest[i-1]:t.line;r.pos=0,r.addToken=zi,Yo(e.display.measure)&&(o=to(l))&&(r.addToken=Bi(r.addToken,o)),r.map=[];var s=t!=e.display.externalMeasured&&Qi(l);Ri(l,r,Wi(e,l,s)),l.styleClasses&&(l.styleClasses.bgClass&&(r.bgClass=$o(l.styleClasses.bgClass,r.bgClass||"")),l.styleClasses.textClass&&(r.textClass=$o(l.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(Xo(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 ml&&/\bcm-tab\b/.test(r.content.lastChild.className)&&(r.content.className="cm-tab-wrap-hack"),Ms(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=$o(r.pre.className,r.textClass||"")),r}function Fi(e){var t=_o("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function zi(e,t,n,r,i,o,l){if(t){var s=e.splitSpaces?t.replace(/ {3,}/g,Pi):t,a=e.cm.state.specialChars,u=!1;if(a.test(t))for(var c=document.createDocumentFragment(),h=0;;){a.lastIndex=h;var f=a.exec(t),d=f?f.index-h:t.length-h;if(d){var p=document.createTextNode(s.slice(h,h+d));c.appendChild(pl&&9>gl?_o("span",[p]):p),e.map.push(e.pos,e.pos+d,p),e.col+=d,e.pos+=d}if(!f)break;if(h+=d+1," "==f[0]){var g=e.cm.options.tabSize,m=g-e.col%g,p=c.appendChild(_o("span",Ao(m),"cm-tab"));p.setAttribute("role","presentation"),p.setAttribute("cm-text"," "),e.col+=m}else{var p=e.cm.options.specialCharPlaceholder(f[0]);p.setAttribute("cm-text",f[0]),c.appendChild(pl&&9>gl?_o("span",[p]):p),e.col+=1}e.map.push(e.pos,e.pos+1,p),e.pos++}else{e.col+=t.length;var c=document.createTextNode(s);e.map.push(e.pos,e.pos+t.length,c),pl&&9>gl&&(u=!0),e.pos+=t.length}if(n||r||i||u||l){var v=n||"";r&&(v+=r),i&&(v+=i);var y=_o("span",[c],v,l);return o&&(y.title=o),e.content.appendChild(y)}e.content.appendChild(c)}}function Pi(e){for(var t=" ",n=0;nu&&f.from<=u)break}if(f.to>=c)return e(n,r,i,o,l,s,a);e(n,r.slice(0,f.to-u),i,o,null,s,a),o=null,r=r.slice(f.to-u),u=f.to}}}function _i(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 Ri(e,t,n){var r=e.markedSpans,i=e.text,o=0;if(r)for(var l,s,a,u,c,h,f,d=i.length,p=0,g=1,m="",v=0;;){if(v==p){a=u=c=h=s="",f=null,v=1/0;for(var y=[],b=0;bp||w.collapsed&&x.to==p&&x.from==p)?(null!=x.to&&x.to!=p&&v>x.to&&(v=x.to,u=""),w.className&&(a+=" "+w.className),w.css&&(s=w.css),w.startStyle&&x.from==p&&(c+=" "+w.startStyle),w.endStyle&&x.to==v&&(u+=" "+w.endStyle),w.title&&!h&&(h=w.title),w.collapsed&&(!f||ci(f.marker,w)<0)&&(f=x)):x.from>p&&v>x.from&&(v=x.from)}if(f&&(f.from||0)==p){if(_i(t,(null==f.to?d+1:f.to)-p,f.marker,null==f.from),null==f.to)return;f.to==p&&(f=!1)}if(!f&&y.length)for(var b=0;b=d)break;for(var C=Math.min(d,v);;){if(m){var k=p+m.length;if(!f){var S=k>C?m.slice(0,C-p):m;t.addToken(t,S,l?l+a:a,c,p+S.length==v?u:"",h,s)}if(k>=C){m=m.slice(C-p),p=C;break}p=k,c=""}m=i.slice(o,o=n[g++]),l=Ei(n[g++],t.cm.options)}}else for(var g=1;gn;++n)o.push(new ps(u[n],i(n),r));return o}var s=t.from,a=t.to,u=t.text,c=Ki(e,s.line),h=Ki(e,a.line),f=Oo(u),d=i(u.length-1),p=a.line-s.line;if(t.full)e.insert(0,l(0,u.length)),e.remove(u.length,e.size-u.length);else if(qi(e,t)){var g=l(0,u.length-1);o(h,h.text,d),p&&e.remove(s.line,p),g.length&&e.insert(s.line,g)}else if(c==h)if(1==u.length)o(c,c.text.slice(0,s.ch)+f+c.text.slice(a.ch),d);else{var g=l(1,u.length-1);g.push(new ps(f+c.text.slice(a.ch),d,r)),o(c,c.text.slice(0,s.ch)+u[0],i(0)),e.insert(s.line+1,g)}else if(1==u.length)o(c,c.text.slice(0,s.ch)+u[0]+h.text.slice(a.ch),i(0)),e.remove(s.line+1,p);else{o(c,c.text.slice(0,s.ch)+u[0],i(0)),o(h,f+h.text.slice(a.ch),d);var g=l(1,u.length-1);p>1&&e.remove(s.line+1,p-1),e.insert(s.line+1,g)}wo(e,"change",e,t)}function Gi(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 Xi(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 Yi(e,t,n){var r=[];return e.iter(t,n,function(e){r.push(e.text)}),r}function Zi(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function Qi(e){if(null==e.parent)return null;for(var t=e.parent,n=Do(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 Ji(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-=s}return n+r}function eo(e){e=gi(e);for(var t=0,n=e.parent,r=0;r1&&!e.done[e.done.length-2].ranges?(e.done.pop(),Oo(e.done)):void 0}function lo(e,t,n,r){var i=e.history;i.undone.length=0;var o,l=+new Date;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>l-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=oo(i,i.lastOp==r))){var s=Oo(o.changes);0==Hl(t.from,t.to)&&0==Hl(t.from,s.to)?s.to=Vl(t):o.changes.push(ro(e,t))}else{var a=Oo(i.done);for(a&&a.ranges||uo(e.sel,i.done),o={changes:[ro(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=l,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,s||Ms(e,"historyAdded")}function so(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 ao(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||so(e,o,Oo(i.done),t))?i.done[i.done.length-1]=t:uo(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=n,r&&r.clearRedo!==!1&&io(i.undone)}function uo(e,t){var n=Oo(t);n&&n.ranges&&n.equals(e)||t.push(e)}function co(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 ho(e){if(!e)return null;for(var t,n=0;n-1&&(Oo(s)[h]=c[h],delete c[h])}}}return i}function go(e,t,n,r){n0}function Mo(e){e.prototype.on=function(e,t){Ss(this,e,t)},e.prototype.off=function(e,t){Ls(this,e,t)}}function To(){this.id=null}function No(e,t,n){for(var r=0,i=0;;){var o=e.indexOf(" ",r);-1==o&&(o=e.length);var l=o-r;if(o==e.length||i+l>=t)return r+Math.min(l,t-i);if(i+=o-r,i+=n-i%n,r=o+1,i>=t)return r}}function Ao(e){for(;Es.length<=e;)Es.push(Oo(Es)+" ");return Es[e]}function Oo(e){return e[e.length-1]}function Do(e,t){for(var n=0;n-1&&Ps(e)?!0:t.test(e):Ps(e)}function Po(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Bo(e){return e.charCodeAt(0)>=768&&Bs.test(e)}function _o(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 qo(e,t){return Ro(e).appendChild(t)}function Uo(){return document.activeElement}function Go(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function $o(e,t){for(var n=e.split(" "),r=0;r2&&!(pl&&8>gl))}var n=Rs?_o("span","​"):_o("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function Yo(e){if(null!=qs)return qs;var t=qo(e,document.createTextNode("AخA")),n=Fs(t,0,1).getBoundingClientRect();if(!n||n.left==n.right)return!1;var r=Fs(t,1,2).getBoundingClientRect();return qs=r.right-n.right<3}function Zo(e){if(null!=Ys)return Ys;var t=qo(e,_o("span","x")),n=t.getBoundingClientRect(),r=Fs(t,0,1).getBoundingClientRect();return Ys=Math.abs(n.left-r.left)>1}function Qo(e,t,n,r){if(!e)return r(t,n,"ltr");for(var i=!1,o=0;ot||t==n&&l.to==t)&&(r(Math.max(l.from,t),Math.min(l.to,n),1==l.level?"rtl":"ltr"),i=!0)}i||r(t,n,"ltr")}function Jo(e){return e.level%2?e.to:e.from}function el(e){return e.level%2?e.from:e.to}function tl(e){var t=to(e);return t?Jo(t[0]):0}function nl(e){var t=to(e);return t?el(Oo(t)):e.text.length}function rl(e,t){var n=Ki(e.doc,t),r=gi(n);r!=n&&(t=Qi(r));var i=to(r),o=i?i[0].level%2?nl(r):tl(r):0;return Wl(t,o)}function il(e,t){for(var n,r=Ki(e.doc,t);n=di(r);)r=n.find(1,!0).line,t=null;var i=to(r),o=i?i[0].level%2?tl(r):nl(r):r.text.length;return Wl(null==t?Qi(r):t,o)}function ol(e,t){var n=rl(e,t.line),r=Ki(e.doc,n.line),i=to(r);if(!i||0==i[0].level){var o=Math.max(0,r.text.search(/\S/)),l=t.line==n.line&&t.ch<=o&&t.ch;return Wl(n.line,l?0:o)}return n}function ll(e,t,n){var r=e[0].level;return t==r?!0:n==r?!1:n>t}function sl(e,t){Qs=null;for(var n,r=0;rt)return r;if(i.from==t||i.to==t){if(null!=n)return ll(e,i.level,e[n].level)?(i.from!=i.to&&(Qs=n),r):(i.from!=i.to&&(Qs=r),n);n=r}}return n}function al(e,t,n,r){if(!r)return t+n;do t+=n;while(t>0&&Bo(e.text.charAt(t)));return t}function ul(e,t,n,r){var i=to(e);if(!i)return cl(e,t,n,r);for(var o=sl(i,t),l=i[o],s=al(e,t,l.level%2?-n:n,r);;){if(s>l.from&&s0==l.level%2?l.to:l.from);if(l=i[o+=n],!l)return null;s=n>0==l.level%2?al(e,l.to,-1,r):al(e,l.from,1,r)}}function cl(e,t,n,r){var i=t+n;if(r)for(;i>0&&Bo(e.text.charAt(i));)i+=n;return 0>i||i>e.text.length?null:i}var hl=/gecko\/\d/i.test(navigator.userAgent),fl=/MSIE \d/.test(navigator.userAgent),dl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),pl=fl||dl,gl=pl&&(fl?document.documentMode||6:dl[1]),ml=/WebKit\//.test(navigator.userAgent),vl=ml&&/Qt\/\d+\.\d+/.test(navigator.userAgent),yl=/Chrome\//.test(navigator.userAgent),bl=/Opera\//.test(navigator.userAgent),xl=/Apple Computer/.test(navigator.vendor),wl=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),Cl=/PhantomJS/.test(navigator.userAgent),kl=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),Sl=kl||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),Ll=kl||/Mac/.test(navigator.platform),Ml=/win/i.test(navigator.platform),Tl=bl&&navigator.userAgent.match(/Version\/(\d*\.\d*)/); Tl&&(Tl=Number(Tl[1])),Tl&&Tl>=15&&(bl=!1,ml=!0);var Nl=Ll&&(vl||bl&&(null==Tl||12.11>Tl)),Al=hl||pl&&gl>=9,Ol=!1,Dl=!1;g.prototype=Io({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.checkedOverlay&&e.clientHeight>0&&(0==r&&this.overlayHack(),this.checkedOverlay=!0),{right:n?r:0,bottom:t?r:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e)},overlayHack:function(){var e=Ll&&!wl?"12px":"18px";this.horiz.style.minHeight=this.vert.style.minWidth=e;var t=this,n=function(e){bo(e)!=t.vert&&bo(e)!=t.horiz&&On(t.cm,Vn)(e)};Ss(this.vert,"mousedown",n),Ss(this.horiz,"mousedown",n)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},g.prototype),m.prototype=Io({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},m.prototype),e.scrollbarModel={"native":g,"null":m},L.prototype.signal=function(e,t){Lo(e,t)&&this.events.push(arguments)},L.prototype.finish=function(){for(var e=0;e=9&&n.hasSelection&&(n.hasSelection=null),n.poll()}),Ss(o,"paste",function(e){return J(e,r)?!0:(r.state.pasteIncoming=!0,void n.fastPoll())}),Ss(o,"cut",t),Ss(o,"copy",t),Ss(e.scroller,"paste",function(t){$n(e,t)||(r.state.pasteIncoming=!0,n.focus())}),Ss(e.lineSpace,"selectstart",function(t){$n(e,t)||ws(t)}),Ss(o,"compositionstart",function(){var e=r.getCursor("from");n.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Ss(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=Et(e);if(e.options.moveInputWithCursor){var i=dn(e,n.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+l.top-o.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+l.left-o.left))}return r},showSelection:function(e){var t=this.cm,n=t.display;qo(n.cursorDiv,e.cursors),qo(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=Xs&&(o.to().line-o.from().line>100||(n=r.getSelection()).length>1e3);var l=t?"-":n||r.getSelection();this.textarea.value=l,r.state.focused&&Is(this.textarea),pl&&gl>=9&&(this.hasSelection=l)}else e||(this.prevInput=this.textarea.value="",pl&&gl>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!Sl||Uo()!=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||Ks(t)&&!n||Z(e)||e.options.disableInput||e.state.keySeq)return!1;var r=t.value;if(r==n&&!e.somethingSelected())return!1;if(pl&&gl>=9&&this.hasSelection===r||Ll&&/[\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,l=Math.min(n.length,r.length);l>o&&n.charCodeAt(o)==r.charCodeAt(o);)++o;var s=this;return An(e,function(){Q(e,r.slice(o),n.length-o,null,s.composing?"*compose":null),r.length>1e3||r.indexOf("\n")>-1?t.value=s.prevInput="":s.prevInput=r,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(){pl&&gl>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=l.selectionStart){var e=i.somethingSelected(),t="​"+(e?l.value:"");l.value="⇚",l.value=t,r.prevInput=e?"":"​",l.selectionStart=1,l.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function n(){if(r.contextMenuPending=!1,r.wrapper.style.position="relative",l.style.cssText=c,pl&&9>gl&&o.scrollbars.setScrollTop(o.scroller.scrollTop=a),null!=l.selectionStart){(!pl||pl&&9>gl)&&t();var e=0,n=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart&&l.selectionEnd>0&&"​"==r.prevInput?On(i,is.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,l=r.textarea,s=jn(i,e),a=o.scroller.scrollTop;if(s&&!bl){var u=i.options.resetSelectionOnContextMenu;u&&-1==i.doc.sel.contains(s)&&On(i,Tt)(i.doc,pt(s),Os);var c=l.style.cssText;if(r.wrapper.style.position="absolute",l.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+(pl?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",ml)var h=window.scrollY;if(o.input.focus(),ml&&window.scrollTo(null,h),o.input.reset(),i.somethingSelected()||(l.value=r.prevInput=" "),r.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),pl&&gl>=9&&t(),Al){ks(e);var f=function(){Ls(window,"mouseup",f),setTimeout(n,20)};Ss(window,"mouseup",f)}else setTimeout(n,50)}},setUneditable:Ho,needsContentAttribute:!1},rt.prototype),ot.prototype=Io({init:function(e){function t(e){if(r.somethingSelected())El=r.getSelections(),"cut"==e.type&&r.replaceSelection("",null,"cut");else{if(!r.options.lineWiseCopyCut)return;var t=tt(r);El=t.text,"cut"==e.type&&r.operation(function(){r.setSelections(t.ranges,0,Os),r.replaceSelection("",null,"cut")})}if(e.clipboardData&&!kl)e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/plain",El.join("\n"));else{var n=it(),i=n.firstChild;r.display.lineSpace.insertBefore(n,r.display.lineSpace.firstChild),i.value=El.join("\n");var o=document.activeElement;Is(i),setTimeout(function(){r.display.lineSpace.removeChild(n),o.focus()},50)}}var n=this,r=n.cm,i=n.div=e.lineDiv;i.contentEditable="true",nt(i),Ss(i,"paste",function(e){J(e,r)}),Ss(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),l=o.indexOf(t,Math.max(0,i.head.ch-t.length));l>-1&&l<=i.head.ch&&(n.composing.sel=pt(Wl(i.head.line,l),Wl(i.head.line,l+t.length)))}}),Ss(i,"compositionupdate",function(e){n.composing.data=e.data}),Ss(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))}),Ss(i,"touchstart",function(){n.forceCompositionEnd()}),Ss(i,"input",function(){n.composing||n.pollContent()||An(n.cm,function(){In(r)})}),Ss(i,"copy",t),Ss(i,"cut",t)},prepareSelection:function(){var e=Et(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=at(this.cm,e.anchorNode,e.anchorOffset),r=at(this.cm,e.focusNode,e.focusOffset);if(!n||n.bad||!r||r.bad||0!=Hl(X(n,r),t.from())||0!=Hl(K(n,r),t.to())){var i=lt(this.cm,t.from()),o=lt(this.cm,t.to());if(i||o){var l=this.cm.display.view,s=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var a=l[l.length-1].measure,u=a.maps?a.maps[a.maps.length-1]:a.map;o={node:u[u.length-1],offset:u[u.length-2]-u[u.length-3]}}}else i={node:l[0].measure.map[2],offset:0};try{var c=Fs(i.node,i.offset,o.offset,o.node)}catch(h){}c&&(e.removeAllRanges(),e.addRange(c),s&&null==e.anchorNode?e.addRange(s):hl&&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){qo(this.cm.display.cursorDiv,e.cursors),qo(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 _s(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():An(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=at(t,e.anchorNode,e.anchorOffset),r=at(t,e.focusNode,e.focusOffset);n&&r&&An(t,function(){Tt(t.doc,pt(n,r),Os),(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=Pn(e,r.line)))var l=Qi(t.view[0].line),s=t.view[0].node;else var l=Qi(t.view[o].line),s=t.view[o-1].node.nextSibling;var a=Pn(e,i.line);if(a==t.view.length-1)var u=t.viewTo-1,c=t.lineDiv.lastChild;else var u=Qi(t.view[a+1].line)-1,c=t.view[a+1].node.previousSibling;for(var h=Vs(ct(e,s,c,l,u)),f=Xi(e.doc,Wl(l,0),Wl(u,Ki(e.doc,u).text.length));h.length>1&&f.length>1;)if(Oo(h)==Oo(f))h.pop(),f.pop(),u--;else{if(h[0]!=f[0])break;h.shift(),f.shift(),l++}for(var d=0,p=0,g=h[0],m=f[0],v=Math.min(g.length,m.length);v>d&&g.charCodeAt(d)==m.charCodeAt(d);)++d;for(var y=Oo(h),b=Oo(f),x=Math.min(y.length-(1==h.length?d:0),b.length-(1==f.length?d:0));x>p&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)++p;h[h.length-1]=y.slice(0,y.length-p),h[0]=h[0].slice(d);var w=Wl(l,d),C=Wl(u,f.length?Oo(f).length-p:0);return h.length>1||h[0]||Hl(w,C)?(Ar(e.doc,h,w,C,"+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){e.data&&e.data!=e.startData&&On(this.cm,Q)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.setAttribute("contenteditable","false")},onKeyPress:function(e){e.preventDefault(),On(this.cm,Q)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},onContextMenu:Ho,resetPosition:Ho,needsContentAttribute:!0},ot.prototype),e.inputStyles={textarea:rt,contenteditable:ot},ht.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&&Hl(e,r.to())<=0)return n}return-1}},ft.prototype={from:function(){return X(this.anchor,this.head)},to:function(){return K(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Il,Fl,zl,Pl={left:0,right:0,top:0,bottom:0},Bl=null,_l=0,Rl=0,ql=0,Ul=null;pl?Ul=-.53:hl?Ul=15:yl?Ul=-.7:xl&&(Ul=-1/3);var Gl=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=Gl(e);return t.x*=Ul,t.y*=Ul,t};var $l=new To,jl=null,Vl=e.changeEnd=function(e){return e.text?Wl(e.from.line+e.text.length-1,Oo(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,Xl.hasOwnProperty(e)&&On(this,Xl[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"](Gr(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;nn&&(zr(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&Ir(this));else{var o=i.from(),l=i.to(),s=Math.max(n,o.line);n=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1;for(var a=s;n>a;++a)zr(this,a,e);var u=this.doc.sel.ranges;0==o.ch&&t.length==u.length&&u[r].from().ch>0&&kt(this.doc,r,new ft(o,u[r].to()),Os)}}}),getTokenAt:function(e,t){return Ai(this,e,t)},getLineTokens:function(e,t){return Ai(this,Wl(e),t,!0)},getTokenTypeAt:function(e){e=mt(this.doc,e);var t,n=Wi(this,Ki(this.doc,e.line)),r=0,i=(n.length-1)/2,o=e.ch;if(0==o)t=n[2];else for(;;){var l=r+i>>1;if((l?n[2*l-1]:0)>=o)i=l;else{if(!(n[2*l+1]s?t:0==s?null:t.slice(0,s-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(!ts.hasOwnProperty(t))return n;var r=ts[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=Ki(this.doc,e)}else n=e;return cn(this,n,{top:0,left:0},t||"page").top+(r?this.doc.height-eo(n):0)},defaultTextHeight:function(){return yn(this.display)},defaultCharWidth:function(){return bn(this.display)},setGutterMarker:Dn(function(e,t,n){return Pr(this.doc,e,"gutter",function(e){var r=e.gutterMarkers||(e.gutterMarkers={});return r[t]=n,!n&&Po(r)&&(e.gutterMarkers=null),!0})}),clearGutter:Dn(function(e){var t=this,n=t.doc,r=n.first;n.iter(function(n){n.gutterMarkers&&n.gutterMarkers[e]&&(n.gutterMarkers[e]=null,Fn(t,r,"gutter"),Po(n.gutterMarkers)&&(n.gutterMarkers=null)),++r})}),lineInfo:function(e){if("number"==typeof e){if(!yt(this.doc,e))return null;var t=e;if(e=Ki(this.doc,e),!e)return null}else{var t=Qi(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=dn(this,mt(this.doc,e));var l=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"==r)l=e.top;else if("above"==r||"near"==r){var a=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==r||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(l=e.bottom),s+t.offsetWidth>u&&(s=u-t.offsetWidth)}t.style.top=l+"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"),n&&Wr(this,s,l,s+t.offsetWidth,l+t.offsetHeight)},triggerOnKeyDown:Dn(ur),triggerOnKeyPress:Dn(fr),triggerOnKeyUp:hr,execCommand:function(e){return is.hasOwnProperty(e)?is[e](this):void 0},triggerElectric:Dn(function(e){et(this,e)}),findPosH:function(e,t,n,r){var i=1;0>t&&(i=-1,t=-t);for(var o=0,l=mt(this.doc,e);t>o&&(l=_r(this.doc,l,i,n,r),!l.hitSide);++o);return l},moveH:Dn(function(e,t){var n=this;n.extendSelectionsBy(function(r){return n.display.shift||n.doc.extend||r.empty()?_r(n.doc,r.head,e,t,n.options.rtlMoveVisually):0>e?r.from():r.to()},Ws)}),deleteH:Dn(function(e,t){var n=this.doc.sel,r=this.doc;n.somethingSelected()?r.replaceSelection("",null,"+delete"):Br(this,function(n){var i=_r(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 l=0,s=mt(this.doc,e);t>l;++l){var a=dn(this,s,"div");if(null==o?o=a.left:a.left=o,s=Rr(this,a,i,n),s.hitSide)break}return s},moveV:Dn(function(e,t){var n=this,r=this.doc,i=[],o=!n.display.shift&&!r.extend&&r.sel.somethingSelected();if(r.extendSelectionsBy(function(l){if(o)return 0>e?l.from():l.to();var s=dn(n,l.head,"div");null!=l.goalColumn&&(s.left=l.goalColumn),i.push(s.left);var a=Rr(n,s,e,t);return"page"==t&&l==r.sel.primary()&&Er(n,null,fn(n,a,"div").top-s.top),a},Ws),i.length)for(var l=0;l0&&s(n.charAt(r-1));)--r;for(;i.5)&&l(this),Ms(this,"refresh",this)}),swapDoc:Dn(function(e){var t=this.doc;return t.cm=null,Vi(this,e),sn(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,wo(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}},Mo(e);var Kl=e.defaults={},Xl=e.optionHandlers={},Yl=e.Init={toString:function(){return"CodeMirror.Init"}};qr("value","",function(e,t){e.setValue(t)},!0),qr("mode",null,function(e,t){e.doc.modeOption=t,n(e)},!0),qr("indentUnit",2,n,!0),qr("indentWithTabs",!1),qr("smartIndent",!0),qr("tabSize",4,function(e){r(e),sn(e),In(e)},!0),qr("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()}),qr("specialCharPlaceholder",Fi,function(e){e.refresh()},!0),qr("electricChars",!0),qr("inputStyle",Sl?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),qr("rtlMoveVisually",!Ml),qr("wholeLineUpdateBefore",!0),qr("theme","default",function(e){s(e),a(e)},!0),qr("keyMap","default",function(t,n,r){var i=Gr(n),o=r!=e.Init&&Gr(r);o&&o.detach&&o.detach(t,i),i.attach&&i.attach(t,o||null)}),qr("extraKeys",null),qr("lineWrapping",!1,i,!0),qr("gutters",[],function(e){d(e.options),a(e)},!0),qr("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?S(e.display)+"px":"0",e.refresh()},!0),qr("coverGutterNextToScrollbar",!1,function(e){y(e)},!0),qr("scrollbarStyle","native",function(e){v(e),y(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),qr("lineNumbers",!1,function(e){d(e.options),a(e)},!0),qr("firstLineNumber",1,a,!0),qr("lineNumberFormatter",function(e){return e},a,!0),qr("showCursorWhenSelecting",!1,Ht,!0),qr("resetSelectionOnContextMenu",!0),qr("lineWiseCopyCut",!0),qr("readOnly",!1,function(e,t){"nocursor"==t?(gr(e),e.display.input.blur(),e.display.disabled=!0):(e.display.disabled=!1,t||e.display.input.reset())}),qr("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),qr("dragDrop",!0,Un),qr("cursorBlinkRate",530),qr("cursorScrollMargin",0),qr("cursorHeight",1,Ht,!0),qr("singleCursorHeightPerLine",!0,Ht,!0),qr("workTime",100),qr("workDelay",100),qr("flattenSpans",!0,r,!0),qr("addModeClass",!1,r,!0),qr("pollInterval",100),qr("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),qr("historyEventDelay",1250),qr("viewportMargin",10,function(e){e.refresh()},!0),qr("maxHighlightLength",1e4,r,!0),qr("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),qr("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),qr("autofocus",null);var Zl=e.modes={},Ql=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)),Zl[t]=n},e.defineMIME=function(e,t){Ql[e]=t},e.resolveMode=function(t){if("string"==typeof t&&Ql.hasOwnProperty(t))t=Ql[t];else if(t&&"string"==typeof t.name&&Ql.hasOwnProperty(t.name)){var n=Ql[t.name];"string"==typeof n&&(n={name:n}),t=Eo(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=Zl[n.name];if(!r)return e.getMode(t,"text/plain");var i=r(t,n);if(Jl.hasOwnProperty(n.name)){var o=Jl[n.name];for(var l in o)o.hasOwnProperty(l)&&(i.hasOwnProperty(l)&&(i["_"+l]=i[l]),i[l]=o[l])}if(i.name=n.name,n.helperType&&(i.helperType=n.helperType),n.modeProps)for(var l in n.modeProps)i[l]=n.modeProps[l];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var Jl=e.modeExtensions={};e.extendMode=function(e,t){var n=Jl.hasOwnProperty(e)?Jl[e]:Jl[e]={};Io(t,n)},e.defineExtension=function(t,n){e.prototype[t]=n},e.defineDocExtension=function(e,t){ys.prototype[e]=t},e.defineOption=qr;var es=[];e.defineInitHook=function(e){es.push(e)};var ts=e.helpers={};e.registerHelper=function(t,n,r){ts.hasOwnProperty(t)||(ts[t]=e[t]={_global:[]}),ts[t][n]=r},e.registerGlobalHelper=function(t,n,r,i){e.registerHelper(t,n,i),ts[t]._global.push({pred:r,val:i})};var ns=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},rs=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 is=e.commands={selectAll:function(e){e.setSelection(Wl(e.firstLine(),0),Wl(e.lastLine()),Os)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Os)},killLine:function(e){Br(e,function(t){if(t.empty()){var n=Ki(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line0)i=new Wl(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),Wl(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=Ki(e.doc,i.line-1).text; l&&e.replaceRange(o.charAt(0)+"\n"+l.charAt(l.length-1),Wl(i.line-1,l.length-1),Wl(i.line,1),"+transpose")}n.push(new ft(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){An(e,function(){for(var t=e.listSelections().length,n=0;t>n;n++){var r=e.listSelections()[n];e.replaceRange("\n",r.anchor,r.head,"+input"),e.indentLine(r.from().line+1,null,!0),Ir(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},os=e.keyMap={};os.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"},os.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"},os.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"},os.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"]},os["default"]=Ll?os.macDefault:os.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=Wo(n.split(" "),Ur),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 cs=0,hs=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++cs};Mo(hs),hs.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&xn(e),Lo(this,"clear")){var n=this.find();n&&wo(this,"clear",n.from,n.to)}for(var r=null,i=null,o=0;oe.display.maxLineLength&&(e.display.maxLine=a,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&&In(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Ot(e.doc)),e&&wo(e,"markerCleared",e,this),t&&Cn(e),this.parent&&this.parent.clear()}},hs.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,Li(i),wo(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}},$i.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),l=r.height;if(r.removeInner(e,o),this.height-=l-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 Gi))){var s=[];this.collapse(s),this.children=[new Gi(s)],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 l=i.lines.splice(i.lines.length-25,25),s=new Gi(l);i.height-=s.height,this.children.splice(r+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),n=new $i(t);if(e.parent){e.size-=n.size,e.height-=n.height;var r=Do(e.parent.children,e);e.parent.children.splice(r+1,0,n)}else{var i=new $i(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 l=Math.min(t,o-e);if(i.iterN(e,l,n))return!0;if(0==(t-=l))break;e=0}else e-=o}}};var vs=0,ys=e.Doc=function(e,t,n){if(!(this instanceof ys))return new ys(e,t,n);null==n&&(n=0),$i.call(this,[new Gi([new ps("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=n;var r=Wl(n,0);this.sel=pt(r),this.history=new no(null),this.id=++vs,this.modeOption=t,"string"==typeof e&&(e=Vs(e)),Ui(this,{from:r,to:r,text:e}),Tt(this,pt(r),Os)};ys.prototype=Eo($i.prototype,{constructor:ys,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--)kr(this,r[o]);s?Mt(this,s):this.cm&&Ir(this.cm)}),undo:Wn(function(){Lr(this,"undo")}),redo:Wn(function(){Lr(this,"redo")}),undoSelection:Wn(function(){Lr(this,"undo",!0)}),redoSelection:Wn(function(){Lr(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=mt(this,e),t=mt(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l)for(var s=0;sa.to||null==a.from&&i!=e.line||i==t.line&&a.from>t.ch||n&&!n(a.marker)||r.push(a.marker.parent||a.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)}),mt(this,Wl(n,t))},indexFromPos:function(e){e=mt(this,e);var t=e.ch;return e.linet&&(t=e.from),null!=e.to&&e.tos||s>=t)return l+(t-o);l+=s-o,l+=n-l%n,o=s+1}},Es=[""],Is=function(e){e.select()};kl?Is=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:pl&&(Is=function(e){try{e.select()}catch(t){}});var Fs,zs=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Ps=e.isWordChar=function(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||zs.test(e))},Bs=/[\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]/;Fs=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 _s=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)};pl&&11>gl&&(Uo=function(){try{return document.activeElement}catch(e){return document.body}});var Rs,qs,Us=e.rmClass=function(e,t){var n=e.className,r=Go(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:"")}},Gs=e.addClass=function(e,t){var n=e.className;Go(t).test(n)||(e.className+=(n?" ":"")+t)},$s=!1,js=function(){if(pl&&9>gl)return!1;var e=_o("div");return"draggable"in e||"dragDrop"in e}(),Vs=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),l=o.indexOf("\r");-1!=l?(n.push(o.slice(0,l)),t+=l+1):(n.push(o),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},Ks=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},Xs=function(){var e=_o("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),Ys=null,Zs={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",107:"=",109:"-",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"};e.keyNames=Zs,function(){for(var e=0;10>e;e++)Zs[e+48]=Zs[e+96]=String(e);for(var e=65;90>=e;e++)Zs[e]=String.fromCharCode(e);for(var e=1;12>=e;e++)Zs[e+111]=Zs[e+63235]="F"+e}();var Qs,Js=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]/,l=/[LRr]/,s=/[Lb1n]/,a=/[1n]/,u="L";return function(n){if(!i.test(n))return!1;for(var r,c=n.length,h=[],f=0;c>f;++f)h.push(r=e(n.charCodeAt(f)));for(var f=0,d=u;c>f;++f){var r=h[f];"m"==r?h[f]=d:d=r}for(var f=0,p=u;c>f;++f){var r=h[f];"1"==r&&"r"==p?h[f]="n":l.test(r)&&(p=r,"r"==r&&(h[f]="R"))}for(var f=1,d=h[0];c-1>f;++f){var r=h[f];"+"==r&&"1"==d&&"1"==h[f+1]?h[f]="1":","!=r||d!=h[f+1]||"1"!=d&&"n"!=d||(h[f]=d),d=r}for(var f=0;c>f;++f){var r=h[f];if(","==r)h[f]="N";else if("%"==r){for(var g=f+1;c>g&&"%"==h[g];++g);for(var m=f&&"!"==h[f-1]||c>g&&"1"==h[g]?"1":"N",v=f;g>v;++v)h[v]=m;f=g-1}}for(var f=0,p=u;c>f;++f){var r=h[f];"L"==p&&"1"==r?h[f]="L":l.test(r)&&(p=r)}for(var f=0;c>f;++f)if(o.test(h[f])){for(var g=f+1;c>g&&o.test(h[g]);++g);for(var y="L"==(f?h[f-1]:u),b="L"==(c>g?h[g]:u),m=y||b?"L":"R",v=f;g>v;++v)h[v]=m;f=g-1}for(var x,w=[],f=0;c>f;)if(s.test(h[f])){var C=f;for(++f;c>f&&s.test(h[f]);++f);w.push(new t(0,C,f))}else{var k=f,S=w.length;for(++f;c>f&&"L"!=h[f];++f);for(var v=k;f>v;)if(a.test(h[v])){v>k&&w.splice(S,0,new t(1,k,v));var L=v;for(++v;f>v&&a.test(h[v]);++v);w.splice(S,0,new t(2,L,v)),k=v}else++v;f>k&&w.splice(S,0,new t(1,k,f))}return 1==w[0].level&&(x=n.match(/^\s+/))&&(w[0].from=x[0].length,w.unshift(new t(0,0,x[0].length))),1==Oo(w).level&&(x=n.match(/\s+$/))&&(Oo(w).to-=x[0].length,w.push(new t(0,c-x[0].length,c))),2==w[0].level&&w.unshift(new t(1,w[0].to,w[0].to)),w[0].level!=Oo(w).level&&w.push(new t(w[0].level,c,c)),w}}();return e.version="5.4.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";var t=/^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\s*)/,n=/^(\s*)(>[> ]*|[*+-]|(\d+)[.)])(\s*)$/,r=/[*+-]\s/;e.commands.newlineAndIndentContinueMarkdownList=function(i){if(i.getOption("disableInput"))return e.Pass;for(var o=i.listSelections(),l=[],s=0;s")>=0?d[2]:parseInt(d[3],10)+1+d[4];l[s]="\n"+p+m+g}}i.replaceSelections(l)},e.commands.shiftTabAndIndentContinueMarkdownList=function(e){var t=e.listSelections(),n=t[0].head,r=e.getStateAfter(n.line),i=r.list!==!1;if(i)return void e.execCommand("indentLess");if(e.options.indentWithTabs)e.execCommand("insertTab");else{var o=Array(e.options.tabSize+1).join(" ");e.replaceSelection(o)}},e.commands.tabAndIndentContinueMarkdownList=function(e){var t=e.listSelections(),n=t[0].head,r=e.getStateAfter(n.line),i=r.list!==!1;if(i)return void e.execCommand("indentMore");if(e.options.indentWithTabs)e.execCommand("insertTab");else{var o=Array(e.options.tabSize+1).join(" ");e.replaceSelection(o)}}}),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 l(e){return e.linkTitle=!1,e.em=!1,e.strong=!1,e.strikethrough=!1,e.quote=0,e.indentedCode=!1,w||e.f!=a||(e.f=d,e.block=s),e.trailingSpace=0,e.trailingSpaceNewLine=!1,e.thisLineHasContent=!1,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 a=null;if(t.indentationDiff>=4)return e.skipToEnd(),s||!t.prevLineHasContent?(t.indentation-=4,t.indentedCode=!0,L):null;if(e.eatSpace())return null;if((a=e.match(G))&&a[1].length<=6)return t.header=a[1].length,n.highlightFormatting&&(t.formatting="header"),t.f=t.inline,h(t);if(t.prevLineHasContent&&!t.quote&&!l&&!s&&(a=e.match($)))return t.header="="==a[0].charAt(0)?1:2,n.highlightFormatting&&(t.formatting="header"),t.f=t.inline,h(t);if(e.eat(">"))return t.quote=o?1:t.quote+1,n.highlightFormatting&&(t.formatting="quote"),e.eatSpace(),h(t);if("["===e.peek())return i(e,t,v);if(e.match(_,!0))return t.hr=!0,O;if((!t.prevLineHasContent||l)&&(e.match(R,!1)||e.match(q,!1))){var c=null;return e.match(R,!0)?c="ul":(e.match(q,!0),c="ol"),t.indentation+=4,t.list=!0,t.listDepth++,n.taskLists&&e.match(U,!1)&&(t.taskList=!0),t.f=t.inline,n.highlightFormatting&&(t.formatting=["list","list-"+c]),h(t)}return n.fencedCodeBlocks&&e.match(/^```[ \t]*([\w+#]*)/,!0)?(t.localMode=r(RegExp.$1),t.localMode&&(t.localState=t.localMode.startState()),t.f=t.block=u,n.highlightFormatting&&(t.formatting="code-block"),t.code=!0,h(t)):i(e,t,t.inline)}function a(e,t){var n=C.token(e,t.htmlState);return(w&&null===t.htmlState.tagStart&&!t.htmlState.context||t.md_inside&&e.current().indexOf(">")>-1)&&(t.f=d,t.block=s,t.htmlState=null),n}function u(e,t){return e.sol()&&e.match("```",!1)?(t.localMode=t.localState=null,t.f=t.block=c,null):t.localMode?t.localMode.token(e,t.localState):(e.skipToEnd(),L)}function c(e,t){e.match("```"),t.block=s,t.f=d,n.highlightFormatting&&(t.formatting="code-block"),t.code=!0;var r=h(t);return t.code=!1,r}function h(e){var t=[];if(e.formatting){t.push(W),"string"==typeof e.formatting&&(e.formatting=[e.formatting]);for(var r=0;r=e.quote?W+"-"+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(F,"url"):(e.strong&&t.push(P),e.em&&t.push(z),e.strikethrough&&t.push(B),e.linkText&&t.push(I),e.code&&t.push(L)),e.header&&(t.push(S),t.push(S+"-"+e.header)),e.quote&&(t.push(M),t.push(!n.maxBlockquoteDepth||n.maxBlockquoteDepth>=e.quote?M+"-"+e.quote:M+"-"+n.maxBlockquoteDepth)),e.list!==!1){var i=(e.listDepth-1)%3;t.push(i?1===i?N:A:T)}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 f(e,t){return e.match(j,!0)?h(t):void 0}function d(t,r){var i=r.text(t,r);if("undefined"!=typeof i)return i;if(r.list)return r.list=null,h(r);if(r.taskList){var l="x"!==t.match(U,!0)[1];return l?r.taskOpen=!0:r.taskClosed=!0,n.highlightFormatting&&(r.formatting="task"),r.taskList=!1,h(r)}if(r.taskOpen=!1,r.taskClosed=!1,r.header&&t.match(/^#+$/,!0))return n.highlightFormatting&&(r.formatting="header"),h(r);var s=t.sol(),u=t.next();if("\\"===u&&(t.next(),n.highlightFormatting)){var c=h(r);return c?c+" formatting-escape":"formatting-escape"}if(r.linkTitle){r.linkTitle=!1;var f=u;"("===u&&(f=")"),f=(f+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");var d="^\\s*(?:[^"+f+"\\\\]+|\\\\\\\\|\\\\.)"+f;if(t.match(new RegExp(d),!0))return F}if("`"===u){var m=r.formatting;n.highlightFormatting&&(r.formatting="code");var v=h(r),y=t.pos;t.eatWhile("`");var b=1+t.pos-y;return r.code?b===k?(r.code=!1,v):(r.formatting=m,h(r)):(k=b,r.code=!0,h(r))}if(r.code)return h(r);if("!"===u&&t.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return t.match(/\[[^\]]*\]/),r.inline=r.f=g,D;if("["===u&&t.match(/.*\](\(.*\)| ?\[.*\])/,!1))return r.linkText=!0,n.highlightFormatting&&(r.formatting="link"),h(r);if("]"===u&&r.linkText&&t.match(/\(.*\)| ?\[.*\]/,!1)){n.highlightFormatting&&(r.formatting="link");var c=h(r);return r.linkText=!1,r.inline=r.f=g,c}if("<"===u&&t.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){r.f=r.inline=p,n.highlightFormatting&&(r.formatting="link");var c=h(r);return c?c+=" ":c="",c+H}if("<"===u&&t.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){r.f=r.inline=p,n.highlightFormatting&&(r.formatting="link");var c=h(r);return c?c+=" ":c="",c+E}if("<"===u&&t.match(/^\w/,!1)){if(-1!=t.string.indexOf(">")){var x=t.string.substring(1,t.string.indexOf(">"));/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(x)&&(r.md_inside=!0)}return t.backUp(1),r.htmlState=e.startState(C),o(t,r,a)}if("<"===u&&t.match(/^\/\w*?>/))return r.md_inside=!1,"tag";var w=!1;if(!n.underscoresBreakWords&&"_"===u&&"_"!==t.peek()&&t.match(/(\w)/,!1)){var S=t.pos-2;if(S>=0){var L=t.string.charAt(S);"_"!==L&&L.match(/(\w)/,!1)&&(w=!0)}}if("*"===u||"_"===u&&!w)if(s&&" "===t.peek());else{if(r.strong===u&&t.eat(u)){n.highlightFormatting&&(r.formatting="strong");var v=h(r);return r.strong=!1,v}if(!r.strong&&t.eat(u))return r.strong=u,n.highlightFormatting&&(r.formatting="strong"),h(r);if(r.em===u){n.highlightFormatting&&(r.formatting="em");var v=h(r);return r.em=!1,v}if(!r.em)return r.em=u,n.highlightFormatting&&(r.formatting="em"),h(r)}else if(" "===u&&(t.eat("*")||t.eat("_"))){if(" "===t.peek())return h(r);t.backUp(1)}if(n.strikethrough)if("~"===u&&t.eatWhile(u)){if(r.strikethrough){n.highlightFormatting&&(r.formatting="strikethrough");var v=h(r);return r.strikethrough=!1,v}if(t.match(/^[^\s]/,!1))return r.strikethrough=!0,n.highlightFormatting&&(r.formatting="strikethrough"),h(r)}else if(" "===u&&t.match(/^~~/,!0)){if(" "===t.peek())return h(r);t.backUp(2)}return" "===u&&(t.match(/ +$/,!1)?r.trailingSpace++:r.trailingSpace&&(r.trailingSpaceNewLine=!0)),h(r)}function p(e,t){var r=e.next();if(">"===r){t.f=t.inline=d,n.highlightFormatting&&(t.formatting="link");var i=h(t);return i?i+=" ":i="",i+H}return e.match(/^[^>]+/,!0),H}function g(e,t){if(e.eatSpace())return null;var r=e.next();return"("===r||"["===r?(t.f=t.inline=m("("===r?")":"]"),n.highlightFormatting&&(t.formatting="link-string"),t.linkHref=!0,h(t)):"error"}function m(e){return function(t,r){var i=t.next();if(i===e){r.f=r.inline=d,n.highlightFormatting&&(r.formatting="link-string");var o=h(r);return r.linkHref=!1,o}return t.match(x(e),!0)&&t.backUp(1),r.linkHref=!0,h(r)}}function v(e,t){return e.match(/^[^\]]*\]:/,!1)?(t.f=y,e.next(),n.highlightFormatting&&(t.formatting="link"),t.linkText=!0,h(t)):i(e,t,d)}function y(e,t){if(e.match(/^\]:/,!0)){t.f=t.inline=b,n.highlightFormatting&&(t.formatting="link");var r=h(t);return t.linkText=!1,r}return e.match(/^[^\]]+/,!0),I}function b(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=d,F+" url")}function x(e){return V[e]||(e=(e+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),V[e]=new RegExp("^(?:[^\\\\]|\\\\.)*?("+e+")")),V[e]}var w=e.modes.hasOwnProperty("xml"),C=e.getMode(t,w?{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.fencedCodeBlocks&&(n.fencedCodeBlocks=!1),void 0===n.taskLists&&(n.taskLists=!1),void 0===n.strikethrough&&(n.strikethrough=!1);var k=0,S="header",L="comment",M="quote",T="variable-2",N="variable-3",A="keyword",O="hr",D="tag",W="formatting",H="link",E="link",I="link",F="string",z="em",P="strong",B="strikethrough",_=/^([*\-_])(?:\s*\1){2,}\s*$/,R=/^[*\-+]\s+/,q=/^[0-9]+([.)])\s+/,U=/^\[(x| )\](?=\s)/,G=/^(#+)(?: |$)/,$=/^ *(?:\={1,}|-{1,})\s*$/,j=/^[^#!\[\]*_\\<>` "'(~]+/,V=[],K={startState:function(){return{f:s,prevLineHasContent:!1,thisLineHasContent:!1,block:s,htmlState:null,indentation:0,inline:d,text:f,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,em:!1,strong:!1,header:0,hr:!1,taskList:!1,list:!1,listDepth:0,quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1}},copyState:function(t){return{f:t.f,prevLineHasContent:t.prevLineHasContent,thisLineHasContent:t.thisLineHasContent,block:t.block,htmlState:t.htmlState&&e.copyState(C,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,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}},token:function(e,t){if(t.formatting=!1,e.sol()){var n=!!t.header||t.hr;if(t.header=0,t.hr=!1,e.match(/^\s*$/,!0)||n)return t.prevLineHasContent=!1,l(t),n?this.token(e,t):null;t.prevLineHasContent=t.thisLineHasContent,t.thisLineHasContent=!0,t.taskList=!1,t.code=!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==a?{state:e.htmlState,mode:C}:e.localState?{state:e.localState,mode:e.localMode}:{state:e,mode:K}},blankLine:l,getType:h,fold:"markdown"};return K},"xml"),e.defineMIME("text/x-markdown","markdown")}),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.defineMode("xml",function(t,n){function r(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(l("atom","]]>")):null:e.match("--")?n(l("comment","-->")):e.match("DOCTYPE",!0,!0)?(e.eatWhile(/[\w\._\-]/),n(s(1))):null:e.eat("?")?(e.eatWhile(/[\w\._\-]/),t.tokenize=l("meta","?>"),"meta"):(k=e.eat("/")?"closeTag":"openTag",t.tokenize=i,"tag bracket");if("&"==r){var o;return o=e.eat("#")?e.eat("x")?e.eatWhile(/[a-fA-F\d]/)&&e.eat(";"):e.eatWhile(/[\d]/)&&e.eat(";"):e.eatWhile(/[\w\.\-:]/)&&e.eat(";"),o?"atom":"error"}return e.eatWhile(/[^&<]/),null}function i(e,t){var n=e.next();if(">"==n||"/"==n&&e.eat(">"))return t.tokenize=r,k=">"==n?"endTag":"selfcloseTag","tag bracket";if("="==n)return k="equals",null;if("<"==n){t.tokenize=r,t.state=h,t.tagName=t.tagStart=null;var i=t.tokenize(e,t);return i?i+" tag error":"tag error"}return/[\'\"]/.test(n)?(t.tokenize=o(n),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function o(e){var t=function(t,n){for(;!t.eol();)if(t.next()==e){n.tokenize=i;break}return"string"};return t.isInAttribute=!0,t}function l(e,t){return function(n,i){for(;!n.eol();){if(n.match(t)){i.tokenize=r;break}n.next()}return e}}function s(e){return function(t,n){for(var i;null!=(i=t.next());){if("<"==i)return n.tokenize=s(e+1),n.tokenize(t,n);if(">"==i){if(1==e){n.tokenize=r;break}return n.tokenize=s(e-1),n.tokenize(t,n)}}return"meta"}}function a(e,t,n){this.prev=e.context,this.tagName=t,this.indent=e.indented,this.startOfLine=n,(L.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)&&(this.noIndent=!0)}function u(e){e.context&&(e.context=e.context.prev)}function c(e,t){for(var n;;){if(!e.context)return;if(n=e.context.tagName,!L.contextGrabbers.hasOwnProperty(n)||!L.contextGrabbers[n].hasOwnProperty(t))return;u(e)}}function h(e,t,n){return"openTag"==e?(n.tagStart=t.column(),f):"closeTag"==e?d:h}function f(e,t,n){return"word"==e?(n.tagName=t.current(),S="tag",m):(S="error",f)}function d(e,t,n){if("word"==e){var r=t.current();return n.context&&n.context.tagName!=r&&L.implicitlyClosed.hasOwnProperty(n.context.tagName)&&u(n),n.context&&n.context.tagName==r?(S="tag",p):(S="tag error",g)}return S="error",g}function p(e,t,n){return"endTag"!=e?(S="error",p):(u(n),h)}function g(e,t,n){return S="error",p(e,t,n)}function m(e,t,n){if("word"==e)return S="attribute",v;if("endTag"==e||"selfcloseTag"==e){var r=n.tagName,i=n.tagStart;return n.tagName=n.tagStart=null,"selfcloseTag"==e||L.autoSelfClosers.hasOwnProperty(r)?c(n,r):(c(n,r),n.context=new a(n,r,i==n.indented)),h}return S="error",m}function v(e,t,n){return"equals"==e?y:(L.allowMissing||(S="error"),m(e,t,n))}function y(e,t,n){return"string"==e?b:"word"==e&&L.allowUnquoted?(S="string",m):(S="error",m(e,t,n))}function b(e,t,n){return"string"==e?b:m(e,t,n)}var x=t.indentUnit,w=n.multilineTagIndentFactor||1,C=n.multilineTagIndentPastTag;null==C&&(C=!0);var k,S,L=n.htmlMode?{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}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1},M=n.alignCDATA;return{startState:function(){return{tokenize:r,state:h,indented:0,tagName:null,tagStart:null,context:null}},token:function(e,t){if(!t.tagName&&e.sol()&&(t.indented=e.indentation()),e.eatSpace())return null;k=null;var n=t.tokenize(e,t);return(n||k)&&"comment"!=n&&(S=null,t.state=t.state(k||n,e,t),S&&(n="error"==S?n+" error":S)),n},indent:function(t,n,o){var l=t.context;if(t.tokenize.isInAttribute)return t.tagStart==t.indented?t.stringStartCol+1:t.indented+x;if(l&&l.noIndent)return e.Pass;if(t.tokenize!=i&&t.tokenize!=r)return o?o.match(/^(\s*)/)[0].length:0;if(t.tagName)return C?t.tagStart+t.tagName.length+2:t.tagStart+x*w;if(M&&/$/,blockCommentStart:"",configuration:n.htmlMode?"html":"xml",helperType:n.htmlMode?"html":"xml"}}),e.defineMIME("text/xml","xml"),e.defineMIME("application/xml","xml"),e.mimeModes.hasOwnProperty("text/html")||e.defineMIME("text/html",{name:"xml",htmlMode:!0})}),function(){function e(e){this.tokens=[],this.tokens.links={},this.options=e||u.defaults,this.rules=c.normal,this.options.gfm&&(this.rules=this.options.tables?c.tables:c.gfm)}function t(e,t){if(this.options=t||u.defaults,this.links=e,this.rules=h.normal,this.renderer=this.options.renderer||new n,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.rules=this.options.breaks?h.breaks:h.gfm:this.options.pedantic&&(this.rules=h.pedantic)}function n(e){this.options=e||{}}function r(e){this.tokens=[],this.token=null,this.options=e||u.defaults,this.options.renderer=this.options.renderer||new n,this.renderer=this.options.renderer,this.renderer.options=this.options}function i(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function o(e){return e.replace(/&([#\w]+);/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?String.fromCharCode("x"===t.charAt(1)?parseInt(t.substring(2),16):+t.substring(1)):""})}function l(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function s(){}function a(e){for(var t,n,r=1;rAn error occured:

"+i(f.message+"",!0)+"
";throw f}}var c={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:s,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:s,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:s,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};c.bullet=/(?:[*+-]|\d+\.)/,c.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,c.item=l(c.item,"gm")(/bull/g,c.bullet)(),c.list=l(c.list)(/bull/g,c.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+c.def.source+")")(),c.blockquote=l(c.blockquote)("def",c.def)(),c._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",c.html=l(c.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,c._tag)(),c.paragraph=l(c.paragraph)("hr",c.hr)("heading",c.heading)("lheading",c.lheading)("blockquote",c.blockquote)("tag","<"+c._tag)("def",c.def)(),c.normal=a({},c),c.gfm=a({},c.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),c.gfm.paragraph=l(c.paragraph)("(?!","(?!"+c.gfm.fences.source.replace("\\1","\\2")+"|"+c.list.source.replace("\\1","\\3")+"|")(),c.tables=a({},c.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),e.rules=c,e.lex=function(t,n){var r=new e(n);return r.lex(t)},e.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},e.prototype.token=function(e,t,n){for(var r,i,o,l,s,a,u,h,f,e=e.replace(/^ +$/gm,"");e;)if((o=this.rules.newline.exec(e))&&(e=e.substring(o[0].length),o[0].length>1&&this.tokens.push({type:"space"})),o=this.rules.code.exec(e))e=e.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?o:o.replace(/\n+$/,"")});else if(o=this.rules.fences.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"code",lang:o[2],text:o[3]});else if(o=this.rules.heading.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"heading",depth:o[1].length,text:o[2]});else if(t&&(o=this.rules.nptable.exec(e))){for(e=e.substring(o[0].length),a={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/\n$/,"").split("\n")},h=0;h ?/gm,""),this.token(o,t,!0),this.tokens.push({type:"blockquote_end"});else if(o=this.rules.list.exec(e)){for(e=e.substring(o[0].length),l=o[2],this.tokens.push({type:"list_start",ordered:l.length>1}),o=o[0].match(this.rules.item),r=!1,f=o.length,h=0;f>h;h++)a=o[h],u=a.length,a=a.replace(/^ *([*+-]|\d+\.) +/,""),~a.indexOf("\n ")&&(u-=a.length,a=this.options.pedantic?a.replace(/^ {1,4}/gm,""):a.replace(new RegExp("^ {1,"+u+"}","gm"),"")),this.options.smartLists&&h!==f-1&&(s=c.bullet.exec(o[h+1])[0],l===s||l.length>1&&s.length>1||(e=o.slice(h+1).join("\n")+e,h=f-1)),i=r||/\n\n(?!\s*$)/.test(a),h!==f-1&&(r="\n"===a.charAt(a.length-1),i||(i=r)),this.tokens.push({type:i?"loose_item_start":"list_item_start"}),this.token(a,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(o=this.rules.html.exec(e))e=e.substring(o[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===o[1]||"script"===o[1]||"style"===o[1]),text:o[0]});else if(!n&&t&&(o=this.rules.def.exec(e)))e=e.substring(o[0].length),this.tokens.links[o[1].toLowerCase()]={href:o[2],title:o[3]};else if(t&&(o=this.rules.table.exec(e))){for(e=e.substring(o[0].length),a={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/(?: *\| *)?\n$/,"").split("\n")},h=0;h])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:s,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:s,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,h.link=l(h.link)("inside",h._inside)("href",h._href)(),h.reflink=l(h.reflink)("inside",h._inside)(),h.normal=a({},h),h.pedantic=a({},h.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),h.gfm=a({},h.normal,{escape:l(h.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:l(h.text)("]|","~]|")("|","|https?://|")()}),h.breaks=a({},h.gfm,{br:l(h.br)("{2,}","*")(),text:l(h.gfm.text)("{2,}","*")()}),t.rules=h,t.output=function(e,n,r){var i=new t(n,r);return i.output(e)},t.prototype.output=function(e){for(var t,n,r,o,l="";e;)if(o=this.rules.escape.exec(e))e=e.substring(o[0].length),l+=o[1];else if(o=this.rules.autolink.exec(e))e=e.substring(o[0].length),"@"===o[2]?(n=this.mangle(":"===o[1].charAt(6)?o[1].substring(7):o[1]),r=this.mangle("mailto:")+n):(n=i(o[1]),r=n),l+=this.renderer.link(r,null,n);else if(this.inLink||!(o=this.rules.url.exec(e))){if(o=this.rules.tag.exec(e))!this.inLink&&/^/i.test(o[0])&&(this.inLink=!1),e=e.substring(o[0].length),l+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(o[0]):i(o[0]):o[0];else if(o=this.rules.link.exec(e))e=e.substring(o[0].length),this.inLink=!0,l+=this.outputLink(o,{href:o[2],title:o[3]}),this.inLink=!1;else if((o=this.rules.reflink.exec(e))||(o=this.rules.nolink.exec(e))){if(e=e.substring(o[0].length),t=(o[2]||o[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){l+=o[0].charAt(0),e=o[0].substring(1)+e;continue}this.inLink=!0,l+=this.outputLink(o,t),this.inLink=!1}else if(o=this.rules.strong.exec(e))e=e.substring(o[0].length),l+=this.renderer.strong(this.output(o[2]||o[1]));else if(o=this.rules.em.exec(e))e=e.substring(o[0].length),l+=this.renderer.em(this.output(o[2]||o[1]));else if(o=this.rules.code.exec(e))e=e.substring(o[0].length),l+=this.renderer.codespan(i(o[2],!0));else if(o=this.rules.br.exec(e))e=e.substring(o[0].length),l+=this.renderer.br();else if(o=this.rules.del.exec(e))e=e.substring(o[0].length),l+=this.renderer.del(this.output(o[1]));else if(o=this.rules.text.exec(e))e=e.substring(o[0].length),l+=this.renderer.text(i(this.smartypants(o[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(o[0].length),n=i(o[1]),r=n,l+=this.renderer.link(r,null,n);return l},t.prototype.outputLink=function(e,t){var n=i(t.href),r=t.title?i(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,i(e[1]))},t.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},t.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,i=0;r>i;i++)t=e.charCodeAt(i),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},n.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'
'+(n?e:i(e,!0))+"\n
\n":"
"+(n?e:i(e,!0))+"\n
"},n.prototype.blockquote=function(e){return"
\n"+e+"
\n"},n.prototype.html=function(e){return e},n.prototype.heading=function(e,t,n){return"'+e+"\n"},n.prototype.hr=function(){return this.options.xhtml?"
\n":"
\n"},n.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"\n"},n.prototype.listitem=function(e){return"
  • "+e+"
  • \n"},n.prototype.paragraph=function(e){return"

    "+e+"

    \n"},n.prototype.table=function(e,t){return"\n\n"+e+"\n\n"+t+"\n
    \n"},n.prototype.tablerow=function(e){return"\n"+e+"\n"},n.prototype.tablecell=function(e,t){var n=t.header?"th":"td",r=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return r+e+"\n"},n.prototype.strong=function(e){return""+e+""},n.prototype.em=function(e){return""+e+""},n.prototype.codespan=function(e){return""+e+""},n.prototype.br=function(){return this.options.xhtml?"
    ":"
    "},n.prototype.del=function(e){return""+e+""},n.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(o(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(i){return""}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:"))return""}var l='
    "},n.prototype.image=function(e,t,n){var r=''+n+'":">"},n.prototype.text=function(e){return e},r.parse=function(e,t,n){var i=new r(t,n);return i.parse(e)},r.prototype.parse=function(e){this.inline=new t(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var n="";this.next();)n+=this.tok();return n},r.prototype.next=function(){return this.token=this.tokens.pop()},r.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},r.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},r.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,i,o="",l="";for(n="",e=0;e=12&&(s=i-12,l="pm"),0==s&&(s=12),o=10>o?"0"+o:o,n.innerHTML="Autosaved: "+s+":"+o+" "+l}setTimeout(function(){t.autosave()},this.options.autosave.delay||1e4)},SimpleMDE.prototype.createToolbar=function(e){if(e=e||this.options.toolbar,e&&0!==e.length){var t=document.createElement("div");t.className="editor-toolbar";var n=this;n.toolbar={};for(var r=0;r