From ed23d1022f0e8735909b5ff80911edf11d02b780 Mon Sep 17 00:00:00 2001
From: ido <idok@wix.com>
Date: Wed, 29 Jul 2015 17:16:37 +0300
Subject: [PATCH] playground changes: update dependencies, minor fixes in
 samples and code

---
 fiddle.html                            |  9 +++++----
 index.html                             |  7 ++++---
 playground/CMLint.js                   |  2 +-
 playground/CodeMirrorViewer.js         |  8 ++------
 playground/dist/fiddle.min.js          |  2 +-
 playground/dist/home.min.js            |  2 +-
 playground/dist/rt-main.browser.js     |  8 ++++++--
 playground/dist/rt-main.browser.min.js |  2 +-
 playground/fiddle-main.js              |  2 +-
 playground/fiddle.js                   |  2 +-
 playground/home-main.js                |  6 ++----
 playground/playground.js               |  4 ++--
 playground/playground.rt               |  2 +-
 playground/playground.rt.js            |  1 +
 playground/samples/hello.code          |  4 +---
 playground/samples/rt-if.code          |  4 +---
 playground/samples/rt-props.code       |  4 +---
 playground/samples/rt-repeat.code      |  4 +---
 playground/samples/todo.code           | 12 ++++++++----
 playground/samples/todo.rt             |  4 ++--
 playground/samples/todo2.code          |  5 ++---
 playground/samples/weather.code        |  4 +---
 22 files changed, 46 insertions(+), 52 deletions(-)

diff --git a/fiddle.html b/fiddle.html
index 165e6f2..03ed20b 100644
--- a/fiddle.html
+++ b/fiddle.html
@@ -12,9 +12,9 @@
     <link href='//fonts.googleapis.com/css?family=Lato:100,300,400,700' rel='stylesheet' type='text/css'>
 
     <!-- Latest compiled and minified CSS -->
-    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
+    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
     <!-- Optional theme -->
-    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
+    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
     <!-- Latest compiled and minified JavaScript -->
 
     <link rel="stylesheet" href="playground/libs/codemirror-4.8/lib/codemirror.css" />
@@ -38,8 +38,9 @@
 <!--<script src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.15/require.min.js"></script>-->
 <!--<script src="playground/dist/fiddle.min.js"></script>-->
 
-<!--<script data-main="playground/fiddle-main.js" src="http://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.15/require.js"></script>-->
-<script data-main="playground/dist/fiddle.min.js" src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.15/require.min.js"></script>
+<!--<script data-main="playground/fiddle-main.js" src="http://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.20/require.js"></script>-->
+<script data-main="playground/dist/fiddle.min.js" src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.20/require.min.js"></script>
+
 <script>
 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
diff --git a/index.html b/index.html
index 97b2b75..24fcd4d 100644
--- a/index.html
+++ b/index.html
@@ -11,7 +11,7 @@
     <link href='//fonts.googleapis.com/css?family=Lato:100,300,700' rel='stylesheet' type='text/css'>
 
     <!-- Latest compiled and minified CSS -->
-    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
+    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
     <!-- Optional theme -->
     <!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">-->
 
@@ -82,8 +82,9 @@
 
 <script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
 <script src="playground/dist/rt-main.browser.min.js"></script>
-<!--<script data-main="playground/home-main.js" src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.15/require.min.js"></script>-->
-<script src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.15/require.min.js"></script>
+<!--<script data-main="playground/home-main.js" src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.20/require.min.js"></script>-->
+<script src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.20/require.min.js"></script>
+<!--<script src="playground/home-main.js"></script>-->
 <script src="playground/dist/home.min.js"></script>
 <script>
 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
diff --git a/playground/CMLint.js b/playground/CMLint.js
index b319d2e..80d8442 100644
--- a/playground/CMLint.js
+++ b/playground/CMLint.js
@@ -62,7 +62,7 @@ define(['react', 'lodash', 'jquery', './libs/codemirror-4.8/lib/codemirror'], fu
                 return CodeMirror.off(document, 'mousemove', position);
             }
             tt.style.top = Math.max(0, ev.clientY - tt.offsetHeight - 5) + 'px';
-            tt.style.left = (ev.clientX + 5) + 'px';
+            tt.style.left = (ev.clientX + 5) + 'px'; //eslint-disable-line no-extra-parens
         }
         CodeMirror.on(document, 'mousemove', position);
         position(e);
diff --git a/playground/CodeMirrorViewer.js b/playground/CodeMirrorViewer.js
index fa42eee..964b1af 100644
--- a/playground/CodeMirrorViewer.js
+++ b/playground/CodeMirrorViewer.js
@@ -13,14 +13,10 @@ define(['react', 'lodash', 'jquery', './libs/codemirror-4.8/lib/codemirror',
             valueLink: React.PropTypes.string
         },
         getDefaultProps: function () {
-            return {
-                mode: 'html'
-            };
+            return {mode: 'html'};
         },
         getInitialState: function () {
-            return {
-                editorId: _.uniqueId()
-            };
+            return {editorId: _.uniqueId()};
         },
         render: function () {
             var props = _.omit(this.props, ['ref', 'key', 'value', 'valueLink', 'onChange']);
diff --git a/playground/dist/fiddle.min.js b/playground/dist/fiddle.min.js
index 8ba6fb0..d5d7e93 100644
--- a/playground/dist/fiddle.min.js
+++ b/playground/dist/fiddle.min.js
@@ -12,4 +12,4 @@
  * Config saved to config.json and https://gist.github.com/b3a553f0244f7a115bca
  */
 
-(function(e){if(typeof exports=="object"&&typeof module=="object")module.exports=e();else{if(typeof define=="function"&&define.amd)return define("libs/codemirror-4.8/lib/codemirror",[],e);this.CodeMirror=e()}})(function(){function S(e,t){if(!(this instanceof S))return new S(e,t);this.options=t=t?zo(t):{},zo(fi,t,!1),H(t);var n=t.value;typeof n=="string"&&(n=new js(n,t.mode)),this.doc=n;var s=this.display=new x(e,n);s.wrapper.CodeMirror=this,M(this),A(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),t.autofocus&&!d&&er(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Do,keySeq:null},r&&i<11&&setTimeout(Wo(Zn,this,!0),20),rr(this),fu(),kn(this),this.curOp.forceUpdate=!0,Rs(this,n),t.autofocus&&!d||nu()==s.input?setTimeout(Wo(Pr,this),20):Hr(this);for(var o in li)li.hasOwnProperty(o)&&li[o](this,t[o],hi);R(this);for(var u=0;u<mi.length;++u)mi[u](this);An(this)}function x(e,t){var n=this,o=n.input=Go("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none");s?o.style.width="1000px":o.setAttribute("wrap","off"),p&&(o.style.border="1px solid black"),o.setAttribute("autocorrect","off"),o.setAttribute("autocapitalize","off"),o.setAttribute("spellcheck","false"),n.inputDiv=Go("div",[o],null,"overflow: hidden; position: relative; width: 3px; height: 0px;"),n.scrollbarH=Go("div",[Go("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar"),n.scrollbarV=Go("div",[Go("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n.scrollbarFiller=Go("div",null,"CodeMirror-scrollbar-filler"),n.gutterFiller=Go("div",null,"CodeMirror-gutter-filler"),n.lineDiv=Go("div",null,"CodeMirror-code"),n.selectionDiv=Go("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=Go("div",null,"CodeMirror-cursors"),n.measure=Go("div",null,"CodeMirror-measure"),n.lineMeasure=Go("div",null,"CodeMirror-measure"),n.lineSpace=Go("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=Go("div",[Go("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=Go("div",[n.mover],"CodeMirror-sizer"),n.heightForcer=Go("div",null,null,"position: absolute; height: "+Lo+"px; width: 1px;"),n.gutters=Go("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=Go("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=Go("div",[n.inputDiv,n.scrollbarH,n.scrollbarV,n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),r&&i<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),p&&(o.style.width="0px"),s||(n.scroller.draggable=!0),l&&(n.inputDiv.style.height="1px",n.inputDiv.style.position="absolute"),r&&i<8&&(n.scrollbarH.style.minHeight=n.scrollbarV.style.minWidth="18px"),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.view=[],n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.prevInput="",n.alignWidgets=!1,n.pollingFast=!1,n.poll=new Do,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.inaccurateSelection=!1,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null}function T(e){e.doc.mode=S.getMode(e.options,e.doc.modeOption),N(e)}function N(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,Xt(e,100),e.state.modeGen++,e.curOp&&Un(e)}function C(e){e.options.lineWrapping?(su(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth=""):(iu(e.display.wrapper,"CodeMirror-wrap"),P(e)),L(e),Un(e),cn(e),setTimeout(function(){F(e)},100)}function k(e){var t=xn(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/Tn(e.display)-3);return function(i){if(ss(e.doc,i))return 0;var s=0;if(i.widgets)for(var o=0;o<i.widgets.length;o++)i.widgets[o].height&&(s+=i.widgets[o].height);return n?s+(Math.ceil(i.text.length/r)||1)*t:s+t}}function L(e){var t=e.doc,n=k(e);t.iter(function(e){var t=n(e);t!=e.height&&Xs(e,t)})}function A(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),cn(e)}function O(e){M(e),Un(e),setTimeout(function(){q(e)},20)}function M(e){var t=e.display.gutters,n=e.options.gutters;Zo(t);for(var r=0;r<n.length;++r){var i=n[r],s=t.appendChild(Go("div",null,"CodeMirror-gutter "+i));i=="CodeMirror-linenumbers"&&(e.display.lineGutter=s,s.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=r?"":"none",_(e)}function _(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px",e.display.scrollbarH.style.left=e.options.fixedGutter?t+"px":0}function D(e){if(e.height==0)return 0;var t=e.text.length,n,r=e;while(n=Yi(r)){var i=n.find(0,!0);r=i.from.line,t+=i.from.ch-i.to.ch}r=e;while(n=Zi(r)){var i=n.find(0,!0);t-=r.text.length-i.from.ch,r=i.to.line,t+=r.text.length-i.to.ch}return t}function P(e){var t=e.display,n=e.doc;t.maxLine=Us(n,n.first),t.maxLineLength=D(t.maxLine),t.maxLineChanged=!0,n.iter(function(e){var n=D(e);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}function H(e){var t=qo(e.gutters,"CodeMirror-linenumbers");t==-1&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function B(e){return e.display.scroller.clientHeight-e.display.wrapper.clientHeight<Lo-3}function j(e){var t=e.display.scroller;return{clientHeight:t.clientHeight,barHeight:e.display.scrollbarV.clientHeight,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth,hScrollbarTakesSpace:B(e),barWidth:e.display.scrollbarH.clientWidth,docHeight:Math.round(e.doc.height+Qt(e.display))}}function F(e,t){t||(t=j(e));var n=e.display,r=pu(n.measure),i=t.docHeight+Lo,s=t.scrollWidth>t.clientWidth;s&&t.scrollWidth<=t.clientWidth+1&&r>0&&!t.hScrollbarTakesSpace&&(s=!1);var o=i>t.clientHeight;o?(n.scrollbarV.style.display="block",n.scrollbarV.style.bottom=s?r+"px":"0",n.scrollbarV.firstChild.style.height=Math.max(0,i-t.clientHeight+(t.barHeight||n.scrollbarV.clientHeight))+"px"):(n.scrollbarV.style.display="",n.scrollbarV.firstChild.style.height="0"),s?(n.scrollbarH.style.display="block",n.scrollbarH.style.right=o?r+"px":"0",n.scrollbarH.firstChild.style.width=t.scrollWidth-t.clientWidth+(t.barWidth||n.scrollbarH.clientWidth)+"px"):(n.scrollbarH.style.display="",n.scrollbarH.firstChild.style.width="0"),s&&o?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=n.scrollbarFiller.style.width=r+"px"):n.scrollbarFiller.style.display="",s&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r+"px",n.gutterFiller.style.width=n.gutters.offsetWidth+"px"):n.gutterFiller.style.display="";if(!e.state.checkedOverlayScrollbar&&t.clientHeight>0){if(r===0){var u=v&&!c?"12px":"18px";n.scrollbarV.style.minWidth=n.scrollbarH.style.minHeight=u;var a=function(t){mo(t)!=n.scrollbarV&&mo(t)!=n.scrollbarH&&jn(e,ur)(t)};yo(n.scrollbarV,"mousedown",a),yo(n.scrollbarH,"mousedown",a)}e.state.checkedOverlayScrollbar=!0}}function I(e,t,n){var r=n&&n.top!=null?Math.max(0,n.top):e.scroller.scrollTop;r=Math.floor(r-Kt(e));var i=n&&n.bottom!=null?n.bottom:r+e.wrapper.clientHeight,s=$s(t,r),o=$s(t,i);if(n&&n.ensure){var u=n.ensure.from.line,a=n.ensure.to.line;if(u<s)return{from:u,to:$s(t,Js(Us(t,u))+e.wrapper.clientHeight)};if(Math.min(a,t.lastLine())>=o)return{from:$s(t,Js(Us(t,a))-e.wrapper.clientHeight),to:a}}return{from:s,to:Math.max(o,s+1)}}function q(e){var t=e.display,n=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;var r=z(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,s=r+"px";for(var o=0;o<n.length;o++)if(!n[o].hidden){e.options.fixedGutter&&n[o].gutter&&(n[o].gutter.style.left=s);var u=n[o].alignable;if(u)for(var a=0;a<u.length;a++)u[a].style.left=s}e.options.fixedGutter&&(t.gutters.style.left=r+i+"px")}function R(e){if(!e.options.lineNumbers)return!1;var t=e.doc,n=U(e.options,t.first+t.size-1),r=e.display;if(n.length!=r.lineNumChars){var i=r.measure.appendChild(Go("div",[Go("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),s=i.firstChild.offsetWidth,o=i.offsetWidth-s;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(s,r.lineGutter.offsetWidth-o),r.lineNumWidth=r.lineNumInnerWidth+o,r.lineNumChars=r.lineNumInnerWidth?n.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",_(e),!0}return!1}function U(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function z(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function W(e,t,n){var r=e.display;this.viewport=t,this.visible=I(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldViewFrom=r.viewFrom,this.oldViewTo=r.viewTo,this.oldScrollerWidth=r.scroller.clientWidth,this.force=n,this.dims=Y(e)}function X(e,t){var n=e.display,r=e.doc;if(t.editorIsHidden)return Wn(e),!1;if(!t.force&&t.visible.from>=n.viewFrom&&t.visible.to<=n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo)&&Jn(e)==0)return!1;R(e)&&(Wn(e),t.dims=Y(e));var i=r.first+r.size,s=Math.max(t.visible.from-e.options.viewportMargin,r.first),o=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFrom<s&&s-n.viewFrom<20&&(s=Math.max(r.first,n.viewFrom)),n.viewTo>o&&n.viewTo-o<20&&(o=Math.min(i,n.viewTo)),E&&(s=rs(e.doc,s),o=is(e.doc,o));var u=s!=n.viewFrom||o!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;$n(e,s,o),n.viewOffset=Js(Us(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var a=Jn(e);if(!u&&a==0&&!t.force&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo))return!1;var f=nu();return a>4&&(n.lineDiv.style.display="none"),Z(e,n.updateLineNumbers,t.dims),a>4&&(n.lineDiv.style.display=""),f&&nu()!=f&&f.offsetHeight&&f.focus(),Zo(n.cursorDiv),Zo(n.selectionDiv),u&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,Xt(e,400)),n.updateLineNumbers=null,!0}function V(e,t){var n=t.force,r=t.viewport;for(var i=!0;;i=!1){if(i&&e.options.lineWrapping&&t.oldScrollerWidth!=e.display.scroller.clientWidth)n=!0;else{n=!1,r&&r.top!=null&&(r={top:Math.min(e.doc.height+Qt(e.display)-Lo-e.display.scroller.clientHeight,r.top)}),t.visible=I(e.display,e.doc,r);if(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}if(!X(e,t))break;Q(e);var s=j(e);Rt(e),J(e,s),F(e,s)}So(e,"update",e),(e.display.viewFrom!=t.oldViewFrom||e.display.viewTo!=t.oldViewTo)&&So(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo)}function $(e,t){var n=new W(e,t);if(X(e,n)){Q(e),V(e,n);var r=j(e);Rt(e),J(e,r),F(e,r)}}function J(e,t){e.display.sizer.style.minHeight=e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=Math.max(t.docHeight,t.clientHeight-Lo)+"px"}function K(e,t){e.display.sizer.offsetWidth+e.display.gutters.offsetWidth<e.display.scroller.clientWidth-1&&(e.display.sizer.style.minHeight=e.display.heightForcer.style.top="0px",e.display.gutters.style.height=t.docHeight+"px")}function Q(e){var t=e.display,n=t.lineDiv.offsetTop;for(var s=0;s<t.view.length;s++){var o=t.view[s],u;if(o.hidden)continue;if(r&&i<8){var a=o.node.offsetTop+o.node.offsetHeight;u=a-n,n=a}else{var f=o.node.getBoundingClientRect();u=f.bottom-f.top}var l=o.line.height-u;u<2&&(u=xn(t));if(l>.001||l<-0.001){Xs(o.line,u),G(o.line);if(o.rest)for(var c=0;c<o.rest.length;c++)G(o.rest[c])}}}function G(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function Y(e){var t=e.display,n={},r={},i=t.gutters.clientLeft;for(var s=t.gutters.firstChild,o=0;s;s=s.nextSibling,++o)n[e.options.gutters[o]]=s.offsetLeft+s.clientLeft+i,r[e.options.gutters[o]]=s.clientWidth;return{fixedPos:z(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Z(e,t,n){function a(t){var n=t.nextSibling;return s&&v&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}var r=e.display,i=e.options.lineNumbers,o=r.lineDiv,u=o.firstChild,f=r.view,l=r.viewFrom;for(var c=0;c<f.length;c++){var h=f[c];if(!h.hidden)if(!h.node){var p=at(e,h,l,n);o.insertBefore(p,u)}else{while(u!=h.node)u=a(u);var d=i&&t!=null&&t<=l&&h.lineNumber;h.changes&&(qo(h.changes,"gutter")>-1&&(d=!1),et(e,h,l,n)),d&&(Zo(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(U(e.options,l)))),u=h.node.nextSibling}l+=h.size}while(u)u=a(u)}function et(e,t,n,r){for(var i=0;i<t.changes.length;i++){var s=t.changes[i];s=="text"?it(e,t):s=="gutter"?ot(e,t,n,r):s=="class"?st(t):s=="widget"&&ut(t,r)}t.changes=null}function tt(e){return e.node==e.text&&(e.node=Go("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),r&&i<8&&(e.node.style.zIndex=2)),e.node}function nt(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;t&&(t+=" CodeMirror-linebackground");if(e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var n=tt(e);e.background=n.insertBefore(Go("div",null,t),n.firstChild)}}function rt(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Ns(e,t)}function it(e,t){var n=t.text.className,r=rt(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,st(t)):n&&(t.text.className=n)}function st(e){nt(e),e.line.wrapClass?tt(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function ot(e,t,n,r){t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null);var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var s=tt(t),o=t.gutter=s.insertBefore(Go("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),t.text);t.line.gutterClass&&(o.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!i||!i["CodeMirror-linenumbers"])&&(t.lineNumber=o.appendChild(Go("div",U(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px")));if(i)for(var u=0;u<e.options.gutters.length;++u){var a=e.options.gutters[u],f=i.hasOwnProperty(a)&&i[a];f&&o.appendChild(Go("div",[f],"CodeMirror-gutter-elt","left: "+r.gutterLeft[a]+"px; width: "+r.gutterWidth[a]+"px"))}}}function ut(e,t){e.alignable&&(e.alignable=null);for(var n=e.node.firstChild,r;n;n=r){var r=n.nextSibling;n.className=="CodeMirror-linewidget"&&e.node.removeChild(n)}ft(e,t)}function at(e,t,n,r){var i=rt(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),st(t),ot(e,t,n,r),ft(t,r),t.node}function ft(e,t){lt(e.line,e,t,!0);if(e.rest)for(var n=0;n<e.rest.length;n++)lt(e.rest[n],e,t,!1)}function lt(e,t,n,r){if(!e.widgets)return;var i=tt(t);for(var s=0,o=e.widgets;s<o.length;++s){var u=o[s],a=Go("div",[u.node],"CodeMirror-linewidget");u.handleMouseEvents||(a.ignoreEvents=!0),ct(u,a,t,n),r&&u.above?i.insertBefore(a,t.gutter||t.text):i.appendChild(a),So(u,"redraw")}}function ct(e,t,n,r){if(e.noHScroll){(n.alignable||(n.alignable=[])).push(t);var i=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(i-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function dt(e){return ht(e.line,e.ch)}function vt(e,t){return pt(e,t)<0?t:e}function mt(e,t){return pt(e,t)<0?e:t}function gt(e,t){this.ranges=e,this.primIndex=t}function yt(e,t){this.anchor=e,this.head=t}function bt(e,t){var n=e[t];e.sort(function(e,t){return pt(e.from(),t.from())}),t=qo(e,n);for(var r=1;r<e.length;r++){var i=e[r],s=e[r-1];if(pt(s.to(),i.from())>=0){var o=mt(s.from(),i.from()),u=vt(s.to(),i.to()),a=s.empty()?i.from()==i.head:s.from()==s.head;r<=t&&--t,e.splice(--r,2,new yt(a?u:o,a?o:u))}}return new gt(e,t)}function wt(e,t){return new gt([new yt(e,t||e)],0)}function Et(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function St(e,t){if(t.line<e.first)return ht(e.first,0);var n=e.first+e.size-1;return t.line>n?ht(n,Us(e,n).text.length):xt(t,Us(e,t.line).text.length)}function xt(e,t){var n=e.ch;return n==null||n>t?ht(e.line,t):n<0?ht(e.line,0):e}function Tt(e,t){return t>=e.first&&t<e.first+e.size}function Nt(e,t){for(var n=[],r=0;r<t.length;r++)n[r]=St(e,t[r]);return n}function Ct(e,t,n,r){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(r){var s=pt(n,i)<0;s!=pt(r,i)<0?(i=n,n=r):s!=pt(n,r)<0&&(n=r)}return new yt(i,n)}return new yt(r||n,n)}function kt(e,t,n,r){Dt(e,new gt([Ct(e,e.sel.primary(),t,n)],0),r)}function Lt(e,t,n){for(var r=[],i=0;i<e.sel.ranges.length;i++)r[i]=Ct(e,e.sel.ranges[i],t[i],null);var s=bt(r,e.sel.primIndex);Dt(e,s,n)}function At(e,t,n,r){var i=e.sel.ranges.slice(0);i[t]=n,Dt(e,bt(i,e.sel.primIndex),r)}function Ot(e,t,n,r){Dt(e,wt(t,n),r)}function Mt(e,t){var n={ranges:t.ranges,update:function(t){this.ranges=[];for(var n=0;n<t.length;n++)this.ranges[n]=new yt(St(e,t[n].anchor),St(e,t[n].head))}};return wo(e,"beforeSelectionChange",e,n),e.cm&&wo(e.cm,"beforeSelectionChange",e.cm,n),n.ranges!=t.ranges?bt(n.ranges,n.ranges.length-1):t}function _t(e,t,n){var r=e.history.done,i=Fo(r);i&&i.ranges?(r[r.length-1]=t,Pt(e,t,n)):Dt(e,t,n)}function Dt(e,t,n){Pt(e,t,n),no(e,e.sel,e.cm?e.cm.curOp.id:NaN,n)}function Pt(e,t,n){if(Co(e,"beforeSelectionChange")||e.cm&&Co(e.cm,"beforeSelectionChange"))t=Mt(e,t);var r=n&&n.bias||(pt(t.primary().head,e.sel.primary().head)<0?-1:1);Ht(e,jt(e,t,r,!0)),(!n||n.scroll!==!1)&&e.cm&&ni(e.cm)}function Ht(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,No(e.cm)),So(e,"cursorActivity",e)}function Bt(e){Ht(e,jt(e,e.sel,null,!1),Oo)}function jt(e,t,n,r){var i;for(var s=0;s<t.ranges.length;s++){var o=t.ranges[s],u=Ft(e,o.anchor,n,r),a=Ft(e,o.head,n,r);if(i||u!=o.anchor||a!=o.head)i||(i=t.ranges.slice(0,s)),i[s]=new yt(u,a)}return i?bt(i,t.primIndex):t}function Ft(e,t,n,r){var i=!1,s=t,o=n||1;e.cantEdit=!1;e:for(;;){var u=Us(e,s.line);if(u.markedSpans)for(var a=0;a<u.markedSpans.length;++a){var f=u.markedSpans[a],l=f.marker;if((f.from==null||(l.inclusiveLeft?f.from<=s.ch:f.from<s.ch))&&(f.to==null||(l.inclusiveRight?f.to>=s.ch:f.to>s.ch))){if(r){wo(l,"beforeCursorEnter");if(l.explicitlyCleared){if(!u.markedSpans)break;--a;continue}}if(!l.atomic)continue;var c=l.find(o<0?-1:1);if(pt(c,s)==0){c.ch+=o,c.ch<0?c.line>e.first?c=St(e,ht(c.line-1)):c=null:c.ch>u.text.length&&(c.line<e.first+e.size-1?c=ht(c.line+1,0):c=null);if(!c){if(i)return r?(e.cantEdit=!0,ht(e.first,0)):Ft(e,t,n,!0);i=!0,c=t,o=-o}}s=c;continue e}}return s}}function It(e){var t=e.display,n=e.doc,r={},i=r.cursors=document.createDocumentFragment(),s=r.selection=document.createDocumentFragment();for(var o=0;o<n.sel.ranges.length;o++){var u=n.sel.ranges[o],a=u.empty();(a||e.options.showCursorWhenSelecting)&&Ut(e,u,i),a||zt(e,u,s)}if(e.options.moveInputWithCursor){var f=gn(e,n.sel.primary().head,"div"),l=t.wrapper.getBoundingClientRect(),c=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,f.top+c.top-l.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,f.left+c.left-l.left))}return r}function qt(e,t){eu(e.display.cursorDiv,t.cursors),eu(e.display.selectionDiv,t.selection),t.teTop!=null&&(e.display.inputDiv.style.top=t.teTop+"px",e.display.inputDiv.style.left=t.teLeft+"px")}function Rt(e){qt(e,It(e))}function Ut(e,t,n){var r=gn(e,t.head,"div",null,null,!e.options.singleCursorHeightPerLine),i=n.appendChild(Go("div"," ","CodeMirror-cursor"));i.style.left=r.left+"px",i.style.top=r.top+"px",i.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px";if(r.other){var s=n.appendChild(Go("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));s.style.display="",s.style.left=r.other.left+"px",s.style.top=r.other.top+"px",s.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function zt(e,t,n){function f(e,t,n,r){t<0&&(t=0),t=Math.round(t),r=Math.round(r),s.appendChild(Go("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(n==null?a-e:n)+"px; height: "+(r-t)+"px"))}function l(t,n,r){function h(n,r){return mn(e,ht(t,n),"div",s,r)}var s=Us(i,t),o=s.text.length,l,c;return Tu(Ks(s),n||0,r==null?o:r,function(e,t,i){var s=h(e,"left"),p,d,v;if(e==t)p=s,d=v=s.left;else{p=h(t-1,"right");if(i=="rtl"){var m=s;s=p,p=m}d=s.left,v=p.right}n==null&&e==0&&(d=u),p.top-s.top>3&&(f(d,s.top,null,s.bottom),d=u,s.bottom<p.top&&f(d,s.bottom,null,p.top)),r==null&&t==o&&(v=a);if(!l||s.top<l.top||s.top==l.top&&s.left<l.left)l=s;if(!c||p.bottom>c.bottom||p.bottom==c.bottom&&p.right>c.right)c=p;d<u+1&&(d=u),f(d,p.top,v-d,p.bottom)}),{start:l,end:c}}var r=e.display,i=e.doc,s=document.createDocumentFragment(),o=Gt(e.display),u=o.left,a=r.lineSpace.offsetWidth-o.right,c=t.from(),h=t.to();if(c.line==h.line)l(c.line,c.ch,h.ch);else{var p=Us(i,c.line),d=Us(i,h.line),v=ts(p)==ts(d),m=l(c.line,c.ch,v?p.text.length+1:null).end,g=l(h.line,v?0:null,h.ch).start;v&&(m.top<g.top-2?(f(m.right,m.top,null,m.bottom),f(u,g.top,g.left,g.bottom)):f(m.right,m.top,g.left-m.right,m.bottom)),m.bottom<g.top&&f(u,m.bottom,null,g.top)}n.appendChild(s)}function Wt(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var n=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function Xt(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Wo(Vt,e))}function Vt(e){var t=e.doc;t.frontier<t.first&&(t.frontier=t.first);if(t.frontier>=e.display.viewTo)return;var n=+(new Date)+e.options.workTime,r=yi(t.mode,Jt(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(s){if(t.frontier>=e.display.viewFrom){var o=s.styles,u=bs(e,s,r,!0);s.styles=u.styles;var a=s.styleClasses,f=u.classes;f?s.styleClasses=f:a&&(s.styleClasses=null);var l=!o||o.length!=s.styles.length||a!=f&&(!a||!f||a.bgClass!=f.bgClass||a.textClass!=f.textClass);for(var c=0;!l&&c<o.length;++c)l=o[c]!=s.styles[c];l&&i.push(t.frontier),s.stateAfter=yi(t.mode,r)}else Es(e,s.text,r),s.stateAfter=t.frontier%5==0?yi(t.mode,r):null;++t.frontier;if(+(new Date)>n)return Xt(e,e.options.workDelay),!0}),i.length&&Bn(e,function(){for(var t=0;t<i.length;t++)zn(e,i[t],"text")})}function $t(e,t,n){var r,i,s=e.doc,o=n?-1:t-(e.doc.mode.innerMode?1e3:100);for(var u=t;u>o;--u){if(u<=s.first)return s.first;var a=Us(s,u-1);if(a.stateAfter&&(!n||u<=s.frontier))return u;var f=Po(a.text,null,e.options.tabSize);if(i==null||r>f)i=u-1,r=f}return i}function Jt(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return!0;var s=$t(e,t,n),o=s>r.first&&Us(r,s-1).stateAfter;return o?o=yi(r.mode,o):o=bi(r.mode),r.iter(s,t,function(n){Es(e,n.text,o);var u=s==t-1||s%5==0||s>=i.viewFrom&&s<i.viewTo;n.stateAfter=u?yi(r.mode,o):null,++s}),n&&(r.frontier=s),o}function Kt(e){return e.lineSpace.offsetTop}function Qt(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Gt(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=eu(e.measure,Go("pre","x")),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function Yt(e,t,n){var r=e.options.lineWrapping,i=r&&e.display.scroller.clientWidth;if(!t.measure.heights||r&&t.measure.width!=i){var s=t.measure.heights=[];if(r){t.measure.width=i;var o=t.text.firstChild.getClientRects();for(var u=0;u<o.length-1;u++){var a=o[u],f=o[u+1];Math.abs(a.bottom-f.bottom)>2&&s.push((a.bottom+f.top)/2-n.top)}}s.push(n.bottom-n.top)}}function Zt(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var r=0;r<e.rest.length;r++)if(Vs(e.rest[r])>n)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}function en(e,t){t=ts(t);var n=Vs(t),r=e.display.externalMeasured=new qn(e.doc,t,n);r.lineN=n;var i=r.built=Ns(e,r);return r.text=i.pre,eu(e.display.lineMeasure,i.pre),r}function tn(e,t,n,r){return sn(e,rn(e,t),n,r)}function nn(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Xn(e,t)];var n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size)return n}function rn(e,t){var n=Vs(t),r=nn(e,n);r&&!r.text?r=null:r&&r.changes&&et(e,r,n,Y(e)),r||(r=en(e,t));var i=Zt(r,t,n);return{line:t,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function sn(e,t,n,r,i){t.before&&(n=-1);var s=n+(r||""),o;return t.cache.hasOwnProperty(s)?o=t.cache[s]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Yt(e,t.view,t.rect),t.hasHeights=!0),o=un(e,t,n,r),o.bogus||(t.cache[s]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function un(e,t,n,s){var o=t.map,u,a,f,l;for(var c=0;c<o.length;c+=3){var h=o[c],p=o[c+1];if(n<h)a=0,f=1,l="left";else if(n<p)a=n-h,f=a+1;else if(c==o.length-3||n==p&&o[c+3]>n)f=p-h,a=f-1,n>=p&&(l="right");if(a!=null){u=o[c+2],h==p&&s==(u.insertLeft?"left":"right")&&(l=s);if(s=="left"&&a==0)while(c&&o[c-2]==o[c-3]&&o[c-1].insertLeft)u=o[(c-=3)+2],l="left";if(s=="right"&&a==p-h)while(c<o.length-3&&o[c+3]==o[c+4]&&!o[c+5].insertLeft)u=o[(c+=3)+2],l="right";break}}var d;if(u.nodeType==3){for(var c=0;c<4;c++){while(a&&Qo(t.line.text.charAt(h+a)))--a;while(h+f<p&&Qo(t.line.text.charAt(h+f)))++f;if(r&&i<9&&a==0&&f==p-h)d=u.parentNode.getBoundingClientRect();else if(r&&e.options.lineWrapping){var v=Yo(u,a,f).getClientRects();v.length?d=v[s=="right"?v.length-1:0]:d=on}else d=Yo(u,a,f).getBoundingClientRect()||on;if(d.left||d.right||a==0)break;f=a,a-=1,l="right"}r&&i<11&&(d=an(e.display.measure,d))}else{a>0&&(l=s="right");var v;e.options.lineWrapping&&(v=u.getClientRects()).length>1?d=v[s=="right"?v.length-1:0]:d=u.getBoundingClientRect()}if(r&&i<9&&!a&&(!d||!d.left&&!d.right)){var m=u.parentNode.getClientRects()[0];m?d={left:m.left,right:m.left+Tn(e.display),top:m.top,bottom:m.bottom}:d=on}var g=d.top-t.rect.top,y=d.bottom-t.rect.top,b=(g+y)/2,w=t.view.measure.heights;for(var c=0;c<w.length-1;c++)if(b<w[c])break;var E=c?w[c-1]:0,S=w[c],x={left:(l=="right"?d.right:d.left)-t.rect.left,right:(l=="left"?d.left:d.right)-t.rect.left,top:E,bottom:S};return!d.left&&!d.right&&(x.bogus=!0),e.options.singleCursorHeightPerLine||(x.rtop=g,x.rbottom=y),x}function an(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Su(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}function fn(e){if(e.measure){e.measure.cache={},e.measure.heights=null;if(e.rest)for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}}function ln(e){e.display.externalMeasure=null,Zo(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)fn(e.display.view[t])}function cn(e){ln(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function hn(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function pn(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function dn(e,t,n,r){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var s=fs(t.widgets[i]);n.top+=s,n.bottom+=s}if(r=="line")return n;r||(r="local");var o=Js(t);r=="local"?o+=Kt(e.display):o-=e.display.viewOffset;if(r=="page"||r=="window"){var u=e.display.lineSpace.getBoundingClientRect();o+=u.top+(r=="window"?0:pn());var a=u.left+(r=="window"?0:hn());n.left+=a,n.right+=a}return n.top+=o,n.bottom+=o,n}function vn(e,t,n){if(n=="div")return t;var r=t.left,i=t.top;if(n=="page")r-=hn(),i-=pn();else if(n=="local"||!n){var s=e.display.sizer.getBoundingClientRect();r+=s.left,i+=s.top}var o=e.display.lineSpace.getBoundingClientRect();return{left:r-o.left,top:i-o.top}}function mn(e,t,n,r,i){return r||(r=Us(e.doc,t.line)),dn(e,r,tn(e,r,t.ch,i),n)}function gn(e,t,n,r,i,s){function o(t,o){var u=sn(e,i,t,o?"right":"left",s);return o?u.left=u.right:u.right=u.left,dn(e,r,u,n)}function u(e,t){var n=a[t],r=n.level%2;return e==Nu(n)&&t&&n.level<a[t-1].level?(n=a[--t],e=Cu(n)-(n.level%2?0:1),r=!0):e==Cu(n)&&t<a.length-1&&n.level<a[t+1].level&&(n=a[++t],e=Nu(n)-n.level%2,r=!1),r&&e==n.to&&e>n.from?o(e-1):o(e,r)}r=r||Us(e.doc,t.line),i||(i=rn(e,r));var a=Ks(r),f=t.ch;if(!a)return o(f);var l=Pu(a,f),c=u(f,l);return Du!=null&&(c.other=u(f,Du)),c}function yn(e,t){var n=0,t=St(e.doc,t);e.options.lineWrapping||(n=Tn(e.display)*t.ch);var r=Us(e.doc,t.line),i=Js(r)+Kt(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function bn(e,t,n,r){var i=ht(e,t);return i.xRel=r,n&&(i.outside=!0),i}function wn(e,t,n){var r=e.doc;n+=e.display.viewOffset;if(n<0)return bn(r.first,0,!0,-1);var i=$s(r,n),s=r.first+r.size-1;if(i>s)return bn(r.first+r.size-1,Us(r,s).text.length,!0,1);t<0&&(t=0);var o=Us(r,i);for(;;){var u=En(e,o,i,t,n),a=Zi(o),f=a&&a.find(0,!0);if(!a||!(u.ch>f.from.ch||u.ch==f.from.ch&&u.xRel>0))return u;i=Vs(o=f.to.line)}}function En(e,t,n,r,i){function f(r){var i=gn(e,ht(n,r),"line",t,a);return o=!0,s>i.bottom?i.left-u:s<i.top?i.left+u:(o=!1,i.left)}var s=i-Js(t),o=!1,u=2*e.display.wrapper.clientWidth,a=rn(e,t),l=Ks(t),c=t.text.length,h=ku(t),p=Lu(t),d=f(h),v=o,m=f(p),g=o;if(r>m)return bn(n,p,g,1);for(;;){if(l?p==h||p==Bu(t,h,1):p-h<=1){var y=r<d||r-d<=m-r?h:p,b=r-(y==h?d:m);while(Qo(t.text.charAt(y)))++y;var w=bn(n,y,y==h?v:g,b<-1?-1:b>1?1:0);return w}var E=Math.ceil(c/2),S=h+E;if(l){S=h;for(var x=0;x<E;++x)S=Bu(t,S,1)}var T=f(S);if(T>r){p=S,m=T;if(g=o)m+=1e3;c=E}else h=S,d=T,v=o,c-=E}}function xn(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Sn==null){Sn=Go("pre");for(var t=0;t<49;++t)Sn.appendChild(document.createTextNode("x")),Sn.appendChild(Go("br"));Sn.appendChild(document.createTextNode("x"))}eu(e.measure,Sn);var n=Sn.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),Zo(e.measure),n||1}function Tn(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=Go("span","xxxxxxxxxx"),n=Go("pre",[t]);eu(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function kn(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++Cn},Nn?Nn.ops.push(e.curOp):e.curOp.ownsGroup=Nn={ops:[e.curOp],delayedCallbacks:[]}}function Ln(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++)t[n]();for(var r=0;r<e.ops.length;r++){var i=e.ops[r];if(i.cursorActivityHandlers)while(i.cursorActivityCalled<i.cursorActivityHandlers.length)i.cursorActivityHandlers[i.cursorActivityCalled++](i.cm)}}while(n<t.length)}function An(e){var t=e.curOp,n=t.ownsGroup;if(!n)return;try{Ln(n)}finally{Nn=null;for(var r=0;r<n.ops.length;r++)n.ops[r].cm.curOp=null;On(n)}}function On(e){var t=e.ops;for(var n=0;n<t.length;n++)Mn(t[n]);for(var n=0;n<t.length;n++)_n(t[n]);for(var n=0;n<t.length;n++)Dn(t[n]);for(var n=0;n<t.length;n++)Pn(t[n]);for(var n=0;n<t.length;n++)Hn(t[n])}function Mn(e){var t=e.cm,n=t.display;e.updateMaxLine&&P(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<n.viewFrom||e.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new W(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function _n(e){e.updatedDisplay=e.mustUpdate&&X(e.cm,e.update)}function Dn(e){var t=e.cm,n=t.display;e.updatedDisplay&&Q(t),e.barMeasure=j(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=tn(t,n.maxLine,n.maxLine.text.length).left+3,e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo+Lo-n.scroller.clientWidth));if(e.updatedDisplay||e.selectionChanged)e.newSelectionNodes=It(t)}function Pn(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&br(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.newSelectionNodes&&qt(t,e.newSelectionNodes),e.updatedDisplay&&J(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&F(t,e.barMeasure),e.selectionChanged&&Wt(t),t.state.focused&&e.updateInput&&Zn(t,e.typing)}function Hn(e){var t=e.cm,n=t.display,r=t.doc;e.adjustWidthTo!=null&&Math.abs(e.barMeasure.scrollWidth-t.display.scroller.scrollWidth)>1&&F(t),e.updatedDisplay&&V(t,e.update),n.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(n.wheelStartX=n.wheelStartY=null);if(e.scrollTop!=null&&(n.scroller.scrollTop!=e.scrollTop||e.forceScroll)){var i=Math.max(0,Math.min(n.scroller.scrollHeight-n.scroller.clientHeight,e.scrollTop));n.scroller.scrollTop=n.scrollbarV.scrollTop=r.scrollTop=i}if(e.scrollLeft!=null&&(n.scroller.scrollLeft!=e.scrollLeft||e.forceScroll)){var o=Math.max(0,Math.min(n.scroller.scrollWidth-n.scroller.clientWidth,e.scrollLeft));n.scroller.scrollLeft=n.scrollbarH.scrollLeft=r.scrollLeft=o,q(t)}if(e.scrollToPos){var u=Yr(t,St(r,e.scrollToPos.from),St(r,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&Gr(t,u)}var a=e.maybeHiddenMarkers,f=e.maybeUnhiddenMarkers;if(a)for(var l=0;l<a.length;++l)a[l].lines.length||wo(a[l],"hide");if(f)for(var l=0;l<f.length;++l)f[l].lines.length&&wo(f[l],"unhide");n.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.updatedDisplay&&s&&(t.options.lineWrapping&&K(t,e.barMeasure),e.barMeasure.scrollWidth>e.barMeasure.clientWidth&&e.barMeasure.scrollWidth<e.barMeasure.clientWidth+1&&!B(t)&&F(t)),e.changeObjs&&wo(t,"changes",t,e.changeObjs)}function Bn(e,t){if(e.curOp)return t();kn(e);try{return t()}finally{An(e)}}function jn(e,t){return function(){if(e.curOp)return t.apply(e,arguments);kn(e);try{return t.apply(e,arguments)}finally{An(e)}}}function Fn(e){return function(){if(this.curOp)return e.apply(this,arguments);kn(this);try{return e.apply(this,arguments)}finally{An(this)}}}function In(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);kn(t);try{return e.apply(this,arguments)}finally{An(t)}}}function qn(e,t,n){this.line=t,this.rest=ns(t),this.size=this.rest?Vs(Fo(this.rest))-n+1:1,this.node=this.text=null,this.hidden=ss(e,t)}function Rn(e,t,n){var r=[],i;for(var s=t;s<n;s=i){var o=new qn(e.doc,Us(e.doc,s),s);i=s+o.size,r.push(o)}return r}function Un(e,t,n,r){t==null&&(t=e.doc.first),n==null&&(n=e.doc.first+e.doc.size),r||(r=0);var i=e.display;r&&n<i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0;if(t>=i.viewTo)E&&rs(e.doc,t)<i.viewTo&&Wn(e);else if(n<=i.viewFrom)E&&is(e.doc,n+r)>i.viewFrom?Wn(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)Wn(e);else if(t<=i.viewFrom){var s=Vn(e,n,n+r,1);s?(i.view=i.view.slice(s.index),i.viewFrom=s.lineN,i.viewTo+=r):Wn(e)}else if(n>=i.viewTo){var s=Vn(e,t,t,-1);s?(i.view=i.view.slice(0,s.index),i.viewTo=s.lineN):Wn(e)}else{var o=Vn(e,t,t,-1),u=Vn(e,n,n+r,1);o&&u?(i.view=i.view.slice(0,o.index).concat(Rn(e,o.lineN,u.lineN)).concat(i.view.slice(u.index)),i.viewTo+=r):Wn(e)}var a=i.externalMeasured;a&&(n<a.lineN?a.lineN+=r:t<a.lineN+a.size&&(i.externalMeasured=null))}function zn(e,t,n){e.curOp.viewChanged=!0;var r=e.display,i=e.display.externalMeasured;i&&t>=i.lineN&&t<i.lineN+i.size&&(r.externalMeasured=null);if(t<r.viewFrom||t>=r.viewTo)return;var s=r.view[Xn(e,t)];if(s.node==null)return;var o=s.changes||(s.changes=[]);qo(o,n)==-1&&o.push(n)}function Wn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Xn(e,t){if(t>=e.display.viewTo)return null;t-=e.display.viewFrom;if(t<0)return null;var n=e.display.view;for(var r=0;r<n.length;r++){t-=n[r].size;if(t<0)return r}}function Vn(e,t,n,r){var i=Xn(e,t),s,o=e.display.view;if(!E||n==e.doc.first+e.doc.size)return{index:i,lineN:n};for(var u=0,a=e.display.viewFrom;u<i;u++)a+=o[u].size;if(a!=t){if(r>0){if(i==o.length-1)return null;s=a+o[i].size-t,i++}else s=a-t;t+=s,n+=s}while(rs(e.doc,n)!=n){if(i==(r<0?0:o.length-1))return null;n+=r*o[i-(r<0?1:0)].size,i+=r}return{index:i,lineN:n}}function $n(e,t,n){var r=e.display,i=r.view;i.length==0||t>=r.viewTo||n<=r.viewFrom?(r.view=Rn(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=Rn(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Xn(e,t))),r.viewFrom=t,r.viewTo<n?r.view=r.view.concat(Rn(e,r.viewTo,n)):r.viewTo>n&&(r.view=r.view.slice(0,Xn(e,n)))),r.viewTo=n}function Jn(e){var t=e.display.view,n=0;for(var r=0;r<t.length;r++){var i=t[r];!i.hidden&&(!i.node||i.changes)&&++n}return n}function Kn(e){if(e.display.pollingFast)return;e.display.poll.set(e.options.pollInterval,function(){Yn(e),e.state.focused&&Kn(e)})}function Qn(e){function n(){var r=Yn(e);!r&&!t?(t=!0,e.display.poll.set(60,n)):(e.display.pollingFast=!1,Kn(e))}var t=!1;e.display.pollingFast=!0,e.display.poll.set(20,n)}function Yn(e){var t=e.display.input,n=e.display.prevInput,s=e.doc;if(!e.state.focused||bu(t)&&!n||nr(e)||e.options.disableInput||e.state.keySeq)return!1;e.state.pasteIncoming&&e.state.fakedLastChar&&(t.value=t.value.substring(0,t.value.length-1),e.state.fakedLastChar=!1);var o=t.value;if(o==n&&!e.somethingSelected())return!1;if(r&&i>=9&&e.display.inputHasSelection===o||v&&/[\uf700-\uf7ff]/.test(o))return Zn(e),!1;var u=!e.curOp;u&&kn(e),e.display.shift=!1,o.charCodeAt(0)==8203&&s.sel==e.display.selForContextMenu&&!n&&(n="​");var a=0,f=Math.min(n.length,o.length);while(a<f&&n.charCodeAt(a)==o.charCodeAt(a))++a;var l=o.slice(a),c=yu(l),h=null;e.state.pasteIncoming&&s.sel.ranges.length>1&&(Gn&&Gn.join("\n")==l?h=s.sel.ranges.length%Gn.length==0&&Ro(Gn,yu):c.length==s.sel.ranges.length&&(h=Ro(c,function(e){return[e]})));for(var p=s.sel.ranges.length-1;p>=0;p--){var d=s.sel.ranges[p],m=d.from(),g=d.to();a<n.length?m=ht(m.line,m.ch-(n.length-a)):e.state.overwrite&&d.empty()&&!e.state.pasteIncoming&&(g=ht(g.line,Math.min(Us(s,g.line).text.length,g.ch+Fo(c).length)));var y=e.curOp.updateInput,b={from:m,to:g,text:h?h[p%h.length]:c,origin:e.state.pasteIncoming?"paste":e.state.cutIncoming?"cut":"+input"};Wr(e.doc,b),So(e,"inputRead",e,b);if(l&&!e.state.pasteIncoming&&e.options.electricChars&&e.options.smartIndent&&d.head.ch<100&&(!p||s.sel.ranges[p-1].head.line!=d.head.line)){var w=e.getModeAt(d.head),E=Fr(b);if(w.electricChars){for(var S=0;S<w.electricChars.length;S++)if(l.indexOf(w.electricChars.charAt(S))>-1){ii(e,E.line,"smart");break}}else w.electricInput&&w.electricInput.test(Us(s,E.line).text.slice(0,E.ch))&&ii(e,E.line,"smart")}}return ni(e),e.curOp.updateInput=y,e.curOp.typing=!0,o.length>1e3||o.indexOf("\n")>-1?t.value=e.display.prevInput="":e.display.prevInput=o,u&&An(e),e.state.pasteIncoming=e.state.cutIncoming=!1,!0}function Zn(e,t){var n,s,o=e.doc;if(e.somethingSelected()){e.display.prevInput="";var u=o.sel.primary();n=wu&&(u.to().line-u.from().line>100||(s=e.getSelection()).length>1e3);var a=n?"-":s||e.getSelection();e.display.input.value=a,e.state.focused&&Io(e.display.input),r&&i>=9&&(e.display.inputHasSelection=a)}else t||(e.display.prevInput=e.display.input.value="",r&&i>=9&&(e.display.inputHasSelection=null));e.display.inaccurateSelection=n}function er(e){e.options.readOnly!="nocursor"&&(!d||nu()!=e.display.input)&&e.display.input.focus()}function tr(e){e.state.focused||(er(e),Pr(e))}function nr(e){return e.options.readOnly||e.doc.cantEdit}function rr(e){function n(){e.state.focused&&setTimeout(Wo(er,e),0)}function o(t){To(e,t)||vo(t)}function u(n){if(e.somethingSelected())Gn=e.getSelections(),t.inaccurateSelection&&(t.prevInput="",t.inaccurateSelection=!1,t.input.value=Gn.join("\n"),Io(t.input));else{var r=[],i=[];for(var s=0;s<e.doc.sel.ranges.length;s++){var o=e.doc.sel.ranges[s].head.line,u={anchor:ht(o,0),head:ht(o+1,0)};i.push(u),r.push(e.getRange(u.anchor,u.head))}n.type=="cut"?e.setSelections(i,null,Oo):(t.prevInput="",t.input.value=r.join("\n"),Io(t.input)),Gn=r}n.type=="cut"&&(e.state.cutIncoming=!0)}var t=e.display;yo(t.scroller,"mousedown",jn(e,ur)),r&&i<11?yo(t.scroller,"dblclick",jn(e,function(t){if(To(e,t))return;var n=or(e,t);if(!n||dr(e,t)||sr(e.display,t))return;co(t);var r=e.findWordAt(n);kt(e.doc,r.anchor,r.head)})):yo(t.scroller,"dblclick",function(t){To(e,t)||co(t)}),yo(t.lineSpace,"selectstart",function(e){sr(t,e)||co(e)}),b||yo(t.scroller,"contextmenu",function(t){Br(e,t)}),yo(t.scroller,"scroll",function(){t.scroller.clientHeight&&(yr(e,t.scroller.scrollTop),br(e,t.scroller.scrollLeft,!0),wo(e,"scroll",e))}),yo(t.scrollbarV,"scroll",function(){t.scroller.clientHeight&&yr(e,t.scrollbarV.scrollTop)}),yo(t.scrollbarH,"scroll",function(){t.scroller.clientHeight&&br(e,t.scrollbarH.scrollLeft)}),yo(t.scroller,"mousewheel",function(t){Sr(e,t)}),yo(t.scroller,"DOMMouseScroll",function(t){Sr(e,t)}),yo(t.scrollbarH,"mousedown",n),yo(t.scrollbarV,"mousedown",n),yo(t.wrapper,"scroll",function(){t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),yo(t.input,"keyup",function(t){_r.call(e,t)}),yo(t.input,"input",function(){r&&i>=9&&e.display.inputHasSelection&&(e.display.inputHasSelection=null),Qn(e)}),yo(t.input,"keydown",jn(e,Or)),yo(t.input,"keypress",jn(e,Dr)),yo(t.input,"focus",Wo(Pr,e)),yo(t.input,"blur",Wo(Hr,e)),e.options.dragDrop&&(yo(t.scroller,"dragstart",function(t){gr(e,t)}),yo(t.scroller,"dragenter",o),yo(t.scroller,"dragover",o),yo(t.scroller,"drop",jn(e,mr))),yo(t.scroller,"paste",function(n){if(sr(t,n))return;e.state.pasteIncoming=!0,er(e),Qn(e)}),yo(t.input,"paste",function(){if(s&&!e.state.fakedLastChar&&!(new Date-e.state.lastMiddleDown<200)){var n=t.input.selectionStart,r=t.input.selectionEnd;t.input.value+="$",t.input.selectionEnd=r,t.input.selectionStart=n,e.state.fakedLastChar=!0}e.state.pasteIncoming=!0,Qn(e)}),yo(t.input,"cut",u),yo(t.input,"copy",u),l&&yo(t.sizer,"mouseup",function(){nu()==t.input&&t.input.blur(),er(e)})}function ir(e){var t=e.display;if(t.lastWrapHeight==t.wrapper.clientHeight&&t.lastWrapWidth==t.wrapper.clientWidth)return;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,e.setSize()}function sr(e,t){for(var n=mo(t);n!=e.wrapper;n=n.parentNode)if(!n||n.ignoreEvents||n.parentNode==e.sizer&&n!=e.mover)return!0}function or(e,t,n,r){var i=e.display;if(!n){var s=mo(t);if(s==i.scrollbarH||s==i.scrollbarV||s==i.scrollbarFiller||s==i.gutterFiller)return null}var o,u,a=i.lineSpace.getBoundingClientRect();try{o=t.clientX-a.left,u=t.clientY-a.top}catch(t){return null}var f=wn(e,o,u),l;if(r&&f.xRel==1&&(l=Us(e.doc,f.line).text).length==f.ch){var c=Po(l,l.length,e.options.tabSize)-l.length;f=ht(f.line,Math.max(0,Math.round((o-Gt(e.display).left)/Tn(e.display))-c))}return f}function ur(e){if(To(this,e))return;var t=this,n=t.display;n.shift=e.shiftKey;if(sr(n,e)){s||(n.scroller.draggable=!1,setTimeout(function(){n.scroller.draggable=!0},100));return}if(dr(t,e))return;var r=or(t,e);window.focus();switch(go(e)){case 1:r?lr(t,e,r):mo(e)==n.scroller&&co(e);break;case 2:s&&(t.state.lastMiddleDown=+(new Date)),r&&kt(t.doc,r),setTimeout(Wo(er,t),20),co(e);break;case 3:b&&Br(t,e)}}function lr(e,t,n){setTimeout(Wo(tr,e),0);var r=+(new Date),i;fr&&fr.time>r-400&&pt(fr.pos,n)==0?i="triple":ar&&ar.time>r-400&&pt(ar.pos,n)==0?(i="double",fr={time:r,pos:n}):(i="single",ar={time:r,pos:n});var s=e.doc.sel,o=v?t.metaKey:t.ctrlKey;e.options.dragDrop&&cu&&!nr(e)&&i=="single"&&s.contains(n)>-1&&s.somethingSelected()?cr(e,t,n,o):hr(e,t,n,i,o)}function cr(e,t,n,o){var u=e.display,a=jn(e,function(f){s&&(u.scroller.draggable=!1),e.state.draggingText=!1,bo(document,"mouseup",a),bo(u.scroller,"drop",a),Math.abs(t.clientX-f.clientX)+Math.abs(t.clientY-f.clientY)<10&&(co(f),o||kt(e.doc,n),er(e),r&&i==9&&setTimeout(function(){document.body.focus(),er(e)},20))});s&&(u.scroller.draggable=!0),e.state.draggingText=a,u.scroller.dragDrop&&u.scroller.dragDrop(),yo(document,"mouseup",a),yo(u.scroller,"drop",a)}function hr(e,t,n,r,i){function p(t){if(pt(h,t)==0)return;h=t;if(r=="rect"){var i=[],s=e.options.tabSize,l=Po(Us(o,n.line).text,n.ch,s),c=Po(Us(o,t.line).text,t.ch,s),p=Math.min(l,c),d=Math.max(l,c);for(var v=Math.min(n.line,t.line),m=Math.min(e.lastLine(),Math.max(n.line,t.line));v<=m;v++){var g=Us(o,v).text,y=Ho(g,p,s);p==d?i.push(new yt(ht(v,y),ht(v,y))):g.length>y&&i.push(new yt(ht(v,y),ht(v,Ho(g,d,s))))}i.length||i.push(new yt(n,n)),Dt(o,bt(f.ranges.slice(0,a).concat(i),a),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=u,w=b.anchor,E=t;if(r!="single"){if(r=="double")var S=e.findWordAt(t);else var S=new yt(ht(t.line,0),St(o,ht(t.line+1,0)));pt(S.anchor,w)>0?(E=S.head,w=mt(b.from(),S.anchor)):(E=S.anchor,w=vt(b.to(),S.head))}var i=f.ranges.slice(0);i[a]=new yt(St(o,w),E),Dt(o,bt(i,a),Mo)}}function m(t){var n=++v,i=or(e,t,!0,r=="rect");if(!i)return;if(pt(i,h)!=0){tr(e),p(i);var u=I(s,o);(i.line>=u.to||i.line<u.from)&&setTimeout(jn(e,function(){v==n&&m(t)}),150)}else{var a=t.clientY<d.top?-20:t.clientY>d.bottom?20:0;a&&setTimeout(jn(e,function(){if(v!=n)return;s.scroller.scrollTop+=a,m(t)}),50)}}function g(t){v=Infinity,co(t),er(e),bo(document,"mousemove",y),bo(document,"mouseup",b),o.history.lastSelOrigin=null}var s=e.display,o=e.doc;co(t);var u,a,f=o.sel;i&&!t.shiftKey?(a=o.sel.contains(n),a>-1?u=o.sel.ranges[a]:u=new yt(n,n)):u=o.sel.primary();if(t.altKey)r="rect",i||(u=new yt(n,n)),n=or(e,t,!0,!0),a=-1;else if(r=="double"){var l=e.findWordAt(n);e.display.shift||o.extend?u=Ct(o,u,l.anchor,l.head):u=l}else if(r=="triple"){var c=new yt(ht(n.line,0),St(o,ht(n.line+1,0)));e.display.shift||o.extend?u=Ct(o,u,c.anchor,c.head):u=c}else u=Ct(o,u,n);i?a>-1?At(o,a,u,Mo):(a=o.sel.ranges.length,Dt(o,bt(o.sel.ranges.concat([u]),a),{scroll:!1,origin:"*mouse"})):(a=0,Dt(o,new gt([u],0),Mo),f=o.sel);var h=n,d=s.wrapper.getBoundingClientRect(),v=0,y=jn(e,function(e){go(e)?m(e):g(e)}),b=jn(e,g);yo(document,"mousemove",y),yo(document,"mouseup",b)}function pr(e,t,n,r,i){try{var s=t.clientX,o=t.clientY}catch(t){return!1}if(s>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&co(t);var u=e.display,a=u.lineDiv.getBoundingClientRect();if(o>a.bottom||!Co(e,n))return po(t);o-=a.top-u.viewOffset;for(var f=0;f<e.options.gutters.length;++f){var l=u.gutters.childNodes[f];if(l&&l.getBoundingClientRect().right>=s){var c=$s(e.doc,o),h=e.options.gutters[f];return i(e,n,e,c,h,t),po(t)}}}function dr(e,t){return pr(e,t,"gutterClick",!0,So)}function mr(e){var t=this;if(To(t,e)||sr(t.display,e))return;co(e),r&&(vr=+(new Date));var n=or(t,e,!0),i=e.dataTransfer.files;if(!n||nr(t))return;if(i&&i.length&&window.FileReader&&window.File){var s=i.length,o=Array(s),u=0,a=function(e,r){var i=new FileReader;i.onload=jn(t,function(){o[r]=i.result;if(++u==s){n=St(t.doc,n);var e={from:n,to:n,text:yu(o.join("\n")),origin:"paste"};Wr(t.doc,e),_t(t.doc,wt(n,Fr(e)))}}),i.readAsText(e)};for(var f=0;f<s;++f)a(i[f],f)}else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1){t.state.draggingText(e),setTimeout(Wo(er,t),20);return}try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&(v?!e.metaKey:!e.ctrlKey))var l=t.listSelections();Pt(t.doc,wt(n,n));if(l)for(var f=0;f<l.length;++f)Qr(t.doc,"",l[f].anchor,l[f].head,"drag");t.replaceSelection(o,"around","paste"),er(t)}}catch(e){}}}function gr(e,t){if(r&&(!e.state.draggingText||+(new Date)-vr<100)){vo(t);return}if(To(e,t)||sr(e.display,t))return;t.dataTransfer.setData("Text",e.getSelection());if(t.dataTransfer.setDragImage&&!f){var n=Go("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",a&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),a&&n.parentNode.removeChild(n)}}function yr(t,n){if(Math.abs(t.doc.scrollTop-n)<2)return;t.doc.scrollTop=n,e||$(t,{top:n}),t.display.scroller.scrollTop!=n&&(t.display.scroller.scrollTop=n),t.display.scrollbarV.scrollTop!=n&&(t.display.scrollbarV.scrollTop=n),e&&$(t),Xt(t,100)}function br(e,t,n){if(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)return;t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,q(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbarH.scrollLeft!=t&&(e.display.scrollbarH.scrollLeft=t)}function Sr(t,n){var r=n.wheelDeltaX,i=n.wheelDeltaY;r==null&&n.detail&&n.axis==n.HORIZONTAL_AXIS&&(r=n.detail),i==null&&n.detail&&n.axis==n.VERTICAL_AXIS?i=n.detail:i==null&&(i=n.wheelDelta);var o=t.display,u=o.scroller;if(!(r&&u.scrollWidth>u.clientWidth||i&&u.scrollHeight>u.clientHeight))return;if(i&&v&&s)e:for(var f=n.target,l=o.view;f!=u;f=f.parentNode)for(var c=0;c<l.length;c++)if(l[c].node==f){t.display.currentWheelTarget=f;break e}if(r&&!e&&!a&&Er!=null){i&&yr(t,Math.max(0,Math.min(u.scrollTop+i*Er,u.scrollHeight-u.clientHeight))),br(t,Math.max(0,Math.min(u.scrollLeft+r*Er,u.scrollWidth-u.clientWidth))),co(n),o.wheelStartX=null;return}if(i&&Er!=null){var h=i*Er,p=t.doc.scrollTop,d=p+o.wrapper.clientHeight;h<0?p=Math.max(0,p+h-50):d=Math.min(t.doc.height,d+h+50),$(t,{top:p,bottom:d})}wr<20&&(o.wheelStartX==null?(o.wheelStartX=u.scrollLeft,o.wheelStartY=u.scrollTop,o.wheelDX=r,o.wheelDY=i,setTimeout(function(){if(o.wheelStartX==null)return;var e=u.scrollLeft-o.wheelStartX,t=u.scrollTop-o.wheelStartY,n=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null;if(!n)return;Er=(Er*wr+n)/(wr+1),++wr},200)):(o.wheelDX+=r,o.wheelDY+=i))}function xr(e,t,n){if(typeof t=="string"){t=wi[t];if(!t)return!1}e.display.pollingFast&&Yn(e)&&(e.display.pollingFast=!1);var r=e.display.shift,i=!1;try{nr(e)&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),i=t(e)!=Ao}finally{e.display.shift=r,e.state.suppressEdits=!1}return i}function Tr(e,t,n){for(var r=0;r<e.state.keyMaps.length;r++){var i=xi(t,e.state.keyMaps[r],n);if(i)return i}return e.options.extraKeys&&xi(t,e.options.extraKeys,n)||xi(t,e.options.keyMap,n)}function Cr(e,t,n,r){var i=e.state.keySeq;if(i){if(Ti(t))return"handled";Nr.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,Zn(e))}),t=i+" "+t}var s=Tr(e,t,r);s=="multi"&&(e.state.keySeq=t),s=="handled"&&So(e,"keyHandled",e,t,n);if(s=="handled"||s=="multi")co(n),Wt(e);return i&&!s&&/\'$/.test(t)?(co(n),!0):!!s}function kr(e,t){var n=Ni(t,!0);return n?t.shiftKey&&!e.state.keySeq?Cr(e,"Shift-"+n,t,function(t){return xr(e,t,!0)})||Cr(e,n,t,function(t){if(typeof t=="string"?/^go[A-Z]/.test(t):t.motion)return xr(e,t)}):Cr(e,n,t,function(t){return xr(e,t)}):!1}function Lr(e,t,n){return Cr(e,"'"+n+"'",t,function(t){return xr(e,t,!0)})}function Or(e){var t=this;tr(t);if(To(t,e))return;r&&i<11&&e.keyCode==27&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=n==16||e.shiftKey;var s=kr(t,e);a&&(Ar=s?n:null,!s&&n==88&&!wu&&(v?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),n==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Mr(t)}function Mr(e){function n(e){if(e.keyCode==18||!e.altKey)iu(t,"CodeMirror-crosshair"),bo(document,"keyup",n),bo(document,"mouseover",n)}var t=e.display.lineDiv;su(t,"CodeMirror-crosshair"),yo(document,"keyup",n),yo(document,"mouseover",n)}function _r(e){e.keyCode==16&&(this.doc.sel.shift=!1),To(this,e)}function Dr(e){var t=this;if(To(t,e)||e.ctrlKey&&!e.altKey||v&&e.metaKey)return;var n=e.keyCode,s=e.charCode;if(a&&n==Ar){Ar=null,co(e);return}if((a&&(!e.which||e.which<10)||l)&&kr(t,e))return;var o=String.fromCharCode(s==null?n:s);if(Lr(t,e,o))return;r&&i>=9&&(t.display.inputHasSelection=null),Qn(t)}function Pr(e){if(e.options.readOnly=="nocursor")return;e.state.focused||(wo(e,"focus",e),e.state.focused=!0,su(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(Zn(e),s&&setTimeout(Wo(Zn,e,!0),0))),Kn(e),Wt(e)}function Hr(e){e.state.focused&&(wo(e,"blur",e),e.state.focused=!1,iu(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Br(e,t){function h(){if(n.input.selectionStart!=null){var t=e.somethingSelected(),r=n.input.value="​"+(t?n.input.value:"");n.prevInput=t?"":"​",n.input.selectionStart=1,n.input.selectionEnd=r.length,n.selForContextMenu=e.doc.sel}}function p(){n.inputDiv.style.position="relative",n.input.style.cssText=l,r&&i<9&&(n.scrollbarV.scrollTop=n.scroller.scrollTop=u),Kn(e);if(n.input.selectionStart!=null){(!r||r&&i<9)&&h();var t=0,s=function(){n.selForContextMenu==e.doc.sel&&n.input.selectionStart==0?jn(e,wi.selectAll)(e):t++<10?n.detectingSelectAll=setTimeout(s,500):Zn(e)};n.detectingSelectAll=setTimeout(s,200)}}if(To(e,t,"contextmenu"))return;var n=e.display;if(sr(n,t)||jr(e,t))return;var o=or(e,t),u=n.scroller.scrollTop;if(!o||a)return;var f=e.options.resetSelectionOnContextMenu;f&&e.doc.sel.contains(o)==-1&&jn(e,Dt)(e.doc,wt(o),Oo);var l=n.input.style.cssText;n.inputDiv.style.position="absolute",n.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(t.clientY-5)+"px; left: "+(t.clientX-5)+"px; z-index: 1000; background: "+(r?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";if(s)var c=window.scrollY;er(e),s&&window.scrollTo(null,c),Zn(e),e.somethingSelected()||(n.input.value=n.prevInput=" "),n.selForContextMenu=e.doc.sel,clearTimeout(n.detectingSelectAll),r&&i>=9&&h();if(b){vo(t);var d=function(){bo(window,"mouseup",d),setTimeout(p,20)};yo(window,"mouseup",d)}else setTimeout(p,50)}function jr(e,t){return Co(e,"gutterContextMenu")?pr(e,t,"gutterContextMenu",!1,wo):!1}function Ir(e,t){if(pt(e,t.from)<0)return e;if(pt(e,t.to)<=0)return Fr(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Fr(t).ch-t.to.ch),ht(n,r)}function qr(e,t){var n=[];for(var r=0;r<e.sel.ranges.length;r++){var i=e.sel.ranges[r];n.push(new yt(Ir(i.anchor,t),Ir(i.head,t)))}return bt(n,e.sel.primIndex)}function Rr(e,t,n){return e.line==t.line?ht(n.line,e.ch-t.ch+n.ch):ht(n.line+(e.line-t.line),e.ch)}function Ur(e,t,n){var r=[],i=ht(e.first,0),s=i;for(var o=0;o<t.length;o++){var u=t[o],a=Rr(u.from,i,s),f=Rr(Fr(u),i,s);i=u.to,s=f;if(n=="around"){var l=e.sel.ranges[o],c=pt(l.head,l.anchor)<0;r[o]=new yt(c?f:a,c?a:f)}else r[o]=new yt(a,a)}return new gt(r,e.sel.primIndex)}function zr(e,t,n){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return n&&(r.update=function(t,n,r,i){t&&(this.from=St(e,t)),n&&(this.to=St(e,n)),r&&(this.text=r),i!==undefined&&(this.origin=i)}),wo(e,"beforeChange",e,r),e.cm&&wo(e.cm,"beforeChange",e.cm,r),r.canceled?null:{from:r.from,to:r.to,text:r.text,origin:r.origin}}function Wr(e,t,n){if(e.cm){if(!e.cm.curOp)return jn(e.cm,Wr)(e,t,n);if(e.cm.state.suppressEdits)return}if(Co(e,"beforeChange")||e.cm&&Co(e.cm,"beforeChange")){t=zr(e,t,!0);if(!t)return}var r=w&&!n&&Xi(e,t.from,t.to);if(r)for(var i=r.length-1;i>=0;--i)Xr(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text});else Xr(e,t)}function Xr(e,t){if(t.text.length==1&&t.text[0]==""&&pt(t.from,t.to)==0)return;var n=qr(e,t);eo(e,t,n,e.cm?e.cm.curOp.id:NaN),Jr(e,t,n,Ui(e,t));var r=[];qs(e,function(e,n){!n&&qo(r,e.history)==-1&&(lo(e.history,t),r.push(e.history)),Jr(e,t,null,Ui(e,t))})}function Vr(e,t,n){if(e.cm&&e.cm.state.suppressEdits)return;var r=e.history,i,s=e.sel,o=t=="undo"?r.done:r.undone,u=t=="undo"?r.undone:r.done;for(var a=0;a<o.length;a++){i=o[a];if(n?i.ranges&&!i.equals(e.sel):!i.ranges)break}if(a==o.length)return;r.lastOrigin=r.lastSelOrigin=null;for(;;){i=o.pop();if(!i.ranges)break;ro(i,u);if(n&&!i.equals(e.sel)){Dt(e,i,{clearRedo:!1});return}s=i}var f=[];ro(s,u),u.push({changes:f,generation:r.generation}),r.generation=i.generation||++r.maxGeneration;var l=Co(e,"beforeChange")||e.cm&&Co(e.cm,"beforeChange");for(var a=i.changes.length-1;a>=0;--a){var c=i.changes[a];c.origin=t;if(l&&!zr(e,c,!1)){o.length=0;return}f.push(Gs(e,c));var h=a?qr(e,c):Fo(o);Jr(e,c,h,Wi(e,c)),!a&&e.cm&&e.cm.scrollIntoView({from:c.from,to:Fr(c)});var p=[];qs(e,function(e,t){!t&&qo(p,e.history)==-1&&(lo(e.history,c),p.push(e.history)),Jr(e,c,null,Wi(e,c))})}}function $r(e,t){if(t==0)return;e.first+=t,e.sel=new gt(Ro(e.sel.ranges,function(e){return new yt(ht(e.anchor.line+t,e.anchor.ch),ht(e.head.line+t,e.head.ch))}),e.sel.primIndex);if(e.cm){Un(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;r<n.viewTo;r++)zn(e.cm,r,"gutter")}}function Jr(e,t,n,r){if(e.cm&&!e.cm.curOp)return jn(e.cm,Jr)(e,t,n,r);if(t.to.line<e.first){$r(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine())return;if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);$r(e,i),t={from:ht(e.first,0),to:ht(t.to.line+i,t.to.ch),text:[Fo(t.text)],origin:t.origin}}var s=e.lastLine();t.to.line>s&&(t={from:t.from,to:ht(s,Us(e,s).text.length),text:[t.text[0]],origin:t.origin}),t.removed=zs(e,t.from,t.to),n||(n=qr(e,t)),e.cm?Kr(e.cm,t,r):Ds(e,t,r),Pt(e,n,Oo)}function Kr(e,t,n){var r=e.doc,i=e.display,s=t.from,o=t.to,u=!1,a=s.line;e.options.lineWrapping||(a=Vs(ts(Us(r,s.line))),r.iter(a,o.line+1,function(e){if(e==i.maxLine)return u=!0,!0})),r.sel.contains(t.from,t.to)>-1&&No(e),Ds(r,t,n,k(e)),e.options.lineWrapping||(r.iter(a,s.line+t.text.length,function(e){var t=D(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,u=!1)}),u&&(e.curOp.updateMaxLine=!0)),r.frontier=Math.min(r.frontier,s.line),Xt(e,400);var f=t.text.length-(o.line-s.line)-1;s.line==o.line&&t.text.length==1&&!_s(e.doc,t)?zn(e,s.line,"text"):Un(e,s.line,o.line+1,f);var l=Co(e,"changes"),c=Co(e,"change");if(c||l){var h={from:s,to:o,text:t.text,removed:t.removed,origin:t.origin};c&&So(e,"change",e,h),l&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function Qr(e,t,n,r,i){r||(r=n);if(pt(r,n)<0){var s=r;r=n,n=s}typeof t=="string"&&(t=yu(t)),Wr(e,{from:n,to:r,text:t,origin:i})}function Gr(e,t){if(To(e,"scrollCursorIntoView"))return;var n=e.display,r=n.sizer.getBoundingClientRect(),i=null;t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1);if(i!=null&&!h){var s=Go("div","​",null,"position: absolute; top: "+(t.top-n.viewOffset-Kt(e.display))+"px; height: "+(t.bottom-t.top+Lo)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(s),s.scrollIntoView(i),e.display.lineSpace.removeChild(s)}}function Yr(e,t,n,r){r==null&&(r=0);for(var i=0;i<5;i++){var s=!1,o=gn(e,t),u=!n||n==t?o:gn(e,n),a=ei(e,Math.min(o.left,u.left),Math.min(o.top,u.top)-r,Math.max(o.left,u.left),Math.max(o.bottom,u.bottom)+r),f=e.doc.scrollTop,l=e.doc.scrollLeft;a.scrollTop!=null&&(yr(e,a.scrollTop),Math.abs(e.doc.scrollTop-f)>1&&(s=!0)),a.scrollLeft!=null&&(br(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-l)>1&&(s=!0));if(!s)return o}}function Zr(e,t,n,r,i){var s=ei(e,t,n,r,i);s.scrollTop!=null&&yr(e,s.scrollTop),s.scrollLeft!=null&&br(e,s.scrollLeft)}function ei(e,t,n,r,i){var s=e.display,o=xn(e.display);n<0&&(n=0);var u=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:s.scroller.scrollTop,a=s.scroller.clientHeight-Lo,f={};i-n>a&&(i=n+a);var l=e.doc.height+Qt(s),c=n<o,h=i>l-o;if(n<u)f.scrollTop=c?0:n;else if(i>u+a){var p=Math.min(n,(h?l:i)-a);p!=u&&(f.scrollTop=p)}var d=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:s.scroller.scrollLeft,v=s.scroller.clientWidth-Lo-s.gutters.offsetWidth,m=r-t>v;return m&&(r=t+v),t<10?f.scrollLeft=0:t<d?f.scrollLeft=Math.max(0,t-(m?0:10)):r>v+d-3&&(f.scrollLeft=r+(m?0:10)-v),f}function ti(e,t,n){(t!=null||n!=null)&&ri(e),t!=null&&(e.curOp.scrollLeft=(e.curOp.scrollLeft==null?e.doc.scrollLeft:e.curOp.scrollLeft)+t),n!=null&&(e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+n)}function ni(e){ri(e);var t=e.getCursor(),n=t,r=t;e.options.lineWrapping||(n=t.ch?ht(t.line,t.ch-1):t,r=ht(t.line,t.ch+1)),e.curOp.scrollToPos={from:n,to:r,margin:e.options.cursorScrollMargin,isCursor:!0}}function ri(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=yn(e,t.from),r=yn(e,t.to),i=ei(e,Math.min(n.left,r.left),Math.min(n.top,r.top)-t.margin,Math.max(n.right,r.right),Math.max(n.bottom,r.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function ii(e,t,n,r){var i=e.doc,s;n==null&&(n="add"),n=="smart"&&(i.mode.indent?s=Jt(e,t):n="prev");var o=e.options.tabSize,u=Us(i,t),a=Po(u.text,null,o);u.stateAfter&&(u.stateAfter=null);var f=u.text.match(/^\s*/)[0],l;if(!r&&!/\S/.test(u.text))l=0,n="not";else if(n=="smart"){l=i.mode.indent(s,u.text.slice(f.length),u.text);if(l==Ao||l>150){if(!r)return;n="prev"}}n=="prev"?t>i.first?l=Po(Us(i,t-1).text,null,o):l=0:n=="add"?l=a+e.options.indentUnit:n=="subtract"?l=a-e.options.indentUnit:typeof n=="number"&&(l=a+n),l=Math.max(0,l);var c="",h=0;if(e.options.indentWithTabs)for(var p=Math.floor(l/o);p;--p)h+=o,c+="	";h<l&&(c+=jo(l-h));if(c!=f)Qr(i,c,ht(t,0),ht(t,f.length),"+input");else for(var p=0;p<i.sel.ranges.length;p++){var d=i.sel.ranges[p];if(d.head.line==t&&d.head.ch<f.length){var h=ht(t,f.length);At(i,p,new yt(h,h));break}}u.stateAfter=null}function si(e,t,n,r){var i=t,s=t;return typeof t=="number"?s=Us(e,Et(e,t)):i=Vs(t),i==null?null:(r(s,i)&&e.cm&&zn(e.cm,i,n),s)}function oi(e,t){var n=e.doc.sel.ranges,r=[];for(var i=0;i<n.length;i++){var s=t(n[i]);while(r.length&&pt(s.from,Fo(r).to)<=0){var o=r.pop();if(pt(o.from,s.from)<0){s.from=o.from;break}}r.push(s)}Bn(e,function(){for(var t=r.length-1;t>=0;t--)Qr(e.doc,"",r[t].from,r[t].to,"+delete");ni(e)})}function ui(e,t,n,r,i){function l(){var t=s+n;return t<e.first||t>=e.first+e.size?f=!1:(s=t,a=Us(e,t))}function c(e){var t=(i?Bu:ju)(a,o,n,!0);if(t==null){if(!!e||!l())return f=!1;i?o=(n<0?Lu:ku)(a):o=n<0?a.text.length:0}else o=t;return!0}var s=t.line,o=t.ch,u=n,a=Us(e,s),f=!0;if(r=="char")c();else if(r=="column")c(!0);else if(r=="word"||r=="group"){var h=null,p=r=="group",d=e.cm&&e.cm.getHelper(t,"wordChars");for(var v=!0;;v=!1){if(n<0&&!c(!v))break;var m=a.text.charAt(o)||"\n",g=$o(m,d)?"w":p&&m=="\n"?"n":!p||/\s/.test(m)?null:"p";p&&!v&&!g&&(g="s");if(h&&h!=g){n<0&&(n=1,c());break}g&&(h=g);if(n>0&&!c(!v))break}}var y=Ft(e,ht(s,o),u,!0);return f||(y.hitSide=!0),y}function ai(e,t,n,r){var i=e.doc,s=t.left,o;if(r=="page"){var u=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);o=t.top+n*(u-(n<0?1.5:.5)*xn(e.display))}else r=="line"&&(o=n>0?t.bottom+3:t.top-3);for(;;){var a=wn(e,s,o);if(!a.outside)break;if(n<0?o<=0:o>=i.height){a.hitSide=!0;break}o+=n*5}return a}function ci(e,t,n,r){S.defaults[e]=t,n&&(li[e]=r?function(e,t,r){r!=hi&&n(e,t,r)}:n)}function Si(e){var t=e.split(/-(?!$)/),e=t[t.length-1],n,r,i,s;for(var o=0;o<t.length-1;o++){var u=t[o];if(/^(cmd|meta|m)$/i.test(u))s=!0;else if(/^a(lt)?$/i.test(u))n=!0;else if(/^(c|ctrl|control)$/i.test(u))r=!0;else{if(!/^s(hift)$/i.test(u))throw new Error("Unrecognized modifier name: "+u);i=!0}}return n&&(e="Alt-"+e),r&&(e="Ctrl-"+e),s&&(e="Cmd-"+e),i&&(e="Shift-"+e),e}function Ci(e){return typeof e=="string"?Ei[e]:e}function Oi(e,t,n,r,i){if(r&&r.shared)return _i(e,t,n,r,i);if(e.cm&&!e.cm.curOp)return jn(e.cm,Oi)(e,t,n,r,i);var s=new Li(e,i),o=pt(t,n);r&&zo(r,s,!1);if(o>0||o==0&&s.clearWhenEmpty!==!1)return s;s.replacedWith&&(s.collapsed=!0,s.widgetNode=Go("span",[s.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||(s.widgetNode.ignoreEvents=!0),r.insertLeft&&(s.widgetNode.insertLeft=!0));if(s.collapsed){if(es(e,t.line,t,n,s)||t.line!=n.line&&es(e,n.line,t,n,s))throw new Error("Inserting collapsed marker partially overlapping an existing one");E=!0}s.addToHistory&&eo(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var u=t.line,a=e.cm,f;e.iter(u,n.line+1,function(e){a&&s.collapsed&&!a.options.lineWrapping&&ts(e)==a.display.maxLine&&(f=!0),s.collapsed&&u!=t.line&&Xs(e,0),Ii(e,new Bi(s,u==t.line?t.ch:null,u==n.line?n.ch:null)),++u}),s.collapsed&&e.iter(t.line,n.line+1,function(t){ss(e,t)&&Xs(t,0)}),s.clearOnEnter&&yo(s,"beforeCursorEnter",function(){s.clear()}),s.readOnly&&(w=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),s.collapsed&&(s.id=++Ai,s.atomic=!0);if(a){f&&(a.curOp.updateMaxLine=!0);if(s.collapsed)Un(a,t.line,n.line+1);else if(s.className||s.title||s.startStyle||s.endStyle)for(var l=t.line;l<=n.line;l++)zn(a,l,"text");s.atomic&&Bt(a.doc),So(a,"markerAdded",a,s)}return s}function _i(e,t,n,r,i){r=zo(r),r.shared=!1;var s=[Oi(e,t,n,r,i)],o=s[0],u=r.widgetNode;return qs(e,function(e){u&&(r.widgetNode=u.cloneNode(!0)),s.push(Oi(e,St(e,t),St(e,n),r,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;o=Fo(s)}),new Mi(s,o)}function Di(e){return e.findMarks(ht(e.first,0),e.clipPos(ht(e.lastLine())),function(e){return e.parent})}function Pi(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.find(),s=e.clipPos(i.from),o=e.clipPos(i.to);if(pt(s,o)){var u=Oi(e,s,o,r.primary,r.primary.type);r.markers.push(u),u.parent=r}}}function Hi(e){for(var t=0;t<e.length;t++){var n=e[t],r=[n.primary.doc];qs(n.primary.doc,function(e){r.push(e)});for(var i=0;i<n.markers.length;i++){var s=n.markers[i];qo(r,s.doc)==-1&&(s.parent=null,n.markers.splice(i--,1))}}}function Bi(e,t,n){this.marker=e,this.from=t,this.to=n}function ji(e,t){if(e)for(var n=0;n<e.length;++n){var r=e[n];if(r.marker==t)return r}}function Fi(e,t){for(var n,r=0;r<e.length;++r)e[r]!=t&&(n||(n=[])).push(e[r]);return n}function Ii(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function qi(e,t,n){if(e)for(var r=0,i;r<e.length;++r){var s=e[r],o=s.marker,u=s.from==null||(o.inclusiveLeft?s.from<=t:s.from<t);if(u||s.from==t&&o.type=="bookmark"&&(!n||!s.marker.insertLeft)){var a=s.to==null||(o.inclusiveRight?s.to>=t:s.to>t);(i||(i=[])).push(new Bi(o,s.from,a?null:s.to))}}return i}function Ri(e,t,n){if(e)for(var r=0,i;r<e.length;++r){var s=e[r],o=s.marker,u=s.to==null||(o.inclusiveRight?s.to>=t:s.to>t);if(u||s.from==t&&o.type=="bookmark"&&(!n||s.marker.insertLeft)){var a=s.from==null||(o.inclusiveLeft?s.from<=t:s.from<t);(i||(i=[])).push(new Bi(o,a?null:s.from-t,s.to==null?null:s.to-t))}}return i}function Ui(e,t){var n=Tt(e,t.from.line)&&Us(e,t.from.line).markedSpans,r=Tt(e,t.to.line)&&Us(e,t.to.line).markedSpans;if(!n&&!r)return null;var i=t.from.ch,s=t.to.ch,o=pt(t.from,t.to)==0,u=qi(n,i,o),a=Ri(r,s,o),f=t.text.length==1,l=Fo(t.text).length+(f?i:0);if(u)for(var c=0;c<u.length;++c){var h=u[c];if(h.to==null){var p=ji(a,h.marker);p?f&&(h.to=p.to==null?null:p.to+l):h.to=i}}if(a)for(var c=0;c<a.length;++c){var h=a[c];h.to!=null&&(h.to+=l);if(h.from==null){var p=ji(u,h.marker);p||(h.from=l,f&&(u||(u=[])).push(h))}else h.from+=l,f&&(u||(u=[])).push(h)}u&&(u=zi(u)),a&&a!=u&&(a=zi(a));var d=[u];if(!f){var v=t.text.length-2,m;if(v>0&&u)for(var c=0;c<u.length;++c)u[c].to==null&&(m||(m=[])).push(new Bi(u[c].marker,null,null));for(var c=0;c<v;++c)d.push(m);d.push(a)}return d}function zi(e){for(var t=0;t<e.length;++t){var n=e[t];n.from!=null&&n.from==n.to&&n.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Wi(e,t){var n=oo(e,t),r=Ui(e,t);if(!n)return r;if(!r)return n;for(var i=0;i<n.length;++i){var s=n[i],o=r[i];if(s&&o)e:for(var u=0;u<o.length;++u){var a=o[u];for(var f=0;f<s.length;++f)if(s[f].marker==a.marker)continue e;s.push(a)}else o&&(n[i]=o)}return n}function Xi(e,t,n){var r=null;e.iter(t.line,n.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var n=e.markedSpans[t].marker;n.readOnly&&(!r||qo(r,n)==-1)&&(r||(r=[])).push(n)}});if(!r)return null;var i=[{from:t,to:n}];for(var s=0;s<r.length;++s){var o=r[s],u=o.find(0);for(var a=0;a<i.length;++a){var f=i[a];if(pt(f.to,u.from)<0||pt(f.from,u.to)>0)continue;var l=[a,1],c=pt(f.from,u.from),h=pt(f.to,u.to);(c<0||!o.inclusiveLeft&&!c)&&l.push({from:f.from,to:u.from}),(h>0||!o.inclusiveRight&&!h)&&l.push({from:u.to,to:f.to}),i.splice.apply(i,l),a+=l.length-1}}return i}function Vi(e){var t=e.markedSpans;if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}function $i(e,t){if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.attachLine(e);e.markedSpans=t}function Ji(e){return e.inclusiveLeft?-1:0}function Ki(e){return e.inclusiveRight?1:0}function Qi(e,t){var n=e.lines.length-t.lines.length;if(n!=0)return n;var r=e.find(),i=t.find(),s=pt(r.from,i.from)||Ji(e)-Ji(t);if(s)return-s;var o=pt(r.to,i.to)||Ki(e)-Ki(t);return o?o:t.id-e.id}function Gi(e,t){var n=E&&e.markedSpans,r;if(n)for(var i,s=0;s<n.length;++s)i=n[s],i.marker.collapsed&&(t?i.from:i.to)==null&&(!r||Qi(r,i.marker)<0)&&(r=i.marker);return r}function Yi(e){return Gi(e,!0)}function Zi(e){return Gi(e,!1)}function es(e,t,n,r,i){var s=Us(e,t),o=E&&s.markedSpans;if(o)for(var u=0;u<o.length;++u){var a=o[u];if(!a.marker.collapsed)continue;var f=a.marker.find(0),l=pt(f.from,n)||Ji(a.marker)-Ji(i),c=pt(f.to,r)||Ki(a.marker)-Ki(i);if(l>=0&&c<=0||l<=0&&c>=0)continue;if(l<=0&&(pt(f.to,n)>0||a.marker.inclusiveRight&&i.inclusiveLeft)||l>=0&&(pt(f.from,r)<0||a.marker.inclusiveLeft&&i.inclusiveRight))return!0}}function ts(e){var t;while(t=Yi(e))e=t.find(-1,!0).line;return e}function ns(e){var t,n;while(t=Zi(e))e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function rs(e,t){var n=Us(e,t),r=ts(n);return n==r?t:Vs(r)}function is(e,t){if(t>e.lastLine())return t;var n=Us(e,t),r;if(!ss(e,n))return t;while(r=Zi(n))n=r.find(1,!0).line;return Vs(n)+1}function ss(e,t){var n=E&&t.markedSpans;if(n)for(var r,i=0;i<n.length;++i){r=n[i];if(!r.marker.collapsed)continue;if(r.from==null)return!0;if(r.marker.widgetNode)continue;if(r.from==0&&r.marker.inclusiveLeft&&os(e,t,r))return!0}}function os(e,t,n){if(n.to==null){var r=n.marker.find(1,!0);return os(e,r.line,ji(r.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length)return!0;for(var i,s=0;s<t.markedSpans.length;++s){i=t.markedSpans[s];if(i.marker.collapsed&&!i.marker.widgetNode&&i.from==n.to&&(i.to==null||i.to!=n.from)&&(i.marker.inclusiveLeft||n.marker.inclusiveRight)&&os(e,t,i))return!0}}function as(e,t,n){Js(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&ti(e,null,n)}function fs(e){if(e.height!=null)return e.height;if(!tu(document.body,e.node)){var t="position: relative;";e.coverGutter&&(t+="margin-left: -"+e.cm.getGutterElement().offsetWidth+"px;"),eu(e.cm.display.measure,Go("div",[e.node],null,t))}return e.height=e.node.offsetHeight}function ls(e,t,n,r){var i=new us(e,n,r);return i.noHScroll&&(e.display.alignWidgets=!0),si(e.doc,t,"widget",function(t){var n=t.widgets||(t.widgets=[]);i.insertAt==null?n.push(i):n.splice(Math.min(n.length-1,Math.max(0,i.insertAt)),0,i),i.line=t;if(!ss(e.doc,t)){var r=Js(t)<e.doc.scrollTop;Xs(t,t.height+fs(i)),r&&ti(e,null,i.height),e.curOp.forceUpdate=!0}return!0}),i}function hs(e,t,n,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),Vi(e),$i(e,n);var i=r?r(e):1;i!=e.height&&Xs(e,i)}function ps(e){e.parent=null,Vi(e)}function ds(e,t){if(e)for(;;){var n=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;e=e.slice(0,n.index)+e.slice(n.index+n[0].length);var r=n[1]?"bgClass":"textClass";t[r]==null?t[r]=n[2]:(new RegExp("(?:^|s)"+n[2]+"(?:$|s)")).test(t[r])||(t[r]+=" "+n[2])}return e}function vs(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var n=S.innerMode(e,t);if(n.mode.blankLine)return n.mode.blankLine(n.state)}function ms(e,t,n,r){for(var i=0;i<10;i++){r&&(r[0]=S.innerMode(e,n).mode);var s=e.token(t,n);if(t.pos>t.start)return s}throw new Error("Mode "+e.name+" failed to advance stream.")}function gs(e,t,n,r){function i(e){return{start:l.start,end:l.pos,string:l.current(),type:u||null,state:e?yi(s.mode,f):f}}var s=e.doc,o=s.mode,u;t=St(s,t);var a=Us(s,t.line),f=Jt(e,t.line,n),l=new ki(a.text,e.options.tabSize),c;r&&(c=[]);while((r||l.pos<t.ch)&&!l.eol())l.start=l.pos,u=ms(o,l,f),r&&c.push(i(!0));return r?c:i()}function ys(e,t,n,r,i,s,o){var u=n.flattenSpans;u==null&&(u=e.options.flattenSpans);var a=0,f=null,l=new ki(t,e.options.tabSize),c,h=e.options.addModeClass&&[null];t==""&&ds(vs(n,r),s);while(!l.eol()){l.pos>e.options.maxHighlightLength?(u=!1,o&&Es(e,t,r,l.pos),l.pos=t.length,c=null):c=ds(ms(n,l,r,h),s);if(h){var p=h[0].name;p&&(c="m-"+(c?p+" "+c:p))}if(!u||f!=c)a<l.start&&i(l.start,f),a=l.start,f=c;l.start=l.pos}while(a<l.pos){var d=Math.min(l.pos,a+5e4);i(d,f),a=d}}function bs(e,t,n,r){var i=[e.state.modeGen],s={};ys(e,t.text,e.doc.mode,n,function(e,t){i.push(e,t)},s,r);for(var o=0;o<e.state.overlays.length;++o){var u=e.state.overlays[o],a=1,f=0;ys(e,t.text,u.mode,!0,function(e,t){var n=a;while(f<e){var r=i[a];r>e&&i.splice(a,1,e,i[a+1],r),a+=2,f=Math.min(e,r)}if(!t)return;if(u.opaque)i.splice(n,a-n,e,"cm-overlay "+t),a=n+2;else for(;n<a;n+=2){var s=i[n+1];i[n+1]=(s?s+" ":"")+"cm-overlay "+t}},s)}return{styles:i,classes:s.bgClass||s.textClass?s:null}}function ws(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=bs(e,t,t.stateAfter=Jt(e,Vs(t)));t.styles=r.styles,r.classes?t.styleClasses=r.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.frontier&&e.doc.frontier++}return t.styles}function Es(e,t,n,r){var i=e.doc.mode,s=new ki(t,e.options.tabSize);s.start=s.pos=r||0,t==""&&vs(i,n);while(!s.eol()&&s.pos<=e.options.maxHighlightLength)ms(i,s,n),s.start=s.pos}function Ts(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?xs:Ss;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Ns(e,t){var n=Go("span",null,null,s?"padding-right: .1px":null),i={pre:Go("pre",[n]),content:n,col:0,pos:0,cm:e};t.measure={};for(var o=0;o<=(t.rest?t.rest.length:0);o++){var u=o?t.rest[o-1]:t.line,a;i.pos=0,i.addToken=ks,(r||s)&&e.getOption("lineWrapping")&&(i.addToken=Ls(i.addToken)),gu(e.display.measure)&&(a=Ks(u))&&(i.addToken=As(i.addToken,a)),i.map=[];var f=t!=e.display.externalMeasured&&Vs(u);Ms(u,i,ws(e,u,f)),u.styleClasses&&(u.styleClasses.bgClass&&(i.bgClass=ou(u.styleClasses.bgClass,i.bgClass||"")),u.styleClasses.textClass&&(i.textClass=ou(u.styleClasses.textClass,i.textClass||""))),i.map.length==0&&i.map.push(0,0,i.content.appendChild(vu(e.display.measure))),o==0?(t.measure.map=i.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(i.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return s&&/\bcm-tab\b/.test(i.content.lastChild.className)&&(i.content.className="cm-tab-wrap-hack"),wo(e,"renderLine",e,t.line,i.pre),i.pre.className&&(i.textClass=ou(i.pre.className,i.textClass||"")),i}function Cs(e){var t=Go("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t}function ks(e,t,n,s,o,u){if(!t)return;var a=e.cm.options.specialChars,f=!1;if(!a.test(t)){e.col+=t.length;var l=document.createTextNode(t);e.map.push(e.pos,e.pos+t.length,l),r&&i<9&&(f=!0),e.pos+=t.length}else{var l=document.createDocumentFragment(),c=0;for(;;){a.lastIndex=c;var h=a.exec(t),p=h?h.index-c:t.length-c;if(p){var d=document.createTextNode(t.slice(c,c+p));r&&i<9?l.appendChild(Go("span",[d])):l.appendChild(d),e.map.push(e.pos,e.pos+p,d),e.col+=p,e.pos+=p}if(!h)break;c+=p+1;if(h[0]=="	"){var v=e.cm.options.tabSize,m=v-e.col%v,d=l.appendChild(Go("span",jo(m),"cm-tab"));e.col+=m}else{var d=e.cm.options.specialCharPlaceholder(h[0]);r&&i<9?l.appendChild(Go("span",[d])):l.appendChild(d),e.col+=1}e.map.push(e.pos,e.pos+1,d),e.pos++}}if(n||s||o||f){var g=n||"";s&&(g+=s),o&&(g+=o);var y=Go("span",[l],g);return u&&(y.title=u),e.content.appendChild(y)}e.content.appendChild(l)}function Ls(e){function t(e){var t=" ";for(var n=0;n<e.length-2;++n)t+=n%2?" ":" ";return t+=" ",t}return function(n,r,i,s,o,u){e(n,r.replace(/ {3,}/g,t),i,s,o,u)}}function As(e,t){return function(n,r,i,s,o,u){i=i?i+" cm-force-border":"cm-force-border";var a=n.pos,f=a+r.length;for(;;){for(var l=0;l<t.length;l++){var c=t[l];if(c.to>a&&c.from<=a)break}if(c.to>=f)return e(n,r,i,s,o,u);e(n,r.slice(0,c.to-a),i,s,null,u),s=null,r=r.slice(c.to-a),a=c.to}}}function Os(e,t,n,r){var i=!r&&n.widgetNode;i&&(e.map.push(e.pos,e.pos+t,i),e.content.appendChild(i)),e.pos+=t}function Ms(e,t,n){var r=e.markedSpans,i=e.text,s=0;if(!r){for(var o=1;o<n.length;o+=2)t.addToken(t,i.slice(s,s=n[o]),Ts(n[o+1],t.cm.options));return}var u=i.length,a=0,o=1,f="",l,c=0,h,p,d,v,m;for(;;){if(c==a){h=p=d=v="",m=null,c=Infinity;var g=[];for(var y=0;y<r.length;++y){var b=r[y],w=b.marker;b.from<=a&&(b.to==null||b.to>a)?(b.to!=null&&c>b.to&&(c=b.to,p=""),w.className&&(h+=" "+w.className),w.startStyle&&b.from==a&&(d+=" "+w.startStyle),w.endStyle&&b.to==c&&(p+=" "+w.endStyle),w.title&&!v&&(v=w.title),w.collapsed&&(!m||Qi(m.marker,w)<0)&&(m=b)):b.from>a&&c>b.from&&(c=b.from),w.type=="bookmark"&&b.from==a&&w.widgetNode&&g.push(w)}if(m&&(m.from||0)==a){Os(t,(m.to==null?u+1:m.to)-a,m.marker,m.from==null);if(m.to==null)return}if(!m&&g.length)for(var y=0;y<g.length;++y)Os(t,0,g[y])}if(a>=u)break;var E=Math.min(u,c);for(;;){if(f){var S=a+f.length;if(!m){var x=S>E?f.slice(0,E-a):f;t.addToken(t,x,l?l+h:h,d,a+x.length==c?p:"",v)}if(S>=E){f=f.slice(E-a),a=E;break}a=S,d=""}f=i.slice(s,s=n[o++]),l=Ts(n[o++],t.cm.options)}}}function _s(e,t){return t.from.ch==0&&t.to.ch==0&&Fo(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Ds(e,t,n,r){function i(e){return n?n[e]:null}function s(e,n,i){hs(e,n,i,r),So(e,"change",e,t)}var o=t.from,u=t.to,a=t.text,f=Us(e,o.line),l=Us(e,u.line),c=Fo(a),h=i(a.length-1),p=u.line-o.line;if(_s(e,t)){for(var d=0,v=[];d<a.length-1;++d)v.push(new cs(a[d],i(d),r));s(l,l.text,h),p&&e.remove(o.line,p),v.length&&e.insert(o.line,v)}else if(f==l)if(a.length==1)s(f,f.text.slice(0,o.ch)+c+f.text.slice(u.ch),h);else{for(var v=[],d=1;d<a.length-1;++d)v.push(new cs(a[d],i(d),r));v.push(new cs(c+f.text.slice(u.ch),h,r)),s(f,f.text.slice(0,o.ch)+a[0],i(0)),e.insert(o.line+1,v)}else if(a.length==1)s(f,f.text.slice(0,o.ch)+a[0]+l.text.slice(u.ch),i(0)),e.remove(o.line+1,p);else{s(f,f.text.slice(0,o.ch)+a[0],i(0)),s(l,c+l.text.slice(u.ch),h);for(var d=1,v=[];d<a.length-1;++d)v.push(new cs(a[d],i(d),r));p>1&&e.remove(o.line+1,p-1),e.insert(o.line+1,v)}So(e,"change",e,t)}function Ps(e){this.lines=e,this.parent=null;for(var t=0,n=0;t<e.length;++t)e[t].parent=this,n+=e[t].height;this.height=n}function Hs(e){this.children=e;var t=0,n=0;for(var r=0;r<e.length;++r){var i=e[r];t+=i.chunkSize(),n+=i.height,i.parent=this}this.size=t,this.height=n,this.parent=null}function qs(e,t,n){function r(e,i,s){if(e.linked)for(var o=0;o<e.linked.length;++o){var u=e.linked[o];if(u.doc==i)continue;var a=s&&u.sharedHist;if(n&&!a)continue;t(u.doc,a),r(u.doc,e,a)}}r(e,null,!0)}function Rs(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,L(e),T(e),e.options.lineWrapping||P(e),e.options.mode=t.modeOption,Un(e)}function Us(e,t){t-=e.first;if(t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],s=i.chunkSize();if(t<s){n=i;break}t-=s}return n.lines[t]}function zs(e,t,n){var r=[],i=t.line;return e.iter(t.line,n.line+1,function(e){var s=e.text;i==n.line&&(s=s.slice(0,n.ch)),i==t.line&&(s=s.slice(t.ch)),r.push(s),++i}),r}function Ws(e,t,n){var r=[];return e.iter(t,n,function(e){r.push(e.text)}),r}function Xs(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function Vs(e){if(e.parent==null)return null;var t=e.parent,n=qo(t.lines,e);for(var r=t.parent;r;t=r,r=r.parent)for(var i=0;;++i){if(r.children[i]==t)break;n+=r.children[i].chunkSize()}return n+t.first}function $s(e,t){var n=e.first;e:do{for(var r=0;r<e.children.length;++r){var i=e.children[r],s=i.height;if(t<s){e=i;continue e}t-=s,n+=i.chunkSize()}return n}while(!e.lines);for(var r=0;r<e.lines.length;++r){var o=e.lines[r],u=o.height;if(t<u)break;t-=u}return n+r}function Js(e){e=ts(e);var t=0,n=e.parent;for(var r=0;r<n.lines.length;++r){var i=n.lines[r];if(i==e)break;t+=i.height}for(var s=n.parent;s;n=s,s=n.parent)for(var r=0;r<s.children.length;++r){var o=s.children[r];if(o==n)break;t+=o.height}return t}function Ks(e){var t=e.order;return t==null&&(t=e.order=Fu(e.text)),t}function Qs(e){this.done=[],this.undone=[],this.undoDepth=Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Gs(e,t){var n={from:dt(t.from),to:Fr(t),text:zs(e,t.from,t.to)};return io(e,n,t.from.line,t.to.line+1),qs(e,function(e){io(e,n,t.from.line,t.to.line+1)},!0),n}function Ys(e){while(e.length){var t=Fo(e);if(!t.ranges)break;e.pop()}}function Zs(e,t){if(t)return Ys(e.done),Fo(e.done);if(e.done.length&&!Fo(e.done).ranges)return Fo(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),Fo(e.done)}function eo(e,t,n,r){var i=e.history;i.undone.length=0;var s=+(new Date),o;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&e.cm&&i.lastModTime>s-e.cm.options.historyEventDelay||t.origin.charAt(0)=="*"))&&(o=Zs(i,i.lastOp==r))){var u=Fo(o.changes);pt(t.from,t.to)==0&&pt(t.from,u.to)==0?u.to=Fr(t):o.changes.push(Gs(e,t))}else{var a=Fo(i.done);(!a||!a.ranges)&&ro(e.sel,i.done),o={changes:[Gs(e,t)],generation:i.generation},i.done.push(o);while(i.done.length>i.undoDepth)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=s,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,u||wo(e,"historyAdded")}function to(e,t,n,r){var i=t.charAt(0);return i=="*"||i=="+"&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function no(e,t,n,r){var i=e.history,s=r&&r.origin;n==i.lastSelOp||s&&i.lastSelOrigin==s&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==s||to(e,s,Fo(i.done),t))?i.done[i.done.length-1]=t:ro(t,i.done),i.lastSelTime=+(new Date),i.lastSelOrigin=s,i.lastSelOp=n,r&&r.clearRedo!==!1&&Ys(i.undone)}function ro(e,t){var n=Fo(t);n&&n.ranges&&n.equals(e)||t.push(e)}function io(e,t,n,r){var i=t["spans_"+e.id],s=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(n){n.markedSpans&&((i||(i=t["spans_"+e.id]={}))[s]=n.markedSpans),++s})}function so(e){if(!e)return null;for(var t=0,n;t<e.length;++t)e[t].marker.explicitlyCleared?n||(n=e.slice(0,t)):n&&n.push(e[t]);return n?n.length?n:null:e}function oo(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var r=0,i=[];r<t.text.length;++r)i.push(so(n[r]));return i}function uo(e,t,n){for(var r=0,i=[];r<e.length;++r){var s=e[r];if(s.ranges){i.push(n?gt.prototype.deepCopy.call(s):s);continue}var o=s.changes,u=[];i.push({changes:u});for(var a=0;a<o.length;++a){var f=o[a],l;u.push({from:f.from,to:f.to,text:f.text});if(t)for(var c in f)(l=c.match(/^spans_(\d+)$/))&&qo(t,Number(l[1]))>-1&&(Fo(u)[c]=f[c],delete f[c])}}return i}function ao(e,t,n,r){n<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function fo(e,t,n,r){for(var i=0;i<e.length;++i){var s=e[i],o=!0;if(s.ranges){s.copied||(s=e[i]=s.deepCopy(),s.copied=!0);for(var u=0;u<s.ranges.length;u++)ao(s.ranges[u].anchor,t,n,r),ao(s.ranges[u].head,t,n,r);continue}for(var u=0;u<s.changes.length;++u){var a=s.changes[u];if(n<a.from.line)a.from=ht(a.from.line+r,a.from.ch),a.to=ht(a.to.line+r,a.to.ch);else if(t<=a.to.line){o=!1;break}}o||(e.splice(0,i+1),i=0)}}function lo(e,t){var n=t.from.line,r=t.to.line,i=t.text.length-(r-n)-1;fo(e.done,n,r,i),fo(e.undone,n,r,i)}function po(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==0}function mo(e){return e.target||e.srcElement}function go(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),v&&e.ctrlKey&&t==1&&(t=3),t}function So(e,t){function s(e){return function(){e.apply(null,r)}}var n=e._handlers&&e._handlers[t];if(!n)return;var r=Array.prototype.slice.call(arguments,2),i;Nn?i=Nn.delayedCallbacks:Eo?i=Eo:(i=Eo=[],setTimeout(xo,0));for(var o=0;o<n.length;++o)i.push(s(n[o]))}function xo(){var e=Eo;Eo=null;for(var t=0;t<e.length;++t)e[t]()}function To(e,t,n){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),wo(e,n||t.type,e,t),po(t)||t.codemirrorIgnore}function No(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t)return;var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]);for(var r=0;r<t.length;++r)qo(n,t[r])==-1&&n.push(t[r])}function Co(e,t){var n=e._handlers&&e._handlers[t];return n&&n.length>0}function ko(e){e.prototype.on=function(e,t){yo(this,e,t)},e.prototype.off=function(e,t){bo(this,e,t)}}function Do(){this.id=null}function Ho(e,t,n){for(var r=0,i=0;;){var s=e.indexOf("	",r);s==-1&&(s=e.length);var o=s-r;if(s==e.length||i+o>=t)return r+Math.min(o,t-i);i+=s-r,i+=n-i%n,r=s+1;if(i>=t)return r}}function jo(e){while(Bo.length<=e)Bo.push(Fo(Bo)+" ");return Bo[e]}function Fo(e){return e[e.length-1]}function qo(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}function Ro(e,t){var n=[];for(var r=0;r<e.length;r++)n[r]=t(e[r],r);return n}function Uo(e,t){var n;if(Object.create)n=Object.create(e);else{var r=function(){};r.prototype=e,n=new r}return t&&zo(t,n),n}function zo(e,t,n){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(n!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function Wo(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function $o(e,t){return t?t.source.indexOf("\\w")>-1&&Vo(e)?!0:t.test(e):Vo(e)}function Jo(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Qo(e){return e.charCodeAt(0)>=768&&Ko.test(e)}function Go(e,t,n,r){var i=document.createElement(e);n&&(i.className=n),r&&(i.style.cssText=r);if(typeof t=="string")i.appendChild(document.createTextNode(t));else if(t)for(var s=0;s<t.length;++s)i.appendChild(t[s]);return i}function Zo(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function eu(e,t){return Zo(e).appendChild(t)}function tu(e,t){if(e.contains)return e.contains(t);while(t=t.parentNode)if(t==e)return!0}function nu(){return document.activeElement}function ru(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function ou(e,t){var n=e.split(" ");for(var r=0;r<n.length;r++)n[r]&&!ru(n[r]).test(t)&&(t+=" "+n[r]);return t}function uu(e){if(!document.body.getElementsByClassName)return;var t=document.body.getElementsByClassName("CodeMirror");for(var n=0;n<t.length;n++){var r=t[n].CodeMirror;r&&e(r)}}function fu(){if(au)return;lu(),au=!0}function lu(){var e;yo(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,hu=null,uu(ir)},100))}),yo(window,"blur",function(){uu(Hr)})}function pu(e){if(hu!=null)return hu;var t=Go("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");return eu(e,t),t.offsetWidth&&(hu=t.offsetHeight-t.clientHeight),hu||0}function vu(e){if(du==null){var t=Go("span","​");eu(e,Go("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(du=t.offsetWidth<=1&&t.offsetHeight>2&&!(r&&i<8))}return du?Go("span","​"):Go("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px")}function gu(e){if(mu!=null)return mu;var t=eu(e,document.createTextNode("AخA")),n=Yo(t,0,1).getBoundingClientRect();if(!n||n.left==n.right)return!1;var r=Yo(t,1,2).getBoundingClientRect();return mu=r.right-n.right<3}function Su(e){if(Eu!=null)return Eu;var t=eu(e,Go("span","x")),n=t.getBoundingClientRect(),r=Yo(t,0,1).getBoundingClientRect();return Eu=Math.abs(n.left-r.left)>1}function Tu(e,t,n,r){if(!e)return r(t,n,"ltr");var i=!1;for(var s=0;s<e.length;++s){var o=e[s];if(o.from<n&&o.to>t||t==n&&o.to==t)r(Math.max(o.from,t),Math.min(o.to,n),o.level==1?"rtl":"ltr"),i=!0}i||r(t,n,"ltr")}function Nu(e){return e.level%2?e.to:e.from}function Cu(e){return e.level%2?e.from:e.to}function ku(e){var t=Ks(e);return t?Nu(t[0]):0}function Lu(e){var t=Ks(e);return t?Cu(Fo(t)):e.text.length}function Au(e,t){var n=Us(e.doc,t),r=ts(n);r!=n&&(t=Vs(r));var i=Ks(r),s=i?i[0].level%2?Lu(r):ku(r):0;return ht(t,s)}function Ou(e,t){var n,r=Us(e.doc,t);while(n=Zi(r))r=n.find(1,!0).line,t=null;var i=Ks(r),s=i?i[0].level%2?ku(r):Lu(r):r.text.length;return ht(t==null?Vs(r):t,s)}function Mu(e,t){var n=Au(e,t.line),r=Us(e.doc,n.line),i=Ks(r);if(!i||i[0].level==0){var s=Math.max(0,r.text.search(/\S/)),o=t.line==n.line&&t.ch<=s&&t.ch;return ht(n.line,o?0:s)}return n}function _u(e,t,n){var r=e[0].level;return t==r?!0:n==r?!1:t<n}function Pu(e,t){Du=null;for(var n=0,r;n<e.length;++n){var i=e[n];if(i.from<t&&i.to>t)return n;if(i.from==t||i.to==t){if(r!=null)return _u(e,i.level,e[r].level)?(i.from!=i.to&&(Du=r),n):(i.from!=i.to&&(Du=n),r);r=n}}return r}function Hu(e,t,n,r){if(!r)return t+n;do t+=n;while(t>0&&Qo(e.text.charAt(t)));return t}function Bu(e,t,n,r){var i=Ks(e);if(!i)return ju(e,t,n,r);var s=Pu(i,t),o=i[s],u=Hu(e,t,o.level%2?-n:n,r);for(;;){if(u>o.from&&u<o.to)return u;if(u==o.from||u==o.to)return Pu(i,u)==s?u:(o=i[s+=n],n>0==o.level%2?o.to:o.from);o=i[s+=n];if(!o)return null;n>0==o.level%2?u=Hu(e,o.to,-1,r):u=Hu(e,o.from,1,r)}}function ju(e,t,n,r){var i=t+n;if(r)while(i>0&&Qo(e.text.charAt(i)))i+=n;return i<0||i>e.text.length?null:i}var e=/gecko\/\d/i.test(navigator.userAgent),t=/MSIE \d/.test(navigator.userAgent),n=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),r=t||n,i=r&&(t?document.documentMode||6:n[1]),s=/WebKit\//.test(navigator.userAgent),o=s&&/Qt\/\d+\.\d+/.test(navigator.userAgent),u=/Chrome\//.test(navigator.userAgent),a=/Opera\//.test(navigator.userAgent),f=/Apple Computer/.test(navigator.vendor),l=/KHTML\//.test(navigator.userAgent),c=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),h=/PhantomJS/.test(navigator.userAgent),p=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),d=p||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),v=p||/Mac/.test(navigator.platform),m=/win/i.test(navigator.platform),g=a&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);g&&(g=Number(g[1])),g&&g>=15&&(a=!1,s=!0);var y=v&&(o||a&&(g==null||g<12.11)),b=e||r&&i>=9,w=!1,E=!1,ht=S.Pos=function(e,t){if(!(this instanceof ht))return new ht(e,t);this.line=e,this.ch=t},pt=S.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch};gt.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var n=this.ranges[t],r=e.ranges[t];if(pt(n.anchor,r.anchor)!=0||pt(n.head,r.head)!=0)return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new yt(dt(this.ranges[t].anchor),dt(this.ranges[t].head));return new gt(e,this.primIndex)},somethingSelected:function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},contains:function(e,t){t||(t=e);for(var n=0;n<this.ranges.length;n++){var r=this.ranges[n];if(pt(t,r.from())>=0&&pt(e,r.to())<=0)return n}return-1}},yt.prototype={from:function(){return mt(this.anchor,this.head)},to:function(){return vt(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var on={left:0,right:0,top:0,bottom:0},Sn,Nn=null,Cn=0,Gn=null,ar,fr,vr=0,wr=0,Er=null;r?Er=-0.53:e?Er=15:u?Er=-0.7:f&&(Er=-1/3);var Nr=new Do,Ar=null,Fr=S.changeEnd=function(e){return e.text?ht(e.from.line+e.text.length-1,Fo(e.text).length+(e.text.length==1?e.from.ch:0)):e.to};S.prototype={constructor:S,focus:function(){window.focus(),er(this),Qn(this)},setOption:function(e,t){var n=this.options,r=n[e];if(n[e]==t&&e!="mode")return;n[e]=t,li.hasOwnProperty(e)&&jn(this,li[e])(this,t,r)},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Ci(e))},removeKeyMap:function(e){var t=this.state.keyMaps;for(var n=0;n<t.length;++n)if(t[n]==e||t[n].name==e)return t.splice(n,1),!0},addOverlay:Fn(function(e,t){var n=e.token?e:S.getMode(this.options,e);if(n.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:n,modeSpec:e,opaque:t&&t.opaque}),this.state.modeGen++,Un(this)}),removeOverlay:Fn(function(e){var t=this.state.overlays;for(var n=0;n<t.length;++n){var r=t[n].modeSpec;if(r==e||typeof e=="string"&&r.name==e){t.splice(n,1),this.state.modeGen++,Un(this);return}}}),indentLine:Fn(function(e,t,n){typeof t!="string"&&typeof t!="number"&&(t==null?t=this.options.smartIndent?"smart":"prev":t=t?"add":"subtract"),Tt(this.doc,e)&&ii(this,e,t,n)}),indentSelection:Fn(function(e){var t=this.doc.sel.ranges,n=-1;for(var r=0;r<t.length;r++){var i=t[r];if(!i.empty()){var s=i.from(),o=i.to(),u=Math.max(n,s.line);n=Math.min(this.lastLine(),o.line-(o.ch?0:1))+1;for(var a=u;a<n;++a)ii(this,a,e);var f=this.doc.sel.ranges;s.ch==0&&t.length==f.length&&f[r].from().ch>0&&At(this.doc,r,new yt(s,f[r].to()),Oo)}else i.head.line>n&&(ii(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&ni(this))}}),getTokenAt:function(e,t){return gs(this,e,t)},getLineTokens:function(e,t){return gs(this,ht(e),t,!0)},getTokenTypeAt:function(e){e=St(this.doc,e);var t=ws(this,Us(this.doc,e.line)),n=0,r=(t.length-1)/2,i=e.ch,s;if(i==0)s=t[2];else for(;;){var o=n+r>>1;if((o?t[o*2-1]:0)>=i)r=o;else{if(!(t[o*2+1]<i)){s=t[o*2+2];break}n=o+1}}var u=s?s.indexOf("cm-overlay "):-1;return u<0?s:u==0?null:s.slice(0,u-1)},getModeAt:function(e){var t=this.doc.mode;return t.innerMode?S.innerMode(t,this.getTokenAt(e).state).mode:t},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var n=[];if(!gi.hasOwnProperty(t))return gi;var r=gi[t],i=this.getModeAt(e);if(typeof i[t]=="string")r[i[t]]&&n.push(r[i[t]]);else if(i[t])for(var s=0;s<i[t].length;s++){var o=r[i[t][s]];o&&n.push(o)}else i.helperType&&r[i.helperType]?n.push(r[i.helperType]):r[i.name]&&n.push(r[i.name]);for(var s=0;s<r._global.length;s++){var u=r._global[s];u.pred(i,this)&&qo(n,u.val)==-1&&n.push(u.val)}return n},getStateAfter:function(e,t){var n=this.doc;return e=Et(n,e==null?n.first+n.size-1:e),Jt(this,e+1,t)},cursorCoords:function(e,t){var n,r=this.doc.sel.primary();return e==null?n=r.head:typeof e=="object"?n=St(this.doc,e):n=e?r.from():r.to(),gn(this,n,t||"page")},charCoords:function(e,t){return mn(this,St(this.doc,e),t||"page")},coordsChar:function(e,t){return e=vn(this,e,t||"page"),wn(this,e.left,e.top)},lineAtHeight:function(e,t){return e=vn(this,{top:e,left:0},t||"page").top,$s(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var n=!1,r=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>r&&(e=r,n=!0);var i=Us(this.doc,e);return dn(this,i,{top:0,left:0},t||"page").top+(n?this.doc.height-Js(i):0)},defaultTextHeight:function(){return xn(this.display)},defaultCharWidth:function(){return Tn(this.display)},setGutterMarker:Fn(function(e,t,n){return si(this.doc,e,"gutter",function(e){var r=e.gutterMarkers||(e.gutterMarkers={});return r[t]=n,!n&&Jo(r)&&(e.gutterMarkers=null),!0})}),clearGutter:Fn(function(e){var t=this,n=t.doc,r=n.first;n.iter(function(n){n.gutterMarkers&&n.gutterMarkers[e]&&(n.gutterMarkers[e]=null,zn(t,r,"gutter"),Jo(n.gutterMarkers)&&(n.gutterMarkers=null)),++r})}),addLineWidget:Fn(function(e,t,n){return ls(this,e,t,n)}),removeLineWidget:function(e){e.clear()},lineInfo:function(e){if(typeof e=="number"){if(!Tt(this.doc,e))return null;var t=e;e=Us(this.doc,e);if(!e)return null}else{var t=Vs(e);if(t==null)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var s=this.display;e=gn(this,St(this.doc,e));var o=e.bottom,u=e.left;t.style.position="absolute",s.sizer.appendChild(t);if(r=="over")o=e.top;else if(r=="above"||r=="near"){var a=Math.max(s.wrapper.clientHeight,this.doc.height),f=Math.max(s.sizer.clientWidth,s.lineSpace.clientWidth);(r=="above"||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?o=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(o=e.bottom),u+t.offsetWidth>f&&(u=f-t.offsetWidth)}t.style.top=o+"px",t.style.left=t.style.right="",i=="right"?(u=s.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):(i=="left"?u=0:i=="middle"&&(u=(s.sizer.clientWidth-t.offsetWidth)/2),t.style.left=u+"px"),n&&Zr(this,u,o,u+t.offsetWidth,o+t.offsetHeight)},triggerOnKeyDown:Fn(Or),triggerOnKeyPress:Fn(Dr),triggerOnKeyUp:_r,execCommand:function(e){if(wi.hasOwnProperty(e))return wi[e](this)},findPosH:function(e,t,n,r){var i=1;t<0&&(i=-1,t=-t);for(var s=0,o=St(this.doc,e);s<t;++s){o=ui(this.doc,o,i,n,r);if(o.hitSide)break}return o},moveH:Fn(function(e,t){var n=this;n.extendSelectionsBy(function(r){return n.display.shift||n.doc.extend||r.empty()?ui(n.doc,r.head,e,t,n.options.rtlMoveVisually):e<0?r.from():r.to()},_o)}),deleteH:Fn(function(e,t){var n=this.doc.sel,r=this.doc;n.somethingSelected()?r.replaceSelection("",null,"+delete"):oi(this,function(n){var i=ui(r,n.head,e,t,!1);return e<0?{from:i,to:n.head}:{from:n.head,to:i}})}),findPosV:function(e,t,n,r){var i=1,s=r;t<0&&(i=-1,t=-t);for(var o=0,u=St(this.doc,e);o<t;++o){var a=gn(this,u,"div");s==null?s=a.left:a.left=s,u=ai(this,a,i,n);if(u.hitSide)break}return u},moveV:Fn(function(e,t){var n=this,r=this.doc,i=[],s=!n.display.shift&&!r.extend&&r.sel.somethingSelected();r.extendSelectionsBy(function(o){if(s)return e<0?o.from():o.to();var u=gn(n,o.head,"div");o.goalColumn!=null&&(u.left=o.goalColumn),i.push(u.left);var a=ai(n,u,e,t);return t=="page"&&o==r.sel.primary()&&ti(n,null,mn(n,a,"div").top-u.top),a},_o);if(i.length)for(var o=0;o<r.sel.ranges.length;o++)r.sel.ranges[o].goalColumn=i[o]}),findWordAt:function(e){var t=this.doc,n=Us(t,e.line).text,r=e.ch,i=e.ch;if(n){var s=this.getHelper(e,"wordChars");(e.xRel<0||i==n.length)&&r?--r:++i;var o=n.charAt(r),u=$o(o,s)?function(e){return $o(e,s)}:/\s/.test(o)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!$o(e)};while(r>0&&u(n.charAt(r-1)))--r;while(i<n.length&&u(n.charAt(i)))++i}return new yt(ht(e.line,r),ht(e.line,i))},toggleOverwrite:function(e){if(e!=null&&e==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?su(this.display.cursorDiv,"CodeMirror-overwrite"):iu(this.display.cursorDiv,"CodeMirror-overwrite"),wo(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return nu()==this.display.input},scrollTo:Fn(function(e,t){(e!=null||t!=null)&&ri(this),e!=null&&(this.curOp.scrollLeft=e),t!=null&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller,t=Lo;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-t,width:e.scrollWidth-t,clientHeight:e.clientHeight-t,clientWidth:e.clientWidth-t}},scrollIntoView:Fn(function(e,t){e==null?(e={from:this.doc.sel.primary().head,to:null},t==null&&(t=this.options.cursorScrollMargin)):typeof e=="number"?e={from:ht(e,0),to:null}:e.from==null&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0;if(e.from.line!=null)ri(this),this.curOp.scrollToPos=e;else{var n=ei(this,Math.min(e.from.left,e.to.left),Math.min(e.from.top,e.to.top)-e.margin,Math.max(e.from.right,e.to.right),Math.max(e.from.bottom,e.to.bottom)+e.margin);this.scrollTo(n.scrollLeft,n.scrollTop)}}),setSize:Fn(function(e,t){function r(e){return typeof e=="number"||/^\d+$/.test(String(e))?e+"px":e}var n=this;e!=null&&(n.display.wrapper.style.width=r(e)),t!=null&&(n.display.wrapper.style.height=r(t)),n.options.lineWrapping&&ln(this);var i=n.display.viewFrom;n.doc.iter(i,n.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){zn(n,i,"widget");break}++i}),n.curOp.forceUpdate=!0,wo(n,"refresh",this)}),operation:function(e){return Bn(this,e)},refresh:Fn(function(){var e=this.display.cachedTextHeight;Un(this),this.curOp.forceUpdate=!0,cn(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),_(this),(e==null||Math.abs(e-xn(this.display))>.5)&&L(this),wo(this,"refresh",this)}),swapDoc:Fn(function(e){var t=this.doc;return t.cm=null,Rs(this,e),cn(this),Zn(this),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,So(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}},ko(S);var fi=S.defaults={},li=S.optionHandlers={},hi=S.Init={toString:function(){return"CodeMirror.Init"}};ci("value","",function(e,t){e.setValue(t)},!0),ci("mode",null,function(e,t){e.doc.modeOption=t,T(e)},!0),ci("indentUnit",2,T,!0),ci("indentWithTabs",!1),ci("smartIndent",!0),ci("tabSize",4,function(e){N(e),cn(e),Un(e)},!0),ci("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t){e.options.specialChars=new RegExp(t.source+(t.test("	")?"":"|	"),"g"),e.refresh()},!0),ci("specialCharPlaceholder",Cs,function(e){e.refresh()},!0),ci("electricChars",!0),ci("rtlMoveVisually",!m),ci("wholeLineUpdateBefore",!0),ci("theme","default",function(e){A(e),O(e)},!0),ci("keyMap","default",function(e,t,n){var r=Ci(t),i=n!=S.Init&&Ci(n);i&&i.detach&&i.detach(e,r),r.attach&&r.attach(e,i||null)}),ci("extraKeys",null),ci("lineWrapping",!1,C,!0),ci("gutters",[],function(e){H(e.options),O(e)},!0),ci("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?z(e.display)+"px":"0",e.refresh()},!0),ci("coverGutterNextToScrollbar",!1,F,!0),ci("lineNumbers",!1,function(e){H(e.options),O(e)},!0),ci("firstLineNumber",1,O,!0),ci("lineNumberFormatter",function(e){return e},O,!0),ci("showCursorWhenSelecting",!1,Rt,!0),ci("resetSelectionOnContextMenu",!0),ci("readOnly",!1,function(e,t){t=="nocursor"?(Hr(e),e.display.input.blur(),e.display.disabled=!0):(e.display.disabled=!1,t||Zn(e))}),ci("disableInput",!1,function(e,t){t||Zn(e)},!0),ci("dragDrop",!0),ci("cursorBlinkRate",530),ci("cursorScrollMargin",0),ci("cursorHeight",1,Rt,!0),ci("singleCursorHeightPerLine",!0,Rt,!0),ci("workTime",100),ci("workDelay",100),ci("flattenSpans",!0,N,!0),ci("addModeClass",!1,N,!0),ci("pollInterval",100),ci("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),ci("historyEventDelay",1250),ci("viewportMargin",10,function(e){e.refresh()},!0),ci("maxHighlightLength",1e4,N,!0),ci("moveInputWithCursor",!0,function(e,t){t||(e.display.inputDiv.style.top=e.display.inputDiv.style.left=0)}),ci("tabindex",null,function(e,t){e.display.input.tabIndex=t||""}),ci("autofocus",null);var pi=S.modes={},di=S.mimeModes={};S.defineMode=function(e,t){!S.defaults.mode&&e!="null"&&(S.defaults.mode=e),arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),pi[e]=t},S.defineMIME=function(e,t){di[e]=t},S.resolveMode=function(e){if(typeof e=="string"&&di.hasOwnProperty(e))e=di[e];else if(e&&typeof e.name=="string"&&di.hasOwnProperty(e.name)){var t=di[e.name];typeof t=="string"&&(t={name:t}),e=Uo(t,e),e.name=t.name}else if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return S.resolveMode("application/xml");return typeof e=="string"?{name:e}:e||{name:"null"}},S.getMode=function(e,t){var t=S.resolveMode(t),n=pi[t.name];if(!n)return S.getMode(e,"text/plain");var r=n(e,t);if(vi.hasOwnProperty(t.name)){var i=vi[t.name];for(var s in i){if(!i.hasOwnProperty(s))continue;r.hasOwnProperty(s)&&(r["_"+s]=r[s]),r[s]=i[s]}}r.name=t.name,t.helperType&&(r.helperType=t.helperType);if(t.modeProps)for(var s in t.modeProps)r[s]=t.modeProps[s];return r},S.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),S.defineMIME("text/plain","null");var vi=S.modeExtensions={};S.extendMode=function(e,t){var n=vi.hasOwnProperty(e)?vi[e]:vi[e]={};zo(t,n)},S.defineExtension=function(e,t){S.prototype[e]=t},S.defineDocExtension=function(e,t){js.prototype[e]=t},S.defineOption=ci;var mi=[];S.defineInitHook=function(e){mi.push(e)};var gi=S.helpers={};S.registerHelper=function(e,t,n){gi.hasOwnProperty(e)||(gi[e]=S[e]={_global:[]}),gi[e][t]=n},S.registerGlobalHelper=function(e,t,n,r){S.registerHelper(e,t,r),gi[e]._global.push({pred:n,val:r})};var yi=S.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n},bi=S.startState=function(e,t,n){return e.startState?e.startState(t,n):!0};S.innerMode=function(e,t){while(e.innerMode){var n=e.innerMode(t);if(!n||n.mode==e)break;t=n.state,e=n.mode}return n||{mode:e,state:t}};var wi=S.commands={selectAll:function(e){e.setSelection(ht(e.firstLine(),0),ht(e.lastLine()),Oo)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Oo)},killLine:function(e){oi(e,function(t){if(t.empty()){var n=Us(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line<e.lastLine()?{from:t.head,to:ht(t.head.line+1,0)}:{from:t.head,to:ht(t.head.line,n)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){oi(e,function(t){return{from:ht(t.from().line,0),to:St(e.doc,ht(t.to().line+1,0))}})},delLineLeft:function(e){oi(e,function(e){return{from:ht(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){oi(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){oi(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div");return{from:t.from(),to:r}})},undo:function(e){e.undo()},redo:function(e){e.redo()},undoSelection:function(e){e.undoSelection()},redoSelection:function(e){e.redoSelection()},goDocStart:function(e){e.extendSelection(ht(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(ht(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return Au(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return Mu(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return Ou(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div")},_o)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:n},"div")},_o)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return r.ch<e.getLine(r.line).search(/\S/)?Mu(e,t.head):r},_o)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goGroupRight:function(e){e.moveH(1,"group")},goGroupLeft:function(e){e.moveH(-1,"group")},goWordRight:function(e){e.moveH(1,"word")},delCharBefore:function(e){e.deleteH(-1,"char")},delCharAfter:function(e){e.deleteH(1,"char")},delWordBefore:function(e){e.deleteH(-1,"word")},delWordAfter:function(e){e.deleteH(1,"word")},delGroupBefore:function(e){e.deleteH(-1,"group")},delGroupAfter:function(e){e.deleteH(1,"group")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection("	")},insertSoftTab:function(e){var t=[],n=e.listSelections(),r=e.options.tabSize;for(var i=0;i<n.length;i++){var s=n[i].from(),o=Po(e.getLine(s.line),s.ch,r);t.push((new Array(r-o%r+1)).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Bn(e,function(){var t=e.listSelections(),n=[];for(var r=0;r<t.length;r++){var i=t[r].head,s=Us(e.doc,i.line).text;if(s){i.ch==s.length&&(i=new ht(i.line,i.ch-1));if(i.ch>0)i=new ht(i.line,i.ch+1),e.replaceRange(s.charAt(i.ch-1)+s.charAt(i.ch-2),ht(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var o=Us(e.doc,i.line-1).text;o&&e.replaceRange(s.charAt(0)+"\n"+o.charAt(o.length-1),ht(i.line-1,o.length-1),ht(i.line,1),"+transpose")}}n.push(new yt(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){Bn(e,function(){var t=e.listSelections().length;for(var n=0;n<t;n++){var r=e.listSelections()[n];e.replaceRange("\n",r.anchor,r.head,"+input"),e.indentLine(r.from().line+1,null,!0),ni(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},Ei=S.keyMap={};Ei.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Ei.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Ei.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"},Ei.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Ei["default"]=v?Ei.macDefault:Ei.pcDefault,S.normalizeKeyMap=function(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if(r=="..."){delete e[n];continue}var i=Ro(n.split(" "),Si);for(var s=0;s<i.length;s++){var o,u;s==i.length-1?(u=n,o=r):(u=i.slice(0,s+1).join(" "),o="...");var a=t[u];if(!a)t[u]=o;else if(a!=o)throw new Error("Inconsistent bindings for "+u)}delete e[n]}for(var f in t)e[f]=t[f];return e};var xi=S.lookupKey=function(e,t,n){t=Ci(t);var r=t.call?t.call(e):t[e];if(r===!1)return"nothing";if(r==="...")return"multi";if(r!=null&&n(r))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return xi(e,t.fallthrough,n);for(var i=0;i<t.fallthrough.length;i++){var s=xi(e,t.fallthrough[i],n);if(s)return s}}},Ti=S.isModifierKey=function(e){var t=typeof e=="string"?e:xu[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"},Ni=S.keyName=function(e,t){if(a&&e.keyCode==34&&e["char"])return!1;var n=xu[e.keyCode],r=n;return r==null||e.altGraphKey?!1:(e.altKey&&n!="Alt"&&(r="Alt-"+r),(y?e.metaKey:e.ctrlKey)&&n!="Ctrl"&&(r="Ctrl-"+r),(y?e.ctrlKey:e.metaKey)&&n!="Cmd"&&(r="Cmd-"+r),!t&&e.shiftKey&&n!="Shift"&&(r="Shift-"+r),r)};S.fromTextArea=function(e,t){function r(){e.value=a.getValue()}t||(t={}),t.value=e.value,!t.tabindex&&e.tabindex&&(t.tabindex=e.tabindex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder);if(t.autofocus==null){var n=nu();t.autofocus=n==e||e.getAttribute("autofocus")!=null&&n==document.body}if(e.form){yo(e.form,"submit",r);if(!t.leaveSubmitMethodAlone){var i=e.form,s=i.submit;try{var o=i.submit=function(){r(),i.submit=s,i.submit(),i.submit=o}}catch(u){}}}e.style.display="none";var a=S(function(t){e.parentNode.insertBefore(t,e.nextSibling)},t);return a.save=r,a.getTextArea=function(){return e},a.toTextArea=function(){a.toTextArea=isNaN,r(),e.parentNode.removeChild(a.getWrapperElement()),e.style.display="",e.form&&(bo(e.form,"submit",r),typeof e.form.submit=="function"&&(e.form.submit=s))},a};var ki=S.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};ki.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},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(e){var t=this.string.charAt(this.pos);if(typeof e=="string")var n=t==e;else var n=t&&(e.test?e.test(t):e(t));if(n)return++this.pos,t},eatWhile:function(e){var t=this.pos;while(this.eat(e));return this.pos>t},eatSpace:function(){var e=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Po(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Po(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Po(this.string,null,this.tabSize)-(this.lineStart?Po(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,n){if(typeof e!="string"){var s=this.string.slice(this.pos).match(e);return s&&s.index>0?null:(s&&t!==!1&&(this.pos+=s[0].length),s)}var r=function(e){return n?e.toLowerCase():e},i=this.string.substr(this.pos,e.length);if(r(i)==r(e))return t!==!1&&(this.pos+=e.length),!0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var Li=S.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e};ko(Li),Li.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;t&&kn(e);if(Co(this,"clear")){var n=this.find();n&&So(this,"clear",n.from,n.to)}var r=null,i=null;for(var s=0;s<this.lines.length;++s){var o=this.lines[s],u=ji(o.markedSpans,this);e&&!this.collapsed?zn(e,Vs(o),"text"):e&&(u.to!=null&&(i=Vs(o)),u.from!=null&&(r=Vs(o))),o.markedSpans=Fi(o.markedSpans,u),u.from==null&&this.collapsed&&!ss(this.doc,o)&&e&&Xs(o,xn(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var s=0;s<this.lines.length;++s){var a=ts(this.lines[s]),f=D(a);f>e.display.maxLineLength&&(e.display.maxLine=a,e.display.maxLineLength=f,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&Un(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Bt(e.doc)),e&&So(e,"markerCleared",e,this),t&&An(e),this.parent&&this.parent.clear()},Li.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);var n,r;for(var i=0;i<this.lines.length;++i){var s=this.lines[i],o=ji(s.markedSpans,this);if(o.from!=null){n=ht(t?s:Vs(s),o.from);if(e==-1)return n}if(o.to!=null){r=ht(t?s:Vs(s),o.to);if(e==1)return r}}return n&&{from:n,to:r}},Li.prototype.changed=function(){var e=this.find(-1,!0),t=this,n=this.doc.cm;if(!e||!n)return;Bn(n,function(){var r=e.line,i=Vs(e.line),s=nn(n,i);s&&(fn(s),n.curOp.selectionChanged=n.curOp.forceUpdate=!0),n.curOp.updateMaxLine=!0;if(!ss(t.doc,r)&&t.height!=null){var o=t.height;t.height=null;var u=fs(t)-o;u&&Xs(r,r.height+u)}})},Li.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||qo(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Li.prototype.detachLine=function(e){this.lines.splice(qo(this.lines,e),1);if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var Ai=0,Mi=S.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=this};ko(Mi),Mi.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();So(this,"clear")},Mi.prototype.find=function(e,t){return this.primary.find(e,t)};var us=S.LineWidget=function(e,t,n){if(n)for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.cm=e,this.node=t};ko(us),us.prototype.clear=function(){var e=this.cm,t=this.line.widgets,n=this.line,r=Vs(n);if(r==null||!t)return;for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(n.widgets=null);var s=fs(this);Bn(e,function(){as(e,n,-s),zn(e,r,"widget"),Xs(n,Math.max(0,n.height-s))})},us.prototype.changed=function(){var e=this.height,t=this.cm,n=this.line;this.height=null;var r=fs(this)-e;if(!r)return;Bn(t,function(){t.curOp.forceUpdate=!0,as(t,n,r),Xs(n,n.height+r)})};var cs=S.Line=function(e,t,n){this.text=e,$i(this,t),this.height=n?n(this):1};ko(cs),cs.prototype.lineNo=function(){return Vs(this)};var Ss={},xs={};Ps.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var n=e,r=e+t;n<r;++n){var i=this.lines[n];this.height-=i.height,ps(i),So(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,n){for(var r=e+t;e<r;++e)if(n(this.lines[e]))return!0}},Hs.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n=0;n<this.children.length;++n){var r=this.children[n],i=r.chunkSize();if(e<i){var s=Math.min(t,i-e),o=r.height;r.removeInner(e,s),this.height-=o-r.height,i==s&&(this.children.splice(n--,1),r.parent=null);if((t-=s)==0)break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Ps))){var u=[];this.collapse(u),this.children=[new Ps(u)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,n){this.size+=t.length,this.height+=n;for(var r=0;r<this.children.length;++r){var i=this.children[r],s=i.chunkSize();if(e<=s){i.insertInner(e,t,n);if(i.lines&&i.lines.length>50){while(i.lines.length>50){var o=i.lines.splice(i.lines.length-25,25),u=new Ps(o);i.height-=u.height,this.children.splice(r+1,0,u),u.parent=this}this.maybeSpill()}break}e-=s}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),n=new Hs(t);if(!e.parent){var r=new Hs(e.children);r.parent=e,e.children=[r,n],e=r}else{e.size-=n.size,e.height-=n.height;var i=qo(e.parent.children,e);e.parent.children.splice(i+1,0,n)}n.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN:function(e,t,n){for(var r=0;r<this.children.length;++r){var i=this.children[r],s=i.chunkSize();if(e<s){var o=Math.min(t,s-e);if(i.iterN(e,o,n))return!0;if((t-=o)==0)break;e=0}else e-=s}}};var Bs=0,js=S.Doc=function(e,t,n){if(!(this instanceof js))return new js(e,t,n);n==null&&(n=0),Hs.call(this,[new Ps([new cs("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=n;var r=ht(n,0);this.sel=wt(r),this.history=new Qs(null),this.id=++Bs,this.modeOption=t,typeof e=="string"&&(e=yu(e)),Ds(this,{from:r,to:r,text:e}),Dt(this,wt(r),Oo)};js.prototype=Uo(Hs.prototype,{constructor:js,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){var n=0;for(var r=0;r<t.length;++r)n+=t[r].height;this.insertInner(e-this.first,t,n)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Ws(this,this.first,this.first+this.size);return e===!1?t:t.join(e||"\n")},setValue:In(function(e){var t=ht(this.first,0),n=this.first+this.size-1;Wr(this,{from:t,to:ht(n,Us(this,n).text.length),text:yu(e),origin:"setValue"},!0),Dt(this,wt(t))}),replaceRange:function(e,t,n,r){t=St(this,t),n=n?St(this,n):t,Qr(this,e,t,n,r)},getRange:function(e,t,n){var r=zs(this,St(this,e),St(this,t));return n===!1?r:r.join(n||"\n")},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(Tt(this,e))return Us(this,e)},getLineNumber:function(e){return Vs(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=Us(this,e)),ts(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return St(this,e)},getCursor:function(e){var t=this.sel.primary(),n;return e==null||e=="head"?n=t.head:e=="anchor"?n=t.anchor:e=="end"||e=="to"||e===!1?n=t.to():n=t.from(),n},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:In(function(e,t,n){Ot(this,St(this,typeof e=="number"?ht(e,t||0):e),null,n)}),setSelection:In(function(e,t,n){Ot(this,St(this,e),St(this,t||e),n)}),extendSelection:In(function(e,t,n){kt(this,St(this,e),t&&St(this,t),n)}),extendSelections:In(function(e,t){Lt(this,Nt(this,e,t))}),extendSelectionsBy:In(function(e,t){Lt(this,Ro(this.sel.ranges,e),t)}),setSelections:In(function(e,t,n){if(!e.length)return;for(var r=0,i=[];r<e.length;r++)i[r]=new yt(St(this,e[r].anchor),St(this,e[r].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),Dt(this,bt(i,t),n)}),addSelection:In(function(e,t,n){var r=this.sel.ranges.slice(0);r.push(new yt(St(this,e),St(this,t||e))),Dt(this,bt(r,r.length-1),n)}),getSelection:function(e){var t=this.sel.ranges,n;for(var r=0;r<t.length;r++){var i=zs(this,t[r].from(),t[r].to());n=n?n.concat(i):i}return e===!1?n:n.join(e||"\n")},getSelections:function(e){var t=[],n=this.sel.ranges;for(var r=0;r<n.length;r++){var i=zs(this,n[r].from(),n[r].to());e!==!1&&(i=i.join(e||"\n")),t[r]=i}return t},replaceSelection:function(e,t,n){var r=[];for(var i=0;i<this.sel.ranges.length;i++)r[i]=e;this.replaceSelections(r,t,n||"+input")},replaceSelections:In(function(e,t,n){var r=[],i=this.sel;for(var s=0;s<i.ranges.length;s++){var o=i.ranges[s];r[s]={from:o.from(),to:o.to(),text:yu(e[s]),origin:n}}var u=t&&t!="end"&&Ur(this,r,t);for(var s=r.length-1;s>=0;s--)Wr(this,r[s]);u?_t(this,u):this.cm&&ni(this.cm)}),undo:In(function(){Vr(this,"undo")}),redo:In(function(){Vr(this,"redo")}),undoSelection:In(function(){Vr(this,"undo",!0)}),redoSelection:In(function(){Vr(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){var e=this.history,t=0,n=0;for(var r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var r=0;r<e.undone.length;r++)e.undone[r].ranges||++n;return{undo:t,redo:n}},clearHistory:function(){this.history=new Qs(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:uo(this.history.done),undone:uo(this.history.undone)}},setHistory:function(e){var t=this.history=new Qs(this.history.maxGeneration);t.done=uo(e.done.slice(0),null,!0),t.undone=uo(e.undone.slice(0),null,!0)},addLineClass:In(function(e,t,n){return si(this,e,t=="gutter"?"gutter":"class",function(e){var r=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(!e[r])e[r]=n;else{if(ru(n).test(e[r]))return!1;e[r]+=" "+n}return!0})}),removeLineClass:In(function(e,t,n){return si(this,e,"class",function(e){var r=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",i=e[r];if(!i)return!1;if(n==null)e[r]=null;else{var s=i.match(ru(n));if(!s)return!1;var o=s.index+s[0].length;e[r]=i.slice(0,s.index)+(!s.index||o==i.length?"":" ")+i.slice(o)||null}return!0})}),markText:function(e,t,n){return Oi(this,St(this,e),St(this,t),n,"range")},setBookmark:function(e,t){var n={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared};return e=St(this,e),Oi(this,e,e,n,"bookmark")},findMarksAt:function(e){e=St(this,e);var t=[],n=Us(this,e.line).markedSpans;if(n)for(var r=0;r<n.length;++r){var i=n[r];(i.from==null||i.from<=e.ch)&&(i.to==null||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=St(this,e),t=St(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(s){var o=s.markedSpans;if(o)for(var u=0;u<o.length;u++){var a=o[u];!(i==e.line&&e.ch>a.to||a.from==null&&i!=e.line||i==t.line&&a.from>t.ch)&&(!n||n(a.marker))&&r.push(a.marker.parent||a.marker)}++i}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var r=0;r<n.length;++r)n[r].from!=null&&e.push(n[r].marker)}),e},posFromIndex:function(e){var t,n=this.first;return this.iter(function(r){var i=r.text.length+1;if(i>e)return t=e,!0;e-=i,++n}),St(this,ht(n,t))},indexFromPos:function(e){e=St(this,e);var t=e.ch;return e.line<this.first||e.ch<0?0:(this.iter(this.first,e.line,function(e){t+=e.text.length+1}),t)},copy:function(e){var t=new js(Ws(this,this.first,this.first+this.size),this.modeOption,this.first);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,n=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<n&&(n=e.to);var r=new js(Ws(this,t,n),e.mode||this.modeOption,t);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Pi(r,Di(this)),r},unlinkDoc:function(e){e instanceof S&&(e=e.doc);if(this.linked)for(var t=0;t<this.linked.length;++t){var n=this.linked[t];if(n.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),Hi(Di(this));break}if(e.history==this.history){var r=[e.id];qs(e,function(e){r.push(e.id)},!0),e.history=new Qs(null),e.history.done=uo(this.history.done,r),e.history.undone=uo(this.history.undone,r)}},iterLinkedDocs:function(e){qs(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),js.prototype.eachLine=js.prototype.iter;var Fs="iter insert remove copy getEditor".split(" ");for(var Is in js.prototype)js.prototype.hasOwnProperty(Is)&&qo(Fs,Is)<0&&(S.prototype[Is]=function(e){return function(){return e.apply(this.doc,arguments)}}(js.prototype[Is]));ko(js);var co=S.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},ho=S.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},vo=S.e_stop=function(e){co(e),ho(e)},yo=S.on=function(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else if(e.attachEvent)e.attachEvent("on"+t,n);else{var r=e._handlers||(e._handlers={}),i=r[t]||(r[t]=[]);i.push(n)}},bo=S.off=function(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else if(e.detachEvent)e.detachEvent("on"+t,n);else{var r=e._handlers&&e._handlers[t];if(!r)return;for(var i=0;i<r.length;++i)if(r[i]==n){r.splice(i,1);break}}},wo=S.signal=function(e,t){var n=e._handlers&&e._handlers[t];if(!n)return;var r=Array.prototype.slice.call(arguments,2);for(var i=0;i<n.length;++i)n[i].apply(null,r)},Eo=null,Lo=30,Ao=S.Pass={toString:function(){return"CodeMirror.Pass"}},Oo={scroll:!1},Mo={origin:"*mouse"},_o={origin:"+move"};Do.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Po=S.countColumn=function(e,t,n,r,i){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var s=r||0,o=i||0;;){var u=e.indexOf("	",s);if(u<0||u>=t)return o+(t-s);o+=u-s,o+=n-o%n,s=u+1}},Bo=[""],Io=function(e){e.select()};p?Io=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:r&&(Io=function(e){try{e.select()}catch(t){}}),[].indexOf&&(qo=function(e,t){return e.indexOf(t)}),[].map&&(Ro=function(e,t){return e.map(t)});var Xo=/[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Vo=S.isWordChar=function(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||Xo.test(e))},Ko=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,Yo;document.createRange?Yo=function(e,t,n){var r=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}:Yo=function(e,t,n){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(i){return r}return r.collapse(!0),r.moveEnd("character",n),r.moveStart("character",t),r},r&&i<11&&(nu=function(){try{return document.activeElement}catch(e){return document.body}});var iu=S.rmClass=function(e,t){var n=e.className,r=ru(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}},su=S.addClass=function(e,t){var n=e.className;ru(t).test(n)||(e.className+=(n?" ":"")+t)},au=!1,cu=function(){if(r&&i<9)return!1;var e=Go("div");return"draggable"in e||"dragDrop"in e}(),hu,du,mu,yu=S.splitLines="\n\nb".split(/\n/).length!=3?function(e){var t=0,n=[],r=e.length;while(t<=r){var i=e.indexOf("\n",t);i==-1&&(i=e.length);var s=e.slice(t,e.charAt(i-1)=="\r"?i-1:i),o=s.indexOf("\r");o!=-1?(n.push(s.slice(0,o)),t+=o+1):(n.push(s),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},bu=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(n){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},wu=function(){var e=Go("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),Eu=null,xu={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};S.keyNames=xu,function(){for(var e=0;e<10;e++)xu[e+48]=xu[e+96]=String(e);for(var e=65;e<=90;e++)xu[e]=String.fromCharCode(e);for(var e=1;e<=12;e++)xu[e+111]=xu[e+63235]="F"+e}();var Du,Fu=function(){function n(n){return n<=247?e.charAt(n):1424<=n&&n<=1524?"R":1536<=n&&n<=1773?t.charAt(n-1536):1774<=n&&n<=2220?"r":8192<=n&&n<=8203?"w":n==8204?"b":"L"}function f(e,t,n){this.level=e,this.from=t,this.to=n}var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,s=/[LRr]/,o=/[Lb1n]/,u=/[1n]/,a="L";return function(e){if(!r.test(e))return!1;var t=e.length,l=[];for(var c=0,h;c<t;++c)l.push(h=n(e.charCodeAt(c)));for(var c=0,p=a;c<t;++c){var h=l[c];h=="m"?l[c]=p:p=h}for(var c=0,d=a;c<t;++c){var h=l[c];h=="1"&&d=="r"?l[c]="n":s.test(h)&&(d=h,h=="r"&&(l[c]="R"))}for(var c=1,p=l[0];c<t-1;++c){var h=l[c];h=="+"&&p=="1"&&l[c+1]=="1"?l[c]="1":h==","&&p==l[c+1]&&(p=="1"||p=="n")&&(l[c]=p),p=h}for(var c=0;c<t;++c){var h=l[c];if(h==",")l[c]="N";else if(h=="%"){for(var v=c+1;v<t&&l[v]=="%";++v);var m=c&&l[c-1]=="!"||v<t&&l[v]=="1"?"1":"N";for(var g=c;g<v;++g)l[g]=m;c=v-1}}for(var c=0,d=a;c<t;++c){var h=l[c];d=="L"&&h=="1"?l[c]="L":s.test(h)&&(d=h)}for(var c=0;c<t;++c)if(i.test(l[c])){for(var v=c+1;v<t&&i.test(l[v]);++v);var y=(c?l[c-1]:a)=="L",b=(v<t?l[v]:a)=="L",m=y||b?"L":"R";for(var g=c;g<v;++g)l[g]=m;c=v-1}var w=[],E;for(var c=0;c<t;)if(o.test(l[c])){var S=c;for(++c;c<t&&o.test(l[c]);++c);w.push(new f(0,S,c))}else{var x=c,T=w.length;for(++c;c<t&&l[c]!="L";++c);for(var g=x;g<c;)if(u.test(l[g])){x<g&&w.splice(T,0,new f(1,x,g));var N=g;for(++g;g<c&&u.test(l[g]);++g);w.splice(T,0,new f(2,N,g)),x=g}else++g;x<c&&w.splice(T,0,new f(1,x,c))}return w[0].level==1&&(E=e.match(/^\s+/))&&(w[0].from=E[0].length,w.unshift(new f(0,0,E[0].length))),Fo(w).level==1&&(E=e.match(/\s+$/))&&(Fo(w).to-=E[0].length,w.push(new f(0,t-E[0].length,t))),w[0].level!=Fo(w).level&&w.push(new f(w[0].level,t,t)),w}}();return S.version="4.8.0",S}),define("CMLint",["react","lodash","jquery","./libs/codemirror-4.8/lib/codemirror"],function(e,t,n,r){function i(e){var t=e.severity;t||(t="error");var n=document.createElement("div");return n.className="CodeMirror-lint-message-"+t,n.appendChild(document.createTextNode(e.message)),n}function o(e,t){var n=document.createDocumentFragment(),r={severity:"error",message:t.message};n.appendChild(i(r)),e.setGutterMarker(Math.max(t.line,0),s,a(n,"error",!1,"state.options.tooltips"))}function u(e){e.clearGutter(s)}function a(e,t,n,i){var s=document.createElement("div"),o=s;return s.className="CodeMirror-lint-marker-"+t,n&&(o=s.appendChild(document.createElement("div")),o.className="CodeMirror-lint-marker-multiple"),i!==!1&&r.on(o,"mouseover",function(t){h(t,e,o)}),s}function f(e,t){function i(e){if(!n.parentNode)return r.off(document,"mousemove",i);n.style.top=Math.max(0,e.clientY-n.offsetHeight-5)+"px",n.style.left=e.clientX+5+"px"}var n=document.createElement("div");return n.className="CodeMirror-lint-tooltip",n.appendChild(t.cloneNode(!0)),document.body.appendChild(n),r.on(document,"mousemove",i),i(e),n.style.opacity!==null&&(n.style.opacity=1),n}function l(e){e.parentNode&&e.parentNode.removeChild(e)}function c(e){if(!e.parentNode)return;e.style.opacity===null&&l(e),e.style.opacity=0,setTimeout(function(){l(e)},600)}function h(e,t,n){function s(){r.off(n,"mouseout",s),i&&(c(i),i=null)}var i=f(e,t),o=setInterval(function(){if(i)for(var e=n;;e=e.parentNode){if(e===document.body)return undefined;if(!e){s();break}}if(!i)return clearInterval(o)},400);r.on(n,"mouseout",s)}var s="rt-annotations";return{GUTTER_ID:s,annotate:o,clearMarks:u}}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/mode/javascript/javascript",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineMode("javascript",function(t,n){function h(e){var t=!1,n,r=!1;while((n=e.next())!=null){if(!t){if(n=="/"&&!r)return;n=="["?r=!0:r&&n=="]"&&(r=!1)}t=!t&&n=="\\"}}function v(e,t,n){return p=e,d=n,t}function m(e,t){var n=e.next();if(n=='"'||n=="'")return t.tokenize=g(n),t.tokenize(e,t);if(n=="."&&e.match(/^\d+(?:[eE][+\-]?\d+)?/))return v("number","number");if(n=="."&&e.match(".."))return v("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return v(n);if(n=="="&&e.eat(">"))return v("=>","operator");if(n=="0"&&e.eat(/x/i))return e.eatWhile(/[\da-f]/i),v("number","number");if(/\d/.test(n))return e.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),v("number","number");if(n=="/")return e.eat("*")?(t.tokenize=y,y(e,t)):e.eat("/")?(e.skipToEnd(),v("comment","comment")):t.lastType=="operator"||t.lastType=="keyword c"||t.lastType=="sof"||/^[\[{}\(,;:]$/.test(t.lastType)?(h(e),e.eatWhile(/[gimy]/),v("regexp","string-2")):(e.eatWhile(l),v("operator","operator",e.current()));if(n=="`")return t.tokenize=b,b(e,t);if(n=="#")return e.skipToEnd(),v("error","error");if(l.test(n))return e.eatWhile(l),v("operator","operator",e.current());if(a.test(n)){e.eatWhile(a);var r=e.current(),i=f.propertyIsEnumerable(r)&&f[r];return i&&t.lastType!="."?v(i.type,i.style,r):v("variable","variable",r)}}function g(e){return function(t,n){var r=!1,i;if(s&&t.peek()=="@"&&t.match(c))return n.tokenize=m,v("jsonld-keyword","meta");while((i=t.next())!=null){if(i==e&&!r)break;r=!r&&i=="\\"}return r||(n.tokenize=m),v("string","string")}}function y(e,t){var n=!1,r;while(r=e.next()){if(r=="/"&&n){t.tokenize=m;break}n=r=="*"}return v("comment","comment")}function b(e,t){var n=!1,r;while((r=e.next())!=null){if(!n&&(r=="`"||r=="$"&&e.eat("{"))){t.tokenize=m;break}n=!n&&r=="\\"}return v("quasi","string-2",e.current())}function E(e,t){t.fatArrowAt&&(t.fatArrowAt=null);var n=e.string.indexOf("=>",e.start);if(n<0)return;var r=0,i=!1;for(var s=n-1;s>=0;--s){var o=e.string.charAt(s),u=w.indexOf(o);if(u>=0&&u<3){if(!r){++s;break}if(--r==0)break}else if(u>=3&&u<6)++r;else if(a.test(o))i=!0;else if(i&&!r){++s;break}}i&&!r&&(t.fatArrowAt=s)}function x(e,t,n,r,i,s){this.indented=e,this.column=t,this.type=n,this.prev=i,this.info=s,r!=null&&(this.align=r)}function T(e,t){for(var n=e.localVars;n;n=n.next)if(n.name==t)return!0;for(var r=e.context;r;r=r.prev)for(var n=r.vars;n;n=n.next)if(n.name==t)return!0}function N(e,t,n,r,i){var s=e.cc;C.state=e,C.stream=i,C.marked=null,C.cc=s,C.style=t,e.lexical.hasOwnProperty("align")||(e.lexical.align=!0);for(;;){var u=s.length?s.pop():o?j:B;if(u(n,r)){while(s.length&&s[s.length-1].lex)s.pop()();return C.marked?C.marked:n=="variable"&&T(e,r)?"variable-2":t}}}function k(){for(var e=arguments.length-1;e>=0;e--)C.cc.push(arguments[e])}function L(){return k.apply(null,arguments),!0}function A(e){function t(t){for(var n=t;n;n=n.next)if(n.name==e)return!0;return!1}var r=C.state;if(r.context){C.marked="def";if(t(r.localVars))return;r.localVars={name:e,next:r.localVars}}else{if(t(r.globalVars))return;n.globalVars&&(r.globalVars={name:e,next:r.globalVars})}}function M(){C.state.context={prev:C.state.context,vars:C.state.localVars},C.state.localVars=O}function _(){C.state.localVars=C.state.context.vars,C.state.context=C.state.context.prev}function D(e,t){var n=function(){var n=C.state,r=n.indented;if(n.lexical.type=="stat")r=n.lexical.indented;else for(var i=n.lexical;i&&i.type==")"&&i.align;i=i.prev)r=i.indented;n.lexical=new x(r,C.stream.column(),e,null,n.lexical,t)};return n.lex=!0,n}function P(){var e=C.state;e.lexical.prev&&(e.lexical.type==")"&&(e.indented=e.lexical.indented),e.lexical=e.lexical.prev)}function H(e){function t(n){return n==e?L():e==";"?k():L(t)}return t}function B(e,t){return e=="var"?L(D("vardef",t.length),it,H(";"),P):e=="keyword a"?L(D("form"),j,B,P):e=="keyword b"?L(D("form"),B,P):e=="{"?L(D("}"),tt,P):e==";"?L():e=="if"?(C.state.lexical.info=="else"&&C.state.cc[C.state.cc.length-1]==P&&C.state.cc.pop()(),L(D("form"),j,B,P,ft)):e=="function"?L(vt):e=="for"?L(D("form"),lt,B,P):e=="variable"?L(D("stat"),J):e=="switch"?L(D("form"),j,D("}","switch"),H("{"),tt,P,P):e=="case"?L(j,H(":")):e=="default"?L(H(":")):e=="catch"?L(D("form"),M,H("("),mt,H(")"),B,P,_):e=="module"?L(D("form"),M,Et,_,P):e=="class"?L(D("form"),gt,P):e=="export"?L(D("form"),St,P):e=="import"?L(D("form"),xt,P):k(D("stat"),j,H(";"),P)}function j(e){return I(e,!1)}function F(e){return I(e,!0)}function I(e,t){if(C.state.fatArrowAt==C.stream.start){var n=t?$:V;if(e=="(")return L(M,D(")"),Z(st,")"),P,H("=>"),n,_);if(e=="variable")return k(M,st,H("=>"),n,_)}var r=t?z:U;return S.hasOwnProperty(e)?L(r):e=="function"?L(vt,r):e=="keyword c"?L(t?R:q):e=="("?L(D(")"),q,Lt,H(")"),P,r):e=="operator"||e=="spread"?L(t?F:j):e=="["?L(D("]"),Ct,P,r):e=="{"?et(Q,"}",null,r):e=="quasi"?k(W,r):L()}function q(e){return e.match(/[;\}\)\],]/)?k():k(j)}function R(e){return e.match(/[;\}\)\],]/)?k():k(F)}function U(e,t){return e==","?L(j):z(e,t,!1)}function z(e,t,n){var r=n==0?U:z,i=n==0?j:F;if(e=="=>")return L(M,n?$:V,_);if(e=="operator")return/\+\+|--/.test(t)?L(r):t=="?"?L(j,H(":"),i):L(i);if(e=="quasi")return k(W,r);if(e==";")return;if(e=="(")return et(F,")","call",r);if(e==".")return L(K,r);if(e=="[")return L(D("]"),q,H("]"),P,r)}function W(e,t){return e!="quasi"?k():t.slice(t.length-2)!="${"?L(W):L(j,X)}function X(e){if(e=="}")return C.marked="string-2",C.state.tokenize=b,L(W)}function V(e){return E(C.stream,C.state),k(e=="{"?B:j)}function $(e){return E(C.stream,C.state),k(e=="{"?B:F)}function J(e){return e==":"?L(P,B):k(U,H(";"),P)}function K(e){if(e=="variable")return C.marked="property",L()}function Q(e,t){if(e=="variable"||C.style=="keyword")return C.marked="property",t=="get"||t=="set"?L(G):L(Y);if(e=="number"||e=="string")return C.marked=s?"property":C.style+" property",L(Y);if(e=="jsonld-keyword")return L(Y);if(e=="[")return L(j,H("]"),Y)}function G(e){return e!="variable"?k(Y):(C.marked="property",L(vt))}function Y(e){if(e==":")return L(F);if(e=="(")return k(vt)}function Z(e,t){function n(r){if(r==","){var i=C.state.lexical;return i.info=="call"&&(i.pos=(i.pos||0)+1),L(e,n)}return r==t?L():L(H(t))}return function(r){return r==t?L():k(e,n)}}function et(e,t,n){for(var r=3;r<arguments.length;r++)C.cc.push(arguments[r]);return L(D(t,n),Z(e,t),P)}function tt(e){return e=="}"?L():k(B,tt)}function nt(e){if(u&&e==":")return L(rt)}function rt(e){if(e=="variable")return C.marked="variable-3",L()}function it(){return k(st,nt,ut,at)}function st(e,t){if(e=="variable")return A(t),L();if(e=="[")return et(st,"]");if(e=="{")return et(ot,"}")}function ot(e,t){return e=="variable"&&!C.stream.match(/^\s*:/,!1)?(A(t),L(ut)):(e=="variable"&&(C.marked="property"),L(H(":"),st,ut))}function ut(e,t){if(t=="=")return L(F)}function at(e){if(e==",")return L(it)}function ft(e,t){if(e=="keyword b"&&t=="else")return L(D("form","else"),B,P)}function lt(e){if(e=="(")return L(D(")"),ct,H(")"),P)}function ct(e){return e=="var"?L(it,H(";"),pt):e==";"?L(pt):e=="variable"?L(ht):k(j,H(";"),pt)}function ht(e,t){return t=="in"||t=="of"?(C.marked="keyword",L(j)):L(U,pt)}function pt(e,t){return e==";"?L(dt):t=="in"||t=="of"?(C.marked="keyword",L(j)):k(j,H(";"),dt)}function dt(e){e!=")"&&L(j)}function vt(e,t){if(t=="*")return C.marked="keyword",L(vt);if(e=="variable")return A(t),L(vt);if(e=="(")return L(M,D(")"),Z(mt,")"),P,B,_)}function mt(e){return e=="spread"?L(mt):k(st,nt)}function gt(e,t){if(e=="variable")return A(t),L(yt)}function yt(e,t){if(t=="extends")return L(j,yt);if(e=="{")return L(D("}"),bt,P)}function bt(e,t){if(e=="variable"||C.style=="keyword")return C.marked="property",t=="get"||t=="set"?L(wt,vt,bt):L(vt,bt);if(t=="*")return C.marked="keyword",L(bt);if(e==";")return L(bt);if(e=="}")return L()}function wt(e){return e!="variable"?k():(C.marked="property",L())}function Et(e,t){if(e=="string")return L(B);if(e=="variable")return A(t),L(Nt)}function St(e,t){return t=="*"?(C.marked="keyword",L(Nt,H(";"))):t=="default"?(C.marked="keyword",L(j,H(";"))):k(B)}function xt(e){return e=="string"?L():k(Tt,Nt)}function Tt(e,t){return e=="{"?et(Tt,"}"):(e=="variable"&&A(t),L())}function Nt(e,t){if(t=="from")return C.marked="keyword",L(j)}function Ct(e){return e=="]"?L():k(F,kt)}function kt(e){return e=="for"?k(Lt,H("]")):e==","?L(Z(R,"]")):k(Z(F,"]"))}function Lt(e){if(e=="for")return L(lt,Lt);if(e=="if")return L(j,Lt)}var r=t.indentUnit,i=n.statementIndent,s=n.jsonld,o=n.json||s,u=n.typescript,a=n.wordCharacters||/[\w$\xa1-\uffff]/,f=function(){function e(e){return{type:e,style:"keyword"}}var t=e("keyword a"),n=e("keyword b"),r=e("keyword c"),i=e("operator"),s={type:"atom",style:"atom"},o={"if":e("if"),"while":t,"with":t,"else":n,"do":n,"try":n,"finally":n,"return":r,"break":r,"continue":r,"new":r,"delete":r,"throw":r,"debugger":r,"var":e("var"),"const":e("var"),let:e("var"),"function":e("function"),"catch":e("catch"),"for":e("for"),"switch":e("switch"),"case":e("case"),"default":e("default"),"in":i,"typeof":i,"instanceof":i,"true":s,"false":s,"null":s,"undefined":s,NaN:s,Infinity:s,"this":e("this"),module:e("module"),"class":e("class"),"super":e("atom"),yield:r,"export":e("export"),"import":e("import"),"extends":r};if(u){var a={type:"variable",style:"variable-3"},f={"interface":e("interface"),"extends":e("extends"),constructor:e("constructor"),"public":e("public"),"private":e("private"),"protected":e("protected"),"static":e("static"),string:a,number:a,bool:a,any:a};for(var l in f)o[l]=f[l]}return o}(),l=/[+\-*&%=<>!?|~^]/,c=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,p,d,w="([{}])",S={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},C={state:null,column:null,marked:null,cc:null},O={name:"this",next:{name:"arguments"}};return P.lex=!0,{startState:function(e){var t={tokenize:m,lastType:"sof",cc:[],lexical:new x((e||0)-r,0,"block",!1),localVars:n.localVars,context:n.localVars&&{vars:n.localVars},indented:0};return n.globalVars&&typeof n.globalVars=="object"&&(t.globalVars=n.globalVars),t},token:function(e,t){e.sol()&&(t.lexical.hasOwnProperty("align")||(t.lexical.align=!1),t.indented=e.indentation(),E(e,t));if(t.tokenize!=y&&e.eatSpace())return null;var n=t.tokenize(e,t);return p=="comment"?n:(t.lastType=p!="operator"||d!="++"&&d!="--"?p:"incdec",N(t,n,p,d,e))},indent:function(t,s){if(t.tokenize==y)return e.Pass;if(t.tokenize!=m)return 0;var o=s&&s.charAt(0),u=t.lexical;if(!/^\s*else\b/.test(s))for(var a=t.cc.length-1;a>=0;--a){var f=t.cc[a];if(f==P)u=u.prev;else if(f!=ft)break}u.type=="stat"&&o=="}"&&(u=u.prev),i&&u.type==")"&&u.prev.type=="stat"&&(u=u.prev);var l=u.type,c=o==l;return l=="vardef"?u.indented+(t.lastType=="operator"||t.lastType==","?u.info+1:0):l=="form"&&o=="{"?u.indented:l=="form"?u.indented+r:l=="stat"?u.indented+(t.lastType=="operator"||t.lastType==","?i||r:0):u.info=="switch"&&!c&&n.doubleIndentSwitch!=0?u.indented+(/^(?:case|default)\b/.test(s)?r:2*r):u.align?u.column+(c?0:1):u.indented+(c?0:r)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:o?null:"/*",blockCommentEnd:o?null:"*/",lineComment:o?null:"//",fold:"brace",helperType:o?"json":"javascript",jsonldMode:s,jsonMode:o}}),e.registerHelper("wordChars","javascript",/[\w$]/),e.defineMIME("text/javascript","javascript"),e.defineMIME("text/ecmascript","javascript"),e.defineMIME("application/javascript","javascript"),e.defineMIME("application/x-javascript","javascript"),e.defineMIME("application/ecmascript","javascript"),e.defineMIME("application/json",{name:"javascript",json:!0}),e.defineMIME("application/x-json",{name:"javascript",json:!0}),e.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),e.defineMIME("text/typescript",{name:"javascript",typescript:!0}),e.defineMIME("application/typescript",{name:"javascript",typescript:!0})}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/hint/xml-hint",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function n(n,r){var i=r&&r.schemaInfo,s=r&&r.quoteChar||'"';if(!i)return;var o=n.getCursor(),u=n.getTokenAt(o);if(/^<\/?$/.test(u.string)&&u.end==o.ch){var a=n.getTokenAt(t(o.line,o.ch+1));a.start==o.ch&&/\btag\b/.test(a.type)&&(u=a)}var f=e.innerMode(n.getMode(),u.state);if(f.mode.name!="xml")return;var l=[],c=!1,h,p=/\btag\b/.test(u.type)&&!/>$/.test(u.string),d=p&&/^\w/.test(u.string),v;if(d){var m=n.getLine(o.line).slice(Math.max(0,u.start-2),u.start),g=/<\/$/.test(m)?"close":/<$/.test(m)?"open":null;g&&(v=u.start-(g=="close"?2:1))}else p&&u.string=="<"?g="open":p&&u.string=="</"&&(g="close");if(!p&&!f.state.tagName||g){d&&(h=u.string),c=g;var y=f.state.context,b=y&&i[y.tagName],w=y?b&&b.children:i["!top"];if(w&&g!="close")for(var E=0;E<w.length;++E)(!h||w[E].lastIndexOf(h,0)==0)&&l.push("<"+w[E]);else if(g!="close")for(var S in i)i.hasOwnProperty(S)&&S!="!top"&&S!="!attrs"&&(!h||S.lastIndexOf(h,0)==0)&&l.push("<"+S);y&&(!h||g=="close"&&y.tagName.lastIndexOf(h,0)==0)&&l.push("</"+y.tagName+">")}else{var b=i[f.state.tagName],x=b&&b.attrs,T=i["!attrs"];if(!x&&!T)return;if(!x)x=T;else if(T){var N={};for(var C in T)T.hasOwnProperty(C)&&(N[C]=T[C]);for(var C in x)x.hasOwnProperty(C)&&(N[C]=x[C]);x=N}if(u.type=="string"||u.string=="="){var m=n.getRange(t(o.line,Math.max(0,o.ch-60)),t(o.line,u.type=="string"?u.start:u.end)),k=m.match(/([^\s\u00a0=<>\"\']+)=$/),L;if(!k||!x.hasOwnProperty(k[1])||!(L=x[k[1]]))return;typeof L=="function"&&(L=L.call(this,n));if(u.type=="string"){h=u.string;var A=0;/['"]/.test(u.string.charAt(0))&&(s=u.string.charAt(0),h=u.string.slice(1),A++);var O=u.string.length;/['"]/.test(u.string.charAt(O-1))&&(s=u.string.charAt(O-1),h=u.string.substr(A,O-2)),c=!0}for(var E=0;E<L.length;++E)(!h||L[E].lastIndexOf(h,0)==0)&&l.push(s+L[E]+s)}else{u.type=="attribute"&&(h=u.string,c=!0);for(var M in x)x.hasOwnProperty(M)&&(!h||M.lastIndexOf(h,0)==0)&&l.push(M)}}return{list:l,from:c?t(o.line,v==null?u.start:v):o,to:c?t(o.line,u.end):o}}var t=e.Pos;e.registerHelper("hint","xml",n)}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror","./xml-hint")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/hint/html-hint",["../../lib/codemirror","./xml-hint"],e):e(CodeMirror)}(function(e){function l(e){for(var t in f)f.hasOwnProperty(t)&&(e.attrs[t]=f[t])}function h(t,n){var r={schemaInfo:a};if(n)for(var i in n)r[i]=n[i];return e.hint.xml(t,r)}var t="ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" "),n=["_blank","_self","_top","_parent"],r=["ascii","utf-8","utf-16","latin1","latin1"],i=["get","post","put","delete"],s=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],o=["all","screen","print","embossed","braille","handheld","print","projection","screen","tty","tv","speech","3d-glasses","resolution [>][<][=] [X]","device-aspect-ratio: X/Y","orientation:portrait","orientation:landscape","device-height: [X]","device-width: [X]"],u={attrs:{}},a={a:{attrs:{href:null,ping:null,type:null,media:o,target:n,hreflang:t}},abbr:u,acronym:u,address:u,applet:u,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:o,hreflang:t,type:null,shape:["default","rect","circle","poly"]}},article:u,aside:u,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["","autoplay"],loop:["","loop"],controls:["","controls"]}},b:u,base:{attrs:{href:null,target:n}},basefont:u,bdi:u,bdo:u,big:u,blockquote:{attrs:{cite:null}},body:u,br:u,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["","autofocus"],disabled:["","autofocus"],formenctype:s,formmethod:i,formnovalidate:["","novalidate"],formtarget:n,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:u,center:u,cite:u,code:u,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["","disabled"],checked:["","checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["","disabled"],multiple:["","multiple"]}},datalist:{attrs:{data:null}},dd:u,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["","open"]}},dfn:u,dir:u,div:u,dl:u,dt:u,em:u,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["","disabled"],form:null,name:null}},figcaption:u,figure:u,font:u,footer:u,form:{attrs:{action:null,name:null,"accept-charset":r,autocomplete:["on","off"],enctype:s,method:i,novalidate:["","novalidate"],target:n}},frame:u,frameset:u,h1:u,h2:u,h3:u,h4:u,h5:u,h6:u,head:{attrs:{},children:["title","base","link","style","meta","script","noscript","command"]},header:u,hgroup:u,hr:u,html:{attrs:{manifest:null},children:["head","body"]},i:u,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["","seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["","autofocus"],checked:["","checked"],disabled:["","disabled"],formenctype:s,formmethod:i,formnovalidate:["","novalidate"],formtarget:n,multiple:["","multiple"],readonly:["","readonly"],required:["","required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:u,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["","autofocus"],disabled:["","disabled"],keytype:["RSA"]}},label:{attrs:{"for":null,form:null}},legend:u,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:t,media:o,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:u,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:r,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:u,noframes:u,noscript:u,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["","typemustmatch"]}},ol:{attrs:{reversed:["","reversed"],start:null,type:["1","a","A","i","I"]}},optgroup:{attrs:{disabled:["","disabled"],label:null}},option:{attrs:{disabled:["","disabled"],label:null,selected:["","selected"],value:null}},output:{attrs:{"for":null,form:null,name:null}},p:u,param:{attrs:{name:null,value:null}},pre:u,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:u,rt:u,ruby:u,s:u,samp:u,script:{attrs:{type:["text/javascript"],src:null,async:["","async"],defer:["","defer"],charset:r}},section:u,select:{attrs:{form:null,name:null,size:null,autofocus:["","autofocus"],disabled:["","disabled"],multiple:["","multiple"]}},small:u,source:{attrs:{src:null,type:null,media:null}},span:u,strike:u,strong:u,style:{attrs:{type:["text/css"],media:o,scoped:null}},sub:u,summary:u,sup:u,table:u,tbody:u,td:{attrs:{colspan:null,rowspan:null,headers:null}},textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["","autofocus"],disabled:["","disabled"],readonly:["","readonly"],required:["","required"],wrap:["soft","hard"]}},tfoot:u,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:u,time:{attrs:{datetime:null}},title:u,tr:u,track:{attrs:{src:null,label:null,"default":null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:t}},tt:u,u:u,ul:u,"var":u,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["","autoplay"],mediagroup:["movie"],muted:["","muted"],controls:["","controls"]}},wbr:u},f={accesskey:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"],"class":null,contenteditable:["true","false"],contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["en","es"],spellcheck:["true","false"],style:null,tabindex:["1","2","3","4","5","6","7","8","9"],title:null,translate:["yes","no"],onclick:null,rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"]};l(u);for(var c in a)a.hasOwnProperty(c)&&a[c]!=u&&l(a[c]);e.htmlSchema=a,e.registerHelper("hint","html",h)}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/hint/show-hint",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function r(e,t){this.cm=e,this.options=this.buildOptions(t),this.widget=this.onClose=null}function i(e){return typeof e=="string"?e:e.text}function s(e,t){function s(e,r){var s;typeof r!="string"?s=function(e){return r(e,t)}:n.hasOwnProperty(r)?s=n[r]:s=r,i[e]=s}var n={Up:function(){t.moveFocus(-1)},Down:function(){t.moveFocus(1)},PageUp:function(){t.moveFocus(-t.menuSize()+1,!0)},PageDown:function(){t.moveFocus(t.menuSize()-1,!0)},Home:function(){t.setFocus(0)},End:function(){t.setFocus(t.length-1)},Enter:t.pick,Tab:t.pick,Esc:t.close},r=e.options.customKeys,i=r?{}:n;if(r)for(var o in r)r.hasOwnProperty(o)&&s(o,r[o]);var u=e.options.extraKeys;if(u)for(var o in u)u.hasOwnProperty(o)&&s(o,u[o]);return i}function o(e,t){while(t&&t!=e){if(t.nodeName.toUpperCase()==="LI"&&t.parentNode==e)return t;t=t.parentNode}}function u(r,u){this.completion=r,this.data=u;var a=this,f=r.cm,l=this.hints=document.createElement("ul");l.className="CodeMirror-hints",this.selectedHint=u.selectedHint||0;var c=u.list;for(var h=0;h<c.length;++h){var p=l.appendChild(document.createElement("li")),d=c[h],v=t+(h!=this.selectedHint?"":" "+n);d.className!=null&&(v=d.className+" "+v),p.className=v,d.render?d.render(p,u,d):p.appendChild(document.createTextNode(d.displayText||i(d))),p.hintId=h}var m=f.cursorCoords(r.options.alignWithWord?u.from:null),g=m.left,y=m.bottom,b=!0;l.style.left=g+"px",l.style.top=y+"px";var w=window.innerWidth||Math.max(document.body.offsetWidth,document.documentElement.offsetWidth),E=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(r.options.container||document.body).appendChild(l);var S=l.getBoundingClientRect(),x=S.bottom-E;if(x>0){var T=S.bottom-S.top,N=m.top-(m.bottom-S.top);if(N-T>0)l.style.top=(y=m.top-T)+"px",b=!1;else if(T>E){l.style.height=E-5+"px",l.style.top=(y=m.bottom-S.top)+"px";var C=f.getCursor();u.from.ch!=C.ch&&(m=f.cursorCoords(C),l.style.left=(g=m.left)+"px",S=l.getBoundingClientRect())}}var k=S.left-w;k>0&&(S.right-S.left>w&&(l.style.width=w-5+"px",k-=S.right-S.left-w),l.style.left=(g=m.left-k)+"px"),f.addKeyMap(this.keyMap=s(r,{moveFocus:function(e,t){a.changeActive(a.selectedHint+e,t)},setFocus:function(e){a.changeActive(e)},menuSize:function(){return a.screenAmount()},length:c.length,close:function(){r.close()},pick:function(){a.pick()},data:u}));if(r.options.closeOnUnfocus){var L;f.on("blur",this.onBlur=function(){L=setTimeout(function(){r.close()},100)}),f.on("focus",this.onFocus=function(){clearTimeout(L)})}var A=f.getScrollInfo();return f.on("scroll",this.onScroll=function(){var e=f.getScrollInfo(),t=f.getWrapperElement().getBoundingClientRect(),n=y+A.top-e.top,i=n-(window.pageYOffset||(document.documentElement||document.body).scrollTop);b||(i+=l.offsetHeight);if(i<=t.top||i>=t.bottom)return r.close();l.style.top=n+"px",l.style.left=g+A.left-e.left+"px"}),e.on(l,"dblclick",function(e){var t=o(l,e.target||e.srcElement);t&&t.hintId!=null&&(a.changeActive(t.hintId),a.pick())}),e.on(l,"click",function(e){var t=o(l,e.target||e.srcElement);t&&t.hintId!=null&&(a.changeActive(t.hintId),r.options.completeOnSingleClick&&a.pick())}),e.on(l,"mousedown",function(){setTimeout(function(){f.focus()},20)}),e.signal(u,"select",c[0],l.firstChild),!0}var t="CodeMirror-hint",n="CodeMirror-hint-active";e.showHint=function(e,t,n){if(!t)return e.showHint(n);n&&n.async&&(t.async=!0);var r={hint:t};if(n)for(var i in n)r[i]=n[i];return e.showHint(r)},e.defineExtension("showHint",function(t){if(this.listSelections().length>1||this.somethingSelected())return;this.state.completionActive&&this.state.completionActive.close();var n=this.state.completionActive=new r(this,t),i=n.options.hint;if(!i)return;e.signal(this,"startCompletion",this);if(!i.async)return n.showHints(i(this,n.options));i(this,function(e){n.showHints(e)},n.options)}),r.prototype={close:function(){if(!this.active())return;this.cm.state.completionActive=null,this.widget&&this.widget.close(),this.onClose&&this.onClose(),e.signal(this.cm,"endCompletion",this.cm)},active:function(){return this.cm.state.completionActive==this},pick:function(t,n){var r=t.list[n];r.hint?r.hint(this.cm,t,r):this.cm.replaceRange(i(r),r.from||t.from,r.to||t.to,"complete"),e.signal(t,"pick",r),this.close()},showHints:function(e){if(!e||!e.list.length||!this.active())return this.close();this.options.completeSingle&&e.list.length==1?this.pick(e,0):this.showWidget(e)},showWidget:function(t){function c(){if(i)return;i=!0,r.close(),r.cm.off("cursorActivity",v),t&&e.signal(t,"close")}function h(){if(i)return;e.signal(t,"update");var n=r.options.hint;n.async?n(r.cm,p,r.options):p(n(r.cm,r.options))}function p(e){t=e;if(i)return;if(!t||!t.list.length)return c();r.widget&&r.widget.close(),r.widget=new u(r,t)}function d(){n&&(l(n),n=0)}function v(){d();var e=r.cm.getCursor(),t=r.cm.getLine(e.line);e.line!=o.line||t.length-e.ch!=a-o.ch||e.ch<o.ch||r.cm.somethingSelected()||e.ch&&s.test(t.charAt(e.ch-1))?r.close():(n=f(h),r.widget&&r.widget.close())}this.widget=new u(this,t),e.signal(t,"shown");var n=0,r=this,i,s=this.options.closeCharacters,o=this.cm.getCursor(),a=this.cm.getLine(o.line).length,f=window.requestAnimationFrame||function(e){return setTimeout(e,1e3/60)},l=window.cancelAnimationFrame||clearTimeout;this.cm.on("cursorActivity",v),this.onClose=c},buildOptions:function(e){var t=this.cm.options.hintOptions,n={};for(var r in a)n[r]=a[r];if(t)for(var r in t)t[r]!==undefined&&(n[r]=t[r]);if(e)for(var r in e)e[r]!==undefined&&(n[r]=e[r]);return n}},u.prototype={close:function(){if(this.completion.widget!=this)return;this.completion.widget=null,this.hints.parentNode.removeChild(this.hints),this.completion.cm.removeKeyMap(this.keyMap);var e=this.completion.cm;this.completion.options.closeOnUnfocus&&(e.off("blur",this.onBlur),e.off("focus",this.onFocus)),e.off("scroll",this.onScroll)},pick:function(){this.completion.pick(this.data,this.selectedHint)},changeActive:function(t,r){t>=this.data.list.length?t=r?this.data.list.length-1:0:t<0&&(t=r?0:this.data.list.length-1);if(this.selectedHint==t)return;var i=this.hints.childNodes[this.selectedHint];i.className=i.className.replace(" "+n,""),i=this.hints.childNodes[this.selectedHint=t],i.className+=" "+n,i.offsetTop<this.hints.scrollTop?this.hints.scrollTop=i.offsetTop-3:i.offsetTop+i.offsetHeight>this.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=i.offsetTop+i.offsetHeight-this.hints.clientHeight+3),e.signal(this.data,"select",this.data.list[this.selectedHint],i)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},e.registerHelper("hint","auto",function(t,n){var r=t.getHelpers(t.getCursor(),"hint"),i;if(r.length)for(var s=0;s<r.length;s++){var o=r[s](t,n);if(o&&o.list.length)return o}else if(i=t.getHelper(t.getCursor(),"hintWords")){if(i)return e.hint.fromList(t,{words:i})}else if(e.hint.anyword)return e.hint.anyword(t,n)}),e.registerHelper("hint","fromList",function(t,n){var r=t.getCursor(),i=t.getTokenAt(r),s=[];for(var o=0;o<n.words.length;o++){var u=n.words[o];u.slice(0,i.string.length)==i.string&&s.push(u)}if(s.length)return{list:s,from:e.Pos(r.line,i.start),to:e.Pos(r.line,i.end)}}),e.commands.autocomplete=e.showHint;var a={hint:e.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:!0,completeOnSingleClick:!1,container:null,customKeys:null,extraKeys:null};e.defineOption("hintOptions",null)}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/mode/xml/xml",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineMode("xml",function(t,n){function l(e,t){function n(n){return t.tokenize=n,n(e,t)}var r=e.next();if(r=="<")return e.eat("!")?e.eat("[")?e.match("CDATA[")?n(p("atom","]]>")):null:e.match("--")?n(p("comment","-->")):e.match("DOCTYPE",!0,!0)?(e.eatWhile(/[\w\._\-]/),n(d(1))):null:e.eat("?")?(e.eatWhile(/[\w\._\-]/),t.tokenize=p("meta","?>"),"meta"):(a=e.eat("/")?"closeTag":"openTag",t.tokenize=c,"tag bracket");if(r=="&"){var i;return e.eat("#")?e.eat("x")?i=e.eatWhile(/[a-fA-F\d]/)&&e.eat(";"):i=e.eatWhile(/[\d]/)&&e.eat(";"):i=e.eatWhile(/[\w\.\-:]/)&&e.eat(";"),i?"atom":"error"}return e.eatWhile(/[^&<]/),null}function c(e,t){var n=e.next();if(n==">"||n=="/"&&e.eat(">"))return t.tokenize=l,a=n==">"?"endTag":"selfcloseTag","tag bracket";if(n=="=")return a="equals",null;if(n=="<"){t.tokenize=l,t.state=y,t.tagName=t.tagStart=null;var r=t.tokenize(e,t);return r?r+" tag error":"tag error"}return/[\'\"]/.test(n)?(t.tokenize=h(n),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function h(e){var t=function(t,n){while(!t.eol())if(t.next()==e){n.tokenize=c;break}return"string"};return t.isInAttribute=!0,t}function p(e,t){return function(n,r){while(!n.eol()){if(n.match(t)){r.tokenize=l;break}n.next()}return e}}function d(e){return function(t,n){var r;while((r=t.next())!=null){if(r=="<")return n.tokenize=d(e+1),n.tokenize(t,n);if(r==">"){if(e==1){n.tokenize=l;break}return n.tokenize=d(e-1),n.tokenize(t,n)}}return"meta"}}function v(e,t,n){this.prev=e.context,this.tagName=t,this.indent=e.indented,this.startOfLine=n;if(o.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)this.noIndent=!0}function m(e){e.context&&(e.context=e.context.prev)}function g(e,t){var n;for(;;){if(!e.context)return;n=e.context.tagName;if(!o.contextGrabbers.hasOwnProperty(n)||!o.contextGrabbers[n].hasOwnProperty(t))return;m(e)}}function y(e,t,n){return e=="openTag"?(n.tagStart=t.column(),b):e=="closeTag"?w:y}function b(e,t,n){return e=="word"?(n.tagName=t.current(),f="tag",x):(f="error",b)}function w(e,t,n){if(e=="word"){var r=t.current();return n.context&&n.context.tagName!=r&&o.implicitlyClosed.hasOwnProperty(n.context.tagName)&&m(n),n.context&&n.context.tagName==r?(f="tag",E):(f="tag error",S)}return f="error",S}function E(e,t,n){return e!="endTag"?(f="error",E):(m(n),y)}function S(e,t,n){return f="error",E(e,t,n)}function x(e,t,n){if(e=="word")return f="attribute",T;if(e=="endTag"||e=="selfcloseTag"){var r=n.tagName,i=n.tagStart;return n.tagName=n.tagStart=null,e=="selfcloseTag"||o.autoSelfClosers.hasOwnProperty(r)?g(n,r):(g(n,r),n.context=new v(n,r,i==n.indented)),y}return f="error",x}function T(e,t,n){return e=="equals"?N:(o.allowMissing||(f="error"),x(e,t,n))}function N(e,t,n){return e=="string"?C:e=="word"&&o.allowUnquoted?(f="string",x):(f="error",x(e,t,n))}function C(e,t,n){return e=="string"?C:x(e,t,n)}var r=t.indentUnit,i=n.multilineTagIndentFactor||1,s=n.multilineTagIndentPastTag;s==null&&(s=!0);var o=n.htmlMode?{autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1},u=n.alignCDATA,a,f;return{startState:function(){return{tokenize:l,state:y,indented:0,tagName:null,tagStart:null,context:null}},token:function(e,t){!t.tagName&&e.sol()&&(t.indented=e.indentation());if(e.eatSpace())return null;a=null;var n=t.tokenize(e,t);return(n||a)&&n!="comment"&&(f=null,t.state=t.state(a||n,e,t),f&&(n=f=="error"?n+" error":f)),n},indent:function(t,n,a){var f=t.context;if(t.tokenize.isInAttribute)return t.tagStart==t.indented?t.stringStartCol+1:t.indented+r;if(f&&f.noIndent)return e.Pass;if(t.tokenize!=c&&t.tokenize!=l)return a?a.match(/^(\s*)/)[0].length:0;if(t.tagName)return s?t.tagStart+t.tagName.length+2:t.tagStart+r*i;if(u&&/<!\[CDATA\[/.test(n))return 0;var h=n&&/^<(\/)?([\w_:\.-]*)/.exec(n);if(h&&h[1])while(f){if(f.tagName==h[2]){f=f.prev;break}if(!o.implicitlyClosed.hasOwnProperty(f.tagName))break;f=f.prev}else if(h)while(f){var p=o.contextGrabbers[f.tagName];if(!p||!p.hasOwnProperty(h[2]))break;f=f.prev}while(f&&!f.startOfLine)f=f.prev;return f?f.indent+r:0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:n.htmlMode?"html":"xml",helperType:n.htmlMode?"html":"xml"}}),e.defineMIME("text/xml","xml"),e.defineMIME("application/xml","xml"),e.mimeModes.hasOwnProperty("text/html")||e.defineMIME("text/html",{name:"xml",htmlMode:!0})}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/runmode/runmode",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.runMode=function(t,n,r,i){var s=e.getMode(e.defaults,n),o=/MSIE \d/.test(navigator.userAgent),u=o&&(document.documentMode==null||document.documentMode<9);if(r.nodeType==1){var a=i&&i.tabSize||e.defaults.tabSize,f=r,l=0;f.innerHTML="",r=function(e,t){if(e=="\n"){f.appendChild(document.createTextNode(u?"\r":e)),l=0;return}var n="";for(var r=0;;){var i=e.indexOf("	",r);if(i==-1){n+=e.slice(r),l+=e.length-r;break}l+=i-r,n+=e.slice(r,i);var s=a-l%a;l+=s;for(var o=0;o<s;++o)n+=" ";r=i+1}if(t){var c=f.appendChild(document.createElement("span"));c.className="cm-"+t.replace(/ +/g," cm-"),c.appendChild(document.createTextNode(n))}else f.appendChild(document.createTextNode(n))}}var c=e.splitLines(t),h=i&&i.state||e.startState(s);for(var p=0,d=c.length;p<d;++p){p&&r("\n");var v=new e.StringStream(c[p]);!v.string&&s.blankLine&&s.blankLine(h);while(!v.eol()){var m=s.token(v,h);r(v.current(),m,p,v.start,h),v.start=v.pos}}}}),define("CodeMirrorEditor",["react","lodash","jquery","./libs/codemirror-4.8/lib/codemirror","./CMLint","./libs/codemirror-4.8/mode/javascript/javascript","./libs/codemirror-4.8/addon/hint/html-hint","./libs/codemirror-4.8/addon/hint/show-hint","./libs/codemirror-4.8/addon/hint/xml-hint","./libs/codemirror-4.8/addon/hint/html-hint","./libs/codemirror-4.8/mode/xml/xml","./libs/codemirror-4.8/addon/runmode/runmode"],function(e,t,n,r,i){function u(e,t){return(!t||t())&&setTimeout(function(){e.state.completionActive||e.showHint({completeSingle:!1})},100),r.Pass}function a(e){return u(e,function(){var t=e.getCursor();return e.getRange(r.Pos(t.line,t.ch-1),t)==="<"})}function f(e){return u(e,function(){var t=e.getTokenAt(e.getCursor());if(t.type!=="string"||!!/['"]/.test(t.string.charAt(t.string.length-1))&&t.string.length!==1){var n=r.innerMode(e.getMode(),t.state).state;return n.tagName}return!1})}var s={div:{attrs:{"rt-props":null,"rt-if":null,"rt-repeat":null,"rt-class":null,"rt-scope":null,valueLink:null,key:null,ref:null,dangerouslySetInnerHTML:null}}},o=r.htmlSchema;return Object.keys(r.htmlSchema).forEach(function(e){o[e].attrs=t.defaults(s.div.attrs,o[e].attrs)}),e.createClass({displayName:"CodeMirrorEditor",propTypes:{id:e.PropTypes.string,readOnly:e.PropTypes.bool,runMode:e.PropTypes.bool,mode:e.PropTypes.string,value:e.PropTypes.string,valueLink:e.PropTypes.string,onChange:e.PropTypes.func},getDefaultProps:function(){return{readOnly:!1,mode:"html"}},getInitialState:function(){return{editorId:t.uniqueId()}},render:function(){var n=t.omit(this.props,["ref","key","value","valueLink","onChange"]);return n.id=this.props.id||this.state.editorId,n.defaultValue=this.props.valueLink?this.props.valueLink():this.props.value,e.DOM.textarea(n)},componentWillUpdate:function(e){var t=e.valueLink?e.valueLink():e.value;this.editor&&this.editor.getValue()!==t&&this.editor.setValue(t||"")},componentDidMount:function(){var e=this.props.valueLink?this.props.valueLink():this.props.value,t={readOnly:this.props.readOnly,lineWrapping:!0,smartIndent:!0,matchBrackets:!0,value:e,lineNumbers:!0,mode:"javascript",gutters:["CodeMirror-linenumbers","rt-annotations"],theme:"solarized"};this.props.mode==="html"?(t.mode="text/html",t.extraKeys={"'<'":u,"'/'":a,"' '":f,"'='":f,"Ctrl-Space":"autocomplete"},t.hintOptions={schemaInfo:o}):t.mode="javascript",this.editor=r.fromTextArea(this.getDOMNode(),t),this.props.readOnly||this.editor.on("change",function(){this.props.valueLink?this.props.valueLink(this.editor.getValue()):this.props.onChange&&this.props.onChange({target:{value:this.editor.getValue()}})}.bind(this))},annotate:function(e){i.annotate(this.editor,e)},clearAnnotations:function(){i.clearMarks(this.editor)},componentWillUnmount:function(){this.editor.toTextArea()}})}),define("playground-fiddle.rt",["react/addons","lodash","./CodeMirrorEditor"],function(e,t,n){function r(e){this.setState({templateHTML:e.target.value})}function i(e){this.setState({templateProps:e.target.value})}function s(e){e.preventDefault()}return function(){return e.createElement("div",{className:"playground"},e.createElement("div",{className:"fiddle-row"},e.createElement("div",{className:"code-area",id:"area-rt"},e.createElement(n,{ref:"editorRT",id:"editor-rt",className:"large-text-area",value:this.state.templateHTML,mode:"html",onChange:r.bind(this)})),e.createElement("div",{className:"code-area",id:"area-code"},e.createElement(n,{ref:"editorCode",id:"editor-code",className:"large-text-area",value:this.state.templateProps,mode:"javascript",onChange:i.bind(this)}))),e.createElement("div",{className:"fiddle-row"},e.createElement("div",{className:"code-area",id:"area-generated"},e.createElement(n,{id:"editor-generated",className:"large-text-area",ref:"editorGenerated",value:this.templateSource,mode:"javascript",readOnly:!0})),e.createElement("div",{className:"code-area",id:"area-result"},e.createElement("div",{id:"result-area",key:"result-area",className:"sample-view"},e.createElement("form",{className:"result-area-form",ref:"mount",onSubmit:s.bind(this)})))))}}),define("playground.rt",["react/addons","lodash","./CodeMirrorEditor"],function(e,t,n){function r(e,t,n){n.preventDefault(),this.setState({currentTab:e[0]})}function i(n,i){return e.createElement("li",{role:"presentation",className:t.keys(t.pick({active:this.state.currentTab===n[0]},t.identity)).join(" "),onClick:r.bind(this,n,i)},e.createElement("a",{"aria-controls":n[1]},n[1]))}function s(e){this.setState({templateHTML:e.target.value})}function o(e){this.setState({templateProps:e.target.value})}function u(e){e.preventDefault()}return function(){return e.createElement("div",{className:"playground"},e.createElement("div",{id:this.props.id+"-myTab",className:"code-area "+this.getLayoutClass()},e.createElement.apply(this,["ul",{className:"nav nav-tabs",role:"tablist"},t.map(this.getTabs(),i.bind(this))]),e.createElement("div",{},this.state.currentTab==="templateHTML"?e.createElement("div",{key:"editorRT",className:"tab-pane active"},e.createElement(n,{ref:"editorRT",className:"large-text-area",style:{border:this.validHTML?"":"2px solid red"},value:this.state.templateHTML,mode:"html",onChange:s.bind(this)})):null,this.state.currentTab==="templateProps"?e.createElement("div",{key:"editorCode",className:"tab-pane active"},e.createElement(n,{ref:"editorCode",className:"large-text-area",style:{border:this.validProps?"":"2px solid red"},value:this.state.templateProps,mode:"javascript",onChange:o.bind(this)})):null,this.state.currentTab==="templateSource"?e.createElement("div",{key:"templateSource",className:"tab-pane active"},e.createElement(n,{className:"large-text-area",value:this.templateSource,mode:"javascript",readOnly:!0})):null)),e.createElement("div",{key:"result-area",className:"result-area "+this.getLayoutClass()},e.createElement("span",{className:"preview-title"}," "),e.createElement("form",{ref:"mount",className:"sample-view",onSubmit:u.bind(this)})),e.createElement("br",{style:{clear:"both"}}))}}),define("playground",["react","jquery","lodash","./playground-fiddle.rt","./playground.rt"],function(React,$,_,pgFiddleTemplate,playgroundTemplate){function showMessage(e,t){e&&e.showMessage&&e.annotate({line:1,message:t})}function clearMessage(e){e&&e.clearAnnotations&&e.clearAnnotations()}function generateRenderFunc(e){return function(){var t=null;try{t=e.apply(this)}catch(n){t=React.DOM.div.apply(this,[{style:{color:"red"}},"Exception:"+n.message])}return React.DOM.div.apply(this,_.flatten([{key:"result"},t]))}}var templateHTML="<div></div>",templateProps="var template = React.createClass({\n   render: templateRT\n});",Playground=React.createClass({displayName:"Playground",mixins:[React.addons.LinkedStateMixin],propTypes:{direction:React.PropTypes.oneOf(["horizontal","vertical"]),codeVisible:React.PropTypes.bool,fiddle:React.PropTypes.bool,templateHTML:React.PropTypes.string,templateProps:React.PropTypes.string,name:React.PropTypes.string},templateSource:"",validHTML:!0,validProps:!0,setTimeout:function(){clearTimeout(this.timeoutID),this.timeoutID=setTimeout.apply(null,arguments)},getDefaultProps:function(){return{direction:"horizontal",codeVisible:!0,fiddle:!1}},getLayoutClass:function(){return this.props.direction==="horizontal"&&"horizontal"||"vertical"},getTabs:function(){return this.props.codeVisible?[["templateHTML","Template"],["templateProps","Class"],["templateSource","Generated code"]]:[["templateHTML","Template"],["templateSource","Generated code"]]},updateSample:function(state){this.generateCode(state),this.validHTML=!0,this.sampleRender=generateRenderFunc(this.sampleFunc);var editor;try{this.validProps=!0,this.sample=eval("(function () {"+this.templateSource+"\n"+state.templateProps+"\n return React.createElement("+state.name+");})()"),clearMessage(this.refs.editorCode)}catch(e){this.validProps=!1,this.sample=null,editor=this.refs.editorCode,this.showError(e,editor)}},showError:function(e,t){var n=this.refs.mount.getDOMNode();this.setTimeout(function(){showMessage(t,e.message),React.render(React.createElement("div",{className:"playground-error"},e.toString()),n)},500)},showErrorAnnotation:function(e,t){var n=this.refs.mount.getDOMNode();this.setTimeout(function(){t.annotate(e),React.render(React.createElement("div",{className:"playground-error"},e.message),n)},500)},clear:function(){var e={templateHTML:templateHTML,templateProps:templateProps};this.setState(e)},generateCode:function(e){var t=e.templateHTML,n=this.refs.editorRT,r=window.reactTemplates.normalizeName(e.name)+"RT",i=null,s=null;try{i=window.reactTemplates.convertTemplateToReact(t.trim().replace(/\r/g,""),{modules:"none",name:r}),clearMessage(n)}catch(o){o.name==="RTCodeError"?s={line:o.line,message:o.message,index:o.index}:s={line:1,message:o.message},this.showErrorAnnotation(s,n),console.log(o)}this.templateSource=i},getInitialState:function(){var e={templateHTML:this.props.templateHTML||templateHTML,templateProps:this.props.templateProps||templateProps,name:this.props.name||"template",currentTab:"templateHTML"};return e},componentDidMount:function(){this.props.fiddle&&(window.addEventListener("resize",this.calcSize),this.calcSize()),this.updateSample(this.state),this.renderSample()},renderSample:function(){var e=this.refs.mount.getDOMNode();this.sample&&React.render(this.sample,e)},componentDidUpdate:function(){this.renderSample()},componentWillUnmount:function(){window.removeEventListener("resize",this.calcSize)},calcSize:function(){var e=$(window).height()-$("#header").height(),t=e/2-10;$(".code-area").each(function(){$(this).height(t)}),this.refs.editorCode.editor.refresh(),this.refs.editorRT.editor.refresh(),this.refs.editorGenerated.editor.refresh()},componentWillUpdate:function(e,t){(t.templateHTML!==this.state.templateHTML||t.templateProps!==this.state.templateProps)&&this.updateSample(t)},render:function(){this.generateCode(this.state);var e=this.props.fiddle?pgFiddleTemplate:playgroundTemplate;return e.apply(this)}});return Playground}),define("fiddle.rt",["react/addons","lodash","./playground"],function(e,t,n){function r(e){e.preventDefault(),this.save()}function i(e){e.preventDefault(),this.clear()}function s(e){e.preventDefault(),this.loadSample("rt-if")}function o(e){e.preventDefault(),this.loadSample("rt-repeat")}function u(e){e.preventDefault(),this.loadSample("rt-props")}function a(e){e.preventDefault(),this.loadSample("todo")}function f(e){e.preventDefault(),this.loadSample("weather")}return function(){return e.createElement("div",{className:"fiddle"},e.createElement("div",{id:"header"},e.createElement("div",{id:"header-title"},e.createElement("a",{href:"index.html",className:"title-link"},e.createElement("img",{className:"nav-logo",src:"https://wix.github.io/react-templates/img/logo-rt.svg",width:"56",height:"24"})),"\n            RT Playground\n        "),e.createElement("div",{id:"buttons-bar"},e.createElement("button",{type:"button",className:"btn btn-default",onClick:r.bind(this)},e.createElement("span",{className:"glyphicon glyphicon-star button-icon","aria-hidden":"true"}),"Save fiddle\n            "),e.createElement("button",{type:"button",className:"btn btn-default",onClick:i.bind(this)},e.createElement("span",{className:"glyphicon glyphicon-trash button-icon","aria-hidden":"true"}),"Clear\n            "),e.createElement("div",{className:"dropdown toolbar-dropdown"},e.createElement("button",{className:"btn btn-default dropdown-toggle",type:"button",id:"dropdownMenu1","data-toggle":"dropdown","aria-expanded":"true"},"\n                    Load Sample\n                    ",e.createElement("span",{className:"caret"})),e.createElement("ul",{className:"dropdown-menu",role:"menu","aria-labelledby":"dropdownMenu1"},e.createElement("li",{role:"presentation"},e.createElement("a",{role:"menuitem",tabIndex:"-1",href:"#",onClick:s.bind(this)},"rt-if")),e.createElement("li",{role:"presentation"},e.createElement("a",{role:"menuitem",tabIndex:"-1",href:"#",onClick:o.bind(this)},"rt-repeat")),e.createElement("li",{role:"presentation"},e.createElement("a",{role:"menuitem",tabIndex:"-1",href:"#",onClick:u.bind(this)},"rt-props")),e.createElement("li",{role:"presentation"},e.createElement("a",{role:"menuitem",tabIndex:"-1",href:"#",onClick:a.bind(this)},"Todo")),e.createElement("li",{role:"presentation"},e.createElement("a",{role:"menuitem",tabIndex:"-1",href:"#",onClick:f.bind(this)},"Weather"))))),e.createElement("ul",{className:"nav-site"},e.createElement("li",{},e.createElement("a",{href:"index.html"},"HOME")),e.createElement("li",{},e.createElement("a",{href:"https://github.com/wix/react-templates#template-directives-and-syntax"},"docs")),e.createElement("li",{},e.createElement("a",{href:"https://github.com/wix/react-templates#installation"},"download")),e.createElement("li",{},e.createElement("a",{href:"https://github.com/wix/react-templates"},"github")))),e.createElement("div",{className:"playground-container"},e.createElement(n,{ref:"playground",direction:"vertical",fiddle:!0})))}}),define("fiddle",["react","firebase","lodash","./fiddle.rt","jquery"],function(e,t,n,r,i){function s(){var e="xxxxxxxx".replace(/[xy]/g,function(e){var t=n.random(0,15);return(e==="x"?t:t&3|8).toString(16)});return e}var o=e.createClass({displayName:"Fiddle",componentDidMount:function(){if(window.location.hash){var e=window.location.hash.replace("#",""),n=new t("https://reacttemplates.firebaseio-demo.com/");n.child("fiddles").child(e).on("value",function(e){this.refs.playground.setState(e.val()),t.goOffline()}.bind(this))}else t.goOffline()},save:function(){var e=s();window.location.hash=e,t.goOnline();var n=this.refs.playground.state,r=new t("https://reacttemplates.firebaseio-demo.com/");r.child("fiddles").child(e).set(n,function(){t.goOffline(),alert("saved the fiddle, you can share your url")})},clear:function(){this.refs.playground.clear()},loadSample:function(e){var t=this.refs.playground;i.get("playground/samples/"+e+".rt",null,function(r){var s=r;i.get("playground/samples/"+e+".code",null,function(e){var r={templateHTML:s,templateProps:n.template(e,{name:"template"})};t.setState(r)})})},render:r});return o});if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(e){var t=e.fn.jquery.split(" ")[0].split(".");if(t[0]<2&&t[1]<9||1==t[0]&&9==t[1]&&t[2]<1)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher")}(jQuery),+function(e){function t(t){t&&3===t.which||(e(i).remove(),e(s).each(function(){var r=e(this),i=n(r),s={relatedTarget:this};i.hasClass("open")&&(i.trigger(t=e.Event("hide.bs.dropdown",s)),t.isDefaultPrevented()||(r.attr("aria-expanded","false"),i.removeClass("open").trigger("hidden.bs.dropdown",s)))}))}function n(t){var n=t.attr("data-target");n||(n=t.attr("href"),n=n&&/#[A-Za-z]/.test(n)&&n.replace(/.*(?=#[^\s]*$)/,""));var r=n&&e(n);return r&&r.length?r:t.parent()}function r(t){return this.each(function(){var n=e(this),r=n.data("bs.dropdown");r||n.data("bs.dropdown",r=new o(this)),"string"==typeof t&&r[t].call(n)})}var i=".dropdown-backdrop",s='[data-toggle="dropdown"]',o=function(t){e(t).on("click.bs.dropdown",this.toggle)};o.VERSION="3.3.1",o.prototype.toggle=function(r){var i=e(this);if(!i.is(".disabled, :disabled")){var s=n(i),o=s.hasClass("open");if(t(),!o){"ontouchstart"in document.documentElement&&!s.closest(".navbar-nav").length&&e('<div class="dropdown-backdrop"/>').insertAfter(e(this)).on("click",t);var u={relatedTarget:this};if(s.trigger(r=e.Event("show.bs.dropdown",u)),r.isDefaultPrevented())return;i.trigger("focus").attr("aria-expanded","true"),s.toggleClass("open").trigger("shown.bs.dropdown",u)}return!1}},o.prototype.keydown=function(t){if(/(38|40|27|32)/.test(t.which)&&!/input|textarea/i.test(t.target.tagName)){var r=e(this);if(t.preventDefault(),t.stopPropagation(),!r.is(".disabled, :disabled")){var i=n(r),o=i.hasClass("open");if(!o&&27!=t.which||o&&27==t.which)return 27==t.which&&i.find(s).trigger("focus"),r.trigger("click");var u=" li:not(.divider):visible a",f=i.find('[role="menu"]'+u+', [role="listbox"]'+u);if(f.length){var l=f.index(t.target);38==t.which&&l>0&&l--,40==t.which&&l<f.length-1&&l++,~l||(l=0),f.eq(l).trigger("focus")}}}};var u=e.fn.dropdown;e.fn.dropdown=r,e.fn.dropdown.Constructor=o,e.fn.dropdown.noConflict=function(){return e.fn.dropdown=u,this},e(document).on("click.bs.dropdown.data-api",t).on("click.bs.dropdown.data-api",".dropdown form",function(e){e.stopPropagation()}).on("click.bs.dropdown.data-api",s,o.prototype.toggle).on("keydown.bs.dropdown.data-api",s,o.prototype.keydown).on("keydown.bs.dropdown.data-api",'[role="menu"]',o.prototype.keydown).on("keydown.bs.dropdown.data-api",'[role="listbox"]',o.prototype.keydown)}(jQuery),define("bootstrap",function(){}),requirejs.config({paths:{lodash:"//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min",jquery:"//code.jquery.com/jquery-2.1.4.min",firebase:"https://cdn.firebase.com/js/client/2.0.5/firebase",react:"//fb.me/react-with-addons-0.12.2",fiddle:"./fiddle",text:"libs/requirejs-plugins/text",json:"libs/requirejs-plugins/json",bootstrap:"libs/bootstrap/bootstrap.min"},shim:{lodash:{exports:"_"},firebase:{exports:"Firebase"},jquery:{exports:"$"},react:{exports:"React"}},map:{"*":{"react/addons":"react"}}}),requirejs(["jquery","react","fiddle","bootstrap"],function(e,t,n){var r=t.createElement(n);window.fiddle=t.render(r,document.getElementById("container"))}),define("fiddle-main.js",function(){});
\ No newline at end of file
+(function(e){if(typeof exports=="object"&&typeof module=="object")module.exports=e();else{if(typeof define=="function"&&define.amd)return define("libs/codemirror-4.8/lib/codemirror",[],e);this.CodeMirror=e()}})(function(){function S(e,t){if(!(this instanceof S))return new S(e,t);this.options=t=t?zo(t):{},zo(fi,t,!1),H(t);var n=t.value;typeof n=="string"&&(n=new js(n,t.mode)),this.doc=n;var s=this.display=new x(e,n);s.wrapper.CodeMirror=this,M(this),A(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),t.autofocus&&!d&&er(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Do,keySeq:null},r&&i<11&&setTimeout(Wo(Zn,this,!0),20),rr(this),fu(),kn(this),this.curOp.forceUpdate=!0,Rs(this,n),t.autofocus&&!d||nu()==s.input?setTimeout(Wo(Pr,this),20):Hr(this);for(var o in li)li.hasOwnProperty(o)&&li[o](this,t[o],hi);R(this);for(var u=0;u<mi.length;++u)mi[u](this);An(this)}function x(e,t){var n=this,o=n.input=Go("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none");s?o.style.width="1000px":o.setAttribute("wrap","off"),p&&(o.style.border="1px solid black"),o.setAttribute("autocorrect","off"),o.setAttribute("autocapitalize","off"),o.setAttribute("spellcheck","false"),n.inputDiv=Go("div",[o],null,"overflow: hidden; position: relative; width: 3px; height: 0px;"),n.scrollbarH=Go("div",[Go("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar"),n.scrollbarV=Go("div",[Go("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n.scrollbarFiller=Go("div",null,"CodeMirror-scrollbar-filler"),n.gutterFiller=Go("div",null,"CodeMirror-gutter-filler"),n.lineDiv=Go("div",null,"CodeMirror-code"),n.selectionDiv=Go("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=Go("div",null,"CodeMirror-cursors"),n.measure=Go("div",null,"CodeMirror-measure"),n.lineMeasure=Go("div",null,"CodeMirror-measure"),n.lineSpace=Go("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=Go("div",[Go("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=Go("div",[n.mover],"CodeMirror-sizer"),n.heightForcer=Go("div",null,null,"position: absolute; height: "+Lo+"px; width: 1px;"),n.gutters=Go("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=Go("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=Go("div",[n.inputDiv,n.scrollbarH,n.scrollbarV,n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),r&&i<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),p&&(o.style.width="0px"),s||(n.scroller.draggable=!0),l&&(n.inputDiv.style.height="1px",n.inputDiv.style.position="absolute"),r&&i<8&&(n.scrollbarH.style.minHeight=n.scrollbarV.style.minWidth="18px"),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.view=[],n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.prevInput="",n.alignWidgets=!1,n.pollingFast=!1,n.poll=new Do,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.inaccurateSelection=!1,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null}function T(e){e.doc.mode=S.getMode(e.options,e.doc.modeOption),N(e)}function N(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,Xt(e,100),e.state.modeGen++,e.curOp&&Un(e)}function C(e){e.options.lineWrapping?(su(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth=""):(iu(e.display.wrapper,"CodeMirror-wrap"),P(e)),L(e),Un(e),cn(e),setTimeout(function(){F(e)},100)}function k(e){var t=xn(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/Tn(e.display)-3);return function(i){if(ss(e.doc,i))return 0;var s=0;if(i.widgets)for(var o=0;o<i.widgets.length;o++)i.widgets[o].height&&(s+=i.widgets[o].height);return n?s+(Math.ceil(i.text.length/r)||1)*t:s+t}}function L(e){var t=e.doc,n=k(e);t.iter(function(e){var t=n(e);t!=e.height&&Xs(e,t)})}function A(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),cn(e)}function O(e){M(e),Un(e),setTimeout(function(){q(e)},20)}function M(e){var t=e.display.gutters,n=e.options.gutters;Zo(t);for(var r=0;r<n.length;++r){var i=n[r],s=t.appendChild(Go("div",null,"CodeMirror-gutter "+i));i=="CodeMirror-linenumbers"&&(e.display.lineGutter=s,s.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=r?"":"none",_(e)}function _(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px",e.display.scrollbarH.style.left=e.options.fixedGutter?t+"px":0}function D(e){if(e.height==0)return 0;var t=e.text.length,n,r=e;while(n=Yi(r)){var i=n.find(0,!0);r=i.from.line,t+=i.from.ch-i.to.ch}r=e;while(n=Zi(r)){var i=n.find(0,!0);t-=r.text.length-i.from.ch,r=i.to.line,t+=r.text.length-i.to.ch}return t}function P(e){var t=e.display,n=e.doc;t.maxLine=Us(n,n.first),t.maxLineLength=D(t.maxLine),t.maxLineChanged=!0,n.iter(function(e){var n=D(e);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}function H(e){var t=qo(e.gutters,"CodeMirror-linenumbers");t==-1&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function B(e){return e.display.scroller.clientHeight-e.display.wrapper.clientHeight<Lo-3}function j(e){var t=e.display.scroller;return{clientHeight:t.clientHeight,barHeight:e.display.scrollbarV.clientHeight,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth,hScrollbarTakesSpace:B(e),barWidth:e.display.scrollbarH.clientWidth,docHeight:Math.round(e.doc.height+Qt(e.display))}}function F(e,t){t||(t=j(e));var n=e.display,r=pu(n.measure),i=t.docHeight+Lo,s=t.scrollWidth>t.clientWidth;s&&t.scrollWidth<=t.clientWidth+1&&r>0&&!t.hScrollbarTakesSpace&&(s=!1);var o=i>t.clientHeight;o?(n.scrollbarV.style.display="block",n.scrollbarV.style.bottom=s?r+"px":"0",n.scrollbarV.firstChild.style.height=Math.max(0,i-t.clientHeight+(t.barHeight||n.scrollbarV.clientHeight))+"px"):(n.scrollbarV.style.display="",n.scrollbarV.firstChild.style.height="0"),s?(n.scrollbarH.style.display="block",n.scrollbarH.style.right=o?r+"px":"0",n.scrollbarH.firstChild.style.width=t.scrollWidth-t.clientWidth+(t.barWidth||n.scrollbarH.clientWidth)+"px"):(n.scrollbarH.style.display="",n.scrollbarH.firstChild.style.width="0"),s&&o?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=n.scrollbarFiller.style.width=r+"px"):n.scrollbarFiller.style.display="",s&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r+"px",n.gutterFiller.style.width=n.gutters.offsetWidth+"px"):n.gutterFiller.style.display="";if(!e.state.checkedOverlayScrollbar&&t.clientHeight>0){if(r===0){var u=v&&!c?"12px":"18px";n.scrollbarV.style.minWidth=n.scrollbarH.style.minHeight=u;var a=function(t){mo(t)!=n.scrollbarV&&mo(t)!=n.scrollbarH&&jn(e,ur)(t)};yo(n.scrollbarV,"mousedown",a),yo(n.scrollbarH,"mousedown",a)}e.state.checkedOverlayScrollbar=!0}}function I(e,t,n){var r=n&&n.top!=null?Math.max(0,n.top):e.scroller.scrollTop;r=Math.floor(r-Kt(e));var i=n&&n.bottom!=null?n.bottom:r+e.wrapper.clientHeight,s=$s(t,r),o=$s(t,i);if(n&&n.ensure){var u=n.ensure.from.line,a=n.ensure.to.line;if(u<s)return{from:u,to:$s(t,Js(Us(t,u))+e.wrapper.clientHeight)};if(Math.min(a,t.lastLine())>=o)return{from:$s(t,Js(Us(t,a))-e.wrapper.clientHeight),to:a}}return{from:s,to:Math.max(o,s+1)}}function q(e){var t=e.display,n=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;var r=z(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,s=r+"px";for(var o=0;o<n.length;o++)if(!n[o].hidden){e.options.fixedGutter&&n[o].gutter&&(n[o].gutter.style.left=s);var u=n[o].alignable;if(u)for(var a=0;a<u.length;a++)u[a].style.left=s}e.options.fixedGutter&&(t.gutters.style.left=r+i+"px")}function R(e){if(!e.options.lineNumbers)return!1;var t=e.doc,n=U(e.options,t.first+t.size-1),r=e.display;if(n.length!=r.lineNumChars){var i=r.measure.appendChild(Go("div",[Go("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),s=i.firstChild.offsetWidth,o=i.offsetWidth-s;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(s,r.lineGutter.offsetWidth-o),r.lineNumWidth=r.lineNumInnerWidth+o,r.lineNumChars=r.lineNumInnerWidth?n.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",_(e),!0}return!1}function U(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function z(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function W(e,t,n){var r=e.display;this.viewport=t,this.visible=I(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldViewFrom=r.viewFrom,this.oldViewTo=r.viewTo,this.oldScrollerWidth=r.scroller.clientWidth,this.force=n,this.dims=Y(e)}function X(e,t){var n=e.display,r=e.doc;if(t.editorIsHidden)return Wn(e),!1;if(!t.force&&t.visible.from>=n.viewFrom&&t.visible.to<=n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo)&&Jn(e)==0)return!1;R(e)&&(Wn(e),t.dims=Y(e));var i=r.first+r.size,s=Math.max(t.visible.from-e.options.viewportMargin,r.first),o=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFrom<s&&s-n.viewFrom<20&&(s=Math.max(r.first,n.viewFrom)),n.viewTo>o&&n.viewTo-o<20&&(o=Math.min(i,n.viewTo)),E&&(s=rs(e.doc,s),o=is(e.doc,o));var u=s!=n.viewFrom||o!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;$n(e,s,o),n.viewOffset=Js(Us(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var a=Jn(e);if(!u&&a==0&&!t.force&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo))return!1;var f=nu();return a>4&&(n.lineDiv.style.display="none"),Z(e,n.updateLineNumbers,t.dims),a>4&&(n.lineDiv.style.display=""),f&&nu()!=f&&f.offsetHeight&&f.focus(),Zo(n.cursorDiv),Zo(n.selectionDiv),u&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,Xt(e,400)),n.updateLineNumbers=null,!0}function V(e,t){var n=t.force,r=t.viewport;for(var i=!0;;i=!1){if(i&&e.options.lineWrapping&&t.oldScrollerWidth!=e.display.scroller.clientWidth)n=!0;else{n=!1,r&&r.top!=null&&(r={top:Math.min(e.doc.height+Qt(e.display)-Lo-e.display.scroller.clientHeight,r.top)}),t.visible=I(e.display,e.doc,r);if(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}if(!X(e,t))break;Q(e);var s=j(e);Rt(e),J(e,s),F(e,s)}So(e,"update",e),(e.display.viewFrom!=t.oldViewFrom||e.display.viewTo!=t.oldViewTo)&&So(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo)}function $(e,t){var n=new W(e,t);if(X(e,n)){Q(e),V(e,n);var r=j(e);Rt(e),J(e,r),F(e,r)}}function J(e,t){e.display.sizer.style.minHeight=e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=Math.max(t.docHeight,t.clientHeight-Lo)+"px"}function K(e,t){e.display.sizer.offsetWidth+e.display.gutters.offsetWidth<e.display.scroller.clientWidth-1&&(e.display.sizer.style.minHeight=e.display.heightForcer.style.top="0px",e.display.gutters.style.height=t.docHeight+"px")}function Q(e){var t=e.display,n=t.lineDiv.offsetTop;for(var s=0;s<t.view.length;s++){var o=t.view[s],u;if(o.hidden)continue;if(r&&i<8){var a=o.node.offsetTop+o.node.offsetHeight;u=a-n,n=a}else{var f=o.node.getBoundingClientRect();u=f.bottom-f.top}var l=o.line.height-u;u<2&&(u=xn(t));if(l>.001||l<-0.001){Xs(o.line,u),G(o.line);if(o.rest)for(var c=0;c<o.rest.length;c++)G(o.rest[c])}}}function G(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function Y(e){var t=e.display,n={},r={},i=t.gutters.clientLeft;for(var s=t.gutters.firstChild,o=0;s;s=s.nextSibling,++o)n[e.options.gutters[o]]=s.offsetLeft+s.clientLeft+i,r[e.options.gutters[o]]=s.clientWidth;return{fixedPos:z(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Z(e,t,n){function a(t){var n=t.nextSibling;return s&&v&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}var r=e.display,i=e.options.lineNumbers,o=r.lineDiv,u=o.firstChild,f=r.view,l=r.viewFrom;for(var c=0;c<f.length;c++){var h=f[c];if(!h.hidden)if(!h.node){var p=at(e,h,l,n);o.insertBefore(p,u)}else{while(u!=h.node)u=a(u);var d=i&&t!=null&&t<=l&&h.lineNumber;h.changes&&(qo(h.changes,"gutter")>-1&&(d=!1),et(e,h,l,n)),d&&(Zo(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(U(e.options,l)))),u=h.node.nextSibling}l+=h.size}while(u)u=a(u)}function et(e,t,n,r){for(var i=0;i<t.changes.length;i++){var s=t.changes[i];s=="text"?it(e,t):s=="gutter"?ot(e,t,n,r):s=="class"?st(t):s=="widget"&&ut(t,r)}t.changes=null}function tt(e){return e.node==e.text&&(e.node=Go("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),r&&i<8&&(e.node.style.zIndex=2)),e.node}function nt(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;t&&(t+=" CodeMirror-linebackground");if(e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var n=tt(e);e.background=n.insertBefore(Go("div",null,t),n.firstChild)}}function rt(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Ns(e,t)}function it(e,t){var n=t.text.className,r=rt(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,st(t)):n&&(t.text.className=n)}function st(e){nt(e),e.line.wrapClass?tt(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function ot(e,t,n,r){t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null);var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var s=tt(t),o=t.gutter=s.insertBefore(Go("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),t.text);t.line.gutterClass&&(o.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!i||!i["CodeMirror-linenumbers"])&&(t.lineNumber=o.appendChild(Go("div",U(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px")));if(i)for(var u=0;u<e.options.gutters.length;++u){var a=e.options.gutters[u],f=i.hasOwnProperty(a)&&i[a];f&&o.appendChild(Go("div",[f],"CodeMirror-gutter-elt","left: "+r.gutterLeft[a]+"px; width: "+r.gutterWidth[a]+"px"))}}}function ut(e,t){e.alignable&&(e.alignable=null);for(var n=e.node.firstChild,r;n;n=r){var r=n.nextSibling;n.className=="CodeMirror-linewidget"&&e.node.removeChild(n)}ft(e,t)}function at(e,t,n,r){var i=rt(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),st(t),ot(e,t,n,r),ft(t,r),t.node}function ft(e,t){lt(e.line,e,t,!0);if(e.rest)for(var n=0;n<e.rest.length;n++)lt(e.rest[n],e,t,!1)}function lt(e,t,n,r){if(!e.widgets)return;var i=tt(t);for(var s=0,o=e.widgets;s<o.length;++s){var u=o[s],a=Go("div",[u.node],"CodeMirror-linewidget");u.handleMouseEvents||(a.ignoreEvents=!0),ct(u,a,t,n),r&&u.above?i.insertBefore(a,t.gutter||t.text):i.appendChild(a),So(u,"redraw")}}function ct(e,t,n,r){if(e.noHScroll){(n.alignable||(n.alignable=[])).push(t);var i=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(i-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function dt(e){return ht(e.line,e.ch)}function vt(e,t){return pt(e,t)<0?t:e}function mt(e,t){return pt(e,t)<0?e:t}function gt(e,t){this.ranges=e,this.primIndex=t}function yt(e,t){this.anchor=e,this.head=t}function bt(e,t){var n=e[t];e.sort(function(e,t){return pt(e.from(),t.from())}),t=qo(e,n);for(var r=1;r<e.length;r++){var i=e[r],s=e[r-1];if(pt(s.to(),i.from())>=0){var o=mt(s.from(),i.from()),u=vt(s.to(),i.to()),a=s.empty()?i.from()==i.head:s.from()==s.head;r<=t&&--t,e.splice(--r,2,new yt(a?u:o,a?o:u))}}return new gt(e,t)}function wt(e,t){return new gt([new yt(e,t||e)],0)}function Et(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function St(e,t){if(t.line<e.first)return ht(e.first,0);var n=e.first+e.size-1;return t.line>n?ht(n,Us(e,n).text.length):xt(t,Us(e,t.line).text.length)}function xt(e,t){var n=e.ch;return n==null||n>t?ht(e.line,t):n<0?ht(e.line,0):e}function Tt(e,t){return t>=e.first&&t<e.first+e.size}function Nt(e,t){for(var n=[],r=0;r<t.length;r++)n[r]=St(e,t[r]);return n}function Ct(e,t,n,r){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(r){var s=pt(n,i)<0;s!=pt(r,i)<0?(i=n,n=r):s!=pt(n,r)<0&&(n=r)}return new yt(i,n)}return new yt(r||n,n)}function kt(e,t,n,r){Dt(e,new gt([Ct(e,e.sel.primary(),t,n)],0),r)}function Lt(e,t,n){for(var r=[],i=0;i<e.sel.ranges.length;i++)r[i]=Ct(e,e.sel.ranges[i],t[i],null);var s=bt(r,e.sel.primIndex);Dt(e,s,n)}function At(e,t,n,r){var i=e.sel.ranges.slice(0);i[t]=n,Dt(e,bt(i,e.sel.primIndex),r)}function Ot(e,t,n,r){Dt(e,wt(t,n),r)}function Mt(e,t){var n={ranges:t.ranges,update:function(t){this.ranges=[];for(var n=0;n<t.length;n++)this.ranges[n]=new yt(St(e,t[n].anchor),St(e,t[n].head))}};return wo(e,"beforeSelectionChange",e,n),e.cm&&wo(e.cm,"beforeSelectionChange",e.cm,n),n.ranges!=t.ranges?bt(n.ranges,n.ranges.length-1):t}function _t(e,t,n){var r=e.history.done,i=Fo(r);i&&i.ranges?(r[r.length-1]=t,Pt(e,t,n)):Dt(e,t,n)}function Dt(e,t,n){Pt(e,t,n),no(e,e.sel,e.cm?e.cm.curOp.id:NaN,n)}function Pt(e,t,n){if(Co(e,"beforeSelectionChange")||e.cm&&Co(e.cm,"beforeSelectionChange"))t=Mt(e,t);var r=n&&n.bias||(pt(t.primary().head,e.sel.primary().head)<0?-1:1);Ht(e,jt(e,t,r,!0)),(!n||n.scroll!==!1)&&e.cm&&ni(e.cm)}function Ht(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,No(e.cm)),So(e,"cursorActivity",e)}function Bt(e){Ht(e,jt(e,e.sel,null,!1),Oo)}function jt(e,t,n,r){var i;for(var s=0;s<t.ranges.length;s++){var o=t.ranges[s],u=Ft(e,o.anchor,n,r),a=Ft(e,o.head,n,r);if(i||u!=o.anchor||a!=o.head)i||(i=t.ranges.slice(0,s)),i[s]=new yt(u,a)}return i?bt(i,t.primIndex):t}function Ft(e,t,n,r){var i=!1,s=t,o=n||1;e.cantEdit=!1;e:for(;;){var u=Us(e,s.line);if(u.markedSpans)for(var a=0;a<u.markedSpans.length;++a){var f=u.markedSpans[a],l=f.marker;if((f.from==null||(l.inclusiveLeft?f.from<=s.ch:f.from<s.ch))&&(f.to==null||(l.inclusiveRight?f.to>=s.ch:f.to>s.ch))){if(r){wo(l,"beforeCursorEnter");if(l.explicitlyCleared){if(!u.markedSpans)break;--a;continue}}if(!l.atomic)continue;var c=l.find(o<0?-1:1);if(pt(c,s)==0){c.ch+=o,c.ch<0?c.line>e.first?c=St(e,ht(c.line-1)):c=null:c.ch>u.text.length&&(c.line<e.first+e.size-1?c=ht(c.line+1,0):c=null);if(!c){if(i)return r?(e.cantEdit=!0,ht(e.first,0)):Ft(e,t,n,!0);i=!0,c=t,o=-o}}s=c;continue e}}return s}}function It(e){var t=e.display,n=e.doc,r={},i=r.cursors=document.createDocumentFragment(),s=r.selection=document.createDocumentFragment();for(var o=0;o<n.sel.ranges.length;o++){var u=n.sel.ranges[o],a=u.empty();(a||e.options.showCursorWhenSelecting)&&Ut(e,u,i),a||zt(e,u,s)}if(e.options.moveInputWithCursor){var f=gn(e,n.sel.primary().head,"div"),l=t.wrapper.getBoundingClientRect(),c=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,f.top+c.top-l.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,f.left+c.left-l.left))}return r}function qt(e,t){eu(e.display.cursorDiv,t.cursors),eu(e.display.selectionDiv,t.selection),t.teTop!=null&&(e.display.inputDiv.style.top=t.teTop+"px",e.display.inputDiv.style.left=t.teLeft+"px")}function Rt(e){qt(e,It(e))}function Ut(e,t,n){var r=gn(e,t.head,"div",null,null,!e.options.singleCursorHeightPerLine),i=n.appendChild(Go("div"," ","CodeMirror-cursor"));i.style.left=r.left+"px",i.style.top=r.top+"px",i.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px";if(r.other){var s=n.appendChild(Go("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));s.style.display="",s.style.left=r.other.left+"px",s.style.top=r.other.top+"px",s.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function zt(e,t,n){function f(e,t,n,r){t<0&&(t=0),t=Math.round(t),r=Math.round(r),s.appendChild(Go("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(n==null?a-e:n)+"px; height: "+(r-t)+"px"))}function l(t,n,r){function h(n,r){return mn(e,ht(t,n),"div",s,r)}var s=Us(i,t),o=s.text.length,l,c;return Tu(Ks(s),n||0,r==null?o:r,function(e,t,i){var s=h(e,"left"),p,d,v;if(e==t)p=s,d=v=s.left;else{p=h(t-1,"right");if(i=="rtl"){var m=s;s=p,p=m}d=s.left,v=p.right}n==null&&e==0&&(d=u),p.top-s.top>3&&(f(d,s.top,null,s.bottom),d=u,s.bottom<p.top&&f(d,s.bottom,null,p.top)),r==null&&t==o&&(v=a);if(!l||s.top<l.top||s.top==l.top&&s.left<l.left)l=s;if(!c||p.bottom>c.bottom||p.bottom==c.bottom&&p.right>c.right)c=p;d<u+1&&(d=u),f(d,p.top,v-d,p.bottom)}),{start:l,end:c}}var r=e.display,i=e.doc,s=document.createDocumentFragment(),o=Gt(e.display),u=o.left,a=r.lineSpace.offsetWidth-o.right,c=t.from(),h=t.to();if(c.line==h.line)l(c.line,c.ch,h.ch);else{var p=Us(i,c.line),d=Us(i,h.line),v=ts(p)==ts(d),m=l(c.line,c.ch,v?p.text.length+1:null).end,g=l(h.line,v?0:null,h.ch).start;v&&(m.top<g.top-2?(f(m.right,m.top,null,m.bottom),f(u,g.top,g.left,g.bottom)):f(m.right,m.top,g.left-m.right,m.bottom)),m.bottom<g.top&&f(u,m.bottom,null,g.top)}n.appendChild(s)}function Wt(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var n=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function Xt(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Wo(Vt,e))}function Vt(e){var t=e.doc;t.frontier<t.first&&(t.frontier=t.first);if(t.frontier>=e.display.viewTo)return;var n=+(new Date)+e.options.workTime,r=yi(t.mode,Jt(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(s){if(t.frontier>=e.display.viewFrom){var o=s.styles,u=bs(e,s,r,!0);s.styles=u.styles;var a=s.styleClasses,f=u.classes;f?s.styleClasses=f:a&&(s.styleClasses=null);var l=!o||o.length!=s.styles.length||a!=f&&(!a||!f||a.bgClass!=f.bgClass||a.textClass!=f.textClass);for(var c=0;!l&&c<o.length;++c)l=o[c]!=s.styles[c];l&&i.push(t.frontier),s.stateAfter=yi(t.mode,r)}else Es(e,s.text,r),s.stateAfter=t.frontier%5==0?yi(t.mode,r):null;++t.frontier;if(+(new Date)>n)return Xt(e,e.options.workDelay),!0}),i.length&&Bn(e,function(){for(var t=0;t<i.length;t++)zn(e,i[t],"text")})}function $t(e,t,n){var r,i,s=e.doc,o=n?-1:t-(e.doc.mode.innerMode?1e3:100);for(var u=t;u>o;--u){if(u<=s.first)return s.first;var a=Us(s,u-1);if(a.stateAfter&&(!n||u<=s.frontier))return u;var f=Po(a.text,null,e.options.tabSize);if(i==null||r>f)i=u-1,r=f}return i}function Jt(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return!0;var s=$t(e,t,n),o=s>r.first&&Us(r,s-1).stateAfter;return o?o=yi(r.mode,o):o=bi(r.mode),r.iter(s,t,function(n){Es(e,n.text,o);var u=s==t-1||s%5==0||s>=i.viewFrom&&s<i.viewTo;n.stateAfter=u?yi(r.mode,o):null,++s}),n&&(r.frontier=s),o}function Kt(e){return e.lineSpace.offsetTop}function Qt(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Gt(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=eu(e.measure,Go("pre","x")),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function Yt(e,t,n){var r=e.options.lineWrapping,i=r&&e.display.scroller.clientWidth;if(!t.measure.heights||r&&t.measure.width!=i){var s=t.measure.heights=[];if(r){t.measure.width=i;var o=t.text.firstChild.getClientRects();for(var u=0;u<o.length-1;u++){var a=o[u],f=o[u+1];Math.abs(a.bottom-f.bottom)>2&&s.push((a.bottom+f.top)/2-n.top)}}s.push(n.bottom-n.top)}}function Zt(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var r=0;r<e.rest.length;r++)if(Vs(e.rest[r])>n)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}function en(e,t){t=ts(t);var n=Vs(t),r=e.display.externalMeasured=new qn(e.doc,t,n);r.lineN=n;var i=r.built=Ns(e,r);return r.text=i.pre,eu(e.display.lineMeasure,i.pre),r}function tn(e,t,n,r){return sn(e,rn(e,t),n,r)}function nn(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Xn(e,t)];var n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size)return n}function rn(e,t){var n=Vs(t),r=nn(e,n);r&&!r.text?r=null:r&&r.changes&&et(e,r,n,Y(e)),r||(r=en(e,t));var i=Zt(r,t,n);return{line:t,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function sn(e,t,n,r,i){t.before&&(n=-1);var s=n+(r||""),o;return t.cache.hasOwnProperty(s)?o=t.cache[s]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Yt(e,t.view,t.rect),t.hasHeights=!0),o=un(e,t,n,r),o.bogus||(t.cache[s]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function un(e,t,n,s){var o=t.map,u,a,f,l;for(var c=0;c<o.length;c+=3){var h=o[c],p=o[c+1];if(n<h)a=0,f=1,l="left";else if(n<p)a=n-h,f=a+1;else if(c==o.length-3||n==p&&o[c+3]>n)f=p-h,a=f-1,n>=p&&(l="right");if(a!=null){u=o[c+2],h==p&&s==(u.insertLeft?"left":"right")&&(l=s);if(s=="left"&&a==0)while(c&&o[c-2]==o[c-3]&&o[c-1].insertLeft)u=o[(c-=3)+2],l="left";if(s=="right"&&a==p-h)while(c<o.length-3&&o[c+3]==o[c+4]&&!o[c+5].insertLeft)u=o[(c+=3)+2],l="right";break}}var d;if(u.nodeType==3){for(var c=0;c<4;c++){while(a&&Qo(t.line.text.charAt(h+a)))--a;while(h+f<p&&Qo(t.line.text.charAt(h+f)))++f;if(r&&i<9&&a==0&&f==p-h)d=u.parentNode.getBoundingClientRect();else if(r&&e.options.lineWrapping){var v=Yo(u,a,f).getClientRects();v.length?d=v[s=="right"?v.length-1:0]:d=on}else d=Yo(u,a,f).getBoundingClientRect()||on;if(d.left||d.right||a==0)break;f=a,a-=1,l="right"}r&&i<11&&(d=an(e.display.measure,d))}else{a>0&&(l=s="right");var v;e.options.lineWrapping&&(v=u.getClientRects()).length>1?d=v[s=="right"?v.length-1:0]:d=u.getBoundingClientRect()}if(r&&i<9&&!a&&(!d||!d.left&&!d.right)){var m=u.parentNode.getClientRects()[0];m?d={left:m.left,right:m.left+Tn(e.display),top:m.top,bottom:m.bottom}:d=on}var g=d.top-t.rect.top,y=d.bottom-t.rect.top,b=(g+y)/2,w=t.view.measure.heights;for(var c=0;c<w.length-1;c++)if(b<w[c])break;var E=c?w[c-1]:0,S=w[c],x={left:(l=="right"?d.right:d.left)-t.rect.left,right:(l=="left"?d.left:d.right)-t.rect.left,top:E,bottom:S};return!d.left&&!d.right&&(x.bogus=!0),e.options.singleCursorHeightPerLine||(x.rtop=g,x.rbottom=y),x}function an(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Su(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}function fn(e){if(e.measure){e.measure.cache={},e.measure.heights=null;if(e.rest)for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}}function ln(e){e.display.externalMeasure=null,Zo(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)fn(e.display.view[t])}function cn(e){ln(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function hn(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function pn(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function dn(e,t,n,r){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var s=fs(t.widgets[i]);n.top+=s,n.bottom+=s}if(r=="line")return n;r||(r="local");var o=Js(t);r=="local"?o+=Kt(e.display):o-=e.display.viewOffset;if(r=="page"||r=="window"){var u=e.display.lineSpace.getBoundingClientRect();o+=u.top+(r=="window"?0:pn());var a=u.left+(r=="window"?0:hn());n.left+=a,n.right+=a}return n.top+=o,n.bottom+=o,n}function vn(e,t,n){if(n=="div")return t;var r=t.left,i=t.top;if(n=="page")r-=hn(),i-=pn();else if(n=="local"||!n){var s=e.display.sizer.getBoundingClientRect();r+=s.left,i+=s.top}var o=e.display.lineSpace.getBoundingClientRect();return{left:r-o.left,top:i-o.top}}function mn(e,t,n,r,i){return r||(r=Us(e.doc,t.line)),dn(e,r,tn(e,r,t.ch,i),n)}function gn(e,t,n,r,i,s){function o(t,o){var u=sn(e,i,t,o?"right":"left",s);return o?u.left=u.right:u.right=u.left,dn(e,r,u,n)}function u(e,t){var n=a[t],r=n.level%2;return e==Nu(n)&&t&&n.level<a[t-1].level?(n=a[--t],e=Cu(n)-(n.level%2?0:1),r=!0):e==Cu(n)&&t<a.length-1&&n.level<a[t+1].level&&(n=a[++t],e=Nu(n)-n.level%2,r=!1),r&&e==n.to&&e>n.from?o(e-1):o(e,r)}r=r||Us(e.doc,t.line),i||(i=rn(e,r));var a=Ks(r),f=t.ch;if(!a)return o(f);var l=Pu(a,f),c=u(f,l);return Du!=null&&(c.other=u(f,Du)),c}function yn(e,t){var n=0,t=St(e.doc,t);e.options.lineWrapping||(n=Tn(e.display)*t.ch);var r=Us(e.doc,t.line),i=Js(r)+Kt(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function bn(e,t,n,r){var i=ht(e,t);return i.xRel=r,n&&(i.outside=!0),i}function wn(e,t,n){var r=e.doc;n+=e.display.viewOffset;if(n<0)return bn(r.first,0,!0,-1);var i=$s(r,n),s=r.first+r.size-1;if(i>s)return bn(r.first+r.size-1,Us(r,s).text.length,!0,1);t<0&&(t=0);var o=Us(r,i);for(;;){var u=En(e,o,i,t,n),a=Zi(o),f=a&&a.find(0,!0);if(!a||!(u.ch>f.from.ch||u.ch==f.from.ch&&u.xRel>0))return u;i=Vs(o=f.to.line)}}function En(e,t,n,r,i){function f(r){var i=gn(e,ht(n,r),"line",t,a);return o=!0,s>i.bottom?i.left-u:s<i.top?i.left+u:(o=!1,i.left)}var s=i-Js(t),o=!1,u=2*e.display.wrapper.clientWidth,a=rn(e,t),l=Ks(t),c=t.text.length,h=ku(t),p=Lu(t),d=f(h),v=o,m=f(p),g=o;if(r>m)return bn(n,p,g,1);for(;;){if(l?p==h||p==Bu(t,h,1):p-h<=1){var y=r<d||r-d<=m-r?h:p,b=r-(y==h?d:m);while(Qo(t.text.charAt(y)))++y;var w=bn(n,y,y==h?v:g,b<-1?-1:b>1?1:0);return w}var E=Math.ceil(c/2),S=h+E;if(l){S=h;for(var x=0;x<E;++x)S=Bu(t,S,1)}var T=f(S);if(T>r){p=S,m=T;if(g=o)m+=1e3;c=E}else h=S,d=T,v=o,c-=E}}function xn(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Sn==null){Sn=Go("pre");for(var t=0;t<49;++t)Sn.appendChild(document.createTextNode("x")),Sn.appendChild(Go("br"));Sn.appendChild(document.createTextNode("x"))}eu(e.measure,Sn);var n=Sn.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),Zo(e.measure),n||1}function Tn(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=Go("span","xxxxxxxxxx"),n=Go("pre",[t]);eu(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function kn(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++Cn},Nn?Nn.ops.push(e.curOp):e.curOp.ownsGroup=Nn={ops:[e.curOp],delayedCallbacks:[]}}function Ln(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++)t[n]();for(var r=0;r<e.ops.length;r++){var i=e.ops[r];if(i.cursorActivityHandlers)while(i.cursorActivityCalled<i.cursorActivityHandlers.length)i.cursorActivityHandlers[i.cursorActivityCalled++](i.cm)}}while(n<t.length)}function An(e){var t=e.curOp,n=t.ownsGroup;if(!n)return;try{Ln(n)}finally{Nn=null;for(var r=0;r<n.ops.length;r++)n.ops[r].cm.curOp=null;On(n)}}function On(e){var t=e.ops;for(var n=0;n<t.length;n++)Mn(t[n]);for(var n=0;n<t.length;n++)_n(t[n]);for(var n=0;n<t.length;n++)Dn(t[n]);for(var n=0;n<t.length;n++)Pn(t[n]);for(var n=0;n<t.length;n++)Hn(t[n])}function Mn(e){var t=e.cm,n=t.display;e.updateMaxLine&&P(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<n.viewFrom||e.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new W(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function _n(e){e.updatedDisplay=e.mustUpdate&&X(e.cm,e.update)}function Dn(e){var t=e.cm,n=t.display;e.updatedDisplay&&Q(t),e.barMeasure=j(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=tn(t,n.maxLine,n.maxLine.text.length).left+3,e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo+Lo-n.scroller.clientWidth));if(e.updatedDisplay||e.selectionChanged)e.newSelectionNodes=It(t)}function Pn(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&br(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.newSelectionNodes&&qt(t,e.newSelectionNodes),e.updatedDisplay&&J(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&F(t,e.barMeasure),e.selectionChanged&&Wt(t),t.state.focused&&e.updateInput&&Zn(t,e.typing)}function Hn(e){var t=e.cm,n=t.display,r=t.doc;e.adjustWidthTo!=null&&Math.abs(e.barMeasure.scrollWidth-t.display.scroller.scrollWidth)>1&&F(t),e.updatedDisplay&&V(t,e.update),n.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(n.wheelStartX=n.wheelStartY=null);if(e.scrollTop!=null&&(n.scroller.scrollTop!=e.scrollTop||e.forceScroll)){var i=Math.max(0,Math.min(n.scroller.scrollHeight-n.scroller.clientHeight,e.scrollTop));n.scroller.scrollTop=n.scrollbarV.scrollTop=r.scrollTop=i}if(e.scrollLeft!=null&&(n.scroller.scrollLeft!=e.scrollLeft||e.forceScroll)){var o=Math.max(0,Math.min(n.scroller.scrollWidth-n.scroller.clientWidth,e.scrollLeft));n.scroller.scrollLeft=n.scrollbarH.scrollLeft=r.scrollLeft=o,q(t)}if(e.scrollToPos){var u=Yr(t,St(r,e.scrollToPos.from),St(r,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&Gr(t,u)}var a=e.maybeHiddenMarkers,f=e.maybeUnhiddenMarkers;if(a)for(var l=0;l<a.length;++l)a[l].lines.length||wo(a[l],"hide");if(f)for(var l=0;l<f.length;++l)f[l].lines.length&&wo(f[l],"unhide");n.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.updatedDisplay&&s&&(t.options.lineWrapping&&K(t,e.barMeasure),e.barMeasure.scrollWidth>e.barMeasure.clientWidth&&e.barMeasure.scrollWidth<e.barMeasure.clientWidth+1&&!B(t)&&F(t)),e.changeObjs&&wo(t,"changes",t,e.changeObjs)}function Bn(e,t){if(e.curOp)return t();kn(e);try{return t()}finally{An(e)}}function jn(e,t){return function(){if(e.curOp)return t.apply(e,arguments);kn(e);try{return t.apply(e,arguments)}finally{An(e)}}}function Fn(e){return function(){if(this.curOp)return e.apply(this,arguments);kn(this);try{return e.apply(this,arguments)}finally{An(this)}}}function In(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);kn(t);try{return e.apply(this,arguments)}finally{An(t)}}}function qn(e,t,n){this.line=t,this.rest=ns(t),this.size=this.rest?Vs(Fo(this.rest))-n+1:1,this.node=this.text=null,this.hidden=ss(e,t)}function Rn(e,t,n){var r=[],i;for(var s=t;s<n;s=i){var o=new qn(e.doc,Us(e.doc,s),s);i=s+o.size,r.push(o)}return r}function Un(e,t,n,r){t==null&&(t=e.doc.first),n==null&&(n=e.doc.first+e.doc.size),r||(r=0);var i=e.display;r&&n<i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0;if(t>=i.viewTo)E&&rs(e.doc,t)<i.viewTo&&Wn(e);else if(n<=i.viewFrom)E&&is(e.doc,n+r)>i.viewFrom?Wn(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)Wn(e);else if(t<=i.viewFrom){var s=Vn(e,n,n+r,1);s?(i.view=i.view.slice(s.index),i.viewFrom=s.lineN,i.viewTo+=r):Wn(e)}else if(n>=i.viewTo){var s=Vn(e,t,t,-1);s?(i.view=i.view.slice(0,s.index),i.viewTo=s.lineN):Wn(e)}else{var o=Vn(e,t,t,-1),u=Vn(e,n,n+r,1);o&&u?(i.view=i.view.slice(0,o.index).concat(Rn(e,o.lineN,u.lineN)).concat(i.view.slice(u.index)),i.viewTo+=r):Wn(e)}var a=i.externalMeasured;a&&(n<a.lineN?a.lineN+=r:t<a.lineN+a.size&&(i.externalMeasured=null))}function zn(e,t,n){e.curOp.viewChanged=!0;var r=e.display,i=e.display.externalMeasured;i&&t>=i.lineN&&t<i.lineN+i.size&&(r.externalMeasured=null);if(t<r.viewFrom||t>=r.viewTo)return;var s=r.view[Xn(e,t)];if(s.node==null)return;var o=s.changes||(s.changes=[]);qo(o,n)==-1&&o.push(n)}function Wn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Xn(e,t){if(t>=e.display.viewTo)return null;t-=e.display.viewFrom;if(t<0)return null;var n=e.display.view;for(var r=0;r<n.length;r++){t-=n[r].size;if(t<0)return r}}function Vn(e,t,n,r){var i=Xn(e,t),s,o=e.display.view;if(!E||n==e.doc.first+e.doc.size)return{index:i,lineN:n};for(var u=0,a=e.display.viewFrom;u<i;u++)a+=o[u].size;if(a!=t){if(r>0){if(i==o.length-1)return null;s=a+o[i].size-t,i++}else s=a-t;t+=s,n+=s}while(rs(e.doc,n)!=n){if(i==(r<0?0:o.length-1))return null;n+=r*o[i-(r<0?1:0)].size,i+=r}return{index:i,lineN:n}}function $n(e,t,n){var r=e.display,i=r.view;i.length==0||t>=r.viewTo||n<=r.viewFrom?(r.view=Rn(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=Rn(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Xn(e,t))),r.viewFrom=t,r.viewTo<n?r.view=r.view.concat(Rn(e,r.viewTo,n)):r.viewTo>n&&(r.view=r.view.slice(0,Xn(e,n)))),r.viewTo=n}function Jn(e){var t=e.display.view,n=0;for(var r=0;r<t.length;r++){var i=t[r];!i.hidden&&(!i.node||i.changes)&&++n}return n}function Kn(e){if(e.display.pollingFast)return;e.display.poll.set(e.options.pollInterval,function(){Yn(e),e.state.focused&&Kn(e)})}function Qn(e){function n(){var r=Yn(e);!r&&!t?(t=!0,e.display.poll.set(60,n)):(e.display.pollingFast=!1,Kn(e))}var t=!1;e.display.pollingFast=!0,e.display.poll.set(20,n)}function Yn(e){var t=e.display.input,n=e.display.prevInput,s=e.doc;if(!e.state.focused||bu(t)&&!n||nr(e)||e.options.disableInput||e.state.keySeq)return!1;e.state.pasteIncoming&&e.state.fakedLastChar&&(t.value=t.value.substring(0,t.value.length-1),e.state.fakedLastChar=!1);var o=t.value;if(o==n&&!e.somethingSelected())return!1;if(r&&i>=9&&e.display.inputHasSelection===o||v&&/[\uf700-\uf7ff]/.test(o))return Zn(e),!1;var u=!e.curOp;u&&kn(e),e.display.shift=!1,o.charCodeAt(0)==8203&&s.sel==e.display.selForContextMenu&&!n&&(n="​");var a=0,f=Math.min(n.length,o.length);while(a<f&&n.charCodeAt(a)==o.charCodeAt(a))++a;var l=o.slice(a),c=yu(l),h=null;e.state.pasteIncoming&&s.sel.ranges.length>1&&(Gn&&Gn.join("\n")==l?h=s.sel.ranges.length%Gn.length==0&&Ro(Gn,yu):c.length==s.sel.ranges.length&&(h=Ro(c,function(e){return[e]})));for(var p=s.sel.ranges.length-1;p>=0;p--){var d=s.sel.ranges[p],m=d.from(),g=d.to();a<n.length?m=ht(m.line,m.ch-(n.length-a)):e.state.overwrite&&d.empty()&&!e.state.pasteIncoming&&(g=ht(g.line,Math.min(Us(s,g.line).text.length,g.ch+Fo(c).length)));var y=e.curOp.updateInput,b={from:m,to:g,text:h?h[p%h.length]:c,origin:e.state.pasteIncoming?"paste":e.state.cutIncoming?"cut":"+input"};Wr(e.doc,b),So(e,"inputRead",e,b);if(l&&!e.state.pasteIncoming&&e.options.electricChars&&e.options.smartIndent&&d.head.ch<100&&(!p||s.sel.ranges[p-1].head.line!=d.head.line)){var w=e.getModeAt(d.head),E=Fr(b);if(w.electricChars){for(var S=0;S<w.electricChars.length;S++)if(l.indexOf(w.electricChars.charAt(S))>-1){ii(e,E.line,"smart");break}}else w.electricInput&&w.electricInput.test(Us(s,E.line).text.slice(0,E.ch))&&ii(e,E.line,"smart")}}return ni(e),e.curOp.updateInput=y,e.curOp.typing=!0,o.length>1e3||o.indexOf("\n")>-1?t.value=e.display.prevInput="":e.display.prevInput=o,u&&An(e),e.state.pasteIncoming=e.state.cutIncoming=!1,!0}function Zn(e,t){var n,s,o=e.doc;if(e.somethingSelected()){e.display.prevInput="";var u=o.sel.primary();n=wu&&(u.to().line-u.from().line>100||(s=e.getSelection()).length>1e3);var a=n?"-":s||e.getSelection();e.display.input.value=a,e.state.focused&&Io(e.display.input),r&&i>=9&&(e.display.inputHasSelection=a)}else t||(e.display.prevInput=e.display.input.value="",r&&i>=9&&(e.display.inputHasSelection=null));e.display.inaccurateSelection=n}function er(e){e.options.readOnly!="nocursor"&&(!d||nu()!=e.display.input)&&e.display.input.focus()}function tr(e){e.state.focused||(er(e),Pr(e))}function nr(e){return e.options.readOnly||e.doc.cantEdit}function rr(e){function n(){e.state.focused&&setTimeout(Wo(er,e),0)}function o(t){To(e,t)||vo(t)}function u(n){if(e.somethingSelected())Gn=e.getSelections(),t.inaccurateSelection&&(t.prevInput="",t.inaccurateSelection=!1,t.input.value=Gn.join("\n"),Io(t.input));else{var r=[],i=[];for(var s=0;s<e.doc.sel.ranges.length;s++){var o=e.doc.sel.ranges[s].head.line,u={anchor:ht(o,0),head:ht(o+1,0)};i.push(u),r.push(e.getRange(u.anchor,u.head))}n.type=="cut"?e.setSelections(i,null,Oo):(t.prevInput="",t.input.value=r.join("\n"),Io(t.input)),Gn=r}n.type=="cut"&&(e.state.cutIncoming=!0)}var t=e.display;yo(t.scroller,"mousedown",jn(e,ur)),r&&i<11?yo(t.scroller,"dblclick",jn(e,function(t){if(To(e,t))return;var n=or(e,t);if(!n||dr(e,t)||sr(e.display,t))return;co(t);var r=e.findWordAt(n);kt(e.doc,r.anchor,r.head)})):yo(t.scroller,"dblclick",function(t){To(e,t)||co(t)}),yo(t.lineSpace,"selectstart",function(e){sr(t,e)||co(e)}),b||yo(t.scroller,"contextmenu",function(t){Br(e,t)}),yo(t.scroller,"scroll",function(){t.scroller.clientHeight&&(yr(e,t.scroller.scrollTop),br(e,t.scroller.scrollLeft,!0),wo(e,"scroll",e))}),yo(t.scrollbarV,"scroll",function(){t.scroller.clientHeight&&yr(e,t.scrollbarV.scrollTop)}),yo(t.scrollbarH,"scroll",function(){t.scroller.clientHeight&&br(e,t.scrollbarH.scrollLeft)}),yo(t.scroller,"mousewheel",function(t){Sr(e,t)}),yo(t.scroller,"DOMMouseScroll",function(t){Sr(e,t)}),yo(t.scrollbarH,"mousedown",n),yo(t.scrollbarV,"mousedown",n),yo(t.wrapper,"scroll",function(){t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),yo(t.input,"keyup",function(t){_r.call(e,t)}),yo(t.input,"input",function(){r&&i>=9&&e.display.inputHasSelection&&(e.display.inputHasSelection=null),Qn(e)}),yo(t.input,"keydown",jn(e,Or)),yo(t.input,"keypress",jn(e,Dr)),yo(t.input,"focus",Wo(Pr,e)),yo(t.input,"blur",Wo(Hr,e)),e.options.dragDrop&&(yo(t.scroller,"dragstart",function(t){gr(e,t)}),yo(t.scroller,"dragenter",o),yo(t.scroller,"dragover",o),yo(t.scroller,"drop",jn(e,mr))),yo(t.scroller,"paste",function(n){if(sr(t,n))return;e.state.pasteIncoming=!0,er(e),Qn(e)}),yo(t.input,"paste",function(){if(s&&!e.state.fakedLastChar&&!(new Date-e.state.lastMiddleDown<200)){var n=t.input.selectionStart,r=t.input.selectionEnd;t.input.value+="$",t.input.selectionEnd=r,t.input.selectionStart=n,e.state.fakedLastChar=!0}e.state.pasteIncoming=!0,Qn(e)}),yo(t.input,"cut",u),yo(t.input,"copy",u),l&&yo(t.sizer,"mouseup",function(){nu()==t.input&&t.input.blur(),er(e)})}function ir(e){var t=e.display;if(t.lastWrapHeight==t.wrapper.clientHeight&&t.lastWrapWidth==t.wrapper.clientWidth)return;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,e.setSize()}function sr(e,t){for(var n=mo(t);n!=e.wrapper;n=n.parentNode)if(!n||n.ignoreEvents||n.parentNode==e.sizer&&n!=e.mover)return!0}function or(e,t,n,r){var i=e.display;if(!n){var s=mo(t);if(s==i.scrollbarH||s==i.scrollbarV||s==i.scrollbarFiller||s==i.gutterFiller)return null}var o,u,a=i.lineSpace.getBoundingClientRect();try{o=t.clientX-a.left,u=t.clientY-a.top}catch(t){return null}var f=wn(e,o,u),l;if(r&&f.xRel==1&&(l=Us(e.doc,f.line).text).length==f.ch){var c=Po(l,l.length,e.options.tabSize)-l.length;f=ht(f.line,Math.max(0,Math.round((o-Gt(e.display).left)/Tn(e.display))-c))}return f}function ur(e){if(To(this,e))return;var t=this,n=t.display;n.shift=e.shiftKey;if(sr(n,e)){s||(n.scroller.draggable=!1,setTimeout(function(){n.scroller.draggable=!0},100));return}if(dr(t,e))return;var r=or(t,e);window.focus();switch(go(e)){case 1:r?lr(t,e,r):mo(e)==n.scroller&&co(e);break;case 2:s&&(t.state.lastMiddleDown=+(new Date)),r&&kt(t.doc,r),setTimeout(Wo(er,t),20),co(e);break;case 3:b&&Br(t,e)}}function lr(e,t,n){setTimeout(Wo(tr,e),0);var r=+(new Date),i;fr&&fr.time>r-400&&pt(fr.pos,n)==0?i="triple":ar&&ar.time>r-400&&pt(ar.pos,n)==0?(i="double",fr={time:r,pos:n}):(i="single",ar={time:r,pos:n});var s=e.doc.sel,o=v?t.metaKey:t.ctrlKey;e.options.dragDrop&&cu&&!nr(e)&&i=="single"&&s.contains(n)>-1&&s.somethingSelected()?cr(e,t,n,o):hr(e,t,n,i,o)}function cr(e,t,n,o){var u=e.display,a=jn(e,function(f){s&&(u.scroller.draggable=!1),e.state.draggingText=!1,bo(document,"mouseup",a),bo(u.scroller,"drop",a),Math.abs(t.clientX-f.clientX)+Math.abs(t.clientY-f.clientY)<10&&(co(f),o||kt(e.doc,n),er(e),r&&i==9&&setTimeout(function(){document.body.focus(),er(e)},20))});s&&(u.scroller.draggable=!0),e.state.draggingText=a,u.scroller.dragDrop&&u.scroller.dragDrop(),yo(document,"mouseup",a),yo(u.scroller,"drop",a)}function hr(e,t,n,r,i){function p(t){if(pt(h,t)==0)return;h=t;if(r=="rect"){var i=[],s=e.options.tabSize,l=Po(Us(o,n.line).text,n.ch,s),c=Po(Us(o,t.line).text,t.ch,s),p=Math.min(l,c),d=Math.max(l,c);for(var v=Math.min(n.line,t.line),m=Math.min(e.lastLine(),Math.max(n.line,t.line));v<=m;v++){var g=Us(o,v).text,y=Ho(g,p,s);p==d?i.push(new yt(ht(v,y),ht(v,y))):g.length>y&&i.push(new yt(ht(v,y),ht(v,Ho(g,d,s))))}i.length||i.push(new yt(n,n)),Dt(o,bt(f.ranges.slice(0,a).concat(i),a),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=u,w=b.anchor,E=t;if(r!="single"){if(r=="double")var S=e.findWordAt(t);else var S=new yt(ht(t.line,0),St(o,ht(t.line+1,0)));pt(S.anchor,w)>0?(E=S.head,w=mt(b.from(),S.anchor)):(E=S.anchor,w=vt(b.to(),S.head))}var i=f.ranges.slice(0);i[a]=new yt(St(o,w),E),Dt(o,bt(i,a),Mo)}}function m(t){var n=++v,i=or(e,t,!0,r=="rect");if(!i)return;if(pt(i,h)!=0){tr(e),p(i);var u=I(s,o);(i.line>=u.to||i.line<u.from)&&setTimeout(jn(e,function(){v==n&&m(t)}),150)}else{var a=t.clientY<d.top?-20:t.clientY>d.bottom?20:0;a&&setTimeout(jn(e,function(){if(v!=n)return;s.scroller.scrollTop+=a,m(t)}),50)}}function g(t){v=Infinity,co(t),er(e),bo(document,"mousemove",y),bo(document,"mouseup",b),o.history.lastSelOrigin=null}var s=e.display,o=e.doc;co(t);var u,a,f=o.sel;i&&!t.shiftKey?(a=o.sel.contains(n),a>-1?u=o.sel.ranges[a]:u=new yt(n,n)):u=o.sel.primary();if(t.altKey)r="rect",i||(u=new yt(n,n)),n=or(e,t,!0,!0),a=-1;else if(r=="double"){var l=e.findWordAt(n);e.display.shift||o.extend?u=Ct(o,u,l.anchor,l.head):u=l}else if(r=="triple"){var c=new yt(ht(n.line,0),St(o,ht(n.line+1,0)));e.display.shift||o.extend?u=Ct(o,u,c.anchor,c.head):u=c}else u=Ct(o,u,n);i?a>-1?At(o,a,u,Mo):(a=o.sel.ranges.length,Dt(o,bt(o.sel.ranges.concat([u]),a),{scroll:!1,origin:"*mouse"})):(a=0,Dt(o,new gt([u],0),Mo),f=o.sel);var h=n,d=s.wrapper.getBoundingClientRect(),v=0,y=jn(e,function(e){go(e)?m(e):g(e)}),b=jn(e,g);yo(document,"mousemove",y),yo(document,"mouseup",b)}function pr(e,t,n,r,i){try{var s=t.clientX,o=t.clientY}catch(t){return!1}if(s>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&co(t);var u=e.display,a=u.lineDiv.getBoundingClientRect();if(o>a.bottom||!Co(e,n))return po(t);o-=a.top-u.viewOffset;for(var f=0;f<e.options.gutters.length;++f){var l=u.gutters.childNodes[f];if(l&&l.getBoundingClientRect().right>=s){var c=$s(e.doc,o),h=e.options.gutters[f];return i(e,n,e,c,h,t),po(t)}}}function dr(e,t){return pr(e,t,"gutterClick",!0,So)}function mr(e){var t=this;if(To(t,e)||sr(t.display,e))return;co(e),r&&(vr=+(new Date));var n=or(t,e,!0),i=e.dataTransfer.files;if(!n||nr(t))return;if(i&&i.length&&window.FileReader&&window.File){var s=i.length,o=Array(s),u=0,a=function(e,r){var i=new FileReader;i.onload=jn(t,function(){o[r]=i.result;if(++u==s){n=St(t.doc,n);var e={from:n,to:n,text:yu(o.join("\n")),origin:"paste"};Wr(t.doc,e),_t(t.doc,wt(n,Fr(e)))}}),i.readAsText(e)};for(var f=0;f<s;++f)a(i[f],f)}else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1){t.state.draggingText(e),setTimeout(Wo(er,t),20);return}try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&(v?!e.metaKey:!e.ctrlKey))var l=t.listSelections();Pt(t.doc,wt(n,n));if(l)for(var f=0;f<l.length;++f)Qr(t.doc,"",l[f].anchor,l[f].head,"drag");t.replaceSelection(o,"around","paste"),er(t)}}catch(e){}}}function gr(e,t){if(r&&(!e.state.draggingText||+(new Date)-vr<100)){vo(t);return}if(To(e,t)||sr(e.display,t))return;t.dataTransfer.setData("Text",e.getSelection());if(t.dataTransfer.setDragImage&&!f){var n=Go("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",a&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),a&&n.parentNode.removeChild(n)}}function yr(t,n){if(Math.abs(t.doc.scrollTop-n)<2)return;t.doc.scrollTop=n,e||$(t,{top:n}),t.display.scroller.scrollTop!=n&&(t.display.scroller.scrollTop=n),t.display.scrollbarV.scrollTop!=n&&(t.display.scrollbarV.scrollTop=n),e&&$(t),Xt(t,100)}function br(e,t,n){if(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)return;t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,q(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbarH.scrollLeft!=t&&(e.display.scrollbarH.scrollLeft=t)}function Sr(t,n){var r=n.wheelDeltaX,i=n.wheelDeltaY;r==null&&n.detail&&n.axis==n.HORIZONTAL_AXIS&&(r=n.detail),i==null&&n.detail&&n.axis==n.VERTICAL_AXIS?i=n.detail:i==null&&(i=n.wheelDelta);var o=t.display,u=o.scroller;if(!(r&&u.scrollWidth>u.clientWidth||i&&u.scrollHeight>u.clientHeight))return;if(i&&v&&s)e:for(var f=n.target,l=o.view;f!=u;f=f.parentNode)for(var c=0;c<l.length;c++)if(l[c].node==f){t.display.currentWheelTarget=f;break e}if(r&&!e&&!a&&Er!=null){i&&yr(t,Math.max(0,Math.min(u.scrollTop+i*Er,u.scrollHeight-u.clientHeight))),br(t,Math.max(0,Math.min(u.scrollLeft+r*Er,u.scrollWidth-u.clientWidth))),co(n),o.wheelStartX=null;return}if(i&&Er!=null){var h=i*Er,p=t.doc.scrollTop,d=p+o.wrapper.clientHeight;h<0?p=Math.max(0,p+h-50):d=Math.min(t.doc.height,d+h+50),$(t,{top:p,bottom:d})}wr<20&&(o.wheelStartX==null?(o.wheelStartX=u.scrollLeft,o.wheelStartY=u.scrollTop,o.wheelDX=r,o.wheelDY=i,setTimeout(function(){if(o.wheelStartX==null)return;var e=u.scrollLeft-o.wheelStartX,t=u.scrollTop-o.wheelStartY,n=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null;if(!n)return;Er=(Er*wr+n)/(wr+1),++wr},200)):(o.wheelDX+=r,o.wheelDY+=i))}function xr(e,t,n){if(typeof t=="string"){t=wi[t];if(!t)return!1}e.display.pollingFast&&Yn(e)&&(e.display.pollingFast=!1);var r=e.display.shift,i=!1;try{nr(e)&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),i=t(e)!=Ao}finally{e.display.shift=r,e.state.suppressEdits=!1}return i}function Tr(e,t,n){for(var r=0;r<e.state.keyMaps.length;r++){var i=xi(t,e.state.keyMaps[r],n);if(i)return i}return e.options.extraKeys&&xi(t,e.options.extraKeys,n)||xi(t,e.options.keyMap,n)}function Cr(e,t,n,r){var i=e.state.keySeq;if(i){if(Ti(t))return"handled";Nr.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,Zn(e))}),t=i+" "+t}var s=Tr(e,t,r);s=="multi"&&(e.state.keySeq=t),s=="handled"&&So(e,"keyHandled",e,t,n);if(s=="handled"||s=="multi")co(n),Wt(e);return i&&!s&&/\'$/.test(t)?(co(n),!0):!!s}function kr(e,t){var n=Ni(t,!0);return n?t.shiftKey&&!e.state.keySeq?Cr(e,"Shift-"+n,t,function(t){return xr(e,t,!0)})||Cr(e,n,t,function(t){if(typeof t=="string"?/^go[A-Z]/.test(t):t.motion)return xr(e,t)}):Cr(e,n,t,function(t){return xr(e,t)}):!1}function Lr(e,t,n){return Cr(e,"'"+n+"'",t,function(t){return xr(e,t,!0)})}function Or(e){var t=this;tr(t);if(To(t,e))return;r&&i<11&&e.keyCode==27&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=n==16||e.shiftKey;var s=kr(t,e);a&&(Ar=s?n:null,!s&&n==88&&!wu&&(v?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),n==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Mr(t)}function Mr(e){function n(e){if(e.keyCode==18||!e.altKey)iu(t,"CodeMirror-crosshair"),bo(document,"keyup",n),bo(document,"mouseover",n)}var t=e.display.lineDiv;su(t,"CodeMirror-crosshair"),yo(document,"keyup",n),yo(document,"mouseover",n)}function _r(e){e.keyCode==16&&(this.doc.sel.shift=!1),To(this,e)}function Dr(e){var t=this;if(To(t,e)||e.ctrlKey&&!e.altKey||v&&e.metaKey)return;var n=e.keyCode,s=e.charCode;if(a&&n==Ar){Ar=null,co(e);return}if((a&&(!e.which||e.which<10)||l)&&kr(t,e))return;var o=String.fromCharCode(s==null?n:s);if(Lr(t,e,o))return;r&&i>=9&&(t.display.inputHasSelection=null),Qn(t)}function Pr(e){if(e.options.readOnly=="nocursor")return;e.state.focused||(wo(e,"focus",e),e.state.focused=!0,su(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(Zn(e),s&&setTimeout(Wo(Zn,e,!0),0))),Kn(e),Wt(e)}function Hr(e){e.state.focused&&(wo(e,"blur",e),e.state.focused=!1,iu(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Br(e,t){function h(){if(n.input.selectionStart!=null){var t=e.somethingSelected(),r=n.input.value="​"+(t?n.input.value:"");n.prevInput=t?"":"​",n.input.selectionStart=1,n.input.selectionEnd=r.length,n.selForContextMenu=e.doc.sel}}function p(){n.inputDiv.style.position="relative",n.input.style.cssText=l,r&&i<9&&(n.scrollbarV.scrollTop=n.scroller.scrollTop=u),Kn(e);if(n.input.selectionStart!=null){(!r||r&&i<9)&&h();var t=0,s=function(){n.selForContextMenu==e.doc.sel&&n.input.selectionStart==0?jn(e,wi.selectAll)(e):t++<10?n.detectingSelectAll=setTimeout(s,500):Zn(e)};n.detectingSelectAll=setTimeout(s,200)}}if(To(e,t,"contextmenu"))return;var n=e.display;if(sr(n,t)||jr(e,t))return;var o=or(e,t),u=n.scroller.scrollTop;if(!o||a)return;var f=e.options.resetSelectionOnContextMenu;f&&e.doc.sel.contains(o)==-1&&jn(e,Dt)(e.doc,wt(o),Oo);var l=n.input.style.cssText;n.inputDiv.style.position="absolute",n.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(t.clientY-5)+"px; left: "+(t.clientX-5)+"px; z-index: 1000; background: "+(r?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";if(s)var c=window.scrollY;er(e),s&&window.scrollTo(null,c),Zn(e),e.somethingSelected()||(n.input.value=n.prevInput=" "),n.selForContextMenu=e.doc.sel,clearTimeout(n.detectingSelectAll),r&&i>=9&&h();if(b){vo(t);var d=function(){bo(window,"mouseup",d),setTimeout(p,20)};yo(window,"mouseup",d)}else setTimeout(p,50)}function jr(e,t){return Co(e,"gutterContextMenu")?pr(e,t,"gutterContextMenu",!1,wo):!1}function Ir(e,t){if(pt(e,t.from)<0)return e;if(pt(e,t.to)<=0)return Fr(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Fr(t).ch-t.to.ch),ht(n,r)}function qr(e,t){var n=[];for(var r=0;r<e.sel.ranges.length;r++){var i=e.sel.ranges[r];n.push(new yt(Ir(i.anchor,t),Ir(i.head,t)))}return bt(n,e.sel.primIndex)}function Rr(e,t,n){return e.line==t.line?ht(n.line,e.ch-t.ch+n.ch):ht(n.line+(e.line-t.line),e.ch)}function Ur(e,t,n){var r=[],i=ht(e.first,0),s=i;for(var o=0;o<t.length;o++){var u=t[o],a=Rr(u.from,i,s),f=Rr(Fr(u),i,s);i=u.to,s=f;if(n=="around"){var l=e.sel.ranges[o],c=pt(l.head,l.anchor)<0;r[o]=new yt(c?f:a,c?a:f)}else r[o]=new yt(a,a)}return new gt(r,e.sel.primIndex)}function zr(e,t,n){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return n&&(r.update=function(t,n,r,i){t&&(this.from=St(e,t)),n&&(this.to=St(e,n)),r&&(this.text=r),i!==undefined&&(this.origin=i)}),wo(e,"beforeChange",e,r),e.cm&&wo(e.cm,"beforeChange",e.cm,r),r.canceled?null:{from:r.from,to:r.to,text:r.text,origin:r.origin}}function Wr(e,t,n){if(e.cm){if(!e.cm.curOp)return jn(e.cm,Wr)(e,t,n);if(e.cm.state.suppressEdits)return}if(Co(e,"beforeChange")||e.cm&&Co(e.cm,"beforeChange")){t=zr(e,t,!0);if(!t)return}var r=w&&!n&&Xi(e,t.from,t.to);if(r)for(var i=r.length-1;i>=0;--i)Xr(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text});else Xr(e,t)}function Xr(e,t){if(t.text.length==1&&t.text[0]==""&&pt(t.from,t.to)==0)return;var n=qr(e,t);eo(e,t,n,e.cm?e.cm.curOp.id:NaN),Jr(e,t,n,Ui(e,t));var r=[];qs(e,function(e,n){!n&&qo(r,e.history)==-1&&(lo(e.history,t),r.push(e.history)),Jr(e,t,null,Ui(e,t))})}function Vr(e,t,n){if(e.cm&&e.cm.state.suppressEdits)return;var r=e.history,i,s=e.sel,o=t=="undo"?r.done:r.undone,u=t=="undo"?r.undone:r.done;for(var a=0;a<o.length;a++){i=o[a];if(n?i.ranges&&!i.equals(e.sel):!i.ranges)break}if(a==o.length)return;r.lastOrigin=r.lastSelOrigin=null;for(;;){i=o.pop();if(!i.ranges)break;ro(i,u);if(n&&!i.equals(e.sel)){Dt(e,i,{clearRedo:!1});return}s=i}var f=[];ro(s,u),u.push({changes:f,generation:r.generation}),r.generation=i.generation||++r.maxGeneration;var l=Co(e,"beforeChange")||e.cm&&Co(e.cm,"beforeChange");for(var a=i.changes.length-1;a>=0;--a){var c=i.changes[a];c.origin=t;if(l&&!zr(e,c,!1)){o.length=0;return}f.push(Gs(e,c));var h=a?qr(e,c):Fo(o);Jr(e,c,h,Wi(e,c)),!a&&e.cm&&e.cm.scrollIntoView({from:c.from,to:Fr(c)});var p=[];qs(e,function(e,t){!t&&qo(p,e.history)==-1&&(lo(e.history,c),p.push(e.history)),Jr(e,c,null,Wi(e,c))})}}function $r(e,t){if(t==0)return;e.first+=t,e.sel=new gt(Ro(e.sel.ranges,function(e){return new yt(ht(e.anchor.line+t,e.anchor.ch),ht(e.head.line+t,e.head.ch))}),e.sel.primIndex);if(e.cm){Un(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;r<n.viewTo;r++)zn(e.cm,r,"gutter")}}function Jr(e,t,n,r){if(e.cm&&!e.cm.curOp)return jn(e.cm,Jr)(e,t,n,r);if(t.to.line<e.first){$r(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine())return;if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);$r(e,i),t={from:ht(e.first,0),to:ht(t.to.line+i,t.to.ch),text:[Fo(t.text)],origin:t.origin}}var s=e.lastLine();t.to.line>s&&(t={from:t.from,to:ht(s,Us(e,s).text.length),text:[t.text[0]],origin:t.origin}),t.removed=zs(e,t.from,t.to),n||(n=qr(e,t)),e.cm?Kr(e.cm,t,r):Ds(e,t,r),Pt(e,n,Oo)}function Kr(e,t,n){var r=e.doc,i=e.display,s=t.from,o=t.to,u=!1,a=s.line;e.options.lineWrapping||(a=Vs(ts(Us(r,s.line))),r.iter(a,o.line+1,function(e){if(e==i.maxLine)return u=!0,!0})),r.sel.contains(t.from,t.to)>-1&&No(e),Ds(r,t,n,k(e)),e.options.lineWrapping||(r.iter(a,s.line+t.text.length,function(e){var t=D(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,u=!1)}),u&&(e.curOp.updateMaxLine=!0)),r.frontier=Math.min(r.frontier,s.line),Xt(e,400);var f=t.text.length-(o.line-s.line)-1;s.line==o.line&&t.text.length==1&&!_s(e.doc,t)?zn(e,s.line,"text"):Un(e,s.line,o.line+1,f);var l=Co(e,"changes"),c=Co(e,"change");if(c||l){var h={from:s,to:o,text:t.text,removed:t.removed,origin:t.origin};c&&So(e,"change",e,h),l&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function Qr(e,t,n,r,i){r||(r=n);if(pt(r,n)<0){var s=r;r=n,n=s}typeof t=="string"&&(t=yu(t)),Wr(e,{from:n,to:r,text:t,origin:i})}function Gr(e,t){if(To(e,"scrollCursorIntoView"))return;var n=e.display,r=n.sizer.getBoundingClientRect(),i=null;t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1);if(i!=null&&!h){var s=Go("div","​",null,"position: absolute; top: "+(t.top-n.viewOffset-Kt(e.display))+"px; height: "+(t.bottom-t.top+Lo)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(s),s.scrollIntoView(i),e.display.lineSpace.removeChild(s)}}function Yr(e,t,n,r){r==null&&(r=0);for(var i=0;i<5;i++){var s=!1,o=gn(e,t),u=!n||n==t?o:gn(e,n),a=ei(e,Math.min(o.left,u.left),Math.min(o.top,u.top)-r,Math.max(o.left,u.left),Math.max(o.bottom,u.bottom)+r),f=e.doc.scrollTop,l=e.doc.scrollLeft;a.scrollTop!=null&&(yr(e,a.scrollTop),Math.abs(e.doc.scrollTop-f)>1&&(s=!0)),a.scrollLeft!=null&&(br(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-l)>1&&(s=!0));if(!s)return o}}function Zr(e,t,n,r,i){var s=ei(e,t,n,r,i);s.scrollTop!=null&&yr(e,s.scrollTop),s.scrollLeft!=null&&br(e,s.scrollLeft)}function ei(e,t,n,r,i){var s=e.display,o=xn(e.display);n<0&&(n=0);var u=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:s.scroller.scrollTop,a=s.scroller.clientHeight-Lo,f={};i-n>a&&(i=n+a);var l=e.doc.height+Qt(s),c=n<o,h=i>l-o;if(n<u)f.scrollTop=c?0:n;else if(i>u+a){var p=Math.min(n,(h?l:i)-a);p!=u&&(f.scrollTop=p)}var d=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:s.scroller.scrollLeft,v=s.scroller.clientWidth-Lo-s.gutters.offsetWidth,m=r-t>v;return m&&(r=t+v),t<10?f.scrollLeft=0:t<d?f.scrollLeft=Math.max(0,t-(m?0:10)):r>v+d-3&&(f.scrollLeft=r+(m?0:10)-v),f}function ti(e,t,n){(t!=null||n!=null)&&ri(e),t!=null&&(e.curOp.scrollLeft=(e.curOp.scrollLeft==null?e.doc.scrollLeft:e.curOp.scrollLeft)+t),n!=null&&(e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+n)}function ni(e){ri(e);var t=e.getCursor(),n=t,r=t;e.options.lineWrapping||(n=t.ch?ht(t.line,t.ch-1):t,r=ht(t.line,t.ch+1)),e.curOp.scrollToPos={from:n,to:r,margin:e.options.cursorScrollMargin,isCursor:!0}}function ri(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=yn(e,t.from),r=yn(e,t.to),i=ei(e,Math.min(n.left,r.left),Math.min(n.top,r.top)-t.margin,Math.max(n.right,r.right),Math.max(n.bottom,r.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function ii(e,t,n,r){var i=e.doc,s;n==null&&(n="add"),n=="smart"&&(i.mode.indent?s=Jt(e,t):n="prev");var o=e.options.tabSize,u=Us(i,t),a=Po(u.text,null,o);u.stateAfter&&(u.stateAfter=null);var f=u.text.match(/^\s*/)[0],l;if(!r&&!/\S/.test(u.text))l=0,n="not";else if(n=="smart"){l=i.mode.indent(s,u.text.slice(f.length),u.text);if(l==Ao||l>150){if(!r)return;n="prev"}}n=="prev"?t>i.first?l=Po(Us(i,t-1).text,null,o):l=0:n=="add"?l=a+e.options.indentUnit:n=="subtract"?l=a-e.options.indentUnit:typeof n=="number"&&(l=a+n),l=Math.max(0,l);var c="",h=0;if(e.options.indentWithTabs)for(var p=Math.floor(l/o);p;--p)h+=o,c+="	";h<l&&(c+=jo(l-h));if(c!=f)Qr(i,c,ht(t,0),ht(t,f.length),"+input");else for(var p=0;p<i.sel.ranges.length;p++){var d=i.sel.ranges[p];if(d.head.line==t&&d.head.ch<f.length){var h=ht(t,f.length);At(i,p,new yt(h,h));break}}u.stateAfter=null}function si(e,t,n,r){var i=t,s=t;return typeof t=="number"?s=Us(e,Et(e,t)):i=Vs(t),i==null?null:(r(s,i)&&e.cm&&zn(e.cm,i,n),s)}function oi(e,t){var n=e.doc.sel.ranges,r=[];for(var i=0;i<n.length;i++){var s=t(n[i]);while(r.length&&pt(s.from,Fo(r).to)<=0){var o=r.pop();if(pt(o.from,s.from)<0){s.from=o.from;break}}r.push(s)}Bn(e,function(){for(var t=r.length-1;t>=0;t--)Qr(e.doc,"",r[t].from,r[t].to,"+delete");ni(e)})}function ui(e,t,n,r,i){function l(){var t=s+n;return t<e.first||t>=e.first+e.size?f=!1:(s=t,a=Us(e,t))}function c(e){var t=(i?Bu:ju)(a,o,n,!0);if(t==null){if(!!e||!l())return f=!1;i?o=(n<0?Lu:ku)(a):o=n<0?a.text.length:0}else o=t;return!0}var s=t.line,o=t.ch,u=n,a=Us(e,s),f=!0;if(r=="char")c();else if(r=="column")c(!0);else if(r=="word"||r=="group"){var h=null,p=r=="group",d=e.cm&&e.cm.getHelper(t,"wordChars");for(var v=!0;;v=!1){if(n<0&&!c(!v))break;var m=a.text.charAt(o)||"\n",g=$o(m,d)?"w":p&&m=="\n"?"n":!p||/\s/.test(m)?null:"p";p&&!v&&!g&&(g="s");if(h&&h!=g){n<0&&(n=1,c());break}g&&(h=g);if(n>0&&!c(!v))break}}var y=Ft(e,ht(s,o),u,!0);return f||(y.hitSide=!0),y}function ai(e,t,n,r){var i=e.doc,s=t.left,o;if(r=="page"){var u=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);o=t.top+n*(u-(n<0?1.5:.5)*xn(e.display))}else r=="line"&&(o=n>0?t.bottom+3:t.top-3);for(;;){var a=wn(e,s,o);if(!a.outside)break;if(n<0?o<=0:o>=i.height){a.hitSide=!0;break}o+=n*5}return a}function ci(e,t,n,r){S.defaults[e]=t,n&&(li[e]=r?function(e,t,r){r!=hi&&n(e,t,r)}:n)}function Si(e){var t=e.split(/-(?!$)/),e=t[t.length-1],n,r,i,s;for(var o=0;o<t.length-1;o++){var u=t[o];if(/^(cmd|meta|m)$/i.test(u))s=!0;else if(/^a(lt)?$/i.test(u))n=!0;else if(/^(c|ctrl|control)$/i.test(u))r=!0;else{if(!/^s(hift)$/i.test(u))throw new Error("Unrecognized modifier name: "+u);i=!0}}return n&&(e="Alt-"+e),r&&(e="Ctrl-"+e),s&&(e="Cmd-"+e),i&&(e="Shift-"+e),e}function Ci(e){return typeof e=="string"?Ei[e]:e}function Oi(e,t,n,r,i){if(r&&r.shared)return _i(e,t,n,r,i);if(e.cm&&!e.cm.curOp)return jn(e.cm,Oi)(e,t,n,r,i);var s=new Li(e,i),o=pt(t,n);r&&zo(r,s,!1);if(o>0||o==0&&s.clearWhenEmpty!==!1)return s;s.replacedWith&&(s.collapsed=!0,s.widgetNode=Go("span",[s.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||(s.widgetNode.ignoreEvents=!0),r.insertLeft&&(s.widgetNode.insertLeft=!0));if(s.collapsed){if(es(e,t.line,t,n,s)||t.line!=n.line&&es(e,n.line,t,n,s))throw new Error("Inserting collapsed marker partially overlapping an existing one");E=!0}s.addToHistory&&eo(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var u=t.line,a=e.cm,f;e.iter(u,n.line+1,function(e){a&&s.collapsed&&!a.options.lineWrapping&&ts(e)==a.display.maxLine&&(f=!0),s.collapsed&&u!=t.line&&Xs(e,0),Ii(e,new Bi(s,u==t.line?t.ch:null,u==n.line?n.ch:null)),++u}),s.collapsed&&e.iter(t.line,n.line+1,function(t){ss(e,t)&&Xs(t,0)}),s.clearOnEnter&&yo(s,"beforeCursorEnter",function(){s.clear()}),s.readOnly&&(w=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),s.collapsed&&(s.id=++Ai,s.atomic=!0);if(a){f&&(a.curOp.updateMaxLine=!0);if(s.collapsed)Un(a,t.line,n.line+1);else if(s.className||s.title||s.startStyle||s.endStyle)for(var l=t.line;l<=n.line;l++)zn(a,l,"text");s.atomic&&Bt(a.doc),So(a,"markerAdded",a,s)}return s}function _i(e,t,n,r,i){r=zo(r),r.shared=!1;var s=[Oi(e,t,n,r,i)],o=s[0],u=r.widgetNode;return qs(e,function(e){u&&(r.widgetNode=u.cloneNode(!0)),s.push(Oi(e,St(e,t),St(e,n),r,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;o=Fo(s)}),new Mi(s,o)}function Di(e){return e.findMarks(ht(e.first,0),e.clipPos(ht(e.lastLine())),function(e){return e.parent})}function Pi(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.find(),s=e.clipPos(i.from),o=e.clipPos(i.to);if(pt(s,o)){var u=Oi(e,s,o,r.primary,r.primary.type);r.markers.push(u),u.parent=r}}}function Hi(e){for(var t=0;t<e.length;t++){var n=e[t],r=[n.primary.doc];qs(n.primary.doc,function(e){r.push(e)});for(var i=0;i<n.markers.length;i++){var s=n.markers[i];qo(r,s.doc)==-1&&(s.parent=null,n.markers.splice(i--,1))}}}function Bi(e,t,n){this.marker=e,this.from=t,this.to=n}function ji(e,t){if(e)for(var n=0;n<e.length;++n){var r=e[n];if(r.marker==t)return r}}function Fi(e,t){for(var n,r=0;r<e.length;++r)e[r]!=t&&(n||(n=[])).push(e[r]);return n}function Ii(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function qi(e,t,n){if(e)for(var r=0,i;r<e.length;++r){var s=e[r],o=s.marker,u=s.from==null||(o.inclusiveLeft?s.from<=t:s.from<t);if(u||s.from==t&&o.type=="bookmark"&&(!n||!s.marker.insertLeft)){var a=s.to==null||(o.inclusiveRight?s.to>=t:s.to>t);(i||(i=[])).push(new Bi(o,s.from,a?null:s.to))}}return i}function Ri(e,t,n){if(e)for(var r=0,i;r<e.length;++r){var s=e[r],o=s.marker,u=s.to==null||(o.inclusiveRight?s.to>=t:s.to>t);if(u||s.from==t&&o.type=="bookmark"&&(!n||s.marker.insertLeft)){var a=s.from==null||(o.inclusiveLeft?s.from<=t:s.from<t);(i||(i=[])).push(new Bi(o,a?null:s.from-t,s.to==null?null:s.to-t))}}return i}function Ui(e,t){var n=Tt(e,t.from.line)&&Us(e,t.from.line).markedSpans,r=Tt(e,t.to.line)&&Us(e,t.to.line).markedSpans;if(!n&&!r)return null;var i=t.from.ch,s=t.to.ch,o=pt(t.from,t.to)==0,u=qi(n,i,o),a=Ri(r,s,o),f=t.text.length==1,l=Fo(t.text).length+(f?i:0);if(u)for(var c=0;c<u.length;++c){var h=u[c];if(h.to==null){var p=ji(a,h.marker);p?f&&(h.to=p.to==null?null:p.to+l):h.to=i}}if(a)for(var c=0;c<a.length;++c){var h=a[c];h.to!=null&&(h.to+=l);if(h.from==null){var p=ji(u,h.marker);p||(h.from=l,f&&(u||(u=[])).push(h))}else h.from+=l,f&&(u||(u=[])).push(h)}u&&(u=zi(u)),a&&a!=u&&(a=zi(a));var d=[u];if(!f){var v=t.text.length-2,m;if(v>0&&u)for(var c=0;c<u.length;++c)u[c].to==null&&(m||(m=[])).push(new Bi(u[c].marker,null,null));for(var c=0;c<v;++c)d.push(m);d.push(a)}return d}function zi(e){for(var t=0;t<e.length;++t){var n=e[t];n.from!=null&&n.from==n.to&&n.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Wi(e,t){var n=oo(e,t),r=Ui(e,t);if(!n)return r;if(!r)return n;for(var i=0;i<n.length;++i){var s=n[i],o=r[i];if(s&&o)e:for(var u=0;u<o.length;++u){var a=o[u];for(var f=0;f<s.length;++f)if(s[f].marker==a.marker)continue e;s.push(a)}else o&&(n[i]=o)}return n}function Xi(e,t,n){var r=null;e.iter(t.line,n.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var n=e.markedSpans[t].marker;n.readOnly&&(!r||qo(r,n)==-1)&&(r||(r=[])).push(n)}});if(!r)return null;var i=[{from:t,to:n}];for(var s=0;s<r.length;++s){var o=r[s],u=o.find(0);for(var a=0;a<i.length;++a){var f=i[a];if(pt(f.to,u.from)<0||pt(f.from,u.to)>0)continue;var l=[a,1],c=pt(f.from,u.from),h=pt(f.to,u.to);(c<0||!o.inclusiveLeft&&!c)&&l.push({from:f.from,to:u.from}),(h>0||!o.inclusiveRight&&!h)&&l.push({from:u.to,to:f.to}),i.splice.apply(i,l),a+=l.length-1}}return i}function Vi(e){var t=e.markedSpans;if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}function $i(e,t){if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.attachLine(e);e.markedSpans=t}function Ji(e){return e.inclusiveLeft?-1:0}function Ki(e){return e.inclusiveRight?1:0}function Qi(e,t){var n=e.lines.length-t.lines.length;if(n!=0)return n;var r=e.find(),i=t.find(),s=pt(r.from,i.from)||Ji(e)-Ji(t);if(s)return-s;var o=pt(r.to,i.to)||Ki(e)-Ki(t);return o?o:t.id-e.id}function Gi(e,t){var n=E&&e.markedSpans,r;if(n)for(var i,s=0;s<n.length;++s)i=n[s],i.marker.collapsed&&(t?i.from:i.to)==null&&(!r||Qi(r,i.marker)<0)&&(r=i.marker);return r}function Yi(e){return Gi(e,!0)}function Zi(e){return Gi(e,!1)}function es(e,t,n,r,i){var s=Us(e,t),o=E&&s.markedSpans;if(o)for(var u=0;u<o.length;++u){var a=o[u];if(!a.marker.collapsed)continue;var f=a.marker.find(0),l=pt(f.from,n)||Ji(a.marker)-Ji(i),c=pt(f.to,r)||Ki(a.marker)-Ki(i);if(l>=0&&c<=0||l<=0&&c>=0)continue;if(l<=0&&(pt(f.to,n)>0||a.marker.inclusiveRight&&i.inclusiveLeft)||l>=0&&(pt(f.from,r)<0||a.marker.inclusiveLeft&&i.inclusiveRight))return!0}}function ts(e){var t;while(t=Yi(e))e=t.find(-1,!0).line;return e}function ns(e){var t,n;while(t=Zi(e))e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function rs(e,t){var n=Us(e,t),r=ts(n);return n==r?t:Vs(r)}function is(e,t){if(t>e.lastLine())return t;var n=Us(e,t),r;if(!ss(e,n))return t;while(r=Zi(n))n=r.find(1,!0).line;return Vs(n)+1}function ss(e,t){var n=E&&t.markedSpans;if(n)for(var r,i=0;i<n.length;++i){r=n[i];if(!r.marker.collapsed)continue;if(r.from==null)return!0;if(r.marker.widgetNode)continue;if(r.from==0&&r.marker.inclusiveLeft&&os(e,t,r))return!0}}function os(e,t,n){if(n.to==null){var r=n.marker.find(1,!0);return os(e,r.line,ji(r.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length)return!0;for(var i,s=0;s<t.markedSpans.length;++s){i=t.markedSpans[s];if(i.marker.collapsed&&!i.marker.widgetNode&&i.from==n.to&&(i.to==null||i.to!=n.from)&&(i.marker.inclusiveLeft||n.marker.inclusiveRight)&&os(e,t,i))return!0}}function as(e,t,n){Js(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&ti(e,null,n)}function fs(e){if(e.height!=null)return e.height;if(!tu(document.body,e.node)){var t="position: relative;";e.coverGutter&&(t+="margin-left: -"+e.cm.getGutterElement().offsetWidth+"px;"),eu(e.cm.display.measure,Go("div",[e.node],null,t))}return e.height=e.node.offsetHeight}function ls(e,t,n,r){var i=new us(e,n,r);return i.noHScroll&&(e.display.alignWidgets=!0),si(e.doc,t,"widget",function(t){var n=t.widgets||(t.widgets=[]);i.insertAt==null?n.push(i):n.splice(Math.min(n.length-1,Math.max(0,i.insertAt)),0,i),i.line=t;if(!ss(e.doc,t)){var r=Js(t)<e.doc.scrollTop;Xs(t,t.height+fs(i)),r&&ti(e,null,i.height),e.curOp.forceUpdate=!0}return!0}),i}function hs(e,t,n,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),Vi(e),$i(e,n);var i=r?r(e):1;i!=e.height&&Xs(e,i)}function ps(e){e.parent=null,Vi(e)}function ds(e,t){if(e)for(;;){var n=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;e=e.slice(0,n.index)+e.slice(n.index+n[0].length);var r=n[1]?"bgClass":"textClass";t[r]==null?t[r]=n[2]:(new RegExp("(?:^|s)"+n[2]+"(?:$|s)")).test(t[r])||(t[r]+=" "+n[2])}return e}function vs(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var n=S.innerMode(e,t);if(n.mode.blankLine)return n.mode.blankLine(n.state)}function ms(e,t,n,r){for(var i=0;i<10;i++){r&&(r[0]=S.innerMode(e,n).mode);var s=e.token(t,n);if(t.pos>t.start)return s}throw new Error("Mode "+e.name+" failed to advance stream.")}function gs(e,t,n,r){function i(e){return{start:l.start,end:l.pos,string:l.current(),type:u||null,state:e?yi(s.mode,f):f}}var s=e.doc,o=s.mode,u;t=St(s,t);var a=Us(s,t.line),f=Jt(e,t.line,n),l=new ki(a.text,e.options.tabSize),c;r&&(c=[]);while((r||l.pos<t.ch)&&!l.eol())l.start=l.pos,u=ms(o,l,f),r&&c.push(i(!0));return r?c:i()}function ys(e,t,n,r,i,s,o){var u=n.flattenSpans;u==null&&(u=e.options.flattenSpans);var a=0,f=null,l=new ki(t,e.options.tabSize),c,h=e.options.addModeClass&&[null];t==""&&ds(vs(n,r),s);while(!l.eol()){l.pos>e.options.maxHighlightLength?(u=!1,o&&Es(e,t,r,l.pos),l.pos=t.length,c=null):c=ds(ms(n,l,r,h),s);if(h){var p=h[0].name;p&&(c="m-"+(c?p+" "+c:p))}if(!u||f!=c)a<l.start&&i(l.start,f),a=l.start,f=c;l.start=l.pos}while(a<l.pos){var d=Math.min(l.pos,a+5e4);i(d,f),a=d}}function bs(e,t,n,r){var i=[e.state.modeGen],s={};ys(e,t.text,e.doc.mode,n,function(e,t){i.push(e,t)},s,r);for(var o=0;o<e.state.overlays.length;++o){var u=e.state.overlays[o],a=1,f=0;ys(e,t.text,u.mode,!0,function(e,t){var n=a;while(f<e){var r=i[a];r>e&&i.splice(a,1,e,i[a+1],r),a+=2,f=Math.min(e,r)}if(!t)return;if(u.opaque)i.splice(n,a-n,e,"cm-overlay "+t),a=n+2;else for(;n<a;n+=2){var s=i[n+1];i[n+1]=(s?s+" ":"")+"cm-overlay "+t}},s)}return{styles:i,classes:s.bgClass||s.textClass?s:null}}function ws(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=bs(e,t,t.stateAfter=Jt(e,Vs(t)));t.styles=r.styles,r.classes?t.styleClasses=r.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.frontier&&e.doc.frontier++}return t.styles}function Es(e,t,n,r){var i=e.doc.mode,s=new ki(t,e.options.tabSize);s.start=s.pos=r||0,t==""&&vs(i,n);while(!s.eol()&&s.pos<=e.options.maxHighlightLength)ms(i,s,n),s.start=s.pos}function Ts(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?xs:Ss;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Ns(e,t){var n=Go("span",null,null,s?"padding-right: .1px":null),i={pre:Go("pre",[n]),content:n,col:0,pos:0,cm:e};t.measure={};for(var o=0;o<=(t.rest?t.rest.length:0);o++){var u=o?t.rest[o-1]:t.line,a;i.pos=0,i.addToken=ks,(r||s)&&e.getOption("lineWrapping")&&(i.addToken=Ls(i.addToken)),gu(e.display.measure)&&(a=Ks(u))&&(i.addToken=As(i.addToken,a)),i.map=[];var f=t!=e.display.externalMeasured&&Vs(u);Ms(u,i,ws(e,u,f)),u.styleClasses&&(u.styleClasses.bgClass&&(i.bgClass=ou(u.styleClasses.bgClass,i.bgClass||"")),u.styleClasses.textClass&&(i.textClass=ou(u.styleClasses.textClass,i.textClass||""))),i.map.length==0&&i.map.push(0,0,i.content.appendChild(vu(e.display.measure))),o==0?(t.measure.map=i.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(i.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return s&&/\bcm-tab\b/.test(i.content.lastChild.className)&&(i.content.className="cm-tab-wrap-hack"),wo(e,"renderLine",e,t.line,i.pre),i.pre.className&&(i.textClass=ou(i.pre.className,i.textClass||"")),i}function Cs(e){var t=Go("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t}function ks(e,t,n,s,o,u){if(!t)return;var a=e.cm.options.specialChars,f=!1;if(!a.test(t)){e.col+=t.length;var l=document.createTextNode(t);e.map.push(e.pos,e.pos+t.length,l),r&&i<9&&(f=!0),e.pos+=t.length}else{var l=document.createDocumentFragment(),c=0;for(;;){a.lastIndex=c;var h=a.exec(t),p=h?h.index-c:t.length-c;if(p){var d=document.createTextNode(t.slice(c,c+p));r&&i<9?l.appendChild(Go("span",[d])):l.appendChild(d),e.map.push(e.pos,e.pos+p,d),e.col+=p,e.pos+=p}if(!h)break;c+=p+1;if(h[0]=="	"){var v=e.cm.options.tabSize,m=v-e.col%v,d=l.appendChild(Go("span",jo(m),"cm-tab"));e.col+=m}else{var d=e.cm.options.specialCharPlaceholder(h[0]);r&&i<9?l.appendChild(Go("span",[d])):l.appendChild(d),e.col+=1}e.map.push(e.pos,e.pos+1,d),e.pos++}}if(n||s||o||f){var g=n||"";s&&(g+=s),o&&(g+=o);var y=Go("span",[l],g);return u&&(y.title=u),e.content.appendChild(y)}e.content.appendChild(l)}function Ls(e){function t(e){var t=" ";for(var n=0;n<e.length-2;++n)t+=n%2?" ":" ";return t+=" ",t}return function(n,r,i,s,o,u){e(n,r.replace(/ {3,}/g,t),i,s,o,u)}}function As(e,t){return function(n,r,i,s,o,u){i=i?i+" cm-force-border":"cm-force-border";var a=n.pos,f=a+r.length;for(;;){for(var l=0;l<t.length;l++){var c=t[l];if(c.to>a&&c.from<=a)break}if(c.to>=f)return e(n,r,i,s,o,u);e(n,r.slice(0,c.to-a),i,s,null,u),s=null,r=r.slice(c.to-a),a=c.to}}}function Os(e,t,n,r){var i=!r&&n.widgetNode;i&&(e.map.push(e.pos,e.pos+t,i),e.content.appendChild(i)),e.pos+=t}function Ms(e,t,n){var r=e.markedSpans,i=e.text,s=0;if(!r){for(var o=1;o<n.length;o+=2)t.addToken(t,i.slice(s,s=n[o]),Ts(n[o+1],t.cm.options));return}var u=i.length,a=0,o=1,f="",l,c=0,h,p,d,v,m;for(;;){if(c==a){h=p=d=v="",m=null,c=Infinity;var g=[];for(var y=0;y<r.length;++y){var b=r[y],w=b.marker;b.from<=a&&(b.to==null||b.to>a)?(b.to!=null&&c>b.to&&(c=b.to,p=""),w.className&&(h+=" "+w.className),w.startStyle&&b.from==a&&(d+=" "+w.startStyle),w.endStyle&&b.to==c&&(p+=" "+w.endStyle),w.title&&!v&&(v=w.title),w.collapsed&&(!m||Qi(m.marker,w)<0)&&(m=b)):b.from>a&&c>b.from&&(c=b.from),w.type=="bookmark"&&b.from==a&&w.widgetNode&&g.push(w)}if(m&&(m.from||0)==a){Os(t,(m.to==null?u+1:m.to)-a,m.marker,m.from==null);if(m.to==null)return}if(!m&&g.length)for(var y=0;y<g.length;++y)Os(t,0,g[y])}if(a>=u)break;var E=Math.min(u,c);for(;;){if(f){var S=a+f.length;if(!m){var x=S>E?f.slice(0,E-a):f;t.addToken(t,x,l?l+h:h,d,a+x.length==c?p:"",v)}if(S>=E){f=f.slice(E-a),a=E;break}a=S,d=""}f=i.slice(s,s=n[o++]),l=Ts(n[o++],t.cm.options)}}}function _s(e,t){return t.from.ch==0&&t.to.ch==0&&Fo(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Ds(e,t,n,r){function i(e){return n?n[e]:null}function s(e,n,i){hs(e,n,i,r),So(e,"change",e,t)}var o=t.from,u=t.to,a=t.text,f=Us(e,o.line),l=Us(e,u.line),c=Fo(a),h=i(a.length-1),p=u.line-o.line;if(_s(e,t)){for(var d=0,v=[];d<a.length-1;++d)v.push(new cs(a[d],i(d),r));s(l,l.text,h),p&&e.remove(o.line,p),v.length&&e.insert(o.line,v)}else if(f==l)if(a.length==1)s(f,f.text.slice(0,o.ch)+c+f.text.slice(u.ch),h);else{for(var v=[],d=1;d<a.length-1;++d)v.push(new cs(a[d],i(d),r));v.push(new cs(c+f.text.slice(u.ch),h,r)),s(f,f.text.slice(0,o.ch)+a[0],i(0)),e.insert(o.line+1,v)}else if(a.length==1)s(f,f.text.slice(0,o.ch)+a[0]+l.text.slice(u.ch),i(0)),e.remove(o.line+1,p);else{s(f,f.text.slice(0,o.ch)+a[0],i(0)),s(l,c+l.text.slice(u.ch),h);for(var d=1,v=[];d<a.length-1;++d)v.push(new cs(a[d],i(d),r));p>1&&e.remove(o.line+1,p-1),e.insert(o.line+1,v)}So(e,"change",e,t)}function Ps(e){this.lines=e,this.parent=null;for(var t=0,n=0;t<e.length;++t)e[t].parent=this,n+=e[t].height;this.height=n}function Hs(e){this.children=e;var t=0,n=0;for(var r=0;r<e.length;++r){var i=e[r];t+=i.chunkSize(),n+=i.height,i.parent=this}this.size=t,this.height=n,this.parent=null}function qs(e,t,n){function r(e,i,s){if(e.linked)for(var o=0;o<e.linked.length;++o){var u=e.linked[o];if(u.doc==i)continue;var a=s&&u.sharedHist;if(n&&!a)continue;t(u.doc,a),r(u.doc,e,a)}}r(e,null,!0)}function Rs(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,L(e),T(e),e.options.lineWrapping||P(e),e.options.mode=t.modeOption,Un(e)}function Us(e,t){t-=e.first;if(t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],s=i.chunkSize();if(t<s){n=i;break}t-=s}return n.lines[t]}function zs(e,t,n){var r=[],i=t.line;return e.iter(t.line,n.line+1,function(e){var s=e.text;i==n.line&&(s=s.slice(0,n.ch)),i==t.line&&(s=s.slice(t.ch)),r.push(s),++i}),r}function Ws(e,t,n){var r=[];return e.iter(t,n,function(e){r.push(e.text)}),r}function Xs(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function Vs(e){if(e.parent==null)return null;var t=e.parent,n=qo(t.lines,e);for(var r=t.parent;r;t=r,r=r.parent)for(var i=0;;++i){if(r.children[i]==t)break;n+=r.children[i].chunkSize()}return n+t.first}function $s(e,t){var n=e.first;e:do{for(var r=0;r<e.children.length;++r){var i=e.children[r],s=i.height;if(t<s){e=i;continue e}t-=s,n+=i.chunkSize()}return n}while(!e.lines);for(var r=0;r<e.lines.length;++r){var o=e.lines[r],u=o.height;if(t<u)break;t-=u}return n+r}function Js(e){e=ts(e);var t=0,n=e.parent;for(var r=0;r<n.lines.length;++r){var i=n.lines[r];if(i==e)break;t+=i.height}for(var s=n.parent;s;n=s,s=n.parent)for(var r=0;r<s.children.length;++r){var o=s.children[r];if(o==n)break;t+=o.height}return t}function Ks(e){var t=e.order;return t==null&&(t=e.order=Fu(e.text)),t}function Qs(e){this.done=[],this.undone=[],this.undoDepth=Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Gs(e,t){var n={from:dt(t.from),to:Fr(t),text:zs(e,t.from,t.to)};return io(e,n,t.from.line,t.to.line+1),qs(e,function(e){io(e,n,t.from.line,t.to.line+1)},!0),n}function Ys(e){while(e.length){var t=Fo(e);if(!t.ranges)break;e.pop()}}function Zs(e,t){if(t)return Ys(e.done),Fo(e.done);if(e.done.length&&!Fo(e.done).ranges)return Fo(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),Fo(e.done)}function eo(e,t,n,r){var i=e.history;i.undone.length=0;var s=+(new Date),o;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&e.cm&&i.lastModTime>s-e.cm.options.historyEventDelay||t.origin.charAt(0)=="*"))&&(o=Zs(i,i.lastOp==r))){var u=Fo(o.changes);pt(t.from,t.to)==0&&pt(t.from,u.to)==0?u.to=Fr(t):o.changes.push(Gs(e,t))}else{var a=Fo(i.done);(!a||!a.ranges)&&ro(e.sel,i.done),o={changes:[Gs(e,t)],generation:i.generation},i.done.push(o);while(i.done.length>i.undoDepth)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=s,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,u||wo(e,"historyAdded")}function to(e,t,n,r){var i=t.charAt(0);return i=="*"||i=="+"&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function no(e,t,n,r){var i=e.history,s=r&&r.origin;n==i.lastSelOp||s&&i.lastSelOrigin==s&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==s||to(e,s,Fo(i.done),t))?i.done[i.done.length-1]=t:ro(t,i.done),i.lastSelTime=+(new Date),i.lastSelOrigin=s,i.lastSelOp=n,r&&r.clearRedo!==!1&&Ys(i.undone)}function ro(e,t){var n=Fo(t);n&&n.ranges&&n.equals(e)||t.push(e)}function io(e,t,n,r){var i=t["spans_"+e.id],s=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(n){n.markedSpans&&((i||(i=t["spans_"+e.id]={}))[s]=n.markedSpans),++s})}function so(e){if(!e)return null;for(var t=0,n;t<e.length;++t)e[t].marker.explicitlyCleared?n||(n=e.slice(0,t)):n&&n.push(e[t]);return n?n.length?n:null:e}function oo(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var r=0,i=[];r<t.text.length;++r)i.push(so(n[r]));return i}function uo(e,t,n){for(var r=0,i=[];r<e.length;++r){var s=e[r];if(s.ranges){i.push(n?gt.prototype.deepCopy.call(s):s);continue}var o=s.changes,u=[];i.push({changes:u});for(var a=0;a<o.length;++a){var f=o[a],l;u.push({from:f.from,to:f.to,text:f.text});if(t)for(var c in f)(l=c.match(/^spans_(\d+)$/))&&qo(t,Number(l[1]))>-1&&(Fo(u)[c]=f[c],delete f[c])}}return i}function ao(e,t,n,r){n<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function fo(e,t,n,r){for(var i=0;i<e.length;++i){var s=e[i],o=!0;if(s.ranges){s.copied||(s=e[i]=s.deepCopy(),s.copied=!0);for(var u=0;u<s.ranges.length;u++)ao(s.ranges[u].anchor,t,n,r),ao(s.ranges[u].head,t,n,r);continue}for(var u=0;u<s.changes.length;++u){var a=s.changes[u];if(n<a.from.line)a.from=ht(a.from.line+r,a.from.ch),a.to=ht(a.to.line+r,a.to.ch);else if(t<=a.to.line){o=!1;break}}o||(e.splice(0,i+1),i=0)}}function lo(e,t){var n=t.from.line,r=t.to.line,i=t.text.length-(r-n)-1;fo(e.done,n,r,i),fo(e.undone,n,r,i)}function po(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==0}function mo(e){return e.target||e.srcElement}function go(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),v&&e.ctrlKey&&t==1&&(t=3),t}function So(e,t){function s(e){return function(){e.apply(null,r)}}var n=e._handlers&&e._handlers[t];if(!n)return;var r=Array.prototype.slice.call(arguments,2),i;Nn?i=Nn.delayedCallbacks:Eo?i=Eo:(i=Eo=[],setTimeout(xo,0));for(var o=0;o<n.length;++o)i.push(s(n[o]))}function xo(){var e=Eo;Eo=null;for(var t=0;t<e.length;++t)e[t]()}function To(e,t,n){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),wo(e,n||t.type,e,t),po(t)||t.codemirrorIgnore}function No(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t)return;var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]);for(var r=0;r<t.length;++r)qo(n,t[r])==-1&&n.push(t[r])}function Co(e,t){var n=e._handlers&&e._handlers[t];return n&&n.length>0}function ko(e){e.prototype.on=function(e,t){yo(this,e,t)},e.prototype.off=function(e,t){bo(this,e,t)}}function Do(){this.id=null}function Ho(e,t,n){for(var r=0,i=0;;){var s=e.indexOf("	",r);s==-1&&(s=e.length);var o=s-r;if(s==e.length||i+o>=t)return r+Math.min(o,t-i);i+=s-r,i+=n-i%n,r=s+1;if(i>=t)return r}}function jo(e){while(Bo.length<=e)Bo.push(Fo(Bo)+" ");return Bo[e]}function Fo(e){return e[e.length-1]}function qo(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}function Ro(e,t){var n=[];for(var r=0;r<e.length;r++)n[r]=t(e[r],r);return n}function Uo(e,t){var n;if(Object.create)n=Object.create(e);else{var r=function(){};r.prototype=e,n=new r}return t&&zo(t,n),n}function zo(e,t,n){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(n!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function Wo(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function $o(e,t){return t?t.source.indexOf("\\w")>-1&&Vo(e)?!0:t.test(e):Vo(e)}function Jo(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Qo(e){return e.charCodeAt(0)>=768&&Ko.test(e)}function Go(e,t,n,r){var i=document.createElement(e);n&&(i.className=n),r&&(i.style.cssText=r);if(typeof t=="string")i.appendChild(document.createTextNode(t));else if(t)for(var s=0;s<t.length;++s)i.appendChild(t[s]);return i}function Zo(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function eu(e,t){return Zo(e).appendChild(t)}function tu(e,t){if(e.contains)return e.contains(t);while(t=t.parentNode)if(t==e)return!0}function nu(){return document.activeElement}function ru(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function ou(e,t){var n=e.split(" ");for(var r=0;r<n.length;r++)n[r]&&!ru(n[r]).test(t)&&(t+=" "+n[r]);return t}function uu(e){if(!document.body.getElementsByClassName)return;var t=document.body.getElementsByClassName("CodeMirror");for(var n=0;n<t.length;n++){var r=t[n].CodeMirror;r&&e(r)}}function fu(){if(au)return;lu(),au=!0}function lu(){var e;yo(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,hu=null,uu(ir)},100))}),yo(window,"blur",function(){uu(Hr)})}function pu(e){if(hu!=null)return hu;var t=Go("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");return eu(e,t),t.offsetWidth&&(hu=t.offsetHeight-t.clientHeight),hu||0}function vu(e){if(du==null){var t=Go("span","​");eu(e,Go("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(du=t.offsetWidth<=1&&t.offsetHeight>2&&!(r&&i<8))}return du?Go("span","​"):Go("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px")}function gu(e){if(mu!=null)return mu;var t=eu(e,document.createTextNode("AخA")),n=Yo(t,0,1).getBoundingClientRect();if(!n||n.left==n.right)return!1;var r=Yo(t,1,2).getBoundingClientRect();return mu=r.right-n.right<3}function Su(e){if(Eu!=null)return Eu;var t=eu(e,Go("span","x")),n=t.getBoundingClientRect(),r=Yo(t,0,1).getBoundingClientRect();return Eu=Math.abs(n.left-r.left)>1}function Tu(e,t,n,r){if(!e)return r(t,n,"ltr");var i=!1;for(var s=0;s<e.length;++s){var o=e[s];if(o.from<n&&o.to>t||t==n&&o.to==t)r(Math.max(o.from,t),Math.min(o.to,n),o.level==1?"rtl":"ltr"),i=!0}i||r(t,n,"ltr")}function Nu(e){return e.level%2?e.to:e.from}function Cu(e){return e.level%2?e.from:e.to}function ku(e){var t=Ks(e);return t?Nu(t[0]):0}function Lu(e){var t=Ks(e);return t?Cu(Fo(t)):e.text.length}function Au(e,t){var n=Us(e.doc,t),r=ts(n);r!=n&&(t=Vs(r));var i=Ks(r),s=i?i[0].level%2?Lu(r):ku(r):0;return ht(t,s)}function Ou(e,t){var n,r=Us(e.doc,t);while(n=Zi(r))r=n.find(1,!0).line,t=null;var i=Ks(r),s=i?i[0].level%2?ku(r):Lu(r):r.text.length;return ht(t==null?Vs(r):t,s)}function Mu(e,t){var n=Au(e,t.line),r=Us(e.doc,n.line),i=Ks(r);if(!i||i[0].level==0){var s=Math.max(0,r.text.search(/\S/)),o=t.line==n.line&&t.ch<=s&&t.ch;return ht(n.line,o?0:s)}return n}function _u(e,t,n){var r=e[0].level;return t==r?!0:n==r?!1:t<n}function Pu(e,t){Du=null;for(var n=0,r;n<e.length;++n){var i=e[n];if(i.from<t&&i.to>t)return n;if(i.from==t||i.to==t){if(r!=null)return _u(e,i.level,e[r].level)?(i.from!=i.to&&(Du=r),n):(i.from!=i.to&&(Du=n),r);r=n}}return r}function Hu(e,t,n,r){if(!r)return t+n;do t+=n;while(t>0&&Qo(e.text.charAt(t)));return t}function Bu(e,t,n,r){var i=Ks(e);if(!i)return ju(e,t,n,r);var s=Pu(i,t),o=i[s],u=Hu(e,t,o.level%2?-n:n,r);for(;;){if(u>o.from&&u<o.to)return u;if(u==o.from||u==o.to)return Pu(i,u)==s?u:(o=i[s+=n],n>0==o.level%2?o.to:o.from);o=i[s+=n];if(!o)return null;n>0==o.level%2?u=Hu(e,o.to,-1,r):u=Hu(e,o.from,1,r)}}function ju(e,t,n,r){var i=t+n;if(r)while(i>0&&Qo(e.text.charAt(i)))i+=n;return i<0||i>e.text.length?null:i}var e=/gecko\/\d/i.test(navigator.userAgent),t=/MSIE \d/.test(navigator.userAgent),n=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),r=t||n,i=r&&(t?document.documentMode||6:n[1]),s=/WebKit\//.test(navigator.userAgent),o=s&&/Qt\/\d+\.\d+/.test(navigator.userAgent),u=/Chrome\//.test(navigator.userAgent),a=/Opera\//.test(navigator.userAgent),f=/Apple Computer/.test(navigator.vendor),l=/KHTML\//.test(navigator.userAgent),c=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),h=/PhantomJS/.test(navigator.userAgent),p=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),d=p||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),v=p||/Mac/.test(navigator.platform),m=/win/i.test(navigator.platform),g=a&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);g&&(g=Number(g[1])),g&&g>=15&&(a=!1,s=!0);var y=v&&(o||a&&(g==null||g<12.11)),b=e||r&&i>=9,w=!1,E=!1,ht=S.Pos=function(e,t){if(!(this instanceof ht))return new ht(e,t);this.line=e,this.ch=t},pt=S.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch};gt.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var n=this.ranges[t],r=e.ranges[t];if(pt(n.anchor,r.anchor)!=0||pt(n.head,r.head)!=0)return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new yt(dt(this.ranges[t].anchor),dt(this.ranges[t].head));return new gt(e,this.primIndex)},somethingSelected:function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},contains:function(e,t){t||(t=e);for(var n=0;n<this.ranges.length;n++){var r=this.ranges[n];if(pt(t,r.from())>=0&&pt(e,r.to())<=0)return n}return-1}},yt.prototype={from:function(){return mt(this.anchor,this.head)},to:function(){return vt(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var on={left:0,right:0,top:0,bottom:0},Sn,Nn=null,Cn=0,Gn=null,ar,fr,vr=0,wr=0,Er=null;r?Er=-0.53:e?Er=15:u?Er=-0.7:f&&(Er=-1/3);var Nr=new Do,Ar=null,Fr=S.changeEnd=function(e){return e.text?ht(e.from.line+e.text.length-1,Fo(e.text).length+(e.text.length==1?e.from.ch:0)):e.to};S.prototype={constructor:S,focus:function(){window.focus(),er(this),Qn(this)},setOption:function(e,t){var n=this.options,r=n[e];if(n[e]==t&&e!="mode")return;n[e]=t,li.hasOwnProperty(e)&&jn(this,li[e])(this,t,r)},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Ci(e))},removeKeyMap:function(e){var t=this.state.keyMaps;for(var n=0;n<t.length;++n)if(t[n]==e||t[n].name==e)return t.splice(n,1),!0},addOverlay:Fn(function(e,t){var n=e.token?e:S.getMode(this.options,e);if(n.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:n,modeSpec:e,opaque:t&&t.opaque}),this.state.modeGen++,Un(this)}),removeOverlay:Fn(function(e){var t=this.state.overlays;for(var n=0;n<t.length;++n){var r=t[n].modeSpec;if(r==e||typeof e=="string"&&r.name==e){t.splice(n,1),this.state.modeGen++,Un(this);return}}}),indentLine:Fn(function(e,t,n){typeof t!="string"&&typeof t!="number"&&(t==null?t=this.options.smartIndent?"smart":"prev":t=t?"add":"subtract"),Tt(this.doc,e)&&ii(this,e,t,n)}),indentSelection:Fn(function(e){var t=this.doc.sel.ranges,n=-1;for(var r=0;r<t.length;r++){var i=t[r];if(!i.empty()){var s=i.from(),o=i.to(),u=Math.max(n,s.line);n=Math.min(this.lastLine(),o.line-(o.ch?0:1))+1;for(var a=u;a<n;++a)ii(this,a,e);var f=this.doc.sel.ranges;s.ch==0&&t.length==f.length&&f[r].from().ch>0&&At(this.doc,r,new yt(s,f[r].to()),Oo)}else i.head.line>n&&(ii(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&ni(this))}}),getTokenAt:function(e,t){return gs(this,e,t)},getLineTokens:function(e,t){return gs(this,ht(e),t,!0)},getTokenTypeAt:function(e){e=St(this.doc,e);var t=ws(this,Us(this.doc,e.line)),n=0,r=(t.length-1)/2,i=e.ch,s;if(i==0)s=t[2];else for(;;){var o=n+r>>1;if((o?t[o*2-1]:0)>=i)r=o;else{if(!(t[o*2+1]<i)){s=t[o*2+2];break}n=o+1}}var u=s?s.indexOf("cm-overlay "):-1;return u<0?s:u==0?null:s.slice(0,u-1)},getModeAt:function(e){var t=this.doc.mode;return t.innerMode?S.innerMode(t,this.getTokenAt(e).state).mode:t},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var n=[];if(!gi.hasOwnProperty(t))return gi;var r=gi[t],i=this.getModeAt(e);if(typeof i[t]=="string")r[i[t]]&&n.push(r[i[t]]);else if(i[t])for(var s=0;s<i[t].length;s++){var o=r[i[t][s]];o&&n.push(o)}else i.helperType&&r[i.helperType]?n.push(r[i.helperType]):r[i.name]&&n.push(r[i.name]);for(var s=0;s<r._global.length;s++){var u=r._global[s];u.pred(i,this)&&qo(n,u.val)==-1&&n.push(u.val)}return n},getStateAfter:function(e,t){var n=this.doc;return e=Et(n,e==null?n.first+n.size-1:e),Jt(this,e+1,t)},cursorCoords:function(e,t){var n,r=this.doc.sel.primary();return e==null?n=r.head:typeof e=="object"?n=St(this.doc,e):n=e?r.from():r.to(),gn(this,n,t||"page")},charCoords:function(e,t){return mn(this,St(this.doc,e),t||"page")},coordsChar:function(e,t){return e=vn(this,e,t||"page"),wn(this,e.left,e.top)},lineAtHeight:function(e,t){return e=vn(this,{top:e,left:0},t||"page").top,$s(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var n=!1,r=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>r&&(e=r,n=!0);var i=Us(this.doc,e);return dn(this,i,{top:0,left:0},t||"page").top+(n?this.doc.height-Js(i):0)},defaultTextHeight:function(){return xn(this.display)},defaultCharWidth:function(){return Tn(this.display)},setGutterMarker:Fn(function(e,t,n){return si(this.doc,e,"gutter",function(e){var r=e.gutterMarkers||(e.gutterMarkers={});return r[t]=n,!n&&Jo(r)&&(e.gutterMarkers=null),!0})}),clearGutter:Fn(function(e){var t=this,n=t.doc,r=n.first;n.iter(function(n){n.gutterMarkers&&n.gutterMarkers[e]&&(n.gutterMarkers[e]=null,zn(t,r,"gutter"),Jo(n.gutterMarkers)&&(n.gutterMarkers=null)),++r})}),addLineWidget:Fn(function(e,t,n){return ls(this,e,t,n)}),removeLineWidget:function(e){e.clear()},lineInfo:function(e){if(typeof e=="number"){if(!Tt(this.doc,e))return null;var t=e;e=Us(this.doc,e);if(!e)return null}else{var t=Vs(e);if(t==null)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var s=this.display;e=gn(this,St(this.doc,e));var o=e.bottom,u=e.left;t.style.position="absolute",s.sizer.appendChild(t);if(r=="over")o=e.top;else if(r=="above"||r=="near"){var a=Math.max(s.wrapper.clientHeight,this.doc.height),f=Math.max(s.sizer.clientWidth,s.lineSpace.clientWidth);(r=="above"||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?o=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(o=e.bottom),u+t.offsetWidth>f&&(u=f-t.offsetWidth)}t.style.top=o+"px",t.style.left=t.style.right="",i=="right"?(u=s.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):(i=="left"?u=0:i=="middle"&&(u=(s.sizer.clientWidth-t.offsetWidth)/2),t.style.left=u+"px"),n&&Zr(this,u,o,u+t.offsetWidth,o+t.offsetHeight)},triggerOnKeyDown:Fn(Or),triggerOnKeyPress:Fn(Dr),triggerOnKeyUp:_r,execCommand:function(e){if(wi.hasOwnProperty(e))return wi[e](this)},findPosH:function(e,t,n,r){var i=1;t<0&&(i=-1,t=-t);for(var s=0,o=St(this.doc,e);s<t;++s){o=ui(this.doc,o,i,n,r);if(o.hitSide)break}return o},moveH:Fn(function(e,t){var n=this;n.extendSelectionsBy(function(r){return n.display.shift||n.doc.extend||r.empty()?ui(n.doc,r.head,e,t,n.options.rtlMoveVisually):e<0?r.from():r.to()},_o)}),deleteH:Fn(function(e,t){var n=this.doc.sel,r=this.doc;n.somethingSelected()?r.replaceSelection("",null,"+delete"):oi(this,function(n){var i=ui(r,n.head,e,t,!1);return e<0?{from:i,to:n.head}:{from:n.head,to:i}})}),findPosV:function(e,t,n,r){var i=1,s=r;t<0&&(i=-1,t=-t);for(var o=0,u=St(this.doc,e);o<t;++o){var a=gn(this,u,"div");s==null?s=a.left:a.left=s,u=ai(this,a,i,n);if(u.hitSide)break}return u},moveV:Fn(function(e,t){var n=this,r=this.doc,i=[],s=!n.display.shift&&!r.extend&&r.sel.somethingSelected();r.extendSelectionsBy(function(o){if(s)return e<0?o.from():o.to();var u=gn(n,o.head,"div");o.goalColumn!=null&&(u.left=o.goalColumn),i.push(u.left);var a=ai(n,u,e,t);return t=="page"&&o==r.sel.primary()&&ti(n,null,mn(n,a,"div").top-u.top),a},_o);if(i.length)for(var o=0;o<r.sel.ranges.length;o++)r.sel.ranges[o].goalColumn=i[o]}),findWordAt:function(e){var t=this.doc,n=Us(t,e.line).text,r=e.ch,i=e.ch;if(n){var s=this.getHelper(e,"wordChars");(e.xRel<0||i==n.length)&&r?--r:++i;var o=n.charAt(r),u=$o(o,s)?function(e){return $o(e,s)}:/\s/.test(o)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!$o(e)};while(r>0&&u(n.charAt(r-1)))--r;while(i<n.length&&u(n.charAt(i)))++i}return new yt(ht(e.line,r),ht(e.line,i))},toggleOverwrite:function(e){if(e!=null&&e==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?su(this.display.cursorDiv,"CodeMirror-overwrite"):iu(this.display.cursorDiv,"CodeMirror-overwrite"),wo(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return nu()==this.display.input},scrollTo:Fn(function(e,t){(e!=null||t!=null)&&ri(this),e!=null&&(this.curOp.scrollLeft=e),t!=null&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller,t=Lo;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-t,width:e.scrollWidth-t,clientHeight:e.clientHeight-t,clientWidth:e.clientWidth-t}},scrollIntoView:Fn(function(e,t){e==null?(e={from:this.doc.sel.primary().head,to:null},t==null&&(t=this.options.cursorScrollMargin)):typeof e=="number"?e={from:ht(e,0),to:null}:e.from==null&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0;if(e.from.line!=null)ri(this),this.curOp.scrollToPos=e;else{var n=ei(this,Math.min(e.from.left,e.to.left),Math.min(e.from.top,e.to.top)-e.margin,Math.max(e.from.right,e.to.right),Math.max(e.from.bottom,e.to.bottom)+e.margin);this.scrollTo(n.scrollLeft,n.scrollTop)}}),setSize:Fn(function(e,t){function r(e){return typeof e=="number"||/^\d+$/.test(String(e))?e+"px":e}var n=this;e!=null&&(n.display.wrapper.style.width=r(e)),t!=null&&(n.display.wrapper.style.height=r(t)),n.options.lineWrapping&&ln(this);var i=n.display.viewFrom;n.doc.iter(i,n.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){zn(n,i,"widget");break}++i}),n.curOp.forceUpdate=!0,wo(n,"refresh",this)}),operation:function(e){return Bn(this,e)},refresh:Fn(function(){var e=this.display.cachedTextHeight;Un(this),this.curOp.forceUpdate=!0,cn(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),_(this),(e==null||Math.abs(e-xn(this.display))>.5)&&L(this),wo(this,"refresh",this)}),swapDoc:Fn(function(e){var t=this.doc;return t.cm=null,Rs(this,e),cn(this),Zn(this),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,So(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}},ko(S);var fi=S.defaults={},li=S.optionHandlers={},hi=S.Init={toString:function(){return"CodeMirror.Init"}};ci("value","",function(e,t){e.setValue(t)},!0),ci("mode",null,function(e,t){e.doc.modeOption=t,T(e)},!0),ci("indentUnit",2,T,!0),ci("indentWithTabs",!1),ci("smartIndent",!0),ci("tabSize",4,function(e){N(e),cn(e),Un(e)},!0),ci("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t){e.options.specialChars=new RegExp(t.source+(t.test("	")?"":"|	"),"g"),e.refresh()},!0),ci("specialCharPlaceholder",Cs,function(e){e.refresh()},!0),ci("electricChars",!0),ci("rtlMoveVisually",!m),ci("wholeLineUpdateBefore",!0),ci("theme","default",function(e){A(e),O(e)},!0),ci("keyMap","default",function(e,t,n){var r=Ci(t),i=n!=S.Init&&Ci(n);i&&i.detach&&i.detach(e,r),r.attach&&r.attach(e,i||null)}),ci("extraKeys",null),ci("lineWrapping",!1,C,!0),ci("gutters",[],function(e){H(e.options),O(e)},!0),ci("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?z(e.display)+"px":"0",e.refresh()},!0),ci("coverGutterNextToScrollbar",!1,F,!0),ci("lineNumbers",!1,function(e){H(e.options),O(e)},!0),ci("firstLineNumber",1,O,!0),ci("lineNumberFormatter",function(e){return e},O,!0),ci("showCursorWhenSelecting",!1,Rt,!0),ci("resetSelectionOnContextMenu",!0),ci("readOnly",!1,function(e,t){t=="nocursor"?(Hr(e),e.display.input.blur(),e.display.disabled=!0):(e.display.disabled=!1,t||Zn(e))}),ci("disableInput",!1,function(e,t){t||Zn(e)},!0),ci("dragDrop",!0),ci("cursorBlinkRate",530),ci("cursorScrollMargin",0),ci("cursorHeight",1,Rt,!0),ci("singleCursorHeightPerLine",!0,Rt,!0),ci("workTime",100),ci("workDelay",100),ci("flattenSpans",!0,N,!0),ci("addModeClass",!1,N,!0),ci("pollInterval",100),ci("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),ci("historyEventDelay",1250),ci("viewportMargin",10,function(e){e.refresh()},!0),ci("maxHighlightLength",1e4,N,!0),ci("moveInputWithCursor",!0,function(e,t){t||(e.display.inputDiv.style.top=e.display.inputDiv.style.left=0)}),ci("tabindex",null,function(e,t){e.display.input.tabIndex=t||""}),ci("autofocus",null);var pi=S.modes={},di=S.mimeModes={};S.defineMode=function(e,t){!S.defaults.mode&&e!="null"&&(S.defaults.mode=e),arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),pi[e]=t},S.defineMIME=function(e,t){di[e]=t},S.resolveMode=function(e){if(typeof e=="string"&&di.hasOwnProperty(e))e=di[e];else if(e&&typeof e.name=="string"&&di.hasOwnProperty(e.name)){var t=di[e.name];typeof t=="string"&&(t={name:t}),e=Uo(t,e),e.name=t.name}else if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return S.resolveMode("application/xml");return typeof e=="string"?{name:e}:e||{name:"null"}},S.getMode=function(e,t){var t=S.resolveMode(t),n=pi[t.name];if(!n)return S.getMode(e,"text/plain");var r=n(e,t);if(vi.hasOwnProperty(t.name)){var i=vi[t.name];for(var s in i){if(!i.hasOwnProperty(s))continue;r.hasOwnProperty(s)&&(r["_"+s]=r[s]),r[s]=i[s]}}r.name=t.name,t.helperType&&(r.helperType=t.helperType);if(t.modeProps)for(var s in t.modeProps)r[s]=t.modeProps[s];return r},S.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),S.defineMIME("text/plain","null");var vi=S.modeExtensions={};S.extendMode=function(e,t){var n=vi.hasOwnProperty(e)?vi[e]:vi[e]={};zo(t,n)},S.defineExtension=function(e,t){S.prototype[e]=t},S.defineDocExtension=function(e,t){js.prototype[e]=t},S.defineOption=ci;var mi=[];S.defineInitHook=function(e){mi.push(e)};var gi=S.helpers={};S.registerHelper=function(e,t,n){gi.hasOwnProperty(e)||(gi[e]=S[e]={_global:[]}),gi[e][t]=n},S.registerGlobalHelper=function(e,t,n,r){S.registerHelper(e,t,r),gi[e]._global.push({pred:n,val:r})};var yi=S.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n},bi=S.startState=function(e,t,n){return e.startState?e.startState(t,n):!0};S.innerMode=function(e,t){while(e.innerMode){var n=e.innerMode(t);if(!n||n.mode==e)break;t=n.state,e=n.mode}return n||{mode:e,state:t}};var wi=S.commands={selectAll:function(e){e.setSelection(ht(e.firstLine(),0),ht(e.lastLine()),Oo)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Oo)},killLine:function(e){oi(e,function(t){if(t.empty()){var n=Us(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line<e.lastLine()?{from:t.head,to:ht(t.head.line+1,0)}:{from:t.head,to:ht(t.head.line,n)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){oi(e,function(t){return{from:ht(t.from().line,0),to:St(e.doc,ht(t.to().line+1,0))}})},delLineLeft:function(e){oi(e,function(e){return{from:ht(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){oi(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){oi(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div");return{from:t.from(),to:r}})},undo:function(e){e.undo()},redo:function(e){e.redo()},undoSelection:function(e){e.undoSelection()},redoSelection:function(e){e.redoSelection()},goDocStart:function(e){e.extendSelection(ht(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(ht(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return Au(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return Mu(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return Ou(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div")},_o)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:n},"div")},_o)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return r.ch<e.getLine(r.line).search(/\S/)?Mu(e,t.head):r},_o)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goGroupRight:function(e){e.moveH(1,"group")},goGroupLeft:function(e){e.moveH(-1,"group")},goWordRight:function(e){e.moveH(1,"word")},delCharBefore:function(e){e.deleteH(-1,"char")},delCharAfter:function(e){e.deleteH(1,"char")},delWordBefore:function(e){e.deleteH(-1,"word")},delWordAfter:function(e){e.deleteH(1,"word")},delGroupBefore:function(e){e.deleteH(-1,"group")},delGroupAfter:function(e){e.deleteH(1,"group")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection("	")},insertSoftTab:function(e){var t=[],n=e.listSelections(),r=e.options.tabSize;for(var i=0;i<n.length;i++){var s=n[i].from(),o=Po(e.getLine(s.line),s.ch,r);t.push((new Array(r-o%r+1)).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Bn(e,function(){var t=e.listSelections(),n=[];for(var r=0;r<t.length;r++){var i=t[r].head,s=Us(e.doc,i.line).text;if(s){i.ch==s.length&&(i=new ht(i.line,i.ch-1));if(i.ch>0)i=new ht(i.line,i.ch+1),e.replaceRange(s.charAt(i.ch-1)+s.charAt(i.ch-2),ht(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var o=Us(e.doc,i.line-1).text;o&&e.replaceRange(s.charAt(0)+"\n"+o.charAt(o.length-1),ht(i.line-1,o.length-1),ht(i.line,1),"+transpose")}}n.push(new yt(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){Bn(e,function(){var t=e.listSelections().length;for(var n=0;n<t;n++){var r=e.listSelections()[n];e.replaceRange("\n",r.anchor,r.head,"+input"),e.indentLine(r.from().line+1,null,!0),ni(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},Ei=S.keyMap={};Ei.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Ei.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Ei.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"},Ei.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Ei["default"]=v?Ei.macDefault:Ei.pcDefault,S.normalizeKeyMap=function(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if(r=="..."){delete e[n];continue}var i=Ro(n.split(" "),Si);for(var s=0;s<i.length;s++){var o,u;s==i.length-1?(u=n,o=r):(u=i.slice(0,s+1).join(" "),o="...");var a=t[u];if(!a)t[u]=o;else if(a!=o)throw new Error("Inconsistent bindings for "+u)}delete e[n]}for(var f in t)e[f]=t[f];return e};var xi=S.lookupKey=function(e,t,n){t=Ci(t);var r=t.call?t.call(e):t[e];if(r===!1)return"nothing";if(r==="...")return"multi";if(r!=null&&n(r))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return xi(e,t.fallthrough,n);for(var i=0;i<t.fallthrough.length;i++){var s=xi(e,t.fallthrough[i],n);if(s)return s}}},Ti=S.isModifierKey=function(e){var t=typeof e=="string"?e:xu[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"},Ni=S.keyName=function(e,t){if(a&&e.keyCode==34&&e["char"])return!1;var n=xu[e.keyCode],r=n;return r==null||e.altGraphKey?!1:(e.altKey&&n!="Alt"&&(r="Alt-"+r),(y?e.metaKey:e.ctrlKey)&&n!="Ctrl"&&(r="Ctrl-"+r),(y?e.ctrlKey:e.metaKey)&&n!="Cmd"&&(r="Cmd-"+r),!t&&e.shiftKey&&n!="Shift"&&(r="Shift-"+r),r)};S.fromTextArea=function(e,t){function r(){e.value=a.getValue()}t||(t={}),t.value=e.value,!t.tabindex&&e.tabindex&&(t.tabindex=e.tabindex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder);if(t.autofocus==null){var n=nu();t.autofocus=n==e||e.getAttribute("autofocus")!=null&&n==document.body}if(e.form){yo(e.form,"submit",r);if(!t.leaveSubmitMethodAlone){var i=e.form,s=i.submit;try{var o=i.submit=function(){r(),i.submit=s,i.submit(),i.submit=o}}catch(u){}}}e.style.display="none";var a=S(function(t){e.parentNode.insertBefore(t,e.nextSibling)},t);return a.save=r,a.getTextArea=function(){return e},a.toTextArea=function(){a.toTextArea=isNaN,r(),e.parentNode.removeChild(a.getWrapperElement()),e.style.display="",e.form&&(bo(e.form,"submit",r),typeof e.form.submit=="function"&&(e.form.submit=s))},a};var ki=S.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};ki.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},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(e){var t=this.string.charAt(this.pos);if(typeof e=="string")var n=t==e;else var n=t&&(e.test?e.test(t):e(t));if(n)return++this.pos,t},eatWhile:function(e){var t=this.pos;while(this.eat(e));return this.pos>t},eatSpace:function(){var e=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Po(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Po(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Po(this.string,null,this.tabSize)-(this.lineStart?Po(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,n){if(typeof e!="string"){var s=this.string.slice(this.pos).match(e);return s&&s.index>0?null:(s&&t!==!1&&(this.pos+=s[0].length),s)}var r=function(e){return n?e.toLowerCase():e},i=this.string.substr(this.pos,e.length);if(r(i)==r(e))return t!==!1&&(this.pos+=e.length),!0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var Li=S.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e};ko(Li),Li.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;t&&kn(e);if(Co(this,"clear")){var n=this.find();n&&So(this,"clear",n.from,n.to)}var r=null,i=null;for(var s=0;s<this.lines.length;++s){var o=this.lines[s],u=ji(o.markedSpans,this);e&&!this.collapsed?zn(e,Vs(o),"text"):e&&(u.to!=null&&(i=Vs(o)),u.from!=null&&(r=Vs(o))),o.markedSpans=Fi(o.markedSpans,u),u.from==null&&this.collapsed&&!ss(this.doc,o)&&e&&Xs(o,xn(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var s=0;s<this.lines.length;++s){var a=ts(this.lines[s]),f=D(a);f>e.display.maxLineLength&&(e.display.maxLine=a,e.display.maxLineLength=f,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&Un(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Bt(e.doc)),e&&So(e,"markerCleared",e,this),t&&An(e),this.parent&&this.parent.clear()},Li.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);var n,r;for(var i=0;i<this.lines.length;++i){var s=this.lines[i],o=ji(s.markedSpans,this);if(o.from!=null){n=ht(t?s:Vs(s),o.from);if(e==-1)return n}if(o.to!=null){r=ht(t?s:Vs(s),o.to);if(e==1)return r}}return n&&{from:n,to:r}},Li.prototype.changed=function(){var e=this.find(-1,!0),t=this,n=this.doc.cm;if(!e||!n)return;Bn(n,function(){var r=e.line,i=Vs(e.line),s=nn(n,i);s&&(fn(s),n.curOp.selectionChanged=n.curOp.forceUpdate=!0),n.curOp.updateMaxLine=!0;if(!ss(t.doc,r)&&t.height!=null){var o=t.height;t.height=null;var u=fs(t)-o;u&&Xs(r,r.height+u)}})},Li.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||qo(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Li.prototype.detachLine=function(e){this.lines.splice(qo(this.lines,e),1);if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var Ai=0,Mi=S.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=this};ko(Mi),Mi.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();So(this,"clear")},Mi.prototype.find=function(e,t){return this.primary.find(e,t)};var us=S.LineWidget=function(e,t,n){if(n)for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.cm=e,this.node=t};ko(us),us.prototype.clear=function(){var e=this.cm,t=this.line.widgets,n=this.line,r=Vs(n);if(r==null||!t)return;for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(n.widgets=null);var s=fs(this);Bn(e,function(){as(e,n,-s),zn(e,r,"widget"),Xs(n,Math.max(0,n.height-s))})},us.prototype.changed=function(){var e=this.height,t=this.cm,n=this.line;this.height=null;var r=fs(this)-e;if(!r)return;Bn(t,function(){t.curOp.forceUpdate=!0,as(t,n,r),Xs(n,n.height+r)})};var cs=S.Line=function(e,t,n){this.text=e,$i(this,t),this.height=n?n(this):1};ko(cs),cs.prototype.lineNo=function(){return Vs(this)};var Ss={},xs={};Ps.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var n=e,r=e+t;n<r;++n){var i=this.lines[n];this.height-=i.height,ps(i),So(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,n){for(var r=e+t;e<r;++e)if(n(this.lines[e]))return!0}},Hs.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n=0;n<this.children.length;++n){var r=this.children[n],i=r.chunkSize();if(e<i){var s=Math.min(t,i-e),o=r.height;r.removeInner(e,s),this.height-=o-r.height,i==s&&(this.children.splice(n--,1),r.parent=null);if((t-=s)==0)break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Ps))){var u=[];this.collapse(u),this.children=[new Ps(u)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,n){this.size+=t.length,this.height+=n;for(var r=0;r<this.children.length;++r){var i=this.children[r],s=i.chunkSize();if(e<=s){i.insertInner(e,t,n);if(i.lines&&i.lines.length>50){while(i.lines.length>50){var o=i.lines.splice(i.lines.length-25,25),u=new Ps(o);i.height-=u.height,this.children.splice(r+1,0,u),u.parent=this}this.maybeSpill()}break}e-=s}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),n=new Hs(t);if(!e.parent){var r=new Hs(e.children);r.parent=e,e.children=[r,n],e=r}else{e.size-=n.size,e.height-=n.height;var i=qo(e.parent.children,e);e.parent.children.splice(i+1,0,n)}n.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN:function(e,t,n){for(var r=0;r<this.children.length;++r){var i=this.children[r],s=i.chunkSize();if(e<s){var o=Math.min(t,s-e);if(i.iterN(e,o,n))return!0;if((t-=o)==0)break;e=0}else e-=s}}};var Bs=0,js=S.Doc=function(e,t,n){if(!(this instanceof js))return new js(e,t,n);n==null&&(n=0),Hs.call(this,[new Ps([new cs("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=n;var r=ht(n,0);this.sel=wt(r),this.history=new Qs(null),this.id=++Bs,this.modeOption=t,typeof e=="string"&&(e=yu(e)),Ds(this,{from:r,to:r,text:e}),Dt(this,wt(r),Oo)};js.prototype=Uo(Hs.prototype,{constructor:js,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){var n=0;for(var r=0;r<t.length;++r)n+=t[r].height;this.insertInner(e-this.first,t,n)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Ws(this,this.first,this.first+this.size);return e===!1?t:t.join(e||"\n")},setValue:In(function(e){var t=ht(this.first,0),n=this.first+this.size-1;Wr(this,{from:t,to:ht(n,Us(this,n).text.length),text:yu(e),origin:"setValue"},!0),Dt(this,wt(t))}),replaceRange:function(e,t,n,r){t=St(this,t),n=n?St(this,n):t,Qr(this,e,t,n,r)},getRange:function(e,t,n){var r=zs(this,St(this,e),St(this,t));return n===!1?r:r.join(n||"\n")},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(Tt(this,e))return Us(this,e)},getLineNumber:function(e){return Vs(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=Us(this,e)),ts(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return St(this,e)},getCursor:function(e){var t=this.sel.primary(),n;return e==null||e=="head"?n=t.head:e=="anchor"?n=t.anchor:e=="end"||e=="to"||e===!1?n=t.to():n=t.from(),n},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:In(function(e,t,n){Ot(this,St(this,typeof e=="number"?ht(e,t||0):e),null,n)}),setSelection:In(function(e,t,n){Ot(this,St(this,e),St(this,t||e),n)}),extendSelection:In(function(e,t,n){kt(this,St(this,e),t&&St(this,t),n)}),extendSelections:In(function(e,t){Lt(this,Nt(this,e,t))}),extendSelectionsBy:In(function(e,t){Lt(this,Ro(this.sel.ranges,e),t)}),setSelections:In(function(e,t,n){if(!e.length)return;for(var r=0,i=[];r<e.length;r++)i[r]=new yt(St(this,e[r].anchor),St(this,e[r].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),Dt(this,bt(i,t),n)}),addSelection:In(function(e,t,n){var r=this.sel.ranges.slice(0);r.push(new yt(St(this,e),St(this,t||e))),Dt(this,bt(r,r.length-1),n)}),getSelection:function(e){var t=this.sel.ranges,n;for(var r=0;r<t.length;r++){var i=zs(this,t[r].from(),t[r].to());n=n?n.concat(i):i}return e===!1?n:n.join(e||"\n")},getSelections:function(e){var t=[],n=this.sel.ranges;for(var r=0;r<n.length;r++){var i=zs(this,n[r].from(),n[r].to());e!==!1&&(i=i.join(e||"\n")),t[r]=i}return t},replaceSelection:function(e,t,n){var r=[];for(var i=0;i<this.sel.ranges.length;i++)r[i]=e;this.replaceSelections(r,t,n||"+input")},replaceSelections:In(function(e,t,n){var r=[],i=this.sel;for(var s=0;s<i.ranges.length;s++){var o=i.ranges[s];r[s]={from:o.from(),to:o.to(),text:yu(e[s]),origin:n}}var u=t&&t!="end"&&Ur(this,r,t);for(var s=r.length-1;s>=0;s--)Wr(this,r[s]);u?_t(this,u):this.cm&&ni(this.cm)}),undo:In(function(){Vr(this,"undo")}),redo:In(function(){Vr(this,"redo")}),undoSelection:In(function(){Vr(this,"undo",!0)}),redoSelection:In(function(){Vr(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){var e=this.history,t=0,n=0;for(var r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var r=0;r<e.undone.length;r++)e.undone[r].ranges||++n;return{undo:t,redo:n}},clearHistory:function(){this.history=new Qs(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:uo(this.history.done),undone:uo(this.history.undone)}},setHistory:function(e){var t=this.history=new Qs(this.history.maxGeneration);t.done=uo(e.done.slice(0),null,!0),t.undone=uo(e.undone.slice(0),null,!0)},addLineClass:In(function(e,t,n){return si(this,e,t=="gutter"?"gutter":"class",function(e){var r=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(!e[r])e[r]=n;else{if(ru(n).test(e[r]))return!1;e[r]+=" "+n}return!0})}),removeLineClass:In(function(e,t,n){return si(this,e,"class",function(e){var r=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",i=e[r];if(!i)return!1;if(n==null)e[r]=null;else{var s=i.match(ru(n));if(!s)return!1;var o=s.index+s[0].length;e[r]=i.slice(0,s.index)+(!s.index||o==i.length?"":" ")+i.slice(o)||null}return!0})}),markText:function(e,t,n){return Oi(this,St(this,e),St(this,t),n,"range")},setBookmark:function(e,t){var n={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared};return e=St(this,e),Oi(this,e,e,n,"bookmark")},findMarksAt:function(e){e=St(this,e);var t=[],n=Us(this,e.line).markedSpans;if(n)for(var r=0;r<n.length;++r){var i=n[r];(i.from==null||i.from<=e.ch)&&(i.to==null||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=St(this,e),t=St(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(s){var o=s.markedSpans;if(o)for(var u=0;u<o.length;u++){var a=o[u];!(i==e.line&&e.ch>a.to||a.from==null&&i!=e.line||i==t.line&&a.from>t.ch)&&(!n||n(a.marker))&&r.push(a.marker.parent||a.marker)}++i}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var r=0;r<n.length;++r)n[r].from!=null&&e.push(n[r].marker)}),e},posFromIndex:function(e){var t,n=this.first;return this.iter(function(r){var i=r.text.length+1;if(i>e)return t=e,!0;e-=i,++n}),St(this,ht(n,t))},indexFromPos:function(e){e=St(this,e);var t=e.ch;return e.line<this.first||e.ch<0?0:(this.iter(this.first,e.line,function(e){t+=e.text.length+1}),t)},copy:function(e){var t=new js(Ws(this,this.first,this.first+this.size),this.modeOption,this.first);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,n=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<n&&(n=e.to);var r=new js(Ws(this,t,n),e.mode||this.modeOption,t);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Pi(r,Di(this)),r},unlinkDoc:function(e){e instanceof S&&(e=e.doc);if(this.linked)for(var t=0;t<this.linked.length;++t){var n=this.linked[t];if(n.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),Hi(Di(this));break}if(e.history==this.history){var r=[e.id];qs(e,function(e){r.push(e.id)},!0),e.history=new Qs(null),e.history.done=uo(this.history.done,r),e.history.undone=uo(this.history.undone,r)}},iterLinkedDocs:function(e){qs(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),js.prototype.eachLine=js.prototype.iter;var Fs="iter insert remove copy getEditor".split(" ");for(var Is in js.prototype)js.prototype.hasOwnProperty(Is)&&qo(Fs,Is)<0&&(S.prototype[Is]=function(e){return function(){return e.apply(this.doc,arguments)}}(js.prototype[Is]));ko(js);var co=S.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},ho=S.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},vo=S.e_stop=function(e){co(e),ho(e)},yo=S.on=function(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else if(e.attachEvent)e.attachEvent("on"+t,n);else{var r=e._handlers||(e._handlers={}),i=r[t]||(r[t]=[]);i.push(n)}},bo=S.off=function(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else if(e.detachEvent)e.detachEvent("on"+t,n);else{var r=e._handlers&&e._handlers[t];if(!r)return;for(var i=0;i<r.length;++i)if(r[i]==n){r.splice(i,1);break}}},wo=S.signal=function(e,t){var n=e._handlers&&e._handlers[t];if(!n)return;var r=Array.prototype.slice.call(arguments,2);for(var i=0;i<n.length;++i)n[i].apply(null,r)},Eo=null,Lo=30,Ao=S.Pass={toString:function(){return"CodeMirror.Pass"}},Oo={scroll:!1},Mo={origin:"*mouse"},_o={origin:"+move"};Do.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Po=S.countColumn=function(e,t,n,r,i){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var s=r||0,o=i||0;;){var u=e.indexOf("	",s);if(u<0||u>=t)return o+(t-s);o+=u-s,o+=n-o%n,s=u+1}},Bo=[""],Io=function(e){e.select()};p?Io=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:r&&(Io=function(e){try{e.select()}catch(t){}}),[].indexOf&&(qo=function(e,t){return e.indexOf(t)}),[].map&&(Ro=function(e,t){return e.map(t)});var Xo=/[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Vo=S.isWordChar=function(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||Xo.test(e))},Ko=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,Yo;document.createRange?Yo=function(e,t,n){var r=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}:Yo=function(e,t,n){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(i){return r}return r.collapse(!0),r.moveEnd("character",n),r.moveStart("character",t),r},r&&i<11&&(nu=function(){try{return document.activeElement}catch(e){return document.body}});var iu=S.rmClass=function(e,t){var n=e.className,r=ru(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}},su=S.addClass=function(e,t){var n=e.className;ru(t).test(n)||(e.className+=(n?" ":"")+t)},au=!1,cu=function(){if(r&&i<9)return!1;var e=Go("div");return"draggable"in e||"dragDrop"in e}(),hu,du,mu,yu=S.splitLines="\n\nb".split(/\n/).length!=3?function(e){var t=0,n=[],r=e.length;while(t<=r){var i=e.indexOf("\n",t);i==-1&&(i=e.length);var s=e.slice(t,e.charAt(i-1)=="\r"?i-1:i),o=s.indexOf("\r");o!=-1?(n.push(s.slice(0,o)),t+=o+1):(n.push(s),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},bu=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(n){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},wu=function(){var e=Go("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),Eu=null,xu={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};S.keyNames=xu,function(){for(var e=0;e<10;e++)xu[e+48]=xu[e+96]=String(e);for(var e=65;e<=90;e++)xu[e]=String.fromCharCode(e);for(var e=1;e<=12;e++)xu[e+111]=xu[e+63235]="F"+e}();var Du,Fu=function(){function n(n){return n<=247?e.charAt(n):1424<=n&&n<=1524?"R":1536<=n&&n<=1773?t.charAt(n-1536):1774<=n&&n<=2220?"r":8192<=n&&n<=8203?"w":n==8204?"b":"L"}function f(e,t,n){this.level=e,this.from=t,this.to=n}var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,s=/[LRr]/,o=/[Lb1n]/,u=/[1n]/,a="L";return function(e){if(!r.test(e))return!1;var t=e.length,l=[];for(var c=0,h;c<t;++c)l.push(h=n(e.charCodeAt(c)));for(var c=0,p=a;c<t;++c){var h=l[c];h=="m"?l[c]=p:p=h}for(var c=0,d=a;c<t;++c){var h=l[c];h=="1"&&d=="r"?l[c]="n":s.test(h)&&(d=h,h=="r"&&(l[c]="R"))}for(var c=1,p=l[0];c<t-1;++c){var h=l[c];h=="+"&&p=="1"&&l[c+1]=="1"?l[c]="1":h==","&&p==l[c+1]&&(p=="1"||p=="n")&&(l[c]=p),p=h}for(var c=0;c<t;++c){var h=l[c];if(h==",")l[c]="N";else if(h=="%"){for(var v=c+1;v<t&&l[v]=="%";++v);var m=c&&l[c-1]=="!"||v<t&&l[v]=="1"?"1":"N";for(var g=c;g<v;++g)l[g]=m;c=v-1}}for(var c=0,d=a;c<t;++c){var h=l[c];d=="L"&&h=="1"?l[c]="L":s.test(h)&&(d=h)}for(var c=0;c<t;++c)if(i.test(l[c])){for(var v=c+1;v<t&&i.test(l[v]);++v);var y=(c?l[c-1]:a)=="L",b=(v<t?l[v]:a)=="L",m=y||b?"L":"R";for(var g=c;g<v;++g)l[g]=m;c=v-1}var w=[],E;for(var c=0;c<t;)if(o.test(l[c])){var S=c;for(++c;c<t&&o.test(l[c]);++c);w.push(new f(0,S,c))}else{var x=c,T=w.length;for(++c;c<t&&l[c]!="L";++c);for(var g=x;g<c;)if(u.test(l[g])){x<g&&w.splice(T,0,new f(1,x,g));var N=g;for(++g;g<c&&u.test(l[g]);++g);w.splice(T,0,new f(2,N,g)),x=g}else++g;x<c&&w.splice(T,0,new f(1,x,c))}return w[0].level==1&&(E=e.match(/^\s+/))&&(w[0].from=E[0].length,w.unshift(new f(0,0,E[0].length))),Fo(w).level==1&&(E=e.match(/\s+$/))&&(Fo(w).to-=E[0].length,w.push(new f(0,t-E[0].length,t))),w[0].level!=Fo(w).level&&w.push(new f(w[0].level,t,t)),w}}();return S.version="4.8.0",S}),define("CMLint",["react","lodash","jquery","./libs/codemirror-4.8/lib/codemirror"],function(e,t,n,r){function i(e){var t=e.severity;t||(t="error");var n=document.createElement("div");return n.className="CodeMirror-lint-message-"+t,n.appendChild(document.createTextNode(e.message)),n}function o(e,t){var n=document.createDocumentFragment(),r={severity:"error",message:t.message};n.appendChild(i(r)),e.setGutterMarker(Math.max(t.line,0),s,a(n,"error",!1,"state.options.tooltips"))}function u(e){e.clearGutter(s)}function a(e,t,n,i){var s=document.createElement("div"),o=s;return s.className="CodeMirror-lint-marker-"+t,n&&(o=s.appendChild(document.createElement("div")),o.className="CodeMirror-lint-marker-multiple"),i!==!1&&r.on(o,"mouseover",function(t){h(t,e,o)}),s}function f(e,t){function i(e){if(!n.parentNode)return r.off(document,"mousemove",i);n.style.top=Math.max(0,e.clientY-n.offsetHeight-5)+"px",n.style.left=e.clientX+5+"px"}var n=document.createElement("div");return n.className="CodeMirror-lint-tooltip",n.appendChild(t.cloneNode(!0)),document.body.appendChild(n),r.on(document,"mousemove",i),i(e),n.style.opacity!==null&&(n.style.opacity=1),n}function l(e){e.parentNode&&e.parentNode.removeChild(e)}function c(e){if(!e.parentNode)return;e.style.opacity===null&&l(e),e.style.opacity=0,setTimeout(function(){l(e)},600)}function h(e,t,n){function s(){r.off(n,"mouseout",s),i&&(c(i),i=null)}var i=f(e,t),o=setInterval(function(){if(i)for(var e=n;;e=e.parentNode){if(e===document.body)return undefined;if(!e){s();break}}if(!i)return clearInterval(o)},400);r.on(n,"mouseout",s)}var s="rt-annotations";return{GUTTER_ID:s,annotate:o,clearMarks:u}}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/mode/javascript/javascript",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineMode("javascript",function(t,n){function h(e){var t=!1,n,r=!1;while((n=e.next())!=null){if(!t){if(n=="/"&&!r)return;n=="["?r=!0:r&&n=="]"&&(r=!1)}t=!t&&n=="\\"}}function v(e,t,n){return p=e,d=n,t}function m(e,t){var n=e.next();if(n=='"'||n=="'")return t.tokenize=g(n),t.tokenize(e,t);if(n=="."&&e.match(/^\d+(?:[eE][+\-]?\d+)?/))return v("number","number");if(n=="."&&e.match(".."))return v("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return v(n);if(n=="="&&e.eat(">"))return v("=>","operator");if(n=="0"&&e.eat(/x/i))return e.eatWhile(/[\da-f]/i),v("number","number");if(/\d/.test(n))return e.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),v("number","number");if(n=="/")return e.eat("*")?(t.tokenize=y,y(e,t)):e.eat("/")?(e.skipToEnd(),v("comment","comment")):t.lastType=="operator"||t.lastType=="keyword c"||t.lastType=="sof"||/^[\[{}\(,;:]$/.test(t.lastType)?(h(e),e.eatWhile(/[gimy]/),v("regexp","string-2")):(e.eatWhile(l),v("operator","operator",e.current()));if(n=="`")return t.tokenize=b,b(e,t);if(n=="#")return e.skipToEnd(),v("error","error");if(l.test(n))return e.eatWhile(l),v("operator","operator",e.current());if(a.test(n)){e.eatWhile(a);var r=e.current(),i=f.propertyIsEnumerable(r)&&f[r];return i&&t.lastType!="."?v(i.type,i.style,r):v("variable","variable",r)}}function g(e){return function(t,n){var r=!1,i;if(s&&t.peek()=="@"&&t.match(c))return n.tokenize=m,v("jsonld-keyword","meta");while((i=t.next())!=null){if(i==e&&!r)break;r=!r&&i=="\\"}return r||(n.tokenize=m),v("string","string")}}function y(e,t){var n=!1,r;while(r=e.next()){if(r=="/"&&n){t.tokenize=m;break}n=r=="*"}return v("comment","comment")}function b(e,t){var n=!1,r;while((r=e.next())!=null){if(!n&&(r=="`"||r=="$"&&e.eat("{"))){t.tokenize=m;break}n=!n&&r=="\\"}return v("quasi","string-2",e.current())}function E(e,t){t.fatArrowAt&&(t.fatArrowAt=null);var n=e.string.indexOf("=>",e.start);if(n<0)return;var r=0,i=!1;for(var s=n-1;s>=0;--s){var o=e.string.charAt(s),u=w.indexOf(o);if(u>=0&&u<3){if(!r){++s;break}if(--r==0)break}else if(u>=3&&u<6)++r;else if(a.test(o))i=!0;else if(i&&!r){++s;break}}i&&!r&&(t.fatArrowAt=s)}function x(e,t,n,r,i,s){this.indented=e,this.column=t,this.type=n,this.prev=i,this.info=s,r!=null&&(this.align=r)}function T(e,t){for(var n=e.localVars;n;n=n.next)if(n.name==t)return!0;for(var r=e.context;r;r=r.prev)for(var n=r.vars;n;n=n.next)if(n.name==t)return!0}function N(e,t,n,r,i){var s=e.cc;C.state=e,C.stream=i,C.marked=null,C.cc=s,C.style=t,e.lexical.hasOwnProperty("align")||(e.lexical.align=!0);for(;;){var u=s.length?s.pop():o?j:B;if(u(n,r)){while(s.length&&s[s.length-1].lex)s.pop()();return C.marked?C.marked:n=="variable"&&T(e,r)?"variable-2":t}}}function k(){for(var e=arguments.length-1;e>=0;e--)C.cc.push(arguments[e])}function L(){return k.apply(null,arguments),!0}function A(e){function t(t){for(var n=t;n;n=n.next)if(n.name==e)return!0;return!1}var r=C.state;if(r.context){C.marked="def";if(t(r.localVars))return;r.localVars={name:e,next:r.localVars}}else{if(t(r.globalVars))return;n.globalVars&&(r.globalVars={name:e,next:r.globalVars})}}function M(){C.state.context={prev:C.state.context,vars:C.state.localVars},C.state.localVars=O}function _(){C.state.localVars=C.state.context.vars,C.state.context=C.state.context.prev}function D(e,t){var n=function(){var n=C.state,r=n.indented;if(n.lexical.type=="stat")r=n.lexical.indented;else for(var i=n.lexical;i&&i.type==")"&&i.align;i=i.prev)r=i.indented;n.lexical=new x(r,C.stream.column(),e,null,n.lexical,t)};return n.lex=!0,n}function P(){var e=C.state;e.lexical.prev&&(e.lexical.type==")"&&(e.indented=e.lexical.indented),e.lexical=e.lexical.prev)}function H(e){function t(n){return n==e?L():e==";"?k():L(t)}return t}function B(e,t){return e=="var"?L(D("vardef",t.length),it,H(";"),P):e=="keyword a"?L(D("form"),j,B,P):e=="keyword b"?L(D("form"),B,P):e=="{"?L(D("}"),tt,P):e==";"?L():e=="if"?(C.state.lexical.info=="else"&&C.state.cc[C.state.cc.length-1]==P&&C.state.cc.pop()(),L(D("form"),j,B,P,ft)):e=="function"?L(vt):e=="for"?L(D("form"),lt,B,P):e=="variable"?L(D("stat"),J):e=="switch"?L(D("form"),j,D("}","switch"),H("{"),tt,P,P):e=="case"?L(j,H(":")):e=="default"?L(H(":")):e=="catch"?L(D("form"),M,H("("),mt,H(")"),B,P,_):e=="module"?L(D("form"),M,Et,_,P):e=="class"?L(D("form"),gt,P):e=="export"?L(D("form"),St,P):e=="import"?L(D("form"),xt,P):k(D("stat"),j,H(";"),P)}function j(e){return I(e,!1)}function F(e){return I(e,!0)}function I(e,t){if(C.state.fatArrowAt==C.stream.start){var n=t?$:V;if(e=="(")return L(M,D(")"),Z(st,")"),P,H("=>"),n,_);if(e=="variable")return k(M,st,H("=>"),n,_)}var r=t?z:U;return S.hasOwnProperty(e)?L(r):e=="function"?L(vt,r):e=="keyword c"?L(t?R:q):e=="("?L(D(")"),q,Lt,H(")"),P,r):e=="operator"||e=="spread"?L(t?F:j):e=="["?L(D("]"),Ct,P,r):e=="{"?et(Q,"}",null,r):e=="quasi"?k(W,r):L()}function q(e){return e.match(/[;\}\)\],]/)?k():k(j)}function R(e){return e.match(/[;\}\)\],]/)?k():k(F)}function U(e,t){return e==","?L(j):z(e,t,!1)}function z(e,t,n){var r=n==0?U:z,i=n==0?j:F;if(e=="=>")return L(M,n?$:V,_);if(e=="operator")return/\+\+|--/.test(t)?L(r):t=="?"?L(j,H(":"),i):L(i);if(e=="quasi")return k(W,r);if(e==";")return;if(e=="(")return et(F,")","call",r);if(e==".")return L(K,r);if(e=="[")return L(D("]"),q,H("]"),P,r)}function W(e,t){return e!="quasi"?k():t.slice(t.length-2)!="${"?L(W):L(j,X)}function X(e){if(e=="}")return C.marked="string-2",C.state.tokenize=b,L(W)}function V(e){return E(C.stream,C.state),k(e=="{"?B:j)}function $(e){return E(C.stream,C.state),k(e=="{"?B:F)}function J(e){return e==":"?L(P,B):k(U,H(";"),P)}function K(e){if(e=="variable")return C.marked="property",L()}function Q(e,t){if(e=="variable"||C.style=="keyword")return C.marked="property",t=="get"||t=="set"?L(G):L(Y);if(e=="number"||e=="string")return C.marked=s?"property":C.style+" property",L(Y);if(e=="jsonld-keyword")return L(Y);if(e=="[")return L(j,H("]"),Y)}function G(e){return e!="variable"?k(Y):(C.marked="property",L(vt))}function Y(e){if(e==":")return L(F);if(e=="(")return k(vt)}function Z(e,t){function n(r){if(r==","){var i=C.state.lexical;return i.info=="call"&&(i.pos=(i.pos||0)+1),L(e,n)}return r==t?L():L(H(t))}return function(r){return r==t?L():k(e,n)}}function et(e,t,n){for(var r=3;r<arguments.length;r++)C.cc.push(arguments[r]);return L(D(t,n),Z(e,t),P)}function tt(e){return e=="}"?L():k(B,tt)}function nt(e){if(u&&e==":")return L(rt)}function rt(e){if(e=="variable")return C.marked="variable-3",L()}function it(){return k(st,nt,ut,at)}function st(e,t){if(e=="variable")return A(t),L();if(e=="[")return et(st,"]");if(e=="{")return et(ot,"}")}function ot(e,t){return e=="variable"&&!C.stream.match(/^\s*:/,!1)?(A(t),L(ut)):(e=="variable"&&(C.marked="property"),L(H(":"),st,ut))}function ut(e,t){if(t=="=")return L(F)}function at(e){if(e==",")return L(it)}function ft(e,t){if(e=="keyword b"&&t=="else")return L(D("form","else"),B,P)}function lt(e){if(e=="(")return L(D(")"),ct,H(")"),P)}function ct(e){return e=="var"?L(it,H(";"),pt):e==";"?L(pt):e=="variable"?L(ht):k(j,H(";"),pt)}function ht(e,t){return t=="in"||t=="of"?(C.marked="keyword",L(j)):L(U,pt)}function pt(e,t){return e==";"?L(dt):t=="in"||t=="of"?(C.marked="keyword",L(j)):k(j,H(";"),dt)}function dt(e){e!=")"&&L(j)}function vt(e,t){if(t=="*")return C.marked="keyword",L(vt);if(e=="variable")return A(t),L(vt);if(e=="(")return L(M,D(")"),Z(mt,")"),P,B,_)}function mt(e){return e=="spread"?L(mt):k(st,nt)}function gt(e,t){if(e=="variable")return A(t),L(yt)}function yt(e,t){if(t=="extends")return L(j,yt);if(e=="{")return L(D("}"),bt,P)}function bt(e,t){if(e=="variable"||C.style=="keyword")return C.marked="property",t=="get"||t=="set"?L(wt,vt,bt):L(vt,bt);if(t=="*")return C.marked="keyword",L(bt);if(e==";")return L(bt);if(e=="}")return L()}function wt(e){return e!="variable"?k():(C.marked="property",L())}function Et(e,t){if(e=="string")return L(B);if(e=="variable")return A(t),L(Nt)}function St(e,t){return t=="*"?(C.marked="keyword",L(Nt,H(";"))):t=="default"?(C.marked="keyword",L(j,H(";"))):k(B)}function xt(e){return e=="string"?L():k(Tt,Nt)}function Tt(e,t){return e=="{"?et(Tt,"}"):(e=="variable"&&A(t),L())}function Nt(e,t){if(t=="from")return C.marked="keyword",L(j)}function Ct(e){return e=="]"?L():k(F,kt)}function kt(e){return e=="for"?k(Lt,H("]")):e==","?L(Z(R,"]")):k(Z(F,"]"))}function Lt(e){if(e=="for")return L(lt,Lt);if(e=="if")return L(j,Lt)}var r=t.indentUnit,i=n.statementIndent,s=n.jsonld,o=n.json||s,u=n.typescript,a=n.wordCharacters||/[\w$\xa1-\uffff]/,f=function(){function e(e){return{type:e,style:"keyword"}}var t=e("keyword a"),n=e("keyword b"),r=e("keyword c"),i=e("operator"),s={type:"atom",style:"atom"},o={"if":e("if"),"while":t,"with":t,"else":n,"do":n,"try":n,"finally":n,"return":r,"break":r,"continue":r,"new":r,"delete":r,"throw":r,"debugger":r,"var":e("var"),"const":e("var"),let:e("var"),"function":e("function"),"catch":e("catch"),"for":e("for"),"switch":e("switch"),"case":e("case"),"default":e("default"),"in":i,"typeof":i,"instanceof":i,"true":s,"false":s,"null":s,"undefined":s,NaN:s,Infinity:s,"this":e("this"),module:e("module"),"class":e("class"),"super":e("atom"),yield:r,"export":e("export"),"import":e("import"),"extends":r};if(u){var a={type:"variable",style:"variable-3"},f={"interface":e("interface"),"extends":e("extends"),constructor:e("constructor"),"public":e("public"),"private":e("private"),"protected":e("protected"),"static":e("static"),string:a,number:a,bool:a,any:a};for(var l in f)o[l]=f[l]}return o}(),l=/[+\-*&%=<>!?|~^]/,c=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,p,d,w="([{}])",S={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},C={state:null,column:null,marked:null,cc:null},O={name:"this",next:{name:"arguments"}};return P.lex=!0,{startState:function(e){var t={tokenize:m,lastType:"sof",cc:[],lexical:new x((e||0)-r,0,"block",!1),localVars:n.localVars,context:n.localVars&&{vars:n.localVars},indented:0};return n.globalVars&&typeof n.globalVars=="object"&&(t.globalVars=n.globalVars),t},token:function(e,t){e.sol()&&(t.lexical.hasOwnProperty("align")||(t.lexical.align=!1),t.indented=e.indentation(),E(e,t));if(t.tokenize!=y&&e.eatSpace())return null;var n=t.tokenize(e,t);return p=="comment"?n:(t.lastType=p!="operator"||d!="++"&&d!="--"?p:"incdec",N(t,n,p,d,e))},indent:function(t,s){if(t.tokenize==y)return e.Pass;if(t.tokenize!=m)return 0;var o=s&&s.charAt(0),u=t.lexical;if(!/^\s*else\b/.test(s))for(var a=t.cc.length-1;a>=0;--a){var f=t.cc[a];if(f==P)u=u.prev;else if(f!=ft)break}u.type=="stat"&&o=="}"&&(u=u.prev),i&&u.type==")"&&u.prev.type=="stat"&&(u=u.prev);var l=u.type,c=o==l;return l=="vardef"?u.indented+(t.lastType=="operator"||t.lastType==","?u.info+1:0):l=="form"&&o=="{"?u.indented:l=="form"?u.indented+r:l=="stat"?u.indented+(t.lastType=="operator"||t.lastType==","?i||r:0):u.info=="switch"&&!c&&n.doubleIndentSwitch!=0?u.indented+(/^(?:case|default)\b/.test(s)?r:2*r):u.align?u.column+(c?0:1):u.indented+(c?0:r)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:o?null:"/*",blockCommentEnd:o?null:"*/",lineComment:o?null:"//",fold:"brace",helperType:o?"json":"javascript",jsonldMode:s,jsonMode:o}}),e.registerHelper("wordChars","javascript",/[\w$]/),e.defineMIME("text/javascript","javascript"),e.defineMIME("text/ecmascript","javascript"),e.defineMIME("application/javascript","javascript"),e.defineMIME("application/x-javascript","javascript"),e.defineMIME("application/ecmascript","javascript"),e.defineMIME("application/json",{name:"javascript",json:!0}),e.defineMIME("application/x-json",{name:"javascript",json:!0}),e.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),e.defineMIME("text/typescript",{name:"javascript",typescript:!0}),e.defineMIME("application/typescript",{name:"javascript",typescript:!0})}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/hint/xml-hint",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function n(n,r){var i=r&&r.schemaInfo,s=r&&r.quoteChar||'"';if(!i)return;var o=n.getCursor(),u=n.getTokenAt(o);if(/^<\/?$/.test(u.string)&&u.end==o.ch){var a=n.getTokenAt(t(o.line,o.ch+1));a.start==o.ch&&/\btag\b/.test(a.type)&&(u=a)}var f=e.innerMode(n.getMode(),u.state);if(f.mode.name!="xml")return;var l=[],c=!1,h,p=/\btag\b/.test(u.type)&&!/>$/.test(u.string),d=p&&/^\w/.test(u.string),v;if(d){var m=n.getLine(o.line).slice(Math.max(0,u.start-2),u.start),g=/<\/$/.test(m)?"close":/<$/.test(m)?"open":null;g&&(v=u.start-(g=="close"?2:1))}else p&&u.string=="<"?g="open":p&&u.string=="</"&&(g="close");if(!p&&!f.state.tagName||g){d&&(h=u.string),c=g;var y=f.state.context,b=y&&i[y.tagName],w=y?b&&b.children:i["!top"];if(w&&g!="close")for(var E=0;E<w.length;++E)(!h||w[E].lastIndexOf(h,0)==0)&&l.push("<"+w[E]);else if(g!="close")for(var S in i)i.hasOwnProperty(S)&&S!="!top"&&S!="!attrs"&&(!h||S.lastIndexOf(h,0)==0)&&l.push("<"+S);y&&(!h||g=="close"&&y.tagName.lastIndexOf(h,0)==0)&&l.push("</"+y.tagName+">")}else{var b=i[f.state.tagName],x=b&&b.attrs,T=i["!attrs"];if(!x&&!T)return;if(!x)x=T;else if(T){var N={};for(var C in T)T.hasOwnProperty(C)&&(N[C]=T[C]);for(var C in x)x.hasOwnProperty(C)&&(N[C]=x[C]);x=N}if(u.type=="string"||u.string=="="){var m=n.getRange(t(o.line,Math.max(0,o.ch-60)),t(o.line,u.type=="string"?u.start:u.end)),k=m.match(/([^\s\u00a0=<>\"\']+)=$/),L;if(!k||!x.hasOwnProperty(k[1])||!(L=x[k[1]]))return;typeof L=="function"&&(L=L.call(this,n));if(u.type=="string"){h=u.string;var A=0;/['"]/.test(u.string.charAt(0))&&(s=u.string.charAt(0),h=u.string.slice(1),A++);var O=u.string.length;/['"]/.test(u.string.charAt(O-1))&&(s=u.string.charAt(O-1),h=u.string.substr(A,O-2)),c=!0}for(var E=0;E<L.length;++E)(!h||L[E].lastIndexOf(h,0)==0)&&l.push(s+L[E]+s)}else{u.type=="attribute"&&(h=u.string,c=!0);for(var M in x)x.hasOwnProperty(M)&&(!h||M.lastIndexOf(h,0)==0)&&l.push(M)}}return{list:l,from:c?t(o.line,v==null?u.start:v):o,to:c?t(o.line,u.end):o}}var t=e.Pos;e.registerHelper("hint","xml",n)}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror","./xml-hint")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/hint/html-hint",["../../lib/codemirror","./xml-hint"],e):e(CodeMirror)}(function(e){function l(e){for(var t in f)f.hasOwnProperty(t)&&(e.attrs[t]=f[t])}function h(t,n){var r={schemaInfo:a};if(n)for(var i in n)r[i]=n[i];return e.hint.xml(t,r)}var t="ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" "),n=["_blank","_self","_top","_parent"],r=["ascii","utf-8","utf-16","latin1","latin1"],i=["get","post","put","delete"],s=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],o=["all","screen","print","embossed","braille","handheld","print","projection","screen","tty","tv","speech","3d-glasses","resolution [>][<][=] [X]","device-aspect-ratio: X/Y","orientation:portrait","orientation:landscape","device-height: [X]","device-width: [X]"],u={attrs:{}},a={a:{attrs:{href:null,ping:null,type:null,media:o,target:n,hreflang:t}},abbr:u,acronym:u,address:u,applet:u,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:o,hreflang:t,type:null,shape:["default","rect","circle","poly"]}},article:u,aside:u,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["","autoplay"],loop:["","loop"],controls:["","controls"]}},b:u,base:{attrs:{href:null,target:n}},basefont:u,bdi:u,bdo:u,big:u,blockquote:{attrs:{cite:null}},body:u,br:u,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["","autofocus"],disabled:["","autofocus"],formenctype:s,formmethod:i,formnovalidate:["","novalidate"],formtarget:n,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:u,center:u,cite:u,code:u,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["","disabled"],checked:["","checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["","disabled"],multiple:["","multiple"]}},datalist:{attrs:{data:null}},dd:u,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["","open"]}},dfn:u,dir:u,div:u,dl:u,dt:u,em:u,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["","disabled"],form:null,name:null}},figcaption:u,figure:u,font:u,footer:u,form:{attrs:{action:null,name:null,"accept-charset":r,autocomplete:["on","off"],enctype:s,method:i,novalidate:["","novalidate"],target:n}},frame:u,frameset:u,h1:u,h2:u,h3:u,h4:u,h5:u,h6:u,head:{attrs:{},children:["title","base","link","style","meta","script","noscript","command"]},header:u,hgroup:u,hr:u,html:{attrs:{manifest:null},children:["head","body"]},i:u,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["","seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["","autofocus"],checked:["","checked"],disabled:["","disabled"],formenctype:s,formmethod:i,formnovalidate:["","novalidate"],formtarget:n,multiple:["","multiple"],readonly:["","readonly"],required:["","required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:u,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["","autofocus"],disabled:["","disabled"],keytype:["RSA"]}},label:{attrs:{"for":null,form:null}},legend:u,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:t,media:o,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:u,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:r,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:u,noframes:u,noscript:u,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["","typemustmatch"]}},ol:{attrs:{reversed:["","reversed"],start:null,type:["1","a","A","i","I"]}},optgroup:{attrs:{disabled:["","disabled"],label:null}},option:{attrs:{disabled:["","disabled"],label:null,selected:["","selected"],value:null}},output:{attrs:{"for":null,form:null,name:null}},p:u,param:{attrs:{name:null,value:null}},pre:u,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:u,rt:u,ruby:u,s:u,samp:u,script:{attrs:{type:["text/javascript"],src:null,async:["","async"],defer:["","defer"],charset:r}},section:u,select:{attrs:{form:null,name:null,size:null,autofocus:["","autofocus"],disabled:["","disabled"],multiple:["","multiple"]}},small:u,source:{attrs:{src:null,type:null,media:null}},span:u,strike:u,strong:u,style:{attrs:{type:["text/css"],media:o,scoped:null}},sub:u,summary:u,sup:u,table:u,tbody:u,td:{attrs:{colspan:null,rowspan:null,headers:null}},textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["","autofocus"],disabled:["","disabled"],readonly:["","readonly"],required:["","required"],wrap:["soft","hard"]}},tfoot:u,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:u,time:{attrs:{datetime:null}},title:u,tr:u,track:{attrs:{src:null,label:null,"default":null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:t}},tt:u,u:u,ul:u,"var":u,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["","autoplay"],mediagroup:["movie"],muted:["","muted"],controls:["","controls"]}},wbr:u},f={accesskey:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"],"class":null,contenteditable:["true","false"],contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["en","es"],spellcheck:["true","false"],style:null,tabindex:["1","2","3","4","5","6","7","8","9"],title:null,translate:["yes","no"],onclick:null,rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"]};l(u);for(var c in a)a.hasOwnProperty(c)&&a[c]!=u&&l(a[c]);e.htmlSchema=a,e.registerHelper("hint","html",h)}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/hint/show-hint",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function r(e,t){this.cm=e,this.options=this.buildOptions(t),this.widget=this.onClose=null}function i(e){return typeof e=="string"?e:e.text}function s(e,t){function s(e,r){var s;typeof r!="string"?s=function(e){return r(e,t)}:n.hasOwnProperty(r)?s=n[r]:s=r,i[e]=s}var n={Up:function(){t.moveFocus(-1)},Down:function(){t.moveFocus(1)},PageUp:function(){t.moveFocus(-t.menuSize()+1,!0)},PageDown:function(){t.moveFocus(t.menuSize()-1,!0)},Home:function(){t.setFocus(0)},End:function(){t.setFocus(t.length-1)},Enter:t.pick,Tab:t.pick,Esc:t.close},r=e.options.customKeys,i=r?{}:n;if(r)for(var o in r)r.hasOwnProperty(o)&&s(o,r[o]);var u=e.options.extraKeys;if(u)for(var o in u)u.hasOwnProperty(o)&&s(o,u[o]);return i}function o(e,t){while(t&&t!=e){if(t.nodeName.toUpperCase()==="LI"&&t.parentNode==e)return t;t=t.parentNode}}function u(r,u){this.completion=r,this.data=u;var a=this,f=r.cm,l=this.hints=document.createElement("ul");l.className="CodeMirror-hints",this.selectedHint=u.selectedHint||0;var c=u.list;for(var h=0;h<c.length;++h){var p=l.appendChild(document.createElement("li")),d=c[h],v=t+(h!=this.selectedHint?"":" "+n);d.className!=null&&(v=d.className+" "+v),p.className=v,d.render?d.render(p,u,d):p.appendChild(document.createTextNode(d.displayText||i(d))),p.hintId=h}var m=f.cursorCoords(r.options.alignWithWord?u.from:null),g=m.left,y=m.bottom,b=!0;l.style.left=g+"px",l.style.top=y+"px";var w=window.innerWidth||Math.max(document.body.offsetWidth,document.documentElement.offsetWidth),E=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(r.options.container||document.body).appendChild(l);var S=l.getBoundingClientRect(),x=S.bottom-E;if(x>0){var T=S.bottom-S.top,N=m.top-(m.bottom-S.top);if(N-T>0)l.style.top=(y=m.top-T)+"px",b=!1;else if(T>E){l.style.height=E-5+"px",l.style.top=(y=m.bottom-S.top)+"px";var C=f.getCursor();u.from.ch!=C.ch&&(m=f.cursorCoords(C),l.style.left=(g=m.left)+"px",S=l.getBoundingClientRect())}}var k=S.left-w;k>0&&(S.right-S.left>w&&(l.style.width=w-5+"px",k-=S.right-S.left-w),l.style.left=(g=m.left-k)+"px"),f.addKeyMap(this.keyMap=s(r,{moveFocus:function(e,t){a.changeActive(a.selectedHint+e,t)},setFocus:function(e){a.changeActive(e)},menuSize:function(){return a.screenAmount()},length:c.length,close:function(){r.close()},pick:function(){a.pick()},data:u}));if(r.options.closeOnUnfocus){var L;f.on("blur",this.onBlur=function(){L=setTimeout(function(){r.close()},100)}),f.on("focus",this.onFocus=function(){clearTimeout(L)})}var A=f.getScrollInfo();return f.on("scroll",this.onScroll=function(){var e=f.getScrollInfo(),t=f.getWrapperElement().getBoundingClientRect(),n=y+A.top-e.top,i=n-(window.pageYOffset||(document.documentElement||document.body).scrollTop);b||(i+=l.offsetHeight);if(i<=t.top||i>=t.bottom)return r.close();l.style.top=n+"px",l.style.left=g+A.left-e.left+"px"}),e.on(l,"dblclick",function(e){var t=o(l,e.target||e.srcElement);t&&t.hintId!=null&&(a.changeActive(t.hintId),a.pick())}),e.on(l,"click",function(e){var t=o(l,e.target||e.srcElement);t&&t.hintId!=null&&(a.changeActive(t.hintId),r.options.completeOnSingleClick&&a.pick())}),e.on(l,"mousedown",function(){setTimeout(function(){f.focus()},20)}),e.signal(u,"select",c[0],l.firstChild),!0}var t="CodeMirror-hint",n="CodeMirror-hint-active";e.showHint=function(e,t,n){if(!t)return e.showHint(n);n&&n.async&&(t.async=!0);var r={hint:t};if(n)for(var i in n)r[i]=n[i];return e.showHint(r)},e.defineExtension("showHint",function(t){if(this.listSelections().length>1||this.somethingSelected())return;this.state.completionActive&&this.state.completionActive.close();var n=this.state.completionActive=new r(this,t),i=n.options.hint;if(!i)return;e.signal(this,"startCompletion",this);if(!i.async)return n.showHints(i(this,n.options));i(this,function(e){n.showHints(e)},n.options)}),r.prototype={close:function(){if(!this.active())return;this.cm.state.completionActive=null,this.widget&&this.widget.close(),this.onClose&&this.onClose(),e.signal(this.cm,"endCompletion",this.cm)},active:function(){return this.cm.state.completionActive==this},pick:function(t,n){var r=t.list[n];r.hint?r.hint(this.cm,t,r):this.cm.replaceRange(i(r),r.from||t.from,r.to||t.to,"complete"),e.signal(t,"pick",r),this.close()},showHints:function(e){if(!e||!e.list.length||!this.active())return this.close();this.options.completeSingle&&e.list.length==1?this.pick(e,0):this.showWidget(e)},showWidget:function(t){function c(){if(i)return;i=!0,r.close(),r.cm.off("cursorActivity",v),t&&e.signal(t,"close")}function h(){if(i)return;e.signal(t,"update");var n=r.options.hint;n.async?n(r.cm,p,r.options):p(n(r.cm,r.options))}function p(e){t=e;if(i)return;if(!t||!t.list.length)return c();r.widget&&r.widget.close(),r.widget=new u(r,t)}function d(){n&&(l(n),n=0)}function v(){d();var e=r.cm.getCursor(),t=r.cm.getLine(e.line);e.line!=o.line||t.length-e.ch!=a-o.ch||e.ch<o.ch||r.cm.somethingSelected()||e.ch&&s.test(t.charAt(e.ch-1))?r.close():(n=f(h),r.widget&&r.widget.close())}this.widget=new u(this,t),e.signal(t,"shown");var n=0,r=this,i,s=this.options.closeCharacters,o=this.cm.getCursor(),a=this.cm.getLine(o.line).length,f=window.requestAnimationFrame||function(e){return setTimeout(e,1e3/60)},l=window.cancelAnimationFrame||clearTimeout;this.cm.on("cursorActivity",v),this.onClose=c},buildOptions:function(e){var t=this.cm.options.hintOptions,n={};for(var r in a)n[r]=a[r];if(t)for(var r in t)t[r]!==undefined&&(n[r]=t[r]);if(e)for(var r in e)e[r]!==undefined&&(n[r]=e[r]);return n}},u.prototype={close:function(){if(this.completion.widget!=this)return;this.completion.widget=null,this.hints.parentNode.removeChild(this.hints),this.completion.cm.removeKeyMap(this.keyMap);var e=this.completion.cm;this.completion.options.closeOnUnfocus&&(e.off("blur",this.onBlur),e.off("focus",this.onFocus)),e.off("scroll",this.onScroll)},pick:function(){this.completion.pick(this.data,this.selectedHint)},changeActive:function(t,r){t>=this.data.list.length?t=r?this.data.list.length-1:0:t<0&&(t=r?0:this.data.list.length-1);if(this.selectedHint==t)return;var i=this.hints.childNodes[this.selectedHint];i.className=i.className.replace(" "+n,""),i=this.hints.childNodes[this.selectedHint=t],i.className+=" "+n,i.offsetTop<this.hints.scrollTop?this.hints.scrollTop=i.offsetTop-3:i.offsetTop+i.offsetHeight>this.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=i.offsetTop+i.offsetHeight-this.hints.clientHeight+3),e.signal(this.data,"select",this.data.list[this.selectedHint],i)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},e.registerHelper("hint","auto",function(t,n){var r=t.getHelpers(t.getCursor(),"hint"),i;if(r.length)for(var s=0;s<r.length;s++){var o=r[s](t,n);if(o&&o.list.length)return o}else if(i=t.getHelper(t.getCursor(),"hintWords")){if(i)return e.hint.fromList(t,{words:i})}else if(e.hint.anyword)return e.hint.anyword(t,n)}),e.registerHelper("hint","fromList",function(t,n){var r=t.getCursor(),i=t.getTokenAt(r),s=[];for(var o=0;o<n.words.length;o++){var u=n.words[o];u.slice(0,i.string.length)==i.string&&s.push(u)}if(s.length)return{list:s,from:e.Pos(r.line,i.start),to:e.Pos(r.line,i.end)}}),e.commands.autocomplete=e.showHint;var a={hint:e.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:!0,completeOnSingleClick:!1,container:null,customKeys:null,extraKeys:null};e.defineOption("hintOptions",null)}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/mode/xml/xml",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineMode("xml",function(t,n){function l(e,t){function n(n){return t.tokenize=n,n(e,t)}var r=e.next();if(r=="<")return e.eat("!")?e.eat("[")?e.match("CDATA[")?n(p("atom","]]>")):null:e.match("--")?n(p("comment","-->")):e.match("DOCTYPE",!0,!0)?(e.eatWhile(/[\w\._\-]/),n(d(1))):null:e.eat("?")?(e.eatWhile(/[\w\._\-]/),t.tokenize=p("meta","?>"),"meta"):(a=e.eat("/")?"closeTag":"openTag",t.tokenize=c,"tag bracket");if(r=="&"){var i;return e.eat("#")?e.eat("x")?i=e.eatWhile(/[a-fA-F\d]/)&&e.eat(";"):i=e.eatWhile(/[\d]/)&&e.eat(";"):i=e.eatWhile(/[\w\.\-:]/)&&e.eat(";"),i?"atom":"error"}return e.eatWhile(/[^&<]/),null}function c(e,t){var n=e.next();if(n==">"||n=="/"&&e.eat(">"))return t.tokenize=l,a=n==">"?"endTag":"selfcloseTag","tag bracket";if(n=="=")return a="equals",null;if(n=="<"){t.tokenize=l,t.state=y,t.tagName=t.tagStart=null;var r=t.tokenize(e,t);return r?r+" tag error":"tag error"}return/[\'\"]/.test(n)?(t.tokenize=h(n),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function h(e){var t=function(t,n){while(!t.eol())if(t.next()==e){n.tokenize=c;break}return"string"};return t.isInAttribute=!0,t}function p(e,t){return function(n,r){while(!n.eol()){if(n.match(t)){r.tokenize=l;break}n.next()}return e}}function d(e){return function(t,n){var r;while((r=t.next())!=null){if(r=="<")return n.tokenize=d(e+1),n.tokenize(t,n);if(r==">"){if(e==1){n.tokenize=l;break}return n.tokenize=d(e-1),n.tokenize(t,n)}}return"meta"}}function v(e,t,n){this.prev=e.context,this.tagName=t,this.indent=e.indented,this.startOfLine=n;if(o.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)this.noIndent=!0}function m(e){e.context&&(e.context=e.context.prev)}function g(e,t){var n;for(;;){if(!e.context)return;n=e.context.tagName;if(!o.contextGrabbers.hasOwnProperty(n)||!o.contextGrabbers[n].hasOwnProperty(t))return;m(e)}}function y(e,t,n){return e=="openTag"?(n.tagStart=t.column(),b):e=="closeTag"?w:y}function b(e,t,n){return e=="word"?(n.tagName=t.current(),f="tag",x):(f="error",b)}function w(e,t,n){if(e=="word"){var r=t.current();return n.context&&n.context.tagName!=r&&o.implicitlyClosed.hasOwnProperty(n.context.tagName)&&m(n),n.context&&n.context.tagName==r?(f="tag",E):(f="tag error",S)}return f="error",S}function E(e,t,n){return e!="endTag"?(f="error",E):(m(n),y)}function S(e,t,n){return f="error",E(e,t,n)}function x(e,t,n){if(e=="word")return f="attribute",T;if(e=="endTag"||e=="selfcloseTag"){var r=n.tagName,i=n.tagStart;return n.tagName=n.tagStart=null,e=="selfcloseTag"||o.autoSelfClosers.hasOwnProperty(r)?g(n,r):(g(n,r),n.context=new v(n,r,i==n.indented)),y}return f="error",x}function T(e,t,n){return e=="equals"?N:(o.allowMissing||(f="error"),x(e,t,n))}function N(e,t,n){return e=="string"?C:e=="word"&&o.allowUnquoted?(f="string",x):(f="error",x(e,t,n))}function C(e,t,n){return e=="string"?C:x(e,t,n)}var r=t.indentUnit,i=n.multilineTagIndentFactor||1,s=n.multilineTagIndentPastTag;s==null&&(s=!0);var o=n.htmlMode?{autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1},u=n.alignCDATA,a,f;return{startState:function(){return{tokenize:l,state:y,indented:0,tagName:null,tagStart:null,context:null}},token:function(e,t){!t.tagName&&e.sol()&&(t.indented=e.indentation());if(e.eatSpace())return null;a=null;var n=t.tokenize(e,t);return(n||a)&&n!="comment"&&(f=null,t.state=t.state(a||n,e,t),f&&(n=f=="error"?n+" error":f)),n},indent:function(t,n,a){var f=t.context;if(t.tokenize.isInAttribute)return t.tagStart==t.indented?t.stringStartCol+1:t.indented+r;if(f&&f.noIndent)return e.Pass;if(t.tokenize!=c&&t.tokenize!=l)return a?a.match(/^(\s*)/)[0].length:0;if(t.tagName)return s?t.tagStart+t.tagName.length+2:t.tagStart+r*i;if(u&&/<!\[CDATA\[/.test(n))return 0;var h=n&&/^<(\/)?([\w_:\.-]*)/.exec(n);if(h&&h[1])while(f){if(f.tagName==h[2]){f=f.prev;break}if(!o.implicitlyClosed.hasOwnProperty(f.tagName))break;f=f.prev}else if(h)while(f){var p=o.contextGrabbers[f.tagName];if(!p||!p.hasOwnProperty(h[2]))break;f=f.prev}while(f&&!f.startOfLine)f=f.prev;return f?f.indent+r:0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:n.htmlMode?"html":"xml",helperType:n.htmlMode?"html":"xml"}}),e.defineMIME("text/xml","xml"),e.defineMIME("application/xml","xml"),e.mimeModes.hasOwnProperty("text/html")||e.defineMIME("text/html",{name:"xml",htmlMode:!0})}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/runmode/runmode",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.runMode=function(t,n,r,i){var s=e.getMode(e.defaults,n),o=/MSIE \d/.test(navigator.userAgent),u=o&&(document.documentMode==null||document.documentMode<9);if(r.nodeType==1){var a=i&&i.tabSize||e.defaults.tabSize,f=r,l=0;f.innerHTML="",r=function(e,t){if(e=="\n"){f.appendChild(document.createTextNode(u?"\r":e)),l=0;return}var n="";for(var r=0;;){var i=e.indexOf("	",r);if(i==-1){n+=e.slice(r),l+=e.length-r;break}l+=i-r,n+=e.slice(r,i);var s=a-l%a;l+=s;for(var o=0;o<s;++o)n+=" ";r=i+1}if(t){var c=f.appendChild(document.createElement("span"));c.className="cm-"+t.replace(/ +/g," cm-"),c.appendChild(document.createTextNode(n))}else f.appendChild(document.createTextNode(n))}}var c=e.splitLines(t),h=i&&i.state||e.startState(s);for(var p=0,d=c.length;p<d;++p){p&&r("\n");var v=new e.StringStream(c[p]);!v.string&&s.blankLine&&s.blankLine(h);while(!v.eol()){var m=s.token(v,h);r(v.current(),m,p,v.start,h),v.start=v.pos}}}}),define("CodeMirrorEditor",["react","lodash","jquery","./libs/codemirror-4.8/lib/codemirror","./CMLint","./libs/codemirror-4.8/mode/javascript/javascript","./libs/codemirror-4.8/addon/hint/html-hint","./libs/codemirror-4.8/addon/hint/show-hint","./libs/codemirror-4.8/addon/hint/xml-hint","./libs/codemirror-4.8/addon/hint/html-hint","./libs/codemirror-4.8/mode/xml/xml","./libs/codemirror-4.8/addon/runmode/runmode"],function(e,t,n,r,i){function u(e,t){return(!t||t())&&setTimeout(function(){e.state.completionActive||e.showHint({completeSingle:!1})},100),r.Pass}function a(e){return u(e,function(){var t=e.getCursor();return e.getRange(r.Pos(t.line,t.ch-1),t)==="<"})}function f(e){return u(e,function(){var t=e.getTokenAt(e.getCursor());if(t.type!=="string"||!!/['"]/.test(t.string.charAt(t.string.length-1))&&t.string.length!==1){var n=r.innerMode(e.getMode(),t.state).state;return n.tagName}return!1})}var s={div:{attrs:{"rt-props":null,"rt-if":null,"rt-repeat":null,"rt-class":null,"rt-scope":null,valueLink:null,key:null,ref:null,dangerouslySetInnerHTML:null}}},o=r.htmlSchema;return Object.keys(r.htmlSchema).forEach(function(e){o[e].attrs=t.defaults(s.div.attrs,o[e].attrs)}),e.createClass({displayName:"CodeMirrorEditor",propTypes:{id:e.PropTypes.string,readOnly:e.PropTypes.bool,runMode:e.PropTypes.bool,mode:e.PropTypes.string,value:e.PropTypes.string,valueLink:e.PropTypes.string,onChange:e.PropTypes.func},getDefaultProps:function(){return{readOnly:!1,mode:"html"}},getInitialState:function(){return{editorId:t.uniqueId()}},render:function(){var n=t.omit(this.props,["ref","key","value","valueLink","onChange"]);return n.id=this.props.id||this.state.editorId,n.defaultValue=this.props.valueLink?this.props.valueLink():this.props.value,e.DOM.textarea(n)},componentWillUpdate:function(e){var t=e.valueLink?e.valueLink():e.value;this.editor&&this.editor.getValue()!==t&&this.editor.setValue(t||"")},componentDidMount:function(){var e=this.props.valueLink?this.props.valueLink():this.props.value,t={readOnly:this.props.readOnly,lineWrapping:!0,smartIndent:!0,matchBrackets:!0,value:e,lineNumbers:!0,mode:"javascript",gutters:["CodeMirror-linenumbers","rt-annotations"],theme:"solarized"};this.props.mode==="html"?(t.mode="text/html",t.extraKeys={"'<'":u,"'/'":a,"' '":f,"'='":f,"Ctrl-Space":"autocomplete"},t.hintOptions={schemaInfo:o}):t.mode="javascript",this.editor=r.fromTextArea(this.getDOMNode(),t),this.props.readOnly||this.editor.on("change",function(){this.props.valueLink?this.props.valueLink(this.editor.getValue()):this.props.onChange&&this.props.onChange({target:{value:this.editor.getValue()}})}.bind(this))},annotate:function(e){i.annotate(this.editor,e)},clearAnnotations:function(){i.clearMarks(this.editor)},componentWillUnmount:function(){this.editor.toTextArea()}})}),define("playground-fiddle.rt",["react/addons","lodash","./CodeMirrorEditor"],function(e,t,n){function r(e){this.setState({templateHTML:e.target.value})}function i(e){this.setState({templateProps:e.target.value})}function s(e){e.preventDefault()}return function(){return e.createElement("div",{className:"playground"},e.createElement("div",{className:"fiddle-row"},e.createElement("div",{className:"code-area",id:"area-rt"},e.createElement(n,{ref:"editorRT",id:"editor-rt",className:"large-text-area",value:this.state.templateHTML,mode:"html",onChange:r.bind(this)})),e.createElement("div",{className:"code-area",id:"area-code"},e.createElement(n,{ref:"editorCode",id:"editor-code",className:"large-text-area",value:this.state.templateProps,mode:"javascript",onChange:i.bind(this)}))),e.createElement("div",{className:"fiddle-row"},e.createElement("div",{className:"code-area",id:"area-generated"},e.createElement(n,{id:"editor-generated",className:"large-text-area",ref:"editorGenerated",value:this.templateSource,mode:"javascript",readOnly:!0})),e.createElement("div",{className:"code-area",id:"area-result"},e.createElement("div",{id:"result-area",key:"result-area",className:"sample-view"},e.createElement("form",{className:"result-area-form",ref:"mount",onSubmit:s.bind(this)})))))}}),define("playground.rt",["react/addons","lodash","./CodeMirrorEditor"],function(e,t,n){function r(e,t,n){n.preventDefault(),this.setState({currentTab:e[0]})}function i(n,i){return e.createElement("li",{role:"presentation",key:"tab"+i,className:t.keys(t.pick({active:this.state.currentTab===n[0]},t.identity)).join(" "),onClick:r.bind(this,n,i)},e.createElement("a",{"aria-controls":n[1]},n[1]))}function s(e){this.setState({templateHTML:e.target.value})}function o(e){this.setState({templateProps:e.target.value})}function u(e){e.preventDefault()}return function(){return e.createElement("div",{className:"playground"},e.createElement("div",{id:this.props.id+"-myTab",className:"code-area "+this.getLayoutClass()},e.createElement.apply(this,["ul",{className:"nav nav-tabs",role:"tablist"},t.map(this.getTabs(),i.bind(this))]),e.createElement("div",{},this.state.currentTab==="templateHTML"?e.createElement("div",{key:"editorRT",className:"tab-pane active"},e.createElement(n,{ref:"editorRT",className:"large-text-area",style:{border:this.validHTML?"":"2px solid red"},value:this.state.templateHTML,mode:"html",onChange:s.bind(this)})):null,this.state.currentTab==="templateProps"?e.createElement("div",{key:"editorCode",className:"tab-pane active"},e.createElement(n,{ref:"editorCode",className:"large-text-area",style:{border:this.validProps?"":"2px solid red"},value:this.state.templateProps,mode:"javascript",onChange:o.bind(this)})):null,this.state.currentTab==="templateSource"?e.createElement("div",{key:"templateSource",className:"tab-pane active"},e.createElement(n,{className:"large-text-area",value:this.templateSource,mode:"javascript",readOnly:!0})):null)),e.createElement("div",{key:"result-area",className:"result-area "+this.getLayoutClass()},e.createElement("span",{className:"preview-title"}," "),e.createElement("form",{ref:"mount",className:"sample-view",onSubmit:u.bind(this)})),e.createElement("br",{style:{clear:"both"}}))}}),define("playground",["react","jquery","lodash","./playground-fiddle.rt","./playground.rt"],function(React,$,_,pgFiddleTemplate,playgroundTemplate){function showMessage(e,t){e&&e.showMessage&&e.annotate({line:1,message:t})}function clearMessage(e){e&&e.clearAnnotations&&e.clearAnnotations()}function generateRenderFunc(e){return function(){var t=null;try{t=e.apply(this)}catch(n){t=React.DOM.div.apply(this,[{style:{color:"red"}},"Exception:"+n.message])}return React.DOM.div.apply(this,_.flatten([{key:"result"},t]))}}var templateHTML="<div></div>",templateProps="var template = React.createClass({\n   render: templateRT\n});",Playground=React.createClass({displayName:"Playground",mixins:[React.addons.LinkedStateMixin],propTypes:{direction:React.PropTypes.oneOf(["horizontal","vertical"]),codeVisible:React.PropTypes.bool,fiddle:React.PropTypes.bool,templateHTML:React.PropTypes.string,templateProps:React.PropTypes.string,name:React.PropTypes.string},templateSource:"",validHTML:!0,validProps:!0,setTimeout:function(){clearTimeout(this.timeoutID),this.timeoutID=setTimeout.apply(null,arguments)},getDefaultProps:function(){return{direction:"horizontal",codeVisible:!0,fiddle:!1}},getLayoutClass:function(){return this.props.direction==="horizontal"&&"horizontal"||"vertical"},getTabs:function(){return this.props.codeVisible?[["templateHTML","Template"],["templateProps","Class"],["templateSource","Generated code"]]:[["templateHTML","Template"],["templateSource","Generated code"]]},updateSample:function(state){this.generateCode(state),this.validHTML=!0,this.sampleRender=generateRenderFunc(this.sampleFunc);var editor;try{this.validProps=!0,this.sample=eval("(function () {"+this.templateSource+"\n"+state.templateProps+"\n return React.createElement("+state.name+");})()"),clearMessage(this.refs.editorCode)}catch(e){this.validProps=!1,this.sample=null,editor=this.refs.editorCode,this.showError(e,editor)}},showError:function(e,t){var n=this.refs.mount.getDOMNode();this.setTimeout(function(){showMessage(t,e.message),React.render(React.createElement("div",{className:"playground-error"},e.toString()),n)},500)},showErrorAnnotation:function(e,t){var n=this.refs.mount.getDOMNode();this.setTimeout(function(){t.annotate(e),React.render(React.createElement("div",{className:"playground-error"},e.message),n)},500)},clear:function(){var e={templateHTML:templateHTML,templateProps:templateProps};this.setState(e)},generateCode:function(e){var t=e.templateHTML,n=this.refs.editorRT,r=window.reactTemplates.normalizeName(e.name)+"RT",i=null,s=null;try{i=window.reactTemplates.convertTemplateToReact(t.trim().replace(/\r/g,""),{modules:"none",name:r}),clearMessage(n)}catch(o){o.name==="RTCodeError"?s={line:o.line,message:o.message,index:o.index}:s={line:1,message:o.message},this.showErrorAnnotation(s,n),console.log(o)}this.templateSource=i},getInitialState:function(){var e={templateHTML:this.props.templateHTML||templateHTML,templateProps:this.props.templateProps||templateProps,name:this.props.name||"template",currentTab:"templateHTML"};return e},componentDidMount:function(){this.props.fiddle&&(window.addEventListener("resize",this.calcSize),this.calcSize()),this.updateSample(this.state),this.renderSample()},renderSample:function(){var e=this.refs.mount.getDOMNode();this.sample&&React.render(this.sample,e)},componentDidUpdate:function(){this.renderSample()},componentWillUnmount:function(){window.removeEventListener("resize",this.calcSize)},calcSize:function(){var e=$(window).height()-$("#header").height(),t=e/2-10;$(".code-area").each(function(){$(this).height(t)}),this.refs.editorCode.editor.refresh(),this.refs.editorRT.editor.refresh(),this.refs.editorGenerated.editor.refresh()},componentWillUpdate:function(e,t){(t.templateHTML!==this.state.templateHTML||t.templateProps!==this.state.templateProps)&&this.updateSample(t)},render:function(){this.generateCode(this.state);var e=this.props.fiddle?pgFiddleTemplate:playgroundTemplate;return e.apply(this)}});return Playground}),define("fiddle.rt",["react/addons","lodash","./playground"],function(e,t,n){function r(e){e.preventDefault(),this.save()}function i(e){e.preventDefault(),this.clear()}function s(e){e.preventDefault(),this.loadSample("rt-if")}function o(e){e.preventDefault(),this.loadSample("rt-repeat")}function u(e){e.preventDefault(),this.loadSample("rt-props")}function a(e){e.preventDefault(),this.loadSample("todo")}function f(e){e.preventDefault(),this.loadSample("weather")}return function(){return e.createElement("div",{className:"fiddle"},e.createElement("div",{id:"header"},e.createElement("div",{id:"header-title"},e.createElement("a",{href:"index.html",className:"title-link"},e.createElement("img",{className:"nav-logo",src:"https://wix.github.io/react-templates/img/logo-rt.svg",width:"56",height:"24"})),"\n            RT Playground\n        "),e.createElement("div",{id:"buttons-bar"},e.createElement("button",{type:"button",className:"btn btn-default",onClick:r.bind(this)},e.createElement("span",{className:"glyphicon glyphicon-star button-icon","aria-hidden":"true"}),"Save fiddle\n            "),e.createElement("button",{type:"button",className:"btn btn-default",onClick:i.bind(this)},e.createElement("span",{className:"glyphicon glyphicon-trash button-icon","aria-hidden":"true"}),"Clear\n            "),e.createElement("div",{className:"dropdown toolbar-dropdown"},e.createElement("button",{className:"btn btn-default dropdown-toggle",type:"button",id:"dropdownMenu1","data-toggle":"dropdown","aria-expanded":"true"},"\n                    Load Sample\n                    ",e.createElement("span",{className:"caret"})),e.createElement("ul",{className:"dropdown-menu",role:"menu","aria-labelledby":"dropdownMenu1"},e.createElement("li",{role:"presentation"},e.createElement("a",{role:"menuitem",tabIndex:"-1",href:"#",onClick:s.bind(this)},"rt-if")),e.createElement("li",{role:"presentation"},e.createElement("a",{role:"menuitem",tabIndex:"-1",href:"#",onClick:o.bind(this)},"rt-repeat")),e.createElement("li",{role:"presentation"},e.createElement("a",{role:"menuitem",tabIndex:"-1",href:"#",onClick:u.bind(this)},"rt-props")),e.createElement("li",{role:"presentation"},e.createElement("a",{role:"menuitem",tabIndex:"-1",href:"#",onClick:a.bind(this)},"Todo")),e.createElement("li",{role:"presentation"},e.createElement("a",{role:"menuitem",tabIndex:"-1",href:"#",onClick:f.bind(this)},"Weather"))))),e.createElement("ul",{className:"nav-site"},e.createElement("li",{},e.createElement("a",{href:"index.html"},"HOME")),e.createElement("li",{},e.createElement("a",{href:"https://github.com/wix/react-templates#template-directives-and-syntax"},"docs")),e.createElement("li",{},e.createElement("a",{href:"https://github.com/wix/react-templates#installation"},"download")),e.createElement("li",{},e.createElement("a",{href:"https://github.com/wix/react-templates"},"github")))),e.createElement("div",{className:"playground-container"},e.createElement(n,{ref:"playground",direction:"vertical",fiddle:!0})))}}),define("fiddle",["react","firebase","lodash","./fiddle.rt","jquery"],function(e,t,n,r,i){function s(){var e="xxxxxxxx".replace(/[xy]/g,function(e){var t=n.random(0,15);return(e==="x"?t:t&3|8).toString(16)});return e}var o=e.createClass({displayName:"Fiddle",componentDidMount:function(){if(window.location.hash){var e=window.location.hash.replace("#",""),n=new t("https://reacttemplates.firebaseio-demo.com/");n.child("fiddles").child(e).on("value",function(e){this.refs.playground.setState(e.val()),t.goOffline()}.bind(this))}else t.goOffline()},save:function(){var e=s();window.location.hash=e,t.goOnline();var n=this.refs.playground.state,r=new t("https://reacttemplates.firebaseio-demo.com/");r.child("fiddles").child(e).set(n,function(){t.goOffline(),alert("saved the fiddle, you can share your url")})},clear:function(){this.refs.playground.clear()},loadSample:function(e){var t=this.refs.playground;i.get("playground/samples/"+e+".rt",null,function(r){var s=r;i.get("playground/samples/"+e+".code",null,function(e){var r={templateHTML:s,templateProps:n.template(e,{name:"template"})};t.setState(r)})})},render:r});return o});if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(e){var t=e.fn.jquery.split(" ")[0].split(".");if(t[0]<2&&t[1]<9||1==t[0]&&9==t[1]&&t[2]<1)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher")}(jQuery),+function(e){function t(t){t&&3===t.which||(e(i).remove(),e(s).each(function(){var r=e(this),i=n(r),s={relatedTarget:this};i.hasClass("open")&&(i.trigger(t=e.Event("hide.bs.dropdown",s)),t.isDefaultPrevented()||(r.attr("aria-expanded","false"),i.removeClass("open").trigger("hidden.bs.dropdown",s)))}))}function n(t){var n=t.attr("data-target");n||(n=t.attr("href"),n=n&&/#[A-Za-z]/.test(n)&&n.replace(/.*(?=#[^\s]*$)/,""));var r=n&&e(n);return r&&r.length?r:t.parent()}function r(t){return this.each(function(){var n=e(this),r=n.data("bs.dropdown");r||n.data("bs.dropdown",r=new o(this)),"string"==typeof t&&r[t].call(n)})}var i=".dropdown-backdrop",s='[data-toggle="dropdown"]',o=function(t){e(t).on("click.bs.dropdown",this.toggle)};o.VERSION="3.3.1",o.prototype.toggle=function(r){var i=e(this);if(!i.is(".disabled, :disabled")){var s=n(i),o=s.hasClass("open");if(t(),!o){"ontouchstart"in document.documentElement&&!s.closest(".navbar-nav").length&&e('<div class="dropdown-backdrop"/>').insertAfter(e(this)).on("click",t);var u={relatedTarget:this};if(s.trigger(r=e.Event("show.bs.dropdown",u)),r.isDefaultPrevented())return;i.trigger("focus").attr("aria-expanded","true"),s.toggleClass("open").trigger("shown.bs.dropdown",u)}return!1}},o.prototype.keydown=function(t){if(/(38|40|27|32)/.test(t.which)&&!/input|textarea/i.test(t.target.tagName)){var r=e(this);if(t.preventDefault(),t.stopPropagation(),!r.is(".disabled, :disabled")){var i=n(r),o=i.hasClass("open");if(!o&&27!=t.which||o&&27==t.which)return 27==t.which&&i.find(s).trigger("focus"),r.trigger("click");var u=" li:not(.divider):visible a",f=i.find('[role="menu"]'+u+', [role="listbox"]'+u);if(f.length){var l=f.index(t.target);38==t.which&&l>0&&l--,40==t.which&&l<f.length-1&&l++,~l||(l=0),f.eq(l).trigger("focus")}}}};var u=e.fn.dropdown;e.fn.dropdown=r,e.fn.dropdown.Constructor=o,e.fn.dropdown.noConflict=function(){return e.fn.dropdown=u,this},e(document).on("click.bs.dropdown.data-api",t).on("click.bs.dropdown.data-api",".dropdown form",function(e){e.stopPropagation()}).on("click.bs.dropdown.data-api",s,o.prototype.toggle).on("keydown.bs.dropdown.data-api",s,o.prototype.keydown).on("keydown.bs.dropdown.data-api",'[role="menu"]',o.prototype.keydown).on("keydown.bs.dropdown.data-api",'[role="listbox"]',o.prototype.keydown)}(jQuery),define("bootstrap",function(){}),requirejs.config({paths:{lodash:"//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min",jquery:"//code.jquery.com/jquery-2.1.4.min",firebase:"https://cdn.firebase.com/js/client/2.0.5/firebase",react:"//fb.me/react-with-addons-0.13.3.min",fiddle:"./fiddle",text:"libs/requirejs-plugins/text",json:"libs/requirejs-plugins/json",bootstrap:"libs/bootstrap/bootstrap.min"},shim:{lodash:{exports:"_"},firebase:{exports:"Firebase"},jquery:{exports:"$"},react:{exports:"React"}},map:{"*":{"react/addons":"react"}}}),requirejs(["jquery","react","fiddle","bootstrap"],function(e,t,n){var r=t.createElement(n);window.fiddle=t.render(r,document.getElementById("container"))}),define("fiddle-main.js",function(){});
\ No newline at end of file
diff --git a/playground/dist/home.min.js b/playground/dist/home.min.js
index 03b2eca..c3e14d8 100644
--- a/playground/dist/home.min.js
+++ b/playground/dist/home.min.js
@@ -7,4 +7,4 @@
  * see: http://github.com/requirejs/text for details
  */
 
-(function(e){if(typeof exports=="object"&&typeof module=="object")module.exports=e();else{if(typeof define=="function"&&define.amd)return define("libs/codemirror-4.8/lib/codemirror",[],e);this.CodeMirror=e()}})(function(){function S(e,t){if(!(this instanceof S))return new S(e,t);this.options=t=t?zo(t):{},zo(fi,t,!1),H(t);var n=t.value;typeof n=="string"&&(n=new js(n,t.mode)),this.doc=n;var s=this.display=new x(e,n);s.wrapper.CodeMirror=this,M(this),A(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),t.autofocus&&!d&&er(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Do,keySeq:null},r&&i<11&&setTimeout(Wo(Zn,this,!0),20),rr(this),fu(),kn(this),this.curOp.forceUpdate=!0,Rs(this,n),t.autofocus&&!d||nu()==s.input?setTimeout(Wo(Pr,this),20):Hr(this);for(var o in li)li.hasOwnProperty(o)&&li[o](this,t[o],hi);R(this);for(var u=0;u<mi.length;++u)mi[u](this);An(this)}function x(e,t){var n=this,o=n.input=Go("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none");s?o.style.width="1000px":o.setAttribute("wrap","off"),p&&(o.style.border="1px solid black"),o.setAttribute("autocorrect","off"),o.setAttribute("autocapitalize","off"),o.setAttribute("spellcheck","false"),n.inputDiv=Go("div",[o],null,"overflow: hidden; position: relative; width: 3px; height: 0px;"),n.scrollbarH=Go("div",[Go("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar"),n.scrollbarV=Go("div",[Go("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n.scrollbarFiller=Go("div",null,"CodeMirror-scrollbar-filler"),n.gutterFiller=Go("div",null,"CodeMirror-gutter-filler"),n.lineDiv=Go("div",null,"CodeMirror-code"),n.selectionDiv=Go("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=Go("div",null,"CodeMirror-cursors"),n.measure=Go("div",null,"CodeMirror-measure"),n.lineMeasure=Go("div",null,"CodeMirror-measure"),n.lineSpace=Go("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=Go("div",[Go("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=Go("div",[n.mover],"CodeMirror-sizer"),n.heightForcer=Go("div",null,null,"position: absolute; height: "+Lo+"px; width: 1px;"),n.gutters=Go("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=Go("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=Go("div",[n.inputDiv,n.scrollbarH,n.scrollbarV,n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),r&&i<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),p&&(o.style.width="0px"),s||(n.scroller.draggable=!0),l&&(n.inputDiv.style.height="1px",n.inputDiv.style.position="absolute"),r&&i<8&&(n.scrollbarH.style.minHeight=n.scrollbarV.style.minWidth="18px"),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.view=[],n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.prevInput="",n.alignWidgets=!1,n.pollingFast=!1,n.poll=new Do,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.inaccurateSelection=!1,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null}function T(e){e.doc.mode=S.getMode(e.options,e.doc.modeOption),N(e)}function N(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,Xt(e,100),e.state.modeGen++,e.curOp&&Un(e)}function C(e){e.options.lineWrapping?(su(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth=""):(iu(e.display.wrapper,"CodeMirror-wrap"),P(e)),L(e),Un(e),cn(e),setTimeout(function(){F(e)},100)}function k(e){var t=xn(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/Tn(e.display)-3);return function(i){if(ss(e.doc,i))return 0;var s=0;if(i.widgets)for(var o=0;o<i.widgets.length;o++)i.widgets[o].height&&(s+=i.widgets[o].height);return n?s+(Math.ceil(i.text.length/r)||1)*t:s+t}}function L(e){var t=e.doc,n=k(e);t.iter(function(e){var t=n(e);t!=e.height&&Xs(e,t)})}function A(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),cn(e)}function O(e){M(e),Un(e),setTimeout(function(){q(e)},20)}function M(e){var t=e.display.gutters,n=e.options.gutters;Zo(t);for(var r=0;r<n.length;++r){var i=n[r],s=t.appendChild(Go("div",null,"CodeMirror-gutter "+i));i=="CodeMirror-linenumbers"&&(e.display.lineGutter=s,s.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=r?"":"none",_(e)}function _(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px",e.display.scrollbarH.style.left=e.options.fixedGutter?t+"px":0}function D(e){if(e.height==0)return 0;var t=e.text.length,n,r=e;while(n=Yi(r)){var i=n.find(0,!0);r=i.from.line,t+=i.from.ch-i.to.ch}r=e;while(n=Zi(r)){var i=n.find(0,!0);t-=r.text.length-i.from.ch,r=i.to.line,t+=r.text.length-i.to.ch}return t}function P(e){var t=e.display,n=e.doc;t.maxLine=Us(n,n.first),t.maxLineLength=D(t.maxLine),t.maxLineChanged=!0,n.iter(function(e){var n=D(e);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}function H(e){var t=qo(e.gutters,"CodeMirror-linenumbers");t==-1&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function B(e){return e.display.scroller.clientHeight-e.display.wrapper.clientHeight<Lo-3}function j(e){var t=e.display.scroller;return{clientHeight:t.clientHeight,barHeight:e.display.scrollbarV.clientHeight,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth,hScrollbarTakesSpace:B(e),barWidth:e.display.scrollbarH.clientWidth,docHeight:Math.round(e.doc.height+Qt(e.display))}}function F(e,t){t||(t=j(e));var n=e.display,r=pu(n.measure),i=t.docHeight+Lo,s=t.scrollWidth>t.clientWidth;s&&t.scrollWidth<=t.clientWidth+1&&r>0&&!t.hScrollbarTakesSpace&&(s=!1);var o=i>t.clientHeight;o?(n.scrollbarV.style.display="block",n.scrollbarV.style.bottom=s?r+"px":"0",n.scrollbarV.firstChild.style.height=Math.max(0,i-t.clientHeight+(t.barHeight||n.scrollbarV.clientHeight))+"px"):(n.scrollbarV.style.display="",n.scrollbarV.firstChild.style.height="0"),s?(n.scrollbarH.style.display="block",n.scrollbarH.style.right=o?r+"px":"0",n.scrollbarH.firstChild.style.width=t.scrollWidth-t.clientWidth+(t.barWidth||n.scrollbarH.clientWidth)+"px"):(n.scrollbarH.style.display="",n.scrollbarH.firstChild.style.width="0"),s&&o?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=n.scrollbarFiller.style.width=r+"px"):n.scrollbarFiller.style.display="",s&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r+"px",n.gutterFiller.style.width=n.gutters.offsetWidth+"px"):n.gutterFiller.style.display="";if(!e.state.checkedOverlayScrollbar&&t.clientHeight>0){if(r===0){var u=v&&!c?"12px":"18px";n.scrollbarV.style.minWidth=n.scrollbarH.style.minHeight=u;var a=function(t){mo(t)!=n.scrollbarV&&mo(t)!=n.scrollbarH&&jn(e,ur)(t)};yo(n.scrollbarV,"mousedown",a),yo(n.scrollbarH,"mousedown",a)}e.state.checkedOverlayScrollbar=!0}}function I(e,t,n){var r=n&&n.top!=null?Math.max(0,n.top):e.scroller.scrollTop;r=Math.floor(r-Kt(e));var i=n&&n.bottom!=null?n.bottom:r+e.wrapper.clientHeight,s=$s(t,r),o=$s(t,i);if(n&&n.ensure){var u=n.ensure.from.line,a=n.ensure.to.line;if(u<s)return{from:u,to:$s(t,Js(Us(t,u))+e.wrapper.clientHeight)};if(Math.min(a,t.lastLine())>=o)return{from:$s(t,Js(Us(t,a))-e.wrapper.clientHeight),to:a}}return{from:s,to:Math.max(o,s+1)}}function q(e){var t=e.display,n=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;var r=z(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,s=r+"px";for(var o=0;o<n.length;o++)if(!n[o].hidden){e.options.fixedGutter&&n[o].gutter&&(n[o].gutter.style.left=s);var u=n[o].alignable;if(u)for(var a=0;a<u.length;a++)u[a].style.left=s}e.options.fixedGutter&&(t.gutters.style.left=r+i+"px")}function R(e){if(!e.options.lineNumbers)return!1;var t=e.doc,n=U(e.options,t.first+t.size-1),r=e.display;if(n.length!=r.lineNumChars){var i=r.measure.appendChild(Go("div",[Go("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),s=i.firstChild.offsetWidth,o=i.offsetWidth-s;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(s,r.lineGutter.offsetWidth-o),r.lineNumWidth=r.lineNumInnerWidth+o,r.lineNumChars=r.lineNumInnerWidth?n.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",_(e),!0}return!1}function U(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function z(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function W(e,t,n){var r=e.display;this.viewport=t,this.visible=I(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldViewFrom=r.viewFrom,this.oldViewTo=r.viewTo,this.oldScrollerWidth=r.scroller.clientWidth,this.force=n,this.dims=Y(e)}function X(e,t){var n=e.display,r=e.doc;if(t.editorIsHidden)return Wn(e),!1;if(!t.force&&t.visible.from>=n.viewFrom&&t.visible.to<=n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo)&&Jn(e)==0)return!1;R(e)&&(Wn(e),t.dims=Y(e));var i=r.first+r.size,s=Math.max(t.visible.from-e.options.viewportMargin,r.first),o=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFrom<s&&s-n.viewFrom<20&&(s=Math.max(r.first,n.viewFrom)),n.viewTo>o&&n.viewTo-o<20&&(o=Math.min(i,n.viewTo)),E&&(s=rs(e.doc,s),o=is(e.doc,o));var u=s!=n.viewFrom||o!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;$n(e,s,o),n.viewOffset=Js(Us(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var a=Jn(e);if(!u&&a==0&&!t.force&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo))return!1;var f=nu();return a>4&&(n.lineDiv.style.display="none"),Z(e,n.updateLineNumbers,t.dims),a>4&&(n.lineDiv.style.display=""),f&&nu()!=f&&f.offsetHeight&&f.focus(),Zo(n.cursorDiv),Zo(n.selectionDiv),u&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,Xt(e,400)),n.updateLineNumbers=null,!0}function V(e,t){var n=t.force,r=t.viewport;for(var i=!0;;i=!1){if(i&&e.options.lineWrapping&&t.oldScrollerWidth!=e.display.scroller.clientWidth)n=!0;else{n=!1,r&&r.top!=null&&(r={top:Math.min(e.doc.height+Qt(e.display)-Lo-e.display.scroller.clientHeight,r.top)}),t.visible=I(e.display,e.doc,r);if(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}if(!X(e,t))break;Q(e);var s=j(e);Rt(e),J(e,s),F(e,s)}So(e,"update",e),(e.display.viewFrom!=t.oldViewFrom||e.display.viewTo!=t.oldViewTo)&&So(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo)}function $(e,t){var n=new W(e,t);if(X(e,n)){Q(e),V(e,n);var r=j(e);Rt(e),J(e,r),F(e,r)}}function J(e,t){e.display.sizer.style.minHeight=e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=Math.max(t.docHeight,t.clientHeight-Lo)+"px"}function K(e,t){e.display.sizer.offsetWidth+e.display.gutters.offsetWidth<e.display.scroller.clientWidth-1&&(e.display.sizer.style.minHeight=e.display.heightForcer.style.top="0px",e.display.gutters.style.height=t.docHeight+"px")}function Q(e){var t=e.display,n=t.lineDiv.offsetTop;for(var s=0;s<t.view.length;s++){var o=t.view[s],u;if(o.hidden)continue;if(r&&i<8){var a=o.node.offsetTop+o.node.offsetHeight;u=a-n,n=a}else{var f=o.node.getBoundingClientRect();u=f.bottom-f.top}var l=o.line.height-u;u<2&&(u=xn(t));if(l>.001||l<-0.001){Xs(o.line,u),G(o.line);if(o.rest)for(var c=0;c<o.rest.length;c++)G(o.rest[c])}}}function G(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function Y(e){var t=e.display,n={},r={},i=t.gutters.clientLeft;for(var s=t.gutters.firstChild,o=0;s;s=s.nextSibling,++o)n[e.options.gutters[o]]=s.offsetLeft+s.clientLeft+i,r[e.options.gutters[o]]=s.clientWidth;return{fixedPos:z(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Z(e,t,n){function a(t){var n=t.nextSibling;return s&&v&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}var r=e.display,i=e.options.lineNumbers,o=r.lineDiv,u=o.firstChild,f=r.view,l=r.viewFrom;for(var c=0;c<f.length;c++){var h=f[c];if(!h.hidden)if(!h.node){var p=at(e,h,l,n);o.insertBefore(p,u)}else{while(u!=h.node)u=a(u);var d=i&&t!=null&&t<=l&&h.lineNumber;h.changes&&(qo(h.changes,"gutter")>-1&&(d=!1),et(e,h,l,n)),d&&(Zo(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(U(e.options,l)))),u=h.node.nextSibling}l+=h.size}while(u)u=a(u)}function et(e,t,n,r){for(var i=0;i<t.changes.length;i++){var s=t.changes[i];s=="text"?it(e,t):s=="gutter"?ot(e,t,n,r):s=="class"?st(t):s=="widget"&&ut(t,r)}t.changes=null}function tt(e){return e.node==e.text&&(e.node=Go("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),r&&i<8&&(e.node.style.zIndex=2)),e.node}function nt(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;t&&(t+=" CodeMirror-linebackground");if(e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var n=tt(e);e.background=n.insertBefore(Go("div",null,t),n.firstChild)}}function rt(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Ns(e,t)}function it(e,t){var n=t.text.className,r=rt(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,st(t)):n&&(t.text.className=n)}function st(e){nt(e),e.line.wrapClass?tt(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function ot(e,t,n,r){t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null);var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var s=tt(t),o=t.gutter=s.insertBefore(Go("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),t.text);t.line.gutterClass&&(o.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!i||!i["CodeMirror-linenumbers"])&&(t.lineNumber=o.appendChild(Go("div",U(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px")));if(i)for(var u=0;u<e.options.gutters.length;++u){var a=e.options.gutters[u],f=i.hasOwnProperty(a)&&i[a];f&&o.appendChild(Go("div",[f],"CodeMirror-gutter-elt","left: "+r.gutterLeft[a]+"px; width: "+r.gutterWidth[a]+"px"))}}}function ut(e,t){e.alignable&&(e.alignable=null);for(var n=e.node.firstChild,r;n;n=r){var r=n.nextSibling;n.className=="CodeMirror-linewidget"&&e.node.removeChild(n)}ft(e,t)}function at(e,t,n,r){var i=rt(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),st(t),ot(e,t,n,r),ft(t,r),t.node}function ft(e,t){lt(e.line,e,t,!0);if(e.rest)for(var n=0;n<e.rest.length;n++)lt(e.rest[n],e,t,!1)}function lt(e,t,n,r){if(!e.widgets)return;var i=tt(t);for(var s=0,o=e.widgets;s<o.length;++s){var u=o[s],a=Go("div",[u.node],"CodeMirror-linewidget");u.handleMouseEvents||(a.ignoreEvents=!0),ct(u,a,t,n),r&&u.above?i.insertBefore(a,t.gutter||t.text):i.appendChild(a),So(u,"redraw")}}function ct(e,t,n,r){if(e.noHScroll){(n.alignable||(n.alignable=[])).push(t);var i=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(i-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function dt(e){return ht(e.line,e.ch)}function vt(e,t){return pt(e,t)<0?t:e}function mt(e,t){return pt(e,t)<0?e:t}function gt(e,t){this.ranges=e,this.primIndex=t}function yt(e,t){this.anchor=e,this.head=t}function bt(e,t){var n=e[t];e.sort(function(e,t){return pt(e.from(),t.from())}),t=qo(e,n);for(var r=1;r<e.length;r++){var i=e[r],s=e[r-1];if(pt(s.to(),i.from())>=0){var o=mt(s.from(),i.from()),u=vt(s.to(),i.to()),a=s.empty()?i.from()==i.head:s.from()==s.head;r<=t&&--t,e.splice(--r,2,new yt(a?u:o,a?o:u))}}return new gt(e,t)}function wt(e,t){return new gt([new yt(e,t||e)],0)}function Et(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function St(e,t){if(t.line<e.first)return ht(e.first,0);var n=e.first+e.size-1;return t.line>n?ht(n,Us(e,n).text.length):xt(t,Us(e,t.line).text.length)}function xt(e,t){var n=e.ch;return n==null||n>t?ht(e.line,t):n<0?ht(e.line,0):e}function Tt(e,t){return t>=e.first&&t<e.first+e.size}function Nt(e,t){for(var n=[],r=0;r<t.length;r++)n[r]=St(e,t[r]);return n}function Ct(e,t,n,r){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(r){var s=pt(n,i)<0;s!=pt(r,i)<0?(i=n,n=r):s!=pt(n,r)<0&&(n=r)}return new yt(i,n)}return new yt(r||n,n)}function kt(e,t,n,r){Dt(e,new gt([Ct(e,e.sel.primary(),t,n)],0),r)}function Lt(e,t,n){for(var r=[],i=0;i<e.sel.ranges.length;i++)r[i]=Ct(e,e.sel.ranges[i],t[i],null);var s=bt(r,e.sel.primIndex);Dt(e,s,n)}function At(e,t,n,r){var i=e.sel.ranges.slice(0);i[t]=n,Dt(e,bt(i,e.sel.primIndex),r)}function Ot(e,t,n,r){Dt(e,wt(t,n),r)}function Mt(e,t){var n={ranges:t.ranges,update:function(t){this.ranges=[];for(var n=0;n<t.length;n++)this.ranges[n]=new yt(St(e,t[n].anchor),St(e,t[n].head))}};return wo(e,"beforeSelectionChange",e,n),e.cm&&wo(e.cm,"beforeSelectionChange",e.cm,n),n.ranges!=t.ranges?bt(n.ranges,n.ranges.length-1):t}function _t(e,t,n){var r=e.history.done,i=Fo(r);i&&i.ranges?(r[r.length-1]=t,Pt(e,t,n)):Dt(e,t,n)}function Dt(e,t,n){Pt(e,t,n),no(e,e.sel,e.cm?e.cm.curOp.id:NaN,n)}function Pt(e,t,n){if(Co(e,"beforeSelectionChange")||e.cm&&Co(e.cm,"beforeSelectionChange"))t=Mt(e,t);var r=n&&n.bias||(pt(t.primary().head,e.sel.primary().head)<0?-1:1);Ht(e,jt(e,t,r,!0)),(!n||n.scroll!==!1)&&e.cm&&ni(e.cm)}function Ht(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,No(e.cm)),So(e,"cursorActivity",e)}function Bt(e){Ht(e,jt(e,e.sel,null,!1),Oo)}function jt(e,t,n,r){var i;for(var s=0;s<t.ranges.length;s++){var o=t.ranges[s],u=Ft(e,o.anchor,n,r),a=Ft(e,o.head,n,r);if(i||u!=o.anchor||a!=o.head)i||(i=t.ranges.slice(0,s)),i[s]=new yt(u,a)}return i?bt(i,t.primIndex):t}function Ft(e,t,n,r){var i=!1,s=t,o=n||1;e.cantEdit=!1;e:for(;;){var u=Us(e,s.line);if(u.markedSpans)for(var a=0;a<u.markedSpans.length;++a){var f=u.markedSpans[a],l=f.marker;if((f.from==null||(l.inclusiveLeft?f.from<=s.ch:f.from<s.ch))&&(f.to==null||(l.inclusiveRight?f.to>=s.ch:f.to>s.ch))){if(r){wo(l,"beforeCursorEnter");if(l.explicitlyCleared){if(!u.markedSpans)break;--a;continue}}if(!l.atomic)continue;var c=l.find(o<0?-1:1);if(pt(c,s)==0){c.ch+=o,c.ch<0?c.line>e.first?c=St(e,ht(c.line-1)):c=null:c.ch>u.text.length&&(c.line<e.first+e.size-1?c=ht(c.line+1,0):c=null);if(!c){if(i)return r?(e.cantEdit=!0,ht(e.first,0)):Ft(e,t,n,!0);i=!0,c=t,o=-o}}s=c;continue e}}return s}}function It(e){var t=e.display,n=e.doc,r={},i=r.cursors=document.createDocumentFragment(),s=r.selection=document.createDocumentFragment();for(var o=0;o<n.sel.ranges.length;o++){var u=n.sel.ranges[o],a=u.empty();(a||e.options.showCursorWhenSelecting)&&Ut(e,u,i),a||zt(e,u,s)}if(e.options.moveInputWithCursor){var f=gn(e,n.sel.primary().head,"div"),l=t.wrapper.getBoundingClientRect(),c=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,f.top+c.top-l.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,f.left+c.left-l.left))}return r}function qt(e,t){eu(e.display.cursorDiv,t.cursors),eu(e.display.selectionDiv,t.selection),t.teTop!=null&&(e.display.inputDiv.style.top=t.teTop+"px",e.display.inputDiv.style.left=t.teLeft+"px")}function Rt(e){qt(e,It(e))}function Ut(e,t,n){var r=gn(e,t.head,"div",null,null,!e.options.singleCursorHeightPerLine),i=n.appendChild(Go("div"," ","CodeMirror-cursor"));i.style.left=r.left+"px",i.style.top=r.top+"px",i.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px";if(r.other){var s=n.appendChild(Go("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));s.style.display="",s.style.left=r.other.left+"px",s.style.top=r.other.top+"px",s.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function zt(e,t,n){function f(e,t,n,r){t<0&&(t=0),t=Math.round(t),r=Math.round(r),s.appendChild(Go("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(n==null?a-e:n)+"px; height: "+(r-t)+"px"))}function l(t,n,r){function h(n,r){return mn(e,ht(t,n),"div",s,r)}var s=Us(i,t),o=s.text.length,l,c;return Tu(Ks(s),n||0,r==null?o:r,function(e,t,i){var s=h(e,"left"),p,d,v;if(e==t)p=s,d=v=s.left;else{p=h(t-1,"right");if(i=="rtl"){var m=s;s=p,p=m}d=s.left,v=p.right}n==null&&e==0&&(d=u),p.top-s.top>3&&(f(d,s.top,null,s.bottom),d=u,s.bottom<p.top&&f(d,s.bottom,null,p.top)),r==null&&t==o&&(v=a);if(!l||s.top<l.top||s.top==l.top&&s.left<l.left)l=s;if(!c||p.bottom>c.bottom||p.bottom==c.bottom&&p.right>c.right)c=p;d<u+1&&(d=u),f(d,p.top,v-d,p.bottom)}),{start:l,end:c}}var r=e.display,i=e.doc,s=document.createDocumentFragment(),o=Gt(e.display),u=o.left,a=r.lineSpace.offsetWidth-o.right,c=t.from(),h=t.to();if(c.line==h.line)l(c.line,c.ch,h.ch);else{var p=Us(i,c.line),d=Us(i,h.line),v=ts(p)==ts(d),m=l(c.line,c.ch,v?p.text.length+1:null).end,g=l(h.line,v?0:null,h.ch).start;v&&(m.top<g.top-2?(f(m.right,m.top,null,m.bottom),f(u,g.top,g.left,g.bottom)):f(m.right,m.top,g.left-m.right,m.bottom)),m.bottom<g.top&&f(u,m.bottom,null,g.top)}n.appendChild(s)}function Wt(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var n=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function Xt(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Wo(Vt,e))}function Vt(e){var t=e.doc;t.frontier<t.first&&(t.frontier=t.first);if(t.frontier>=e.display.viewTo)return;var n=+(new Date)+e.options.workTime,r=yi(t.mode,Jt(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(s){if(t.frontier>=e.display.viewFrom){var o=s.styles,u=bs(e,s,r,!0);s.styles=u.styles;var a=s.styleClasses,f=u.classes;f?s.styleClasses=f:a&&(s.styleClasses=null);var l=!o||o.length!=s.styles.length||a!=f&&(!a||!f||a.bgClass!=f.bgClass||a.textClass!=f.textClass);for(var c=0;!l&&c<o.length;++c)l=o[c]!=s.styles[c];l&&i.push(t.frontier),s.stateAfter=yi(t.mode,r)}else Es(e,s.text,r),s.stateAfter=t.frontier%5==0?yi(t.mode,r):null;++t.frontier;if(+(new Date)>n)return Xt(e,e.options.workDelay),!0}),i.length&&Bn(e,function(){for(var t=0;t<i.length;t++)zn(e,i[t],"text")})}function $t(e,t,n){var r,i,s=e.doc,o=n?-1:t-(e.doc.mode.innerMode?1e3:100);for(var u=t;u>o;--u){if(u<=s.first)return s.first;var a=Us(s,u-1);if(a.stateAfter&&(!n||u<=s.frontier))return u;var f=Po(a.text,null,e.options.tabSize);if(i==null||r>f)i=u-1,r=f}return i}function Jt(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return!0;var s=$t(e,t,n),o=s>r.first&&Us(r,s-1).stateAfter;return o?o=yi(r.mode,o):o=bi(r.mode),r.iter(s,t,function(n){Es(e,n.text,o);var u=s==t-1||s%5==0||s>=i.viewFrom&&s<i.viewTo;n.stateAfter=u?yi(r.mode,o):null,++s}),n&&(r.frontier=s),o}function Kt(e){return e.lineSpace.offsetTop}function Qt(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Gt(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=eu(e.measure,Go("pre","x")),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function Yt(e,t,n){var r=e.options.lineWrapping,i=r&&e.display.scroller.clientWidth;if(!t.measure.heights||r&&t.measure.width!=i){var s=t.measure.heights=[];if(r){t.measure.width=i;var o=t.text.firstChild.getClientRects();for(var u=0;u<o.length-1;u++){var a=o[u],f=o[u+1];Math.abs(a.bottom-f.bottom)>2&&s.push((a.bottom+f.top)/2-n.top)}}s.push(n.bottom-n.top)}}function Zt(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var r=0;r<e.rest.length;r++)if(Vs(e.rest[r])>n)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}function en(e,t){t=ts(t);var n=Vs(t),r=e.display.externalMeasured=new qn(e.doc,t,n);r.lineN=n;var i=r.built=Ns(e,r);return r.text=i.pre,eu(e.display.lineMeasure,i.pre),r}function tn(e,t,n,r){return sn(e,rn(e,t),n,r)}function nn(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Xn(e,t)];var n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size)return n}function rn(e,t){var n=Vs(t),r=nn(e,n);r&&!r.text?r=null:r&&r.changes&&et(e,r,n,Y(e)),r||(r=en(e,t));var i=Zt(r,t,n);return{line:t,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function sn(e,t,n,r,i){t.before&&(n=-1);var s=n+(r||""),o;return t.cache.hasOwnProperty(s)?o=t.cache[s]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Yt(e,t.view,t.rect),t.hasHeights=!0),o=un(e,t,n,r),o.bogus||(t.cache[s]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function un(e,t,n,s){var o=t.map,u,a,f,l;for(var c=0;c<o.length;c+=3){var h=o[c],p=o[c+1];if(n<h)a=0,f=1,l="left";else if(n<p)a=n-h,f=a+1;else if(c==o.length-3||n==p&&o[c+3]>n)f=p-h,a=f-1,n>=p&&(l="right");if(a!=null){u=o[c+2],h==p&&s==(u.insertLeft?"left":"right")&&(l=s);if(s=="left"&&a==0)while(c&&o[c-2]==o[c-3]&&o[c-1].insertLeft)u=o[(c-=3)+2],l="left";if(s=="right"&&a==p-h)while(c<o.length-3&&o[c+3]==o[c+4]&&!o[c+5].insertLeft)u=o[(c+=3)+2],l="right";break}}var d;if(u.nodeType==3){for(var c=0;c<4;c++){while(a&&Qo(t.line.text.charAt(h+a)))--a;while(h+f<p&&Qo(t.line.text.charAt(h+f)))++f;if(r&&i<9&&a==0&&f==p-h)d=u.parentNode.getBoundingClientRect();else if(r&&e.options.lineWrapping){var v=Yo(u,a,f).getClientRects();v.length?d=v[s=="right"?v.length-1:0]:d=on}else d=Yo(u,a,f).getBoundingClientRect()||on;if(d.left||d.right||a==0)break;f=a,a-=1,l="right"}r&&i<11&&(d=an(e.display.measure,d))}else{a>0&&(l=s="right");var v;e.options.lineWrapping&&(v=u.getClientRects()).length>1?d=v[s=="right"?v.length-1:0]:d=u.getBoundingClientRect()}if(r&&i<9&&!a&&(!d||!d.left&&!d.right)){var m=u.parentNode.getClientRects()[0];m?d={left:m.left,right:m.left+Tn(e.display),top:m.top,bottom:m.bottom}:d=on}var g=d.top-t.rect.top,y=d.bottom-t.rect.top,b=(g+y)/2,w=t.view.measure.heights;for(var c=0;c<w.length-1;c++)if(b<w[c])break;var E=c?w[c-1]:0,S=w[c],x={left:(l=="right"?d.right:d.left)-t.rect.left,right:(l=="left"?d.left:d.right)-t.rect.left,top:E,bottom:S};return!d.left&&!d.right&&(x.bogus=!0),e.options.singleCursorHeightPerLine||(x.rtop=g,x.rbottom=y),x}function an(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Su(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}function fn(e){if(e.measure){e.measure.cache={},e.measure.heights=null;if(e.rest)for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}}function ln(e){e.display.externalMeasure=null,Zo(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)fn(e.display.view[t])}function cn(e){ln(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function hn(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function pn(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function dn(e,t,n,r){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var s=fs(t.widgets[i]);n.top+=s,n.bottom+=s}if(r=="line")return n;r||(r="local");var o=Js(t);r=="local"?o+=Kt(e.display):o-=e.display.viewOffset;if(r=="page"||r=="window"){var u=e.display.lineSpace.getBoundingClientRect();o+=u.top+(r=="window"?0:pn());var a=u.left+(r=="window"?0:hn());n.left+=a,n.right+=a}return n.top+=o,n.bottom+=o,n}function vn(e,t,n){if(n=="div")return t;var r=t.left,i=t.top;if(n=="page")r-=hn(),i-=pn();else if(n=="local"||!n){var s=e.display.sizer.getBoundingClientRect();r+=s.left,i+=s.top}var o=e.display.lineSpace.getBoundingClientRect();return{left:r-o.left,top:i-o.top}}function mn(e,t,n,r,i){return r||(r=Us(e.doc,t.line)),dn(e,r,tn(e,r,t.ch,i),n)}function gn(e,t,n,r,i,s){function o(t,o){var u=sn(e,i,t,o?"right":"left",s);return o?u.left=u.right:u.right=u.left,dn(e,r,u,n)}function u(e,t){var n=a[t],r=n.level%2;return e==Nu(n)&&t&&n.level<a[t-1].level?(n=a[--t],e=Cu(n)-(n.level%2?0:1),r=!0):e==Cu(n)&&t<a.length-1&&n.level<a[t+1].level&&(n=a[++t],e=Nu(n)-n.level%2,r=!1),r&&e==n.to&&e>n.from?o(e-1):o(e,r)}r=r||Us(e.doc,t.line),i||(i=rn(e,r));var a=Ks(r),f=t.ch;if(!a)return o(f);var l=Pu(a,f),c=u(f,l);return Du!=null&&(c.other=u(f,Du)),c}function yn(e,t){var n=0,t=St(e.doc,t);e.options.lineWrapping||(n=Tn(e.display)*t.ch);var r=Us(e.doc,t.line),i=Js(r)+Kt(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function bn(e,t,n,r){var i=ht(e,t);return i.xRel=r,n&&(i.outside=!0),i}function wn(e,t,n){var r=e.doc;n+=e.display.viewOffset;if(n<0)return bn(r.first,0,!0,-1);var i=$s(r,n),s=r.first+r.size-1;if(i>s)return bn(r.first+r.size-1,Us(r,s).text.length,!0,1);t<0&&(t=0);var o=Us(r,i);for(;;){var u=En(e,o,i,t,n),a=Zi(o),f=a&&a.find(0,!0);if(!a||!(u.ch>f.from.ch||u.ch==f.from.ch&&u.xRel>0))return u;i=Vs(o=f.to.line)}}function En(e,t,n,r,i){function f(r){var i=gn(e,ht(n,r),"line",t,a);return o=!0,s>i.bottom?i.left-u:s<i.top?i.left+u:(o=!1,i.left)}var s=i-Js(t),o=!1,u=2*e.display.wrapper.clientWidth,a=rn(e,t),l=Ks(t),c=t.text.length,h=ku(t),p=Lu(t),d=f(h),v=o,m=f(p),g=o;if(r>m)return bn(n,p,g,1);for(;;){if(l?p==h||p==Bu(t,h,1):p-h<=1){var y=r<d||r-d<=m-r?h:p,b=r-(y==h?d:m);while(Qo(t.text.charAt(y)))++y;var w=bn(n,y,y==h?v:g,b<-1?-1:b>1?1:0);return w}var E=Math.ceil(c/2),S=h+E;if(l){S=h;for(var x=0;x<E;++x)S=Bu(t,S,1)}var T=f(S);if(T>r){p=S,m=T;if(g=o)m+=1e3;c=E}else h=S,d=T,v=o,c-=E}}function xn(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Sn==null){Sn=Go("pre");for(var t=0;t<49;++t)Sn.appendChild(document.createTextNode("x")),Sn.appendChild(Go("br"));Sn.appendChild(document.createTextNode("x"))}eu(e.measure,Sn);var n=Sn.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),Zo(e.measure),n||1}function Tn(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=Go("span","xxxxxxxxxx"),n=Go("pre",[t]);eu(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function kn(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++Cn},Nn?Nn.ops.push(e.curOp):e.curOp.ownsGroup=Nn={ops:[e.curOp],delayedCallbacks:[]}}function Ln(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++)t[n]();for(var r=0;r<e.ops.length;r++){var i=e.ops[r];if(i.cursorActivityHandlers)while(i.cursorActivityCalled<i.cursorActivityHandlers.length)i.cursorActivityHandlers[i.cursorActivityCalled++](i.cm)}}while(n<t.length)}function An(e){var t=e.curOp,n=t.ownsGroup;if(!n)return;try{Ln(n)}finally{Nn=null;for(var r=0;r<n.ops.length;r++)n.ops[r].cm.curOp=null;On(n)}}function On(e){var t=e.ops;for(var n=0;n<t.length;n++)Mn(t[n]);for(var n=0;n<t.length;n++)_n(t[n]);for(var n=0;n<t.length;n++)Dn(t[n]);for(var n=0;n<t.length;n++)Pn(t[n]);for(var n=0;n<t.length;n++)Hn(t[n])}function Mn(e){var t=e.cm,n=t.display;e.updateMaxLine&&P(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<n.viewFrom||e.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new W(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function _n(e){e.updatedDisplay=e.mustUpdate&&X(e.cm,e.update)}function Dn(e){var t=e.cm,n=t.display;e.updatedDisplay&&Q(t),e.barMeasure=j(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=tn(t,n.maxLine,n.maxLine.text.length).left+3,e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo+Lo-n.scroller.clientWidth));if(e.updatedDisplay||e.selectionChanged)e.newSelectionNodes=It(t)}function Pn(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&br(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.newSelectionNodes&&qt(t,e.newSelectionNodes),e.updatedDisplay&&J(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&F(t,e.barMeasure),e.selectionChanged&&Wt(t),t.state.focused&&e.updateInput&&Zn(t,e.typing)}function Hn(e){var t=e.cm,n=t.display,r=t.doc;e.adjustWidthTo!=null&&Math.abs(e.barMeasure.scrollWidth-t.display.scroller.scrollWidth)>1&&F(t),e.updatedDisplay&&V(t,e.update),n.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(n.wheelStartX=n.wheelStartY=null);if(e.scrollTop!=null&&(n.scroller.scrollTop!=e.scrollTop||e.forceScroll)){var i=Math.max(0,Math.min(n.scroller.scrollHeight-n.scroller.clientHeight,e.scrollTop));n.scroller.scrollTop=n.scrollbarV.scrollTop=r.scrollTop=i}if(e.scrollLeft!=null&&(n.scroller.scrollLeft!=e.scrollLeft||e.forceScroll)){var o=Math.max(0,Math.min(n.scroller.scrollWidth-n.scroller.clientWidth,e.scrollLeft));n.scroller.scrollLeft=n.scrollbarH.scrollLeft=r.scrollLeft=o,q(t)}if(e.scrollToPos){var u=Yr(t,St(r,e.scrollToPos.from),St(r,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&Gr(t,u)}var a=e.maybeHiddenMarkers,f=e.maybeUnhiddenMarkers;if(a)for(var l=0;l<a.length;++l)a[l].lines.length||wo(a[l],"hide");if(f)for(var l=0;l<f.length;++l)f[l].lines.length&&wo(f[l],"unhide");n.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.updatedDisplay&&s&&(t.options.lineWrapping&&K(t,e.barMeasure),e.barMeasure.scrollWidth>e.barMeasure.clientWidth&&e.barMeasure.scrollWidth<e.barMeasure.clientWidth+1&&!B(t)&&F(t)),e.changeObjs&&wo(t,"changes",t,e.changeObjs)}function Bn(e,t){if(e.curOp)return t();kn(e);try{return t()}finally{An(e)}}function jn(e,t){return function(){if(e.curOp)return t.apply(e,arguments);kn(e);try{return t.apply(e,arguments)}finally{An(e)}}}function Fn(e){return function(){if(this.curOp)return e.apply(this,arguments);kn(this);try{return e.apply(this,arguments)}finally{An(this)}}}function In(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);kn(t);try{return e.apply(this,arguments)}finally{An(t)}}}function qn(e,t,n){this.line=t,this.rest=ns(t),this.size=this.rest?Vs(Fo(this.rest))-n+1:1,this.node=this.text=null,this.hidden=ss(e,t)}function Rn(e,t,n){var r=[],i;for(var s=t;s<n;s=i){var o=new qn(e.doc,Us(e.doc,s),s);i=s+o.size,r.push(o)}return r}function Un(e,t,n,r){t==null&&(t=e.doc.first),n==null&&(n=e.doc.first+e.doc.size),r||(r=0);var i=e.display;r&&n<i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0;if(t>=i.viewTo)E&&rs(e.doc,t)<i.viewTo&&Wn(e);else if(n<=i.viewFrom)E&&is(e.doc,n+r)>i.viewFrom?Wn(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)Wn(e);else if(t<=i.viewFrom){var s=Vn(e,n,n+r,1);s?(i.view=i.view.slice(s.index),i.viewFrom=s.lineN,i.viewTo+=r):Wn(e)}else if(n>=i.viewTo){var s=Vn(e,t,t,-1);s?(i.view=i.view.slice(0,s.index),i.viewTo=s.lineN):Wn(e)}else{var o=Vn(e,t,t,-1),u=Vn(e,n,n+r,1);o&&u?(i.view=i.view.slice(0,o.index).concat(Rn(e,o.lineN,u.lineN)).concat(i.view.slice(u.index)),i.viewTo+=r):Wn(e)}var a=i.externalMeasured;a&&(n<a.lineN?a.lineN+=r:t<a.lineN+a.size&&(i.externalMeasured=null))}function zn(e,t,n){e.curOp.viewChanged=!0;var r=e.display,i=e.display.externalMeasured;i&&t>=i.lineN&&t<i.lineN+i.size&&(r.externalMeasured=null);if(t<r.viewFrom||t>=r.viewTo)return;var s=r.view[Xn(e,t)];if(s.node==null)return;var o=s.changes||(s.changes=[]);qo(o,n)==-1&&o.push(n)}function Wn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Xn(e,t){if(t>=e.display.viewTo)return null;t-=e.display.viewFrom;if(t<0)return null;var n=e.display.view;for(var r=0;r<n.length;r++){t-=n[r].size;if(t<0)return r}}function Vn(e,t,n,r){var i=Xn(e,t),s,o=e.display.view;if(!E||n==e.doc.first+e.doc.size)return{index:i,lineN:n};for(var u=0,a=e.display.viewFrom;u<i;u++)a+=o[u].size;if(a!=t){if(r>0){if(i==o.length-1)return null;s=a+o[i].size-t,i++}else s=a-t;t+=s,n+=s}while(rs(e.doc,n)!=n){if(i==(r<0?0:o.length-1))return null;n+=r*o[i-(r<0?1:0)].size,i+=r}return{index:i,lineN:n}}function $n(e,t,n){var r=e.display,i=r.view;i.length==0||t>=r.viewTo||n<=r.viewFrom?(r.view=Rn(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=Rn(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Xn(e,t))),r.viewFrom=t,r.viewTo<n?r.view=r.view.concat(Rn(e,r.viewTo,n)):r.viewTo>n&&(r.view=r.view.slice(0,Xn(e,n)))),r.viewTo=n}function Jn(e){var t=e.display.view,n=0;for(var r=0;r<t.length;r++){var i=t[r];!i.hidden&&(!i.node||i.changes)&&++n}return n}function Kn(e){if(e.display.pollingFast)return;e.display.poll.set(e.options.pollInterval,function(){Yn(e),e.state.focused&&Kn(e)})}function Qn(e){function n(){var r=Yn(e);!r&&!t?(t=!0,e.display.poll.set(60,n)):(e.display.pollingFast=!1,Kn(e))}var t=!1;e.display.pollingFast=!0,e.display.poll.set(20,n)}function Yn(e){var t=e.display.input,n=e.display.prevInput,s=e.doc;if(!e.state.focused||bu(t)&&!n||nr(e)||e.options.disableInput||e.state.keySeq)return!1;e.state.pasteIncoming&&e.state.fakedLastChar&&(t.value=t.value.substring(0,t.value.length-1),e.state.fakedLastChar=!1);var o=t.value;if(o==n&&!e.somethingSelected())return!1;if(r&&i>=9&&e.display.inputHasSelection===o||v&&/[\uf700-\uf7ff]/.test(o))return Zn(e),!1;var u=!e.curOp;u&&kn(e),e.display.shift=!1,o.charCodeAt(0)==8203&&s.sel==e.display.selForContextMenu&&!n&&(n="​");var a=0,f=Math.min(n.length,o.length);while(a<f&&n.charCodeAt(a)==o.charCodeAt(a))++a;var l=o.slice(a),c=yu(l),h=null;e.state.pasteIncoming&&s.sel.ranges.length>1&&(Gn&&Gn.join("\n")==l?h=s.sel.ranges.length%Gn.length==0&&Ro(Gn,yu):c.length==s.sel.ranges.length&&(h=Ro(c,function(e){return[e]})));for(var p=s.sel.ranges.length-1;p>=0;p--){var d=s.sel.ranges[p],m=d.from(),g=d.to();a<n.length?m=ht(m.line,m.ch-(n.length-a)):e.state.overwrite&&d.empty()&&!e.state.pasteIncoming&&(g=ht(g.line,Math.min(Us(s,g.line).text.length,g.ch+Fo(c).length)));var y=e.curOp.updateInput,b={from:m,to:g,text:h?h[p%h.length]:c,origin:e.state.pasteIncoming?"paste":e.state.cutIncoming?"cut":"+input"};Wr(e.doc,b),So(e,"inputRead",e,b);if(l&&!e.state.pasteIncoming&&e.options.electricChars&&e.options.smartIndent&&d.head.ch<100&&(!p||s.sel.ranges[p-1].head.line!=d.head.line)){var w=e.getModeAt(d.head),E=Fr(b);if(w.electricChars){for(var S=0;S<w.electricChars.length;S++)if(l.indexOf(w.electricChars.charAt(S))>-1){ii(e,E.line,"smart");break}}else w.electricInput&&w.electricInput.test(Us(s,E.line).text.slice(0,E.ch))&&ii(e,E.line,"smart")}}return ni(e),e.curOp.updateInput=y,e.curOp.typing=!0,o.length>1e3||o.indexOf("\n")>-1?t.value=e.display.prevInput="":e.display.prevInput=o,u&&An(e),e.state.pasteIncoming=e.state.cutIncoming=!1,!0}function Zn(e,t){var n,s,o=e.doc;if(e.somethingSelected()){e.display.prevInput="";var u=o.sel.primary();n=wu&&(u.to().line-u.from().line>100||(s=e.getSelection()).length>1e3);var a=n?"-":s||e.getSelection();e.display.input.value=a,e.state.focused&&Io(e.display.input),r&&i>=9&&(e.display.inputHasSelection=a)}else t||(e.display.prevInput=e.display.input.value="",r&&i>=9&&(e.display.inputHasSelection=null));e.display.inaccurateSelection=n}function er(e){e.options.readOnly!="nocursor"&&(!d||nu()!=e.display.input)&&e.display.input.focus()}function tr(e){e.state.focused||(er(e),Pr(e))}function nr(e){return e.options.readOnly||e.doc.cantEdit}function rr(e){function n(){e.state.focused&&setTimeout(Wo(er,e),0)}function o(t){To(e,t)||vo(t)}function u(n){if(e.somethingSelected())Gn=e.getSelections(),t.inaccurateSelection&&(t.prevInput="",t.inaccurateSelection=!1,t.input.value=Gn.join("\n"),Io(t.input));else{var r=[],i=[];for(var s=0;s<e.doc.sel.ranges.length;s++){var o=e.doc.sel.ranges[s].head.line,u={anchor:ht(o,0),head:ht(o+1,0)};i.push(u),r.push(e.getRange(u.anchor,u.head))}n.type=="cut"?e.setSelections(i,null,Oo):(t.prevInput="",t.input.value=r.join("\n"),Io(t.input)),Gn=r}n.type=="cut"&&(e.state.cutIncoming=!0)}var t=e.display;yo(t.scroller,"mousedown",jn(e,ur)),r&&i<11?yo(t.scroller,"dblclick",jn(e,function(t){if(To(e,t))return;var n=or(e,t);if(!n||dr(e,t)||sr(e.display,t))return;co(t);var r=e.findWordAt(n);kt(e.doc,r.anchor,r.head)})):yo(t.scroller,"dblclick",function(t){To(e,t)||co(t)}),yo(t.lineSpace,"selectstart",function(e){sr(t,e)||co(e)}),b||yo(t.scroller,"contextmenu",function(t){Br(e,t)}),yo(t.scroller,"scroll",function(){t.scroller.clientHeight&&(yr(e,t.scroller.scrollTop),br(e,t.scroller.scrollLeft,!0),wo(e,"scroll",e))}),yo(t.scrollbarV,"scroll",function(){t.scroller.clientHeight&&yr(e,t.scrollbarV.scrollTop)}),yo(t.scrollbarH,"scroll",function(){t.scroller.clientHeight&&br(e,t.scrollbarH.scrollLeft)}),yo(t.scroller,"mousewheel",function(t){Sr(e,t)}),yo(t.scroller,"DOMMouseScroll",function(t){Sr(e,t)}),yo(t.scrollbarH,"mousedown",n),yo(t.scrollbarV,"mousedown",n),yo(t.wrapper,"scroll",function(){t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),yo(t.input,"keyup",function(t){_r.call(e,t)}),yo(t.input,"input",function(){r&&i>=9&&e.display.inputHasSelection&&(e.display.inputHasSelection=null),Qn(e)}),yo(t.input,"keydown",jn(e,Or)),yo(t.input,"keypress",jn(e,Dr)),yo(t.input,"focus",Wo(Pr,e)),yo(t.input,"blur",Wo(Hr,e)),e.options.dragDrop&&(yo(t.scroller,"dragstart",function(t){gr(e,t)}),yo(t.scroller,"dragenter",o),yo(t.scroller,"dragover",o),yo(t.scroller,"drop",jn(e,mr))),yo(t.scroller,"paste",function(n){if(sr(t,n))return;e.state.pasteIncoming=!0,er(e),Qn(e)}),yo(t.input,"paste",function(){if(s&&!e.state.fakedLastChar&&!(new Date-e.state.lastMiddleDown<200)){var n=t.input.selectionStart,r=t.input.selectionEnd;t.input.value+="$",t.input.selectionEnd=r,t.input.selectionStart=n,e.state.fakedLastChar=!0}e.state.pasteIncoming=!0,Qn(e)}),yo(t.input,"cut",u),yo(t.input,"copy",u),l&&yo(t.sizer,"mouseup",function(){nu()==t.input&&t.input.blur(),er(e)})}function ir(e){var t=e.display;if(t.lastWrapHeight==t.wrapper.clientHeight&&t.lastWrapWidth==t.wrapper.clientWidth)return;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,e.setSize()}function sr(e,t){for(var n=mo(t);n!=e.wrapper;n=n.parentNode)if(!n||n.ignoreEvents||n.parentNode==e.sizer&&n!=e.mover)return!0}function or(e,t,n,r){var i=e.display;if(!n){var s=mo(t);if(s==i.scrollbarH||s==i.scrollbarV||s==i.scrollbarFiller||s==i.gutterFiller)return null}var o,u,a=i.lineSpace.getBoundingClientRect();try{o=t.clientX-a.left,u=t.clientY-a.top}catch(t){return null}var f=wn(e,o,u),l;if(r&&f.xRel==1&&(l=Us(e.doc,f.line).text).length==f.ch){var c=Po(l,l.length,e.options.tabSize)-l.length;f=ht(f.line,Math.max(0,Math.round((o-Gt(e.display).left)/Tn(e.display))-c))}return f}function ur(e){if(To(this,e))return;var t=this,n=t.display;n.shift=e.shiftKey;if(sr(n,e)){s||(n.scroller.draggable=!1,setTimeout(function(){n.scroller.draggable=!0},100));return}if(dr(t,e))return;var r=or(t,e);window.focus();switch(go(e)){case 1:r?lr(t,e,r):mo(e)==n.scroller&&co(e);break;case 2:s&&(t.state.lastMiddleDown=+(new Date)),r&&kt(t.doc,r),setTimeout(Wo(er,t),20),co(e);break;case 3:b&&Br(t,e)}}function lr(e,t,n){setTimeout(Wo(tr,e),0);var r=+(new Date),i;fr&&fr.time>r-400&&pt(fr.pos,n)==0?i="triple":ar&&ar.time>r-400&&pt(ar.pos,n)==0?(i="double",fr={time:r,pos:n}):(i="single",ar={time:r,pos:n});var s=e.doc.sel,o=v?t.metaKey:t.ctrlKey;e.options.dragDrop&&cu&&!nr(e)&&i=="single"&&s.contains(n)>-1&&s.somethingSelected()?cr(e,t,n,o):hr(e,t,n,i,o)}function cr(e,t,n,o){var u=e.display,a=jn(e,function(f){s&&(u.scroller.draggable=!1),e.state.draggingText=!1,bo(document,"mouseup",a),bo(u.scroller,"drop",a),Math.abs(t.clientX-f.clientX)+Math.abs(t.clientY-f.clientY)<10&&(co(f),o||kt(e.doc,n),er(e),r&&i==9&&setTimeout(function(){document.body.focus(),er(e)},20))});s&&(u.scroller.draggable=!0),e.state.draggingText=a,u.scroller.dragDrop&&u.scroller.dragDrop(),yo(document,"mouseup",a),yo(u.scroller,"drop",a)}function hr(e,t,n,r,i){function p(t){if(pt(h,t)==0)return;h=t;if(r=="rect"){var i=[],s=e.options.tabSize,l=Po(Us(o,n.line).text,n.ch,s),c=Po(Us(o,t.line).text,t.ch,s),p=Math.min(l,c),d=Math.max(l,c);for(var v=Math.min(n.line,t.line),m=Math.min(e.lastLine(),Math.max(n.line,t.line));v<=m;v++){var g=Us(o,v).text,y=Ho(g,p,s);p==d?i.push(new yt(ht(v,y),ht(v,y))):g.length>y&&i.push(new yt(ht(v,y),ht(v,Ho(g,d,s))))}i.length||i.push(new yt(n,n)),Dt(o,bt(f.ranges.slice(0,a).concat(i),a),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=u,w=b.anchor,E=t;if(r!="single"){if(r=="double")var S=e.findWordAt(t);else var S=new yt(ht(t.line,0),St(o,ht(t.line+1,0)));pt(S.anchor,w)>0?(E=S.head,w=mt(b.from(),S.anchor)):(E=S.anchor,w=vt(b.to(),S.head))}var i=f.ranges.slice(0);i[a]=new yt(St(o,w),E),Dt(o,bt(i,a),Mo)}}function m(t){var n=++v,i=or(e,t,!0,r=="rect");if(!i)return;if(pt(i,h)!=0){tr(e),p(i);var u=I(s,o);(i.line>=u.to||i.line<u.from)&&setTimeout(jn(e,function(){v==n&&m(t)}),150)}else{var a=t.clientY<d.top?-20:t.clientY>d.bottom?20:0;a&&setTimeout(jn(e,function(){if(v!=n)return;s.scroller.scrollTop+=a,m(t)}),50)}}function g(t){v=Infinity,co(t),er(e),bo(document,"mousemove",y),bo(document,"mouseup",b),o.history.lastSelOrigin=null}var s=e.display,o=e.doc;co(t);var u,a,f=o.sel;i&&!t.shiftKey?(a=o.sel.contains(n),a>-1?u=o.sel.ranges[a]:u=new yt(n,n)):u=o.sel.primary();if(t.altKey)r="rect",i||(u=new yt(n,n)),n=or(e,t,!0,!0),a=-1;else if(r=="double"){var l=e.findWordAt(n);e.display.shift||o.extend?u=Ct(o,u,l.anchor,l.head):u=l}else if(r=="triple"){var c=new yt(ht(n.line,0),St(o,ht(n.line+1,0)));e.display.shift||o.extend?u=Ct(o,u,c.anchor,c.head):u=c}else u=Ct(o,u,n);i?a>-1?At(o,a,u,Mo):(a=o.sel.ranges.length,Dt(o,bt(o.sel.ranges.concat([u]),a),{scroll:!1,origin:"*mouse"})):(a=0,Dt(o,new gt([u],0),Mo),f=o.sel);var h=n,d=s.wrapper.getBoundingClientRect(),v=0,y=jn(e,function(e){go(e)?m(e):g(e)}),b=jn(e,g);yo(document,"mousemove",y),yo(document,"mouseup",b)}function pr(e,t,n,r,i){try{var s=t.clientX,o=t.clientY}catch(t){return!1}if(s>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&co(t);var u=e.display,a=u.lineDiv.getBoundingClientRect();if(o>a.bottom||!Co(e,n))return po(t);o-=a.top-u.viewOffset;for(var f=0;f<e.options.gutters.length;++f){var l=u.gutters.childNodes[f];if(l&&l.getBoundingClientRect().right>=s){var c=$s(e.doc,o),h=e.options.gutters[f];return i(e,n,e,c,h,t),po(t)}}}function dr(e,t){return pr(e,t,"gutterClick",!0,So)}function mr(e){var t=this;if(To(t,e)||sr(t.display,e))return;co(e),r&&(vr=+(new Date));var n=or(t,e,!0),i=e.dataTransfer.files;if(!n||nr(t))return;if(i&&i.length&&window.FileReader&&window.File){var s=i.length,o=Array(s),u=0,a=function(e,r){var i=new FileReader;i.onload=jn(t,function(){o[r]=i.result;if(++u==s){n=St(t.doc,n);var e={from:n,to:n,text:yu(o.join("\n")),origin:"paste"};Wr(t.doc,e),_t(t.doc,wt(n,Fr(e)))}}),i.readAsText(e)};for(var f=0;f<s;++f)a(i[f],f)}else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1){t.state.draggingText(e),setTimeout(Wo(er,t),20);return}try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&(v?!e.metaKey:!e.ctrlKey))var l=t.listSelections();Pt(t.doc,wt(n,n));if(l)for(var f=0;f<l.length;++f)Qr(t.doc,"",l[f].anchor,l[f].head,"drag");t.replaceSelection(o,"around","paste"),er(t)}}catch(e){}}}function gr(e,t){if(r&&(!e.state.draggingText||+(new Date)-vr<100)){vo(t);return}if(To(e,t)||sr(e.display,t))return;t.dataTransfer.setData("Text",e.getSelection());if(t.dataTransfer.setDragImage&&!f){var n=Go("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",a&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),a&&n.parentNode.removeChild(n)}}function yr(t,n){if(Math.abs(t.doc.scrollTop-n)<2)return;t.doc.scrollTop=n,e||$(t,{top:n}),t.display.scroller.scrollTop!=n&&(t.display.scroller.scrollTop=n),t.display.scrollbarV.scrollTop!=n&&(t.display.scrollbarV.scrollTop=n),e&&$(t),Xt(t,100)}function br(e,t,n){if(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)return;t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,q(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbarH.scrollLeft!=t&&(e.display.scrollbarH.scrollLeft=t)}function Sr(t,n){var r=n.wheelDeltaX,i=n.wheelDeltaY;r==null&&n.detail&&n.axis==n.HORIZONTAL_AXIS&&(r=n.detail),i==null&&n.detail&&n.axis==n.VERTICAL_AXIS?i=n.detail:i==null&&(i=n.wheelDelta);var o=t.display,u=o.scroller;if(!(r&&u.scrollWidth>u.clientWidth||i&&u.scrollHeight>u.clientHeight))return;if(i&&v&&s)e:for(var f=n.target,l=o.view;f!=u;f=f.parentNode)for(var c=0;c<l.length;c++)if(l[c].node==f){t.display.currentWheelTarget=f;break e}if(r&&!e&&!a&&Er!=null){i&&yr(t,Math.max(0,Math.min(u.scrollTop+i*Er,u.scrollHeight-u.clientHeight))),br(t,Math.max(0,Math.min(u.scrollLeft+r*Er,u.scrollWidth-u.clientWidth))),co(n),o.wheelStartX=null;return}if(i&&Er!=null){var h=i*Er,p=t.doc.scrollTop,d=p+o.wrapper.clientHeight;h<0?p=Math.max(0,p+h-50):d=Math.min(t.doc.height,d+h+50),$(t,{top:p,bottom:d})}wr<20&&(o.wheelStartX==null?(o.wheelStartX=u.scrollLeft,o.wheelStartY=u.scrollTop,o.wheelDX=r,o.wheelDY=i,setTimeout(function(){if(o.wheelStartX==null)return;var e=u.scrollLeft-o.wheelStartX,t=u.scrollTop-o.wheelStartY,n=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null;if(!n)return;Er=(Er*wr+n)/(wr+1),++wr},200)):(o.wheelDX+=r,o.wheelDY+=i))}function xr(e,t,n){if(typeof t=="string"){t=wi[t];if(!t)return!1}e.display.pollingFast&&Yn(e)&&(e.display.pollingFast=!1);var r=e.display.shift,i=!1;try{nr(e)&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),i=t(e)!=Ao}finally{e.display.shift=r,e.state.suppressEdits=!1}return i}function Tr(e,t,n){for(var r=0;r<e.state.keyMaps.length;r++){var i=xi(t,e.state.keyMaps[r],n);if(i)return i}return e.options.extraKeys&&xi(t,e.options.extraKeys,n)||xi(t,e.options.keyMap,n)}function Cr(e,t,n,r){var i=e.state.keySeq;if(i){if(Ti(t))return"handled";Nr.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,Zn(e))}),t=i+" "+t}var s=Tr(e,t,r);s=="multi"&&(e.state.keySeq=t),s=="handled"&&So(e,"keyHandled",e,t,n);if(s=="handled"||s=="multi")co(n),Wt(e);return i&&!s&&/\'$/.test(t)?(co(n),!0):!!s}function kr(e,t){var n=Ni(t,!0);return n?t.shiftKey&&!e.state.keySeq?Cr(e,"Shift-"+n,t,function(t){return xr(e,t,!0)})||Cr(e,n,t,function(t){if(typeof t=="string"?/^go[A-Z]/.test(t):t.motion)return xr(e,t)}):Cr(e,n,t,function(t){return xr(e,t)}):!1}function Lr(e,t,n){return Cr(e,"'"+n+"'",t,function(t){return xr(e,t,!0)})}function Or(e){var t=this;tr(t);if(To(t,e))return;r&&i<11&&e.keyCode==27&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=n==16||e.shiftKey;var s=kr(t,e);a&&(Ar=s?n:null,!s&&n==88&&!wu&&(v?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),n==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Mr(t)}function Mr(e){function n(e){if(e.keyCode==18||!e.altKey)iu(t,"CodeMirror-crosshair"),bo(document,"keyup",n),bo(document,"mouseover",n)}var t=e.display.lineDiv;su(t,"CodeMirror-crosshair"),yo(document,"keyup",n),yo(document,"mouseover",n)}function _r(e){e.keyCode==16&&(this.doc.sel.shift=!1),To(this,e)}function Dr(e){var t=this;if(To(t,e)||e.ctrlKey&&!e.altKey||v&&e.metaKey)return;var n=e.keyCode,s=e.charCode;if(a&&n==Ar){Ar=null,co(e);return}if((a&&(!e.which||e.which<10)||l)&&kr(t,e))return;var o=String.fromCharCode(s==null?n:s);if(Lr(t,e,o))return;r&&i>=9&&(t.display.inputHasSelection=null),Qn(t)}function Pr(e){if(e.options.readOnly=="nocursor")return;e.state.focused||(wo(e,"focus",e),e.state.focused=!0,su(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(Zn(e),s&&setTimeout(Wo(Zn,e,!0),0))),Kn(e),Wt(e)}function Hr(e){e.state.focused&&(wo(e,"blur",e),e.state.focused=!1,iu(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Br(e,t){function h(){if(n.input.selectionStart!=null){var t=e.somethingSelected(),r=n.input.value="​"+(t?n.input.value:"");n.prevInput=t?"":"​",n.input.selectionStart=1,n.input.selectionEnd=r.length,n.selForContextMenu=e.doc.sel}}function p(){n.inputDiv.style.position="relative",n.input.style.cssText=l,r&&i<9&&(n.scrollbarV.scrollTop=n.scroller.scrollTop=u),Kn(e);if(n.input.selectionStart!=null){(!r||r&&i<9)&&h();var t=0,s=function(){n.selForContextMenu==e.doc.sel&&n.input.selectionStart==0?jn(e,wi.selectAll)(e):t++<10?n.detectingSelectAll=setTimeout(s,500):Zn(e)};n.detectingSelectAll=setTimeout(s,200)}}if(To(e,t,"contextmenu"))return;var n=e.display;if(sr(n,t)||jr(e,t))return;var o=or(e,t),u=n.scroller.scrollTop;if(!o||a)return;var f=e.options.resetSelectionOnContextMenu;f&&e.doc.sel.contains(o)==-1&&jn(e,Dt)(e.doc,wt(o),Oo);var l=n.input.style.cssText;n.inputDiv.style.position="absolute",n.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(t.clientY-5)+"px; left: "+(t.clientX-5)+"px; z-index: 1000; background: "+(r?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";if(s)var c=window.scrollY;er(e),s&&window.scrollTo(null,c),Zn(e),e.somethingSelected()||(n.input.value=n.prevInput=" "),n.selForContextMenu=e.doc.sel,clearTimeout(n.detectingSelectAll),r&&i>=9&&h();if(b){vo(t);var d=function(){bo(window,"mouseup",d),setTimeout(p,20)};yo(window,"mouseup",d)}else setTimeout(p,50)}function jr(e,t){return Co(e,"gutterContextMenu")?pr(e,t,"gutterContextMenu",!1,wo):!1}function Ir(e,t){if(pt(e,t.from)<0)return e;if(pt(e,t.to)<=0)return Fr(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Fr(t).ch-t.to.ch),ht(n,r)}function qr(e,t){var n=[];for(var r=0;r<e.sel.ranges.length;r++){var i=e.sel.ranges[r];n.push(new yt(Ir(i.anchor,t),Ir(i.head,t)))}return bt(n,e.sel.primIndex)}function Rr(e,t,n){return e.line==t.line?ht(n.line,e.ch-t.ch+n.ch):ht(n.line+(e.line-t.line),e.ch)}function Ur(e,t,n){var r=[],i=ht(e.first,0),s=i;for(var o=0;o<t.length;o++){var u=t[o],a=Rr(u.from,i,s),f=Rr(Fr(u),i,s);i=u.to,s=f;if(n=="around"){var l=e.sel.ranges[o],c=pt(l.head,l.anchor)<0;r[o]=new yt(c?f:a,c?a:f)}else r[o]=new yt(a,a)}return new gt(r,e.sel.primIndex)}function zr(e,t,n){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return n&&(r.update=function(t,n,r,i){t&&(this.from=St(e,t)),n&&(this.to=St(e,n)),r&&(this.text=r),i!==undefined&&(this.origin=i)}),wo(e,"beforeChange",e,r),e.cm&&wo(e.cm,"beforeChange",e.cm,r),r.canceled?null:{from:r.from,to:r.to,text:r.text,origin:r.origin}}function Wr(e,t,n){if(e.cm){if(!e.cm.curOp)return jn(e.cm,Wr)(e,t,n);if(e.cm.state.suppressEdits)return}if(Co(e,"beforeChange")||e.cm&&Co(e.cm,"beforeChange")){t=zr(e,t,!0);if(!t)return}var r=w&&!n&&Xi(e,t.from,t.to);if(r)for(var i=r.length-1;i>=0;--i)Xr(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text});else Xr(e,t)}function Xr(e,t){if(t.text.length==1&&t.text[0]==""&&pt(t.from,t.to)==0)return;var n=qr(e,t);eo(e,t,n,e.cm?e.cm.curOp.id:NaN),Jr(e,t,n,Ui(e,t));var r=[];qs(e,function(e,n){!n&&qo(r,e.history)==-1&&(lo(e.history,t),r.push(e.history)),Jr(e,t,null,Ui(e,t))})}function Vr(e,t,n){if(e.cm&&e.cm.state.suppressEdits)return;var r=e.history,i,s=e.sel,o=t=="undo"?r.done:r.undone,u=t=="undo"?r.undone:r.done;for(var a=0;a<o.length;a++){i=o[a];if(n?i.ranges&&!i.equals(e.sel):!i.ranges)break}if(a==o.length)return;r.lastOrigin=r.lastSelOrigin=null;for(;;){i=o.pop();if(!i.ranges)break;ro(i,u);if(n&&!i.equals(e.sel)){Dt(e,i,{clearRedo:!1});return}s=i}var f=[];ro(s,u),u.push({changes:f,generation:r.generation}),r.generation=i.generation||++r.maxGeneration;var l=Co(e,"beforeChange")||e.cm&&Co(e.cm,"beforeChange");for(var a=i.changes.length-1;a>=0;--a){var c=i.changes[a];c.origin=t;if(l&&!zr(e,c,!1)){o.length=0;return}f.push(Gs(e,c));var h=a?qr(e,c):Fo(o);Jr(e,c,h,Wi(e,c)),!a&&e.cm&&e.cm.scrollIntoView({from:c.from,to:Fr(c)});var p=[];qs(e,function(e,t){!t&&qo(p,e.history)==-1&&(lo(e.history,c),p.push(e.history)),Jr(e,c,null,Wi(e,c))})}}function $r(e,t){if(t==0)return;e.first+=t,e.sel=new gt(Ro(e.sel.ranges,function(e){return new yt(ht(e.anchor.line+t,e.anchor.ch),ht(e.head.line+t,e.head.ch))}),e.sel.primIndex);if(e.cm){Un(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;r<n.viewTo;r++)zn(e.cm,r,"gutter")}}function Jr(e,t,n,r){if(e.cm&&!e.cm.curOp)return jn(e.cm,Jr)(e,t,n,r);if(t.to.line<e.first){$r(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine())return;if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);$r(e,i),t={from:ht(e.first,0),to:ht(t.to.line+i,t.to.ch),text:[Fo(t.text)],origin:t.origin}}var s=e.lastLine();t.to.line>s&&(t={from:t.from,to:ht(s,Us(e,s).text.length),text:[t.text[0]],origin:t.origin}),t.removed=zs(e,t.from,t.to),n||(n=qr(e,t)),e.cm?Kr(e.cm,t,r):Ds(e,t,r),Pt(e,n,Oo)}function Kr(e,t,n){var r=e.doc,i=e.display,s=t.from,o=t.to,u=!1,a=s.line;e.options.lineWrapping||(a=Vs(ts(Us(r,s.line))),r.iter(a,o.line+1,function(e){if(e==i.maxLine)return u=!0,!0})),r.sel.contains(t.from,t.to)>-1&&No(e),Ds(r,t,n,k(e)),e.options.lineWrapping||(r.iter(a,s.line+t.text.length,function(e){var t=D(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,u=!1)}),u&&(e.curOp.updateMaxLine=!0)),r.frontier=Math.min(r.frontier,s.line),Xt(e,400);var f=t.text.length-(o.line-s.line)-1;s.line==o.line&&t.text.length==1&&!_s(e.doc,t)?zn(e,s.line,"text"):Un(e,s.line,o.line+1,f);var l=Co(e,"changes"),c=Co(e,"change");if(c||l){var h={from:s,to:o,text:t.text,removed:t.removed,origin:t.origin};c&&So(e,"change",e,h),l&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function Qr(e,t,n,r,i){r||(r=n);if(pt(r,n)<0){var s=r;r=n,n=s}typeof t=="string"&&(t=yu(t)),Wr(e,{from:n,to:r,text:t,origin:i})}function Gr(e,t){if(To(e,"scrollCursorIntoView"))return;var n=e.display,r=n.sizer.getBoundingClientRect(),i=null;t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1);if(i!=null&&!h){var s=Go("div","​",null,"position: absolute; top: "+(t.top-n.viewOffset-Kt(e.display))+"px; height: "+(t.bottom-t.top+Lo)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(s),s.scrollIntoView(i),e.display.lineSpace.removeChild(s)}}function Yr(e,t,n,r){r==null&&(r=0);for(var i=0;i<5;i++){var s=!1,o=gn(e,t),u=!n||n==t?o:gn(e,n),a=ei(e,Math.min(o.left,u.left),Math.min(o.top,u.top)-r,Math.max(o.left,u.left),Math.max(o.bottom,u.bottom)+r),f=e.doc.scrollTop,l=e.doc.scrollLeft;a.scrollTop!=null&&(yr(e,a.scrollTop),Math.abs(e.doc.scrollTop-f)>1&&(s=!0)),a.scrollLeft!=null&&(br(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-l)>1&&(s=!0));if(!s)return o}}function Zr(e,t,n,r,i){var s=ei(e,t,n,r,i);s.scrollTop!=null&&yr(e,s.scrollTop),s.scrollLeft!=null&&br(e,s.scrollLeft)}function ei(e,t,n,r,i){var s=e.display,o=xn(e.display);n<0&&(n=0);var u=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:s.scroller.scrollTop,a=s.scroller.clientHeight-Lo,f={};i-n>a&&(i=n+a);var l=e.doc.height+Qt(s),c=n<o,h=i>l-o;if(n<u)f.scrollTop=c?0:n;else if(i>u+a){var p=Math.min(n,(h?l:i)-a);p!=u&&(f.scrollTop=p)}var d=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:s.scroller.scrollLeft,v=s.scroller.clientWidth-Lo-s.gutters.offsetWidth,m=r-t>v;return m&&(r=t+v),t<10?f.scrollLeft=0:t<d?f.scrollLeft=Math.max(0,t-(m?0:10)):r>v+d-3&&(f.scrollLeft=r+(m?0:10)-v),f}function ti(e,t,n){(t!=null||n!=null)&&ri(e),t!=null&&(e.curOp.scrollLeft=(e.curOp.scrollLeft==null?e.doc.scrollLeft:e.curOp.scrollLeft)+t),n!=null&&(e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+n)}function ni(e){ri(e);var t=e.getCursor(),n=t,r=t;e.options.lineWrapping||(n=t.ch?ht(t.line,t.ch-1):t,r=ht(t.line,t.ch+1)),e.curOp.scrollToPos={from:n,to:r,margin:e.options.cursorScrollMargin,isCursor:!0}}function ri(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=yn(e,t.from),r=yn(e,t.to),i=ei(e,Math.min(n.left,r.left),Math.min(n.top,r.top)-t.margin,Math.max(n.right,r.right),Math.max(n.bottom,r.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function ii(e,t,n,r){var i=e.doc,s;n==null&&(n="add"),n=="smart"&&(i.mode.indent?s=Jt(e,t):n="prev");var o=e.options.tabSize,u=Us(i,t),a=Po(u.text,null,o);u.stateAfter&&(u.stateAfter=null);var f=u.text.match(/^\s*/)[0],l;if(!r&&!/\S/.test(u.text))l=0,n="not";else if(n=="smart"){l=i.mode.indent(s,u.text.slice(f.length),u.text);if(l==Ao||l>150){if(!r)return;n="prev"}}n=="prev"?t>i.first?l=Po(Us(i,t-1).text,null,o):l=0:n=="add"?l=a+e.options.indentUnit:n=="subtract"?l=a-e.options.indentUnit:typeof n=="number"&&(l=a+n),l=Math.max(0,l);var c="",h=0;if(e.options.indentWithTabs)for(var p=Math.floor(l/o);p;--p)h+=o,c+="	";h<l&&(c+=jo(l-h));if(c!=f)Qr(i,c,ht(t,0),ht(t,f.length),"+input");else for(var p=0;p<i.sel.ranges.length;p++){var d=i.sel.ranges[p];if(d.head.line==t&&d.head.ch<f.length){var h=ht(t,f.length);At(i,p,new yt(h,h));break}}u.stateAfter=null}function si(e,t,n,r){var i=t,s=t;return typeof t=="number"?s=Us(e,Et(e,t)):i=Vs(t),i==null?null:(r(s,i)&&e.cm&&zn(e.cm,i,n),s)}function oi(e,t){var n=e.doc.sel.ranges,r=[];for(var i=0;i<n.length;i++){var s=t(n[i]);while(r.length&&pt(s.from,Fo(r).to)<=0){var o=r.pop();if(pt(o.from,s.from)<0){s.from=o.from;break}}r.push(s)}Bn(e,function(){for(var t=r.length-1;t>=0;t--)Qr(e.doc,"",r[t].from,r[t].to,"+delete");ni(e)})}function ui(e,t,n,r,i){function l(){var t=s+n;return t<e.first||t>=e.first+e.size?f=!1:(s=t,a=Us(e,t))}function c(e){var t=(i?Bu:ju)(a,o,n,!0);if(t==null){if(!!e||!l())return f=!1;i?o=(n<0?Lu:ku)(a):o=n<0?a.text.length:0}else o=t;return!0}var s=t.line,o=t.ch,u=n,a=Us(e,s),f=!0;if(r=="char")c();else if(r=="column")c(!0);else if(r=="word"||r=="group"){var h=null,p=r=="group",d=e.cm&&e.cm.getHelper(t,"wordChars");for(var v=!0;;v=!1){if(n<0&&!c(!v))break;var m=a.text.charAt(o)||"\n",g=$o(m,d)?"w":p&&m=="\n"?"n":!p||/\s/.test(m)?null:"p";p&&!v&&!g&&(g="s");if(h&&h!=g){n<0&&(n=1,c());break}g&&(h=g);if(n>0&&!c(!v))break}}var y=Ft(e,ht(s,o),u,!0);return f||(y.hitSide=!0),y}function ai(e,t,n,r){var i=e.doc,s=t.left,o;if(r=="page"){var u=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);o=t.top+n*(u-(n<0?1.5:.5)*xn(e.display))}else r=="line"&&(o=n>0?t.bottom+3:t.top-3);for(;;){var a=wn(e,s,o);if(!a.outside)break;if(n<0?o<=0:o>=i.height){a.hitSide=!0;break}o+=n*5}return a}function ci(e,t,n,r){S.defaults[e]=t,n&&(li[e]=r?function(e,t,r){r!=hi&&n(e,t,r)}:n)}function Si(e){var t=e.split(/-(?!$)/),e=t[t.length-1],n,r,i,s;for(var o=0;o<t.length-1;o++){var u=t[o];if(/^(cmd|meta|m)$/i.test(u))s=!0;else if(/^a(lt)?$/i.test(u))n=!0;else if(/^(c|ctrl|control)$/i.test(u))r=!0;else{if(!/^s(hift)$/i.test(u))throw new Error("Unrecognized modifier name: "+u);i=!0}}return n&&(e="Alt-"+e),r&&(e="Ctrl-"+e),s&&(e="Cmd-"+e),i&&(e="Shift-"+e),e}function Ci(e){return typeof e=="string"?Ei[e]:e}function Oi(e,t,n,r,i){if(r&&r.shared)return _i(e,t,n,r,i);if(e.cm&&!e.cm.curOp)return jn(e.cm,Oi)(e,t,n,r,i);var s=new Li(e,i),o=pt(t,n);r&&zo(r,s,!1);if(o>0||o==0&&s.clearWhenEmpty!==!1)return s;s.replacedWith&&(s.collapsed=!0,s.widgetNode=Go("span",[s.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||(s.widgetNode.ignoreEvents=!0),r.insertLeft&&(s.widgetNode.insertLeft=!0));if(s.collapsed){if(es(e,t.line,t,n,s)||t.line!=n.line&&es(e,n.line,t,n,s))throw new Error("Inserting collapsed marker partially overlapping an existing one");E=!0}s.addToHistory&&eo(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var u=t.line,a=e.cm,f;e.iter(u,n.line+1,function(e){a&&s.collapsed&&!a.options.lineWrapping&&ts(e)==a.display.maxLine&&(f=!0),s.collapsed&&u!=t.line&&Xs(e,0),Ii(e,new Bi(s,u==t.line?t.ch:null,u==n.line?n.ch:null)),++u}),s.collapsed&&e.iter(t.line,n.line+1,function(t){ss(e,t)&&Xs(t,0)}),s.clearOnEnter&&yo(s,"beforeCursorEnter",function(){s.clear()}),s.readOnly&&(w=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),s.collapsed&&(s.id=++Ai,s.atomic=!0);if(a){f&&(a.curOp.updateMaxLine=!0);if(s.collapsed)Un(a,t.line,n.line+1);else if(s.className||s.title||s.startStyle||s.endStyle)for(var l=t.line;l<=n.line;l++)zn(a,l,"text");s.atomic&&Bt(a.doc),So(a,"markerAdded",a,s)}return s}function _i(e,t,n,r,i){r=zo(r),r.shared=!1;var s=[Oi(e,t,n,r,i)],o=s[0],u=r.widgetNode;return qs(e,function(e){u&&(r.widgetNode=u.cloneNode(!0)),s.push(Oi(e,St(e,t),St(e,n),r,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;o=Fo(s)}),new Mi(s,o)}function Di(e){return e.findMarks(ht(e.first,0),e.clipPos(ht(e.lastLine())),function(e){return e.parent})}function Pi(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.find(),s=e.clipPos(i.from),o=e.clipPos(i.to);if(pt(s,o)){var u=Oi(e,s,o,r.primary,r.primary.type);r.markers.push(u),u.parent=r}}}function Hi(e){for(var t=0;t<e.length;t++){var n=e[t],r=[n.primary.doc];qs(n.primary.doc,function(e){r.push(e)});for(var i=0;i<n.markers.length;i++){var s=n.markers[i];qo(r,s.doc)==-1&&(s.parent=null,n.markers.splice(i--,1))}}}function Bi(e,t,n){this.marker=e,this.from=t,this.to=n}function ji(e,t){if(e)for(var n=0;n<e.length;++n){var r=e[n];if(r.marker==t)return r}}function Fi(e,t){for(var n,r=0;r<e.length;++r)e[r]!=t&&(n||(n=[])).push(e[r]);return n}function Ii(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function qi(e,t,n){if(e)for(var r=0,i;r<e.length;++r){var s=e[r],o=s.marker,u=s.from==null||(o.inclusiveLeft?s.from<=t:s.from<t);if(u||s.from==t&&o.type=="bookmark"&&(!n||!s.marker.insertLeft)){var a=s.to==null||(o.inclusiveRight?s.to>=t:s.to>t);(i||(i=[])).push(new Bi(o,s.from,a?null:s.to))}}return i}function Ri(e,t,n){if(e)for(var r=0,i;r<e.length;++r){var s=e[r],o=s.marker,u=s.to==null||(o.inclusiveRight?s.to>=t:s.to>t);if(u||s.from==t&&o.type=="bookmark"&&(!n||s.marker.insertLeft)){var a=s.from==null||(o.inclusiveLeft?s.from<=t:s.from<t);(i||(i=[])).push(new Bi(o,a?null:s.from-t,s.to==null?null:s.to-t))}}return i}function Ui(e,t){var n=Tt(e,t.from.line)&&Us(e,t.from.line).markedSpans,r=Tt(e,t.to.line)&&Us(e,t.to.line).markedSpans;if(!n&&!r)return null;var i=t.from.ch,s=t.to.ch,o=pt(t.from,t.to)==0,u=qi(n,i,o),a=Ri(r,s,o),f=t.text.length==1,l=Fo(t.text).length+(f?i:0);if(u)for(var c=0;c<u.length;++c){var h=u[c];if(h.to==null){var p=ji(a,h.marker);p?f&&(h.to=p.to==null?null:p.to+l):h.to=i}}if(a)for(var c=0;c<a.length;++c){var h=a[c];h.to!=null&&(h.to+=l);if(h.from==null){var p=ji(u,h.marker);p||(h.from=l,f&&(u||(u=[])).push(h))}else h.from+=l,f&&(u||(u=[])).push(h)}u&&(u=zi(u)),a&&a!=u&&(a=zi(a));var d=[u];if(!f){var v=t.text.length-2,m;if(v>0&&u)for(var c=0;c<u.length;++c)u[c].to==null&&(m||(m=[])).push(new Bi(u[c].marker,null,null));for(var c=0;c<v;++c)d.push(m);d.push(a)}return d}function zi(e){for(var t=0;t<e.length;++t){var n=e[t];n.from!=null&&n.from==n.to&&n.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Wi(e,t){var n=oo(e,t),r=Ui(e,t);if(!n)return r;if(!r)return n;for(var i=0;i<n.length;++i){var s=n[i],o=r[i];if(s&&o)e:for(var u=0;u<o.length;++u){var a=o[u];for(var f=0;f<s.length;++f)if(s[f].marker==a.marker)continue e;s.push(a)}else o&&(n[i]=o)}return n}function Xi(e,t,n){var r=null;e.iter(t.line,n.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var n=e.markedSpans[t].marker;n.readOnly&&(!r||qo(r,n)==-1)&&(r||(r=[])).push(n)}});if(!r)return null;var i=[{from:t,to:n}];for(var s=0;s<r.length;++s){var o=r[s],u=o.find(0);for(var a=0;a<i.length;++a){var f=i[a];if(pt(f.to,u.from)<0||pt(f.from,u.to)>0)continue;var l=[a,1],c=pt(f.from,u.from),h=pt(f.to,u.to);(c<0||!o.inclusiveLeft&&!c)&&l.push({from:f.from,to:u.from}),(h>0||!o.inclusiveRight&&!h)&&l.push({from:u.to,to:f.to}),i.splice.apply(i,l),a+=l.length-1}}return i}function Vi(e){var t=e.markedSpans;if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}function $i(e,t){if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.attachLine(e);e.markedSpans=t}function Ji(e){return e.inclusiveLeft?-1:0}function Ki(e){return e.inclusiveRight?1:0}function Qi(e,t){var n=e.lines.length-t.lines.length;if(n!=0)return n;var r=e.find(),i=t.find(),s=pt(r.from,i.from)||Ji(e)-Ji(t);if(s)return-s;var o=pt(r.to,i.to)||Ki(e)-Ki(t);return o?o:t.id-e.id}function Gi(e,t){var n=E&&e.markedSpans,r;if(n)for(var i,s=0;s<n.length;++s)i=n[s],i.marker.collapsed&&(t?i.from:i.to)==null&&(!r||Qi(r,i.marker)<0)&&(r=i.marker);return r}function Yi(e){return Gi(e,!0)}function Zi(e){return Gi(e,!1)}function es(e,t,n,r,i){var s=Us(e,t),o=E&&s.markedSpans;if(o)for(var u=0;u<o.length;++u){var a=o[u];if(!a.marker.collapsed)continue;var f=a.marker.find(0),l=pt(f.from,n)||Ji(a.marker)-Ji(i),c=pt(f.to,r)||Ki(a.marker)-Ki(i);if(l>=0&&c<=0||l<=0&&c>=0)continue;if(l<=0&&(pt(f.to,n)>0||a.marker.inclusiveRight&&i.inclusiveLeft)||l>=0&&(pt(f.from,r)<0||a.marker.inclusiveLeft&&i.inclusiveRight))return!0}}function ts(e){var t;while(t=Yi(e))e=t.find(-1,!0).line;return e}function ns(e){var t,n;while(t=Zi(e))e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function rs(e,t){var n=Us(e,t),r=ts(n);return n==r?t:Vs(r)}function is(e,t){if(t>e.lastLine())return t;var n=Us(e,t),r;if(!ss(e,n))return t;while(r=Zi(n))n=r.find(1,!0).line;return Vs(n)+1}function ss(e,t){var n=E&&t.markedSpans;if(n)for(var r,i=0;i<n.length;++i){r=n[i];if(!r.marker.collapsed)continue;if(r.from==null)return!0;if(r.marker.widgetNode)continue;if(r.from==0&&r.marker.inclusiveLeft&&os(e,t,r))return!0}}function os(e,t,n){if(n.to==null){var r=n.marker.find(1,!0);return os(e,r.line,ji(r.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length)return!0;for(var i,s=0;s<t.markedSpans.length;++s){i=t.markedSpans[s];if(i.marker.collapsed&&!i.marker.widgetNode&&i.from==n.to&&(i.to==null||i.to!=n.from)&&(i.marker.inclusiveLeft||n.marker.inclusiveRight)&&os(e,t,i))return!0}}function as(e,t,n){Js(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&ti(e,null,n)}function fs(e){if(e.height!=null)return e.height;if(!tu(document.body,e.node)){var t="position: relative;";e.coverGutter&&(t+="margin-left: -"+e.cm.getGutterElement().offsetWidth+"px;"),eu(e.cm.display.measure,Go("div",[e.node],null,t))}return e.height=e.node.offsetHeight}function ls(e,t,n,r){var i=new us(e,n,r);return i.noHScroll&&(e.display.alignWidgets=!0),si(e.doc,t,"widget",function(t){var n=t.widgets||(t.widgets=[]);i.insertAt==null?n.push(i):n.splice(Math.min(n.length-1,Math.max(0,i.insertAt)),0,i),i.line=t;if(!ss(e.doc,t)){var r=Js(t)<e.doc.scrollTop;Xs(t,t.height+fs(i)),r&&ti(e,null,i.height),e.curOp.forceUpdate=!0}return!0}),i}function hs(e,t,n,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),Vi(e),$i(e,n);var i=r?r(e):1;i!=e.height&&Xs(e,i)}function ps(e){e.parent=null,Vi(e)}function ds(e,t){if(e)for(;;){var n=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;e=e.slice(0,n.index)+e.slice(n.index+n[0].length);var r=n[1]?"bgClass":"textClass";t[r]==null?t[r]=n[2]:(new RegExp("(?:^|s)"+n[2]+"(?:$|s)")).test(t[r])||(t[r]+=" "+n[2])}return e}function vs(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var n=S.innerMode(e,t);if(n.mode.blankLine)return n.mode.blankLine(n.state)}function ms(e,t,n,r){for(var i=0;i<10;i++){r&&(r[0]=S.innerMode(e,n).mode);var s=e.token(t,n);if(t.pos>t.start)return s}throw new Error("Mode "+e.name+" failed to advance stream.")}function gs(e,t,n,r){function i(e){return{start:l.start,end:l.pos,string:l.current(),type:u||null,state:e?yi(s.mode,f):f}}var s=e.doc,o=s.mode,u;t=St(s,t);var a=Us(s,t.line),f=Jt(e,t.line,n),l=new ki(a.text,e.options.tabSize),c;r&&(c=[]);while((r||l.pos<t.ch)&&!l.eol())l.start=l.pos,u=ms(o,l,f),r&&c.push(i(!0));return r?c:i()}function ys(e,t,n,r,i,s,o){var u=n.flattenSpans;u==null&&(u=e.options.flattenSpans);var a=0,f=null,l=new ki(t,e.options.tabSize),c,h=e.options.addModeClass&&[null];t==""&&ds(vs(n,r),s);while(!l.eol()){l.pos>e.options.maxHighlightLength?(u=!1,o&&Es(e,t,r,l.pos),l.pos=t.length,c=null):c=ds(ms(n,l,r,h),s);if(h){var p=h[0].name;p&&(c="m-"+(c?p+" "+c:p))}if(!u||f!=c)a<l.start&&i(l.start,f),a=l.start,f=c;l.start=l.pos}while(a<l.pos){var d=Math.min(l.pos,a+5e4);i(d,f),a=d}}function bs(e,t,n,r){var i=[e.state.modeGen],s={};ys(e,t.text,e.doc.mode,n,function(e,t){i.push(e,t)},s,r);for(var o=0;o<e.state.overlays.length;++o){var u=e.state.overlays[o],a=1,f=0;ys(e,t.text,u.mode,!0,function(e,t){var n=a;while(f<e){var r=i[a];r>e&&i.splice(a,1,e,i[a+1],r),a+=2,f=Math.min(e,r)}if(!t)return;if(u.opaque)i.splice(n,a-n,e,"cm-overlay "+t),a=n+2;else for(;n<a;n+=2){var s=i[n+1];i[n+1]=(s?s+" ":"")+"cm-overlay "+t}},s)}return{styles:i,classes:s.bgClass||s.textClass?s:null}}function ws(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=bs(e,t,t.stateAfter=Jt(e,Vs(t)));t.styles=r.styles,r.classes?t.styleClasses=r.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.frontier&&e.doc.frontier++}return t.styles}function Es(e,t,n,r){var i=e.doc.mode,s=new ki(t,e.options.tabSize);s.start=s.pos=r||0,t==""&&vs(i,n);while(!s.eol()&&s.pos<=e.options.maxHighlightLength)ms(i,s,n),s.start=s.pos}function Ts(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?xs:Ss;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Ns(e,t){var n=Go("span",null,null,s?"padding-right: .1px":null),i={pre:Go("pre",[n]),content:n,col:0,pos:0,cm:e};t.measure={};for(var o=0;o<=(t.rest?t.rest.length:0);o++){var u=o?t.rest[o-1]:t.line,a;i.pos=0,i.addToken=ks,(r||s)&&e.getOption("lineWrapping")&&(i.addToken=Ls(i.addToken)),gu(e.display.measure)&&(a=Ks(u))&&(i.addToken=As(i.addToken,a)),i.map=[];var f=t!=e.display.externalMeasured&&Vs(u);Ms(u,i,ws(e,u,f)),u.styleClasses&&(u.styleClasses.bgClass&&(i.bgClass=ou(u.styleClasses.bgClass,i.bgClass||"")),u.styleClasses.textClass&&(i.textClass=ou(u.styleClasses.textClass,i.textClass||""))),i.map.length==0&&i.map.push(0,0,i.content.appendChild(vu(e.display.measure))),o==0?(t.measure.map=i.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(i.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return s&&/\bcm-tab\b/.test(i.content.lastChild.className)&&(i.content.className="cm-tab-wrap-hack"),wo(e,"renderLine",e,t.line,i.pre),i.pre.className&&(i.textClass=ou(i.pre.className,i.textClass||"")),i}function Cs(e){var t=Go("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t}function ks(e,t,n,s,o,u){if(!t)return;var a=e.cm.options.specialChars,f=!1;if(!a.test(t)){e.col+=t.length;var l=document.createTextNode(t);e.map.push(e.pos,e.pos+t.length,l),r&&i<9&&(f=!0),e.pos+=t.length}else{var l=document.createDocumentFragment(),c=0;for(;;){a.lastIndex=c;var h=a.exec(t),p=h?h.index-c:t.length-c;if(p){var d=document.createTextNode(t.slice(c,c+p));r&&i<9?l.appendChild(Go("span",[d])):l.appendChild(d),e.map.push(e.pos,e.pos+p,d),e.col+=p,e.pos+=p}if(!h)break;c+=p+1;if(h[0]=="	"){var v=e.cm.options.tabSize,m=v-e.col%v,d=l.appendChild(Go("span",jo(m),"cm-tab"));e.col+=m}else{var d=e.cm.options.specialCharPlaceholder(h[0]);r&&i<9?l.appendChild(Go("span",[d])):l.appendChild(d),e.col+=1}e.map.push(e.pos,e.pos+1,d),e.pos++}}if(n||s||o||f){var g=n||"";s&&(g+=s),o&&(g+=o);var y=Go("span",[l],g);return u&&(y.title=u),e.content.appendChild(y)}e.content.appendChild(l)}function Ls(e){function t(e){var t=" ";for(var n=0;n<e.length-2;++n)t+=n%2?" ":" ";return t+=" ",t}return function(n,r,i,s,o,u){e(n,r.replace(/ {3,}/g,t),i,s,o,u)}}function As(e,t){return function(n,r,i,s,o,u){i=i?i+" cm-force-border":"cm-force-border";var a=n.pos,f=a+r.length;for(;;){for(var l=0;l<t.length;l++){var c=t[l];if(c.to>a&&c.from<=a)break}if(c.to>=f)return e(n,r,i,s,o,u);e(n,r.slice(0,c.to-a),i,s,null,u),s=null,r=r.slice(c.to-a),a=c.to}}}function Os(e,t,n,r){var i=!r&&n.widgetNode;i&&(e.map.push(e.pos,e.pos+t,i),e.content.appendChild(i)),e.pos+=t}function Ms(e,t,n){var r=e.markedSpans,i=e.text,s=0;if(!r){for(var o=1;o<n.length;o+=2)t.addToken(t,i.slice(s,s=n[o]),Ts(n[o+1],t.cm.options));return}var u=i.length,a=0,o=1,f="",l,c=0,h,p,d,v,m;for(;;){if(c==a){h=p=d=v="",m=null,c=Infinity;var g=[];for(var y=0;y<r.length;++y){var b=r[y],w=b.marker;b.from<=a&&(b.to==null||b.to>a)?(b.to!=null&&c>b.to&&(c=b.to,p=""),w.className&&(h+=" "+w.className),w.startStyle&&b.from==a&&(d+=" "+w.startStyle),w.endStyle&&b.to==c&&(p+=" "+w.endStyle),w.title&&!v&&(v=w.title),w.collapsed&&(!m||Qi(m.marker,w)<0)&&(m=b)):b.from>a&&c>b.from&&(c=b.from),w.type=="bookmark"&&b.from==a&&w.widgetNode&&g.push(w)}if(m&&(m.from||0)==a){Os(t,(m.to==null?u+1:m.to)-a,m.marker,m.from==null);if(m.to==null)return}if(!m&&g.length)for(var y=0;y<g.length;++y)Os(t,0,g[y])}if(a>=u)break;var E=Math.min(u,c);for(;;){if(f){var S=a+f.length;if(!m){var x=S>E?f.slice(0,E-a):f;t.addToken(t,x,l?l+h:h,d,a+x.length==c?p:"",v)}if(S>=E){f=f.slice(E-a),a=E;break}a=S,d=""}f=i.slice(s,s=n[o++]),l=Ts(n[o++],t.cm.options)}}}function _s(e,t){return t.from.ch==0&&t.to.ch==0&&Fo(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Ds(e,t,n,r){function i(e){return n?n[e]:null}function s(e,n,i){hs(e,n,i,r),So(e,"change",e,t)}var o=t.from,u=t.to,a=t.text,f=Us(e,o.line),l=Us(e,u.line),c=Fo(a),h=i(a.length-1),p=u.line-o.line;if(_s(e,t)){for(var d=0,v=[];d<a.length-1;++d)v.push(new cs(a[d],i(d),r));s(l,l.text,h),p&&e.remove(o.line,p),v.length&&e.insert(o.line,v)}else if(f==l)if(a.length==1)s(f,f.text.slice(0,o.ch)+c+f.text.slice(u.ch),h);else{for(var v=[],d=1;d<a.length-1;++d)v.push(new cs(a[d],i(d),r));v.push(new cs(c+f.text.slice(u.ch),h,r)),s(f,f.text.slice(0,o.ch)+a[0],i(0)),e.insert(o.line+1,v)}else if(a.length==1)s(f,f.text.slice(0,o.ch)+a[0]+l.text.slice(u.ch),i(0)),e.remove(o.line+1,p);else{s(f,f.text.slice(0,o.ch)+a[0],i(0)),s(l,c+l.text.slice(u.ch),h);for(var d=1,v=[];d<a.length-1;++d)v.push(new cs(a[d],i(d),r));p>1&&e.remove(o.line+1,p-1),e.insert(o.line+1,v)}So(e,"change",e,t)}function Ps(e){this.lines=e,this.parent=null;for(var t=0,n=0;t<e.length;++t)e[t].parent=this,n+=e[t].height;this.height=n}function Hs(e){this.children=e;var t=0,n=0;for(var r=0;r<e.length;++r){var i=e[r];t+=i.chunkSize(),n+=i.height,i.parent=this}this.size=t,this.height=n,this.parent=null}function qs(e,t,n){function r(e,i,s){if(e.linked)for(var o=0;o<e.linked.length;++o){var u=e.linked[o];if(u.doc==i)continue;var a=s&&u.sharedHist;if(n&&!a)continue;t(u.doc,a),r(u.doc,e,a)}}r(e,null,!0)}function Rs(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,L(e),T(e),e.options.lineWrapping||P(e),e.options.mode=t.modeOption,Un(e)}function Us(e,t){t-=e.first;if(t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],s=i.chunkSize();if(t<s){n=i;break}t-=s}return n.lines[t]}function zs(e,t,n){var r=[],i=t.line;return e.iter(t.line,n.line+1,function(e){var s=e.text;i==n.line&&(s=s.slice(0,n.ch)),i==t.line&&(s=s.slice(t.ch)),r.push(s),++i}),r}function Ws(e,t,n){var r=[];return e.iter(t,n,function(e){r.push(e.text)}),r}function Xs(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function Vs(e){if(e.parent==null)return null;var t=e.parent,n=qo(t.lines,e);for(var r=t.parent;r;t=r,r=r.parent)for(var i=0;;++i){if(r.children[i]==t)break;n+=r.children[i].chunkSize()}return n+t.first}function $s(e,t){var n=e.first;e:do{for(var r=0;r<e.children.length;++r){var i=e.children[r],s=i.height;if(t<s){e=i;continue e}t-=s,n+=i.chunkSize()}return n}while(!e.lines);for(var r=0;r<e.lines.length;++r){var o=e.lines[r],u=o.height;if(t<u)break;t-=u}return n+r}function Js(e){e=ts(e);var t=0,n=e.parent;for(var r=0;r<n.lines.length;++r){var i=n.lines[r];if(i==e)break;t+=i.height}for(var s=n.parent;s;n=s,s=n.parent)for(var r=0;r<s.children.length;++r){var o=s.children[r];if(o==n)break;t+=o.height}return t}function Ks(e){var t=e.order;return t==null&&(t=e.order=Fu(e.text)),t}function Qs(e){this.done=[],this.undone=[],this.undoDepth=Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Gs(e,t){var n={from:dt(t.from),to:Fr(t),text:zs(e,t.from,t.to)};return io(e,n,t.from.line,t.to.line+1),qs(e,function(e){io(e,n,t.from.line,t.to.line+1)},!0),n}function Ys(e){while(e.length){var t=Fo(e);if(!t.ranges)break;e.pop()}}function Zs(e,t){if(t)return Ys(e.done),Fo(e.done);if(e.done.length&&!Fo(e.done).ranges)return Fo(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),Fo(e.done)}function eo(e,t,n,r){var i=e.history;i.undone.length=0;var s=+(new Date),o;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&e.cm&&i.lastModTime>s-e.cm.options.historyEventDelay||t.origin.charAt(0)=="*"))&&(o=Zs(i,i.lastOp==r))){var u=Fo(o.changes);pt(t.from,t.to)==0&&pt(t.from,u.to)==0?u.to=Fr(t):o.changes.push(Gs(e,t))}else{var a=Fo(i.done);(!a||!a.ranges)&&ro(e.sel,i.done),o={changes:[Gs(e,t)],generation:i.generation},i.done.push(o);while(i.done.length>i.undoDepth)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=s,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,u||wo(e,"historyAdded")}function to(e,t,n,r){var i=t.charAt(0);return i=="*"||i=="+"&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function no(e,t,n,r){var i=e.history,s=r&&r.origin;n==i.lastSelOp||s&&i.lastSelOrigin==s&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==s||to(e,s,Fo(i.done),t))?i.done[i.done.length-1]=t:ro(t,i.done),i.lastSelTime=+(new Date),i.lastSelOrigin=s,i.lastSelOp=n,r&&r.clearRedo!==!1&&Ys(i.undone)}function ro(e,t){var n=Fo(t);n&&n.ranges&&n.equals(e)||t.push(e)}function io(e,t,n,r){var i=t["spans_"+e.id],s=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(n){n.markedSpans&&((i||(i=t["spans_"+e.id]={}))[s]=n.markedSpans),++s})}function so(e){if(!e)return null;for(var t=0,n;t<e.length;++t)e[t].marker.explicitlyCleared?n||(n=e.slice(0,t)):n&&n.push(e[t]);return n?n.length?n:null:e}function oo(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var r=0,i=[];r<t.text.length;++r)i.push(so(n[r]));return i}function uo(e,t,n){for(var r=0,i=[];r<e.length;++r){var s=e[r];if(s.ranges){i.push(n?gt.prototype.deepCopy.call(s):s);continue}var o=s.changes,u=[];i.push({changes:u});for(var a=0;a<o.length;++a){var f=o[a],l;u.push({from:f.from,to:f.to,text:f.text});if(t)for(var c in f)(l=c.match(/^spans_(\d+)$/))&&qo(t,Number(l[1]))>-1&&(Fo(u)[c]=f[c],delete f[c])}}return i}function ao(e,t,n,r){n<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function fo(e,t,n,r){for(var i=0;i<e.length;++i){var s=e[i],o=!0;if(s.ranges){s.copied||(s=e[i]=s.deepCopy(),s.copied=!0);for(var u=0;u<s.ranges.length;u++)ao(s.ranges[u].anchor,t,n,r),ao(s.ranges[u].head,t,n,r);continue}for(var u=0;u<s.changes.length;++u){var a=s.changes[u];if(n<a.from.line)a.from=ht(a.from.line+r,a.from.ch),a.to=ht(a.to.line+r,a.to.ch);else if(t<=a.to.line){o=!1;break}}o||(e.splice(0,i+1),i=0)}}function lo(e,t){var n=t.from.line,r=t.to.line,i=t.text.length-(r-n)-1;fo(e.done,n,r,i),fo(e.undone,n,r,i)}function po(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==0}function mo(e){return e.target||e.srcElement}function go(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),v&&e.ctrlKey&&t==1&&(t=3),t}function So(e,t){function s(e){return function(){e.apply(null,r)}}var n=e._handlers&&e._handlers[t];if(!n)return;var r=Array.prototype.slice.call(arguments,2),i;Nn?i=Nn.delayedCallbacks:Eo?i=Eo:(i=Eo=[],setTimeout(xo,0));for(var o=0;o<n.length;++o)i.push(s(n[o]))}function xo(){var e=Eo;Eo=null;for(var t=0;t<e.length;++t)e[t]()}function To(e,t,n){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),wo(e,n||t.type,e,t),po(t)||t.codemirrorIgnore}function No(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t)return;var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]);for(var r=0;r<t.length;++r)qo(n,t[r])==-1&&n.push(t[r])}function Co(e,t){var n=e._handlers&&e._handlers[t];return n&&n.length>0}function ko(e){e.prototype.on=function(e,t){yo(this,e,t)},e.prototype.off=function(e,t){bo(this,e,t)}}function Do(){this.id=null}function Ho(e,t,n){for(var r=0,i=0;;){var s=e.indexOf("	",r);s==-1&&(s=e.length);var o=s-r;if(s==e.length||i+o>=t)return r+Math.min(o,t-i);i+=s-r,i+=n-i%n,r=s+1;if(i>=t)return r}}function jo(e){while(Bo.length<=e)Bo.push(Fo(Bo)+" ");return Bo[e]}function Fo(e){return e[e.length-1]}function qo(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}function Ro(e,t){var n=[];for(var r=0;r<e.length;r++)n[r]=t(e[r],r);return n}function Uo(e,t){var n;if(Object.create)n=Object.create(e);else{var r=function(){};r.prototype=e,n=new r}return t&&zo(t,n),n}function zo(e,t,n){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(n!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function Wo(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function $o(e,t){return t?t.source.indexOf("\\w")>-1&&Vo(e)?!0:t.test(e):Vo(e)}function Jo(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Qo(e){return e.charCodeAt(0)>=768&&Ko.test(e)}function Go(e,t,n,r){var i=document.createElement(e);n&&(i.className=n),r&&(i.style.cssText=r);if(typeof t=="string")i.appendChild(document.createTextNode(t));else if(t)for(var s=0;s<t.length;++s)i.appendChild(t[s]);return i}function Zo(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function eu(e,t){return Zo(e).appendChild(t)}function tu(e,t){if(e.contains)return e.contains(t);while(t=t.parentNode)if(t==e)return!0}function nu(){return document.activeElement}function ru(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function ou(e,t){var n=e.split(" ");for(var r=0;r<n.length;r++)n[r]&&!ru(n[r]).test(t)&&(t+=" "+n[r]);return t}function uu(e){if(!document.body.getElementsByClassName)return;var t=document.body.getElementsByClassName("CodeMirror");for(var n=0;n<t.length;n++){var r=t[n].CodeMirror;r&&e(r)}}function fu(){if(au)return;lu(),au=!0}function lu(){var e;yo(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,hu=null,uu(ir)},100))}),yo(window,"blur",function(){uu(Hr)})}function pu(e){if(hu!=null)return hu;var t=Go("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");return eu(e,t),t.offsetWidth&&(hu=t.offsetHeight-t.clientHeight),hu||0}function vu(e){if(du==null){var t=Go("span","​");eu(e,Go("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(du=t.offsetWidth<=1&&t.offsetHeight>2&&!(r&&i<8))}return du?Go("span","​"):Go("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px")}function gu(e){if(mu!=null)return mu;var t=eu(e,document.createTextNode("AخA")),n=Yo(t,0,1).getBoundingClientRect();if(!n||n.left==n.right)return!1;var r=Yo(t,1,2).getBoundingClientRect();return mu=r.right-n.right<3}function Su(e){if(Eu!=null)return Eu;var t=eu(e,Go("span","x")),n=t.getBoundingClientRect(),r=Yo(t,0,1).getBoundingClientRect();return Eu=Math.abs(n.left-r.left)>1}function Tu(e,t,n,r){if(!e)return r(t,n,"ltr");var i=!1;for(var s=0;s<e.length;++s){var o=e[s];if(o.from<n&&o.to>t||t==n&&o.to==t)r(Math.max(o.from,t),Math.min(o.to,n),o.level==1?"rtl":"ltr"),i=!0}i||r(t,n,"ltr")}function Nu(e){return e.level%2?e.to:e.from}function Cu(e){return e.level%2?e.from:e.to}function ku(e){var t=Ks(e);return t?Nu(t[0]):0}function Lu(e){var t=Ks(e);return t?Cu(Fo(t)):e.text.length}function Au(e,t){var n=Us(e.doc,t),r=ts(n);r!=n&&(t=Vs(r));var i=Ks(r),s=i?i[0].level%2?Lu(r):ku(r):0;return ht(t,s)}function Ou(e,t){var n,r=Us(e.doc,t);while(n=Zi(r))r=n.find(1,!0).line,t=null;var i=Ks(r),s=i?i[0].level%2?ku(r):Lu(r):r.text.length;return ht(t==null?Vs(r):t,s)}function Mu(e,t){var n=Au(e,t.line),r=Us(e.doc,n.line),i=Ks(r);if(!i||i[0].level==0){var s=Math.max(0,r.text.search(/\S/)),o=t.line==n.line&&t.ch<=s&&t.ch;return ht(n.line,o?0:s)}return n}function _u(e,t,n){var r=e[0].level;return t==r?!0:n==r?!1:t<n}function Pu(e,t){Du=null;for(var n=0,r;n<e.length;++n){var i=e[n];if(i.from<t&&i.to>t)return n;if(i.from==t||i.to==t){if(r!=null)return _u(e,i.level,e[r].level)?(i.from!=i.to&&(Du=r),n):(i.from!=i.to&&(Du=n),r);r=n}}return r}function Hu(e,t,n,r){if(!r)return t+n;do t+=n;while(t>0&&Qo(e.text.charAt(t)));return t}function Bu(e,t,n,r){var i=Ks(e);if(!i)return ju(e,t,n,r);var s=Pu(i,t),o=i[s],u=Hu(e,t,o.level%2?-n:n,r);for(;;){if(u>o.from&&u<o.to)return u;if(u==o.from||u==o.to)return Pu(i,u)==s?u:(o=i[s+=n],n>0==o.level%2?o.to:o.from);o=i[s+=n];if(!o)return null;n>0==o.level%2?u=Hu(e,o.to,-1,r):u=Hu(e,o.from,1,r)}}function ju(e,t,n,r){var i=t+n;if(r)while(i>0&&Qo(e.text.charAt(i)))i+=n;return i<0||i>e.text.length?null:i}var e=/gecko\/\d/i.test(navigator.userAgent),t=/MSIE \d/.test(navigator.userAgent),n=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),r=t||n,i=r&&(t?document.documentMode||6:n[1]),s=/WebKit\//.test(navigator.userAgent),o=s&&/Qt\/\d+\.\d+/.test(navigator.userAgent),u=/Chrome\//.test(navigator.userAgent),a=/Opera\//.test(navigator.userAgent),f=/Apple Computer/.test(navigator.vendor),l=/KHTML\//.test(navigator.userAgent),c=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),h=/PhantomJS/.test(navigator.userAgent),p=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),d=p||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),v=p||/Mac/.test(navigator.platform),m=/win/i.test(navigator.platform),g=a&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);g&&(g=Number(g[1])),g&&g>=15&&(a=!1,s=!0);var y=v&&(o||a&&(g==null||g<12.11)),b=e||r&&i>=9,w=!1,E=!1,ht=S.Pos=function(e,t){if(!(this instanceof ht))return new ht(e,t);this.line=e,this.ch=t},pt=S.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch};gt.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var n=this.ranges[t],r=e.ranges[t];if(pt(n.anchor,r.anchor)!=0||pt(n.head,r.head)!=0)return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new yt(dt(this.ranges[t].anchor),dt(this.ranges[t].head));return new gt(e,this.primIndex)},somethingSelected:function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},contains:function(e,t){t||(t=e);for(var n=0;n<this.ranges.length;n++){var r=this.ranges[n];if(pt(t,r.from())>=0&&pt(e,r.to())<=0)return n}return-1}},yt.prototype={from:function(){return mt(this.anchor,this.head)},to:function(){return vt(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var on={left:0,right:0,top:0,bottom:0},Sn,Nn=null,Cn=0,Gn=null,ar,fr,vr=0,wr=0,Er=null;r?Er=-0.53:e?Er=15:u?Er=-0.7:f&&(Er=-1/3);var Nr=new Do,Ar=null,Fr=S.changeEnd=function(e){return e.text?ht(e.from.line+e.text.length-1,Fo(e.text).length+(e.text.length==1?e.from.ch:0)):e.to};S.prototype={constructor:S,focus:function(){window.focus(),er(this),Qn(this)},setOption:function(e,t){var n=this.options,r=n[e];if(n[e]==t&&e!="mode")return;n[e]=t,li.hasOwnProperty(e)&&jn(this,li[e])(this,t,r)},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Ci(e))},removeKeyMap:function(e){var t=this.state.keyMaps;for(var n=0;n<t.length;++n)if(t[n]==e||t[n].name==e)return t.splice(n,1),!0},addOverlay:Fn(function(e,t){var n=e.token?e:S.getMode(this.options,e);if(n.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:n,modeSpec:e,opaque:t&&t.opaque}),this.state.modeGen++,Un(this)}),removeOverlay:Fn(function(e){var t=this.state.overlays;for(var n=0;n<t.length;++n){var r=t[n].modeSpec;if(r==e||typeof e=="string"&&r.name==e){t.splice(n,1),this.state.modeGen++,Un(this);return}}}),indentLine:Fn(function(e,t,n){typeof t!="string"&&typeof t!="number"&&(t==null?t=this.options.smartIndent?"smart":"prev":t=t?"add":"subtract"),Tt(this.doc,e)&&ii(this,e,t,n)}),indentSelection:Fn(function(e){var t=this.doc.sel.ranges,n=-1;for(var r=0;r<t.length;r++){var i=t[r];if(!i.empty()){var s=i.from(),o=i.to(),u=Math.max(n,s.line);n=Math.min(this.lastLine(),o.line-(o.ch?0:1))+1;for(var a=u;a<n;++a)ii(this,a,e);var f=this.doc.sel.ranges;s.ch==0&&t.length==f.length&&f[r].from().ch>0&&At(this.doc,r,new yt(s,f[r].to()),Oo)}else i.head.line>n&&(ii(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&ni(this))}}),getTokenAt:function(e,t){return gs(this,e,t)},getLineTokens:function(e,t){return gs(this,ht(e),t,!0)},getTokenTypeAt:function(e){e=St(this.doc,e);var t=ws(this,Us(this.doc,e.line)),n=0,r=(t.length-1)/2,i=e.ch,s;if(i==0)s=t[2];else for(;;){var o=n+r>>1;if((o?t[o*2-1]:0)>=i)r=o;else{if(!(t[o*2+1]<i)){s=t[o*2+2];break}n=o+1}}var u=s?s.indexOf("cm-overlay "):-1;return u<0?s:u==0?null:s.slice(0,u-1)},getModeAt:function(e){var t=this.doc.mode;return t.innerMode?S.innerMode(t,this.getTokenAt(e).state).mode:t},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var n=[];if(!gi.hasOwnProperty(t))return gi;var r=gi[t],i=this.getModeAt(e);if(typeof i[t]=="string")r[i[t]]&&n.push(r[i[t]]);else if(i[t])for(var s=0;s<i[t].length;s++){var o=r[i[t][s]];o&&n.push(o)}else i.helperType&&r[i.helperType]?n.push(r[i.helperType]):r[i.name]&&n.push(r[i.name]);for(var s=0;s<r._global.length;s++){var u=r._global[s];u.pred(i,this)&&qo(n,u.val)==-1&&n.push(u.val)}return n},getStateAfter:function(e,t){var n=this.doc;return e=Et(n,e==null?n.first+n.size-1:e),Jt(this,e+1,t)},cursorCoords:function(e,t){var n,r=this.doc.sel.primary();return e==null?n=r.head:typeof e=="object"?n=St(this.doc,e):n=e?r.from():r.to(),gn(this,n,t||"page")},charCoords:function(e,t){return mn(this,St(this.doc,e),t||"page")},coordsChar:function(e,t){return e=vn(this,e,t||"page"),wn(this,e.left,e.top)},lineAtHeight:function(e,t){return e=vn(this,{top:e,left:0},t||"page").top,$s(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var n=!1,r=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>r&&(e=r,n=!0);var i=Us(this.doc,e);return dn(this,i,{top:0,left:0},t||"page").top+(n?this.doc.height-Js(i):0)},defaultTextHeight:function(){return xn(this.display)},defaultCharWidth:function(){return Tn(this.display)},setGutterMarker:Fn(function(e,t,n){return si(this.doc,e,"gutter",function(e){var r=e.gutterMarkers||(e.gutterMarkers={});return r[t]=n,!n&&Jo(r)&&(e.gutterMarkers=null),!0})}),clearGutter:Fn(function(e){var t=this,n=t.doc,r=n.first;n.iter(function(n){n.gutterMarkers&&n.gutterMarkers[e]&&(n.gutterMarkers[e]=null,zn(t,r,"gutter"),Jo(n.gutterMarkers)&&(n.gutterMarkers=null)),++r})}),addLineWidget:Fn(function(e,t,n){return ls(this,e,t,n)}),removeLineWidget:function(e){e.clear()},lineInfo:function(e){if(typeof e=="number"){if(!Tt(this.doc,e))return null;var t=e;e=Us(this.doc,e);if(!e)return null}else{var t=Vs(e);if(t==null)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var s=this.display;e=gn(this,St(this.doc,e));var o=e.bottom,u=e.left;t.style.position="absolute",s.sizer.appendChild(t);if(r=="over")o=e.top;else if(r=="above"||r=="near"){var a=Math.max(s.wrapper.clientHeight,this.doc.height),f=Math.max(s.sizer.clientWidth,s.lineSpace.clientWidth);(r=="above"||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?o=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(o=e.bottom),u+t.offsetWidth>f&&(u=f-t.offsetWidth)}t.style.top=o+"px",t.style.left=t.style.right="",i=="right"?(u=s.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):(i=="left"?u=0:i=="middle"&&(u=(s.sizer.clientWidth-t.offsetWidth)/2),t.style.left=u+"px"),n&&Zr(this,u,o,u+t.offsetWidth,o+t.offsetHeight)},triggerOnKeyDown:Fn(Or),triggerOnKeyPress:Fn(Dr),triggerOnKeyUp:_r,execCommand:function(e){if(wi.hasOwnProperty(e))return wi[e](this)},findPosH:function(e,t,n,r){var i=1;t<0&&(i=-1,t=-t);for(var s=0,o=St(this.doc,e);s<t;++s){o=ui(this.doc,o,i,n,r);if(o.hitSide)break}return o},moveH:Fn(function(e,t){var n=this;n.extendSelectionsBy(function(r){return n.display.shift||n.doc.extend||r.empty()?ui(n.doc,r.head,e,t,n.options.rtlMoveVisually):e<0?r.from():r.to()},_o)}),deleteH:Fn(function(e,t){var n=this.doc.sel,r=this.doc;n.somethingSelected()?r.replaceSelection("",null,"+delete"):oi(this,function(n){var i=ui(r,n.head,e,t,!1);return e<0?{from:i,to:n.head}:{from:n.head,to:i}})}),findPosV:function(e,t,n,r){var i=1,s=r;t<0&&(i=-1,t=-t);for(var o=0,u=St(this.doc,e);o<t;++o){var a=gn(this,u,"div");s==null?s=a.left:a.left=s,u=ai(this,a,i,n);if(u.hitSide)break}return u},moveV:Fn(function(e,t){var n=this,r=this.doc,i=[],s=!n.display.shift&&!r.extend&&r.sel.somethingSelected();r.extendSelectionsBy(function(o){if(s)return e<0?o.from():o.to();var u=gn(n,o.head,"div");o.goalColumn!=null&&(u.left=o.goalColumn),i.push(u.left);var a=ai(n,u,e,t);return t=="page"&&o==r.sel.primary()&&ti(n,null,mn(n,a,"div").top-u.top),a},_o);if(i.length)for(var o=0;o<r.sel.ranges.length;o++)r.sel.ranges[o].goalColumn=i[o]}),findWordAt:function(e){var t=this.doc,n=Us(t,e.line).text,r=e.ch,i=e.ch;if(n){var s=this.getHelper(e,"wordChars");(e.xRel<0||i==n.length)&&r?--r:++i;var o=n.charAt(r),u=$o(o,s)?function(e){return $o(e,s)}:/\s/.test(o)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!$o(e)};while(r>0&&u(n.charAt(r-1)))--r;while(i<n.length&&u(n.charAt(i)))++i}return new yt(ht(e.line,r),ht(e.line,i))},toggleOverwrite:function(e){if(e!=null&&e==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?su(this.display.cursorDiv,"CodeMirror-overwrite"):iu(this.display.cursorDiv,"CodeMirror-overwrite"),wo(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return nu()==this.display.input},scrollTo:Fn(function(e,t){(e!=null||t!=null)&&ri(this),e!=null&&(this.curOp.scrollLeft=e),t!=null&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller,t=Lo;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-t,width:e.scrollWidth-t,clientHeight:e.clientHeight-t,clientWidth:e.clientWidth-t}},scrollIntoView:Fn(function(e,t){e==null?(e={from:this.doc.sel.primary().head,to:null},t==null&&(t=this.options.cursorScrollMargin)):typeof e=="number"?e={from:ht(e,0),to:null}:e.from==null&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0;if(e.from.line!=null)ri(this),this.curOp.scrollToPos=e;else{var n=ei(this,Math.min(e.from.left,e.to.left),Math.min(e.from.top,e.to.top)-e.margin,Math.max(e.from.right,e.to.right),Math.max(e.from.bottom,e.to.bottom)+e.margin);this.scrollTo(n.scrollLeft,n.scrollTop)}}),setSize:Fn(function(e,t){function r(e){return typeof e=="number"||/^\d+$/.test(String(e))?e+"px":e}var n=this;e!=null&&(n.display.wrapper.style.width=r(e)),t!=null&&(n.display.wrapper.style.height=r(t)),n.options.lineWrapping&&ln(this);var i=n.display.viewFrom;n.doc.iter(i,n.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){zn(n,i,"widget");break}++i}),n.curOp.forceUpdate=!0,wo(n,"refresh",this)}),operation:function(e){return Bn(this,e)},refresh:Fn(function(){var e=this.display.cachedTextHeight;Un(this),this.curOp.forceUpdate=!0,cn(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),_(this),(e==null||Math.abs(e-xn(this.display))>.5)&&L(this),wo(this,"refresh",this)}),swapDoc:Fn(function(e){var t=this.doc;return t.cm=null,Rs(this,e),cn(this),Zn(this),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,So(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}},ko(S);var fi=S.defaults={},li=S.optionHandlers={},hi=S.Init={toString:function(){return"CodeMirror.Init"}};ci("value","",function(e,t){e.setValue(t)},!0),ci("mode",null,function(e,t){e.doc.modeOption=t,T(e)},!0),ci("indentUnit",2,T,!0),ci("indentWithTabs",!1),ci("smartIndent",!0),ci("tabSize",4,function(e){N(e),cn(e),Un(e)},!0),ci("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t){e.options.specialChars=new RegExp(t.source+(t.test("	")?"":"|	"),"g"),e.refresh()},!0),ci("specialCharPlaceholder",Cs,function(e){e.refresh()},!0),ci("electricChars",!0),ci("rtlMoveVisually",!m),ci("wholeLineUpdateBefore",!0),ci("theme","default",function(e){A(e),O(e)},!0),ci("keyMap","default",function(e,t,n){var r=Ci(t),i=n!=S.Init&&Ci(n);i&&i.detach&&i.detach(e,r),r.attach&&r.attach(e,i||null)}),ci("extraKeys",null),ci("lineWrapping",!1,C,!0),ci("gutters",[],function(e){H(e.options),O(e)},!0),ci("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?z(e.display)+"px":"0",e.refresh()},!0),ci("coverGutterNextToScrollbar",!1,F,!0),ci("lineNumbers",!1,function(e){H(e.options),O(e)},!0),ci("firstLineNumber",1,O,!0),ci("lineNumberFormatter",function(e){return e},O,!0),ci("showCursorWhenSelecting",!1,Rt,!0),ci("resetSelectionOnContextMenu",!0),ci("readOnly",!1,function(e,t){t=="nocursor"?(Hr(e),e.display.input.blur(),e.display.disabled=!0):(e.display.disabled=!1,t||Zn(e))}),ci("disableInput",!1,function(e,t){t||Zn(e)},!0),ci("dragDrop",!0),ci("cursorBlinkRate",530),ci("cursorScrollMargin",0),ci("cursorHeight",1,Rt,!0),ci("singleCursorHeightPerLine",!0,Rt,!0),ci("workTime",100),ci("workDelay",100),ci("flattenSpans",!0,N,!0),ci("addModeClass",!1,N,!0),ci("pollInterval",100),ci("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),ci("historyEventDelay",1250),ci("viewportMargin",10,function(e){e.refresh()},!0),ci("maxHighlightLength",1e4,N,!0),ci("moveInputWithCursor",!0,function(e,t){t||(e.display.inputDiv.style.top=e.display.inputDiv.style.left=0)}),ci("tabindex",null,function(e,t){e.display.input.tabIndex=t||""}),ci("autofocus",null);var pi=S.modes={},di=S.mimeModes={};S.defineMode=function(e,t){!S.defaults.mode&&e!="null"&&(S.defaults.mode=e),arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),pi[e]=t},S.defineMIME=function(e,t){di[e]=t},S.resolveMode=function(e){if(typeof e=="string"&&di.hasOwnProperty(e))e=di[e];else if(e&&typeof e.name=="string"&&di.hasOwnProperty(e.name)){var t=di[e.name];typeof t=="string"&&(t={name:t}),e=Uo(t,e),e.name=t.name}else if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return S.resolveMode("application/xml");return typeof e=="string"?{name:e}:e||{name:"null"}},S.getMode=function(e,t){var t=S.resolveMode(t),n=pi[t.name];if(!n)return S.getMode(e,"text/plain");var r=n(e,t);if(vi.hasOwnProperty(t.name)){var i=vi[t.name];for(var s in i){if(!i.hasOwnProperty(s))continue;r.hasOwnProperty(s)&&(r["_"+s]=r[s]),r[s]=i[s]}}r.name=t.name,t.helperType&&(r.helperType=t.helperType);if(t.modeProps)for(var s in t.modeProps)r[s]=t.modeProps[s];return r},S.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),S.defineMIME("text/plain","null");var vi=S.modeExtensions={};S.extendMode=function(e,t){var n=vi.hasOwnProperty(e)?vi[e]:vi[e]={};zo(t,n)},S.defineExtension=function(e,t){S.prototype[e]=t},S.defineDocExtension=function(e,t){js.prototype[e]=t},S.defineOption=ci;var mi=[];S.defineInitHook=function(e){mi.push(e)};var gi=S.helpers={};S.registerHelper=function(e,t,n){gi.hasOwnProperty(e)||(gi[e]=S[e]={_global:[]}),gi[e][t]=n},S.registerGlobalHelper=function(e,t,n,r){S.registerHelper(e,t,r),gi[e]._global.push({pred:n,val:r})};var yi=S.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n},bi=S.startState=function(e,t,n){return e.startState?e.startState(t,n):!0};S.innerMode=function(e,t){while(e.innerMode){var n=e.innerMode(t);if(!n||n.mode==e)break;t=n.state,e=n.mode}return n||{mode:e,state:t}};var wi=S.commands={selectAll:function(e){e.setSelection(ht(e.firstLine(),0),ht(e.lastLine()),Oo)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Oo)},killLine:function(e){oi(e,function(t){if(t.empty()){var n=Us(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line<e.lastLine()?{from:t.head,to:ht(t.head.line+1,0)}:{from:t.head,to:ht(t.head.line,n)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){oi(e,function(t){return{from:ht(t.from().line,0),to:St(e.doc,ht(t.to().line+1,0))}})},delLineLeft:function(e){oi(e,function(e){return{from:ht(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){oi(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){oi(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div");return{from:t.from(),to:r}})},undo:function(e){e.undo()},redo:function(e){e.redo()},undoSelection:function(e){e.undoSelection()},redoSelection:function(e){e.redoSelection()},goDocStart:function(e){e.extendSelection(ht(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(ht(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return Au(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return Mu(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return Ou(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div")},_o)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:n},"div")},_o)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return r.ch<e.getLine(r.line).search(/\S/)?Mu(e,t.head):r},_o)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goGroupRight:function(e){e.moveH(1,"group")},goGroupLeft:function(e){e.moveH(-1,"group")},goWordRight:function(e){e.moveH(1,"word")},delCharBefore:function(e){e.deleteH(-1,"char")},delCharAfter:function(e){e.deleteH(1,"char")},delWordBefore:function(e){e.deleteH(-1,"word")},delWordAfter:function(e){e.deleteH(1,"word")},delGroupBefore:function(e){e.deleteH(-1,"group")},delGroupAfter:function(e){e.deleteH(1,"group")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection("	")},insertSoftTab:function(e){var t=[],n=e.listSelections(),r=e.options.tabSize;for(var i=0;i<n.length;i++){var s=n[i].from(),o=Po(e.getLine(s.line),s.ch,r);t.push((new Array(r-o%r+1)).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Bn(e,function(){var t=e.listSelections(),n=[];for(var r=0;r<t.length;r++){var i=t[r].head,s=Us(e.doc,i.line).text;if(s){i.ch==s.length&&(i=new ht(i.line,i.ch-1));if(i.ch>0)i=new ht(i.line,i.ch+1),e.replaceRange(s.charAt(i.ch-1)+s.charAt(i.ch-2),ht(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var o=Us(e.doc,i.line-1).text;o&&e.replaceRange(s.charAt(0)+"\n"+o.charAt(o.length-1),ht(i.line-1,o.length-1),ht(i.line,1),"+transpose")}}n.push(new yt(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){Bn(e,function(){var t=e.listSelections().length;for(var n=0;n<t;n++){var r=e.listSelections()[n];e.replaceRange("\n",r.anchor,r.head,"+input"),e.indentLine(r.from().line+1,null,!0),ni(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},Ei=S.keyMap={};Ei.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Ei.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Ei.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"},Ei.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Ei["default"]=v?Ei.macDefault:Ei.pcDefault,S.normalizeKeyMap=function(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if(r=="..."){delete e[n];continue}var i=Ro(n.split(" "),Si);for(var s=0;s<i.length;s++){var o,u;s==i.length-1?(u=n,o=r):(u=i.slice(0,s+1).join(" "),o="...");var a=t[u];if(!a)t[u]=o;else if(a!=o)throw new Error("Inconsistent bindings for "+u)}delete e[n]}for(var f in t)e[f]=t[f];return e};var xi=S.lookupKey=function(e,t,n){t=Ci(t);var r=t.call?t.call(e):t[e];if(r===!1)return"nothing";if(r==="...")return"multi";if(r!=null&&n(r))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return xi(e,t.fallthrough,n);for(var i=0;i<t.fallthrough.length;i++){var s=xi(e,t.fallthrough[i],n);if(s)return s}}},Ti=S.isModifierKey=function(e){var t=typeof e=="string"?e:xu[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"},Ni=S.keyName=function(e,t){if(a&&e.keyCode==34&&e["char"])return!1;var n=xu[e.keyCode],r=n;return r==null||e.altGraphKey?!1:(e.altKey&&n!="Alt"&&(r="Alt-"+r),(y?e.metaKey:e.ctrlKey)&&n!="Ctrl"&&(r="Ctrl-"+r),(y?e.ctrlKey:e.metaKey)&&n!="Cmd"&&(r="Cmd-"+r),!t&&e.shiftKey&&n!="Shift"&&(r="Shift-"+r),r)};S.fromTextArea=function(e,t){function r(){e.value=a.getValue()}t||(t={}),t.value=e.value,!t.tabindex&&e.tabindex&&(t.tabindex=e.tabindex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder);if(t.autofocus==null){var n=nu();t.autofocus=n==e||e.getAttribute("autofocus")!=null&&n==document.body}if(e.form){yo(e.form,"submit",r);if(!t.leaveSubmitMethodAlone){var i=e.form,s=i.submit;try{var o=i.submit=function(){r(),i.submit=s,i.submit(),i.submit=o}}catch(u){}}}e.style.display="none";var a=S(function(t){e.parentNode.insertBefore(t,e.nextSibling)},t);return a.save=r,a.getTextArea=function(){return e},a.toTextArea=function(){a.toTextArea=isNaN,r(),e.parentNode.removeChild(a.getWrapperElement()),e.style.display="",e.form&&(bo(e.form,"submit",r),typeof e.form.submit=="function"&&(e.form.submit=s))},a};var ki=S.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};ki.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},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(e){var t=this.string.charAt(this.pos);if(typeof e=="string")var n=t==e;else var n=t&&(e.test?e.test(t):e(t));if(n)return++this.pos,t},eatWhile:function(e){var t=this.pos;while(this.eat(e));return this.pos>t},eatSpace:function(){var e=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Po(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Po(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Po(this.string,null,this.tabSize)-(this.lineStart?Po(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,n){if(typeof e!="string"){var s=this.string.slice(this.pos).match(e);return s&&s.index>0?null:(s&&t!==!1&&(this.pos+=s[0].length),s)}var r=function(e){return n?e.toLowerCase():e},i=this.string.substr(this.pos,e.length);if(r(i)==r(e))return t!==!1&&(this.pos+=e.length),!0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var Li=S.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e};ko(Li),Li.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;t&&kn(e);if(Co(this,"clear")){var n=this.find();n&&So(this,"clear",n.from,n.to)}var r=null,i=null;for(var s=0;s<this.lines.length;++s){var o=this.lines[s],u=ji(o.markedSpans,this);e&&!this.collapsed?zn(e,Vs(o),"text"):e&&(u.to!=null&&(i=Vs(o)),u.from!=null&&(r=Vs(o))),o.markedSpans=Fi(o.markedSpans,u),u.from==null&&this.collapsed&&!ss(this.doc,o)&&e&&Xs(o,xn(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var s=0;s<this.lines.length;++s){var a=ts(this.lines[s]),f=D(a);f>e.display.maxLineLength&&(e.display.maxLine=a,e.display.maxLineLength=f,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&Un(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Bt(e.doc)),e&&So(e,"markerCleared",e,this),t&&An(e),this.parent&&this.parent.clear()},Li.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);var n,r;for(var i=0;i<this.lines.length;++i){var s=this.lines[i],o=ji(s.markedSpans,this);if(o.from!=null){n=ht(t?s:Vs(s),o.from);if(e==-1)return n}if(o.to!=null){r=ht(t?s:Vs(s),o.to);if(e==1)return r}}return n&&{from:n,to:r}},Li.prototype.changed=function(){var e=this.find(-1,!0),t=this,n=this.doc.cm;if(!e||!n)return;Bn(n,function(){var r=e.line,i=Vs(e.line),s=nn(n,i);s&&(fn(s),n.curOp.selectionChanged=n.curOp.forceUpdate=!0),n.curOp.updateMaxLine=!0;if(!ss(t.doc,r)&&t.height!=null){var o=t.height;t.height=null;var u=fs(t)-o;u&&Xs(r,r.height+u)}})},Li.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||qo(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Li.prototype.detachLine=function(e){this.lines.splice(qo(this.lines,e),1);if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var Ai=0,Mi=S.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=this};ko(Mi),Mi.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();So(this,"clear")},Mi.prototype.find=function(e,t){return this.primary.find(e,t)};var us=S.LineWidget=function(e,t,n){if(n)for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.cm=e,this.node=t};ko(us),us.prototype.clear=function(){var e=this.cm,t=this.line.widgets,n=this.line,r=Vs(n);if(r==null||!t)return;for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(n.widgets=null);var s=fs(this);Bn(e,function(){as(e,n,-s),zn(e,r,"widget"),Xs(n,Math.max(0,n.height-s))})},us.prototype.changed=function(){var e=this.height,t=this.cm,n=this.line;this.height=null;var r=fs(this)-e;if(!r)return;Bn(t,function(){t.curOp.forceUpdate=!0,as(t,n,r),Xs(n,n.height+r)})};var cs=S.Line=function(e,t,n){this.text=e,$i(this,t),this.height=n?n(this):1};ko(cs),cs.prototype.lineNo=function(){return Vs(this)};var Ss={},xs={};Ps.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var n=e,r=e+t;n<r;++n){var i=this.lines[n];this.height-=i.height,ps(i),So(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,n){for(var r=e+t;e<r;++e)if(n(this.lines[e]))return!0}},Hs.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n=0;n<this.children.length;++n){var r=this.children[n],i=r.chunkSize();if(e<i){var s=Math.min(t,i-e),o=r.height;r.removeInner(e,s),this.height-=o-r.height,i==s&&(this.children.splice(n--,1),r.parent=null);if((t-=s)==0)break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Ps))){var u=[];this.collapse(u),this.children=[new Ps(u)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,n){this.size+=t.length,this.height+=n;for(var r=0;r<this.children.length;++r){var i=this.children[r],s=i.chunkSize();if(e<=s){i.insertInner(e,t,n);if(i.lines&&i.lines.length>50){while(i.lines.length>50){var o=i.lines.splice(i.lines.length-25,25),u=new Ps(o);i.height-=u.height,this.children.splice(r+1,0,u),u.parent=this}this.maybeSpill()}break}e-=s}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),n=new Hs(t);if(!e.parent){var r=new Hs(e.children);r.parent=e,e.children=[r,n],e=r}else{e.size-=n.size,e.height-=n.height;var i=qo(e.parent.children,e);e.parent.children.splice(i+1,0,n)}n.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN:function(e,t,n){for(var r=0;r<this.children.length;++r){var i=this.children[r],s=i.chunkSize();if(e<s){var o=Math.min(t,s-e);if(i.iterN(e,o,n))return!0;if((t-=o)==0)break;e=0}else e-=s}}};var Bs=0,js=S.Doc=function(e,t,n){if(!(this instanceof js))return new js(e,t,n);n==null&&(n=0),Hs.call(this,[new Ps([new cs("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=n;var r=ht(n,0);this.sel=wt(r),this.history=new Qs(null),this.id=++Bs,this.modeOption=t,typeof e=="string"&&(e=yu(e)),Ds(this,{from:r,to:r,text:e}),Dt(this,wt(r),Oo)};js.prototype=Uo(Hs.prototype,{constructor:js,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){var n=0;for(var r=0;r<t.length;++r)n+=t[r].height;this.insertInner(e-this.first,t,n)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Ws(this,this.first,this.first+this.size);return e===!1?t:t.join(e||"\n")},setValue:In(function(e){var t=ht(this.first,0),n=this.first+this.size-1;Wr(this,{from:t,to:ht(n,Us(this,n).text.length),text:yu(e),origin:"setValue"},!0),Dt(this,wt(t))}),replaceRange:function(e,t,n,r){t=St(this,t),n=n?St(this,n):t,Qr(this,e,t,n,r)},getRange:function(e,t,n){var r=zs(this,St(this,e),St(this,t));return n===!1?r:r.join(n||"\n")},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(Tt(this,e))return Us(this,e)},getLineNumber:function(e){return Vs(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=Us(this,e)),ts(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return St(this,e)},getCursor:function(e){var t=this.sel.primary(),n;return e==null||e=="head"?n=t.head:e=="anchor"?n=t.anchor:e=="end"||e=="to"||e===!1?n=t.to():n=t.from(),n},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:In(function(e,t,n){Ot(this,St(this,typeof e=="number"?ht(e,t||0):e),null,n)}),setSelection:In(function(e,t,n){Ot(this,St(this,e),St(this,t||e),n)}),extendSelection:In(function(e,t,n){kt(this,St(this,e),t&&St(this,t),n)}),extendSelections:In(function(e,t){Lt(this,Nt(this,e,t))}),extendSelectionsBy:In(function(e,t){Lt(this,Ro(this.sel.ranges,e),t)}),setSelections:In(function(e,t,n){if(!e.length)return;for(var r=0,i=[];r<e.length;r++)i[r]=new yt(St(this,e[r].anchor),St(this,e[r].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),Dt(this,bt(i,t),n)}),addSelection:In(function(e,t,n){var r=this.sel.ranges.slice(0);r.push(new yt(St(this,e),St(this,t||e))),Dt(this,bt(r,r.length-1),n)}),getSelection:function(e){var t=this.sel.ranges,n;for(var r=0;r<t.length;r++){var i=zs(this,t[r].from(),t[r].to());n=n?n.concat(i):i}return e===!1?n:n.join(e||"\n")},getSelections:function(e){var t=[],n=this.sel.ranges;for(var r=0;r<n.length;r++){var i=zs(this,n[r].from(),n[r].to());e!==!1&&(i=i.join(e||"\n")),t[r]=i}return t},replaceSelection:function(e,t,n){var r=[];for(var i=0;i<this.sel.ranges.length;i++)r[i]=e;this.replaceSelections(r,t,n||"+input")},replaceSelections:In(function(e,t,n){var r=[],i=this.sel;for(var s=0;s<i.ranges.length;s++){var o=i.ranges[s];r[s]={from:o.from(),to:o.to(),text:yu(e[s]),origin:n}}var u=t&&t!="end"&&Ur(this,r,t);for(var s=r.length-1;s>=0;s--)Wr(this,r[s]);u?_t(this,u):this.cm&&ni(this.cm)}),undo:In(function(){Vr(this,"undo")}),redo:In(function(){Vr(this,"redo")}),undoSelection:In(function(){Vr(this,"undo",!0)}),redoSelection:In(function(){Vr(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){var e=this.history,t=0,n=0;for(var r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var r=0;r<e.undone.length;r++)e.undone[r].ranges||++n;return{undo:t,redo:n}},clearHistory:function(){this.history=new Qs(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:uo(this.history.done),undone:uo(this.history.undone)}},setHistory:function(e){var t=this.history=new Qs(this.history.maxGeneration);t.done=uo(e.done.slice(0),null,!0),t.undone=uo(e.undone.slice(0),null,!0)},addLineClass:In(function(e,t,n){return si(this,e,t=="gutter"?"gutter":"class",function(e){var r=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(!e[r])e[r]=n;else{if(ru(n).test(e[r]))return!1;e[r]+=" "+n}return!0})}),removeLineClass:In(function(e,t,n){return si(this,e,"class",function(e){var r=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",i=e[r];if(!i)return!1;if(n==null)e[r]=null;else{var s=i.match(ru(n));if(!s)return!1;var o=s.index+s[0].length;e[r]=i.slice(0,s.index)+(!s.index||o==i.length?"":" ")+i.slice(o)||null}return!0})}),markText:function(e,t,n){return Oi(this,St(this,e),St(this,t),n,"range")},setBookmark:function(e,t){var n={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared};return e=St(this,e),Oi(this,e,e,n,"bookmark")},findMarksAt:function(e){e=St(this,e);var t=[],n=Us(this,e.line).markedSpans;if(n)for(var r=0;r<n.length;++r){var i=n[r];(i.from==null||i.from<=e.ch)&&(i.to==null||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=St(this,e),t=St(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(s){var o=s.markedSpans;if(o)for(var u=0;u<o.length;u++){var a=o[u];!(i==e.line&&e.ch>a.to||a.from==null&&i!=e.line||i==t.line&&a.from>t.ch)&&(!n||n(a.marker))&&r.push(a.marker.parent||a.marker)}++i}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var r=0;r<n.length;++r)n[r].from!=null&&e.push(n[r].marker)}),e},posFromIndex:function(e){var t,n=this.first;return this.iter(function(r){var i=r.text.length+1;if(i>e)return t=e,!0;e-=i,++n}),St(this,ht(n,t))},indexFromPos:function(e){e=St(this,e);var t=e.ch;return e.line<this.first||e.ch<0?0:(this.iter(this.first,e.line,function(e){t+=e.text.length+1}),t)},copy:function(e){var t=new js(Ws(this,this.first,this.first+this.size),this.modeOption,this.first);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,n=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<n&&(n=e.to);var r=new js(Ws(this,t,n),e.mode||this.modeOption,t);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Pi(r,Di(this)),r},unlinkDoc:function(e){e instanceof S&&(e=e.doc);if(this.linked)for(var t=0;t<this.linked.length;++t){var n=this.linked[t];if(n.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),Hi(Di(this));break}if(e.history==this.history){var r=[e.id];qs(e,function(e){r.push(e.id)},!0),e.history=new Qs(null),e.history.done=uo(this.history.done,r),e.history.undone=uo(this.history.undone,r)}},iterLinkedDocs:function(e){qs(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),js.prototype.eachLine=js.prototype.iter;var Fs="iter insert remove copy getEditor".split(" ");for(var Is in js.prototype)js.prototype.hasOwnProperty(Is)&&qo(Fs,Is)<0&&(S.prototype[Is]=function(e){return function(){return e.apply(this.doc,arguments)}}(js.prototype[Is]));ko(js);var co=S.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},ho=S.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},vo=S.e_stop=function(e){co(e),ho(e)},yo=S.on=function(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else if(e.attachEvent)e.attachEvent("on"+t,n);else{var r=e._handlers||(e._handlers={}),i=r[t]||(r[t]=[]);i.push(n)}},bo=S.off=function(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else if(e.detachEvent)e.detachEvent("on"+t,n);else{var r=e._handlers&&e._handlers[t];if(!r)return;for(var i=0;i<r.length;++i)if(r[i]==n){r.splice(i,1);break}}},wo=S.signal=function(e,t){var n=e._handlers&&e._handlers[t];if(!n)return;var r=Array.prototype.slice.call(arguments,2);for(var i=0;i<n.length;++i)n[i].apply(null,r)},Eo=null,Lo=30,Ao=S.Pass={toString:function(){return"CodeMirror.Pass"}},Oo={scroll:!1},Mo={origin:"*mouse"},_o={origin:"+move"};Do.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Po=S.countColumn=function(e,t,n,r,i){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var s=r||0,o=i||0;;){var u=e.indexOf("	",s);if(u<0||u>=t)return o+(t-s);o+=u-s,o+=n-o%n,s=u+1}},Bo=[""],Io=function(e){e.select()};p?Io=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:r&&(Io=function(e){try{e.select()}catch(t){}}),[].indexOf&&(qo=function(e,t){return e.indexOf(t)}),[].map&&(Ro=function(e,t){return e.map(t)});var Xo=/[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Vo=S.isWordChar=function(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||Xo.test(e))},Ko=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,Yo;document.createRange?Yo=function(e,t,n){var r=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}:Yo=function(e,t,n){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(i){return r}return r.collapse(!0),r.moveEnd("character",n),r.moveStart("character",t),r},r&&i<11&&(nu=function(){try{return document.activeElement}catch(e){return document.body}});var iu=S.rmClass=function(e,t){var n=e.className,r=ru(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}},su=S.addClass=function(e,t){var n=e.className;ru(t).test(n)||(e.className+=(n?" ":"")+t)},au=!1,cu=function(){if(r&&i<9)return!1;var e=Go("div");return"draggable"in e||"dragDrop"in e}(),hu,du,mu,yu=S.splitLines="\n\nb".split(/\n/).length!=3?function(e){var t=0,n=[],r=e.length;while(t<=r){var i=e.indexOf("\n",t);i==-1&&(i=e.length);var s=e.slice(t,e.charAt(i-1)=="\r"?i-1:i),o=s.indexOf("\r");o!=-1?(n.push(s.slice(0,o)),t+=o+1):(n.push(s),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},bu=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(n){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},wu=function(){var e=Go("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),Eu=null,xu={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};S.keyNames=xu,function(){for(var e=0;e<10;e++)xu[e+48]=xu[e+96]=String(e);for(var e=65;e<=90;e++)xu[e]=String.fromCharCode(e);for(var e=1;e<=12;e++)xu[e+111]=xu[e+63235]="F"+e}();var Du,Fu=function(){function n(n){return n<=247?e.charAt(n):1424<=n&&n<=1524?"R":1536<=n&&n<=1773?t.charAt(n-1536):1774<=n&&n<=2220?"r":8192<=n&&n<=8203?"w":n==8204?"b":"L"}function f(e,t,n){this.level=e,this.from=t,this.to=n}var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,s=/[LRr]/,o=/[Lb1n]/,u=/[1n]/,a="L";return function(e){if(!r.test(e))return!1;var t=e.length,l=[];for(var c=0,h;c<t;++c)l.push(h=n(e.charCodeAt(c)));for(var c=0,p=a;c<t;++c){var h=l[c];h=="m"?l[c]=p:p=h}for(var c=0,d=a;c<t;++c){var h=l[c];h=="1"&&d=="r"?l[c]="n":s.test(h)&&(d=h,h=="r"&&(l[c]="R"))}for(var c=1,p=l[0];c<t-1;++c){var h=l[c];h=="+"&&p=="1"&&l[c+1]=="1"?l[c]="1":h==","&&p==l[c+1]&&(p=="1"||p=="n")&&(l[c]=p),p=h}for(var c=0;c<t;++c){var h=l[c];if(h==",")l[c]="N";else if(h=="%"){for(var v=c+1;v<t&&l[v]=="%";++v);var m=c&&l[c-1]=="!"||v<t&&l[v]=="1"?"1":"N";for(var g=c;g<v;++g)l[g]=m;c=v-1}}for(var c=0,d=a;c<t;++c){var h=l[c];d=="L"&&h=="1"?l[c]="L":s.test(h)&&(d=h)}for(var c=0;c<t;++c)if(i.test(l[c])){for(var v=c+1;v<t&&i.test(l[v]);++v);var y=(c?l[c-1]:a)=="L",b=(v<t?l[v]:a)=="L",m=y||b?"L":"R";for(var g=c;g<v;++g)l[g]=m;c=v-1}var w=[],E;for(var c=0;c<t;)if(o.test(l[c])){var S=c;for(++c;c<t&&o.test(l[c]);++c);w.push(new f(0,S,c))}else{var x=c,T=w.length;for(++c;c<t&&l[c]!="L";++c);for(var g=x;g<c;)if(u.test(l[g])){x<g&&w.splice(T,0,new f(1,x,g));var N=g;for(++g;g<c&&u.test(l[g]);++g);w.splice(T,0,new f(2,N,g)),x=g}else++g;x<c&&w.splice(T,0,new f(1,x,c))}return w[0].level==1&&(E=e.match(/^\s+/))&&(w[0].from=E[0].length,w.unshift(new f(0,0,E[0].length))),Fo(w).level==1&&(E=e.match(/\s+$/))&&(Fo(w).to-=E[0].length,w.push(new f(0,t-E[0].length,t))),w[0].level!=Fo(w).level&&w.push(new f(w[0].level,t,t)),w}}();return S.version="4.8.0",S}),define("CMLint",["react","lodash","jquery","./libs/codemirror-4.8/lib/codemirror"],function(e,t,n,r){function i(e){var t=e.severity;t||(t="error");var n=document.createElement("div");return n.className="CodeMirror-lint-message-"+t,n.appendChild(document.createTextNode(e.message)),n}function o(e,t){var n=document.createDocumentFragment(),r={severity:"error",message:t.message};n.appendChild(i(r)),e.setGutterMarker(Math.max(t.line,0),s,a(n,"error",!1,"state.options.tooltips"))}function u(e){e.clearGutter(s)}function a(e,t,n,i){var s=document.createElement("div"),o=s;return s.className="CodeMirror-lint-marker-"+t,n&&(o=s.appendChild(document.createElement("div")),o.className="CodeMirror-lint-marker-multiple"),i!==!1&&r.on(o,"mouseover",function(t){h(t,e,o)}),s}function f(e,t){function i(e){if(!n.parentNode)return r.off(document,"mousemove",i);n.style.top=Math.max(0,e.clientY-n.offsetHeight-5)+"px",n.style.left=e.clientX+5+"px"}var n=document.createElement("div");return n.className="CodeMirror-lint-tooltip",n.appendChild(t.cloneNode(!0)),document.body.appendChild(n),r.on(document,"mousemove",i),i(e),n.style.opacity!==null&&(n.style.opacity=1),n}function l(e){e.parentNode&&e.parentNode.removeChild(e)}function c(e){if(!e.parentNode)return;e.style.opacity===null&&l(e),e.style.opacity=0,setTimeout(function(){l(e)},600)}function h(e,t,n){function s(){r.off(n,"mouseout",s),i&&(c(i),i=null)}var i=f(e,t),o=setInterval(function(){if(i)for(var e=n;;e=e.parentNode){if(e===document.body)return undefined;if(!e){s();break}}if(!i)return clearInterval(o)},400);r.on(n,"mouseout",s)}var s="rt-annotations";return{GUTTER_ID:s,annotate:o,clearMarks:u}}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/mode/javascript/javascript",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineMode("javascript",function(t,n){function h(e){var t=!1,n,r=!1;while((n=e.next())!=null){if(!t){if(n=="/"&&!r)return;n=="["?r=!0:r&&n=="]"&&(r=!1)}t=!t&&n=="\\"}}function v(e,t,n){return p=e,d=n,t}function m(e,t){var n=e.next();if(n=='"'||n=="'")return t.tokenize=g(n),t.tokenize(e,t);if(n=="."&&e.match(/^\d+(?:[eE][+\-]?\d+)?/))return v("number","number");if(n=="."&&e.match(".."))return v("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return v(n);if(n=="="&&e.eat(">"))return v("=>","operator");if(n=="0"&&e.eat(/x/i))return e.eatWhile(/[\da-f]/i),v("number","number");if(/\d/.test(n))return e.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),v("number","number");if(n=="/")return e.eat("*")?(t.tokenize=y,y(e,t)):e.eat("/")?(e.skipToEnd(),v("comment","comment")):t.lastType=="operator"||t.lastType=="keyword c"||t.lastType=="sof"||/^[\[{}\(,;:]$/.test(t.lastType)?(h(e),e.eatWhile(/[gimy]/),v("regexp","string-2")):(e.eatWhile(l),v("operator","operator",e.current()));if(n=="`")return t.tokenize=b,b(e,t);if(n=="#")return e.skipToEnd(),v("error","error");if(l.test(n))return e.eatWhile(l),v("operator","operator",e.current());if(a.test(n)){e.eatWhile(a);var r=e.current(),i=f.propertyIsEnumerable(r)&&f[r];return i&&t.lastType!="."?v(i.type,i.style,r):v("variable","variable",r)}}function g(e){return function(t,n){var r=!1,i;if(s&&t.peek()=="@"&&t.match(c))return n.tokenize=m,v("jsonld-keyword","meta");while((i=t.next())!=null){if(i==e&&!r)break;r=!r&&i=="\\"}return r||(n.tokenize=m),v("string","string")}}function y(e,t){var n=!1,r;while(r=e.next()){if(r=="/"&&n){t.tokenize=m;break}n=r=="*"}return v("comment","comment")}function b(e,t){var n=!1,r;while((r=e.next())!=null){if(!n&&(r=="`"||r=="$"&&e.eat("{"))){t.tokenize=m;break}n=!n&&r=="\\"}return v("quasi","string-2",e.current())}function E(e,t){t.fatArrowAt&&(t.fatArrowAt=null);var n=e.string.indexOf("=>",e.start);if(n<0)return;var r=0,i=!1;for(var s=n-1;s>=0;--s){var o=e.string.charAt(s),u=w.indexOf(o);if(u>=0&&u<3){if(!r){++s;break}if(--r==0)break}else if(u>=3&&u<6)++r;else if(a.test(o))i=!0;else if(i&&!r){++s;break}}i&&!r&&(t.fatArrowAt=s)}function x(e,t,n,r,i,s){this.indented=e,this.column=t,this.type=n,this.prev=i,this.info=s,r!=null&&(this.align=r)}function T(e,t){for(var n=e.localVars;n;n=n.next)if(n.name==t)return!0;for(var r=e.context;r;r=r.prev)for(var n=r.vars;n;n=n.next)if(n.name==t)return!0}function N(e,t,n,r,i){var s=e.cc;C.state=e,C.stream=i,C.marked=null,C.cc=s,C.style=t,e.lexical.hasOwnProperty("align")||(e.lexical.align=!0);for(;;){var u=s.length?s.pop():o?j:B;if(u(n,r)){while(s.length&&s[s.length-1].lex)s.pop()();return C.marked?C.marked:n=="variable"&&T(e,r)?"variable-2":t}}}function k(){for(var e=arguments.length-1;e>=0;e--)C.cc.push(arguments[e])}function L(){return k.apply(null,arguments),!0}function A(e){function t(t){for(var n=t;n;n=n.next)if(n.name==e)return!0;return!1}var r=C.state;if(r.context){C.marked="def";if(t(r.localVars))return;r.localVars={name:e,next:r.localVars}}else{if(t(r.globalVars))return;n.globalVars&&(r.globalVars={name:e,next:r.globalVars})}}function M(){C.state.context={prev:C.state.context,vars:C.state.localVars},C.state.localVars=O}function _(){C.state.localVars=C.state.context.vars,C.state.context=C.state.context.prev}function D(e,t){var n=function(){var n=C.state,r=n.indented;if(n.lexical.type=="stat")r=n.lexical.indented;else for(var i=n.lexical;i&&i.type==")"&&i.align;i=i.prev)r=i.indented;n.lexical=new x(r,C.stream.column(),e,null,n.lexical,t)};return n.lex=!0,n}function P(){var e=C.state;e.lexical.prev&&(e.lexical.type==")"&&(e.indented=e.lexical.indented),e.lexical=e.lexical.prev)}function H(e){function t(n){return n==e?L():e==";"?k():L(t)}return t}function B(e,t){return e=="var"?L(D("vardef",t.length),it,H(";"),P):e=="keyword a"?L(D("form"),j,B,P):e=="keyword b"?L(D("form"),B,P):e=="{"?L(D("}"),tt,P):e==";"?L():e=="if"?(C.state.lexical.info=="else"&&C.state.cc[C.state.cc.length-1]==P&&C.state.cc.pop()(),L(D("form"),j,B,P,ft)):e=="function"?L(vt):e=="for"?L(D("form"),lt,B,P):e=="variable"?L(D("stat"),J):e=="switch"?L(D("form"),j,D("}","switch"),H("{"),tt,P,P):e=="case"?L(j,H(":")):e=="default"?L(H(":")):e=="catch"?L(D("form"),M,H("("),mt,H(")"),B,P,_):e=="module"?L(D("form"),M,Et,_,P):e=="class"?L(D("form"),gt,P):e=="export"?L(D("form"),St,P):e=="import"?L(D("form"),xt,P):k(D("stat"),j,H(";"),P)}function j(e){return I(e,!1)}function F(e){return I(e,!0)}function I(e,t){if(C.state.fatArrowAt==C.stream.start){var n=t?$:V;if(e=="(")return L(M,D(")"),Z(st,")"),P,H("=>"),n,_);if(e=="variable")return k(M,st,H("=>"),n,_)}var r=t?z:U;return S.hasOwnProperty(e)?L(r):e=="function"?L(vt,r):e=="keyword c"?L(t?R:q):e=="("?L(D(")"),q,Lt,H(")"),P,r):e=="operator"||e=="spread"?L(t?F:j):e=="["?L(D("]"),Ct,P,r):e=="{"?et(Q,"}",null,r):e=="quasi"?k(W,r):L()}function q(e){return e.match(/[;\}\)\],]/)?k():k(j)}function R(e){return e.match(/[;\}\)\],]/)?k():k(F)}function U(e,t){return e==","?L(j):z(e,t,!1)}function z(e,t,n){var r=n==0?U:z,i=n==0?j:F;if(e=="=>")return L(M,n?$:V,_);if(e=="operator")return/\+\+|--/.test(t)?L(r):t=="?"?L(j,H(":"),i):L(i);if(e=="quasi")return k(W,r);if(e==";")return;if(e=="(")return et(F,")","call",r);if(e==".")return L(K,r);if(e=="[")return L(D("]"),q,H("]"),P,r)}function W(e,t){return e!="quasi"?k():t.slice(t.length-2)!="${"?L(W):L(j,X)}function X(e){if(e=="}")return C.marked="string-2",C.state.tokenize=b,L(W)}function V(e){return E(C.stream,C.state),k(e=="{"?B:j)}function $(e){return E(C.stream,C.state),k(e=="{"?B:F)}function J(e){return e==":"?L(P,B):k(U,H(";"),P)}function K(e){if(e=="variable")return C.marked="property",L()}function Q(e,t){if(e=="variable"||C.style=="keyword")return C.marked="property",t=="get"||t=="set"?L(G):L(Y);if(e=="number"||e=="string")return C.marked=s?"property":C.style+" property",L(Y);if(e=="jsonld-keyword")return L(Y);if(e=="[")return L(j,H("]"),Y)}function G(e){return e!="variable"?k(Y):(C.marked="property",L(vt))}function Y(e){if(e==":")return L(F);if(e=="(")return k(vt)}function Z(e,t){function n(r){if(r==","){var i=C.state.lexical;return i.info=="call"&&(i.pos=(i.pos||0)+1),L(e,n)}return r==t?L():L(H(t))}return function(r){return r==t?L():k(e,n)}}function et(e,t,n){for(var r=3;r<arguments.length;r++)C.cc.push(arguments[r]);return L(D(t,n),Z(e,t),P)}function tt(e){return e=="}"?L():k(B,tt)}function nt(e){if(u&&e==":")return L(rt)}function rt(e){if(e=="variable")return C.marked="variable-3",L()}function it(){return k(st,nt,ut,at)}function st(e,t){if(e=="variable")return A(t),L();if(e=="[")return et(st,"]");if(e=="{")return et(ot,"}")}function ot(e,t){return e=="variable"&&!C.stream.match(/^\s*:/,!1)?(A(t),L(ut)):(e=="variable"&&(C.marked="property"),L(H(":"),st,ut))}function ut(e,t){if(t=="=")return L(F)}function at(e){if(e==",")return L(it)}function ft(e,t){if(e=="keyword b"&&t=="else")return L(D("form","else"),B,P)}function lt(e){if(e=="(")return L(D(")"),ct,H(")"),P)}function ct(e){return e=="var"?L(it,H(";"),pt):e==";"?L(pt):e=="variable"?L(ht):k(j,H(";"),pt)}function ht(e,t){return t=="in"||t=="of"?(C.marked="keyword",L(j)):L(U,pt)}function pt(e,t){return e==";"?L(dt):t=="in"||t=="of"?(C.marked="keyword",L(j)):k(j,H(";"),dt)}function dt(e){e!=")"&&L(j)}function vt(e,t){if(t=="*")return C.marked="keyword",L(vt);if(e=="variable")return A(t),L(vt);if(e=="(")return L(M,D(")"),Z(mt,")"),P,B,_)}function mt(e){return e=="spread"?L(mt):k(st,nt)}function gt(e,t){if(e=="variable")return A(t),L(yt)}function yt(e,t){if(t=="extends")return L(j,yt);if(e=="{")return L(D("}"),bt,P)}function bt(e,t){if(e=="variable"||C.style=="keyword")return C.marked="property",t=="get"||t=="set"?L(wt,vt,bt):L(vt,bt);if(t=="*")return C.marked="keyword",L(bt);if(e==";")return L(bt);if(e=="}")return L()}function wt(e){return e!="variable"?k():(C.marked="property",L())}function Et(e,t){if(e=="string")return L(B);if(e=="variable")return A(t),L(Nt)}function St(e,t){return t=="*"?(C.marked="keyword",L(Nt,H(";"))):t=="default"?(C.marked="keyword",L(j,H(";"))):k(B)}function xt(e){return e=="string"?L():k(Tt,Nt)}function Tt(e,t){return e=="{"?et(Tt,"}"):(e=="variable"&&A(t),L())}function Nt(e,t){if(t=="from")return C.marked="keyword",L(j)}function Ct(e){return e=="]"?L():k(F,kt)}function kt(e){return e=="for"?k(Lt,H("]")):e==","?L(Z(R,"]")):k(Z(F,"]"))}function Lt(e){if(e=="for")return L(lt,Lt);if(e=="if")return L(j,Lt)}var r=t.indentUnit,i=n.statementIndent,s=n.jsonld,o=n.json||s,u=n.typescript,a=n.wordCharacters||/[\w$\xa1-\uffff]/,f=function(){function e(e){return{type:e,style:"keyword"}}var t=e("keyword a"),n=e("keyword b"),r=e("keyword c"),i=e("operator"),s={type:"atom",style:"atom"},o={"if":e("if"),"while":t,"with":t,"else":n,"do":n,"try":n,"finally":n,"return":r,"break":r,"continue":r,"new":r,"delete":r,"throw":r,"debugger":r,"var":e("var"),"const":e("var"),let:e("var"),"function":e("function"),"catch":e("catch"),"for":e("for"),"switch":e("switch"),"case":e("case"),"default":e("default"),"in":i,"typeof":i,"instanceof":i,"true":s,"false":s,"null":s,"undefined":s,NaN:s,Infinity:s,"this":e("this"),module:e("module"),"class":e("class"),"super":e("atom"),yield:r,"export":e("export"),"import":e("import"),"extends":r};if(u){var a={type:"variable",style:"variable-3"},f={"interface":e("interface"),"extends":e("extends"),constructor:e("constructor"),"public":e("public"),"private":e("private"),"protected":e("protected"),"static":e("static"),string:a,number:a,bool:a,any:a};for(var l in f)o[l]=f[l]}return o}(),l=/[+\-*&%=<>!?|~^]/,c=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,p,d,w="([{}])",S={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},C={state:null,column:null,marked:null,cc:null},O={name:"this",next:{name:"arguments"}};return P.lex=!0,{startState:function(e){var t={tokenize:m,lastType:"sof",cc:[],lexical:new x((e||0)-r,0,"block",!1),localVars:n.localVars,context:n.localVars&&{vars:n.localVars},indented:0};return n.globalVars&&typeof n.globalVars=="object"&&(t.globalVars=n.globalVars),t},token:function(e,t){e.sol()&&(t.lexical.hasOwnProperty("align")||(t.lexical.align=!1),t.indented=e.indentation(),E(e,t));if(t.tokenize!=y&&e.eatSpace())return null;var n=t.tokenize(e,t);return p=="comment"?n:(t.lastType=p!="operator"||d!="++"&&d!="--"?p:"incdec",N(t,n,p,d,e))},indent:function(t,s){if(t.tokenize==y)return e.Pass;if(t.tokenize!=m)return 0;var o=s&&s.charAt(0),u=t.lexical;if(!/^\s*else\b/.test(s))for(var a=t.cc.length-1;a>=0;--a){var f=t.cc[a];if(f==P)u=u.prev;else if(f!=ft)break}u.type=="stat"&&o=="}"&&(u=u.prev),i&&u.type==")"&&u.prev.type=="stat"&&(u=u.prev);var l=u.type,c=o==l;return l=="vardef"?u.indented+(t.lastType=="operator"||t.lastType==","?u.info+1:0):l=="form"&&o=="{"?u.indented:l=="form"?u.indented+r:l=="stat"?u.indented+(t.lastType=="operator"||t.lastType==","?i||r:0):u.info=="switch"&&!c&&n.doubleIndentSwitch!=0?u.indented+(/^(?:case|default)\b/.test(s)?r:2*r):u.align?u.column+(c?0:1):u.indented+(c?0:r)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:o?null:"/*",blockCommentEnd:o?null:"*/",lineComment:o?null:"//",fold:"brace",helperType:o?"json":"javascript",jsonldMode:s,jsonMode:o}}),e.registerHelper("wordChars","javascript",/[\w$]/),e.defineMIME("text/javascript","javascript"),e.defineMIME("text/ecmascript","javascript"),e.defineMIME("application/javascript","javascript"),e.defineMIME("application/x-javascript","javascript"),e.defineMIME("application/ecmascript","javascript"),e.defineMIME("application/json",{name:"javascript",json:!0}),e.defineMIME("application/x-json",{name:"javascript",json:!0}),e.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),e.defineMIME("text/typescript",{name:"javascript",typescript:!0}),e.defineMIME("application/typescript",{name:"javascript",typescript:!0})}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/hint/xml-hint",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function n(n,r){var i=r&&r.schemaInfo,s=r&&r.quoteChar||'"';if(!i)return;var o=n.getCursor(),u=n.getTokenAt(o);if(/^<\/?$/.test(u.string)&&u.end==o.ch){var a=n.getTokenAt(t(o.line,o.ch+1));a.start==o.ch&&/\btag\b/.test(a.type)&&(u=a)}var f=e.innerMode(n.getMode(),u.state);if(f.mode.name!="xml")return;var l=[],c=!1,h,p=/\btag\b/.test(u.type)&&!/>$/.test(u.string),d=p&&/^\w/.test(u.string),v;if(d){var m=n.getLine(o.line).slice(Math.max(0,u.start-2),u.start),g=/<\/$/.test(m)?"close":/<$/.test(m)?"open":null;g&&(v=u.start-(g=="close"?2:1))}else p&&u.string=="<"?g="open":p&&u.string=="</"&&(g="close");if(!p&&!f.state.tagName||g){d&&(h=u.string),c=g;var y=f.state.context,b=y&&i[y.tagName],w=y?b&&b.children:i["!top"];if(w&&g!="close")for(var E=0;E<w.length;++E)(!h||w[E].lastIndexOf(h,0)==0)&&l.push("<"+w[E]);else if(g!="close")for(var S in i)i.hasOwnProperty(S)&&S!="!top"&&S!="!attrs"&&(!h||S.lastIndexOf(h,0)==0)&&l.push("<"+S);y&&(!h||g=="close"&&y.tagName.lastIndexOf(h,0)==0)&&l.push("</"+y.tagName+">")}else{var b=i[f.state.tagName],x=b&&b.attrs,T=i["!attrs"];if(!x&&!T)return;if(!x)x=T;else if(T){var N={};for(var C in T)T.hasOwnProperty(C)&&(N[C]=T[C]);for(var C in x)x.hasOwnProperty(C)&&(N[C]=x[C]);x=N}if(u.type=="string"||u.string=="="){var m=n.getRange(t(o.line,Math.max(0,o.ch-60)),t(o.line,u.type=="string"?u.start:u.end)),k=m.match(/([^\s\u00a0=<>\"\']+)=$/),L;if(!k||!x.hasOwnProperty(k[1])||!(L=x[k[1]]))return;typeof L=="function"&&(L=L.call(this,n));if(u.type=="string"){h=u.string;var A=0;/['"]/.test(u.string.charAt(0))&&(s=u.string.charAt(0),h=u.string.slice(1),A++);var O=u.string.length;/['"]/.test(u.string.charAt(O-1))&&(s=u.string.charAt(O-1),h=u.string.substr(A,O-2)),c=!0}for(var E=0;E<L.length;++E)(!h||L[E].lastIndexOf(h,0)==0)&&l.push(s+L[E]+s)}else{u.type=="attribute"&&(h=u.string,c=!0);for(var M in x)x.hasOwnProperty(M)&&(!h||M.lastIndexOf(h,0)==0)&&l.push(M)}}return{list:l,from:c?t(o.line,v==null?u.start:v):o,to:c?t(o.line,u.end):o}}var t=e.Pos;e.registerHelper("hint","xml",n)}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror","./xml-hint")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/hint/html-hint",["../../lib/codemirror","./xml-hint"],e):e(CodeMirror)}(function(e){function l(e){for(var t in f)f.hasOwnProperty(t)&&(e.attrs[t]=f[t])}function h(t,n){var r={schemaInfo:a};if(n)for(var i in n)r[i]=n[i];return e.hint.xml(t,r)}var t="ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" "),n=["_blank","_self","_top","_parent"],r=["ascii","utf-8","utf-16","latin1","latin1"],i=["get","post","put","delete"],s=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],o=["all","screen","print","embossed","braille","handheld","print","projection","screen","tty","tv","speech","3d-glasses","resolution [>][<][=] [X]","device-aspect-ratio: X/Y","orientation:portrait","orientation:landscape","device-height: [X]","device-width: [X]"],u={attrs:{}},a={a:{attrs:{href:null,ping:null,type:null,media:o,target:n,hreflang:t}},abbr:u,acronym:u,address:u,applet:u,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:o,hreflang:t,type:null,shape:["default","rect","circle","poly"]}},article:u,aside:u,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["","autoplay"],loop:["","loop"],controls:["","controls"]}},b:u,base:{attrs:{href:null,target:n}},basefont:u,bdi:u,bdo:u,big:u,blockquote:{attrs:{cite:null}},body:u,br:u,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["","autofocus"],disabled:["","autofocus"],formenctype:s,formmethod:i,formnovalidate:["","novalidate"],formtarget:n,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:u,center:u,cite:u,code:u,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["","disabled"],checked:["","checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["","disabled"],multiple:["","multiple"]}},datalist:{attrs:{data:null}},dd:u,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["","open"]}},dfn:u,dir:u,div:u,dl:u,dt:u,em:u,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["","disabled"],form:null,name:null}},figcaption:u,figure:u,font:u,footer:u,form:{attrs:{action:null,name:null,"accept-charset":r,autocomplete:["on","off"],enctype:s,method:i,novalidate:["","novalidate"],target:n}},frame:u,frameset:u,h1:u,h2:u,h3:u,h4:u,h5:u,h6:u,head:{attrs:{},children:["title","base","link","style","meta","script","noscript","command"]},header:u,hgroup:u,hr:u,html:{attrs:{manifest:null},children:["head","body"]},i:u,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["","seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["","autofocus"],checked:["","checked"],disabled:["","disabled"],formenctype:s,formmethod:i,formnovalidate:["","novalidate"],formtarget:n,multiple:["","multiple"],readonly:["","readonly"],required:["","required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:u,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["","autofocus"],disabled:["","disabled"],keytype:["RSA"]}},label:{attrs:{"for":null,form:null}},legend:u,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:t,media:o,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:u,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:r,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:u,noframes:u,noscript:u,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["","typemustmatch"]}},ol:{attrs:{reversed:["","reversed"],start:null,type:["1","a","A","i","I"]}},optgroup:{attrs:{disabled:["","disabled"],label:null}},option:{attrs:{disabled:["","disabled"],label:null,selected:["","selected"],value:null}},output:{attrs:{"for":null,form:null,name:null}},p:u,param:{attrs:{name:null,value:null}},pre:u,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:u,rt:u,ruby:u,s:u,samp:u,script:{attrs:{type:["text/javascript"],src:null,async:["","async"],defer:["","defer"],charset:r}},section:u,select:{attrs:{form:null,name:null,size:null,autofocus:["","autofocus"],disabled:["","disabled"],multiple:["","multiple"]}},small:u,source:{attrs:{src:null,type:null,media:null}},span:u,strike:u,strong:u,style:{attrs:{type:["text/css"],media:o,scoped:null}},sub:u,summary:u,sup:u,table:u,tbody:u,td:{attrs:{colspan:null,rowspan:null,headers:null}},textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["","autofocus"],disabled:["","disabled"],readonly:["","readonly"],required:["","required"],wrap:["soft","hard"]}},tfoot:u,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:u,time:{attrs:{datetime:null}},title:u,tr:u,track:{attrs:{src:null,label:null,"default":null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:t}},tt:u,u:u,ul:u,"var":u,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["","autoplay"],mediagroup:["movie"],muted:["","muted"],controls:["","controls"]}},wbr:u},f={accesskey:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"],"class":null,contenteditable:["true","false"],contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["en","es"],spellcheck:["true","false"],style:null,tabindex:["1","2","3","4","5","6","7","8","9"],title:null,translate:["yes","no"],onclick:null,rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"]};l(u);for(var c in a)a.hasOwnProperty(c)&&a[c]!=u&&l(a[c]);e.htmlSchema=a,e.registerHelper("hint","html",h)}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/hint/show-hint",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function r(e,t){this.cm=e,this.options=this.buildOptions(t),this.widget=this.onClose=null}function i(e){return typeof e=="string"?e:e.text}function s(e,t){function s(e,r){var s;typeof r!="string"?s=function(e){return r(e,t)}:n.hasOwnProperty(r)?s=n[r]:s=r,i[e]=s}var n={Up:function(){t.moveFocus(-1)},Down:function(){t.moveFocus(1)},PageUp:function(){t.moveFocus(-t.menuSize()+1,!0)},PageDown:function(){t.moveFocus(t.menuSize()-1,!0)},Home:function(){t.setFocus(0)},End:function(){t.setFocus(t.length-1)},Enter:t.pick,Tab:t.pick,Esc:t.close},r=e.options.customKeys,i=r?{}:n;if(r)for(var o in r)r.hasOwnProperty(o)&&s(o,r[o]);var u=e.options.extraKeys;if(u)for(var o in u)u.hasOwnProperty(o)&&s(o,u[o]);return i}function o(e,t){while(t&&t!=e){if(t.nodeName.toUpperCase()==="LI"&&t.parentNode==e)return t;t=t.parentNode}}function u(r,u){this.completion=r,this.data=u;var a=this,f=r.cm,l=this.hints=document.createElement("ul");l.className="CodeMirror-hints",this.selectedHint=u.selectedHint||0;var c=u.list;for(var h=0;h<c.length;++h){var p=l.appendChild(document.createElement("li")),d=c[h],v=t+(h!=this.selectedHint?"":" "+n);d.className!=null&&(v=d.className+" "+v),p.className=v,d.render?d.render(p,u,d):p.appendChild(document.createTextNode(d.displayText||i(d))),p.hintId=h}var m=f.cursorCoords(r.options.alignWithWord?u.from:null),g=m.left,y=m.bottom,b=!0;l.style.left=g+"px",l.style.top=y+"px";var w=window.innerWidth||Math.max(document.body.offsetWidth,document.documentElement.offsetWidth),E=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(r.options.container||document.body).appendChild(l);var S=l.getBoundingClientRect(),x=S.bottom-E;if(x>0){var T=S.bottom-S.top,N=m.top-(m.bottom-S.top);if(N-T>0)l.style.top=(y=m.top-T)+"px",b=!1;else if(T>E){l.style.height=E-5+"px",l.style.top=(y=m.bottom-S.top)+"px";var C=f.getCursor();u.from.ch!=C.ch&&(m=f.cursorCoords(C),l.style.left=(g=m.left)+"px",S=l.getBoundingClientRect())}}var k=S.left-w;k>0&&(S.right-S.left>w&&(l.style.width=w-5+"px",k-=S.right-S.left-w),l.style.left=(g=m.left-k)+"px"),f.addKeyMap(this.keyMap=s(r,{moveFocus:function(e,t){a.changeActive(a.selectedHint+e,t)},setFocus:function(e){a.changeActive(e)},menuSize:function(){return a.screenAmount()},length:c.length,close:function(){r.close()},pick:function(){a.pick()},data:u}));if(r.options.closeOnUnfocus){var L;f.on("blur",this.onBlur=function(){L=setTimeout(function(){r.close()},100)}),f.on("focus",this.onFocus=function(){clearTimeout(L)})}var A=f.getScrollInfo();return f.on("scroll",this.onScroll=function(){var e=f.getScrollInfo(),t=f.getWrapperElement().getBoundingClientRect(),n=y+A.top-e.top,i=n-(window.pageYOffset||(document.documentElement||document.body).scrollTop);b||(i+=l.offsetHeight);if(i<=t.top||i>=t.bottom)return r.close();l.style.top=n+"px",l.style.left=g+A.left-e.left+"px"}),e.on(l,"dblclick",function(e){var t=o(l,e.target||e.srcElement);t&&t.hintId!=null&&(a.changeActive(t.hintId),a.pick())}),e.on(l,"click",function(e){var t=o(l,e.target||e.srcElement);t&&t.hintId!=null&&(a.changeActive(t.hintId),r.options.completeOnSingleClick&&a.pick())}),e.on(l,"mousedown",function(){setTimeout(function(){f.focus()},20)}),e.signal(u,"select",c[0],l.firstChild),!0}var t="CodeMirror-hint",n="CodeMirror-hint-active";e.showHint=function(e,t,n){if(!t)return e.showHint(n);n&&n.async&&(t.async=!0);var r={hint:t};if(n)for(var i in n)r[i]=n[i];return e.showHint(r)},e.defineExtension("showHint",function(t){if(this.listSelections().length>1||this.somethingSelected())return;this.state.completionActive&&this.state.completionActive.close();var n=this.state.completionActive=new r(this,t),i=n.options.hint;if(!i)return;e.signal(this,"startCompletion",this);if(!i.async)return n.showHints(i(this,n.options));i(this,function(e){n.showHints(e)},n.options)}),r.prototype={close:function(){if(!this.active())return;this.cm.state.completionActive=null,this.widget&&this.widget.close(),this.onClose&&this.onClose(),e.signal(this.cm,"endCompletion",this.cm)},active:function(){return this.cm.state.completionActive==this},pick:function(t,n){var r=t.list[n];r.hint?r.hint(this.cm,t,r):this.cm.replaceRange(i(r),r.from||t.from,r.to||t.to,"complete"),e.signal(t,"pick",r),this.close()},showHints:function(e){if(!e||!e.list.length||!this.active())return this.close();this.options.completeSingle&&e.list.length==1?this.pick(e,0):this.showWidget(e)},showWidget:function(t){function c(){if(i)return;i=!0,r.close(),r.cm.off("cursorActivity",v),t&&e.signal(t,"close")}function h(){if(i)return;e.signal(t,"update");var n=r.options.hint;n.async?n(r.cm,p,r.options):p(n(r.cm,r.options))}function p(e){t=e;if(i)return;if(!t||!t.list.length)return c();r.widget&&r.widget.close(),r.widget=new u(r,t)}function d(){n&&(l(n),n=0)}function v(){d();var e=r.cm.getCursor(),t=r.cm.getLine(e.line);e.line!=o.line||t.length-e.ch!=a-o.ch||e.ch<o.ch||r.cm.somethingSelected()||e.ch&&s.test(t.charAt(e.ch-1))?r.close():(n=f(h),r.widget&&r.widget.close())}this.widget=new u(this,t),e.signal(t,"shown");var n=0,r=this,i,s=this.options.closeCharacters,o=this.cm.getCursor(),a=this.cm.getLine(o.line).length,f=window.requestAnimationFrame||function(e){return setTimeout(e,1e3/60)},l=window.cancelAnimationFrame||clearTimeout;this.cm.on("cursorActivity",v),this.onClose=c},buildOptions:function(e){var t=this.cm.options.hintOptions,n={};for(var r in a)n[r]=a[r];if(t)for(var r in t)t[r]!==undefined&&(n[r]=t[r]);if(e)for(var r in e)e[r]!==undefined&&(n[r]=e[r]);return n}},u.prototype={close:function(){if(this.completion.widget!=this)return;this.completion.widget=null,this.hints.parentNode.removeChild(this.hints),this.completion.cm.removeKeyMap(this.keyMap);var e=this.completion.cm;this.completion.options.closeOnUnfocus&&(e.off("blur",this.onBlur),e.off("focus",this.onFocus)),e.off("scroll",this.onScroll)},pick:function(){this.completion.pick(this.data,this.selectedHint)},changeActive:function(t,r){t>=this.data.list.length?t=r?this.data.list.length-1:0:t<0&&(t=r?0:this.data.list.length-1);if(this.selectedHint==t)return;var i=this.hints.childNodes[this.selectedHint];i.className=i.className.replace(" "+n,""),i=this.hints.childNodes[this.selectedHint=t],i.className+=" "+n,i.offsetTop<this.hints.scrollTop?this.hints.scrollTop=i.offsetTop-3:i.offsetTop+i.offsetHeight>this.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=i.offsetTop+i.offsetHeight-this.hints.clientHeight+3),e.signal(this.data,"select",this.data.list[this.selectedHint],i)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},e.registerHelper("hint","auto",function(t,n){var r=t.getHelpers(t.getCursor(),"hint"),i;if(r.length)for(var s=0;s<r.length;s++){var o=r[s](t,n);if(o&&o.list.length)return o}else if(i=t.getHelper(t.getCursor(),"hintWords")){if(i)return e.hint.fromList(t,{words:i})}else if(e.hint.anyword)return e.hint.anyword(t,n)}),e.registerHelper("hint","fromList",function(t,n){var r=t.getCursor(),i=t.getTokenAt(r),s=[];for(var o=0;o<n.words.length;o++){var u=n.words[o];u.slice(0,i.string.length)==i.string&&s.push(u)}if(s.length)return{list:s,from:e.Pos(r.line,i.start),to:e.Pos(r.line,i.end)}}),e.commands.autocomplete=e.showHint;var a={hint:e.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:!0,completeOnSingleClick:!1,container:null,customKeys:null,extraKeys:null};e.defineOption("hintOptions",null)}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/mode/xml/xml",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineMode("xml",function(t,n){function l(e,t){function n(n){return t.tokenize=n,n(e,t)}var r=e.next();if(r=="<")return e.eat("!")?e.eat("[")?e.match("CDATA[")?n(p("atom","]]>")):null:e.match("--")?n(p("comment","-->")):e.match("DOCTYPE",!0,!0)?(e.eatWhile(/[\w\._\-]/),n(d(1))):null:e.eat("?")?(e.eatWhile(/[\w\._\-]/),t.tokenize=p("meta","?>"),"meta"):(a=e.eat("/")?"closeTag":"openTag",t.tokenize=c,"tag bracket");if(r=="&"){var i;return e.eat("#")?e.eat("x")?i=e.eatWhile(/[a-fA-F\d]/)&&e.eat(";"):i=e.eatWhile(/[\d]/)&&e.eat(";"):i=e.eatWhile(/[\w\.\-:]/)&&e.eat(";"),i?"atom":"error"}return e.eatWhile(/[^&<]/),null}function c(e,t){var n=e.next();if(n==">"||n=="/"&&e.eat(">"))return t.tokenize=l,a=n==">"?"endTag":"selfcloseTag","tag bracket";if(n=="=")return a="equals",null;if(n=="<"){t.tokenize=l,t.state=y,t.tagName=t.tagStart=null;var r=t.tokenize(e,t);return r?r+" tag error":"tag error"}return/[\'\"]/.test(n)?(t.tokenize=h(n),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function h(e){var t=function(t,n){while(!t.eol())if(t.next()==e){n.tokenize=c;break}return"string"};return t.isInAttribute=!0,t}function p(e,t){return function(n,r){while(!n.eol()){if(n.match(t)){r.tokenize=l;break}n.next()}return e}}function d(e){return function(t,n){var r;while((r=t.next())!=null){if(r=="<")return n.tokenize=d(e+1),n.tokenize(t,n);if(r==">"){if(e==1){n.tokenize=l;break}return n.tokenize=d(e-1),n.tokenize(t,n)}}return"meta"}}function v(e,t,n){this.prev=e.context,this.tagName=t,this.indent=e.indented,this.startOfLine=n;if(o.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)this.noIndent=!0}function m(e){e.context&&(e.context=e.context.prev)}function g(e,t){var n;for(;;){if(!e.context)return;n=e.context.tagName;if(!o.contextGrabbers.hasOwnProperty(n)||!o.contextGrabbers[n].hasOwnProperty(t))return;m(e)}}function y(e,t,n){return e=="openTag"?(n.tagStart=t.column(),b):e=="closeTag"?w:y}function b(e,t,n){return e=="word"?(n.tagName=t.current(),f="tag",x):(f="error",b)}function w(e,t,n){if(e=="word"){var r=t.current();return n.context&&n.context.tagName!=r&&o.implicitlyClosed.hasOwnProperty(n.context.tagName)&&m(n),n.context&&n.context.tagName==r?(f="tag",E):(f="tag error",S)}return f="error",S}function E(e,t,n){return e!="endTag"?(f="error",E):(m(n),y)}function S(e,t,n){return f="error",E(e,t,n)}function x(e,t,n){if(e=="word")return f="attribute",T;if(e=="endTag"||e=="selfcloseTag"){var r=n.tagName,i=n.tagStart;return n.tagName=n.tagStart=null,e=="selfcloseTag"||o.autoSelfClosers.hasOwnProperty(r)?g(n,r):(g(n,r),n.context=new v(n,r,i==n.indented)),y}return f="error",x}function T(e,t,n){return e=="equals"?N:(o.allowMissing||(f="error"),x(e,t,n))}function N(e,t,n){return e=="string"?C:e=="word"&&o.allowUnquoted?(f="string",x):(f="error",x(e,t,n))}function C(e,t,n){return e=="string"?C:x(e,t,n)}var r=t.indentUnit,i=n.multilineTagIndentFactor||1,s=n.multilineTagIndentPastTag;s==null&&(s=!0);var o=n.htmlMode?{autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1},u=n.alignCDATA,a,f;return{startState:function(){return{tokenize:l,state:y,indented:0,tagName:null,tagStart:null,context:null}},token:function(e,t){!t.tagName&&e.sol()&&(t.indented=e.indentation());if(e.eatSpace())return null;a=null;var n=t.tokenize(e,t);return(n||a)&&n!="comment"&&(f=null,t.state=t.state(a||n,e,t),f&&(n=f=="error"?n+" error":f)),n},indent:function(t,n,a){var f=t.context;if(t.tokenize.isInAttribute)return t.tagStart==t.indented?t.stringStartCol+1:t.indented+r;if(f&&f.noIndent)return e.Pass;if(t.tokenize!=c&&t.tokenize!=l)return a?a.match(/^(\s*)/)[0].length:0;if(t.tagName)return s?t.tagStart+t.tagName.length+2:t.tagStart+r*i;if(u&&/<!\[CDATA\[/.test(n))return 0;var h=n&&/^<(\/)?([\w_:\.-]*)/.exec(n);if(h&&h[1])while(f){if(f.tagName==h[2]){f=f.prev;break}if(!o.implicitlyClosed.hasOwnProperty(f.tagName))break;f=f.prev}else if(h)while(f){var p=o.contextGrabbers[f.tagName];if(!p||!p.hasOwnProperty(h[2]))break;f=f.prev}while(f&&!f.startOfLine)f=f.prev;return f?f.indent+r:0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:n.htmlMode?"html":"xml",helperType:n.htmlMode?"html":"xml"}}),e.defineMIME("text/xml","xml"),e.defineMIME("application/xml","xml"),e.mimeModes.hasOwnProperty("text/html")||e.defineMIME("text/html",{name:"xml",htmlMode:!0})}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/runmode/runmode",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.runMode=function(t,n,r,i){var s=e.getMode(e.defaults,n),o=/MSIE \d/.test(navigator.userAgent),u=o&&(document.documentMode==null||document.documentMode<9);if(r.nodeType==1){var a=i&&i.tabSize||e.defaults.tabSize,f=r,l=0;f.innerHTML="",r=function(e,t){if(e=="\n"){f.appendChild(document.createTextNode(u?"\r":e)),l=0;return}var n="";for(var r=0;;){var i=e.indexOf("	",r);if(i==-1){n+=e.slice(r),l+=e.length-r;break}l+=i-r,n+=e.slice(r,i);var s=a-l%a;l+=s;for(var o=0;o<s;++o)n+=" ";r=i+1}if(t){var c=f.appendChild(document.createElement("span"));c.className="cm-"+t.replace(/ +/g," cm-"),c.appendChild(document.createTextNode(n))}else f.appendChild(document.createTextNode(n))}}var c=e.splitLines(t),h=i&&i.state||e.startState(s);for(var p=0,d=c.length;p<d;++p){p&&r("\n");var v=new e.StringStream(c[p]);!v.string&&s.blankLine&&s.blankLine(h);while(!v.eol()){var m=s.token(v,h);r(v.current(),m,p,v.start,h),v.start=v.pos}}}}),define("CodeMirrorEditor",["react","lodash","jquery","./libs/codemirror-4.8/lib/codemirror","./CMLint","./libs/codemirror-4.8/mode/javascript/javascript","./libs/codemirror-4.8/addon/hint/html-hint","./libs/codemirror-4.8/addon/hint/show-hint","./libs/codemirror-4.8/addon/hint/xml-hint","./libs/codemirror-4.8/addon/hint/html-hint","./libs/codemirror-4.8/mode/xml/xml","./libs/codemirror-4.8/addon/runmode/runmode"],function(e,t,n,r,i){function u(e,t){return(!t||t())&&setTimeout(function(){e.state.completionActive||e.showHint({completeSingle:!1})},100),r.Pass}function a(e){return u(e,function(){var t=e.getCursor();return e.getRange(r.Pos(t.line,t.ch-1),t)==="<"})}function f(e){return u(e,function(){var t=e.getTokenAt(e.getCursor());if(t.type!=="string"||!!/['"]/.test(t.string.charAt(t.string.length-1))&&t.string.length!==1){var n=r.innerMode(e.getMode(),t.state).state;return n.tagName}return!1})}var s={div:{attrs:{"rt-props":null,"rt-if":null,"rt-repeat":null,"rt-class":null,"rt-scope":null,valueLink:null,key:null,ref:null,dangerouslySetInnerHTML:null}}},o=r.htmlSchema;return Object.keys(r.htmlSchema).forEach(function(e){o[e].attrs=t.defaults(s.div.attrs,o[e].attrs)}),e.createClass({displayName:"CodeMirrorEditor",propTypes:{id:e.PropTypes.string,readOnly:e.PropTypes.bool,runMode:e.PropTypes.bool,mode:e.PropTypes.string,value:e.PropTypes.string,valueLink:e.PropTypes.string,onChange:e.PropTypes.func},getDefaultProps:function(){return{readOnly:!1,mode:"html"}},getInitialState:function(){return{editorId:t.uniqueId()}},render:function(){var n=t.omit(this.props,["ref","key","value","valueLink","onChange"]);return n.id=this.props.id||this.state.editorId,n.defaultValue=this.props.valueLink?this.props.valueLink():this.props.value,e.DOM.textarea(n)},componentWillUpdate:function(e){var t=e.valueLink?e.valueLink():e.value;this.editor&&this.editor.getValue()!==t&&this.editor.setValue(t||"")},componentDidMount:function(){var e=this.props.valueLink?this.props.valueLink():this.props.value,t={readOnly:this.props.readOnly,lineWrapping:!0,smartIndent:!0,matchBrackets:!0,value:e,lineNumbers:!0,mode:"javascript",gutters:["CodeMirror-linenumbers","rt-annotations"],theme:"solarized"};this.props.mode==="html"?(t.mode="text/html",t.extraKeys={"'<'":u,"'/'":a,"' '":f,"'='":f,"Ctrl-Space":"autocomplete"},t.hintOptions={schemaInfo:o}):t.mode="javascript",this.editor=r.fromTextArea(this.getDOMNode(),t),this.props.readOnly||this.editor.on("change",function(){this.props.valueLink?this.props.valueLink(this.editor.getValue()):this.props.onChange&&this.props.onChange({target:{value:this.editor.getValue()}})}.bind(this))},annotate:function(e){i.annotate(this.editor,e)},clearAnnotations:function(){i.clearMarks(this.editor)},componentWillUnmount:function(){this.editor.toTextArea()}})}),define("playground-fiddle.rt",["react/addons","lodash","./CodeMirrorEditor"],function(e,t,n){function r(e){this.setState({templateHTML:e.target.value})}function i(e){this.setState({templateProps:e.target.value})}function s(e){e.preventDefault()}return function(){return e.createElement("div",{className:"playground"},e.createElement("div",{className:"fiddle-row"},e.createElement("div",{className:"code-area",id:"area-rt"},e.createElement(n,{ref:"editorRT",id:"editor-rt",className:"large-text-area",value:this.state.templateHTML,mode:"html",onChange:r.bind(this)})),e.createElement("div",{className:"code-area",id:"area-code"},e.createElement(n,{ref:"editorCode",id:"editor-code",className:"large-text-area",value:this.state.templateProps,mode:"javascript",onChange:i.bind(this)}))),e.createElement("div",{className:"fiddle-row"},e.createElement("div",{className:"code-area",id:"area-generated"},e.createElement(n,{id:"editor-generated",className:"large-text-area",ref:"editorGenerated",value:this.templateSource,mode:"javascript",readOnly:!0})),e.createElement("div",{className:"code-area",id:"area-result"},e.createElement("div",{id:"result-area",key:"result-area",className:"sample-view"},e.createElement("form",{className:"result-area-form",ref:"mount",onSubmit:s.bind(this)})))))}}),define("playground.rt",["react/addons","lodash","./CodeMirrorEditor"],function(e,t,n){function r(e,t,n){n.preventDefault(),this.setState({currentTab:e[0]})}function i(n,i){return e.createElement("li",{role:"presentation",className:t.keys(t.pick({active:this.state.currentTab===n[0]},t.identity)).join(" "),onClick:r.bind(this,n,i)},e.createElement("a",{"aria-controls":n[1]},n[1]))}function s(e){this.setState({templateHTML:e.target.value})}function o(e){this.setState({templateProps:e.target.value})}function u(e){e.preventDefault()}return function(){return e.createElement("div",{className:"playground"},e.createElement("div",{id:this.props.id+"-myTab",className:"code-area "+this.getLayoutClass()},e.createElement.apply(this,["ul",{className:"nav nav-tabs",role:"tablist"},t.map(this.getTabs(),i.bind(this))]),e.createElement("div",{},this.state.currentTab==="templateHTML"?e.createElement("div",{key:"editorRT",className:"tab-pane active"},e.createElement(n,{ref:"editorRT",className:"large-text-area",style:{border:this.validHTML?"":"2px solid red"},value:this.state.templateHTML,mode:"html",onChange:s.bind(this)})):null,this.state.currentTab==="templateProps"?e.createElement("div",{key:"editorCode",className:"tab-pane active"},e.createElement(n,{ref:"editorCode",className:"large-text-area",style:{border:this.validProps?"":"2px solid red"},value:this.state.templateProps,mode:"javascript",onChange:o.bind(this)})):null,this.state.currentTab==="templateSource"?e.createElement("div",{key:"templateSource",className:"tab-pane active"},e.createElement(n,{className:"large-text-area",value:this.templateSource,mode:"javascript",readOnly:!0})):null)),e.createElement("div",{key:"result-area",className:"result-area "+this.getLayoutClass()},e.createElement("span",{className:"preview-title"}," "),e.createElement("form",{ref:"mount",className:"sample-view",onSubmit:u.bind(this)})),e.createElement("br",{style:{clear:"both"}}))}}),define("playground",["react","jquery","lodash","./playground-fiddle.rt","./playground.rt"],function(React,$,_,pgFiddleTemplate,playgroundTemplate){function showMessage(e,t){e&&e.showMessage&&e.annotate({line:1,message:t})}function clearMessage(e){e&&e.clearAnnotations&&e.clearAnnotations()}function generateRenderFunc(e){return function(){var t=null;try{t=e.apply(this)}catch(n){t=React.DOM.div.apply(this,[{style:{color:"red"}},"Exception:"+n.message])}return React.DOM.div.apply(this,_.flatten([{key:"result"},t]))}}var templateHTML="<div></div>",templateProps="var template = React.createClass({\n   render: templateRT\n});",Playground=React.createClass({displayName:"Playground",mixins:[React.addons.LinkedStateMixin],propTypes:{direction:React.PropTypes.oneOf(["horizontal","vertical"]),codeVisible:React.PropTypes.bool,fiddle:React.PropTypes.bool,templateHTML:React.PropTypes.string,templateProps:React.PropTypes.string,name:React.PropTypes.string},templateSource:"",validHTML:!0,validProps:!0,setTimeout:function(){clearTimeout(this.timeoutID),this.timeoutID=setTimeout.apply(null,arguments)},getDefaultProps:function(){return{direction:"horizontal",codeVisible:!0,fiddle:!1}},getLayoutClass:function(){return this.props.direction==="horizontal"&&"horizontal"||"vertical"},getTabs:function(){return this.props.codeVisible?[["templateHTML","Template"],["templateProps","Class"],["templateSource","Generated code"]]:[["templateHTML","Template"],["templateSource","Generated code"]]},updateSample:function(state){this.generateCode(state),this.validHTML=!0,this.sampleRender=generateRenderFunc(this.sampleFunc);var editor;try{this.validProps=!0,this.sample=eval("(function () {"+this.templateSource+"\n"+state.templateProps+"\n return React.createElement("+state.name+");})()"),clearMessage(this.refs.editorCode)}catch(e){this.validProps=!1,this.sample=null,editor=this.refs.editorCode,this.showError(e,editor)}},showError:function(e,t){var n=this.refs.mount.getDOMNode();this.setTimeout(function(){showMessage(t,e.message),React.render(React.createElement("div",{className:"playground-error"},e.toString()),n)},500)},showErrorAnnotation:function(e,t){var n=this.refs.mount.getDOMNode();this.setTimeout(function(){t.annotate(e),React.render(React.createElement("div",{className:"playground-error"},e.message),n)},500)},clear:function(){var e={templateHTML:templateHTML,templateProps:templateProps};this.setState(e)},generateCode:function(e){var t=e.templateHTML,n=this.refs.editorRT,r=window.reactTemplates.normalizeName(e.name)+"RT",i=null,s=null;try{i=window.reactTemplates.convertTemplateToReact(t.trim().replace(/\r/g,""),{modules:"none",name:r}),clearMessage(n)}catch(o){o.name==="RTCodeError"?s={line:o.line,message:o.message,index:o.index}:s={line:1,message:o.message},this.showErrorAnnotation(s,n),console.log(o)}this.templateSource=i},getInitialState:function(){var e={templateHTML:this.props.templateHTML||templateHTML,templateProps:this.props.templateProps||templateProps,name:this.props.name||"template",currentTab:"templateHTML"};return e},componentDidMount:function(){this.props.fiddle&&(window.addEventListener("resize",this.calcSize),this.calcSize()),this.updateSample(this.state),this.renderSample()},renderSample:function(){var e=this.refs.mount.getDOMNode();this.sample&&React.render(this.sample,e)},componentDidUpdate:function(){this.renderSample()},componentWillUnmount:function(){window.removeEventListener("resize",this.calcSize)},calcSize:function(){var e=$(window).height()-$("#header").height(),t=e/2-10;$(".code-area").each(function(){$(this).height(t)}),this.refs.editorCode.editor.refresh(),this.refs.editorRT.editor.refresh(),this.refs.editorGenerated.editor.refresh()},componentWillUpdate:function(e,t){(t.templateHTML!==this.state.templateHTML||t.templateProps!==this.state.templateProps)&&this.updateSample(t)},render:function(){this.generateCode(this.state);var e=this.props.fiddle?pgFiddleTemplate:playgroundTemplate;return e.apply(this)}});return Playground}),define("CodeMirrorViewer",["react","lodash","jquery","./libs/codemirror-4.8/lib/codemirror","./libs/codemirror-4.8/mode/javascript/javascript","./libs/codemirror-4.8/mode/xml/xml","./libs/codemirror-4.8/addon/runmode/runmode"],function(e,t,n,r){return e.createClass({displayName:"CodeMirrorViewer",propTypes:{id:e.PropTypes.string,mode:e.PropTypes.string,value:e.PropTypes.string,valueLink:e.PropTypes.string},getDefaultProps:function(){return{mode:"html"}},getInitialState:function(){return{editorId:t.uniqueId()}},render:function(){var n=t.omit(this.props,["ref","key","value","valueLink","onChange"]);n.id=this.props.id||this.state.editorId,n.className="cm-s-default";var r=this.props.valueLink?this.props.valueLink():this.props.value;return e.DOM.pre(n,r)},componentWillUpdate:function(e){var t=e.valueLink?e.valueLink():e.value;this.editor&&this.editor.getValue()!==t&&this.editor.setValue(t||"")},componentDidMount:function(){var e=this.props.valueLink?this.props.valueLink():this.props.value,t=this.props.mode;this.props.mode==="html"&&(t="text/html"),this.editor=r.runMode(e,t,this.getDOMNode())},componentWillUnmount:function(){this.editor.toTextArea()}})}),define("examples.rt",["react/addons","lodash","./playground","./CodeMirrorViewer"],function(e,t,n,r){return function(){return e.createElement("div",{id:"examples"},e.createElement("div",{className:"example"},e.createElement("h3",{},"Hello world in React Templates"),e.createElement("p",{},'\n            Simple "Hello world" HTML transformed into React JavaScript code.\n        '),e.createElement(n,t.assign({},{id:"helloExample",direction:"horizontal"},this.state.samples.hello))),e.createElement("div",{className:"example"},e.createElement("h3",{},"rt-if"),e.createElement("p",{},"\n            This shows the use of rt-if.\n        "),e.createElement(n,t.assign({},{id:"ifExample",direction:"horizontal"},this.state.samples.rtIf))),e.createElement("div",{className:"example"},e.createElement("h3",{},"rt-repeat"),e.createElement("p",{},"\n            This uses rt-repeat to show multiple items and rt-scope to create a reusable name for multiple calculations.\n        "),e.createElement(n,t.assign({},{id:"repeatExample",direction:"horizontal"},this.state.samples.repeat))),e.createElement("div",{className:"example"},e.createElement("h3",{},"rt-props"),e.createElement("p",{},"\n            rt-props is used to pass all the original properties set on this component (except the ones used for the component logic: onClick and eventId) to the element that will actually represent this component.\n        "),e.createElement(n,t.assign({},{id:"propsExample",direction:"horizontal"},this.state.samples.props))),e.createElement("div",{className:"example"},e.createElement("h3",{},"Improved todo list"),e.createElement("p",{},"\n            Every project needs a todo list example, so here is ours.\n        "),e.createElement(n,t.assign({},{id:"todoExample",direction:"horizontal"},this.state.samples.todo))),e.createElement("div",{className:"example"},e.createElement("h3",{},"Weather"),e.createElement("p",{},"\n            This example shows working with async events, the usage of regular event handler function pointers instead of lambda expression, and working with two-way binding.\n        "),e.createElement(n,t.assign({},{id:"weatherExample",direction:"horizontal"},this.state.samples.weather))),e.createElement("div",{id:"rt-require",className:"example"},e.createElement("h3",{},"rt-require"),e.createElement("p",{},"\n            This example shows how to load other React components and libraries into a React template and then use them within the template.\n        "),e.createElement(r,t.assign({},{mode:"javascript"},this.state.rtRequire))),e.createElement("div",{id:"amd",className:"example"},e.createElement("h3",{},"AMD"),e.createElement("p",{},"\n            This example shows the rt-require sample output with AMD support.\n        "),e.createElement(r,t.assign({},{mode:"javascript"},this.state.amd))),e.createElement("div",{id:"commonjs",className:"example"},e.createElement("h3",{},"CommonJS"),e.createElement("p",{},"\n            This example shows the rt-require sample output with CommonJS support.\n        "),e.createElement(r,t.assign({},{mode:"javascript"},this.state.cjs))),e.createElement("div",{id:"es6",className:"example"},e.createElement("h3",{},"ES6"),e.createElement("p",{},"\n            This example shows the rt-require sample output with ES6 support.\n        "),e.createElement(r,t.assign({},{mode:"javascript"},this.state.es6))))}}),define("text",["module"],function(e){var t,n,r=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],i=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,s=/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,o=typeof location!="undefined"&&location.href,u=o&&location.protocol&&location.protocol.replace(/\:/,""),a=o&&location.hostname,f=o&&(location.port||undefined),l=[],c=e.config&&e.config()||{};t={version:"2.0.5",strip:function(e){if(e){e=e.replace(i,"");var t=e.match(s);t&&(e=t[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")},createXhr:c.createXhr||function(){var e,t,n;if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;if(typeof ActiveXObject!="undefined")for(t=0;t<3;t+=1){n=r[t];try{e=new ActiveXObject(n)}catch(i){}if(e){r=[n];break}}return e},parseName:function(e){var t,n,r,i=!1,s=e.indexOf("."),o=e.indexOf("./")===0||e.indexOf("../")===0;return s!==-1&&(!o||s>1)?(t=e.substring(0,s),n=e.substring(s+1,e.length)):t=e,r=n||t,s=r.indexOf("!"),s!==-1&&(i=r.substring(s+1)==="strip",r=r.substring(0,s),n?n=r:t=r),{moduleName:t,ext:n,strip:i}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(e,n,r,i){var s,o,u,a=t.xdRegExp.exec(e);return a?(s=a[2],o=a[3],o=o.split(":"),u=o[1],o=o[0],(!s||s===n)&&(!o||o.toLowerCase()===r.toLowerCase())&&(!u&&!o||u===i)):!0},finishLoad:function(e,n,r,i){r=n?t.strip(r):r,c.isBuild&&(l[e]=r),i(r)},load:function(e,n,r,i){if(i.isBuild&&!i.inlineText){r();return}c.isBuild=i.isBuild;var s=t.parseName(e),l=s.moduleName+(s.ext?"."+s.ext:""),h=n.toUrl(l),p=c.useXhr||t.useXhr;!o||p(h,u,a,f)?t.get(h,function(n){t.finishLoad(e,s.strip,n,r)},function(e){r.error&&r.error(e)}):n([l],function(e){t.finishLoad(s.moduleName+"."+s.ext,s.strip,e,r)})},write:function(e,n,r,i){if(l.hasOwnProperty(n)){var s=t.jsEscape(l[n]);r.asModule(e+"!"+n,"define(function () { return '"+s+"';});\n")}},writeFile:function(e,n,r,i,s){var o=t.parseName(n),u=o.ext?"."+o.ext:"",a=o.moduleName+u,f=r.toUrl(o.moduleName+u)+".js";t.load(a,r,function(n){var r=function(e){return i(f,e)};r.asModule=function(e,t){return i.asModule(e,f,t)},t.write(e,a,r,s)},s)}};if(c.env==="node"||!c.env&&typeof process!="undefined"&&process.versions&&!!process.versions.node)n=require.nodeRequire("fs"),t.get=function(e,t){var r=n.readFileSync(e,"utf8");r.indexOf("")===0&&(r=r.substring(1)),t(r)};else if(c.env==="xhr"||!c.env&&t.createXhr())t.get=function(e,n,r,i){var s=t.createXhr(),o;s.open("GET",e,!0);if(i)for(o in i)i.hasOwnProperty(o)&&s.setRequestHeader(o.toLowerCase(),i[o]);c.onXhr&&c.onXhr(s,e),s.onreadystatechange=function(t){var i,o;s.readyState===4&&(i=s.status,i>399&&i<600?(o=new Error(e+" HTTP status: "+i),o.xhr=s,r(o)):n(s.responseText))},s.send(null)};else if(c.env==="rhino"||!c.env&&typeof Packages!="undefined"&&typeof java!="undefined")t.get=function(e,t){var n,r,i="utf-8",s=new java.io.File(e),o=java.lang.System.getProperty("line.separator"),u=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(s),i)),a="";try{n=new java.lang.StringBuffer,r=u.readLine(),r&&r.length()&&r.charAt(0)===65279&&(r=r.substring(1)),n.append(r);while((r=u.readLine())!==null)n.append(o),n.append(r);a=String(n.toString())}finally{u.close()}t(a)};return t}),define("text!samples/hello.code",[],function(){return"var <%= name %> = React.createClass({\n    render: function () {\n        return <%= name %>RT.apply(this);\n    }\n});"}),define("text!samples/hello.rt",[],function(){return"<h2>Hello world</h2>\n"}),define("text!samples/todo.code",[],function(){return"var <%= name %> = React.createClass({\n    mixins: [React.addons.LinkedStateMixin],\n    getInitialState: function () {\n        return {edited: '', todos: [], counter: 0};\n    },\n    add: function () {\n        if (this.state.edited.trim().length === 0) {\n            return;\n        }\n        var newTodo = {value: this.state.edited, done: false, key: this.state.counter};\n        this.setState({todos: this.state.todos.concat(newTodo), edited: '', counter: this.state.counter + 1});\n    },\n    remove: function (todo) {\n        this.setState({todos: _.reject(this.state.todos, todo)});\n    },\n    toggleChecked: function (index) {\n        var todos = _.cloneDeep(this.state.todos);\n        todos[index].done = !todos[index].done;\n        this.setState({todos: todos});\n    },\n    clearDone: function () {\n        this.setState({todos: _.filter(this.state.todos, {done: false})});\n    },\n    render: function () {\n        return <%= name %>RT.apply(this);\n    }\n});"}),define("text!samples/todo.rt",[],function(){return'<div>\n    <strong>{_.filter(this.state.todos, {done:true}).length}</strong>\n    done,\n    <strong>{_.filter(this.state.todos, {done:false}).length}</strong>\n    pending\n    <br/>\n    <div rt-repeat="todo in this.state.todos" key="{todo.key}">\n        <img src="img/samples/delete.png"\n             onClick="()=>this.remove(todo)"\n             title="Remove Todo"\n             style="cursor:pointer"/>\n        <input type="checkbox" checked="{todo.done}"\n               onChange="()=>this.toggleChecked(todoIndex)"/>\n        <span style="text-decoration: {todo.done ? \'line-through\': \'none\'}">{todo.value}</span>\n    </div>\n    <input key="myinput" style="width:130px" type="text"\n           onKeyDown="(e) => if (e.keyCode == 13) { e.preventDefault(); this.add(); }"\n           valueLink="{this.linkState(\'edited\')}"/>\n    <button onClick="()=>this.add()">Add</button><br/>\n    <button onClick="()=>this.clearDone()">Clear done</button>\n</div>'}),define("text!samples/rt-if.code",[],function(){return"var <%= name %> = React.createClass({\n    getInitialState: function () {\n        return {open: false};\n    },\n    toggle: function() {\n        this.setState({open: !this.state.open});\n    },\n    render: function () {\n        return <%= name %>RT.apply(this);\n    }\n});"}),define("text!samples/rt-if.rt",[],function(){return'<div>\n    <h4 style="cursor:pointer" onClick="()=>this.toggle()">\n        Click to {this.state.open ? \'close\' : \'open\'}\n    </h4>\n    <p rt-if="this.state.open">This is my paragraph. It opens and\n                               closes</p>\n</div>'}),define("text!samples/rt-props.code",[],function(){return"var <%= name %> = React.createClass({\n    mixins: [React.addons.LinkedStateMixin],\n    getInitialState: function() {\n        return { key: 'color', val: 'blue' };\n    },\n    getProps: function() {\n        var ret = { style: {\n          color: 'black',\n          backgroundColor: 'white',\n          borderColor: 'black'\n        }};\n        ret.style[this.state.key] = this.state.val;\n        return ret;\n    },\n    render: function () {\n        return <%= name %>RT.apply(this);\n    }\n});"}),define("text!samples/rt-props.rt",[],function(){return'<div>\n    Style:\n    <select valueLink="{this.linkState(\'key\')}">\n        <option value="color">Color</option>\n        <option value="backgroundColor">Background color</option>\n        <option value="borderColor">Border color</option>\n    </select><br/>\n    Value:\n    <select valueLink="{this.linkState(\'val\')}">\n        <option value="blue">Blue</option>\n        <option value="red">Red</option>\n        <option value="yellow">Yellow</option>\n    </select><br/><br/>\n    <div style="padding:5px;text-align:center;border:1px solid"\n         rt-props="this.getProps()">Sample</div>\n</div>'}),define("text!samples/rt-repeat.code",[],function(){return"var <%= name %> = React.createClass({\n    getInitialState: function () {\n        return {\n            items: ['One', 'Two', 'Three']\n        };\n    },\n    render: function () {\n        return <%= name %>RT.apply(this);\n    }\n});"}),define("text!samples/rt-repeat.rt",[],function(){return'<div>\n    <ul>\n        <li rt-repeat="item in this.state.items">{item}</li>\n    </ul>\n</div>'}),define("text!samples/weather.code",[],function(){return"var <%= name %> = React.createClass({\n    mixins: [React.addons.LinkedStateMixin],\n    getInitialState: function() {\n        this.cityIds = [5391959,293397,2643743];\n        this.fetchWeather();\n        return { loading: true, cityToAdd: '', info: [] };\n    },\n    addCity: function() {\n        if (this.state.cityToAdd.trim() == '') {\n            return;\n        }\n        this.setState({ loading: true, cityToAdd: '' });\n        $.get('http://api.openweathermap.org/data/2.5/weather?q=' + this.state.cityToAdd, this.findCityCallback);\n    },\n    findCityCallback: function(result) {\n        if (result.id && !_.contains(this.cityIds, result.id)) {\n            this.cityIds.unshift(result.id);\n            this.fetchWeather();\n        } else {\n            this.setState({ loading: false });\n        }\n    },\n    refresh: function() {\n        this.setState({ loading:true });\n        this.fetchWeather();\n    },\n    fetchWeather: function() {\n       $.get('http://api.openweathermap.org/data/2.5/group?id=' + this.cityIds.join(',') + '&units=metric', this.fetchWeatherCallback);\n    },\n    fetchWeatherCallback: function(result) {\n        this.setState({ loading:false, info: result.list });\n    },\n    render: function () {\n        return <%= name %>RT.apply(this);\n    }\n});"}),define("text!samples/weather.rt",[],function(){return'<div>\n    <h4>Cities weather report</h4>\n    <input placeholder="Type a city to add"\n           style="width:130px"\n           valueLink="{this.linkState(\'cityToAdd\')}"\n           onKeyDown="(e)=>if (e.keyCode === 13) { e.preventDefault(); this.addCity(); }"/>\n    <button onClick="{this.addCity}">Add</button>\n    <div key="preloader" rt-if="this.state.loading">\n        -- Loading --\n    </div>\n    <div rt-repeat="city in this.state.info" key="{city.id}">\n        {cityIndex+1})\n        <img rt-repeat="weather in city.weather"\n             src="http://openweathermap.org/img/w/{weather.icon}.png"\n             title="{weather.description}"/>\n        <span style="white-space:nowrap">{city.name}, {city.sys.country}</span>\n    </div>\n    <button onClick="{this.refresh}">Refresh</button>\n</div>'}),define("text!samples/rt-require.rt",[],function(){return'<rt-require dependency="comps/myComp" as="myComp"/>\n<rt-require dependency="utils/utils" as="utils"/>\n<div>\n    <myComp customProp="{utils.doSomething()}">myComp is just a regular tag</myComp>\n</div>\n'}),define("examples",["lodash","react","./examples.rt","text!./samples/hello.code","text!./samples/hello.rt","text!./samples/todo.code","text!./samples/todo.rt","text!./samples/rt-if.code","text!./samples/rt-if.rt","text!./samples/rt-props.code","text!./samples/rt-props.rt","text!./samples/rt-repeat.code","text!./samples/rt-repeat.rt","text!./samples/weather.code","text!./samples/weather.rt","text!./samples/rt-require.rt"],function(e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v){var m={hello:[r,i],todo:[s,o],props:[f,l],rtIf:[u,a],repeat:[c,h],weather:[p,d]};Object.keys(m).forEach(function(t){m[t]={name:t,templateProps:e.template(m[t][0],{name:t}),templateHTML:m[t][1]}});var g=t.createClass({displayName:"Examples",mixins:[t.addons.LinkedStateMixin],getInitialState:function(){var e=window.reactTemplates.convertTemplateToReact(v,{modules:"amd",name:"template"}),t=window.reactTemplates.convertTemplateToReact(v,{modules:"commonjs",name:"template"}),n=window.reactTemplates.convertTemplateToReact(v,{modules:"es6",name:"template"});return{rtRequire:{value:v},amd:{value:e},cjs:{value:t},es6:{value:n},samples:m}},render:n});return g}),requirejs.config({paths:{lodash:"//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min",jquery:"//code.jquery.com/jquery-2.1.4.min",firebase:"https://cdn.firebase.com/js/client/2.0.5/firebase",react:"//fb.me/react-with-addons-0.12.2",text:"libs/requirejs-plugins/text",json:"libs/requirejs-plugins/json"},shim:{lodash:{exports:"_"},firebase:{exports:"Firebase"},jquery:{exports:"$"},react:{exports:"React"}},map:{"*":{"react/addons":"react"}}}),requirejs(["jquery","react","./examples"],function(e,t,n){var r=t.createElement(n);t.render(r,document.getElementById("home-section"))}),define("home-main.js",function(){});
\ No newline at end of file
+(function(e){if(typeof exports=="object"&&typeof module=="object")module.exports=e();else{if(typeof define=="function"&&define.amd)return define("libs/codemirror-4.8/lib/codemirror",[],e);this.CodeMirror=e()}})(function(){function S(e,t){if(!(this instanceof S))return new S(e,t);this.options=t=t?zo(t):{},zo(fi,t,!1),H(t);var n=t.value;typeof n=="string"&&(n=new js(n,t.mode)),this.doc=n;var s=this.display=new x(e,n);s.wrapper.CodeMirror=this,M(this),A(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),t.autofocus&&!d&&er(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Do,keySeq:null},r&&i<11&&setTimeout(Wo(Zn,this,!0),20),rr(this),fu(),kn(this),this.curOp.forceUpdate=!0,Rs(this,n),t.autofocus&&!d||nu()==s.input?setTimeout(Wo(Pr,this),20):Hr(this);for(var o in li)li.hasOwnProperty(o)&&li[o](this,t[o],hi);R(this);for(var u=0;u<mi.length;++u)mi[u](this);An(this)}function x(e,t){var n=this,o=n.input=Go("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none");s?o.style.width="1000px":o.setAttribute("wrap","off"),p&&(o.style.border="1px solid black"),o.setAttribute("autocorrect","off"),o.setAttribute("autocapitalize","off"),o.setAttribute("spellcheck","false"),n.inputDiv=Go("div",[o],null,"overflow: hidden; position: relative; width: 3px; height: 0px;"),n.scrollbarH=Go("div",[Go("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar"),n.scrollbarV=Go("div",[Go("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),n.scrollbarFiller=Go("div",null,"CodeMirror-scrollbar-filler"),n.gutterFiller=Go("div",null,"CodeMirror-gutter-filler"),n.lineDiv=Go("div",null,"CodeMirror-code"),n.selectionDiv=Go("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=Go("div",null,"CodeMirror-cursors"),n.measure=Go("div",null,"CodeMirror-measure"),n.lineMeasure=Go("div",null,"CodeMirror-measure"),n.lineSpace=Go("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none"),n.mover=Go("div",[Go("div",[n.lineSpace],"CodeMirror-lines")],null,"position: relative"),n.sizer=Go("div",[n.mover],"CodeMirror-sizer"),n.heightForcer=Go("div",null,null,"position: absolute; height: "+Lo+"px; width: 1px;"),n.gutters=Go("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=Go("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=Go("div",[n.inputDiv,n.scrollbarH,n.scrollbarV,n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),r&&i<8&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),p&&(o.style.width="0px"),s||(n.scroller.draggable=!0),l&&(n.inputDiv.style.height="1px",n.inputDiv.style.position="absolute"),r&&i<8&&(n.scrollbarH.style.minHeight=n.scrollbarV.style.minWidth="18px"),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.view=[],n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.prevInput="",n.alignWidgets=!1,n.pollingFast=!1,n.poll=new Do,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.inaccurateSelection=!1,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null}function T(e){e.doc.mode=S.getMode(e.options,e.doc.modeOption),N(e)}function N(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,Xt(e,100),e.state.modeGen++,e.curOp&&Un(e)}function C(e){e.options.lineWrapping?(su(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth=""):(iu(e.display.wrapper,"CodeMirror-wrap"),P(e)),L(e),Un(e),cn(e),setTimeout(function(){F(e)},100)}function k(e){var t=xn(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/Tn(e.display)-3);return function(i){if(ss(e.doc,i))return 0;var s=0;if(i.widgets)for(var o=0;o<i.widgets.length;o++)i.widgets[o].height&&(s+=i.widgets[o].height);return n?s+(Math.ceil(i.text.length/r)||1)*t:s+t}}function L(e){var t=e.doc,n=k(e);t.iter(function(e){var t=n(e);t!=e.height&&Xs(e,t)})}function A(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),cn(e)}function O(e){M(e),Un(e),setTimeout(function(){q(e)},20)}function M(e){var t=e.display.gutters,n=e.options.gutters;Zo(t);for(var r=0;r<n.length;++r){var i=n[r],s=t.appendChild(Go("div",null,"CodeMirror-gutter "+i));i=="CodeMirror-linenumbers"&&(e.display.lineGutter=s,s.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=r?"":"none",_(e)}function _(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px",e.display.scrollbarH.style.left=e.options.fixedGutter?t+"px":0}function D(e){if(e.height==0)return 0;var t=e.text.length,n,r=e;while(n=Yi(r)){var i=n.find(0,!0);r=i.from.line,t+=i.from.ch-i.to.ch}r=e;while(n=Zi(r)){var i=n.find(0,!0);t-=r.text.length-i.from.ch,r=i.to.line,t+=r.text.length-i.to.ch}return t}function P(e){var t=e.display,n=e.doc;t.maxLine=Us(n,n.first),t.maxLineLength=D(t.maxLine),t.maxLineChanged=!0,n.iter(function(e){var n=D(e);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}function H(e){var t=qo(e.gutters,"CodeMirror-linenumbers");t==-1&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function B(e){return e.display.scroller.clientHeight-e.display.wrapper.clientHeight<Lo-3}function j(e){var t=e.display.scroller;return{clientHeight:t.clientHeight,barHeight:e.display.scrollbarV.clientHeight,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth,hScrollbarTakesSpace:B(e),barWidth:e.display.scrollbarH.clientWidth,docHeight:Math.round(e.doc.height+Qt(e.display))}}function F(e,t){t||(t=j(e));var n=e.display,r=pu(n.measure),i=t.docHeight+Lo,s=t.scrollWidth>t.clientWidth;s&&t.scrollWidth<=t.clientWidth+1&&r>0&&!t.hScrollbarTakesSpace&&(s=!1);var o=i>t.clientHeight;o?(n.scrollbarV.style.display="block",n.scrollbarV.style.bottom=s?r+"px":"0",n.scrollbarV.firstChild.style.height=Math.max(0,i-t.clientHeight+(t.barHeight||n.scrollbarV.clientHeight))+"px"):(n.scrollbarV.style.display="",n.scrollbarV.firstChild.style.height="0"),s?(n.scrollbarH.style.display="block",n.scrollbarH.style.right=o?r+"px":"0",n.scrollbarH.firstChild.style.width=t.scrollWidth-t.clientWidth+(t.barWidth||n.scrollbarH.clientWidth)+"px"):(n.scrollbarH.style.display="",n.scrollbarH.firstChild.style.width="0"),s&&o?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=n.scrollbarFiller.style.width=r+"px"):n.scrollbarFiller.style.display="",s&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r+"px",n.gutterFiller.style.width=n.gutters.offsetWidth+"px"):n.gutterFiller.style.display="";if(!e.state.checkedOverlayScrollbar&&t.clientHeight>0){if(r===0){var u=v&&!c?"12px":"18px";n.scrollbarV.style.minWidth=n.scrollbarH.style.minHeight=u;var a=function(t){mo(t)!=n.scrollbarV&&mo(t)!=n.scrollbarH&&jn(e,ur)(t)};yo(n.scrollbarV,"mousedown",a),yo(n.scrollbarH,"mousedown",a)}e.state.checkedOverlayScrollbar=!0}}function I(e,t,n){var r=n&&n.top!=null?Math.max(0,n.top):e.scroller.scrollTop;r=Math.floor(r-Kt(e));var i=n&&n.bottom!=null?n.bottom:r+e.wrapper.clientHeight,s=$s(t,r),o=$s(t,i);if(n&&n.ensure){var u=n.ensure.from.line,a=n.ensure.to.line;if(u<s)return{from:u,to:$s(t,Js(Us(t,u))+e.wrapper.clientHeight)};if(Math.min(a,t.lastLine())>=o)return{from:$s(t,Js(Us(t,a))-e.wrapper.clientHeight),to:a}}return{from:s,to:Math.max(o,s+1)}}function q(e){var t=e.display,n=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter))return;var r=z(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,s=r+"px";for(var o=0;o<n.length;o++)if(!n[o].hidden){e.options.fixedGutter&&n[o].gutter&&(n[o].gutter.style.left=s);var u=n[o].alignable;if(u)for(var a=0;a<u.length;a++)u[a].style.left=s}e.options.fixedGutter&&(t.gutters.style.left=r+i+"px")}function R(e){if(!e.options.lineNumbers)return!1;var t=e.doc,n=U(e.options,t.first+t.size-1),r=e.display;if(n.length!=r.lineNumChars){var i=r.measure.appendChild(Go("div",[Go("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),s=i.firstChild.offsetWidth,o=i.offsetWidth-s;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(s,r.lineGutter.offsetWidth-o),r.lineNumWidth=r.lineNumInnerWidth+o,r.lineNumChars=r.lineNumInnerWidth?n.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",_(e),!0}return!1}function U(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function z(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function W(e,t,n){var r=e.display;this.viewport=t,this.visible=I(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldViewFrom=r.viewFrom,this.oldViewTo=r.viewTo,this.oldScrollerWidth=r.scroller.clientWidth,this.force=n,this.dims=Y(e)}function X(e,t){var n=e.display,r=e.doc;if(t.editorIsHidden)return Wn(e),!1;if(!t.force&&t.visible.from>=n.viewFrom&&t.visible.to<=n.viewTo&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo)&&Jn(e)==0)return!1;R(e)&&(Wn(e),t.dims=Y(e));var i=r.first+r.size,s=Math.max(t.visible.from-e.options.viewportMargin,r.first),o=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFrom<s&&s-n.viewFrom<20&&(s=Math.max(r.first,n.viewFrom)),n.viewTo>o&&n.viewTo-o<20&&(o=Math.min(i,n.viewTo)),E&&(s=rs(e.doc,s),o=is(e.doc,o));var u=s!=n.viewFrom||o!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;$n(e,s,o),n.viewOffset=Js(Us(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var a=Jn(e);if(!u&&a==0&&!t.force&&(n.updateLineNumbers==null||n.updateLineNumbers>=n.viewTo))return!1;var f=nu();return a>4&&(n.lineDiv.style.display="none"),Z(e,n.updateLineNumbers,t.dims),a>4&&(n.lineDiv.style.display=""),f&&nu()!=f&&f.offsetHeight&&f.focus(),Zo(n.cursorDiv),Zo(n.selectionDiv),u&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,Xt(e,400)),n.updateLineNumbers=null,!0}function V(e,t){var n=t.force,r=t.viewport;for(var i=!0;;i=!1){if(i&&e.options.lineWrapping&&t.oldScrollerWidth!=e.display.scroller.clientWidth)n=!0;else{n=!1,r&&r.top!=null&&(r={top:Math.min(e.doc.height+Qt(e.display)-Lo-e.display.scroller.clientHeight,r.top)}),t.visible=I(e.display,e.doc,r);if(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break}if(!X(e,t))break;Q(e);var s=j(e);Rt(e),J(e,s),F(e,s)}So(e,"update",e),(e.display.viewFrom!=t.oldViewFrom||e.display.viewTo!=t.oldViewTo)&&So(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo)}function $(e,t){var n=new W(e,t);if(X(e,n)){Q(e),V(e,n);var r=j(e);Rt(e),J(e,r),F(e,r)}}function J(e,t){e.display.sizer.style.minHeight=e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=Math.max(t.docHeight,t.clientHeight-Lo)+"px"}function K(e,t){e.display.sizer.offsetWidth+e.display.gutters.offsetWidth<e.display.scroller.clientWidth-1&&(e.display.sizer.style.minHeight=e.display.heightForcer.style.top="0px",e.display.gutters.style.height=t.docHeight+"px")}function Q(e){var t=e.display,n=t.lineDiv.offsetTop;for(var s=0;s<t.view.length;s++){var o=t.view[s],u;if(o.hidden)continue;if(r&&i<8){var a=o.node.offsetTop+o.node.offsetHeight;u=a-n,n=a}else{var f=o.node.getBoundingClientRect();u=f.bottom-f.top}var l=o.line.height-u;u<2&&(u=xn(t));if(l>.001||l<-0.001){Xs(o.line,u),G(o.line);if(o.rest)for(var c=0;c<o.rest.length;c++)G(o.rest[c])}}}function G(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function Y(e){var t=e.display,n={},r={},i=t.gutters.clientLeft;for(var s=t.gutters.firstChild,o=0;s;s=s.nextSibling,++o)n[e.options.gutters[o]]=s.offsetLeft+s.clientLeft+i,r[e.options.gutters[o]]=s.clientWidth;return{fixedPos:z(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Z(e,t,n){function a(t){var n=t.nextSibling;return s&&v&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}var r=e.display,i=e.options.lineNumbers,o=r.lineDiv,u=o.firstChild,f=r.view,l=r.viewFrom;for(var c=0;c<f.length;c++){var h=f[c];if(!h.hidden)if(!h.node){var p=at(e,h,l,n);o.insertBefore(p,u)}else{while(u!=h.node)u=a(u);var d=i&&t!=null&&t<=l&&h.lineNumber;h.changes&&(qo(h.changes,"gutter")>-1&&(d=!1),et(e,h,l,n)),d&&(Zo(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(U(e.options,l)))),u=h.node.nextSibling}l+=h.size}while(u)u=a(u)}function et(e,t,n,r){for(var i=0;i<t.changes.length;i++){var s=t.changes[i];s=="text"?it(e,t):s=="gutter"?ot(e,t,n,r):s=="class"?st(t):s=="widget"&&ut(t,r)}t.changes=null}function tt(e){return e.node==e.text&&(e.node=Go("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),r&&i<8&&(e.node.style.zIndex=2)),e.node}function nt(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;t&&(t+=" CodeMirror-linebackground");if(e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var n=tt(e);e.background=n.insertBefore(Go("div",null,t),n.firstChild)}}function rt(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Ns(e,t)}function it(e,t){var n=t.text.className,r=rt(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,st(t)):n&&(t.text.className=n)}function st(e){nt(e),e.line.wrapClass?tt(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function ot(e,t,n,r){t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null);var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var s=tt(t),o=t.gutter=s.insertBefore(Go("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),t.text);t.line.gutterClass&&(o.className+=" "+t.line.gutterClass),e.options.lineNumbers&&(!i||!i["CodeMirror-linenumbers"])&&(t.lineNumber=o.appendChild(Go("div",U(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px")));if(i)for(var u=0;u<e.options.gutters.length;++u){var a=e.options.gutters[u],f=i.hasOwnProperty(a)&&i[a];f&&o.appendChild(Go("div",[f],"CodeMirror-gutter-elt","left: "+r.gutterLeft[a]+"px; width: "+r.gutterWidth[a]+"px"))}}}function ut(e,t){e.alignable&&(e.alignable=null);for(var n=e.node.firstChild,r;n;n=r){var r=n.nextSibling;n.className=="CodeMirror-linewidget"&&e.node.removeChild(n)}ft(e,t)}function at(e,t,n,r){var i=rt(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),st(t),ot(e,t,n,r),ft(t,r),t.node}function ft(e,t){lt(e.line,e,t,!0);if(e.rest)for(var n=0;n<e.rest.length;n++)lt(e.rest[n],e,t,!1)}function lt(e,t,n,r){if(!e.widgets)return;var i=tt(t);for(var s=0,o=e.widgets;s<o.length;++s){var u=o[s],a=Go("div",[u.node],"CodeMirror-linewidget");u.handleMouseEvents||(a.ignoreEvents=!0),ct(u,a,t,n),r&&u.above?i.insertBefore(a,t.gutter||t.text):i.appendChild(a),So(u,"redraw")}}function ct(e,t,n,r){if(e.noHScroll){(n.alignable||(n.alignable=[])).push(t);var i=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(i-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function dt(e){return ht(e.line,e.ch)}function vt(e,t){return pt(e,t)<0?t:e}function mt(e,t){return pt(e,t)<0?e:t}function gt(e,t){this.ranges=e,this.primIndex=t}function yt(e,t){this.anchor=e,this.head=t}function bt(e,t){var n=e[t];e.sort(function(e,t){return pt(e.from(),t.from())}),t=qo(e,n);for(var r=1;r<e.length;r++){var i=e[r],s=e[r-1];if(pt(s.to(),i.from())>=0){var o=mt(s.from(),i.from()),u=vt(s.to(),i.to()),a=s.empty()?i.from()==i.head:s.from()==s.head;r<=t&&--t,e.splice(--r,2,new yt(a?u:o,a?o:u))}}return new gt(e,t)}function wt(e,t){return new gt([new yt(e,t||e)],0)}function Et(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function St(e,t){if(t.line<e.first)return ht(e.first,0);var n=e.first+e.size-1;return t.line>n?ht(n,Us(e,n).text.length):xt(t,Us(e,t.line).text.length)}function xt(e,t){var n=e.ch;return n==null||n>t?ht(e.line,t):n<0?ht(e.line,0):e}function Tt(e,t){return t>=e.first&&t<e.first+e.size}function Nt(e,t){for(var n=[],r=0;r<t.length;r++)n[r]=St(e,t[r]);return n}function Ct(e,t,n,r){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(r){var s=pt(n,i)<0;s!=pt(r,i)<0?(i=n,n=r):s!=pt(n,r)<0&&(n=r)}return new yt(i,n)}return new yt(r||n,n)}function kt(e,t,n,r){Dt(e,new gt([Ct(e,e.sel.primary(),t,n)],0),r)}function Lt(e,t,n){for(var r=[],i=0;i<e.sel.ranges.length;i++)r[i]=Ct(e,e.sel.ranges[i],t[i],null);var s=bt(r,e.sel.primIndex);Dt(e,s,n)}function At(e,t,n,r){var i=e.sel.ranges.slice(0);i[t]=n,Dt(e,bt(i,e.sel.primIndex),r)}function Ot(e,t,n,r){Dt(e,wt(t,n),r)}function Mt(e,t){var n={ranges:t.ranges,update:function(t){this.ranges=[];for(var n=0;n<t.length;n++)this.ranges[n]=new yt(St(e,t[n].anchor),St(e,t[n].head))}};return wo(e,"beforeSelectionChange",e,n),e.cm&&wo(e.cm,"beforeSelectionChange",e.cm,n),n.ranges!=t.ranges?bt(n.ranges,n.ranges.length-1):t}function _t(e,t,n){var r=e.history.done,i=Fo(r);i&&i.ranges?(r[r.length-1]=t,Pt(e,t,n)):Dt(e,t,n)}function Dt(e,t,n){Pt(e,t,n),no(e,e.sel,e.cm?e.cm.curOp.id:NaN,n)}function Pt(e,t,n){if(Co(e,"beforeSelectionChange")||e.cm&&Co(e.cm,"beforeSelectionChange"))t=Mt(e,t);var r=n&&n.bias||(pt(t.primary().head,e.sel.primary().head)<0?-1:1);Ht(e,jt(e,t,r,!0)),(!n||n.scroll!==!1)&&e.cm&&ni(e.cm)}function Ht(e,t){if(t.equals(e.sel))return;e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,No(e.cm)),So(e,"cursorActivity",e)}function Bt(e){Ht(e,jt(e,e.sel,null,!1),Oo)}function jt(e,t,n,r){var i;for(var s=0;s<t.ranges.length;s++){var o=t.ranges[s],u=Ft(e,o.anchor,n,r),a=Ft(e,o.head,n,r);if(i||u!=o.anchor||a!=o.head)i||(i=t.ranges.slice(0,s)),i[s]=new yt(u,a)}return i?bt(i,t.primIndex):t}function Ft(e,t,n,r){var i=!1,s=t,o=n||1;e.cantEdit=!1;e:for(;;){var u=Us(e,s.line);if(u.markedSpans)for(var a=0;a<u.markedSpans.length;++a){var f=u.markedSpans[a],l=f.marker;if((f.from==null||(l.inclusiveLeft?f.from<=s.ch:f.from<s.ch))&&(f.to==null||(l.inclusiveRight?f.to>=s.ch:f.to>s.ch))){if(r){wo(l,"beforeCursorEnter");if(l.explicitlyCleared){if(!u.markedSpans)break;--a;continue}}if(!l.atomic)continue;var c=l.find(o<0?-1:1);if(pt(c,s)==0){c.ch+=o,c.ch<0?c.line>e.first?c=St(e,ht(c.line-1)):c=null:c.ch>u.text.length&&(c.line<e.first+e.size-1?c=ht(c.line+1,0):c=null);if(!c){if(i)return r?(e.cantEdit=!0,ht(e.first,0)):Ft(e,t,n,!0);i=!0,c=t,o=-o}}s=c;continue e}}return s}}function It(e){var t=e.display,n=e.doc,r={},i=r.cursors=document.createDocumentFragment(),s=r.selection=document.createDocumentFragment();for(var o=0;o<n.sel.ranges.length;o++){var u=n.sel.ranges[o],a=u.empty();(a||e.options.showCursorWhenSelecting)&&Ut(e,u,i),a||zt(e,u,s)}if(e.options.moveInputWithCursor){var f=gn(e,n.sel.primary().head,"div"),l=t.wrapper.getBoundingClientRect(),c=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,f.top+c.top-l.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,f.left+c.left-l.left))}return r}function qt(e,t){eu(e.display.cursorDiv,t.cursors),eu(e.display.selectionDiv,t.selection),t.teTop!=null&&(e.display.inputDiv.style.top=t.teTop+"px",e.display.inputDiv.style.left=t.teLeft+"px")}function Rt(e){qt(e,It(e))}function Ut(e,t,n){var r=gn(e,t.head,"div",null,null,!e.options.singleCursorHeightPerLine),i=n.appendChild(Go("div"," ","CodeMirror-cursor"));i.style.left=r.left+"px",i.style.top=r.top+"px",i.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px";if(r.other){var s=n.appendChild(Go("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));s.style.display="",s.style.left=r.other.left+"px",s.style.top=r.other.top+"px",s.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function zt(e,t,n){function f(e,t,n,r){t<0&&(t=0),t=Math.round(t),r=Math.round(r),s.appendChild(Go("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(n==null?a-e:n)+"px; height: "+(r-t)+"px"))}function l(t,n,r){function h(n,r){return mn(e,ht(t,n),"div",s,r)}var s=Us(i,t),o=s.text.length,l,c;return Tu(Ks(s),n||0,r==null?o:r,function(e,t,i){var s=h(e,"left"),p,d,v;if(e==t)p=s,d=v=s.left;else{p=h(t-1,"right");if(i=="rtl"){var m=s;s=p,p=m}d=s.left,v=p.right}n==null&&e==0&&(d=u),p.top-s.top>3&&(f(d,s.top,null,s.bottom),d=u,s.bottom<p.top&&f(d,s.bottom,null,p.top)),r==null&&t==o&&(v=a);if(!l||s.top<l.top||s.top==l.top&&s.left<l.left)l=s;if(!c||p.bottom>c.bottom||p.bottom==c.bottom&&p.right>c.right)c=p;d<u+1&&(d=u),f(d,p.top,v-d,p.bottom)}),{start:l,end:c}}var r=e.display,i=e.doc,s=document.createDocumentFragment(),o=Gt(e.display),u=o.left,a=r.lineSpace.offsetWidth-o.right,c=t.from(),h=t.to();if(c.line==h.line)l(c.line,c.ch,h.ch);else{var p=Us(i,c.line),d=Us(i,h.line),v=ts(p)==ts(d),m=l(c.line,c.ch,v?p.text.length+1:null).end,g=l(h.line,v?0:null,h.ch).start;v&&(m.top<g.top-2?(f(m.right,m.top,null,m.bottom),f(u,g.top,g.left,g.bottom)):f(m.right,m.top,g.left-m.right,m.bottom)),m.bottom<g.top&&f(u,m.bottom,null,g.top)}n.appendChild(s)}function Wt(e){if(!e.state.focused)return;var t=e.display;clearInterval(t.blinker);var n=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}function Xt(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,Wo(Vt,e))}function Vt(e){var t=e.doc;t.frontier<t.first&&(t.frontier=t.first);if(t.frontier>=e.display.viewTo)return;var n=+(new Date)+e.options.workTime,r=yi(t.mode,Jt(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(s){if(t.frontier>=e.display.viewFrom){var o=s.styles,u=bs(e,s,r,!0);s.styles=u.styles;var a=s.styleClasses,f=u.classes;f?s.styleClasses=f:a&&(s.styleClasses=null);var l=!o||o.length!=s.styles.length||a!=f&&(!a||!f||a.bgClass!=f.bgClass||a.textClass!=f.textClass);for(var c=0;!l&&c<o.length;++c)l=o[c]!=s.styles[c];l&&i.push(t.frontier),s.stateAfter=yi(t.mode,r)}else Es(e,s.text,r),s.stateAfter=t.frontier%5==0?yi(t.mode,r):null;++t.frontier;if(+(new Date)>n)return Xt(e,e.options.workDelay),!0}),i.length&&Bn(e,function(){for(var t=0;t<i.length;t++)zn(e,i[t],"text")})}function $t(e,t,n){var r,i,s=e.doc,o=n?-1:t-(e.doc.mode.innerMode?1e3:100);for(var u=t;u>o;--u){if(u<=s.first)return s.first;var a=Us(s,u-1);if(a.stateAfter&&(!n||u<=s.frontier))return u;var f=Po(a.text,null,e.options.tabSize);if(i==null||r>f)i=u-1,r=f}return i}function Jt(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return!0;var s=$t(e,t,n),o=s>r.first&&Us(r,s-1).stateAfter;return o?o=yi(r.mode,o):o=bi(r.mode),r.iter(s,t,function(n){Es(e,n.text,o);var u=s==t-1||s%5==0||s>=i.viewFrom&&s<i.viewTo;n.stateAfter=u?yi(r.mode,o):null,++s}),n&&(r.frontier=s),o}function Kt(e){return e.lineSpace.offsetTop}function Qt(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Gt(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=eu(e.measure,Go("pre","x")),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return!isNaN(r.left)&&!isNaN(r.right)&&(e.cachedPaddingH=r),r}function Yt(e,t,n){var r=e.options.lineWrapping,i=r&&e.display.scroller.clientWidth;if(!t.measure.heights||r&&t.measure.width!=i){var s=t.measure.heights=[];if(r){t.measure.width=i;var o=t.text.firstChild.getClientRects();for(var u=0;u<o.length-1;u++){var a=o[u],f=o[u+1];Math.abs(a.bottom-f.bottom)>2&&s.push((a.bottom+f.top)/2-n.top)}}s.push(n.bottom-n.top)}}function Zt(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var r=0;r<e.rest.length;r++)if(Vs(e.rest[r])>n)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}function en(e,t){t=ts(t);var n=Vs(t),r=e.display.externalMeasured=new qn(e.doc,t,n);r.lineN=n;var i=r.built=Ns(e,r);return r.text=i.pre,eu(e.display.lineMeasure,i.pre),r}function tn(e,t,n,r){return sn(e,rn(e,t),n,r)}function nn(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[Xn(e,t)];var n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size)return n}function rn(e,t){var n=Vs(t),r=nn(e,n);r&&!r.text?r=null:r&&r.changes&&et(e,r,n,Y(e)),r||(r=en(e,t));var i=Zt(r,t,n);return{line:t,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function sn(e,t,n,r,i){t.before&&(n=-1);var s=n+(r||""),o;return t.cache.hasOwnProperty(s)?o=t.cache[s]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(Yt(e,t.view,t.rect),t.hasHeights=!0),o=un(e,t,n,r),o.bogus||(t.cache[s]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}function un(e,t,n,s){var o=t.map,u,a,f,l;for(var c=0;c<o.length;c+=3){var h=o[c],p=o[c+1];if(n<h)a=0,f=1,l="left";else if(n<p)a=n-h,f=a+1;else if(c==o.length-3||n==p&&o[c+3]>n)f=p-h,a=f-1,n>=p&&(l="right");if(a!=null){u=o[c+2],h==p&&s==(u.insertLeft?"left":"right")&&(l=s);if(s=="left"&&a==0)while(c&&o[c-2]==o[c-3]&&o[c-1].insertLeft)u=o[(c-=3)+2],l="left";if(s=="right"&&a==p-h)while(c<o.length-3&&o[c+3]==o[c+4]&&!o[c+5].insertLeft)u=o[(c+=3)+2],l="right";break}}var d;if(u.nodeType==3){for(var c=0;c<4;c++){while(a&&Qo(t.line.text.charAt(h+a)))--a;while(h+f<p&&Qo(t.line.text.charAt(h+f)))++f;if(r&&i<9&&a==0&&f==p-h)d=u.parentNode.getBoundingClientRect();else if(r&&e.options.lineWrapping){var v=Yo(u,a,f).getClientRects();v.length?d=v[s=="right"?v.length-1:0]:d=on}else d=Yo(u,a,f).getBoundingClientRect()||on;if(d.left||d.right||a==0)break;f=a,a-=1,l="right"}r&&i<11&&(d=an(e.display.measure,d))}else{a>0&&(l=s="right");var v;e.options.lineWrapping&&(v=u.getClientRects()).length>1?d=v[s=="right"?v.length-1:0]:d=u.getBoundingClientRect()}if(r&&i<9&&!a&&(!d||!d.left&&!d.right)){var m=u.parentNode.getClientRects()[0];m?d={left:m.left,right:m.left+Tn(e.display),top:m.top,bottom:m.bottom}:d=on}var g=d.top-t.rect.top,y=d.bottom-t.rect.top,b=(g+y)/2,w=t.view.measure.heights;for(var c=0;c<w.length-1;c++)if(b<w[c])break;var E=c?w[c-1]:0,S=w[c],x={left:(l=="right"?d.right:d.left)-t.rect.left,right:(l=="left"?d.left:d.right)-t.rect.left,top:E,bottom:S};return!d.left&&!d.right&&(x.bogus=!0),e.options.singleCursorHeightPerLine||(x.rtop=g,x.rbottom=y),x}function an(e,t){if(!window.screen||screen.logicalXDPI==null||screen.logicalXDPI==screen.deviceXDPI||!Su(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}function fn(e){if(e.measure){e.measure.cache={},e.measure.heights=null;if(e.rest)for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}}function ln(e){e.display.externalMeasure=null,Zo(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)fn(e.display.view[t])}function cn(e){ln(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function hn(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function pn(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function dn(e,t,n,r){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var s=fs(t.widgets[i]);n.top+=s,n.bottom+=s}if(r=="line")return n;r||(r="local");var o=Js(t);r=="local"?o+=Kt(e.display):o-=e.display.viewOffset;if(r=="page"||r=="window"){var u=e.display.lineSpace.getBoundingClientRect();o+=u.top+(r=="window"?0:pn());var a=u.left+(r=="window"?0:hn());n.left+=a,n.right+=a}return n.top+=o,n.bottom+=o,n}function vn(e,t,n){if(n=="div")return t;var r=t.left,i=t.top;if(n=="page")r-=hn(),i-=pn();else if(n=="local"||!n){var s=e.display.sizer.getBoundingClientRect();r+=s.left,i+=s.top}var o=e.display.lineSpace.getBoundingClientRect();return{left:r-o.left,top:i-o.top}}function mn(e,t,n,r,i){return r||(r=Us(e.doc,t.line)),dn(e,r,tn(e,r,t.ch,i),n)}function gn(e,t,n,r,i,s){function o(t,o){var u=sn(e,i,t,o?"right":"left",s);return o?u.left=u.right:u.right=u.left,dn(e,r,u,n)}function u(e,t){var n=a[t],r=n.level%2;return e==Nu(n)&&t&&n.level<a[t-1].level?(n=a[--t],e=Cu(n)-(n.level%2?0:1),r=!0):e==Cu(n)&&t<a.length-1&&n.level<a[t+1].level&&(n=a[++t],e=Nu(n)-n.level%2,r=!1),r&&e==n.to&&e>n.from?o(e-1):o(e,r)}r=r||Us(e.doc,t.line),i||(i=rn(e,r));var a=Ks(r),f=t.ch;if(!a)return o(f);var l=Pu(a,f),c=u(f,l);return Du!=null&&(c.other=u(f,Du)),c}function yn(e,t){var n=0,t=St(e.doc,t);e.options.lineWrapping||(n=Tn(e.display)*t.ch);var r=Us(e.doc,t.line),i=Js(r)+Kt(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function bn(e,t,n,r){var i=ht(e,t);return i.xRel=r,n&&(i.outside=!0),i}function wn(e,t,n){var r=e.doc;n+=e.display.viewOffset;if(n<0)return bn(r.first,0,!0,-1);var i=$s(r,n),s=r.first+r.size-1;if(i>s)return bn(r.first+r.size-1,Us(r,s).text.length,!0,1);t<0&&(t=0);var o=Us(r,i);for(;;){var u=En(e,o,i,t,n),a=Zi(o),f=a&&a.find(0,!0);if(!a||!(u.ch>f.from.ch||u.ch==f.from.ch&&u.xRel>0))return u;i=Vs(o=f.to.line)}}function En(e,t,n,r,i){function f(r){var i=gn(e,ht(n,r),"line",t,a);return o=!0,s>i.bottom?i.left-u:s<i.top?i.left+u:(o=!1,i.left)}var s=i-Js(t),o=!1,u=2*e.display.wrapper.clientWidth,a=rn(e,t),l=Ks(t),c=t.text.length,h=ku(t),p=Lu(t),d=f(h),v=o,m=f(p),g=o;if(r>m)return bn(n,p,g,1);for(;;){if(l?p==h||p==Bu(t,h,1):p-h<=1){var y=r<d||r-d<=m-r?h:p,b=r-(y==h?d:m);while(Qo(t.text.charAt(y)))++y;var w=bn(n,y,y==h?v:g,b<-1?-1:b>1?1:0);return w}var E=Math.ceil(c/2),S=h+E;if(l){S=h;for(var x=0;x<E;++x)S=Bu(t,S,1)}var T=f(S);if(T>r){p=S,m=T;if(g=o)m+=1e3;c=E}else h=S,d=T,v=o,c-=E}}function xn(e){if(e.cachedTextHeight!=null)return e.cachedTextHeight;if(Sn==null){Sn=Go("pre");for(var t=0;t<49;++t)Sn.appendChild(document.createTextNode("x")),Sn.appendChild(Go("br"));Sn.appendChild(document.createTextNode("x"))}eu(e.measure,Sn);var n=Sn.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),Zo(e.measure),n||1}function Tn(e){if(e.cachedCharWidth!=null)return e.cachedCharWidth;var t=Go("span","xxxxxxxxxx"),n=Go("pre",[t]);eu(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function kn(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++Cn},Nn?Nn.ops.push(e.curOp):e.curOp.ownsGroup=Nn={ops:[e.curOp],delayedCallbacks:[]}}function Ln(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++)t[n]();for(var r=0;r<e.ops.length;r++){var i=e.ops[r];if(i.cursorActivityHandlers)while(i.cursorActivityCalled<i.cursorActivityHandlers.length)i.cursorActivityHandlers[i.cursorActivityCalled++](i.cm)}}while(n<t.length)}function An(e){var t=e.curOp,n=t.ownsGroup;if(!n)return;try{Ln(n)}finally{Nn=null;for(var r=0;r<n.ops.length;r++)n.ops[r].cm.curOp=null;On(n)}}function On(e){var t=e.ops;for(var n=0;n<t.length;n++)Mn(t[n]);for(var n=0;n<t.length;n++)_n(t[n]);for(var n=0;n<t.length;n++)Dn(t[n]);for(var n=0;n<t.length;n++)Pn(t[n]);for(var n=0;n<t.length;n++)Hn(t[n])}function Mn(e){var t=e.cm,n=t.display;e.updateMaxLine&&P(t),e.mustUpdate=e.viewChanged||e.forceUpdate||e.scrollTop!=null||e.scrollToPos&&(e.scrollToPos.from.line<n.viewFrom||e.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new W(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function _n(e){e.updatedDisplay=e.mustUpdate&&X(e.cm,e.update)}function Dn(e){var t=e.cm,n=t.display;e.updatedDisplay&&Q(t),e.barMeasure=j(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=tn(t,n.maxLine,n.maxLine.text.length).left+3,e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo+Lo-n.scroller.clientWidth));if(e.updatedDisplay||e.selectionChanged)e.newSelectionNodes=It(t)}function Pn(e){var t=e.cm;e.adjustWidthTo!=null&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&br(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1),e.newSelectionNodes&&qt(t,e.newSelectionNodes),e.updatedDisplay&&J(t,e.barMeasure),(e.updatedDisplay||e.startHeight!=t.doc.height)&&F(t,e.barMeasure),e.selectionChanged&&Wt(t),t.state.focused&&e.updateInput&&Zn(t,e.typing)}function Hn(e){var t=e.cm,n=t.display,r=t.doc;e.adjustWidthTo!=null&&Math.abs(e.barMeasure.scrollWidth-t.display.scroller.scrollWidth)>1&&F(t),e.updatedDisplay&&V(t,e.update),n.wheelStartX!=null&&(e.scrollTop!=null||e.scrollLeft!=null||e.scrollToPos)&&(n.wheelStartX=n.wheelStartY=null);if(e.scrollTop!=null&&(n.scroller.scrollTop!=e.scrollTop||e.forceScroll)){var i=Math.max(0,Math.min(n.scroller.scrollHeight-n.scroller.clientHeight,e.scrollTop));n.scroller.scrollTop=n.scrollbarV.scrollTop=r.scrollTop=i}if(e.scrollLeft!=null&&(n.scroller.scrollLeft!=e.scrollLeft||e.forceScroll)){var o=Math.max(0,Math.min(n.scroller.scrollWidth-n.scroller.clientWidth,e.scrollLeft));n.scroller.scrollLeft=n.scrollbarH.scrollLeft=r.scrollLeft=o,q(t)}if(e.scrollToPos){var u=Yr(t,St(r,e.scrollToPos.from),St(r,e.scrollToPos.to),e.scrollToPos.margin);e.scrollToPos.isCursor&&t.state.focused&&Gr(t,u)}var a=e.maybeHiddenMarkers,f=e.maybeUnhiddenMarkers;if(a)for(var l=0;l<a.length;++l)a[l].lines.length||wo(a[l],"hide");if(f)for(var l=0;l<f.length;++l)f[l].lines.length&&wo(f[l],"unhide");n.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.updatedDisplay&&s&&(t.options.lineWrapping&&K(t,e.barMeasure),e.barMeasure.scrollWidth>e.barMeasure.clientWidth&&e.barMeasure.scrollWidth<e.barMeasure.clientWidth+1&&!B(t)&&F(t)),e.changeObjs&&wo(t,"changes",t,e.changeObjs)}function Bn(e,t){if(e.curOp)return t();kn(e);try{return t()}finally{An(e)}}function jn(e,t){return function(){if(e.curOp)return t.apply(e,arguments);kn(e);try{return t.apply(e,arguments)}finally{An(e)}}}function Fn(e){return function(){if(this.curOp)return e.apply(this,arguments);kn(this);try{return e.apply(this,arguments)}finally{An(this)}}}function In(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);kn(t);try{return e.apply(this,arguments)}finally{An(t)}}}function qn(e,t,n){this.line=t,this.rest=ns(t),this.size=this.rest?Vs(Fo(this.rest))-n+1:1,this.node=this.text=null,this.hidden=ss(e,t)}function Rn(e,t,n){var r=[],i;for(var s=t;s<n;s=i){var o=new qn(e.doc,Us(e.doc,s),s);i=s+o.size,r.push(o)}return r}function Un(e,t,n,r){t==null&&(t=e.doc.first),n==null&&(n=e.doc.first+e.doc.size),r||(r=0);var i=e.display;r&&n<i.viewTo&&(i.updateLineNumbers==null||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0;if(t>=i.viewTo)E&&rs(e.doc,t)<i.viewTo&&Wn(e);else if(n<=i.viewFrom)E&&is(e.doc,n+r)>i.viewFrom?Wn(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)Wn(e);else if(t<=i.viewFrom){var s=Vn(e,n,n+r,1);s?(i.view=i.view.slice(s.index),i.viewFrom=s.lineN,i.viewTo+=r):Wn(e)}else if(n>=i.viewTo){var s=Vn(e,t,t,-1);s?(i.view=i.view.slice(0,s.index),i.viewTo=s.lineN):Wn(e)}else{var o=Vn(e,t,t,-1),u=Vn(e,n,n+r,1);o&&u?(i.view=i.view.slice(0,o.index).concat(Rn(e,o.lineN,u.lineN)).concat(i.view.slice(u.index)),i.viewTo+=r):Wn(e)}var a=i.externalMeasured;a&&(n<a.lineN?a.lineN+=r:t<a.lineN+a.size&&(i.externalMeasured=null))}function zn(e,t,n){e.curOp.viewChanged=!0;var r=e.display,i=e.display.externalMeasured;i&&t>=i.lineN&&t<i.lineN+i.size&&(r.externalMeasured=null);if(t<r.viewFrom||t>=r.viewTo)return;var s=r.view[Xn(e,t)];if(s.node==null)return;var o=s.changes||(s.changes=[]);qo(o,n)==-1&&o.push(n)}function Wn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Xn(e,t){if(t>=e.display.viewTo)return null;t-=e.display.viewFrom;if(t<0)return null;var n=e.display.view;for(var r=0;r<n.length;r++){t-=n[r].size;if(t<0)return r}}function Vn(e,t,n,r){var i=Xn(e,t),s,o=e.display.view;if(!E||n==e.doc.first+e.doc.size)return{index:i,lineN:n};for(var u=0,a=e.display.viewFrom;u<i;u++)a+=o[u].size;if(a!=t){if(r>0){if(i==o.length-1)return null;s=a+o[i].size-t,i++}else s=a-t;t+=s,n+=s}while(rs(e.doc,n)!=n){if(i==(r<0?0:o.length-1))return null;n+=r*o[i-(r<0?1:0)].size,i+=r}return{index:i,lineN:n}}function $n(e,t,n){var r=e.display,i=r.view;i.length==0||t>=r.viewTo||n<=r.viewFrom?(r.view=Rn(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=Rn(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(Xn(e,t))),r.viewFrom=t,r.viewTo<n?r.view=r.view.concat(Rn(e,r.viewTo,n)):r.viewTo>n&&(r.view=r.view.slice(0,Xn(e,n)))),r.viewTo=n}function Jn(e){var t=e.display.view,n=0;for(var r=0;r<t.length;r++){var i=t[r];!i.hidden&&(!i.node||i.changes)&&++n}return n}function Kn(e){if(e.display.pollingFast)return;e.display.poll.set(e.options.pollInterval,function(){Yn(e),e.state.focused&&Kn(e)})}function Qn(e){function n(){var r=Yn(e);!r&&!t?(t=!0,e.display.poll.set(60,n)):(e.display.pollingFast=!1,Kn(e))}var t=!1;e.display.pollingFast=!0,e.display.poll.set(20,n)}function Yn(e){var t=e.display.input,n=e.display.prevInput,s=e.doc;if(!e.state.focused||bu(t)&&!n||nr(e)||e.options.disableInput||e.state.keySeq)return!1;e.state.pasteIncoming&&e.state.fakedLastChar&&(t.value=t.value.substring(0,t.value.length-1),e.state.fakedLastChar=!1);var o=t.value;if(o==n&&!e.somethingSelected())return!1;if(r&&i>=9&&e.display.inputHasSelection===o||v&&/[\uf700-\uf7ff]/.test(o))return Zn(e),!1;var u=!e.curOp;u&&kn(e),e.display.shift=!1,o.charCodeAt(0)==8203&&s.sel==e.display.selForContextMenu&&!n&&(n="​");var a=0,f=Math.min(n.length,o.length);while(a<f&&n.charCodeAt(a)==o.charCodeAt(a))++a;var l=o.slice(a),c=yu(l),h=null;e.state.pasteIncoming&&s.sel.ranges.length>1&&(Gn&&Gn.join("\n")==l?h=s.sel.ranges.length%Gn.length==0&&Ro(Gn,yu):c.length==s.sel.ranges.length&&(h=Ro(c,function(e){return[e]})));for(var p=s.sel.ranges.length-1;p>=0;p--){var d=s.sel.ranges[p],m=d.from(),g=d.to();a<n.length?m=ht(m.line,m.ch-(n.length-a)):e.state.overwrite&&d.empty()&&!e.state.pasteIncoming&&(g=ht(g.line,Math.min(Us(s,g.line).text.length,g.ch+Fo(c).length)));var y=e.curOp.updateInput,b={from:m,to:g,text:h?h[p%h.length]:c,origin:e.state.pasteIncoming?"paste":e.state.cutIncoming?"cut":"+input"};Wr(e.doc,b),So(e,"inputRead",e,b);if(l&&!e.state.pasteIncoming&&e.options.electricChars&&e.options.smartIndent&&d.head.ch<100&&(!p||s.sel.ranges[p-1].head.line!=d.head.line)){var w=e.getModeAt(d.head),E=Fr(b);if(w.electricChars){for(var S=0;S<w.electricChars.length;S++)if(l.indexOf(w.electricChars.charAt(S))>-1){ii(e,E.line,"smart");break}}else w.electricInput&&w.electricInput.test(Us(s,E.line).text.slice(0,E.ch))&&ii(e,E.line,"smart")}}return ni(e),e.curOp.updateInput=y,e.curOp.typing=!0,o.length>1e3||o.indexOf("\n")>-1?t.value=e.display.prevInput="":e.display.prevInput=o,u&&An(e),e.state.pasteIncoming=e.state.cutIncoming=!1,!0}function Zn(e,t){var n,s,o=e.doc;if(e.somethingSelected()){e.display.prevInput="";var u=o.sel.primary();n=wu&&(u.to().line-u.from().line>100||(s=e.getSelection()).length>1e3);var a=n?"-":s||e.getSelection();e.display.input.value=a,e.state.focused&&Io(e.display.input),r&&i>=9&&(e.display.inputHasSelection=a)}else t||(e.display.prevInput=e.display.input.value="",r&&i>=9&&(e.display.inputHasSelection=null));e.display.inaccurateSelection=n}function er(e){e.options.readOnly!="nocursor"&&(!d||nu()!=e.display.input)&&e.display.input.focus()}function tr(e){e.state.focused||(er(e),Pr(e))}function nr(e){return e.options.readOnly||e.doc.cantEdit}function rr(e){function n(){e.state.focused&&setTimeout(Wo(er,e),0)}function o(t){To(e,t)||vo(t)}function u(n){if(e.somethingSelected())Gn=e.getSelections(),t.inaccurateSelection&&(t.prevInput="",t.inaccurateSelection=!1,t.input.value=Gn.join("\n"),Io(t.input));else{var r=[],i=[];for(var s=0;s<e.doc.sel.ranges.length;s++){var o=e.doc.sel.ranges[s].head.line,u={anchor:ht(o,0),head:ht(o+1,0)};i.push(u),r.push(e.getRange(u.anchor,u.head))}n.type=="cut"?e.setSelections(i,null,Oo):(t.prevInput="",t.input.value=r.join("\n"),Io(t.input)),Gn=r}n.type=="cut"&&(e.state.cutIncoming=!0)}var t=e.display;yo(t.scroller,"mousedown",jn(e,ur)),r&&i<11?yo(t.scroller,"dblclick",jn(e,function(t){if(To(e,t))return;var n=or(e,t);if(!n||dr(e,t)||sr(e.display,t))return;co(t);var r=e.findWordAt(n);kt(e.doc,r.anchor,r.head)})):yo(t.scroller,"dblclick",function(t){To(e,t)||co(t)}),yo(t.lineSpace,"selectstart",function(e){sr(t,e)||co(e)}),b||yo(t.scroller,"contextmenu",function(t){Br(e,t)}),yo(t.scroller,"scroll",function(){t.scroller.clientHeight&&(yr(e,t.scroller.scrollTop),br(e,t.scroller.scrollLeft,!0),wo(e,"scroll",e))}),yo(t.scrollbarV,"scroll",function(){t.scroller.clientHeight&&yr(e,t.scrollbarV.scrollTop)}),yo(t.scrollbarH,"scroll",function(){t.scroller.clientHeight&&br(e,t.scrollbarH.scrollLeft)}),yo(t.scroller,"mousewheel",function(t){Sr(e,t)}),yo(t.scroller,"DOMMouseScroll",function(t){Sr(e,t)}),yo(t.scrollbarH,"mousedown",n),yo(t.scrollbarV,"mousedown",n),yo(t.wrapper,"scroll",function(){t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),yo(t.input,"keyup",function(t){_r.call(e,t)}),yo(t.input,"input",function(){r&&i>=9&&e.display.inputHasSelection&&(e.display.inputHasSelection=null),Qn(e)}),yo(t.input,"keydown",jn(e,Or)),yo(t.input,"keypress",jn(e,Dr)),yo(t.input,"focus",Wo(Pr,e)),yo(t.input,"blur",Wo(Hr,e)),e.options.dragDrop&&(yo(t.scroller,"dragstart",function(t){gr(e,t)}),yo(t.scroller,"dragenter",o),yo(t.scroller,"dragover",o),yo(t.scroller,"drop",jn(e,mr))),yo(t.scroller,"paste",function(n){if(sr(t,n))return;e.state.pasteIncoming=!0,er(e),Qn(e)}),yo(t.input,"paste",function(){if(s&&!e.state.fakedLastChar&&!(new Date-e.state.lastMiddleDown<200)){var n=t.input.selectionStart,r=t.input.selectionEnd;t.input.value+="$",t.input.selectionEnd=r,t.input.selectionStart=n,e.state.fakedLastChar=!0}e.state.pasteIncoming=!0,Qn(e)}),yo(t.input,"cut",u),yo(t.input,"copy",u),l&&yo(t.sizer,"mouseup",function(){nu()==t.input&&t.input.blur(),er(e)})}function ir(e){var t=e.display;if(t.lastWrapHeight==t.wrapper.clientHeight&&t.lastWrapWidth==t.wrapper.clientWidth)return;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,e.setSize()}function sr(e,t){for(var n=mo(t);n!=e.wrapper;n=n.parentNode)if(!n||n.ignoreEvents||n.parentNode==e.sizer&&n!=e.mover)return!0}function or(e,t,n,r){var i=e.display;if(!n){var s=mo(t);if(s==i.scrollbarH||s==i.scrollbarV||s==i.scrollbarFiller||s==i.gutterFiller)return null}var o,u,a=i.lineSpace.getBoundingClientRect();try{o=t.clientX-a.left,u=t.clientY-a.top}catch(t){return null}var f=wn(e,o,u),l;if(r&&f.xRel==1&&(l=Us(e.doc,f.line).text).length==f.ch){var c=Po(l,l.length,e.options.tabSize)-l.length;f=ht(f.line,Math.max(0,Math.round((o-Gt(e.display).left)/Tn(e.display))-c))}return f}function ur(e){if(To(this,e))return;var t=this,n=t.display;n.shift=e.shiftKey;if(sr(n,e)){s||(n.scroller.draggable=!1,setTimeout(function(){n.scroller.draggable=!0},100));return}if(dr(t,e))return;var r=or(t,e);window.focus();switch(go(e)){case 1:r?lr(t,e,r):mo(e)==n.scroller&&co(e);break;case 2:s&&(t.state.lastMiddleDown=+(new Date)),r&&kt(t.doc,r),setTimeout(Wo(er,t),20),co(e);break;case 3:b&&Br(t,e)}}function lr(e,t,n){setTimeout(Wo(tr,e),0);var r=+(new Date),i;fr&&fr.time>r-400&&pt(fr.pos,n)==0?i="triple":ar&&ar.time>r-400&&pt(ar.pos,n)==0?(i="double",fr={time:r,pos:n}):(i="single",ar={time:r,pos:n});var s=e.doc.sel,o=v?t.metaKey:t.ctrlKey;e.options.dragDrop&&cu&&!nr(e)&&i=="single"&&s.contains(n)>-1&&s.somethingSelected()?cr(e,t,n,o):hr(e,t,n,i,o)}function cr(e,t,n,o){var u=e.display,a=jn(e,function(f){s&&(u.scroller.draggable=!1),e.state.draggingText=!1,bo(document,"mouseup",a),bo(u.scroller,"drop",a),Math.abs(t.clientX-f.clientX)+Math.abs(t.clientY-f.clientY)<10&&(co(f),o||kt(e.doc,n),er(e),r&&i==9&&setTimeout(function(){document.body.focus(),er(e)},20))});s&&(u.scroller.draggable=!0),e.state.draggingText=a,u.scroller.dragDrop&&u.scroller.dragDrop(),yo(document,"mouseup",a),yo(u.scroller,"drop",a)}function hr(e,t,n,r,i){function p(t){if(pt(h,t)==0)return;h=t;if(r=="rect"){var i=[],s=e.options.tabSize,l=Po(Us(o,n.line).text,n.ch,s),c=Po(Us(o,t.line).text,t.ch,s),p=Math.min(l,c),d=Math.max(l,c);for(var v=Math.min(n.line,t.line),m=Math.min(e.lastLine(),Math.max(n.line,t.line));v<=m;v++){var g=Us(o,v).text,y=Ho(g,p,s);p==d?i.push(new yt(ht(v,y),ht(v,y))):g.length>y&&i.push(new yt(ht(v,y),ht(v,Ho(g,d,s))))}i.length||i.push(new yt(n,n)),Dt(o,bt(f.ranges.slice(0,a).concat(i),a),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b=u,w=b.anchor,E=t;if(r!="single"){if(r=="double")var S=e.findWordAt(t);else var S=new yt(ht(t.line,0),St(o,ht(t.line+1,0)));pt(S.anchor,w)>0?(E=S.head,w=mt(b.from(),S.anchor)):(E=S.anchor,w=vt(b.to(),S.head))}var i=f.ranges.slice(0);i[a]=new yt(St(o,w),E),Dt(o,bt(i,a),Mo)}}function m(t){var n=++v,i=or(e,t,!0,r=="rect");if(!i)return;if(pt(i,h)!=0){tr(e),p(i);var u=I(s,o);(i.line>=u.to||i.line<u.from)&&setTimeout(jn(e,function(){v==n&&m(t)}),150)}else{var a=t.clientY<d.top?-20:t.clientY>d.bottom?20:0;a&&setTimeout(jn(e,function(){if(v!=n)return;s.scroller.scrollTop+=a,m(t)}),50)}}function g(t){v=Infinity,co(t),er(e),bo(document,"mousemove",y),bo(document,"mouseup",b),o.history.lastSelOrigin=null}var s=e.display,o=e.doc;co(t);var u,a,f=o.sel;i&&!t.shiftKey?(a=o.sel.contains(n),a>-1?u=o.sel.ranges[a]:u=new yt(n,n)):u=o.sel.primary();if(t.altKey)r="rect",i||(u=new yt(n,n)),n=or(e,t,!0,!0),a=-1;else if(r=="double"){var l=e.findWordAt(n);e.display.shift||o.extend?u=Ct(o,u,l.anchor,l.head):u=l}else if(r=="triple"){var c=new yt(ht(n.line,0),St(o,ht(n.line+1,0)));e.display.shift||o.extend?u=Ct(o,u,c.anchor,c.head):u=c}else u=Ct(o,u,n);i?a>-1?At(o,a,u,Mo):(a=o.sel.ranges.length,Dt(o,bt(o.sel.ranges.concat([u]),a),{scroll:!1,origin:"*mouse"})):(a=0,Dt(o,new gt([u],0),Mo),f=o.sel);var h=n,d=s.wrapper.getBoundingClientRect(),v=0,y=jn(e,function(e){go(e)?m(e):g(e)}),b=jn(e,g);yo(document,"mousemove",y),yo(document,"mouseup",b)}function pr(e,t,n,r,i){try{var s=t.clientX,o=t.clientY}catch(t){return!1}if(s>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&co(t);var u=e.display,a=u.lineDiv.getBoundingClientRect();if(o>a.bottom||!Co(e,n))return po(t);o-=a.top-u.viewOffset;for(var f=0;f<e.options.gutters.length;++f){var l=u.gutters.childNodes[f];if(l&&l.getBoundingClientRect().right>=s){var c=$s(e.doc,o),h=e.options.gutters[f];return i(e,n,e,c,h,t),po(t)}}}function dr(e,t){return pr(e,t,"gutterClick",!0,So)}function mr(e){var t=this;if(To(t,e)||sr(t.display,e))return;co(e),r&&(vr=+(new Date));var n=or(t,e,!0),i=e.dataTransfer.files;if(!n||nr(t))return;if(i&&i.length&&window.FileReader&&window.File){var s=i.length,o=Array(s),u=0,a=function(e,r){var i=new FileReader;i.onload=jn(t,function(){o[r]=i.result;if(++u==s){n=St(t.doc,n);var e={from:n,to:n,text:yu(o.join("\n")),origin:"paste"};Wr(t.doc,e),_t(t.doc,wt(n,Fr(e)))}}),i.readAsText(e)};for(var f=0;f<s;++f)a(i[f],f)}else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1){t.state.draggingText(e),setTimeout(Wo(er,t),20);return}try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&(v?!e.metaKey:!e.ctrlKey))var l=t.listSelections();Pt(t.doc,wt(n,n));if(l)for(var f=0;f<l.length;++f)Qr(t.doc,"",l[f].anchor,l[f].head,"drag");t.replaceSelection(o,"around","paste"),er(t)}}catch(e){}}}function gr(e,t){if(r&&(!e.state.draggingText||+(new Date)-vr<100)){vo(t);return}if(To(e,t)||sr(e.display,t))return;t.dataTransfer.setData("Text",e.getSelection());if(t.dataTransfer.setDragImage&&!f){var n=Go("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",a&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),a&&n.parentNode.removeChild(n)}}function yr(t,n){if(Math.abs(t.doc.scrollTop-n)<2)return;t.doc.scrollTop=n,e||$(t,{top:n}),t.display.scroller.scrollTop!=n&&(t.display.scroller.scrollTop=n),t.display.scrollbarV.scrollTop!=n&&(t.display.scrollbarV.scrollTop=n),e&&$(t),Xt(t,100)}function br(e,t,n){if(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)return;t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,q(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbarH.scrollLeft!=t&&(e.display.scrollbarH.scrollLeft=t)}function Sr(t,n){var r=n.wheelDeltaX,i=n.wheelDeltaY;r==null&&n.detail&&n.axis==n.HORIZONTAL_AXIS&&(r=n.detail),i==null&&n.detail&&n.axis==n.VERTICAL_AXIS?i=n.detail:i==null&&(i=n.wheelDelta);var o=t.display,u=o.scroller;if(!(r&&u.scrollWidth>u.clientWidth||i&&u.scrollHeight>u.clientHeight))return;if(i&&v&&s)e:for(var f=n.target,l=o.view;f!=u;f=f.parentNode)for(var c=0;c<l.length;c++)if(l[c].node==f){t.display.currentWheelTarget=f;break e}if(r&&!e&&!a&&Er!=null){i&&yr(t,Math.max(0,Math.min(u.scrollTop+i*Er,u.scrollHeight-u.clientHeight))),br(t,Math.max(0,Math.min(u.scrollLeft+r*Er,u.scrollWidth-u.clientWidth))),co(n),o.wheelStartX=null;return}if(i&&Er!=null){var h=i*Er,p=t.doc.scrollTop,d=p+o.wrapper.clientHeight;h<0?p=Math.max(0,p+h-50):d=Math.min(t.doc.height,d+h+50),$(t,{top:p,bottom:d})}wr<20&&(o.wheelStartX==null?(o.wheelStartX=u.scrollLeft,o.wheelStartY=u.scrollTop,o.wheelDX=r,o.wheelDY=i,setTimeout(function(){if(o.wheelStartX==null)return;var e=u.scrollLeft-o.wheelStartX,t=u.scrollTop-o.wheelStartY,n=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null;if(!n)return;Er=(Er*wr+n)/(wr+1),++wr},200)):(o.wheelDX+=r,o.wheelDY+=i))}function xr(e,t,n){if(typeof t=="string"){t=wi[t];if(!t)return!1}e.display.pollingFast&&Yn(e)&&(e.display.pollingFast=!1);var r=e.display.shift,i=!1;try{nr(e)&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),i=t(e)!=Ao}finally{e.display.shift=r,e.state.suppressEdits=!1}return i}function Tr(e,t,n){for(var r=0;r<e.state.keyMaps.length;r++){var i=xi(t,e.state.keyMaps[r],n);if(i)return i}return e.options.extraKeys&&xi(t,e.options.extraKeys,n)||xi(t,e.options.keyMap,n)}function Cr(e,t,n,r){var i=e.state.keySeq;if(i){if(Ti(t))return"handled";Nr.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,Zn(e))}),t=i+" "+t}var s=Tr(e,t,r);s=="multi"&&(e.state.keySeq=t),s=="handled"&&So(e,"keyHandled",e,t,n);if(s=="handled"||s=="multi")co(n),Wt(e);return i&&!s&&/\'$/.test(t)?(co(n),!0):!!s}function kr(e,t){var n=Ni(t,!0);return n?t.shiftKey&&!e.state.keySeq?Cr(e,"Shift-"+n,t,function(t){return xr(e,t,!0)})||Cr(e,n,t,function(t){if(typeof t=="string"?/^go[A-Z]/.test(t):t.motion)return xr(e,t)}):Cr(e,n,t,function(t){return xr(e,t)}):!1}function Lr(e,t,n){return Cr(e,"'"+n+"'",t,function(t){return xr(e,t,!0)})}function Or(e){var t=this;tr(t);if(To(t,e))return;r&&i<11&&e.keyCode==27&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=n==16||e.shiftKey;var s=kr(t,e);a&&(Ar=s?n:null,!s&&n==88&&!wu&&(v?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),n==18&&!/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)&&Mr(t)}function Mr(e){function n(e){if(e.keyCode==18||!e.altKey)iu(t,"CodeMirror-crosshair"),bo(document,"keyup",n),bo(document,"mouseover",n)}var t=e.display.lineDiv;su(t,"CodeMirror-crosshair"),yo(document,"keyup",n),yo(document,"mouseover",n)}function _r(e){e.keyCode==16&&(this.doc.sel.shift=!1),To(this,e)}function Dr(e){var t=this;if(To(t,e)||e.ctrlKey&&!e.altKey||v&&e.metaKey)return;var n=e.keyCode,s=e.charCode;if(a&&n==Ar){Ar=null,co(e);return}if((a&&(!e.which||e.which<10)||l)&&kr(t,e))return;var o=String.fromCharCode(s==null?n:s);if(Lr(t,e,o))return;r&&i>=9&&(t.display.inputHasSelection=null),Qn(t)}function Pr(e){if(e.options.readOnly=="nocursor")return;e.state.focused||(wo(e,"focus",e),e.state.focused=!0,su(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(Zn(e),s&&setTimeout(Wo(Zn,e,!0),0))),Kn(e),Wt(e)}function Hr(e){e.state.focused&&(wo(e,"blur",e),e.state.focused=!1,iu(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Br(e,t){function h(){if(n.input.selectionStart!=null){var t=e.somethingSelected(),r=n.input.value="​"+(t?n.input.value:"");n.prevInput=t?"":"​",n.input.selectionStart=1,n.input.selectionEnd=r.length,n.selForContextMenu=e.doc.sel}}function p(){n.inputDiv.style.position="relative",n.input.style.cssText=l,r&&i<9&&(n.scrollbarV.scrollTop=n.scroller.scrollTop=u),Kn(e);if(n.input.selectionStart!=null){(!r||r&&i<9)&&h();var t=0,s=function(){n.selForContextMenu==e.doc.sel&&n.input.selectionStart==0?jn(e,wi.selectAll)(e):t++<10?n.detectingSelectAll=setTimeout(s,500):Zn(e)};n.detectingSelectAll=setTimeout(s,200)}}if(To(e,t,"contextmenu"))return;var n=e.display;if(sr(n,t)||jr(e,t))return;var o=or(e,t),u=n.scroller.scrollTop;if(!o||a)return;var f=e.options.resetSelectionOnContextMenu;f&&e.doc.sel.contains(o)==-1&&jn(e,Dt)(e.doc,wt(o),Oo);var l=n.input.style.cssText;n.inputDiv.style.position="absolute",n.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(t.clientY-5)+"px; left: "+(t.clientX-5)+"px; z-index: 1000; background: "+(r?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";if(s)var c=window.scrollY;er(e),s&&window.scrollTo(null,c),Zn(e),e.somethingSelected()||(n.input.value=n.prevInput=" "),n.selForContextMenu=e.doc.sel,clearTimeout(n.detectingSelectAll),r&&i>=9&&h();if(b){vo(t);var d=function(){bo(window,"mouseup",d),setTimeout(p,20)};yo(window,"mouseup",d)}else setTimeout(p,50)}function jr(e,t){return Co(e,"gutterContextMenu")?pr(e,t,"gutterContextMenu",!1,wo):!1}function Ir(e,t){if(pt(e,t.from)<0)return e;if(pt(e,t.to)<=0)return Fr(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Fr(t).ch-t.to.ch),ht(n,r)}function qr(e,t){var n=[];for(var r=0;r<e.sel.ranges.length;r++){var i=e.sel.ranges[r];n.push(new yt(Ir(i.anchor,t),Ir(i.head,t)))}return bt(n,e.sel.primIndex)}function Rr(e,t,n){return e.line==t.line?ht(n.line,e.ch-t.ch+n.ch):ht(n.line+(e.line-t.line),e.ch)}function Ur(e,t,n){var r=[],i=ht(e.first,0),s=i;for(var o=0;o<t.length;o++){var u=t[o],a=Rr(u.from,i,s),f=Rr(Fr(u),i,s);i=u.to,s=f;if(n=="around"){var l=e.sel.ranges[o],c=pt(l.head,l.anchor)<0;r[o]=new yt(c?f:a,c?a:f)}else r[o]=new yt(a,a)}return new gt(r,e.sel.primIndex)}function zr(e,t,n){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return n&&(r.update=function(t,n,r,i){t&&(this.from=St(e,t)),n&&(this.to=St(e,n)),r&&(this.text=r),i!==undefined&&(this.origin=i)}),wo(e,"beforeChange",e,r),e.cm&&wo(e.cm,"beforeChange",e.cm,r),r.canceled?null:{from:r.from,to:r.to,text:r.text,origin:r.origin}}function Wr(e,t,n){if(e.cm){if(!e.cm.curOp)return jn(e.cm,Wr)(e,t,n);if(e.cm.state.suppressEdits)return}if(Co(e,"beforeChange")||e.cm&&Co(e.cm,"beforeChange")){t=zr(e,t,!0);if(!t)return}var r=w&&!n&&Xi(e,t.from,t.to);if(r)for(var i=r.length-1;i>=0;--i)Xr(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text});else Xr(e,t)}function Xr(e,t){if(t.text.length==1&&t.text[0]==""&&pt(t.from,t.to)==0)return;var n=qr(e,t);eo(e,t,n,e.cm?e.cm.curOp.id:NaN),Jr(e,t,n,Ui(e,t));var r=[];qs(e,function(e,n){!n&&qo(r,e.history)==-1&&(lo(e.history,t),r.push(e.history)),Jr(e,t,null,Ui(e,t))})}function Vr(e,t,n){if(e.cm&&e.cm.state.suppressEdits)return;var r=e.history,i,s=e.sel,o=t=="undo"?r.done:r.undone,u=t=="undo"?r.undone:r.done;for(var a=0;a<o.length;a++){i=o[a];if(n?i.ranges&&!i.equals(e.sel):!i.ranges)break}if(a==o.length)return;r.lastOrigin=r.lastSelOrigin=null;for(;;){i=o.pop();if(!i.ranges)break;ro(i,u);if(n&&!i.equals(e.sel)){Dt(e,i,{clearRedo:!1});return}s=i}var f=[];ro(s,u),u.push({changes:f,generation:r.generation}),r.generation=i.generation||++r.maxGeneration;var l=Co(e,"beforeChange")||e.cm&&Co(e.cm,"beforeChange");for(var a=i.changes.length-1;a>=0;--a){var c=i.changes[a];c.origin=t;if(l&&!zr(e,c,!1)){o.length=0;return}f.push(Gs(e,c));var h=a?qr(e,c):Fo(o);Jr(e,c,h,Wi(e,c)),!a&&e.cm&&e.cm.scrollIntoView({from:c.from,to:Fr(c)});var p=[];qs(e,function(e,t){!t&&qo(p,e.history)==-1&&(lo(e.history,c),p.push(e.history)),Jr(e,c,null,Wi(e,c))})}}function $r(e,t){if(t==0)return;e.first+=t,e.sel=new gt(Ro(e.sel.ranges,function(e){return new yt(ht(e.anchor.line+t,e.anchor.ch),ht(e.head.line+t,e.head.ch))}),e.sel.primIndex);if(e.cm){Un(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;r<n.viewTo;r++)zn(e.cm,r,"gutter")}}function Jr(e,t,n,r){if(e.cm&&!e.cm.curOp)return jn(e.cm,Jr)(e,t,n,r);if(t.to.line<e.first){$r(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine())return;if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);$r(e,i),t={from:ht(e.first,0),to:ht(t.to.line+i,t.to.ch),text:[Fo(t.text)],origin:t.origin}}var s=e.lastLine();t.to.line>s&&(t={from:t.from,to:ht(s,Us(e,s).text.length),text:[t.text[0]],origin:t.origin}),t.removed=zs(e,t.from,t.to),n||(n=qr(e,t)),e.cm?Kr(e.cm,t,r):Ds(e,t,r),Pt(e,n,Oo)}function Kr(e,t,n){var r=e.doc,i=e.display,s=t.from,o=t.to,u=!1,a=s.line;e.options.lineWrapping||(a=Vs(ts(Us(r,s.line))),r.iter(a,o.line+1,function(e){if(e==i.maxLine)return u=!0,!0})),r.sel.contains(t.from,t.to)>-1&&No(e),Ds(r,t,n,k(e)),e.options.lineWrapping||(r.iter(a,s.line+t.text.length,function(e){var t=D(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,u=!1)}),u&&(e.curOp.updateMaxLine=!0)),r.frontier=Math.min(r.frontier,s.line),Xt(e,400);var f=t.text.length-(o.line-s.line)-1;s.line==o.line&&t.text.length==1&&!_s(e.doc,t)?zn(e,s.line,"text"):Un(e,s.line,o.line+1,f);var l=Co(e,"changes"),c=Co(e,"change");if(c||l){var h={from:s,to:o,text:t.text,removed:t.removed,origin:t.origin};c&&So(e,"change",e,h),l&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function Qr(e,t,n,r,i){r||(r=n);if(pt(r,n)<0){var s=r;r=n,n=s}typeof t=="string"&&(t=yu(t)),Wr(e,{from:n,to:r,text:t,origin:i})}function Gr(e,t){if(To(e,"scrollCursorIntoView"))return;var n=e.display,r=n.sizer.getBoundingClientRect(),i=null;t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1);if(i!=null&&!h){var s=Go("div","​",null,"position: absolute; top: "+(t.top-n.viewOffset-Kt(e.display))+"px; height: "+(t.bottom-t.top+Lo)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(s),s.scrollIntoView(i),e.display.lineSpace.removeChild(s)}}function Yr(e,t,n,r){r==null&&(r=0);for(var i=0;i<5;i++){var s=!1,o=gn(e,t),u=!n||n==t?o:gn(e,n),a=ei(e,Math.min(o.left,u.left),Math.min(o.top,u.top)-r,Math.max(o.left,u.left),Math.max(o.bottom,u.bottom)+r),f=e.doc.scrollTop,l=e.doc.scrollLeft;a.scrollTop!=null&&(yr(e,a.scrollTop),Math.abs(e.doc.scrollTop-f)>1&&(s=!0)),a.scrollLeft!=null&&(br(e,a.scrollLeft),Math.abs(e.doc.scrollLeft-l)>1&&(s=!0));if(!s)return o}}function Zr(e,t,n,r,i){var s=ei(e,t,n,r,i);s.scrollTop!=null&&yr(e,s.scrollTop),s.scrollLeft!=null&&br(e,s.scrollLeft)}function ei(e,t,n,r,i){var s=e.display,o=xn(e.display);n<0&&(n=0);var u=e.curOp&&e.curOp.scrollTop!=null?e.curOp.scrollTop:s.scroller.scrollTop,a=s.scroller.clientHeight-Lo,f={};i-n>a&&(i=n+a);var l=e.doc.height+Qt(s),c=n<o,h=i>l-o;if(n<u)f.scrollTop=c?0:n;else if(i>u+a){var p=Math.min(n,(h?l:i)-a);p!=u&&(f.scrollTop=p)}var d=e.curOp&&e.curOp.scrollLeft!=null?e.curOp.scrollLeft:s.scroller.scrollLeft,v=s.scroller.clientWidth-Lo-s.gutters.offsetWidth,m=r-t>v;return m&&(r=t+v),t<10?f.scrollLeft=0:t<d?f.scrollLeft=Math.max(0,t-(m?0:10)):r>v+d-3&&(f.scrollLeft=r+(m?0:10)-v),f}function ti(e,t,n){(t!=null||n!=null)&&ri(e),t!=null&&(e.curOp.scrollLeft=(e.curOp.scrollLeft==null?e.doc.scrollLeft:e.curOp.scrollLeft)+t),n!=null&&(e.curOp.scrollTop=(e.curOp.scrollTop==null?e.doc.scrollTop:e.curOp.scrollTop)+n)}function ni(e){ri(e);var t=e.getCursor(),n=t,r=t;e.options.lineWrapping||(n=t.ch?ht(t.line,t.ch-1):t,r=ht(t.line,t.ch+1)),e.curOp.scrollToPos={from:n,to:r,margin:e.options.cursorScrollMargin,isCursor:!0}}function ri(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=yn(e,t.from),r=yn(e,t.to),i=ei(e,Math.min(n.left,r.left),Math.min(n.top,r.top)-t.margin,Math.max(n.right,r.right),Math.max(n.bottom,r.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function ii(e,t,n,r){var i=e.doc,s;n==null&&(n="add"),n=="smart"&&(i.mode.indent?s=Jt(e,t):n="prev");var o=e.options.tabSize,u=Us(i,t),a=Po(u.text,null,o);u.stateAfter&&(u.stateAfter=null);var f=u.text.match(/^\s*/)[0],l;if(!r&&!/\S/.test(u.text))l=0,n="not";else if(n=="smart"){l=i.mode.indent(s,u.text.slice(f.length),u.text);if(l==Ao||l>150){if(!r)return;n="prev"}}n=="prev"?t>i.first?l=Po(Us(i,t-1).text,null,o):l=0:n=="add"?l=a+e.options.indentUnit:n=="subtract"?l=a-e.options.indentUnit:typeof n=="number"&&(l=a+n),l=Math.max(0,l);var c="",h=0;if(e.options.indentWithTabs)for(var p=Math.floor(l/o);p;--p)h+=o,c+="	";h<l&&(c+=jo(l-h));if(c!=f)Qr(i,c,ht(t,0),ht(t,f.length),"+input");else for(var p=0;p<i.sel.ranges.length;p++){var d=i.sel.ranges[p];if(d.head.line==t&&d.head.ch<f.length){var h=ht(t,f.length);At(i,p,new yt(h,h));break}}u.stateAfter=null}function si(e,t,n,r){var i=t,s=t;return typeof t=="number"?s=Us(e,Et(e,t)):i=Vs(t),i==null?null:(r(s,i)&&e.cm&&zn(e.cm,i,n),s)}function oi(e,t){var n=e.doc.sel.ranges,r=[];for(var i=0;i<n.length;i++){var s=t(n[i]);while(r.length&&pt(s.from,Fo(r).to)<=0){var o=r.pop();if(pt(o.from,s.from)<0){s.from=o.from;break}}r.push(s)}Bn(e,function(){for(var t=r.length-1;t>=0;t--)Qr(e.doc,"",r[t].from,r[t].to,"+delete");ni(e)})}function ui(e,t,n,r,i){function l(){var t=s+n;return t<e.first||t>=e.first+e.size?f=!1:(s=t,a=Us(e,t))}function c(e){var t=(i?Bu:ju)(a,o,n,!0);if(t==null){if(!!e||!l())return f=!1;i?o=(n<0?Lu:ku)(a):o=n<0?a.text.length:0}else o=t;return!0}var s=t.line,o=t.ch,u=n,a=Us(e,s),f=!0;if(r=="char")c();else if(r=="column")c(!0);else if(r=="word"||r=="group"){var h=null,p=r=="group",d=e.cm&&e.cm.getHelper(t,"wordChars");for(var v=!0;;v=!1){if(n<0&&!c(!v))break;var m=a.text.charAt(o)||"\n",g=$o(m,d)?"w":p&&m=="\n"?"n":!p||/\s/.test(m)?null:"p";p&&!v&&!g&&(g="s");if(h&&h!=g){n<0&&(n=1,c());break}g&&(h=g);if(n>0&&!c(!v))break}}var y=Ft(e,ht(s,o),u,!0);return f||(y.hitSide=!0),y}function ai(e,t,n,r){var i=e.doc,s=t.left,o;if(r=="page"){var u=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);o=t.top+n*(u-(n<0?1.5:.5)*xn(e.display))}else r=="line"&&(o=n>0?t.bottom+3:t.top-3);for(;;){var a=wn(e,s,o);if(!a.outside)break;if(n<0?o<=0:o>=i.height){a.hitSide=!0;break}o+=n*5}return a}function ci(e,t,n,r){S.defaults[e]=t,n&&(li[e]=r?function(e,t,r){r!=hi&&n(e,t,r)}:n)}function Si(e){var t=e.split(/-(?!$)/),e=t[t.length-1],n,r,i,s;for(var o=0;o<t.length-1;o++){var u=t[o];if(/^(cmd|meta|m)$/i.test(u))s=!0;else if(/^a(lt)?$/i.test(u))n=!0;else if(/^(c|ctrl|control)$/i.test(u))r=!0;else{if(!/^s(hift)$/i.test(u))throw new Error("Unrecognized modifier name: "+u);i=!0}}return n&&(e="Alt-"+e),r&&(e="Ctrl-"+e),s&&(e="Cmd-"+e),i&&(e="Shift-"+e),e}function Ci(e){return typeof e=="string"?Ei[e]:e}function Oi(e,t,n,r,i){if(r&&r.shared)return _i(e,t,n,r,i);if(e.cm&&!e.cm.curOp)return jn(e.cm,Oi)(e,t,n,r,i);var s=new Li(e,i),o=pt(t,n);r&&zo(r,s,!1);if(o>0||o==0&&s.clearWhenEmpty!==!1)return s;s.replacedWith&&(s.collapsed=!0,s.widgetNode=Go("span",[s.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||(s.widgetNode.ignoreEvents=!0),r.insertLeft&&(s.widgetNode.insertLeft=!0));if(s.collapsed){if(es(e,t.line,t,n,s)||t.line!=n.line&&es(e,n.line,t,n,s))throw new Error("Inserting collapsed marker partially overlapping an existing one");E=!0}s.addToHistory&&eo(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var u=t.line,a=e.cm,f;e.iter(u,n.line+1,function(e){a&&s.collapsed&&!a.options.lineWrapping&&ts(e)==a.display.maxLine&&(f=!0),s.collapsed&&u!=t.line&&Xs(e,0),Ii(e,new Bi(s,u==t.line?t.ch:null,u==n.line?n.ch:null)),++u}),s.collapsed&&e.iter(t.line,n.line+1,function(t){ss(e,t)&&Xs(t,0)}),s.clearOnEnter&&yo(s,"beforeCursorEnter",function(){s.clear()}),s.readOnly&&(w=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),s.collapsed&&(s.id=++Ai,s.atomic=!0);if(a){f&&(a.curOp.updateMaxLine=!0);if(s.collapsed)Un(a,t.line,n.line+1);else if(s.className||s.title||s.startStyle||s.endStyle)for(var l=t.line;l<=n.line;l++)zn(a,l,"text");s.atomic&&Bt(a.doc),So(a,"markerAdded",a,s)}return s}function _i(e,t,n,r,i){r=zo(r),r.shared=!1;var s=[Oi(e,t,n,r,i)],o=s[0],u=r.widgetNode;return qs(e,function(e){u&&(r.widgetNode=u.cloneNode(!0)),s.push(Oi(e,St(e,t),St(e,n),r,i));for(var a=0;a<e.linked.length;++a)if(e.linked[a].isParent)return;o=Fo(s)}),new Mi(s,o)}function Di(e){return e.findMarks(ht(e.first,0),e.clipPos(ht(e.lastLine())),function(e){return e.parent})}function Pi(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.find(),s=e.clipPos(i.from),o=e.clipPos(i.to);if(pt(s,o)){var u=Oi(e,s,o,r.primary,r.primary.type);r.markers.push(u),u.parent=r}}}function Hi(e){for(var t=0;t<e.length;t++){var n=e[t],r=[n.primary.doc];qs(n.primary.doc,function(e){r.push(e)});for(var i=0;i<n.markers.length;i++){var s=n.markers[i];qo(r,s.doc)==-1&&(s.parent=null,n.markers.splice(i--,1))}}}function Bi(e,t,n){this.marker=e,this.from=t,this.to=n}function ji(e,t){if(e)for(var n=0;n<e.length;++n){var r=e[n];if(r.marker==t)return r}}function Fi(e,t){for(var n,r=0;r<e.length;++r)e[r]!=t&&(n||(n=[])).push(e[r]);return n}function Ii(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function qi(e,t,n){if(e)for(var r=0,i;r<e.length;++r){var s=e[r],o=s.marker,u=s.from==null||(o.inclusiveLeft?s.from<=t:s.from<t);if(u||s.from==t&&o.type=="bookmark"&&(!n||!s.marker.insertLeft)){var a=s.to==null||(o.inclusiveRight?s.to>=t:s.to>t);(i||(i=[])).push(new Bi(o,s.from,a?null:s.to))}}return i}function Ri(e,t,n){if(e)for(var r=0,i;r<e.length;++r){var s=e[r],o=s.marker,u=s.to==null||(o.inclusiveRight?s.to>=t:s.to>t);if(u||s.from==t&&o.type=="bookmark"&&(!n||s.marker.insertLeft)){var a=s.from==null||(o.inclusiveLeft?s.from<=t:s.from<t);(i||(i=[])).push(new Bi(o,a?null:s.from-t,s.to==null?null:s.to-t))}}return i}function Ui(e,t){var n=Tt(e,t.from.line)&&Us(e,t.from.line).markedSpans,r=Tt(e,t.to.line)&&Us(e,t.to.line).markedSpans;if(!n&&!r)return null;var i=t.from.ch,s=t.to.ch,o=pt(t.from,t.to)==0,u=qi(n,i,o),a=Ri(r,s,o),f=t.text.length==1,l=Fo(t.text).length+(f?i:0);if(u)for(var c=0;c<u.length;++c){var h=u[c];if(h.to==null){var p=ji(a,h.marker);p?f&&(h.to=p.to==null?null:p.to+l):h.to=i}}if(a)for(var c=0;c<a.length;++c){var h=a[c];h.to!=null&&(h.to+=l);if(h.from==null){var p=ji(u,h.marker);p||(h.from=l,f&&(u||(u=[])).push(h))}else h.from+=l,f&&(u||(u=[])).push(h)}u&&(u=zi(u)),a&&a!=u&&(a=zi(a));var d=[u];if(!f){var v=t.text.length-2,m;if(v>0&&u)for(var c=0;c<u.length;++c)u[c].to==null&&(m||(m=[])).push(new Bi(u[c].marker,null,null));for(var c=0;c<v;++c)d.push(m);d.push(a)}return d}function zi(e){for(var t=0;t<e.length;++t){var n=e[t];n.from!=null&&n.from==n.to&&n.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Wi(e,t){var n=oo(e,t),r=Ui(e,t);if(!n)return r;if(!r)return n;for(var i=0;i<n.length;++i){var s=n[i],o=r[i];if(s&&o)e:for(var u=0;u<o.length;++u){var a=o[u];for(var f=0;f<s.length;++f)if(s[f].marker==a.marker)continue e;s.push(a)}else o&&(n[i]=o)}return n}function Xi(e,t,n){var r=null;e.iter(t.line,n.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var n=e.markedSpans[t].marker;n.readOnly&&(!r||qo(r,n)==-1)&&(r||(r=[])).push(n)}});if(!r)return null;var i=[{from:t,to:n}];for(var s=0;s<r.length;++s){var o=r[s],u=o.find(0);for(var a=0;a<i.length;++a){var f=i[a];if(pt(f.to,u.from)<0||pt(f.from,u.to)>0)continue;var l=[a,1],c=pt(f.from,u.from),h=pt(f.to,u.to);(c<0||!o.inclusiveLeft&&!c)&&l.push({from:f.from,to:u.from}),(h>0||!o.inclusiveRight&&!h)&&l.push({from:u.to,to:f.to}),i.splice.apply(i,l),a+=l.length-1}}return i}function Vi(e){var t=e.markedSpans;if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}function $i(e,t){if(!t)return;for(var n=0;n<t.length;++n)t[n].marker.attachLine(e);e.markedSpans=t}function Ji(e){return e.inclusiveLeft?-1:0}function Ki(e){return e.inclusiveRight?1:0}function Qi(e,t){var n=e.lines.length-t.lines.length;if(n!=0)return n;var r=e.find(),i=t.find(),s=pt(r.from,i.from)||Ji(e)-Ji(t);if(s)return-s;var o=pt(r.to,i.to)||Ki(e)-Ki(t);return o?o:t.id-e.id}function Gi(e,t){var n=E&&e.markedSpans,r;if(n)for(var i,s=0;s<n.length;++s)i=n[s],i.marker.collapsed&&(t?i.from:i.to)==null&&(!r||Qi(r,i.marker)<0)&&(r=i.marker);return r}function Yi(e){return Gi(e,!0)}function Zi(e){return Gi(e,!1)}function es(e,t,n,r,i){var s=Us(e,t),o=E&&s.markedSpans;if(o)for(var u=0;u<o.length;++u){var a=o[u];if(!a.marker.collapsed)continue;var f=a.marker.find(0),l=pt(f.from,n)||Ji(a.marker)-Ji(i),c=pt(f.to,r)||Ki(a.marker)-Ki(i);if(l>=0&&c<=0||l<=0&&c>=0)continue;if(l<=0&&(pt(f.to,n)>0||a.marker.inclusiveRight&&i.inclusiveLeft)||l>=0&&(pt(f.from,r)<0||a.marker.inclusiveLeft&&i.inclusiveRight))return!0}}function ts(e){var t;while(t=Yi(e))e=t.find(-1,!0).line;return e}function ns(e){var t,n;while(t=Zi(e))e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function rs(e,t){var n=Us(e,t),r=ts(n);return n==r?t:Vs(r)}function is(e,t){if(t>e.lastLine())return t;var n=Us(e,t),r;if(!ss(e,n))return t;while(r=Zi(n))n=r.find(1,!0).line;return Vs(n)+1}function ss(e,t){var n=E&&t.markedSpans;if(n)for(var r,i=0;i<n.length;++i){r=n[i];if(!r.marker.collapsed)continue;if(r.from==null)return!0;if(r.marker.widgetNode)continue;if(r.from==0&&r.marker.inclusiveLeft&&os(e,t,r))return!0}}function os(e,t,n){if(n.to==null){var r=n.marker.find(1,!0);return os(e,r.line,ji(r.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length)return!0;for(var i,s=0;s<t.markedSpans.length;++s){i=t.markedSpans[s];if(i.marker.collapsed&&!i.marker.widgetNode&&i.from==n.to&&(i.to==null||i.to!=n.from)&&(i.marker.inclusiveLeft||n.marker.inclusiveRight)&&os(e,t,i))return!0}}function as(e,t,n){Js(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&ti(e,null,n)}function fs(e){if(e.height!=null)return e.height;if(!tu(document.body,e.node)){var t="position: relative;";e.coverGutter&&(t+="margin-left: -"+e.cm.getGutterElement().offsetWidth+"px;"),eu(e.cm.display.measure,Go("div",[e.node],null,t))}return e.height=e.node.offsetHeight}function ls(e,t,n,r){var i=new us(e,n,r);return i.noHScroll&&(e.display.alignWidgets=!0),si(e.doc,t,"widget",function(t){var n=t.widgets||(t.widgets=[]);i.insertAt==null?n.push(i):n.splice(Math.min(n.length-1,Math.max(0,i.insertAt)),0,i),i.line=t;if(!ss(e.doc,t)){var r=Js(t)<e.doc.scrollTop;Xs(t,t.height+fs(i)),r&&ti(e,null,i.height),e.curOp.forceUpdate=!0}return!0}),i}function hs(e,t,n,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),e.order!=null&&(e.order=null),Vi(e),$i(e,n);var i=r?r(e):1;i!=e.height&&Xs(e,i)}function ps(e){e.parent=null,Vi(e)}function ds(e,t){if(e)for(;;){var n=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;e=e.slice(0,n.index)+e.slice(n.index+n[0].length);var r=n[1]?"bgClass":"textClass";t[r]==null?t[r]=n[2]:(new RegExp("(?:^|s)"+n[2]+"(?:$|s)")).test(t[r])||(t[r]+=" "+n[2])}return e}function vs(e,t){if(e.blankLine)return e.blankLine(t);if(!e.innerMode)return;var n=S.innerMode(e,t);if(n.mode.blankLine)return n.mode.blankLine(n.state)}function ms(e,t,n,r){for(var i=0;i<10;i++){r&&(r[0]=S.innerMode(e,n).mode);var s=e.token(t,n);if(t.pos>t.start)return s}throw new Error("Mode "+e.name+" failed to advance stream.")}function gs(e,t,n,r){function i(e){return{start:l.start,end:l.pos,string:l.current(),type:u||null,state:e?yi(s.mode,f):f}}var s=e.doc,o=s.mode,u;t=St(s,t);var a=Us(s,t.line),f=Jt(e,t.line,n),l=new ki(a.text,e.options.tabSize),c;r&&(c=[]);while((r||l.pos<t.ch)&&!l.eol())l.start=l.pos,u=ms(o,l,f),r&&c.push(i(!0));return r?c:i()}function ys(e,t,n,r,i,s,o){var u=n.flattenSpans;u==null&&(u=e.options.flattenSpans);var a=0,f=null,l=new ki(t,e.options.tabSize),c,h=e.options.addModeClass&&[null];t==""&&ds(vs(n,r),s);while(!l.eol()){l.pos>e.options.maxHighlightLength?(u=!1,o&&Es(e,t,r,l.pos),l.pos=t.length,c=null):c=ds(ms(n,l,r,h),s);if(h){var p=h[0].name;p&&(c="m-"+(c?p+" "+c:p))}if(!u||f!=c)a<l.start&&i(l.start,f),a=l.start,f=c;l.start=l.pos}while(a<l.pos){var d=Math.min(l.pos,a+5e4);i(d,f),a=d}}function bs(e,t,n,r){var i=[e.state.modeGen],s={};ys(e,t.text,e.doc.mode,n,function(e,t){i.push(e,t)},s,r);for(var o=0;o<e.state.overlays.length;++o){var u=e.state.overlays[o],a=1,f=0;ys(e,t.text,u.mode,!0,function(e,t){var n=a;while(f<e){var r=i[a];r>e&&i.splice(a,1,e,i[a+1],r),a+=2,f=Math.min(e,r)}if(!t)return;if(u.opaque)i.splice(n,a-n,e,"cm-overlay "+t),a=n+2;else for(;n<a;n+=2){var s=i[n+1];i[n+1]=(s?s+" ":"")+"cm-overlay "+t}},s)}return{styles:i,classes:s.bgClass||s.textClass?s:null}}function ws(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=bs(e,t,t.stateAfter=Jt(e,Vs(t)));t.styles=r.styles,r.classes?t.styleClasses=r.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.frontier&&e.doc.frontier++}return t.styles}function Es(e,t,n,r){var i=e.doc.mode,s=new ki(t,e.options.tabSize);s.start=s.pos=r||0,t==""&&vs(i,n);while(!s.eol()&&s.pos<=e.options.maxHighlightLength)ms(i,s,n),s.start=s.pos}function Ts(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?xs:Ss;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Ns(e,t){var n=Go("span",null,null,s?"padding-right: .1px":null),i={pre:Go("pre",[n]),content:n,col:0,pos:0,cm:e};t.measure={};for(var o=0;o<=(t.rest?t.rest.length:0);o++){var u=o?t.rest[o-1]:t.line,a;i.pos=0,i.addToken=ks,(r||s)&&e.getOption("lineWrapping")&&(i.addToken=Ls(i.addToken)),gu(e.display.measure)&&(a=Ks(u))&&(i.addToken=As(i.addToken,a)),i.map=[];var f=t!=e.display.externalMeasured&&Vs(u);Ms(u,i,ws(e,u,f)),u.styleClasses&&(u.styleClasses.bgClass&&(i.bgClass=ou(u.styleClasses.bgClass,i.bgClass||"")),u.styleClasses.textClass&&(i.textClass=ou(u.styleClasses.textClass,i.textClass||""))),i.map.length==0&&i.map.push(0,0,i.content.appendChild(vu(e.display.measure))),o==0?(t.measure.map=i.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(i.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return s&&/\bcm-tab\b/.test(i.content.lastChild.className)&&(i.content.className="cm-tab-wrap-hack"),wo(e,"renderLine",e,t.line,i.pre),i.pre.className&&(i.textClass=ou(i.pre.className,i.textClass||"")),i}function Cs(e){var t=Go("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t}function ks(e,t,n,s,o,u){if(!t)return;var a=e.cm.options.specialChars,f=!1;if(!a.test(t)){e.col+=t.length;var l=document.createTextNode(t);e.map.push(e.pos,e.pos+t.length,l),r&&i<9&&(f=!0),e.pos+=t.length}else{var l=document.createDocumentFragment(),c=0;for(;;){a.lastIndex=c;var h=a.exec(t),p=h?h.index-c:t.length-c;if(p){var d=document.createTextNode(t.slice(c,c+p));r&&i<9?l.appendChild(Go("span",[d])):l.appendChild(d),e.map.push(e.pos,e.pos+p,d),e.col+=p,e.pos+=p}if(!h)break;c+=p+1;if(h[0]=="	"){var v=e.cm.options.tabSize,m=v-e.col%v,d=l.appendChild(Go("span",jo(m),"cm-tab"));e.col+=m}else{var d=e.cm.options.specialCharPlaceholder(h[0]);r&&i<9?l.appendChild(Go("span",[d])):l.appendChild(d),e.col+=1}e.map.push(e.pos,e.pos+1,d),e.pos++}}if(n||s||o||f){var g=n||"";s&&(g+=s),o&&(g+=o);var y=Go("span",[l],g);return u&&(y.title=u),e.content.appendChild(y)}e.content.appendChild(l)}function Ls(e){function t(e){var t=" ";for(var n=0;n<e.length-2;++n)t+=n%2?" ":" ";return t+=" ",t}return function(n,r,i,s,o,u){e(n,r.replace(/ {3,}/g,t),i,s,o,u)}}function As(e,t){return function(n,r,i,s,o,u){i=i?i+" cm-force-border":"cm-force-border";var a=n.pos,f=a+r.length;for(;;){for(var l=0;l<t.length;l++){var c=t[l];if(c.to>a&&c.from<=a)break}if(c.to>=f)return e(n,r,i,s,o,u);e(n,r.slice(0,c.to-a),i,s,null,u),s=null,r=r.slice(c.to-a),a=c.to}}}function Os(e,t,n,r){var i=!r&&n.widgetNode;i&&(e.map.push(e.pos,e.pos+t,i),e.content.appendChild(i)),e.pos+=t}function Ms(e,t,n){var r=e.markedSpans,i=e.text,s=0;if(!r){for(var o=1;o<n.length;o+=2)t.addToken(t,i.slice(s,s=n[o]),Ts(n[o+1],t.cm.options));return}var u=i.length,a=0,o=1,f="",l,c=0,h,p,d,v,m;for(;;){if(c==a){h=p=d=v="",m=null,c=Infinity;var g=[];for(var y=0;y<r.length;++y){var b=r[y],w=b.marker;b.from<=a&&(b.to==null||b.to>a)?(b.to!=null&&c>b.to&&(c=b.to,p=""),w.className&&(h+=" "+w.className),w.startStyle&&b.from==a&&(d+=" "+w.startStyle),w.endStyle&&b.to==c&&(p+=" "+w.endStyle),w.title&&!v&&(v=w.title),w.collapsed&&(!m||Qi(m.marker,w)<0)&&(m=b)):b.from>a&&c>b.from&&(c=b.from),w.type=="bookmark"&&b.from==a&&w.widgetNode&&g.push(w)}if(m&&(m.from||0)==a){Os(t,(m.to==null?u+1:m.to)-a,m.marker,m.from==null);if(m.to==null)return}if(!m&&g.length)for(var y=0;y<g.length;++y)Os(t,0,g[y])}if(a>=u)break;var E=Math.min(u,c);for(;;){if(f){var S=a+f.length;if(!m){var x=S>E?f.slice(0,E-a):f;t.addToken(t,x,l?l+h:h,d,a+x.length==c?p:"",v)}if(S>=E){f=f.slice(E-a),a=E;break}a=S,d=""}f=i.slice(s,s=n[o++]),l=Ts(n[o++],t.cm.options)}}}function _s(e,t){return t.from.ch==0&&t.to.ch==0&&Fo(t.text)==""&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Ds(e,t,n,r){function i(e){return n?n[e]:null}function s(e,n,i){hs(e,n,i,r),So(e,"change",e,t)}var o=t.from,u=t.to,a=t.text,f=Us(e,o.line),l=Us(e,u.line),c=Fo(a),h=i(a.length-1),p=u.line-o.line;if(_s(e,t)){for(var d=0,v=[];d<a.length-1;++d)v.push(new cs(a[d],i(d),r));s(l,l.text,h),p&&e.remove(o.line,p),v.length&&e.insert(o.line,v)}else if(f==l)if(a.length==1)s(f,f.text.slice(0,o.ch)+c+f.text.slice(u.ch),h);else{for(var v=[],d=1;d<a.length-1;++d)v.push(new cs(a[d],i(d),r));v.push(new cs(c+f.text.slice(u.ch),h,r)),s(f,f.text.slice(0,o.ch)+a[0],i(0)),e.insert(o.line+1,v)}else if(a.length==1)s(f,f.text.slice(0,o.ch)+a[0]+l.text.slice(u.ch),i(0)),e.remove(o.line+1,p);else{s(f,f.text.slice(0,o.ch)+a[0],i(0)),s(l,c+l.text.slice(u.ch),h);for(var d=1,v=[];d<a.length-1;++d)v.push(new cs(a[d],i(d),r));p>1&&e.remove(o.line+1,p-1),e.insert(o.line+1,v)}So(e,"change",e,t)}function Ps(e){this.lines=e,this.parent=null;for(var t=0,n=0;t<e.length;++t)e[t].parent=this,n+=e[t].height;this.height=n}function Hs(e){this.children=e;var t=0,n=0;for(var r=0;r<e.length;++r){var i=e[r];t+=i.chunkSize(),n+=i.height,i.parent=this}this.size=t,this.height=n,this.parent=null}function qs(e,t,n){function r(e,i,s){if(e.linked)for(var o=0;o<e.linked.length;++o){var u=e.linked[o];if(u.doc==i)continue;var a=s&&u.sharedHist;if(n&&!a)continue;t(u.doc,a),r(u.doc,e,a)}}r(e,null,!0)}function Rs(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,L(e),T(e),e.options.lineWrapping||P(e),e.options.mode=t.modeOption,Un(e)}function Us(e,t){t-=e.first;if(t<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],s=i.chunkSize();if(t<s){n=i;break}t-=s}return n.lines[t]}function zs(e,t,n){var r=[],i=t.line;return e.iter(t.line,n.line+1,function(e){var s=e.text;i==n.line&&(s=s.slice(0,n.ch)),i==t.line&&(s=s.slice(t.ch)),r.push(s),++i}),r}function Ws(e,t,n){var r=[];return e.iter(t,n,function(e){r.push(e.text)}),r}function Xs(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function Vs(e){if(e.parent==null)return null;var t=e.parent,n=qo(t.lines,e);for(var r=t.parent;r;t=r,r=r.parent)for(var i=0;;++i){if(r.children[i]==t)break;n+=r.children[i].chunkSize()}return n+t.first}function $s(e,t){var n=e.first;e:do{for(var r=0;r<e.children.length;++r){var i=e.children[r],s=i.height;if(t<s){e=i;continue e}t-=s,n+=i.chunkSize()}return n}while(!e.lines);for(var r=0;r<e.lines.length;++r){var o=e.lines[r],u=o.height;if(t<u)break;t-=u}return n+r}function Js(e){e=ts(e);var t=0,n=e.parent;for(var r=0;r<n.lines.length;++r){var i=n.lines[r];if(i==e)break;t+=i.height}for(var s=n.parent;s;n=s,s=n.parent)for(var r=0;r<s.children.length;++r){var o=s.children[r];if(o==n)break;t+=o.height}return t}function Ks(e){var t=e.order;return t==null&&(t=e.order=Fu(e.text)),t}function Qs(e){this.done=[],this.undone=[],this.undoDepth=Infinity,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Gs(e,t){var n={from:dt(t.from),to:Fr(t),text:zs(e,t.from,t.to)};return io(e,n,t.from.line,t.to.line+1),qs(e,function(e){io(e,n,t.from.line,t.to.line+1)},!0),n}function Ys(e){while(e.length){var t=Fo(e);if(!t.ranges)break;e.pop()}}function Zs(e,t){if(t)return Ys(e.done),Fo(e.done);if(e.done.length&&!Fo(e.done).ranges)return Fo(e.done);if(e.done.length>1&&!e.done[e.done.length-2].ranges)return e.done.pop(),Fo(e.done)}function eo(e,t,n,r){var i=e.history;i.undone.length=0;var s=+(new Date),o;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&(t.origin.charAt(0)=="+"&&e.cm&&i.lastModTime>s-e.cm.options.historyEventDelay||t.origin.charAt(0)=="*"))&&(o=Zs(i,i.lastOp==r))){var u=Fo(o.changes);pt(t.from,t.to)==0&&pt(t.from,u.to)==0?u.to=Fr(t):o.changes.push(Gs(e,t))}else{var a=Fo(i.done);(!a||!a.ranges)&&ro(e.sel,i.done),o={changes:[Gs(e,t)],generation:i.generation},i.done.push(o);while(i.done.length>i.undoDepth)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=s,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,u||wo(e,"historyAdded")}function to(e,t,n,r){var i=t.charAt(0);return i=="*"||i=="+"&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function no(e,t,n,r){var i=e.history,s=r&&r.origin;n==i.lastSelOp||s&&i.lastSelOrigin==s&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==s||to(e,s,Fo(i.done),t))?i.done[i.done.length-1]=t:ro(t,i.done),i.lastSelTime=+(new Date),i.lastSelOrigin=s,i.lastSelOp=n,r&&r.clearRedo!==!1&&Ys(i.undone)}function ro(e,t){var n=Fo(t);n&&n.ranges&&n.equals(e)||t.push(e)}function io(e,t,n,r){var i=t["spans_"+e.id],s=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(n){n.markedSpans&&((i||(i=t["spans_"+e.id]={}))[s]=n.markedSpans),++s})}function so(e){if(!e)return null;for(var t=0,n;t<e.length;++t)e[t].marker.explicitlyCleared?n||(n=e.slice(0,t)):n&&n.push(e[t]);return n?n.length?n:null:e}function oo(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var r=0,i=[];r<t.text.length;++r)i.push(so(n[r]));return i}function uo(e,t,n){for(var r=0,i=[];r<e.length;++r){var s=e[r];if(s.ranges){i.push(n?gt.prototype.deepCopy.call(s):s);continue}var o=s.changes,u=[];i.push({changes:u});for(var a=0;a<o.length;++a){var f=o[a],l;u.push({from:f.from,to:f.to,text:f.text});if(t)for(var c in f)(l=c.match(/^spans_(\d+)$/))&&qo(t,Number(l[1]))>-1&&(Fo(u)[c]=f[c],delete f[c])}}return i}function ao(e,t,n,r){n<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function fo(e,t,n,r){for(var i=0;i<e.length;++i){var s=e[i],o=!0;if(s.ranges){s.copied||(s=e[i]=s.deepCopy(),s.copied=!0);for(var u=0;u<s.ranges.length;u++)ao(s.ranges[u].anchor,t,n,r),ao(s.ranges[u].head,t,n,r);continue}for(var u=0;u<s.changes.length;++u){var a=s.changes[u];if(n<a.from.line)a.from=ht(a.from.line+r,a.from.ch),a.to=ht(a.to.line+r,a.to.ch);else if(t<=a.to.line){o=!1;break}}o||(e.splice(0,i+1),i=0)}}function lo(e,t){var n=t.from.line,r=t.to.line,i=t.text.length-(r-n)-1;fo(e.done,n,r,i),fo(e.undone,n,r,i)}function po(e){return e.defaultPrevented!=null?e.defaultPrevented:e.returnValue==0}function mo(e){return e.target||e.srcElement}function go(e){var t=e.which;return t==null&&(e.button&1?t=1:e.button&2?t=3:e.button&4&&(t=2)),v&&e.ctrlKey&&t==1&&(t=3),t}function So(e,t){function s(e){return function(){e.apply(null,r)}}var n=e._handlers&&e._handlers[t];if(!n)return;var r=Array.prototype.slice.call(arguments,2),i;Nn?i=Nn.delayedCallbacks:Eo?i=Eo:(i=Eo=[],setTimeout(xo,0));for(var o=0;o<n.length;++o)i.push(s(n[o]))}function xo(){var e=Eo;Eo=null;for(var t=0;t<e.length;++t)e[t]()}function To(e,t,n){return typeof t=="string"&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),wo(e,n||t.type,e,t),po(t)||t.codemirrorIgnore}function No(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t)return;var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]);for(var r=0;r<t.length;++r)qo(n,t[r])==-1&&n.push(t[r])}function Co(e,t){var n=e._handlers&&e._handlers[t];return n&&n.length>0}function ko(e){e.prototype.on=function(e,t){yo(this,e,t)},e.prototype.off=function(e,t){bo(this,e,t)}}function Do(){this.id=null}function Ho(e,t,n){for(var r=0,i=0;;){var s=e.indexOf("	",r);s==-1&&(s=e.length);var o=s-r;if(s==e.length||i+o>=t)return r+Math.min(o,t-i);i+=s-r,i+=n-i%n,r=s+1;if(i>=t)return r}}function jo(e){while(Bo.length<=e)Bo.push(Fo(Bo)+" ");return Bo[e]}function Fo(e){return e[e.length-1]}function qo(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}function Ro(e,t){var n=[];for(var r=0;r<e.length;r++)n[r]=t(e[r],r);return n}function Uo(e,t){var n;if(Object.create)n=Object.create(e);else{var r=function(){};r.prototype=e,n=new r}return t&&zo(t,n),n}function zo(e,t,n){t||(t={});for(var r in e)e.hasOwnProperty(r)&&(n!==!1||!t.hasOwnProperty(r))&&(t[r]=e[r]);return t}function Wo(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function $o(e,t){return t?t.source.indexOf("\\w")>-1&&Vo(e)?!0:t.test(e):Vo(e)}function Jo(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function Qo(e){return e.charCodeAt(0)>=768&&Ko.test(e)}function Go(e,t,n,r){var i=document.createElement(e);n&&(i.className=n),r&&(i.style.cssText=r);if(typeof t=="string")i.appendChild(document.createTextNode(t));else if(t)for(var s=0;s<t.length;++s)i.appendChild(t[s]);return i}function Zo(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function eu(e,t){return Zo(e).appendChild(t)}function tu(e,t){if(e.contains)return e.contains(t);while(t=t.parentNode)if(t==e)return!0}function nu(){return document.activeElement}function ru(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function ou(e,t){var n=e.split(" ");for(var r=0;r<n.length;r++)n[r]&&!ru(n[r]).test(t)&&(t+=" "+n[r]);return t}function uu(e){if(!document.body.getElementsByClassName)return;var t=document.body.getElementsByClassName("CodeMirror");for(var n=0;n<t.length;n++){var r=t[n].CodeMirror;r&&e(r)}}function fu(){if(au)return;lu(),au=!0}function lu(){var e;yo(window,"resize",function(){e==null&&(e=setTimeout(function(){e=null,hu=null,uu(ir)},100))}),yo(window,"blur",function(){uu(Hr)})}function pu(e){if(hu!=null)return hu;var t=Go("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");return eu(e,t),t.offsetWidth&&(hu=t.offsetHeight-t.clientHeight),hu||0}function vu(e){if(du==null){var t=Go("span","​");eu(e,Go("span",[t,document.createTextNode("x")])),e.firstChild.offsetHeight!=0&&(du=t.offsetWidth<=1&&t.offsetHeight>2&&!(r&&i<8))}return du?Go("span","​"):Go("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px")}function gu(e){if(mu!=null)return mu;var t=eu(e,document.createTextNode("AخA")),n=Yo(t,0,1).getBoundingClientRect();if(!n||n.left==n.right)return!1;var r=Yo(t,1,2).getBoundingClientRect();return mu=r.right-n.right<3}function Su(e){if(Eu!=null)return Eu;var t=eu(e,Go("span","x")),n=t.getBoundingClientRect(),r=Yo(t,0,1).getBoundingClientRect();return Eu=Math.abs(n.left-r.left)>1}function Tu(e,t,n,r){if(!e)return r(t,n,"ltr");var i=!1;for(var s=0;s<e.length;++s){var o=e[s];if(o.from<n&&o.to>t||t==n&&o.to==t)r(Math.max(o.from,t),Math.min(o.to,n),o.level==1?"rtl":"ltr"),i=!0}i||r(t,n,"ltr")}function Nu(e){return e.level%2?e.to:e.from}function Cu(e){return e.level%2?e.from:e.to}function ku(e){var t=Ks(e);return t?Nu(t[0]):0}function Lu(e){var t=Ks(e);return t?Cu(Fo(t)):e.text.length}function Au(e,t){var n=Us(e.doc,t),r=ts(n);r!=n&&(t=Vs(r));var i=Ks(r),s=i?i[0].level%2?Lu(r):ku(r):0;return ht(t,s)}function Ou(e,t){var n,r=Us(e.doc,t);while(n=Zi(r))r=n.find(1,!0).line,t=null;var i=Ks(r),s=i?i[0].level%2?ku(r):Lu(r):r.text.length;return ht(t==null?Vs(r):t,s)}function Mu(e,t){var n=Au(e,t.line),r=Us(e.doc,n.line),i=Ks(r);if(!i||i[0].level==0){var s=Math.max(0,r.text.search(/\S/)),o=t.line==n.line&&t.ch<=s&&t.ch;return ht(n.line,o?0:s)}return n}function _u(e,t,n){var r=e[0].level;return t==r?!0:n==r?!1:t<n}function Pu(e,t){Du=null;for(var n=0,r;n<e.length;++n){var i=e[n];if(i.from<t&&i.to>t)return n;if(i.from==t||i.to==t){if(r!=null)return _u(e,i.level,e[r].level)?(i.from!=i.to&&(Du=r),n):(i.from!=i.to&&(Du=n),r);r=n}}return r}function Hu(e,t,n,r){if(!r)return t+n;do t+=n;while(t>0&&Qo(e.text.charAt(t)));return t}function Bu(e,t,n,r){var i=Ks(e);if(!i)return ju(e,t,n,r);var s=Pu(i,t),o=i[s],u=Hu(e,t,o.level%2?-n:n,r);for(;;){if(u>o.from&&u<o.to)return u;if(u==o.from||u==o.to)return Pu(i,u)==s?u:(o=i[s+=n],n>0==o.level%2?o.to:o.from);o=i[s+=n];if(!o)return null;n>0==o.level%2?u=Hu(e,o.to,-1,r):u=Hu(e,o.from,1,r)}}function ju(e,t,n,r){var i=t+n;if(r)while(i>0&&Qo(e.text.charAt(i)))i+=n;return i<0||i>e.text.length?null:i}var e=/gecko\/\d/i.test(navigator.userAgent),t=/MSIE \d/.test(navigator.userAgent),n=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),r=t||n,i=r&&(t?document.documentMode||6:n[1]),s=/WebKit\//.test(navigator.userAgent),o=s&&/Qt\/\d+\.\d+/.test(navigator.userAgent),u=/Chrome\//.test(navigator.userAgent),a=/Opera\//.test(navigator.userAgent),f=/Apple Computer/.test(navigator.vendor),l=/KHTML\//.test(navigator.userAgent),c=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),h=/PhantomJS/.test(navigator.userAgent),p=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),d=p||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),v=p||/Mac/.test(navigator.platform),m=/win/i.test(navigator.platform),g=a&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);g&&(g=Number(g[1])),g&&g>=15&&(a=!1,s=!0);var y=v&&(o||a&&(g==null||g<12.11)),b=e||r&&i>=9,w=!1,E=!1,ht=S.Pos=function(e,t){if(!(this instanceof ht))return new ht(e,t);this.line=e,this.ch=t},pt=S.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch};gt.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var n=this.ranges[t],r=e.ranges[t];if(pt(n.anchor,r.anchor)!=0||pt(n.head,r.head)!=0)return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new yt(dt(this.ranges[t].anchor),dt(this.ranges[t].head));return new gt(e,this.primIndex)},somethingSelected:function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},contains:function(e,t){t||(t=e);for(var n=0;n<this.ranges.length;n++){var r=this.ranges[n];if(pt(t,r.from())>=0&&pt(e,r.to())<=0)return n}return-1}},yt.prototype={from:function(){return mt(this.anchor,this.head)},to:function(){return vt(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var on={left:0,right:0,top:0,bottom:0},Sn,Nn=null,Cn=0,Gn=null,ar,fr,vr=0,wr=0,Er=null;r?Er=-0.53:e?Er=15:u?Er=-0.7:f&&(Er=-1/3);var Nr=new Do,Ar=null,Fr=S.changeEnd=function(e){return e.text?ht(e.from.line+e.text.length-1,Fo(e.text).length+(e.text.length==1?e.from.ch:0)):e.to};S.prototype={constructor:S,focus:function(){window.focus(),er(this),Qn(this)},setOption:function(e,t){var n=this.options,r=n[e];if(n[e]==t&&e!="mode")return;n[e]=t,li.hasOwnProperty(e)&&jn(this,li[e])(this,t,r)},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Ci(e))},removeKeyMap:function(e){var t=this.state.keyMaps;for(var n=0;n<t.length;++n)if(t[n]==e||t[n].name==e)return t.splice(n,1),!0},addOverlay:Fn(function(e,t){var n=e.token?e:S.getMode(this.options,e);if(n.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:n,modeSpec:e,opaque:t&&t.opaque}),this.state.modeGen++,Un(this)}),removeOverlay:Fn(function(e){var t=this.state.overlays;for(var n=0;n<t.length;++n){var r=t[n].modeSpec;if(r==e||typeof e=="string"&&r.name==e){t.splice(n,1),this.state.modeGen++,Un(this);return}}}),indentLine:Fn(function(e,t,n){typeof t!="string"&&typeof t!="number"&&(t==null?t=this.options.smartIndent?"smart":"prev":t=t?"add":"subtract"),Tt(this.doc,e)&&ii(this,e,t,n)}),indentSelection:Fn(function(e){var t=this.doc.sel.ranges,n=-1;for(var r=0;r<t.length;r++){var i=t[r];if(!i.empty()){var s=i.from(),o=i.to(),u=Math.max(n,s.line);n=Math.min(this.lastLine(),o.line-(o.ch?0:1))+1;for(var a=u;a<n;++a)ii(this,a,e);var f=this.doc.sel.ranges;s.ch==0&&t.length==f.length&&f[r].from().ch>0&&At(this.doc,r,new yt(s,f[r].to()),Oo)}else i.head.line>n&&(ii(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&ni(this))}}),getTokenAt:function(e,t){return gs(this,e,t)},getLineTokens:function(e,t){return gs(this,ht(e),t,!0)},getTokenTypeAt:function(e){e=St(this.doc,e);var t=ws(this,Us(this.doc,e.line)),n=0,r=(t.length-1)/2,i=e.ch,s;if(i==0)s=t[2];else for(;;){var o=n+r>>1;if((o?t[o*2-1]:0)>=i)r=o;else{if(!(t[o*2+1]<i)){s=t[o*2+2];break}n=o+1}}var u=s?s.indexOf("cm-overlay "):-1;return u<0?s:u==0?null:s.slice(0,u-1)},getModeAt:function(e){var t=this.doc.mode;return t.innerMode?S.innerMode(t,this.getTokenAt(e).state).mode:t},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var n=[];if(!gi.hasOwnProperty(t))return gi;var r=gi[t],i=this.getModeAt(e);if(typeof i[t]=="string")r[i[t]]&&n.push(r[i[t]]);else if(i[t])for(var s=0;s<i[t].length;s++){var o=r[i[t][s]];o&&n.push(o)}else i.helperType&&r[i.helperType]?n.push(r[i.helperType]):r[i.name]&&n.push(r[i.name]);for(var s=0;s<r._global.length;s++){var u=r._global[s];u.pred(i,this)&&qo(n,u.val)==-1&&n.push(u.val)}return n},getStateAfter:function(e,t){var n=this.doc;return e=Et(n,e==null?n.first+n.size-1:e),Jt(this,e+1,t)},cursorCoords:function(e,t){var n,r=this.doc.sel.primary();return e==null?n=r.head:typeof e=="object"?n=St(this.doc,e):n=e?r.from():r.to(),gn(this,n,t||"page")},charCoords:function(e,t){return mn(this,St(this.doc,e),t||"page")},coordsChar:function(e,t){return e=vn(this,e,t||"page"),wn(this,e.left,e.top)},lineAtHeight:function(e,t){return e=vn(this,{top:e,left:0},t||"page").top,$s(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var n=!1,r=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>r&&(e=r,n=!0);var i=Us(this.doc,e);return dn(this,i,{top:0,left:0},t||"page").top+(n?this.doc.height-Js(i):0)},defaultTextHeight:function(){return xn(this.display)},defaultCharWidth:function(){return Tn(this.display)},setGutterMarker:Fn(function(e,t,n){return si(this.doc,e,"gutter",function(e){var r=e.gutterMarkers||(e.gutterMarkers={});return r[t]=n,!n&&Jo(r)&&(e.gutterMarkers=null),!0})}),clearGutter:Fn(function(e){var t=this,n=t.doc,r=n.first;n.iter(function(n){n.gutterMarkers&&n.gutterMarkers[e]&&(n.gutterMarkers[e]=null,zn(t,r,"gutter"),Jo(n.gutterMarkers)&&(n.gutterMarkers=null)),++r})}),addLineWidget:Fn(function(e,t,n){return ls(this,e,t,n)}),removeLineWidget:function(e){e.clear()},lineInfo:function(e){if(typeof e=="number"){if(!Tt(this.doc,e))return null;var t=e;e=Us(this.doc,e);if(!e)return null}else{var t=Vs(e);if(t==null)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var s=this.display;e=gn(this,St(this.doc,e));var o=e.bottom,u=e.left;t.style.position="absolute",s.sizer.appendChild(t);if(r=="over")o=e.top;else if(r=="above"||r=="near"){var a=Math.max(s.wrapper.clientHeight,this.doc.height),f=Math.max(s.sizer.clientWidth,s.lineSpace.clientWidth);(r=="above"||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?o=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(o=e.bottom),u+t.offsetWidth>f&&(u=f-t.offsetWidth)}t.style.top=o+"px",t.style.left=t.style.right="",i=="right"?(u=s.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):(i=="left"?u=0:i=="middle"&&(u=(s.sizer.clientWidth-t.offsetWidth)/2),t.style.left=u+"px"),n&&Zr(this,u,o,u+t.offsetWidth,o+t.offsetHeight)},triggerOnKeyDown:Fn(Or),triggerOnKeyPress:Fn(Dr),triggerOnKeyUp:_r,execCommand:function(e){if(wi.hasOwnProperty(e))return wi[e](this)},findPosH:function(e,t,n,r){var i=1;t<0&&(i=-1,t=-t);for(var s=0,o=St(this.doc,e);s<t;++s){o=ui(this.doc,o,i,n,r);if(o.hitSide)break}return o},moveH:Fn(function(e,t){var n=this;n.extendSelectionsBy(function(r){return n.display.shift||n.doc.extend||r.empty()?ui(n.doc,r.head,e,t,n.options.rtlMoveVisually):e<0?r.from():r.to()},_o)}),deleteH:Fn(function(e,t){var n=this.doc.sel,r=this.doc;n.somethingSelected()?r.replaceSelection("",null,"+delete"):oi(this,function(n){var i=ui(r,n.head,e,t,!1);return e<0?{from:i,to:n.head}:{from:n.head,to:i}})}),findPosV:function(e,t,n,r){var i=1,s=r;t<0&&(i=-1,t=-t);for(var o=0,u=St(this.doc,e);o<t;++o){var a=gn(this,u,"div");s==null?s=a.left:a.left=s,u=ai(this,a,i,n);if(u.hitSide)break}return u},moveV:Fn(function(e,t){var n=this,r=this.doc,i=[],s=!n.display.shift&&!r.extend&&r.sel.somethingSelected();r.extendSelectionsBy(function(o){if(s)return e<0?o.from():o.to();var u=gn(n,o.head,"div");o.goalColumn!=null&&(u.left=o.goalColumn),i.push(u.left);var a=ai(n,u,e,t);return t=="page"&&o==r.sel.primary()&&ti(n,null,mn(n,a,"div").top-u.top),a},_o);if(i.length)for(var o=0;o<r.sel.ranges.length;o++)r.sel.ranges[o].goalColumn=i[o]}),findWordAt:function(e){var t=this.doc,n=Us(t,e.line).text,r=e.ch,i=e.ch;if(n){var s=this.getHelper(e,"wordChars");(e.xRel<0||i==n.length)&&r?--r:++i;var o=n.charAt(r),u=$o(o,s)?function(e){return $o(e,s)}:/\s/.test(o)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!$o(e)};while(r>0&&u(n.charAt(r-1)))--r;while(i<n.length&&u(n.charAt(i)))++i}return new yt(ht(e.line,r),ht(e.line,i))},toggleOverwrite:function(e){if(e!=null&&e==this.state.overwrite)return;(this.state.overwrite=!this.state.overwrite)?su(this.display.cursorDiv,"CodeMirror-overwrite"):iu(this.display.cursorDiv,"CodeMirror-overwrite"),wo(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return nu()==this.display.input},scrollTo:Fn(function(e,t){(e!=null||t!=null)&&ri(this),e!=null&&(this.curOp.scrollLeft=e),t!=null&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller,t=Lo;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-t,width:e.scrollWidth-t,clientHeight:e.clientHeight-t,clientWidth:e.clientWidth-t}},scrollIntoView:Fn(function(e,t){e==null?(e={from:this.doc.sel.primary().head,to:null},t==null&&(t=this.options.cursorScrollMargin)):typeof e=="number"?e={from:ht(e,0),to:null}:e.from==null&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0;if(e.from.line!=null)ri(this),this.curOp.scrollToPos=e;else{var n=ei(this,Math.min(e.from.left,e.to.left),Math.min(e.from.top,e.to.top)-e.margin,Math.max(e.from.right,e.to.right),Math.max(e.from.bottom,e.to.bottom)+e.margin);this.scrollTo(n.scrollLeft,n.scrollTop)}}),setSize:Fn(function(e,t){function r(e){return typeof e=="number"||/^\d+$/.test(String(e))?e+"px":e}var n=this;e!=null&&(n.display.wrapper.style.width=r(e)),t!=null&&(n.display.wrapper.style.height=r(t)),n.options.lineWrapping&&ln(this);var i=n.display.viewFrom;n.doc.iter(i,n.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){zn(n,i,"widget");break}++i}),n.curOp.forceUpdate=!0,wo(n,"refresh",this)}),operation:function(e){return Bn(this,e)},refresh:Fn(function(){var e=this.display.cachedTextHeight;Un(this),this.curOp.forceUpdate=!0,cn(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),_(this),(e==null||Math.abs(e-xn(this.display))>.5)&&L(this),wo(this,"refresh",this)}),swapDoc:Fn(function(e){var t=this.doc;return t.cm=null,Rs(this,e),cn(this),Zn(this),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,So(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}},ko(S);var fi=S.defaults={},li=S.optionHandlers={},hi=S.Init={toString:function(){return"CodeMirror.Init"}};ci("value","",function(e,t){e.setValue(t)},!0),ci("mode",null,function(e,t){e.doc.modeOption=t,T(e)},!0),ci("indentUnit",2,T,!0),ci("indentWithTabs",!1),ci("smartIndent",!0),ci("tabSize",4,function(e){N(e),cn(e),Un(e)},!0),ci("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t){e.options.specialChars=new RegExp(t.source+(t.test("	")?"":"|	"),"g"),e.refresh()},!0),ci("specialCharPlaceholder",Cs,function(e){e.refresh()},!0),ci("electricChars",!0),ci("rtlMoveVisually",!m),ci("wholeLineUpdateBefore",!0),ci("theme","default",function(e){A(e),O(e)},!0),ci("keyMap","default",function(e,t,n){var r=Ci(t),i=n!=S.Init&&Ci(n);i&&i.detach&&i.detach(e,r),r.attach&&r.attach(e,i||null)}),ci("extraKeys",null),ci("lineWrapping",!1,C,!0),ci("gutters",[],function(e){H(e.options),O(e)},!0),ci("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?z(e.display)+"px":"0",e.refresh()},!0),ci("coverGutterNextToScrollbar",!1,F,!0),ci("lineNumbers",!1,function(e){H(e.options),O(e)},!0),ci("firstLineNumber",1,O,!0),ci("lineNumberFormatter",function(e){return e},O,!0),ci("showCursorWhenSelecting",!1,Rt,!0),ci("resetSelectionOnContextMenu",!0),ci("readOnly",!1,function(e,t){t=="nocursor"?(Hr(e),e.display.input.blur(),e.display.disabled=!0):(e.display.disabled=!1,t||Zn(e))}),ci("disableInput",!1,function(e,t){t||Zn(e)},!0),ci("dragDrop",!0),ci("cursorBlinkRate",530),ci("cursorScrollMargin",0),ci("cursorHeight",1,Rt,!0),ci("singleCursorHeightPerLine",!0,Rt,!0),ci("workTime",100),ci("workDelay",100),ci("flattenSpans",!0,N,!0),ci("addModeClass",!1,N,!0),ci("pollInterval",100),ci("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),ci("historyEventDelay",1250),ci("viewportMargin",10,function(e){e.refresh()},!0),ci("maxHighlightLength",1e4,N,!0),ci("moveInputWithCursor",!0,function(e,t){t||(e.display.inputDiv.style.top=e.display.inputDiv.style.left=0)}),ci("tabindex",null,function(e,t){e.display.input.tabIndex=t||""}),ci("autofocus",null);var pi=S.modes={},di=S.mimeModes={};S.defineMode=function(e,t){!S.defaults.mode&&e!="null"&&(S.defaults.mode=e),arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),pi[e]=t},S.defineMIME=function(e,t){di[e]=t},S.resolveMode=function(e){if(typeof e=="string"&&di.hasOwnProperty(e))e=di[e];else if(e&&typeof e.name=="string"&&di.hasOwnProperty(e.name)){var t=di[e.name];typeof t=="string"&&(t={name:t}),e=Uo(t,e),e.name=t.name}else if(typeof e=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return S.resolveMode("application/xml");return typeof e=="string"?{name:e}:e||{name:"null"}},S.getMode=function(e,t){var t=S.resolveMode(t),n=pi[t.name];if(!n)return S.getMode(e,"text/plain");var r=n(e,t);if(vi.hasOwnProperty(t.name)){var i=vi[t.name];for(var s in i){if(!i.hasOwnProperty(s))continue;r.hasOwnProperty(s)&&(r["_"+s]=r[s]),r[s]=i[s]}}r.name=t.name,t.helperType&&(r.helperType=t.helperType);if(t.modeProps)for(var s in t.modeProps)r[s]=t.modeProps[s];return r},S.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),S.defineMIME("text/plain","null");var vi=S.modeExtensions={};S.extendMode=function(e,t){var n=vi.hasOwnProperty(e)?vi[e]:vi[e]={};zo(t,n)},S.defineExtension=function(e,t){S.prototype[e]=t},S.defineDocExtension=function(e,t){js.prototype[e]=t},S.defineOption=ci;var mi=[];S.defineInitHook=function(e){mi.push(e)};var gi=S.helpers={};S.registerHelper=function(e,t,n){gi.hasOwnProperty(e)||(gi[e]=S[e]={_global:[]}),gi[e][t]=n},S.registerGlobalHelper=function(e,t,n,r){S.registerHelper(e,t,r),gi[e]._global.push({pred:n,val:r})};var yi=S.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n},bi=S.startState=function(e,t,n){return e.startState?e.startState(t,n):!0};S.innerMode=function(e,t){while(e.innerMode){var n=e.innerMode(t);if(!n||n.mode==e)break;t=n.state,e=n.mode}return n||{mode:e,state:t}};var wi=S.commands={selectAll:function(e){e.setSelection(ht(e.firstLine(),0),ht(e.lastLine()),Oo)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Oo)},killLine:function(e){oi(e,function(t){if(t.empty()){var n=Us(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line<e.lastLine()?{from:t.head,to:ht(t.head.line+1,0)}:{from:t.head,to:ht(t.head.line,n)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){oi(e,function(t){return{from:ht(t.from().line,0),to:St(e.doc,ht(t.to().line+1,0))}})},delLineLeft:function(e){oi(e,function(e){return{from:ht(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){oi(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return{from:r,to:t.from()}})},delWrappedLineRight:function(e){oi(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div");return{from:t.from(),to:r}})},undo:function(e){e.undo()},redo:function(e){e.redo()},undoSelection:function(e){e.undoSelection()},redoSelection:function(e){e.redoSelection()},goDocStart:function(e){e.extendSelection(ht(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(ht(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return Au(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){return Mu(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){e.extendSelectionsBy(function(t){return Ou(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div")},_o)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:n},"div")},_o)},goLineLeftSmart:function(e){e.extendSelectionsBy(function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return r.ch<e.getLine(r.line).search(/\S/)?Mu(e,t.head):r},_o)},goLineUp:function(e){e.moveV(-1,"line")},goLineDown:function(e){e.moveV(1,"line")},goPageUp:function(e){e.moveV(-1,"page")},goPageDown:function(e){e.moveV(1,"page")},goCharLeft:function(e){e.moveH(-1,"char")},goCharRight:function(e){e.moveH(1,"char")},goColumnLeft:function(e){e.moveH(-1,"column")},goColumnRight:function(e){e.moveH(1,"column")},goWordLeft:function(e){e.moveH(-1,"word")},goGroupRight:function(e){e.moveH(1,"group")},goGroupLeft:function(e){e.moveH(-1,"group")},goWordRight:function(e){e.moveH(1,"word")},delCharBefore:function(e){e.deleteH(-1,"char")},delCharAfter:function(e){e.deleteH(1,"char")},delWordBefore:function(e){e.deleteH(-1,"word")},delWordAfter:function(e){e.deleteH(1,"word")},delGroupBefore:function(e){e.deleteH(-1,"group")},delGroupAfter:function(e){e.deleteH(1,"group")},indentAuto:function(e){e.indentSelection("smart")},indentMore:function(e){e.indentSelection("add")},indentLess:function(e){e.indentSelection("subtract")},insertTab:function(e){e.replaceSelection("	")},insertSoftTab:function(e){var t=[],n=e.listSelections(),r=e.options.tabSize;for(var i=0;i<n.length;i++){var s=n[i].from(),o=Po(e.getLine(s.line),s.ch,r);t.push((new Array(r-o%r+1)).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Bn(e,function(){var t=e.listSelections(),n=[];for(var r=0;r<t.length;r++){var i=t[r].head,s=Us(e.doc,i.line).text;if(s){i.ch==s.length&&(i=new ht(i.line,i.ch-1));if(i.ch>0)i=new ht(i.line,i.ch+1),e.replaceRange(s.charAt(i.ch-1)+s.charAt(i.ch-2),ht(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var o=Us(e.doc,i.line-1).text;o&&e.replaceRange(s.charAt(0)+"\n"+o.charAt(o.length-1),ht(i.line-1,o.length-1),ht(i.line,1),"+transpose")}}n.push(new yt(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){Bn(e,function(){var t=e.listSelections().length;for(var n=0;n<t;n++){var r=e.listSelections()[n];e.replaceRange("\n",r.anchor,r.head,"+input"),e.indentLine(r.from().line+1,null,!0),ni(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},Ei=S.keyMap={};Ei.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Ei.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Ei.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"},Ei.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Ei["default"]=v?Ei.macDefault:Ei.pcDefault,S.normalizeKeyMap=function(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if(r=="..."){delete e[n];continue}var i=Ro(n.split(" "),Si);for(var s=0;s<i.length;s++){var o,u;s==i.length-1?(u=n,o=r):(u=i.slice(0,s+1).join(" "),o="...");var a=t[u];if(!a)t[u]=o;else if(a!=o)throw new Error("Inconsistent bindings for "+u)}delete e[n]}for(var f in t)e[f]=t[f];return e};var xi=S.lookupKey=function(e,t,n){t=Ci(t);var r=t.call?t.call(e):t[e];if(r===!1)return"nothing";if(r==="...")return"multi";if(r!=null&&n(r))return"handled";if(t.fallthrough){if(Object.prototype.toString.call(t.fallthrough)!="[object Array]")return xi(e,t.fallthrough,n);for(var i=0;i<t.fallthrough.length;i++){var s=xi(e,t.fallthrough[i],n);if(s)return s}}},Ti=S.isModifierKey=function(e){var t=typeof e=="string"?e:xu[e.keyCode];return t=="Ctrl"||t=="Alt"||t=="Shift"||t=="Mod"},Ni=S.keyName=function(e,t){if(a&&e.keyCode==34&&e["char"])return!1;var n=xu[e.keyCode],r=n;return r==null||e.altGraphKey?!1:(e.altKey&&n!="Alt"&&(r="Alt-"+r),(y?e.metaKey:e.ctrlKey)&&n!="Ctrl"&&(r="Ctrl-"+r),(y?e.ctrlKey:e.metaKey)&&n!="Cmd"&&(r="Cmd-"+r),!t&&e.shiftKey&&n!="Shift"&&(r="Shift-"+r),r)};S.fromTextArea=function(e,t){function r(){e.value=a.getValue()}t||(t={}),t.value=e.value,!t.tabindex&&e.tabindex&&(t.tabindex=e.tabindex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder);if(t.autofocus==null){var n=nu();t.autofocus=n==e||e.getAttribute("autofocus")!=null&&n==document.body}if(e.form){yo(e.form,"submit",r);if(!t.leaveSubmitMethodAlone){var i=e.form,s=i.submit;try{var o=i.submit=function(){r(),i.submit=s,i.submit(),i.submit=o}}catch(u){}}}e.style.display="none";var a=S(function(t){e.parentNode.insertBefore(t,e.nextSibling)},t);return a.save=r,a.getTextArea=function(){return e},a.toTextArea=function(){a.toTextArea=isNaN,r(),e.parentNode.removeChild(a.getWrapperElement()),e.style.display="",e.form&&(bo(e.form,"submit",r),typeof e.form.submit=="function"&&(e.form.submit=s))},a};var ki=S.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};ki.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},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(e){var t=this.string.charAt(this.pos);if(typeof e=="string")var n=t==e;else var n=t&&(e.test?e.test(t):e(t));if(n)return++this.pos,t},eatWhile:function(e){var t=this.pos;while(this.eat(e));return this.pos>t},eatSpace:function(){var e=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Po(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?Po(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Po(this.string,null,this.tabSize)-(this.lineStart?Po(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,n){if(typeof e!="string"){var s=this.string.slice(this.pos).match(e);return s&&s.index>0?null:(s&&t!==!1&&(this.pos+=s[0].length),s)}var r=function(e){return n?e.toLowerCase():e},i=this.string.substr(this.pos,e.length);if(r(i)==r(e))return t!==!1&&(this.pos+=e.length),!0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var Li=S.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e};ko(Li),Li.prototype.clear=function(){if(this.explicitlyCleared)return;var e=this.doc.cm,t=e&&!e.curOp;t&&kn(e);if(Co(this,"clear")){var n=this.find();n&&So(this,"clear",n.from,n.to)}var r=null,i=null;for(var s=0;s<this.lines.length;++s){var o=this.lines[s],u=ji(o.markedSpans,this);e&&!this.collapsed?zn(e,Vs(o),"text"):e&&(u.to!=null&&(i=Vs(o)),u.from!=null&&(r=Vs(o))),o.markedSpans=Fi(o.markedSpans,u),u.from==null&&this.collapsed&&!ss(this.doc,o)&&e&&Xs(o,xn(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var s=0;s<this.lines.length;++s){var a=ts(this.lines[s]),f=D(a);f>e.display.maxLineLength&&(e.display.maxLine=a,e.display.maxLineLength=f,e.display.maxLineChanged=!0)}r!=null&&e&&this.collapsed&&Un(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Bt(e.doc)),e&&So(e,"markerCleared",e,this),t&&An(e),this.parent&&this.parent.clear()},Li.prototype.find=function(e,t){e==null&&this.type=="bookmark"&&(e=1);var n,r;for(var i=0;i<this.lines.length;++i){var s=this.lines[i],o=ji(s.markedSpans,this);if(o.from!=null){n=ht(t?s:Vs(s),o.from);if(e==-1)return n}if(o.to!=null){r=ht(t?s:Vs(s),o.to);if(e==1)return r}}return n&&{from:n,to:r}},Li.prototype.changed=function(){var e=this.find(-1,!0),t=this,n=this.doc.cm;if(!e||!n)return;Bn(n,function(){var r=e.line,i=Vs(e.line),s=nn(n,i);s&&(fn(s),n.curOp.selectionChanged=n.curOp.forceUpdate=!0),n.curOp.updateMaxLine=!0;if(!ss(t.doc,r)&&t.height!=null){var o=t.height;t.height=null;var u=fs(t)-o;u&&Xs(r,r.height+u)}})},Li.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(!t.maybeHiddenMarkers||qo(t.maybeHiddenMarkers,this)==-1)&&(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},Li.prototype.detachLine=function(e){this.lines.splice(qo(this.lines,e),1);if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var Ai=0,Mi=S.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=this};ko(Mi),Mi.prototype.clear=function(){if(this.explicitlyCleared)return;this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();So(this,"clear")},Mi.prototype.find=function(e,t){return this.primary.find(e,t)};var us=S.LineWidget=function(e,t,n){if(n)for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.cm=e,this.node=t};ko(us),us.prototype.clear=function(){var e=this.cm,t=this.line.widgets,n=this.line,r=Vs(n);if(r==null||!t)return;for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(n.widgets=null);var s=fs(this);Bn(e,function(){as(e,n,-s),zn(e,r,"widget"),Xs(n,Math.max(0,n.height-s))})},us.prototype.changed=function(){var e=this.height,t=this.cm,n=this.line;this.height=null;var r=fs(this)-e;if(!r)return;Bn(t,function(){t.curOp.forceUpdate=!0,as(t,n,r),Xs(n,n.height+r)})};var cs=S.Line=function(e,t,n){this.text=e,$i(this,t),this.height=n?n(this):1};ko(cs),cs.prototype.lineNo=function(){return Vs(this)};var Ss={},xs={};Ps.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var n=e,r=e+t;n<r;++n){var i=this.lines[n];this.height-=i.height,ps(i),So(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,n){for(var r=e+t;e<r;++e)if(n(this.lines[e]))return!0}},Hs.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n=0;n<this.children.length;++n){var r=this.children[n],i=r.chunkSize();if(e<i){var s=Math.min(t,i-e),o=r.height;r.removeInner(e,s),this.height-=o-r.height,i==s&&(this.children.splice(n--,1),r.parent=null);if((t-=s)==0)break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof Ps))){var u=[];this.collapse(u),this.children=[new Ps(u)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,n){this.size+=t.length,this.height+=n;for(var r=0;r<this.children.length;++r){var i=this.children[r],s=i.chunkSize();if(e<=s){i.insertInner(e,t,n);if(i.lines&&i.lines.length>50){while(i.lines.length>50){var o=i.lines.splice(i.lines.length-25,25),u=new Ps(o);i.height-=u.height,this.children.splice(r+1,0,u),u.parent=this}this.maybeSpill()}break}e-=s}},maybeSpill:function(){if(this.children.length<=10)return;var e=this;do{var t=e.children.splice(e.children.length-5,5),n=new Hs(t);if(!e.parent){var r=new Hs(e.children);r.parent=e,e.children=[r,n],e=r}else{e.size-=n.size,e.height-=n.height;var i=qo(e.parent.children,e);e.parent.children.splice(i+1,0,n)}n.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()},iterN:function(e,t,n){for(var r=0;r<this.children.length;++r){var i=this.children[r],s=i.chunkSize();if(e<s){var o=Math.min(t,s-e);if(i.iterN(e,o,n))return!0;if((t-=o)==0)break;e=0}else e-=s}}};var Bs=0,js=S.Doc=function(e,t,n){if(!(this instanceof js))return new js(e,t,n);n==null&&(n=0),Hs.call(this,[new Ps([new cs("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=n;var r=ht(n,0);this.sel=wt(r),this.history=new Qs(null),this.id=++Bs,this.modeOption=t,typeof e=="string"&&(e=yu(e)),Ds(this,{from:r,to:r,text:e}),Dt(this,wt(r),Oo)};js.prototype=Uo(Hs.prototype,{constructor:js,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){var n=0;for(var r=0;r<t.length;++r)n+=t[r].height;this.insertInner(e-this.first,t,n)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=Ws(this,this.first,this.first+this.size);return e===!1?t:t.join(e||"\n")},setValue:In(function(e){var t=ht(this.first,0),n=this.first+this.size-1;Wr(this,{from:t,to:ht(n,Us(this,n).text.length),text:yu(e),origin:"setValue"},!0),Dt(this,wt(t))}),replaceRange:function(e,t,n,r){t=St(this,t),n=n?St(this,n):t,Qr(this,e,t,n,r)},getRange:function(e,t,n){var r=zs(this,St(this,e),St(this,t));return n===!1?r:r.join(n||"\n")},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(Tt(this,e))return Us(this,e)},getLineNumber:function(e){return Vs(e)},getLineHandleVisualStart:function(e){return typeof e=="number"&&(e=Us(this,e)),ts(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return St(this,e)},getCursor:function(e){var t=this.sel.primary(),n;return e==null||e=="head"?n=t.head:e=="anchor"?n=t.anchor:e=="end"||e=="to"||e===!1?n=t.to():n=t.from(),n},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:In(function(e,t,n){Ot(this,St(this,typeof e=="number"?ht(e,t||0):e),null,n)}),setSelection:In(function(e,t,n){Ot(this,St(this,e),St(this,t||e),n)}),extendSelection:In(function(e,t,n){kt(this,St(this,e),t&&St(this,t),n)}),extendSelections:In(function(e,t){Lt(this,Nt(this,e,t))}),extendSelectionsBy:In(function(e,t){Lt(this,Ro(this.sel.ranges,e),t)}),setSelections:In(function(e,t,n){if(!e.length)return;for(var r=0,i=[];r<e.length;r++)i[r]=new yt(St(this,e[r].anchor),St(this,e[r].head));t==null&&(t=Math.min(e.length-1,this.sel.primIndex)),Dt(this,bt(i,t),n)}),addSelection:In(function(e,t,n){var r=this.sel.ranges.slice(0);r.push(new yt(St(this,e),St(this,t||e))),Dt(this,bt(r,r.length-1),n)}),getSelection:function(e){var t=this.sel.ranges,n;for(var r=0;r<t.length;r++){var i=zs(this,t[r].from(),t[r].to());n=n?n.concat(i):i}return e===!1?n:n.join(e||"\n")},getSelections:function(e){var t=[],n=this.sel.ranges;for(var r=0;r<n.length;r++){var i=zs(this,n[r].from(),n[r].to());e!==!1&&(i=i.join(e||"\n")),t[r]=i}return t},replaceSelection:function(e,t,n){var r=[];for(var i=0;i<this.sel.ranges.length;i++)r[i]=e;this.replaceSelections(r,t,n||"+input")},replaceSelections:In(function(e,t,n){var r=[],i=this.sel;for(var s=0;s<i.ranges.length;s++){var o=i.ranges[s];r[s]={from:o.from(),to:o.to(),text:yu(e[s]),origin:n}}var u=t&&t!="end"&&Ur(this,r,t);for(var s=r.length-1;s>=0;s--)Wr(this,r[s]);u?_t(this,u):this.cm&&ni(this.cm)}),undo:In(function(){Vr(this,"undo")}),redo:In(function(){Vr(this,"redo")}),undoSelection:In(function(){Vr(this,"undo",!0)}),redoSelection:In(function(){Vr(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){var e=this.history,t=0,n=0;for(var r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var r=0;r<e.undone.length;r++)e.undone[r].ranges||++n;return{undo:t,redo:n}},clearHistory:function(){this.history=new Qs(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:uo(this.history.done),undone:uo(this.history.undone)}},setHistory:function(e){var t=this.history=new Qs(this.history.maxGeneration);t.done=uo(e.done.slice(0),null,!0),t.undone=uo(e.undone.slice(0),null,!0)},addLineClass:In(function(e,t,n){return si(this,e,t=="gutter"?"gutter":"class",function(e){var r=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass";if(!e[r])e[r]=n;else{if(ru(n).test(e[r]))return!1;e[r]+=" "+n}return!0})}),removeLineClass:In(function(e,t,n){return si(this,e,"class",function(e){var r=t=="text"?"textClass":t=="background"?"bgClass":t=="gutter"?"gutterClass":"wrapClass",i=e[r];if(!i)return!1;if(n==null)e[r]=null;else{var s=i.match(ru(n));if(!s)return!1;var o=s.index+s[0].length;e[r]=i.slice(0,s.index)+(!s.index||o==i.length?"":" ")+i.slice(o)||null}return!0})}),markText:function(e,t,n){return Oi(this,St(this,e),St(this,t),n,"range")},setBookmark:function(e,t){var n={replacedWith:t&&(t.nodeType==null?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared};return e=St(this,e),Oi(this,e,e,n,"bookmark")},findMarksAt:function(e){e=St(this,e);var t=[],n=Us(this,e.line).markedSpans;if(n)for(var r=0;r<n.length;++r){var i=n[r];(i.from==null||i.from<=e.ch)&&(i.to==null||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=St(this,e),t=St(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(s){var o=s.markedSpans;if(o)for(var u=0;u<o.length;u++){var a=o[u];!(i==e.line&&e.ch>a.to||a.from==null&&i!=e.line||i==t.line&&a.from>t.ch)&&(!n||n(a.marker))&&r.push(a.marker.parent||a.marker)}++i}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var r=0;r<n.length;++r)n[r].from!=null&&e.push(n[r].marker)}),e},posFromIndex:function(e){var t,n=this.first;return this.iter(function(r){var i=r.text.length+1;if(i>e)return t=e,!0;e-=i,++n}),St(this,ht(n,t))},indexFromPos:function(e){e=St(this,e);var t=e.ch;return e.line<this.first||e.ch<0?0:(this.iter(this.first,e.line,function(e){t+=e.text.length+1}),t)},copy:function(e){var t=new js(Ws(this,this.first,this.first+this.size),this.modeOption,this.first);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,n=this.first+this.size;e.from!=null&&e.from>t&&(t=e.from),e.to!=null&&e.to<n&&(n=e.to);var r=new js(Ws(this,t,n),e.mode||this.modeOption,t);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],Pi(r,Di(this)),r},unlinkDoc:function(e){e instanceof S&&(e=e.doc);if(this.linked)for(var t=0;t<this.linked.length;++t){var n=this.linked[t];if(n.doc!=e)continue;this.linked.splice(t,1),e.unlinkDoc(this),Hi(Di(this));break}if(e.history==this.history){var r=[e.id];qs(e,function(e){r.push(e.id)},!0),e.history=new Qs(null),e.history.done=uo(this.history.done,r),e.history.undone=uo(this.history.undone,r)}},iterLinkedDocs:function(e){qs(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),js.prototype.eachLine=js.prototype.iter;var Fs="iter insert remove copy getEditor".split(" ");for(var Is in js.prototype)js.prototype.hasOwnProperty(Is)&&qo(Fs,Is)<0&&(S.prototype[Is]=function(e){return function(){return e.apply(this.doc,arguments)}}(js.prototype[Is]));ko(js);var co=S.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},ho=S.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},vo=S.e_stop=function(e){co(e),ho(e)},yo=S.on=function(e,t,n){if(e.addEventListener)e.addEventListener(t,n,!1);else if(e.attachEvent)e.attachEvent("on"+t,n);else{var r=e._handlers||(e._handlers={}),i=r[t]||(r[t]=[]);i.push(n)}},bo=S.off=function(e,t,n){if(e.removeEventListener)e.removeEventListener(t,n,!1);else if(e.detachEvent)e.detachEvent("on"+t,n);else{var r=e._handlers&&e._handlers[t];if(!r)return;for(var i=0;i<r.length;++i)if(r[i]==n){r.splice(i,1);break}}},wo=S.signal=function(e,t){var n=e._handlers&&e._handlers[t];if(!n)return;var r=Array.prototype.slice.call(arguments,2);for(var i=0;i<n.length;++i)n[i].apply(null,r)},Eo=null,Lo=30,Ao=S.Pass={toString:function(){return"CodeMirror.Pass"}},Oo={scroll:!1},Mo={origin:"*mouse"},_o={origin:"+move"};Do.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Po=S.countColumn=function(e,t,n,r,i){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));for(var s=r||0,o=i||0;;){var u=e.indexOf("	",s);if(u<0||u>=t)return o+(t-s);o+=u-s,o+=n-o%n,s=u+1}},Bo=[""],Io=function(e){e.select()};p?Io=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:r&&(Io=function(e){try{e.select()}catch(t){}}),[].indexOf&&(qo=function(e,t){return e.indexOf(t)}),[].map&&(Ro=function(e,t){return e.map(t)});var Xo=/[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Vo=S.isWordChar=function(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||Xo.test(e))},Ko=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,Yo;document.createRange?Yo=function(e,t,n){var r=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}:Yo=function(e,t,n){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(i){return r}return r.collapse(!0),r.moveEnd("character",n),r.moveStart("character",t),r},r&&i<11&&(nu=function(){try{return document.activeElement}catch(e){return document.body}});var iu=S.rmClass=function(e,t){var n=e.className,r=ru(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}},su=S.addClass=function(e,t){var n=e.className;ru(t).test(n)||(e.className+=(n?" ":"")+t)},au=!1,cu=function(){if(r&&i<9)return!1;var e=Go("div");return"draggable"in e||"dragDrop"in e}(),hu,du,mu,yu=S.splitLines="\n\nb".split(/\n/).length!=3?function(e){var t=0,n=[],r=e.length;while(t<=r){var i=e.indexOf("\n",t);i==-1&&(i=e.length);var s=e.slice(t,e.charAt(i-1)=="\r"?i-1:i),o=s.indexOf("\r");o!=-1?(n.push(s.slice(0,o)),t+=o+1):(n.push(s),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},bu=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(n){}return!t||t.parentElement()!=e?!1:t.compareEndPoints("StartToEnd",t)!=0},wu=function(){var e=Go("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),typeof e.oncopy=="function")}(),Eu=null,xu={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};S.keyNames=xu,function(){for(var e=0;e<10;e++)xu[e+48]=xu[e+96]=String(e);for(var e=65;e<=90;e++)xu[e]=String.fromCharCode(e);for(var e=1;e<=12;e++)xu[e+111]=xu[e+63235]="F"+e}();var Du,Fu=function(){function n(n){return n<=247?e.charAt(n):1424<=n&&n<=1524?"R":1536<=n&&n<=1773?t.charAt(n-1536):1774<=n&&n<=2220?"r":8192<=n&&n<=8203?"w":n==8204?"b":"L"}function f(e,t,n){this.level=e,this.from=t,this.to=n}var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,s=/[LRr]/,o=/[Lb1n]/,u=/[1n]/,a="L";return function(e){if(!r.test(e))return!1;var t=e.length,l=[];for(var c=0,h;c<t;++c)l.push(h=n(e.charCodeAt(c)));for(var c=0,p=a;c<t;++c){var h=l[c];h=="m"?l[c]=p:p=h}for(var c=0,d=a;c<t;++c){var h=l[c];h=="1"&&d=="r"?l[c]="n":s.test(h)&&(d=h,h=="r"&&(l[c]="R"))}for(var c=1,p=l[0];c<t-1;++c){var h=l[c];h=="+"&&p=="1"&&l[c+1]=="1"?l[c]="1":h==","&&p==l[c+1]&&(p=="1"||p=="n")&&(l[c]=p),p=h}for(var c=0;c<t;++c){var h=l[c];if(h==",")l[c]="N";else if(h=="%"){for(var v=c+1;v<t&&l[v]=="%";++v);var m=c&&l[c-1]=="!"||v<t&&l[v]=="1"?"1":"N";for(var g=c;g<v;++g)l[g]=m;c=v-1}}for(var c=0,d=a;c<t;++c){var h=l[c];d=="L"&&h=="1"?l[c]="L":s.test(h)&&(d=h)}for(var c=0;c<t;++c)if(i.test(l[c])){for(var v=c+1;v<t&&i.test(l[v]);++v);var y=(c?l[c-1]:a)=="L",b=(v<t?l[v]:a)=="L",m=y||b?"L":"R";for(var g=c;g<v;++g)l[g]=m;c=v-1}var w=[],E;for(var c=0;c<t;)if(o.test(l[c])){var S=c;for(++c;c<t&&o.test(l[c]);++c);w.push(new f(0,S,c))}else{var x=c,T=w.length;for(++c;c<t&&l[c]!="L";++c);for(var g=x;g<c;)if(u.test(l[g])){x<g&&w.splice(T,0,new f(1,x,g));var N=g;for(++g;g<c&&u.test(l[g]);++g);w.splice(T,0,new f(2,N,g)),x=g}else++g;x<c&&w.splice(T,0,new f(1,x,c))}return w[0].level==1&&(E=e.match(/^\s+/))&&(w[0].from=E[0].length,w.unshift(new f(0,0,E[0].length))),Fo(w).level==1&&(E=e.match(/\s+$/))&&(Fo(w).to-=E[0].length,w.push(new f(0,t-E[0].length,t))),w[0].level!=Fo(w).level&&w.push(new f(w[0].level,t,t)),w}}();return S.version="4.8.0",S}),define("CMLint",["react","lodash","jquery","./libs/codemirror-4.8/lib/codemirror"],function(e,t,n,r){function i(e){var t=e.severity;t||(t="error");var n=document.createElement("div");return n.className="CodeMirror-lint-message-"+t,n.appendChild(document.createTextNode(e.message)),n}function o(e,t){var n=document.createDocumentFragment(),r={severity:"error",message:t.message};n.appendChild(i(r)),e.setGutterMarker(Math.max(t.line,0),s,a(n,"error",!1,"state.options.tooltips"))}function u(e){e.clearGutter(s)}function a(e,t,n,i){var s=document.createElement("div"),o=s;return s.className="CodeMirror-lint-marker-"+t,n&&(o=s.appendChild(document.createElement("div")),o.className="CodeMirror-lint-marker-multiple"),i!==!1&&r.on(o,"mouseover",function(t){h(t,e,o)}),s}function f(e,t){function i(e){if(!n.parentNode)return r.off(document,"mousemove",i);n.style.top=Math.max(0,e.clientY-n.offsetHeight-5)+"px",n.style.left=e.clientX+5+"px"}var n=document.createElement("div");return n.className="CodeMirror-lint-tooltip",n.appendChild(t.cloneNode(!0)),document.body.appendChild(n),r.on(document,"mousemove",i),i(e),n.style.opacity!==null&&(n.style.opacity=1),n}function l(e){e.parentNode&&e.parentNode.removeChild(e)}function c(e){if(!e.parentNode)return;e.style.opacity===null&&l(e),e.style.opacity=0,setTimeout(function(){l(e)},600)}function h(e,t,n){function s(){r.off(n,"mouseout",s),i&&(c(i),i=null)}var i=f(e,t),o=setInterval(function(){if(i)for(var e=n;;e=e.parentNode){if(e===document.body)return undefined;if(!e){s();break}}if(!i)return clearInterval(o)},400);r.on(n,"mouseout",s)}var s="rt-annotations";return{GUTTER_ID:s,annotate:o,clearMarks:u}}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/mode/javascript/javascript",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineMode("javascript",function(t,n){function h(e){var t=!1,n,r=!1;while((n=e.next())!=null){if(!t){if(n=="/"&&!r)return;n=="["?r=!0:r&&n=="]"&&(r=!1)}t=!t&&n=="\\"}}function v(e,t,n){return p=e,d=n,t}function m(e,t){var n=e.next();if(n=='"'||n=="'")return t.tokenize=g(n),t.tokenize(e,t);if(n=="."&&e.match(/^\d+(?:[eE][+\-]?\d+)?/))return v("number","number");if(n=="."&&e.match(".."))return v("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return v(n);if(n=="="&&e.eat(">"))return v("=>","operator");if(n=="0"&&e.eat(/x/i))return e.eatWhile(/[\da-f]/i),v("number","number");if(/\d/.test(n))return e.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),v("number","number");if(n=="/")return e.eat("*")?(t.tokenize=y,y(e,t)):e.eat("/")?(e.skipToEnd(),v("comment","comment")):t.lastType=="operator"||t.lastType=="keyword c"||t.lastType=="sof"||/^[\[{}\(,;:]$/.test(t.lastType)?(h(e),e.eatWhile(/[gimy]/),v("regexp","string-2")):(e.eatWhile(l),v("operator","operator",e.current()));if(n=="`")return t.tokenize=b,b(e,t);if(n=="#")return e.skipToEnd(),v("error","error");if(l.test(n))return e.eatWhile(l),v("operator","operator",e.current());if(a.test(n)){e.eatWhile(a);var r=e.current(),i=f.propertyIsEnumerable(r)&&f[r];return i&&t.lastType!="."?v(i.type,i.style,r):v("variable","variable",r)}}function g(e){return function(t,n){var r=!1,i;if(s&&t.peek()=="@"&&t.match(c))return n.tokenize=m,v("jsonld-keyword","meta");while((i=t.next())!=null){if(i==e&&!r)break;r=!r&&i=="\\"}return r||(n.tokenize=m),v("string","string")}}function y(e,t){var n=!1,r;while(r=e.next()){if(r=="/"&&n){t.tokenize=m;break}n=r=="*"}return v("comment","comment")}function b(e,t){var n=!1,r;while((r=e.next())!=null){if(!n&&(r=="`"||r=="$"&&e.eat("{"))){t.tokenize=m;break}n=!n&&r=="\\"}return v("quasi","string-2",e.current())}function E(e,t){t.fatArrowAt&&(t.fatArrowAt=null);var n=e.string.indexOf("=>",e.start);if(n<0)return;var r=0,i=!1;for(var s=n-1;s>=0;--s){var o=e.string.charAt(s),u=w.indexOf(o);if(u>=0&&u<3){if(!r){++s;break}if(--r==0)break}else if(u>=3&&u<6)++r;else if(a.test(o))i=!0;else if(i&&!r){++s;break}}i&&!r&&(t.fatArrowAt=s)}function x(e,t,n,r,i,s){this.indented=e,this.column=t,this.type=n,this.prev=i,this.info=s,r!=null&&(this.align=r)}function T(e,t){for(var n=e.localVars;n;n=n.next)if(n.name==t)return!0;for(var r=e.context;r;r=r.prev)for(var n=r.vars;n;n=n.next)if(n.name==t)return!0}function N(e,t,n,r,i){var s=e.cc;C.state=e,C.stream=i,C.marked=null,C.cc=s,C.style=t,e.lexical.hasOwnProperty("align")||(e.lexical.align=!0);for(;;){var u=s.length?s.pop():o?j:B;if(u(n,r)){while(s.length&&s[s.length-1].lex)s.pop()();return C.marked?C.marked:n=="variable"&&T(e,r)?"variable-2":t}}}function k(){for(var e=arguments.length-1;e>=0;e--)C.cc.push(arguments[e])}function L(){return k.apply(null,arguments),!0}function A(e){function t(t){for(var n=t;n;n=n.next)if(n.name==e)return!0;return!1}var r=C.state;if(r.context){C.marked="def";if(t(r.localVars))return;r.localVars={name:e,next:r.localVars}}else{if(t(r.globalVars))return;n.globalVars&&(r.globalVars={name:e,next:r.globalVars})}}function M(){C.state.context={prev:C.state.context,vars:C.state.localVars},C.state.localVars=O}function _(){C.state.localVars=C.state.context.vars,C.state.context=C.state.context.prev}function D(e,t){var n=function(){var n=C.state,r=n.indented;if(n.lexical.type=="stat")r=n.lexical.indented;else for(var i=n.lexical;i&&i.type==")"&&i.align;i=i.prev)r=i.indented;n.lexical=new x(r,C.stream.column(),e,null,n.lexical,t)};return n.lex=!0,n}function P(){var e=C.state;e.lexical.prev&&(e.lexical.type==")"&&(e.indented=e.lexical.indented),e.lexical=e.lexical.prev)}function H(e){function t(n){return n==e?L():e==";"?k():L(t)}return t}function B(e,t){return e=="var"?L(D("vardef",t.length),it,H(";"),P):e=="keyword a"?L(D("form"),j,B,P):e=="keyword b"?L(D("form"),B,P):e=="{"?L(D("}"),tt,P):e==";"?L():e=="if"?(C.state.lexical.info=="else"&&C.state.cc[C.state.cc.length-1]==P&&C.state.cc.pop()(),L(D("form"),j,B,P,ft)):e=="function"?L(vt):e=="for"?L(D("form"),lt,B,P):e=="variable"?L(D("stat"),J):e=="switch"?L(D("form"),j,D("}","switch"),H("{"),tt,P,P):e=="case"?L(j,H(":")):e=="default"?L(H(":")):e=="catch"?L(D("form"),M,H("("),mt,H(")"),B,P,_):e=="module"?L(D("form"),M,Et,_,P):e=="class"?L(D("form"),gt,P):e=="export"?L(D("form"),St,P):e=="import"?L(D("form"),xt,P):k(D("stat"),j,H(";"),P)}function j(e){return I(e,!1)}function F(e){return I(e,!0)}function I(e,t){if(C.state.fatArrowAt==C.stream.start){var n=t?$:V;if(e=="(")return L(M,D(")"),Z(st,")"),P,H("=>"),n,_);if(e=="variable")return k(M,st,H("=>"),n,_)}var r=t?z:U;return S.hasOwnProperty(e)?L(r):e=="function"?L(vt,r):e=="keyword c"?L(t?R:q):e=="("?L(D(")"),q,Lt,H(")"),P,r):e=="operator"||e=="spread"?L(t?F:j):e=="["?L(D("]"),Ct,P,r):e=="{"?et(Q,"}",null,r):e=="quasi"?k(W,r):L()}function q(e){return e.match(/[;\}\)\],]/)?k():k(j)}function R(e){return e.match(/[;\}\)\],]/)?k():k(F)}function U(e,t){return e==","?L(j):z(e,t,!1)}function z(e,t,n){var r=n==0?U:z,i=n==0?j:F;if(e=="=>")return L(M,n?$:V,_);if(e=="operator")return/\+\+|--/.test(t)?L(r):t=="?"?L(j,H(":"),i):L(i);if(e=="quasi")return k(W,r);if(e==";")return;if(e=="(")return et(F,")","call",r);if(e==".")return L(K,r);if(e=="[")return L(D("]"),q,H("]"),P,r)}function W(e,t){return e!="quasi"?k():t.slice(t.length-2)!="${"?L(W):L(j,X)}function X(e){if(e=="}")return C.marked="string-2",C.state.tokenize=b,L(W)}function V(e){return E(C.stream,C.state),k(e=="{"?B:j)}function $(e){return E(C.stream,C.state),k(e=="{"?B:F)}function J(e){return e==":"?L(P,B):k(U,H(";"),P)}function K(e){if(e=="variable")return C.marked="property",L()}function Q(e,t){if(e=="variable"||C.style=="keyword")return C.marked="property",t=="get"||t=="set"?L(G):L(Y);if(e=="number"||e=="string")return C.marked=s?"property":C.style+" property",L(Y);if(e=="jsonld-keyword")return L(Y);if(e=="[")return L(j,H("]"),Y)}function G(e){return e!="variable"?k(Y):(C.marked="property",L(vt))}function Y(e){if(e==":")return L(F);if(e=="(")return k(vt)}function Z(e,t){function n(r){if(r==","){var i=C.state.lexical;return i.info=="call"&&(i.pos=(i.pos||0)+1),L(e,n)}return r==t?L():L(H(t))}return function(r){return r==t?L():k(e,n)}}function et(e,t,n){for(var r=3;r<arguments.length;r++)C.cc.push(arguments[r]);return L(D(t,n),Z(e,t),P)}function tt(e){return e=="}"?L():k(B,tt)}function nt(e){if(u&&e==":")return L(rt)}function rt(e){if(e=="variable")return C.marked="variable-3",L()}function it(){return k(st,nt,ut,at)}function st(e,t){if(e=="variable")return A(t),L();if(e=="[")return et(st,"]");if(e=="{")return et(ot,"}")}function ot(e,t){return e=="variable"&&!C.stream.match(/^\s*:/,!1)?(A(t),L(ut)):(e=="variable"&&(C.marked="property"),L(H(":"),st,ut))}function ut(e,t){if(t=="=")return L(F)}function at(e){if(e==",")return L(it)}function ft(e,t){if(e=="keyword b"&&t=="else")return L(D("form","else"),B,P)}function lt(e){if(e=="(")return L(D(")"),ct,H(")"),P)}function ct(e){return e=="var"?L(it,H(";"),pt):e==";"?L(pt):e=="variable"?L(ht):k(j,H(";"),pt)}function ht(e,t){return t=="in"||t=="of"?(C.marked="keyword",L(j)):L(U,pt)}function pt(e,t){return e==";"?L(dt):t=="in"||t=="of"?(C.marked="keyword",L(j)):k(j,H(";"),dt)}function dt(e){e!=")"&&L(j)}function vt(e,t){if(t=="*")return C.marked="keyword",L(vt);if(e=="variable")return A(t),L(vt);if(e=="(")return L(M,D(")"),Z(mt,")"),P,B,_)}function mt(e){return e=="spread"?L(mt):k(st,nt)}function gt(e,t){if(e=="variable")return A(t),L(yt)}function yt(e,t){if(t=="extends")return L(j,yt);if(e=="{")return L(D("}"),bt,P)}function bt(e,t){if(e=="variable"||C.style=="keyword")return C.marked="property",t=="get"||t=="set"?L(wt,vt,bt):L(vt,bt);if(t=="*")return C.marked="keyword",L(bt);if(e==";")return L(bt);if(e=="}")return L()}function wt(e){return e!="variable"?k():(C.marked="property",L())}function Et(e,t){if(e=="string")return L(B);if(e=="variable")return A(t),L(Nt)}function St(e,t){return t=="*"?(C.marked="keyword",L(Nt,H(";"))):t=="default"?(C.marked="keyword",L(j,H(";"))):k(B)}function xt(e){return e=="string"?L():k(Tt,Nt)}function Tt(e,t){return e=="{"?et(Tt,"}"):(e=="variable"&&A(t),L())}function Nt(e,t){if(t=="from")return C.marked="keyword",L(j)}function Ct(e){return e=="]"?L():k(F,kt)}function kt(e){return e=="for"?k(Lt,H("]")):e==","?L(Z(R,"]")):k(Z(F,"]"))}function Lt(e){if(e=="for")return L(lt,Lt);if(e=="if")return L(j,Lt)}var r=t.indentUnit,i=n.statementIndent,s=n.jsonld,o=n.json||s,u=n.typescript,a=n.wordCharacters||/[\w$\xa1-\uffff]/,f=function(){function e(e){return{type:e,style:"keyword"}}var t=e("keyword a"),n=e("keyword b"),r=e("keyword c"),i=e("operator"),s={type:"atom",style:"atom"},o={"if":e("if"),"while":t,"with":t,"else":n,"do":n,"try":n,"finally":n,"return":r,"break":r,"continue":r,"new":r,"delete":r,"throw":r,"debugger":r,"var":e("var"),"const":e("var"),let:e("var"),"function":e("function"),"catch":e("catch"),"for":e("for"),"switch":e("switch"),"case":e("case"),"default":e("default"),"in":i,"typeof":i,"instanceof":i,"true":s,"false":s,"null":s,"undefined":s,NaN:s,Infinity:s,"this":e("this"),module:e("module"),"class":e("class"),"super":e("atom"),yield:r,"export":e("export"),"import":e("import"),"extends":r};if(u){var a={type:"variable",style:"variable-3"},f={"interface":e("interface"),"extends":e("extends"),constructor:e("constructor"),"public":e("public"),"private":e("private"),"protected":e("protected"),"static":e("static"),string:a,number:a,bool:a,any:a};for(var l in f)o[l]=f[l]}return o}(),l=/[+\-*&%=<>!?|~^]/,c=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,p,d,w="([{}])",S={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},C={state:null,column:null,marked:null,cc:null},O={name:"this",next:{name:"arguments"}};return P.lex=!0,{startState:function(e){var t={tokenize:m,lastType:"sof",cc:[],lexical:new x((e||0)-r,0,"block",!1),localVars:n.localVars,context:n.localVars&&{vars:n.localVars},indented:0};return n.globalVars&&typeof n.globalVars=="object"&&(t.globalVars=n.globalVars),t},token:function(e,t){e.sol()&&(t.lexical.hasOwnProperty("align")||(t.lexical.align=!1),t.indented=e.indentation(),E(e,t));if(t.tokenize!=y&&e.eatSpace())return null;var n=t.tokenize(e,t);return p=="comment"?n:(t.lastType=p!="operator"||d!="++"&&d!="--"?p:"incdec",N(t,n,p,d,e))},indent:function(t,s){if(t.tokenize==y)return e.Pass;if(t.tokenize!=m)return 0;var o=s&&s.charAt(0),u=t.lexical;if(!/^\s*else\b/.test(s))for(var a=t.cc.length-1;a>=0;--a){var f=t.cc[a];if(f==P)u=u.prev;else if(f!=ft)break}u.type=="stat"&&o=="}"&&(u=u.prev),i&&u.type==")"&&u.prev.type=="stat"&&(u=u.prev);var l=u.type,c=o==l;return l=="vardef"?u.indented+(t.lastType=="operator"||t.lastType==","?u.info+1:0):l=="form"&&o=="{"?u.indented:l=="form"?u.indented+r:l=="stat"?u.indented+(t.lastType=="operator"||t.lastType==","?i||r:0):u.info=="switch"&&!c&&n.doubleIndentSwitch!=0?u.indented+(/^(?:case|default)\b/.test(s)?r:2*r):u.align?u.column+(c?0:1):u.indented+(c?0:r)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:o?null:"/*",blockCommentEnd:o?null:"*/",lineComment:o?null:"//",fold:"brace",helperType:o?"json":"javascript",jsonldMode:s,jsonMode:o}}),e.registerHelper("wordChars","javascript",/[\w$]/),e.defineMIME("text/javascript","javascript"),e.defineMIME("text/ecmascript","javascript"),e.defineMIME("application/javascript","javascript"),e.defineMIME("application/x-javascript","javascript"),e.defineMIME("application/ecmascript","javascript"),e.defineMIME("application/json",{name:"javascript",json:!0}),e.defineMIME("application/x-json",{name:"javascript",json:!0}),e.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),e.defineMIME("text/typescript",{name:"javascript",typescript:!0}),e.defineMIME("application/typescript",{name:"javascript",typescript:!0})}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/hint/xml-hint",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function n(n,r){var i=r&&r.schemaInfo,s=r&&r.quoteChar||'"';if(!i)return;var o=n.getCursor(),u=n.getTokenAt(o);if(/^<\/?$/.test(u.string)&&u.end==o.ch){var a=n.getTokenAt(t(o.line,o.ch+1));a.start==o.ch&&/\btag\b/.test(a.type)&&(u=a)}var f=e.innerMode(n.getMode(),u.state);if(f.mode.name!="xml")return;var l=[],c=!1,h,p=/\btag\b/.test(u.type)&&!/>$/.test(u.string),d=p&&/^\w/.test(u.string),v;if(d){var m=n.getLine(o.line).slice(Math.max(0,u.start-2),u.start),g=/<\/$/.test(m)?"close":/<$/.test(m)?"open":null;g&&(v=u.start-(g=="close"?2:1))}else p&&u.string=="<"?g="open":p&&u.string=="</"&&(g="close");if(!p&&!f.state.tagName||g){d&&(h=u.string),c=g;var y=f.state.context,b=y&&i[y.tagName],w=y?b&&b.children:i["!top"];if(w&&g!="close")for(var E=0;E<w.length;++E)(!h||w[E].lastIndexOf(h,0)==0)&&l.push("<"+w[E]);else if(g!="close")for(var S in i)i.hasOwnProperty(S)&&S!="!top"&&S!="!attrs"&&(!h||S.lastIndexOf(h,0)==0)&&l.push("<"+S);y&&(!h||g=="close"&&y.tagName.lastIndexOf(h,0)==0)&&l.push("</"+y.tagName+">")}else{var b=i[f.state.tagName],x=b&&b.attrs,T=i["!attrs"];if(!x&&!T)return;if(!x)x=T;else if(T){var N={};for(var C in T)T.hasOwnProperty(C)&&(N[C]=T[C]);for(var C in x)x.hasOwnProperty(C)&&(N[C]=x[C]);x=N}if(u.type=="string"||u.string=="="){var m=n.getRange(t(o.line,Math.max(0,o.ch-60)),t(o.line,u.type=="string"?u.start:u.end)),k=m.match(/([^\s\u00a0=<>\"\']+)=$/),L;if(!k||!x.hasOwnProperty(k[1])||!(L=x[k[1]]))return;typeof L=="function"&&(L=L.call(this,n));if(u.type=="string"){h=u.string;var A=0;/['"]/.test(u.string.charAt(0))&&(s=u.string.charAt(0),h=u.string.slice(1),A++);var O=u.string.length;/['"]/.test(u.string.charAt(O-1))&&(s=u.string.charAt(O-1),h=u.string.substr(A,O-2)),c=!0}for(var E=0;E<L.length;++E)(!h||L[E].lastIndexOf(h,0)==0)&&l.push(s+L[E]+s)}else{u.type=="attribute"&&(h=u.string,c=!0);for(var M in x)x.hasOwnProperty(M)&&(!h||M.lastIndexOf(h,0)==0)&&l.push(M)}}return{list:l,from:c?t(o.line,v==null?u.start:v):o,to:c?t(o.line,u.end):o}}var t=e.Pos;e.registerHelper("hint","xml",n)}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror","./xml-hint")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/hint/html-hint",["../../lib/codemirror","./xml-hint"],e):e(CodeMirror)}(function(e){function l(e){for(var t in f)f.hasOwnProperty(t)&&(e.attrs[t]=f[t])}function h(t,n){var r={schemaInfo:a};if(n)for(var i in n)r[i]=n[i];return e.hint.xml(t,r)}var t="ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" "),n=["_blank","_self","_top","_parent"],r=["ascii","utf-8","utf-16","latin1","latin1"],i=["get","post","put","delete"],s=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],o=["all","screen","print","embossed","braille","handheld","print","projection","screen","tty","tv","speech","3d-glasses","resolution [>][<][=] [X]","device-aspect-ratio: X/Y","orientation:portrait","orientation:landscape","device-height: [X]","device-width: [X]"],u={attrs:{}},a={a:{attrs:{href:null,ping:null,type:null,media:o,target:n,hreflang:t}},abbr:u,acronym:u,address:u,applet:u,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:o,hreflang:t,type:null,shape:["default","rect","circle","poly"]}},article:u,aside:u,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["","autoplay"],loop:["","loop"],controls:["","controls"]}},b:u,base:{attrs:{href:null,target:n}},basefont:u,bdi:u,bdo:u,big:u,blockquote:{attrs:{cite:null}},body:u,br:u,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["","autofocus"],disabled:["","autofocus"],formenctype:s,formmethod:i,formnovalidate:["","novalidate"],formtarget:n,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:u,center:u,cite:u,code:u,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["","disabled"],checked:["","checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["","disabled"],multiple:["","multiple"]}},datalist:{attrs:{data:null}},dd:u,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["","open"]}},dfn:u,dir:u,div:u,dl:u,dt:u,em:u,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["","disabled"],form:null,name:null}},figcaption:u,figure:u,font:u,footer:u,form:{attrs:{action:null,name:null,"accept-charset":r,autocomplete:["on","off"],enctype:s,method:i,novalidate:["","novalidate"],target:n}},frame:u,frameset:u,h1:u,h2:u,h3:u,h4:u,h5:u,h6:u,head:{attrs:{},children:["title","base","link","style","meta","script","noscript","command"]},header:u,hgroup:u,hr:u,html:{attrs:{manifest:null},children:["head","body"]},i:u,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["","seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["","autofocus"],checked:["","checked"],disabled:["","disabled"],formenctype:s,formmethod:i,formnovalidate:["","novalidate"],formtarget:n,multiple:["","multiple"],readonly:["","readonly"],required:["","required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:u,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["","autofocus"],disabled:["","disabled"],keytype:["RSA"]}},label:{attrs:{"for":null,form:null}},legend:u,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:t,media:o,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:u,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:r,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:u,noframes:u,noscript:u,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["","typemustmatch"]}},ol:{attrs:{reversed:["","reversed"],start:null,type:["1","a","A","i","I"]}},optgroup:{attrs:{disabled:["","disabled"],label:null}},option:{attrs:{disabled:["","disabled"],label:null,selected:["","selected"],value:null}},output:{attrs:{"for":null,form:null,name:null}},p:u,param:{attrs:{name:null,value:null}},pre:u,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:u,rt:u,ruby:u,s:u,samp:u,script:{attrs:{type:["text/javascript"],src:null,async:["","async"],defer:["","defer"],charset:r}},section:u,select:{attrs:{form:null,name:null,size:null,autofocus:["","autofocus"],disabled:["","disabled"],multiple:["","multiple"]}},small:u,source:{attrs:{src:null,type:null,media:null}},span:u,strike:u,strong:u,style:{attrs:{type:["text/css"],media:o,scoped:null}},sub:u,summary:u,sup:u,table:u,tbody:u,td:{attrs:{colspan:null,rowspan:null,headers:null}},textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["","autofocus"],disabled:["","disabled"],readonly:["","readonly"],required:["","required"],wrap:["soft","hard"]}},tfoot:u,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:u,time:{attrs:{datetime:null}},title:u,tr:u,track:{attrs:{src:null,label:null,"default":null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:t}},tt:u,u:u,ul:u,"var":u,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["","autoplay"],mediagroup:["movie"],muted:["","muted"],controls:["","controls"]}},wbr:u},f={accesskey:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"],"class":null,contenteditable:["true","false"],contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["en","es"],spellcheck:["true","false"],style:null,tabindex:["1","2","3","4","5","6","7","8","9"],title:null,translate:["yes","no"],onclick:null,rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"]};l(u);for(var c in a)a.hasOwnProperty(c)&&a[c]!=u&&l(a[c]);e.htmlSchema=a,e.registerHelper("hint","html",h)}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/hint/show-hint",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){function r(e,t){this.cm=e,this.options=this.buildOptions(t),this.widget=this.onClose=null}function i(e){return typeof e=="string"?e:e.text}function s(e,t){function s(e,r){var s;typeof r!="string"?s=function(e){return r(e,t)}:n.hasOwnProperty(r)?s=n[r]:s=r,i[e]=s}var n={Up:function(){t.moveFocus(-1)},Down:function(){t.moveFocus(1)},PageUp:function(){t.moveFocus(-t.menuSize()+1,!0)},PageDown:function(){t.moveFocus(t.menuSize()-1,!0)},Home:function(){t.setFocus(0)},End:function(){t.setFocus(t.length-1)},Enter:t.pick,Tab:t.pick,Esc:t.close},r=e.options.customKeys,i=r?{}:n;if(r)for(var o in r)r.hasOwnProperty(o)&&s(o,r[o]);var u=e.options.extraKeys;if(u)for(var o in u)u.hasOwnProperty(o)&&s(o,u[o]);return i}function o(e,t){while(t&&t!=e){if(t.nodeName.toUpperCase()==="LI"&&t.parentNode==e)return t;t=t.parentNode}}function u(r,u){this.completion=r,this.data=u;var a=this,f=r.cm,l=this.hints=document.createElement("ul");l.className="CodeMirror-hints",this.selectedHint=u.selectedHint||0;var c=u.list;for(var h=0;h<c.length;++h){var p=l.appendChild(document.createElement("li")),d=c[h],v=t+(h!=this.selectedHint?"":" "+n);d.className!=null&&(v=d.className+" "+v),p.className=v,d.render?d.render(p,u,d):p.appendChild(document.createTextNode(d.displayText||i(d))),p.hintId=h}var m=f.cursorCoords(r.options.alignWithWord?u.from:null),g=m.left,y=m.bottom,b=!0;l.style.left=g+"px",l.style.top=y+"px";var w=window.innerWidth||Math.max(document.body.offsetWidth,document.documentElement.offsetWidth),E=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(r.options.container||document.body).appendChild(l);var S=l.getBoundingClientRect(),x=S.bottom-E;if(x>0){var T=S.bottom-S.top,N=m.top-(m.bottom-S.top);if(N-T>0)l.style.top=(y=m.top-T)+"px",b=!1;else if(T>E){l.style.height=E-5+"px",l.style.top=(y=m.bottom-S.top)+"px";var C=f.getCursor();u.from.ch!=C.ch&&(m=f.cursorCoords(C),l.style.left=(g=m.left)+"px",S=l.getBoundingClientRect())}}var k=S.left-w;k>0&&(S.right-S.left>w&&(l.style.width=w-5+"px",k-=S.right-S.left-w),l.style.left=(g=m.left-k)+"px"),f.addKeyMap(this.keyMap=s(r,{moveFocus:function(e,t){a.changeActive(a.selectedHint+e,t)},setFocus:function(e){a.changeActive(e)},menuSize:function(){return a.screenAmount()},length:c.length,close:function(){r.close()},pick:function(){a.pick()},data:u}));if(r.options.closeOnUnfocus){var L;f.on("blur",this.onBlur=function(){L=setTimeout(function(){r.close()},100)}),f.on("focus",this.onFocus=function(){clearTimeout(L)})}var A=f.getScrollInfo();return f.on("scroll",this.onScroll=function(){var e=f.getScrollInfo(),t=f.getWrapperElement().getBoundingClientRect(),n=y+A.top-e.top,i=n-(window.pageYOffset||(document.documentElement||document.body).scrollTop);b||(i+=l.offsetHeight);if(i<=t.top||i>=t.bottom)return r.close();l.style.top=n+"px",l.style.left=g+A.left-e.left+"px"}),e.on(l,"dblclick",function(e){var t=o(l,e.target||e.srcElement);t&&t.hintId!=null&&(a.changeActive(t.hintId),a.pick())}),e.on(l,"click",function(e){var t=o(l,e.target||e.srcElement);t&&t.hintId!=null&&(a.changeActive(t.hintId),r.options.completeOnSingleClick&&a.pick())}),e.on(l,"mousedown",function(){setTimeout(function(){f.focus()},20)}),e.signal(u,"select",c[0],l.firstChild),!0}var t="CodeMirror-hint",n="CodeMirror-hint-active";e.showHint=function(e,t,n){if(!t)return e.showHint(n);n&&n.async&&(t.async=!0);var r={hint:t};if(n)for(var i in n)r[i]=n[i];return e.showHint(r)},e.defineExtension("showHint",function(t){if(this.listSelections().length>1||this.somethingSelected())return;this.state.completionActive&&this.state.completionActive.close();var n=this.state.completionActive=new r(this,t),i=n.options.hint;if(!i)return;e.signal(this,"startCompletion",this);if(!i.async)return n.showHints(i(this,n.options));i(this,function(e){n.showHints(e)},n.options)}),r.prototype={close:function(){if(!this.active())return;this.cm.state.completionActive=null,this.widget&&this.widget.close(),this.onClose&&this.onClose(),e.signal(this.cm,"endCompletion",this.cm)},active:function(){return this.cm.state.completionActive==this},pick:function(t,n){var r=t.list[n];r.hint?r.hint(this.cm,t,r):this.cm.replaceRange(i(r),r.from||t.from,r.to||t.to,"complete"),e.signal(t,"pick",r),this.close()},showHints:function(e){if(!e||!e.list.length||!this.active())return this.close();this.options.completeSingle&&e.list.length==1?this.pick(e,0):this.showWidget(e)},showWidget:function(t){function c(){if(i)return;i=!0,r.close(),r.cm.off("cursorActivity",v),t&&e.signal(t,"close")}function h(){if(i)return;e.signal(t,"update");var n=r.options.hint;n.async?n(r.cm,p,r.options):p(n(r.cm,r.options))}function p(e){t=e;if(i)return;if(!t||!t.list.length)return c();r.widget&&r.widget.close(),r.widget=new u(r,t)}function d(){n&&(l(n),n=0)}function v(){d();var e=r.cm.getCursor(),t=r.cm.getLine(e.line);e.line!=o.line||t.length-e.ch!=a-o.ch||e.ch<o.ch||r.cm.somethingSelected()||e.ch&&s.test(t.charAt(e.ch-1))?r.close():(n=f(h),r.widget&&r.widget.close())}this.widget=new u(this,t),e.signal(t,"shown");var n=0,r=this,i,s=this.options.closeCharacters,o=this.cm.getCursor(),a=this.cm.getLine(o.line).length,f=window.requestAnimationFrame||function(e){return setTimeout(e,1e3/60)},l=window.cancelAnimationFrame||clearTimeout;this.cm.on("cursorActivity",v),this.onClose=c},buildOptions:function(e){var t=this.cm.options.hintOptions,n={};for(var r in a)n[r]=a[r];if(t)for(var r in t)t[r]!==undefined&&(n[r]=t[r]);if(e)for(var r in e)e[r]!==undefined&&(n[r]=e[r]);return n}},u.prototype={close:function(){if(this.completion.widget!=this)return;this.completion.widget=null,this.hints.parentNode.removeChild(this.hints),this.completion.cm.removeKeyMap(this.keyMap);var e=this.completion.cm;this.completion.options.closeOnUnfocus&&(e.off("blur",this.onBlur),e.off("focus",this.onFocus)),e.off("scroll",this.onScroll)},pick:function(){this.completion.pick(this.data,this.selectedHint)},changeActive:function(t,r){t>=this.data.list.length?t=r?this.data.list.length-1:0:t<0&&(t=r?0:this.data.list.length-1);if(this.selectedHint==t)return;var i=this.hints.childNodes[this.selectedHint];i.className=i.className.replace(" "+n,""),i=this.hints.childNodes[this.selectedHint=t],i.className+=" "+n,i.offsetTop<this.hints.scrollTop?this.hints.scrollTop=i.offsetTop-3:i.offsetTop+i.offsetHeight>this.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=i.offsetTop+i.offsetHeight-this.hints.clientHeight+3),e.signal(this.data,"select",this.data.list[this.selectedHint],i)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},e.registerHelper("hint","auto",function(t,n){var r=t.getHelpers(t.getCursor(),"hint"),i;if(r.length)for(var s=0;s<r.length;s++){var o=r[s](t,n);if(o&&o.list.length)return o}else if(i=t.getHelper(t.getCursor(),"hintWords")){if(i)return e.hint.fromList(t,{words:i})}else if(e.hint.anyword)return e.hint.anyword(t,n)}),e.registerHelper("hint","fromList",function(t,n){var r=t.getCursor(),i=t.getTokenAt(r),s=[];for(var o=0;o<n.words.length;o++){var u=n.words[o];u.slice(0,i.string.length)==i.string&&s.push(u)}if(s.length)return{list:s,from:e.Pos(r.line,i.start),to:e.Pos(r.line,i.end)}}),e.commands.autocomplete=e.showHint;var a={hint:e.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:!0,completeOnSingleClick:!1,container:null,customKeys:null,extraKeys:null};e.defineOption("hintOptions",null)}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/mode/xml/xml",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.defineMode("xml",function(t,n){function l(e,t){function n(n){return t.tokenize=n,n(e,t)}var r=e.next();if(r=="<")return e.eat("!")?e.eat("[")?e.match("CDATA[")?n(p("atom","]]>")):null:e.match("--")?n(p("comment","-->")):e.match("DOCTYPE",!0,!0)?(e.eatWhile(/[\w\._\-]/),n(d(1))):null:e.eat("?")?(e.eatWhile(/[\w\._\-]/),t.tokenize=p("meta","?>"),"meta"):(a=e.eat("/")?"closeTag":"openTag",t.tokenize=c,"tag bracket");if(r=="&"){var i;return e.eat("#")?e.eat("x")?i=e.eatWhile(/[a-fA-F\d]/)&&e.eat(";"):i=e.eatWhile(/[\d]/)&&e.eat(";"):i=e.eatWhile(/[\w\.\-:]/)&&e.eat(";"),i?"atom":"error"}return e.eatWhile(/[^&<]/),null}function c(e,t){var n=e.next();if(n==">"||n=="/"&&e.eat(">"))return t.tokenize=l,a=n==">"?"endTag":"selfcloseTag","tag bracket";if(n=="=")return a="equals",null;if(n=="<"){t.tokenize=l,t.state=y,t.tagName=t.tagStart=null;var r=t.tokenize(e,t);return r?r+" tag error":"tag error"}return/[\'\"]/.test(n)?(t.tokenize=h(n),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function h(e){var t=function(t,n){while(!t.eol())if(t.next()==e){n.tokenize=c;break}return"string"};return t.isInAttribute=!0,t}function p(e,t){return function(n,r){while(!n.eol()){if(n.match(t)){r.tokenize=l;break}n.next()}return e}}function d(e){return function(t,n){var r;while((r=t.next())!=null){if(r=="<")return n.tokenize=d(e+1),n.tokenize(t,n);if(r==">"){if(e==1){n.tokenize=l;break}return n.tokenize=d(e-1),n.tokenize(t,n)}}return"meta"}}function v(e,t,n){this.prev=e.context,this.tagName=t,this.indent=e.indented,this.startOfLine=n;if(o.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)this.noIndent=!0}function m(e){e.context&&(e.context=e.context.prev)}function g(e,t){var n;for(;;){if(!e.context)return;n=e.context.tagName;if(!o.contextGrabbers.hasOwnProperty(n)||!o.contextGrabbers[n].hasOwnProperty(t))return;m(e)}}function y(e,t,n){return e=="openTag"?(n.tagStart=t.column(),b):e=="closeTag"?w:y}function b(e,t,n){return e=="word"?(n.tagName=t.current(),f="tag",x):(f="error",b)}function w(e,t,n){if(e=="word"){var r=t.current();return n.context&&n.context.tagName!=r&&o.implicitlyClosed.hasOwnProperty(n.context.tagName)&&m(n),n.context&&n.context.tagName==r?(f="tag",E):(f="tag error",S)}return f="error",S}function E(e,t,n){return e!="endTag"?(f="error",E):(m(n),y)}function S(e,t,n){return f="error",E(e,t,n)}function x(e,t,n){if(e=="word")return f="attribute",T;if(e=="endTag"||e=="selfcloseTag"){var r=n.tagName,i=n.tagStart;return n.tagName=n.tagStart=null,e=="selfcloseTag"||o.autoSelfClosers.hasOwnProperty(r)?g(n,r):(g(n,r),n.context=new v(n,r,i==n.indented)),y}return f="error",x}function T(e,t,n){return e=="equals"?N:(o.allowMissing||(f="error"),x(e,t,n))}function N(e,t,n){return e=="string"?C:e=="word"&&o.allowUnquoted?(f="string",x):(f="error",x(e,t,n))}function C(e,t,n){return e=="string"?C:x(e,t,n)}var r=t.indentUnit,i=n.multilineTagIndentFactor||1,s=n.multilineTagIndentPastTag;s==null&&(s=!0);var o=n.htmlMode?{autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1},u=n.alignCDATA,a,f;return{startState:function(){return{tokenize:l,state:y,indented:0,tagName:null,tagStart:null,context:null}},token:function(e,t){!t.tagName&&e.sol()&&(t.indented=e.indentation());if(e.eatSpace())return null;a=null;var n=t.tokenize(e,t);return(n||a)&&n!="comment"&&(f=null,t.state=t.state(a||n,e,t),f&&(n=f=="error"?n+" error":f)),n},indent:function(t,n,a){var f=t.context;if(t.tokenize.isInAttribute)return t.tagStart==t.indented?t.stringStartCol+1:t.indented+r;if(f&&f.noIndent)return e.Pass;if(t.tokenize!=c&&t.tokenize!=l)return a?a.match(/^(\s*)/)[0].length:0;if(t.tagName)return s?t.tagStart+t.tagName.length+2:t.tagStart+r*i;if(u&&/<!\[CDATA\[/.test(n))return 0;var h=n&&/^<(\/)?([\w_:\.-]*)/.exec(n);if(h&&h[1])while(f){if(f.tagName==h[2]){f=f.prev;break}if(!o.implicitlyClosed.hasOwnProperty(f.tagName))break;f=f.prev}else if(h)while(f){var p=o.contextGrabbers[f.tagName];if(!p||!p.hasOwnProperty(h[2]))break;f=f.prev}while(f&&!f.startOfLine)f=f.prev;return f?f.indent+r:0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"<!--",blockCommentEnd:"-->",configuration:n.htmlMode?"html":"xml",helperType:n.htmlMode?"html":"xml"}}),e.defineMIME("text/xml","xml"),e.defineMIME("application/xml","xml"),e.mimeModes.hasOwnProperty("text/html")||e.defineMIME("text/html",{name:"xml",htmlMode:!0})}),function(e){typeof exports=="object"&&typeof module=="object"?e(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define("libs/codemirror-4.8/addon/runmode/runmode",["../../lib/codemirror"],e):e(CodeMirror)}(function(e){e.runMode=function(t,n,r,i){var s=e.getMode(e.defaults,n),o=/MSIE \d/.test(navigator.userAgent),u=o&&(document.documentMode==null||document.documentMode<9);if(r.nodeType==1){var a=i&&i.tabSize||e.defaults.tabSize,f=r,l=0;f.innerHTML="",r=function(e,t){if(e=="\n"){f.appendChild(document.createTextNode(u?"\r":e)),l=0;return}var n="";for(var r=0;;){var i=e.indexOf("	",r);if(i==-1){n+=e.slice(r),l+=e.length-r;break}l+=i-r,n+=e.slice(r,i);var s=a-l%a;l+=s;for(var o=0;o<s;++o)n+=" ";r=i+1}if(t){var c=f.appendChild(document.createElement("span"));c.className="cm-"+t.replace(/ +/g," cm-"),c.appendChild(document.createTextNode(n))}else f.appendChild(document.createTextNode(n))}}var c=e.splitLines(t),h=i&&i.state||e.startState(s);for(var p=0,d=c.length;p<d;++p){p&&r("\n");var v=new e.StringStream(c[p]);!v.string&&s.blankLine&&s.blankLine(h);while(!v.eol()){var m=s.token(v,h);r(v.current(),m,p,v.start,h),v.start=v.pos}}}}),define("CodeMirrorEditor",["react","lodash","jquery","./libs/codemirror-4.8/lib/codemirror","./CMLint","./libs/codemirror-4.8/mode/javascript/javascript","./libs/codemirror-4.8/addon/hint/html-hint","./libs/codemirror-4.8/addon/hint/show-hint","./libs/codemirror-4.8/addon/hint/xml-hint","./libs/codemirror-4.8/addon/hint/html-hint","./libs/codemirror-4.8/mode/xml/xml","./libs/codemirror-4.8/addon/runmode/runmode"],function(e,t,n,r,i){function u(e,t){return(!t||t())&&setTimeout(function(){e.state.completionActive||e.showHint({completeSingle:!1})},100),r.Pass}function a(e){return u(e,function(){var t=e.getCursor();return e.getRange(r.Pos(t.line,t.ch-1),t)==="<"})}function f(e){return u(e,function(){var t=e.getTokenAt(e.getCursor());if(t.type!=="string"||!!/['"]/.test(t.string.charAt(t.string.length-1))&&t.string.length!==1){var n=r.innerMode(e.getMode(),t.state).state;return n.tagName}return!1})}var s={div:{attrs:{"rt-props":null,"rt-if":null,"rt-repeat":null,"rt-class":null,"rt-scope":null,valueLink:null,key:null,ref:null,dangerouslySetInnerHTML:null}}},o=r.htmlSchema;return Object.keys(r.htmlSchema).forEach(function(e){o[e].attrs=t.defaults(s.div.attrs,o[e].attrs)}),e.createClass({displayName:"CodeMirrorEditor",propTypes:{id:e.PropTypes.string,readOnly:e.PropTypes.bool,runMode:e.PropTypes.bool,mode:e.PropTypes.string,value:e.PropTypes.string,valueLink:e.PropTypes.string,onChange:e.PropTypes.func},getDefaultProps:function(){return{readOnly:!1,mode:"html"}},getInitialState:function(){return{editorId:t.uniqueId()}},render:function(){var n=t.omit(this.props,["ref","key","value","valueLink","onChange"]);return n.id=this.props.id||this.state.editorId,n.defaultValue=this.props.valueLink?this.props.valueLink():this.props.value,e.DOM.textarea(n)},componentWillUpdate:function(e){var t=e.valueLink?e.valueLink():e.value;this.editor&&this.editor.getValue()!==t&&this.editor.setValue(t||"")},componentDidMount:function(){var e=this.props.valueLink?this.props.valueLink():this.props.value,t={readOnly:this.props.readOnly,lineWrapping:!0,smartIndent:!0,matchBrackets:!0,value:e,lineNumbers:!0,mode:"javascript",gutters:["CodeMirror-linenumbers","rt-annotations"],theme:"solarized"};this.props.mode==="html"?(t.mode="text/html",t.extraKeys={"'<'":u,"'/'":a,"' '":f,"'='":f,"Ctrl-Space":"autocomplete"},t.hintOptions={schemaInfo:o}):t.mode="javascript",this.editor=r.fromTextArea(this.getDOMNode(),t),this.props.readOnly||this.editor.on("change",function(){this.props.valueLink?this.props.valueLink(this.editor.getValue()):this.props.onChange&&this.props.onChange({target:{value:this.editor.getValue()}})}.bind(this))},annotate:function(e){i.annotate(this.editor,e)},clearAnnotations:function(){i.clearMarks(this.editor)},componentWillUnmount:function(){this.editor.toTextArea()}})}),define("playground-fiddle.rt",["react/addons","lodash","./CodeMirrorEditor"],function(e,t,n){function r(e){this.setState({templateHTML:e.target.value})}function i(e){this.setState({templateProps:e.target.value})}function s(e){e.preventDefault()}return function(){return e.createElement("div",{className:"playground"},e.createElement("div",{className:"fiddle-row"},e.createElement("div",{className:"code-area",id:"area-rt"},e.createElement(n,{ref:"editorRT",id:"editor-rt",className:"large-text-area",value:this.state.templateHTML,mode:"html",onChange:r.bind(this)})),e.createElement("div",{className:"code-area",id:"area-code"},e.createElement(n,{ref:"editorCode",id:"editor-code",className:"large-text-area",value:this.state.templateProps,mode:"javascript",onChange:i.bind(this)}))),e.createElement("div",{className:"fiddle-row"},e.createElement("div",{className:"code-area",id:"area-generated"},e.createElement(n,{id:"editor-generated",className:"large-text-area",ref:"editorGenerated",value:this.templateSource,mode:"javascript",readOnly:!0})),e.createElement("div",{className:"code-area",id:"area-result"},e.createElement("div",{id:"result-area",key:"result-area",className:"sample-view"},e.createElement("form",{className:"result-area-form",ref:"mount",onSubmit:s.bind(this)})))))}}),define("playground.rt",["react/addons","lodash","./CodeMirrorEditor"],function(e,t,n){function r(e,t,n){n.preventDefault(),this.setState({currentTab:e[0]})}function i(n,i){return e.createElement("li",{role:"presentation",key:"tab"+i,className:t.keys(t.pick({active:this.state.currentTab===n[0]},t.identity)).join(" "),onClick:r.bind(this,n,i)},e.createElement("a",{"aria-controls":n[1]},n[1]))}function s(e){this.setState({templateHTML:e.target.value})}function o(e){this.setState({templateProps:e.target.value})}function u(e){e.preventDefault()}return function(){return e.createElement("div",{className:"playground"},e.createElement("div",{id:this.props.id+"-myTab",className:"code-area "+this.getLayoutClass()},e.createElement.apply(this,["ul",{className:"nav nav-tabs",role:"tablist"},t.map(this.getTabs(),i.bind(this))]),e.createElement("div",{},this.state.currentTab==="templateHTML"?e.createElement("div",{key:"editorRT",className:"tab-pane active"},e.createElement(n,{ref:"editorRT",className:"large-text-area",style:{border:this.validHTML?"":"2px solid red"},value:this.state.templateHTML,mode:"html",onChange:s.bind(this)})):null,this.state.currentTab==="templateProps"?e.createElement("div",{key:"editorCode",className:"tab-pane active"},e.createElement(n,{ref:"editorCode",className:"large-text-area",style:{border:this.validProps?"":"2px solid red"},value:this.state.templateProps,mode:"javascript",onChange:o.bind(this)})):null,this.state.currentTab==="templateSource"?e.createElement("div",{key:"templateSource",className:"tab-pane active"},e.createElement(n,{className:"large-text-area",value:this.templateSource,mode:"javascript",readOnly:!0})):null)),e.createElement("div",{key:"result-area",className:"result-area "+this.getLayoutClass()},e.createElement("span",{className:"preview-title"}," "),e.createElement("form",{ref:"mount",className:"sample-view",onSubmit:u.bind(this)})),e.createElement("br",{style:{clear:"both"}}))}}),define("playground",["react","jquery","lodash","./playground-fiddle.rt","./playground.rt"],function(React,$,_,pgFiddleTemplate,playgroundTemplate){function showMessage(e,t){e&&e.showMessage&&e.annotate({line:1,message:t})}function clearMessage(e){e&&e.clearAnnotations&&e.clearAnnotations()}function generateRenderFunc(e){return function(){var t=null;try{t=e.apply(this)}catch(n){t=React.DOM.div.apply(this,[{style:{color:"red"}},"Exception:"+n.message])}return React.DOM.div.apply(this,_.flatten([{key:"result"},t]))}}var templateHTML="<div></div>",templateProps="var template = React.createClass({\n   render: templateRT\n});",Playground=React.createClass({displayName:"Playground",mixins:[React.addons.LinkedStateMixin],propTypes:{direction:React.PropTypes.oneOf(["horizontal","vertical"]),codeVisible:React.PropTypes.bool,fiddle:React.PropTypes.bool,templateHTML:React.PropTypes.string,templateProps:React.PropTypes.string,name:React.PropTypes.string},templateSource:"",validHTML:!0,validProps:!0,setTimeout:function(){clearTimeout(this.timeoutID),this.timeoutID=setTimeout.apply(null,arguments)},getDefaultProps:function(){return{direction:"horizontal",codeVisible:!0,fiddle:!1}},getLayoutClass:function(){return this.props.direction==="horizontal"&&"horizontal"||"vertical"},getTabs:function(){return this.props.codeVisible?[["templateHTML","Template"],["templateProps","Class"],["templateSource","Generated code"]]:[["templateHTML","Template"],["templateSource","Generated code"]]},updateSample:function(state){this.generateCode(state),this.validHTML=!0,this.sampleRender=generateRenderFunc(this.sampleFunc);var editor;try{this.validProps=!0,this.sample=eval("(function () {"+this.templateSource+"\n"+state.templateProps+"\n return React.createElement("+state.name+");})()"),clearMessage(this.refs.editorCode)}catch(e){this.validProps=!1,this.sample=null,editor=this.refs.editorCode,this.showError(e,editor)}},showError:function(e,t){var n=this.refs.mount.getDOMNode();this.setTimeout(function(){showMessage(t,e.message),React.render(React.createElement("div",{className:"playground-error"},e.toString()),n)},500)},showErrorAnnotation:function(e,t){var n=this.refs.mount.getDOMNode();this.setTimeout(function(){t.annotate(e),React.render(React.createElement("div",{className:"playground-error"},e.message),n)},500)},clear:function(){var e={templateHTML:templateHTML,templateProps:templateProps};this.setState(e)},generateCode:function(e){var t=e.templateHTML,n=this.refs.editorRT,r=window.reactTemplates.normalizeName(e.name)+"RT",i=null,s=null;try{i=window.reactTemplates.convertTemplateToReact(t.trim().replace(/\r/g,""),{modules:"none",name:r}),clearMessage(n)}catch(o){o.name==="RTCodeError"?s={line:o.line,message:o.message,index:o.index}:s={line:1,message:o.message},this.showErrorAnnotation(s,n),console.log(o)}this.templateSource=i},getInitialState:function(){var e={templateHTML:this.props.templateHTML||templateHTML,templateProps:this.props.templateProps||templateProps,name:this.props.name||"template",currentTab:"templateHTML"};return e},componentDidMount:function(){this.props.fiddle&&(window.addEventListener("resize",this.calcSize),this.calcSize()),this.updateSample(this.state),this.renderSample()},renderSample:function(){var e=this.refs.mount.getDOMNode();this.sample&&React.render(this.sample,e)},componentDidUpdate:function(){this.renderSample()},componentWillUnmount:function(){window.removeEventListener("resize",this.calcSize)},calcSize:function(){var e=$(window).height()-$("#header").height(),t=e/2-10;$(".code-area").each(function(){$(this).height(t)}),this.refs.editorCode.editor.refresh(),this.refs.editorRT.editor.refresh(),this.refs.editorGenerated.editor.refresh()},componentWillUpdate:function(e,t){(t.templateHTML!==this.state.templateHTML||t.templateProps!==this.state.templateProps)&&this.updateSample(t)},render:function(){this.generateCode(this.state);var e=this.props.fiddle?pgFiddleTemplate:playgroundTemplate;return e.apply(this)}});return Playground}),define("CodeMirrorViewer",["react","lodash","jquery","./libs/codemirror-4.8/lib/codemirror","./libs/codemirror-4.8/mode/javascript/javascript","./libs/codemirror-4.8/mode/xml/xml","./libs/codemirror-4.8/addon/runmode/runmode"],function(e,t,n,r){return e.createClass({displayName:"CodeMirrorViewer",propTypes:{id:e.PropTypes.string,mode:e.PropTypes.string,value:e.PropTypes.string,valueLink:e.PropTypes.string},getDefaultProps:function(){return{mode:"html"}},getInitialState:function(){return{editorId:t.uniqueId()}},render:function(){var n=t.omit(this.props,["ref","key","value","valueLink","onChange"]);n.id=this.props.id||this.state.editorId,n.className="cm-s-default";var r=this.props.valueLink?this.props.valueLink():this.props.value;return e.DOM.pre(n,r)},componentWillUpdate:function(e){var t=e.valueLink?e.valueLink():e.value;this.editor&&this.editor.getValue()!==t&&this.editor.setValue(t||"")},componentDidMount:function(){var e=this.props.valueLink?this.props.valueLink():this.props.value,t=this.props.mode;this.props.mode==="html"&&(t="text/html"),this.editor=r.runMode(e,t,this.getDOMNode())},componentWillUnmount:function(){this.editor.toTextArea()}})}),define("examples.rt",["react/addons","lodash","./playground","./CodeMirrorViewer"],function(e,t,n,r){return function(){return e.createElement("div",{id:"examples"},e.createElement("div",{className:"example"},e.createElement("h3",{},"Hello world in React Templates"),e.createElement("p",{},'\n            Simple "Hello world" HTML transformed into React JavaScript code.\n        '),e.createElement(n,t.assign({},{id:"helloExample",direction:"horizontal"},this.state.samples.hello))),e.createElement("div",{className:"example"},e.createElement("h3",{},"rt-if"),e.createElement("p",{},"\n            This shows the use of rt-if.\n        "),e.createElement(n,t.assign({},{id:"ifExample",direction:"horizontal"},this.state.samples.rtIf))),e.createElement("div",{className:"example"},e.createElement("h3",{},"rt-repeat"),e.createElement("p",{},"\n            This uses rt-repeat to show multiple items and rt-scope to create a reusable name for multiple calculations.\n        "),e.createElement(n,t.assign({},{id:"repeatExample",direction:"horizontal"},this.state.samples.repeat))),e.createElement("div",{className:"example"},e.createElement("h3",{},"rt-props"),e.createElement("p",{},"\n            rt-props is used to pass all the original properties set on this component (except the ones used for the component logic: onClick and eventId) to the element that will actually represent this component.\n        "),e.createElement(n,t.assign({},{id:"propsExample",direction:"horizontal"},this.state.samples.props))),e.createElement("div",{className:"example"},e.createElement("h3",{},"Improved todo list"),e.createElement("p",{},"\n            Every project needs a todo list example, so here is ours.\n        "),e.createElement(n,t.assign({},{id:"todoExample",direction:"horizontal"},this.state.samples.todo))),e.createElement("div",{className:"example"},e.createElement("h3",{},"Weather"),e.createElement("p",{},"\n            This example shows working with async events, the usage of regular event handler function pointers instead of lambda expression, and working with two-way binding.\n        "),e.createElement(n,t.assign({},{id:"weatherExample",direction:"horizontal"},this.state.samples.weather))),e.createElement("div",{id:"rt-require",className:"example"},e.createElement("h3",{},"rt-require"),e.createElement("p",{},"\n            This example shows how to load other React components and libraries into a React template and then use them within the template.\n        "),e.createElement(r,t.assign({},{mode:"javascript"},this.state.rtRequire))),e.createElement("div",{id:"amd",className:"example"},e.createElement("h3",{},"AMD"),e.createElement("p",{},"\n            This example shows the rt-require sample output with AMD support.\n        "),e.createElement(r,t.assign({},{mode:"javascript"},this.state.amd))),e.createElement("div",{id:"commonjs",className:"example"},e.createElement("h3",{},"CommonJS"),e.createElement("p",{},"\n            This example shows the rt-require sample output with CommonJS support.\n        "),e.createElement(r,t.assign({},{mode:"javascript"},this.state.cjs))),e.createElement("div",{id:"es6",className:"example"},e.createElement("h3",{},"ES6"),e.createElement("p",{},"\n            This example shows the rt-require sample output with ES6 support.\n        "),e.createElement(r,t.assign({},{mode:"javascript"},this.state.es6))))}}),define("text",["module"],function(e){var t,n,r=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],i=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,s=/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,o=typeof location!="undefined"&&location.href,u=o&&location.protocol&&location.protocol.replace(/\:/,""),a=o&&location.hostname,f=o&&(location.port||undefined),l=[],c=e.config&&e.config()||{};t={version:"2.0.5",strip:function(e){if(e){e=e.replace(i,"");var t=e.match(s);t&&(e=t[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")},createXhr:c.createXhr||function(){var e,t,n;if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;if(typeof ActiveXObject!="undefined")for(t=0;t<3;t+=1){n=r[t];try{e=new ActiveXObject(n)}catch(i){}if(e){r=[n];break}}return e},parseName:function(e){var t,n,r,i=!1,s=e.indexOf("."),o=e.indexOf("./")===0||e.indexOf("../")===0;return s!==-1&&(!o||s>1)?(t=e.substring(0,s),n=e.substring(s+1,e.length)):t=e,r=n||t,s=r.indexOf("!"),s!==-1&&(i=r.substring(s+1)==="strip",r=r.substring(0,s),n?n=r:t=r),{moduleName:t,ext:n,strip:i}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(e,n,r,i){var s,o,u,a=t.xdRegExp.exec(e);return a?(s=a[2],o=a[3],o=o.split(":"),u=o[1],o=o[0],(!s||s===n)&&(!o||o.toLowerCase()===r.toLowerCase())&&(!u&&!o||u===i)):!0},finishLoad:function(e,n,r,i){r=n?t.strip(r):r,c.isBuild&&(l[e]=r),i(r)},load:function(e,n,r,i){if(i.isBuild&&!i.inlineText){r();return}c.isBuild=i.isBuild;var s=t.parseName(e),l=s.moduleName+(s.ext?"."+s.ext:""),h=n.toUrl(l),p=c.useXhr||t.useXhr;!o||p(h,u,a,f)?t.get(h,function(n){t.finishLoad(e,s.strip,n,r)},function(e){r.error&&r.error(e)}):n([l],function(e){t.finishLoad(s.moduleName+"."+s.ext,s.strip,e,r)})},write:function(e,n,r,i){if(l.hasOwnProperty(n)){var s=t.jsEscape(l[n]);r.asModule(e+"!"+n,"define(function () { return '"+s+"';});\n")}},writeFile:function(e,n,r,i,s){var o=t.parseName(n),u=o.ext?"."+o.ext:"",a=o.moduleName+u,f=r.toUrl(o.moduleName+u)+".js";t.load(a,r,function(n){var r=function(e){return i(f,e)};r.asModule=function(e,t){return i.asModule(e,f,t)},t.write(e,a,r,s)},s)}};if(c.env==="node"||!c.env&&typeof process!="undefined"&&process.versions&&!!process.versions.node)n=require.nodeRequire("fs"),t.get=function(e,t){var r=n.readFileSync(e,"utf8");r.indexOf("")===0&&(r=r.substring(1)),t(r)};else if(c.env==="xhr"||!c.env&&t.createXhr())t.get=function(e,n,r,i){var s=t.createXhr(),o;s.open("GET",e,!0);if(i)for(o in i)i.hasOwnProperty(o)&&s.setRequestHeader(o.toLowerCase(),i[o]);c.onXhr&&c.onXhr(s,e),s.onreadystatechange=function(t){var i,o;s.readyState===4&&(i=s.status,i>399&&i<600?(o=new Error(e+" HTTP status: "+i),o.xhr=s,r(o)):n(s.responseText))},s.send(null)};else if(c.env==="rhino"||!c.env&&typeof Packages!="undefined"&&typeof java!="undefined")t.get=function(e,t){var n,r,i="utf-8",s=new java.io.File(e),o=java.lang.System.getProperty("line.separator"),u=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(s),i)),a="";try{n=new java.lang.StringBuffer,r=u.readLine(),r&&r.length()&&r.charAt(0)===65279&&(r=r.substring(1)),n.append(r);while((r=u.readLine())!==null)n.append(o),n.append(r);a=String(n.toString())}finally{u.close()}t(a)};return t}),define("text!samples/hello.code",[],function(){return"var <%= name %> = React.createClass({\n    render: <%= name %>RT\n});"}),define("text!samples/hello.rt",[],function(){return"<h2>Hello world</h2>\n"}),define("text!samples/todo.code",[],function(){return"var <%= name %> = React.createClass({\n    mixins: [React.addons.LinkedStateMixin],\n    getInitialState: function () {\n        return {edited: '', todos: [], counter: 0};\n    },\n    add: function () {\n        if (this.state.edited.trim().length === 0) {\n            return;\n        }\n        var newTodo = {value: this.state.edited, done: false, key: this.state.counter};\n        this.setState({todos: this.state.todos.concat(newTodo), edited: '', counter: this.state.counter + 1});\n    },\n    remove: function (todo) {\n        this.setState({todos: _.reject(this.state.todos, todo)});\n    },\n    toggleChecked: function (index) {\n        var todos = _.cloneDeep(this.state.todos);\n        todos[index].done = !todos[index].done;\n        this.setState({todos: todos});\n    },\n    clearDone: function () {\n        this.setState({todos: this.getPending()});\n    },\n    getDone: function () {\n        return _.filter(this.state.todos, {done: true});\n    },\n    getPending: function () {\n        return _.filter(this.state.todos, {done: false});\n    },\n    render: <%= name %>RT\n});"}),define("text!samples/todo.rt",[],function(){return'<div>\n    <strong>{this.getDone().length}</strong>\n    done,\n    <strong>{this.getPending().length}</strong>\n    pending\n    <br/>\n    <div rt-repeat="todo in this.state.todos" key="{todo.key}">\n        <img src="img/samples/delete.png"\n             onClick="()=>this.remove(todo)"\n             title="Remove Todo"\n             style="cursor:pointer"/>\n        <input type="checkbox" checked="{todo.done}"\n               onChange="()=>this.toggleChecked(todoIndex)"/>\n        <span style="text-decoration: {todo.done ? \'line-through\': \'none\'}">{todo.value}</span>\n    </div>\n    <input key="myinput" style="width:130px" type="text"\n           onKeyDown="(e) => if (e.keyCode == 13) { e.preventDefault(); this.add(); }"\n           valueLink="{this.linkState(\'edited\')}"/>\n    <button onClick="()=>this.add()">Add</button><br/>\n    <button onClick="()=>this.clearDone()">Clear done</button>\n</div>'}),define("text!samples/rt-if.code",[],function(){return"var <%= name %> = React.createClass({\n    getInitialState: function () {\n        return {open: false};\n    },\n    toggle: function() {\n        this.setState({open: !this.state.open});\n    },\n    render: <%= name %>RT\n});"}),define("text!samples/rt-if.rt",[],function(){return'<div>\n    <h4 style="cursor:pointer" onClick="()=>this.toggle()">\n        Click to {this.state.open ? \'close\' : \'open\'}\n    </h4>\n    <p rt-if="this.state.open">This is my paragraph. It opens and\n                               closes</p>\n</div>'}),define("text!samples/rt-props.code",[],function(){return"var <%= name %> = React.createClass({\n    mixins: [React.addons.LinkedStateMixin],\n    getInitialState: function() {\n        return { key: 'color', val: 'blue' };\n    },\n    getProps: function() {\n        var ret = { style: {\n          color: 'black',\n          backgroundColor: 'white',\n          borderColor: 'black'\n        }};\n        ret.style[this.state.key] = this.state.val;\n        return ret;\n    },\n    render: <%= name %>RT\n});"}),define("text!samples/rt-props.rt",[],function(){return'<div>\n    Style:\n    <select valueLink="{this.linkState(\'key\')}">\n        <option value="color">Color</option>\n        <option value="backgroundColor">Background color</option>\n        <option value="borderColor">Border color</option>\n    </select><br/>\n    Value:\n    <select valueLink="{this.linkState(\'val\')}">\n        <option value="blue">Blue</option>\n        <option value="red">Red</option>\n        <option value="yellow">Yellow</option>\n    </select><br/><br/>\n    <div style="padding:5px;text-align:center;border:1px solid"\n         rt-props="this.getProps()">Sample</div>\n</div>'}),define("text!samples/rt-repeat.code",[],function(){return"var <%= name %> = React.createClass({\n    getInitialState: function () {\n        return {\n            items: ['One', 'Two', 'Three']\n        };\n    },\n    render: <%= name %>RT\n});"}),define("text!samples/rt-repeat.rt",[],function(){return'<div>\n    <ul>\n        <li rt-repeat="item in this.state.items">{item}</li>\n    </ul>\n</div>'}),define("text!samples/weather.code",[],function(){return"var <%= name %> = React.createClass({\n    mixins: [React.addons.LinkedStateMixin],\n    getInitialState: function() {\n        this.cityIds = [5391959,293397,2643743];\n        this.fetchWeather();\n        return { loading: true, cityToAdd: '', info: [] };\n    },\n    addCity: function() {\n        if (this.state.cityToAdd.trim() == '') {\n            return;\n        }\n        this.setState({ loading: true, cityToAdd: '' });\n        $.get('http://api.openweathermap.org/data/2.5/weather?q=' + this.state.cityToAdd, this.findCityCallback);\n    },\n    findCityCallback: function(result) {\n        if (result.id && !_.contains(this.cityIds, result.id)) {\n            this.cityIds.unshift(result.id);\n            this.fetchWeather();\n        } else {\n            this.setState({ loading: false });\n        }\n    },\n    refresh: function() {\n        this.setState({ loading:true });\n        this.fetchWeather();\n    },\n    fetchWeather: function() {\n       $.get('http://api.openweathermap.org/data/2.5/group?id=' + this.cityIds.join(',') + '&units=metric', this.fetchWeatherCallback);\n    },\n    fetchWeatherCallback: function(result) {\n        this.setState({ loading:false, info: result.list });\n    },\n    render: <%= name %>RT\n});"}),define("text!samples/weather.rt",[],function(){return'<div>\n    <h4>Cities weather report</h4>\n    <input placeholder="Type a city to add"\n           style="width:130px"\n           valueLink="{this.linkState(\'cityToAdd\')}"\n           onKeyDown="(e)=>if (e.keyCode === 13) { e.preventDefault(); this.addCity(); }"/>\n    <button onClick="{this.addCity}">Add</button>\n    <div key="preloader" rt-if="this.state.loading">\n        -- Loading --\n    </div>\n    <div rt-repeat="city in this.state.info" key="{city.id}">\n        {cityIndex+1})\n        <img rt-repeat="weather in city.weather"\n             src="http://openweathermap.org/img/w/{weather.icon}.png"\n             title="{weather.description}"/>\n        <span style="white-space:nowrap">{city.name}, {city.sys.country}</span>\n    </div>\n    <button onClick="{this.refresh}">Refresh</button>\n</div>'}),define("text!samples/rt-require.rt",[],function(){return'<rt-require dependency="comps/myComp" as="myComp"/>\n<rt-require dependency="utils/utils" as="utils"/>\n<div>\n    <myComp customProp="{utils.doSomething()}">myComp is just a regular tag</myComp>\n</div>\n'}),define("examples",["lodash","react","./examples.rt","text!./samples/hello.code","text!./samples/hello.rt","text!./samples/todo.code","text!./samples/todo.rt","text!./samples/rt-if.code","text!./samples/rt-if.rt","text!./samples/rt-props.code","text!./samples/rt-props.rt","text!./samples/rt-repeat.code","text!./samples/rt-repeat.rt","text!./samples/weather.code","text!./samples/weather.rt","text!./samples/rt-require.rt"],function(e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v){var m={hello:[r,i],todo:[s,o],props:[f,l],rtIf:[u,a],repeat:[c,h],weather:[p,d]};Object.keys(m).forEach(function(t){m[t]={name:t,templateProps:e.template(m[t][0],{name:t}),templateHTML:m[t][1]}});var g=t.createClass({displayName:"Examples",mixins:[t.addons.LinkedStateMixin],getInitialState:function(){var e=window.reactTemplates.convertTemplateToReact(v,{modules:"amd",name:"template"}),t=window.reactTemplates.convertTemplateToReact(v,{modules:"commonjs",name:"template"}),n=window.reactTemplates.convertTemplateToReact(v,{modules:"es6",name:"template"});return{rtRequire:{value:v},amd:{value:e},cjs:{value:t},es6:{value:n},samples:m}},render:n});return g}),requirejs.config({paths:{lodash:"//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min",jquery:"//code.jquery.com/jquery-2.1.4.min",firebase:"https://cdn.firebase.com/js/client/2.0.5/firebase",react:"//fb.me/react-with-addons-0.13.3.min",text:"libs/requirejs-plugins/text",json:"libs/requirejs-plugins/json"},shim:{lodash:{exports:"_"},firebase:{exports:"Firebase"},jquery:{exports:"$"},react:{exports:"React"}},map:{"*":{"react/addons":"react"}}}),requirejs(["jquery","react","./examples"],function(e,t,n){var r=t.createElement(n);t.render(r,document.getElementById("home-section"))}),define("home-main.js",function(){});
\ No newline at end of file
diff --git a/playground/dist/rt-main.browser.js b/playground/dist/rt-main.browser.js
index c44164f..8f317a9 100644
--- a/playground/dist/rt-main.browser.js
+++ b/playground/dist/rt-main.browser.js
@@ -55574,6 +55574,10 @@ function convertHtmlToReact(node, context) {
                 data.scopeMapping[boundParam] = boundParam;
             });
             _.each(node.attribs[scopeProp].split(';'), function (scopePart) {
+                if (scopePart.trim().length === 0) {
+                    return;
+                }
+
                 var scopeSubParts = scopePart.split(' as ');
                 if (scopeSubParts.length < 2) {
                     throw RTCodeError.build("invalid scope part '" + scopePart + "'", context, node);
@@ -55630,7 +55634,7 @@ function convertHtmlToReact(node, context) {
         if (node.attribs[templateProp]) {
             data.repeatFunction = generateInjectedFunc(context, 'repeat' + stringUtils.capitalize(data.item), 'return ' + data.body);
             data.repeatBinds = ['this'].concat(_.reject(context.boundParams, function (param) {
-                return (param === data.item || param === data.item + 'Index');
+                return param === data.item || param === data.item + 'Index';
             }));
             data.body = repeatTemplate(data);
         }
@@ -55643,7 +55647,7 @@ function convertHtmlToReact(node, context) {
         }
         return data.body;
     } else if (node.type === 'comment') {
-        return (commentTemplate(node));
+        return commentTemplate(node);
     } else if (node.type === 'text') {
         if (node.data.trim()) {
             return convertText(node, context, node.data);
diff --git a/playground/dist/rt-main.browser.min.js b/playground/dist/rt-main.browser.min.js
index 77805a6..7769358 100644
--- a/playground/dist/rt-main.browser.min.js
+++ b/playground/dist/rt-main.browser.min.js
@@ -15,4 +15,4 @@ forEach:f.forEach,count:f.count,only:z},DOM:m,PropTypes:u,initializeTouchEvents:
 this.topLevelType=null,this.nativeEvent=null,this.ancestors.length=0}}),j.addPoolingTo(e,j.twoArgumentPooler);var q={_enabled:!0,_handleTopLevel:null,WINDOW_HANDLE:i.canUseDOM?window:null,setHandleTopLevel:function(a){q._handleTopLevel=a},setEnabled:function(a){q._enabled=!!a},isEnabled:function(){return q._enabled},trapBubbledEvent:function(a,b,c){var d=c;if(d)return h.listen(d,b,q.dispatchEvent.bind(null,a))},trapCapturedEvent:function(a,b,c){var d=c;if(d)return h.capture(d,b,q.dispatchEvent.bind(null,a))},monitorScrollValue:function(a){var b=g.bind(null,a);h.listen(window,"scroll",b),h.listen(window,"resize",b)},dispatchEvent:function(a,b){if(q._enabled){var c=e.getPooled(a,b);try{m.batchedUpdates(f,c)}finally{e.release(c)}}}};b.exports=q},{"./EventListener":126,"./ExecutionEnvironment":131,"./Object.assign":136,"./PooledClass":137,"./ReactInstanceHandles":170,"./ReactMount":173,"./ReactUpdates":189,"./getEventTarget":227,"./getUnboundedScrollPosition":232}],168:[function(a,b,c){"use strict";var d=a("./DOMProperty"),e=a("./EventPluginHub"),f=a("./ReactComponent"),g=a("./ReactCompositeComponent"),h=a("./ReactEmptyComponent"),i=a("./ReactBrowserEventEmitter"),j=a("./ReactNativeComponent"),k=a("./ReactPerf"),l=a("./ReactRootIndex"),m=a("./ReactUpdates"),n={Component:f.injection,CompositeComponent:g.injection,DOMProperty:d.injection,EmptyComponent:h.injection,EventPluginHub:e.injection,EventEmitter:i.injection,NativeComponent:j.injection,Perf:k.injection,RootIndex:l.injection,Updates:m.injection};b.exports=n},{"./DOMProperty":120,"./EventPluginHub":127,"./ReactBrowserEventEmitter":140,"./ReactComponent":142,"./ReactCompositeComponent":144,"./ReactEmptyComponent":164,"./ReactNativeComponent":176,"./ReactPerf":178,"./ReactRootIndex":185,"./ReactUpdates":189}],169:[function(a,b,c){"use strict";function d(a){return f(document.documentElement,a)}var e=a("./ReactDOMSelection"),f=a("./containsNode"),g=a("./focusNode"),h=a("./getActiveElement"),i={hasSelectionCapabilities:function(a){return a&&("INPUT"===a.nodeName&&"text"===a.type||"TEXTAREA"===a.nodeName||"true"===a.contentEditable)},getSelectionInformation:function(){var a=h();return{focusedElem:a,selectionRange:i.hasSelectionCapabilities(a)?i.getSelection(a):null}},restoreSelection:function(a){var b=h(),c=a.focusedElem,e=a.selectionRange;b!==c&&d(c)&&(i.hasSelectionCapabilities(c)&&i.setSelection(c,e),g(c))},getSelection:function(a){var b;if("selectionStart"in a)b={start:a.selectionStart,end:a.selectionEnd};else if(document.selection&&"INPUT"===a.nodeName){var c=document.selection.createRange();c.parentElement()===a&&(b={start:-c.moveStart("character",-a.value.length),end:-c.moveEnd("character",-a.value.length)})}else b=e.getOffsets(a);return b||{start:0,end:0}},setSelection:function(a,b){var c=b.start,d=b.end;if("undefined"==typeof d&&(d=c),"selectionStart"in a)a.selectionStart=c,a.selectionEnd=Math.min(d,a.value.length);else if(document.selection&&"INPUT"===a.nodeName){var f=a.createTextRange();f.collapse(!0),f.moveStart("character",c),f.moveEnd("character",d-c),f.select()}else e.setOffsets(a,b)}};b.exports=i},{"./ReactDOMSelection":156,"./containsNode":211,"./focusNode":221,"./getActiveElement":223}],170:[function(a,b,c){(function(c){"use strict";function d(a){return n+a.toString(36)}function e(a,b){return a.charAt(b)===n||b===a.length}function f(a){return""===a||a.charAt(0)===n&&a.charAt(a.length-1)!==n}function g(a,b){return 0===b.indexOf(a)&&e(b,a.length)}function h(a){return a?a.substr(0,a.lastIndexOf(n)):""}function i(a,b){if("production"!==c.env.NODE_ENV?m(f(a)&&f(b),"getNextDescendantID(%s, %s): Received an invalid React DOM ID.",a,b):m(f(a)&&f(b)),"production"!==c.env.NODE_ENV?m(g(a,b),"getNextDescendantID(...): React has made an invalid assumption about the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.",a,b):m(g(a,b)),a===b)return a;for(var d=a.length+o,h=d;h<b.length&&!e(b,h);h++);return b.substr(0,h)}function j(a,b){var d=Math.min(a.length,b.length);if(0===d)return"";for(var g=0,h=0;d>=h;h++)if(e(a,h)&&e(b,h))g=h;else if(a.charAt(h)!==b.charAt(h))break;var i=a.substr(0,g);return"production"!==c.env.NODE_ENV?m(f(i),"getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s",a,b,i):m(f(i)),i}function k(a,b,d,e,f,j){a=a||"",b=b||"","production"!==c.env.NODE_ENV?m(a!==b,"traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.",a):m(a!==b);var k=g(b,a);"production"!==c.env.NODE_ENV?m(k||g(a,b),"traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do not have a parent path.",a,b):m(k||g(a,b));for(var l=0,n=k?h:i,o=a;;o=n(o,b)){var q;if(f&&o===a||j&&o===b||(q=d(o,k,e)),q===!1||o===b)break;"production"!==c.env.NODE_ENV?m(l++<p,"traverseParentPath(%s, %s, ...): Detected an infinite loop while traversing the React DOM ID tree. This may be due to malformed IDs: %s",a,b):m(l++<p)}}var l=a("./ReactRootIndex"),m=a("./invariant"),n=".",o=n.length,p=100,q={createReactRootID:function(){return d(l.createReactRootIndex())},createReactID:function(a,b){return a+b},getReactRootIDFromNodeID:function(a){if(a&&a.charAt(0)===n&&a.length>1){var b=a.indexOf(n,1);return b>-1?a.substr(0,b):a}return null},traverseEnterLeave:function(a,b,c,d,e){var f=j(a,b);f!==a&&k(a,f,c,d,!1,!0),f!==b&&k(f,b,c,e,!0,!1)},traverseTwoPhase:function(a,b,c){a&&(k("",a,b,c,!0,!1),k(a,"",b,c,!1,!0))},traverseAncestors:function(a,b,c){k("",a,b,c,!0,!1)},_getFirstCommonAncestorID:j,_getNextDescendantID:i,isAncestorIDOf:g,SEPARATOR:n};b.exports=q}).call(this,a("_process"))},{"./ReactRootIndex":185,"./invariant":236,_process:94}],171:[function(a,b,c){(function(c){"use strict";function d(){if(o._isLegacyCallWarningEnabled){var a=h.current,b=a&&a.constructor?a.constructor.displayName:"";b||(b="Something"),l.hasOwnProperty(b)||(l[b]=!0,"production"!==c.env.NODE_ENV?k(!1,b+" is calling a React component directly. Use a factory or JSX instead. See: http://fb.me/react-legacyfactory"):null,j("react_legacy_factory_call",{version:3,name:b}))}}function e(a){var b=a.prototype&&"function"==typeof a.prototype.mountComponent&&"function"==typeof a.prototype.receiveComponent;if(b)"production"!==c.env.NODE_ENV?k(!1,"Did not expect to get a React class here. Use `Component` instead of `Component.type` or `this.constructor`."):null;else{if(!a._reactWarnedForThisType){try{a._reactWarnedForThisType=!0}catch(d){}j("react_non_component_in_jsx",{version:3,name:a.name})}"production"!==c.env.NODE_ENV?k(!1,"This JSX uses a plain function. Only React components are valid in React's JSX transform."):null}}function f(a){"production"!==c.env.NODE_ENV?k(!1,"Do not pass React.DOM."+a.type+' to JSX or createFactory. Use the string "'+a.type+'" instead.'):null}function g(a,b){if("function"==typeof b)for(var c in b)if(b.hasOwnProperty(c)){var d=b[c];if("function"==typeof d){var e=d.bind(b);for(var f in d)d.hasOwnProperty(f)&&(e[f]=d[f]);a[c]=e}else a[c]=d}}var h=a("./ReactCurrentOwner"),i=a("./invariant"),j=a("./monitorCodeUse"),k=a("./warning"),l={},m={},n={},o={};o.wrapCreateFactory=function(a){var b=function(b){return"function"!=typeof b?a(b):b.isReactNonLegacyFactory?("production"!==c.env.NODE_ENV&&f(b),a(b.type)):b.isReactLegacyFactory?a(b.type):("production"!==c.env.NODE_ENV&&e(b),b)};return b},o.wrapCreateElement=function(a){var b=function(b,d,g){if("function"!=typeof b)return a.apply(this,arguments);var h;return b.isReactNonLegacyFactory?("production"!==c.env.NODE_ENV&&f(b),h=Array.prototype.slice.call(arguments,0),h[0]=b.type,a.apply(this,h)):b.isReactLegacyFactory?(b._isMockFunction&&(b.type._mockedReactClassConstructor=b),h=Array.prototype.slice.call(arguments,0),h[0]=b.type,a.apply(this,h)):("production"!==c.env.NODE_ENV&&e(b),b.apply(null,Array.prototype.slice.call(arguments,1)))};return b},o.wrapFactory=function(a){"production"!==c.env.NODE_ENV?i("function"==typeof a,"This is suppose to accept a element factory"):i("function"==typeof a);var b=function(b,e){return"production"!==c.env.NODE_ENV&&d(),a.apply(this,arguments)};return g(b,a.type),b.isReactLegacyFactory=m,b.type=a.type,b},o.markNonLegacyFactory=function(a){return a.isReactNonLegacyFactory=n,a},o.isValidFactory=function(a){return"function"==typeof a&&a.isReactLegacyFactory===m},o.isValidClass=function(a){return"production"!==c.env.NODE_ENV&&("production"!==c.env.NODE_ENV?k(!1,"isValidClass is deprecated and will be removed in a future release. Use a more specific validator instead."):null),o.isValidFactory(a)},o._isLegacyCallWarningEnabled=!0,b.exports=o}).call(this,a("_process"))},{"./ReactCurrentOwner":146,"./invariant":236,"./monitorCodeUse":246,"./warning":255,_process:94}],172:[function(a,b,c){"use strict";var d=a("./adler32"),e={CHECKSUM_ATTR_NAME:"data-react-checksum",addChecksumToMarkup:function(a){var b=d(a);return a.replace(">"," "+e.CHECKSUM_ATTR_NAME+'="'+b+'">')},canReuseMarkup:function(a,b){var c=b.getAttribute(e.CHECKSUM_ATTR_NAME);c=c&&parseInt(c,10);var f=d(a);return f===c}};b.exports=e},{"./adler32":208}],173:[function(a,b,c){(function(c){"use strict";function d(a){var b=v(a);return b&&L.getID(b)}function e(a){var b=f(a);if(b)if(D.hasOwnProperty(b)){var d=D[b];d!==a&&("production"!==c.env.NODE_ENV?x(!i(d,b),"ReactMount: Two valid but unequal nodes with the same `%s`: %s",C,b):x(!i(d,b)),D[b]=a)}else D[b]=a;return b}function f(a){return a&&a.getAttribute&&a.getAttribute(C)||""}function g(a,b){var c=f(a);c!==b&&delete D[c],a.setAttribute(C,b),D[b]=a}function h(a){return D.hasOwnProperty(a)&&i(D[a],a)||(D[a]=L.findReactNodeByID(a)),D[a]}function i(a,b){if(a){"production"!==c.env.NODE_ENV?x(f(a)===b,"ReactMount: Unexpected modification of `%s`",C):x(f(a)===b);var d=L.findReactContainerForID(b);if(d&&t(d,a))return!0}return!1}function j(a){delete D[a]}function k(a){var b=D[a];return b&&i(b,a)?void(K=b):!1}function l(a){K=null,r.traverseAncestors(a,k);var b=K;return K=null,b}var m=a("./DOMProperty"),n=a("./ReactBrowserEventEmitter"),o=a("./ReactCurrentOwner"),p=a("./ReactElement"),q=a("./ReactLegacyElement"),r=a("./ReactInstanceHandles"),s=a("./ReactPerf"),t=a("./containsNode"),u=a("./deprecated"),v=a("./getReactRootElementInContainer"),w=a("./instantiateReactComponent"),x=a("./invariant"),y=a("./shouldUpdateReactComponent"),z=a("./warning"),A=q.wrapCreateElement(p.createElement),B=r.SEPARATOR,C=m.ID_ATTRIBUTE_NAME,D={},E=1,F=9,G={},H={};if("production"!==c.env.NODE_ENV)var I={};var J=[],K=null,L={_instancesByReactRootID:G,scrollMonitor:function(a,b){b()},_updateRootComponent:function(a,b,e,f){var g=b.props;return L.scrollMonitor(e,function(){a.replaceProps(g,f)}),"production"!==c.env.NODE_ENV&&(I[d(e)]=v(e)),a},_registerComponent:function(a,b){"production"!==c.env.NODE_ENV?x(b&&(b.nodeType===E||b.nodeType===F),"_registerComponent(...): Target container is not a DOM element."):x(b&&(b.nodeType===E||b.nodeType===F)),n.ensureScrollValueMonitoring();var d=L.registerContainer(b);return G[d]=a,d},_renderNewRootComponent:s.measure("ReactMount","_renderNewRootComponent",function(a,b,d){"production"!==c.env.NODE_ENV?z(null==o.current,"_renderNewRootComponent(): Render methods should be a pure function of props and state; triggering nested component updates from render is not allowed. If necessary, trigger nested updates in componentDidUpdate."):null;var e=w(a,null),f=L._registerComponent(e,b);return e.mountComponentIntoNode(f,b,d),"production"!==c.env.NODE_ENV&&(I[f]=v(b)),e}),render:function(a,b,e){"production"!==c.env.NODE_ENV?x(p.isValidElement(a),"renderComponent(): Invalid component element.%s","string"==typeof a?" Instead of passing an element string, make sure to instantiate it by passing it to React.createElement.":q.isValidFactory(a)?" Instead of passing a component class, make sure to instantiate it by passing it to React.createElement.":"undefined"!=typeof a.props?" This may be caused by unintentionally loading two independent copies of React.":""):x(p.isValidElement(a));var f=G[d(b)];if(f){var g=f._currentElement;if(y(g,a))return L._updateRootComponent(f,a,b,e);L.unmountComponentAtNode(b)}var h=v(b),i=h&&L.isRenderedByReact(h),j=i&&!f,k=L._renderNewRootComponent(a,b,j);return e&&e.call(k),k},constructAndRenderComponent:function(a,b,c){var d=A(a,b);return L.render(d,c)},constructAndRenderComponentByID:function(a,b,d){var e=document.getElementById(d);return"production"!==c.env.NODE_ENV?x(e,'Tried to get element with id of "%s" but it is not present on the page.',d):x(e),L.constructAndRenderComponent(a,b,e)},registerContainer:function(a){var b=d(a);return b&&(b=r.getReactRootIDFromNodeID(b)),b||(b=r.createReactRootID()),H[b]=a,b},unmountComponentAtNode:function(a){"production"!==c.env.NODE_ENV?z(null==o.current,"unmountComponentAtNode(): Render methods should be a pure function of props and state; triggering nested component updates from render is not allowed. If necessary, trigger nested updates in componentDidUpdate."):null;var b=d(a),e=G[b];return e?(L.unmountComponentFromNode(e,a),delete G[b],delete H[b],"production"!==c.env.NODE_ENV&&delete I[b],!0):!1},unmountComponentFromNode:function(a,b){for(a.unmountComponent(),b.nodeType===F&&(b=b.documentElement);b.lastChild;)b.removeChild(b.lastChild)},findReactContainerForID:function(a){var b=r.getReactRootIDFromNodeID(a),d=H[b];if("production"!==c.env.NODE_ENV){var e=I[b];if(e&&e.parentNode!==d){"production"!==c.env.NODE_ENV?x(f(e)===b,"ReactMount: Root element ID differed from reactRootID."):x(f(e)===b);var g=d.firstChild;g&&b===f(g)?I[b]=g:console.warn("ReactMount: Root element has been removed from its original container. New container:",e.parentNode)}}return d},findReactNodeByID:function(a){var b=L.findReactContainerForID(a);return L.findComponentRoot(b,a)},isRenderedByReact:function(a){if(1!==a.nodeType)return!1;var b=L.getID(a);return b?b.charAt(0)===B:!1},getFirstReactDOM:function(a){for(var b=a;b&&b.parentNode!==b;){if(L.isRenderedByReact(b))return b;b=b.parentNode}return null},findComponentRoot:function(a,b){var d=J,e=0,f=l(b)||a;for(d[0]=f.firstChild,d.length=1;e<d.length;){for(var g,h=d[e++];h;){var i=L.getID(h);i?b===i?g=h:r.isAncestorIDOf(i,b)&&(d.length=e=0,d.push(h.firstChild)):d.push(h.firstChild),h=h.nextSibling}if(g)return d.length=0,g}d.length=0,"production"!==c.env.NODE_ENV?x(!1,"findComponentRoot(..., %s): Unable to find element. This probably means the DOM was unexpectedly mutated (e.g., by the browser), usually due to forgetting a <tbody> when using tables, nesting tags like <form>, <p>, or <a>, or using non-SVG elements in an <svg> parent. Try inspecting the child nodes of the element with React ID `%s`.",b,L.getID(a)):x(!1)},getReactRootID:d,getID:e,setID:g,getNode:h,purgeID:j};L.renderComponent=u("ReactMount","renderComponent","render",this,L.render),b.exports=L}).call(this,a("_process"))},{"./DOMProperty":120,"./ReactBrowserEventEmitter":140,"./ReactCurrentOwner":146,"./ReactElement":162,"./ReactInstanceHandles":170,"./ReactLegacyElement":171,"./ReactPerf":178,"./containsNode":211,"./deprecated":216,"./getReactRootElementInContainer":230,"./instantiateReactComponent":235,"./invariant":236,"./shouldUpdateReactComponent":252,"./warning":255,_process:94}],174:[function(a,b,c){"use strict";function d(a,b,c){p.push({parentID:a,parentNode:null,type:k.INSERT_MARKUP,markupIndex:q.push(b)-1,textContent:null,fromIndex:null,toIndex:c})}function e(a,b,c){p.push({parentID:a,parentNode:null,type:k.MOVE_EXISTING,markupIndex:null,textContent:null,fromIndex:b,toIndex:c})}function f(a,b){p.push({parentID:a,parentNode:null,type:k.REMOVE_NODE,markupIndex:null,textContent:null,fromIndex:b,toIndex:null})}function g(a,b){p.push({parentID:a,parentNode:null,type:k.TEXT_CONTENT,markupIndex:null,textContent:b,fromIndex:null,toIndex:null})}function h(){p.length&&(j.BackendIDOperations.dangerouslyProcessChildrenUpdates(p,q),i())}function i(){p.length=0,q.length=0}var j=a("./ReactComponent"),k=a("./ReactMultiChildUpdateTypes"),l=a("./flattenChildren"),m=a("./instantiateReactComponent"),n=a("./shouldUpdateReactComponent"),o=0,p=[],q=[],r={Mixin:{mountChildren:function(a,b){var c=l(a),d=[],e=0;this._renderedChildren=c;for(var f in c){var g=c[f];if(c.hasOwnProperty(f)){var h=m(g,null);c[f]=h;var i=this._rootNodeID+f,j=h.mountComponent(i,b,this._mountDepth+1);h._mountIndex=e,d.push(j),e++}}return d},updateTextContent:function(a){o++;var b=!0;try{var c=this._renderedChildren;for(var d in c)c.hasOwnProperty(d)&&this._unmountChildByName(c[d],d);this.setTextContent(a),b=!1}finally{o--,o||(b?i():h())}},updateChildren:function(a,b){o++;var c=!0;try{this._updateChildren(a,b),c=!1}finally{o--,o||(c?i():h())}},_updateChildren:function(a,b){var c=l(a),d=this._renderedChildren;if(c||d){var e,f=0,g=0;for(e in c)if(c.hasOwnProperty(e)){var h=d&&d[e],i=h&&h._currentElement,j=c[e];if(n(i,j))this.moveChild(h,g,f),f=Math.max(h._mountIndex,f),h.receiveComponent(j,b),h._mountIndex=g;else{h&&(f=Math.max(h._mountIndex,f),this._unmountChildByName(h,e));var k=m(j,null);this._mountChildByNameAtIndex(k,e,g,b)}g++}for(e in d)!d.hasOwnProperty(e)||c&&c[e]||this._unmountChildByName(d[e],e)}},unmountChildren:function(){var a=this._renderedChildren;for(var b in a){var c=a[b];c.unmountComponent&&c.unmountComponent()}this._renderedChildren=null},moveChild:function(a,b,c){a._mountIndex<c&&e(this._rootNodeID,a._mountIndex,b)},createChild:function(a,b){d(this._rootNodeID,b,a._mountIndex)},removeChild:function(a){f(this._rootNodeID,a._mountIndex)},setTextContent:function(a){g(this._rootNodeID,a)},_mountChildByNameAtIndex:function(a,b,c,d){var e=this._rootNodeID+b,f=a.mountComponent(e,d,this._mountDepth+1);a._mountIndex=c,this.createChild(a,f),this._renderedChildren=this._renderedChildren||{},this._renderedChildren[b]=a},_unmountChildByName:function(a,b){this.removeChild(a),a._mountIndex=null,a.unmountComponent(),delete this._renderedChildren[b]}}};b.exports=r},{"./ReactComponent":142,"./ReactMultiChildUpdateTypes":175,"./flattenChildren":220,"./instantiateReactComponent":235,"./shouldUpdateReactComponent":252}],175:[function(a,b,c){"use strict";var d=a("./keyMirror"),e=d({INSERT_MARKUP:null,MOVE_EXISTING:null,REMOVE_NODE:null,TEXT_CONTENT:null});b.exports=e},{"./keyMirror":242}],176:[function(a,b,c){(function(c){"use strict";function d(a,b,d){var e=h[a];return null==e?("production"!==c.env.NODE_ENV?f(g,"There is no registered component for the tag %s",a):f(g),new g(a,b)):d===a?("production"!==c.env.NODE_ENV?f(g,"There is no registered component for the tag %s",a):f(g),new g(a,b)):new e.type(b)}var e=a("./Object.assign"),f=a("./invariant"),g=null,h={},i={injectGenericComponentClass:function(a){g=a},injectComponentClasses:function(a){e(h,a)}},j={createInstanceForTag:d,injection:i};b.exports=j}).call(this,a("_process"))},{"./Object.assign":136,"./invariant":236,_process:94}],177:[function(a,b,c){(function(c){"use strict";var d=a("./emptyObject"),e=a("./invariant"),f={isValidOwner:function(a){return!(!a||"function"!=typeof a.attachRef||"function"!=typeof a.detachRef)},addComponentAsRefTo:function(a,b,d){"production"!==c.env.NODE_ENV?e(f.isValidOwner(d),"addComponentAsRefTo(...): Only a ReactOwner can have refs. This usually means that you're trying to add a ref to a component that doesn't have an owner (that is, was not created inside of another component's `render` method). Try rendering this component inside of a new top-level component which will hold the ref."):e(f.isValidOwner(d)),d.attachRef(b,a)},removeComponentAsRefFrom:function(a,b,d){"production"!==c.env.NODE_ENV?e(f.isValidOwner(d),"removeComponentAsRefFrom(...): Only a ReactOwner can have refs. This usually means that you're trying to remove a ref to a component that doesn't have an owner (that is, was not created inside of another component's `render` method). Try rendering this component inside of a new top-level component which will hold the ref."):e(f.isValidOwner(d)),d.refs[b]===a&&d.detachRef(b)},Mixin:{construct:function(){this.refs=d},attachRef:function(a,b){"production"!==c.env.NODE_ENV?e(b.isOwnedBy(this),"attachRef(%s, ...): Only a component's owner can store a ref to it.",a):e(b.isOwnedBy(this));var f=this.refs===d?this.refs={}:this.refs;f[a]=b},detachRef:function(a){delete this.refs[a]}}};b.exports=f}).call(this,a("_process"))},{"./emptyObject":218,"./invariant":236,_process:94}],178:[function(a,b,c){(function(a){"use strict";function c(a,b,c){return c}var d={enableMeasure:!1,storedMeasure:c,measure:function(b,c,e){if("production"!==a.env.NODE_ENV){var f=null,g=function(){return d.enableMeasure?(f||(f=d.storedMeasure(b,c,e)),f.apply(this,arguments)):e.apply(this,arguments)};return g.displayName=b+"_"+c,g}return e},injection:{injectMeasure:function(a){d.storedMeasure=a}}};b.exports=d}).call(this,a("_process"))},{_process:94}],179:[function(a,b,c){(function(c){"use strict";function d(a){return function(b,c,d){b.hasOwnProperty(c)?b[c]=a(b[c],d):b[c]=d}}function e(a,b){for(var c in b)if(b.hasOwnProperty(c)){var d=m[c];d&&m.hasOwnProperty(c)?d(a,c,b[c]):a.hasOwnProperty(c)||(a[c]=b[c])}return a}var f=a("./Object.assign"),g=a("./emptyFunction"),h=a("./invariant"),i=a("./joinClasses"),j=a("./warning"),k=!1,l=d(function(a,b){return f({},b,a)}),m={children:g,className:d(i),style:l},n={TransferStrategies:m,mergeProps:function(a,b){return e(f({},a),b)},Mixin:{transferPropsTo:function(a){return"production"!==c.env.NODE_ENV?h(a._owner===this,"%s: You can't call transferPropsTo() on a component that you don't own, %s. This usually means you are calling transferPropsTo() on a component passed in as props or children.",this.constructor.displayName,"string"==typeof a.type?a.type:a.type.displayName):h(a._owner===this),"production"!==c.env.NODE_ENV&&(k||(k=!0,"production"!==c.env.NODE_ENV?j(!1,"transferPropsTo is deprecated. See http://fb.me/react-transferpropsto for more information."):null)),e(a.props,this.props),a}}};b.exports=n}).call(this,a("_process"))},{"./Object.assign":136,"./emptyFunction":217,"./invariant":236,"./joinClasses":241,"./warning":255,_process:94}],180:[function(a,b,c){(function(a){"use strict";var c={};"production"!==a.env.NODE_ENV&&(c={prop:"prop",context:"context",childContext:"child context"}),b.exports=c}).call(this,a("_process"))},{_process:94}],181:[function(a,b,c){"use strict";var d=a("./keyMirror"),e=d({prop:null,context:null,childContext:null});b.exports=e},{"./keyMirror":242}],182:[function(a,b,c){"use strict";function d(a){function b(b,c,d,e,f){if(e=e||v,null!=c[d])return a(c,d,e,f);var g=s[f];return b?new Error("Required "+g+" `"+d+"` was not specified in "+("`"+e+"`.")):void 0}var c=b.bind(null,!1);return c.isRequired=b.bind(null,!0),c}function e(a){function b(b,c,d,e){var f=b[c],g=p(f);if(g!==a){var h=s[e],i=q(f);return new Error("Invalid "+h+" `"+c+"` of type `"+i+"` "+("supplied to `"+d+"`, expected `"+a+"`."))}}return d(b)}function f(){return d(u.thatReturns())}function g(a){function b(b,c,d,e){var f=b[c];if(!Array.isArray(f)){var g=s[e],h=p(f);return new Error("Invalid "+g+" `"+c+"` of type "+("`"+h+"` supplied to `"+d+"`, expected an array."))}for(var i=0;i<f.length;i++){var j=a(f,i,d,e);if(j instanceof Error)return j}}return d(b)}function h(){function a(a,b,c,d){if(!r.isValidElement(a[b])){var e=s[d];return new Error("Invalid "+e+" `"+b+"` supplied to "+("`"+c+"`, expected a ReactElement."))}}return d(a)}function i(a){function b(b,c,d,e){if(!(b[c]instanceof a)){var f=s[e],g=a.name||v;return new Error("Invalid "+f+" `"+c+"` supplied to "+("`"+d+"`, expected instance of `"+g+"`."))}}return d(b)}function j(a){function b(b,c,d,e){for(var f=b[c],g=0;g<a.length;g++)if(f===a[g])return;var h=s[e],i=JSON.stringify(a);return new Error("Invalid "+h+" `"+c+"` of value `"+f+"` "+("supplied to `"+d+"`, expected one of "+i+"."))}return d(b)}function k(a){function b(b,c,d,e){var f=b[c],g=p(f);if("object"!==g){var h=s[e];return new Error("Invalid "+h+" `"+c+"` of type "+("`"+g+"` supplied to `"+d+"`, expected an object."))}for(var i in f)if(f.hasOwnProperty(i)){var j=a(f,i,d,e);if(j instanceof Error)return j}}return d(b)}function l(a){function b(b,c,d,e){for(var f=0;f<a.length;f++){var g=a[f];if(null==g(b,c,d,e))return}var h=s[e];return new Error("Invalid "+h+" `"+c+"` supplied to "+("`"+d+"`."))}return d(b)}function m(){function a(a,b,c,d){if(!o(a[b])){var e=s[d];return new Error("Invalid "+e+" `"+b+"` supplied to "+("`"+c+"`, expected a ReactNode."))}}return d(a)}function n(a){function b(b,c,d,e){var f=b[c],g=p(f);if("object"!==g){var h=s[e];return new Error("Invalid "+h+" `"+c+"` of type `"+g+"` "+("supplied to `"+d+"`, expected `object`."))}for(var i in a){var j=a[i];if(j){var k=j(f,i,d,e);if(k)return k}}}return d(b,"expected `object`")}function o(a){switch(typeof a){case"number":case"string":return!0;case"boolean":return!a;case"object":if(Array.isArray(a))return a.every(o);if(r.isValidElement(a))return!0;for(var b in a)if(!o(a[b]))return!1;return!0;default:return!1}}function p(a){var b=typeof a;return Array.isArray(a)?"array":a instanceof RegExp?"object":b}function q(a){var b=p(a);if("object"===b){if(a instanceof Date)return"date";if(a instanceof RegExp)return"regexp"}return b}var r=a("./ReactElement"),s=a("./ReactPropTypeLocationNames"),t=a("./deprecated"),u=a("./emptyFunction"),v="<<anonymous>>",w=h(),x=m(),y={array:e("array"),bool:e("boolean"),func:e("function"),number:e("number"),object:e("object"),string:e("string"),any:f(),arrayOf:g,element:w,instanceOf:i,node:x,objectOf:k,oneOf:j,oneOfType:l,shape:n,component:t("React.PropTypes","component","element",this,w),renderable:t("React.PropTypes","renderable","node",this,x)};b.exports=y},{"./ReactElement":162,"./ReactPropTypeLocationNames":180,"./deprecated":216,"./emptyFunction":217}],183:[function(a,b,c){"use strict";function d(){this.listenersToPut=[]}var e=a("./PooledClass"),f=a("./ReactBrowserEventEmitter"),g=a("./Object.assign");g(d.prototype,{enqueuePutListener:function(a,b,c){this.listenersToPut.push({rootNodeID:a,propKey:b,propValue:c})},putListeners:function(){for(var a=0;a<this.listenersToPut.length;a++){var b=this.listenersToPut[a];f.putListener(b.rootNodeID,b.propKey,b.propValue)}},reset:function(){this.listenersToPut.length=0},destructor:function(){this.reset()}}),e.addPoolingTo(d),b.exports=d},{"./Object.assign":136,"./PooledClass":137,"./ReactBrowserEventEmitter":140}],184:[function(a,b,c){"use strict";function d(){this.reinitializeTransaction(),this.renderToStaticMarkup=!1,this.reactMountReady=e.getPooled(null),this.putListenerQueue=i.getPooled()}var e=a("./CallbackQueue"),f=a("./PooledClass"),g=a("./ReactBrowserEventEmitter"),h=a("./ReactInputSelection"),i=a("./ReactPutListenerQueue"),j=a("./Transaction"),k=a("./Object.assign"),l={initialize:h.getSelectionInformation,close:h.restoreSelection},m={initialize:function(){var a=g.isEnabled();return g.setEnabled(!1),a},close:function(a){g.setEnabled(a)}},n={initialize:function(){this.reactMountReady.reset()},close:function(){this.reactMountReady.notifyAll()}},o={initialize:function(){this.putListenerQueue.reset()},close:function(){this.putListenerQueue.putListeners()}},p=[o,l,m,n],q={getTransactionWrappers:function(){return p},getReactMountReady:function(){return this.reactMountReady},getPutListenerQueue:function(){return this.putListenerQueue},destructor:function(){e.release(this.reactMountReady),this.reactMountReady=null,i.release(this.putListenerQueue),this.putListenerQueue=null}};k(d.prototype,j.Mixin,q),f.addPoolingTo(d),b.exports=d},{"./CallbackQueue":115,"./Object.assign":136,"./PooledClass":137,"./ReactBrowserEventEmitter":140,"./ReactInputSelection":169,"./ReactPutListenerQueue":183,"./Transaction":205}],185:[function(a,b,c){"use strict";var d={injectCreateReactRootIndex:function(a){e.createReactRootIndex=a}},e={createReactRootIndex:null,injection:d};b.exports=e},{}],186:[function(a,b,c){(function(c){"use strict";function d(a){"production"!==c.env.NODE_ENV?k(f.isValidElement(a),"renderToString(): You must pass a valid ReactElement."):k(f.isValidElement(a));var b;try{var d=g.createReactRootID();return b=i.getPooled(!1),b.perform(function(){var c=j(a,null),e=c.mountComponent(d,b,0);return h.addChecksumToMarkup(e)},null)}finally{i.release(b)}}function e(a){"production"!==c.env.NODE_ENV?k(f.isValidElement(a),"renderToStaticMarkup(): You must pass a valid ReactElement."):k(f.isValidElement(a));var b;try{var d=g.createReactRootID();return b=i.getPooled(!0),b.perform(function(){var c=j(a,null);return c.mountComponent(d,b,0)},null)}finally{i.release(b)}}var f=a("./ReactElement"),g=a("./ReactInstanceHandles"),h=a("./ReactMarkupChecksum"),i=a("./ReactServerRenderingTransaction"),j=a("./instantiateReactComponent"),k=a("./invariant");b.exports={renderToString:d,renderToStaticMarkup:e}}).call(this,a("_process"))},{"./ReactElement":162,"./ReactInstanceHandles":170,"./ReactMarkupChecksum":172,"./ReactServerRenderingTransaction":187,"./instantiateReactComponent":235,"./invariant":236,_process:94}],187:[function(a,b,c){"use strict";function d(a){this.reinitializeTransaction(),this.renderToStaticMarkup=a,this.reactMountReady=f.getPooled(null),this.putListenerQueue=g.getPooled()}var e=a("./PooledClass"),f=a("./CallbackQueue"),g=a("./ReactPutListenerQueue"),h=a("./Transaction"),i=a("./Object.assign"),j=a("./emptyFunction"),k={initialize:function(){this.reactMountReady.reset()},close:j},l={initialize:function(){this.putListenerQueue.reset()},close:j},m=[l,k],n={getTransactionWrappers:function(){return m},getReactMountReady:function(){return this.reactMountReady},getPutListenerQueue:function(){return this.putListenerQueue},destructor:function(){f.release(this.reactMountReady),this.reactMountReady=null,g.release(this.putListenerQueue),this.putListenerQueue=null}};i(d.prototype,h.Mixin,n),e.addPoolingTo(d),b.exports=d},{"./CallbackQueue":115,"./Object.assign":136,"./PooledClass":137,"./ReactPutListenerQueue":183,"./Transaction":205,"./emptyFunction":217}],188:[function(a,b,c){"use strict";var d=a("./DOMPropertyOperations"),e=a("./ReactComponent"),f=a("./ReactElement"),g=a("./Object.assign"),h=a("./escapeTextForBrowser"),i=function(a){};g(i.prototype,e.Mixin,{mountComponent:function(a,b,c){e.Mixin.mountComponent.call(this,a,b,c);var f=h(this.props);return b.renderToStaticMarkup?f:"<span "+d.createMarkupForID(a)+">"+f+"</span>"},receiveComponent:function(a,b){var c=a.props;c!==this.props&&(this.props=c,e.BackendIDOperations.updateTextContentByID(this._rootNodeID,c))}});var j=function(a){return new f(i,null,null,null,null,a)};j.type=i,b.exports=j},{"./DOMPropertyOperations":121,"./Object.assign":136,"./ReactComponent":142,"./ReactElement":162,"./escapeTextForBrowser":219}],189:[function(a,b,c){(function(c){"use strict";function d(){"production"!==c.env.NODE_ENV?q(B.ReactReconcileTransaction&&v,"ReactUpdates: must inject a reconcile transaction class and batching strategy"):q(B.ReactReconcileTransaction&&v)}function e(){this.reinitializeTransaction(),this.dirtyComponentsLength=null,this.callbackQueue=k.getPooled(),this.reconcileTransaction=B.ReactReconcileTransaction.getPooled()}function f(a,b,c){d(),v.batchedUpdates(a,b,c)}function g(a,b){return a._mountDepth-b._mountDepth}function h(a){var b=a.dirtyComponentsLength;"production"!==c.env.NODE_ENV?q(b===s.length,"Expected flush transaction's stored dirty-components length (%s) to match dirty-components array length (%s).",b,s.length):q(b===s.length),s.sort(g);for(var d=0;b>d;d++){var e=s[d];if(e.isMounted()){var f=e._pendingCallbacks;if(e._pendingCallbacks=null,e.performUpdateIfNecessary(a.reconcileTransaction),f)for(var h=0;h<f.length;h++)a.callbackQueue.enqueue(f[h],e)}}}function i(a,b){return"production"!==c.env.NODE_ENV?q(!b||"function"==typeof b,"enqueueUpdate(...): You called `setProps`, `replaceProps`, `setState`, `replaceState`, or `forceUpdate` with a callback that isn't callable."):q(!b||"function"==typeof b),d(),"production"!==c.env.NODE_ENV?r(null==m.current,"enqueueUpdate(): Render methods should be a pure function of props and state; triggering nested component updates from render is not allowed. If necessary, trigger nested updates in componentDidUpdate."):null,
 v.isBatchingUpdates?(s.push(a),void(b&&(a._pendingCallbacks?a._pendingCallbacks.push(b):a._pendingCallbacks=[b]))):void v.batchedUpdates(i,a,b)}function j(a,b){"production"!==c.env.NODE_ENV?q(v.isBatchingUpdates,"ReactUpdates.asap: Can't enqueue an asap callback in a context whereupdates are not being batched."):q(v.isBatchingUpdates),t.enqueue(a,b),u=!0}var k=a("./CallbackQueue"),l=a("./PooledClass"),m=a("./ReactCurrentOwner"),n=a("./ReactPerf"),o=a("./Transaction"),p=a("./Object.assign"),q=a("./invariant"),r=a("./warning"),s=[],t=k.getPooled(),u=!1,v=null,w={initialize:function(){this.dirtyComponentsLength=s.length},close:function(){this.dirtyComponentsLength!==s.length?(s.splice(0,this.dirtyComponentsLength),z()):s.length=0}},x={initialize:function(){this.callbackQueue.reset()},close:function(){this.callbackQueue.notifyAll()}},y=[w,x];p(e.prototype,o.Mixin,{getTransactionWrappers:function(){return y},destructor:function(){this.dirtyComponentsLength=null,k.release(this.callbackQueue),this.callbackQueue=null,B.ReactReconcileTransaction.release(this.reconcileTransaction),this.reconcileTransaction=null},perform:function(a,b,c){return o.Mixin.perform.call(this,this.reconcileTransaction.perform,this.reconcileTransaction,a,b,c)}}),l.addPoolingTo(e);var z=n.measure("ReactUpdates","flushBatchedUpdates",function(){for(;s.length||u;){if(s.length){var a=e.getPooled();a.perform(h,null,a),e.release(a)}if(u){u=!1;var b=t;t=k.getPooled(),b.notifyAll(),k.release(b)}}}),A={injectReconcileTransaction:function(a){"production"!==c.env.NODE_ENV?q(a,"ReactUpdates: must provide a reconcile transaction class"):q(a),B.ReactReconcileTransaction=a},injectBatchingStrategy:function(a){"production"!==c.env.NODE_ENV?q(a,"ReactUpdates: must provide a batching strategy"):q(a),"production"!==c.env.NODE_ENV?q("function"==typeof a.batchedUpdates,"ReactUpdates: must provide a batchedUpdates() function"):q("function"==typeof a.batchedUpdates),"production"!==c.env.NODE_ENV?q("boolean"==typeof a.isBatchingUpdates,"ReactUpdates: must provide an isBatchingUpdates boolean attribute"):q("boolean"==typeof a.isBatchingUpdates),v=a}},B={ReactReconcileTransaction:null,batchedUpdates:f,enqueueUpdate:i,flushBatchedUpdates:z,injection:A,asap:j};b.exports=B}).call(this,a("_process"))},{"./CallbackQueue":115,"./Object.assign":136,"./PooledClass":137,"./ReactCurrentOwner":146,"./ReactPerf":178,"./Transaction":205,"./invariant":236,"./warning":255,_process:94}],190:[function(a,b,c){"use strict";var d=a("./DOMProperty"),e=d.injection.MUST_USE_ATTRIBUTE,f={Properties:{cx:e,cy:e,d:e,dx:e,dy:e,fill:e,fillOpacity:e,fontFamily:e,fontSize:e,fx:e,fy:e,gradientTransform:e,gradientUnits:e,markerEnd:e,markerMid:e,markerStart:e,offset:e,opacity:e,patternContentUnits:e,patternUnits:e,points:e,preserveAspectRatio:e,r:e,rx:e,ry:e,spreadMethod:e,stopColor:e,stopOpacity:e,stroke:e,strokeDasharray:e,strokeLinecap:e,strokeOpacity:e,strokeWidth:e,textAnchor:e,transform:e,version:e,viewBox:e,x1:e,x2:e,x:e,y1:e,y2:e,y:e},DOMAttributeNames:{fillOpacity:"fill-opacity",fontFamily:"font-family",fontSize:"font-size",gradientTransform:"gradientTransform",gradientUnits:"gradientUnits",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",patternContentUnits:"patternContentUnits",patternUnits:"patternUnits",preserveAspectRatio:"preserveAspectRatio",spreadMethod:"spreadMethod",stopColor:"stop-color",stopOpacity:"stop-opacity",strokeDasharray:"stroke-dasharray",strokeLinecap:"stroke-linecap",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",textAnchor:"text-anchor",viewBox:"viewBox"}};b.exports=f},{"./DOMProperty":120}],191:[function(a,b,c){"use strict";function d(a){if("selectionStart"in a&&h.hasSelectionCapabilities(a))return{start:a.selectionStart,end:a.selectionEnd};if(window.getSelection){var b=window.getSelection();return{anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}}if(document.selection){var c=document.selection.createRange();return{parentElement:c.parentElement(),text:c.text,top:c.boundingTop,left:c.boundingLeft}}}function e(a){if(!s&&null!=p&&p==j()){var b=d(p);if(!r||!m(r,b)){r=b;var c=i.getPooled(o.select,q,a);return c.type="select",c.target=p,g.accumulateTwoPhaseDispatches(c),c}}}var f=a("./EventConstants"),g=a("./EventPropagators"),h=a("./ReactInputSelection"),i=a("./SyntheticEvent"),j=a("./getActiveElement"),k=a("./isTextInputElement"),l=a("./keyOf"),m=a("./shallowEqual"),n=f.topLevelTypes,o={select:{phasedRegistrationNames:{bubbled:l({onSelect:null}),captured:l({onSelectCapture:null})},dependencies:[n.topBlur,n.topContextMenu,n.topFocus,n.topKeyDown,n.topMouseDown,n.topMouseUp,n.topSelectionChange]}},p=null,q=null,r=null,s=!1,t={eventTypes:o,extractEvents:function(a,b,c,d){switch(a){case n.topFocus:(k(b)||"true"===b.contentEditable)&&(p=b,q=c,r=null);break;case n.topBlur:p=null,q=null,r=null;break;case n.topMouseDown:s=!0;break;case n.topContextMenu:case n.topMouseUp:return s=!1,e(d);case n.topSelectionChange:case n.topKeyDown:case n.topKeyUp:return e(d)}}};b.exports=t},{"./EventConstants":125,"./EventPropagators":130,"./ReactInputSelection":169,"./SyntheticEvent":197,"./getActiveElement":223,"./isTextInputElement":239,"./keyOf":243,"./shallowEqual":251}],192:[function(a,b,c){"use strict";var d=Math.pow(2,53),e={createReactRootIndex:function(){return Math.ceil(Math.random()*d)}};b.exports=e},{}],193:[function(a,b,c){(function(c){"use strict";var d=a("./EventConstants"),e=a("./EventPluginUtils"),f=a("./EventPropagators"),g=a("./SyntheticClipboardEvent"),h=a("./SyntheticEvent"),i=a("./SyntheticFocusEvent"),j=a("./SyntheticKeyboardEvent"),k=a("./SyntheticMouseEvent"),l=a("./SyntheticDragEvent"),m=a("./SyntheticTouchEvent"),n=a("./SyntheticUIEvent"),o=a("./SyntheticWheelEvent"),p=a("./getEventCharCode"),q=a("./invariant"),r=a("./keyOf"),s=a("./warning"),t=d.topLevelTypes,u={blur:{phasedRegistrationNames:{bubbled:r({onBlur:!0}),captured:r({onBlurCapture:!0})}},click:{phasedRegistrationNames:{bubbled:r({onClick:!0}),captured:r({onClickCapture:!0})}},contextMenu:{phasedRegistrationNames:{bubbled:r({onContextMenu:!0}),captured:r({onContextMenuCapture:!0})}},copy:{phasedRegistrationNames:{bubbled:r({onCopy:!0}),captured:r({onCopyCapture:!0})}},cut:{phasedRegistrationNames:{bubbled:r({onCut:!0}),captured:r({onCutCapture:!0})}},doubleClick:{phasedRegistrationNames:{bubbled:r({onDoubleClick:!0}),captured:r({onDoubleClickCapture:!0})}},drag:{phasedRegistrationNames:{bubbled:r({onDrag:!0}),captured:r({onDragCapture:!0})}},dragEnd:{phasedRegistrationNames:{bubbled:r({onDragEnd:!0}),captured:r({onDragEndCapture:!0})}},dragEnter:{phasedRegistrationNames:{bubbled:r({onDragEnter:!0}),captured:r({onDragEnterCapture:!0})}},dragExit:{phasedRegistrationNames:{bubbled:r({onDragExit:!0}),captured:r({onDragExitCapture:!0})}},dragLeave:{phasedRegistrationNames:{bubbled:r({onDragLeave:!0}),captured:r({onDragLeaveCapture:!0})}},dragOver:{phasedRegistrationNames:{bubbled:r({onDragOver:!0}),captured:r({onDragOverCapture:!0})}},dragStart:{phasedRegistrationNames:{bubbled:r({onDragStart:!0}),captured:r({onDragStartCapture:!0})}},drop:{phasedRegistrationNames:{bubbled:r({onDrop:!0}),captured:r({onDropCapture:!0})}},focus:{phasedRegistrationNames:{bubbled:r({onFocus:!0}),captured:r({onFocusCapture:!0})}},input:{phasedRegistrationNames:{bubbled:r({onInput:!0}),captured:r({onInputCapture:!0})}},keyDown:{phasedRegistrationNames:{bubbled:r({onKeyDown:!0}),captured:r({onKeyDownCapture:!0})}},keyPress:{phasedRegistrationNames:{bubbled:r({onKeyPress:!0}),captured:r({onKeyPressCapture:!0})}},keyUp:{phasedRegistrationNames:{bubbled:r({onKeyUp:!0}),captured:r({onKeyUpCapture:!0})}},load:{phasedRegistrationNames:{bubbled:r({onLoad:!0}),captured:r({onLoadCapture:!0})}},error:{phasedRegistrationNames:{bubbled:r({onError:!0}),captured:r({onErrorCapture:!0})}},mouseDown:{phasedRegistrationNames:{bubbled:r({onMouseDown:!0}),captured:r({onMouseDownCapture:!0})}},mouseMove:{phasedRegistrationNames:{bubbled:r({onMouseMove:!0}),captured:r({onMouseMoveCapture:!0})}},mouseOut:{phasedRegistrationNames:{bubbled:r({onMouseOut:!0}),captured:r({onMouseOutCapture:!0})}},mouseOver:{phasedRegistrationNames:{bubbled:r({onMouseOver:!0}),captured:r({onMouseOverCapture:!0})}},mouseUp:{phasedRegistrationNames:{bubbled:r({onMouseUp:!0}),captured:r({onMouseUpCapture:!0})}},paste:{phasedRegistrationNames:{bubbled:r({onPaste:!0}),captured:r({onPasteCapture:!0})}},reset:{phasedRegistrationNames:{bubbled:r({onReset:!0}),captured:r({onResetCapture:!0})}},scroll:{phasedRegistrationNames:{bubbled:r({onScroll:!0}),captured:r({onScrollCapture:!0})}},submit:{phasedRegistrationNames:{bubbled:r({onSubmit:!0}),captured:r({onSubmitCapture:!0})}},touchCancel:{phasedRegistrationNames:{bubbled:r({onTouchCancel:!0}),captured:r({onTouchCancelCapture:!0})}},touchEnd:{phasedRegistrationNames:{bubbled:r({onTouchEnd:!0}),captured:r({onTouchEndCapture:!0})}},touchMove:{phasedRegistrationNames:{bubbled:r({onTouchMove:!0}),captured:r({onTouchMoveCapture:!0})}},touchStart:{phasedRegistrationNames:{bubbled:r({onTouchStart:!0}),captured:r({onTouchStartCapture:!0})}},wheel:{phasedRegistrationNames:{bubbled:r({onWheel:!0}),captured:r({onWheelCapture:!0})}}},v={topBlur:u.blur,topClick:u.click,topContextMenu:u.contextMenu,topCopy:u.copy,topCut:u.cut,topDoubleClick:u.doubleClick,topDrag:u.drag,topDragEnd:u.dragEnd,topDragEnter:u.dragEnter,topDragExit:u.dragExit,topDragLeave:u.dragLeave,topDragOver:u.dragOver,topDragStart:u.dragStart,topDrop:u.drop,topError:u.error,topFocus:u.focus,topInput:u.input,topKeyDown:u.keyDown,topKeyPress:u.keyPress,topKeyUp:u.keyUp,topLoad:u.load,topMouseDown:u.mouseDown,topMouseMove:u.mouseMove,topMouseOut:u.mouseOut,topMouseOver:u.mouseOver,topMouseUp:u.mouseUp,topPaste:u.paste,topReset:u.reset,topScroll:u.scroll,topSubmit:u.submit,topTouchCancel:u.touchCancel,topTouchEnd:u.touchEnd,topTouchMove:u.touchMove,topTouchStart:u.touchStart,topWheel:u.wheel};for(var w in v)v[w].dependencies=[w];var x={eventTypes:u,executeDispatch:function(a,b,d){var f=e.executeDispatch(a,b,d);"production"!==c.env.NODE_ENV?s("boolean"!=typeof f,"Returning `false` from an event handler is deprecated and will be ignored in a future release. Instead, manually call e.stopPropagation() or e.preventDefault(), as appropriate."):null,f===!1&&(a.stopPropagation(),a.preventDefault())},extractEvents:function(a,b,d,e){var r=v[a];if(!r)return null;var s;switch(a){case t.topInput:case t.topLoad:case t.topError:case t.topReset:case t.topSubmit:s=h;break;case t.topKeyPress:if(0===p(e))return null;case t.topKeyDown:case t.topKeyUp:s=j;break;case t.topBlur:case t.topFocus:s=i;break;case t.topClick:if(2===e.button)return null;case t.topContextMenu:case t.topDoubleClick:case t.topMouseDown:case t.topMouseMove:case t.topMouseOut:case t.topMouseOver:case t.topMouseUp:s=k;break;case t.topDrag:case t.topDragEnd:case t.topDragEnter:case t.topDragExit:case t.topDragLeave:case t.topDragOver:case t.topDragStart:case t.topDrop:s=l;break;case t.topTouchCancel:case t.topTouchEnd:case t.topTouchMove:case t.topTouchStart:s=m;break;case t.topScroll:s=n;break;case t.topWheel:s=o;break;case t.topCopy:case t.topCut:case t.topPaste:s=g}"production"!==c.env.NODE_ENV?q(s,"SimpleEventPlugin: Unhandled event type, `%s`.",a):q(s);var u=s.getPooled(r,d,e);return f.accumulateTwoPhaseDispatches(u),u}};b.exports=x}).call(this,a("_process"))},{"./EventConstants":125,"./EventPluginUtils":129,"./EventPropagators":130,"./SyntheticClipboardEvent":194,"./SyntheticDragEvent":196,"./SyntheticEvent":197,"./SyntheticFocusEvent":198,"./SyntheticKeyboardEvent":200,"./SyntheticMouseEvent":201,"./SyntheticTouchEvent":202,"./SyntheticUIEvent":203,"./SyntheticWheelEvent":204,"./getEventCharCode":224,"./invariant":236,"./keyOf":243,"./warning":255,_process:94}],194:[function(a,b,c){"use strict";function d(a,b,c){e.call(this,a,b,c)}var e=a("./SyntheticEvent"),f={clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}};e.augmentClass(d,f),b.exports=d},{"./SyntheticEvent":197}],195:[function(a,b,c){"use strict";function d(a,b,c){e.call(this,a,b,c)}var e=a("./SyntheticEvent"),f={data:null};e.augmentClass(d,f),b.exports=d},{"./SyntheticEvent":197}],196:[function(a,b,c){"use strict";function d(a,b,c){e.call(this,a,b,c)}var e=a("./SyntheticMouseEvent"),f={dataTransfer:null};e.augmentClass(d,f),b.exports=d},{"./SyntheticMouseEvent":201}],197:[function(a,b,c){"use strict";function d(a,b,c){this.dispatchConfig=a,this.dispatchMarker=b,this.nativeEvent=c;var d=this.constructor.Interface;for(var e in d)if(d.hasOwnProperty(e)){var f=d[e];f?this[e]=f(c):this[e]=c[e]}var h=null!=c.defaultPrevented?c.defaultPrevented:c.returnValue===!1;h?this.isDefaultPrevented=g.thatReturnsTrue:this.isDefaultPrevented=g.thatReturnsFalse,this.isPropagationStopped=g.thatReturnsFalse}var e=a("./PooledClass"),f=a("./Object.assign"),g=a("./emptyFunction"),h=a("./getEventTarget"),i={type:null,target:h,currentTarget:g.thatReturnsNull,eventPhase:null,bubbles:null,cancelable:null,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:null,isTrusted:null};f(d.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a.preventDefault?a.preventDefault():a.returnValue=!1,this.isDefaultPrevented=g.thatReturnsTrue},stopPropagation:function(){var a=this.nativeEvent;a.stopPropagation?a.stopPropagation():a.cancelBubble=!0,this.isPropagationStopped=g.thatReturnsTrue},persist:function(){this.isPersistent=g.thatReturnsTrue},isPersistent:g.thatReturnsFalse,destructor:function(){var a=this.constructor.Interface;for(var b in a)this[b]=null;this.dispatchConfig=null,this.dispatchMarker=null,this.nativeEvent=null}}),d.Interface=i,d.augmentClass=function(a,b){var c=this,d=Object.create(c.prototype);f(d,a.prototype),a.prototype=d,a.prototype.constructor=a,a.Interface=f({},c.Interface,b),a.augmentClass=c.augmentClass,e.addPoolingTo(a,e.threeArgumentPooler)},e.addPoolingTo(d,e.threeArgumentPooler),b.exports=d},{"./Object.assign":136,"./PooledClass":137,"./emptyFunction":217,"./getEventTarget":227}],198:[function(a,b,c){"use strict";function d(a,b,c){e.call(this,a,b,c)}var e=a("./SyntheticUIEvent"),f={relatedTarget:null};e.augmentClass(d,f),b.exports=d},{"./SyntheticUIEvent":203}],199:[function(a,b,c){"use strict";function d(a,b,c){e.call(this,a,b,c)}var e=a("./SyntheticEvent"),f={data:null};e.augmentClass(d,f),b.exports=d},{"./SyntheticEvent":197}],200:[function(a,b,c){"use strict";function d(a,b,c){e.call(this,a,b,c)}var e=a("./SyntheticUIEvent"),f=a("./getEventCharCode"),g=a("./getEventKey"),h=a("./getEventModifierState"),i={key:g,location:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,repeat:null,locale:null,getModifierState:h,charCode:function(a){return"keypress"===a.type?f(a):0},keyCode:function(a){return"keydown"===a.type||"keyup"===a.type?a.keyCode:0},which:function(a){return"keypress"===a.type?f(a):"keydown"===a.type||"keyup"===a.type?a.keyCode:0}};e.augmentClass(d,i),b.exports=d},{"./SyntheticUIEvent":203,"./getEventCharCode":224,"./getEventKey":225,"./getEventModifierState":226}],201:[function(a,b,c){"use strict";function d(a,b,c){e.call(this,a,b,c)}var e=a("./SyntheticUIEvent"),f=a("./ViewportMetrics"),g=a("./getEventModifierState"),h={screenX:null,screenY:null,clientX:null,clientY:null,ctrlKey:null,shiftKey:null,altKey:null,metaKey:null,getModifierState:g,button:function(a){var b=a.button;return"which"in a?b:2===b?2:4===b?1:0},buttons:null,relatedTarget:function(a){return a.relatedTarget||(a.fromElement===a.srcElement?a.toElement:a.fromElement)},pageX:function(a){return"pageX"in a?a.pageX:a.clientX+f.currentScrollLeft},pageY:function(a){return"pageY"in a?a.pageY:a.clientY+f.currentScrollTop}};e.augmentClass(d,h),b.exports=d},{"./SyntheticUIEvent":203,"./ViewportMetrics":206,"./getEventModifierState":226}],202:[function(a,b,c){"use strict";function d(a,b,c){e.call(this,a,b,c)}var e=a("./SyntheticUIEvent"),f=a("./getEventModifierState"),g={touches:null,targetTouches:null,changedTouches:null,altKey:null,metaKey:null,ctrlKey:null,shiftKey:null,getModifierState:f};e.augmentClass(d,g),b.exports=d},{"./SyntheticUIEvent":203,"./getEventModifierState":226}],203:[function(a,b,c){"use strict";function d(a,b,c){e.call(this,a,b,c)}var e=a("./SyntheticEvent"),f=a("./getEventTarget"),g={view:function(a){if(a.view)return a.view;var b=f(a);if(null!=b&&b.window===b)return b;var c=b.ownerDocument;return c?c.defaultView||c.parentWindow:window},detail:function(a){return a.detail||0}};e.augmentClass(d,g),b.exports=d},{"./SyntheticEvent":197,"./getEventTarget":227}],204:[function(a,b,c){"use strict";function d(a,b,c){e.call(this,a,b,c)}var e=a("./SyntheticMouseEvent"),f={deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:null,deltaMode:null};e.augmentClass(d,f),b.exports=d},{"./SyntheticMouseEvent":201}],205:[function(a,b,c){(function(c){"use strict";var d=a("./invariant"),e={reinitializeTransaction:function(){this.transactionWrappers=this.getTransactionWrappers(),this.wrapperInitData?this.wrapperInitData.length=0:this.wrapperInitData=[],this._isInTransaction=!1},_isInTransaction:!1,getTransactionWrappers:null,isInTransaction:function(){return!!this._isInTransaction},perform:function(a,b,e,f,g,h,i,j){"production"!==c.env.NODE_ENV?d(!this.isInTransaction(),"Transaction.perform(...): Cannot initialize a transaction when there is already an outstanding transaction."):d(!this.isInTransaction());var k,l;try{this._isInTransaction=!0,k=!0,this.initializeAll(0),l=a.call(b,e,f,g,h,i,j),k=!1}finally{try{if(k)try{this.closeAll(0)}catch(m){}else this.closeAll(0)}finally{this._isInTransaction=!1}}return l},initializeAll:function(a){for(var b=this.transactionWrappers,c=a;c<b.length;c++){var d=b[c];try{this.wrapperInitData[c]=f.OBSERVED_ERROR,this.wrapperInitData[c]=d.initialize?d.initialize.call(this):null}finally{if(this.wrapperInitData[c]===f.OBSERVED_ERROR)try{this.initializeAll(c+1)}catch(e){}}}},closeAll:function(a){"production"!==c.env.NODE_ENV?d(this.isInTransaction(),"Transaction.closeAll(): Cannot close transaction when none are open."):d(this.isInTransaction());for(var b=this.transactionWrappers,e=a;e<b.length;e++){var g,h=b[e],i=this.wrapperInitData[e];try{g=!0,i!==f.OBSERVED_ERROR&&h.close&&h.close.call(this,i),g=!1}finally{if(g)try{this.closeAll(e+1)}catch(j){}}}this.wrapperInitData.length=0}},f={Mixin:e,OBSERVED_ERROR:{}};b.exports=f}).call(this,a("_process"))},{"./invariant":236,_process:94}],206:[function(a,b,c){"use strict";var d=a("./getUnboundedScrollPosition"),e={currentScrollLeft:0,currentScrollTop:0,refreshScrollValues:function(){var a=d(window);e.currentScrollLeft=a.x,e.currentScrollTop=a.y}};b.exports=e},{"./getUnboundedScrollPosition":232}],207:[function(a,b,c){(function(c){"use strict";function d(a,b){if("production"!==c.env.NODE_ENV?e(null!=b,"accumulateInto(...): Accumulated items must not be null or undefined."):e(null!=b),null==a)return b;var d=Array.isArray(a),f=Array.isArray(b);return d&&f?(a.push.apply(a,b),a):d?(a.push(b),a):f?[a].concat(b):[a,b]}var e=a("./invariant");b.exports=d}).call(this,a("_process"))},{"./invariant":236,_process:94}],208:[function(a,b,c){"use strict";function d(a){for(var b=1,c=0,d=0;d<a.length;d++)b=(b+a.charCodeAt(d))%e,c=(c+b)%e;return b|c<<16}var e=65521;b.exports=d},{}],209:[function(a,b,c){function d(a){return a.replace(e,function(a,b){return b.toUpperCase()})}var e=/-(.)/g;b.exports=d},{}],210:[function(a,b,c){"use strict";function d(a){return e(a.replace(f,"ms-"))}var e=a("./camelize"),f=/^-ms-/;b.exports=d},{"./camelize":209}],211:[function(a,b,c){function d(a,b){return a&&b?a===b?!0:e(a)?!1:e(b)?d(a,b.parentNode):a.contains?a.contains(b):a.compareDocumentPosition?!!(16&a.compareDocumentPosition(b)):!1:!1}var e=a("./isTextNode");b.exports=d},{"./isTextNode":240}],212:[function(a,b,c){function d(a){return!!a&&("object"==typeof a||"function"==typeof a)&&"length"in a&&!("setInterval"in a)&&"number"!=typeof a.nodeType&&(Array.isArray(a)||"callee"in a||"item"in a)}function e(a){return d(a)?Array.isArray(a)?a.slice():f(a):[a]}var f=a("./toArray");b.exports=e},{"./toArray":253}],213:[function(a,b,c){(function(c){"use strict";function d(a){var b=f.createFactory(a),d=e.createClass({displayName:"ReactFullPageComponent"+a,componentWillUnmount:function(){"production"!==c.env.NODE_ENV?g(!1,"%s tried to unmount. Because of cross-browser quirks it is impossible to unmount some top-level components (eg <html>, <head>, and <body>) reliably and efficiently. To fix this, have a single top-level component that never unmounts render these elements.",this.constructor.displayName):g(!1)},render:function(){return b(this.props)}});return d}var e=a("./ReactCompositeComponent"),f=a("./ReactElement"),g=a("./invariant");b.exports=d}).call(this,a("_process"))},{"./ReactCompositeComponent":144,"./ReactElement":162,"./invariant":236,_process:94}],214:[function(a,b,c){(function(c){function d(a){var b=a.match(k);return b&&b[1].toLowerCase()}function e(a,b){var e=j;"production"!==c.env.NODE_ENV?i(!!j,"createNodesFromMarkup dummy not initialized"):i(!!j);var f=d(a),k=f&&h(f);if(k){e.innerHTML=k[1]+a+k[2];for(var l=k[0];l--;)e=e.lastChild}else e.innerHTML=a;var m=e.getElementsByTagName("script");m.length&&("production"!==c.env.NODE_ENV?i(b,"createNodesFromMarkup(...): Unexpected <script> element rendered."):i(b),g(m).forEach(b));for(var n=g(e.childNodes);e.lastChild;)e.removeChild(e.lastChild);return n}var f=a("./ExecutionEnvironment"),g=a("./createArrayFrom"),h=a("./getMarkupWrap"),i=a("./invariant"),j=f.canUseDOM?document.createElement("div"):null,k=/^\s*<(\w+)/;b.exports=e}).call(this,a("_process"))},{"./ExecutionEnvironment":131,"./createArrayFrom":212,"./getMarkupWrap":228,"./invariant":236,_process:94}],215:[function(a,b,c){"use strict";function d(a,b){var c=null==b||"boolean"==typeof b||""===b;if(c)return"";var d=isNaN(b);return d||0===b||f.hasOwnProperty(a)&&f[a]?""+b:("string"==typeof b&&(b=b.trim()),b+"px")}var e=a("./CSSProperty"),f=e.isUnitlessNumber;b.exports=d},{"./CSSProperty":113}],216:[function(a,b,c){(function(c){function d(a,b,d,g,h){var i=!1;if("production"!==c.env.NODE_ENV){var j=function(){return"production"!==c.env.NODE_ENV?f(i,a+"."+b+" will be deprecated in a future version. "+("Use "+a+"."+d+" instead.")):null,i=!0,h.apply(g,arguments)};return j.displayName=a+"_"+b,e(j,h)}return h}var e=a("./Object.assign"),f=a("./warning");b.exports=d}).call(this,a("_process"))},{"./Object.assign":136,"./warning":255,_process:94}],217:[function(a,b,c){function d(a){return function(){return a}}function e(){}e.thatReturns=d,e.thatReturnsFalse=d(!1),e.thatReturnsTrue=d(!0),e.thatReturnsNull=d(null),e.thatReturnsThis=function(){return this},e.thatReturnsArgument=function(a){return a},b.exports=e},{}],218:[function(a,b,c){(function(a){"use strict";var c={};"production"!==a.env.NODE_ENV&&Object.freeze(c),b.exports=c}).call(this,a("_process"))},{_process:94}],219:[function(a,b,c){"use strict";function d(a){return f[a]}function e(a){return(""+a).replace(g,d)}var f={"&":"&amp;",">":"&gt;","<":"&lt;",'"':"&quot;","'":"&#x27;"},g=/[&><"']/g;b.exports=e},{}],220:[function(a,b,c){(function(c){"use strict";function d(a,b,d){var e=a,g=!e.hasOwnProperty(d);if("production"!==c.env.NODE_ENV?h(g,"flattenChildren(...): Encountered two children with the same key, `%s`. Child keys must be unique; when two children share a key, only the first child will be used.",d):null,g&&null!=b){var i,j=typeof b;i="string"===j?f(b):"number"===j?f(""+b):b,e[d]=i}}function e(a){if(null==a)return a;var b={};return g(a,d,b),b}var f=a("./ReactTextComponent"),g=a("./traverseAllChildren"),h=a("./warning");b.exports=e}).call(this,a("_process"))},{"./ReactTextComponent":188,"./traverseAllChildren":254,"./warning":255,_process:94}],221:[function(a,b,c){"use strict";function d(a){try{a.focus()}catch(b){}}b.exports=d},{}],222:[function(a,b,c){"use strict";var d=function(a,b,c){Array.isArray(a)?a.forEach(b,c):a&&b.call(c,a)};b.exports=d},{}],223:[function(a,b,c){function d(){try{return document.activeElement||document.body}catch(a){return document.body}}b.exports=d},{}],224:[function(a,b,c){"use strict";function d(a){var b,c=a.keyCode;return"charCode"in a?(b=a.charCode,0===b&&13===c&&(b=13)):b=c,b>=32||13===b?b:0}b.exports=d},{}],225:[function(a,b,c){"use strict";function d(a){if(a.key){var b=f[a.key]||a.key;if("Unidentified"!==b)return b}if("keypress"===a.type){var c=e(a);return 13===c?"Enter":String.fromCharCode(c)}return"keydown"===a.type||"keyup"===a.type?g[a.keyCode]||"Unidentified":""}var e=a("./getEventCharCode"),f={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},g={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"};b.exports=d},{"./getEventCharCode":224}],226:[function(a,b,c){"use strict";function d(a){var b=this,c=b.nativeEvent;if(c.getModifierState)return c.getModifierState(a);var d=f[a];return d?!!c[d]:!1}function e(a){return d}var f={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};b.exports=e},{}],227:[function(a,b,c){"use strict";function d(a){var b=a.target||a.srcElement||window;return 3===b.nodeType?b.parentNode:b}b.exports=d},{}],228:[function(a,b,c){(function(c){function d(a){return"production"!==c.env.NODE_ENV?f(!!g,"Markup wrapping node not initialized"):f(!!g),m.hasOwnProperty(a)||(a="*"),h.hasOwnProperty(a)||("*"===a?g.innerHTML="<link />":g.innerHTML="<"+a+"></"+a+">",h[a]=!g.firstChild),h[a]?m[a]:null}var e=a("./ExecutionEnvironment"),f=a("./invariant"),g=e.canUseDOM?document.createElement("div"):null,h={circle:!0,defs:!0,ellipse:!0,g:!0,line:!0,linearGradient:!0,path:!0,polygon:!0,polyline:!0,radialGradient:!0,rect:!0,stop:!0,text:!0},i=[1,'<select multiple="true">',"</select>"],j=[1,"<table>","</table>"],k=[3,"<table><tbody><tr>","</tr></tbody></table>"],l=[1,"<svg>","</svg>"],m={"*":[1,"?<div>","</div>"],area:[1,"<map>","</map>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],legend:[1,"<fieldset>","</fieldset>"],param:[1,"<object>","</object>"],tr:[2,"<table><tbody>","</tbody></table>"],optgroup:i,option:i,caption:j,colgroup:j,tbody:j,tfoot:j,thead:j,td:k,th:k,circle:l,defs:l,ellipse:l,g:l,line:l,linearGradient:l,path:l,polygon:l,polyline:l,radialGradient:l,rect:l,stop:l,text:l};b.exports=d}).call(this,a("_process"))},{"./ExecutionEnvironment":131,"./invariant":236,_process:94}],229:[function(a,b,c){"use strict";function d(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function e(a){for(;a;){if(a.nextSibling)return a.nextSibling;a=a.parentNode}}function f(a,b){for(var c=d(a),f=0,g=0;c;){if(3==c.nodeType){if(g=f+c.textContent.length,b>=f&&g>=b)return{node:c,offset:b-f};f=g}c=d(e(c))}}b.exports=f},{}],230:[function(a,b,c){"use strict";function d(a){return a?a.nodeType===e?a.documentElement:a.firstChild:null}var e=9;b.exports=d},{}],231:[function(a,b,c){"use strict";function d(){return!f&&e.canUseDOM&&(f="textContent"in document.documentElement?"textContent":"innerText"),f}var e=a("./ExecutionEnvironment"),f=null;b.exports=d},{"./ExecutionEnvironment":131}],232:[function(a,b,c){"use strict";function d(a){return a===window?{x:window.pageXOffset||document.documentElement.scrollLeft,y:window.pageYOffset||document.documentElement.scrollTop}:{x:a.scrollLeft,y:a.scrollTop}}b.exports=d},{}],233:[function(a,b,c){function d(a){return a.replace(e,"-$1").toLowerCase()}var e=/([A-Z])/g;b.exports=d},{}],234:[function(a,b,c){"use strict";function d(a){return e(a).replace(f,"-ms-")}var e=a("./hyphenate"),f=/^ms-/;b.exports=d},{"./hyphenate":233}],235:[function(a,b,c){(function(c){"use strict";function d(a,b){var d;if("production"!==c.env.NODE_ENV&&("production"!==c.env.NODE_ENV?e(a&&("function"==typeof a.type||"string"==typeof a.type),"Only functions or strings can be mounted as React components."):null,a.type._mockedReactClassConstructor)){g._isLegacyCallWarningEnabled=!1;try{d=new a.type._mockedReactClassConstructor(a.props)}finally{g._isLegacyCallWarningEnabled=!0}f.isValidElement(d)&&(d=new d.type(d.props));var j=d.render;if(j)return j._isMockFunction&&!j._getMockImplementation()&&j.mockImplementation(i.getEmptyComponent),d.construct(a),d;a=i.getEmptyComponent()}return d="string"==typeof a.type?h.createInstanceForTag(a.type,a.props,b):new a.type(a.props),"production"!==c.env.NODE_ENV&&("production"!==c.env.NODE_ENV?e("function"==typeof d.construct&&"function"==typeof d.mountComponent&&"function"==typeof d.receiveComponent,"Only React Components can be mounted."):null),d.construct(a),d}var e=a("./warning"),f=a("./ReactElement"),g=a("./ReactLegacyElement"),h=a("./ReactNativeComponent"),i=a("./ReactEmptyComponent");b.exports=d}).call(this,a("_process"))},{"./ReactElement":162,"./ReactEmptyComponent":164,"./ReactLegacyElement":171,"./ReactNativeComponent":176,"./warning":255,_process:94}],236:[function(a,b,c){(function(a){"use strict";var c=function(b,c,d,e,f,g,h,i){if("production"!==a.env.NODE_ENV&&void 0===c)throw new Error("invariant requires an error message argument");if(!b){var j;if(void 0===c)j=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var k=[d,e,f,g,h,i],l=0;j=new Error("Invariant Violation: "+c.replace(/%s/g,function(){return k[l++]}))}throw j.framesToPop=1,j}};b.exports=c}).call(this,a("_process"))},{_process:94}],237:[function(a,b,c){"use strict";function d(a,b){if(!f.canUseDOM||b&&!("addEventListener"in document))return!1;var c="on"+a,d=c in document;if(!d){var g=document.createElement("div");g.setAttribute(c,"return;"),d="function"==typeof g[c]}return!d&&e&&"wheel"===a&&(d=document.implementation.hasFeature("Events.wheel","3.0")),d}var e,f=a("./ExecutionEnvironment");f.canUseDOM&&(e=document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("","")!==!0),b.exports=d},{"./ExecutionEnvironment":131}],238:[function(a,b,c){function d(a){return!(!a||!("function"==typeof Node?a instanceof Node:"object"==typeof a&&"number"==typeof a.nodeType&&"string"==typeof a.nodeName))}b.exports=d},{}],239:[function(a,b,c){"use strict";function d(a){return a&&("INPUT"===a.nodeName&&e[a.type]||"TEXTAREA"===a.nodeName)}var e={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};b.exports=d},{}],240:[function(a,b,c){function d(a){return e(a)&&3==a.nodeType}var e=a("./isNode");b.exports=d},{"./isNode":238}],241:[function(a,b,c){"use strict";function d(a){a||(a="");var b,c=arguments.length;if(c>1)for(var d=1;c>d;d++)b=arguments[d],b&&(a=(a?a+" ":"")+b);return a}b.exports=d},{}],242:[function(a,b,c){(function(c){"use strict";var d=a("./invariant"),e=function(a){var b,e={};"production"!==c.env.NODE_ENV?d(a instanceof Object&&!Array.isArray(a),"keyMirror(...): Argument must be an object."):d(a instanceof Object&&!Array.isArray(a));for(b in a)a.hasOwnProperty(b)&&(e[b]=b);return e};b.exports=e}).call(this,a("_process"))},{"./invariant":236,_process:94}],243:[function(a,b,c){var d=function(a){var b;for(b in a)if(a.hasOwnProperty(b))return b;return null};b.exports=d},{}],244:[function(a,b,c){"use strict";function d(a,b,c){if(!a)return null;var d={};for(var f in a)e.call(a,f)&&(d[f]=b.call(c,a[f],f,a));return d}var e=Object.prototype.hasOwnProperty;
 
-b.exports=d},{}],245:[function(a,b,c){"use strict";function d(a){var b={};return function(c){return b.hasOwnProperty(c)?b[c]:b[c]=a.call(this,c)}}b.exports=d},{}],246:[function(a,b,c){(function(c){"use strict";function d(a,b){"production"!==c.env.NODE_ENV?e(a&&!/[^a-z0-9_]/.test(a),"You must provide an eventName using only the characters [a-z0-9_]"):e(a&&!/[^a-z0-9_]/.test(a))}var e=a("./invariant");b.exports=d}).call(this,a("_process"))},{"./invariant":236,_process:94}],247:[function(a,b,c){(function(c){"use strict";function d(a){return"production"!==c.env.NODE_ENV?f(e.isValidElement(a),"onlyChild must be passed a children with exactly one child."):f(e.isValidElement(a)),a}var e=a("./ReactElement"),f=a("./invariant");b.exports=d}).call(this,a("_process"))},{"./ReactElement":162,"./invariant":236,_process:94}],248:[function(a,b,c){"use strict";var d,e=a("./ExecutionEnvironment");e.canUseDOM&&(d=window.performance||window.msPerformance||window.webkitPerformance),b.exports=d||{}},{"./ExecutionEnvironment":131}],249:[function(a,b,c){var d=a("./performance");d&&d.now||(d=Date);var e=d.now.bind(d);b.exports=e},{"./performance":248}],250:[function(a,b,c){"use strict";var d=a("./ExecutionEnvironment"),e=/^[ \r\n\t\f]/,f=/<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/,g=function(a,b){a.innerHTML=b};if(d.canUseDOM){var h=document.createElement("div");h.innerHTML=" ",""===h.innerHTML&&(g=function(a,b){if(a.parentNode&&a.parentNode.replaceChild(a,a),e.test(b)||"<"===b[0]&&f.test(b)){a.innerHTML="\ufeff"+b;var c=a.firstChild;1===c.data.length?a.removeChild(c):c.deleteData(0,1)}else a.innerHTML=b})}b.exports=g},{"./ExecutionEnvironment":131}],251:[function(a,b,c){"use strict";function d(a,b){if(a===b)return!0;var c;for(c in a)if(a.hasOwnProperty(c)&&(!b.hasOwnProperty(c)||a[c]!==b[c]))return!1;for(c in b)if(b.hasOwnProperty(c)&&!a.hasOwnProperty(c))return!1;return!0}b.exports=d},{}],252:[function(a,b,c){"use strict";function d(a,b){return a&&b&&a.type===b.type&&a.key===b.key&&a._owner===b._owner?!0:!1}b.exports=d},{}],253:[function(a,b,c){(function(c){function d(a){var b=a.length;if("production"!==c.env.NODE_ENV?e(!Array.isArray(a)&&("object"==typeof a||"function"==typeof a),"toArray: Array-like object expected"):e(!Array.isArray(a)&&("object"==typeof a||"function"==typeof a)),"production"!==c.env.NODE_ENV?e("number"==typeof b,"toArray: Object needs a length property"):e("number"==typeof b),"production"!==c.env.NODE_ENV?e(0===b||b-1 in a,"toArray: Object should have keys for indices"):e(0===b||b-1 in a),a.hasOwnProperty)try{return Array.prototype.slice.call(a)}catch(d){}for(var f=Array(b),g=0;b>g;g++)f[g]=a[g];return f}var e=a("./invariant");b.exports=d}).call(this,a("_process"))},{"./invariant":236,_process:94}],254:[function(a,b,c){(function(c){"use strict";function d(a){return n[a]}function e(a,b){return a&&null!=a.key?g(a.key):b.toString(36)}function f(a){return(""+a).replace(o,d)}function g(a){return"$"+f(a)}function h(a,b,c){return null==a?0:p(a,"",0,b,c)}var i=a("./ReactElement"),j=a("./ReactInstanceHandles"),k=a("./invariant"),l=j.SEPARATOR,m=":",n={"=":"=0",".":"=1",":":"=2"},o=/[=.:]/g,p=function(a,b,d,f,h){var j,n,o=0;if(Array.isArray(a))for(var q=0;q<a.length;q++){var r=a[q];j=b+(b?m:l)+e(r,q),n=d+o,o+=p(r,j,n,f,h)}else{var s=typeof a,t=""===b,u=t?l+e(a,0):b;if(null==a||"boolean"===s)f(h,null,u,d),o=1;else if("string"===s||"number"===s||i.isValidElement(a))f(h,a,u,d),o=1;else if("object"===s){"production"!==c.env.NODE_ENV?k(!a||1!==a.nodeType,"traverseAllChildren(...): Encountered an invalid child; DOM elements are not valid children of React components."):k(!a||1!==a.nodeType);for(var v in a)a.hasOwnProperty(v)&&(j=b+(b?m:l)+g(v)+m+e(a[v],0),n=d+o,o+=p(a[v],j,n,f,h))}}return o};b.exports=h}).call(this,a("_process"))},{"./ReactElement":162,"./ReactInstanceHandles":170,"./invariant":236,_process:94}],255:[function(a,b,c){(function(c){"use strict";var d=a("./emptyFunction"),e=d;"production"!==c.env.NODE_ENV&&(e=function(a,b){for(var c=[],d=2,e=arguments.length;e>d;d++)c.push(arguments[d]);if(void 0===b)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(!a){var f=0;console.warn("Warning: "+b.replace(/%s/g,function(){return c[f++]}))}}),b.exports=e}).call(this,a("_process"))},{"./emptyFunction":217,_process:94}],256:[function(a,b,c){"use strict";a("lodash");var d=a("../src/reactTemplates");window.reactTemplates=d},{"../src/reactTemplates":260,lodash:110}],257:[function(a,b,c){"use strict";function d(a,b){if(!b)return{line:1,col:1};var c=a.substring(0,b.startIndex).split("\n");return{line:c.length,col:c[c.length-1].length+1}}function e(a,b,c,d,g){Error.captureStackTrace(this,e),this.name="RTCodeError",this.message=a||"",this.index=f(b),this.startOffset=f(b),this.endOffset=f(c),this.line=f(d),this.column=f(g)}function f(a){return void 0===a?-1:a}function g(a,b,c){var d=h(b,c);return new e(a,d.start,d.end,d.pos.line,d.pos.col)}function h(a,b){var c,e=d(a.html,b);return c=b.data?b.startIndex+b.data.length:b.next?b.next.startIndex:a.html.length,{pos:e,start:b.startIndex,end:c}}Object.defineProperty(Error.prototype,"message",{configurable:!0,enumerable:!0}),Object.defineProperty(Error.prototype,"stack",{configurable:!0,enumerable:!0}),e.prototype=Object.create(Error.prototype),e.build=g,e.norm=f,e.prototype.toIssue=function(){},b.exports={RTCodeError:e,getNodeLoc:h}},{}],258:[function(a,b,c){(function(c){"use strict";var d={ERROR:"ERROR",WARN:"WARN",INFO:"INFO"},e=a("lodash"),f=a("./RTCodeError"),g=f.RTCodeError.norm,h={messages:[],color:!0,cwd:c.cwd(),report:function(a){console.log(a)},verbose:function(a){h.options.verbose&&console.log(a)},info:function(a,b,c,e){h.issue(d.INFO,a,b,c,e)},warn:function(a,b,c,e,f,g){h.issue(d.WARN,a,b,c,e,f,g)},error:function(a,b,c,e,f,g){h.issue(d.ERROR,a,b,c,e,f,g)},issue:function(a,b,c,d,e,f,i){h.messages.push({level:a,msg:b,file:c||null,line:g(d),column:g(e),index:g(f),startOffset:g(f),endOffset:g(i)})},getMessages:function(){return h.messages},clear:function(){h.messages=[]},hasErrors:function(){return e.some(h.messages,{level:d.ERROR})},options:{verbose:!1,outFile:null,format:"stylish"},MESSAGE_LEVEL:d};b.exports=h}).call(this,a("_process"))},{"./RTCodeError":257,_process:94,lodash:110}],259:[function(a,b,c){"use strict";var d=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","defs","ellipse","g","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],e=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","defs","ellipse","g","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan","injection"],f=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","defs","ellipse","g","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan","injection"],g=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","defs","g","line","linearGradient","path","polygon","polyline","radialGradient","rect","stop","svg","text","injection"],h={"0.13.1":d,"0.12.2":d,"0.12.1":d,"0.12.0":d,"0.11.2":e,"0.11.1":f,"0.11.0":f,"0.10.0":g};b.exports=h},{}],260:[function(a,b,c){"use strict";function d(a){switch(a.options.targetVersion){case"0.11.2":case"0.11.1":case"0.11.0":case"0.10.0":return!1;default:return!0}}function e(a){var b="";return x.forEach(a,function(a){b+=a&&0!==a.indexOf(" /*")?","+a:a},this),b}function f(a,b,c){for(var d="",e=!0,f="text"===a.type?",":"+";-1!==c.indexOf("{");){var g=c.indexOf("{"),h=c.substr(0,g);h&&(d+=(e?"":f)+JSON.stringify(h),e=!1);var i,j=1;for(i=g+1;i<c.length&&j>0;i++)j+=da[c.charAt(i)]||0;if(0!==j)throw D.build("Failed to parse text '"+c+"'",b,a);var k=0!==g||i!==c.length-1;d+=(e?"":f)+(k?"(":"")+c.substr(g+1,i-g-2)+(k?")":""),e=!1,c=c.substr(i)}return c&&(d+=(e?"":f)+JSON.stringify(c)),""===d&&(d="true"),d}function g(a){return a=a.trim(),a.length&&"{"===a.charAt(0)&&"}"===a.charAt(a.length-1)}function h(a,b,c,d){d=d||a.boundParams;var e=b.replace(",","")+(a.injectedFunctions.length+1),f="function "+e+"("+d.join(",");return f+=") {\n"+c+"\n}\n",a.injectedFunctions.push(f),e}function i(a,b){var c={};return x.forOwn(a.attribs,function(d,e){var i=ca[e.toLowerCase()]||e;if(c.hasOwnProperty(i))throw D.build("duplicate definition of "+i+" "+JSON.stringify(a.attribs),b,a);if(0!==e.indexOf("on")||g(d))if("style"!==e||g(d))e===Z?c[i]=J({classSet:d}):0!==e.indexOf("rt-")&&(c[i]=f(a,b,d.trim()));else{var j=d.trim().split(";");j=x.compact(x.map(j,function(a){if(a=a.trim(),!a||-1===a.indexOf(":"))return null;var b=a.split(":");return b[0]=b[0].trim(),b[1]=b.slice(1).join(":").trim(),b}));var k=[];x.forEach(j,function(c){k.push(B.convertToCamelCase(c[0])+" : "+f(a,b,c[1].trim()))}),c[i]="{"+k.join(",")+"}"}else{var l=d.split("=>");if(2!==l.length)throw D.build("when using 'on' events, use lambda '(p1,p2)=>body' notation or use {} to return a callback function. error: ["+e+"='"+d+"']",b,a);var m=l[0].replace("(","").replace(")","").trim(),n=l[1].trim(),o=b.boundParams;""!==m.trim()&&(o=o.concat([m.trim()]));var p=h(b,e,n,o);c[i]=p+".bind("+["this"].concat(b.boundParams).join(",")+")"}}),"{"+x.map(c,function(a,b){return JSON.stringify(b)+" : "+a}).join(",")+"}"}function j(a,b){var c=x.contains(A[b.options.targetVersion],a);return d(b)?(c=c||a.match(/^\w+(-\w+)$/),c?"'"+a+"'":a):c?"React.DOM."+a:a}function k(a,b){return{boundParams:[],injectedFunctions:[],html:a,options:b}}function l(a){return x.any(a.children,function(a){return"tag"===a.type&&a.attribs[X]})}function m(a,b){if("tag"===a.type||"style"===a.type){b={boundParams:x.clone(b.boundParams),injectedFunctions:b.injectedFunctions,html:b.html,options:b.options};var c={name:j(a.name,b)};if(a.attribs[$]&&(c.scopeMapping={},c.scopeName="",x.each(b.boundParams,function(a){c.scopeMapping[a]=a}),x.each(a.attribs[$].split(";"),function(d){var e=d.split(" as ");if(e.length<2)throw D.build("invalid scope part '"+d+"'",b,a);var f=e[1].trim();u(f,a,b),B.addIfMissing(b.boundParams,f),c.scopeName+=B.capitalize(f),c.scopeMapping[f]=e[0].trim(),u(c.scopeMapping[f],a,b)})),a.attribs[X]){var g=a.attribs[X].split(" in ");if(2!==g.length)throw D.build("rt-repeat invalid 'in' expression '"+a.attribs[X]+"'",b,a);c.item=g[0].trim(),c.collection=g[1].trim(),u(c.item,a,b),u(c.collection,a,b),B.addIfMissing(b.boundParams,c.item),B.addIfMissing(b.boundParams,c.item+"Index")}if(c.props=i(a,b),a.attribs[_]&&("{}"===c.props?c.props=a.attribs[_]:a.attribs.style||a.attribs["class"]?(c.props=H({generatedProps:c.props,rtProps:a.attribs[_]}),x.contains(b.injectedFunctions,I)||b.injectedFunctions.push(I)):c.props=G({generatedProps:c.props,rtProps:a.attribs[_]})),a.attribs[Y]&&(c.condition=a.attribs[Y].trim()),c.children=a.children?e(x.map(a.children,function(a){var c=m(a,b);return u(c,a,b),c})):"",l(a)?c.body=d(b)?N(c):L(c):c.body=d(b)?M(c):K(c),a.attribs[X]&&(c.repeatFunction=h(b,"repeat"+B.capitalize(c.item),"return "+c.body),c.repeatBinds=["this"].concat(x.reject(b.boundParams,function(a){return a===c.item||a===c.item+"Index"})),c.body=E(c)),a.attribs[Y]&&(c.body=F(c)),a.attribs[$]){var k=h(b,"scope"+c.scopeName,"return "+c.body,x.keys(c.scopeMapping));c.body=k+".apply(this, ["+x.values(c.scopeMapping).join(",")+"])"}return c.body}return"comment"===a.type?O(a):"text"===a.type?a.data.trim()?f(a,b,a.data):"":void 0}function n(a){return"tag"===a.type}function o(a){return x(a).map(function(a){var b=[];return a.children=o(a.children),"tag"===a.type&&x.contains(W,a.name)&&(b=x.filter(a.children,n),x.forEach(b,function(b){b.parent=a}),a.children=x.reject(a.children,n)),[a].concat(b)}).flatten().value()}function p(a,b,c,d){if("tag"===d.type&&d.attribs["rt-if"]&&!d.attribs.key){var e=C.getNodeLoc(b,d);c.warn("rt-if without a key",a.fileName,e.pos.line,e.pos.col,e.start,e.end)}d.children&&d.children.forEach(p.bind(this,a,b,c))}function q(b,c){var d=a("./context");return r(b,d,c)}function r(a,b,c){var d=w.load(a,{lowerCaseTags:!1,lowerCaseAttributeNames:!1,xmlMode:!0,withStartIndices:!0});c=x.defaults({},c,aa);var e=c.defines?x.clone(c.defines):{"react/addons":"React",lodash:"_"},f=k(a,c);p(c,f,b,d.root()[0]);var g=x.filter(d.root()[0].children,{type:"tag"});if(g=o(g),!g||0===g.length)throw new D("Document should have a root element");var h=null;if(x.forEach(g,function(a){if("rt-require"===a.name){if(!a.attribs.dependency||!a.attribs.as)throw D.build("rt-require needs 'dependency' and 'as' attributes",f,a);if(a.children.length)throw D.build("rt-require may have no children",f,a);e[a.attribs.dependency]=a.attribs.as}else{if(null!==h)throw D.build("Document should have no more than a single root element",f,a);h=a}}),null===h)throw D.build("Document should have a single root element",f,d.root()[0]);var i,j=m(h,f),l=x(e).keys().map(function(a){return'"'+a+'"'}).value().join(","),n=x(e).values().value().join(",");i="typescript"===c.modules?x(e).map(function(a,b){return"import "+a+" = require('"+b+"');"}).join("\n"):"es6"===c.modules?x(e).map(function(a,b){return"import "+a+" from '"+b+"';"}).join("\n"):x(e).map(function(a,b){return"var "+a+" = require('"+b+"');"}).join("\n");var q={body:j,injectedFunctions:"",requireNames:n,requirePaths:l,vars:i,name:c.name};q.injectedFunctions=f.injectedFunctions.join("\n");var r=t(q,c);if("typescript"!==c.modules&&"jsrt"!==c.modules)try{var s=y.parse(r,{range:!0,tokens:!0,comment:!0});s=z.attachComments(s,s.comments,s.tokens),r=z.generate(s,{comment:!0})}catch(u){throw new D(u.message,u.index,-1)}return r}function s(a,b,c){c=x.defaults({},c,aa),c.modules="jsrt";var d=/<template>([^]*?)<\/template>/gm,e=a.replace(d,function(a,d){return r(d,b,c).replace(/;$/,"")});try{var f=y.parse(e,{range:!0,tokens:!0,comment:!0});f=z.attachComments(f,f.comments,f.tokens),e=z.generate(f,{comment:!0})}catch(g){throw new D(g.message,g.index,-1)}return e}function t(a,b){var c=V[b.modules];return c(a)}function u(a,b,c){try{y.parse(a)}catch(d){throw D.build(d.description,c,b)}}function v(a){return a.replace(/-/g,"_")}var w=a("cheerio"),x=a("lodash"),y=a("esprima-harmony"),z=a("escodegen"),A=a("./reactDOMSupport"),B=a("./stringUtils"),C=a("./RTCodeError"),D=C.RTCodeError,E=x.template("_.map(<%= collection %>,<%= repeatFunction %>.bind(<%= repeatBinds %>))"),F=x.template("((<%= condition %>)?(<%= body %>):null)"),G=x.template("_.assign({}, <%= generatedProps %>, <%= rtProps %>)"),H=x.template("mergeProps( <%= generatedProps %>, <%= rtProps %>)"),I="function mergeProps(inline,external) {\n var res = _.assign({},inline,external)\nif (inline.hasOwnProperty('style')) {\n res.style = _.defaults(res.style, inline.style);\n}\n if (inline.hasOwnProperty('className') && external.hasOwnProperty('className')) {\n res.className = external.className + ' ' + inline.className;\n} return res;\n}\n",J=x.template('_.keys(_.pick(<%= classSet %>, _.identity)).join(" ")'),K=x.template("<%= name %>(<%= props %><%= children %>)"),L=x.template("<%= name %>.apply(this, [<%= props %><%= children %>])"),M=x.template("React.createElement(<%= name %>,<%= props %><%= children %>)"),N=x.template("React.createElement.apply(this, [<%= name %>,<%= props %><%= children %>])"),O=x.template(" /* <%= data %> */ "),P=x.template("define(<%= name ? '\"'+name + '\", ' : '' %>[<%= requirePaths %>], function (<%= requireNames %>) {\n'use strict';\n <%= injectedFunctions %>\nreturn function(){ return <%= body %>};\n});"),Q=x.template("'use strict';\n<%= vars %>\n\n<%= injectedFunctions %>\nmodule.exports = function(){ return <%= body %>};\n"),R=x.template("<%= vars %>\n\n<%= injectedFunctions %>\nexport default function(){ return <%= body %>}\n"),S=x.template("var <%= name %> = function () {\n<%= injectedFunctions %>\nreturn <%= body %>\n};\n"),T=x.template("<%= vars %>\n\n<%= injectedFunctions %>\nvar fn = function() { return <%= body %> };\nexport = fn\n"),U=x.template("(function () {\n <%= injectedFunctions %>\n return function(){\nreturn <%= body %>}}\n)()"),V={amd:P,commonjs:Q,typescript:T,es6:R,none:S,jsrt:U},W=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],X="rt-repeat",Y="rt-if",Z="rt-class",$="rt-scope",_="rt-props",aa={modules:"amd",version:!1,force:!1,format:"stylish",targetVersion:"0.13.1"},ba=["accept","acceptCharset","accessKey","action","allowFullScreen","allowTransparency","alt","async","autoComplete","autoPlay","cellPadding","cellSpacing","charSet","checked","classID","className","cols","colSpan","content","contentEditable","contextMenu","controls","coords","crossOrigin","data","dateTime","defer","dir","disabled","download","draggable","encType","form","formNoValidate","frameBorder","height","hidden","href","hrefLang","htmlFor","httpEquiv","icon","id","label","lang","list","loop","manifest","max","maxLength","media","mediaGroup","method","min","multiple","muted","name","noValidate","open","pattern","placeholder","poster","preload","radioGroup","readOnly","rel","required","role","rows","rowSpan","sandbox","scope","scrolling","seamless","selected","shape","size","sizes","span","spellCheck","src","srcDoc","srcSet","start","step","style","tabIndex","target","title","type","useMap","value","width","wmode"],ca={"class":"className","rt-class":"className","for":"htmlFor"};x.forEach(ba,function(a){a!==a.toLowerCase()&&(ca[a.toLowerCase()]=a)});var da={"{":1,"}":-1};b.exports={convertTemplateToReact:q,convertRT:r,convertJSRTToJS:s,RTCodeError:D,normalizeName:v,_test:{convertText:f}}},{"./RTCodeError":257,"./context":258,"./reactDOMSupport":259,"./stringUtils":261,cheerio:1,escodegen:66,"esprima-harmony":84,lodash:110}],261:[function(a,b,c){"use strict";function d(a){return a.replace(/-([a-z])/g,function(a){return a[1].toUpperCase()})}function e(a){return a[0].toUpperCase()+a.slice(1)}function f(a,b){g.contains(a,b)||a.push(b)}var g=a("lodash");b.exports={convertToCamelCase:d,capitalize:e,addIfMissing:f}},{lodash:110}],"react/addons":[function(a,b,c){b.exports=a("./lib/React")},{"./lib/React":138}]},{},[256]);
\ No newline at end of file
+b.exports=d},{}],245:[function(a,b,c){"use strict";function d(a){var b={};return function(c){return b.hasOwnProperty(c)?b[c]:b[c]=a.call(this,c)}}b.exports=d},{}],246:[function(a,b,c){(function(c){"use strict";function d(a,b){"production"!==c.env.NODE_ENV?e(a&&!/[^a-z0-9_]/.test(a),"You must provide an eventName using only the characters [a-z0-9_]"):e(a&&!/[^a-z0-9_]/.test(a))}var e=a("./invariant");b.exports=d}).call(this,a("_process"))},{"./invariant":236,_process:94}],247:[function(a,b,c){(function(c){"use strict";function d(a){return"production"!==c.env.NODE_ENV?f(e.isValidElement(a),"onlyChild must be passed a children with exactly one child."):f(e.isValidElement(a)),a}var e=a("./ReactElement"),f=a("./invariant");b.exports=d}).call(this,a("_process"))},{"./ReactElement":162,"./invariant":236,_process:94}],248:[function(a,b,c){"use strict";var d,e=a("./ExecutionEnvironment");e.canUseDOM&&(d=window.performance||window.msPerformance||window.webkitPerformance),b.exports=d||{}},{"./ExecutionEnvironment":131}],249:[function(a,b,c){var d=a("./performance");d&&d.now||(d=Date);var e=d.now.bind(d);b.exports=e},{"./performance":248}],250:[function(a,b,c){"use strict";var d=a("./ExecutionEnvironment"),e=/^[ \r\n\t\f]/,f=/<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/,g=function(a,b){a.innerHTML=b};if(d.canUseDOM){var h=document.createElement("div");h.innerHTML=" ",""===h.innerHTML&&(g=function(a,b){if(a.parentNode&&a.parentNode.replaceChild(a,a),e.test(b)||"<"===b[0]&&f.test(b)){a.innerHTML="\ufeff"+b;var c=a.firstChild;1===c.data.length?a.removeChild(c):c.deleteData(0,1)}else a.innerHTML=b})}b.exports=g},{"./ExecutionEnvironment":131}],251:[function(a,b,c){"use strict";function d(a,b){if(a===b)return!0;var c;for(c in a)if(a.hasOwnProperty(c)&&(!b.hasOwnProperty(c)||a[c]!==b[c]))return!1;for(c in b)if(b.hasOwnProperty(c)&&!a.hasOwnProperty(c))return!1;return!0}b.exports=d},{}],252:[function(a,b,c){"use strict";function d(a,b){return a&&b&&a.type===b.type&&a.key===b.key&&a._owner===b._owner?!0:!1}b.exports=d},{}],253:[function(a,b,c){(function(c){function d(a){var b=a.length;if("production"!==c.env.NODE_ENV?e(!Array.isArray(a)&&("object"==typeof a||"function"==typeof a),"toArray: Array-like object expected"):e(!Array.isArray(a)&&("object"==typeof a||"function"==typeof a)),"production"!==c.env.NODE_ENV?e("number"==typeof b,"toArray: Object needs a length property"):e("number"==typeof b),"production"!==c.env.NODE_ENV?e(0===b||b-1 in a,"toArray: Object should have keys for indices"):e(0===b||b-1 in a),a.hasOwnProperty)try{return Array.prototype.slice.call(a)}catch(d){}for(var f=Array(b),g=0;b>g;g++)f[g]=a[g];return f}var e=a("./invariant");b.exports=d}).call(this,a("_process"))},{"./invariant":236,_process:94}],254:[function(a,b,c){(function(c){"use strict";function d(a){return n[a]}function e(a,b){return a&&null!=a.key?g(a.key):b.toString(36)}function f(a){return(""+a).replace(o,d)}function g(a){return"$"+f(a)}function h(a,b,c){return null==a?0:p(a,"",0,b,c)}var i=a("./ReactElement"),j=a("./ReactInstanceHandles"),k=a("./invariant"),l=j.SEPARATOR,m=":",n={"=":"=0",".":"=1",":":"=2"},o=/[=.:]/g,p=function(a,b,d,f,h){var j,n,o=0;if(Array.isArray(a))for(var q=0;q<a.length;q++){var r=a[q];j=b+(b?m:l)+e(r,q),n=d+o,o+=p(r,j,n,f,h)}else{var s=typeof a,t=""===b,u=t?l+e(a,0):b;if(null==a||"boolean"===s)f(h,null,u,d),o=1;else if("string"===s||"number"===s||i.isValidElement(a))f(h,a,u,d),o=1;else if("object"===s){"production"!==c.env.NODE_ENV?k(!a||1!==a.nodeType,"traverseAllChildren(...): Encountered an invalid child; DOM elements are not valid children of React components."):k(!a||1!==a.nodeType);for(var v in a)a.hasOwnProperty(v)&&(j=b+(b?m:l)+g(v)+m+e(a[v],0),n=d+o,o+=p(a[v],j,n,f,h))}}return o};b.exports=h}).call(this,a("_process"))},{"./ReactElement":162,"./ReactInstanceHandles":170,"./invariant":236,_process:94}],255:[function(a,b,c){(function(c){"use strict";var d=a("./emptyFunction"),e=d;"production"!==c.env.NODE_ENV&&(e=function(a,b){for(var c=[],d=2,e=arguments.length;e>d;d++)c.push(arguments[d]);if(void 0===b)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(!a){var f=0;console.warn("Warning: "+b.replace(/%s/g,function(){return c[f++]}))}}),b.exports=e}).call(this,a("_process"))},{"./emptyFunction":217,_process:94}],256:[function(a,b,c){"use strict";a("lodash");var d=a("../src/reactTemplates");window.reactTemplates=d},{"../src/reactTemplates":260,lodash:110}],257:[function(a,b,c){"use strict";function d(a,b){if(!b)return{line:1,col:1};var c=a.substring(0,b.startIndex).split("\n");return{line:c.length,col:c[c.length-1].length+1}}function e(a,b,c,d,g){Error.captureStackTrace(this,e),this.name="RTCodeError",this.message=a||"",this.index=f(b),this.startOffset=f(b),this.endOffset=f(c),this.line=f(d),this.column=f(g)}function f(a){return void 0===a?-1:a}function g(a,b,c){var d=h(b,c);return new e(a,d.start,d.end,d.pos.line,d.pos.col)}function h(a,b){var c,e=d(a.html,b);return c=b.data?b.startIndex+b.data.length:b.next?b.next.startIndex:a.html.length,{pos:e,start:b.startIndex,end:c}}Object.defineProperty(Error.prototype,"message",{configurable:!0,enumerable:!0}),Object.defineProperty(Error.prototype,"stack",{configurable:!0,enumerable:!0}),e.prototype=Object.create(Error.prototype),e.build=g,e.norm=f,e.prototype.toIssue=function(){},b.exports={RTCodeError:e,getNodeLoc:h}},{}],258:[function(a,b,c){(function(c){"use strict";var d={ERROR:"ERROR",WARN:"WARN",INFO:"INFO"},e=a("lodash"),f=a("./RTCodeError"),g=f.RTCodeError.norm,h={messages:[],color:!0,cwd:c.cwd(),report:function(a){console.log(a)},verbose:function(a){h.options.verbose&&console.log(a)},info:function(a,b,c,e){h.issue(d.INFO,a,b,c,e)},warn:function(a,b,c,e,f,g){h.issue(d.WARN,a,b,c,e,f,g)},error:function(a,b,c,e,f,g){h.issue(d.ERROR,a,b,c,e,f,g)},issue:function(a,b,c,d,e,f,i){h.messages.push({level:a,msg:b,file:c||null,line:g(d),column:g(e),index:g(f),startOffset:g(f),endOffset:g(i)})},getMessages:function(){return h.messages},clear:function(){h.messages=[]},hasErrors:function(){return e.some(h.messages,{level:d.ERROR})},options:{verbose:!1,outFile:null,format:"stylish"},MESSAGE_LEVEL:d};b.exports=h}).call(this,a("_process"))},{"./RTCodeError":257,_process:94,lodash:110}],259:[function(a,b,c){"use strict";var d=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","defs","ellipse","g","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],e=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","defs","ellipse","g","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan","injection"],f=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","defs","ellipse","g","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan","injection"],g=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","defs","g","line","linearGradient","path","polygon","polyline","radialGradient","rect","stop","svg","text","injection"],h={"0.13.1":d,"0.12.2":d,"0.12.1":d,"0.12.0":d,"0.11.2":e,"0.11.1":f,"0.11.0":f,"0.10.0":g};b.exports=h},{}],260:[function(a,b,c){"use strict";function d(a){switch(a.options.targetVersion){case"0.11.2":case"0.11.1":case"0.11.0":case"0.10.0":return!1;default:return!0}}function e(a){var b="";return x.forEach(a,function(a){b+=a&&0!==a.indexOf(" /*")?","+a:a},this),b}function f(a,b,c){for(var d="",e=!0,f="text"===a.type?",":"+";-1!==c.indexOf("{");){var g=c.indexOf("{"),h=c.substr(0,g);h&&(d+=(e?"":f)+JSON.stringify(h),e=!1);var i,j=1;for(i=g+1;i<c.length&&j>0;i++)j+=da[c.charAt(i)]||0;if(0!==j)throw D.build("Failed to parse text '"+c+"'",b,a);var k=0!==g||i!==c.length-1;d+=(e?"":f)+(k?"(":"")+c.substr(g+1,i-g-2)+(k?")":""),e=!1,c=c.substr(i)}return c&&(d+=(e?"":f)+JSON.stringify(c)),""===d&&(d="true"),d}function g(a){return a=a.trim(),a.length&&"{"===a.charAt(0)&&"}"===a.charAt(a.length-1)}function h(a,b,c,d){d=d||a.boundParams;var e=b.replace(",","")+(a.injectedFunctions.length+1),f="function "+e+"("+d.join(",");return f+=") {\n"+c+"\n}\n",a.injectedFunctions.push(f),e}function i(a,b){var c={};return x.forOwn(a.attribs,function(d,e){var i=ca[e.toLowerCase()]||e;if(c.hasOwnProperty(i))throw D.build("duplicate definition of "+i+" "+JSON.stringify(a.attribs),b,a);if(0!==e.indexOf("on")||g(d))if("style"!==e||g(d))e===Z?c[i]=J({classSet:d}):0!==e.indexOf("rt-")&&(c[i]=f(a,b,d.trim()));else{var j=d.trim().split(";");j=x.compact(x.map(j,function(a){if(a=a.trim(),!a||-1===a.indexOf(":"))return null;var b=a.split(":");return b[0]=b[0].trim(),b[1]=b.slice(1).join(":").trim(),b}));var k=[];x.forEach(j,function(c){k.push(B.convertToCamelCase(c[0])+" : "+f(a,b,c[1].trim()))}),c[i]="{"+k.join(",")+"}"}else{var l=d.split("=>");if(2!==l.length)throw D.build("when using 'on' events, use lambda '(p1,p2)=>body' notation or use {} to return a callback function. error: ["+e+"='"+d+"']",b,a);var m=l[0].replace("(","").replace(")","").trim(),n=l[1].trim(),o=b.boundParams;""!==m.trim()&&(o=o.concat([m.trim()]));var p=h(b,e,n,o);c[i]=p+".bind("+["this"].concat(b.boundParams).join(",")+")"}}),"{"+x.map(c,function(a,b){return JSON.stringify(b)+" : "+a}).join(",")+"}"}function j(a,b){var c=x.contains(A[b.options.targetVersion],a);return d(b)?(c=c||a.match(/^\w+(-\w+)$/),c?"'"+a+"'":a):c?"React.DOM."+a:a}function k(a,b){return{boundParams:[],injectedFunctions:[],html:a,options:b}}function l(a){return x.any(a.children,function(a){return"tag"===a.type&&a.attribs[X]})}function m(a,b){if("tag"===a.type||"style"===a.type){b={boundParams:x.clone(b.boundParams),injectedFunctions:b.injectedFunctions,html:b.html,options:b.options};var c={name:j(a.name,b)};if(a.attribs[$]&&(c.scopeMapping={},c.scopeName="",x.each(b.boundParams,function(a){c.scopeMapping[a]=a}),x.each(a.attribs[$].split(";"),function(d){if(0!==d.trim().length){var e=d.split(" as ");if(e.length<2)throw D.build("invalid scope part '"+d+"'",b,a);var f=e[1].trim();u(f,a,b),B.addIfMissing(b.boundParams,f),c.scopeName+=B.capitalize(f),c.scopeMapping[f]=e[0].trim(),u(c.scopeMapping[f],a,b)}})),a.attribs[X]){var g=a.attribs[X].split(" in ");if(2!==g.length)throw D.build("rt-repeat invalid 'in' expression '"+a.attribs[X]+"'",b,a);c.item=g[0].trim(),c.collection=g[1].trim(),u(c.item,a,b),u(c.collection,a,b),B.addIfMissing(b.boundParams,c.item),B.addIfMissing(b.boundParams,c.item+"Index")}if(c.props=i(a,b),a.attribs[_]&&("{}"===c.props?c.props=a.attribs[_]:a.attribs.style||a.attribs["class"]?(c.props=H({generatedProps:c.props,rtProps:a.attribs[_]}),x.contains(b.injectedFunctions,I)||b.injectedFunctions.push(I)):c.props=G({generatedProps:c.props,rtProps:a.attribs[_]})),a.attribs[Y]&&(c.condition=a.attribs[Y].trim()),c.children=a.children?e(x.map(a.children,function(a){var c=m(a,b);return u(c,a,b),c})):"",l(a)?c.body=d(b)?N(c):L(c):c.body=d(b)?M(c):K(c),a.attribs[X]&&(c.repeatFunction=h(b,"repeat"+B.capitalize(c.item),"return "+c.body),c.repeatBinds=["this"].concat(x.reject(b.boundParams,function(a){return a===c.item||a===c.item+"Index"})),c.body=E(c)),a.attribs[Y]&&(c.body=F(c)),a.attribs[$]){var k=h(b,"scope"+c.scopeName,"return "+c.body,x.keys(c.scopeMapping));c.body=k+".apply(this, ["+x.values(c.scopeMapping).join(",")+"])"}return c.body}return"comment"===a.type?O(a):"text"===a.type?a.data.trim()?f(a,b,a.data):"":void 0}function n(a){return"tag"===a.type}function o(a){return x(a).map(function(a){var b=[];return a.children=o(a.children),"tag"===a.type&&x.contains(W,a.name)&&(b=x.filter(a.children,n),x.forEach(b,function(b){b.parent=a}),a.children=x.reject(a.children,n)),[a].concat(b)}).flatten().value()}function p(a,b,c,d){if("tag"===d.type&&d.attribs["rt-if"]&&!d.attribs.key){var e=C.getNodeLoc(b,d);c.warn("rt-if without a key",a.fileName,e.pos.line,e.pos.col,e.start,e.end)}d.children&&d.children.forEach(p.bind(this,a,b,c))}function q(b,c){var d=a("./context");return r(b,d,c)}function r(a,b,c){var d=w.load(a,{lowerCaseTags:!1,lowerCaseAttributeNames:!1,xmlMode:!0,withStartIndices:!0});c=x.defaults({},c,aa);var e=c.defines?x.clone(c.defines):{"react/addons":"React",lodash:"_"},f=k(a,c);p(c,f,b,d.root()[0]);var g=x.filter(d.root()[0].children,{type:"tag"});if(g=o(g),!g||0===g.length)throw new D("Document should have a root element");var h=null;if(x.forEach(g,function(a){if("rt-require"===a.name){if(!a.attribs.dependency||!a.attribs.as)throw D.build("rt-require needs 'dependency' and 'as' attributes",f,a);if(a.children.length)throw D.build("rt-require may have no children",f,a);e[a.attribs.dependency]=a.attribs.as}else{if(null!==h)throw D.build("Document should have no more than a single root element",f,a);h=a}}),null===h)throw D.build("Document should have a single root element",f,d.root()[0]);var i,j=m(h,f),l=x(e).keys().map(function(a){return'"'+a+'"'}).value().join(","),n=x(e).values().value().join(",");i="typescript"===c.modules?x(e).map(function(a,b){return"import "+a+" = require('"+b+"');"}).join("\n"):"es6"===c.modules?x(e).map(function(a,b){return"import "+a+" from '"+b+"';"}).join("\n"):x(e).map(function(a,b){return"var "+a+" = require('"+b+"');"}).join("\n");var q={body:j,injectedFunctions:"",requireNames:n,requirePaths:l,vars:i,name:c.name};q.injectedFunctions=f.injectedFunctions.join("\n");var r=t(q,c);if("typescript"!==c.modules&&"jsrt"!==c.modules)try{var s=y.parse(r,{range:!0,tokens:!0,comment:!0});s=z.attachComments(s,s.comments,s.tokens),r=z.generate(s,{comment:!0})}catch(u){throw new D(u.message,u.index,-1)}return r}function s(a,b,c){c=x.defaults({},c,aa),c.modules="jsrt";var d=/<template>([^]*?)<\/template>/gm,e=a.replace(d,function(a,d){return r(d,b,c).replace(/;$/,"")});try{var f=y.parse(e,{range:!0,tokens:!0,comment:!0});f=z.attachComments(f,f.comments,f.tokens),e=z.generate(f,{comment:!0})}catch(g){throw new D(g.message,g.index,-1)}return e}function t(a,b){var c=V[b.modules];return c(a)}function u(a,b,c){try{y.parse(a)}catch(d){throw D.build(d.description,c,b)}}function v(a){return a.replace(/-/g,"_")}var w=a("cheerio"),x=a("lodash"),y=a("esprima-harmony"),z=a("escodegen"),A=a("./reactDOMSupport"),B=a("./stringUtils"),C=a("./RTCodeError"),D=C.RTCodeError,E=x.template("_.map(<%= collection %>,<%= repeatFunction %>.bind(<%= repeatBinds %>))"),F=x.template("((<%= condition %>)?(<%= body %>):null)"),G=x.template("_.assign({}, <%= generatedProps %>, <%= rtProps %>)"),H=x.template("mergeProps( <%= generatedProps %>, <%= rtProps %>)"),I="function mergeProps(inline,external) {\n var res = _.assign({},inline,external)\nif (inline.hasOwnProperty('style')) {\n res.style = _.defaults(res.style, inline.style);\n}\n if (inline.hasOwnProperty('className') && external.hasOwnProperty('className')) {\n res.className = external.className + ' ' + inline.className;\n} return res;\n}\n",J=x.template('_.keys(_.pick(<%= classSet %>, _.identity)).join(" ")'),K=x.template("<%= name %>(<%= props %><%= children %>)"),L=x.template("<%= name %>.apply(this, [<%= props %><%= children %>])"),M=x.template("React.createElement(<%= name %>,<%= props %><%= children %>)"),N=x.template("React.createElement.apply(this, [<%= name %>,<%= props %><%= children %>])"),O=x.template(" /* <%= data %> */ "),P=x.template("define(<%= name ? '\"'+name + '\", ' : '' %>[<%= requirePaths %>], function (<%= requireNames %>) {\n'use strict';\n <%= injectedFunctions %>\nreturn function(){ return <%= body %>};\n});"),Q=x.template("'use strict';\n<%= vars %>\n\n<%= injectedFunctions %>\nmodule.exports = function(){ return <%= body %>};\n"),R=x.template("<%= vars %>\n\n<%= injectedFunctions %>\nexport default function(){ return <%= body %>}\n"),S=x.template("var <%= name %> = function () {\n<%= injectedFunctions %>\nreturn <%= body %>\n};\n"),T=x.template("<%= vars %>\n\n<%= injectedFunctions %>\nvar fn = function() { return <%= body %> };\nexport = fn\n"),U=x.template("(function () {\n <%= injectedFunctions %>\n return function(){\nreturn <%= body %>}}\n)()"),V={amd:P,commonjs:Q,typescript:T,es6:R,none:S,jsrt:U},W=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],X="rt-repeat",Y="rt-if",Z="rt-class",$="rt-scope",_="rt-props",aa={modules:"amd",version:!1,force:!1,format:"stylish",targetVersion:"0.13.1"},ba=["accept","acceptCharset","accessKey","action","allowFullScreen","allowTransparency","alt","async","autoComplete","autoPlay","cellPadding","cellSpacing","charSet","checked","classID","className","cols","colSpan","content","contentEditable","contextMenu","controls","coords","crossOrigin","data","dateTime","defer","dir","disabled","download","draggable","encType","form","formNoValidate","frameBorder","height","hidden","href","hrefLang","htmlFor","httpEquiv","icon","id","label","lang","list","loop","manifest","max","maxLength","media","mediaGroup","method","min","multiple","muted","name","noValidate","open","pattern","placeholder","poster","preload","radioGroup","readOnly","rel","required","role","rows","rowSpan","sandbox","scope","scrolling","seamless","selected","shape","size","sizes","span","spellCheck","src","srcDoc","srcSet","start","step","style","tabIndex","target","title","type","useMap","value","width","wmode"],ca={"class":"className","rt-class":"className","for":"htmlFor"};x.forEach(ba,function(a){a!==a.toLowerCase()&&(ca[a.toLowerCase()]=a)});var da={"{":1,"}":-1};b.exports={convertTemplateToReact:q,convertRT:r,convertJSRTToJS:s,RTCodeError:D,normalizeName:v,_test:{convertText:f}}},{"./RTCodeError":257,"./context":258,"./reactDOMSupport":259,"./stringUtils":261,cheerio:1,escodegen:66,"esprima-harmony":84,lodash:110}],261:[function(a,b,c){"use strict";function d(a){return a.replace(/-([a-z])/g,function(a){return a[1].toUpperCase()})}function e(a){return a[0].toUpperCase()+a.slice(1)}function f(a,b){g.contains(a,b)||a.push(b)}var g=a("lodash");b.exports={convertToCamelCase:d,capitalize:e,addIfMissing:f}},{lodash:110}],"react/addons":[function(a,b,c){b.exports=a("./lib/React")},{"./lib/React":138}]},{},[256]);
\ No newline at end of file
diff --git a/playground/fiddle-main.js b/playground/fiddle-main.js
index 42bcae1..e0e50d0 100644
--- a/playground/fiddle-main.js
+++ b/playground/fiddle-main.js
@@ -4,7 +4,7 @@ requirejs.config({
         lodash: '//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min',
         jquery: '//code.jquery.com/jquery-2.1.4.min',
         firebase: 'https://cdn.firebase.com/js/client/2.0.5/firebase',
-        react: '//fb.me/react-with-addons-0.12.2',
+        react: '//fb.me/react-with-addons-0.13.3.min',
         //ace: '../ace-builds-1.1.8/src-min/ace',
         fiddle: './fiddle',
         text: 'libs/requirejs-plugins/text',
diff --git a/playground/fiddle.js b/playground/fiddle.js
index 4a51d85..3f87208 100644
--- a/playground/fiddle.js
+++ b/playground/fiddle.js
@@ -9,7 +9,7 @@ define(['react', 'firebase', 'lodash', './fiddle.rt', 'jquery'], function (React
     function generateRandomId() {
         var uuid = 'xxxxxxxx'.replace(/[xy]/g, function (c) {
             var r = _.random(0, 15);
-            return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
+            return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
         });
         return uuid;
     }
diff --git a/playground/home-main.js b/playground/home-main.js
index 8af54c0..711b8b6 100644
--- a/playground/home-main.js
+++ b/playground/home-main.js
@@ -4,7 +4,7 @@ requirejs.config({
         lodash: '//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min',
         jquery: '//code.jquery.com/jquery-2.1.4.min',
         firebase: 'https://cdn.firebase.com/js/client/2.0.5/firebase',
-        react: '//fb.me/react-with-addons-0.12.2',
+        react: '//fb.me/react-with-addons-0.13.3.min',
         text: 'libs/requirejs-plugins/text',
         json: 'libs/requirejs-plugins/json'
         //ace: '../ace-builds-1.1.8/src-min/ace',
@@ -18,9 +18,7 @@ requirejs.config({
         react: {exports: 'React'}
     },
     map: {
-        '*': {
-            'react/addons': 'react'
-        }
+        '*': {'react/addons': 'react'}
     }
 });
 
diff --git a/playground/playground.js b/playground/playground.js
index 00724d9..2a7c842 100644
--- a/playground/playground.js
+++ b/playground/playground.js
@@ -111,7 +111,7 @@ define(['react', 'jquery', 'lodash', './playground-fiddle.rt', './playground.rt'
             };
         },
         getLayoutClass: function () {
-            return (this.props.direction === 'horizontal' && 'horizontal') || 'vertical';
+            return (this.props.direction === 'horizontal' && 'horizontal') || 'vertical'; //eslint-disable-line no-extra-parens
         },
         //executeCode: function() {
         //    var mountNode = this.refs.mount.getDOMNode();
@@ -247,7 +247,7 @@ define(['react', 'jquery', 'lodash', './playground-fiddle.rt', './playground.rt'
         componentDidUpdate: function () {
             this.renderSample();
         },
-        componentWillUnmount: function (){
+        componentWillUnmount: function () {
             window.removeEventListener('resize', this.calcSize);
         },
         calcSize: function () {
diff --git a/playground/playground.rt b/playground/playground.rt
index 6c92487..eb51884 100644
--- a/playground/playground.rt
+++ b/playground/playground.rt
@@ -5,7 +5,7 @@
     <div id="{this.props.id}-myTab" class="code-area {this.getLayoutClass()}">
         <!-- Nav tabs -->
         <ul class="nav nav-tabs" role="tablist">
-            <li rt-repeat="tab in this.getTabs()" role="presentation"
+            <li rt-repeat="tab in this.getTabs()" role="presentation" key="tab{tabIndex}"
                 rt-class="{active:this.state.currentTab === tab[0]}"
                 onClick="(evt)=> evt.preventDefault();this.setState({'currentTab':tab[0]});">
                 <a aria-controls="{tab[1]}">{tab[1]}</a>
diff --git a/playground/playground.rt.js b/playground/playground.rt.js
index 88dc7d8..4f35b97 100644
--- a/playground/playground.rt.js
+++ b/playground/playground.rt.js
@@ -11,6 +11,7 @@ define([
     function repeatTab2(tab, tabIndex) {
         return React.createElement('li', {
             'role': 'presentation',
+            'key': 'tab' + tabIndex,
             'className': _.keys(_.pick({ active: this.state.currentTab === tab[0] }, _.identity)).join(' '),
             'onClick': onClick1.bind(this, tab, tabIndex)
         }, React.createElement('a', { 'aria-controls': tab[1] }, tab[1]));
diff --git a/playground/samples/hello.code b/playground/samples/hello.code
index de1d2d7..8ea027f 100644
--- a/playground/samples/hello.code
+++ b/playground/samples/hello.code
@@ -1,5 +1,3 @@
 var <%= name %> = React.createClass({
-    render: function () {
-        return <%= name %>RT.apply(this);
-    }
+    render: <%= name %>RT
 });
\ No newline at end of file
diff --git a/playground/samples/rt-if.code b/playground/samples/rt-if.code
index 3a28e0c..bdf3d8c 100644
--- a/playground/samples/rt-if.code
+++ b/playground/samples/rt-if.code
@@ -5,7 +5,5 @@ var <%= name %> = React.createClass({
     toggle: function() {
         this.setState({open: !this.state.open});
     },
-    render: function () {
-        return <%= name %>RT.apply(this);
-    }
+    render: <%= name %>RT
 });
\ No newline at end of file
diff --git a/playground/samples/rt-props.code b/playground/samples/rt-props.code
index dc3576e..0955434 100644
--- a/playground/samples/rt-props.code
+++ b/playground/samples/rt-props.code
@@ -12,7 +12,5 @@ var <%= name %> = React.createClass({
         ret.style[this.state.key] = this.state.val;
         return ret;
     },
-    render: function () {
-        return <%= name %>RT.apply(this);
-    }
+    render: <%= name %>RT
 });
\ No newline at end of file
diff --git a/playground/samples/rt-repeat.code b/playground/samples/rt-repeat.code
index ba19949..36450cf 100644
--- a/playground/samples/rt-repeat.code
+++ b/playground/samples/rt-repeat.code
@@ -4,7 +4,5 @@ var <%= name %> = React.createClass({
             items: ['One', 'Two', 'Three']
         };
     },
-    render: function () {
-        return <%= name %>RT.apply(this);
-    }
+    render: <%= name %>RT
 });
\ No newline at end of file
diff --git a/playground/samples/todo.code b/playground/samples/todo.code
index 43561ec..db4f3f0 100644
--- a/playground/samples/todo.code
+++ b/playground/samples/todo.code
@@ -19,9 +19,13 @@ var <%= name %> = React.createClass({
         this.setState({todos: todos});
     },
     clearDone: function () {
-        this.setState({todos: _.filter(this.state.todos, {done: false})});
+        this.setState({todos: this.getPending()});
     },
-    render: function () {
-        return <%= name %>RT.apply(this);
-    }
+    getDone: function () {
+        return _.filter(this.state.todos, {done: true});
+    },
+    getPending: function () {
+        return _.filter(this.state.todos, {done: false});
+    },
+    render: <%= name %>RT
 });
\ No newline at end of file
diff --git a/playground/samples/todo.rt b/playground/samples/todo.rt
index 2cc706a..c35addf 100644
--- a/playground/samples/todo.rt
+++ b/playground/samples/todo.rt
@@ -1,7 +1,7 @@
 <div>
-    <strong>{_.filter(this.state.todos, {done:true}).length}</strong>
+    <strong>{this.getDone().length}</strong>
     done,
-    <strong>{_.filter(this.state.todos, {done:false}).length}</strong>
+    <strong>{this.getPending().length}</strong>
     pending
     <br/>
     <div rt-repeat="todo in this.state.todos" key="{todo.key}">
diff --git a/playground/samples/todo2.code b/playground/samples/todo2.code
index 5e234a9..364b35e 100644
--- a/playground/samples/todo2.code
+++ b/playground/samples/todo2.code
@@ -1,8 +1,7 @@
 {
     mixins: [React.addons.LinkedStateMixin],
-        getInitialState: function () {
-    return {
-        edited: '', todos: [], counter: 0};
+    getInitialState: function () {
+        return {edited: '', todos: [], counter: 0};
     },
     add: function () {
         if (this.state.edited.trim().length === 0) {
diff --git a/playground/samples/weather.code b/playground/samples/weather.code
index fc58e6e..5f57e0f 100644
--- a/playground/samples/weather.code
+++ b/playground/samples/weather.code
@@ -30,7 +30,5 @@ var <%= name %> = React.createClass({
     fetchWeatherCallback: function(result) {
         this.setState({ loading:false, info: result.list });
     },
-    render: function () {
-        return <%= name %>RT.apply(this);
-    }
+    render: <%= name %>RT
 });
\ No newline at end of file