/** * simplemde v1.11.2 * Copyright Next Step Webs, Inc. * @link https://github.com/NextStepWebs/simplemde-markdown-editor * @license MIT */ !function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).SimpleMDE=e()}(function(){return function i(r,o,l){function a(t,e){if(!o[t]){if(!r[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(s)return s(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}n=o[t]={exports:{}},r[t][0].call(n.exports,function(e){return a(r[t][1][e]||e)},n,n.exports,i,r,o,l)}return o[t].exports}for(var s="function"==typeof require&&require,e=0;e[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,d=/^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,h=/[*+-]\s/;u.commands.newlineAndIndentContinueMarkdownList=function(e){if(e.getOption("disableInput"))return u.Pass;for(var t=e.listSelections(),n=[],i=0;i\s*$/.test(a),c=!/>\s*$/.test(a),(l||c)&&e.replaceRange("",{line:r.line,ch:0},{line:r.line,ch:r.ch+1}),n[i]="\n"):(o=s[1],a=s[5],c=(l=!(h.test(s[2])||0<=s[2].indexOf(">")))?parseInt(s[3],10)+1+s[4]:s[2].replace("x"," "),n[i]="\n"+o+c+a,l&&function(e,t){var n=t.line,i=0,r=0,o=p.exec(e.getLine(n)),l=o[1];do{var a=n+(i+=1),s=e.getLine(a),c=p.exec(s);if(c){var u=c[1],d=parseInt(o[3],10)+i-r,h=parseInt(c[3],10),f=h;if(l!==u||isNaN(h)){if(l.length>u.length)return;if(l.length=n.line,u=c?n:h(s,0),a=e.markText(a,u,{className:o});if(null==i?r.push(a):r.splice(i++,0,a),c)break;l=s}}function s(e){for(var t=e.state.markedSelection,n=0;nt)return r;o.to==t&&(o.from!=o.to&&"before"==n?i=r:He=r),o.from==t&&(o.from!=o.to&&"before"!=n?i=r:He=r)}return null!=i?i:He}We=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,Pe=/[stwN]/,Re=/[LRr]/,Be=/[Lb1n]/,ze=/[1n]/;var We,Pe,Re,Be,ze,je=function(e,t){var n="ltr"==t?"L":"R";if(0==e.length||"ltr"==t&&!We.test(e))return!1;for(var i,r=e.length,o=[],l=0;l=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var i=0;;++i){var r=n.children[i],o=r.chunkSize();if(t=e.first&&tn?O(n,F(e,n).text.length):(e=F(e,(n=t).line).text.length,null==(t=n.ch)||e=this.string.length},m.prototype.sol=function(){return this.pos==this.lineStart},m.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},m.prototype.next=function(){if(this.post},m.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},m.prototype.skipToEnd=function(){this.pos=this.string.length},m.prototype.skipTo=function(e){e=this.string.indexOf(e,this.pos);if(-1e.options.maxHighlightLength&&ft(e.doc.mode,i.state),o=At(e,t,i),r&&(i.state=r),t.stateAfter=i.save(!r),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))),t.styles}function Et(n,i,e){var t,r,o,l=n.doc,a=n.display;return l.mode.startState?(r=(t=function(e,t,n){for(var i,r,o=e.doc,l=n?-1:t-(e.doc.mode.innerMode?1e3:100),a=t;ll.first&&F(l,t-1).stateAfter,o=r?Dt.fromSaved(l,r,t):new Dt(l,mt(l.mode),t),l.iter(t,i,function(e){Ot(n,e.text,o);var t=o.line;e.stateAfter=t==i-1||t%5==0||t>=a.viewFrom&&tt.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}Dt.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},Dt.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},Dt.prototype.nextLine=function(){this.line++,0e.options.maxHighlightLength?(a=!1,l&&Ot(e,t,i,u.pos),u.pos=t.length,null):Rt(It(n,u,i.state,d),o);if(d&&(h=d[0].name)&&(f="m-"+(f?h+" "+f:h)),!a||c!=f){for(;s=t:l.to>t),(i=i||[]).push(new qt(a,l.from,o?null:l.to)))}return i}(n,i,o),a=function(e,t,n){var i;if(e)for(var r=0;r=t:l.to>t))&&(l.from!=t||"bookmark"!=a.type||n&&!l.marker.insertLeft)||(o=null==l.from||(a.inclusiveLeft?l.from<=t:l.frome.lastLine())return t;var n,i=F(e,t);if(!on(e,i))return t;for(;n=Jt(i);)i=n.find(1,!0).line;return E(i)+1}function on(e,t){var n=jt&&t.markedSpans;if(n)for(var i,r=0;rn.maxLineLength&&(n.maxLineLength=t,n.maxLine=e)})}var cn=function(e,t,n){this.text=e,$t(this,t),this.height=n?n(this):1};cn.prototype.lineNo=function(){return E(this)},Xe(cn);var un={},dn={};function hn(e,t){return!e||/^\s*$/.test(e)?null:(t=t.addModeClass?dn:un)[e]||(t[e]=e.replace(/\S+/g,"cm-$&"))}function fn(e,t){var n=te("span",null,null,w?"padding-right: .1px":null),i={pre:te("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var r,o,l=0;l<=(t.rest?t.rest.length:0);l++){var a=l?t.rest[l-1]:t.line,s=void 0,c=(i.pos=0,i.addToken=mn,c=e.display.measure,o=r=void 0,(null!=tt?tt:(o=y(c,document.createTextNode("AخA")),r=oe(o,0,1).getBoundingClientRect(),o=oe(o,1,2).getBoundingClientRect(),ee(c),r&&r.left!=r.right&&(tt=o.right-r.right<3)))&&(s=_e(a,e.doc.direction))&&(i.addToken=function(d,h){return function(e,t,n,i,r,o,l){n=n?n+" cm-force-border":"cm-force-border";for(var a=e.pos,s=a+t.length;;){for(var c=void 0,u=0;ua&&c.from<=a);u++);if(c.to>=s)return d(e,t,n,i,r,o,l);d(e,t.slice(0,c.to-a),n,i,null,o,l),i=null,t=t.slice(c.to-a),a=c.to}}}(i.addToken,s)),i.map=[],t!=e.display.externalMeasured&&E(a));!function(e,t,n){var i=e.markedSpans,r=e.text,o=0;if(i)for(var l,a,s,c,u,d,h,f=r.length,p=0,m=1,g="",v=0;;){if(v==p){s=c=u=a="",d=h=null,v=1/0;for(var y=[],x=void 0,b=0;bp||C.collapsed&&w.to==p&&w.from==p)){if(null!=w.to&&w.to!=p&&v>w.to&&(v=w.to,c=""),C.className&&(s+=" "+C.className),C.css&&(a=(a?a+";":"")+C.css),C.startStyle&&w.from==p&&(u+=" "+C.startStyle),C.endStyle&&w.to==v&&(x=x||[]).push(C.endStyle,w.to),C.title&&((h=h||{}).title=C.title),C.attributes)for(var k in C.attributes)(h=h||{})[k]=C.attributes[k];C.collapsed&&(!d||Yt(d.marker,C)<0)&&(d=w)}else w.from>p&&v>w.from&&(v=w.from)}if(x)for(var S=0;Sn)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}}function Rn(e,t,n,i){return jn(e,zn(e,t),n,i)}function Bn(e,t){return t>=e.display.viewFrom&&t=e.lineN&&tt)&&(r=(o=s-a)-1,s<=t)&&(l="right"),null!=r){if(i=e[c+2],a==s&&n==(i.insertLeft?"left":"right")&&(l=n),"left"==n&&0==r)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)i=e[2+(c-=3)],l="left";if("right"==n&&r==s-a)for(;c=r.text.length?(u=r.text.length,e="before"):u<=0&&(u=0,e="after"),c?(s=Ie(c,u,e),t=He,s=d(u,s,"before"==e),null!=t&&(s.other=d(u,t,"before"!=e)),s):a("before"==e?u-1:u,"before"==e);function d(e,t,n){return a(n?e-1:e,1==c[t].level!=n)}}function ti(e,t){var n=0,t=(t=I(e.doc,t),e.options.lineWrapping||(n=ui(e.display)*t.ch),F(e.doc,t.line)),e=ln(t)+Fn(e.display);return{left:n,right:n,top:e,bottom:e+t.height}}function ni(e,t,n,i,r){e=O(e,t,n);return e.xRel=r,i&&(e.outside=i),e}function ii(e,t,n){var i=e.doc;if((n+=e.display.viewOffset)<0)return ni(i.first,0,null,-1,-1);var r=xt(i,n),o=i.first+i.size-1;if(o=s.bottom?1:0)}return u=Ee(e.text,u,1),ni(t,u,m,f,i-p)}(e,l,r,t,n),s=function(e,t){var n,i=jt&&e.markedSpans;if(i)for(var r=0;rt)&&(!n||Yt(n,o.marker)<0)&&(n=o.marker)}return n}(l,a.ch+(0i},r,e)}}function oi(e,t,n,i){return ri(e,t,n=n||zn(e,t),Zn(e,t,jn(e,n,i),"line").top)}function li(e,t,n,i){return!(e.bottom<=n)&&(e.top>n||(i?e.left:e.right)>t)}function ai(n,i,r,o,l,a,s){var e,t=Oe(function(e){var e=l[e],t=1!=e.level;return li(ei(n,O(r,t?e.to:e.from,t?"before":"after"),"line",i,o),a,s,!0)},0,l.length-1),c=l[t];return c=0s?l[t-1]:c}function si(e,t,n,i,r,o,l){for(var l=ri(e,t,i,l),a=l.begin,s=l.end,c=(/\s/.test(t.text.charAt(s-1))&&s--,null),u=null,d=0;d=s||f.to<=a||(h=(h=jn(e,i,1!=f.level?Math.min(s,f.to)-1:Math.max(a,f.from)).right)s?{from:c.from,to:s,level:c.level}:c}function ci(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==qn){qn=M("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)qn.appendChild(document.createTextNode("x")),qn.appendChild(M("br"));qn.appendChild(document.createTextNode("x"))}y(e.measure,qn);var n=qn.offsetHeight/50;return 3=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var n=e.display.view,i=0;it)&&(o.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=o.viewTo?jt&&nn(e.doc,t)o.viewFrom?yi(e):(o.viewFrom+=i,o.viewTo+=i):t<=o.viewFrom&&n>=o.viewTo?yi(e):t<=o.viewFrom?(l=xi(e,n,n+i,1))?(o.view=o.view.slice(l.index),o.viewFrom=l.lineN,o.viewTo+=i):yi(e):n>=o.viewTo?(l=xi(e,t,t,-1))?(o.view=o.view.slice(0,l.index),o.viewTo=l.lineN):yi(e):(l=xi(e,t,t,-1),r=xi(e,n,n+i,1),l&&r?(o.view=o.view.slice(0,l.index).concat(yn(e,l.lineN,r.lineN)).concat(o.view.slice(r.index)),o.viewTo+=i):yi(e)),o.externalMeasured);l&&(n=r.lineN&&t=i.viewTo||null!=(r=i.view[gi(e,t)]).node&&-1==k(i=r.changes||(r.changes=[]),n)&&i.push(n)}function yi(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function xi(e,t,n,i){var r,o=gi(e,t),l=e.display.view;if(jt&&n!=e.doc.first+e.doc.size){for(var a=e.display.viewFrom,s=0;s=e.display.viewTo||a.to().linet||t==n&&l.to==t)&&(i(Math.max(l.from,t),Math.min(l.to,n),1==l.level?"rtl":"ltr",o),r=!0)}r||i(t,n,"ltr")}(C,m||0,null==g?x:g,function(e,t,n,i){var r,o,l,a,s,c="ltr"==n,u=b(e,c?"left":"right"),d=b(t-1,c?"right":"left"),h=null==m&&0==e,f=null==g&&t==x,p=0==i,i=!C||i==C.length-1;d.top-u.top<=3?(r=(L?h:f)&&p?k:(c?u:d).left,s=(L?f:h)&&i?S:(c?d:u).right,T(r,u.top,s-r,u.bottom)):(s=c?(o=L&&h&&p?k:u.left,l=L?S:w(e,n,"before"),a=L?k:w(t,n,"after"),L&&f&&i?S:d.right):(o=L?w(e,n,"before"):k,l=!L&&h&&p?S:u.right,a=!L&&f&&i?k:d.left,L?w(t,n,"after"):S),T(o,u.top,l-o,u.bottom),u.bottome.display.sizerWidth&&(s=Math.ceil(u/ui(e.display)))>e.display.maxLineLength&&(e.display.maxLineLength=s,e.display.maxLine=a.line,e.display.maxLineChanged=!0)}}2=o&&(r=xt(t,ln(F(t,n))-e.wrapper.clientHeight),o=n)),{from:r,to:Math.max(o,r+1)}}function Oi(e,t){var n=e.display,i=ci(e.display),r=(t.top<0&&(t.top=0),(e.curOp&&null!=e.curOp.scrollTop?e.curOp:n.scroller).scrollTop),o=Wn(e),l={},a=(t.bottom-t.top>o&&(t.bottom=t.top+o),e.doc.height+En(n)),s=t.topa-i,i=(t.topr+o&&(s=Math.min(t.top,(i?a:t.bottom)-o))!=r&&(l.scrollTop=s),e.options.fixedGutter?0:n.gutters.offsetWidth),a=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:n.scroller.scrollLeft-i,o=In(e)-n.gutters.offsetWidth,r=t.right-t.left>o;return r&&(t.right=t.left+o),t.left<10?l.scrollLeft=0:t.lefto+a-3&&(l.scrollLeft=t.right+(r?0:10)-o),l}function Hi(e,t){null!=t&&(Pi(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc:e.curOp).scrollTop+t)}function Ii(e){Pi(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Wi(e,t,n){null==t&&null==n||Pi(e),null!=t&&(e.curOp.scrollLeft=t),null!=n&&(e.curOp.scrollTop=n)}function Pi(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,Ri(e,ti(e,t.from),ti(e,t.to),t.margin))}function Ri(e,t,n,i){t=Oi(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-i,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+i});Wi(e,t.scrollLeft,t.scrollTop)}function Bi(e,t){Math.abs(e.doc.scrollTop-t)<2||(g||ir(e,{top:t}),zi(e,t,!0),g&&ir(e),Qi(e,100))}function zi(e,t,n){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!n||(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop==t)||(e.display.scroller.scrollTop=t)}function ji(e,t,n,i){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!i||(e.doc.scrollLeft=t,lr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function qi(e){var t=e.display,n=t.gutters.offsetWidth,i=Math.round(e.doc.height+En(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:i,scrollHeight:i+Hn(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}function _i(e,t,n){this.cm=n;var i=this.vert=M("div",[M("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),r=this.horiz=M("div",[M("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");i.tabIndex=r.tabIndex=-1,e(i),e(r),S(i,"scroll",function(){i.clientHeight&&t(i.scrollTop,"vertical")}),S(r,"scroll",function(){r.clientWidth&&t(r.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,b&&v<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function Ui(){}_i.prototype.update=function(e){var t,n=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;return i?(this.vert.style.display="block",this.vert.style.bottom=n?r+"px":"0",t=e.viewHeight-(n?r:0),this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+t)+"px"):(this.vert.scrollTop=0,this.vert.style.display="",this.vert.firstChild.style.height="0"),n?(this.horiz.style.display="block",this.horiz.style.right=i?r+"px":"0",this.horiz.style.left=e.barLeft+"px",t=e.viewWidth-e.barLeft-(i?r:0),this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+t)+"px"):(this.horiz.style.display="",this.horiz.firstChild.style.width="0"),!this.checkedZeroWidth&&0=l.viewTo)||l.maxLineChanged&&o.options.lineWrapping,r.update=r.mustUpdate&&new er(o,r.mustUpdate&&{top:r.scrollTop,ensure:r.scrollToPos},r.forceUpdate)}for(var a=0;a(r.defaultView.innerHeight||r.documentElement.clientHeight)&&(i=!1),null==i)||V||(o=M("div","​",null,"position: absolute;\n top: "+(t.top-n.viewOffset-Fn(e.display))+"px;\n height: "+(t.bottom-t.top+Hn(e)+n.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;"),e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o))}(b,v));var k=x.maybeHiddenMarkers,S=x.maybeUnhiddenMarkers;if(k)for(var L=0;L=l.display.viewTo||(a=+new Date+l.options.workTime,s=Et(l,u.highlightFrontier),c=[],u.iter(s.line,Math.min(u.first+u.size,l.display.viewTo+500),function(e){if(s.line>=l.display.viewFrom){for(var t=e.styles,n=e.text.length>l.options.maxHighlightLength?ft(u.mode,s.state):null,i=At(l,e,s,!0),n=(n&&(s.state=n),e.styles=i.styles,e.styleClasses),i=i.classes,r=(i?e.styleClasses=i:n&&(e.styleClasses=null),!t||t.length!=e.styles.length||n!=i&&(!n||!i||n.bgClass!=i.bgClass||n.textClass!=i.textClass)),o=0;!r&&oa)return Qi(l,l.options.workDelay),!0}),u.highlightFrontier=s.line,u.modeFrontier=Math.max(u.modeFrontier,s.line),c.length&&d(l,function(){for(var e=0;e=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==bi(e))return!1;ar(e)&&(yi(e),t.dims=di(e));var r=i.first+i.size,o=Math.max(t.visible.from-e.options.viewportMargin,i.first),l=Math.min(r,t.visible.to+e.options.viewportMargin),i=(n.viewFroml&&n.viewTo-l<20&&(l=Math.min(r,n.viewTo)),jt&&(o=nn(e.doc,o),l=rn(e.doc,l)),o!=n.viewFrom||l!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth),r=(r=o,o=l,0==(a=(l=e).display).view.length||r>=a.viewTo||o<=a.viewFrom?(a.view=yn(l,r,o),a.viewFrom=r):(a.viewFrom>r?a.view=yn(l,r,a.viewFrom).concat(a.view):a.viewFromo&&(a.view=a.view.slice(0,gi(l,o)))),a.viewTo=o,n.viewOffset=ln(F(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px",bi(e));if(!i&&0==r&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var a,l=!(l=e).hasFocus()&&(a=N(se(l)))&&ne(l.display.lineDiv,a)?(a={activeElt:a},window.getSelection&&(o=ue(l).getSelection()).anchorNode&&o.extend&&ne(l.display.lineDiv,o.anchorNode)&&(a.anchorNode=o.anchorNode,a.anchorOffset=o.anchorOffset,a.focusNode=o.focusNode,a.focusOffset=o.focusOffset),a):null,s=(4=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!tr(e,t))break;Ai(e);var r=qi(e);wi(e),Gi(e,r),or(e,r),t.force=!1}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 ir(e,t){var n,t=new er(e,t);tr(e,t)&&(Ai(e),nr(e,t),n=qi(e),wi(e),Gi(e,n),or(e,n),t.finish())}function rr(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px",x(e,"gutterChanged",e)}function or(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Hn(e)+"px"}function lr(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var i=hi(t)-t.scroller.scrollLeft+e.doc.scrollLeft,r=t.gutters.offsetWidth,o=i+"px",l=0;ls.clientWidth,u=s.scrollHeight>s.clientHeight;if(o&&c||r&&u){if(r&&C&&w)e:for(var d=t.target,h=a.view;d!=s;d=d.parentNode)for(var f=0;fa-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(o=(o=l).lastOp==i?(Er(o.done),R(o.done)):o.done.length&&!R(o.done).ranges?R(o.done):1l.undoDepth;)l.done.shift(),l.done[0].ranges||l.done.shift()}l.done.push(n),l.generation=++l.maxGeneration,l.lastModTime=l.lastSelTime=a,l.lastOp=l.lastSelOp=i,l.lastOrigin=l.lastSelOrigin=t.origin,r||D(e,"historyAdded")}function Hr(e,t,n,i){var r,o,l,a=e.history,s=i&&i.origin;n==a.lastSelOp||s&&a.lastSelOrigin==s&&(a.lastModTime==a.lastSelTime&&a.lastOrigin==s||(e=e,r=s,o=R(a.done),l=t,"*"==(r=r.charAt(0)))||"+"==r&&o.ranges.length==l.ranges.length&&o.somethingSelected()==l.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500))?a.done[a.done.length-1]=t:Ir(t,a.done),a.lastSelTime=+new Date,a.lastSelOrigin=s,a.lastSelOp=n,i&&!1!==i.clearRedo&&Er(a.undone)}function Ir(e,t){var n=R(t);n&&n.ranges&&n.equals(e)||t.push(e)}function Wr(t,n,e,i){var r=n["spans_"+t.id],o=0;t.iter(Math.max(t.first,e),Math.min(t.first+t.size,i),function(e){e.markedSpans&&((r=r||(n["spans_"+t.id]={}))[o]=e.markedSpans),++o})}function Pr(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var i=[],r=0;r=t.ch:a.to>t.ch))){if(r&&(D(s,"beforeCursorEnter"),s.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(s.atomic){if(n){var a=s.find(i<0?1:-1),d=void 0;if((a=(i<0?u:c)?Qr(e,a,-i,a&&a.line==t.line?o:null):a)&&a.line==t.line&&(d=H(a,n))&&(i<0?d<0:0e.first?I(e,O(t.line-1)):null:0e.lastLine())){t.from.liner?{from:t.from,to:O(r,F(e,r).text.length),text:[t.text[0]],origin:t.origin}:t).removed=gt(e,t.from,t.to),n=n||wr(e,t),e.cm){var r=e.cm,o=t,l=i,a=r.doc,s=r.display,c=o.from,u=o.to,d=!1,h=c.line,f=(r.options.lineWrapping||(h=E(tn(F(a,c.line))),a.iter(h,u.line+1,function(e){if(e==s.maxLine)return d=!0})),-1s.maxLineLength&&(s.maxLine=e,s.maxLineLength=t,s.maxLineChanged=!0,d=!1)}),d&&(r.curOp.updateMaxLine=!0)),a),p=c.line;if(f.modeFrontier=Math.min(f.modeFrontier,p),!(f.highlightFrontiert.display.maxLineLength&&(t.display.maxLine=c,t.display.maxLineLength=u,t.display.maxLineChanged=!0)}null!=i&&t&&this.collapsed&&W(t,i,r+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t)&&Xr(t.doc),t&&x(t,"markerCleared",t,this,i,r),n&&Zi(t),this.parent&&this.parent.clear()}},go.prototype.find=function(e,t){var n,i;null==e&&"bookmark"==this.type&&(e=1);for(var r=0;r=e.ch)&&t.push(r.marker.parent||r.marker)}return t},findMarks:function(r,o,l){r=I(this,r),o=I(this,o);var a=[],s=r.line;return this.iter(r.line,o.line+1,function(e){var t=e.markedSpans;if(t)for(var n=0;n=i.to||null==i.from&&s!=r.line||null!=i.from&&s==o.line&&i.from>=o.ch||l&&!l(i.marker)||a.push(i.marker.parent||i.marker)}++s}),a},getAllMarks:function(){var i=[];return this.iter(function(e){var t=e.markedSpans;if(t)for(var n=0;nt&&(t=e.from),null!=e.to&&e.toe.text.length?null:t}function Uo(e,t,n){e=_o(e,t.ch,n);return null==e?null:new O(t.line,e,n<0?"after":"before")}function Go(e,t,n,i,r){if(e){"rtl"==t.doc.direction&&(r=-r);var o,l,a,s,e=_e(n,t.doc.direction);if(e)return o=r<0==(1==(e=r<0?R(e):e[0]).level)?"after":"before",0=n.text.length?(a.ch=n.text.length,a.sticky="before"):a.ch<=0&&(a.ch=0,a.sticky="after");var i=Ie(s,a.ch,a.sticky),r=s[i];if("ltr"==t.doc.direction&&r.level%2==0&&(0a.ch:r.from=r.from&&h>=u.begin))return new O(a.line,h,d?"before":"after")}function f(e,t,n){for(var i=function(e,t){return t?new O(a.line,c(e,1),"before"):new O(a.line,e,"after")};0<=e&&el.doc.first&&(n=F(l.doc,e.line-1).text)&&(e=new O(e.line,1),l.replaceRange(t.charAt(0)+l.doc.lineSeparator()+n.charAt(n.length-1),O(e.line-1,n.length-1),e,"+transpose"))),r.push(new z(e,e)));l.setSelections(r)})},newlineAndIndent:function(i){return d(i,function(){for(var e=(t=i.listSelections()).length-1;0<=e;e--)i.replaceRange(i.doc.lineSeparator(),t[e].anchor,t[e].head,"+input");for(var t=i.listSelections(),n=0;nu&&t.push(new z(O(a,u),O(a,be(c,l,n))))}t.length||t.push(new z(f,f)),j(m,vr(h,y.ranges.slice(0,v).concat(t),v),{origin:"*mouse",scroll:!1}),h.scrollIntoView(e)}else{var d,i=g,r=cl(h,e,p.unit),e=i.anchor,e=0=n.to||o.lines.bottom?20:0)&&setTimeout(P(h,function(){c==r&&(l.scroller.scrollTop+=i,e(t))}),50))}:n)(e)}),r=P(h,n);h.state.selectingText=r,S(l.wrapper.ownerDocument,"mousemove",i),S(l.wrapper.ownerDocument,"mouseup",r)})(r,a,o,s)):Qe(e)==d.scroller&&T(e):2==n?(t&&jr(u.doc,t),setTimeout(function(){return d.input.focus()},20)):3==n&&(Z?u.display.input.onContextMenu(e):Mi(u))))}function cl(e,t,n){return"char"==n?new z(t,t):"word"==n?e.findWordAt(t):"line"==n?new z(O(t.line,0),I(e.doc,O(t.line+1,0))):(n=n(e,t),new z(n.from,n.to))}function ul(e,t,n,i){var r,o;if(t.touches)r=t.touches[0].clientX,o=t.touches[0].clientY;else try{r=t.clientX,o=t.clientY}catch(e){return!1}if(r>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;i&&T(t);var l=e.display,i=l.lineDiv.getBoundingClientRect();if(o>i.bottom||!$e(e,n))return Ye(t);o-=i.top-l.viewOffset;for(var a=0;a=r)return D(e,n,e,xt(e.doc,o),e.display.gutterSpecs[a].className,t),Ye(t)}}function dl(e,t){return ul(e,t,"gutterClick",!0)}function hl(e,t){var n,i;An(e.display,t)||(i=t,$e(n=e,"gutterContextMenu")&&ul(n,i,"gutterContextMenu",!1))||(A(e,t,"contextmenu")||Z||e.display.input.onContextMenu(t))}function fl(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),$n(e)}ol.prototype.compare=function(e,t,n){return this.time+400>e&&0==H(t,this.pos)&&n==this.button};var pl={toString:function(){return"CodeMirror.Init"}},ml={},gl={};function vl(e,t,n){!t!=!(n&&n!=pl)&&(n=e.display.dragFunctions,(t=t?S:L)(e.display.scroller,"dragstart",n.start),t(e.display.scroller,"dragenter",n.enter),t(e.display.scroller,"dragover",n.over),t(e.display.scroller,"dragleave",n.leave),t(e.display.scroller,"drop",n.drop))}function yl(e){e.options.lineWrapping?(ie(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(J(e.display.wrapper,"CodeMirror-wrap"),sn(e)),pi(e),W(e),$n(e),setTimeout(function(){return Gi(e)},100)}function p(e,t){var n=this;if(!(this instanceof p))return new p(e,t);this.options=t=t?he(t):{},he(ml,t,!1);var i,r=t.value,o=("string"==typeof r?r=new f(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r,new p.inputStyles[t.inputStyle](this)),e=this.display=new dr(e,r,o,t),l=(fl(e.wrapper.CodeMirror=this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Xi(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new pe,keySeq:null,specialChars:null},t.autofocus&&!X&&e.input.focus(),b&&v<11&&setTimeout(function(){return n.display.input.reset(!0)},20),this),a=l.display;S(a.scroller,"mousedown",P(l,sl)),S(a.scroller,"dblclick",b&&v<11?P(l,function(e){var t;A(l,e)||!(t=mi(l,e))||dl(l,e)||An(l.display,e)||(T(e),e=l.findWordAt(t),jr(l.doc,e.anchor,e.head))}):function(e){return A(l,e)||T(e)}),S(a.scroller,"contextmenu",function(e){return hl(l,e)}),S(a.input.getField(),"contextmenu",function(e){a.scroller.contains(e.target)||hl(l,e)});var s,c={end:0};function u(){a.activeTouch&&(s=setTimeout(function(){return a.activeTouch=null},1e3),(c=a.activeTouch).end=+new Date)}function d(e,t){var n;return null==t.left||400<(n=t.left-e.left)*n+(n=t.top-e.top)*n}S(a.scroller,"touchstart",function(e){var t;A(l,e)||function(e){if(1==e.touches.length)return(e=e.touches[0]).radiusX<=1&&e.radiusY<=1}(e)||dl(l,e)||(a.input.ensurePolled(),clearTimeout(s),t=+new Date,a.activeTouch={start:t,moved:!1,prev:t-c.end<=300?c:null},1==e.touches.length&&(a.activeTouch.left=e.touches[0].pageX,a.activeTouch.top=e.touches[0].pageY))}),S(a.scroller,"touchmove",function(){a.activeTouch&&(a.activeTouch.moved=!0)}),S(a.scroller,"touchend",function(e){var t,n=a.activeTouch;n&&!An(a,e)&&null!=n.left&&!n.moved&&new Date-n.start<300&&(t=l.coordsChar(a.activeTouch,"page"),n=!n.prev||d(n,n.prev)?new z(t,t):!n.prev.prev||d(n,n.prev.prev)?l.findWordAt(t):new z(O(t.line,0),I(l.doc,O(t.line+1,0))),l.setSelection(n.anchor,n.head),l.focus(),T(e)),u()}),S(a.scroller,"touchcancel",u),S(a.scroller,"scroll",function(){a.scroller.clientHeight&&(Bi(l,a.scroller.scrollTop),ji(l,a.scroller.scrollLeft,!0),D(l,"scroll",l))}),S(a.scroller,"mousewheel",function(e){return gr(l,e)}),S(a.scroller,"DOMMouseScroll",function(e){return gr(l,e)}),S(a.wrapper,"scroll",function(){return a.wrapper.scrollTop=a.wrapper.scrollLeft=0}),a.dragFunctions={enter:function(e){A(l,e)||Ze(e)},over:function(e){var t,n;A(l,e)||((n=mi(t=l,n=e))&&(ki(t,n,n=document.createDocumentFragment()),t.display.dragCursor||(t.display.dragCursor=M("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),t.display.lineSpace.insertBefore(t.display.dragCursor,t.display.cursorDiv)),y(t.display.dragCursor,n)),Ze(e))},start:function(e){var t,n;t=l,e=e,b&&(!t.state.draggingText||+new Date-ko<100)?Ze(e):A(t,e)||An(t.display,e)||(e.dataTransfer.setData("Text",t.getSelection()),e.dataTransfer.effectAllowed="copyMove",e.dataTransfer.setDragImage&&!G&&((n=M("img",null,null,"position: fixed; left: 0; top: 0;")).src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",U&&(n.width=n.height=1,t.display.wrapper.appendChild(n),n._top=n.offsetTop),e.dataTransfer.setDragImage(n,0,0),U)&&n.parentNode.removeChild(n))},drop:P(l,So),leave:function(e){A(l,e)||Lo(l)}};o=a.input.getField();for(i in S(o,"keyup",function(e){return il.call(l,e)}),S(o,"keydown",P(l,nl)),S(o,"keypress",P(l,rl)),S(o,"focus",function(e){return Ni(l,e)}),S(o,"blur",function(e){return Di(l,e)}),No(),Yi(this),this.curOp.forceUpdate=!0,Nr(this,r),t.autofocus&&!X||this.hasFocus()?setTimeout(function(){n.hasFocus()&&!n.state.focused&&Ni(n)},20):Di(this),gl)gl.hasOwnProperty(i)&&gl[i](this,t[i],pl);ar(this),t.finishInit&&t.finishInit(this);for(var h=0;ho.first?fe(F(o,t-1).text,null,l):0:"add"==n?u=s+e.options.indentUnit:"subtract"==n?u=s-e.options.indentUnit:"number"==typeof n&&(u=s+n);var u=Math.max(0,u),d="",h=0;if(e.options.indentWithTabs)for(var f=Math.floor(u/l);f;--f)h+=l,d+="\t";if(hl,s=it(t),c=null;if(a&&1l?"cut":"+input")});to(e.doc,f),x(e,"inputRead",e,f)}t&&!a&&Ll(e,t),Ii(e),e.curOp.updateInput<2&&(e.curOp.updateInput=d),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Sl(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");return n&&(e.preventDefault(),t.isReadOnly()||t.options.disableInput||!t.hasFocus()||d(t,function(){return kl(t,n,0,null,"paste")}),1)}function Ll(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,i=n.ranges.length-1;0<=i;i--){var r=n.ranges[i];if(!(100=n.first+n.size||(i=new O(e,i.ch,i.sticky),!(a=F(n,e))))return;i=Go(l,n.cm,a,i.line,s)}else i=t;return 1}if("char"==o||"codepoint"==o)c();else if("column"==o)c(!0);else if("word"==o||"group"==o)for(var u=null,d="group"==o,h=n.cm&&n.cm.getHelper(i,"wordChars"),f=!0;!(r<0)||c(!f);f=!1){var p=a.text.charAt(i.ch)||"\n",p=Ne(p,h)?"w":d&&"\n"==p?"n":!d||/\s/.test(p)?null:"p";if(d&&!f&&(p=p||"s"),u&&u!=p){r<0&&(r=1,c(),i.sticky="after");break}if(p&&(u=p),0=a.height){l.hitSide=!0;break}o+=5*n}return l}function r(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new pe,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null}function Fl(e,t){var n,i,r=Bn(e,t.line);return!r||r.hidden?null:(n=Pn(r,r=F(e.doc,t.line),t.line),i="left",(r=_e(r,e.doc.direction))&&(i=Ie(r,t.ch)%2?"right":"left"),(e=Un(n.map,t.ch,i)).offset="right"==e.collapse?e.end:e.start,e)}function El(e,t){return t&&(e.bad=!0),e}function Ol(e,t,n){var i;if(t==e.display.lineDiv){if(!(i=e.display.lineDiv.childNodes[n]))return El(e.clipPos(O(e.display.viewTo-1)),!0);t=null,n=0}else for(i=t;;i=i.parentNode){if(!i||i==e.display.lineDiv)return null;if(i.parentNode&&i.parentNode==e.display.lineDiv)break}for(var r=0;r=t.display.viewTo||n.line=t.display.viewFrom&&Fl(t,i)||{node:r[0].measure.map[2],offset:0},i=n.linet.firstLine()&&(r=O(r.line-1,F(t.doc,r.line-1).length)),i.ch==F(t.doc,i.line).text.length&&i.linen.viewTo-1)return!1;var o,l=r.line==n.viewFrom||0==(l=gi(t,r.line))?(e=E(n.view[0].line),n.view[0].node):(e=E(n.view[l].line),n.view[l-1].node.nextSibling),i=gi(t,i.line),n=i==n.view.length-1?(o=n.viewTo-1,n.lineDiv.lastChild):(o=E(n.view[i+1].line)-1,n.view[i+1].node.previousSibling);if(!l)return!1;for(var a=t.doc.splitLines(function(o,e,t,l,a){var n="",s=!1,c=o.doc.lineSeparator(),u=!1;function d(){s&&(n+=c,u&&(n+=c),s=u=!1)}function h(e){e&&(d(),n+=e)}for(;!function e(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(n)h(n);else if(n=t.getAttribute("cm-marker"))(n=o.findMarks(O(l,0),O(a+1,0),(r=+n,function(e){return e.id==r}))).length&&(n=n[0].find(0))&&h(gt(o.doc,n.from,n.to).join(c));else if("false"!=t.getAttribute("contenteditable")&&(n=/^(pre|div|p|li|table|br)$/i.test(t.nodeName),/^br$/i.test(t.nodeName)||0!=t.textContent.length)){n&&d();for(var i=0;ir.ch&&p.charCodeAt(p.length-u-1)==m.charCodeAt(m.length-u-1);)c--,u++;a[a.length-1]=p.slice(0,p.length-u).replace(/^\u200b+/,""),a[0]=a[0].slice(c).replace(/\u200b+$/,"");i=O(e,c),l=O(o,s.length?R(s).length-u:0);return 1n&&(bl(this,r.head.line,e,!0),n=r.head.line,i==this.doc.sel.primIndex)&&Ii(this);else{for(var o=r.from(),r=r.to(),l=Math.max(n,o.line),n=Math.min(this.lastLine(),r.line-(r.ch?0:1))+1,a=l;a>1;if((l?n[2*l-1]:0)>=o)r=l;else{if(!(n[2*l+1]l)&&e.top>t.offsetHeight?s=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=l&&(s=e.bottom),c+t.offsetWidth>o&&(c=o-t.offsetWidth)),t.style.top=s+"px",t.style.left=t.style.right="","right"==r?(c=a.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==r?c=0:"middle"==r&&(c=(a.sizer.clientWidth-t.offsetWidth)/2),t.style.left=c+"px"),n&&(i=this,l={left:c,top:s,right:c+t.offsetWidth,bottom:s+t.offsetHeight},null!=(l=Oi(i,l)).scrollTop&&Bi(i,l.scrollTop),null!=l.scrollLeft)&&ji(i,l.scrollLeft)},triggerOnKeyDown:n(nl),triggerOnKeyPress:n(rl),triggerOnKeyUp:il,triggerOnMouseDown:n(sl),execCommand:function(e){if($o.hasOwnProperty(e))return $o[e].call(null,this)},triggerElectric:n(function(e){Ll(this,e)}),findPosH:function(e,t,n,i){for(var r=1,o=(t<0&&(r=-1,t=-t),I(this.doc,e)),l=0;l]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i;l.defineMode("gfm",function(e,i){var r=0;var t,n={startState:function(){return{code:!1,codeBlock:!1,ateSpace:!1}},copyState:function(e){return{code:e.code,codeBlock:e.codeBlock,ateSpace:e.ateSpace}},token:function(e,t){var n;if(t.combineTokens=null,t.codeBlock)e.match(/^```+/)?t.codeBlock=!1:e.skipToEnd();else if(e.sol()&&(t.code=!1),e.sol()&&e.match(/^```+/))e.skipToEnd(),t.codeBlock=!0;else if("`"===e.peek())e.next(),n=e.pos,e.eatWhile("`"),n=1+e.pos-n,t.code?n===r&&(t.code=!1):(r=n,t.code=!0);else if(t.code)e.next();else if(e.eatSpace())t.ateSpace=!0;else{if((e.sol()||t.ateSpace)&&(t.ateSpace=!1)!==i.gitHubSpice){if(e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?=.{0,6}\d)(?:[a-f0-9]{7,40}\b)/))return t.combineTokens=!0,"link";if(e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/))return t.combineTokens=!0,"link"}if(e.match(a)&&"]("!=e.string.slice(e.start-2,e.start)&&(0==e.start||/\W/.test(e.string.charAt(e.start-1))))return t.combineTokens=!0,"link";e.next()}return null},blankLine:function(e){return e.code=!1,null}},o={taskLists:!0,strikethrough:!0,emoji:!0};for(t in i)o[t]=i[t];return o.name="markdown",l.overlayMode(l.getMode(e,o),n)},"markdown"),l.defineMIME("text/x-gfm","gfm")},"object"==typeof n&&"object"==typeof t?i(e("../../lib/codemirror"),e("../markdown/markdown"),e("../../addon/mode/overlay")):i(CodeMirror)},{"../../addon/mode/overlay":6,"../../lib/codemirror":8,"../markdown/markdown":10}],10:[function(e,t,n){var i;i=function(E){"use strict";E.defineMode("markdown",function(h,f){var d=E.getMode(h,"text/html"),r="null"==d.name;void 0===f.highlightFormatting&&(f.highlightFormatting=!1),void 0===f.maxBlockquoteDepth&&(f.maxBlockquoteDepth=0),void 0===f.taskLists&&(f.taskLists=!1),void 0===f.strikethrough&&(f.strikethrough=!1),void 0===f.emoji&&(f.emoji=!1),void 0===f.fencedCodeBlockHighlighting&&(f.fencedCodeBlockHighlighting=!0),void 0===f.fencedCodeBlockDefaultMode&&(f.fencedCodeBlockDefaultMode="text/plain"),void 0===f.xml&&(f.xml=!0),void 0===f.tokenTypeOverrides&&(f.tokenTypeOverrides={});var e,p={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(e in p)p.hasOwnProperty(e)&&f.tokenTypeOverrides[e]&&(p[e]=f.tokenTypeOverrides[e]);var m=/^([*\-_])(?:\s*\1){2,}\s*$/,g=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,v=/^\[(x| )\](?=\s)/i,y=f.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,x=/^ {0,3}(?:\={1,}|-{2,})\s*$/,n=/^[^#!\[\]*_\\<>` "'(~:]+/,b=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,w=/^\s*\[[^\]]+?\]:.*$/,C=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/;function k(e,t,n){return(t.f=t.inline=n)(e,t)}function S(e,t,n){return(t.f=t.block=n)(e,t)}function i(e){var t;return e.linkTitle=!1,e.linkHref=!1,e.linkText=!1,e.em=!1,e.strong=!1,e.strikethrough=!1,e.quote=0,e.indentedCode=!1,e.f==L&&(r||"xml"==(t=E.innerMode(d,e.htmlState)).mode.name&&null===t.state.tagStart&&!t.state.context&&t.state.tokenize.isInText)&&(e.f=N,e.block=o,e.htmlState=null),e.trailingSpace=0,e.trailingSpaceNewLine=!1,e.prevLine=e.thisLine,e.thisLine={stream:null},null}function o(e,t){var n=e.column()===t.indentation,i=!(i=t.prevLine.stream)||!/\S/.test(i.string),r=t.indentedCode,o=t.prevLine.hr,l=!1!==t.list,a=(t.listStack[t.listStack.length-1]||0)+3,s=(t.indentedCode=!1,t.indentation);if(null===t.indentationDiff&&(t.indentationDiff=t.indentation,l)){for(t.list=null;s")?(t.quote=n?1:t.quote+1,f.highlightFormatting&&(t.formatting="quote"),e.eatSpace(),M(t)):!o&&!t.setext&&n&&t.indentation<=a&&(d=e.match(g))?(r=d[1]?"ol":"ul",t.indentation=s+e.current().length,t.list=!0,t.quote=0,t.listStack.push(t.indentation),t.em=!1,t.strong=!1,t.code=!1,t.strikethrough=!1,f.taskLists&&e.match(v,!1)&&(t.taskList=!0),t.f=t.inline,f.highlightFormatting&&(t.formatting=["list","list-"+r]),M(t)):n&&t.indentation<=a&&(d=e.match(b,!0))?(t.quote=0,t.fencedEndRE=new RegExp(d[1]+"+ *$"),t.localMode=f.fencedCodeBlockHighlighting&&(i=d[2]||f.fencedCodeBlockDefaultMode,E.findModeByName&&(c=E.findModeByName(i))&&(i=c.mime||c.mimes[0]),"null"==(c=E.getMode(h,i)).name?null:c),t.localMode&&(t.localState=E.startState(t.localMode)),t.f=t.block=T,f.highlightFormatting&&(t.formatting="code-block"),t.code=-1,M(t)):t.setext||!(u&&l||t.quote||!1!==t.list||t.code||o||w.test(e.string))&&(d=(d=e.lookAhead(1))&&d.match(x))?(t.setext?(t.header=t.setext,t.setext=0,e.skipToEnd(),f.highlightFormatting&&(t.formatting="header")):(t.header="="==d[0].charAt(0)?1:2,t.setext=t.header),t.thisLine.header=!0,t.f=t.inline,M(t)):o?(e.skipToEnd(),t.hr=!0,t.thisLine.hr=!0,p.hr):"["===e.peek()?k(e,t,F):k(e,t,t.inline)}function L(e,t){var n,i=d.token(e,t.htmlState);return!r&&("xml"==(n=E.innerMode(d,t.htmlState)).mode.name&&null===n.state.tagStart&&!n.state.context&&n.state.tokenize.isInText||t.md_inside&&-1"))&&(t.f=N,t.block=o,t.htmlState=null),i}function T(e,t){var n,i=t.listStack[t.listStack.length-1]||0,r=t.indentation=e.quote?n.push(p.formatting+"-"+e.formatting[i]+"-"+e.quote):n.push("error"))}return e.taskOpen?n.push("meta"):e.taskClosed?n.push("property"):(e.linkHref?n.push(p.linkHref,"url"):(e.strong&&n.push(p.strong),e.em&&n.push(p.em),e.strikethrough&&n.push(p.strikethrough),e.emoji&&n.push(p.emoji),e.linkText&&n.push(p.linkText),e.code&&n.push(p.code),e.image&&n.push(p.image),e.imageAltText&&n.push(p.imageAltText,"link"),e.imageMarker&&n.push(p.imageMarker)),e.header&&n.push(p.header,p.header+"-"+e.header),e.quote&&(n.push(p.quote),!f.maxBlockquoteDepth||f.maxBlockquoteDepth>=e.quote?n.push(p.quote+"-"+e.quote):n.push(p.quote+"-"+f.maxBlockquoteDepth)),!1!==e.list&&(t=(e.listStack.length-1)%3,n.push(t?1==t?p.list2:p.list3:p.list1)),e.trailingSpaceNewLine?n.push("trailing-space-new-line"):e.trailingSpace&&n.push("trailing-space-"+(e.trailingSpace%2?"a":"b"))),n.length?n.join(" "):null}function t(e,t){if(e.match(n,!0))return M(t)}function N(e,t){var n=t.text(e,t);if(void 0!==n)return n;if(t.list)t.list=null;else if(t.taskList)" "===e.match(v,!0)[1]?t.taskOpen=!0:t.taskClosed=!0,f.highlightFormatting&&(t.formatting="task"),t.taskList=!1;else if(t.taskOpen=!1,t.taskClosed=!1,t.header&&e.match(/^#+$/,!0))f.highlightFormatting&&(t.formatting="header");else{var i=e.next();if(t.linkTitle){t.linkTitle=!1;var n=((n="("===i?")":i)+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");if(e.match(new RegExp("^\\s*(?:[^"+n+"\\\\]+|\\\\\\\\|\\\\.)"+n),!0))return p.linkHref}if("`"===i)return n=t.formatting,f.highlightFormatting&&(t.formatting="code"),e.eatWhile("`"),a=e.current().length,0!=t.code||t.quote&&1!=a?a==t.code?(l=M(t),t.code=0,l):(t.formatting=n,M(t)):(t.code=a,M(t));if(!t.code){if("\\"===i)if(e.next(),f.highlightFormatting)return o=M(t),n=p.formatting+"-escape",o?o+" "+n:n;if("!"===i&&e.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))t.imageMarker=!0,t.image=!0,f.highlightFormatting&&(t.formatting="image");else if("["===i&&t.imageMarker&&e.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))t.imageMarker=!1,t.imageAltText=!0,f.highlightFormatting&&(t.formatting="image");else{if("]"===i&&t.imageAltText)return f.highlightFormatting&&(t.formatting="image"),o=M(t),t.imageAltText=!1,t.image=!1,t.inline=t.f=A,o;if("["!==i||t.image){if("]"===i&&t.linkText)return f.highlightFormatting&&(t.formatting="link"),o=M(t),t.linkText=!1,t.inline=t.f=e.match(/\(.*?\)| ?\[.*?\]/,!1)?A:N,o;if("<"===i&&e.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1))return t.f=t.inline=D,f.highlightFormatting&&(t.formatting="link"),(o=M(t))?o+=" ":o="",o+p.linkInline;if("<"===i&&e.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1))return t.f=t.inline=D,f.highlightFormatting&&(t.formatting="link"),(o=M(t))?o+=" ":o="",o+p.linkEmail;if(f.xml&&"<"===i&&e.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1))return-1!=(a=e.string.indexOf(">",e.pos))&&(n=e.string.substring(e.start,a),/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(n))&&(t.md_inside=!0),e.backUp(1),t.htmlState=E.startState(d),S(e,t,L);if(f.xml&&"<"===i&&e.match(/^\/\w*?>/))return t.md_inside=!1,"tag";if("*"===i||"_"===i){for(var r=1,o=1==e.pos?" ":e.string.charAt(e.pos-2);r<3&&e.eat(i);)r++;var l,a=e.peek()||" ",n=!/\s/.test(a)&&(!C.test(a)||/\s/.test(o)||C.test(o)),s=!/\s/.test(o)&&(!C.test(o)||/\s/.test(a)||C.test(a)),c=null,u=null;if(r%2&&(t.em||!n||"*"!==i&&s&&!C.test(o)?t.em!=i||!s||"*"!==i&&n&&!C.test(a)||(c=!1):c=!0),1"===e.next()?(t.f=t.inline=N,f.highlightFormatting&&(t.formatting="link"),(t=M(t))?t+=" ":t="",t+p.linkInline):(e.match(/^[^>]+/,!0),p.linkInline)}function A(e,t){var i;return e.eatSpace()?null:"("===(e=e.next())||"["===e?(t.f=t.inline=(i="("===e?")":"]",function(e,t){var n;return e.next()===i?(t.f=t.inline=N,f.highlightFormatting&&(t.formatting="link-string"),n=M(t),t.linkHref=!1,n):(e.match(l[i]),t.linkHref=!0,M(t))}),f.highlightFormatting&&(t.formatting="link-string"),t.linkHref=!0,M(t)):"error"}var l={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function F(e,t){return e.match(/^([^\]\\]|\\.)*\]:/,!1)?(t.f=a,e.next(),f.highlightFormatting&&(t.formatting="link"),t.linkText=!0,M(t)):k(e,t,N)}function a(e,t){var n;return e.match("]:",!0)?(t.f=t.inline=s,f.highlightFormatting&&(t.formatting="link"),n=M(t),t.linkText=!1,n):(e.match(/^([^\]\\]|\\.)+/,!0),p.linkText)}function s(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=N,p.linkHref+" url")}var c={startState:function(){return{f:o,prevLine:{stream:null},thisLine:{stream:null},block:o,htmlState:null,indentation:0,inline:N,text:t,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(e){return{f:e.f,prevLine:e.prevLine,thisLine:e.thisLine,block:e.block,htmlState:e.htmlState&&E.copyState(d,e.htmlState),indentation:e.indentation,localMode:e.localMode,localState:e.localMode?E.copyState(e.localMode,e.localState):null,inline:e.inline,text:e.text,formatting:!1,linkText:e.linkText,linkTitle:e.linkTitle,linkHref:e.linkHref,code:e.code,em:e.em,strong:e.strong,strikethrough:e.strikethrough,emoji:e.emoji,header:e.header,setext:e.setext,hr:e.hr,taskList:e.taskList,list:e.list,listStack:e.listStack.slice(0),quote:e.quote,indentedCode:e.indentedCode,trailingSpace:e.trailingSpace,trailingSpaceNewLine:e.trailingSpaceNewLine,md_inside:e.md_inside,fencedEndRE:e.fencedEndRE}},token:function(e,t){if(t.formatting=!1,e!=t.thisLine.stream){if(t.header=0,t.hr=!1,e.match(/^\s*$/,!0))return i(t),null;if(t.prevLine=t.thisLine,t.thisLine={stream:e},t.taskList=!1,t.trailingSpace=0,t.trailingSpaceNewLine=!1,!t.localState&&(t.f=t.block,t.f!=L)){var n=e.match(/^\s*/,!0)[0].replace(/\t/g," ").length;if(t.indentation=n,t.indentationDiff=null,0")):null:t.match("--")?e(r("comment","--\x3e")):t.match("DOCTYPE",!0,!0)?(t.eatWhile(/[\w\._\-]/),e(function i(r){return function(e,t){for(var n;null!=(n=e.next());){if("<"==n)return t.tokenize=i(r+1),t.tokenize(e,t);if(">"==n){if(1!=r)return t.tokenize=i(r-1),t.tokenize(e,t);t.tokenize=c;break}}return"meta"}}(1))):null:t.eat("?")?(t.eatWhile(/[\w\._\-]/),n.tokenize=r("meta","?>"),"meta"):(l=t.eat("/")?"closeTag":"openTag",n.tokenize=u,"tag bracket"):"&"==i?(t.eat("#")?t.eat("x")?t.eatWhile(/[a-fA-F\d]/)&&t.eat(";"):t.eatWhile(/[\d]/)&&t.eat(";"):t.eatWhile(/[\w\.\-:]/)&&t.eat(";"))?"atom":"error":(t.eatWhile(/[^&<]/),null)}function u(e,t){var n,i,r=e.next();return">"==r||"/"==r&&e.eat(">")?(t.tokenize=c,l=">"==r?"endTag":"selfcloseTag","tag bracket"):"="==r?(l="equals",null):"<"==r?(t.tokenize=c,t.state=m,t.tagName=t.tagStart=null,(n=t.tokenize(e,t))?n+" tag error":"tag error"):/[\'\"]/.test(r)?(t.tokenize=(i=r,o.isInAttribute=!0,o),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word");function o(e,t){for(;!e.eol();)if(e.next()==i){t.tokenize=u;break}return"string"}}function r(n,i){return function(e,t){for(;!e.eol();){if(e.match(i)){t.tokenize=c;break}e.next()}return n}}function d(e){return e&&e.toLowerCase()}function h(e,t,n){this.prev=e.context,this.tagName=t||"",this.indent=e.indented,this.startOfLine=n,(s.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)&&(this.noIndent=!0)}function f(e){e.context&&(e.context=e.context.prev)}function p(e,t){for(var n;;){if(!e.context)return;if(n=e.context.tagName,!s.contextGrabbers.hasOwnProperty(d(n))||!s.contextGrabbers[d(n)].hasOwnProperty(d(t)))return;f(e)}}function m(e,t,n){return"openTag"==e?(n.tagStart=t.column(),g):"closeTag"==e?v:m}function g(e,t,n){return"word"==e?(n.tagName=t.current(),o="tag",b):s.allowMissingTagName&&"endTag"==e?(o="tag bracket",b(e,0,n)):(o="error",g)}function v(e,t,n){var i;return"word"==e?(i=t.current(),n.context&&n.context.tagName!=i&&s.implicitlyClosed.hasOwnProperty(d(n.context.tagName))&&f(n),n.context&&n.context.tagName==i||!1===s.matchClosing?(o="tag",y):(o="tag error",x)):s.allowMissingTagName&&"endTag"==e?(o="tag bracket",y(e,0,n)):(o="error",x)}function y(e,t,n){return"endTag"!=e?(o="error",y):(f(n),m)}function x(e,t,n){return o="error",y(e,0,n)}function b(e,t,n){var i,r;return"word"==e?(o="attribute",w):"endTag"==e||"selfcloseTag"==e?(i=n.tagName,r=n.tagStart,n.tagName=n.tagStart=null,"selfcloseTag"==e||s.autoSelfClosers.hasOwnProperty(d(i))?p(n,i):(p(n,i),n.context=new h(n,i,r==n.indented)),m):(o="error",b)}function w(e,t,n){return"equals"==e?C:(s.allowMissing||(o="error"),b(e,0,n))}function C(e,t,n){return"string"==e?k:"word"==e&&s.allowUnquoted?(o="string",b):(o="error",b(e,0,n))}function k(e,t,n){return"string"==e?k:b(e,0,n)}return c.isInText=!0,{startState:function(e){var t={tokenize:c,state:m,indented:e||0,tagName:null,tagStart:null,context:null};return null!=e&&(t.baseIndent=e),t},token:function(e,t){if(!t.tagName&&e.sol()&&(t.indented=e.indentation()),e.eatSpace())return null;l=null;var n=t.tokenize(e,t);return n=(n||l)&&"comment"!=n&&(o=null,t.state=t.state(l||n,e,t),o)?"error"==o?n+" error":o:n},indent:function(e,t,n){var i=e.context;if(e.tokenize.isInAttribute)return e.tagStart==e.indented?e.stringStartCol+1:e.indented+a;if(i&&i.noIndent)return S.Pass;if(e.tokenize!=u&&e.tokenize!=c)return n?n.match(/^(\s*)/)[0].length:0;if(e.tagName)return!1!==s.multilineTagIndentPastTag?e.tagStart+e.tagName.length+2:e.tagStart+a*(s.multilineTagIndentFactor||1);if(s.alignCDATA&&/$/,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",configuration:s.htmlMode?"html":"xml",helperType:s.htmlMode?"html":"xml",skipAttribute:function(e){e.state==C&&(e.state=b)},xmlCurrentTag:function(e){return e.tagName?{name:e.tagName,close:"closeTag"==e.type}:null},xmlCurrentContext:function(e){for(var t=[],n=e.context;n;n=n.prev)t.push(n.tagName);return t.reverse()}}}),S.defineMIME("text/xml","xml"),S.defineMIME("application/xml","xml"),S.mimeModes.hasOwnProperty("text/html")||S.defineMIME("text/html",{name:"xml",htmlMode:!0})})("object"==typeof n&&"object"==typeof t?e("../../lib/codemirror"):CodeMirror)},{"../../lib/codemirror":8}],13:[function(o,t,e){!function(p){!function(){var e;!function(){"use strict";(e=function(e,r,o,l){l=l||{},this.dictionary=null,this.rules={},this.dictionaryTable={},this.compoundRules=[],this.compoundRuleCodes={},this.replacementTable=[],this.flags=l.flags||{},this.memoized={},this.loaded=!1;var t,a,s,c,u,d=this;function n(e,t){e=d._readFile(e,null,l.asyncLoad);l.asyncLoad?e.then(function(e){t(e)}):t(e)}function i(e){r=e,o&&f()}function h(e){o=e,r&&f()}function f(){for(d.rules=d._parseAFF(r),d.compoundRuleCodes={},a=0,c=d.compoundRules.length;a=this.flags.COMPOUNDMIN)for(t=0,n=this.compoundRules.length;t ]+|[0-9]+(.|\)))[ ]*/,""),t.replaceRange(n,{line:r,ch:0},{line:r,ch:99999999999999})}function w(e){var t=e.codemirror,n=h(t),e=e.options,i="http://";if(e.promptURLs&&!(i=prompt(e.promptTexts.link)))return!1;D(t,n.link,e.insertTexts.link,i)}function C(e){var t=e.codemirror,n=h(t),e=e.options,i="http://";if(e.promptURLs&&!(i=prompt(e.promptTexts.image)))return!1;D(t,n.image,e.insertTexts.image,i)}function k(e){var t=e.codemirror,n=h(t),e=e.options;D(t,n.table,e.insertTexts.table)}function S(e){var t=e.codemirror,n=h(t),e=e.options;D(t,n.image,e.insertTexts.horizontalRule)}function L(e){e=e.codemirror;e.undo(),e.focus()}function T(e){e=e.codemirror;e.redo(),e.focus()}function M(e){var t=e.codemirror,n=t.getWrapperElement(),i=n.nextSibling,r=e.toolbarElements["side-by-side"],o=!1,r=(/editor-preview-active-side/.test(i.className)?(i.className=i.className.replace(/\s*editor-preview-active-side\s*/g,""),r.className=r.className.replace(/\s*active\s*/g,""),n.className=n.className.replace(/\s*CodeMirror-sided\s*/g," ")):(setTimeout(function(){t.getOption("fullScreen")||f(e),i.className+=" editor-preview-active-side"},1),r.className+=" active",n.className+=" CodeMirror-sided",o=!0),n.lastChild);/editor-preview-active/.test(r.className)&&(r.className=r.className.replace(/\s*editor-preview-active\s*/g,""),r=e.toolbarElements.preview,n=n.previousSibling,r.className=r.className.replace(/\s*active\s*/g,""),n.className=n.className.replace(/\s*disabled-for-preview*/g,""));t.sideBySideRenderingFunction||(t.sideBySideRenderingFunction=function(){i.innerHTML=e.options.previewRender(e.value(),i)}),o?(i.innerHTML=e.options.previewRender(e.value(),i),t.on("update",t.sideBySideRenderingFunction)):t.off("update",t.sideBySideRenderingFunction),t.refresh()}function N(e){var t=e.codemirror,n=t.getWrapperElement(),i=n.previousSibling,r=!!e.options.toolbar&&e.toolbarElements.preview,o=n.lastChild,n=(o&&/editor-preview/.test(o.className)||((o=document.createElement("div")).className="editor-preview",n.appendChild(o)),/editor-preview-active/.test(o.className)?(o.className=o.className.replace(/\s*editor-preview-active\s*/g,""),r&&(r.className=r.className.replace(/\s*active\s*/g,""),i.className=i.className.replace(/\s*disabled-for-preview*/g,""))):(setTimeout(function(){o.className+=" editor-preview-active"},1),r&&(r.className+=" active",i.className+=" disabled-for-preview")),o.innerHTML=e.options.previewRender(e.value(),o),t.getWrapperElement().nextSibling);/editor-preview-active-side/.test(n.className)&&M(e)}function D(e,t,n,i){var r,o,l,a;/editor-preview-active/.test(e.getWrapperElement().lastChild.className)||(o=n[0],n=n[1],l=e.getCursor("start"),a=e.getCursor("end"),i&&(n=n.replace("#url#",i)),t?(o=(r=e.getLine(l.line)).slice(0,l.ch),n=r.slice(l.ch),e.replaceRange(o+n,{line:l.line,ch:0})):(r=e.getSelection(),e.replaceSelection(o+r+n),l.ch+=o.length,l!==a&&(a.ch+=o.length)),e.setSelection(l,a),e.focus())}function A(e,t,n){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){for(var i,r,o,l=e.getCursor("start"),a=e.getCursor("end"),s=l.line;s<=a.line;s++)i=s,o=r=void 0,r=(o=e.getLine(i)).search(/[^#]/),o=void 0!==t?r<=0?"bigger"==t?"###### "+o:"# "+o:6==r&&"smaller"==t?o.substr(7):1==r&&"bigger"==t?o.substr(2):"bigger"==t?o.substr(1):"#"+o:1==n?r<=0?"# "+o:r==n?o.substr(r+1):"# "+o.substr(r+1):2==n?r<=0?"## "+o:r==n?o.substr(r+1):"## "+o.substr(r+1):r<=0?"### "+o:r==n?o.substr(r+1):"### "+o.substr(r+1),e.replaceRange(o,{line:i,ch:0},{line:i,ch:99999999999999});e.focus()}}function F(e,t){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){for(var n,i,r=h(e),o=e.getCursor("start"),l=e.getCursor("end"),a={quote:/^(\s*)\>\s+/,"unordered-list":/^(\s*)(\*|\-|\+)\s+/,"ordered-list":/^(\s*)\d+\.\s+/},s={quote:"> ","unordered-list":"* ","ordered-list":"1. "},c=o.line;c<=l.line;c++)n=c,i=void 0,i=e.getLine(n),i=r[t]?i.replace(a[t],"$1"):s[t]+i,e.replaceRange(i,{line:n,ch:0},{line:n,ch:99999999999999});e.focus()}}function E(e,t,n,i){var r,o,l,a,s;/editor-preview-active/.test(e.codemirror.getWrapperElement().lastChild.className)||(i=void 0===i?n:i,r=h(e=e.codemirror),l=n,i=i,a=e.getCursor("start"),s=e.getCursor("end"),r[t]?(l=(o=e.getLine(a.line)).slice(0,a.ch),i=o.slice(a.ch),"bold"==t?(l=l.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/,""),i=i.replace(/(\*\*|__)/,"")):"italic"==t?(l=l.replace(/(\*|_)(?![\s\S]*(\*|_))/,""),i=i.replace(/(\*|_)/,"")):"strikethrough"==t&&(l=l.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/,""),i=i.replace(/(\*\*|~~)/,"")),e.replaceRange(l+i,{line:a.line,ch:0},{line:a.line,ch:99999999999999}),"bold"==t||"strikethrough"==t?(a.ch-=2,a!==s&&(s.ch-=2)):"italic"==t&&(--a.ch,a!==s)&&--s.ch):(o=e.getSelection(),"bold"==t?o=(o=o.split("**").join("")).split("__").join(""):"italic"==t?o=(o=o.split("*").join("")).split("_").join(""):"strikethrough"==t&&(o=o.split("~~").join("")),e.replaceSelection(l+o+i),a.ch+=n.length,s.ch=a.ch+o.length),e.setSelection(a,s),e.focus())}function O(e){for(var t=1;t