function iframReSize(n){n.style.height=n.contentDocument.documentElement.offsetHeight+"px";var t=n.contentDocument.documentElement.scrollHeight-n.contentDocument.documentElement.clientHeight;n.style.height=Math.min(Math.max(document.documentElement.clientHeight,window.innerHeight||0),parseInt(n.style.height,10)+(t>0?t:0)||400)+"px"}function attachFrameResizeEvent(n){$(n).on("load",function(){iframReSize(n)});n.contentDocument.readyState.toUpperCase()==="COMPLETE"&&$(n).trigger("load")}window.CodeMirror=function(){"use strict";function n(t,i){var r,o,f,u,s;if(!(this instanceof n))return new n(t,i);this.options=i=i||{};for(r in fe)!i.hasOwnProperty(r)&&fe.hasOwnProperty(r)&&(i[r]=fe[r]);le(i);o=typeof i.value=="string"?0:i.value.first;f=this.display=ta(t,o);f.wrapper.CodeMirror=this;ih(this);i.autofocus&&!ls&&it(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,draggingText:!1,highlight:new rs};th(this);i.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");u=i.value;typeof u=="string"&&(u=new b(i.value,i.mode));e(this,kc)(this,u);l&&setTimeout(ft(vt,this,!0),20);da(this);try{s=document.activeElement==f.input}catch(h){}s||i.autofocus&&!ls?setTimeout(ft(wr,this),20):fo(this);e(this,function(){var n,t;for(n in ei)ei.propertyIsEnumerable(n)&&ei[n](this,i[n],ys);for(t=0;t<ee.length;++t)ee[t](this)})()}function ta(n,t){var r={},u=r.input=i("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none; font-size: 4px;");return p?u.style.width="1000px":u.setAttribute("wrap","off"),au&&(u.style.border="1px solid black"),u.setAttribute("autocorrect","off"),u.setAttribute("autocapitalize","off"),u.setAttribute("spellcheck","false"),r.inputDiv=i("div",[u],null,"overflow: hidden; position: relative; width: 3px; height: 0px;"),r.scrollbarH=i("div",[i("div",null,null,"height: 1px")],"CodeMirror-hscrollbar"),r.scrollbarV=i("div",[i("div",null,null,"width: 1px")],"CodeMirror-vscrollbar"),r.scrollbarFiller=i("div",null,"CodeMirror-scrollbar-filler"),r.gutterFiller=i("div",null,"CodeMirror-gutter-filler"),r.lineDiv=i("div",null,"CodeMirror-code"),r.selectionDiv=i("div",null,null,"position: relative; z-index: 1"),r.cursor=i("div"," ","CodeMirror-cursor"),r.otherCursor=i("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"),r.measure=i("div",null,"CodeMirror-measure"),r.lineSpace=i("div",[r.measure,r.selectionDiv,r.lineDiv,r.cursor,r.otherCursor],null,"position: relative; outline: none"),r.mover=i("div",[i("div",[r.lineSpace],"CodeMirror-lines")],null,"position: relative"),r.sizer=i("div",[r.mover],"CodeMirror-sizer"),r.heightForcer=i("div",null,null,"position: absolute; height: "+oi+"px; width: 1px;"),r.gutters=i("div",null,"CodeMirror-gutters"),r.lineGutter=null,r.scroller=i("div",[r.sizer,r.heightForcer,r.gutters],"CodeMirror-scroll"),r.scroller.setAttribute("tabIndex","-1"),r.wrapper=i("div",[r.inputDiv,r.scrollbarH,r.scrollbarV,r.scrollbarFiller,r.gutterFiller,r.scroller],"CodeMirror"),nr&&(r.gutters.style.zIndex=-1,r.scroller.style.paddingRight=0),n.appendChild?n.appendChild(r.wrapper):n(r.wrapper),au&&(u.style.width="0px"),p||(r.scroller.draggable=!0),cs?(r.inputDiv.style.height="1px",r.inputDiv.style.position="absolute"):nr&&(r.scrollbarH.style.minWidth=r.scrollbarV.style.minWidth="18px"),r.viewOffset=r.lastSizeC=0,r.showingFrom=r.showingTo=t,r.lineNumWidth=r.lineNumInnerWidth=r.lineNumChars=null,r.prevInput="",r.alignWidgets=!1,r.pollingFast=!1,r.poll=new rs,r.cachedCharWidth=r.cachedTextHeight=null,r.measureLineCache=[],r.measureLineCachePos=0,r.inaccurateSelection=!1,r.maxLine=null,r.maxLineLength=0,r.maxLineChanged=!1,r.wheelDX=r.wheelDY=r.wheelStartX=r.wheelStartY=null,r}function er(t){t.doc.mode=n.getMode(t.options,t.doc.modeOption);t.doc.iter(function(n){n.stateAfter&&(n.stateAfter=null);n.styles&&(n.styles=null)});t.doc.frontier=t.doc.first;sr(t,100);t.state.modeGen++;t.curOp&&a(t)}function ia(n){n.options.lineWrapping?(n.display.wrapper.className+=" CodeMirror-wrap",n.display.sizer.style.minWidth=""):(n.display.wrapper.className=n.display.wrapper.className.replace(" CodeMirror-wrap",""),ce(n));he(n);a(n);hi(n);setTimeout(function(){ae(n)},100)}function gs(n){var t=ci(n.display),i=n.options.lineWrapping,r=i&&Math.max(5,n.display.scroller.clientWidth/ch(n.display)-3);return function(u){return ri(n.doc,u)?0:i?(Math.ceil(u.text.length/r)||1)*t:t}}function he(n){var t=n.doc,i=gs(n);t.iter(function(n){var t=i(n);t!=n.height&&ut(n,t)})}function nh(n){var t=at[n.options.keyMap],i=t.style;n.display.wrapper.className=n.display.wrapper.className.replace(/\s*cm-keymap-\S+/g,"")+(i?" cm-keymap-"+i:"");n.state.disableInput=t.disableInput}function th(n){n.display.wrapper.className=n.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+n.options.theme.replace(/(^|\s)\s*/g," cm-s-");hi(n)}function or(n){ih(n);a(n);setTimeout(function(){ye(n)},20)}function ih(n){var r=n.display.gutters,e=n.options.gutters,t,u,f;for(su(r),t=0;t<e.length;++t)u=e[t],f=r.appendChild(i("div",null,"CodeMirror-gutter "+u)),u=="CodeMirror-linenumbers"&&(n.display.lineGutter=f,f.style.width=(n.display.lineNumWidth||1)+"px");r.style.display=t?"":"none"}function gu(n,t){var f,e,i,u;if(t.height==0)return 0;for(f=t.text.length,i=t;e=vo(i);)u=e.find(),i=r(n,u.from.line),f+=u.from.ch-u.to.ch;for(i=t;e=vf(i);)u=e.find(),f-=i.text.length-u.from.ch,i=r(n,u.to.line),f+=i.text.length-u.to.ch;return f}function ce(n){var t=n.display,i=n.doc;t.maxLine=r(i,i.first);t.maxLineLength=gu(i,t.maxLine);t.maxLineChanged=!0;i.iter(function(n){var r=gu(i,n);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=n)})}function le(n){var t=ct(n.gutters,"CodeMirror-linenumbers");t==-1&&n.lineNumbers?n.gutters=n.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!n.lineNumbers&&(n.gutters=n.gutters.slice(0),n.gutters.splice(t,1))}function ae(n){var t=n.display,e=n.doc.height,r=e+fh(t);t.sizer.style.minHeight=t.heightForcer.style.top=r+"px";t.gutters.style.height=Math.max(r,t.scroller.clientHeight-oi)+"px";var f=Math.max(r,t.scroller.scrollHeight),i=t.scroller.scrollWidth>t.scroller.clientWidth+1,u=f>t.scroller.clientHeight+1;u?(t.scrollbarV.style.display="block",t.scrollbarV.style.bottom=i?cu(t.measure)+"px":"0",t.scrollbarV.firstChild.style.height=f-t.scroller.clientHeight+t.scrollbarV.clientHeight+"px"):(t.scrollbarV.style.display="",t.scrollbarV.firstChild.style.height="0");i?(t.scrollbarH.style.display="block",t.scrollbarH.style.right=u?cu(t.measure)+"px":"0",t.scrollbarH.firstChild.style.width=t.scroller.scrollWidth-t.scroller.clientWidth+t.scrollbarH.clientWidth+"px"):(t.scrollbarH.style.display="",t.scrollbarH.firstChild.style.width="0");i&&u?(t.scrollbarFiller.style.display="block",t.scrollbarFiller.style.height=t.scrollbarFiller.style.width=cu(t.measure)+"px"):t.scrollbarFiller.style.display="";i&&n.options.coverGutterNextToScrollbar&&n.options.fixedGutter?(t.gutterFiller.style.display="block",t.gutterFiller.style.height=cu(t.measure)+"px",t.gutterFiller.style.width=t.gutters.offsetWidth+"px"):t.gutterFiller.style.display="";ay&&cu(t.measure)===0&&(t.scrollbarV.style.minWidth=t.scrollbarH.style.minHeight=vy?"18px":"12px",t.scrollbarV.style.pointerEvents=t.scrollbarH.style.pointerEvents="none")}function ve(n,t,i){var r=n.scroller.scrollTop,u=n.wrapper.clientHeight,f;return typeof i=="number"?r=i:i&&(r=i.top,u=i.bottom-i.top),r=Math.floor(r-uh(n)),f=Math.ceil(r+u),{from:ru(t,r),to:ru(t,f)}}function ye(n){var t=n.display,i,r,u;if(t.alignWidgets||t.gutters.firstChild&&n.options.fixedGutter){var f=we(t)-t.scroller.scrollLeft+n.doc.scrollLeft,e=t.gutters.offsetWidth,o=f+"px";for(i=t.lineDiv.firstChild;i;i=i.nextSibling)if(i.alignable)for(r=0,u=i.alignable;r<u.length;++r)u[r].style.left=o;n.options.fixedGutter&&(t.gutters.style.left=f+e+"px")}}function ra(n){if(!n.options.lineNumbers)return!1;var u=n.doc,r=pe(n.options,u.first+u.size-1),t=n.display;if(r.length!=t.lineNumChars){var f=t.measure.appendChild(i("div",[i("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),e=f.firstChild.offsetWidth,o=f.offsetWidth-e;return t.lineGutter.style.width="",t.lineNumInnerWidth=Math.max(e,t.lineGutter.offsetWidth-o),t.lineNumWidth=t.lineNumInnerWidth+o,t.lineNumChars=t.lineNumInnerWidth?r.length:-1,t.lineGutter.style.width=t.lineNumWidth+"px",!0}return!1}function pe(n,t){return String(n.lineNumberFormatter(t+n.firstLineNumber))}function we(n){return c(n.scroller).left-c(n.sizer).left}function nf(n,t,i,r){for(var e,s=n.display.showingFrom,h=n.display.showingTo,f,u=ve(n.display,n.doc,i),o=!0;;o=!1){if(e=n.display.scroller.clientWidth,!ua(n,t,u,r))break;if(f=!0,t=[],ke(n),ae(n),o&&n.options.lineWrapping&&e!=n.display.scroller.clientWidth){r=!0;continue}if(r=!1,i&&(i=Math.min(n.display.scroller.scrollHeight-n.display.scroller.clientHeight,typeof i=="number"?i:i.top)),u=ve(n.display,n.doc,i),u.from>=n.display.showingFrom&&u.to<=n.display.showingTo)break}return f&&(k(n,"update",n),(n.display.showingFrom!=s||n.display.showingTo!=h)&&k(n,"viewportChange",n,n.display.showingFrom,n.display.showingTo)),f}function ua(n,t,i,u){var f=n.display,o=n.doc,b,v,h,k,w,y,e,c,a,d;if(!f.wrapper.clientWidth){f.showingFrom=f.showingTo=o.first;f.viewOffset=0;return}if(u||t.length!=0||!(i.from>f.showingFrom)||!(i.to<f.showingTo)){if(ra(n)&&(t=[{from:o.first,to:o.first+o.size}]),b=f.sizer.style.marginLeft=f.gutters.offsetWidth+"px",f.scrollbarH.style.left=n.options.fixedGutter?b:"0",v=Infinity,n.options.lineNumbers)for(e=0;e<t.length;++e)t[e].diff&&t[e].from<v&&(v=t[e].from);var p=o.first+o.size,l=Math.max(i.from-n.options.viewportMargin,o.first),s=Math.min(p,i.to+n.options.viewportMargin);if(f.showingFrom<l&&l-f.showingFrom<20&&(l=Math.max(o.first,f.showingFrom)),f.showingTo>s&&f.showingTo-s<20&&(s=Math.min(p,f.showingTo)),du)for(l=g(pt(o,r(o,l)));s<p&&ri(o,r(o,s));)++s;if(h=[{from:Math.max(f.showingFrom,o.first),to:Math.min(f.showingTo,p)}],h=h[0].from>=h[0].to?[]:ea(h,t),du)for(e=0;e<h.length;++e)for(c=h[e];k=vf(r(o,c.to-1));)if(w=k.find().from.line,w>c.from)c.to=w;else{h.splice(e--,1);break}for(y=0,e=0;e<h.length;++e)c=h[e],c.from<l&&(c.from=l),c.to>s&&(c.to=s),c.from>=c.to?h.splice(e--,1):y+=c.to-c.from;if(!u&&y==s-l&&l==f.showingFrom&&s==f.showingTo){rh(n);return}h.sort(function(n,t){return n.from-t.from});try{a=document.activeElement}catch(nt){}return y<(s-l)*.7&&(f.lineDiv.style.display="none"),sa(n,l,s,h,v),f.lineDiv.style.display="",a&&document.activeElement!=a&&a.offsetHeight&&a.focus(),d=l!=f.showingFrom||s!=f.showingTo||f.lastSizeC!=f.wrapper.clientHeight,d&&(f.lastSizeC=f.wrapper.clientHeight,sr(n,400)),f.showingFrom=l,f.showingTo=s,fa(n),rh(n),!0}}function fa(n){for(var f,e,o,r,u,s=n.display,h=s.lineDiv.offsetTop,t=s.lineDiv.firstChild,i;t;t=t.nextSibling)if(t.lineObj&&(nr?(f=t.offsetTop+t.offsetHeight,i=f-h,h=f):(e=c(t),i=e.bottom-e.top),o=t.lineObj.height-i,i<2&&(i=ci(s)),(o>.001||o<-.001)&&(ut(t.lineObj,i),r=t.lineObj.widgets,r)))for(u=0;u<r.length;++u)r[u].height=r[u].node.offsetHeight}function rh(n){var t=n.display.viewOffset=uu(n,r(n.doc,n.display.showingFrom));n.display.mover.style.top=t+"px"}function ea(n,t){for(var f,s,i,e=0,h=t.length||0;e<h;++e){var r=t[e],u=[],o=r.diff||0;for(f=0,s=n.length;f<s;++f)i=n[f],r.to<=i.from&&r.diff?u.push({from:i.from+o,to:i.to+o}):r.to<=i.from||r.from>=i.to?u.push(i):(r.from>i.from&&u.push({from:i.from,to:r.from}),r.to<i.to&&u.push({from:r.to+o,to:i.to+o}));n=u}return n}function oa(n){for(var i=n.display,u={},f={},t=i.gutters.firstChild,r=0;t;t=t.nextSibling,++r)u[n.options.gutters[r]]=t.offsetLeft,f[n.options.gutters[r]]=t.offsetWidth;return{fixedPos:we(i),gutterTotalWidth:i.gutters.offsetWidth,gutterLeft:u,gutterWidth:f,wrapperWidth:i.wrapper.clientWidth}}function sa(n,t,r,u,f){function h(t){var i=t.nextSibling;return p&&tr&&n.display.currentWheelTarget==t?(t.style.display="none",t.lineObj=null):t.parentNode.removeChild(t),i}var l=oa(n),a=n.display,v=n.options.lineNumbers,c,e,s,o;for(u.length||p&&n.display.currentWheelTarget||su(a.lineDiv),c=a.lineDiv,e=c.firstChild,s=u.shift(),o=t,n.doc.iter(t,r,function(t){var p,y,r,w,d,g,a,b,k;if(s&&s.to==o&&(s=u.shift()),ri(n.doc,t)){if(t.height!=0&&ut(t,0),t.widgets&&e&&e.previousSibling)for(p=0;p<t.widgets.length;++p)y=t.widgets[p],y.showIfHidden&&(r=e.previousSibling,/pre/i.test(r.nodeName)&&(w=i("div",null,null,"position: relative"),r.parentNode.replaceChild(w,r),w.appendChild(r),r=w),d=r.appendChild(i("div",[y.node],"CodeMirror-linewidget")),y.handleMouseEvents||(d.ignoreEvents=!0),be(y,d,r,l))}else if(s&&s.from<=o&&s.to>o){while(e.lineObj!=t)e=h(e);v&&f<=o&&e.lineNumber&&hl(e.lineNumber,pe(n.options,o));e=e.nextSibling}else{if(t.widgets)for(g=0,a=e;a&&g<20;++g,a=a.nextSibling)if(a.lineObj==t&&/div/i.test(a.nodeName)){b=a;break}if(k=ha(n,t,o,l,b),k!=b)c.insertBefore(k,e);else{while(e!=b)e=h(e);e=e.nextSibling}k.lineObj=t}++o});e;)e=h(e)}function ha(n,t,r,u,f){var w=wo(n,t),y=w.pre,c=t.gutterMarkers,ut=n.display,e,b=w.bgClass?w.bgClass+" "+(t.bgClass||""):t.bgClass,s,tt,l,p,a,d,h,g,o,v;if(!n.options.lineNumbers&&!c&&!b&&!t.wrapClass&&!t.widgets)return y;if(f){f.alignable=null;var it=!0,rt=0,nt=null;for(s=f.firstChild;s;s=tt)if(tt=s.nextSibling,/\bCodeMirror-linewidget\b/.test(s.className)){for(h=0;h<t.widgets.length;++h)if(o=t.widgets[h],o.node==s.firstChild){o.above||nt||(nt=s);be(o,s,f,u);++rt;break}if(h==t.widgets.length){it=!1;break}}else f.removeChild(s);f.insertBefore(y,nt);it&&rt==t.widgets.length&&(e=f,f.className=t.wrapClass||"")}if(e||(e=i("div",null,t.wrapClass,"position: relative"),e.appendChild(y)),b&&e.insertBefore(i("div",null,b+" CodeMirror-linebackground"),e.firstChild),(n.options.lineNumbers||c)&&(l=e.insertBefore(i("div",null,null,"position: absolute; left: "+(n.options.fixedGutter?u.fixedPos:-u.gutterTotalWidth)+"px"),e.firstChild),n.options.fixedGutter&&(e.alignable||(e.alignable=[])).push(l),!n.options.lineNumbers||c&&c["CodeMirror-linenumbers"]||(e.lineNumber=l.appendChild(i("div",pe(n.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+u.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+ut.lineNumInnerWidth+"px"))),c))for(p=0;p<n.options.gutters.length;++p)a=n.options.gutters[p],d=c.hasOwnProperty(a)&&c[a],d&&l.appendChild(i("div",[d],"CodeMirror-gutter-elt","left: "+u.gutterLeft[a]+"px; width: "+u.gutterWidth[a]+"px"));if(nr&&(e.style.zIndex=2),t.widgets&&e!=f)for(h=0,g=t.widgets;h<g.length;++h)o=g[h],v=i("div",[o.node],"CodeMirror-linewidget"),o.handleMouseEvents||(v.ignoreEvents=!0),be(o,v,e,u),o.above?e.insertBefore(v,n.options.lineNumbers&&t.height!=0?l:y):e.appendChild(v),k(o,"redraw");return e}function be(n,t,i,r){if(n.noHScroll){(i.alignable||(i.alignable=[])).push(t);var u=r.wrapperWidth;t.style.left=r.fixedPos+"px";n.coverGutter||(u-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px");t.style.width=u+"px"}n.coverGutter&&(t.style.zIndex=5,t.style.position="relative",n.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function ke(n){var t=n.display,i=s(n.doc.sel.from,n.doc.sel.to);if(i||n.options.showCursorWhenSelecting?ca(n):t.cursor.style.display=t.otherCursor.style.display="none",i?t.selectionDiv.style.display="none":la(n),n.options.moveInputWithCursor){var r=tt(n,n.doc.sel.head,"div"),u=c(t.wrapper),f=c(t.lineDiv);t.inputDiv.style.top=Math.max(0,Math.min(t.wrapper.clientHeight-10,r.top+f.top-u.top))+"px";t.inputDiv.style.left=Math.max(0,Math.min(t.wrapper.clientWidth-10,r.left+f.left-u.left))+"px"}}function ca(n){var t=n.display,i=tt(n,n.doc.sel.head,"div");t.cursor.style.left=i.left+"px";t.cursor.style.top=i.top+"px";t.cursor.style.height=Math.max(0,i.bottom-i.top)*n.options.cursorHeight+"px";t.cursor.style.display="";i.other?(t.otherCursor.style.display="",t.otherCursor.style.left=i.other.left+"px",t.otherCursor.style.top=i.other.top+"px",t.otherCursor.style.height=(i.other.bottom-i.other.top)*.85+"px"):t.otherCursor.style.display="none"}function la(n){function e(n,t,r,u){t<0&&(t=0);v.appendChild(i("div",null,"CodeMirror-selected","position: absolute; left: "+n+"px; top: "+t+"px; width: "+(r==null?y-n:r)+"px; height: "+(u-t)+"px"))}function c(i,u,f){function a(r,u){return to(n,t(i,r),"div",l,u)}var l=r(h,i),v=l.text.length,o,c;return ey(ot(l),u||0,f==null?v:f,function(n,t,i){var r=a(n,"left"),h,l,p,w;n==t?(h=r,l=p=r.left):(h=a(t-1,"right"),i=="rtl"&&(w=r,r=h,h=w),l=r.left,p=h.right);u==null&&n==0&&(l=s);h.top-r.top>3&&(e(l,r.top,null,r.bottom),l=s,r.bottom<h.top&&e(l,r.bottom,null,h.top));f==null&&t==v&&(p=y);(!o||r.top<o.top||r.top==o.top&&r.left<o.left)&&(o=r);(!c||h.bottom>c.bottom||h.bottom==c.bottom&&h.right>c.right)&&(c=h);l<s+1&&(l=s);e(l,h.top,p-l,h.bottom)}),{start:o,end:c}}var l=n.display,h=n.doc,u=n.doc.sel,v=document.createDocumentFragment(),y=l.lineSpace.offsetWidth,s=ya(n.display);if(u.from.line==u.to.line)c(u.from.line,u.from.ch,u.to.ch);else{var p=r(h,u.from.line),w=r(h,u.to.line),a=pt(h,p)==pt(h,w),f=c(u.from.line,u.from.ch,a?p.text.length:null).end,o=c(u.to.line,a?0:null,u.to.ch).start;a&&(f.top<o.top-2?(e(f.right,f.top,null,f.bottom),e(s,o.top,o.left,o.bottom)):e(f.right,f.top,o.left-f.right,f.bottom));f.bottom<o.top&&e(s,f.bottom,null,o.top)}lt(l.selectionDiv,v);l.selectionDiv.style.display=""}function tf(n){var t,i;n.state.focused&&(t=n.display,clearInterval(t.blinker),i=!0,t.cursor.style.visibility=t.otherCursor.style.visibility="",n.options.cursorBlinkRate>0&&(t.blinker=setInterval(function(){t.cursor.style.visibility=t.otherCursor.style.visibility=(i=!i)?"":"hidden"},n.options.cursorBlinkRate)))}function sr(n,t){n.doc.mode.startState&&n.doc.frontier<n.display.showingTo&&n.state.highlight.set(t,ft(aa,n))}function aa(n){var t=n.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=n.display.showingTo)){var f=+new Date+n.options.workTime,r=wi(t.mode,hr(n,t.frontier)),i=[],u;t.iter(t.frontier,Math.min(t.first+t.size,n.display.showingTo+500),function(e){var o,h,s;if(t.frontier>=n.display.showingFrom){for(o=e.styles,e.styles=vc(n,e,r,!0),h=!o||o.length!=e.styles.length,s=0;!h&&s<o.length;++s)h=o[s]!=e.styles[s];h&&(u&&u.end==t.frontier?u.end++:i.push(u={start:t.frontier,end:t.frontier+1}));e.stateAfter=wi(t.mode,r)}else po(n,e.text,r),e.stateAfter=t.frontier%5==0?wi(t.mode,r):null;return++t.frontier,+new Date>f?(sr(n,n.options.workDelay),!0):void 0});i.length&&e(n,function(){for(var n=0;n<i.length;++n)a(this,i[n].start,i[n].end)})()}}function va(n,t,i){for(var e,o,h,s,f=n.doc,c=i?-1:t-(n.doc.mode.innerMode?1e3:100),u=t;u>c;--u){if(u<=f.first)return f.first;if(e=r(f,u-1),e.stateAfter&&(!i||u<=f.frontier))return u;o=di(e.text,null,n.options.tabSize);(s==null||h>o)&&(s=u-1,h=o)}return s}function hr(n,t,i){var f=n.doc,o=n.display,u,e;return f.mode.startState?(u=va(n,t,i),e=u>f.first&&r(f,u-1).stateAfter,e=e?wi(f.mode,e):fc(f.mode),f.iter(u,t,function(i){po(n,i.text,e);var r=u==t-1||u%5==0||u>=o.showingFrom&&u<o.showingTo;i.stateAfter=r?wi(f.mode,e):null;++u}),i&&(f.frontier=u),e):!0}function uh(n){return n.lineSpace.offsetTop}function fh(n){return n.mover.offsetHeight-n.lineSpace.offsetHeight}function ya(n){var t=lt(n.measure,i("pre",null,null,"text-align: left")).appendChild(i("span","x"));return t.offsetLeft}function cr(n,t,i,r,u){var o=-1,s,e,f;if(r=r||ge(n,t),r.crude)return s=r.left+i*r.width,{left:s,right:s+r.width,top:r.top,bottom:r.bottom};for(e=i;;e+=o){if(f=r[e],f)break;o<0&&e==0&&(o=1)}return u=e>i?"left":e<i?"right":u,u=="left"&&f.leftSide?f=f.leftSide:u=="right"&&f.rightSide&&(f=f.rightSide),{left:e<i?f.right:f.left,right:e>i?f.left:f.right,top:f.top,bottom:f.bottom}}function de(n,t){for(var i,u=n.display.measureLineCache,r=0;r<u.length;++r)if(i=u[r],i.text==t.text&&i.markedSpans==t.markedSpans&&n.display.scroller.clientWidth==i.width&&i.classes==t.textClass+"|"+t.wrapClass)return i}function pa(n,t){var i=de(n,t);i&&(i.text=i.measure=i.markedSpans=null)}function ge(n,t){var r=de(n,t);if(r)return r.measure;var u=eh(n,t),i=n.display.measureLineCache,f={text:t.text,width:n.display.scroller.clientWidth,markedSpans:t.markedSpans,measure:u,classes:t.textClass+"|"+t.wrapClass};return i.length==16?i[++n.display.measureLineCachePos%16]=f:i.push(f),u}function eh(n,t){function a(n){var i=n.top-p.top,r=n.bottom-p.top,t,u,e;for(r>ut&&(r=ut),i<0&&(i=0),t=f.length-2;t>=0;t-=2)if((u=f[t],e=f[t+1],!(u>r)&&!(e<i))&&(u<=i&&e>=r||i<=u&&r>=e||Math.min(r,e)-Math.max(i,u)>=r-i>>1)){f[t]=Math.min(i,u);f[t+1]=Math.max(r,e);break}return t<0&&(t=f.length,f.push(i,r)),{left:n.left-p.left,right:n.right-p.left,top:t,bottom:null}}function w(n){n.bottom=f[n.top+1];n.top=f[n.top]}var tt,b,k,v,o,s,u,r;if(!n.options.lineWrapping&&t.text.length>=n.options.crudeMeasuringFrom)return wa(n,t);var y=n.display,d=ol(t.text.length),e=wo(n,t,d,!0).pre;if(l&&!nr&&!n.options.lineWrapping&&e.childNodes.length>100){var it=document.createDocumentFragment(),rt=10,g=e.childNodes.length;for(u=0,tt=Math.ceil(g/rt);u<tt;++u){for(b=i("div",null,null,"display: inline-block"),k=0;k<rt&&g;++k)b.appendChild(e.firstChild),--g;it.appendChild(b)}e.appendChild(it)}lt(y.measure,e);var p=c(y.lineDiv),f=[],h=ol(t.text.length),ut=e.offsetHeight;for(nt&&y.measure.first!=e&&lt(y.measure,e),u=0;u<d.length;++u)(r=d[u])&&(v=r,o=null,/\bCodeMirror-widget\b/.test(r.className)&&r.getClientRects&&(r.firstChild.nodeType==1&&(v=r.firstChild),s=v.getClientRects(),s.length>1&&(o=h[u]=a(s[0]),o.rightSide=a(s[s.length-1]))),o||(o=h[u]=a(c(v))),r.measureRight&&(o.right=c(r.measureRight).left),r.leftSide&&(o.leftSide=a(c(r.leftSide))));for(su(n.display.measure),u=0;u<h.length;++u)(r=h[u])&&(w(r),r.leftSide&&w(r.leftSide),r.rightSide&&w(r.rightSide));return h}function wa(n,t){var i=new bt(t.text.slice(0,100),null);t.textClass&&(i.textClass=t.textClass);var u=eh(n,i),r=cr(n,i,0,u,"left"),f=cr(n,i,99,u,"right");return{crude:!0,top:r.top,left:r.left,bottom:r.bottom,width:(f.right-r.left)/100}}function ba(n,t){var e=!1,i,r,u,f,o;if(t.markedSpans)for(i=0;i<t.markedSpans;++i)r=t.markedSpans[i],r.collapsed&&(r.to==null||r.to==t.text.length)&&(e=!0);return(u=!e&&de(n,t),u||t.text.length>=n.options.crudeMeasuringFrom)?cr(n,t,t.text.length,u&&u.measure,"right").right:(f=wo(n,t,null,!0).pre,o=f.appendChild(lu(n.display.measure)),lt(n.display.measure,f),c(o).right-c(n.display.lineDiv).left)}function hi(n){n.display.measureLineCache.length=n.display.measureLineCachePos=0;n.display.cachedCharWidth=n.display.cachedTextHeight=null;n.options.lineWrapping||(n.display.maxLineChanged=!0);n.display.lineNumChars=null}function oh(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function sh(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function no(n,t,i,r){var f,e,u,o,s;if(t.widgets)for(f=0;f<t.widgets.length;++f)t.widgets[f].above&&(e=yf(t.widgets[f]),i.top+=e,i.bottom+=e);return r=="line"?i:(r||(r="local"),u=uu(n,t),r=="local"?u+=uh(n.display):u-=n.display.viewOffset,(r=="page"||r=="window")&&(o=c(n.display.lineSpace),u+=o.top+(r=="window"?0:sh()),s=o.left+(r=="window"?0:oh()),i.left+=s,i.right+=s),i.top+=u,i.bottom+=u,i)}function hh(n,t,i){var r,u,f,e;return i=="div"?t:(r=t.left,u=t.top,i=="page"?(r-=oh(),u-=sh()):i!="local"&&i||(f=c(n.display.sizer),r+=f.left,u+=f.top),e=c(n.display.lineSpace),{left:r-e.left,top:u-e.top})}function to(n,t,i,u,f){return u||(u=r(n.doc,t.line)),no(n,u,cr(n,u,t.ch,null,f),i)}function tt(n,t,i,u,f){function s(t,r){var e=cr(n,u,t,f,r?"right":"left");return r?e.left=e.right:e.right=e.left,no(n,u,e,i)}function c(n,t){var i=e[t],r=i.level%2;return(n==us(i)&&t&&i.level<e[t-1].level?(i=e[--t],n=fs(i)-(i.level%2?0:1),r=!0):n==fs(i)&&t<e.length-1&&i.level<e[t+1].level&&(i=e[++t],n=us(i)-i.level%2,r=!1),r&&n==i.to&&n>i.from)?s(n-1):s(n,r)}var e,o,l,h;return(u=u||r(n.doc,t.line),f||(f=ge(n,u)),e=ot(u),o=t.ch,!e)?s(o):(l=es(e,o),h=c(o,l),fr!=null&&(h.other=c(o,fr)),h)}function rf(n,i,r,u){var f=new t(n,i);return f.xRel=u,r&&(f.outside=!0),f}function io(n,t,i){var u=n.doc,f,o;if(i+=n.display.viewOffset,i<0)return rf(u.first,0,!0,-1);if(f=ru(u,i),o=u.first+u.size-1,f>o)return rf(u.first+u.size-1,r(u,o).text.length,!0,1);for(t<0&&(t=0);;){var c=r(u,f),e=ka(n,c,f,t,i),s=vf(c),h=s&&s.find();if(s&&(e.ch>h.from.ch||e.ch==h.from.ch&&e.xRel>0))f=h.to.line;else return e}}function ka(n,i,r,u,f){function p(u){var f=tt(n,t(r,u),"line",i,ut);return(h=!0,g>f.bottom)?f.left-nt:g<f.top?f.left+nt:(h=!1,f.left)}var g=f-uu(n,i),h=!1,nt=2*n.display.wrapper.clientWidth,ut=ge(n,i),it=ot(i),w=i.text.length,e=gf(i),o=ne(i),v=p(e),rt=h,l=p(o),b=h,c,k,a,s,d,y;if(u>l)return rf(r,o,b,1);for(;;){if(it?o==e||o==ss(i,e,1):o-e<=1){for(c=u<v||u-v<=l-u?e:o,k=u-(c==e?v:l);se.test(i.text.charAt(c));)++c;return rf(r,c,c==e?rt:b,k<0?-1:k?1:0)}if(a=Math.ceil(w/2),s=e+a,it)for(s=e,d=0;d<a;++d)s=ss(i,s,1);y=p(s);y>u?(o=s,l=y,(b=h)&&(l+=1e3),w=a):(e=s,v=y,rt=h,w-=a)}}function ci(n){var r,t;if(n.cachedTextHeight!=null)return n.cachedTextHeight;if(fi==null){for(fi=i("pre"),r=0;r<49;++r)fi.appendChild(document.createTextNode("x")),fi.appendChild(i("br"));fi.appendChild(document.createTextNode("x"))}return lt(n.measure,fi),t=fi.offsetHeight/50,t>3&&(n.cachedTextHeight=t),su(n.measure),t||1}function ch(n){var r,u,t;return n.cachedCharWidth!=null?n.cachedCharWidth:(r=i("span","x"),u=i("pre",[r]),lt(n.measure,u),t=r.offsetWidth,t>2&&(n.cachedCharWidth=t),t||10)}function li(n){n.curOp={changes:[],forceUpdate:!1,updateInput:null,userSelChange:null,textChanged:null,selectionChanged:!1,cursorActivity:!1,updateMaxLine:!1,updateScrollPos:!1,id:++al};wu++||(gt=[])}function ai(n){var t=n.curOp,h=n.doc,i=n.display,a,l,f,v,e,p,w,o,s,c,r;if(n.curOp=null,t.updateMaxLine&&ce(n),i.maxLineChanged&&!n.options.lineWrapping&&i.maxLine&&(a=ba(n,i.maxLine),i.sizer.style.minWidth=Math.max(0,a+3+oi)+"px",i.maxLineChanged=!1,l=Math.max(0,i.sizer.offsetLeft+i.sizer.offsetWidth-i.scroller.clientWidth),l<h.scrollLeft&&!t.updateScrollPos&&vi(n,Math.min(i.scroller.scrollLeft,l),!0)),t.updateScrollPos?f=t.updateScrollPos:t.selectionChanged&&i.scroller.clientHeight&&(e=tt(n,h.sel.head),f=sf(n,e.left,e.top,e.left,e.bottom)),(t.changes.length||t.forceUpdate||f&&f.scrollTop!=null)&&(v=nf(n,t.changes,f&&f.scrollTop,t.forceUpdate),n.display.scroller.offsetHeight&&(n.doc.scrollTop=n.display.scroller.scrollTop)),!v&&t.selectionChanged&&ke(n),t.updateScrollPos?(p=Math.max(0,Math.min(i.scroller.scrollHeight-i.scroller.clientHeight,f.scrollTop)),w=Math.max(0,Math.min(i.scroller.scrollWidth-i.scroller.clientWidth,f.scrollLeft)),i.scroller.scrollTop=i.scrollbarV.scrollTop=h.scrollTop=p,i.scroller.scrollLeft=i.scrollbarH.scrollLeft=h.scrollLeft=w,ye(n),t.scrollToPos&&rc(n,u(n.doc,t.scrollToPos.from),u(n.doc,t.scrollToPos.to),t.scrollToPos.margin)):f&&ov(n),t.selectionChanged&&tf(n),n.state.focused&&t.updateInput&&vt(n,t.userSelChange),o=t.maybeHiddenMarkers,s=t.maybeUnhiddenMarkers,o)for(r=0;r<o.length;++r)o[r].lines.length||y(o[r],"hide");if(s)for(r=0;r<s.length;++r)s[r].lines.length&&y(s[r],"unhide");if(--wu||(c=gt,gt=null),t.textChanged&&y(n,"change",n,t.textChanged),t.cursorActivity&&y(n,"cursorActivity",n),c)for(r=0;r<c.length;++r)c[r]()}function e(n,t){return function(){var i=n||this,r=!i.curOp,u;r&&li(i);try{u=t.apply(i,arguments)}finally{r&&ai(i)}return u}}function lr(n){return function(){var t=this.cm&&!this.cm.curOp,i;t&&li(this.cm);try{i=n.apply(this,arguments)}finally{t&&ai(this.cm)}return i}}function ro(n,t){var i=!n.curOp,r;i&&li(n);try{r=t()}finally{i&&ai(n)}return r}function a(n,t,i,r){t==null&&(t=n.doc.first);i==null&&(i=n.doc.first+n.doc.size);n.curOp.changes.push({from:t,to:i,diff:r})}function uf(n){n.display.pollingFast||n.display.poll.set(n.options.pollInterval,function(){uo(n);n.state.focused&&uf(n)})}function ar(n){function t(){var r=uo(n);r||i?(n.display.pollingFast=!1,uf(n)):(i=!0,n.display.poll.set(60,t))}var i=!1;n.display.pollingFast=!0;n.display.poll.set(20,t)}function uo(n){var e=n.display.input,h=n.display.prevInput,y=n.doc,c=y.sel,i,a,u,p,o,f,w,v;if(!n.state.focused||wy(e)||vr(n)||n.state.disableInput||(n.state.pasteIncoming&&n.state.fakedLastChar&&(e.value=e.value.substring(0,e.value.length-1),n.state.fakedLastChar=!1),i=e.value,i==h&&s(c.from,c.to)))return!1;if(l&&!nt&&n.display.inputHasSelection===i)return vt(n,!0),!1;for(a=!n.curOp,a&&li(n),c.shift=!1,u=0,p=Math.min(h.length,i.length);u<p&&h.charCodeAt(u)==i.charCodeAt(u);)++u;return o=c.from,f=c.to,u<h.length?o=t(o.line,o.ch-(h.length-u)):n.state.overwrite&&s(o,f)&&!n.state.pasteIncoming&&(f=t(f.line,Math.min(r(y,f.line).text.length,f.ch+(i.length-u)))),w=n.curOp.updateInput,v={from:o,to:f,text:ni(i.slice(u)),origin:n.state.pasteIncoming?"paste":"+input"},yi(n.doc,v,"end"),n.curOp.updateInput=w,k(n,"inputRead",n,v),i.length>1e3||i.indexOf("\n")>-1?e.value=n.display.prevInput="":n.display.prevInput=i,a&&ai(n),n.state.pasteIncoming=!1,!0}function vt(n,t){var r,f,i=n.doc,u;s(i.sel.from,i.sel.to)?t&&(n.display.prevInput=n.display.input.value="",l&&!nt&&(n.display.inputHasSelection=null)):(n.display.prevInput="",r=na&&(i.sel.to.line-i.sel.from.line>100||(f=n.getSelection()).length>1e3),u=r?"-":f||n.getSelection(),n.display.input.value=u,n.state.focused&&fl(n.display.input),l&&!nt&&(n.display.inputHasSelection=u));n.display.inaccurateSelection=r}function it(n){n.options.readOnly=="nocursor"||ls&&document.activeElement==n.display.input||n.display.input.focus()}function vr(n){return n.options.readOnly||n.doc.cantEdit}function da(n){function u(){n.state.focused&&setTimeout(ft(it,n),0)}function f(){i==null&&(i=setTimeout(function(){i=null;t.cachedCharWidth=t.cachedTextHeight=ku=null;hi(n);ro(n,ft(a,n))},100))}function s(){for(var n=t.wrapper.parentNode;n&&n!=document.body;n=n.parentNode);n?setTimeout(s,5e3):wt(window,"resize",f)}function h(t){st(n,t)||n.options.onDragEvent&&n.options.onDragEvent(n,fu(t))||eu(t)}function c(){t.inaccurateSelection&&(t.prevInput="",t.inaccurateSelection=!1,t.input.value=n.getSelection(),fl(t.input))}var t=n.display,i;o(t.scroller,"mousedown",e(n,ga));l?o(t.scroller,"dblclick",e(n,function(t){var i,u;st(n,t)||(i=yr(n,t),!i||ah(n,t)||ti(n.display,t))||(v(t),u=co(r(n.doc,i.line).text,i),w(n.doc,u.from,u.to))})):o(t.scroller,"dblclick",function(t){st(n,t)||v(t)});o(t.lineSpace,"selectstart",function(n){ti(t,n)||v(n)});ds||o(t.scroller,"contextmenu",function(t){bh(n,t)});o(t.scroller,"scroll",function(){t.scroller.clientHeight&&(pr(n,t.scroller.scrollTop),vi(n,t.scroller.scrollLeft,!0),y(n,"scroll",n))});o(t.scrollbarV,"scroll",function(){t.scroller.clientHeight&&pr(n,t.scrollbarV.scrollTop)});o(t.scrollbarH,"scroll",function(){t.scroller.clientHeight&&vi(n,t.scrollbarH.scrollLeft)});o(t.scroller,"mousewheel",function(t){vh(n,t)});o(t.scroller,"DOMMouseScroll",function(t){vh(n,t)});o(t.scrollbarH,"mousedown",u);o(t.scrollbarV,"mousedown",u);o(t.wrapper,"scroll",function(){t.wrapper.scrollTop=t.wrapper.scrollLeft=0});o(window,"resize",f);setTimeout(s,5e3);o(t.input,"keyup",e(n,function(t){st(n,t)||n.options.onKeyEvent&&n.options.onKeyEvent(n,fu(t))||t.keyCode==16&&(n.doc.sel.shift=!1)}));o(t.input,"input",function(){l&&!nt&&n.display.inputHasSelection&&(n.display.inputHasSelection=null);ar(n)});o(t.input,"keydown",e(n,wh));o(t.input,"keypress",e(n,uv));o(t.input,"focus",ft(wr,n));o(t.input,"blur",ft(fo,n));n.options.dragDrop&&(o(t.scroller,"dragstart",function(t){iv(n,t)}),o(t.scroller,"dragenter",h),o(t.scroller,"dragover",h),o(t.scroller,"drop",e(n,tv)));o(t.scroller,"paste",function(i){ti(t,i)||(it(n),ar(n))});o(t.input,"paste",function(){if(p&&!n.state.fakedLastChar&&!(new Date-n.state.lastMiddleDown<200)){var i=t.input.selectionStart,r=t.input.selectionEnd;t.input.value+="$";t.input.selectionStart=i;t.input.selectionEnd=r;n.state.fakedLastChar=!0}n.state.pasteIncoming=!0;ar(n)});o(t.input,"cut",c);o(t.input,"copy",c);cs&&o(t.sizer,"mouseup",function(){document.activeElement==t.input&&t.input.blur();it(n)})}function ti(n,t){for(var i=is(t);i!=n.wrapper;i=i.parentNode)if(!i||i.ignoreEvents||i.parentNode==n.sizer&&i!=n.mover)return!0}function yr(n,t,i){var r=n.display,u,e,o,f;if(!i&&(u=is(t),u==r.scrollbarH||u==r.scrollbarH.firstChild||u==r.scrollbarV||u==r.scrollbarV.firstChild||u==r.scrollbarFiller||u==r.gutterFiller))return null;f=c(r.lineSpace);try{e=t.clientX;o=t.clientY}catch(t){return null}return io(n,e-f.left,o-f.top)}function ga(n){function yt(n){if(!s(vt,n)){if(vt=n,b=="single"){w(i.doc,u(y,f),n);return}if(g=u(y,g),rt=u(y,rt),b=="double"){var e=co(r(y,n.line).text,n);h(n,g)?w(i.doc,e.from,rt):w(i.doc,g,e.to)}else b=="triple"&&(h(n,g)?w(i.doc,rt,u(y,t(n.line,0))):w(i.doc,g,u(y,t(n.line+1,0))))}}function ut(n){var f=++tt,t=yr(i,n,!0),r,u;t&&(s(t,ot)?(u=n.clientY<ht.top?-20:n.clientY>ht.bottom?20:0,u&&setTimeout(e(i,function(){tt==f&&(a.scroller.scrollTop+=u,ut(n))}),50)):(i.state.focused||wr(i),ot=t,yt(t),r=ve(a,y),(t.line>=r.to||t.line<r.from)&&setTimeout(e(i,function(){tt==f&&ut(n)}),150)))}function at(n){tt=Infinity;v(n);it(i);wt(document,"mousemove",ct);wt(document,"mouseup",lt)}var f,nt,b,et,ot,d,ht,tt,ct,lt;if(!st(this,n)){var i=this,a=i.display,y=i.doc,k=y.sel;if(k.shift=n.shiftKey,ti(a,n)){p||(a.scroller.draggable=!1,setTimeout(function(){a.scroller.draggable=!0},100));return}if(!ah(i,n)){f=yr(i,n);switch(rl(n)){case 3:ds&&bh.call(i,i,n);return;case 2:p&&(i.state.lastMiddleDown=+new Date);f&&w(i.doc,f);setTimeout(ft(it,i),20);v(n);return}if(!f){is(n)==a.scroller&&v(n);return}if(i.state.focused||wr(i),nt=+new Date,b="single",ie&&ie.time>nt-400&&s(ie.pos,f)?(b="triple",v(n),setTimeout(ft(it,i),20),hv(i,f.line)):te&&te.time>nt-400&&s(te.pos,f)?(b="double",ie={time:nt,pos:f},v(n),et=co(r(y,f.line).text,f),w(i.doc,et.from,et.to)):te={time:nt,pos:f},ot=f,i.options.dragDrop&&bl&&!vr(i)&&!s(k.from,k.to)&&!h(f,k.from)&&!h(k.to,f)&&b=="single"){d=e(i,function(t){p&&(a.scroller.draggable=!1);i.state.draggingText=!1;wt(document,"mouseup",d);wt(a.scroller,"drop",d);Math.abs(n.clientX-t.clientX)+Math.abs(n.clientY-t.clientY)<10&&(v(t),w(i.doc,f),it(i))});p&&(a.scroller.draggable=!0);i.state.draggingText=d;a.scroller.dragDrop&&a.scroller.dragDrop();o(document,"mouseup",d);o(a.scroller,"drop",d);return}v(n);b=="single"&&w(i.doc,u(y,f));var g=k.from,rt=k.to,vt=f;ht=c(a.wrapper);tt=0;ct=e(i,function(n){l||rl(n)?ut(n):at(n)});lt=e(i,at);o(document,"mousemove",ct);o(document,"mouseup",lt)}}}function lh(n,t,i,r,u){var s,e,o,h,f,l,a,y;try{s=t.clientX;e=t.clientY}catch(t){return!1}if(s>=Math.floor(c(n.display.gutters).right))return!1;if(r&&v(t),o=n.display,h=c(o.lineDiv),e>h.bottom||!ht(n,i))return ts(t);for(e-=h.top-o.viewOffset,f=0;f<n.options.gutters.length;++f)if(l=o.gutters.childNodes[f],l&&c(l).right>=s)return a=ru(n.doc,e),y=n.options.gutters[f],u(n,i,n,a,y,t),ts(t)}function nv(n,t){return ht(n,"gutterContextMenu")?lh(n,t,"gutterContextMenu",!1,y):!1}function ah(n,t){return lh(n,t,"gutterClick",!0,k)}function tv(n){var t=this,i,r,f,e,s,c;if(!st(t,n)&&!ti(t.display,n)&&(!t.options.onDragEvent||!t.options.onDragEvent(t,fu(n)))&&(v(n),l&&(as=+new Date),i=yr(t,n,!0),r=n.dataTransfer.files,i&&!vr(t)))if(r&&r.length&&window.FileReader&&window.File){var o=r.length,e=Array(o),a=0,y=function(n,r){var f=new FileReader;f.onload=function(){e[r]=f.result;++a==o&&(i=u(t.doc,i),yi(t.doc,{from:i,to:i,text:ni(e.join("\n")),origin:"paste"},"around"))};f.readAsText(n)};for(f=0;f<o;++f)y(r[f],f)}else{if(t.state.draggingText&&!(h(i,t.doc.sel.from)||h(t.doc.sel.to,i))){t.state.draggingText(n);setTimeout(ft(it,t),20);return}try{e=n.dataTransfer.getData("Text");e&&(s=t.doc.sel.from,c=t.doc.sel.to,yt(t.doc,i,i),t.state.draggingText&&kt(t.doc,"",s,c,"paste"),t.replaceSelection(e,null,"paste"),it(t))}catch(n){}}}function iv(n,t){var u,r;if(l&&(!n.state.draggingText||+new Date-as<100)){eu(t);return}st(n,t)||ti(n.display,t)||(u=n.getSelection(),t.dataTransfer.setData("Text",u),t.dataTransfer.setDragImage&&!hs&&(r=i("img",null,null,"position: fixed; left: 0; top: 0;"),r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",et&&(r.width=r.height=1,n.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),et&&r.parentNode.removeChild(r)))}function pr(n,t){Math.abs(n.doc.scrollTop-t)<2||(n.doc.scrollTop=t,gi||nf(n,[],t),n.display.scroller.scrollTop!=t&&(n.display.scroller.scrollTop=t),n.display.scrollbarV.scrollTop!=t&&(n.display.scrollbarV.scrollTop=t),gi&&nf(n,[]),sr(n,100))}function vi(n,t,i){(i?t==n.doc.scrollLeft:Math.abs(n.doc.scrollLeft-t)<2)||(t=Math.min(t,n.display.scroller.scrollWidth-n.display.scroller.clientWidth),n.doc.scrollLeft=t,ye(n),n.display.scroller.scrollLeft!=t&&(n.display.scroller.scrollLeft=t),n.display.scrollbarH.scrollLeft!=t&&(n.display.scrollbarH.scrollLeft=t))}function vh(n,t){var f=t.wheelDeltaX,u=t.wheelDeltaY,i,r,e;if(f==null&&t.detail&&t.axis==t.HORIZONTAL_AXIS&&(f=t.detail),u==null&&t.detail&&t.axis==t.VERTICAL_AXIS?u=t.detail:u==null&&(u=t.wheelDelta),i=n.display,r=i.scroller,f&&r.scrollWidth>r.clientWidth||u&&r.scrollHeight>r.clientHeight){if(u&&tr&&p)for(e=t.target;e!=r;e=e.parentNode)if(e.lineObj){n.display.currentWheelTarget=e;break}if(f&&!gi&&!et&&rt!=null){u&&pr(n,Math.max(0,Math.min(r.scrollTop+u*rt,r.scrollHeight-r.clientHeight)));vi(n,Math.max(0,Math.min(r.scrollLeft+f*rt,r.scrollWidth-r.clientWidth)));v(t);i.wheelStartX=null;return}if(u&&rt!=null){var s=u*rt,o=n.doc.scrollTop,h=o+i.wrapper.clientHeight;s<0?o=Math.max(0,o+s-50):h=Math.min(n.doc.height,h+s+50);nf(n,[],{top:o,bottom:h})}vu<20&&(i.wheelStartX==null?(i.wheelStartX=r.scrollLeft,i.wheelStartY=r.scrollTop,i.wheelDX=f,i.wheelDY=u,setTimeout(function(){if(i.wheelStartX!=null){var n=r.scrollLeft-i.wheelStartX,t=r.scrollTop-i.wheelStartY,u=t&&i.wheelDY&&t/i.wheelDY||n&&i.wheelDX&&n/i.wheelDX;(i.wheelStartX=i.wheelStartY=null,u)&&(rt=(rt*vu+u)/(vu+1),++vu)}},200)):(i.wheelDX+=f,i.wheelDY+=u))}}function ff(n,t,i){if(typeof t=="string"&&(t=oe[t],!t))return!1;n.display.pollingFast&&uo(n)&&(n.display.pollingFast=!1);var r=n.doc,f=r.sel.shift,u=!1;try{vr(n)&&(n.state.suppressEdits=!0);i&&(r.sel.shift=!1);u=t(n)!=bs}finally{r.sel.shift=f;n.state.suppressEdits=!1}return u}function yh(n){var t=n.state.keyMaps.slice(0);return n.options.extraKeys&&t.push(n.options.extraKeys),t.push(n.options.keyMap),t}function ph(n,t){var e=lo(n.options.keyMap),r=e.auto,i,u,f;return(clearTimeout(vl),r&&!ec(t)&&(vl=setTimeout(function(){lo(n.options.keyMap)==e&&(n.options.keyMap=r.call?r.call(null,n):r,nh(n))},50)),i=oc(t,!0),u=!1,!i)?!1:(f=yh(n),u=t.shiftKey?kr("Shift-"+i,f,function(t){return ff(n,t,!0)})||kr(i,f,function(t){if(typeof t=="string"?/^go[A-Z]/.test(t):t.motion)return ff(n,t)}):kr(i,f,function(t){return ff(n,t)}),u&&(v(t),tf(n),nt&&(t.oldKeyCode=t.keyCode,t.keyCode=0),k(n,"keyHandled",n,i,t)),u)}function rv(n,t,i){var r=kr("'"+i+"'",yh(n),function(t){return ff(n,t,!0)});return r&&(v(t),tf(n),k(n,"keyHandled",n,"'"+i+"'",t)),r}function wh(n){var t=this,i,r;(t.state.focused||wr(t),st(t,n)||t.options.onKeyEvent&&t.options.onKeyEvent(t,fu(n)))||(l&&n.keyCode==27&&(n.returnValue=!1),i=n.keyCode,t.doc.sel.shift=i==16||n.shiftKey,r=ph(t,n),et&&(re=r?i:null,r||i!=88||na||!(tr?n.metaKey:n.ctrlKey)||t.replaceSelection("")))}function uv(n){var t=this,i,r,u;if(!st(t,n)&&(!t.options.onKeyEvent||!t.options.onKeyEvent(t,fu(n)))){if(i=n.keyCode,r=n.charCode,et&&i==re){re=null;v(n);return}(et&&(!n.which||n.which<10)||cs)&&ph(t,n)||(u=String.fromCharCode(r==null?i:r),this.options.electricChars&&this.doc.mode.electricChars&&this.options.smartIndent&&!vr(this)&&this.doc.mode.electricChars.indexOf(u)>-1&&setTimeout(e(t,function(){cf(t,t.doc.sel.to.line,"smart")}),75),rv(t,n,u))||(l&&!nt&&(t.display.inputHasSelection=null),ar(t))}}function wr(n){n.options.readOnly!="nocursor"&&(n.state.focused||(y(n,"focus",n),n.state.focused=!0,n.display.wrapper.className.search(/\bCodeMirror-focused\b/)==-1&&(n.display.wrapper.className+=" CodeMirror-focused"),n.curOp||(vt(n,!0),p&&setTimeout(ft(vt,n,!0),0))),uf(n),tf(n))}function fo(n){n.state.focused&&(y(n,"blur",n),n.state.focused=!1,n.display.wrapper.className=n.display.wrapper.className.replace(" CodeMirror-focused",""));clearInterval(n.display.blinker);setTimeout(function(){n.state.focused||(n.doc.sel.shift=!1)},150)}function bh(n,t){function c(){if(i.input.selectionStart!=null){var n=i.input.value="​"+(s(r.from,r.to)?"":i.input.value);i.prevInput="​";i.input.selectionStart=1;i.input.selectionEnd=n.length}}function a(){if(i.inputDiv.style.position="relative",i.input.style.cssText=p,nt&&(i.scrollbarV.scrollTop=i.scroller.scrollTop=v),uf(n),i.input.selectionStart!=null){(!l||nt)&&c();clearTimeout(vs);var r=0,t=function(){i.prevInput==" "&&i.input.selectionStart==0?e(n,oe.selectAll)(n):r++<10?vs=setTimeout(t,500):vt(n)};vs=setTimeout(t,200)}}var i,r,u,v,y,p,f;st(n,t,"contextmenu")||(i=n.display,r=n.doc.sel,ti(i,t)||nv(n,t))||(u=yr(n,t),v=i.scroller.scrollTop,u&&!et)&&(y=n.options.resetSelectionOnContextMenu,y&&(s(r.from,r.to)||h(u,r.from)||!h(u,r.to))&&e(n,yt)(n.doc,u,u),p=i.input.style.cssText,i.inputDiv.style.position="absolute",i.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(t.clientY-5)+"px; left: "+(t.clientX-5)+"px; z-index: 1000; background: white; outline: none;border-width: 0; outline: none; overflow: hidden; opacity: .05; -ms-opacity: .05; filter: alpha(opacity=5);",it(n),vt(n,!0),s(r.from,r.to)&&(i.input.value=i.prevInput=" "),l&&!nt&&c(),ds?(eu(t),f=function(){wt(window,"mouseup",f);setTimeout(a,20)},o(window,"mouseup",f)):setTimeout(a,50))}function kh(n,i,f){var e,s,o,c;return h(i.from,f)?(e=i.text.length-1-(i.to.line-i.from.line),f.line>i.to.line+e)?(s=f.line-e,o=n.first+n.size-1,s>o)?t(o,r(n,o).text.length):ef(f,r(n,s).text.length):f.line==i.to.line+e?ef(f,d(i.text).length+(i.text.length==1?i.from.ch:0)+r(n,i.to.line).text.length-i.to.ch):(c=f.line-i.from.line,ef(f,i.text[c].length+(c?0:i.from.ch))):u(n,f)}function eo(n,i,r){var u,f;return r&&typeof r=="object"?{anchor:kh(n,i,r.anchor),head:kh(n,i,r.head)}:r=="start"?{anchor:i.from,head:i.from}:(u=ue(i),r=="around")?{anchor:i.from,head:u}:r=="end"?{anchor:u,head:u}:(f=function(n){if(h(n,i.from))return n;if(!h(i.to,n))return u;var f=n.line+i.text.length-(i.to.line-i.from.line)-1,r=n.ch;return n.line==i.to.line&&(r+=u.ch-i.to.ch),t(f,r)},{anchor:f(n.sel.anchor),head:f(n.sel.head)})}function dh(n,t,i){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return(i&&(r.update=function(t,i,r,f){t&&(this.from=u(n,t));i&&(this.to=u(n,i));r&&(this.text=r);f!==undefined&&(this.origin=f)}),y(n,"beforeChange",n,r),n.cm&&y(n.cm,"beforeChange",n.cm,r),r.canceled)?null:{from:r.from,to:r.to,text:r.text,origin:r.origin}}function yi(n,t,i,r){var u,f;if(n.cm){if(!n.cm.curOp)return e(n.cm,yi)(n,t,i,r);if(n.cm.state.suppressEdits)return}if(!ht(n,"beforeChange")&&(!n.cm||!ht(n.cm,"beforeChange"))||(t=dh(n,t,!0),t))if(u=gl&&!r&&pv(n,t.from,t.to),u){for(f=u.length-1;f>=1;--f)oo(n,{from:u[f].from,to:u[f].to,text:[""]});u.length&&oo(n,{from:u[0].from,to:u[0].to,text:t.text},i)}else oo(n,t,i)}function oo(n,t,i){var r,u;t.text.length==1&&t.text[0]==""&&s(t.from,t.to)||(r=eo(n,t,i),gc(n,t,r,n.cm?n.cm.curOp.id:NaN),br(n,t,r,ao(n,t)),u=[],bi(n,function(n,i){i||ct(u,n.history)!=-1||(tl(n.history,t),u.push(n.history));br(n,t,null,ao(n,t))}))}function gh(n,t){var r,i,e,s,f,u,h,o;if((!n.cm||!n.cm.state.suppressEdits)&&(r=n.history,i=(t=="undo"?r.done:r.undone).pop(),i))for(e={changes:[],anchorBefore:i.anchorAfter,headBefore:i.headAfter,anchorAfter:i.anchorBefore,headAfter:i.headBefore,generation:r.generation},(t=="undo"?r.undone:r.done).push(e),r.generation=i.generation||++r.maxGeneration,s=ht(n,"beforeChange")||n.cm&&ht(n.cm,"beforeChange"),f=i.changes.length-1;f>=0;--f){if(u=i.changes[f],u.origin=t,s&&!dh(n,u,!1)){(t=="undo"?r.done:r.undone).length=0;return}e.changes.push(ns(n,u));h=f?eo(n,u,null):{anchor:i.anchorBefore,head:i.headBefore};br(n,u,h,sc(n,u));o=[];bi(n,function(n,t){t||ct(o,n.history)!=-1||(tl(n.history,u),o.push(n.history));br(n,u,null,sc(n,u))})}}function nc(n,i){function r(n){return t(n.line+i,n.ch)}n.first+=i;n.cm&&a(n.cm,n.first,n.first,i);n.sel.head=r(n.sel.head);n.sel.anchor=r(n.sel.anchor);n.sel.from=r(n.sel.from);n.sel.to=r(n.sel.to)}function br(n,i,u,f){var s,o;if(n.cm&&!n.cm.curOp)return e(n.cm,br)(n,i,u,f);if(i.to.line<n.first){nc(n,i.text.length-1-(i.to.line-i.from.line));return}i.from.line>n.lastLine()||(i.from.line<n.first&&(s=i.text.length-1-(n.first-i.from.line),nc(n,s),i={from:t(n.first,0),to:t(i.to.line+s,i.to.ch),text:[d(i.text)],origin:i.origin}),o=n.lastLine(),i.to.line>o&&(i={from:i.from,to:t(o,r(n,o).text.length),text:[i.text[0]],origin:i.origin}),i.removed=ko(n,i.from,i.to),u||(u=eo(n,i,null)),n.cm?fv(n.cm,i,f,u):bo(n,i,f,u))}function fv(n,t,i,u){var f=n.doc,o=n.display,e=t.from,c=t.to,l=!1,v=e.line,p,y,s;if(n.options.lineWrapping||(v=g(pt(f,r(f,e.line))),f.iter(v,c.line+1,function(n){if(n==o.maxLine)return l=!0,!0})),h(f.sel.head,t.from)||h(t.to,f.sel.head)||(n.curOp.cursorActivity=!0),bo(f,t,i,u,gs(n)),n.options.lineWrapping||(f.iter(v,e.line+t.text.length,function(n){var t=gu(f,n);t>o.maxLineLength&&(o.maxLine=n,o.maxLineLength=t,o.maxLineChanged=!0,l=!1)}),l&&(n.curOp.updateMaxLine=!0)),f.frontier=Math.min(f.frontier,e.line),sr(n,400),p=t.text.length-(c.line-e.line)-1,a(n,e.line,c.line+1,p),ht(n,"change"))if(y={from:e,to:c,text:t.text,removed:t.removed,origin:t.origin},n.curOp.textChanged){for(s=n.curOp.textChanged;s.next;s=s.next);s.next=y}else n.curOp.textChanged=y}function kt(n,t,i,r,u){if(r||(r=i),h(r,i)){var f=r;r=i;i=f}typeof t=="string"&&(t=ni(t));yi(n,{from:i,to:r,text:t,origin:u},null)}function t(n,i){if(!(this instanceof t))return new t(n,i);this.line=n;this.ch=i}function s(n,t){return n.line==t.line&&n.ch==t.ch}function h(n,t){return n.line<t.line||n.line==t.line&&n.ch<t.ch}function ii(n){return t(n.line,n.ch)}function tc(n,t){return Math.max(n.first,Math.min(t,n.first+n.size-1))}function u(n,i){if(i.line<n.first)return t(n.first,0);var u=n.first+n.size-1;return i.line>u?t(u,r(n,u).text.length):ef(i,r(n,i.line).text.length)}function ef(n,i){var r=n.ch;return r==null||r>i?t(n.line,i):r<0?t(n.line,0):n}function pi(n,t){return t>=n.first&&t<n.first+n.size}function w(n,t,i,r){var u,f;n.sel.shift||n.sel.extend?(u=n.sel.anchor,i&&(f=h(t,u),f!=h(i,u)?(u=t,t=i):f!=h(t,i)&&(t=i)),yt(n,u,t,r)):yt(n,t,i||t,r);n.cm&&(n.cm.curOp.userSelChange=!0)}function ev(n,t,i){var r={anchor:t,head:i};return y(n,"beforeSelectionChange",n,r),n.cm&&y(n.cm,"beforeSelectionChange",n.cm,r),r.anchor=u(n,r.anchor),r.head=u(n,r.head),r}function yt(n,t,i,r,u){var e,f,o;((!u&&ht(n,"beforeSelectionChange")||n.cm&&ht(n.cm,"beforeSelectionChange"))&&(e=ev(n,t,i),i=e.head,t=e.anchor),f=n.sel,f.goalColumn=null,r==null&&(r=h(i,f.head)?-1:1),(u||!s(t,f.anchor))&&(t=of(n,t,r,u!="push")),(u||!s(i,f.head))&&(i=of(n,i,r,u!="push")),s(f.anchor,t)&&s(f.head,i))||(f.anchor=t,f.head=i,o=h(i,t),f.from=o?i:t,f.to=o?t:i,n.cm&&(n.cm.curOp.updateInput=n.cm.curOp.selectionChanged=n.cm.curOp.cursorActivity=!0),k(n,"cursorActivity",n))}function ic(n){yt(n.doc,n.doc.sel.from,n.doc.sel.to,null,"push")}function of(n,i,f,e){var w=!1,h=i,p=f||1,a,v,c,l,o;n.cantEdit=!1;n:for(;;){if(a=r(n,h.line),a.markedSpans)for(v=0;v<a.markedSpans.length;++v)if(c=a.markedSpans[v],l=c.marker,(c.from==null||(l.inclusiveLeft?c.from<=h.ch:c.from<h.ch))&&(c.to==null||(l.inclusiveRight?c.to>=h.ch:c.to>h.ch))){if(e&&(y(l,"beforeCursorEnter"),l.explicitlyCleared))if(a.markedSpans){--v;continue}else break;if(!l.atomic)continue;if(o=l.find()[p<0?"from":"to"],s(o,h)&&(o.ch+=p,o.ch<0?o=o.line>n.first?u(n,t(o.line-1)):null:o.ch>a.text.length&&(o=o.line<n.first+n.size-1?t(o.line+1,0):null),!o)){if(w)return e?(n.cantEdit=!0,t(n.first,0)):of(n,i,f,!0);w=!0;o=i;p=-p}h=o;continue n}return h}}function ov(n){var i=rc(n,n.doc.sel.head,null,n.options.cursorScrollMargin),u;if(n.state.focused){var t=n.display,f=c(t.sizer),r=null;i.top+f.top<0?r=!0:i.bottom+f.top>(window.innerHeight||document.documentElement.clientHeight)&&(r=!1);r==null||yy||(u=t.cursor.style.display=="none",u&&(t.cursor.style.display="",t.cursor.style.left=i.left+"px",t.cursor.style.top=i.top-t.viewOffset+"px"),t.cursor.scrollIntoView(r),u&&(t.cursor.style.display="none"))}}function rc(n,t,i,r){for(r==null&&(r=0);;){var o=!1,u=tt(n,t),f=!i||i==t?u:tt(n,i),e=sf(n,Math.min(u.left,f.left),Math.min(u.top,f.top)-r,Math.max(u.left,f.left),Math.max(u.bottom,f.bottom)+r),s=n.doc.scrollTop,h=n.doc.scrollLeft;if(e.scrollTop!=null&&(pr(n,e.scrollTop),Math.abs(n.doc.scrollTop-s)>1&&(o=!0)),e.scrollLeft!=null&&(vi(n,e.scrollLeft),Math.abs(n.doc.scrollLeft-h)>1&&(o=!0)),!o)return u}}function sv(n,t,i,r,u){var f=sf(n,t,i,r,u);f.scrollTop!=null&&pr(n,f.scrollTop);f.scrollLeft!=null&&vi(n,f.scrollLeft)}function sf(n,t,i,r,u){var f=n.display,v=ci(n.display),s,h,c,o,l;i<0&&(i=0);var y=f.scroller.clientHeight-oi,a=f.scroller.scrollTop,e={},p=n.doc.height+fh(f),w=i<v,b=u>p-v;return i<a?e.scrollTop=w?0:i:u>a+y&&(s=Math.min(i,(b?p:u)-y),s!=a&&(e.scrollTop=s)),h=f.scroller.clientWidth-oi,c=f.scroller.scrollLeft,t+=f.gutters.offsetWidth,r+=f.gutters.offsetWidth,o=f.gutters.offsetWidth,l=t<o+10,t<c+o||l?(l&&(t=0),e.scrollLeft=Math.max(0,t-10-o)):r>h+c-3&&(e.scrollLeft=r+10-h),e}function hf(n,t,i){n.curOp.updateScrollPos={scrollLeft:t==null?n.doc.scrollLeft:t,scrollTop:i==null?n.doc.scrollTop:i}}function so(n,t,i){var r=n.curOp.updateScrollPos||(n.curOp.updateScrollPos={scrollLeft:n.doc.scrollLeft,scrollTop:n.doc.scrollTop}),u=n.display.scroller;r.scrollTop=Math.max(0,Math.min(u.scrollHeight-u.clientHeight,r.scrollTop+i));r.scrollLeft=Math.max(0,Math.min(u.scrollWidth-u.clientWidth,r.scrollLeft+t))}function cf(n,i,u,f){var o=n.doc,p,h,l,v;u==null&&(u="add");u=="smart"&&(n.doc.mode.indent?p=hr(n,i):u="prev");var a=n.options.tabSize,c=r(o,i),y=di(c.text,null,a),s=c.text.match(/^\s*/)[0],e;if(u=="smart"&&(e=n.doc.mode.indent(p,c.text.slice(s.length),c.text),e==bs)){if(!f)return;u="prev"}if(u=="prev"?e=i>o.first?di(r(o,i-1).text,null,a):0:u=="add"?e=y+n.options.indentUnit:u=="subtract"?e=y-n.options.indentUnit:typeof u=="number"&&(e=y+u),e=Math.max(0,e),h="",l=0,n.options.indentWithTabs)for(v=Math.floor(e/a);v;--v)l+=a,h+="\t";l<e&&(h+=ul(e-l));h!=s?kt(n.doc,h,t(i,0),t(i,s.length),"+input"):o.sel.head.line==i&&o.sel.head.ch<s.length&&yt(o,t(i,s.length),t(i,s.length),1);c.stateAfter=null}function lf(n,t,i){var u=t,f=t,e=n.doc;if(typeof t=="number"?f=r(e,tc(e,t)):u=g(t),u==null)return null;if(i(f,u))a(n,u,u+1);else return null;return f}function ho(n,i,u,f,e){function k(){var t=c+u;return t<n.first||t>=n.first+n.size?y=!1:(c=t,h=r(n,t))}function o(n){var t=(e?ss:ll)(h,s,u,!0);if(t==null)if(!n&&k())s=e?(u<0?ne:gf)(h):u<0?h.text.length:0;else return y=!1;else s=t;return!0}var c=i.line,s=i.ch,d=u,h=r(n,c),y=!0,l,b,a,p,v,w;if(f=="char")o();else if(f=="column")o(!0);else if(f=="word"||f=="group")for(l=null,b=f=="group",a=!0;;a=!1){if(u<0&&!o(!a))break;if(p=h.text.charAt(s)||"\n",v=ou(p)?"w":b?/\s/.test(p)?null:"p":null,l&&l!=v){u<0&&(u=1,o());break}if(v&&(l=v),u>0&&!o(!a))break}return w=of(n,t(c,s),d,!0),y||(w.hitSide=!0),w}function uc(n,t,i,r){var o=n.doc,s=t.left,u,e,f;for(r=="page"?(e=Math.min(n.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),u=t.top+i*(e-(i<0?1.5:.5)*ci(n.display))):r=="line"&&(u=i>0?t.bottom+3:t.top-3);;){if(f=io(n,s,u),!f.outside)break;if(i<0?u<=0:u>=o.height){f.hitSide=!0;break}u+=i*5}return f}function co(n,i){var r=i.ch,u=i.ch,f,e;if(n){for((i.xRel<0||u==n.length)&&r?--r:++u,f=n.charAt(r),e=ou(f)?ou:/\s/.test(f)?function(n){return/\s/.test(n)}:function(n){return!/\s/.test(n)&&!ou(n)};r>0&&e(n.charAt(r-1));)--r;while(u<n.length&&e(n.charAt(u)))++u}return{from:t(i.line,r),to:t(i.line,u)}}function hv(n,i){w(n.doc,t(i,0),u(n.doc,t(i+1,0)))}function f(t,i,r,u){n.defaults[t]=i;r&&(ei[t]=u?function(n,t,i){i!=ys&&r(n,t,i)}:r)}function wi(n,t){var r,u,i;if(t===!0)return t;if(n.copyState)return n.copyState(t);r={};for(u in t)i=t[u],i instanceof Array&&(i=i.concat([])),r[u]=i;return r}function fc(n,t,i){return n.startState?n.startState(t,i):!0}function lo(n){return typeof n=="string"?at[n]:n}function kr(n,t,i){function r(t){var f,u,e,s,o;if(t=lo(t),f=t[n],f===!1)return"stop";if(f!=null&&i(f))return!0;if(t.nofallthrough)return"stop";if(u=t.fallthrough,u==null)return!1;if(Object.prototype.toString.call(u)!="[object Array]")return r(u);for(e=0,s=u.length;e<s;++e)if(o=r(u[e]),o)return o;return!1}for(var u,f=0;f<t.length;++f)if(u=r(t[f]),u)return u!="stop"}function ec(n){var t=si[n.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"}function oc(n,t){if(et&&n.keyCode==34&&n.char)return!1;var i=si[n.keyCode];return i==null||n.altGraphKey?!1:(n.altKey&&(i="Alt-"+i),(dl?n.metaKey:n.ctrlKey)&&(i="Ctrl-"+i),(dl?n.ctrlKey:n.metaKey)&&(i="Cmd-"+i),!t&&n.shiftKey&&(i="Shift-"+i),i)}function dr(n,t){this.pos=this.start=0;this.string=n;this.tabSize=t||8;this.lastColumnPos=this.lastColumnValue=0}function dt(n,t){this.lines=[];this.type=t;this.doc=n}function gr(n,t,r,u,f){var c;if(u&&u.shared)return cv(n,t,r,u,f);if(n.cm&&!n.cm.curOp)return e(n.cm,gr)(n,t,r,u,f);if(c=new dt(n,f),h(r,t)||s(t,r)&&f=="range"&&!(u.inclusiveLeft&&u.inclusiveRight))return c;u&&df(u,c);c.replacedWith&&(c.collapsed=!0,c.replacedWith=i("span",[c.replacedWith],"CodeMirror-widget"),u.handleMouseEvents||(c.replacedWith.ignoreEvents=!0));c.collapsed&&(du=!0);c.addToHistory&&gc(n,{from:t,to:r,origin:"markText"},{head:n.sel.head,anchor:n.sel.anchor},NaN);var v=t.line,y=0,p,w,l=n.cm,b;if(n.iter(v,r.line+1,function(i){l&&c.collapsed&&!l.options.lineWrapping&&pt(n,i)==l.display.maxLine&&(b=!0);var u={from:null,to:null,marker:c};y+=i.text.length;v==t.line&&(u.from=t.ch,y-=t.ch);v==r.line&&(u.to=r.ch,y-=i.text.length-r.ch);c.collapsed&&(v==r.line&&(w=af(i,r.ch)),v==t.line?p=af(i,t.ch):ut(i,0));av(i,u);++v}),c.collapsed&&n.iter(t.line,r.line+1,function(t){ri(n,t)&&ut(t,0)}),c.clearOnEnter&&o(c,"beforeCursorEnter",function(){c.clear()}),c.readOnly&&(gl=!0,(n.history.done.length||n.history.undone.length)&&n.clearHistory()),c.collapsed){if(p!=w)throw new Error("Inserting collapsed marker overlapping an existing one");c.size=y;c.atomic=!0}return l&&(b&&(l.curOp.updateMaxLine=!0),(c.className||c.title||c.startStyle||c.endStyle||c.collapsed)&&a(l,t.line,r.line+1),c.atomic&&ic(l)),c}function nu(n,t){this.markers=n;this.primary=t;for(var i=0,r=this;i<n.length;++i)n[i].parent=this,o(n[i],"clear",function(){r.clear()})}function cv(n,t,i,r,f){r=df(r);r.shared=!1;var e=[gr(n,t,i,r,f)],o=e[0],s=r.replacedWith;return bi(n,function(n){s&&(r.replacedWith=s.cloneNode(!0));e.push(gr(n,u(n,t),u(n,i),r,f));for(var h=0;h<n.linked.length;++h)if(n.linked[h].isParent)return;o=d(e)}),new nu(e,o)}function tu(n,t){var i,r;if(n)for(i=0;i<n.length;++i)if(r=n[i],r.marker==t)return r}function lv(n,t){for(var r,i=0;i<n.length;++i)n[i]!=t&&(r||(r=[])).push(n[i]);return r}function av(n,t){n.markedSpans=n.markedSpans?n.markedSpans.concat([t]):[t];t.marker.attachLine(n)}function vv(n,t,i){var f,e,o;if(n)for(f=0;f<n.length;++f){var r=n[f],u=r.marker,s=r.from==null||(u.inclusiveLeft?r.from<=t:r.from<t);(s||(u.inclusiveLeft&&u.inclusiveRight||u.type=="bookmark")&&r.from==t&&(!i||!r.marker.insertLeft))&&(o=r.to==null||(u.inclusiveRight?r.to>=t:r.to>t),(e||(e=[])).push({from:r.from,to:o?null:r.to,marker:u}))}return e}function yv(n,t,i){var u,e,o;if(n)for(u=0;u<n.length;++u){var r=n[u],f=r.marker,s=r.to==null||(f.inclusiveRight?r.to>=t:r.to>t);(s||f.type=="bookmark"&&r.from==t&&(!i||r.marker.insertLeft))&&(o=r.from==null||(f.inclusiveLeft?r.from<=t:r.from<t),(e||(e=[])).push({from:o?null:r.from-t,to:r.to==null?null:r.to-t,marker:f}))}return e}function ao(n,t){var p=pi(n,t.from.line)&&r(n,t.from.line).markedSpans,w=pi(n,t.to.line)&&r(n,t.to.line).markedSpans,f,e,c,a,v,i;if(!p&&!w)return null;var y=t.from.ch,k=t.to.ch,b=s(t.from,t.to),u=vv(p,y,b),h=yv(w,k,b),o=t.text.length==1,l=d(t.text).length+(o?y:0);if(u)for(i=0;i<u.length;++i)f=u[i],f.to==null&&(e=tu(h,f.marker),e?o&&(f.to=e.to==null?null:e.to+l):f.to=y);if(h)for(i=0;i<h.length;++i)f=h[i],f.to!=null&&(f.to+=l),f.from==null?(e=tu(u,f.marker),e||(f.from=l,o&&(u||(u=[])).push(f))):(f.from+=l,o&&(u||(u=[])).push(f));if(o&&u){for(i=0;i<u.length;++i)u[i].from!=null&&u[i].from==u[i].to&&u[i].marker.type!="bookmark"&&u.splice(i--,1);u.length||(u=null)}if(c=[u],!o){if(a=t.text.length-2,a>0&&u)for(i=0;i<u.length;++i)u[i].to==null&&(v||(v=[])).push({from:null,to:null,marker:u[i].marker});for(i=0;i<a;++i)c.push(v);c.push(h)}return c}function sc(n,t){var i=ry(n,t),s=ao(n,t),r,f,u,e,h,o;if(!i)return s;if(!s)return i;for(r=0;r<i.length;++r)if(f=i[r],u=s[r],f&&u)n:for(e=0;e<u.length;++e){for(h=u[e],o=0;o<f.length;++o)if(f[o].marker==h.marker)continue n;f.push(h)}else u&&(i[r]=u);return i}function pv(n,t,i){var f=null,e,l,a,r,o,u,c;if(n.iter(t.line,i.line+1,function(n){var t,i;if(n.markedSpans)for(t=0;t<n.markedSpans.length;++t)i=n.markedSpans[t].marker,i.readOnly&&(!f||ct(f,i)==-1)&&(f||(f=[])).push(i)}),!f)return null;for(e=[{from:t,to:i}],l=0;l<f.length;++l)for(a=f[l],r=a.find(),o=0;o<e.length;++o)(u=e[o],h(u.to,r.from)||h(r.to,u.from))||(c=[o,1],(h(u.from,r.from)||!a.inclusiveLeft&&s(u.from,r.from))&&c.push({from:u.from,to:r.from}),(h(r.to,u.to)||!a.inclusiveRight&&s(u.to,r.to))&&c.push({from:r.to,to:u.to}),e.splice.apply(e,c),o+=c.length-1);return e}function af(n,t){var f=du&&n.markedSpans,r,i,u;if(f)for(u=0;u<f.length;++u)(i=f[u],i.marker.collapsed)&&(i.from==null||i.from<t)&&(i.to==null||i.to>t)&&(!r||r.width<i.marker.width)&&(r=i.marker);return r}function vo(n){return af(n,-1)}function vf(n){return af(n,n.text.length+1)}function pt(n,t){for(var i;i=vo(t);)t=r(n,i.find().from.line);return t}function ri(n,t){var u=du&&t.markedSpans,i,r;if(u)for(r=0;r<u.length;++r)if((i=u[r],i.marker.collapsed)&&(i.from==null||!i.marker.replacedWith&&i.from==0&&i.marker.inclusiveLeft&&yo(n,t,i)))return!0}function yo(n,t,i){var o,e,u,f;if(i.to==null)return o=i.marker.find().to,e=r(n,o.line),yo(n,e,tu(e.markedSpans,i.marker));if(i.marker.inclusiveRight&&i.to==t.text.length)return!0;for(f=0;f<t.markedSpans.length;++f)if(u=t.markedSpans[f],u.marker.collapsed&&!u.marker.replacedWith&&u.from==i.to&&(u.marker.inclusiveLeft||i.marker.inclusiveRight)&&yo(n,t,u))return!0}function hc(n){var i=n.markedSpans,t;if(i){for(t=0;t<i.length;++t)i[t].marker.detachLine(n);n.markedSpans=null}}function cc(n,t){if(t){for(var i=0;i<t.length;++i)t[i].marker.attachLine(n);n.markedSpans=t}}function lc(n){return function(){var t=!this.cm.curOp,i;t&&li(this.cm);try{i=n.apply(this,arguments)}finally{t&&ai(this.cm)}return i}}function yf(n){return n.height!=null?n.height:(n.node.parentNode&&n.node.parentNode.nodeType==1||lt(n.cm.display.measure,i("div",[n.node],null,"position: relative")),n.height=n.node.offsetHeight)}function wv(n,t,i,r){var u=new yu(n,i,r);return u.noHScroll&&(n.display.alignWidgets=!0),lf(n,t,function(t){var i=t.widgets||(t.widgets=[]),r;return u.insertAt==null?i.push(u):i.splice(Math.min(i.length-1,Math.max(0,u.insertAt)),0,u),u.line=t,(!ri(n.doc,t)||u.showIfHidden)&&(r=uu(n,t)<n.doc.scrollTop,ut(t,t.height+yf(u)),r&&so(n,0,u.height)),!0}),u}function bv(n,t,i,r){n.text=t;n.stateAfter&&(n.stateAfter=null);n.styles&&(n.styles=null);n.order!=null&&(n.order=null);hc(n);cc(n,i);var u=r?r(n):1;u!=n.height&&ut(n,u)}function kv(n){n.parent=null;hc(n)}function ac(n,t,i,r,u,f){var s=i.flattenSpans,l;s==null&&(s=n.options.flattenSpans);var o=0,h=null,e=new dr(t,n.options.tabSize),c;for(t==""&&i.blankLine&&i.blankLine(r);!e.eol();)e.pos>n.options.maxHighlightLength?(s=!1,f&&po(n,t,r,e.pos),e.pos=t.length,c=null):c=i.token(e,r),s&&h==c||(o<e.start&&u(e.start,h),o=e.start,h=c),e.start=e.pos;while(o<e.pos)l=Math.min(e.pos,o+5e4),u(l,h),o=l}function vc(n,t,i,r){var u=[n.state.modeGen],e;for(ac(n,t.text,n.doc.mode,i,function(n,t){u.push(n,t)},r),e=0;e<n.state.overlays.length;++e){var o=n.state.overlays[e],f=1,s=0;ac(n,t.text,o.mode,!0,function(n,t){for(var i=f,r,e;s<n;)r=u[f],r>n&&u.splice(f,1,n,u[f+1],r),f+=2,s=Math.min(n,r);if(t)if(o.opaque)u.splice(i,f-i,n,t),f=i+2;else for(;i<f;i+=2)e=u[i+1],u[i+1]=e?e+" "+t:t})}return u}function yc(n,t){return t.styles&&t.styles[0]==n.state.modeGen||(t.styles=vc(n,t,t.stateAfter=hr(n,g(t)))),t.styles}function po(n,t,i,r){var f=n.doc.mode,u=new dr(t,n.options.tabSize);for(u.start=u.pos=r||0,t==""&&f.blankLine&&f.blankLine(i);!u.eol()&&u.pos<=n.options.maxHighlightLength;)f.token(u,i),u.start=u.pos}function pc(n,t){var i,r;if(!n)return null;for(;;){if(i=n.match(/(?:^|\s)line-(background-)?(\S+)/),!i)break;n=n.slice(0,i.index)+n.slice(i.index+i[0].length);r=i[1]?"bgClass":"textClass";t[r]==null?t[r]=i[2]:new RegExp("(?:^|s)"+i[2]+"(?:$|s)").test(t[r])||(t[r]+=" "+i[2])}return ws[n]||(ws[n]="cm-"+n.replace(/ +/g," cm-"))}function wo(n,t,u,f){for(var k,o=t,d=!0,e,a,s,h,v,w,c,b;k=vo(o);)o=r(n.doc,k.find().from.line);e={pre:i("pre"),col:0,pos:0,measure:null,measuredSomething:!1,cm:n,copyWidgets:f};do o.text&&(d=!1),e.measure=o==t&&u,e.pos=0,e.addToken=e.measure?gv:wc,(l||p)&&n.getOption("lineWrapping")&&(e.addToken=ny(e.addToken)),a=ty(o,e,yc(n,o)),u&&o==t&&!e.measuredSomething&&(u[0]=e.pre.appendChild(lu(n.display.measure)),e.measuredSomething=!0),a&&(o=r(n.doc,a.to.line));while(a);return!u||e.measuredSomething||u[0]||(u[0]=e.pre.appendChild(d?i("span"," "):lu(n.display.measure))),e.pre.firstChild||ri(n.doc,t)||e.pre.appendChild(document.createTextNode(" ")),u&&(l||hy)&&(s=ot(o))&&(h=s.length-1,s[h].from==s[h].to&&--h,v=s[h],w=s[h-1],v.from+1==v.to&&w&&v.level<w.level&&(c=u[e.pos-1],c&&c.parentNode.insertBefore(c.measureRight=lu(n.display.measure),c.nextSibling))),b=e.textClass?e.textClass+" "+(t.textClass||""):t.textClass,b&&(e.pre.className=b),y(n,"renderLine",n,t,e.pre),e}function dv(n){var t=i("span","•","cm-invalidchar");return t.title="\\u"+n.charCodeAt(0).toString(16),t}function wc(n,t,r,u,f,e){var a,o,s,h,c,y,p,v,l;if(t){if(a=n.cm.options.specialChars,a.test(t))for(o=document.createDocumentFragment(),s=0;;){if(a.lastIndex=s,h=a.exec(t),c=h?h.index-s:t.length-s,c&&(o.appendChild(document.createTextNode(t.slice(s,s+c))),n.col+=c),!h)break;s+=c+1;h[0]=="\t"?(y=n.cm.options.tabSize,p=y-n.col%y,o.appendChild(i("span",ul(p),"cm-tab")),n.col+=p):(l=n.cm.options.specialCharPlaceholder(h[0]),o.appendChild(l),n.col+=1)}else n.col+=t.length,o=document.createTextNode(t);if(r||u||f||n.measure)return v=r||"",u&&(v+=u),f&&(v+=f),l=i("span",[o],v),e&&(l.title=e),n.pre.appendChild(l);n.pre.appendChild(o)}}function gv(n,t,r,u,f){for(var o,c,s,h,a=n.cm.options.lineWrapping,e=0;e<t.length;++e)o=t.charAt(e),c=e==0,o>="\ud800"&&o<"\udbff"&&e<t.length-1?(o=t.slice(e,e+2),++e):e&&a&&hu(t,e)&&n.pre.appendChild(i("wbr")),s=n.measure[n.pos],h=n.measure[n.pos]=wc(n,o,r,c&&u,e==t.length-1&&f),s&&(h.leftSide=s.leftSide||s),l&&a&&o==" "&&e&&!/\s/.test(t.charAt(e-1))&&e<t.length-1&&!/\s/.test(t.charAt(e+1))&&(h.style.whiteSpace="normal"),n.pos+=o.length;t.length&&(n.measuredSomething=!0)}function ny(n){function t(n){for(var i=" ",t=0;t<n.length-2;++t)i+=t%2?" ":" ";return i+" "}return function(i,r,u,f,e,o){return n(i,r.replace(/ {3,}/g,t),u,f,e,o)}}function bc(n,t,i,r){var u=!r&&i.replacedWith,f;if(u&&(n.copyWidgets&&(u=u.cloneNode(!0)),n.pre.appendChild(u),n.measure)){if(t)n.measure[n.pos]=u;else if(f=lu(n.cm.display.measure),i.type!="bookmark"||i.insertLeft){if(n.measure[n.pos])return;n.measure[n.pos]=n.pre.insertBefore(f,u)}else n.measure[n.pos]=n.pre.appendChild(f);n.measuredSomething=!0}n.pos+=t}function ty(n,t,i){var d=n.markedSpans,g=n.text,v=0,h,a,r,f,s,l,y,nt;if(!d){for(h=1;h<i.length;h+=2)t.addToken(t,g.slice(v,v=i[h]),pc(i[h+1],t));return}for(var tt=g.length,u=0,h=1,c="",it,o=0,p,w,b,k,e;;){if(o==u){for(p=w=b=k="",e=null,o=Infinity,a=[],s=0;s<d.length;++s)r=d[s],f=r.marker,r.from<=u&&(r.to==null||r.to>u)?(r.to!=null&&o>r.to&&(o=r.to,w=""),f.className&&(p+=" "+f.className),f.startStyle&&r.from==u&&(b+=" "+f.startStyle),f.endStyle&&r.to==o&&(w+=" "+f.endStyle),f.title&&!k&&(k=f.title),f.collapsed&&(!e||e.marker.size<f.size)&&(e=r)):r.from>u&&o>r.from&&(o=r.from),f.type=="bookmark"&&r.from==u&&f.replacedWith&&a.push(f);if(e&&(e.from||0)==u&&(bc(t,(e.to==null?tt:e.to)-u,e.marker,e.from==null),e.to==null))return e.marker.find();if(!e&&a.length)for(s=0;s<a.length;++s)bc(t,0,a[s])}if(u>=tt)break;for(l=Math.min(tt,o);;){if(c){if(y=u+c.length,e||(nt=y>l?c.slice(0,l-u):c,t.addToken(t,nt,it?it+p:p,b,u+nt.length==o?w:"",k)),y>=l){c=c.slice(l-u);u=l;break}u=y;b=""}c=g.slice(v,v=i[h++]);it=pc(i[h++],t)}}}function bo(n,t,i,u,f){function l(n){return i?i[n]:null}function v(n,i,r){bv(n,i,r,f);k(n,"change",n,t)}var e=t.from,a=t.to,o=t.text,h=r(n,e.line),y=r(n,a.line),w=d(o),b=l(o.length-1),p=a.line-e.line;if(e.ch==0&&a.ch==0&&w==""&&(!n.cm||n.cm.options.wholeLineUpdateBefore)){for(var s=0,g=o.length-1,c=[];s<g;++s)c.push(new bt(o[s],l(s),f));v(y,y.text,b);p&&n.remove(e.line,p);c.length&&n.insert(e.line,c)}else if(h==y)if(o.length==1)v(h,h.text.slice(0,e.ch)+w+h.text.slice(a.ch),b);else{for(var c=[],s=1,g=o.length-1;s<g;++s)c.push(new bt(o[s],l(s),f));c.push(new bt(w+h.text.slice(a.ch),b,f));v(h,h.text.slice(0,e.ch)+o[0],l(0));n.insert(e.line+1,c)}else if(o.length==1)v(h,h.text.slice(0,e.ch)+o[0]+y.text.slice(a.ch),l(0)),n.remove(e.line+1,p);else{v(h,h.text.slice(0,e.ch)+o[0],l(0));v(y,w+y.text.slice(a.ch),b);for(var s=1,g=o.length-1,c=[];s<g;++s)c.push(new bt(o[s],l(s),f));p>1&&n.remove(e.line+1,p-1);n.insert(e.line+1,c)}k(n,"change",n,t);yt(n,u.anchor,u.head,null,!0)}function pf(n){this.lines=n;this.parent=null;for(var t=0,r=n.length,i=0;t<r;++t)n[t].parent=this,i+=n[t].height;this.height=i}function iu(n){var r,u,t,f,i;for(this.children=n,r=0,u=0,t=0,f=n.length;t<f;++t)i=n[t],r+=i.chunkSize(),u+=i.height,i.parent=this;this.size=r;this.height=u;this.parent=null}function bi(n,t,i){function r(n,u,f){var o,e,s;if(n.linked)for(o=0;o<n.linked.length;++o)(e=n.linked[o],e.doc!=u)&&(s=f&&e.sharedHist,!i||s)&&(t(e.doc,s),r(e.doc,n,s))}r(n,null,!0)}function kc(n,t){if(t.cm)throw new Error("This document is already in use.");n.doc=t;t.cm=n;he(n);er(n);n.options.lineWrapping||ce(n);n.options.mode=t.modeOption;a(n)}function r(n,t){var i,r,u;for(t-=n.first;!n.lines;)for(i=0;;++i){if(r=n.children[i],u=r.chunkSize(),t<u){n=r;break}t-=u}return n.lines[t]}function ko(n,t,i){var u=[],r=t.line;return n.iter(t.line,i.line+1,function(n){var f=n.text;r==i.line&&(f=f.slice(0,i.ch));r==t.line&&(f=f.slice(t.ch));u.push(f);++r}),u}function go(n,t,i){var r=[];return n.iter(t,i,function(n){r.push(n.text)}),r}function ut(n,t){for(var r=t-n.height,i=n;i;i=i.parent)i.height+=r}function g(n){var i,u,t,r;if(n.parent==null)return null;for(i=n.parent,u=ct(i.lines,n),t=i.parent;t;i=t,t=t.parent)for(r=0;;++r){if(t.children[r]==i)break;u+=t.children[r].chunkSize()}return u+i.first}function ru(n,t){var f=n.first,r,e,i,u,s,o;n:do{for(i=0,u=n.children.length;i<u;++i){if(r=n.children[i],e=r.height,t<e){n=r;continue n}t-=e;f+=r.chunkSize()}return f}while(!n.lines);for(i=0,u=n.lines.length;i<u;++i){if(s=n.lines[i],o=s.height,t<o)break;t-=o}return f+i}function uu(n,t){var f,r,e,u,i,o;for(t=pt(n.doc,t),f=0,r=t.parent,i=0;i<r.lines.length;++i)if(e=r.lines[i],e==t)break;else f+=e.height;for(u=r.parent;u;r=u,u=r.parent)for(i=0;i<u.children.length;++i)if(o=u.children[i],o==r)break;else f+=o.height;return f}function ot(n){var t=n.order;return t==null&&(t=n.order=kl(n.text)),t}function wf(n){return{done:[],undone:[],undoDepth:Infinity,lastTime:0,lastOp:null,lastOrigin:null,generation:n||1,maxGeneration:n||1}}function dc(n,t,i,r){var u=t["spans_"+n.id],f=0;n.iter(Math.max(n.first,i),Math.min(n.first+n.size,r),function(i){i.markedSpans&&((u||(u=t["spans_"+n.id]={}))[f]=i.markedSpans);++f})}function ns(n,t){var r={line:t.from.line,ch:t.from.ch},i={from:r,to:ue(t),text:ko(n,t.from,t.to)};return dc(n,i,t.from.line,t.to.line+1),bi(n,function(n){dc(n,i,t.from.line,t.to.line+1)},!0),i}function gc(n,t,i,r){var u=n.history,e,f,o;if(u.undone.length=0,e=+new Date,f=d(u.done),f&&(u.lastOp==r||u.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&n.cm&&u.lastTime>e-n.cm.options.historyEventDelay||t.origin.charAt(0)=="*")))o=d(f.changes),s(t.from,t.to)&&s(t.from,o.to)?o.to=ue(t):f.changes.push(ns(n,t)),f.anchorAfter=i.anchor,f.headAfter=i.head;else for(f={changes:[ns(n,t)],generation:u.generation,anchorBefore:n.sel.anchor,headBefore:n.sel.head,anchorAfter:i.anchor,headAfter:i.head},u.done.push(f),u.generation=++u.maxGeneration;u.done.length>u.undoDepth;)u.done.shift();u.lastTime=e;u.lastOp=r;u.lastOrigin=t.origin}function iy(n){if(!n)return null;for(var i=0,t;i<n.length;++i)n[i].marker.explicitlyCleared?t||(t=n.slice(0,i)):t&&t.push(n[i]);return t?t.length?t:null:n}function ry(n,t){var u=t["spans_"+n.id],i,r;if(!u)return null;for(i=0,r=[];i<t.text.length;++i)r.push(iy(u[i]));return r}function bf(n,t){for(var f,i,h,r,e=0,o=[];e<n.length;++e){var u=n[e],c=u.changes,s=[];for(o.push({changes:s,anchorBefore:u.anchorBefore,headBefore:u.headBefore,anchorAfter:u.anchorAfter,headAfter:u.headAfter}),f=0;f<c.length;++f)if(i=c[f],s.push({from:i.from,to:i.to,text:i.text}),t)for(r in i)(h=r.match(/^spans_(\d+)$/))&&ct(t,Number(h[1]))>-1&&(d(s)[r]=i[r],delete i[r])}return o}function kf(n,t,i,r){i<n.line?n.line+=r:t<n.line&&(n.line=t,n.ch=0)}function nl(n,t,i,r){for(var u,s,o,f,e=0;e<n.length;++e){for(u=n[e],s=!0,o=0;o<u.changes.length;++o)if(f=u.changes[o],u.copied||(f.from=ii(f.from),f.to=ii(f.to)),i<f.from.line)f.from.line+=r,f.to.line+=r;else if(t<=f.to.line){s=!1;break}u.copied||(u.anchorBefore=ii(u.anchorBefore),u.headBefore=ii(u.headBefore),u.anchorAfter=ii(u.anchorAfter),u.readAfter=ii(u.headAfter),u.copied=!0);s?(kf(u.anchorBefore),kf(u.headBefore),kf(u.anchorAfter),kf(u.headAfter)):(n.splice(0,e+1),e=0)}}function tl(n,t){var i=t.from.line,r=t.to.line,u=t.text.length-(r-i)-1;nl(n.done,i,r,u);nl(n.undone,i,r,u)}function uy(){eu(this)}function fu(n){return n.stop||(n.stop=uy),n}function v(n){n.preventDefault?n.preventDefault():n.returnValue=!1}function il(n){n.stopPropagation?n.stopPropagation():n.cancelBubble=!0}function ts(n){return n.defaultPrevented!=null?n.defaultPrevented:n.returnValue==!1}function eu(n){v(n);il(n)}function is(n){return n.target||n.srcElement}function rl(n){var t=n.which;return t==null&&(n.button&1?t=1:n.button&2?t=3:n.button&4&&(t=2)),tr&&n.ctrlKey&&t==1&&(t=3),t}function o(n,t,i){if(n.addEventListener)n.addEventListener(t,i,!1);else if(n.attachEvent)n.attachEvent("on"+t,i);else{var r=n._handlers||(n._handlers={}),u=r[t]||(r[t]=[]);u.push(i)}}function wt(n,t,i){var r,u;if(n.removeEventListener)n.removeEventListener(t,i,!1);else if(n.detachEvent)n.detachEvent("on"+t,i);else{if(r=n._handlers&&n._handlers[t],!r)return;for(u=0;u<r.length;++u)if(r[u]==i){r.splice(u,1);break}}}function y(n,t){var r=n._handlers&&n._handlers[t],u,i;if(r)for(u=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,u)}function k(n,t){function f(n){return function(){n.apply(null,u)}}var r=n._handlers&&n._handlers[t],u,i;if(r)for(u=Array.prototype.slice.call(arguments,2),gt||(++wu,gt=[],setTimeout(fy,0)),i=0;i<r.length;++i)gt.push(f(r[i]))}function st(n,t,i){return y(n,i||t.type,n,t),ts(t)||t.codemirrorIgnore}function fy(){var t,n;for(--wu,t=gt,gt=null,n=0;n<t.length;++n)t[n]()}function ht(n,t){var i=n._handlers&&n._handlers[t];return i&&i.length>0}function ki(n){n.prototype.on=function(n,t){o(this,n,t)};n.prototype.off=function(n,t){wt(this,n,t)}}function rs(){this.id=null}function di(n,t,i,r,u){t==null&&(t=n.search(/[^\s\u00a0]/),t==-1&&(t=n.length));for(var e=r||0,f=u||0;e<t;++e)n.charAt(e)=="\t"?f+=i-f%i:++f;return f}function ul(n){while(bu.length<=n)bu.push(d(bu)+" ");return bu[n]}function d(n){return n[n.length-1]}function fl(n){if(au)n.selectionStart=0,n.selectionEnd=n.value.length;else try{n.select()}catch(t){}}function ct(n,t){if(n.indexOf)return n.indexOf(t);for(var i=0,r=n.length;i<r;++i)if(n[i]==t)return i;return-1}function el(n,t){function i(){}i.prototype=n;var r=new i;return t&&df(t,r),r}function df(n,t){t||(t={});for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i]);return t}function ol(n){for(var t=[],i=0;i<n;++i)t.push(undefined);return t}function ft(n){var t=Array.prototype.slice.call(arguments,1);return function(){return n.apply(null,t)}}function ou(n){return/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||wl.test(n))}function sl(n){for(var t in n)if(n.hasOwnProperty(t)&&n[t])return!1;return!0}function i(n,t,i,r){var u=document.createElement(n),f;if(i&&(u.className=i),r&&(u.style.cssText=r),typeof t=="string")hl(u,t);else if(t)for(f=0;f<t.length;++f)u.appendChild(t[f]);return u}function su(n){for(var t=n.childNodes.length;t>0;--t)n.removeChild(n.firstChild);return n}function lt(n,t){return su(n).appendChild(t)}function hl(n,t){nt?(n.innerHTML="",n.appendChild(document.createTextNode(t))):n.textContent=t}function c(n){return n.getBoundingClientRect()}function hu(){return!1}function cu(n){if(ku!=null)return ku;var t=i("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");return lt(n,t),t.offsetWidth&&(ku=t.offsetHeight-t.clientHeight),ku||0}function lu(n){if(ks==null){var t=i("span","​");lt(n,i("span",[t,document.createTextNode("x")]));n.firstChild.offsetHeight!=0&&(ks=t.offsetWidth<=1&&t.offsetHeight>2&&!nr)}return ks?i("span","​"):i("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px")}function ey(n,t,i,r){var e,f,u;if(!n)return r(t,i,"ltr");for(e=!1,f=0;f<n.length;++f)u=n[f],(u.from<i&&u.to>t||t==i&&u.to==t)&&(r(Math.max(u.from,t),Math.min(u.to,i),u.level==1?"rtl":"ltr"),e=!0);e||r(t,i,"ltr")}function us(n){return n.level%2?n.to:n.from}function fs(n){return n.level%2?n.from:n.to}function gf(n){var t=ot(n);return t?us(t[0]):0}function ne(n){var t=ot(n);return t?fs(d(t)):n.text.length}function cl(n,i){var e=r(n.doc,i),u=pt(n.doc,e),f,o;return u!=e&&(i=g(u)),f=ot(u),o=f?f[0].level%2?ne(u):gf(u):0,t(i,o)}function oy(n,i){for(var e,u,f,o;e=vf(u=r(n.doc,i));)i=e.find().to.line;return f=ot(u),o=f?f[0].level%2?gf(u):ne(u):u.text.length,t(i,o)}function sy(n,t,i){var r=n[0].level;return t==r?!0:i==r?!1:t<i}function es(n,t){for(var r,u,i=0;i<n.length;++i){if(u=n[i],u.from<t&&u.to>t)return fr=null,i;if(u.from==t||u.to==t)if(r==null)r=i;else return sy(n,u.level,n[r].level)?(fr=r,i):(fr=i,r)}return fr=null,r}function os(n,t,i,r){if(!r)return t+i;do t+=i;while(t>0&&se.test(n.text.charAt(t)));return t}function ss(n,t,i,r){var e=ot(n);if(!e)return ll(n,t,i,r);for(var o=es(e,t),u=e[o],f=os(n,t,u.level%2?-i:i,r);;){if(f>u.from&&f<u.to)return f;if(f==u.from||f==u.to)return es(e,f)==o?f:(u=e[o+=i],i>0==u.level%2?u.to:u.from);if(u=e[o+=i],!u)return null;f=i>0==u.level%2?os(n,u.to,-1,r):os(n,u.from,1,r)}}function ll(n,t,i,r){var u=t+i;if(r)while(u>0&&se.test(n.text.charAt(u)))u+=i;return u<0||u>n.text.length?null:u}var gi=/gecko\/\d/i.test(navigator.userAgent),l=/MSIE \d/.test(navigator.userAgent),nr=l&&(document.documentMode==null||document.documentMode<8),nt=l&&(document.documentMode==null||document.documentMode<9),hy=/Trident\/([7-9]|\d{2,})\./.test(navigator.userAgent),p=/WebKit\//.test(navigator.userAgent),cy=p&&/Qt\/\d+\.\d+/.test(navigator.userAgent),ly=/Chrome\//.test(navigator.userAgent),et=/Opera\//.test(navigator.userAgent),hs=/Apple Computer/.test(navigator.vendor),cs=/KHTML\//.test(navigator.userAgent),ay=/Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent),vy=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),yy=/PhantomJS/.test(navigator.userAgent),au=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),ls=au||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),tr=au||/Mac/.test(navigator.platform),py=/win/i.test(navigator.platform),ui=et&&navigator.userAgent.match(/Version\/(\d*\.\d*)/),fi,al,te,ie,as,vu,rt,vl,re,vs,ue,ei,fe,ys,ps,ir,rr,ee,ur,oe,at,yu,bt,ws,yl,b,pl,pu,gt,wu,oi,bs,bu,wl,se,bl,ku,ks,ni,fr,kl;ui&&(ui=Number(ui[1]));ui&&ui>=15&&(et=!1,p=!0);var dl=tr&&(cy||et&&(ui==null||ui<12.11)),ds=gi||l&&!nt,gl=!1,du=!1;al=0;as=0;vu=0;rt=null;l?rt=-.53:gi?rt=15:ly?rt=-.7:hs&&(rt=-1/3);re=null;ue=n.changeEnd=function(n){return n.text?t(n.from.line+n.text.length-1,d(n.text).length+(n.text.length==1?n.from.ch:0)):n.to};n.Pos=t;n.prototype={constructor:n,focus:function(){window.focus();it(this);ar(this)},setOption:function(n,t){var i=this.options,r=i[n];(i[n]!=t||n=="mode")&&(i[n]=t,ei.hasOwnProperty(n)&&e(this,ei[n])(this,t,r))},getOption:function(n){return this.options[n]},getDoc:function(){return this.doc},addKeyMap:function(n,t){this.state.keyMaps[t?"push":"unshift"](n)},removeKeyMap:function(n){for(var i=this.state.keyMaps,t=0;t<i.length;++t)if(i[t]==n||typeof i[t]!="string"&&i[t].name==n)return i.splice(t,1),!0},addOverlay:e(null,function(t,i){var r=t.token?t:n.getMode(this.options,t);if(r.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:r,modeSpec:t,opaque:i&&i.opaque});this.state.modeGen++;a(this)}),removeOverlay:e(null,function(n){for(var i,r=this.state.overlays,t=0;t<r.length;++t)if(i=r[t].modeSpec,i==n||typeof n=="string"&&i.name==n){r.splice(t,1);this.state.modeGen++;a(this);return}}),indentLine:e(null,function(n,t,i){typeof t!="string"&&typeof t!="number"&&(t=t==null?this.options.smartIndent?"smart":"prev":t?"add":"subtract");pi(this.doc,n)&&cf(this,n,t,i)}),indentSelection:e(null,function(n){var t=this.doc.sel,r,i;if(s(t.from,t.to))return cf(this,t.from.line,n);for(r=t.to.line-(t.to.ch?0:1),i=t.from.line;i<=r;++i)cf(this,i,n)}),getTokenAt:function(n,t){var e=this.doc,f;n=u(e,n);for(var o=hr(this,n.line,t),s=this.doc.mode,h=r(e,n.line),i=new dr(h.text,this.options.tabSize);i.pos<n.ch&&!i.eol();)i.start=i.pos,f=s.token(i,o);return{start:i.start,end:i.pos,string:i.current(),className:f||null,type:f||null,state:o}},getTokenTypeAt:function(n){var t;n=u(this.doc,n);var i=yc(this,r(this.doc,n.line)),e=0,o=(i.length-1)/2,f=n.ch;if(f==0)return i[2];for(;;)if(t=e+o>>1,(t?i[t*2-1]:0)>=f)o=t;else if(i[t*2+1]<f)e=t+1;else return i[t*2+2]},getModeAt:function(t){var i=this.doc.mode;return i.innerMode?n.innerMode(i,this.getTokenAt(t).state).mode:i},getHelper:function(n,t){if(ur.hasOwnProperty(t)){var r=ur[t],i=this.getModeAt(n);return i[t]&&r[i[t]]||i.helperType&&r[i.helperType]||r[i.name]}},getStateAfter:function(n,t){var i=this.doc;return n=tc(i,n==null?i.first+i.size-1:n),hr(this,n+1,t)},cursorCoords:function(n,t){var r,i=this.doc.sel;return r=n==null?i.head:typeof n=="object"?u(this.doc,n):n?i.from:i.to,tt(this,r,t||"page")},charCoords:function(n,t){return to(this,u(this.doc,n),t||"page")},coordsChar:function(n,t){return n=hh(this,n,t||"page"),io(this,n.left,n.top)},lineAtHeight:function(n,t){return n=hh(this,{top:n,left:0},t||"page").top,ru(this.doc,n+this.display.viewOffset)},heightAtLine:function(n,t){var i=!1,u=this.doc.first+this.doc.size-1,f;return n<this.doc.first?n=this.doc.first:n>u&&(n=u,i=!0),f=r(this.doc,n),no(this,r(this.doc,n),{top:0,left:0},t||"page").top+(i?f.height:0)},defaultTextHeight:function(){return ci(this.display)},defaultCharWidth:function(){return ch(this.display)},setGutterMarker:e(null,function(n,t,i){return lf(this,n,function(n){var r=n.gutterMarkers||(n.gutterMarkers={});return r[t]=i,!i&&sl(r)&&(n.gutterMarkers=null),!0})}),clearGutter:e(null,function(n){var i=this,r=i.doc,t=r.first;r.iter(function(r){r.gutterMarkers&&r.gutterMarkers[n]&&(r.gutterMarkers[n]=null,a(i,t,t+1),sl(r.gutterMarkers)&&(r.gutterMarkers=null));++t})}),addLineClass:e(null,function(n,t,i){return lf(this,n,function(n){var r=t=="text"?"textClass":t=="background"?"bgClass":"wrapClass";if(n[r]){if(new RegExp("(?:^|\\s)"+i+"(?:$|\\s)").test(n[r]))return!1;n[r]+=" "+i}else n[r]=i;return!0})}),removeLineClass:e(null,function(n,t,i){return lf(this,n,function(n){var f=t=="text"?"textClass":t=="background"?"bgClass":"wrapClass",u=n[f],r,e;if(u)if(i==null)n[f]=null;else{if(r=u.match(new RegExp("(?:^|\\s+)"+i+"(?:$|\\s+)")),!r)return!1;e=r.index+r[0].length;n[f]=u.slice(0,r.index)+(!r.index||e==u.length?"":" ")+u.slice(e)||null}else return!1;return!0})}),addLineWidget:e(null,function(n,t,i){return wv(this,n,t,i)}),removeLineWidget:function(n){n.clear()},lineInfo:function(n){var t;if(typeof n=="number"){if(!pi(this.doc,n)||(t=n,n=r(this.doc,n),!n))return null}else if(t=g(n),t==null)return null;return{line:t,handle:n,text:n.text,gutterMarkers:n.gutterMarkers,textClass:n.textClass,bgClass:n.bgClass,wrapClass:n.wrapClass,widgets:n.widgets}},getViewport:function(){return{from:this.display.showingFrom,to:this.display.showingTo}},addWidget:function(n,t,i,r,f){var s=this.display,o,e,h,c;n=tt(this,u(this.doc,n));o=n.bottom;e=n.left;t.style.position="absolute";s.sizer.appendChild(t);r=="over"?o=n.top:(r=="above"||r=="near")&&(h=Math.max(s.wrapper.clientHeight,this.doc.height),c=Math.max(s.sizer.clientWidth,s.lineSpace.clientWidth),(r=="above"||n.bottom+t.offsetHeight>h)&&n.top>t.offsetHeight?o=n.top-t.offsetHeight:n.bottom+t.offsetHeight<=h&&(o=n.bottom),e+t.offsetWidth>c&&(e=c-t.offsetWidth));t.style.top=o+"px";t.style.left=t.style.right="";f=="right"?(e=s.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):(f=="left"?e=0:f=="middle"&&(e=(s.sizer.clientWidth-t.offsetWidth)/2),t.style.left=e+"px");i&&sv(this,e,o,e+t.offsetWidth,o+t.offsetHeight)},triggerOnKeyDown:e(null,wh),execCommand:function(n){return oe[n](this)},findPosH:function(n,t,i,r){var o=1,e,f;for(t<0&&(o=-1,t=-t),e=0,f=u(this.doc,n);e<t;++e)if(f=ho(this.doc,f,o,i,r),f.hitSide)break;return f},moveH:e(null,function(n,t){var i=this.doc.sel,r;r=i.shift||i.extend||s(i.from,i.to)?ho(this.doc,i.head,n,t,this.options.rtlMoveVisually):n<0?i.from:i.to;w(this.doc,r,r,n)}),deleteH:e(null,function(n,t){var i=this.doc.sel;s(i.from,i.to)?kt(this.doc,"",i.from,ho(this.doc,i.head,n,t,!1),"+delete"):kt(this.doc,"",i.from,i.to,"+delete");this.curOp.userSelChange=!0}),findPosV:function(n,t,i,r){var h=1,o=r,s,f,e;for(t<0&&(h=-1,t=-t),s=0,f=u(this.doc,n);s<t;++s)if(e=tt(this,f,"div"),o==null?o=e.left:e.left=o,f=uc(this,e,h,i),f.hitSide)break;return f},moveV:e(null,function(n,t){var i=this.doc.sel,r=tt(this,i.head,"div"),u;i.goalColumn!=null&&(r.left=i.goalColumn);u=uc(this,r,n,t);t=="page"&&so(this,0,to(this,u,"div").top-r.top);w(this.doc,u,u,n);i.goalColumn=r.left}),toggleOverwrite:function(n){(n==null||n!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?this.display.cursor.className+=" CodeMirror-overwrite":this.display.cursor.className=this.display.cursor.className.replace(" CodeMirror-overwrite",""))},hasFocus:function(){return this.state.focused},scrollTo:e(null,function(n,t){hf(this,n,t)}),getScrollInfo:function(){var n=this.display.scroller,t=oi;return{left:n.scrollLeft,top:n.scrollTop,height:n.scrollHeight-t,width:n.scrollWidth-t,clientHeight:n.clientHeight-t,clientWidth:n.clientWidth-t}},scrollIntoView:e(null,function(n,i){var r,u;n==null?n={from:this.doc.sel.head,to:null}:typeof n=="number"?n={from:t(n,0),to:null}:n.from==null&&(n={from:n,to:null});n.to||(n.to=n.from);i||(i=0);r=n;n.from.line!=null&&(this.curOp.scrollToPos={from:n.from,to:n.to,margin:i},r={from:tt(this,n.from),to:tt(this,n.to)});u=sf(this,Math.min(r.from.left,r.to.left),Math.min(r.from.top,r.to.top)-i,Math.max(r.from.right,r.to.right),Math.max(r.from.bottom,r.to.bottom)+i);hf(this,u.scrollLeft,u.scrollTop)}),setSize:e(null,function(n,t){function i(n){return typeof n=="number"||/^\d+$/.test(String(n))?n+"px":n}n!=null&&(this.display.wrapper.style.width=i(n));t!=null&&(this.display.wrapper.style.height=i(t));this.options.lineWrapping&&(this.display.measureLineCache.length=this.display.measureLineCachePos=0);this.curOp.forceUpdate=!0}),operation:function(n){return ro(this,n)},refresh:e(null,function(){var n=this.display.cachedTextHeight==null;hi(this);hf(this,this.doc.scrollLeft,this.doc.scrollTop);a(this);n&&he(this)}),swapDoc:e(null,function(n){var t=this.doc;return t.cm=null,kc(this,n),hi(this),vt(this,!0),hf(this,n.scrollLeft,n.scrollTop),k(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};ki(n);ei=n.optionHandlers={};fe=n.defaults={};ys=n.Init={toString:function(){return"CodeMirror.Init"}};f("value","",function(n,t){n.setValue(t)},!0);f("mode",null,function(n,t){n.doc.modeOption=t;er(n)},!0);f("indentUnit",2,er,!0);f("indentWithTabs",!1);f("smartIndent",!0);f("tabSize",4,function(n){er(n);hi(n);a(n)},!0);f("specialChars",/[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\ufeff]/g,function(n,t){n.options.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g");n.refresh()},!0);f("specialCharPlaceholder",dv,function(n){n.refresh()},!0);f("electricChars",!0);f("rtlMoveVisually",!py);f("wholeLineUpdateBefore",!0);f("theme","default",function(n){th(n);or(n)},!0);f("keyMap","default",nh);f("extraKeys",null);f("onKeyEvent",null);f("onDragEvent",null);f("lineWrapping",!1,ia,!0);f("gutters",[],function(n){le(n.options);or(n)},!0);f("fixedGutter",!0,function(n,t){n.display.gutters.style.left=t?we(n.display)+"px":"0";n.refresh()},!0);f("coverGutterNextToScrollbar",!1,ae,!0);f("lineNumbers",!1,function(n){le(n.options);or(n)},!0);f("firstLineNumber",1,or,!0);f("lineNumberFormatter",function(n){return n},or,!0);f("showCursorWhenSelecting",!1,ke,!0);f("resetSelectionOnContextMenu",!0);f("readOnly",!1,function(n,t){t=="nocursor"?(fo(n),n.display.input.blur(),n.display.disabled=!0):(n.display.disabled=!1,t||vt(n,!0))});f("dragDrop",!0);f("cursorBlinkRate",530);f("cursorScrollMargin",0);f("cursorHeight",1);f("workTime",100);f("workDelay",100);f("flattenSpans",!0);f("pollInterval",100);f("undoDepth",40,function(n,t){n.doc.history.undoDepth=t});f("historyEventDelay",500);f("viewportMargin",10,function(n){n.refresh()},!0);f("maxHighlightLength",1e4,function(n){er(n);n.refresh()},!0);f("crudeMeasuringFrom",1e4);f("moveInputWithCursor",!0,function(n,t){t||(n.display.inputDiv.style.top=n.display.inputDiv.style.left=0)});f("tabindex",null,function(n,t){n.display.input.tabIndex=t||""});f("autofocus",null);ps=n.modes={};ir=n.mimeModes={};n.defineMode=function(t,i){if(n.defaults.mode||t=="null"||(n.defaults.mode=t),arguments.length>2){i.dependencies=[];for(var r=2;r<arguments.length;++r)i.dependencies.push(arguments[r])}ps[t]=i};n.defineMIME=function(n,t){ir[n]=t};n.resolveMode=function(t){if(typeof t=="string"&&ir.hasOwnProperty(t))t=ir[t];else if(t&&typeof t.name=="string"&&ir.hasOwnProperty(t.name)){var i=ir[t.name];t=el(i,t);t.name=i.name}else if(typeof t=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return n.resolveMode("application/xml");return typeof t=="string"?{name:t}:t||{name:"null"}};n.getMode=function(t,i){var i=n.resolveMode(i),e=ps[i.name],r,f,u;if(!e)return n.getMode(t,"text/plain");if(r=e(t,i),rr.hasOwnProperty(i.name)){f=rr[i.name];for(u in f)f.hasOwnProperty(u)&&(r.hasOwnProperty(u)&&(r["_"+u]=r[u]),r[u]=f[u])}return r.name=i.name,r};n.defineMode("null",function(){return{token:function(n){n.skipToEnd()}}});n.defineMIME("text/plain","null");rr=n.modeExtensions={};n.extendMode=function(n,t){var i=rr.hasOwnProperty(n)?rr[n]:rr[n]={};df(t,i)};n.defineExtension=function(t,i){n.prototype[t]=i};n.defineDocExtension=function(n,t){b.prototype[n]=t};n.defineOption=f;ee=[];n.defineInitHook=function(n){ee.push(n)};ur=n.helpers={};n.registerHelper=function(t,i,r){ur.hasOwnProperty(t)||(ur[t]=n[t]={});ur[t][i]=r};n.isWordChar=ou;n.copyState=wi;n.startState=fc;n.innerMode=function(n,t){while(n.innerMode){var i=n.innerMode(t);if(!i||i.mode==n)break;t=i.state;n=i.mode}return i||{mode:n,state:t}};oe=n.commands={selectAll:function(n){n.setSelection(t(n.firstLine(),0),t(n.lastLine()))},killLine:function(n){var i=n.getCursor(!0),r=n.getCursor(!1),u=!s(i,r);u||n.getLine(i.line).length!=i.ch?n.replaceRange("",i,u?r:t(i.line),"+delete"):n.replaceRange("",i,t(i.line+1,0),"+delete")},deleteLine:function(n){var i=n.getCursor().line;n.replaceRange("",t(i,0),t(i),"+delete")},delLineLeft:function(n){var i=n.getCursor();n.replaceRange("",t(i.line,0),i,"+delete")},undo:function(n){n.undo()},redo:function(n){n.redo()},goDocStart:function(n){n.extendSelection(t(n.firstLine(),0))},goDocEnd:function(n){n.extendSelection(t(n.lastLine()))},goLineStart:function(n){n.extendSelection(cl(n,n.getCursor().line))},goLineStartSmart:function(n){var i=n.getCursor(),r=cl(n,i.line),f=n.getLineHandle(r.line),e=ot(f),u,o;e&&e[0].level!=0?n.extendSelection(r):(u=Math.max(0,f.text.search(/\S/)),o=i.line==r.line&&i.ch<=u&&i.ch,n.extendSelection(t(r.line,o?0:u)))},goLineEnd:function(n){n.extendSelection(oy(n,n.getCursor().line))},goLineRight:function(n){var t=n.charCoords(n.getCursor(),"div").top+5;n.extendSelection(n.coordsChar({left:n.display.lineDiv.offsetWidth+100,top:t},"div"))},goLineLeft:function(n){var t=n.charCoords(n.getCursor(),"div").top+5;n.extendSelection(n.coordsChar({left:0,top:t},"div"))},goLineUp:function(n){n.moveV(-1,"line")},goLineDown:function(n){n.moveV(1,"line")},goPageUp:function(n){n.moveV(-1,"page")},goPageDown:function(n){n.moveV(1,"page")},goCharLeft:function(n){n.moveH(-1,"char")},goCharRight:function(n){n.moveH(1,"char")},goColumnLeft:function(n){n.moveH(-1,"column")},goColumnRight:function(n){n.moveH(1,"column")},goWordLeft:function(n){n.moveH(-1,"word")},goGroupRight:function(n){n.moveH(1,"group")},goGroupLeft:function(n){n.moveH(-1,"group")},goWordRight:function(n){n.moveH(1,"word")},delCharBefore:function(n){n.deleteH(-1,"char")},delCharAfter:function(n){n.deleteH(1,"char")},delWordBefore:function(n){n.deleteH(-1,"word")},delWordAfter:function(n){n.deleteH(1,"word")},delGroupBefore:function(n){n.deleteH(-1,"group")},delGroupAfter:function(n){n.deleteH(1,"group")},indentAuto:function(n){n.indentSelection("smart")},indentMore:function(n){n.indentSelection("add")},indentLess:function(n){n.indentSelection("subtract")},insertTab:function(n){n.replaceSelection("\t","end","+input")},defaultTab:function(n){n.somethingSelected()?n.indentSelection("add"):n.replaceSelection("\t","end","+input")},transposeChars:function(n){var i=n.getCursor(),r=n.getLine(i.line);i.ch>0&&i.ch<r.length-1&&n.replaceRange(r.charAt(i.ch)+r.charAt(i.ch-1),t(i.line,i.ch-1),t(i.line,i.ch+1))},newlineAndIndent:function(n){e(n,function(){n.replaceSelection("\n","end","+input");n.indentLine(n.getCursor().line,null,!0)})()},toggleOverwrite:function(n){n.toggleOverwrite()}};at=n.keyMap={};at.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"};at.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Alt-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd","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",fallthrough:"basic"};at.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","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":"delLineLeft",fallthrough:["basic","emacsy"]};at["default"]=tr?at.macDefault:at.pcDefault;at.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"};n.lookupKey=kr;n.isModifierKey=ec;n.keyName=oc;n.fromTextArea=function(t,i){function f(){t.value=r.getValue()}var e,u,s,h,r;if(i||(i={}),i.value=t.value,!i.tabindex&&t.tabindex&&(i.tabindex=t.tabindex),!i.placeholder&&t.placeholder&&(i.placeholder=t.placeholder),i.autofocus==null){e=document.body;try{e=document.activeElement}catch(c){}i.autofocus=e==t||t.getAttribute("autofocus")!=null&&e==document.body}if(t.form&&(o(t.form,"submit",f),!i.leaveSubmitMethodAlone)){u=t.form;s=u.submit;try{h=u.submit=function(){f();u.submit=s;u.submit();u.submit=h}}catch(c){}}return t.style.display="none",r=n(function(n){t.parentNode.insertBefore(n,t.nextSibling)},i),r.save=f,r.getTextArea=function(){return t},r.toTextArea=function(){f();t.parentNode.removeChild(r.getWrapperElement());t.style.display="";t.form&&(wt(t.form,"submit",f),typeof t.form.submit=="function"&&(t.form.submit=s))},r};dr.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==0},peek:function(){return this.string.charAt(this.pos)||undefined},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(n){var t=this.string.charAt(this.pos),i;return i=typeof n=="string"?t==n:t&&(n.test?n.test(t):n(t)),i?(++this.pos,t):void 0},eatWhile:function(n){for(var t=this.pos;this.eat(n););return this.pos>t},eatSpace:function(){for(var n=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>n},skipToEnd:function(){this.pos=this.string.length},skipTo:function(n){var t=this.string.indexOf(n,this.pos);if(t>-1)return this.pos=t,!0},backUp:function(n){this.pos-=n},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=di(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue},indentation:function(){return di(this.string,null,this.tabSize)},match:function(n,t,i){var u,f,r;if(typeof n=="string"){if(u=function(n){return i?n.toLowerCase():n},f=this.string.substr(this.pos,n.length),u(f)==u(n))return t!==!1&&(this.pos+=n.length),!0}else return(r=this.string.slice(this.pos).match(n),r&&r.index>0)?null:(r&&t!==!1&&(this.pos+=r[0].length),r)},current:function(){return this.string.slice(this.start,this.pos)}};n.StringStream=dr;n.TextMarker=dt;ki(dt);dt.prototype.clear=function(){var n,e,r,u,o,t,f,i,s,h;if(!this.explicitlyCleared){for(n=this.doc.cm,e=n&&!n.curOp,e&&li(n),ht(this,"clear")&&(r=this.find(),r&&k(this,"clear",r.from,r.to)),u=null,o=null,i=0;i<this.lines.length;++i)t=this.lines[i],f=tu(t.markedSpans,this),f.to!=null&&(o=g(t)),t.markedSpans=lv(t.markedSpans,f),f.from!=null?u=g(t):this.collapsed&&!ri(this.doc,t)&&n&&ut(t,ci(n.display));if(n&&this.collapsed&&!n.options.lineWrapping)for(i=0;i<this.lines.length;++i)s=pt(n.doc,this.lines[i]),h=gu(n.doc,s),h>n.display.maxLineLength&&(n.display.maxLine=s,n.display.maxLineLength=h,n.display.maxLineChanged=!0);u!=null&&n&&a(n,u,o+1);this.lines.length=0;this.explicitlyCleared=!0;this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,n&&ic(n));e&&ai(n)}};dt.prototype.find=function(){for(var r,n,u,i,e,f=0;f<this.lines.length;++f)r=this.lines[f],n=tu(r.markedSpans,this),(n.from!=null||n.to!=null)&&(u=g(r),n.from!=null&&(i=t(u,n.from)),n.to!=null&&(e=t(u,n.to)));return this.type=="bookmark"?i:i&&{from:i,to:e}};dt.prototype.changed=function(){var i=this.find(),n=this.doc.cm,u,t;if(i&&n&&(this.type!="bookmark"&&(i=i.from),u=r(this.doc,i.line),pa(n,u),i.line>=n.display.showingFrom&&i.line<n.display.showingTo)){for(t=n.display.lineDiv.firstChild;t;t=t.nextSibling)if(t.lineObj==u){t.offsetHeight!=u.height&&ut(u,t.offsetHeight);break}ro(n,function(){n.curOp.selectionChanged=n.curOp.forceUpdate=n.curOp.updateMaxLine=!0})}};dt.prototype.attachLine=function(n){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&ct(t.maybeHiddenMarkers,this)!=-1||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(n)};dt.prototype.detachLine=function(n){if(this.lines.splice(ct(this.lines,n),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};n.SharedTextMarker=nu;ki(nu);nu.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var n=0;n<this.markers.length;++n)this.markers[n].clear();k(this,"clear")}};nu.prototype.find=function(){return this.primary.find()};yu=n.LineWidget=function(n,t,i){if(i)for(var r in i)i.hasOwnProperty(r)&&(this[r]=i[r]);this.cm=n;this.node=t};ki(yu);yu.prototype.clear=lc(function(){var n=this.line.widgets,i=g(this.line),t,r;if(i!=null&&n){for(t=0;t<n.length;++t)n[t]==this&&n.splice(t--,1);n.length||(this.line.widgets=null);r=uu(this.cm,this.line)<this.cm.doc.scrollTop;ut(this.line,Math.max(0,this.line.height-yf(this)));r&&so(this.cm,0,-this.height);a(this.cm,i,i+1)}});yu.prototype.changed=lc(function(){var i=this.height,n,t;(this.height=null,n=yf(this)-i,n)&&(ut(this.line,this.line.height+n),t=g(this.line),a(this.cm,t,t+1))});bt=n.Line=function(n,t,i){this.text=n;cc(this,t);this.height=i?i(this):1};ki(bt);bt.prototype.lineNo=function(){return g(this)};ws={};pf.prototype={chunkSize:function(){return this.lines.length},removeInner:function(n,t){for(var i,r=n,u=n+t;r<u;++r)i=this.lines[r],this.height-=i.height,kv(i),k(i,"delete");this.lines.splice(n,t)},collapse:function(n){n.splice.apply(n,[n.length,0].concat(this.lines))},insertInner:function(n,t,i){this.height+=i;this.lines=this.lines.slice(0,n).concat(t).concat(this.lines.slice(n));for(var r=0,u=t.length;r<u;++r)t[r].parent=this},iterN:function(n,t,i){for(var r=n+t;n<r;++n)if(i(this.lines[n]))return!0}};iu.prototype={chunkSize:function(){return this.size},removeInner:function(n,t){var r,i,u,f,o,e;for(this.size-=t,r=0;r<this.children.length;++r)if(i=this.children[r],u=i.chunkSize(),n<u){if(f=Math.min(t,u-n),o=i.height,i.removeInner(n,f),this.height-=o-i.height,u==f&&(this.children.splice(r--,1),i.parent=null),(t-=f)==0)break;n=0}else n-=u;this.size-t<25&&(e=[],this.collapse(e),this.children=[new pf(e)],this.children[0].parent=this)},collapse:function(n){for(var t=0,i=this.children.length;t<i;++t)this.children[t].collapse(n)},insertInner:function(n,t,i){var u,o,r,e,s,f;for(this.size+=t.length,this.height+=i,u=0,o=this.children.length;u<o;++u){if(r=this.children[u],e=r.chunkSize(),n<=e){if(r.insertInner(n,t,i),r.lines&&r.lines.length>50){while(r.lines.length>50)s=r.lines.splice(r.lines.length-25,25),f=new pf(s),r.height-=f.height,this.children.splice(u+1,0,f),f.parent=this;this.maybeSpill()}break}n-=e}},maybeSpill:function(){var n,r,t,i,u;if(!(this.children.length<=10)){n=this;do r=n.children.splice(n.children.length-5,5),t=new iu(r),n.parent?(n.size-=t.size,n.height-=t.height,u=ct(n.parent.children,n),n.parent.children.splice(u+1,0,t)):(i=new iu(n.children),i.parent=n,n.children=[i,t],n=i),t.parent=n.parent;while(n.children.length>10);n.parent.maybeSpill()}},iterN:function(n,t,i){for(var u,r,f,e=0,o=this.children.length;e<o;++e)if(u=this.children[e],r=u.chunkSize(),n<r){if(f=Math.min(t,r-n),u.iterN(n,f,i))return!0;if((t-=f)==0)break;n=0}else n-=r}};yl=0;b=n.Doc=function(n,i,r){if(!(this instanceof b))return new b(n,i,r);r==null&&(r=0);iu.call(this,[new pf([new bt("",null)])]);this.first=r;this.scrollTop=this.scrollLeft=0;this.cantEdit=!1;this.history=wf();this.cleanGeneration=1;this.frontier=r;var u=t(r,0);this.sel={from:u,to:u,head:u,anchor:u,shift:!1,extend:!1,goalColumn:null};this.id=++yl;this.modeOption=i;typeof n=="string"&&(n=ni(n));bo(this,{from:u,to:u,text:n},null,{head:u,anchor:u})};b.prototype=el(iu.prototype,{constructor:b,iter:function(n,t,i){i?this.iterN(n-this.first,t-n,i):this.iterN(this.first,this.first+this.size,n)},insert:function(n,t){for(var r=0,i=0,u=t.length;i<u;++i)r+=t[i].height;this.insertInner(n-this.first,t,r)},remove:function(n,t){this.removeInner(n-this.first,t)},getValue:function(n){var t=go(this,this.first,this.first+this.size);return n===!1?t:t.join(n||"\n")},setValue:function(n){var i=t(this.first,0),u=this.first+this.size-1;yi(this,{from:i,to:t(u,r(this,u).text.length),text:ni(n),origin:"setValue"},{head:i,anchor:i},!0)},replaceRange:function(n,t,i,r){t=u(this,t);i=i?u(this,i):t;kt(this,n,t,i,r)},getRange:function(n,t,i){var r=ko(this,u(this,n),u(this,t));return i===!1?r:r.join(i||"\n")},getLine:function(n){var t=this.getLineHandle(n);return t&&t.text},setLine:function(n,i){pi(this,n)&&kt(this,i,t(n,0),u(this,t(n)))},removeLine:function(n){n?kt(this,"",u(this,t(n-1)),u(this,t(n))):kt(this,"",t(0,0),u(this,t(1,0)))},getLineHandle:function(n){if(pi(this,n))return r(this,n)},getLineNumber:function(n){return g(n)},getLineHandleVisualStart:function(n){return typeof n=="number"&&(n=r(this,n)),pt(this,n)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(n){return u(this,n)},getCursor:function(n){var t=this.sel,i;return i=n==null||n=="head"?t.head:n=="anchor"?t.anchor:n=="end"||n===!1?t.to:t.from,ii(i)},somethingSelected:function(){return!s(this.sel.head,this.sel.anchor)},setCursor:lr(function(n,i,r){var f=u(this,typeof n=="number"?t(n,i||0):n);r?w(this,f):yt(this,f,f)}),setSelection:lr(function(n,t,i){yt(this,u(this,n),u(this,t||n),i)}),extendSelection:lr(function(n,t,i){w(this,u(this,n),t&&u(this,t),i)}),getSelection:function(n){return this.getRange(this.sel.from,this.sel.to,n)},replaceSelection:function(n,t,i){yi(this,{from:this.sel.from,to:this.sel.to,text:ni(n),origin:i},t||"around")},undo:lr(function(){gh(this,"undo")}),redo:lr(function(){gh(this,"redo")}),setExtending:function(n){this.sel.extend=n},historySize:function(){var n=this.history;return{undo:n.done.length,redo:n.undone.length}},clearHistory:function(){this.history=wf(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration()},changeGeneration:function(){return this.history.lastOp=this.history.lastOrigin=null,this.history.generation},isClean:function(n){return this.history.generation==(n||this.cleanGeneration)},getHistory:function(){return{done:bf(this.history.done),undone:bf(this.history.undone)}},setHistory:function(n){var t=this.history=wf(this.history.maxGeneration);t.done=n.done.slice(0);t.undone=n.undone.slice(0)},markText:function(n,t,i){return gr(this,u(this,n),u(this,t),i,"range")},setBookmark:function(n,t){var i={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft};return n=u(this,n),gr(this,n,n,i,"bookmark")},findMarksAt:function(n){var e,i,f,t;if(n=u(this,n),e=[],i=r(this,n.line).markedSpans,i)for(f=0;f<i.length;++f)t=i[f],(t.from==null||t.from<=n.ch)&&(t.to==null||t.to>=n.ch)&&e.push(t.marker.parent||t.marker);return e},getAllMarks:function(){var n=[];return this.iter(function(t){var r=t.markedSpans,i;if(r)for(i=0;i<r.length;++i)r[i].from!=null&&n.push(r[i].marker)}),n},posFromIndex:function(n){var i,r=this.first;return this.iter(function(t){var u=t.text.length+1;if(u>n)return i=n,!0;n-=u;++r}),u(this,t(r,i))},indexFromPos:function(n){n=u(this,n);var t=n.ch;return n.line<this.first||n.ch<0?0:(this.iter(this.first,n.line,function(n){t+=n.text.length+1}),t)},copy:function(n){var t=new b(go(this,this.first,this.first+this.size),this.modeOption,this.first);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel={from:this.sel.from,to:this.sel.to,head:this.sel.head,anchor:this.sel.anchor,shift:this.sel.shift,extend:!1,goalColumn:this.sel.goalColumn},n&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(n){var t,r,i;return n||(n={}),t=this.first,r=this.first+this.size,n.from!=null&&n.from>t&&(t=n.from),n.to!=null&&n.to<r&&(r=n.to),i=new b(go(this,t,r),n.mode||this.modeOption,t),n.sharedHist&&(i.history=this.history),(this.linked||(this.linked=[])).push({doc:i,sharedHist:n.sharedHist}),i.linked=[{doc:this,isParent:!0,sharedHist:n.sharedHist}],i},unlinkDoc:function(t){var i,u,r;if(t instanceof n&&(t=t.doc),this.linked)for(i=0;i<this.linked.length;++i)if(u=this.linked[i],u.doc==t){this.linked.splice(i,1);t.unlinkDoc(this);break}t.history==this.history&&(r=[t.id],bi(t,function(n){r.push(n.id)},!0),t.history=wf(),t.history.done=bf(this.history.done,r),t.history.undone=bf(this.history.undone,r))},iterLinkedDocs:function(n){bi(this,n)},getMode:function(){return this.mode},getEditor:function(){return this.cm}});b.prototype.eachLine=b.prototype.iter;pl="iter insert remove copy getEditor".split(" ");for(pu in b.prototype)b.prototype.hasOwnProperty(pu)&&ct(pl,pu)<0&&(n.prototype[pu]=function(n){return function(){return n.apply(this.doc,arguments)}}(b.prototype[pu]));ki(b);n.e_stop=eu;n.e_preventDefault=v;n.e_stopPropagation=il;wu=0;n.on=o;n.off=wt;n.signal=y;oi=30;bs=n.Pass={toString:function(){return"CodeMirror.Pass"}};rs.prototype={set:function(n,t){clearTimeout(this.id);this.id=setTimeout(t,n)}};n.countColumn=di;bu=[""];wl=/[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;se=/[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\u1DC0–\u1DFF\u20D0–\u20FF\uA670-\uA672\uA674-\uA67D\uA69F\udc00-\udfff\uFE20–\uFE2F]/;n.replaceGetRect=function(n){c=n};bl=function(){if(nt)return!1;var n=i("div");return"draggable"in n||"dragDrop"in n}();gi?hu=function(n,t){return n.charCodeAt(t-1)==36&&n.charCodeAt(t)==39}:hs&&!/Version\/([6-9]|\d\d)\b/.test(navigator.userAgent)?hu=function(n,t){return/\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(n.slice(t-1,t+1))}:p&&/Chrome\/(?:29|[3-9]\d|\d\d\d)\./.test(navigator.userAgent)?hu=function(n,t){var i=n.charCodeAt(t-1);return i>=8208&&i<=8212}:p&&(hu=function(n,t){if(t>1&&n.charCodeAt(t-1)==45){if(/\w/.test(n.charAt(t-2))&&/[^\-?\.]/.test(n.charAt(t)))return!0;if(t>2&&/[\d\.,]/.test(n.charAt(t-2))&&/[\d\.,]/.test(n.charAt(t)))return!1}return/[~!#%&*)=+}\]\\|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|…[\w~`@#$%\^&*(_=+{[><]/.test(n.slice(t-1,t+1))});ni="\n\nb".split(/\n/).length!=3?function(n){for(var i=0,f=[],e=n.length,t,r,u;i<=e;)t=n.indexOf("\n",i),t==-1&&(t=n.length),r=n.slice(i,n.charAt(t-1)=="\r"?t-1:t),u=r.indexOf("\r"),u!=-1?(f.push(r.slice(0,u)),i+=u+1):(f.push(r),i=t+1);return f}:function(n){return n.split(/\r\n?|\n/)};n.splitLines=ni;var wy=window.getSelection?function(n){try{return n.selectionStart!=n.selectionEnd}catch(t){return!1}}:function(n){try{var t=n.ownerDocument.selection.createRange()}catch(i){}return!t||t.parentElement()!=n?!1:t.compareEndPoints("StartToEnd",t)!=0},na=function(){var n=i("div");return"oncopy"in n?!0:(n.setAttribute("oncopy","return;"),typeof n.oncopy=="function")}(),si={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:";",91:"Mod",92:"Mod",93:"Mod",109:"-",107:"=",127:"Delete",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63276:"PageUp",63277:"PageDown",63275:"End",63273:"Home",63234:"Left",63232:"Up",63235:"Right",63233:"Down",63302:"Insert",63272:"Delete"};return n.keyNames=si,function(){for(var n=0;n<10;n++)si[n+48]=String(n);for(n=65;n<=90;n++)si[n]=String.fromCharCode(n);for(n=1;n<=12;n++)si[n+111]=si[n+63235]="F"+n}(),kl=function(){function f(n){return n<=255?e.charAt(n):1424<=n&&n<=1524?"R":1536<=n&&n<=1791?o.charAt(n-1536):1792<=n&&n<=2220?"r":"L"}var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL",o="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr",s=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,t=/[stwN]/,i=/[LRr]/,r=/[Lb1n]/,u=/[1n]/,n="L";return function(e){var a,h,p,nt,b,l,y,v,k,o,tt,w,g,c,it;if(!s.test(e))return!1;for(a=e.length,h=[],o=0;o<a;++o)h.push(l=f(e.charCodeAt(o)));for(o=0,p=n;o<a;++o)l=h[o],l=="m"?h[o]=p:p=l;for(o=0,b=n;o<a;++o)l=h[o],l=="1"&&b=="r"?h[o]="n":i.test(l)&&(b=l,l=="r"&&(h[o]="R"));for(o=1,p=h[0];o<a-1;++o)l=h[o],l=="+"&&p=="1"&&h[o+1]=="1"?h[o]="1":l==","&&p==h[o+1]&&(p=="1"||p=="n")&&(h[o]=p),p=l;for(o=0;o<a;++o)if(l=h[o],l==",")h[o]="N";else if(l=="%"){for(y=o+1;y<a&&h[y]=="%";++y);for(nt=o&&h[o-1]=="!"||y<a-1&&h[y]=="1"?"1":"N",c=o;c<y;++c)h[c]=nt;o=y-1}for(o=0,b=n;o<a;++o)l=h[o],b=="L"&&l=="1"?h[o]="L":i.test(l)&&(b=l);for(o=0;o<a;++o)if(t.test(h[o])){for(y=o+1;y<a&&t.test(h[y]);++y);var rt=(o?h[o-1]:n)=="L",ut=(y<a-1?h[y]:n)=="L",nt=rt||ut?"L":"R";for(c=o;c<y;++c)h[c]=nt;o=y-1}for(v=[],o=0;o<a;)if(r.test(h[o])){for(tt=o,++o;o<a&&r.test(h[o]);++o);v.push({from:tt,to:o,level:0})}else{for(w=o,g=v.length,++o;o<a&&h[o]!="L";++o);for(c=w;c<o;)if(u.test(h[c])){for(w<c&&v.splice(g,0,{from:w,to:c,level:1}),it=c,++c;c<o&&u.test(h[c]);++c);v.splice(g,0,{from:it,to:c,level:2});w=c}else++c;w<o&&v.splice(g,0,{from:w,to:o,level:1})}return v[0].level==1&&(k=e.match(/^\s+/))&&(v[0].from=k[0].length,v.unshift({from:0,to:k[0].length,level:0})),d(v).level==1&&(k=e.match(/\s+$/))&&(d(v).to-=k[0].length,v.push({from:a-k[0].length,to:a,level:0})),v[0].level!=d(v).level&&v.push({from:a,to:a,level:v[0].level}),v}}(),n.version="3.20.0",n}();CodeMirror.defineMode("xml",function(n,t){function s(n,t){function i(i){return t.tokenize=i,i(n,t)}var r=n.next(),u,f,s;if(r=="<"){if(n.eat("!"))return n.eat("[")?n.match("CDATA[")?i(a("atom","]\]>")):null:n.match("--")?i(a("comment","-->")):n.match("DOCTYPE",!0,!0)?(n.eatWhile(/[\w\._\-]/),i(v(1))):null;if(n.eat("?"))return n.eatWhile(/[\w\._\-]/),t.tokenize=a("meta","?>"),"meta";for(u=n.eat("/"),e="";f=n.eat(/[^\s\u00a0=<>\"\'\/?]/);)e+=f;return e?(o=u?"closeTag":"openTag",t.tokenize=l,"tag"):"tag error"}return r=="&"?(s=n.eat("#")?n.eat("x")?n.eatWhile(/[a-fA-F\d]/)&&n.eat(";"):n.eatWhile(/[\d]/)&&n.eat(";"):n.eatWhile(/[\w\.\-:]/)&&n.eat(";"),s?"atom":"error"):(n.eatWhile(/[^&<]/),null)}function l(n,t){var i=n.next(),r;return i==">"||i=="/"&&n.eat(">")?(t.tokenize=s,o=i==">"?"endTag":"selfcloseTag","tag"):i=="="?(o="equals",null):i=="<"?(t.tokenize=s,r=t.tokenize(n,t),r?r+" error":"error"):/[\'\"]/.test(i)?(t.tokenize=g(i),t.stringStartCol=n.column(),t.tokenize(n,t)):(n.eatWhile(/[^\s\u00a0=<>\"\']/),"word")}function g(n){var t=function(t,i){while(!t.eol())if(t.next()==n){i.tokenize=l;break}return"string"};return t.isInAttribute=!0,t}function a(n,t){return function(i,r){while(!i.eol()){if(i.match(t)){r.tokenize=s;break}i.next()}return n}}function v(n){return function(t,i){for(var r;(r=t.next())!=null;){if(r=="<")return i.tokenize=v(n+1),i.tokenize(t,i);if(r==">"){if(n==1){i.tokenize=s;break}return i.tokenize=v(n-1),i.tokenize(t,i)}}return"meta"}}function h(){for(var n=arguments.length-1;n>=0;n--)i.cc.push(arguments[n])}function r(){return h.apply(null,arguments),!0}function nt(n,t){var r=f.doNotIndent.hasOwnProperty(n)||i.context&&i.context.noIndent;i.context={prev:i.context,tagName:n,indent:i.indented,startOfLine:t,noIndent:r}}function y(){i.context&&(i.context=i.context.prev)}function tt(n){if(n=="openTag")return i.tagName=e,i.tagStart=d.column(),r(c,it(i.startOfLine));if(n=="closeTag"){var t=!1;return i.context?i.context.tagName!=e&&(f.implicitlyClosed.hasOwnProperty(i.context.tagName.toLowerCase())&&y(),t=!i.context||i.context.tagName!=e):t=!0,t&&(u="error"),r(rt(t))}return r()}function it(n){return function(t){var u=i.tagName;return i.tagName=i.tagStart=null,t=="selfcloseTag"||t=="endTag"&&f.autoSelfClosers.hasOwnProperty(u.toLowerCase())?(p(u.toLowerCase()),r()):t=="endTag"?(p(u.toLowerCase()),nt(u,n),r()):r()}}function rt(n){return function(t){return n&&(u="error"),t=="endTag"?(y(),r()):(u="error",r(arguments.callee))}}function p(n){for(var t;;){if(!i.context)return;if(t=i.context.tagName.toLowerCase(),!f.contextGrabbers.hasOwnProperty(t)||!f.contextGrabbers[t].hasOwnProperty(n))return;y()}}function c(n){return n=="word"?(u="attribute",r(w,c)):n=="endTag"||n=="selfcloseTag"?h():(u="error",r(c))}function w(n){if(n=="equals")return r(ut,c);if(f.allowMissing){if(n=="word")return u="attribute",r(w,c)}else u="error";return n=="endTag"||n=="selfcloseTag"?h():r()}function ut(n){return n=="string"?r(b):n=="word"&&f.allowUnquoted?(u="string",r()):(u="error",n=="endTag"||n=="selfCloseTag"?h():r())}function b(n){return n=="string"?r(b):h()}var k=n.indentUnit,ft=t.multilineTagIndentFactor||1,et=t.multilineTagIndentPastTag||!0,f=t.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},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}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1},ot=t.alignCDATA,e,o,i,d,u;return{startState:function(){return{tokenize:s,cc:[],indented:0,startOfLine:!0,tagName:null,tagStart:null,context:null}},token:function(n,t){var r,f;if(!t.tagName&&n.sol()&&(t.startOfLine=!0,t.indented=n.indentation()),n.eatSpace())return null;if(u=o=e=null,r=t.tokenize(n,t),t.type=o,(r||o)&&r!="comment")for(i=t,d=n;;)if(f=t.cc.pop()||tt,f(o||r))break;return t.startOfLine=!1,u&&(r=u=="error"?r+" error":u),r},indent:function(n,t,i){var r=n.context;if(n.tokenize.isInAttribute)return n.stringStartCol+1;if(n.tokenize!=l&&n.tokenize!=s||r&&r.noIndent)return i?i.match(/^(\s*)/)[0].length:0;if(n.tagName)return et?n.tagStart+n.tagName.length+2:n.tagStart+k*ft;if(ot&&/<!\[CDATA\[/.test(t))return 0;for(r&&/^<\//.test(t)&&(r=r.prev);r&&!r.startOfLine;)r=r.prev;return r?r.indent+k:0},electricChars:"/",blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:t.htmlMode?"html":"xml",helperType:t.htmlMode?"html":"xml"}});CodeMirror.defineMIME("text/xml","xml");CodeMirror.defineMIME("application/xml","xml");CodeMirror.mimeModes.hasOwnProperty("text/html")||CodeMirror.defineMIME("text/html",{name:"xml",htmlMode:!0}),function(){function n(n){for(var i,t,f=[/for\s*?\((.*?)\)/,/\"(.*?)(\"|$)/,/\'(.*?)(\'|$)/,/\/\*(.*?)(\*\/|$)/,/\/\/.*/],r=[],u=0;f.length>u;u++)for(i=0;n.length>i;){if(t=n.substr(i).match(f[u]),null==t)break;r.push({start:i+t.index,end:i+t.index+t[0].length});i+=t.index+Math.max(1,t[0].length)}return r.sort(function(n,t){return n.start-t.start}),r}function t(n,t){return CodeMirror.innerMode(n.getMode(),n.getTokenAt(t).state).mode}function i(n,t,i,r){var f=n.getMode(),s=n.getLine(t),l,o;if(null==r&&(r=s.length),!f.innerMode)return[{from:i,to:r,mode:f}];var h=n.getTokenAt({line:t,ch:i}).state,e=CodeMirror.innerMode(f,h).mode,c=[],u=new CodeMirror.StringStream(s);for(u.pos=u.start=i;;){if(f.token(u,h),l=CodeMirror.innerMode(f,h).mode,l!=e&&(o=u.start,"xml"==e.name&&">"==s.charAt(u.pos-1)&&(o=u.pos),c.push({from:i,to:o,mode:e}),i=o,e=l),u.pos>=r)break;u.start=u.pos}return r>i&&c.push({from:i,to:r,mode:e}),c}CodeMirror.extendMode("css",{commentStart:"/*",commentEnd:"*/",wordWrapChars:[";","\\{","\\}"],autoFormatLineBreaks:function(n){return n.replace(RegExp("(;|\\{|\\})([^\r\n])","g"),"$1\n$2")}});CodeMirror.extendMode("javascript",{commentStart:"/*",commentEnd:"*/",wordWrapChars:[";","\\{","\\}"],autoFormatLineBreaks:function(t){var r=0,e=this.jsonMode?function(n){return n.replace(/([,{])/g,"$1\n").replace(/}/g,"\n}")}:function(n){return n.replace(/(;|\{|\})([^\r\n;])/g,"$1\n$2")},u=n(t),f="",i;if(null!=u){for(i=0;u.length>i;i++)u[i].start>r&&(f+=e(t.substring(r,u[i].start)),r=u[i].start),r>=u[i].start&&u[i].end>=r&&(f+=t.substring(r,u[i].end),r=u[i].end);t.length>r&&(f+=e(t.substr(r)))}else f=e(t);return f.replace(/^\n*|\n*$/,"")}});CodeMirror.extendMode("xml",{commentStart:"<!--",commentEnd:"-->",wordWrapChars:[">"],autoFormatLineBreaks:function(n){for(var t,i=n.split("\n"),u=RegExp("(^\\s*?<|^[^<]*?)(.+)(>\\s*?$|[^>]*?$)"),f=RegExp("<","g"),e=RegExp("(>)([^\r\n])","g"),r=0;i.length>r;r++)t=i[r].match(u),null!=t&&t.length>3&&(i[r]=t[1]+t[2].replace(f,"\n$&").replace(e,"$1\n$2")+t[3]);return i.join("\n")}});CodeMirror.defineExtension("commentRange",function(n,i,r){var u=t(this,i),f=this;this.operation(function(){if(n)f.replaceRange(u.commentEnd,r),f.replaceRange(u.commentStart,i),i.line==r.line&&i.ch==r.ch&&f.setCursor(i.line,i.ch+u.commentStart.length);else{var t=f.getRange(i,r),e=t.indexOf(u.commentStart),o=t.lastIndexOf(u.commentEnd);e>-1&&o>-1&&o>e&&(t=t.substr(0,e)+t.substring(e+u.commentStart.length,o)+t.substr(o+u.commentEnd.length));f.replaceRange(t,i,r)}})});CodeMirror.defineExtension("autoIndentRange",function(n,t){var i=this;this.operation(function(){for(var r=n.line;t.line>=r;r++)i.indentLine(r,"smart")})});CodeMirror.defineExtension("autoFormatRange",function(n,t){var r=this;r.operation(function(){for(var y,c,l,u=n.line,s=t.line;s>=u;++u){for(var a={line:u,ch:u==n.line?n.ch:0},v={line:u,ch:u==s?t.ch:null},e=i(r,u,a.ch,v.ch),f="",h=r.getRange(a,v),o=0;e.length>o;++o)y=e.length>1?h.slice(e[o].from,e[o].to):h,f&&(f+="\n"),f+=e[o].mode.autoFormatLineBreaks?e[o].mode.autoFormatLineBreaks(y):h;if(f!=h){for(c=0,l=f.indexOf("\n");-1!=l;l=f.indexOf("\n",l+1),++c);r.replaceRange(f,a,v);u+=c;s+=c}}for(u=n.line+1;s>=u;++u)r.indentLine(u,"smart");r.setSelection(n,r.getCursor(!1))})})}(),function(n){typeof define=="function"&&define.amd?define(["jquery","codemirror"],n):n(window.jQuery,window.CodeMirror)}(function(n,t){var o,s;"function"!=typeof Array.prototype.reduce&&(Array.prototype.reduce=function(n,t){var i,r,f=this.length>>>0,u=!1;for(1<arguments.length&&(r=t,u=!0),i=0;f>i;++i)this.hasOwnProperty(i)&&(u?r=n(r,this[i],i,this):(r=this[i],u=!0));if(!u)throw new TypeError("Reduce of empty array with no initial value");return r});var u={bMac:navigator.appVersion.indexOf("Mac")>-1,bMSIE:navigator.userAgent.indexOf("MSIE")>-1,bFF:navigator.userAgent.indexOf("Firefox")>-1,jqueryVersion:parseFloat(n.fn.jquery),bCodeMirror:!!t},e=function(){var n=function(n){return function(t){return n===t}},t=function(n,t){return n===t},i=function(){return!0},r=function(){return!1},u=function(n){return function(){return!n.apply(n,arguments)}},f=function(n){return n};return{eq:n,eq2:t,ok:i,fail:r,not:u,self:f}}(),f=function(){var t=function(n){return n[0]},n=function(n){return n[n.length-1]},r=function(n){return n.slice(0,n.length-1)},i=function(n){return n.slice(1)},u=function(n,t){var i=n.indexOf(t);return i===-1?null:n[i+1]},f=function(n,t){var i=n.indexOf(t);return i===-1?null:n[i-1]},o=function(n,t){return t=t||e.self,n.reduce(function(n,i){return n+t(i)},0)},s=function(n){for(var i=[],t=-1,r=n.length;++t<r;)i[t]=n[t];return i},h=function(r,u){if(r.length===0)return[];var f=i(r);return f.reduce(function(t,i){var r=n(t);return u(n(r),i)?r[r.length]=i:t[t.length]=[i],t},[[t(r)]])},c=function(n){for(var i=[],t=0,r=n.length;t<r;t++)n[t]&&i.push(n[t]);return i};return{head:t,last:n,initial:r,tail:i,prev:f,next:u,sum:o,from:s,compact:c,clusterBy:h}}(),i=function(){var c=function(t){return t&&n(t).hasClass("note-editable")},w=function(t){return t&&n(t).hasClass("note-control-sizing")},b=function(n){var t=function(t){return function(){return n.find(t)}};return{editor:function(){return n},dropzone:t(".note-dropzone"),toolbar:t(".note-toolbar"),editable:t(".note-editable"),codable:t(".note-codable"),statusbar:t(".note-statusbar"),popover:t(".note-popover"),handle:t(".note-handle"),dialog:t(".note-dialog")}},t=function(n){return function(t){return t&&t.nodeName===n}},k=function(n){return n&&/^DIV|^P|^LI|^H[1-7]/.test(n.nodeName)},d=function(n){return n&&/^UL|^OL/.test(n.nodeName)},g=function(n){return n&&/^TD|^TH/.test(n.nodeName)},l=function(n,t){while(n){if(t(n))return n;if(c(n))break;n=n.parentNode}return null},r=function(n,t){t=t||e.fail;var i=[];return l(n,function(n){return i.push(n),t(n)}),i},a=function(t,i){for(var f=r(t),u=i;u;u=u.parentNode)if(n.inArray(u,f)>-1)return u;return null},nt=function(n,t){var i=[],r=!1,u=!1;return function f(e){if(e){if(e===n&&(r=!0),r&&!u&&i.push(e),e===t){u=!0;return}for(var o=0,s=e.childNodes.length;o<s;o++)f(e.childNodes[o])}}(a(n,t)),i},tt=function(n,t){t=t||e.fail;for(var i=[];n;){if(i.push(n),t(n))break;n=n.previousSibling}return i},o=function(n,t){t=t||e.fail;for(var i=[];n;){if(i.push(n),t(n))break;n=n.nextSibling}return i},it=function(n,t){var i=[];return t=t||e.ok,function r(u){n!==u&&t(u)&&i.push(u);for(var f=0,e=u.childNodes.length;f<e;f++)r(u.childNodes[f])}(n),i},s=function(n,t){var i=t.nextSibling,r=t.parentNode;return i?r.insertBefore(n,i):r.appendChild(n),n},v=function(t,i){return n.each(i,function(n,i){t.appendChild(i)}),t},h=t("#text"),rt=function(n){return h(n)?n.nodeValue.length:n.childNodes.length},y=function(n){for(var t=0;n=n.previousSibling;)t+=1;return t},ut=function(t,i){var u=f.initial(r(i,e.eq(t)));return n.map(u,y).reverse()},ft=function(n,t){for(var i=n,r=0,u=t.length;r<u;r++)i=i.childNodes[t[r]];return i},p=function(n,t){if(t===0)return n;if(t>=rt(n))return n.nextSibling;if(h(n))return n.splitText(t);var i=n.childNodes[t];return n=s(n.cloneNode(!1),n),v(n,o(i))},et=function(n,t,i){var u=r(t,e.eq(n));return u.length===1?p(t,i):u.reduce(function(n,r){var u=r.cloneNode(!1);return s(u,r),n===t&&(n=p(n,i)),v(u,o(n)),u})},ot=function(n,t){var f,r,i,u;if(n&&n.parentNode){if(n.removeNode)return n.removeNode(t);if(f=n.parentNode,!t){for(r=[],i=0,u=n.childNodes.length;i<u;i++)r.push(n.childNodes[i]);for(i=0,u=r.length;i<u;i++)f.insertBefore(r[i],n)}f.removeChild(n)}},st=function(n){return i.isTextarea(n[0])?n.val():n.html()},ht=function(n){return n.replace(/<script>/gi,'<script type="text/javascript">').replace(/type='(text\/)*javascript'/ig,"type='text/undefined'").replace(/type="(text\/)*javascript"/ig,'type="text/undefined"')},ct=function(n){return n.replace(/type='(text\/)*undefined'/ig,"type='text/javascript'").replace(/type="(text\/)*undefined"/ig,'type="text/javascript"')};return{blank:u.bMSIE?"&nbsp;":"<br/>",emptyPara:"<p><br/><\/p>",isEditable:c,isControlSizing:w,buildLayoutInfo:b,isText:h,isPara:k,isList:d,isTable:t("TABLE"),isCell:g,isAnchor:t("A"),isDiv:t("DIV"),isLi:t("LI"),isSpan:t("SPAN"),isB:t("B"),isU:t("U"),isS:t("S"),isI:t("I"),isImg:t("IMG"),isTextarea:t("TEXTAREA"),ancestor:l,listAncestor:r,listNext:o,listPrev:tt,listDescendant:it,commonAncestor:a,listBetween:nt,insertAfter:s,position:y,makeOffsetPath:ut,fromOffsetPath:ft,split:et,remove:ot,html:st,escapejs:ht,unescapejs:ct}}(),c=function(){var t=function(t){return n.Deferred(function(i){n.extend(new FileReader,{onload:function(n){var t=n.target.result;i.resolve(t)},onerror:function(){i.reject(this)}}).readAsDataURL(t)}).promise()},i=function(t){return n.Deferred(function(i){n("<img>").one("load",function(){i.resolve(n(this))}).one("error abort",function(){i.reject(n(this))}).css({display:"none"}).appendTo(document.body).attr("src",t)}).promise()};return{readFileAsDataURL:t,createImage:i}}(),h={isEdit:function(n){return[8,9,13,32].indexOf(n)!==-1},nameFromCode:{"8":"BACKSPACE","9":"TAB","13":"ENTER","32":"SPACE","48":"NUM0","49":"NUM1","50":"NUM2","51":"NUM3","52":"NUM4","53":"NUM5","54":"NUM6","55":"NUM7","56":"NUM8","66":"B","69":"E","73":"I","74":"J","75":"K","76":"L","82":"R","83":"S","85":"U","89":"Y","90":"Z","191":"SLASH","219":"LEFTBRACKET","220":"BACKSLASH","221":"RIGHTBRACKET"}},l=function(){var t=function(t,i){if(u.jqueryVersion<1.9){var r={};return n.each(i,function(n,i){r[i]=t.css(i)}),r}return t.css.call(t,i)};this.stylePara=function(t,r){n.each(t.nodes(i.isPara),function(t,i){n(i).css(r)})};this.current=function(r,u){var c=n(i.isText(r.sc)?r.sc.parentNode:r.sc),f=t(c,["font-family","font-size","text-align","list-style-type","line-height"])||{},o,s,e,h;return f["font-size"]=parseInt(f["font-size"]),f["font-bold"]=document.queryCommandState("bold")?"bold":"normal",f["font-italic"]=document.queryCommandState("italic")?"italic":"normal",f["font-underline"]=document.queryCommandState("underline")?"underline":"normal",r.isOnList()?(o=["circle","disc","disc-leading-zero","square"],s=n.inArray(f["list-style-type"],o)>-1,f["list-style"]=s?"unordered":"ordered"):f["list-style"]="none",e=i.ancestor(r.sc,i.isPara),e&&e.style["line-height"]?f["line-height"]=e.style.lineHeight:(h=parseInt(f["line-height"])/parseInt(f["font-size"]),f["line-height"]=h.toFixed(1)),f.image=i.isImg(u)&&u,f.anchor=r.isOnAnchor()&&i.ancestor(r.sc,i.isAnchor),f.aAncestor=i.listAncestor(r.sc,i.isEditable),f}},r=function(){var t=!!document.createRange,r=function(n,t){for(var o=n.parentElement(),a=document.body.createTextRange(),s,h=f.from(o.childNodes),c,r,l,e,v,u=0;u<h.length;u++)if(!i.isText(h[u])){if(a.moveToElementText(h[u]),a.compareEndPoints("StartToStart",n)>=0)break;s=h[u]}if(u!==0&&i.isText(h[u-1])){for(c=document.body.createTextRange(),r=null,c.moveToElementText(s||o),c.collapse(!s),r=s?s.nextSibling:o.firstChild,l=n.duplicate(),l.setEndPoint("StartToStart",c),e=l.text.replace(/[\r\n]/g,"").length;e>r.nodeValue.length&&r.nextSibling;)e-=r.nodeValue.length,r=r.nextSibling;v=r.nodeValue;t&&r.nextSibling&&i.isText(r.nextSibling)&&e===r.nodeValue.length&&(e-=r.nodeValue.length,r=r.nextSibling);o=r;u=e}return{cont:o,offset:u}},u=function(n){var u=function(n,t){var r,o,s,h;if(i.isText(n))s=i.listPrev(n,e.not(i.isText)),h=f.last(s).previousSibling,r=h||n.parentNode,t+=f.sum(f.tail(s),i.length),o=!h;else{if(r=n.childNodes[t]||n,i.isText(r))return u(r,t);t=0;o=!1}return{cont:r,collapseToStart:o,offset:t}},t=document.body.createTextRange(),r=u(n.cont,n.offset);return t.moveToElementText(r.cont),t.collapse(r.collapseToStart),t.moveStart("character",r.offset),t},o=function(r,o,s,h){var l,c;this.sc=r;this.so=o;this.ec=s;this.eo=h;l=function(){var n,i;return t?(n=document.createRange(),n.setStart(r,o),n.setEnd(s,h),n):(i=u({cont:r,offset:o}),i.setEndPoint("EndToEnd",u({cont:s,offset:h})),i)};this.select=function(){var i=l(),n;t?(n=document.getSelection(),n.rangeCount>0&&n.removeAllRanges(),n.addRange(i)):i.select()};this.nodes=function(t){var u=i.listBetween(r,s),o=f.compact(n.map(u,function(n){return i.ancestor(n,t)}));return n.map(f.clusterBy(o,e.eq2),f.head)};this.commonAncestor=function(){return i.commonAncestor(r,s)};c=function(n){return function(){var t=i.ancestor(r,n);return!!t&&t===i.ancestor(s,n)}};this.isOnEditable=c(i.isEditable);this.isOnList=c(i.isList);this.isOnAnchor=c(i.isAnchor);this.isOnCell=c(i.isCell);this.isCollapsed=function(){return r===s&&o===h};this.insertNode=function(n){var i=l();t?i.insertNode(n):i.pasteHTML(n.outerHTML)};this.toString=function(){var n=l();return t?n.toString():n.text};this.bookmark=function(n){return{s:{path:i.makeOffsetPath(n,r),offset:o},e:{path:i.makeOffsetPath(n,s),offset:h}}}};return{create:function(n,i,u,f){var s,e,h,c,l,a,v;if(arguments.length===0)if(t){if(s=document.getSelection(),s.rangeCount===0)return null;e=s.getRangeAt(0);n=e.startContainer;i=e.startOffset;u=e.endContainer;f=e.endOffset}else h=document.selection.createRange(),c=h.duplicate(),c.collapse(!1),l=h,l.collapse(!0),a=r(l,!0),v=r(c,!1),n=a.cont,i=a.offset,u=v.cont,f=v.offset;else arguments.length===2&&(u=n,f=i);return new o(n,i,u,f)},createFromNode:function(n){return this.create(n,0,n,1)},createFromBookmark:function(n,t){var r=i.fromOffsetPath(n,t.s.path),u=t.s.offset,f=i.fromOffsetPath(n,t.e.path),e=t.e.offset;return new o(r,u,f,e)}}}(),a=function(){this.tab=function(n,t){var u=i.ancestor(n.commonAncestor(),i.isCell),o=i.ancestor(u,i.isTable),s=i.listDescendant(o,i.isCell),e=f[t?"prev":"next"](s,u);e&&r.create(e,0).select()};this.createTable=function(t,r){for(var u,e,f,o,s=[],h,c=0;c<t;c++)s.push("<td>"+i.blank+"<\/td>");for(h=s.join(""),u=[],f=0;f<r;f++)u.push("<tr>"+h+"<\/tr>");return e=u.join(""),o='<table class="table table-bordered">'+e+"<\/table>",n(o)[0]}},v=function(){var s=new l,o=new a,t,e,h,v,f;for(this.saveRange=function(n){n.data("range",r.create())},this.restoreRange=function(n){var t=n.data("range");t&&t.select()},this.currentStyle=function(n){var t=r.create();return t.isOnEditable()&&s.current(t,n)},this.undo=function(n){n.data("NoteHistory").undo(n)},this.redo=function(n){n.data("NoteHistory").redo(n)},t=this.recordUndo=function(n){n.data("NoteHistory").recordUndo(n)},e=["bold","italic","underline","strikethrough","justifyLeft","justifyCenter","justifyRight","justifyFull","insertOrderedList","insertUnorderedList","indent","outdent","formatBlock","removeFormat","backColor","foreColor","insertHorizontalRule","fontName"],f=0,h=e.length;f<h;f++)this[e[f]]=function(n){return function(i,r){t(i);document.execCommand(n,!1,r)}}(e[f]);for(v=function(u,f,e){var s,o;t(u);s=new Array(e+1).join("&nbsp;");f.insertNode(n('<span id="noteTab">'+s+"<\/span>")[0]);o=n("#noteTab").removeAttr("id");f=r.create(o[0],1);f.select();i.remove(o[0])},this.tab=function(n,t){var i=r.create();i.isCollapsed()&&i.isOnCell()?o.tab(i):v(n,i,t.tabsize)},this.untab=function(){var n=r.create();n.isCollapsed()&&n.isOnCell()&&o.tab(n,!0)},this.insertImage=function(n,i){c.createImage(i).then(function(i){t(n);i.css({display:"",width:Math.min(n.width(),i.width())});r.create().insertNode(i[0])}).fail(function(){var t=n.data("callbacks");t.onImageUploadError&&t.onImageUploadError()})},this.insertVideo=function(i,u){var l;t(i);var e=u.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/),o=u.match(/\/\/instagram.com\/p\/(.[a-zA-Z0-9]*)/),s=u.match(/\/\/vine.co\/v\/(.[a-zA-Z0-9]*)/),h=u.match(/\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/),c=u.match(/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/),f;e&&e[2].length===11?(l=e[2],f=n("<iframe>").attr("src","//www.youtube.com/embed/"+l).attr("width","640").attr("height","360")):o&&o[0].length>0?f=n("<iframe>").attr("src",o[0]+"/embed/").attr("width","612").attr("height","710").attr("scrolling","no").attr("allowtransparency","true"):s&&s[0].length>0?f=n("<iframe>").attr("src",s[0]+"/embed/simple").attr("width","600").attr("height","600").attr("class","vine-embed"):h&&h[3].length>0?f=n("<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen>").attr("src","//player.vimeo.com/video/"+h[3]).attr("width","640").attr("height","360"):c&&c[2].length>0&&(f=n("<iframe>").attr("src","//www.dailymotion.com/embed/video/"+c[2]).attr("width","640").attr("height","360"));f&&(f.attr("frameborder",0),r.create().insertNode(f[0]))},this.formatBlock=function(n,i){t(n);i=u.bMSIE?"<"+i+">":i;document.execCommand("FormatBlock",!1,i)},this.formatPara=function(n){this.formatBlock(n,"P")},f=1;f<=6;f++)this["formatH"+f]=function(n){return function(t){this.formatBlock(t,"H"+n)}}(f);this.fontSize=function(n,i){t(n);document.execCommand("fontSize",!1,3);u.bFF?n.find("font[size=3]").removeAttr("size").css("font-size",i+"px"):n.find("span").filter(function(){return this.style.fontSize==="medium"}).css("font-size",i+"px")};this.lineHeight=function(n,i){t(n);s.stylePara(r.create(),{lineHeight:i})};this.unlink=function(n){var u=r.create(),f;u.isOnAnchor()&&(t(n),f=i.ancestor(u.sc,i.isAnchor),u=r.createFromNode(f),u.select(),document.execCommand("unlink"))};this.createLink=function(f,e,o){var s=r.create(),h,c;t(f);h=e;e.indexOf("@")!==-1&&e.indexOf(":")===-1?h="mailto:"+e:e.indexOf("://")===-1&&(h="http://"+e);(u.bMSIE||u.bFF)&&s.isCollapsed()?(s.insertNode(n('<A id="linkAnchor">'+e+"<\/A>")[0]),c=n("#linkAnchor").attr("href",h).removeAttr("id"),s=r.createFromNode(c[0]),s.select()):(document.execCommand("createlink",!1,h),s=r.create());n.each(s.nodes(i.isAnchor),function(t,i){o?n(i).attr("target","_blank"):n(i).removeAttr("target")})};this.getLinkInfo=function(){var t=r.create(),f=!0,e="",u;return t.isOnAnchor()&&(u=i.ancestor(t.sc,i.isAnchor),t=r.createFromNode(u),f=n(u).attr("target")==="_blank",e=u.href),{text:t.toString(),url:e,newWindow:f}};this.getVideoInfo=function(){var n=r.create(),t;return n.isOnAnchor()&&(t=i.ancestor(n.sc,i.isAnchor),n=r.createFromNode(t)),{text:n.toString()}};this.color=function(n,i){var r=JSON.parse(i),u=r.foreColor,f=r.backColor;t(n);u&&document.execCommand("foreColor",!1,u);f&&document.execCommand("backColor",!1,f)};this.insertTable=function(n,i){t(n);var u=i.split("x");r.create().insertNode(o.createTable(u[0],u[1]))};this.floatMe=function(n,i,r){t(n);r.css("float",i)};this.resize=function(n,i,r){t(n);r.css({width:n.width()*i+"px",height:""})};this.resizeTo=function(n,t,i){var u,f,r;i?(f=n.y/n.x,r=t.data("ratio"),u={width:r>f?n.x:n.y/r,height:r>f?n.x*r:n.y}):u={width:n.x,height:n.y};t.css(u)};this.removeMedia=function(n,i,r){t(n);r.detach()}},y=function(){var n=[],t=[],i=function(n){var t=n[0],i=r.create();return{contents:n.html(),bookmark:i.bookmark(t),scrollTop:n.scrollTop()}},u=function(n,t){n.html(t.contents).scrollTop(t.scrollTop);r.createFromBookmark(n[0],t.bookmark).select()};this.undo=function(r){var f=i(r);n.length!==0&&(u(r,n.pop()),t.push(f))};this.redo=function(r){var f=i(r);t.length!==0&&(u(r,t.pop()),n.push(f))};this.recordUndo=function(r){t=[];n.push(i(r))}},p=function(){this.update=function(t,i){var e=function(t,i){t.find(".dropdown-menu li a").each(function(){var t=n(this).data("value")+""==i+"";this.className=t?"checked":""})},r=function(n,i){var r=t.find(n);r.toggleClass("active",i())},o=t.find(".note-fontname"),u,s,h;o.length>0&&(u=i["font-family"],!u||(u=f.head(u.split(",")),u=u.replace(/\'/g,""),o.find(".note-current-fontname").text(u),e(o,u)));s=t.find(".note-fontsize");s.find(".note-current-fontsize").text(i["font-size"]);e(s,parseFloat(i["font-size"]));h=t.find(".note-height");e(h,parseFloat(i["line-height"]));r('button[data-event="bold"]',function(){return i["font-bold"]==="bold"});r('button[data-event="italic"]',function(){return i["font-italic"]==="italic"});r('button[data-event="underline"]',function(){return i["font-underline"]==="underline"});r('button[data-event="justifyLeft"]',function(){return i["text-align"]==="left"||i["text-align"]==="start"});r('button[data-event="justifyCenter"]',function(){return i["text-align"]==="center"});r('button[data-event="justifyRight"]',function(){return i["text-align"]==="right"});r('button[data-event="justifyFull"]',function(){return i["text-align"]==="justify"});r('button[data-event="insertUnorderedList"]',function(){return i["list-style"]==="unordered"});r('button[data-event="insertOrderedList"]',function(){return i["list-style"]==="ordered"})};this.updateRecentColor=function(t,i,r){var o=n(t).closest(".note-color"),u=o.find(".note-recent-color"),f=JSON.parse(u.attr("data-value")),e;f[i]=r;u.attr("data-value",JSON.stringify(f));e=i==="backColor"?"background-color":"color";u.find("i").css(e,r)};this.updateFullscreen=function(n,t){var i=n.find('button[data-event="fullscreen"]');i.toggleClass("active",t)};this.updateCodeview=function(n,t){var i=n.find('button[data-event="codeview"]');i.toggleClass("active",t)};this.activate=function(n){n.find("button").not('button[data-event="codeview"]').removeClass("disabled")};this.deactivate=function(n){n.find("button").not('button[data-event="codeview"]').addClass("disabled")}},w=function(){var t=function(t,i){var r=n(i),u=r.position(),f=r.height();t.css({display:"block",left:u.left,top:u.top+f})};this.update=function(n,i){var r=n.find(".note-link-popover"),f,u;i.anchor?(f=r.find("a"),f.attr("href",i.anchor.href).html(i.anchor.href),t(r,i.anchor)):r.hide();u=n.find(".note-image-popover");i.image?t(u,i.image):u.hide()};this.hide=function(n){n.children().hide()}},b=function(){this.update=function(t,i){var u=t.find(".note-control-selection"),e;if(i.image){var f=n(i.image),o=f.position(),r={w:f.width(),h:f.height()};u.css({display:"block",left:o.left,top:o.top,width:r.w,height:r.h}).data("target",i.image);e=r.w+"x"+r.h;u.find(".note-control-selection-info").text(e)}else u.hide()};this.hide=function(n){n.children().hide()}},k=function(){var t=function(n,t){n.toggleClass("disabled",!t);n.attr("disabled",!t)};this.showImageDialog=function(i,r){return n.Deferred(function(n){var f=r.find(".note-image-dialog"),e=r.find(".note-image-input"),u=r.find(".note-image-url"),o=r.find(".note-image-btn");f.one("shown.bs.modal",function(i){i.stopPropagation();e.replaceWith(e.clone().on("change",function(){f.modal("hide");n.resolve(this.files)}));o.click(function(t){t.preventDefault();f.modal("hide");n.resolve(u.val())});u.keyup(function(){t(o,u.val())}).val("").focus()}).one("hidden.bs.modal",function(n){n.stopPropagation();i.focus();e.off("change");u.off("keyup");o.off("click")}).modal("show")})};this.showVideoDialog=function(i,r,u){return n.Deferred(function(n){var f=r.find(".note-video-dialog"),e=f.find(".note-video-url"),o=f.find(".note-video-btn");f.one("shown.bs.modal",function(i){i.stopPropagation();e.val(u.text).keyup(function(){t(o,e.val())}).trigger("keyup").trigger("focus");o.click(function(t){t.preventDefault();f.modal("hide");n.resolve(e.val())})}).one("hidden.bs.modal",function(n){n.stopPropagation();i.focus();e.off("keyup");o.off("click")}).modal("show")})};this.showLinkDialog=function(i,r,u){return n.Deferred(function(f){var e=r.find(".note-link-dialog"),s=e.find(".note-link-text"),o=e.find(".note-link-url"),h=e.find(".note-link-btn"),c=e.find("input[type=checkbox]");e.one("shown.bs.modal",function(i){i.stopPropagation();s.val(u.text);o.keyup(function(){t(h,o.val());u.text||s.val(o.val())}).val(u.url).trigger("focus");c.prop("checked",u.newWindow);h.one("click",function(n){n.preventDefault();e.modal("hide");f.resolve(o.val(),c.is(":checked"))});n(".modal-backdrop.in").remove()}).one("hidden.bs.modal",function(t){t.stopPropagation();i.focus();o.off("keyup");n("body").removeClass("modal-open")}).modal("show")}).promise()};this.showHelpDialog=function(t,i){var r=i.find(".note-help-dialog");r.one("hidden.bs.modal",function(){t.focus()}).modal("show");n(".modal-backdrop.in").remove()}},d=function(){var r=new v,f=new p,s=new w,l=new b,o=new k,e=function(t){var r=n(t).closest(".note-editor");return r.length>0&&i.buildLayoutInfo(r)},a=function(t,i){r.restoreRange(t);var u=t.data("callbacks");if(u.onImageUpload)u.onImageUpload(i,r,t);else n.each(i,function(n,i){c.readFileAsDataURL(i).then(function(n){r.insertImage(t,n)}).fail(function(){u.onImageUploadError&&u.onImageUploadError()})})},it=function(n){i.isImg(n.target)&&n.preventDefault()},d=function(n){var i=e(n.currentTarget||n.target),t=r.currentStyle(n.target);t&&(f.update(i.toolbar(),t),s.update(i.popover(),t),l.update(i.handle(),t))},rt=function(n){var t=e(n.currentTarget||n.target);s.hide(t.popover());l.hide(t.handle())},ut=function(t){if(i.isControlSizing(t.target)){var f=e(t.target),h=f.handle(),v=f.popover(),y=f.editable(),c=f.editor(),o=h.find(".note-control-selection").data("target"),u=n(o),a=u.offset(),p=n(document).scrollTop();c.on("mousemove",function(n){r.resizeTo({x:n.clientX-a.left,y:n.clientY-(a.top-p)},u,!n.shiftKey);l.update(h,{image:o});s.update(v,{image:o})}).one("mouseup",function(){c.off("mousemove")});u.data("ratio")||u.data("ratio",u.height()/u.width());r.recordUndo(y);t.stopPropagation();t.preventDefault()}},g=function(t){var i=n(t.target).closest("[data-event]");i.length>0&&t.preventDefault()},nt=function(s){var w=n(s.target).closest("[data-event]"),et,ot,st,ht,g,nt,tt,it,rt;if(w.length>0){var v=w.attr("data-event"),ct=w.attr("data-value"),y=e(s.target),p=y.editor(),b=y.toolbar(),k=y.dialog(),h=y.editable(),c=y.codable(),ut,l,ft=p.data("options"),lt;if(n.inArray(v,["resize","floatMe","removeMedia"])!==-1&&(et=y.handle(),ot=et.find(".note-control-selection"),lt=n(ot.data("target"))),r[v]&&(h.trigger("focus"),r[v](h,ct,lt)),n.inArray(v,["backColor","foreColor"])!==-1)f.updateRecentColor(w[0],v,ct);else if(v==="showLinkDialog")h.focus(),st=r.getLinkInfo(),r.saveRange(h),o.showLinkDialog(h,k,st).then(function(n,t){r.restoreRange(h);r.createLink(h,n,t)});else if(v==="showImageDialog")h.focus(),o.showImageDialog(h,k).then(function(n){typeof n=="string"?(r.restoreRange(h),r.insertImage(h,n)):a(h,n)});else if(v==="showVideoDialog")h.focus(),ht=r.getVideoInfo(),r.saveRange(h),o.showVideoDialog(h,k,ht).then(function(n){r.restoreRange(h);r.insertVideo(h,n)});else if(v==="showHelpDialog")o.showHelpDialog(h,k);else if(v==="fullscreen")g=n("html, body"),nt=function(n){p.css("width",n.w);h.css("height",n.h);c.css("height",n.h);c.data("cmEditor")&&c.data("cmEditor").setSize(null,n.h)},p.toggleClass("fullscreen"),tt=p.hasClass("fullscreen"),tt?(h.data("orgHeight",h.css("height")),n(window).on("resize",function(){nt({w:n(window).width(),h:n(window).height()-b.outerHeight()})}).trigger("resize"),g.css("overflow","hidden")):(n(window).off("resize"),nt({w:ft.width||"",h:h.data("orgHeight")}),g.css("overflow","auto")),f.updateFullscreen(b,tt);else if(v==="codeview"){if(p.toggleClass("codeview"),it=p.hasClass("codeview"),it){if(c.val(i.unescapejs(h.html())),c.height(h.height()),f.deactivate(b),c.focus(),u.bCodeMirror){if(l=t.fromTextArea(c[0],n.extend({mode:"text/html",lineNumbers:!0},ft.codemirror)),rt=p.data("options").codemirror.tern||!1,rt){ut=new t.TernServer(rt);l.ternServer=ut;l.on("cursorActivity",function(n){ut.updateArgHints(n)})}l.setSize(null,h.outerHeight());l.autoFormatRange&&l.autoFormatRange({line:0,ch:0},{line:l.lineCount(),ch:l.getTextArea().value.length});c.data("cmEditor",l)}}else u.bCodeMirror&&(l=c.data("cmEditor"),c.val(l.getValue()),l.toTextArea()),h.html(i.escapejs(c.val())||i.emptyPara),h.height(ft.height?c.height():"auto"),f.activate(b),h.focus();f.updateCodeview(y.toolbar(),it)}d(s)}},ft=24,et=function(t){var i=n(document),r=e(t.target).editable(),u=r.offset().top-i.scrollTop();i.on("mousemove",function(n){var t=n.clientY-(u+ft);r.height(t)}).one("mouseup",function(){i.off("mousemove")});t.stopPropagation();t.preventDefault()},tt=18,ot=function(t){var r=n(t.target.parentNode),o=r.next(),s=r.find(".note-dimension-picker-mousecatcher"),h=r.find(".note-dimension-picker-highlighted"),e=r.find(".note-dimension-picker-unhighlighted"),u,f,i;t.offsetX===undefined?(f=n(t.target).offset(),u={x:t.pageX-f.left,y:t.pageY-f.top}):u={x:t.offsetX,y:t.offsetY};i={c:Math.ceil(u.x/tt)||1,r:Math.ceil(u.y/tt)||1};h.css({width:i.c+"em",height:i.r+"em"});s.attr("data-value",i.c+"x"+i.r);3<i.c&&i.c<10&&e.css({width:i.c+1+"em"});3<i.r&&i.r<10&&e.css({height:i.r+1+"em"});o.html(i.c+" x "+i.r)},st=function(t){var i=n(),r=t.dropzone,u=t.dropzone.find(".note-dropzone-message");n(document).on("dragenter",function(n){var f=t.editor.hasClass("codeview");f||i.length!==0||(t.editor.addClass("dragover"),r.width(t.editor.width()),r.height(t.editor.height()),u.text("Drag Image Here"));i=i.add(n.target)}).on("dragleave",function(n){i=i.not(n.target);i.length===0&&t.editor.removeClass("dragover")}).on("drop",function(){i=n();t.editor.removeClass("dragover")});r.on("dragenter",function(){r.addClass("hover");u.text("Drop Image")}).on("dragleave",function(){r.removeClass("hover");u.text("Drag Image Here")});r.on("drop",function(n){var t=n.originalEvent.dataTransfer,i;t&&t.files&&(i=e(n.currentTarget||n.target),i.editable().focus(),a(i.editable(),t.files));n.preventDefault()}).on("dragover",!1)};this.bindKeyMap=function(n,t){var u=n.editor,i=n.editable;i.on("keydown",function(n){var f=[],e,o;n.metaKey&&f.push("CMD");n.ctrlKey&&f.push("CTRL");n.shiftKey&&f.push("SHIFT");e=h.nameFromCode[n.keyCode];e&&f.push(e);o=t[f.join("+")];o?(n.preventDefault(),r[o](i,u.data("options"))):h.isEdit(n.keyCode)&&r.recordUndo(i)})};this.attach=function(n,t){var e=t.keyMap[u.bMac?"mac":"pc"],i,f;this.bindKeyMap(n,e);n.editable.on("mousedown",it);n.editable.on("keyup mouseup",d);n.editable.on("scroll",rt);t.disableDragAndDrop||st(n);n.handle.on("mousedown",ut);n.toolbar.on("click",nt);n.popover.on("click",nt);n.toolbar.on("mousedown",g);n.popover.on("mousedown",g);n.statusbar.on("mousedown",et);i=n.toolbar;f=i.find(".note-dimension-picker-mousecatcher");f.on("mousemove",ot);n.editable.on("blur",function(){r.saveRange(n.editable)});if(n.editor.data("options",t),t.styleWithSpan&&!u.bMSIE&&setTimeout(function(){document.execCommand("styleWithCSS",0,!0)}),n.editable.data("NoteHistory",new y),t.onenter&&n.editable.keypress(function(n){if(n.keyCode===h.ENTER)t.onenter(n)}),t.onfocus&&n.editable.focus(t.onfocus),t.onblur&&n.editable.blur(t.onblur),t.onkeyup&&n.editable.keyup(t.onkeyup),t.onkeydown&&n.editable.keydown(t.onkeydown),t.onpaste)n.editable.on("paste",t.onpaste);t.onToolbarClick&&n.toolbar.click(t.onToolbarClick);n.editable.data("callbacks",{onChange:t.onChange,onAutoSave:t.onAutoSave,onImageUpload:t.onImageUpload,onImageUploadError:t.onImageUploadError,onFileUpload:t.onFileUpload,onFileUploadError:t.onFileUpload})};this.dettach=function(n){n.editable.off();n.toolbar.off();n.handle.off();n.popover.off()}},g=function(){var t,r,c,f,e;t={picture:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.image.image+'" data-event="showImageDialog" tabindex="-1"><i class="fa fa-picture-o icon-picture"><\/i><\/button>'},link:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.link.link+'" data-event="showLinkDialog" tabindex="-1"><i class="fa fa-link icon-link"><\/i><\/button>'},video:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.video.video+'" data-event="showVideoDialog" tabindex="-1"><i class="fa fa-youtube-play icon-play"><\/i><\/button>'},table:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="'+n.table.table+'" data-toggle="dropdown" tabindex="-1"><i class="fa fa-table icon-table"><\/i> <span class="caret"><\/span><\/button><ul class="dropdown-menu"><div class="note-dimension-picker"><div class="note-dimension-picker-mousecatcher" data-event="insertTable" data-value="1x1"><\/div><div class="note-dimension-picker-highlighted"><\/div><div class="note-dimension-picker-unhighlighted"><\/div><\/div><div class="note-dimension-display"> 1 x 1 <\/div><\/ul>'},style:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="'+n.style.style+'" data-toggle="dropdown" tabindex="-1"><i class="fa fa-magic icon-magic"><\/i> <span class="caret"><\/span><\/button><ul class="dropdown-menu"><li><a data-event="formatBlock" data-value="p">'+n.style.normal+'<\/a><\/li><li><a data-event="formatBlock" data-value="blockquote"><blockquote>'+n.style.blockquote+'<\/blockquote><\/a><\/li><li><a data-event="formatBlock" data-value="pre">'+n.style.pre+'<\/a><\/li><li><a data-event="formatBlock" data-value="h1"><h1>'+n.style.h1+'<\/h1><\/a><\/li><li><a data-event="formatBlock" data-value="h2"><h2>'+n.style.h2+'<\/h2><\/a><\/li><li><a data-event="formatBlock" data-value="h3"><h3>'+n.style.h3+'<\/h3><\/a><\/li><li><a data-event="formatBlock" data-value="h4"><h4>'+n.style.h4+'<\/h4><\/a><\/li><li><a data-event="formatBlock" data-value="h5"><h5>'+n.style.h5+'<\/h5><\/a><\/li><li><a data-event="formatBlock" data-value="h6"><h6>'+n.style.h6+"<\/h6><\/a><\/li><\/ul>"},fontname:function(n){var i=["Serif","Sans","Arial","Arial Black","Courier","Courier New","Comic Sans MS","Helvetica","Impact","Lucida Grande","Lucida Sans","Tahoma","Times","Times New Roman","Verdana"],r='<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" data-toggle="dropdown" title="'+n.font.name+'" tabindex="-1"><span class="note-current-fontname">Arial<\/span> <b class="caret"><\/b><\/button>',t;for(r+='<ul class="dropdown-menu">',t=0;t<i.length;t++)r+='<li><a data-event="fontName" data-value="'+i[t]+'"><i class="fa fa-check icon-ok"><\/i> '+i[t]+"<\/a><\/li>";return r+"<\/ul>"},fontsize:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" data-toggle="dropdown" title="'+n.font.size+'" tabindex="-1"><span class="note-current-fontsize">11<\/span> <b class="caret"><\/b><\/button><ul class="dropdown-menu"><li><a data-event="fontSize" data-value="8"><i class="fa fa-check icon-ok"><\/i> 8<\/a><\/li><li><a data-event="fontSize" data-value="9"><i class="fa fa-check icon-ok"><\/i> 9<\/a><\/li><li><a data-event="fontSize" data-value="10"><i class="fa fa-check icon-ok"><\/i> 10<\/a><\/li><li><a data-event="fontSize" data-value="11"><i class="fa fa-check icon-ok"><\/i> 11<\/a><\/li><li><a data-event="fontSize" data-value="12"><i class="fa fa-check icon-ok"><\/i> 12<\/a><\/li><li><a data-event="fontSize" data-value="14"><i class="fa fa-check icon-ok"><\/i> 14<\/a><\/li><li><a data-event="fontSize" data-value="18"><i class="fa fa-check icon-ok"><\/i> 18<\/a><\/li><li><a data-event="fontSize" data-value="24"><i class="fa fa-check icon-ok"><\/i> 24<\/a><\/li><li><a data-event="fontSize" data-value="36"><i class="fa fa-check icon-ok"><\/i> 36<\/a><\/li><\/ul>'},color:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small note-recent-color" title="'+n.color.recent+'" data-event="color" data-value=\'{"backColor":"yellow"}\' tabindex="-1"><i class="fa fa-font icon-font" style="color:black;background-color:yellow;"><\/i><\/button><button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="'+n.color.more+'" data-toggle="dropdown" tabindex="-1"><span class="caret"><\/span><\/button><ul class="dropdown-menu"><li><div class="btn-group"><div class="note-palette-title">'+n.color.background+'<\/div><div class="note-color-reset" data-event="backColor" data-value="inherit" title="'+n.color.transparent+'">'+n.color.setTransparent+'<\/div><div class="note-color-palette" data-target-event="backColor"><\/div><\/div><div class="btn-group"><div class="note-palette-title">'+n.color.foreground+'<\/div><div class="note-color-reset" data-event="foreColor" data-value="inherit" title="'+n.color.reset+'">'+n.color.resetToDefault+'<\/div><div class="note-color-palette" data-target-event="foreColor"><\/div><\/div><\/li><\/ul>'},bold:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.font.bold+'" data-shortcut="Ctrl+B" data-mac-shortcut="⌘+B" data-event="bold" tabindex="-1"><i class="fa fa-bold icon-bold"><\/i><\/button>'},italic:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.font.italic+'" data-shortcut="Ctrl+I" data-mac-shortcut="⌘+I" data-event="italic" tabindex="-1"><i class="fa fa-italic icon-italic"><\/i><\/button>'},underline:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.font.underline+'" data-shortcut="Ctrl+U" data-mac-shortcut="⌘+U" data-event="underline" tabindex="-1"><i class="fa fa-underline icon-underline"><\/i><\/button>'},clear:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.font.clear+'" data-shortcut="Ctrl+\\" data-mac-shortcut="⌘+\\" data-event="removeFormat" tabindex="-1"><i class="fa fa-eraser icon-eraser"><\/i><\/button>'},ul:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.lists.unordered+'" data-shortcut="Ctrl+Shift+8" data-mac-shortcut="⌘+⇧+7" data-event="insertUnorderedList" tabindex="-1"><i class="fa fa-list-ul icon-list-ul"><\/i><\/button>'},ol:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.lists.ordered+'" data-shortcut="Ctrl+Shift+7" data-mac-shortcut="⌘+⇧+8" data-event="insertOrderedList" tabindex="-1"><i class="fa fa-list-ol icon-list-ol"><\/i><\/button>'},paragraph:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="'+n.paragraph.paragraph+'" data-toggle="dropdown" tabindex="-1"><i class="fa fa-align-left icon-align-left"><\/i>  <span class="caret"><\/span><\/button><div class="dropdown-menu"><div class="note-align btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.paragraph.left+'" data-shortcut="Ctrl+Shift+L" data-mac-shortcut="⌘+⇧+L" data-event="justifyLeft" tabindex="-1"><i class="fa fa-align-left icon-align-left"><\/i><\/button><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.paragraph.center+'" data-shortcut="Ctrl+Shift+E" data-mac-shortcut="⌘+⇧+E" data-event="justifyCenter" tabindex="-1"><i class="fa fa-align-center icon-align-center"><\/i><\/button><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.paragraph.right+'" data-shortcut="Ctrl+Shift+R" data-mac-shortcut="⌘+⇧+R" data-event="justifyRight" tabindex="-1"><i class="fa fa-align-right icon-align-right"><\/i><\/button><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.paragraph.justify+'" data-shortcut="Ctrl+Shift+J" data-mac-shortcut="⌘+⇧+J" data-event="justifyFull" tabindex="-1"><i class="fa fa-align-justify icon-align-justify"><\/i><\/button><\/div><div class="note-list btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.paragraph.outdent+'" data-shortcut="Ctrl+[" data-mac-shortcut="⌘+[" data-event="outdent" tabindex="-1"><i class="fa fa-outdent icon-indent-left"><\/i><\/button><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.paragraph.indent+'" data-shortcut="Ctrl+]" data-mac-shortcut="⌘+]" data-event="indent" tabindex="-1"><i class="fa fa-indent icon-indent-right"><\/i><\/button><\/div><\/div>'},height:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" data-toggle="dropdown" title="'+n.font.height+'" tabindex="-1"><i class="fa fa-text-height icon-text-height"><\/i>&nbsp; <b class="caret"><\/b><\/button><ul class="dropdown-menu"><li><a data-event="lineHeight" data-value="1.0"><i class="fa fa-check icon-ok"><\/i> 1.0<\/a><\/li><li><a data-event="lineHeight" data-value="1.2"><i class="fa fa-check icon-ok"><\/i> 1.2<\/a><\/li><li><a data-event="lineHeight" data-value="1.4"><i class="fa fa-check icon-ok"><\/i> 1.4<\/a><\/li><li><a data-event="lineHeight" data-value="1.5"><i class="fa fa-check icon-ok"><\/i> 1.5<\/a><\/li><li><a data-event="lineHeight" data-value="1.6"><i class="fa fa-check icon-ok"><\/i> 1.6<\/a><\/li><li><a data-event="lineHeight" data-value="1.8"><i class="fa fa-check icon-ok"><\/i> 1.8<\/a><\/li><li><a data-event="lineHeight" data-value="2.0"><i class="fa fa-check icon-ok"><\/i> 2.0<\/a><\/li><li><a data-event="lineHeight" data-value="3.0"><i class="fa fa-check icon-ok"><\/i> 3.0<\/a><\/li><\/ul>'},help:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.options.help+'" data-event="showHelpDialog" tabindex="-1"><i class="fa fa-question icon-question"><\/i><\/button>'},fullscreen:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.options.fullscreen+'" data-event="fullscreen" tabindex="-1"><i class="fa fa-arrows-alt icon-fullscreen"><\/i><\/button>'},codeview:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.options.codeview+'" data-event="codeview" tabindex="-1"><i class="fa fa-code icon-code"><\/i><\/button>'},undo:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.history.undo+'" data-event="undo" tabindex="-1"><i class="fa fa-undo icon-undo"><\/i><\/button>'},redo:function(n){return'<button type="button" class="btn btn-default btn-sm btn-small" title="'+n.history.redo+'" data-event="redo" tabindex="-1"><i class="fa fa-repeat icon-repeat"><\/i><\/button>'}};r=function(n){return'<div class="note-popover"><div class="note-link-popover popover bottom in" style="display: none;"><div class="arrow"><\/div><div class="popover-content note-link-content"><a href="http://www.google.com" target="_blank">www.google.com<\/a>&nbsp;&nbsp;<div class="note-insert btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.link.edit+'" data-event="showLinkDialog" tabindex="-1"><i class="fa fa-edit icon-edit"><\/i><\/button><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.link.unlink+'" data-event="unlink" tabindex="-1"><i class="fa fa-unlink icon-unlink"><\/i><\/button><\/div><\/div><\/div><div class="note-image-popover popover bottom in" style="display: none;"><div class="arrow"><\/div><div class="popover-content note-image-content"><div class="btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.image.resizeFull+'" data-event="resize" data-value="1" tabindex="-1"><span class="note-fontsize-10">100%<\/span> <\/button><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.image.resizeHalf+'" data-event="resize" data-value="0.5" tabindex="-1"><span class="note-fontsize-10">50%<\/span> <\/button><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.image.resizeQuarter+'" data-event="resize" data-value="0.25" tabindex="-1"><span class="note-fontsize-10">25%<\/span> <\/button><\/div><div class="btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.image.floatLeft+'" data-event="floatMe" data-value="left" tabindex="-1"><i class="fa fa-align-left icon-align-left"><\/i><\/button><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.image.floatRight+'" data-event="floatMe" data-value="right" tabindex="-1"><i class="fa fa-align-right icon-align-right"><\/i><\/button><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.image.floatNone+'" data-event="floatMe" data-value="none" tabindex="-1"><i class="fa fa-align-justify icon-align-justify"><\/i><\/button><\/div><div class="btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="'+n.image.remove+'" data-event="removeMedia" data-value="none" tabindex="-1"><i class="fa fa-trash-o icon-trash"><\/i><\/button><\/div><\/div><\/div><\/div>'};var c=function(){return'<div class="note-handle"><div class="note-control-selection"><div class="note-control-selection-bg"><\/div><div class="note-control-holder note-control-nw"><\/div><div class="note-control-holder note-control-ne"><\/div><div class="note-control-holder note-control-sw"><\/div><div class="note-control-sizing note-control-se"><\/div><div class="note-control-selection-info"><\/div><\/div><\/div>'},l=function(n){return'<table class="note-shortcut"><thead><tr><th><\/th><th>'+n.shortcut.textFormatting+"<\/th><\/tr><\/thead><tbody><tr><td>⌘ + B<\/td><td>"+n.font.bold+"<\/td><\/tr><tr><td>⌘ + I<\/td><td>"+n.font.italic+"<\/td><\/tr><tr><td>⌘ + U<\/td><td>"+n.font.underline+"<\/td><\/tr><tr><td>⌘ + ⇧ + S<\/td><td>"+n.font.strike+"<\/td><\/tr><tr><td>⌘ + \\<\/td><td>"+n.font.clear+"<\/td><\/tr><\/tr><\/tbody><\/table>"},a=function(n){return'<table class="note-shortcut"><thead><tr><th><\/th><th>'+n.shortcut.action+"<\/th><\/tr><\/thead><tbody><tr><td>⌘ + Z<\/td><td>"+n.history.undo+"<\/td><\/tr><tr><td>⌘ + ⇧ + Z<\/td><td>"+n.history.redo+"<\/td><\/tr><tr><td>⌘ + ]<\/td><td>"+n.paragraph.indent+"<\/td><\/tr><tr><td>⌘ + [<\/td><td>"+n.paragraph.outdent+"<\/td><\/tr><tr><td>⌘ + ENTER<\/td><td>"+n.hr.insert+"<\/td><\/tr><\/tbody><\/table>"},v=function(n,t){var r='<table class="note-shortcut"><thead><tr><th><\/th><th>'+n.shortcut.extraKeys+"<\/th><\/tr><\/thead><tbody>";for(var i in t.extraKeys)t.extraKeys.hasOwnProperty(i)&&(r+="<tr><td>"+i+"<\/td><td>"+t.extraKeys[i]+"<\/td><\/tr>");return r+"<\/tbody><\/table>"},y=function(n){return'<table class="note-shortcut"><thead><tr><th><\/th><th>'+n.shortcut.paragraphFormatting+"<\/th><\/tr><\/thead><tbody><tr><td>⌘ + ⇧ + L<\/td><td>"+n.paragraph.left+"<\/td><\/tr><tr><td>⌘ + ⇧ + E<\/td><td>"+n.paragraph.center+"<\/td><\/tr><tr><td>⌘ + ⇧ + R<\/td><td>"+n.paragraph.right+"<\/td><\/tr><tr><td>⌘ + ⇧ + J<\/td><td>"+n.paragraph.justify+"<\/td><\/tr><tr><td>⌘ + ⇧ + NUM7<\/td><td>"+n.lists.ordered+"<\/td><\/tr><tr><td>⌘ + ⇧ + NUM8<\/td><td>"+n.lists.unordered+"<\/td><\/tr><\/tbody><\/table>"},p=function(n){return'<table class="note-shortcut"><thead><tr><th><\/th><th>'+n.shortcut.documentStyle+"<\/th><\/tr><\/thead><tbody><tr><td>⌘ + NUM0<\/td><td>"+n.style.normal+"<\/td><\/tr><tr><td>⌘ + NUM1<\/td><td>"+n.style.h1+"<\/td><\/tr><tr><td>⌘ + NUM2<\/td><td>"+n.style.h2+"<\/td><\/tr><tr><td>⌘ + NUM3<\/td><td>"+n.style.h3+"<\/td><\/tr><tr><td>⌘ + NUM4<\/td><td>"+n.style.h4+"<\/td><\/tr><tr><td>⌘ + NUM5<\/td><td>"+n.style.h5+"<\/td><\/tr><tr><td>⌘ + NUM6<\/td><td>"+n.style.h6+"<\/td><\/tr><\/tbody><\/table>"},o=function(n,t){var i='<table class="note-shortcut-layout"><tbody><tr><td>'+a(n,t)+"<\/td><td>"+l(n,t)+"<\/td><\/tr><tr><td>"+p(n,t)+"<\/td><td>"+y(n,t)+"<\/td><\/tr>";return t.extraKeys&&(i+='<tr><td colspan="2">'+v(n,t)+"<\/td><\/tr>"),i+"<\/tbody<\/table>"},w=function(n){return n.replace(/⌘/g,"Ctrl").replace(/⇧/g,"Shift")};f=function(n,t){var i=function(){return'<div class="note-image-dialog modal" aria-hidden="false"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" aria-hidden="true" tabindex="-1">&times;<\/button><h4>'+n.image.insert+'<\/h4><\/div><div class="modal-body"><div class="row-fluid"><h5>'+n.image.selectFromFiles+'<\/h5><input class="note-image-input" type="file" name="files" accept="image/*" /><h5>'+n.image.url+'<\/h5><input class="note-image-url form-control span12" type="text" /><\/div><\/div><div class="modal-footer"><button href="#" class="btn btn-primary note-image-btn disabled" disabled="disabled">'+n.image.insert+"<\/button><\/div><\/div><\/div><\/div>"},r=function(){return'<div class="note-link-dialog modal" aria-hidden="false"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" aria-hidden="true" tabindex="-1">&times;<\/button><h4>'+n.link.insert+'<\/h4><\/div><div class="modal-body"><div class="row-fluid"><div class="form-group"><label>'+n.link.textToDisplay+'<\/label><input class="note-link-text form-control span12" disabled type="text" /><\/div><div class="form-group"><label>'+n.link.url+'<\/label><input class="note-link-url form-control span12" type="text" /><\/div>'+(t.disableLinkTarget?"":'<div class="checkbox"><label><input type="checkbox" checked> '+n.link.openInNewWindow+"<\/label><\/div>")+'<\/div><\/div><div class="modal-footer"><button href="#" class="btn btn-primary note-link-btn disabled" disabled="disabled">'+n.link.insert+"<\/button><\/div><\/div><\/div><\/div>"},f=function(){return'<div class="note-video-dialog modal" aria-hidden="false"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" aria-hidden="true" tabindex="-1">&times;<\/button><h4>'+n.video.insert+'<\/h4><\/div><div class="modal-body"><div class="row-fluid"><div class="form-group"><label>'+n.video.url+'<\/label>&nbsp;<small class="text-muted">'+n.video.providers+'<\/small><input class="note-video-url form-control span12" type="text" /><\/div><\/div><\/div><div class="modal-footer"><button href="#" class="btn btn-primary note-video-btn disabled" disabled="disabled">'+n.video.insert+"<\/button><\/div><\/div><\/div><\/div>"},e=function(){return'<div class="note-help-dialog modal" aria-hidden="false"><div class="modal-dialog"><div class="modal-content"><div class="modal-body"><a class="modal-close pull-right" aria-hidden="true" tabindex="-1">'+n.shortcut.close+'<\/a><div class="title">'+n.shortcut.shortcuts+"<\/div>"+(u.bMac?o(n,t):w(o(n,t)))+'<p class="text-center"><a href="//hackerwins.github.io/summernote/" target="_blank">Summernote 0.5.1<\/a> · <a href="//github.com/HackerWins/summernote" target="_blank">Project<\/a> · <a href="//github.com/HackerWins/summernote/issues" target="_blank">Issues<\/a><\/p><\/div><\/div><\/div><\/div>'};return'<div class="note-dialog">'+i()+r()+f()+e()+"<\/div>"};e=function(){return'<div class="note-resizebar"><div class="note-icon-bar"><\/div><div class="note-icon-bar"><\/div><div class="note-icon-bar"><\/div><\/div>'};var s=function(t,i){t.find("button").each(function(t,i){var r=n(i),f=r.attr(u.bMac?"data-mac-shortcut":"data-shortcut");f&&r.attr("title",function(n,t){return t+" ("+f+")"})}).tooltip({container:"body",trigger:"hover",placement:i||"top"}).on("click",function(){n(this).tooltip("hide")})},h=[["#000000","#424242","#636363","#9C9C94","#CEC6CE","#EFEFEF","#F7F7F7","#FFFFFF"],["#FF0000","#FF9C00","#FFFF00","#00FF00","#00FFFF","#0000FF","#9C00FF","#FF00FF"],["#F7C6CE","#FFE7CE","#FFEFC6","#D6EFD6","#CEDEE7","#CEE7F7","#D6D6E7","#E7D6DE"],["#E79C9C","#FFC69C","#FFE79C","#B5D6A5","#A5C6CE","#9CC6EF","#B5A5D6","#D6A5BD"],["#E76363","#F7AD6B","#FFD663","#94BD7B","#73A5AD","#6BADDE","#8C7BC6","#C67BA5"],["#CE0000","#E79439","#EFC631","#6BA54A","#4A7B8C","#3984C6","#634AA5","#A54A7B"],["#9C0000","#B56308","#BD9400","#397B21","#104A5A","#085294","#311873","#731842"],["#630000","#7B3900","#846300","#295218","#083139","#003163","#21104A","#4A1031"]],b=function(t){t.find(".note-color-palette").each(function(){for(var r,u,t,e,i,o=n(this),c=o.attr("data-target-event"),s=[],f=0,l=h.length;f<l;f++){for(r=h[f],u=[],t=0,e=r.length;t<e;t++)i=r[t],u.push(['<button type="button" class="note-color-btn" style="background-color:',i,';" data-event="',c,'" data-value="',i,'" title="',i,'" data-toggle="button" tabindex="-1"><\/button>'].join(""));s.push("<div>"+u.join("")+"<\/div>")}o.html(s.join(""))})};this.createLayout=function(u,o){var d=u.next(),h,g,a,v,l,y,nt,p,w,tt,k,it,rt;if(!d||!d.hasClass("note-editor")){for(h=n('<div class="note-editor"><\/div>'),o.width&&h.width(o.width),o.height>0&&n('<div class="note-statusbar">'+e()+"<\/div>").prependTo(h),g=!u.is(":disabled"),a=n('<div class="note-editable" contentEditable="'+g+'"><\/div>').prependTo(h),o.height&&a.height(o.height),o.direction&&a.attr("dir",o.direction),a.html(i.escapejs(i.html(u))||i.emptyPara),n('<textarea class="note-codable"><\/textarea>').prependTo(h),v=n.summernote.lang[o.lang],l="",y=0,nt=o.toolbar.length;y<nt;y++){for(p=o.toolbar[y],l+='<div class="note-'+p[0]+' btn-group">',w=0,tt=p[1].length;w<tt;w++)l+=t[p[1][w]](v);l+="<\/div>"}l='<div class="note-toolbar btn-toolbar">'+l+"<\/div>";k=n(l).prependTo(h);b(k);s(k,"bottom");it=n(r(v)).prependTo(h);s(it);n(c()).prependTo(h);rt=n(f(v,o)).prependTo(h);rt.find("button.close, a.modal-close").click(function(){n(this).closest(".modal").modal("hide")});n('<div class="note-dropzone"><div class="note-dropzone-message"><\/div><\/div>').prependTo(h);h.insertAfter(u);u.hide()}};this.layoutInfoFromHolder=function(n){var u=n.next(),t,r;if(u.hasClass("note-editor")){t=i.buildLayoutInfo(u);for(r in t)t.hasOwnProperty(r)&&(t[r]=t[r].call());return t}};this.removeLayout=function(n){var t=this.layoutInfoFromHolder(n);t&&(n.html(t.editable.html()),t.editor.remove(),n.show())}};n.summernote=n.summernote||{};n.extend(n.summernote,{version:"0.5.1",options:{width:null,height:null,focus:!1,tabsize:null,styleWithSpan:!0,disableLinkTarget:!1,disableDragAndDrop:!1,codemirror:null,lang:"en-US",direction:null,toolbar:[["style",["style"]],["font",["bold","italic","underline","clear"]],["fontname",["fontname"]],["color",["color"]],["para",["ul","ol","paragraph"]],["height",["height"]],["table",["table"]],["insert",["link","picture","video"]],["view",["fullscreen","codeview"]],["help",["help"]]],oninit:null,onfocus:null,onblur:null,onenter:null,onkeyup:null,onkeydown:null,onImageUpload:null,onImageUploadError:null,onToolbarClick:null,keyMap:{pc:{"CTRL+Z":"undo","CTRL+Y":"redo",TAB:"tab","SHIFT+TAB":"untab","CTRL+B":"bold","CTRL+I":"italic","CTRL+U":"underline","CTRL+SHIFT+S":"strikethrough","CTRL+BACKSLASH":"removeFormat","CTRL+SHIFT+L":"justifyLeft","CTRL+SHIFT+E":"justifyCenter","CTRL+SHIFT+R":"justifyRight","CTRL+SHIFT+J":"justifyFull","CTRL+SHIFT+NUM7":"insertUnorderedList","CTRL+SHIFT+NUM8":"insertOrderedList","CTRL+LEFTBRACKET":"outdent","CTRL+RIGHTBRACKET":"indent","CTRL+NUM0":"formatPara","CTRL+NUM1":"formatH1","CTRL+NUM2":"formatH2","CTRL+NUM3":"formatH3","CTRL+NUM4":"formatH4","CTRL+NUM5":"formatH5","CTRL+NUM6":"formatH6","CTRL+ENTER":"insertHorizontalRule"},mac:{"CMD+Z":"undo","CMD+SHIFT+Z":"redo",TAB:"tab","SHIFT+TAB":"untab","CMD+B":"bold","CMD+I":"italic","CMD+U":"underline","CMD+SHIFT+S":"strikethrough","CMD+BACKSLASH":"removeFormat","CMD+SHIFT+L":"justifyLeft","CMD+SHIFT+E":"justifyCenter","CMD+SHIFT+R":"justifyRight","CMD+SHIFT+J":"justifyFull","CMD+SHIFT+NUM7":"insertUnorderedList","CMD+SHIFT+NUM8":"insertOrderedList","CMD+LEFTBRACKET":"outdent","CMD+RIGHTBRACKET":"indent","CMD+NUM0":"formatPara","CMD+NUM1":"formatH1","CMD+NUM2":"formatH2","CMD+NUM3":"formatH3","CMD+NUM4":"formatH4","CMD+NUM5":"formatH5","CMD+NUM6":"formatH6","CMD+ENTER":"insertHorizontalRule"}}},lang:{"en-US":{font:{bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strike",clear:"Remove Font Style",height:"Line Height",name:"Font Family",size:"Font Size"},image:{image:"Picture",insert:"Insert Image",resizeFull:"Resize Full",resizeHalf:"Resize Half",resizeQuarter:"Resize Quarter",floatLeft:"Float Left",floatRight:"Float Right",floatNone:"Float None",dragImageHere:"Drag an image here",selectFromFiles:"Select from files",url:"Image URL",remove:"Remove Image"},link:{link:"Link",insert:"Insert Link",unlink:"Unlink",edit:"Edit",textToDisplay:"Text to display",url:"To what URL should this link go?",openInNewWindow:"Open in new window"},video:{video:"Video",videoLink:"Video Link",insert:"Insert Video",url:"Video URL?",providers:"(YouTube, Vimeo, Vine, Instagram, or DailyMotion)"},table:{table:"Table"},hr:{insert:"Insert Horizontal Rule"},style:{style:"Style",normal:"Normal",blockquote:"Quote",pre:"Code",h1:"Header 1",h2:"Header 2",h3:"Header 3",h4:"Header 4",h5:"Header 5",h6:"Header 6"},lists:{unordered:"Unordered list",ordered:"Ordered list"},options:{help:"Help",fullscreen:"Full Screen",codeview:"Code View"},paragraph:{paragraph:"Paragraph",outdent:"Outdent",indent:"Indent",left:"Align left",center:"Align center",right:"Align right",justify:"Justify full"},color:{recent:"Recent Color",more:"More Color",background:"BackColor",foreground:"FontColor",transparent:"Transparent",setTransparent:"Set transparent",reset:"Reset",resetToDefault:"Reset to default"},shortcut:{shortcuts:"Keyboard shortcuts",close:"Close",textFormatting:"Text formatting",action:"Action",paragraphFormatting:"Paragraph formatting",documentStyle:"Document Style"},history:{undo:"Undo",redo:"Redo"}}}});o=new g;s=new d;n.fn.extend({summernote:function(t){if(t=n.extend({},n.summernote.options,t),this.each(function(r,u){var f=n(u),e;o.createLayout(f,t);e=o.layoutInfoFromHolder(f);s.attach(e,t);i.isTextarea(f[0])&&f.closest("form").submit(function(){f.val(f.code())})}),this.first()&&t.focus){var r=o.layoutInfoFromHolder(this.first());r.editable.focus()}return this.length>0&&t.oninit&&t.oninit(),this},code:function(t){var f,r,e;return t===undefined?(f=this.first(),f.length===0)?void 0:(r=o.layoutInfoFromHolder(f),!!(r&&r.editable))?(e=r.editor.hasClass("codeview"),e&&u.bCodeMirror&&r.codable.data("cmEditor").save(),e?r.codable.val():i.unescapejs(r.editable.html())):f.html():(this.each(function(r,u){var f=o.layoutInfoFromHolder(n(u));f&&f.editable&&f.editable.html(i.escapejs(t))}),this)},destroy:function(){return this.each(function(t,i){var u=n(i),r=o.layoutInfoFromHolder(u);r&&r.editable&&(s.dettach(r),o.removeLayout(u))}),this}})}),function(n,t){var i,r,e=n.srcDoc,o=!!("srcdoc"in t.createElement("iframe")),f={compliant:function(n,t){t&&n.setAttribute("srcdoc",t);attachFrameResizeEvent(n)},legacy:function(n,t){var i;n&&n.getAttribute&&(t?n.setAttribute("srcdoc",t):t=n.getAttribute("srcdoc"),t&&(i="javascript: window.frameElement.getAttribute('srcdoc');",n.setAttribute("src",i),n.contentWindow&&(n.contentWindow.location=i)),attachFrameResizeEvent(n))}},u=n.srcDoc={set:f.compliant,noConflict:function(){return n.srcDoc=e,u}};for(o||(u.set=f.legacy),r=t.getElementsByTagName("iframe"),i=r.length;i--;)u.set(r[i])}(this,this.document);$(document).ajaxComplete(function(n,t){t&&t.responseText&&t.responseText.indexOf("iframe")>-1&&$.each($("iframe"),function(n,t){isNaN(parseInt(t.style.height,10))&&srcDoc.set(t)})})