HTML Editor Syntax Highlighter - Version 1.6.1

Version Description

  • Compatibility with WP 4.0
Download this release

Release Info

Developer nixdns
Plugin Icon 128x128 HTML Editor Syntax Highlighter
Version 1.6.1
Comparing to
See all releases

Code changes from version 1.6.0 to 1.6.1

html-editor-syntax-highlighter.php CHANGED
@@ -1,33 +1,33 @@
1
- <?php
2
  /**
3
  * Plugin Name: HTML Editor Syntax Highlighter
4
  * Plugin URI: http://wordpress.org/extend/plugins/html-editor-syntax-highlighter/
5
  * Description: Syntax Highlighting in WordPress HTML Editor
6
  * Author: Petr Mukhortov
7
  * Author URI: http://mukhortov.com/
8
- * Version: 1.6.0
9
  * Requires at least: 3.3
10
- * Tested up to: 3.9.1
11
- * Stable tag: 1.6.0
12
  **/
13
 
14
  if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
15
 
16
- define('HESH_LIBS',plugins_url('/lib/',__FILE__));
17
 
18
  class wp_html_editor_syntax {
19
- public function __construct(){
20
- add_action('admin_head',array(&$this,'admin_head'));
21
- add_action('admin_footer',array(&$this,'admin_footer'));
22
  }
23
- public function admin_head(){
24
  if (!$this->is_editor())
25
  return;
26
  ?>
27
  <link rel="stylesheet" href="<?php echo HESH_LIBS; ?>hesh.min.css">
28
  <?php
29
  }
30
- public function admin_footer(){
31
  if (!$this->is_editor())
32
  return;
33
  ?>
@@ -35,13 +35,14 @@ class wp_html_editor_syntax {
35
  <?php
36
  }
37
  private function is_editor(){
38
- if (!strstr($_SERVER['SCRIPT_NAME'],'post.php') && !strstr($_SERVER['SCRIPT_NAME'],'post-new.php')) {
39
  return false;
40
  }
41
  return true;
42
  }
43
  }
44
 
45
- if (is_admin())
46
  $hesh = new wp_html_editor_syntax();
 
47
  ?>
1
+  <?php
2
  /**
3
  * Plugin Name: HTML Editor Syntax Highlighter
4
  * Plugin URI: http://wordpress.org/extend/plugins/html-editor-syntax-highlighter/
5
  * Description: Syntax Highlighting in WordPress HTML Editor
6
  * Author: Petr Mukhortov
7
  * Author URI: http://mukhortov.com/
8
+ * Version: 1.6.1
9
  * Requires at least: 3.3
10
+ * Tested up to: 4.0
11
+ * Stable tag: 1.6.1
12
  **/
13
 
14
  if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
15
 
16
+ define('HESH_LIBS', plugins_url('/lib/',__FILE__));
17
 
18
  class wp_html_editor_syntax {
19
+ public function __construct() {
20
+ add_action('admin_head', array(&$this,'admin_head'));
21
+ add_action('admin_footer', array(&$this,'admin_footer'));
22
  }
23
+ public function admin_head() {
24
  if (!$this->is_editor())
25
  return;
26
  ?>
27
  <link rel="stylesheet" href="<?php echo HESH_LIBS; ?>hesh.min.css">
28
  <?php
29
  }
30
+ public function admin_footer() {
31
  if (!$this->is_editor())
32
  return;
33
  ?>
35
  <?php
36
  }
37
  private function is_editor(){
38
+ if (!strstr($_SERVER['SCRIPT_NAME'], 'post.php') && !strstr($_SERVER['SCRIPT_NAME'], 'post-new.php')) {
39
  return false;
40
  }
41
  return true;
42
  }
43
  }
44
 
45
+ if (is_admin()) {
46
  $hesh = new wp_html_editor_syntax();
47
+ }
48
  ?>
lib/hesh.min.css CHANGED
@@ -1 +1 @@
1
- .CodeMirror{font-family:monospace;height:300px}.CodeMirror-scroll{overflow:auto}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror div.CodeMirror-cursor{border-left:1px solid #000}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor{width:auto;border:0;background:#7e7}.cm-tab{display:inline-block}.CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-s-default .cm-error{color:red}.cm-invalidchar{color:red}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{line-height:1;position:relative;overflow:hidden;background:#fff;color:#000}.CodeMirror-scroll{margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative;-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-sizer{position:relative;border-right:30px solid transparent;-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-vscrollbar,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;padding-bottom:30px;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;-moz-box-sizing:content-box;box-sizing:content-box;padding-bottom:30px;margin-bottom:-32px;display:inline-block;*zoom:1;*display:inline}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-lines{cursor:text}.CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-wrap .CodeMirror-scroll{overflow-x:hidden}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-measure pre{position:static}.CodeMirror div.CodeMirror-cursor{position:absolute;border-right:none;width:0}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:1}.CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.CodeMirror span{*vertical-align:text-bottom}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-s-mbo.CodeMirror{background:#2c2c2c;color:#ffffe9}.cm-s-mbo div.CodeMirror-selected{background:#716C62!important}.cm-s-mbo .CodeMirror-gutters{background:#4e4e4e;border-right:0}.cm-s-mbo .CodeMirror-linenumber{color:#dadada}.cm-s-mbo .CodeMirror-cursor{border-left:1px solid #ffffec!important}.cm-s-mbo span.cm-comment{color:#95958a}.cm-s-mbo span.cm-atom{color:#00a8c6}.cm-s-mbo span.cm-number{color:#00a8c6}.cm-s-mbo span.cm-property,.cm-s-mbo span.cm-attribute{color:#9ddfe9}.cm-s-mbo span.cm-keyword{color:#ffb928}.cm-s-mbo span.cm-string{color:#ffcf6c}.cm-s-mbo span.cm-variable{color:#ffffec}.cm-s-mbo span.cm-variable-2{color:#00a8c6}.cm-s-mbo span.cm-def{color:#ffffec}.cm-s-mbo span.cm-bracket{color:#fffffc;font-weight:700}.cm-s-mbo span.cm-tag{color:#9ddfe9}.cm-s-mbo span.cm-link{color:#f54b07}.cm-s-mbo span.cm-error{background:#636363;color:#ffffec}.cm-s-mbo .CodeMirror-activeline-background{background:#494b41!important}.cm-s-mbo .CodeMirror-matchingbracket{text-decoration:underline;color:#f5e107!important}.cm-s-mbo .CodeMirror-matchingtag{background:#4e4e4e}.cm-s-mbo span.cm-searching{background-color:none;background:0 0;box-shadow:0 0 0 1px #ffffec}.CodeMirror{font-family:Menlo Regular,Consolas,Monaco,monospace;line-height:150%;font-size:12px;height:500px}.wp-fullscreen-both,#wp-fullscreen-modes,.heshFullscreen #content_wp_fullscreen,#qt_content_strong,#qt_content_em,#qt_content_link,#qt_content_block,#qt_content_del,#qt_content_ins,#qt_content_img,#qt_content_ul,#qt_content_ol,#qt_content_li,#qt_content_code,#qt_content_more,#qt_content_close,#qt_content_fullscreen,#wp-content-editor-container .wp-editor-area{display:none!important}.quicktags-toolbar input#cm_content_fullscreen,#ed_toolbar input.cm_ed_button{display:inline-block!important}.CodeMirror-matchingbracket{background-color:#fff490;color:inherit!important;box-shadow:0 0 5px #fff490}.cm-s-mbo .CodeMirror-matchingbracket{color:#000!important;text-decoration:none}.content-resize-handle{width:12px;height:19px;cursor:ns-resize;right:2px;position:absolute}.tmce-active .content-resize-handle{display:none}.has-dfw .quicktags-toolbar{padding-right:3px!important}#cm_content_fullscreen,#cm_select_theme,#cm_font_size{float:right}@-moz-document url-prefix(){#cm_font_size{margin-top:4px}}@media screen and (-webkit-min-device-pixel-ratio:0){#cm_font_size{height:inherit;font-size:10px}}.heshFullscreen{z-index:99999;position:fixed;top:0;left:0;right:0;bottom:0;height:100%;background:#fff;padding:2% 2% 0}.heshFullscreen .CodeMirror,.heshFullscreen #ed_toolbar{border:1px solid #ccc}.heshFullscreen #ed_toolbar{border-bottom:0;border-radius:4px 4px 0 0}.heshFullscreen .CodeMirror{border-radius:0 0 4px 4px;height:85%!important}@media only screen and (max-height:550px),only screen and (max-device-height:550px){.heshFullscreen .CodeMirror{height:75%!important}}
1
+ .CodeMirror{font-family:monospace;height:300px}.CodeMirror-scroll{overflow:auto}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror div.CodeMirror-cursor{border-left:1px solid #000}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor{width:auto;border:0;background:#7e7}.cm-tab{display:inline-block}.CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-s-default .cm-error{color:red}.cm-invalidchar{color:red}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{line-height:1;position:relative;overflow:hidden;background:#fff;color:#000}.CodeMirror-scroll{margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative;-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-sizer{position:relative;border-right:30px solid transparent;-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-vscrollbar,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;padding-bottom:30px;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;-moz-box-sizing:content-box;box-sizing:content-box;padding-bottom:30px;margin-bottom:-32px;display:inline-block;*zoom:1;*display:inline}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-lines{cursor:text}.CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-wrap .CodeMirror-scroll{overflow-x:hidden}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-measure pre{position:static}.CodeMirror div.CodeMirror-cursor{position:absolute;border-right:none;width:0}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:1}.CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.CodeMirror span{*vertical-align:text-bottom}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-s-mbo.CodeMirror{background:#2c2c2c;color:#ffffe9}.cm-s-mbo div.CodeMirror-selected{background:#716C62!important}.cm-s-mbo .CodeMirror-gutters{background:#4e4e4e;border-right:0}.cm-s-mbo .CodeMirror-linenumber{color:#dadada}.cm-s-mbo .CodeMirror-cursor{border-left:1px solid #ffffec!important}.cm-s-mbo span.cm-comment{color:#95958a}.cm-s-mbo span.cm-atom{color:#00a8c6}.cm-s-mbo span.cm-number{color:#00a8c6}.cm-s-mbo span.cm-property,.cm-s-mbo span.cm-attribute{color:#9ddfe9}.cm-s-mbo span.cm-keyword{color:#ffb928}.cm-s-mbo span.cm-string{color:#ffcf6c}.cm-s-mbo span.cm-variable{color:#ffffec}.cm-s-mbo span.cm-variable-2{color:#00a8c6}.cm-s-mbo span.cm-def{color:#ffffec}.cm-s-mbo span.cm-bracket{color:#fffffc;font-weight:700}.cm-s-mbo span.cm-tag{color:#9ddfe9}.cm-s-mbo span.cm-link{color:#f54b07}.cm-s-mbo span.cm-error{background:#636363;color:#ffffec}.cm-s-mbo .CodeMirror-activeline-background{background:#494b41!important}.cm-s-mbo .CodeMirror-matchingbracket{text-decoration:underline;color:#f5e107!important}.cm-s-mbo .CodeMirror-matchingtag{background:#4e4e4e}.cm-s-mbo span.cm-searching{background-color:none;background:0 0;box-shadow:0 0 0 1px #ffffec}.CodeMirror{font-family:Menlo Regular,Consolas,Monaco,monospace;line-height:150%;font-size:12px;height:auto}.wp-fullscreen-both,#wp-fullscreen-modes,.heshFullscreen #content_wp_fullscreen,#qt_content_strong,#qt_content_em,#qt_content_link,#qt_content_block,#qt_content_del,#qt_content_ins,#qt_content_img,#qt_content_ul,#qt_content_ol,#qt_content_li,#qt_content_code,#qt_content_more,#qt_content_close,#qt_content_fullscreen,#wp-content-editor-container .wp-editor-area{display:none!important}.quicktags-toolbar input#cm_content_fullscreen,#ed_toolbar input.cm_ed_button{display:inline-block!important}.CodeMirror-matchingbracket{background-color:#fff490;color:inherit!important;box-shadow:0 0 5px #fff490}.cm-s-mbo .CodeMirror-matchingbracket{color:#000!important;text-decoration:none}.content-resize-handle{width:12px;height:19px;cursor:ns-resize;right:2px;position:absolute}.tmce-active .content-resize-handle{display:none}.has-dfw .quicktags-toolbar{padding-right:3px!important}.has-dfw .quicktags-toolbar .button:not(:first-child){margin-right:3px}#cm_content_fullscreen,#cm_select_theme,#cm_font_size{float:right}@-moz-document url-prefix(){#cm_font_size{margin-top:4px}}@media screen and (-webkit-min-device-pixel-ratio:0){#cm_font_size{height:inherit;font-size:10px}}.heshFullscreen{z-index:99999;position:fixed;top:0;left:0;right:0;bottom:0;height:100%;background:#fff;padding:2% 2% 0}.heshFullscreen .CodeMirror,.heshFullscreen #ed_toolbar{border:1px solid #ccc}.heshFullscreen #ed_toolbar{border-bottom:0;border-radius:4px 4px 0 0}.heshFullscreen .CodeMirror{border-radius:0 0 4px 4px;height:85%!important}@media only screen and (max-height:550px),only screen and (max-device-height:550px){.heshFullscreen .CodeMirror{height:75%!important}}.wp-editor-expand .html-active #post-status-info{position:static!important}.wp-editor-expand .html-active #ed_toolbar{z-index:2}.wp-editor-expand .html-active .CodeMirror{position:relative;z-index:1;margin-top:35px}.wp-editor-expand .html-active textarea.wp-editor-area{height:800px!important}
lib/hesh.min.js CHANGED
@@ -1,4 +1,4 @@
1
- function heshPlugin(){var e=null,t=0,r=0,n=document.getElementById("content"),i=null!==document.getElementById("post_ID")?document.getElementById("post_ID").value:0,o=document.getElementById("content-html"),a=document.getElementById("content-tmce"),l=-1!==document.cookie.indexOf("hesh_plugin_theme=mbo")?"mbo":"default",s=-1!==document.cookie.indexOf("editor%3Dtinymce")?!0:!1,u=null!==document.getElementById("content-tmce")?!0:!1,c=document.getElementById("ed_toolbar"),f=document.getElementById("wp-content-editor-container"),d="heshFullscreen",h=document.getElementById("publish"),p={mode:"text/html",tabMode:"indent",theme:l,lineNumbers:!0,matchBrackets:!0,indentUnit:4,indentWithTabs:!0,enterMode:"keep",lineWrapping:!0,autofocus:!0,styleActiveLine:!0,electricChars:!1,extraKeys:{F11:function(){C()},Esc:function(){C()},"Ctrl-S":function(){h.click()},"Cmd-S":function(){h.click()}}},m=function(e){var t="; "+document.cookie,r=t.split("; "+e+"=");return 2==r.length?r.pop().split(";").shift():void 0},g=m("hesh_plugin_font_size")||"12",v=function(r){y(),e=CodeMirror.fromTextArea(r,p),e.on("change",function(){e.save()}),e.on("cursorActivity",function(){var t=e.getCursor();document.cookie="hesh_plugin_pos="+i+","+t.line+","+t.ch});var n=(m("hesh_plugin_pos")||"0,0,0").split(",");i===n[0]&&e.setCursor(parseFloat(n[1]),parseFloat(n[2])),k(),A(),t=1},y=function(){if(!r){var e={more:["<!--more-->",""],comment:["<!-- "," -->"],code:["<code>","</code>"],li:["<li>","</li>"],ol:["<ol>","</ol>"],ul:["<ul>","</ul>"],img:['<img src="$" alt="','">',"Enter the URL of the image"],ins:["<ins>","</ins>"],del:["<del>","</del>"],link:['<a href="$">',"</a>","Enter the destination URL"],blockquote:["\r<blockquote>","</blockquote>\r"],h3:["<h3>","</h3>"],h2:["<h2>","</h2>"],h1:["<h1>","</h1>"],i:["<em>","</em>"],b:["<strong>","</strong>"]};for(var t in e){var n=e[t],i=n[2]?'data-prompt="'+n[2]+'"':"";c.insertAdjacentHTML("afterbegin",'<input type="button" id="cm_content_'+t+"\" data-start='"+n[0]+"' data-end='"+n[1]+"' "+i+' class="ed_button cm_ed_button" value="'+t+'">'),document.getElementById("cm_content_"+t).onclick=b}S(),T(),L(),r=1}},b=function(){var t=e.getCursor("start"),r=this.getAttribute("data-start"),n=this.getAttribute("data-end"),i=this.getAttribute("data-prompt")||null,o=e.getSelection();"cm_content_link"===this.id&&wpLink?(wpLink.open(),document.getElementById("wp-link-submit").onclick=function(){var n=wpLink.getAttrs();r='<a href="'+n.href+'" title="'+n.title+'" target="'+n.target+'">',e.replaceSelection(r+o+"</a>"),wpLink.close(),e.setCursor(t.line,t.ch+r.length),e.focus()}):(i&&(r=r.replace("$",prompt(i,""))),e.replaceSelection(r+o+n),e.setCursor(t.line,t.ch+r.length),e.focus())},w=function(){t&&(e.toTextArea(),o.onclick=x,switchEditors.switchto(this),t=0)},x=function(){t||(switchEditors.switchto(this),v(n),a.onclick=w)},k=function(){var e=document.querySelector(".CodeMirror"),t=document.createElement("div"),r=document.getElementById("wp-content-wrap"),n=e.getBoundingClientRect().top,i=function(t){t=t||window.event;var r=(t.pageY||t.clientY+document.body.scrollTop+document.documentElement.scrollTop)-n;e.style.height=(r>10?r:10)+"px",window.getSelection().removeAllRanges()};t.className="content-resize-handle",r.appendChild(t),t.onmousedown=function(){document.onmousemove=i},document.onmouseup=function(){document.onmousemove=null}},C=function(){f.className=-1===f.className.indexOf(d)?f.className+" "+d:f.className.replace(d,"");var t=document.getElementById("cm_content_fullscreen");t.value="fullscreen"===t.value?"exit fullscreen":"fullscreen",e.focus()},L=function(){c.insertAdjacentHTML("afterbegin",'<input type="button" id="cm_content_fullscreen" class="ed_button" title="Toggle fullscreen mode" value="fullscreen">'),document.getElementById("cm_content_fullscreen").onclick=C},S=function(){var t=function(){return"mbo"===l?"light":"dark"};c.insertAdjacentHTML("afterbegin",'<input type="button" id="cm_select_theme" class="ed_button" title="Change editor colour scheme" value="'+t()+'">'),document.getElementById("cm_select_theme").onclick=function(){l="mbo"===l?"default":"mbo",e.setOption("theme",l),document.cookie="hesh_plugin_theme="+l,this.value=t()}},M=function(){var e=document.getElementById("hesh-style"),t=".CodeMirror {font-size: "+g+"px !important;}";e?e.innerHTML=t:document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend",'<style id="hesh-style">'+t+"</style>")},T=function(){c.insertAdjacentHTML("afterbegin",'<select id="cm_font_size"><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="16">16</option><option value="18">18</option><option value="20">20</option><option value="22">22</option></select>');var t=document.getElementById("cm_font_size");M(),t.value=g,t.onchange=function(){g=this.value,M(),e.toTextArea(),v(n),e.focus(),document.cookie="hesh_plugin_font_size="+g}},A=function(){window.send_to_editor_wp||(window.send_to_editor_wp=send_to_editor,send_to_editor=function(r){t&&"content"===wpActiveEditor?(e.replaceSelection(r),e.save()):window.send_to_editor_wp(r)})};s&&u?o.onclick=x:(v(n),u&&(a.onclick=w))}!function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);this.CodeMirror=e()}}(function(){"use strict";function e(r,n){if(!(this instanceof e))return new e(r,n);this.options=n=n||{},no(ga,n,!1),p(n);var i=n.value;"string"==typeof i&&(i=new Ba(i,n.mode)),this.doc=i;var o=this.display=new t(r,i);o.wrapper.CodeMirror=this,c(this),s(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),n.autofocus&&!$o&&hr(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Xi},Wo&&setTimeout(io(dr,this,!0),20),gr(this);var a=this;Xt(this,function(){a.curOp.forceUpdate=!0,vi(a,i),n.autofocus&&!$o||fo()==o.input?setTimeout(io(_r,a),20):Fr(a);for(var e in va)va.hasOwnProperty(e)&&va[e](a,n[e],ya);for(var t=0;t<ka.length;++t)ka[t](a)})}function t(e,t){var r=this,n=r.input=lo("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none");Fo?n.style.width="1000px":n.setAttribute("wrap","off"),Ko&&(n.style.border="1px solid black"),n.setAttribute("autocorrect","off"),n.setAttribute("autocapitalize","off"),n.setAttribute("spellcheck","false"),r.inputDiv=lo("div",[n],null,"overflow: hidden; position: relative; width: 3px; height: 0px;"),r.scrollbarH=lo("div",[lo("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar"),r.scrollbarV=lo("div",[lo("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),r.scrollbarFiller=lo("div",null,"CodeMirror-scrollbar-filler"),r.gutterFiller=lo("div",null,"CodeMirror-gutter-filler"),r.lineDiv=lo("div",null,"CodeMirror-code"),r.selectionDiv=lo("div",null,null,"position: relative; z-index: 1"),r.cursorDiv=lo("div",null,"CodeMirror-cursors"),r.measure=lo("div",null,"CodeMirror-measure"),r.lineMeasure=lo("div",null,"CodeMirror-measure"),r.lineSpace=lo("div",[r.measure,r.lineMeasure,r.selectionDiv,r.cursorDiv,r.lineDiv],null,"position: relative; outline: none"),r.mover=lo("div",[lo("div",[r.lineSpace],"CodeMirror-lines")],null,"position: relative"),r.sizer=lo("div",[r.mover],"CodeMirror-sizer"),r.heightForcer=lo("div",null,null,"position: absolute; height: "+Za+"px; width: 1px;"),r.gutters=lo("div",null,"CodeMirror-gutters"),r.lineGutter=null,r.scroller=lo("div",[r.sizer,r.heightForcer,r.gutters],"CodeMirror-scroll"),r.scroller.setAttribute("tabIndex","-1"),r.wrapper=lo("div",[r.inputDiv,r.scrollbarH,r.scrollbarV,r.scrollbarFiller,r.gutterFiller,r.scroller],"CodeMirror"),Eo&&(r.gutters.style.zIndex=-1,r.scroller.style.paddingRight=0),Ko&&(n.style.width="0px"),Fo||(r.scroller.draggable=!0),Go&&(r.inputDiv.style.height="1px",r.inputDiv.style.position="absolute"),Eo&&(r.scrollbarH.style.minHeight=r.scrollbarV.style.minWidth="18px"),e.appendChild?e.appendChild(r.wrapper):e(r.wrapper),r.viewFrom=r.viewTo=t.first,r.view=[],r.externalMeasured=null,r.viewOffset=0,r.lastSizeC=0,r.updateLineNumbers=null,r.lineNumWidth=r.lineNumInnerWidth=r.lineNumChars=null,r.prevInput="",r.alignWidgets=!1,r.pollingFast=!1,r.poll=new Xi,r.cachedCharWidth=r.cachedTextHeight=r.cachedPaddingH=null,r.inaccurateSelection=!1,r.maxLine=null,r.maxLineLength=0,r.maxLineChanged=!1,r.wheelDX=r.wheelDY=r.wheelStartX=r.wheelStartY=null,r.shift=!1}function r(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),n(t)}function n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,yt(e,100),e.state.modeGen++,e.curOp&&rr(e)}function i(e){e.options.lineWrapping?(mo(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth=""):(po(e.display.wrapper,"CodeMirror-wrap"),h(e)),a(e),rr(e),It(e),setTimeout(function(){g(e)},100)}function o(e){var t=Ut(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/Kt(e.display)-3);return function(i){if(Gn(e.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;a<i.widgets.length;a++)i.widgets[a].height&&(o+=i.widgets[a].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function a(e){var t=e.doc,r=o(e);t.iter(function(e){var t=r(e);t!=e.height&&xi(e,t)})}function l(e){var t=Ta[e.options.keyMap],r=t.style;e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-keymap-\S+/g,"")+(r?" cm-keymap-"+r:"")}function s(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),It(e)}function u(e){c(e),rr(e),setTimeout(function(){y(e)},20)}function c(e){var t=e.display.gutters,r=e.options.gutters;so(t);for(var n=0;n<r.length;++n){var i=r[n],o=t.appendChild(lo("div",null,"CodeMirror-gutter "+i));"CodeMirror-linenumbers"==i&&(e.display.lineGutter=o,o.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=n?"":"none",f(e)}function f(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(0==e.height)return 0;for(var t=e.text.length,r,n=e;r=Pn(n);){var i=r.find(0,!0);n=i.from.line,t+=i.from.ch-i.to.ch}for(n=e;r=_n(n);){var i=r.find(0,!0);t-=n.text.length-i.from.ch,n=i.to.line,t+=n.text.length-i.to.ch}return t}function h(e){var t=e.display,r=e.doc;t.maxLine=yi(r,r.first),t.maxLineLength=d(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=d(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function p(e){var t=eo(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function m(e){var t=e.display.scroller;return{clientHeight:t.clientHeight,barHeight:e.display.scrollbarV.clientHeight,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth,barWidth:e.display.scrollbarH.clientWidth,docHeight:Math.round(e.doc.height+Ct(e.display))}}function g(e,t){t||(t=m(e));var r=e.display,n=t.docHeight+Za,i=t.scrollWidth>t.clientWidth,o=n>t.clientHeight;if(o?(r.scrollbarV.style.display="block",r.scrollbarV.style.bottom=i?vo(r.measure)+"px":"0",r.scrollbarV.firstChild.style.height=Math.max(0,n-t.clientHeight+(t.barHeight||r.scrollbarV.clientHeight))+"px"):(r.scrollbarV.style.display="",r.scrollbarV.firstChild.style.height="0"),i?(r.scrollbarH.style.display="block",r.scrollbarH.style.right=o?vo(r.measure)+"px":"0",r.scrollbarH.firstChild.style.width=t.scrollWidth-t.clientWidth+(t.barWidth||r.scrollbarH.clientWidth)+"px"):(r.scrollbarH.style.display="",r.scrollbarH.firstChild.style.width="0"),i&&o?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=r.scrollbarFiller.style.width=vo(r.measure)+"px"):r.scrollbarFiller.style.display="",i&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=vo(r.measure)+"px",r.gutterFiller.style.width=r.gutters.offsetWidth+"px"):r.gutterFiller.style.display="",!e.state.checkedOverlayScrollbar&&t.clientHeight>0){if(0===vo(r.measure)){var a=Yo&&!qo?"12px":"18px";r.scrollbarV.style.minWidth=r.scrollbarH.style.minHeight=a;var l=function(t){ji(t)!=r.scrollbarV&&ji(t)!=r.scrollbarH&&Zt(e,br)(t)};Ua(r.scrollbarV,"mousedown",l),Ua(r.scrollbarH,"mousedown",l)}e.state.checkedOverlayScrollbar=!0}}function v(e,t,r){var n=r&&null!=r.top?r.top:e.scroller.scrollTop;n=Math.floor(n-kt(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=Ci(t,n),a=Ci(t,i);if(r&&r.ensure){var l=r.ensure.from.line,s=r.ensure.to.line;if(o>l)return{from:l,to:Ci(t,Li(yi(t,l))+e.wrapper.clientHeight)};if(Math.min(s,t.lastLine())>=a)return{from:Ci(t,Li(yi(t,s))-e.wrapper.clientHeight),to:s}}return{from:o,to:a}}function y(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=x(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",a=0;a<r.length;a++)if(!r[a].hidden){e.options.fixedGutter&&r[a].gutter&&(r[a].gutter.style.left=o);var l=r[a].alignable;if(l)for(var s=0;s<l.length;s++)l[s].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function b(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=w(e.options,t.first+t.size-1),n=e.display;if(r.length!=n.lineNumChars){var i=n.measure.appendChild(lo("div",[lo("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,a=i.offsetWidth-o;return n.lineGutter.style.width="",n.lineNumInnerWidth=Math.max(o,n.lineGutter.offsetWidth-a),n.lineNumWidth=n.lineNumInnerWidth+a,n.lineNumChars=n.lineNumInnerWidth?r.length:-1,n.lineGutter.style.width=n.lineNumWidth+"px",f(e),!0}return!1}function w(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function x(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function k(e,t,r){for(var n=e.display.viewFrom,i=e.display.viewTo,o,a=v(e.display,e.doc,t),l=!0;;l=!1){var s=e.display.scroller.clientWidth;if(!C(e,a,r))break;o=!0,e.display.maxLineChanged&&!e.options.lineWrapping&&L(e);var u=m(e);if(pt(e),S(e,u),g(e,u),Fo&&e.options.lineWrapping&&M(e,u),l&&e.options.lineWrapping&&s!=e.display.scroller.clientWidth)r=!0;else if(r=!1,t&&null!=t.top&&(t={top:Math.min(u.docHeight-Za-u.clientHeight,t.top)}),a=v(e.display,e.doc,t),a.from>=e.display.viewFrom&&a.to<=e.display.viewTo)break}return e.display.updateLineNumbers=null,o&&(Gi(e,"update",e),(e.display.viewFrom!=n||e.display.viewTo!=i)&&Gi(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo)),o}function C(e,t,r){var n=e.display,i=e.doc;if(!n.wrapper.offsetWidth)return void ir(e);if(!(!r&&t.from>=n.viewFrom&&t.to<=n.viewTo&&0==sr(e))){b(e)&&ir(e);var o=N(e),a=i.first+i.size,l=Math.max(t.from-e.options.viewportMargin,i.first),s=Math.min(a,t.to+e.options.viewportMargin);n.viewFrom<l&&l-n.viewFrom<20&&(l=Math.max(i.first,n.viewFrom)),n.viewTo>s&&n.viewTo-s<20&&(s=Math.min(a,n.viewTo)),ta&&(l=jn(e.doc,l),s=Vn(e.doc,s));var u=l!=n.viewFrom||s!=n.viewTo||n.lastSizeC!=n.wrapper.clientHeight;lr(e,l,s),n.viewOffset=Li(yi(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var c=sr(e);if(u||0!=c||r){var f=fo();return c>4&&(n.lineDiv.style.display="none"),H(e,n.updateLineNumbers,o),c>4&&(n.lineDiv.style.display=""),f&&fo()!=f&&f.offsetHeight&&f.focus(),so(n.cursorDiv),so(n.selectionDiv),u&&(n.lastSizeC=n.wrapper.clientHeight,yt(e,400)),T(e),!0}}}function L(e){var t=e.display,r=At(e,t.maxLine,t.maxLine.text.length).left;t.maxLineChanged=!1;var n=Math.max(0,r+3),i=Math.max(0,t.sizer.offsetLeft+n+Za-t.scroller.clientWidth);t.sizer.style.minWidth=n+"px",i<e.doc.scrollLeft&&Ar(e,Math.min(t.scroller.scrollLeft,i),!0)}function S(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-Za)+"px"}function M(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 T(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i=t.view[n],o;if(!i.hidden){if(Eo){var a=i.node.offsetTop+i.node.offsetHeight;o=a-r,r=a}else{var l=i.node.getBoundingClientRect();o=l.bottom-l.top}var s=i.line.height-o;if(2>o&&(o=Ut(t)),(s>.001||-.001>s)&&(xi(i.line,o),A(i.line),i.rest))for(var u=0;u<i.rest.length;u++)A(i.rest[u])}}}function A(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function N(e){for(var t=e.display,r={},n={},i=t.gutters.firstChild,o=0;i;i=i.nextSibling,++o)r[e.options.gutters[o]]=i.offsetLeft,n[e.options.gutters[o]]=i.offsetWidth;return{fixedPos:x(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function H(e,t,r){function n(t){var r=t.nextSibling;return Fo&&Yo&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var i=e.display,o=e.options.lineNumbers,a=i.lineDiv,l=a.firstChild,s=i.view,u=i.viewFrom,c=0;c<s.length;c++){var f=s[c];if(f.hidden);else if(f.node){for(;l!=f.node;)l=n(l);var d=o&&null!=t&&u>=t&&f.lineNumber;f.changes&&(eo(f.changes,"gutter")>-1&&(d=!1),O(e,f,u,r)),d&&(so(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(w(e.options,u)))),l=f.node.nextSibling}else{var h=F(e,f,u,r);a.insertBefore(h,l)}u+=f.size}for(;l;)l=n(l)}function O(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?I(e,t):"gutter"==o?P(e,t,r,n):"class"==o?D(t):"widget"==o&&_(t,n)}t.changes=null}function z(e){return e.node==e.text&&(e.node=lo("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),Eo&&(e.node.style.zIndex=2)),e.node}function W(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=z(e);e.background=r.insertBefore(lo("div",null,t),r.firstChild)}}function E(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):oi(e,t)}function I(e,t){var r=t.text.className,n=E(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,D(t)):r&&(t.text.className=r)}function D(e){W(e),e.line.wrapClass?z(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 P(e,t,r,n){t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null);var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var o=z(t),a=t.gutter=o.insertBefore(lo("div",null,"CodeMirror-gutter-wrapper","position: absolute; left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px"),t.text);if(!e.options.lineNumbers||i&&i["CodeMirror-linenumbers"]||(t.lineNumber=a.appendChild(lo("div",w(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),i)for(var l=0;l<e.options.gutters.length;++l){var s=e.options.gutters[l],u=i.hasOwnProperty(s)&&i[s];u&&a.appendChild(lo("div",[u],"CodeMirror-gutter-elt","left: "+n.gutterLeft[s]+"px; width: "+n.gutterWidth[s]+"px"))}}}function _(e,t){e.alignable&&(e.alignable=null);for(var r=e.node.firstChild,n;r;r=n){var n=r.nextSibling;"CodeMirror-linewidget"==r.className&&e.node.removeChild(r)}B(e,t)}function F(e,t,r,n){var i=E(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),D(t),P(e,t,r,n),B(t,n),t.node}function B(e,t){if(R(e.line,e,t,!0),e.rest)for(var r=0;r<e.rest.length;r++)R(e.rest[r],e,t,!1)}function R(e,t,r,n){if(e.widgets)for(var i=z(t),o=0,a=e.widgets;o<a.length;++o){var l=a[o],s=lo("div",[l.node],"CodeMirror-linewidget");l.handleMouseEvents||(s.ignoreEvents=!0),j(l,s,t,r),n&&l.above?i.insertBefore(s,t.gutter||t.text):i.appendChild(s),Gi(l,"redraw")}}function j(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function V(e){return ra(e.line,e.ch)}function G(e,t){return na(e,t)<0?t:e}function q(e,t){return na(e,t)<0?e:t}function U(e,t){this.ranges=e,this.primIndex=t}function K(e,t){this.anchor=e,this.head=t}function $(e,t){var r=e[t];e.sort(function(e,t){return na(e.from(),t.from())}),t=eo(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(na(o.to(),i.from())>=0){var a=q(o.from(),i.from()),l=G(o.to(),i.to()),s=o.empty()?i.from()==i.head:o.from()==o.head;t>=n&&--t,e.splice(--n,2,new K(s?l:a,s?a:l))}}return new U(e,t)}function Y(e,t){return new U([new K(e,t||e)],0)}function X(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function Z(e,t){if(t.line<e.first)return ra(e.first,0);var r=e.first+e.size-1;return t.line>r?ra(r,yi(e,r).text.length):Q(t,yi(e,t.line).text.length)}function Q(e,t){var r=e.ch;return null==r||r>t?ra(e.line,t):0>r?ra(e.line,0):e}function J(e,t){return t>=e.first&&t<e.first+e.size}function et(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=Z(e,t[n]);return r}function tt(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=na(r,i)<0;o!=na(n,i)<0?(i=r,r=n):o!=na(r,n)<0&&(r=n)}return new K(i,r)}return new K(n||r,r)}function rt(e,t,r,n){st(e,new U([tt(e,e.sel.primary(),t,r)],0),n)}function nt(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=tt(e,e.sel.ranges[i],t[i],null);var o=$(n,e.sel.primIndex);st(e,o,r)}function it(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,st(e,$(i,e.sel.primIndex),n)}function ot(e,t,r,n){st(e,Y(t,r),n)}function at(e,t){var r={ranges:t.ranges,update:function(t){this.ranges=[];for(var r=0;r<t.length;r++)this.ranges[r]=new K(Z(e,t[r].anchor),Z(e,t[r].head))}};return $a(e,"beforeSelectionChange",e,r),e.cm&&$a(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?$(r.ranges,r.ranges.length-1):t}function lt(e,t,r){var n=e.history.done,i=Ji(n);i&&i.ranges?(n[n.length-1]=t,ut(e,t,r)):st(e,t,r)}function st(e,t,r){ut(e,t,r),zi(e,e.sel,e.cm?e.cm.curOp.id:0/0,r)}function ut(e,t,r){($i(e,"beforeSelectionChange")||e.cm&&$i(e.cm,"beforeSelectionChange"))&&(t=at(e,t));var n=na(t.primary().head,e.sel.primary().head)<0?-1:1;ct(e,dt(e,t,n,!0)),r&&r.scroll===!1||!e.cm||an(e.cm)}function ct(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,Ki(e.cm)),Gi(e,"cursorActivity",e))}function ft(e){ct(e,dt(e,e.sel,null,!1),Ja)}function dt(e,t,r,n){for(var i,o=0;o<t.ranges.length;o++){var a=t.ranges[o],l=ht(e,a.anchor,r,n),s=ht(e,a.head,r,n);(i||l!=a.anchor||s!=a.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new K(l,s))}return i?$(i,t.primIndex):t}function ht(e,t,r,n){var i=!1,o=t,a=r||1;e.cantEdit=!1;e:for(;;){var l=yi(e,o.line);if(l.markedSpans)for(var s=0;s<l.markedSpans.length;++s){var u=l.markedSpans[s],c=u.marker;if((null==u.from||(c.inclusiveLeft?u.from<=o.ch:u.from<o.ch))&&(null==u.to||(c.inclusiveRight?u.to>=o.ch:u.to>o.ch))){if(n&&($a(c,"beforeCursorEnter"),c.explicitlyCleared)){if(l.markedSpans){--s;continue}break}if(!c.atomic)continue;var f=c.find(0>a?-1:1);if(0==na(f,o)&&(f.ch+=a,f.ch<0?f=f.line>e.first?Z(e,ra(f.line-1)):null:f.ch>l.text.length&&(f=f.line<e.first+e.size-1?ra(f.line+1,0):null),!f)){if(i)return n?(e.cantEdit=!0,ra(e.first,0)):ht(e,t,r,!0);i=!0,f=t,a=-a}o=f;continue e}}return o}}function pt(e){for(var t=e.display,r=e.doc,n=document.createDocumentFragment(),i=document.createDocumentFragment(),o=0;o<r.sel.ranges.length;o++){var a=r.sel.ranges[o],l=a.empty();(l||e.options.showCursorWhenSelecting)&&mt(e,a,n),l||gt(e,a,i)}if(e.options.moveInputWithCursor){var s=Rt(e,r.sel.primary().head,"div"),u=t.wrapper.getBoundingClientRect(),c=t.lineDiv.getBoundingClientRect(),f=Math.max(0,Math.min(t.wrapper.clientHeight-10,s.top+c.top-u.top)),d=Math.max(0,Math.min(t.wrapper.clientWidth-10,s.left+c.left-u.left));t.inputDiv.style.top=f+"px",t.inputDiv.style.left=d+"px"}uo(t.cursorDiv,n),uo(t.selectionDiv,i)}function mt(e,t,r){var n=Rt(e,t.head,"div"),i=r.appendChild(lo("div"," ","CodeMirror-cursor"));if(i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px",n.other){var o=r.appendChild(lo("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=n.other.left+"px",o.style.top=n.other.top+"px",o.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function gt(e,t,r){function n(e,t,r,n){0>t&&(t=0),t=Math.round(t),n=Math.round(n),l.appendChild(lo("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?c-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return Bt(e,ra(t,r),"div",l,n)}var l=yi(a,t),s=l.text.length,f,d;return wo(Si(l),r||0,null==i?s:i,function(e,t,a){var l=o(e,"left"),h,p,m;if(e==t)h=l,p=m=l.left;else{if(h=o(t-1,"right"),"rtl"==a){var g=l;l=h,h=g}p=l.left,m=h.right}null==r&&0==e&&(p=u),h.top-l.top>3&&(n(p,l.top,null,l.bottom),p=u,l.bottom<h.top&&n(p,l.bottom,null,h.top)),null==i&&t==s&&(m=c),(!f||l.top<f.top||l.top==f.top&&l.left<f.left)&&(f=l),(!d||h.bottom>d.bottom||h.bottom==d.bottom&&h.right>d.right)&&(d=h),u+1>p&&(p=u),n(p,h.top,m-p,h.bottom)}),{start:f,end:d}}var o=e.display,a=e.doc,l=document.createDocumentFragment(),s=Lt(e.display),u=s.left,c=o.lineSpace.offsetWidth-s.right,f=t.from(),d=t.to();if(f.line==d.line)i(f.line,f.ch,d.ch);else{var h=yi(a,f.line),p=yi(a,d.line),m=Bn(h)==Bn(p),g=i(f.line,f.ch,m?h.text.length+1:null).end,v=i(d.line,m?0:null,d.ch).start;m&&(g.top<v.top-2?(n(g.right,g.top,null,g.bottom),n(u,v.top,v.left,v.bottom)):n(g.right,g.top,v.left-g.right,g.bottom)),g.bottom<v.top&&n(u,g.bottom,null,v.top)}r.appendChild(l)}function vt(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0&&(t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate))}}function yt(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,io(bt,e))}function bt(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=La(t.mode,xt(e,t.frontier));Xt(e,function(){t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(i){if(t.frontier>=e.display.viewFrom){var o=i.styles,a=ti(e,i,n,!0);i.styles=a.styles,a.classes?i.styleClasses=a.classes:i.styleClasses&&(i.styleClasses=null);for(var l=!o||o.length!=i.styles.length,s=0;!l&&s<o.length;++s)l=o[s]!=i.styles[s];l&&nr(e,t.frontier,"text"),i.stateAfter=La(t.mode,n)}else ni(e,i.text,n),i.stateAfter=t.frontier%5==0?La(t.mode,n):null;return++t.frontier,+new Date>r?(yt(e,e.options.workDelay),!0):void 0})})}}function wt(e,t,r){for(var n,i,o=e.doc,a=r?-1:t-(e.doc.mode.innerMode?1e3:100),l=t;l>a;--l){if(l<=o.first)return o.first;var s=yi(o,l-1);if(s.stateAfter&&(!r||l<=o.frontier))return l;var u=rl(s.text,null,e.options.tabSize);(null==i||n>u)&&(i=l-1,n=u)}return i}function xt(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=wt(e,t,r),a=o>n.first&&yi(n,o-1).stateAfter;return a=a?La(n.mode,a):Sa(n.mode),n.iter(o,t,function(r){ni(e,r.text,a);var l=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=l?La(n.mode,a):null,++o}),r&&(n.frontier=o),a}function kt(e){return e.lineSpace.offsetTop}function Ct(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Lt(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=uo(e.measure,lo("pre","x")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,n={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(n.left)||isNaN(n.right)||(e.cachedPaddingH=n),n}function St(e,t,r){var n=e.options.lineWrapping,i=n&&e.display.scroller.clientWidth;if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var a=t.text.firstChild.getClientRects(),l=0;l<a.length-1;l++){var s=a[l],u=a[l+1];Math.abs(s.bottom-u.bottom)>2&&o.push((s.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}function Mt(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var n=0;n<e.rest.length;n++)if(ki(e.rest[n])>r)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Tt(e,t){t=Bn(t);var r=ki(t),n=e.display.externalMeasured=new er(e.doc,t,r);n.lineN=r;var i=n.built=oi(e,n);return n.text=i.pre,uo(e.display.lineMeasure,i.pre),n}function At(e,t,r,n){return Ot(e,Ht(e,t),r,n)}function Nt(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[or(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function Ht(e,t){var r=ki(t),n=Nt(e,r);n&&!n.text?n=null:n&&n.changes&&O(e,n,r,N(e)),n||(n=Tt(e,t));var i=Mt(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function Ot(e,t,r,n){t.before&&(r=-1);var i=r+(n||""),o;return t.cache.hasOwnProperty(i)?o=t.cache[i]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(St(e,t.view,t.rect),t.hasHeights=!0),o=zt(e,t,r,n),o.bogus||(t.cache[i]=o)),{left:o.left,right:o.right,top:o.top,bottom:o.bottom}}function zt(e,t,r,n){for(var i=t.map,o,a,l,s,u=0;u<i.length;u+=3){var c=i[u],f=i[u+1];if(c>r?(a=0,l=1,s="left"):f>r?(a=r-c,l=a+1):(u==i.length-3||r==f&&i[u+3]>r)&&(l=f-c,a=l-1,r>=f&&(s="right")),null!=a){if(o=i[u+2],c==f&&n==(o.insertLeft?"left":"right")&&(s=n),"left"==n&&0==a)for(;u&&i[u-2]==i[u-3]&&i[u-1].insertLeft;)o=i[(u-=3)+2],s="left";if("right"==n&&a==f-c)for(;u<i.length-3&&i[u+3]==i[u+4]&&!i[u+5].insertLeft;)o=i[(u+=3)+2],s="right";break}}var d;if(3==o.nodeType){for(;a&&ao(t.line.text.charAt(c+a));)--a;for(;f>c+l&&ao(t.line.text.charAt(c+l));)++l;if(Io&&0==a&&l==f-c)d=o.parentNode.getBoundingClientRect();else if(_o&&e.options.lineWrapping){var h=sl(o,a,l).getClientRects();d=h.length?h["right"==n?h.length-1:0]:ia}else d=sl(o,a,l).getBoundingClientRect()}else{a>0&&(s=n="right");var h;d=e.options.lineWrapping&&(h=o.getClientRects()).length>1?h["right"==n?h.length-1:0]:o.getBoundingClientRect()}if(Io&&!a&&(!d||!d.left&&!d.right)){var p=o.parentNode.getClientRects()[0];d=p?{left:p.left,right:p.left+Kt(e.display),top:p.top,bottom:p.bottom}:ia}for(var m,g=(d.bottom+d.top)/2-t.rect.top,v=t.view.measure.heights,u=0;u<v.length-1&&!(g<v[u]);u++);m=u?v[u-1]:0,g=v[u];var y={left:("right"==s?d.right:d.left)-t.rect.left,right:("left"==s?d.left:d.right)-t.rect.left,top:m,bottom:g};return d.left||d.right||(y.bogus=!0),y}function Wt(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function Et(e){e.display.externalMeasure=null,so(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)Wt(e.display.view[t])}function It(e){Et(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function Dt(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function Pt(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function _t(e,t,r,n){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var o=Kn(t.widgets[i]);
2
  r.top+=o,r.bottom+=o}if("line"==n)return r;n||(n="local");var a=Li(t);if("local"==n?a+=kt(e.display):a-=e.display.viewOffset,"page"==n||"window"==n){var l=e.display.lineSpace.getBoundingClientRect();a+=l.top+("window"==n?0:Pt());var s=l.left+("window"==n?0:Dt());r.left+=s,r.right+=s}return r.top+=a,r.bottom+=a,r}function Ft(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=Dt(),i-=Pt();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var a=e.display.lineSpace.getBoundingClientRect();return{left:n-a.left,top:i-a.top}}function Bt(e,t,r,n,i){return n||(n=yi(e.doc,t.line)),_t(e,n,At(e,n,t.ch,i),r)}function Rt(e,t,r,n,i){function o(t,o){var a=Ot(e,i,t,o?"right":"left");return o?a.left=a.right:a.right=a.left,_t(e,n,a,r)}function a(e,t){var r=l[t],n=r.level%2;return e==xo(r)&&t&&r.level<l[t-1].level?(r=l[--t],e=ko(r)-(r.level%2?0:1),n=!0):e==ko(r)&&t<l.length-1&&r.level<l[t+1].level&&(r=l[++t],e=xo(r)-r.level%2,n=!1),n&&e==r.to&&e>r.from?o(e-1):o(e,n)}n=n||yi(e.doc,t.line),i||(i=Ht(e,n));var l=Si(n),s=t.ch;if(!l)return o(s);var u=Ao(l,s),c=a(s,u);return null!=vl&&(c.other=a(s,vl)),c}function jt(e,t){var r=0,t=Z(e.doc,t);e.options.lineWrapping||(r=Kt(e.display)*t.ch);var n=yi(e.doc,t.line),i=Li(n)+kt(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function Vt(e,t,r,n){var i=ra(e,t);return i.xRel=n,r&&(i.outside=!0),i}function Gt(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,0>r)return Vt(n.first,0,!0,-1);var i=Ci(n,r),o=n.first+n.size-1;if(i>o)return Vt(n.first+n.size-1,yi(n,o).text.length,!0,1);0>t&&(t=0);for(var a=yi(n,i);;){var l=qt(e,a,i,t,r),s=_n(a),u=s&&s.find(0,!0);if(!s||!(l.ch>u.from.ch||l.ch==u.from.ch&&l.xRel>0))return l;i=ki(a=u.to.line)}}function qt(e,t,r,n,i){function o(n){var i=Rt(e,ra(r,n),"line",t,u);return l=!0,a>i.bottom?i.left-s:a<i.top?i.left+s:(l=!1,i.left)}var a=i-Li(t),l=!1,s=2*e.display.wrapper.clientWidth,u=Ht(e,t),c=Si(t),f=t.text.length,d=Co(t),h=Lo(t),p=o(d),m=l,g=o(h),v=l;if(n>g)return Vt(r,h,v,1);for(;;){if(c?h==d||h==Ho(t,d,1):1>=h-d){for(var y=p>n||g-n>=n-p?d:h,b=n-(y==d?p:g);ao(t.text.charAt(y));)++y;var w=Vt(r,y,y==d?m:v,-1>b?-1:b>1?1:0);return w}var x=Math.ceil(f/2),k=d+x;if(c){k=d;for(var C=0;x>C;++C)k=Ho(t,k,1)}var L=o(k);L>n?(h=k,g=L,(v=l)&&(g+=1e3),f=x):(d=k,p=L,m=l,f-=x)}}function Ut(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==oa){oa=lo("pre");for(var t=0;49>t;++t)oa.appendChild(document.createTextNode("x")),oa.appendChild(lo("br"));oa.appendChild(document.createTextNode("x"))}uo(e.measure,oa);var r=oa.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),so(e.measure),r||1}function Kt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=lo("span","xxxxxxxxxx"),r=lo("pre",[t]);uo(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function $t(e){e.curOp={viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++aa},Xa++||(Ya=[])}function Yt(e){var t=e.curOp,r=e.doc,n=e.display;if(e.curOp=null,t.updateMaxLine&&h(e),t.viewChanged||t.forceUpdate||null!=t.scrollTop||t.scrollToPos&&(t.scrollToPos.from.line<n.viewFrom||t.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&e.options.lineWrapping){var i=k(e,{top:t.scrollTop,ensure:t.scrollToPos},t.forceUpdate);e.display.scroller.offsetHeight&&(e.doc.scrollTop=e.display.scroller.scrollTop)}if(!i&&t.selectionChanged&&pt(e),i||t.startHeight==e.doc.height||g(e),null!=t.scrollTop&&n.scroller.scrollTop!=t.scrollTop){var o=Math.max(0,Math.min(n.scroller.scrollHeight-n.scroller.clientHeight,t.scrollTop));n.scroller.scrollTop=n.scrollbarV.scrollTop=r.scrollTop=o}if(null!=t.scrollLeft&&n.scroller.scrollLeft!=t.scrollLeft){var a=Math.max(0,Math.min(n.scroller.scrollWidth-n.scroller.clientWidth,t.scrollLeft));n.scroller.scrollLeft=n.scrollbarH.scrollLeft=r.scrollLeft=a,y(e)}if(t.scrollToPos){var l=tn(e,Z(e.doc,t.scrollToPos.from),Z(e.doc,t.scrollToPos.to),t.scrollToPos.margin);t.scrollToPos.isCursor&&e.state.focused&&en(e,l)}t.selectionChanged&&vt(e),e.state.focused&&t.updateInput&&dr(e,t.typing);var s=t.maybeHiddenMarkers,u=t.maybeUnhiddenMarkers;if(s)for(var c=0;c<s.length;++c)s[c].lines.length||$a(s[c],"hide");if(u)for(var c=0;c<u.length;++c)u[c].lines.length&&$a(u[c],"unhide");var f;if(--Xa||(f=Ya,Ya=null),t.changeObjs&&$a(e,"changes",e,t.changeObjs),f)for(var c=0;c<f.length;++c)f[c]();if(t.cursorActivityHandlers)for(var c=0;c<t.cursorActivityHandlers.length;c++)t.cursorActivityHandlers[c](e)}function Xt(e,t){if(e.curOp)return t();$t(e);try{return t()}finally{Yt(e)}}function Zt(e,t){return function(){if(e.curOp)return t.apply(e,arguments);$t(e);try{return t.apply(e,arguments)}finally{Yt(e)}}}function Qt(e){return function(){if(this.curOp)return e.apply(this,arguments);$t(this);try{return e.apply(this,arguments)}finally{Yt(this)}}}function Jt(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);$t(t);try{return e.apply(this,arguments)}finally{Yt(t)}}}function er(e,t,r){this.line=t,this.rest=Rn(t),this.size=this.rest?ki(Ji(this.rest))-r+1:1,this.node=this.text=null,this.hidden=Gn(e,t)}function tr(e,t,r){for(var n=[],i,o=t;r>o;o=i){var a=new er(e.doc,yi(e.doc,o),o);i=o+a.size,n.push(a)}return n}function rr(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&r<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)ta&&jn(e.doc,t)<i.viewTo&&ir(e);else if(r<=i.viewFrom)ta&&Vn(e.doc,r+n)>i.viewFrom?ir(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)ir(e);else if(t<=i.viewFrom){var o=ar(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):ir(e)}else if(r>=i.viewTo){var o=ar(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):ir(e)}else{var a=ar(e,t,t,-1),l=ar(e,r,r+n,1);a&&l?(i.view=i.view.slice(0,a.index).concat(tr(e,a.lineN,l.lineN)).concat(i.view.slice(l.index)),i.viewTo+=n):ir(e)}var s=i.externalMeasured;s&&(r<s.lineN?s.lineN+=n:t<s.lineN+s.size&&(i.externalMeasured=null))}function nr(e,t,r){e.curOp.viewChanged=!0;var n=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(n.externalMeasured=null),!(t<n.viewFrom||t>=n.viewTo)){var o=n.view[or(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==eo(a,r)&&a.push(r)}}}function ir(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function or(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,0>t)return n}function ar(e,t,r,n){var i=or(e,t),o,a=e.display.view;if(!ta)return{index:i,lineN:r};for(var l=0,s=e.display.viewFrom;i>l;l++)s+=a[l].size;if(s!=t){if(n>0){if(i==a.length-1)return null;o=s+a[i].size-t,i++}else o=s-t;t+=o,r+=o}for(;jn(e.doc,r)!=r;){if(i==(0>n?0:a.length-1))return null;r+=n*a[i-(0>n?1:0)].size,i+=n}return{index:i,lineN:r}}function lr(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=tr(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=tr(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(or(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(tr(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,or(e,r)))),n.viewTo=r}function sr(e){for(var t=e.display.view,r=0,n=0;n<t.length;n++){var i=t[n];i.hidden||i.node&&!i.changes||++r}return r}function ur(e){e.display.pollingFast||e.display.poll.set(e.options.pollInterval,function(){fr(e),e.state.focused&&ur(e)})}function cr(e){function t(){var n=fr(e);n||r?(e.display.pollingFast=!1,ur(e)):(r=!0,e.display.poll.set(60,t))}var r=!1;e.display.pollingFast=!0,e.display.poll.set(20,t)}function fr(e){var t=e.display.input,r=e.display.prevInput,n=e.doc;if(!e.state.focused||pl(t)&&!r||mr(e)||e.options.disableInput)return!1;e.state.pasteIncoming&&e.state.fakedLastChar&&(t.value=t.value.substring(0,t.value.length-1),e.state.fakedLastChar=!1);var i=t.value;if(i==r&&!e.somethingSelected())return!1;if(_o&&!Io&&e.display.inputHasSelection===i)return dr(e),!1;var o=!e.curOp;o&&$t(e),e.display.shift=!1;for(var a=0,l=Math.min(r.length,i.length);l>a&&r.charCodeAt(a)==i.charCodeAt(a);)++a;for(var s=i.slice(a),u=hl(s),c=e.state.pasteIncoming&&u.length>1&&n.sel.ranges.length==u.length,f=n.sel.ranges.length-1;f>=0;f--){var d=n.sel.ranges[f],h=d.from(),p=d.to();a<r.length?h=ra(h.line,h.ch-(r.length-a)):e.state.overwrite&&d.empty()&&!e.state.pasteIncoming&&(p=ra(p.line,Math.min(yi(n,p.line).text.length,p.ch+Ji(u).length)));var m=e.curOp.updateInput,g={from:h,to:p,text:c?[u[f]]:u,origin:e.state.pasteIncoming?"paste":e.state.cutIncoming?"cut":"+input"};if(Kr(e.doc,g),Gi(e,"inputRead",e,g),s&&!e.state.pasteIncoming&&e.options.electricChars&&e.options.smartIndent&&d.head.ch<100&&(!f||n.sel.ranges[f-1].head.line!=d.head.line)){var v=e.getModeAt(d.head);if(v.electricChars){for(var y=0;y<v.electricChars.length;y++)if(s.indexOf(v.electricChars.charAt(y))>-1){sn(e,d.head.line,"smart");break}}else if(v.electricInput){var b=ma(g);v.electricInput.test(yi(n,b.line).text.slice(0,b.ch))&&sn(e,d.head.line,"smart")}}}return an(e),e.curOp.updateInput=m,e.curOp.typing=!0,i.length>1e3||i.indexOf("\n")>-1?t.value=e.display.prevInput="":e.display.prevInput=i,o&&Yt(e),e.state.pasteIncoming=e.state.cutIncoming=!1,!0}function dr(e,t){var r,n,i=e.doc;if(e.somethingSelected()){e.display.prevInput="";var o=i.sel.primary();r=ml&&(o.to().line-o.from().line>100||(n=e.getSelection()).length>1e3);var a=r?"-":n||e.getSelection();e.display.input.value=a,e.state.focused&&il(e.display.input),_o&&!Io&&(e.display.inputHasSelection=a)}else t||(e.display.prevInput=e.display.input.value="",_o&&!Io&&(e.display.inputHasSelection=null));e.display.inaccurateSelection=r}function hr(e){"nocursor"==e.options.readOnly||$o&&fo()==e.display.input||e.display.input.focus()}function pr(e){e.state.focused||(hr(e),_r(e))}function mr(e){return e.options.readOnly||e.doc.cantEdit}function gr(e){function t(){e.state.focused&&setTimeout(io(hr,e),0)}function r(){null==l&&(l=setTimeout(function(){l=null,a.cachedCharWidth=a.cachedTextHeight=a.cachedPaddingH=cl=null,e.setSize()},100))}function n(){co(document.body,a.wrapper)?setTimeout(n,5e3):Ka(window,"resize",r)}function i(t){Ui(e,t)||qa(t)}function o(t){if(e.somethingSelected())a.inaccurateSelection&&(a.prevInput="",a.inaccurateSelection=!1,a.input.value=e.getSelection(),il(a.input));else{for(var r="",n=[],i=0;i<e.doc.sel.ranges.length;i++){var o=e.doc.sel.ranges[i].head.line,l={anchor:ra(o,0),head:ra(o+1,0)};n.push(l),r+=e.getRange(l.anchor,l.head)}"cut"==t.type?e.setSelections(n,null,Ja):(a.prevInput="",a.input.value=r,il(a.input))}"cut"==t.type&&(e.state.cutIncoming=!0)}var a=e.display;Ua(a.scroller,"mousedown",Zt(e,br)),Wo?Ua(a.scroller,"dblclick",Zt(e,function(t){if(!Ui(e,t)){var r=yr(e,t);if(r&&!Lr(e,t)&&!vr(e.display,t)){Va(t);var n=hn(e.doc,r);rt(e.doc,n.anchor,n.head)}}})):Ua(a.scroller,"dblclick",function(t){Ui(e,t)||Va(t)}),Ua(a.lineSpace,"selectstart",function(e){vr(a,e)||Va(e)}),Jo||Ua(a.scroller,"contextmenu",function(t){Br(e,t)}),Ua(a.scroller,"scroll",function(){a.scroller.clientHeight&&(Tr(e,a.scroller.scrollTop),Ar(e,a.scroller.scrollLeft,!0),$a(e,"scroll",e))}),Ua(a.scrollbarV,"scroll",function(){a.scroller.clientHeight&&Tr(e,a.scrollbarV.scrollTop)}),Ua(a.scrollbarH,"scroll",function(){a.scroller.clientHeight&&Ar(e,a.scrollbarH.scrollLeft)}),Ua(a.scroller,"mousewheel",function(t){Nr(e,t)}),Ua(a.scroller,"DOMMouseScroll",function(t){Nr(e,t)}),Ua(a.scrollbarH,"mousedown",t),Ua(a.scrollbarV,"mousedown",t),Ua(a.wrapper,"scroll",function(){a.wrapper.scrollTop=a.wrapper.scrollLeft=0});var l;Ua(window,"resize",r),setTimeout(n,5e3),Ua(a.input,"keyup",Zt(e,Dr)),Ua(a.input,"input",function(){_o&&!Io&&e.display.inputHasSelection&&(e.display.inputHasSelection=null),cr(e)}),Ua(a.input,"keydown",Zt(e,Er)),Ua(a.input,"keypress",Zt(e,Pr)),Ua(a.input,"focus",io(_r,e)),Ua(a.input,"blur",io(Fr,e)),e.options.dragDrop&&(Ua(a.scroller,"dragstart",function(t){Mr(e,t)}),Ua(a.scroller,"dragenter",i),Ua(a.scroller,"dragover",i),Ua(a.scroller,"drop",Zt(e,Sr))),Ua(a.scroller,"paste",function(t){vr(a,t)||(e.state.pasteIncoming=!0,hr(e),cr(e))}),Ua(a.input,"paste",function(){if(Fo&&!e.state.fakedLastChar&&!(new Date-e.state.lastMiddleDown<200)){var t=a.input.selectionStart,r=a.input.selectionEnd;a.input.value+="$",a.input.selectionStart=t,a.input.selectionEnd=r,e.state.fakedLastChar=!0}e.state.pasteIncoming=!0,cr(e)}),Ua(a.input,"cut",o),Ua(a.input,"copy",o),Go&&Ua(a.sizer,"mouseup",function(){fo()==a.input&&a.input.blur(),hr(e)})}function vr(e,t){for(var r=ji(t);r!=e.wrapper;r=r.parentNode)if(!r||r.ignoreEvents||r.parentNode==e.sizer&&r!=e.mover)return!0}function yr(e,t,r,n){var i=e.display;if(!r){var o=ji(t);if(o==i.scrollbarH||o==i.scrollbarV||o==i.scrollbarFiller||o==i.gutterFiller)return null}var a,l,s=i.lineSpace.getBoundingClientRect();try{a=t.clientX-s.left,l=t.clientY-s.top}catch(t){return null}var u=Gt(e,a,l),c;if(n&&1==u.xRel&&(c=yi(e.doc,u.line).text).length==u.ch){var f=rl(c,c.length,e.options.tabSize)-c.length;u=ra(u.line,Math.max(0,Math.round((a-Lt(e.display).left)/Kt(e.display))-f))}return u}function br(e){if(!Ui(this,e)){var t=this,r=t.display;if(r.shift=e.shiftKey,vr(r,e))return void(Fo||(r.scroller.draggable=!1,setTimeout(function(){r.scroller.draggable=!0},100)));if(!Lr(t,e)){var n=yr(t,e);switch(window.focus(),Vi(e)){case 1:n?wr(t,e,n):ji(e)==r.scroller&&Va(e);break;case 2:Fo&&(t.state.lastMiddleDown=+new Date),n&&rt(t.doc,n),setTimeout(io(hr,t),20),Va(e);break;case 3:Jo&&Br(t,e)}}}}function wr(e,t,r){setTimeout(io(pr,e),0);var n=+new Date,i;sa&&sa.time>n-400&&0==na(sa.pos,r)?i="triple":la&&la.time>n-400&&0==na(la.pos,r)?(i="double",sa={time:n,pos:r}):(i="single",la={time:n,pos:r});var o=e.doc.sel,a=Yo?t.metaKey:t.ctrlKey;e.options.dragDrop&&ul&&!a&&!mr(e)&&"single"==i&&o.contains(r)>-1&&o.somethingSelected()?xr(e,t,r):kr(e,t,r,i,a)}function xr(e,t,r){var n=e.display,i=Zt(e,function(o){Fo&&(n.scroller.draggable=!1),e.state.draggingText=!1,Ka(document,"mouseup",i),Ka(n.scroller,"drop",i),Math.abs(t.clientX-o.clientX)+Math.abs(t.clientY-o.clientY)<10&&(Va(o),rt(e.doc,r),hr(e),Wo&&!Io&&setTimeout(function(){document.body.focus(),hr(e)},20))});Fo&&(n.scroller.draggable=!0),e.state.draggingText=i,n.scroller.dragDrop&&n.scroller.dragDrop(),Ua(document,"mouseup",i),Ua(n.scroller,"drop",i)}function kr(e,t,r,n,i){function o(t){if(0!=na(m,t))if(m=t,"rect"==n){for(var i=[],o=e.options.tabSize,a=rl(yi(u,r.line).text,r.ch,o),l=rl(yi(u,t.line).text,t.ch,o),s=Math.min(a,l),h=Math.max(a,l),p=Math.min(r.line,t.line),g=Math.min(e.lastLine(),Math.max(r.line,t.line));g>=p;p++){var v=yi(u,p).text,y=Zi(v,s,o);s==h?i.push(new K(ra(p,y),ra(p,y))):v.length>y&&i.push(new K(ra(p,y),ra(p,Zi(v,h,o))))}i.length||i.push(new K(r,r)),st(u,$(d.ranges.slice(0,f).concat(i),f),el)}else{var b=c,w=b.anchor,x=t;if("single"!=n){if("double"==n)var k=hn(u,t);else var k=new K(ra(t.line,0),Z(u,ra(t.line+1,0)));na(k.anchor,w)>0?(x=k.head,w=q(b.from(),k.anchor)):(x=k.anchor,w=G(b.to(),k.head))}var i=d.ranges.slice(0);i[f]=new K(Z(u,w),x),st(u,$(i,f),el)}}function a(t){var r=++y,i=yr(e,t,!0,"rect"==n);if(i)if(0!=na(i,m)){pr(e),o(i);var l=v(s,u);(i.line>=l.to||i.line<l.from)&&setTimeout(Zt(e,function(){y==r&&a(t)}),150)}else{var c=t.clientY<g.top?-20:t.clientY>g.bottom?20:0;c&&setTimeout(Zt(e,function(){y==r&&(s.scroller.scrollTop+=c,a(t))}),50)}}function l(t){y=1/0,Va(t),hr(e),Ka(document,"mousemove",b),Ka(document,"mouseup",w),u.history.lastSelOrigin=null}var s=e.display,u=e.doc;Va(t);var c,f,d=u.sel;if(i&&!t.shiftKey?(f=u.sel.contains(r),c=f>-1?u.sel.ranges[f]:new K(r,r)):c=u.sel.primary(),t.altKey)n="rect",i||(c=new K(r,r)),r=yr(e,t,!0,!0),f=-1;else if("double"==n){var h=hn(u,r);c=e.display.shift||u.extend?tt(u,c,h.anchor,h.head):h}else if("triple"==n){var p=new K(ra(r.line,0),Z(u,ra(r.line+1,0)));c=e.display.shift||u.extend?tt(u,c,p.anchor,p.head):p}else c=tt(u,c,r);i?f>-1?it(u,f,c,el):(f=u.sel.ranges.length,st(u,$(u.sel.ranges.concat([c]),f),{scroll:!1,origin:"*mouse"})):(f=0,st(u,new U([c],0),el),d=u.sel);var m=r,g=s.wrapper.getBoundingClientRect(),y=0,b=Zt(e,function(e){(_o&&!Do?e.buttons:Vi(e))?a(e):l(e)}),w=Zt(e,l);Ua(document,"mousemove",b),Ua(document,"mouseup",w)}function Cr(e,t,r,n,i){try{var o=t.clientX,a=t.clientY}catch(t){return!1}if(o>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&Va(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(a>s.bottom||!$i(e,r))return Ri(t);a-=s.top-l.viewOffset;for(var u=0;u<e.options.gutters.length;++u){var c=l.gutters.childNodes[u];if(c&&c.getBoundingClientRect().right>=o){var f=Ci(e.doc,a),d=e.options.gutters[u];return i(e,r,e,f,d,t),Ri(t)}}}function Lr(e,t){return Cr(e,t,"gutterClick",!0,Gi)}function Sr(e){var t=this;if(!Ui(t,e)&&!vr(t.display,e)){Va(e),_o&&(ua=+new Date);var r=yr(t,e,!0),n=e.dataTransfer.files;if(r&&!mr(t))if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),a=0,l=function(e,n){var l=new FileReader;l.onload=Zt(t,function(){if(o[n]=l.result,++a==i){r=Z(t.doc,r);var e={from:r,to:r,text:hl(o.join("\n")),origin:"paste"};Kr(t.doc,e),lt(t.doc,Y(r,ma(e)))}}),l.readAsText(e)},s=0;i>s;++s)l(n[s],s);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(io(hr,t),20);try{var o=e.dataTransfer.getData("Text");if(o){var u=t.state.draggingText&&t.listSelections();if(ut(t.doc,Y(r,r)),u)for(var s=0;s<u.length;++s)Jr(t.doc,"",u[s].anchor,u[s].head,"drag");t.replaceSelection(o,"around","paste"),hr(t)}}catch(e){}}}}function Mr(e,t){if(_o&&(!e.state.draggingText||+new Date-ua<100))return void qa(t);if(!Ui(e,t)&&!vr(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.setDragImage&&!Vo)){var r=lo("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",jo&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),jo&&r.parentNode.removeChild(r)}}function Tr(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,zo||k(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbarV.scrollTop!=t&&(e.display.scrollbarV.scrollTop=t),zo&&k(e),yt(e,100))}function Ar(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,y(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbarH.scrollLeft!=t&&(e.display.scrollbarH.scrollLeft=t))}function Nr(e,t){var r=t.wheelDeltaX,n=t.wheelDeltaY;null==r&&t.detail&&t.axis==t.HORIZONTAL_AXIS&&(r=t.detail),null==n&&t.detail&&t.axis==t.VERTICAL_AXIS?n=t.detail:null==n&&(n=t.wheelDelta);var i=e.display,o=i.scroller;if(r&&o.scrollWidth>o.clientWidth||n&&o.scrollHeight>o.clientHeight){if(n&&Yo&&Fo)e:for(var a=t.target,l=i.view;a!=o;a=a.parentNode)for(var s=0;s<l.length;s++)if(l[s].node==a){e.display.currentWheelTarget=a;break e}if(r&&!zo&&!jo&&null!=fa)return n&&Tr(e,Math.max(0,Math.min(o.scrollTop+n*fa,o.scrollHeight-o.clientHeight))),Ar(e,Math.max(0,Math.min(o.scrollLeft+r*fa,o.scrollWidth-o.clientWidth))),Va(t),void(i.wheelStartX=null);if(n&&null!=fa){var u=n*fa,c=e.doc.scrollTop,f=c+i.wrapper.clientHeight;0>u?c=Math.max(0,c+u-50):f=Math.min(e.doc.height,f+u+50),k(e,{top:c,bottom:f})}20>ca&&(null==i.wheelStartX?(i.wheelStartX=o.scrollLeft,i.wheelStartY=o.scrollTop,i.wheelDX=r,i.wheelDY=n,setTimeout(function(){if(null!=i.wheelStartX){var e=o.scrollLeft-i.wheelStartX,t=o.scrollTop-i.wheelStartY,r=t&&i.wheelDY&&t/i.wheelDY||e&&i.wheelDX&&e/i.wheelDX;i.wheelStartX=i.wheelStartY=null,r&&(fa=(fa*ca+r)/(ca+1),++ca)}},200)):(i.wheelDX+=r,i.wheelDY+=n))}}function Hr(e,t,r){if("string"==typeof t&&(t=Ma[t],!t))return!1;e.display.pollingFast&&fr(e)&&(e.display.pollingFast=!1);var n=e.display.shift,i=!1;try{mr(e)&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=Qa}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function Or(e){var t=e.state.keyMaps.slice(0);return e.options.extraKeys&&t.push(e.options.extraKeys),t.push(e.options.keyMap),t}function zr(e,t){var r=mn(e.options.keyMap),n=r.auto;clearTimeout(da),n&&!Na(t)&&(da=setTimeout(function(){mn(e.options.keyMap)==r&&(e.options.keyMap=n.call?n.call(null,e):n,l(e))},50));var i=Ha(t,!0),o=!1;if(!i)return!1;var a=Or(e);return o=t.shiftKey?Aa("Shift-"+i,a,function(t){return Hr(e,t,!0)})||Aa(i,a,function(t){return("string"==typeof t?/^go[A-Z]/.test(t):t.motion)?Hr(e,t):void 0}):Aa(i,a,function(t){return Hr(e,t)}),o&&(Va(t),vt(e),Gi(e,"keyHandled",e,i,t)),o}function Wr(e,t,r){var n=Aa("'"+r+"'",Or(e),function(t){return Hr(e,t,!0)});return n&&(Va(t),vt(e),Gi(e,"keyHandled",e,"'"+r+"'",t)),n}function Er(e){var t=this;if(pr(t),!Ui(t,e)){Wo&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=zr(t,e);jo&&(ha=n?r:null,!n&&88==r&&!ml&&(Yo?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||Ir(t)}}function Ir(e){function t(e){18!=e.keyCode&&e.altKey||(po(r,"CodeMirror-crosshair"),Ka(document,"keyup",t),Ka(document,"mouseover",t))}var r=e.display.lineDiv;mo(r,"CodeMirror-crosshair"),Ua(document,"keyup",t),Ua(document,"mouseover",t)}function Dr(e){Ui(this,e)||16==e.keyCode&&(this.doc.sel.shift=!1)}function Pr(e){var t=this;if(!Ui(t,e)){var r=e.keyCode,n=e.charCode;if(jo&&r==ha)return ha=null,void Va(e);if(!(jo&&(!e.which||e.which<10)||Go)||!zr(t,e)){var i=String.fromCharCode(null==n?r:n);Wr(t,e,i)||(_o&&!Io&&(t.display.inputHasSelection=null),cr(t))}}}function _r(e){"nocursor"!=e.options.readOnly&&(e.state.focused||($a(e,"focus",e),e.state.focused=!0,mo(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu!=e.doc.sel||(dr(e),Fo&&setTimeout(io(dr,e,!0),0))),ur(e),vt(e))}function Fr(e){e.state.focused&&($a(e,"blur",e),e.state.focused=!1,po(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Br(e,t){function r(){if(null!=i.input.selectionStart){var t=e.somethingSelected(),r=i.input.value="​"+(t?i.input.value:"");i.prevInput=t?"":"​",i.input.selectionStart=1,i.input.selectionEnd=r.length}}function n(){if(i.inputDiv.style.position="relative",i.input.style.cssText=s,Io&&(i.scrollbarV.scrollTop=i.scroller.scrollTop=a),ur(e),null!=i.input.selectionStart){(!_o||Io)&&r(),clearTimeout(pa);var t=0,n=function(){i.selForContextMenu==e.doc.sel&&0==i.input.selectionStart?Zt(e,Ma.selectAll)(e):t++<10?pa=setTimeout(n,500):dr(e)};pa=setTimeout(n,200)}}if(!Ui(e,t,"contextmenu")){var i=e.display;if(!vr(i,t)&&!Rr(e,t)){var o=yr(e,t),a=i.scroller.scrollTop;if(o&&!jo){var l=e.options.resetSelectionOnContextMenu;l&&-1==e.doc.sel.contains(o)&&Zt(e,st)(e.doc,Y(o),Ja);var s=i.input.style.cssText;if(i.inputDiv.style.position="absolute",i.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(t.clientY-5)+"px; left: "+(t.clientX-5)+"px; z-index: 1000; background: "+(_o?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",hr(e),dr(e),e.somethingSelected()||(i.input.value=i.prevInput=" "),i.selForContextMenu=e.doc.sel,_o&&!Io&&r(),Jo){qa(t);var u=function(){Ka(window,"mouseup",u),setTimeout(n,20)};Ua(window,"mouseup",u)}else setTimeout(n,50)}}}}function Rr(e,t){return $i(e,"gutterContextMenu")?Cr(e,t,"gutterContextMenu",!1,$a):!1}function jr(e,t){if(na(e,t.from)<0)return e;if(na(e,t.to)<=0)return ma(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=ma(t).ch-t.to.ch),ra(r,n)}function Vr(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new K(jr(i.anchor,t),jr(i.head,t)))}return $(r,e.sel.primIndex)}function Gr(e,t,r){return e.line==t.line?ra(r.line,e.ch-t.ch+r.ch):ra(r.line+(e.line-t.line),e.ch)}function qr(e,t,r){for(var n=[],i=ra(e.first,0),o=i,a=0;a<t.length;a++){var l=t[a],s=Gr(l.from,i,o),u=Gr(ma(l),i,o);if(i=l.to,o=u,"around"==r){var c=e.sel.ranges[a],f=na(c.head,c.anchor)<0;n[a]=new K(f?u:s,f?s:u)}else n[a]=new K(s,s)}return new U(n,e.sel.primIndex)}function Ur(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return r&&(n.update=function(t,r,n,i){t&&(this.from=Z(e,t)),r&&(this.to=Z(e,r)),n&&(this.text=n),void 0!==i&&(this.origin=i)}),$a(e,"beforeChange",e,n),e.cm&&$a(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function Kr(e,t,r){if(e.cm){if(!e.cm.curOp)return Zt(e.cm,Kr)(e,t,r);if(e.cm.state.suppressEdits)return}if(!($i(e,"beforeChange")||e.cm&&$i(e.cm,"beforeChange"))||(t=Ur(e,t,!0))){var n=ea&&!r&&Hn(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)$r(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else $r(e,t)}}function $r(e,t){if(1!=t.text.length||""!=t.text[0]||0!=na(t.from,t.to)){var r=Vr(e,t);Hi(e,t,r,e.cm?e.cm.curOp.id:0/0),Zr(e,t,r,Tn(e,t));var n=[];gi(e,function(e,r){r||-1!=eo(n,e.history)||(Bi(e.history,t),n.push(e.history)),Zr(e,t,null,Tn(e,t))})}}function Yr(e,t,r){if(!e.cm||!e.cm.state.suppressEdits){for(var n=e.history,i,o=e.sel,a="undo"==t?n.done:n.undone,l="undo"==t?n.undone:n.done,s=0;s<a.length&&(i=a[s],r?!i.ranges||i.equals(e.sel):i.ranges);s++);if(s!=a.length){for(n.lastOrigin=n.lastSelOrigin=null;i=a.pop(),i.ranges;){if(Wi(i,l),r&&!i.equals(e.sel))return void st(e,i,{clearRedo:!1});o=i}var u=[];Wi(o,l),l.push({changes:u,generation:n.generation}),n.generation=i.generation||++n.maxGeneration;for(var c=$i(e,"beforeChange")||e.cm&&$i(e.cm,"beforeChange"),s=i.changes.length-1;s>=0;--s){var f=i.changes[s];if(f.origin=t,c&&!Ur(e,f,!1))return void(a.length=0);u.push(Ti(e,f));var d=s?Vr(e,f,null):Ji(a);Zr(e,f,d,Nn(e,f)),e.cm&&an(e.cm);var h=[];gi(e,function(e,t){t||-1!=eo(h,e.history)||(Bi(e.history,f),h.push(e.history)),Zr(e,f,null,Nn(e,f))})}}}}function Xr(e,t){e.first+=t,e.sel=new U(to(e.sel.ranges,function(e){return new K(ra(e.anchor.line+t,e.anchor.ch),ra(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm&&rr(e.cm,e.first,e.first-t,t)}function Zr(e,t,r,n){if(e.cm&&!e.cm.curOp)return Zt(e.cm,Zr)(e,t,r,n);if(t.to.line<e.first)return void Xr(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);Xr(e,i),t={from:ra(e.first,0),to:ra(t.to.line+i,t.to.ch),text:[Ji(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:ra(o,yi(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=bi(e,t.from,t.to),r||(r=Vr(e,t,null)),e.cm?Qr(e.cm,t,n):hi(e,t,n),ut(e,r,Ja)}}function Qr(e,t,r){var n=e.doc,i=e.display,a=t.from,l=t.to,s=!1,u=a.line;e.options.lineWrapping||(u=ki(Bn(yi(n,a.line))),n.iter(u,l.line+1,function(e){return e==i.maxLine?(s=!0,!0):void 0})),n.sel.contains(t.from,t.to)>-1&&Ki(e),hi(n,t,r,o(e)),e.options.lineWrapping||(n.iter(u,a.line+t.text.length,function(e){var t=d(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,a.line),yt(e,400);var c=t.text.length-(l.line-a.line)-1;a.line!=l.line||1!=t.text.length||di(e.doc,t)?rr(e,a.line,l.line+1,c):nr(e,a.line,"text");var f=$i(e,"changes"),h=$i(e,"change");if(h||f){var p={from:a,to:l,text:t.text,removed:t.removed,origin:t.origin};h&&Gi(e,"change",e,p),f&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}}function Jr(e,t,r,n,i){if(n||(n=r),na(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=hl(t)),Kr(e,{from:r,to:n,text:t,origin:i})}function en(e,t){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null;if(t.top+n.top<0?i=!0:t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!Uo){var o=lo("div","​",null,"position: absolute; top: "+(t.top-r.viewOffset-kt(e.display))+"px; height: "+(t.bottom-t.top+Za)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}function tn(e,t,r,n){for(null==n&&(n=0);;){var i=!1,o=Rt(e,t),a=r&&r!=t?Rt(e,r):o,l=nn(e,Math.min(o.left,a.left),Math.min(o.top,a.top)-n,Math.max(o.left,a.left),Math.max(o.bottom,a.bottom)+n),s=e.doc.scrollTop,u=e.doc.scrollLeft;if(null!=l.scrollTop&&(Tr(e,l.scrollTop),Math.abs(e.doc.scrollTop-s)>1&&(i=!0)),null!=l.scrollLeft&&(Ar(e,l.scrollLeft),Math.abs(e.doc.scrollLeft-u)>1&&(i=!0)),!i)return o}}function rn(e,t,r,n,i){var o=nn(e,t,r,n,i);null!=o.scrollTop&&Tr(e,o.scrollTop),null!=o.scrollLeft&&Ar(e,o.scrollLeft)}function nn(e,t,r,n,i){var o=e.display,a=Ut(e.display);0>r&&(r=0);var l=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,s=o.scroller.clientHeight-Za,u={},c=e.doc.height+Ct(o),f=a>r,d=i>c-a;if(l>r)u.scrollTop=f?0:r;else if(i>l+s){var h=Math.min(r,(d?c:i)-s);h!=l&&(u.scrollTop=h)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,m=o.scroller.clientWidth-Za;t+=o.gutters.offsetWidth,n+=o.gutters.offsetWidth;var g=o.gutters.offsetWidth,v=g+10>t;return p+g>t||v?(v&&(t=0),u.scrollLeft=Math.max(0,t-10-g)):n>m+p-3&&(u.scrollLeft=n+10-m),u}function on(e,t,r){(null!=t||null!=r)&&ln(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function an(e){ln(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?ra(t.line,t.ch-1):t,n=ra(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function ln(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=jt(e,t.from),n=jt(e,t.to),i=nn(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function sn(e,t,r,n){var i=e.doc,o;null==r&&(r="add"),"smart"==r&&(e.doc.mode.indent?o=xt(e,t):r="prev");var a=e.options.tabSize,l=yi(i,t),s=rl(l.text,null,a);l.stateAfter&&(l.stateAfter=null);var u=l.text.match(/^\s*/)[0],c;if(n||/\S/.test(l.text)){if("smart"==r&&(c=e.doc.mode.indent(o,l.text.slice(u.length),l.text),c==Qa)){if(!n)return;r="prev"}}else c=0,r="not";"prev"==r?c=t>i.first?rl(yi(i,t-1).text,null,a):0:"add"==r?c=s+e.options.indentUnit:"subtract"==r?c=s-e.options.indentUnit:"number"==typeof r&&(c=s+r),c=Math.max(0,c);var f="",d=0;if(e.options.indentWithTabs)for(var h=Math.floor(c/a);h;--h)d+=a,f+=" ";if(c>d&&(f+=Qi(c-d)),f!=u)Jr(e.doc,f,ra(t,0),ra(t,u.length),"+input");else for(var h=0;h<i.sel.ranges.length;h++){var p=i.sel.ranges[h];if(p.head.line==t&&p.head.ch<u.length){var d=ra(t,u.length);it(i,h,new K(d,d));break}}l.stateAfter=null}function un(e,t,r,n){var i=t,o=t,a=e.doc;return"number"==typeof t?o=yi(a,X(a,t)):i=ki(t),null==i?null:(n(o,i)&&nr(e,i,r),o)}function cn(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&na(o.from,Ji(n).to)<=0;){var a=n.pop();if(na(a.from,o.from)<0){o.from=a.from;break}}n.push(o)}Xt(e,function(){for(var t=n.length-1;t>=0;t--)Jr(e.doc,"",n[t].from,n[t].to,"+delete");an(e)})}function fn(e,t,r,n,i){function o(){var t=l+r;return t<e.first||t>=e.first+e.size?f=!1:(l=t,c=yi(e,t))}function a(e){var t=(i?Ho:Oo)(c,s,r,!0);if(null==t){if(e||!o())return f=!1;s=i?(0>r?Lo:Co)(c):0>r?c.text.length:0}else s=t;return!0}var l=t.line,s=t.ch,u=r,c=yi(e,l),f=!0;if("char"==n)a();else if("column"==n)a(!0);else if("word"==n||"group"==n)for(var d=null,h="group"==n,p=!0;!(0>r)||a(!p);p=!1){var m=c.text.charAt(s)||"\n",g=al(m)?"w":h&&"\n"==m?"n":!h||/\s/.test(m)?null:"p";if(!h||p||g||(g="s"),d&&d!=g){0>r&&(r=1,a());break}if(g&&(d=g),r>0&&!a(!p))break
3
  }var v=ht(e,ra(l,s),u,!0);return f||(v.hitSide=!0),v}function dn(e,t,r,n){var i=e.doc,o=t.left,a;if("page"==n){var l=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);a=t.top+r*(l-(0>r?1.5:.5)*Ut(e.display))}else"line"==n&&(a=r>0?t.bottom+3:t.top-3);for(;;){var s=Gt(e,o,a);if(!s.outside)break;if(0>r?0>=a:a>=i.height){s.hitSide=!0;break}a+=5*r}return s}function hn(e,t){var r=yi(e,t.line).text,n=t.ch,i=t.ch;if(r){(t.xRel<0||i==r.length)&&n?--n:++i;for(var o=r.charAt(n),a=al(o)?al:/\s/.test(o)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!al(e)};n>0&&a(r.charAt(n-1));)--n;for(;i<r.length&&a(r.charAt(i));)++i}return new K(ra(t.line,n),ra(t.line,i))}function pn(t,r,n,i){e.defaults[t]=r,n&&(va[t]=i?function(e,t,r){r!=ya&&n(e,t,r)}:n)}function mn(e){return"string"==typeof e?Ta[e]:e}function gn(e,t,r,n,i){if(n&&n.shared)return vn(e,t,r,n,i);if(e.cm&&!e.cm.curOp)return Zt(e.cm,gn)(e,t,r,n,i);var o=new za(e,i),a=na(t,r);if(n&&no(n,o,!1),a>0||0==a&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=lo("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||(o.widgetNode.ignoreEvents=!0),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(Fn(e,t.line,t,r,o)||t.line!=r.line&&Fn(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");ta=!0}o.addToHistory&&Hi(e,{from:t,to:r,origin:"markText"},e.sel,0/0);var l=t.line,s=e.cm,u;if(e.iter(l,r.line+1,function(e){s&&o.collapsed&&!s.options.lineWrapping&&Bn(e)==s.display.maxLine&&(u=!0),o.collapsed&&l!=t.line&&xi(e,0),Ln(e,new xn(o,l==t.line?t.ch:null,l==r.line?r.ch:null)),++l}),o.collapsed&&e.iter(t.line,r.line+1,function(t){Gn(e,t)&&xi(t,0)}),o.clearOnEnter&&Ua(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(ea=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++Wa,o.atomic=!0),s){if(u&&(s.curOp.updateMaxLine=!0),o.collapsed)rr(s,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle)for(var c=t.line;c<=r.line;c++)nr(s,c,"text");o.atomic&&ft(s.doc),Gi(s,"markerAdded",s,o)}return o}function vn(e,t,r,n,i){n=no(n),n.shared=!1;var o=[gn(e,t,r,n,i)],a=o[0],l=n.widgetNode;return gi(e,function(e){l&&(n.widgetNode=l.cloneNode(!0)),o.push(gn(e,Z(e,t),Z(e,r),n,i));for(var s=0;s<e.linked.length;++s)if(e.linked[s].isParent)return;a=Ji(o)}),new Ea(o,a)}function yn(e){return e.findMarks(ra(e.first,0),e.clipPos(ra(e.lastLine())),function(e){return e.parent})}function bn(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=n.find(),o=e.clipPos(i.from),a=e.clipPos(i.to);if(na(o,a)){var l=gn(e,o,a,n.primary,n.primary.type);n.markers.push(l),l.parent=n}}}function wn(e){for(var t=0;t<e.length;t++){var r=e[t],n=[r.primary.doc];gi(r.primary.doc,function(e){n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];-1==eo(n,o.doc)&&(o.parent=null,r.markers.splice(i--,1))}}}function xn(e,t,r){this.marker=e,this.from=t,this.to=r}function kn(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function Cn(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function Ln(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function Sn(e,t,r){if(e)for(var n=0,i;n<e.length;++n){var o=e[n],a=o.marker,l=null==o.from||(a.inclusiveLeft?o.from<=t:o.from<t);if(l||o.from==t&&"bookmark"==a.type&&(!r||!o.marker.insertLeft)){var s=null==o.to||(a.inclusiveRight?o.to>=t:o.to>t);(i||(i=[])).push(new xn(a,o.from,s?null:o.to))}}return i}function Mn(e,t,r){if(e)for(var n=0,i;n<e.length;++n){var o=e[n],a=o.marker,l=null==o.to||(a.inclusiveRight?o.to>=t:o.to>t);if(l||o.from==t&&"bookmark"==a.type&&(!r||o.marker.insertLeft)){var s=null==o.from||(a.inclusiveLeft?o.from<=t:o.from<t);(i||(i=[])).push(new xn(a,s?null:o.from-t,null==o.to?null:o.to-t))}}return i}function Tn(e,t){var r=J(e,t.from.line)&&yi(e,t.from.line).markedSpans,n=J(e,t.to.line)&&yi(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,a=0==na(t.from,t.to),l=Sn(r,i,a),s=Mn(n,o,a),u=1==t.text.length,c=Ji(t.text).length+(u?i:0);if(l)for(var f=0;f<l.length;++f){var d=l[f];if(null==d.to){var h=kn(s,d.marker);h?u&&(d.to=null==h.to?null:h.to+c):d.to=i}}if(s)for(var f=0;f<s.length;++f){var d=s[f];if(null!=d.to&&(d.to+=c),null==d.from){var h=kn(l,d.marker);h||(d.from=c,u&&(l||(l=[])).push(d))}else d.from+=c,u&&(l||(l=[])).push(d)}l&&(l=An(l)),s&&s!=l&&(s=An(s));var p=[l];if(!u){var m=t.text.length-2,g;if(m>0&&l)for(var f=0;f<l.length;++f)null==l[f].to&&(g||(g=[])).push(new xn(l[f].marker,null,null));for(var f=0;m>f;++f)p.push(g);p.push(s)}return p}function An(e){for(var t=0;t<e.length;++t){var r=e[t];null!=r.from&&r.from==r.to&&r.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Nn(e,t){var r=Di(e,t),n=Tn(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],a=n[i];if(o&&a)e:for(var l=0;l<a.length;++l){for(var s=a[l],u=0;u<o.length;++u)if(o[u].marker==s.marker)continue e;o.push(s)}else a&&(r[i]=a)}return r}function Hn(e,t,r){var n=null;if(e.iter(t.line,r.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var r=e.markedSpans[t].marker;!r.readOnly||n&&-1!=eo(n,r)||(n||(n=[])).push(r)}}),!n)return null;for(var i=[{from:t,to:r}],o=0;o<n.length;++o)for(var a=n[o],l=a.find(0),s=0;s<i.length;++s){var u=i[s];if(!(na(u.to,l.from)<0||na(u.from,l.to)>0)){var c=[s,1],f=na(u.from,l.from),d=na(u.to,l.to);(0>f||!a.inclusiveLeft&&!f)&&c.push({from:u.from,to:l.from}),(d>0||!a.inclusiveRight&&!d)&&c.push({from:l.to,to:u.to}),i.splice.apply(i,c),s+=c.length-1}}return i}function On(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function zn(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function Wn(e){return e.inclusiveLeft?-1:0}function En(e){return e.inclusiveRight?1:0}function In(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=na(n.from,i.from)||Wn(e)-Wn(t);if(o)return-o;var a=na(n.to,i.to)||En(e)-En(t);return a?a:t.id-e.id}function Dn(e,t){var r=ta&&e.markedSpans,n;if(r)for(var i,o=0;o<r.length;++o)i=r[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!n||In(n,i.marker)<0)&&(n=i.marker);return n}function Pn(e){return Dn(e,!0)}function _n(e){return Dn(e,!1)}function Fn(e,t,r,n,i){var o=yi(e,t),a=ta&&o.markedSpans;if(a)for(var l=0;l<a.length;++l){var s=a[l];if(s.marker.collapsed){var u=s.marker.find(0),c=na(u.from,r)||Wn(s.marker)-Wn(i),f=na(u.to,n)||En(s.marker)-En(i);if(!(c>=0&&0>=f||0>=c&&f>=0)&&(0>=c&&(na(u.to,r)||En(s.marker)-Wn(i))>0||c>=0&&(na(u.from,n)||Wn(s.marker)-En(i))<0))return!0}}}function Bn(e){for(var t;t=Pn(e);)e=t.find(-1,!0).line;return e}function Rn(e){for(var t,r;t=_n(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function jn(e,t){var r=yi(e,t),n=Bn(r);return r==n?t:ki(n)}function Vn(e,t){if(t>e.lastLine())return t;var r=yi(e,t),n;if(!Gn(e,r))return t;for(;n=_n(r);)r=n.find(1,!0).line;return ki(r)+1}function Gn(e,t){var r=ta&&t.markedSpans;if(r)for(var n,i=0;i<r.length;++i)if(n=r[i],n.marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&qn(e,t,n))return!0}}function qn(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return qn(e,n.line,kn(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==r.to&&(null==i.to||i.to!=r.from)&&(i.marker.inclusiveLeft||r.marker.inclusiveRight)&&qn(e,t,i))return!0}function Un(e,t,r){Li(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&on(e,null,r)}function Kn(e){return null!=e.height?e.height:(co(document.body,e.node)||uo(e.cm.display.measure,lo("div",[e.node],null,"position: relative")),e.height=e.node.offsetHeight)}function $n(e,t,r,n){var i=new Ia(e,r,n);return i.noHScroll&&(e.display.alignWidgets=!0),un(e,t,"widget",function(t){var r=t.widgets||(t.widgets=[]);if(null==i.insertAt?r.push(i):r.splice(Math.min(r.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,!Gn(e.doc,t)){var n=Li(t)<e.doc.scrollTop;xi(t,t.height+Kn(i)),n&&on(e,null,i.height),e.curOp.forceUpdate=!0}return!0}),i}function Yn(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),On(e),zn(e,r);var i=n?n(e):1;i!=e.height&&xi(e,i)}function Xn(e){e.parent=null,On(e)}function Zn(e,t){if(e)for(;;){var r=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;e=e.slice(0,r.index)+e.slice(r.index+r[0].length);var n=r[1]?"bgClass":"textClass";null==t[n]?t[n]=r[2]:new RegExp("(?:^|s)"+r[2]+"(?:$|s)").test(t[n])||(t[n]+=" "+r[2])}return e}function Qn(t,r){if(t.blankLine)return t.blankLine(r);if(t.innerMode){var n=e.innerMode(t,r);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function Jn(e,t,r){var n=e.token(t,r);if(t.pos<=t.start)throw new Error("Mode "+e.name+" failed to advance stream.");return n}function ei(t,r,n,i,o,a,l){var s=n.flattenSpans;null==s&&(s=t.options.flattenSpans);var u=0,c=null,f=new Oa(r,t.options.tabSize),d;for(""==r&&Zn(Qn(n,i),a);!f.eol();){if(f.pos>t.options.maxHighlightLength?(s=!1,l&&ni(t,r,i,f.pos),f.pos=r.length,d=null):d=Zn(Jn(n,f,i),a),t.options.addModeClass){var h=e.innerMode(n,i).mode.name;h&&(d="m-"+(d?h+" "+d:h))}s&&c==d||(u<f.start&&o(f.start,c),u=f.start,c=d),f.start=f.pos}for(;u<f.pos;){var p=Math.min(f.pos,u+5e4);o(p,c),u=p}}function ti(e,t,r,n){var i=[e.state.modeGen],o={};ei(e,t.text,e.doc.mode,r,function(e,t){i.push(e,t)},o,n);for(var a=0;a<e.state.overlays.length;++a){var l=e.state.overlays[a],s=1,u=0;ei(e,t.text,l.mode,!0,function(e,t){for(var r=s;e>u;){var n=i[s];n>e&&i.splice(s,1,e,i[s+1],n),s+=2,u=Math.min(e,n)}if(t)if(l.opaque)i.splice(r,s-r,e,"cm-overlay "+t),s=r+2;else for(;s>r;r+=2){var o=i[r+1];i[r+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function ri(e,t){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=ti(e,t,t.stateAfter=xt(e,ki(t)));t.styles=r.styles,r.classes?t.styleClasses=r.classes:t.styleClasses&&(t.styleClasses=null)}return t.styles}function ni(e,t,r,n){var i=e.doc.mode,o=new Oa(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&Qn(i,r);!o.eol()&&o.pos<=e.options.maxHighlightLength;)Jn(i,o,r),o.start=o.pos}function ii(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?_a:Pa;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function oi(e,t){var r=lo("span",null,null,Fo?"padding-right: .1px":null),n={pre:lo("pre",[r]),content:r,col:0,pos:0,cm:e};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o=i?t.rest[i-1]:t.line,a;n.pos=0,n.addToken=li,(_o||Fo)&&e.getOption("lineWrapping")&&(n.addToken=si(n.addToken)),bo(e.display.measure)&&(a=Si(o))&&(n.addToken=ui(n.addToken,a)),n.map=[],fi(o,n,ri(e,o)),o.styleClasses&&(o.styleClasses.bgClass&&(n.bgClass=go(o.styleClasses.bgClass,n.bgClass||"")),o.styleClasses.textClass&&(n.textClass=go(o.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(yo(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return $a(e,"renderLine",e,t.line,n.pre),n}function ai(e){var t=lo("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t}function li(e,t,r,n,i,o){if(t){var a=e.cm.options.specialChars,l=!1;if(a.test(t))for(var s=document.createDocumentFragment(),u=0;;){a.lastIndex=u;var c=a.exec(t),f=c?c.index-u:t.length-u;if(f){var d=document.createTextNode(t.slice(u,u+f));s.appendChild(Io?lo("span",[d]):d),e.map.push(e.pos,e.pos+f,d),e.col+=f,e.pos+=f}if(!c)break;if(u+=f+1," "==c[0]){var h=e.cm.options.tabSize,p=h-e.col%h,d=s.appendChild(lo("span",Qi(p),"cm-tab"));e.col+=p}else{var d=e.cm.options.specialCharPlaceholder(c[0]);s.appendChild(Io?lo("span",[d]):d),e.col+=1}e.map.push(e.pos,e.pos+1,d),e.pos++}else{e.col+=t.length;var s=document.createTextNode(t);e.map.push(e.pos,e.pos+t.length,s),Io&&(l=!0),e.pos+=t.length}if(r||n||i||l){var m=r||"";n&&(m+=n),i&&(m+=i);var g=lo("span",[s],m);return o&&(g.title=o),e.content.appendChild(g)}e.content.appendChild(s)}}function si(e){function t(e){for(var t=" ",r=0;r<e.length-2;++r)t+=r%2?" ":" ";return t+=" "}return function(r,n,i,o,a,l){e(r,n.replace(/ {3,}/g,t),i,o,a,l)}}function ui(e,t){return function(r,n,i,o,a,l){i=i?i+" cm-force-border":"cm-force-border";for(var s=r.pos,u=s+n.length;;){for(var c=0;c<t.length;c++){var f=t[c];if(f.to>s&&f.from<=s)break}if(f.to>=u)return e(r,n,i,o,a,l);e(r,n.slice(0,f.to-s),i,o,null,l),o=null,n=n.slice(f.to-s),s=f.to}}}function ci(e,t,r,n){var i=!n&&r.widgetNode;i&&(e.map.push(e.pos,e.pos+t,i),e.content.appendChild(i)),e.pos+=t}function fi(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var a=i.length,l=0,s=1,u="",c,f=0,d,h,p,m,g;;){if(f==l){d=h=p=m="",g=null,f=1/0;for(var v=[],y=0;y<n.length;++y){var b=n[y],w=b.marker;b.from<=l&&(null==b.to||b.to>l)?(null!=b.to&&f>b.to&&(f=b.to,h=""),w.className&&(d+=" "+w.className),w.startStyle&&b.from==l&&(p+=" "+w.startStyle),w.endStyle&&b.to==f&&(h+=" "+w.endStyle),w.title&&!m&&(m=w.title),w.collapsed&&(!g||In(g.marker,w)<0)&&(g=b)):b.from>l&&f>b.from&&(f=b.from),"bookmark"==w.type&&b.from==l&&w.widgetNode&&v.push(w)}if(g&&(g.from||0)==l&&(ci(t,(null==g.to?a+1:g.to)-l,g.marker,null==g.from),null==g.to))return;if(!g&&v.length)for(var y=0;y<v.length;++y)ci(t,0,v[y])}if(l>=a)break;for(var x=Math.min(a,f);;){if(u){var k=l+u.length;if(!g){var C=k>x?u.slice(0,x-l):u;t.addToken(t,C,c?c+d:d,p,l+C.length==f?h:"",m)}if(k>=x){u=u.slice(x-l),l=x;break}l=k,p=""}u=i.slice(o,o=r[s++]),c=ii(r[s++],t.cm.options)}}else for(var s=1;s<r.length;s+=2)t.addToken(t,i.slice(o,o=r[s]),ii(r[s+1],t.cm.options))}function di(e,t){return 0==t.from.ch&&0==t.to.ch&&""==Ji(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function hi(e,t,r,n){function i(e){return r?r[e]:null}function o(e,r,i){Yn(e,r,i,n),Gi(e,"change",e,t)}var a=t.from,l=t.to,s=t.text,u=yi(e,a.line),c=yi(e,l.line),f=Ji(s),d=i(s.length-1),h=l.line-a.line;if(di(e,t)){for(var p=0,m=[];p<s.length-1;++p)m.push(new Da(s[p],i(p),n));o(c,c.text,d),h&&e.remove(a.line,h),m.length&&e.insert(a.line,m)}else if(u==c)if(1==s.length)o(u,u.text.slice(0,a.ch)+f+u.text.slice(l.ch),d);else{for(var m=[],p=1;p<s.length-1;++p)m.push(new Da(s[p],i(p),n));m.push(new Da(f+u.text.slice(l.ch),d,n)),o(u,u.text.slice(0,a.ch)+s[0],i(0)),e.insert(a.line+1,m)}else if(1==s.length)o(u,u.text.slice(0,a.ch)+s[0]+c.text.slice(l.ch),i(0)),e.remove(a.line+1,h);else{o(u,u.text.slice(0,a.ch)+s[0],i(0)),o(c,f+c.text.slice(l.ch),d);for(var p=1,m=[];p<s.length-1;++p)m.push(new Da(s[p],i(p),n));h>1&&e.remove(a.line+1,h-1),e.insert(a.line+1,m)}Gi(e,"change",e,t)}function pi(e){this.lines=e,this.parent=null;for(var t=0,r=0;t<e.length;++t)e[t].parent=this,r+=e[t].height;this.height=r}function mi(e){this.children=e;for(var t=0,r=0,n=0;n<e.length;++n){var i=e[n];t+=i.chunkSize(),r+=i.height,i.parent=this}this.size=t,this.height=r,this.parent=null}function gi(e,t,r){function n(e,i,o){if(e.linked)for(var a=0;a<e.linked.length;++a){var l=e.linked[a];if(l.doc!=i){var s=o&&l.sharedHist;(!r||s)&&(t(l.doc,s),n(l.doc,e,s))}}}n(e,null,!0)}function vi(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,a(e),r(e),e.options.lineWrapping||h(e),e.options.mode=t.modeOption,rr(e)}function yi(e,t){if(t-=e.first,0>t||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(o>t){r=i;break}t-=o}return r.lines[t]}function bi(e,t,r){var n=[],i=t.line;return e.iter(t.line,r.line+1,function(e){var o=e.text;i==r.line&&(o=o.slice(0,r.ch)),i==t.line&&(o=o.slice(t.ch)),n.push(o),++i}),n}function wi(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function xi(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function ki(e){if(null==e.parent)return null;for(var t=e.parent,r=eo(t.lines,e),n=t.parent;n;t=n,n=n.parent)for(var i=0;n.children[i]!=t;++i)r+=n.children[i].chunkSize();return r+t.first}function Ci(e,t){var r=e.first;e:do{for(var n=0;n<e.children.length;++n){var i=e.children[n],o=i.height;if(o>t){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var n=0;n<e.lines.length;++n){var a=e.lines[n],l=a.height;if(l>t)break;t-=l}return r+n}function Li(e){e=Bn(e);for(var t=0,r=e.parent,n=0;n<r.lines.length;++n){var i=r.lines[n];if(i==e)break;t+=i.height}for(var o=r.parent;o;r=o,o=r.parent)for(var n=0;n<o.children.length;++n){var a=o.children[n];if(a==r)break;t+=a.height}return t}function Si(e){var t=e.order;return null==t&&(t=e.order=yl(e.text)),t}function Mi(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Ti(e,t){var r={from:V(t.from),to:ma(t),text:bi(e,t.from,t.to)};return Ei(e,r,t.from.line,t.to.line+1),gi(e,function(e){Ei(e,r,t.from.line,t.to.line+1)},!0),r}function Ai(e){for(;e.length;){var t=Ji(e);if(!t.ranges)break;e.pop()}}function Ni(e,t){return t?(Ai(e.done),Ji(e.done)):e.done.length&&!Ji(e.done).ranges?Ji(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),Ji(e.done)):void 0}function Hi(e,t,r,n){var i=e.history;i.undone.length=0;var o=+new Date,a;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>o-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(a=Ni(i,i.lastOp==n))){var l=Ji(a.changes);0==na(t.from,t.to)&&0==na(t.from,l.to)?l.to=ma(t):a.changes.push(Ti(e,t))}else{var s=Ji(i.done);for(s&&s.ranges||Wi(e.sel,i.done),a={changes:[Ti(e,t)],generation:i.generation},i.done.push(a);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=o,i.lastOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,l||$a(e,"historyAdded")}function Oi(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function zi(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||Oi(e,o,Ji(i.done),t))?i.done[i.done.length-1]=t:Wi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastOp=r,n&&n.clearRedo!==!1&&Ai(i.undone)}function Wi(e,t){var r=Ji(t);r&&r.ranges&&r.equals(e)||t.push(e)}function Ei(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function Ii(e){if(!e)return null;for(var t=0,r;t<e.length;++t)e[t].marker.explicitlyCleared?r||(r=e.slice(0,t)):r&&r.push(e[t]);return r?r.length?r:null:e}function Di(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=0,i=[];n<t.text.length;++n)i.push(Ii(r[n]));return i}function Pi(e,t,r){for(var n=0,i=[];n<e.length;++n){var o=e[n];if(o.ranges)i.push(r?U.prototype.deepCopy.call(o):o);else{var a=o.changes,l=[];i.push({changes:l});for(var s=0;s<a.length;++s){var u=a[s],c;if(l.push({from:u.from,to:u.to,text:u.text}),t)for(var f in u)(c=f.match(/^spans_(\d+)$/))&&eo(t,Number(c[1]))>-1&&(Ji(l)[f]=u[f],delete u[f])}}}return i}function _i(e,t,r,n){r<e.line?e.line+=n:t<e.line&&(e.line=t,e.ch=0)}function Fi(e,t,r,n){for(var i=0;i<e.length;++i){var o=e[i],a=!0;if(o.ranges){o.copied||(o=e[i]=o.deepCopy(),o.copied=!0);for(var l=0;l<o.ranges.length;l++)_i(o.ranges[l].anchor,t,r,n),_i(o.ranges[l].head,t,r,n)}else{for(var l=0;l<o.changes.length;++l){var s=o.changes[l];if(r<s.from.line)s.from=ra(s.from.line+n,s.from.ch),s.to=ra(s.to.line+n,s.to.ch);else if(t<=s.to.line){a=!1;break}}a||(e.splice(0,i+1),i=0)}}}function Bi(e,t){var r=t.from.line,n=t.to.line,i=t.text.length-(n-r)-1;Fi(e.done,r,n,i),Fi(e.undone,r,n,i)}function Ri(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function ji(e){return e.target||e.srcElement}function Vi(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),Yo&&e.ctrlKey&&1==t&&(t=3),t}function Gi(e,t){function r(e){return function(){e.apply(null,i)}}var n=e._handlers&&e._handlers[t];if(n){var i=Array.prototype.slice.call(arguments,2);Ya||(++Xa,Ya=[],setTimeout(qi,0));for(var o=0;o<n.length;++o)Ya.push(r(n[o]))}}function qi(){--Xa;var e=Ya;Ya=null;for(var t=0;t<e.length;++t)e[t]()}function Ui(e,t,r){return $a(e,r||t.type,e,t),Ri(t)||t.codemirrorIgnore}function Ki(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var r=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),n=0;n<t.length;++n)-1==eo(r,t[n])&&r.push(t[n])}function $i(e,t){var r=e._handlers&&e._handlers[t];return r&&r.length>0}function Yi(e){e.prototype.on=function(e,t){Ua(this,e,t)},e.prototype.off=function(e,t){Ka(this,e,t)}}function Xi(){this.id=null}function Zi(e,t,r){for(var n=0,i=0;;){var o=e.indexOf(" ",n);-1==o&&(o=e.length);var a=o-n;if(o==e.length||i+a>=t)return n+Math.min(a,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}}function Qi(e){for(;nl.length<=e;)nl.push(Ji(nl)+" ");return nl[e]}function Ji(e){return e[e.length-1]}function eo(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function to(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function ro(e,t){var r;if(Object.create)r=Object.create(e);else{var n=function(){};n.prototype=e,r=new n}return t&&no(t,r),r}function no(e,t,r){t||(t={});for(var n in e)!e.hasOwnProperty(n)||r===!1&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function io(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function oo(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function ao(e){return e.charCodeAt(0)>=768&&ll.test(e)}function lo(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function so(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function uo(e,t){return so(e).appendChild(t)}function co(e,t){if(e.contains)return e.contains(t);for(;t=t.parentNode;)if(t==e)return!0}function fo(){return document.activeElement}function ho(e){return new RegExp("\\b"+e+"\\b\\s*")}function po(e,t){var r=ho(t);r.test(e.className)&&(e.className=e.className.replace(r,""))}function mo(e,t){ho(t).test(e.className)||(e.className+=" "+t)}function go(e,t){for(var r=e.split(" "),n=0;n<r.length;n++)r[n]&&!ho(r[n]).test(t)&&(t+=" "+r[n]);return t}function vo(e){if(null!=cl)return cl;var t=lo("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");return uo(e,t),t.offsetWidth&&(cl=t.offsetHeight-t.clientHeight),cl||0}function yo(e){if(null==fl){var t=lo("span","​");uo(e,lo("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(fl=t.offsetWidth<=1&&t.offsetHeight>2&&!Eo)}return fl?lo("span","​"):lo("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px")}function bo(e){if(null!=dl)return dl;var t=uo(e,document.createTextNode("AخA")),r=sl(t,0,1).getBoundingClientRect();if(r.left==r.right)return!1;var n=sl(t,1,2).getBoundingClientRect();return dl=n.right-r.right<3}function wo(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;o<e.length;++o){var a=e[o];(a.from<r&&a.to>t||t==r&&a.to==t)&&(n(Math.max(a.from,t),Math.min(a.to,r),1==a.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function xo(e){return e.level%2?e.to:e.from}function ko(e){return e.level%2?e.from:e.to}function Co(e){var t=Si(e);return t?xo(t[0]):0}function Lo(e){var t=Si(e);return t?ko(Ji(t)):e.text.length}function So(e,t){var r=yi(e.doc,t),n=Bn(r);n!=r&&(t=ki(n));var i=Si(n),o=i?i[0].level%2?Lo(n):Co(n):0;return ra(t,o)}function Mo(e,t){for(var r,n=yi(e.doc,t);r=_n(n);)n=r.find(1,!0).line,t=null;var i=Si(n),o=i?i[0].level%2?Co(n):Lo(n):n.text.length;return ra(null==t?ki(n):t,o)}function To(e,t,r){var n=e[0].level;return t==n?!0:r==n?!1:r>t}function Ao(e,t){vl=null;for(var r=0,n;r<e.length;++r){var i=e[r];if(i.from<t&&i.to>t)return r;if(i.from==t||i.to==t){if(null!=n)return To(e,i.level,e[n].level)?(i.from!=i.to&&(vl=n),r):(i.from!=i.to&&(vl=r),n);n=r}}return n}function No(e,t,r,n){if(!n)return t+r;do t+=r;while(t>0&&ao(e.text.charAt(t)));return t}function Ho(e,t,r,n){var i=Si(e);if(!i)return Oo(e,t,r,n);for(var o=Ao(i,t),a=i[o],l=No(e,t,a.level%2?-r:r,n);;){if(l>a.from&&l<a.to)return l;if(l==a.from||l==a.to)return Ao(i,l)==o?l:(a=i[o+=r],r>0==a.level%2?a.to:a.from);if(a=i[o+=r],!a)return null;l=r>0==a.level%2?No(e,a.to,-1,n):No(e,a.from,1,n)}}function Oo(e,t,r,n){var i=t+r;if(n)for(;i>0&&ao(e.text.charAt(i));)i+=r;return 0>i||i>e.text.length?null:i}var zo=/gecko\/\d/i.test(navigator.userAgent),Wo=/MSIE \d/.test(navigator.userAgent),Eo=Wo&&(null==document.documentMode||document.documentMode<8),Io=Wo&&(null==document.documentMode||document.documentMode<9),Do=Wo&&(null==document.documentMode||document.documentMode<10),Po=/Trident\/([7-9]|\d{2,})\./.test(navigator.userAgent),_o=Wo||Po,Fo=/WebKit\//.test(navigator.userAgent),Bo=Fo&&/Qt\/\d+\.\d+/.test(navigator.userAgent),Ro=/Chrome\//.test(navigator.userAgent),jo=/Opera\//.test(navigator.userAgent),Vo=/Apple Computer/.test(navigator.vendor),Go=/KHTML\//.test(navigator.userAgent),qo=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),Uo=/PhantomJS/.test(navigator.userAgent),Ko=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),$o=Ko||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),Yo=Ko||/Mac/.test(navigator.platform),Xo=/win/i.test(navigator.platform),Zo=jo&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);Zo&&(Zo=Number(Zo[1])),Zo&&Zo>=15&&(jo=!1,Fo=!0);var Qo=Yo&&(Bo||jo&&(null==Zo||12.11>Zo)),Jo=zo||_o&&!Io,ea=!1,ta=!1,ra=e.Pos=function(e,t){return this instanceof ra?(this.line=e,void(this.ch=t)):new ra(e,t)},na=e.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch};U.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 r=this.ranges[t],n=e.ranges[t];if(0!=na(r.anchor,n.anchor)||0!=na(r.head,n.head))return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new K(V(this.ranges[t].anchor),V(this.ranges[t].head));return new U(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 r=0;r<this.ranges.length;r++){var n=this.ranges[r];if(na(t,n.from())>=0&&na(e,n.to())<=0)return r}return-1}},K.prototype={from:function(){return q(this.anchor,this.head)},to:function(){return G(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var ia={left:0,right:0,top:0,bottom:0},oa,aa=0,la,sa,ua=0,ca=0,fa=null;_o?fa=-.53:zo?fa=15:Ro?fa=-.7:Vo&&(fa=-1/3);var da,ha=null,pa,ma=e.changeEnd=function(e){return e.text?ra(e.from.line+e.text.length-1,Ji(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),hr(this),cr(this)},setOption:function(e,t){var r=this.options,n=r[e];(r[e]!=t||"mode"==e)&&(r[e]=t,va.hasOwnProperty(e)&&Zt(this,va[e])(this,t,n))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](e)},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;r<t.length;++r)if(t[r]==e||"string"!=typeof t[r]&&t[r].name==e)return t.splice(r,1),!0},addOverlay:Qt(function(t,r){var n=t.token?t:e.getMode(this.options,t);if(n.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:n,modeSpec:t,opaque:r&&r.opaque}),this.state.modeGen++,rr(this)}),removeOverlay:Qt(function(e){for(var t=this.state.overlays,r=0;r<t.length;++r){var n=t[r].modeSpec;if(n==e||"string"==typeof e&&n.name==e)return t.splice(r,1),this.state.modeGen++,void rr(this)}}),indentLine:Qt(function(e,t,r){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),J(this.doc,e)&&sn(this,e,t,r)}),indentSelection:Qt(function(e){for(var t=this.doc.sel.ranges,r=-1,n=0;n<t.length;n++){var i=t[n];if(i.empty())i.head.line>r&&(sn(this,i.head.line,e,!0),r=i.head.line,n==this.doc.sel.primIndex&&an(this));else{var o=Math.max(r,i.from().line),a=i.to();r=Math.min(this.lastLine(),a.line-(a.ch?0:1))+1;for(var l=o;r>l;++l)sn(this,l,e)}}}),getTokenAt:function(e,t){var r=this.doc;e=Z(r,e);for(var n=xt(this,e.line,t),i=this.doc.mode,o=yi(r,e.line),a=new Oa(o.text,this.options.tabSize);a.pos<e.ch&&!a.eol();){a.start=a.pos;var l=Jn(i,a,n)}return{start:a.start,end:a.pos,string:a.current(),type:l||null,state:n}},getTokenTypeAt:function(e){e=Z(this.doc,e);var t=ri(this,yi(this.doc,e.line)),r=0,n=(t.length-1)/2,i=e.ch,o;if(0==i)o=t[2];else for(;;){var a=r+n>>1;if((a?t[2*a-1]:0)>=i)n=a;else{if(!(t[2*a+1]<i)){o=t[2*a+2];break}r=a+1}}var l=o?o.indexOf("cm-overlay "):-1;return 0>l?o:0==l?null:o.slice(0,l-1)},getModeAt:function(t){var r=this.doc.mode;return r.innerMode?e.innerMode(r,this.getTokenAt(t).state).mode:r},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var r=[];if(!Ca.hasOwnProperty(t))return Ca;var n=Ca[t],i=this.getModeAt(e);if("string"==typeof i[t])n[i[t]]&&r.push(n[i[t]]);else if(i[t])for(var o=0;o<i[t].length;o++){var a=n[i[t][o]];a&&r.push(a)}else i.helperType&&n[i.helperType]?r.push(n[i.helperType]):n[i.name]&&r.push(n[i.name]);for(var o=0;o<n._global.length;o++){var l=n._global[o];l.pred(i,this)&&-1==eo(r,l.val)&&r.push(l.val)}return r},getStateAfter:function(e,t){var r=this.doc;return e=X(r,null==e?r.first+r.size-1:e),xt(this,e+1,t)},cursorCoords:function(e,t){var r,n=this.doc.sel.primary();return r=null==e?n.head:"object"==typeof e?Z(this.doc,e):e?n.from():n.to(),Rt(this,r,t||"page")},charCoords:function(e,t){return Bt(this,Z(this.doc,e),t||"page")},coordsChar:function(e,t){return e=Ft(this,e,t||"page"),Gt(this,e.left,e.top)},lineAtHeight:function(e,t){return e=Ft(this,{top:e,left:0},t||"page").top,Ci(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var r=!1,n=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>n&&(e=n,r=!0);var i=yi(this.doc,e);return _t(this,i,{top:0,left:0},t||"page").top+(r?this.doc.height-Li(i):0)},defaultTextHeight:function(){return Ut(this.display)},defaultCharWidth:function(){return Kt(this.display)},setGutterMarker:Qt(function(e,t,r){return un(this,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});return n[t]=r,!r&&oo(n)&&(e.gutterMarkers=null),!0})}),clearGutter:Qt(function(e){var t=this,r=t.doc,n=r.first;r.iter(function(r){r.gutterMarkers&&r.gutterMarkers[e]&&(r.gutterMarkers[e]=null,nr(t,n,"gutter"),oo(r.gutterMarkers)&&(r.gutterMarkers=null)),++n})}),addLineClass:Qt(function(e,t,r){return un(this,e,"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"wrapClass";if(e[n]){if(new RegExp("(?:^|\\s)"+r+"(?:$|\\s)").test(e[n]))return!1;e[n]+=" "+r}else e[n]=r;return!0})}),removeLineClass:Qt(function(e,t,r){return un(this,e,"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"wrapClass",i=e[n];if(!i)return!1;if(null==r)e[n]=null;else{var o=i.match(new RegExp("(?:^|\\s+)"+r+"(?:$|\\s+)"));if(!o)return!1;var a=o.index+o[0].length;e[n]=i.slice(0,o.index)+(o.index&&a!=i.length?" ":"")+i.slice(a)||null}return!0})}),addLineWidget:Qt(function(e,t,r){return $n(this,e,t,r)}),removeLineWidget:function(e){e.clear()},lineInfo:function(e){if("number"==typeof e){if(!J(this.doc,e))return null;
4
  var t=e;if(e=yi(this.doc,e),!e)return null}else{var t=ki(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=Rt(this,Z(this.doc,e));var a=e.bottom,l=e.left;if(t.style.position="absolute",o.sizer.appendChild(t),"over"==n)a=e.top;else if("above"==n||"near"==n){var s=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>s)&&e.top>t.offsetHeight?a=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=s&&(a=e.bottom),l+t.offsetWidth>u&&(l=u-t.offsetWidth)}t.style.top=a+"px",t.style.left=t.style.right="","right"==i?(l=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?l=0:"middle"==i&&(l=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=l+"px"),r&&rn(this,l,a,l+t.offsetWidth,a+t.offsetHeight)},triggerOnKeyDown:Qt(Er),triggerOnKeyPress:Qt(Pr),triggerOnKeyUp:Qt(Dr),execCommand:function(e){return Ma.hasOwnProperty(e)?Ma[e](this):void 0},findPosH:function(e,t,r,n){var i=1;0>t&&(i=-1,t=-t);for(var o=0,a=Z(this.doc,e);t>o&&(a=fn(this.doc,a,i,r,n),!a.hitSide);++o);return a},moveH:Qt(function(e,t){var r=this;r.extendSelectionsBy(function(n){return r.display.shift||r.doc.extend||n.empty()?fn(r.doc,n.head,e,t,r.options.rtlMoveVisually):0>e?n.from():n.to()},tl)}),deleteH:Qt(function(e,t){var r=this.doc.sel,n=this.doc;r.somethingSelected()?n.replaceSelection("",null,"+delete"):cn(this,function(r){var i=fn(n,r.head,e,t,!1);return 0>e?{from:i,to:r.head}:{from:r.head,to:i}})}),findPosV:function(e,t,r,n){var i=1,o=n;0>t&&(i=-1,t=-t);for(var a=0,l=Z(this.doc,e);t>a;++a){var s=Rt(this,l,"div");if(null==o?o=s.left:s.left=o,l=dn(this,s,i,r),l.hitSide)break}return l},moveV:Qt(function(e,t){var r=this,n=this.doc,i=[],o=!r.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(function(a){if(o)return 0>e?a.from():a.to();var l=Rt(r,a.head,"div");null!=a.goalColumn&&(l.left=a.goalColumn),i.push(l.left);var s=dn(r,l,e,t);return"page"==t&&a==n.sel.primary()&&on(r,null,Bt(r,s,"div").top-l.top),s},tl),i.length)for(var a=0;a<n.sel.ranges.length;a++)n.sel.ranges[a].goalColumn=i[a]}),toggleOverwrite:function(e){(null==e||e!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?mo(this.display.cursorDiv,"CodeMirror-overwrite"):po(this.display.cursorDiv,"CodeMirror-overwrite"),$a(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return fo()==this.display.input},scrollTo:Qt(function(e,t){(null!=e||null!=t)&&ln(this),null!=e&&(this.curOp.scrollLeft=e),null!=t&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller,t=Za;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-t,width:e.scrollWidth-t,clientHeight:e.clientHeight-t,clientWidth:e.clientWidth-t}},scrollIntoView:Qt(function(e,t){if(null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:ra(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line)ln(this),this.curOp.scrollToPos=e;else{var r=nn(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(r.scrollLeft,r.scrollTop)}}),setSize:Qt(function(e,t){function r(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e}null!=e&&(this.display.wrapper.style.width=r(e)),null!=t&&(this.display.wrapper.style.height=r(t)),this.options.lineWrapping&&Et(this),this.curOp.forceUpdate=!0,$a(this,"refresh",this)}),operation:function(e){return Xt(this,e)},refresh:Qt(function(){var e=this.display.cachedTextHeight;rr(this),this.curOp.forceUpdate=!0,It(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),f(this),(null==e||Math.abs(e-Ut(this.display))>.5)&&a(this),$a(this,"refresh",this)}),swapDoc:Qt(function(e){var t=this.doc;return t.cm=null,vi(this,e),It(this),dr(this),this.scrollTo(e.scrollLeft,e.scrollTop),Gi(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}},Yi(e);var ga=e.defaults={},va=e.optionHandlers={},ya=e.Init={toString:function(){return"CodeMirror.Init"}};pn("value","",function(e,t){e.setValue(t)},!0),pn("mode",null,function(e,t){e.doc.modeOption=t,r(e)},!0),pn("indentUnit",2,r,!0),pn("indentWithTabs",!1),pn("smartIndent",!0),pn("tabSize",4,function(e){n(e),It(e),rr(e)},!0),pn("specialChars",/[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\ufeff]/g,function(e,t){e.options.specialChars=new RegExp(t.source+(t.test(" ")?"":"| "),"g"),e.refresh()},!0),pn("specialCharPlaceholder",ai,function(e){e.refresh()},!0),pn("electricChars",!0),pn("rtlMoveVisually",!Xo),pn("wholeLineUpdateBefore",!0),pn("theme","default",function(e){s(e),u(e)},!0),pn("keyMap","default",l),pn("extraKeys",null),pn("lineWrapping",!1,i,!0),pn("gutters",[],function(e){p(e.options),u(e)},!0),pn("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?x(e.display)+"px":"0",e.refresh()},!0),pn("coverGutterNextToScrollbar",!1,g,!0),pn("lineNumbers",!1,function(e){p(e.options),u(e)},!0),pn("firstLineNumber",1,u,!0),pn("lineNumberFormatter",function(e){return e},u,!0),pn("showCursorWhenSelecting",!1,pt,!0),pn("resetSelectionOnContextMenu",!0),pn("readOnly",!1,function(e,t){"nocursor"==t?(Fr(e),e.display.input.blur(),e.display.disabled=!0):(e.display.disabled=!1,t||dr(e))}),pn("disableInput",!1,function(e,t){t||dr(e)},!0),pn("dragDrop",!0),pn("cursorBlinkRate",530),pn("cursorScrollMargin",0),pn("cursorHeight",1),pn("workTime",100),pn("workDelay",100),pn("flattenSpans",!0,n,!0),pn("addModeClass",!1,n,!0),pn("pollInterval",100),pn("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),pn("historyEventDelay",1250),pn("viewportMargin",10,function(e){e.refresh()},!0),pn("maxHighlightLength",1e4,n,!0),pn("moveInputWithCursor",!0,function(e,t){t||(e.display.inputDiv.style.top=e.display.inputDiv.style.left=0)}),pn("tabindex",null,function(e,t){e.display.input.tabIndex=t||""}),pn("autofocus",null);var ba=e.modes={},wa=e.mimeModes={};e.defineMode=function(t,r){if(e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2){r.dependencies=[];for(var n=2;n<arguments.length;++n)r.dependencies.push(arguments[n])}ba[t]=r},e.defineMIME=function(e,t){wa[e]=t},e.resolveMode=function(t){if("string"==typeof t&&wa.hasOwnProperty(t))t=wa[t];else if(t&&"string"==typeof t.name&&wa.hasOwnProperty(t.name)){var r=wa[t.name];"string"==typeof r&&(r={name:r}),t=ro(r,t),t.name=r.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,r){var r=e.resolveMode(r),n=ba[r.name];if(!n)return e.getMode(t,"text/plain");var i=n(t,r);if(xa.hasOwnProperty(r.name)){var o=xa[r.name];for(var a in o)o.hasOwnProperty(a)&&(i.hasOwnProperty(a)&&(i["_"+a]=i[a]),i[a]=o[a])}if(i.name=r.name,r.helperType&&(i.helperType=r.helperType),r.modeProps)for(var a in r.modeProps)i[a]=r.modeProps[a];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var xa=e.modeExtensions={};e.extendMode=function(e,t){var r=xa.hasOwnProperty(e)?xa[e]:xa[e]={};no(t,r)},e.defineExtension=function(t,r){e.prototype[t]=r},e.defineDocExtension=function(e,t){Ba.prototype[e]=t},e.defineOption=pn;var ka=[];e.defineInitHook=function(e){ka.push(e)};var Ca=e.helpers={};e.registerHelper=function(t,r,n){Ca.hasOwnProperty(t)||(Ca[t]=e[t]={_global:[]}),Ca[t][r]=n},e.registerGlobalHelper=function(t,r,n,i){e.registerHelper(t,r,i),Ca[t]._global.push({pred:n,val:i})};var La=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r},Sa=e.startState=function(e,t,r){return e.startState?e.startState(t,r):!0};e.innerMode=function(e,t){for(;e.innerMode;){var r=e.innerMode(t);if(!r||r.mode==e)break;t=r.state,e=r.mode}return r||{mode:e,state:t}};var Ma=e.commands={selectAll:function(e){e.setSelection(ra(e.firstLine(),0),ra(e.lastLine()),Ja)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Ja)},killLine:function(e){cn(e,function(t){if(t.empty()){var r=yi(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line<e.lastLine()?{from:t.head,to:ra(t.head.line+1,0)}:{from:t.head,to:ra(t.head.line,r)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){cn(e,function(t){return{from:ra(t.from().line,0),to:Z(e.doc,ra(t.to().line+1,0))}})},delLineLeft:function(e){cn(e,function(e){return{from:ra(e.from().line,0),to:e.from()}})},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(ra(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(ra(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return So(e,t.head.line)},tl)},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){var r=So(e,t.head.line),n=e.getLineHandle(r.line),i=Si(n);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),a=t.head.line==r.line&&t.head.ch<=o&&t.head.ch;return ra(r.line,a?0:o)}return r},tl)},goLineEnd:function(e){e.extendSelectionsBy(function(t){return Mo(e,t.head.line)},tl)},goLineRight:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div")},tl)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:r},"div")},tl)},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){for(var t=[],r=e.listSelections(),n=e.options.tabSize,i=0;i<r.length;i++){var o=r[i].from(),a=rl(e.getLine(o.line),o.ch,n);t.push(new Array(n-a%n+1).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Xt(e,function(){for(var t=e.listSelections(),r=0;r<t.length;r++){var n=t[r].head,i=yi(e.doc,n.line).text;n.ch>0&&n.ch<i.length-1&&e.replaceRange(i.charAt(n.ch)+i.charAt(n.ch-1),ra(n.line,n.ch-1),ra(n.line,n.ch+1))}})},newlineAndIndent:function(e){Xt(e,function(){for(var t=e.listSelections().length,r=0;t>r;r++){var n=e.listSelections()[r];e.replaceRange("\n",n.anchor,n.head,"+input"),e.indentLine(n.from().line+1,null,!0),an(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},Ta=e.keyMap={};Ta.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"},Ta.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Ta.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delLineLeft","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection",fallthrough:["basic","emacsy"]},Ta.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"},Ta["default"]=Yo?Ta.macDefault:Ta.pcDefault;var Aa=e.lookupKey=function(e,t,r){function n(t){t=mn(t);var i=t[e];if(i===!1)return"stop";if(null!=i&&r(i))return!0;if(t.nofallthrough)return"stop";var o=t.fallthrough;if(null==o)return!1;if("[object Array]"!=Object.prototype.toString.call(o))return n(o);for(var a=0;a<o.length;++a){var l=n(o[a]);if(l)return l}return!1}for(var i=0;i<t.length;++i){var o=n(t[i]);if(o)return"stop"!=o}},Na=e.isModifierKey=function(e){var t=gl[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t},Ha=e.keyName=function(e,t){if(jo&&34==e.keyCode&&e["char"])return!1;var r=gl[e.keyCode];return null==r||e.altGraphKey?!1:(e.altKey&&(r="Alt-"+r),(Qo?e.metaKey:e.ctrlKey)&&(r="Ctrl-"+r),(Qo?e.ctrlKey:e.metaKey)&&(r="Cmd-"+r),!t&&e.shiftKey&&(r="Shift-"+r),r)};e.fromTextArea=function(t,r){function n(){t.value=u.getValue()}if(r||(r={}),r.value=t.value,!r.tabindex&&t.tabindex&&(r.tabindex=t.tabindex),!r.placeholder&&t.placeholder&&(r.placeholder=t.placeholder),null==r.autofocus){var i=fo();r.autofocus=i==t||null!=t.getAttribute("autofocus")&&i==document.body}if(t.form&&(Ua(t.form,"submit",n),!r.leaveSubmitMethodAlone)){var o=t.form,a=o.submit;try{var l=o.submit=function(){n(),o.submit=a,o.submit(),o.submit=l}}catch(s){}}t.style.display="none";var u=e(function(e){t.parentNode.insertBefore(e,t.nextSibling)},r);return u.save=n,u.getTextArea=function(){return t},u.toTextArea=function(){n(),t.parentNode.removeChild(u.getWrapperElement()),t.style.display="",t.form&&(Ka(t.form,"submit",n),"function"==typeof t.form.submit&&(t.form.submit=a))},u};var Oa=e.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};Oa.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(e){var t=this.string.charAt(this.pos);if("string"==typeof e)var r=t==e;else var r=t&&(e.test?e.test(t):e(t));return r?(++this.pos,t):void 0},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=rl(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?rl(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return rl(this.string,null,this.tabSize)-(this.lineStart?rl(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,r){if("string"!=typeof e){var n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var za=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e};Yi(za),za.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&$t(e),$i(this,"clear")){var r=this.find();r&&Gi(this,"clear",r.from,r.to)}for(var n=null,i=null,o=0;o<this.lines.length;++o){var a=this.lines[o],l=kn(a.markedSpans,this);e&&!this.collapsed?nr(e,ki(a),"text"):e&&(null!=l.to&&(i=ki(a)),null!=l.from&&(n=ki(a))),a.markedSpans=Cn(a.markedSpans,l),null==l.from&&this.collapsed&&!Gn(this.doc,a)&&e&&xi(a,Ut(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var o=0;o<this.lines.length;++o){var s=Bn(this.lines[o]),u=d(s);u>e.display.maxLineLength&&(e.display.maxLine=s,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=n&&e&&this.collapsed&&rr(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&ft(e.doc)),e&&Gi(e,"markerCleared",e,this),t&&Yt(e),this.parent&&this.parent.clear()}},za.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var r,n,i=0;i<this.lines.length;++i){var o=this.lines[i],a=kn(o.markedSpans,this);if(null!=a.from&&(r=ra(t?o:ki(o),a.from),-1==e))return r;if(null!=a.to&&(n=ra(t?o:ki(o),a.to),1==e))return n}return r&&{from:r,to:n}},za.prototype.changed=function(){var e=this.find(-1,!0),t=this,r=this.doc.cm;e&&r&&Xt(r,function(){var n=e.line,i=ki(e.line),o=Nt(r,i);if(o&&(Wt(o),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Gn(t.doc,n)&&null!=t.height){var a=t.height;t.height=null;var l=Kn(t)-a;l&&xi(n,n.height+l)}})},za.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&-1!=eo(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},za.prototype.detachLine=function(e){if(this.lines.splice(eo(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var Wa=0,Ea=e.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var r=0;r<e.length;++r)e[r].parent=this};Yi(Ea),Ea.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();Gi(this,"clear")}},Ea.prototype.find=function(e,t){return this.primary.find(e,t)};var Ia=e.LineWidget=function(e,t,r){if(r)for(var n in r)r.hasOwnProperty(n)&&(this[n]=r[n]);this.cm=e,this.node=t};Yi(Ia),Ia.prototype.clear=function(){var e=this.cm,t=this.line.widgets,r=this.line,n=ki(r);if(null!=n&&t){for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(r.widgets=null);var o=Kn(this);Xt(e,function(){Un(e,r,-o),nr(e,n,"widget"),xi(r,Math.max(0,r.height-o))})}},Ia.prototype.changed=function(){var e=this.height,t=this.cm,r=this.line;this.height=null;var n=Kn(this)-e;n&&Xt(t,function(){t.curOp.forceUpdate=!0,Un(t,r,n),xi(r,r.height+n)})};var Da=e.Line=function(e,t,r){this.text=e,zn(this,t),this.height=r?r(this):1};Yi(Da),Da.prototype.lineNo=function(){return ki(this)};var Pa={},_a={};pi.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var r=e,n=e+t;n>r;++r){var i=this.lines[r];this.height-=i.height,Xn(i),Gi(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,r){this.height+=r,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var n=0;n<t.length;++n)t[n].parent=this},iterN:function(e,t,r){for(var n=e+t;n>e;++e)if(r(this.lines[e]))return!0}},mi.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var r=0;r<this.children.length;++r){var n=this.children[r],i=n.chunkSize();if(i>e){var o=Math.min(t,i-e),a=n.height;if(n.removeInner(e,o),this.height-=a-n.height,i==o&&(this.children.splice(r--,1),n.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof pi))){var l=[];this.collapse(l),this.children=[new pi(l)],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,r){this.size+=t.length,this.height+=r;for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>=e){if(i.insertInner(e,t,r),i.lines&&i.lines.length>50){for(;i.lines.length>50;){var a=i.lines.splice(i.lines.length-25,25),l=new pi(a);i.height-=l.height,this.children.splice(n+1,0,l),l.parent=this}this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),r=new mi(t);if(e.parent){e.size-=r.size,e.height-=r.height;var n=eo(e.parent.children,e);e.parent.children.splice(n+1,0,r)}else{var i=new mi(e.children);i.parent=e,e.children=[i,r],e=i}r.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>e){var a=Math.min(t,o-e);if(i.iterN(e,a,r))return!0;if(0==(t-=a))break;e=0}else e-=o}}};var Fa=0,Ba=e.Doc=function(e,t,r){if(!(this instanceof Ba))return new Ba(e,t,r);null==r&&(r=0),mi.call(this,[new pi([new Da("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var n=ra(r,0);this.sel=Y(n),this.history=new Mi(null),this.id=++Fa,this.modeOption=t,"string"==typeof e&&(e=hl(e)),hi(this,{from:n,to:n,text:e}),st(this,Y(n),Ja)};Ba.prototype=ro(mi.prototype,{constructor:Ba,iter:function(e,t,r){r?this.iterN(e-this.first,t-e,r):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var r=0,n=0;n<t.length;++n)r+=t[n].height;this.insertInner(e-this.first,t,r)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=wi(this,this.first,this.first+this.size);return e===!1?t:t.join(e||"\n")},setValue:Jt(function(e){var t=ra(this.first,0),r=this.first+this.size-1;Kr(this,{from:t,to:ra(r,yi(this,r).text.length),text:hl(e),origin:"setValue"},!0),st(this,Y(t))}),replaceRange:function(e,t,r,n){t=Z(this,t),r=r?Z(this,r):t,Jr(this,e,t,r,n)},getRange:function(e,t,r){var n=bi(this,Z(this,e),Z(this,t));return r===!1?n:n.join(r||"\n")},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){return J(this,e)?yi(this,e):void 0},getLineNumber:function(e){return ki(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=yi(this,e)),Bn(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return Z(this,e)},getCursor:function(e){var t=this.sel.primary(),r;return r=null==e||"head"==e?t.head:"anchor"==e?t.anchor:"end"==e||"to"==e||e===!1?t.to():t.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:Jt(function(e,t,r){ot(this,Z(this,"number"==typeof e?ra(e,t||0):e),null,r)}),setSelection:Jt(function(e,t,r){ot(this,Z(this,e),Z(this,t||e),r)}),extendSelection:Jt(function(e,t,r){rt(this,Z(this,e),t&&Z(this,t),r)}),extendSelections:Jt(function(e,t){nt(this,et(this,e,t))}),extendSelectionsBy:Jt(function(e,t){nt(this,to(this.sel.ranges,e),t)}),setSelections:Jt(function(e,t,r){if(e.length){for(var n=0,i=[];n<e.length;n++)i[n]=new K(Z(this,e[n].anchor),Z(this,e[n].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),st(this,$(i,t),r)}}),addSelection:Jt(function(e,t,r){var n=this.sel.ranges.slice(0);n.push(new K(Z(this,e),Z(this,t||e))),st(this,$(n,n.length-1),r)}),getSelection:function(e){for(var t=this.sel.ranges,r,n=0;n<t.length;n++){var i=bi(this,t[n].from(),t[n].to());r=r?r.concat(i):i}return e===!1?r:r.join(e||"\n")},getSelections:function(e){for(var t=[],r=this.sel.ranges,n=0;n<r.length;n++){var i=bi(this,r[n].from(),r[n].to());e!==!1&&(i=i.join(e||"\n")),t[n]=i}return t},replaceSelection:function(e,t,r){for(var n=[],i=0;i<this.sel.ranges.length;i++)n[i]=e;this.replaceSelections(n,t,r||"+input")},replaceSelections:Jt(function(e,t,r){for(var n=[],i=this.sel,o=0;o<i.ranges.length;o++){var a=i.ranges[o];n[o]={from:a.from(),to:a.to(),text:hl(e[o]),origin:r}}for(var l=t&&"end"!=t&&qr(this,n,t),o=n.length-1;o>=0;o--)Kr(this,n[o]);l?lt(this,l):this.cm&&an(this.cm)}),undo:Jt(function(){Yr(this,"undo")}),redo:Jt(function(){Yr(this,"redo")}),undoSelection:Jt(function(){Yr(this,"undo",!0)}),redoSelection:Jt(function(){Yr(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n<e.done.length;n++)e.done[n].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++r;return{undo:t,redo:r}},clearHistory:function(){this.history=new Mi(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:Pi(this.history.done),undone:Pi(this.history.undone)}},setHistory:function(e){var t=this.history=new Mi(this.history.maxGeneration);t.done=Pi(e.done.slice(0),null,!0),t.undone=Pi(e.undone.slice(0),null,!0)},markText:function(e,t,r){return gn(this,Z(this,e),Z(this,t),r,"range")},setBookmark:function(e,t){var r={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared};return e=Z(this,e),gn(this,e,e,r,"bookmark")},findMarksAt:function(e){e=Z(this,e);var t=[],r=yi(this,e.line).markedSpans;if(r)for(var n=0;n<r.length;++n){var i=r[n];(null==i.from||i.from<=e.ch)&&(null==i.to||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=Z(this,e),t=Z(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var a=o.markedSpans;if(a)for(var l=0;l<a.length;l++){var s=a[l];i==e.line&&e.ch>s.to||null==s.from&&i!=e.line||i==t.line&&s.from>t.ch||r&&!r(s.marker)||n.push(s.marker.parent||s.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;n<r.length;++n)null!=r[n].from&&e.push(r[n].marker)}),e},posFromIndex:function(e){var t,r=this.first;return this.iter(function(n){var i=n.text.length+1;return i>e?(t=e,!0):(e-=i,void++r)}),Z(this,ra(r,t))},indexFromPos:function(e){e=Z(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 Ba(wi(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,r=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<r&&(r=e.to);var n=new Ba(wi(this,t,r),e.mode||this.modeOption,t);return e.sharedHist&&(n.history=this.history),(this.linked||(this.linked=[])).push({doc:n,sharedHist:e.sharedHist}),n.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],bn(n,yn(this)),n},unlinkDoc:function(t){if(t instanceof e&&(t=t.doc),this.linked)for(var r=0;r<this.linked.length;++r){var n=this.linked[r];if(n.doc==t){this.linked.splice(r,1),t.unlinkDoc(this),wn(yn(this));break}}if(t.history==this.history){var i=[t.id];gi(t,function(e){i.push(e.id)},!0),t.history=new Mi(null),t.history.done=Pi(this.history.done,i),t.history.undone=Pi(this.history.undone,i)}},iterLinkedDocs:function(e){gi(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),Ba.prototype.eachLine=Ba.prototype.iter;var Ra="iter insert remove copy getEditor".split(" ");for(var ja in Ba.prototype)Ba.prototype.hasOwnProperty(ja)&&eo(Ra,ja)<0&&(e.prototype[ja]=function(e){return function(){return e.apply(this.doc,arguments)}}(Ba.prototype[ja]));Yi(Ba);var Va=e.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},Ga=e.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},qa=e.e_stop=function(e){Va(e),Ga(e)},Ua=e.on=function(e,t,r){if(e.addEventListener)e.addEventListener(t,r,!1);else if(e.attachEvent)e.attachEvent("on"+t,r);else{var n=e._handlers||(e._handlers={}),i=n[t]||(n[t]=[]);i.push(r)}},Ka=e.off=function(e,t,r){if(e.removeEventListener)e.removeEventListener(t,r,!1);else if(e.detachEvent)e.detachEvent("on"+t,r);else{var n=e._handlers&&e._handlers[t];if(!n)return;for(var i=0;i<n.length;++i)if(n[i]==r){n.splice(i,1);break}}},$a=e.signal=function(e,t){var r=e._handlers&&e._handlers[t];if(r)for(var n=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,n)},Ya,Xa=0,Za=30,Qa=e.Pass={toString:function(){return"CodeMirror.Pass"}},Ja={scroll:!1},el={origin:"*mouse"},tl={origin:"+move"};Xi.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var rl=e.countColumn=function(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/),-1==t&&(t=e.length));for(var o=n||0,a=i||0;;){var l=e.indexOf(" ",o);if(0>l||l>=t)return a+(t-o);a+=l-o,a+=r-a%r,o=l+1}},nl=[""],il=function(e){e.select()};Ko?il=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:_o&&(il=function(e){try{e.select()}catch(t){}}),[].indexOf&&(eo=function(e,t){return e.indexOf(t)}),[].map&&(to=function(e,t){return e.map(t)});var ol=/[\u00df\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,al=e.isWordChar=function(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||ol.test(e))},ll=/[\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]/,sl;
1
+ function heshPlugin(){var e=null,t=0,r=0,n=document.getElementById("content"),i=null!==document.getElementById("post_ID")?document.getElementById("post_ID").value:0,o=document.getElementById("content-html"),a=document.getElementById("content-tmce"),l=-1!==document.cookie.indexOf("hesh_plugin_theme=mbo")?"mbo":"default",s=-1!==document.cookie.indexOf("editor%3Dtinymce")?!0:!1,u=null!==document.getElementById("content-tmce")?!0:!1,c=document.getElementById("ed_toolbar"),f=document.getElementById("wp-content-editor-container"),d="heshFullscreen",h=document.getElementById("publish"),p={mode:"text/html",tabMode:"indent",theme:l,lineNumbers:!0,matchBrackets:!0,indentUnit:4,indentWithTabs:!0,enterMode:"keep",lineWrapping:!0,autofocus:!0,styleActiveLine:!0,electricChars:!1,extraKeys:{F11:function(){C()},Esc:function(){C()},"Ctrl-S":function(){h.click()},"Cmd-S":function(){h.click()}}},m=function(e){var t="; "+document.cookie,r=t.split("; "+e+"=");return 2==r.length?r.pop().split(";").shift():void 0},g=m("hesh_plugin_font_size")||"12",v=function(r){y(),e=CodeMirror.fromTextArea(r,p),e.on("change",function(){e.save()}),e.on("cursorActivity",function(){var t=e.getCursor();document.cookie="hesh_plugin_pos="+i+","+t.line+","+t.ch});var n=(m("hesh_plugin_pos")||"0,0,0").split(",");i===n[0]&&e.setCursor(parseFloat(n[1]),parseFloat(n[2])),k(),A(),t=1},y=function(){if(!r){var e={more:["<!--more-->",""],comment:["<!-- "," -->"],code:["<code>","</code>"],li:["<li>","</li>"],ol:["<ol>","</ol>"],ul:["<ul>","</ul>"],img:['<img src="$" alt="','">',"Enter the URL of the image"],ins:["<ins>","</ins>"],del:["<del>","</del>"],link:['<a href="$">',"</a>","Enter the destination URL"],blockquote:["\r<blockquote>","</blockquote>\r"],h3:["<h3>","</h3>"],h2:["<h2>","</h2>"],h1:["<h1>","</h1>"],i:["<em>","</em>"],b:["<strong>","</strong>"]};for(var t in e){var n=e[t],i=n[2]?'data-prompt="'+n[2]+'"':"";c.insertAdjacentHTML("afterbegin",'<input type="button" id="cm_content_'+t+"\" data-start='"+n[0]+"' data-end='"+n[1]+"' "+i+' class="ed_button button cm_ed_button" value="'+t+'">'),document.getElementById("cm_content_"+t).onclick=b}S(),T(),L(),r=1}},b=function(){var t=e.getCursor("start"),r=this.getAttribute("data-start"),n=this.getAttribute("data-end"),i=this.getAttribute("data-prompt")||null,o=e.getSelection();"cm_content_link"===this.id&&wpLink?(wpLink.open(),document.getElementById("wp-link-submit").onclick=function(){var n=wpLink.getAttrs();r='<a href="'+n.href+'" title="'+n.title+'" target="'+n.target+'">',e.replaceSelection(r+o+"</a>"),wpLink.close(),e.setCursor(t.line,t.ch+r.length),e.focus()}):(i&&(r=r.replace("$",prompt(i,""))),e.replaceSelection(r+o+n),e.setCursor(t.line,t.ch+r.length),e.focus())},w=function(){t&&(e.toTextArea(),o.onclick=x,switchEditors.switchto(this),t=0)},x=function(){t||(switchEditors.switchto(this),v(n),a.onclick=w)},k=function(){var e=document.querySelector(".CodeMirror"),t=document.createElement("div"),r=document.getElementById("wp-content-wrap"),n=e.getBoundingClientRect().top,i=function(t){t=t||window.event;var r=(t.pageY||t.clientY+document.body.scrollTop+document.documentElement.scrollTop)-n;e.style.height=(r>10?r:10)+"px",window.getSelection().removeAllRanges()};t.className="content-resize-handle",r.appendChild(t),t.onmousedown=function(){document.onmousemove=i},document.onmouseup=function(){document.onmousemove=null}},C=function(){f.className=-1===f.className.indexOf(d)?f.className+" "+d:f.className.replace(d,"");var t=document.getElementById("cm_content_fullscreen");t.value="fullscreen"===t.value?"exit fullscreen":"fullscreen",e.focus()},L=function(){c.insertAdjacentHTML("afterbegin",'<input type="button" id="cm_content_fullscreen" class="ed_button button" title="Toggle fullscreen mode" value="fullscreen">'),document.getElementById("cm_content_fullscreen").onclick=C},S=function(){var t=function(){return"mbo"===l?"light":"dark"};c.insertAdjacentHTML("afterbegin",'<input type="button" id="cm_select_theme" class="ed_button button" title="Change editor colour scheme" value="'+t()+'">'),document.getElementById("cm_select_theme").onclick=function(){l="mbo"===l?"default":"mbo",e.setOption("theme",l),document.cookie="hesh_plugin_theme="+l,this.value=t()}},M=function(){var e=document.getElementById("hesh-style"),t=".CodeMirror {font-size: "+g+"px !important;}";e?e.innerHTML=t:document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend",'<style id="hesh-style">'+t+"</style>")},T=function(){c.insertAdjacentHTML("afterbegin",'<select id="cm_font_size" class="button"><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="16">16</option><option value="18">18</option><option value="20">20</option><option value="22">22</option></select>');var t=document.getElementById("cm_font_size");M(),t.value=g,t.onchange=function(){g=this.value,M(),e.toTextArea(),v(n),e.focus(),document.cookie="hesh_plugin_font_size="+g}},A=function(){window.send_to_editor_wp||(window.send_to_editor_wp=send_to_editor,send_to_editor=function(r){t&&"content"===wpActiveEditor?(e.replaceSelection(r),e.save()):window.send_to_editor_wp(r)})};s&&u?o.onclick=x:(v(n),u&&(a.onclick=w))}!function(e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else{if("function"==typeof define&&define.amd)return define([],e);this.CodeMirror=e()}}(function(){"use strict";function e(r,n){if(!(this instanceof e))return new e(r,n);this.options=n=n||{},no(ga,n,!1),p(n);var i=n.value;"string"==typeof i&&(i=new Ba(i,n.mode)),this.doc=i;var o=this.display=new t(r,i);o.wrapper.CodeMirror=this,c(this),s(this),n.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),n.autofocus&&!$o&&hr(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Xi},Wo&&setTimeout(io(dr,this,!0),20),gr(this);var a=this;Xt(this,function(){a.curOp.forceUpdate=!0,vi(a,i),n.autofocus&&!$o||fo()==o.input?setTimeout(io(_r,a),20):Fr(a);for(var e in va)va.hasOwnProperty(e)&&va[e](a,n[e],ya);for(var t=0;t<ka.length;++t)ka[t](a)})}function t(e,t){var r=this,n=r.input=lo("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none");Fo?n.style.width="1000px":n.setAttribute("wrap","off"),Ko&&(n.style.border="1px solid black"),n.setAttribute("autocorrect","off"),n.setAttribute("autocapitalize","off"),n.setAttribute("spellcheck","false"),r.inputDiv=lo("div",[n],null,"overflow: hidden; position: relative; width: 3px; height: 0px;"),r.scrollbarH=lo("div",[lo("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar"),r.scrollbarV=lo("div",[lo("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),r.scrollbarFiller=lo("div",null,"CodeMirror-scrollbar-filler"),r.gutterFiller=lo("div",null,"CodeMirror-gutter-filler"),r.lineDiv=lo("div",null,"CodeMirror-code"),r.selectionDiv=lo("div",null,null,"position: relative; z-index: 1"),r.cursorDiv=lo("div",null,"CodeMirror-cursors"),r.measure=lo("div",null,"CodeMirror-measure"),r.lineMeasure=lo("div",null,"CodeMirror-measure"),r.lineSpace=lo("div",[r.measure,r.lineMeasure,r.selectionDiv,r.cursorDiv,r.lineDiv],null,"position: relative; outline: none"),r.mover=lo("div",[lo("div",[r.lineSpace],"CodeMirror-lines")],null,"position: relative"),r.sizer=lo("div",[r.mover],"CodeMirror-sizer"),r.heightForcer=lo("div",null,null,"position: absolute; height: "+Za+"px; width: 1px;"),r.gutters=lo("div",null,"CodeMirror-gutters"),r.lineGutter=null,r.scroller=lo("div",[r.sizer,r.heightForcer,r.gutters],"CodeMirror-scroll"),r.scroller.setAttribute("tabIndex","-1"),r.wrapper=lo("div",[r.inputDiv,r.scrollbarH,r.scrollbarV,r.scrollbarFiller,r.gutterFiller,r.scroller],"CodeMirror"),Eo&&(r.gutters.style.zIndex=-1,r.scroller.style.paddingRight=0),Ko&&(n.style.width="0px"),Fo||(r.scroller.draggable=!0),Go&&(r.inputDiv.style.height="1px",r.inputDiv.style.position="absolute"),Eo&&(r.scrollbarH.style.minHeight=r.scrollbarV.style.minWidth="18px"),e.appendChild?e.appendChild(r.wrapper):e(r.wrapper),r.viewFrom=r.viewTo=t.first,r.view=[],r.externalMeasured=null,r.viewOffset=0,r.lastSizeC=0,r.updateLineNumbers=null,r.lineNumWidth=r.lineNumInnerWidth=r.lineNumChars=null,r.prevInput="",r.alignWidgets=!1,r.pollingFast=!1,r.poll=new Xi,r.cachedCharWidth=r.cachedTextHeight=r.cachedPaddingH=null,r.inaccurateSelection=!1,r.maxLine=null,r.maxLineLength=0,r.maxLineChanged=!1,r.wheelDX=r.wheelDY=r.wheelStartX=r.wheelStartY=null,r.shift=!1}function r(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),n(t)}function n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,yt(e,100),e.state.modeGen++,e.curOp&&rr(e)}function i(e){e.options.lineWrapping?(mo(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth=""):(po(e.display.wrapper,"CodeMirror-wrap"),h(e)),a(e),rr(e),It(e),setTimeout(function(){g(e)},100)}function o(e){var t=Ut(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/Kt(e.display)-3);return function(i){if(Gn(e.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;a<i.widgets.length;a++)i.widgets[a].height&&(o+=i.widgets[a].height);return r?o+(Math.ceil(i.text.length/n)||1)*t:o+t}}function a(e){var t=e.doc,r=o(e);t.iter(function(e){var t=r(e);t!=e.height&&xi(e,t)})}function l(e){var t=Ta[e.options.keyMap],r=t.style;e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-keymap-\S+/g,"")+(r?" cm-keymap-"+r:"")}function s(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),It(e)}function u(e){c(e),rr(e),setTimeout(function(){y(e)},20)}function c(e){var t=e.display.gutters,r=e.options.gutters;so(t);for(var n=0;n<r.length;++n){var i=r[n],o=t.appendChild(lo("div",null,"CodeMirror-gutter "+i));"CodeMirror-linenumbers"==i&&(e.display.lineGutter=o,o.style.width=(e.display.lineNumWidth||1)+"px")}t.style.display=n?"":"none",f(e)}function f(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(0==e.height)return 0;for(var t=e.text.length,r,n=e;r=Pn(n);){var i=r.find(0,!0);n=i.from.line,t+=i.from.ch-i.to.ch}for(n=e;r=_n(n);){var i=r.find(0,!0);t-=n.text.length-i.from.ch,n=i.to.line,t+=n.text.length-i.to.ch}return t}function h(e){var t=e.display,r=e.doc;t.maxLine=yi(r,r.first),t.maxLineLength=d(t.maxLine),t.maxLineChanged=!0,r.iter(function(e){var r=d(e);r>t.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function p(e){var t=eo(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function m(e){var t=e.display.scroller;return{clientHeight:t.clientHeight,barHeight:e.display.scrollbarV.clientHeight,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth,barWidth:e.display.scrollbarH.clientWidth,docHeight:Math.round(e.doc.height+Ct(e.display))}}function g(e,t){t||(t=m(e));var r=e.display,n=t.docHeight+Za,i=t.scrollWidth>t.clientWidth,o=n>t.clientHeight;if(o?(r.scrollbarV.style.display="block",r.scrollbarV.style.bottom=i?vo(r.measure)+"px":"0",r.scrollbarV.firstChild.style.height=Math.max(0,n-t.clientHeight+(t.barHeight||r.scrollbarV.clientHeight))+"px"):(r.scrollbarV.style.display="",r.scrollbarV.firstChild.style.height="0"),i?(r.scrollbarH.style.display="block",r.scrollbarH.style.right=o?vo(r.measure)+"px":"0",r.scrollbarH.firstChild.style.width=t.scrollWidth-t.clientWidth+(t.barWidth||r.scrollbarH.clientWidth)+"px"):(r.scrollbarH.style.display="",r.scrollbarH.firstChild.style.width="0"),i&&o?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=r.scrollbarFiller.style.width=vo(r.measure)+"px"):r.scrollbarFiller.style.display="",i&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=vo(r.measure)+"px",r.gutterFiller.style.width=r.gutters.offsetWidth+"px"):r.gutterFiller.style.display="",!e.state.checkedOverlayScrollbar&&t.clientHeight>0){if(0===vo(r.measure)){var a=Yo&&!qo?"12px":"18px";r.scrollbarV.style.minWidth=r.scrollbarH.style.minHeight=a;var l=function(t){ji(t)!=r.scrollbarV&&ji(t)!=r.scrollbarH&&Zt(e,br)(t)};Ua(r.scrollbarV,"mousedown",l),Ua(r.scrollbarH,"mousedown",l)}e.state.checkedOverlayScrollbar=!0}}function v(e,t,r){var n=r&&null!=r.top?r.top:e.scroller.scrollTop;n=Math.floor(n-kt(e));var i=r&&null!=r.bottom?r.bottom:n+e.wrapper.clientHeight,o=Ci(t,n),a=Ci(t,i);if(r&&r.ensure){var l=r.ensure.from.line,s=r.ensure.to.line;if(o>l)return{from:l,to:Ci(t,Li(yi(t,l))+e.wrapper.clientHeight)};if(Math.min(s,t.lastLine())>=a)return{from:Ci(t,Li(yi(t,s))-e.wrapper.clientHeight),to:s}}return{from:o,to:a}}function y(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=x(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",a=0;a<r.length;a++)if(!r[a].hidden){e.options.fixedGutter&&r[a].gutter&&(r[a].gutter.style.left=o);var l=r[a].alignable;if(l)for(var s=0;s<l.length;s++)l[s].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=n+i+"px")}}function b(e){if(!e.options.lineNumbers)return!1;var t=e.doc,r=w(e.options,t.first+t.size-1),n=e.display;if(r.length!=n.lineNumChars){var i=n.measure.appendChild(lo("div",[lo("div",r)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,a=i.offsetWidth-o;return n.lineGutter.style.width="",n.lineNumInnerWidth=Math.max(o,n.lineGutter.offsetWidth-a),n.lineNumWidth=n.lineNumInnerWidth+a,n.lineNumChars=n.lineNumInnerWidth?r.length:-1,n.lineGutter.style.width=n.lineNumWidth+"px",f(e),!0}return!1}function w(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function x(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function k(e,t,r){for(var n=e.display.viewFrom,i=e.display.viewTo,o,a=v(e.display,e.doc,t),l=!0;;l=!1){var s=e.display.scroller.clientWidth;if(!C(e,a,r))break;o=!0,e.display.maxLineChanged&&!e.options.lineWrapping&&L(e);var u=m(e);if(pt(e),S(e,u),g(e,u),Fo&&e.options.lineWrapping&&M(e,u),l&&e.options.lineWrapping&&s!=e.display.scroller.clientWidth)r=!0;else if(r=!1,t&&null!=t.top&&(t={top:Math.min(u.docHeight-Za-u.clientHeight,t.top)}),a=v(e.display,e.doc,t),a.from>=e.display.viewFrom&&a.to<=e.display.viewTo)break}return e.display.updateLineNumbers=null,o&&(Gi(e,"update",e),(e.display.viewFrom!=n||e.display.viewTo!=i)&&Gi(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo)),o}function C(e,t,r){var n=e.display,i=e.doc;if(!n.wrapper.offsetWidth)return void ir(e);if(!(!r&&t.from>=n.viewFrom&&t.to<=n.viewTo&&0==sr(e))){b(e)&&ir(e);var o=N(e),a=i.first+i.size,l=Math.max(t.from-e.options.viewportMargin,i.first),s=Math.min(a,t.to+e.options.viewportMargin);n.viewFrom<l&&l-n.viewFrom<20&&(l=Math.max(i.first,n.viewFrom)),n.viewTo>s&&n.viewTo-s<20&&(s=Math.min(a,n.viewTo)),ta&&(l=jn(e.doc,l),s=Vn(e.doc,s));var u=l!=n.viewFrom||s!=n.viewTo||n.lastSizeC!=n.wrapper.clientHeight;lr(e,l,s),n.viewOffset=Li(yi(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var c=sr(e);if(u||0!=c||r){var f=fo();return c>4&&(n.lineDiv.style.display="none"),H(e,n.updateLineNumbers,o),c>4&&(n.lineDiv.style.display=""),f&&fo()!=f&&f.offsetHeight&&f.focus(),so(n.cursorDiv),so(n.selectionDiv),u&&(n.lastSizeC=n.wrapper.clientHeight,yt(e,400)),T(e),!0}}}function L(e){var t=e.display,r=At(e,t.maxLine,t.maxLine.text.length).left;t.maxLineChanged=!1;var n=Math.max(0,r+3),i=Math.max(0,t.sizer.offsetLeft+n+Za-t.scroller.clientWidth);t.sizer.style.minWidth=n+"px",i<e.doc.scrollLeft&&Ar(e,Math.min(t.scroller.scrollLeft,i),!0)}function S(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-Za)+"px"}function M(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 T(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n<t.view.length;n++){var i=t.view[n],o;if(!i.hidden){if(Eo){var a=i.node.offsetTop+i.node.offsetHeight;o=a-r,r=a}else{var l=i.node.getBoundingClientRect();o=l.bottom-l.top}var s=i.line.height-o;if(2>o&&(o=Ut(t)),(s>.001||-.001>s)&&(xi(i.line,o),A(i.line),i.rest))for(var u=0;u<i.rest.length;u++)A(i.rest[u])}}}function A(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t)e.widgets[t].height=e.widgets[t].node.offsetHeight}function N(e){for(var t=e.display,r={},n={},i=t.gutters.firstChild,o=0;i;i=i.nextSibling,++o)r[e.options.gutters[o]]=i.offsetLeft,n[e.options.gutters[o]]=i.offsetWidth;return{fixedPos:x(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function H(e,t,r){function n(t){var r=t.nextSibling;return Fo&&Yo&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var i=e.display,o=e.options.lineNumbers,a=i.lineDiv,l=a.firstChild,s=i.view,u=i.viewFrom,c=0;c<s.length;c++){var f=s[c];if(f.hidden);else if(f.node){for(;l!=f.node;)l=n(l);var d=o&&null!=t&&u>=t&&f.lineNumber;f.changes&&(eo(f.changes,"gutter")>-1&&(d=!1),O(e,f,u,r)),d&&(so(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(w(e.options,u)))),l=f.node.nextSibling}else{var h=F(e,f,u,r);a.insertBefore(h,l)}u+=f.size}for(;l;)l=n(l)}function O(e,t,r,n){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?I(e,t):"gutter"==o?P(e,t,r,n):"class"==o?D(t):"widget"==o&&_(t,n)}t.changes=null}function z(e){return e.node==e.text&&(e.node=lo("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),Eo&&(e.node.style.zIndex=2)),e.node}function W(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var r=z(e);e.background=r.insertBefore(lo("div",null,t),r.firstChild)}}function E(e,t){var r=e.display.externalMeasured;return r&&r.line==t.line?(e.display.externalMeasured=null,t.measure=r.measure,r.built):oi(e,t)}function I(e,t){var r=t.text.className,n=E(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,D(t)):r&&(t.text.className=r)}function D(e){W(e),e.line.wrapClass?z(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 P(e,t,r,n){t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null);var i=t.line.gutterMarkers;if(e.options.lineNumbers||i){var o=z(t),a=t.gutter=o.insertBefore(lo("div",null,"CodeMirror-gutter-wrapper","position: absolute; left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px"),t.text);if(!e.options.lineNumbers||i&&i["CodeMirror-linenumbers"]||(t.lineNumber=a.appendChild(lo("div",w(e.options,r),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),i)for(var l=0;l<e.options.gutters.length;++l){var s=e.options.gutters[l],u=i.hasOwnProperty(s)&&i[s];u&&a.appendChild(lo("div",[u],"CodeMirror-gutter-elt","left: "+n.gutterLeft[s]+"px; width: "+n.gutterWidth[s]+"px"))}}}function _(e,t){e.alignable&&(e.alignable=null);for(var r=e.node.firstChild,n;r;r=n){var n=r.nextSibling;"CodeMirror-linewidget"==r.className&&e.node.removeChild(r)}B(e,t)}function F(e,t,r,n){var i=E(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),D(t),P(e,t,r,n),B(t,n),t.node}function B(e,t){if(R(e.line,e,t,!0),e.rest)for(var r=0;r<e.rest.length;r++)R(e.rest[r],e,t,!1)}function R(e,t,r,n){if(e.widgets)for(var i=z(t),o=0,a=e.widgets;o<a.length;++o){var l=a[o],s=lo("div",[l.node],"CodeMirror-linewidget");l.handleMouseEvents||(s.ignoreEvents=!0),j(l,s,t,r),n&&l.above?i.insertBefore(s,t.gutter||t.text):i.appendChild(s),Gi(l,"redraw")}}function j(e,t,r,n){if(e.noHScroll){(r.alignable||(r.alignable=[])).push(t);var i=n.wrapperWidth;t.style.left=n.fixedPos+"px",e.coverGutter||(i-=n.gutterTotalWidth,t.style.paddingLeft=n.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-n.gutterTotalWidth+"px"))}function V(e){return ra(e.line,e.ch)}function G(e,t){return na(e,t)<0?t:e}function q(e,t){return na(e,t)<0?e:t}function U(e,t){this.ranges=e,this.primIndex=t}function K(e,t){this.anchor=e,this.head=t}function $(e,t){var r=e[t];e.sort(function(e,t){return na(e.from(),t.from())}),t=eo(e,r);for(var n=1;n<e.length;n++){var i=e[n],o=e[n-1];if(na(o.to(),i.from())>=0){var a=q(o.from(),i.from()),l=G(o.to(),i.to()),s=o.empty()?i.from()==i.head:o.from()==o.head;t>=n&&--t,e.splice(--n,2,new K(s?l:a,s?a:l))}}return new U(e,t)}function Y(e,t){return new U([new K(e,t||e)],0)}function X(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function Z(e,t){if(t.line<e.first)return ra(e.first,0);var r=e.first+e.size-1;return t.line>r?ra(r,yi(e,r).text.length):Q(t,yi(e,t.line).text.length)}function Q(e,t){var r=e.ch;return null==r||r>t?ra(e.line,t):0>r?ra(e.line,0):e}function J(e,t){return t>=e.first&&t<e.first+e.size}function et(e,t){for(var r=[],n=0;n<t.length;n++)r[n]=Z(e,t[n]);return r}function tt(e,t,r,n){if(e.cm&&e.cm.display.shift||e.extend){var i=t.anchor;if(n){var o=na(r,i)<0;o!=na(n,i)<0?(i=r,r=n):o!=na(r,n)<0&&(r=n)}return new K(i,r)}return new K(n||r,r)}function rt(e,t,r,n){st(e,new U([tt(e,e.sel.primary(),t,r)],0),n)}function nt(e,t,r){for(var n=[],i=0;i<e.sel.ranges.length;i++)n[i]=tt(e,e.sel.ranges[i],t[i],null);var o=$(n,e.sel.primIndex);st(e,o,r)}function it(e,t,r,n){var i=e.sel.ranges.slice(0);i[t]=r,st(e,$(i,e.sel.primIndex),n)}function ot(e,t,r,n){st(e,Y(t,r),n)}function at(e,t){var r={ranges:t.ranges,update:function(t){this.ranges=[];for(var r=0;r<t.length;r++)this.ranges[r]=new K(Z(e,t[r].anchor),Z(e,t[r].head))}};return $a(e,"beforeSelectionChange",e,r),e.cm&&$a(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges?$(r.ranges,r.ranges.length-1):t}function lt(e,t,r){var n=e.history.done,i=Ji(n);i&&i.ranges?(n[n.length-1]=t,ut(e,t,r)):st(e,t,r)}function st(e,t,r){ut(e,t,r),zi(e,e.sel,e.cm?e.cm.curOp.id:0/0,r)}function ut(e,t,r){($i(e,"beforeSelectionChange")||e.cm&&$i(e.cm,"beforeSelectionChange"))&&(t=at(e,t));var n=na(t.primary().head,e.sel.primary().head)<0?-1:1;ct(e,dt(e,t,n,!0)),r&&r.scroll===!1||!e.cm||an(e.cm)}function ct(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,Ki(e.cm)),Gi(e,"cursorActivity",e))}function ft(e){ct(e,dt(e,e.sel,null,!1),Ja)}function dt(e,t,r,n){for(var i,o=0;o<t.ranges.length;o++){var a=t.ranges[o],l=ht(e,a.anchor,r,n),s=ht(e,a.head,r,n);(i||l!=a.anchor||s!=a.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new K(l,s))}return i?$(i,t.primIndex):t}function ht(e,t,r,n){var i=!1,o=t,a=r||1;e.cantEdit=!1;e:for(;;){var l=yi(e,o.line);if(l.markedSpans)for(var s=0;s<l.markedSpans.length;++s){var u=l.markedSpans[s],c=u.marker;if((null==u.from||(c.inclusiveLeft?u.from<=o.ch:u.from<o.ch))&&(null==u.to||(c.inclusiveRight?u.to>=o.ch:u.to>o.ch))){if(n&&($a(c,"beforeCursorEnter"),c.explicitlyCleared)){if(l.markedSpans){--s;continue}break}if(!c.atomic)continue;var f=c.find(0>a?-1:1);if(0==na(f,o)&&(f.ch+=a,f.ch<0?f=f.line>e.first?Z(e,ra(f.line-1)):null:f.ch>l.text.length&&(f=f.line<e.first+e.size-1?ra(f.line+1,0):null),!f)){if(i)return n?(e.cantEdit=!0,ra(e.first,0)):ht(e,t,r,!0);i=!0,f=t,a=-a}o=f;continue e}}return o}}function pt(e){for(var t=e.display,r=e.doc,n=document.createDocumentFragment(),i=document.createDocumentFragment(),o=0;o<r.sel.ranges.length;o++){var a=r.sel.ranges[o],l=a.empty();(l||e.options.showCursorWhenSelecting)&&mt(e,a,n),l||gt(e,a,i)}if(e.options.moveInputWithCursor){var s=Rt(e,r.sel.primary().head,"div"),u=t.wrapper.getBoundingClientRect(),c=t.lineDiv.getBoundingClientRect(),f=Math.max(0,Math.min(t.wrapper.clientHeight-10,s.top+c.top-u.top)),d=Math.max(0,Math.min(t.wrapper.clientWidth-10,s.left+c.left-u.left));t.inputDiv.style.top=f+"px",t.inputDiv.style.left=d+"px"}uo(t.cursorDiv,n),uo(t.selectionDiv,i)}function mt(e,t,r){var n=Rt(e,t.head,"div"),i=r.appendChild(lo("div"," ","CodeMirror-cursor"));if(i.style.left=n.left+"px",i.style.top=n.top+"px",i.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px",n.other){var o=r.appendChild(lo("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=n.other.left+"px",o.style.top=n.other.top+"px",o.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function gt(e,t,r){function n(e,t,r,n){0>t&&(t=0),t=Math.round(t),n=Math.round(n),l.appendChild(lo("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==r?c-e:r)+"px; height: "+(n-t)+"px"))}function i(t,r,i){function o(r,n){return Bt(e,ra(t,r),"div",l,n)}var l=yi(a,t),s=l.text.length,f,d;return wo(Si(l),r||0,null==i?s:i,function(e,t,a){var l=o(e,"left"),h,p,m;if(e==t)h=l,p=m=l.left;else{if(h=o(t-1,"right"),"rtl"==a){var g=l;l=h,h=g}p=l.left,m=h.right}null==r&&0==e&&(p=u),h.top-l.top>3&&(n(p,l.top,null,l.bottom),p=u,l.bottom<h.top&&n(p,l.bottom,null,h.top)),null==i&&t==s&&(m=c),(!f||l.top<f.top||l.top==f.top&&l.left<f.left)&&(f=l),(!d||h.bottom>d.bottom||h.bottom==d.bottom&&h.right>d.right)&&(d=h),u+1>p&&(p=u),n(p,h.top,m-p,h.bottom)}),{start:f,end:d}}var o=e.display,a=e.doc,l=document.createDocumentFragment(),s=Lt(e.display),u=s.left,c=o.lineSpace.offsetWidth-s.right,f=t.from(),d=t.to();if(f.line==d.line)i(f.line,f.ch,d.ch);else{var h=yi(a,f.line),p=yi(a,d.line),m=Bn(h)==Bn(p),g=i(f.line,f.ch,m?h.text.length+1:null).end,v=i(d.line,m?0:null,d.ch).start;m&&(g.top<v.top-2?(n(g.right,g.top,null,g.bottom),n(u,v.top,v.left,v.bottom)):n(g.right,g.top,v.left-g.right,g.bottom)),g.bottom<v.top&&n(u,g.bottom,null,v.top)}r.appendChild(l)}function vt(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var r=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0&&(t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate))}}function yt(e,t){e.doc.mode.startState&&e.doc.frontier<e.display.viewTo&&e.state.highlight.set(t,io(bt,e))}function bt(e){var t=e.doc;if(t.frontier<t.first&&(t.frontier=t.first),!(t.frontier>=e.display.viewTo)){var r=+new Date+e.options.workTime,n=La(t.mode,xt(e,t.frontier));Xt(e,function(){t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(i){if(t.frontier>=e.display.viewFrom){var o=i.styles,a=ti(e,i,n,!0);i.styles=a.styles,a.classes?i.styleClasses=a.classes:i.styleClasses&&(i.styleClasses=null);for(var l=!o||o.length!=i.styles.length,s=0;!l&&s<o.length;++s)l=o[s]!=i.styles[s];l&&nr(e,t.frontier,"text"),i.stateAfter=La(t.mode,n)}else ni(e,i.text,n),i.stateAfter=t.frontier%5==0?La(t.mode,n):null;return++t.frontier,+new Date>r?(yt(e,e.options.workDelay),!0):void 0})})}}function wt(e,t,r){for(var n,i,o=e.doc,a=r?-1:t-(e.doc.mode.innerMode?1e3:100),l=t;l>a;--l){if(l<=o.first)return o.first;var s=yi(o,l-1);if(s.stateAfter&&(!r||l<=o.frontier))return l;var u=rl(s.text,null,e.options.tabSize);(null==i||n>u)&&(i=l-1,n=u)}return i}function xt(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return!0;var o=wt(e,t,r),a=o>n.first&&yi(n,o-1).stateAfter;return a=a?La(n.mode,a):Sa(n.mode),n.iter(o,t,function(r){ni(e,r.text,a);var l=o==t-1||o%5==0||o>=i.viewFrom&&o<i.viewTo;r.stateAfter=l?La(n.mode,a):null,++o}),r&&(n.frontier=o),a}function kt(e){return e.lineSpace.offsetTop}function Ct(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Lt(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=uo(e.measure,lo("pre","x")),r=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,n={left:parseInt(r.paddingLeft),right:parseInt(r.paddingRight)};return isNaN(n.left)||isNaN(n.right)||(e.cachedPaddingH=n),n}function St(e,t,r){var n=e.options.lineWrapping,i=n&&e.display.scroller.clientWidth;if(!t.measure.heights||n&&t.measure.width!=i){var o=t.measure.heights=[];if(n){t.measure.width=i;for(var a=t.text.firstChild.getClientRects(),l=0;l<a.length-1;l++){var s=a[l],u=a[l+1];Math.abs(s.bottom-u.bottom)>2&&o.push((s.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}function Mt(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var n=0;n<e.rest.length;n++)if(e.rest[n]==t)return{map:e.measure.maps[n],cache:e.measure.caches[n]};for(var n=0;n<e.rest.length;n++)if(ki(e.rest[n])>r)return{map:e.measure.maps[n],cache:e.measure.caches[n],before:!0}}function Tt(e,t){t=Bn(t);var r=ki(t),n=e.display.externalMeasured=new er(e.doc,t,r);n.lineN=r;var i=n.built=oi(e,n);return n.text=i.pre,uo(e.display.lineMeasure,i.pre),n}function At(e,t,r,n){return Ot(e,Ht(e,t),r,n)}function Nt(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[or(e,t)];var r=e.display.externalMeasured;return r&&t>=r.lineN&&t<r.lineN+r.size?r:void 0}function Ht(e,t){var r=ki(t),n=Nt(e,r);n&&!n.text?n=null:n&&n.changes&&O(e,n,r,N(e)),n||(n=Tt(e,t));var i=Mt(n,t,r);return{line:t,view:n,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function Ot(e,t,r,n){t.before&&(r=-1);var i=r+(n||""),o;return t.cache.hasOwnProperty(i)?o=t.cache[i]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(St(e,t.view,t.rect),t.hasHeights=!0),o=zt(e,t,r,n),o.bogus||(t.cache[i]=o)),{left:o.left,right:o.right,top:o.top,bottom:o.bottom}}function zt(e,t,r,n){for(var i=t.map,o,a,l,s,u=0;u<i.length;u+=3){var c=i[u],f=i[u+1];if(c>r?(a=0,l=1,s="left"):f>r?(a=r-c,l=a+1):(u==i.length-3||r==f&&i[u+3]>r)&&(l=f-c,a=l-1,r>=f&&(s="right")),null!=a){if(o=i[u+2],c==f&&n==(o.insertLeft?"left":"right")&&(s=n),"left"==n&&0==a)for(;u&&i[u-2]==i[u-3]&&i[u-1].insertLeft;)o=i[(u-=3)+2],s="left";if("right"==n&&a==f-c)for(;u<i.length-3&&i[u+3]==i[u+4]&&!i[u+5].insertLeft;)o=i[(u+=3)+2],s="right";break}}var d;if(3==o.nodeType){for(;a&&ao(t.line.text.charAt(c+a));)--a;for(;f>c+l&&ao(t.line.text.charAt(c+l));)++l;if(Io&&0==a&&l==f-c)d=o.parentNode.getBoundingClientRect();else if(_o&&e.options.lineWrapping){var h=sl(o,a,l).getClientRects();d=h.length?h["right"==n?h.length-1:0]:ia}else d=sl(o,a,l).getBoundingClientRect()}else{a>0&&(s=n="right");var h;d=e.options.lineWrapping&&(h=o.getClientRects()).length>1?h["right"==n?h.length-1:0]:o.getBoundingClientRect()}if(Io&&!a&&(!d||!d.left&&!d.right)){var p=o.parentNode.getClientRects()[0];d=p?{left:p.left,right:p.left+Kt(e.display),top:p.top,bottom:p.bottom}:ia}for(var m,g=(d.bottom+d.top)/2-t.rect.top,v=t.view.measure.heights,u=0;u<v.length-1&&!(g<v[u]);u++);m=u?v[u-1]:0,g=v[u];var y={left:("right"==s?d.right:d.left)-t.rect.left,right:("left"==s?d.left:d.right)-t.rect.left,top:m,bottom:g};return d.left||d.right||(y.bogus=!0),y}function Wt(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function Et(e){e.display.externalMeasure=null,so(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)Wt(e.display.view[t])}function It(e){Et(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function Dt(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function Pt(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function _t(e,t,r,n){if(t.widgets)for(var i=0;i<t.widgets.length;++i)if(t.widgets[i].above){var o=Kn(t.widgets[i]);
2
  r.top+=o,r.bottom+=o}if("line"==n)return r;n||(n="local");var a=Li(t);if("local"==n?a+=kt(e.display):a-=e.display.viewOffset,"page"==n||"window"==n){var l=e.display.lineSpace.getBoundingClientRect();a+=l.top+("window"==n?0:Pt());var s=l.left+("window"==n?0:Dt());r.left+=s,r.right+=s}return r.top+=a,r.bottom+=a,r}function Ft(e,t,r){if("div"==r)return t;var n=t.left,i=t.top;if("page"==r)n-=Dt(),i-=Pt();else if("local"==r||!r){var o=e.display.sizer.getBoundingClientRect();n+=o.left,i+=o.top}var a=e.display.lineSpace.getBoundingClientRect();return{left:n-a.left,top:i-a.top}}function Bt(e,t,r,n,i){return n||(n=yi(e.doc,t.line)),_t(e,n,At(e,n,t.ch,i),r)}function Rt(e,t,r,n,i){function o(t,o){var a=Ot(e,i,t,o?"right":"left");return o?a.left=a.right:a.right=a.left,_t(e,n,a,r)}function a(e,t){var r=l[t],n=r.level%2;return e==xo(r)&&t&&r.level<l[t-1].level?(r=l[--t],e=ko(r)-(r.level%2?0:1),n=!0):e==ko(r)&&t<l.length-1&&r.level<l[t+1].level&&(r=l[++t],e=xo(r)-r.level%2,n=!1),n&&e==r.to&&e>r.from?o(e-1):o(e,n)}n=n||yi(e.doc,t.line),i||(i=Ht(e,n));var l=Si(n),s=t.ch;if(!l)return o(s);var u=Ao(l,s),c=a(s,u);return null!=vl&&(c.other=a(s,vl)),c}function jt(e,t){var r=0,t=Z(e.doc,t);e.options.lineWrapping||(r=Kt(e.display)*t.ch);var n=yi(e.doc,t.line),i=Li(n)+kt(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function Vt(e,t,r,n){var i=ra(e,t);return i.xRel=n,r&&(i.outside=!0),i}function Gt(e,t,r){var n=e.doc;if(r+=e.display.viewOffset,0>r)return Vt(n.first,0,!0,-1);var i=Ci(n,r),o=n.first+n.size-1;if(i>o)return Vt(n.first+n.size-1,yi(n,o).text.length,!0,1);0>t&&(t=0);for(var a=yi(n,i);;){var l=qt(e,a,i,t,r),s=_n(a),u=s&&s.find(0,!0);if(!s||!(l.ch>u.from.ch||l.ch==u.from.ch&&l.xRel>0))return l;i=ki(a=u.to.line)}}function qt(e,t,r,n,i){function o(n){var i=Rt(e,ra(r,n),"line",t,u);return l=!0,a>i.bottom?i.left-s:a<i.top?i.left+s:(l=!1,i.left)}var a=i-Li(t),l=!1,s=2*e.display.wrapper.clientWidth,u=Ht(e,t),c=Si(t),f=t.text.length,d=Co(t),h=Lo(t),p=o(d),m=l,g=o(h),v=l;if(n>g)return Vt(r,h,v,1);for(;;){if(c?h==d||h==Ho(t,d,1):1>=h-d){for(var y=p>n||g-n>=n-p?d:h,b=n-(y==d?p:g);ao(t.text.charAt(y));)++y;var w=Vt(r,y,y==d?m:v,-1>b?-1:b>1?1:0);return w}var x=Math.ceil(f/2),k=d+x;if(c){k=d;for(var C=0;x>C;++C)k=Ho(t,k,1)}var L=o(k);L>n?(h=k,g=L,(v=l)&&(g+=1e3),f=x):(d=k,p=L,m=l,f-=x)}}function Ut(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==oa){oa=lo("pre");for(var t=0;49>t;++t)oa.appendChild(document.createTextNode("x")),oa.appendChild(lo("br"));oa.appendChild(document.createTextNode("x"))}uo(e.measure,oa);var r=oa.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),so(e.measure),r||1}function Kt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=lo("span","xxxxxxxxxx"),r=lo("pre",[t]);uo(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function $t(e){e.curOp={viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++aa},Xa++||(Ya=[])}function Yt(e){var t=e.curOp,r=e.doc,n=e.display;if(e.curOp=null,t.updateMaxLine&&h(e),t.viewChanged||t.forceUpdate||null!=t.scrollTop||t.scrollToPos&&(t.scrollToPos.from.line<n.viewFrom||t.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&e.options.lineWrapping){var i=k(e,{top:t.scrollTop,ensure:t.scrollToPos},t.forceUpdate);e.display.scroller.offsetHeight&&(e.doc.scrollTop=e.display.scroller.scrollTop)}if(!i&&t.selectionChanged&&pt(e),i||t.startHeight==e.doc.height||g(e),null!=t.scrollTop&&n.scroller.scrollTop!=t.scrollTop){var o=Math.max(0,Math.min(n.scroller.scrollHeight-n.scroller.clientHeight,t.scrollTop));n.scroller.scrollTop=n.scrollbarV.scrollTop=r.scrollTop=o}if(null!=t.scrollLeft&&n.scroller.scrollLeft!=t.scrollLeft){var a=Math.max(0,Math.min(n.scroller.scrollWidth-n.scroller.clientWidth,t.scrollLeft));n.scroller.scrollLeft=n.scrollbarH.scrollLeft=r.scrollLeft=a,y(e)}if(t.scrollToPos){var l=tn(e,Z(e.doc,t.scrollToPos.from),Z(e.doc,t.scrollToPos.to),t.scrollToPos.margin);t.scrollToPos.isCursor&&e.state.focused&&en(e,l)}t.selectionChanged&&vt(e),e.state.focused&&t.updateInput&&dr(e,t.typing);var s=t.maybeHiddenMarkers,u=t.maybeUnhiddenMarkers;if(s)for(var c=0;c<s.length;++c)s[c].lines.length||$a(s[c],"hide");if(u)for(var c=0;c<u.length;++c)u[c].lines.length&&$a(u[c],"unhide");var f;if(--Xa||(f=Ya,Ya=null),t.changeObjs&&$a(e,"changes",e,t.changeObjs),f)for(var c=0;c<f.length;++c)f[c]();if(t.cursorActivityHandlers)for(var c=0;c<t.cursorActivityHandlers.length;c++)t.cursorActivityHandlers[c](e)}function Xt(e,t){if(e.curOp)return t();$t(e);try{return t()}finally{Yt(e)}}function Zt(e,t){return function(){if(e.curOp)return t.apply(e,arguments);$t(e);try{return t.apply(e,arguments)}finally{Yt(e)}}}function Qt(e){return function(){if(this.curOp)return e.apply(this,arguments);$t(this);try{return e.apply(this,arguments)}finally{Yt(this)}}}function Jt(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);$t(t);try{return e.apply(this,arguments)}finally{Yt(t)}}}function er(e,t,r){this.line=t,this.rest=Rn(t),this.size=this.rest?ki(Ji(this.rest))-r+1:1,this.node=this.text=null,this.hidden=Gn(e,t)}function tr(e,t,r){for(var n=[],i,o=t;r>o;o=i){var a=new er(e.doc,yi(e.doc,o),o);i=o+a.size,n.push(a)}return n}function rr(e,t,r,n){null==t&&(t=e.doc.first),null==r&&(r=e.doc.first+e.doc.size),n||(n=0);var i=e.display;if(n&&r<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)ta&&jn(e.doc,t)<i.viewTo&&ir(e);else if(r<=i.viewFrom)ta&&Vn(e.doc,r+n)>i.viewFrom?ir(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)ir(e);else if(t<=i.viewFrom){var o=ar(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):ir(e)}else if(r>=i.viewTo){var o=ar(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):ir(e)}else{var a=ar(e,t,t,-1),l=ar(e,r,r+n,1);a&&l?(i.view=i.view.slice(0,a.index).concat(tr(e,a.lineN,l.lineN)).concat(i.view.slice(l.index)),i.viewTo+=n):ir(e)}var s=i.externalMeasured;s&&(r<s.lineN?s.lineN+=n:t<s.lineN+s.size&&(i.externalMeasured=null))}function nr(e,t,r){e.curOp.viewChanged=!0;var n=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(n.externalMeasured=null),!(t<n.viewFrom||t>=n.viewTo)){var o=n.view[or(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==eo(a,r)&&a.push(r)}}}function ir(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function or(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var r=e.display.view,n=0;n<r.length;n++)if(t-=r[n].size,0>t)return n}function ar(e,t,r,n){var i=or(e,t),o,a=e.display.view;if(!ta)return{index:i,lineN:r};for(var l=0,s=e.display.viewFrom;i>l;l++)s+=a[l].size;if(s!=t){if(n>0){if(i==a.length-1)return null;o=s+a[i].size-t,i++}else o=s-t;t+=o,r+=o}for(;jn(e.doc,r)!=r;){if(i==(0>n?0:a.length-1))return null;r+=n*a[i-(0>n?1:0)].size,i+=n}return{index:i,lineN:r}}function lr(e,t,r){var n=e.display,i=n.view;0==i.length||t>=n.viewTo||r<=n.viewFrom?(n.view=tr(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=tr(e,t,n.viewFrom).concat(n.view):n.viewFrom<t&&(n.view=n.view.slice(or(e,t))),n.viewFrom=t,n.viewTo<r?n.view=n.view.concat(tr(e,n.viewTo,r)):n.viewTo>r&&(n.view=n.view.slice(0,or(e,r)))),n.viewTo=r}function sr(e){for(var t=e.display.view,r=0,n=0;n<t.length;n++){var i=t[n];i.hidden||i.node&&!i.changes||++r}return r}function ur(e){e.display.pollingFast||e.display.poll.set(e.options.pollInterval,function(){fr(e),e.state.focused&&ur(e)})}function cr(e){function t(){var n=fr(e);n||r?(e.display.pollingFast=!1,ur(e)):(r=!0,e.display.poll.set(60,t))}var r=!1;e.display.pollingFast=!0,e.display.poll.set(20,t)}function fr(e){var t=e.display.input,r=e.display.prevInput,n=e.doc;if(!e.state.focused||pl(t)&&!r||mr(e)||e.options.disableInput)return!1;e.state.pasteIncoming&&e.state.fakedLastChar&&(t.value=t.value.substring(0,t.value.length-1),e.state.fakedLastChar=!1);var i=t.value;if(i==r&&!e.somethingSelected())return!1;if(_o&&!Io&&e.display.inputHasSelection===i)return dr(e),!1;var o=!e.curOp;o&&$t(e),e.display.shift=!1;for(var a=0,l=Math.min(r.length,i.length);l>a&&r.charCodeAt(a)==i.charCodeAt(a);)++a;for(var s=i.slice(a),u=hl(s),c=e.state.pasteIncoming&&u.length>1&&n.sel.ranges.length==u.length,f=n.sel.ranges.length-1;f>=0;f--){var d=n.sel.ranges[f],h=d.from(),p=d.to();a<r.length?h=ra(h.line,h.ch-(r.length-a)):e.state.overwrite&&d.empty()&&!e.state.pasteIncoming&&(p=ra(p.line,Math.min(yi(n,p.line).text.length,p.ch+Ji(u).length)));var m=e.curOp.updateInput,g={from:h,to:p,text:c?[u[f]]:u,origin:e.state.pasteIncoming?"paste":e.state.cutIncoming?"cut":"+input"};if(Kr(e.doc,g),Gi(e,"inputRead",e,g),s&&!e.state.pasteIncoming&&e.options.electricChars&&e.options.smartIndent&&d.head.ch<100&&(!f||n.sel.ranges[f-1].head.line!=d.head.line)){var v=e.getModeAt(d.head);if(v.electricChars){for(var y=0;y<v.electricChars.length;y++)if(s.indexOf(v.electricChars.charAt(y))>-1){sn(e,d.head.line,"smart");break}}else if(v.electricInput){var b=ma(g);v.electricInput.test(yi(n,b.line).text.slice(0,b.ch))&&sn(e,d.head.line,"smart")}}}return an(e),e.curOp.updateInput=m,e.curOp.typing=!0,i.length>1e3||i.indexOf("\n")>-1?t.value=e.display.prevInput="":e.display.prevInput=i,o&&Yt(e),e.state.pasteIncoming=e.state.cutIncoming=!1,!0}function dr(e,t){var r,n,i=e.doc;if(e.somethingSelected()){e.display.prevInput="";var o=i.sel.primary();r=ml&&(o.to().line-o.from().line>100||(n=e.getSelection()).length>1e3);var a=r?"-":n||e.getSelection();e.display.input.value=a,e.state.focused&&il(e.display.input),_o&&!Io&&(e.display.inputHasSelection=a)}else t||(e.display.prevInput=e.display.input.value="",_o&&!Io&&(e.display.inputHasSelection=null));e.display.inaccurateSelection=r}function hr(e){"nocursor"==e.options.readOnly||$o&&fo()==e.display.input||e.display.input.focus()}function pr(e){e.state.focused||(hr(e),_r(e))}function mr(e){return e.options.readOnly||e.doc.cantEdit}function gr(e){function t(){e.state.focused&&setTimeout(io(hr,e),0)}function r(){null==l&&(l=setTimeout(function(){l=null,a.cachedCharWidth=a.cachedTextHeight=a.cachedPaddingH=cl=null,e.setSize()},100))}function n(){co(document.body,a.wrapper)?setTimeout(n,5e3):Ka(window,"resize",r)}function i(t){Ui(e,t)||qa(t)}function o(t){if(e.somethingSelected())a.inaccurateSelection&&(a.prevInput="",a.inaccurateSelection=!1,a.input.value=e.getSelection(),il(a.input));else{for(var r="",n=[],i=0;i<e.doc.sel.ranges.length;i++){var o=e.doc.sel.ranges[i].head.line,l={anchor:ra(o,0),head:ra(o+1,0)};n.push(l),r+=e.getRange(l.anchor,l.head)}"cut"==t.type?e.setSelections(n,null,Ja):(a.prevInput="",a.input.value=r,il(a.input))}"cut"==t.type&&(e.state.cutIncoming=!0)}var a=e.display;Ua(a.scroller,"mousedown",Zt(e,br)),Wo?Ua(a.scroller,"dblclick",Zt(e,function(t){if(!Ui(e,t)){var r=yr(e,t);if(r&&!Lr(e,t)&&!vr(e.display,t)){Va(t);var n=hn(e.doc,r);rt(e.doc,n.anchor,n.head)}}})):Ua(a.scroller,"dblclick",function(t){Ui(e,t)||Va(t)}),Ua(a.lineSpace,"selectstart",function(e){vr(a,e)||Va(e)}),Jo||Ua(a.scroller,"contextmenu",function(t){Br(e,t)}),Ua(a.scroller,"scroll",function(){a.scroller.clientHeight&&(Tr(e,a.scroller.scrollTop),Ar(e,a.scroller.scrollLeft,!0),$a(e,"scroll",e))}),Ua(a.scrollbarV,"scroll",function(){a.scroller.clientHeight&&Tr(e,a.scrollbarV.scrollTop)}),Ua(a.scrollbarH,"scroll",function(){a.scroller.clientHeight&&Ar(e,a.scrollbarH.scrollLeft)}),Ua(a.scroller,"mousewheel",function(t){Nr(e,t)}),Ua(a.scroller,"DOMMouseScroll",function(t){Nr(e,t)}),Ua(a.scrollbarH,"mousedown",t),Ua(a.scrollbarV,"mousedown",t),Ua(a.wrapper,"scroll",function(){a.wrapper.scrollTop=a.wrapper.scrollLeft=0});var l;Ua(window,"resize",r),setTimeout(n,5e3),Ua(a.input,"keyup",Zt(e,Dr)),Ua(a.input,"input",function(){_o&&!Io&&e.display.inputHasSelection&&(e.display.inputHasSelection=null),cr(e)}),Ua(a.input,"keydown",Zt(e,Er)),Ua(a.input,"keypress",Zt(e,Pr)),Ua(a.input,"focus",io(_r,e)),Ua(a.input,"blur",io(Fr,e)),e.options.dragDrop&&(Ua(a.scroller,"dragstart",function(t){Mr(e,t)}),Ua(a.scroller,"dragenter",i),Ua(a.scroller,"dragover",i),Ua(a.scroller,"drop",Zt(e,Sr))),Ua(a.scroller,"paste",function(t){vr(a,t)||(e.state.pasteIncoming=!0,hr(e),cr(e))}),Ua(a.input,"paste",function(){if(Fo&&!e.state.fakedLastChar&&!(new Date-e.state.lastMiddleDown<200)){var t=a.input.selectionStart,r=a.input.selectionEnd;a.input.value+="$",a.input.selectionStart=t,a.input.selectionEnd=r,e.state.fakedLastChar=!0}e.state.pasteIncoming=!0,cr(e)}),Ua(a.input,"cut",o),Ua(a.input,"copy",o),Go&&Ua(a.sizer,"mouseup",function(){fo()==a.input&&a.input.blur(),hr(e)})}function vr(e,t){for(var r=ji(t);r!=e.wrapper;r=r.parentNode)if(!r||r.ignoreEvents||r.parentNode==e.sizer&&r!=e.mover)return!0}function yr(e,t,r,n){var i=e.display;if(!r){var o=ji(t);if(o==i.scrollbarH||o==i.scrollbarV||o==i.scrollbarFiller||o==i.gutterFiller)return null}var a,l,s=i.lineSpace.getBoundingClientRect();try{a=t.clientX-s.left,l=t.clientY-s.top}catch(t){return null}var u=Gt(e,a,l),c;if(n&&1==u.xRel&&(c=yi(e.doc,u.line).text).length==u.ch){var f=rl(c,c.length,e.options.tabSize)-c.length;u=ra(u.line,Math.max(0,Math.round((a-Lt(e.display).left)/Kt(e.display))-f))}return u}function br(e){if(!Ui(this,e)){var t=this,r=t.display;if(r.shift=e.shiftKey,vr(r,e))return void(Fo||(r.scroller.draggable=!1,setTimeout(function(){r.scroller.draggable=!0},100)));if(!Lr(t,e)){var n=yr(t,e);switch(window.focus(),Vi(e)){case 1:n?wr(t,e,n):ji(e)==r.scroller&&Va(e);break;case 2:Fo&&(t.state.lastMiddleDown=+new Date),n&&rt(t.doc,n),setTimeout(io(hr,t),20),Va(e);break;case 3:Jo&&Br(t,e)}}}}function wr(e,t,r){setTimeout(io(pr,e),0);var n=+new Date,i;sa&&sa.time>n-400&&0==na(sa.pos,r)?i="triple":la&&la.time>n-400&&0==na(la.pos,r)?(i="double",sa={time:n,pos:r}):(i="single",la={time:n,pos:r});var o=e.doc.sel,a=Yo?t.metaKey:t.ctrlKey;e.options.dragDrop&&ul&&!a&&!mr(e)&&"single"==i&&o.contains(r)>-1&&o.somethingSelected()?xr(e,t,r):kr(e,t,r,i,a)}function xr(e,t,r){var n=e.display,i=Zt(e,function(o){Fo&&(n.scroller.draggable=!1),e.state.draggingText=!1,Ka(document,"mouseup",i),Ka(n.scroller,"drop",i),Math.abs(t.clientX-o.clientX)+Math.abs(t.clientY-o.clientY)<10&&(Va(o),rt(e.doc,r),hr(e),Wo&&!Io&&setTimeout(function(){document.body.focus(),hr(e)},20))});Fo&&(n.scroller.draggable=!0),e.state.draggingText=i,n.scroller.dragDrop&&n.scroller.dragDrop(),Ua(document,"mouseup",i),Ua(n.scroller,"drop",i)}function kr(e,t,r,n,i){function o(t){if(0!=na(m,t))if(m=t,"rect"==n){for(var i=[],o=e.options.tabSize,a=rl(yi(u,r.line).text,r.ch,o),l=rl(yi(u,t.line).text,t.ch,o),s=Math.min(a,l),h=Math.max(a,l),p=Math.min(r.line,t.line),g=Math.min(e.lastLine(),Math.max(r.line,t.line));g>=p;p++){var v=yi(u,p).text,y=Zi(v,s,o);s==h?i.push(new K(ra(p,y),ra(p,y))):v.length>y&&i.push(new K(ra(p,y),ra(p,Zi(v,h,o))))}i.length||i.push(new K(r,r)),st(u,$(d.ranges.slice(0,f).concat(i),f),el)}else{var b=c,w=b.anchor,x=t;if("single"!=n){if("double"==n)var k=hn(u,t);else var k=new K(ra(t.line,0),Z(u,ra(t.line+1,0)));na(k.anchor,w)>0?(x=k.head,w=q(b.from(),k.anchor)):(x=k.anchor,w=G(b.to(),k.head))}var i=d.ranges.slice(0);i[f]=new K(Z(u,w),x),st(u,$(i,f),el)}}function a(t){var r=++y,i=yr(e,t,!0,"rect"==n);if(i)if(0!=na(i,m)){pr(e),o(i);var l=v(s,u);(i.line>=l.to||i.line<l.from)&&setTimeout(Zt(e,function(){y==r&&a(t)}),150)}else{var c=t.clientY<g.top?-20:t.clientY>g.bottom?20:0;c&&setTimeout(Zt(e,function(){y==r&&(s.scroller.scrollTop+=c,a(t))}),50)}}function l(t){y=1/0,Va(t),hr(e),Ka(document,"mousemove",b),Ka(document,"mouseup",w),u.history.lastSelOrigin=null}var s=e.display,u=e.doc;Va(t);var c,f,d=u.sel;if(i&&!t.shiftKey?(f=u.sel.contains(r),c=f>-1?u.sel.ranges[f]:new K(r,r)):c=u.sel.primary(),t.altKey)n="rect",i||(c=new K(r,r)),r=yr(e,t,!0,!0),f=-1;else if("double"==n){var h=hn(u,r);c=e.display.shift||u.extend?tt(u,c,h.anchor,h.head):h}else if("triple"==n){var p=new K(ra(r.line,0),Z(u,ra(r.line+1,0)));c=e.display.shift||u.extend?tt(u,c,p.anchor,p.head):p}else c=tt(u,c,r);i?f>-1?it(u,f,c,el):(f=u.sel.ranges.length,st(u,$(u.sel.ranges.concat([c]),f),{scroll:!1,origin:"*mouse"})):(f=0,st(u,new U([c],0),el),d=u.sel);var m=r,g=s.wrapper.getBoundingClientRect(),y=0,b=Zt(e,function(e){(_o&&!Do?e.buttons:Vi(e))?a(e):l(e)}),w=Zt(e,l);Ua(document,"mousemove",b),Ua(document,"mouseup",w)}function Cr(e,t,r,n,i){try{var o=t.clientX,a=t.clientY}catch(t){return!1}if(o>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&Va(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(a>s.bottom||!$i(e,r))return Ri(t);a-=s.top-l.viewOffset;for(var u=0;u<e.options.gutters.length;++u){var c=l.gutters.childNodes[u];if(c&&c.getBoundingClientRect().right>=o){var f=Ci(e.doc,a),d=e.options.gutters[u];return i(e,r,e,f,d,t),Ri(t)}}}function Lr(e,t){return Cr(e,t,"gutterClick",!0,Gi)}function Sr(e){var t=this;if(!Ui(t,e)&&!vr(t.display,e)){Va(e),_o&&(ua=+new Date);var r=yr(t,e,!0),n=e.dataTransfer.files;if(r&&!mr(t))if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),a=0,l=function(e,n){var l=new FileReader;l.onload=Zt(t,function(){if(o[n]=l.result,++a==i){r=Z(t.doc,r);var e={from:r,to:r,text:hl(o.join("\n")),origin:"paste"};Kr(t.doc,e),lt(t.doc,Y(r,ma(e)))}}),l.readAsText(e)},s=0;i>s;++s)l(n[s],s);else{if(t.state.draggingText&&t.doc.sel.contains(r)>-1)return t.state.draggingText(e),void setTimeout(io(hr,t),20);try{var o=e.dataTransfer.getData("Text");if(o){var u=t.state.draggingText&&t.listSelections();if(ut(t.doc,Y(r,r)),u)for(var s=0;s<u.length;++s)Jr(t.doc,"",u[s].anchor,u[s].head,"drag");t.replaceSelection(o,"around","paste"),hr(t)}}catch(e){}}}}function Mr(e,t){if(_o&&(!e.state.draggingText||+new Date-ua<100))return void qa(t);if(!Ui(e,t)&&!vr(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.setDragImage&&!Vo)){var r=lo("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",jo&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),jo&&r.parentNode.removeChild(r)}}function Tr(e,t){Math.abs(e.doc.scrollTop-t)<2||(e.doc.scrollTop=t,zo||k(e,{top:t}),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t),e.display.scrollbarV.scrollTop!=t&&(e.display.scrollbarV.scrollTop=t),zo&&k(e),yt(e,100))}function Ar(e,t,r){(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)||(t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),e.doc.scrollLeft=t,y(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbarH.scrollLeft!=t&&(e.display.scrollbarH.scrollLeft=t))}function Nr(e,t){var r=t.wheelDeltaX,n=t.wheelDeltaY;null==r&&t.detail&&t.axis==t.HORIZONTAL_AXIS&&(r=t.detail),null==n&&t.detail&&t.axis==t.VERTICAL_AXIS?n=t.detail:null==n&&(n=t.wheelDelta);var i=e.display,o=i.scroller;if(r&&o.scrollWidth>o.clientWidth||n&&o.scrollHeight>o.clientHeight){if(n&&Yo&&Fo)e:for(var a=t.target,l=i.view;a!=o;a=a.parentNode)for(var s=0;s<l.length;s++)if(l[s].node==a){e.display.currentWheelTarget=a;break e}if(r&&!zo&&!jo&&null!=fa)return n&&Tr(e,Math.max(0,Math.min(o.scrollTop+n*fa,o.scrollHeight-o.clientHeight))),Ar(e,Math.max(0,Math.min(o.scrollLeft+r*fa,o.scrollWidth-o.clientWidth))),Va(t),void(i.wheelStartX=null);if(n&&null!=fa){var u=n*fa,c=e.doc.scrollTop,f=c+i.wrapper.clientHeight;0>u?c=Math.max(0,c+u-50):f=Math.min(e.doc.height,f+u+50),k(e,{top:c,bottom:f})}20>ca&&(null==i.wheelStartX?(i.wheelStartX=o.scrollLeft,i.wheelStartY=o.scrollTop,i.wheelDX=r,i.wheelDY=n,setTimeout(function(){if(null!=i.wheelStartX){var e=o.scrollLeft-i.wheelStartX,t=o.scrollTop-i.wheelStartY,r=t&&i.wheelDY&&t/i.wheelDY||e&&i.wheelDX&&e/i.wheelDX;i.wheelStartX=i.wheelStartY=null,r&&(fa=(fa*ca+r)/(ca+1),++ca)}},200)):(i.wheelDX+=r,i.wheelDY+=n))}}function Hr(e,t,r){if("string"==typeof t&&(t=Ma[t],!t))return!1;e.display.pollingFast&&fr(e)&&(e.display.pollingFast=!1);var n=e.display.shift,i=!1;try{mr(e)&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=Qa}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function Or(e){var t=e.state.keyMaps.slice(0);return e.options.extraKeys&&t.push(e.options.extraKeys),t.push(e.options.keyMap),t}function zr(e,t){var r=mn(e.options.keyMap),n=r.auto;clearTimeout(da),n&&!Na(t)&&(da=setTimeout(function(){mn(e.options.keyMap)==r&&(e.options.keyMap=n.call?n.call(null,e):n,l(e))},50));var i=Ha(t,!0),o=!1;if(!i)return!1;var a=Or(e);return o=t.shiftKey?Aa("Shift-"+i,a,function(t){return Hr(e,t,!0)})||Aa(i,a,function(t){return("string"==typeof t?/^go[A-Z]/.test(t):t.motion)?Hr(e,t):void 0}):Aa(i,a,function(t){return Hr(e,t)}),o&&(Va(t),vt(e),Gi(e,"keyHandled",e,i,t)),o}function Wr(e,t,r){var n=Aa("'"+r+"'",Or(e),function(t){return Hr(e,t,!0)});return n&&(Va(t),vt(e),Gi(e,"keyHandled",e,"'"+r+"'",t)),n}function Er(e){var t=this;if(pr(t),!Ui(t,e)){Wo&&27==e.keyCode&&(e.returnValue=!1);var r=e.keyCode;t.display.shift=16==r||e.shiftKey;var n=zr(t,e);jo&&(ha=n?r:null,!n&&88==r&&!ml&&(Yo?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=r||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||Ir(t)}}function Ir(e){function t(e){18!=e.keyCode&&e.altKey||(po(r,"CodeMirror-crosshair"),Ka(document,"keyup",t),Ka(document,"mouseover",t))}var r=e.display.lineDiv;mo(r,"CodeMirror-crosshair"),Ua(document,"keyup",t),Ua(document,"mouseover",t)}function Dr(e){Ui(this,e)||16==e.keyCode&&(this.doc.sel.shift=!1)}function Pr(e){var t=this;if(!Ui(t,e)){var r=e.keyCode,n=e.charCode;if(jo&&r==ha)return ha=null,void Va(e);if(!(jo&&(!e.which||e.which<10)||Go)||!zr(t,e)){var i=String.fromCharCode(null==n?r:n);Wr(t,e,i)||(_o&&!Io&&(t.display.inputHasSelection=null),cr(t))}}}function _r(e){"nocursor"!=e.options.readOnly&&(e.state.focused||($a(e,"focus",e),e.state.focused=!0,mo(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu!=e.doc.sel||(dr(e),Fo&&setTimeout(io(dr,e,!0),0))),ur(e),vt(e))}function Fr(e){e.state.focused&&($a(e,"blur",e),e.state.focused=!1,po(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150)}function Br(e,t){function r(){if(null!=i.input.selectionStart){var t=e.somethingSelected(),r=i.input.value="​"+(t?i.input.value:"");i.prevInput=t?"":"​",i.input.selectionStart=1,i.input.selectionEnd=r.length}}function n(){if(i.inputDiv.style.position="relative",i.input.style.cssText=s,Io&&(i.scrollbarV.scrollTop=i.scroller.scrollTop=a),ur(e),null!=i.input.selectionStart){(!_o||Io)&&r(),clearTimeout(pa);var t=0,n=function(){i.selForContextMenu==e.doc.sel&&0==i.input.selectionStart?Zt(e,Ma.selectAll)(e):t++<10?pa=setTimeout(n,500):dr(e)};pa=setTimeout(n,200)}}if(!Ui(e,t,"contextmenu")){var i=e.display;if(!vr(i,t)&&!Rr(e,t)){var o=yr(e,t),a=i.scroller.scrollTop;if(o&&!jo){var l=e.options.resetSelectionOnContextMenu;l&&-1==e.doc.sel.contains(o)&&Zt(e,st)(e.doc,Y(o),Ja);var s=i.input.style.cssText;if(i.inputDiv.style.position="absolute",i.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(t.clientY-5)+"px; left: "+(t.clientX-5)+"px; z-index: 1000; background: "+(_o?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",hr(e),dr(e),e.somethingSelected()||(i.input.value=i.prevInput=" "),i.selForContextMenu=e.doc.sel,_o&&!Io&&r(),Jo){qa(t);var u=function(){Ka(window,"mouseup",u),setTimeout(n,20)};Ua(window,"mouseup",u)}else setTimeout(n,50)}}}}function Rr(e,t){return $i(e,"gutterContextMenu")?Cr(e,t,"gutterContextMenu",!1,$a):!1}function jr(e,t){if(na(e,t.from)<0)return e;if(na(e,t.to)<=0)return ma(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=ma(t).ch-t.to.ch),ra(r,n)}function Vr(e,t){for(var r=[],n=0;n<e.sel.ranges.length;n++){var i=e.sel.ranges[n];r.push(new K(jr(i.anchor,t),jr(i.head,t)))}return $(r,e.sel.primIndex)}function Gr(e,t,r){return e.line==t.line?ra(r.line,e.ch-t.ch+r.ch):ra(r.line+(e.line-t.line),e.ch)}function qr(e,t,r){for(var n=[],i=ra(e.first,0),o=i,a=0;a<t.length;a++){var l=t[a],s=Gr(l.from,i,o),u=Gr(ma(l),i,o);if(i=l.to,o=u,"around"==r){var c=e.sel.ranges[a],f=na(c.head,c.anchor)<0;n[a]=new K(f?u:s,f?s:u)}else n[a]=new K(s,s)}return new U(n,e.sel.primIndex)}function Ur(e,t,r){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){this.canceled=!0}};return r&&(n.update=function(t,r,n,i){t&&(this.from=Z(e,t)),r&&(this.to=Z(e,r)),n&&(this.text=n),void 0!==i&&(this.origin=i)}),$a(e,"beforeChange",e,n),e.cm&&$a(e.cm,"beforeChange",e.cm,n),n.canceled?null:{from:n.from,to:n.to,text:n.text,origin:n.origin}}function Kr(e,t,r){if(e.cm){if(!e.cm.curOp)return Zt(e.cm,Kr)(e,t,r);if(e.cm.state.suppressEdits)return}if(!($i(e,"beforeChange")||e.cm&&$i(e.cm,"beforeChange"))||(t=Ur(e,t,!0))){var n=ea&&!r&&Hn(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)$r(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text});else $r(e,t)}}function $r(e,t){if(1!=t.text.length||""!=t.text[0]||0!=na(t.from,t.to)){var r=Vr(e,t);Hi(e,t,r,e.cm?e.cm.curOp.id:0/0),Zr(e,t,r,Tn(e,t));var n=[];gi(e,function(e,r){r||-1!=eo(n,e.history)||(Bi(e.history,t),n.push(e.history)),Zr(e,t,null,Tn(e,t))})}}function Yr(e,t,r){if(!e.cm||!e.cm.state.suppressEdits){for(var n=e.history,i,o=e.sel,a="undo"==t?n.done:n.undone,l="undo"==t?n.undone:n.done,s=0;s<a.length&&(i=a[s],r?!i.ranges||i.equals(e.sel):i.ranges);s++);if(s!=a.length){for(n.lastOrigin=n.lastSelOrigin=null;i=a.pop(),i.ranges;){if(Wi(i,l),r&&!i.equals(e.sel))return void st(e,i,{clearRedo:!1});o=i}var u=[];Wi(o,l),l.push({changes:u,generation:n.generation}),n.generation=i.generation||++n.maxGeneration;for(var c=$i(e,"beforeChange")||e.cm&&$i(e.cm,"beforeChange"),s=i.changes.length-1;s>=0;--s){var f=i.changes[s];if(f.origin=t,c&&!Ur(e,f,!1))return void(a.length=0);u.push(Ti(e,f));var d=s?Vr(e,f,null):Ji(a);Zr(e,f,d,Nn(e,f)),e.cm&&an(e.cm);var h=[];gi(e,function(e,t){t||-1!=eo(h,e.history)||(Bi(e.history,f),h.push(e.history)),Zr(e,f,null,Nn(e,f))})}}}}function Xr(e,t){e.first+=t,e.sel=new U(to(e.sel.ranges,function(e){return new K(ra(e.anchor.line+t,e.anchor.ch),ra(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm&&rr(e.cm,e.first,e.first-t,t)}function Zr(e,t,r,n){if(e.cm&&!e.cm.curOp)return Zt(e.cm,Zr)(e,t,r,n);if(t.to.line<e.first)return void Xr(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);Xr(e,i),t={from:ra(e.first,0),to:ra(t.to.line+i,t.to.ch),text:[Ji(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:ra(o,yi(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=bi(e,t.from,t.to),r||(r=Vr(e,t,null)),e.cm?Qr(e.cm,t,n):hi(e,t,n),ut(e,r,Ja)}}function Qr(e,t,r){var n=e.doc,i=e.display,a=t.from,l=t.to,s=!1,u=a.line;e.options.lineWrapping||(u=ki(Bn(yi(n,a.line))),n.iter(u,l.line+1,function(e){return e==i.maxLine?(s=!0,!0):void 0})),n.sel.contains(t.from,t.to)>-1&&Ki(e),hi(n,t,r,o(e)),e.options.lineWrapping||(n.iter(u,a.line+t.text.length,function(e){var t=d(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),n.frontier=Math.min(n.frontier,a.line),yt(e,400);var c=t.text.length-(l.line-a.line)-1;a.line!=l.line||1!=t.text.length||di(e.doc,t)?rr(e,a.line,l.line+1,c):nr(e,a.line,"text");var f=$i(e,"changes"),h=$i(e,"change");if(h||f){var p={from:a,to:l,text:t.text,removed:t.removed,origin:t.origin};h&&Gi(e,"change",e,p),f&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}}function Jr(e,t,r,n,i){if(n||(n=r),na(n,r)<0){var o=n;n=r,r=o}"string"==typeof t&&(t=hl(t)),Kr(e,{from:r,to:n,text:t,origin:i})}function en(e,t){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null;if(t.top+n.top<0?i=!0:t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!Uo){var o=lo("div","​",null,"position: absolute; top: "+(t.top-r.viewOffset-kt(e.display))+"px; height: "+(t.bottom-t.top+Za)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}function tn(e,t,r,n){for(null==n&&(n=0);;){var i=!1,o=Rt(e,t),a=r&&r!=t?Rt(e,r):o,l=nn(e,Math.min(o.left,a.left),Math.min(o.top,a.top)-n,Math.max(o.left,a.left),Math.max(o.bottom,a.bottom)+n),s=e.doc.scrollTop,u=e.doc.scrollLeft;if(null!=l.scrollTop&&(Tr(e,l.scrollTop),Math.abs(e.doc.scrollTop-s)>1&&(i=!0)),null!=l.scrollLeft&&(Ar(e,l.scrollLeft),Math.abs(e.doc.scrollLeft-u)>1&&(i=!0)),!i)return o}}function rn(e,t,r,n,i){var o=nn(e,t,r,n,i);null!=o.scrollTop&&Tr(e,o.scrollTop),null!=o.scrollLeft&&Ar(e,o.scrollLeft)}function nn(e,t,r,n,i){var o=e.display,a=Ut(e.display);0>r&&(r=0);var l=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,s=o.scroller.clientHeight-Za,u={},c=e.doc.height+Ct(o),f=a>r,d=i>c-a;if(l>r)u.scrollTop=f?0:r;else if(i>l+s){var h=Math.min(r,(d?c:i)-s);h!=l&&(u.scrollTop=h)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,m=o.scroller.clientWidth-Za;t+=o.gutters.offsetWidth,n+=o.gutters.offsetWidth;var g=o.gutters.offsetWidth,v=g+10>t;return p+g>t||v?(v&&(t=0),u.scrollLeft=Math.max(0,t-10-g)):n>m+p-3&&(u.scrollLeft=n+10-m),u}function on(e,t,r){(null!=t||null!=r)&&ln(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=r&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+r)}function an(e){ln(e);var t=e.getCursor(),r=t,n=t;e.options.lineWrapping||(r=t.ch?ra(t.line,t.ch-1):t,n=ra(t.line,t.ch+1)),e.curOp.scrollToPos={from:r,to:n,margin:e.options.cursorScrollMargin,isCursor:!0}}function ln(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var r=jt(e,t.from),n=jt(e,t.to),i=nn(e,Math.min(r.left,n.left),Math.min(r.top,n.top)-t.margin,Math.max(r.right,n.right),Math.max(r.bottom,n.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function sn(e,t,r,n){var i=e.doc,o;null==r&&(r="add"),"smart"==r&&(e.doc.mode.indent?o=xt(e,t):r="prev");var a=e.options.tabSize,l=yi(i,t),s=rl(l.text,null,a);l.stateAfter&&(l.stateAfter=null);var u=l.text.match(/^\s*/)[0],c;if(n||/\S/.test(l.text)){if("smart"==r&&(c=e.doc.mode.indent(o,l.text.slice(u.length),l.text),c==Qa)){if(!n)return;r="prev"}}else c=0,r="not";"prev"==r?c=t>i.first?rl(yi(i,t-1).text,null,a):0:"add"==r?c=s+e.options.indentUnit:"subtract"==r?c=s-e.options.indentUnit:"number"==typeof r&&(c=s+r),c=Math.max(0,c);var f="",d=0;if(e.options.indentWithTabs)for(var h=Math.floor(c/a);h;--h)d+=a,f+=" ";if(c>d&&(f+=Qi(c-d)),f!=u)Jr(e.doc,f,ra(t,0),ra(t,u.length),"+input");else for(var h=0;h<i.sel.ranges.length;h++){var p=i.sel.ranges[h];if(p.head.line==t&&p.head.ch<u.length){var d=ra(t,u.length);it(i,h,new K(d,d));break}}l.stateAfter=null}function un(e,t,r,n){var i=t,o=t,a=e.doc;return"number"==typeof t?o=yi(a,X(a,t)):i=ki(t),null==i?null:(n(o,i)&&nr(e,i,r),o)}function cn(e,t){for(var r=e.doc.sel.ranges,n=[],i=0;i<r.length;i++){for(var o=t(r[i]);n.length&&na(o.from,Ji(n).to)<=0;){var a=n.pop();if(na(a.from,o.from)<0){o.from=a.from;break}}n.push(o)}Xt(e,function(){for(var t=n.length-1;t>=0;t--)Jr(e.doc,"",n[t].from,n[t].to,"+delete");an(e)})}function fn(e,t,r,n,i){function o(){var t=l+r;return t<e.first||t>=e.first+e.size?f=!1:(l=t,c=yi(e,t))}function a(e){var t=(i?Ho:Oo)(c,s,r,!0);if(null==t){if(e||!o())return f=!1;s=i?(0>r?Lo:Co)(c):0>r?c.text.length:0}else s=t;return!0}var l=t.line,s=t.ch,u=r,c=yi(e,l),f=!0;if("char"==n)a();else if("column"==n)a(!0);else if("word"==n||"group"==n)for(var d=null,h="group"==n,p=!0;!(0>r)||a(!p);p=!1){var m=c.text.charAt(s)||"\n",g=al(m)?"w":h&&"\n"==m?"n":!h||/\s/.test(m)?null:"p";if(!h||p||g||(g="s"),d&&d!=g){0>r&&(r=1,a());break}if(g&&(d=g),r>0&&!a(!p))break
3
  }var v=ht(e,ra(l,s),u,!0);return f||(v.hitSide=!0),v}function dn(e,t,r,n){var i=e.doc,o=t.left,a;if("page"==n){var l=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);a=t.top+r*(l-(0>r?1.5:.5)*Ut(e.display))}else"line"==n&&(a=r>0?t.bottom+3:t.top-3);for(;;){var s=Gt(e,o,a);if(!s.outside)break;if(0>r?0>=a:a>=i.height){s.hitSide=!0;break}a+=5*r}return s}function hn(e,t){var r=yi(e,t.line).text,n=t.ch,i=t.ch;if(r){(t.xRel<0||i==r.length)&&n?--n:++i;for(var o=r.charAt(n),a=al(o)?al:/\s/.test(o)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!al(e)};n>0&&a(r.charAt(n-1));)--n;for(;i<r.length&&a(r.charAt(i));)++i}return new K(ra(t.line,n),ra(t.line,i))}function pn(t,r,n,i){e.defaults[t]=r,n&&(va[t]=i?function(e,t,r){r!=ya&&n(e,t,r)}:n)}function mn(e){return"string"==typeof e?Ta[e]:e}function gn(e,t,r,n,i){if(n&&n.shared)return vn(e,t,r,n,i);if(e.cm&&!e.cm.curOp)return Zt(e.cm,gn)(e,t,r,n,i);var o=new za(e,i),a=na(t,r);if(n&&no(n,o,!1),a>0||0==a&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=lo("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||(o.widgetNode.ignoreEvents=!0),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(Fn(e,t.line,t,r,o)||t.line!=r.line&&Fn(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");ta=!0}o.addToHistory&&Hi(e,{from:t,to:r,origin:"markText"},e.sel,0/0);var l=t.line,s=e.cm,u;if(e.iter(l,r.line+1,function(e){s&&o.collapsed&&!s.options.lineWrapping&&Bn(e)==s.display.maxLine&&(u=!0),o.collapsed&&l!=t.line&&xi(e,0),Ln(e,new xn(o,l==t.line?t.ch:null,l==r.line?r.ch:null)),++l}),o.collapsed&&e.iter(t.line,r.line+1,function(t){Gn(e,t)&&xi(t,0)}),o.clearOnEnter&&Ua(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(ea=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++Wa,o.atomic=!0),s){if(u&&(s.curOp.updateMaxLine=!0),o.collapsed)rr(s,t.line,r.line+1);else if(o.className||o.title||o.startStyle||o.endStyle)for(var c=t.line;c<=r.line;c++)nr(s,c,"text");o.atomic&&ft(s.doc),Gi(s,"markerAdded",s,o)}return o}function vn(e,t,r,n,i){n=no(n),n.shared=!1;var o=[gn(e,t,r,n,i)],a=o[0],l=n.widgetNode;return gi(e,function(e){l&&(n.widgetNode=l.cloneNode(!0)),o.push(gn(e,Z(e,t),Z(e,r),n,i));for(var s=0;s<e.linked.length;++s)if(e.linked[s].isParent)return;a=Ji(o)}),new Ea(o,a)}function yn(e){return e.findMarks(ra(e.first,0),e.clipPos(ra(e.lastLine())),function(e){return e.parent})}function bn(e,t){for(var r=0;r<t.length;r++){var n=t[r],i=n.find(),o=e.clipPos(i.from),a=e.clipPos(i.to);if(na(o,a)){var l=gn(e,o,a,n.primary,n.primary.type);n.markers.push(l),l.parent=n}}}function wn(e){for(var t=0;t<e.length;t++){var r=e[t],n=[r.primary.doc];gi(r.primary.doc,function(e){n.push(e)});for(var i=0;i<r.markers.length;i++){var o=r.markers[i];-1==eo(n,o.doc)&&(o.parent=null,r.markers.splice(i--,1))}}}function xn(e,t,r){this.marker=e,this.from=t,this.to=r}function kn(e,t){if(e)for(var r=0;r<e.length;++r){var n=e[r];if(n.marker==t)return n}}function Cn(e,t){for(var r,n=0;n<e.length;++n)e[n]!=t&&(r||(r=[])).push(e[n]);return r}function Ln(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function Sn(e,t,r){if(e)for(var n=0,i;n<e.length;++n){var o=e[n],a=o.marker,l=null==o.from||(a.inclusiveLeft?o.from<=t:o.from<t);if(l||o.from==t&&"bookmark"==a.type&&(!r||!o.marker.insertLeft)){var s=null==o.to||(a.inclusiveRight?o.to>=t:o.to>t);(i||(i=[])).push(new xn(a,o.from,s?null:o.to))}}return i}function Mn(e,t,r){if(e)for(var n=0,i;n<e.length;++n){var o=e[n],a=o.marker,l=null==o.to||(a.inclusiveRight?o.to>=t:o.to>t);if(l||o.from==t&&"bookmark"==a.type&&(!r||o.marker.insertLeft)){var s=null==o.from||(a.inclusiveLeft?o.from<=t:o.from<t);(i||(i=[])).push(new xn(a,s?null:o.from-t,null==o.to?null:o.to-t))}}return i}function Tn(e,t){var r=J(e,t.from.line)&&yi(e,t.from.line).markedSpans,n=J(e,t.to.line)&&yi(e,t.to.line).markedSpans;if(!r&&!n)return null;var i=t.from.ch,o=t.to.ch,a=0==na(t.from,t.to),l=Sn(r,i,a),s=Mn(n,o,a),u=1==t.text.length,c=Ji(t.text).length+(u?i:0);if(l)for(var f=0;f<l.length;++f){var d=l[f];if(null==d.to){var h=kn(s,d.marker);h?u&&(d.to=null==h.to?null:h.to+c):d.to=i}}if(s)for(var f=0;f<s.length;++f){var d=s[f];if(null!=d.to&&(d.to+=c),null==d.from){var h=kn(l,d.marker);h||(d.from=c,u&&(l||(l=[])).push(d))}else d.from+=c,u&&(l||(l=[])).push(d)}l&&(l=An(l)),s&&s!=l&&(s=An(s));var p=[l];if(!u){var m=t.text.length-2,g;if(m>0&&l)for(var f=0;f<l.length;++f)null==l[f].to&&(g||(g=[])).push(new xn(l[f].marker,null,null));for(var f=0;m>f;++f)p.push(g);p.push(s)}return p}function An(e){for(var t=0;t<e.length;++t){var r=e[t];null!=r.from&&r.from==r.to&&r.marker.clearWhenEmpty!==!1&&e.splice(t--,1)}return e.length?e:null}function Nn(e,t){var r=Di(e,t),n=Tn(e,t);if(!r)return n;if(!n)return r;for(var i=0;i<r.length;++i){var o=r[i],a=n[i];if(o&&a)e:for(var l=0;l<a.length;++l){for(var s=a[l],u=0;u<o.length;++u)if(o[u].marker==s.marker)continue e;o.push(s)}else a&&(r[i]=a)}return r}function Hn(e,t,r){var n=null;if(e.iter(t.line,r.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var r=e.markedSpans[t].marker;!r.readOnly||n&&-1!=eo(n,r)||(n||(n=[])).push(r)}}),!n)return null;for(var i=[{from:t,to:r}],o=0;o<n.length;++o)for(var a=n[o],l=a.find(0),s=0;s<i.length;++s){var u=i[s];if(!(na(u.to,l.from)<0||na(u.from,l.to)>0)){var c=[s,1],f=na(u.from,l.from),d=na(u.to,l.to);(0>f||!a.inclusiveLeft&&!f)&&c.push({from:u.from,to:l.from}),(d>0||!a.inclusiveRight&&!d)&&c.push({from:l.to,to:u.to}),i.splice.apply(i,c),s+=c.length-1}}return i}function On(e){var t=e.markedSpans;if(t){for(var r=0;r<t.length;++r)t[r].marker.detachLine(e);e.markedSpans=null}}function zn(e,t){if(t){for(var r=0;r<t.length;++r)t[r].marker.attachLine(e);e.markedSpans=t}}function Wn(e){return e.inclusiveLeft?-1:0}function En(e){return e.inclusiveRight?1:0}function In(e,t){var r=e.lines.length-t.lines.length;if(0!=r)return r;var n=e.find(),i=t.find(),o=na(n.from,i.from)||Wn(e)-Wn(t);if(o)return-o;var a=na(n.to,i.to)||En(e)-En(t);return a?a:t.id-e.id}function Dn(e,t){var r=ta&&e.markedSpans,n;if(r)for(var i,o=0;o<r.length;++o)i=r[o],i.marker.collapsed&&null==(t?i.from:i.to)&&(!n||In(n,i.marker)<0)&&(n=i.marker);return n}function Pn(e){return Dn(e,!0)}function _n(e){return Dn(e,!1)}function Fn(e,t,r,n,i){var o=yi(e,t),a=ta&&o.markedSpans;if(a)for(var l=0;l<a.length;++l){var s=a[l];if(s.marker.collapsed){var u=s.marker.find(0),c=na(u.from,r)||Wn(s.marker)-Wn(i),f=na(u.to,n)||En(s.marker)-En(i);if(!(c>=0&&0>=f||0>=c&&f>=0)&&(0>=c&&(na(u.to,r)||En(s.marker)-Wn(i))>0||c>=0&&(na(u.from,n)||Wn(s.marker)-En(i))<0))return!0}}}function Bn(e){for(var t;t=Pn(e);)e=t.find(-1,!0).line;return e}function Rn(e){for(var t,r;t=_n(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function jn(e,t){var r=yi(e,t),n=Bn(r);return r==n?t:ki(n)}function Vn(e,t){if(t>e.lastLine())return t;var r=yi(e,t),n;if(!Gn(e,r))return t;for(;n=_n(r);)r=n.find(1,!0).line;return ki(r)+1}function Gn(e,t){var r=ta&&t.markedSpans;if(r)for(var n,i=0;i<r.length;++i)if(n=r[i],n.marker.collapsed){if(null==n.from)return!0;if(!n.marker.widgetNode&&0==n.from&&n.marker.inclusiveLeft&&qn(e,t,n))return!0}}function qn(e,t,r){if(null==r.to){var n=r.marker.find(1,!0);return qn(e,n.line,kn(n.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==t.text.length)return!0;for(var i,o=0;o<t.markedSpans.length;++o)if(i=t.markedSpans[o],i.marker.collapsed&&!i.marker.widgetNode&&i.from==r.to&&(null==i.to||i.to!=r.from)&&(i.marker.inclusiveLeft||r.marker.inclusiveRight)&&qn(e,t,i))return!0}function Un(e,t,r){Li(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&on(e,null,r)}function Kn(e){return null!=e.height?e.height:(co(document.body,e.node)||uo(e.cm.display.measure,lo("div",[e.node],null,"position: relative")),e.height=e.node.offsetHeight)}function $n(e,t,r,n){var i=new Ia(e,r,n);return i.noHScroll&&(e.display.alignWidgets=!0),un(e,t,"widget",function(t){var r=t.widgets||(t.widgets=[]);if(null==i.insertAt?r.push(i):r.splice(Math.min(r.length-1,Math.max(0,i.insertAt)),0,i),i.line=t,!Gn(e.doc,t)){var n=Li(t)<e.doc.scrollTop;xi(t,t.height+Kn(i)),n&&on(e,null,i.height),e.curOp.forceUpdate=!0}return!0}),i}function Yn(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),On(e),zn(e,r);var i=n?n(e):1;i!=e.height&&xi(e,i)}function Xn(e){e.parent=null,On(e)}function Zn(e,t){if(e)for(;;){var r=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!r)break;e=e.slice(0,r.index)+e.slice(r.index+r[0].length);var n=r[1]?"bgClass":"textClass";null==t[n]?t[n]=r[2]:new RegExp("(?:^|s)"+r[2]+"(?:$|s)").test(t[n])||(t[n]+=" "+r[2])}return e}function Qn(t,r){if(t.blankLine)return t.blankLine(r);if(t.innerMode){var n=e.innerMode(t,r);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function Jn(e,t,r){var n=e.token(t,r);if(t.pos<=t.start)throw new Error("Mode "+e.name+" failed to advance stream.");return n}function ei(t,r,n,i,o,a,l){var s=n.flattenSpans;null==s&&(s=t.options.flattenSpans);var u=0,c=null,f=new Oa(r,t.options.tabSize),d;for(""==r&&Zn(Qn(n,i),a);!f.eol();){if(f.pos>t.options.maxHighlightLength?(s=!1,l&&ni(t,r,i,f.pos),f.pos=r.length,d=null):d=Zn(Jn(n,f,i),a),t.options.addModeClass){var h=e.innerMode(n,i).mode.name;h&&(d="m-"+(d?h+" "+d:h))}s&&c==d||(u<f.start&&o(f.start,c),u=f.start,c=d),f.start=f.pos}for(;u<f.pos;){var p=Math.min(f.pos,u+5e4);o(p,c),u=p}}function ti(e,t,r,n){var i=[e.state.modeGen],o={};ei(e,t.text,e.doc.mode,r,function(e,t){i.push(e,t)},o,n);for(var a=0;a<e.state.overlays.length;++a){var l=e.state.overlays[a],s=1,u=0;ei(e,t.text,l.mode,!0,function(e,t){for(var r=s;e>u;){var n=i[s];n>e&&i.splice(s,1,e,i[s+1],n),s+=2,u=Math.min(e,n)}if(t)if(l.opaque)i.splice(r,s-r,e,"cm-overlay "+t),s=r+2;else for(;s>r;r+=2){var o=i[r+1];i[r+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function ri(e,t){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=ti(e,t,t.stateAfter=xt(e,ki(t)));t.styles=r.styles,r.classes?t.styleClasses=r.classes:t.styleClasses&&(t.styleClasses=null)}return t.styles}function ni(e,t,r,n){var i=e.doc.mode,o=new Oa(t,e.options.tabSize);for(o.start=o.pos=n||0,""==t&&Qn(i,r);!o.eol()&&o.pos<=e.options.maxHighlightLength;)Jn(i,o,r),o.start=o.pos}function ii(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?_a:Pa;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function oi(e,t){var r=lo("span",null,null,Fo?"padding-right: .1px":null),n={pre:lo("pre",[r]),content:r,col:0,pos:0,cm:e};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o=i?t.rest[i-1]:t.line,a;n.pos=0,n.addToken=li,(_o||Fo)&&e.getOption("lineWrapping")&&(n.addToken=si(n.addToken)),bo(e.display.measure)&&(a=Si(o))&&(n.addToken=ui(n.addToken,a)),n.map=[],fi(o,n,ri(e,o)),o.styleClasses&&(o.styleClasses.bgClass&&(n.bgClass=go(o.styleClasses.bgClass,n.bgClass||"")),o.styleClasses.textClass&&(n.textClass=go(o.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(yo(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return $a(e,"renderLine",e,t.line,n.pre),n}function ai(e){var t=lo("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t}function li(e,t,r,n,i,o){if(t){var a=e.cm.options.specialChars,l=!1;if(a.test(t))for(var s=document.createDocumentFragment(),u=0;;){a.lastIndex=u;var c=a.exec(t),f=c?c.index-u:t.length-u;if(f){var d=document.createTextNode(t.slice(u,u+f));s.appendChild(Io?lo("span",[d]):d),e.map.push(e.pos,e.pos+f,d),e.col+=f,e.pos+=f}if(!c)break;if(u+=f+1," "==c[0]){var h=e.cm.options.tabSize,p=h-e.col%h,d=s.appendChild(lo("span",Qi(p),"cm-tab"));e.col+=p}else{var d=e.cm.options.specialCharPlaceholder(c[0]);s.appendChild(Io?lo("span",[d]):d),e.col+=1}e.map.push(e.pos,e.pos+1,d),e.pos++}else{e.col+=t.length;var s=document.createTextNode(t);e.map.push(e.pos,e.pos+t.length,s),Io&&(l=!0),e.pos+=t.length}if(r||n||i||l){var m=r||"";n&&(m+=n),i&&(m+=i);var g=lo("span",[s],m);return o&&(g.title=o),e.content.appendChild(g)}e.content.appendChild(s)}}function si(e){function t(e){for(var t=" ",r=0;r<e.length-2;++r)t+=r%2?" ":" ";return t+=" "}return function(r,n,i,o,a,l){e(r,n.replace(/ {3,}/g,t),i,o,a,l)}}function ui(e,t){return function(r,n,i,o,a,l){i=i?i+" cm-force-border":"cm-force-border";for(var s=r.pos,u=s+n.length;;){for(var c=0;c<t.length;c++){var f=t[c];if(f.to>s&&f.from<=s)break}if(f.to>=u)return e(r,n,i,o,a,l);e(r,n.slice(0,f.to-s),i,o,null,l),o=null,n=n.slice(f.to-s),s=f.to}}}function ci(e,t,r,n){var i=!n&&r.widgetNode;i&&(e.map.push(e.pos,e.pos+t,i),e.content.appendChild(i)),e.pos+=t}function fi(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var a=i.length,l=0,s=1,u="",c,f=0,d,h,p,m,g;;){if(f==l){d=h=p=m="",g=null,f=1/0;for(var v=[],y=0;y<n.length;++y){var b=n[y],w=b.marker;b.from<=l&&(null==b.to||b.to>l)?(null!=b.to&&f>b.to&&(f=b.to,h=""),w.className&&(d+=" "+w.className),w.startStyle&&b.from==l&&(p+=" "+w.startStyle),w.endStyle&&b.to==f&&(h+=" "+w.endStyle),w.title&&!m&&(m=w.title),w.collapsed&&(!g||In(g.marker,w)<0)&&(g=b)):b.from>l&&f>b.from&&(f=b.from),"bookmark"==w.type&&b.from==l&&w.widgetNode&&v.push(w)}if(g&&(g.from||0)==l&&(ci(t,(null==g.to?a+1:g.to)-l,g.marker,null==g.from),null==g.to))return;if(!g&&v.length)for(var y=0;y<v.length;++y)ci(t,0,v[y])}if(l>=a)break;for(var x=Math.min(a,f);;){if(u){var k=l+u.length;if(!g){var C=k>x?u.slice(0,x-l):u;t.addToken(t,C,c?c+d:d,p,l+C.length==f?h:"",m)}if(k>=x){u=u.slice(x-l),l=x;break}l=k,p=""}u=i.slice(o,o=r[s++]),c=ii(r[s++],t.cm.options)}}else for(var s=1;s<r.length;s+=2)t.addToken(t,i.slice(o,o=r[s]),ii(r[s+1],t.cm.options))}function di(e,t){return 0==t.from.ch&&0==t.to.ch&&""==Ji(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function hi(e,t,r,n){function i(e){return r?r[e]:null}function o(e,r,i){Yn(e,r,i,n),Gi(e,"change",e,t)}var a=t.from,l=t.to,s=t.text,u=yi(e,a.line),c=yi(e,l.line),f=Ji(s),d=i(s.length-1),h=l.line-a.line;if(di(e,t)){for(var p=0,m=[];p<s.length-1;++p)m.push(new Da(s[p],i(p),n));o(c,c.text,d),h&&e.remove(a.line,h),m.length&&e.insert(a.line,m)}else if(u==c)if(1==s.length)o(u,u.text.slice(0,a.ch)+f+u.text.slice(l.ch),d);else{for(var m=[],p=1;p<s.length-1;++p)m.push(new Da(s[p],i(p),n));m.push(new Da(f+u.text.slice(l.ch),d,n)),o(u,u.text.slice(0,a.ch)+s[0],i(0)),e.insert(a.line+1,m)}else if(1==s.length)o(u,u.text.slice(0,a.ch)+s[0]+c.text.slice(l.ch),i(0)),e.remove(a.line+1,h);else{o(u,u.text.slice(0,a.ch)+s[0],i(0)),o(c,f+c.text.slice(l.ch),d);for(var p=1,m=[];p<s.length-1;++p)m.push(new Da(s[p],i(p),n));h>1&&e.remove(a.line+1,h-1),e.insert(a.line+1,m)}Gi(e,"change",e,t)}function pi(e){this.lines=e,this.parent=null;for(var t=0,r=0;t<e.length;++t)e[t].parent=this,r+=e[t].height;this.height=r}function mi(e){this.children=e;for(var t=0,r=0,n=0;n<e.length;++n){var i=e[n];t+=i.chunkSize(),r+=i.height,i.parent=this}this.size=t,this.height=r,this.parent=null}function gi(e,t,r){function n(e,i,o){if(e.linked)for(var a=0;a<e.linked.length;++a){var l=e.linked[a];if(l.doc!=i){var s=o&&l.sharedHist;(!r||s)&&(t(l.doc,s),n(l.doc,e,s))}}}n(e,null,!0)}function vi(e,t){if(t.cm)throw new Error("This document is already in use.");e.doc=t,t.cm=e,a(e),r(e),e.options.lineWrapping||h(e),e.options.mode=t.modeOption,rr(e)}function yi(e,t){if(t-=e.first,0>t||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(o>t){r=i;break}t-=o}return r.lines[t]}function bi(e,t,r){var n=[],i=t.line;return e.iter(t.line,r.line+1,function(e){var o=e.text;i==r.line&&(o=o.slice(0,r.ch)),i==t.line&&(o=o.slice(t.ch)),n.push(o),++i}),n}function wi(e,t,r){var n=[];return e.iter(t,r,function(e){n.push(e.text)}),n}function xi(e,t){var r=t-e.height;if(r)for(var n=e;n;n=n.parent)n.height+=r}function ki(e){if(null==e.parent)return null;for(var t=e.parent,r=eo(t.lines,e),n=t.parent;n;t=n,n=n.parent)for(var i=0;n.children[i]!=t;++i)r+=n.children[i].chunkSize();return r+t.first}function Ci(e,t){var r=e.first;e:do{for(var n=0;n<e.children.length;++n){var i=e.children[n],o=i.height;if(o>t){e=i;continue e}t-=o,r+=i.chunkSize()}return r}while(!e.lines);for(var n=0;n<e.lines.length;++n){var a=e.lines[n],l=a.height;if(l>t)break;t-=l}return r+n}function Li(e){e=Bn(e);for(var t=0,r=e.parent,n=0;n<r.lines.length;++n){var i=r.lines[n];if(i==e)break;t+=i.height}for(var o=r.parent;o;r=o,o=r.parent)for(var n=0;n<o.children.length;++n){var a=o.children[n];if(a==r)break;t+=a.height}return t}function Si(e){var t=e.order;return null==t&&(t=e.order=yl(e.text)),t}function Mi(e){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e||1}function Ti(e,t){var r={from:V(t.from),to:ma(t),text:bi(e,t.from,t.to)};return Ei(e,r,t.from.line,t.to.line+1),gi(e,function(e){Ei(e,r,t.from.line,t.to.line+1)},!0),r}function Ai(e){for(;e.length;){var t=Ji(e);if(!t.ranges)break;e.pop()}}function Ni(e,t){return t?(Ai(e.done),Ji(e.done)):e.done.length&&!Ji(e.done).ranges?Ji(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),Ji(e.done)):void 0}function Hi(e,t,r,n){var i=e.history;i.undone.length=0;var o=+new Date,a;if((i.lastOp==n||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>o-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(a=Ni(i,i.lastOp==n))){var l=Ji(a.changes);0==na(t.from,t.to)&&0==na(t.from,l.to)?l.to=ma(t):a.changes.push(Ti(e,t))}else{var s=Ji(i.done);for(s&&s.ranges||Wi(e.sel,i.done),a={changes:[Ti(e,t)],generation:i.generation},i.done.push(a);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=o,i.lastOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,l||$a(e,"historyAdded")}function Oi(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function zi(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||Oi(e,o,Ji(i.done),t))?i.done[i.done.length-1]=t:Wi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastOp=r,n&&n.clearRedo!==!1&&Ai(i.undone)}function Wi(e,t){var r=Ji(t);r&&r.ranges&&r.equals(e)||t.push(e)}function Ei(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o})}function Ii(e){if(!e)return null;for(var t=0,r;t<e.length;++t)e[t].marker.explicitlyCleared?r||(r=e.slice(0,t)):r&&r.push(e[t]);return r?r.length?r:null:e}function Di(e,t){var r=t["spans_"+e.id];if(!r)return null;for(var n=0,i=[];n<t.text.length;++n)i.push(Ii(r[n]));return i}function Pi(e,t,r){for(var n=0,i=[];n<e.length;++n){var o=e[n];if(o.ranges)i.push(r?U.prototype.deepCopy.call(o):o);else{var a=o.changes,l=[];i.push({changes:l});for(var s=0;s<a.length;++s){var u=a[s],c;if(l.push({from:u.from,to:u.to,text:u.text}),t)for(var f in u)(c=f.match(/^spans_(\d+)$/))&&eo(t,Number(c[1]))>-1&&(Ji(l)[f]=u[f],delete u[f])}}}return i}function _i(e,t,r,n){r<e.line?e.line+=n:t<e.line&&(e.line=t,e.ch=0)}function Fi(e,t,r,n){for(var i=0;i<e.length;++i){var o=e[i],a=!0;if(o.ranges){o.copied||(o=e[i]=o.deepCopy(),o.copied=!0);for(var l=0;l<o.ranges.length;l++)_i(o.ranges[l].anchor,t,r,n),_i(o.ranges[l].head,t,r,n)}else{for(var l=0;l<o.changes.length;++l){var s=o.changes[l];if(r<s.from.line)s.from=ra(s.from.line+n,s.from.ch),s.to=ra(s.to.line+n,s.to.ch);else if(t<=s.to.line){a=!1;break}}a||(e.splice(0,i+1),i=0)}}}function Bi(e,t){var r=t.from.line,n=t.to.line,i=t.text.length-(n-r)-1;Fi(e.done,r,n,i),Fi(e.undone,r,n,i)}function Ri(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function ji(e){return e.target||e.srcElement}function Vi(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),Yo&&e.ctrlKey&&1==t&&(t=3),t}function Gi(e,t){function r(e){return function(){e.apply(null,i)}}var n=e._handlers&&e._handlers[t];if(n){var i=Array.prototype.slice.call(arguments,2);Ya||(++Xa,Ya=[],setTimeout(qi,0));for(var o=0;o<n.length;++o)Ya.push(r(n[o]))}}function qi(){--Xa;var e=Ya;Ya=null;for(var t=0;t<e.length;++t)e[t]()}function Ui(e,t,r){return $a(e,r||t.type,e,t),Ri(t)||t.codemirrorIgnore}function Ki(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var r=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),n=0;n<t.length;++n)-1==eo(r,t[n])&&r.push(t[n])}function $i(e,t){var r=e._handlers&&e._handlers[t];return r&&r.length>0}function Yi(e){e.prototype.on=function(e,t){Ua(this,e,t)},e.prototype.off=function(e,t){Ka(this,e,t)}}function Xi(){this.id=null}function Zi(e,t,r){for(var n=0,i=0;;){var o=e.indexOf(" ",n);-1==o&&(o=e.length);var a=o-n;if(o==e.length||i+a>=t)return n+Math.min(a,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}}function Qi(e){for(;nl.length<=e;)nl.push(Ji(nl)+" ");return nl[e]}function Ji(e){return e[e.length-1]}function eo(e,t){for(var r=0;r<e.length;++r)if(e[r]==t)return r;return-1}function to(e,t){for(var r=[],n=0;n<e.length;n++)r[n]=t(e[n],n);return r}function ro(e,t){var r;if(Object.create)r=Object.create(e);else{var n=function(){};n.prototype=e,r=new n}return t&&no(t,r),r}function no(e,t,r){t||(t={});for(var n in e)!e.hasOwnProperty(n)||r===!1&&t.hasOwnProperty(n)||(t[n]=e[n]);return t}function io(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function oo(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function ao(e){return e.charCodeAt(0)>=768&&ll.test(e)}function lo(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function so(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function uo(e,t){return so(e).appendChild(t)}function co(e,t){if(e.contains)return e.contains(t);for(;t=t.parentNode;)if(t==e)return!0}function fo(){return document.activeElement}function ho(e){return new RegExp("\\b"+e+"\\b\\s*")}function po(e,t){var r=ho(t);r.test(e.className)&&(e.className=e.className.replace(r,""))}function mo(e,t){ho(t).test(e.className)||(e.className+=" "+t)}function go(e,t){for(var r=e.split(" "),n=0;n<r.length;n++)r[n]&&!ho(r[n]).test(t)&&(t+=" "+r[n]);return t}function vo(e){if(null!=cl)return cl;var t=lo("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");return uo(e,t),t.offsetWidth&&(cl=t.offsetHeight-t.clientHeight),cl||0}function yo(e){if(null==fl){var t=lo("span","​");uo(e,lo("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(fl=t.offsetWidth<=1&&t.offsetHeight>2&&!Eo)}return fl?lo("span","​"):lo("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px")}function bo(e){if(null!=dl)return dl;var t=uo(e,document.createTextNode("AخA")),r=sl(t,0,1).getBoundingClientRect();if(r.left==r.right)return!1;var n=sl(t,1,2).getBoundingClientRect();return dl=n.right-r.right<3}function wo(e,t,r,n){if(!e)return n(t,r,"ltr");for(var i=!1,o=0;o<e.length;++o){var a=e[o];(a.from<r&&a.to>t||t==r&&a.to==t)&&(n(Math.max(a.from,t),Math.min(a.to,r),1==a.level?"rtl":"ltr"),i=!0)}i||n(t,r,"ltr")}function xo(e){return e.level%2?e.to:e.from}function ko(e){return e.level%2?e.from:e.to}function Co(e){var t=Si(e);return t?xo(t[0]):0}function Lo(e){var t=Si(e);return t?ko(Ji(t)):e.text.length}function So(e,t){var r=yi(e.doc,t),n=Bn(r);n!=r&&(t=ki(n));var i=Si(n),o=i?i[0].level%2?Lo(n):Co(n):0;return ra(t,o)}function Mo(e,t){for(var r,n=yi(e.doc,t);r=_n(n);)n=r.find(1,!0).line,t=null;var i=Si(n),o=i?i[0].level%2?Co(n):Lo(n):n.text.length;return ra(null==t?ki(n):t,o)}function To(e,t,r){var n=e[0].level;return t==n?!0:r==n?!1:r>t}function Ao(e,t){vl=null;for(var r=0,n;r<e.length;++r){var i=e[r];if(i.from<t&&i.to>t)return r;if(i.from==t||i.to==t){if(null!=n)return To(e,i.level,e[n].level)?(i.from!=i.to&&(vl=n),r):(i.from!=i.to&&(vl=r),n);n=r}}return n}function No(e,t,r,n){if(!n)return t+r;do t+=r;while(t>0&&ao(e.text.charAt(t)));return t}function Ho(e,t,r,n){var i=Si(e);if(!i)return Oo(e,t,r,n);for(var o=Ao(i,t),a=i[o],l=No(e,t,a.level%2?-r:r,n);;){if(l>a.from&&l<a.to)return l;if(l==a.from||l==a.to)return Ao(i,l)==o?l:(a=i[o+=r],r>0==a.level%2?a.to:a.from);if(a=i[o+=r],!a)return null;l=r>0==a.level%2?No(e,a.to,-1,n):No(e,a.from,1,n)}}function Oo(e,t,r,n){var i=t+r;if(n)for(;i>0&&ao(e.text.charAt(i));)i+=r;return 0>i||i>e.text.length?null:i}var zo=/gecko\/\d/i.test(navigator.userAgent),Wo=/MSIE \d/.test(navigator.userAgent),Eo=Wo&&(null==document.documentMode||document.documentMode<8),Io=Wo&&(null==document.documentMode||document.documentMode<9),Do=Wo&&(null==document.documentMode||document.documentMode<10),Po=/Trident\/([7-9]|\d{2,})\./.test(navigator.userAgent),_o=Wo||Po,Fo=/WebKit\//.test(navigator.userAgent),Bo=Fo&&/Qt\/\d+\.\d+/.test(navigator.userAgent),Ro=/Chrome\//.test(navigator.userAgent),jo=/Opera\//.test(navigator.userAgent),Vo=/Apple Computer/.test(navigator.vendor),Go=/KHTML\//.test(navigator.userAgent),qo=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),Uo=/PhantomJS/.test(navigator.userAgent),Ko=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),$o=Ko||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),Yo=Ko||/Mac/.test(navigator.platform),Xo=/win/i.test(navigator.platform),Zo=jo&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);Zo&&(Zo=Number(Zo[1])),Zo&&Zo>=15&&(jo=!1,Fo=!0);var Qo=Yo&&(Bo||jo&&(null==Zo||12.11>Zo)),Jo=zo||_o&&!Io,ea=!1,ta=!1,ra=e.Pos=function(e,t){return this instanceof ra?(this.line=e,void(this.ch=t)):new ra(e,t)},na=e.cmpPos=function(e,t){return e.line-t.line||e.ch-t.ch};U.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 r=this.ranges[t],n=e.ranges[t];if(0!=na(r.anchor,n.anchor)||0!=na(r.head,n.head))return!1}return!0},deepCopy:function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new K(V(this.ranges[t].anchor),V(this.ranges[t].head));return new U(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 r=0;r<this.ranges.length;r++){var n=this.ranges[r];if(na(t,n.from())>=0&&na(e,n.to())<=0)return r}return-1}},K.prototype={from:function(){return q(this.anchor,this.head)},to:function(){return G(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var ia={left:0,right:0,top:0,bottom:0},oa,aa=0,la,sa,ua=0,ca=0,fa=null;_o?fa=-.53:zo?fa=15:Ro?fa=-.7:Vo&&(fa=-1/3);var da,ha=null,pa,ma=e.changeEnd=function(e){return e.text?ra(e.from.line+e.text.length-1,Ji(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),hr(this),cr(this)},setOption:function(e,t){var r=this.options,n=r[e];(r[e]!=t||"mode"==e)&&(r[e]=t,va.hasOwnProperty(e)&&Zt(this,va[e])(this,t,n))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](e)},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;r<t.length;++r)if(t[r]==e||"string"!=typeof t[r]&&t[r].name==e)return t.splice(r,1),!0},addOverlay:Qt(function(t,r){var n=t.token?t:e.getMode(this.options,t);if(n.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:n,modeSpec:t,opaque:r&&r.opaque}),this.state.modeGen++,rr(this)}),removeOverlay:Qt(function(e){for(var t=this.state.overlays,r=0;r<t.length;++r){var n=t[r].modeSpec;if(n==e||"string"==typeof e&&n.name==e)return t.splice(r,1),this.state.modeGen++,void rr(this)}}),indentLine:Qt(function(e,t,r){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),J(this.doc,e)&&sn(this,e,t,r)}),indentSelection:Qt(function(e){for(var t=this.doc.sel.ranges,r=-1,n=0;n<t.length;n++){var i=t[n];if(i.empty())i.head.line>r&&(sn(this,i.head.line,e,!0),r=i.head.line,n==this.doc.sel.primIndex&&an(this));else{var o=Math.max(r,i.from().line),a=i.to();r=Math.min(this.lastLine(),a.line-(a.ch?0:1))+1;for(var l=o;r>l;++l)sn(this,l,e)}}}),getTokenAt:function(e,t){var r=this.doc;e=Z(r,e);for(var n=xt(this,e.line,t),i=this.doc.mode,o=yi(r,e.line),a=new Oa(o.text,this.options.tabSize);a.pos<e.ch&&!a.eol();){a.start=a.pos;var l=Jn(i,a,n)}return{start:a.start,end:a.pos,string:a.current(),type:l||null,state:n}},getTokenTypeAt:function(e){e=Z(this.doc,e);var t=ri(this,yi(this.doc,e.line)),r=0,n=(t.length-1)/2,i=e.ch,o;if(0==i)o=t[2];else for(;;){var a=r+n>>1;if((a?t[2*a-1]:0)>=i)n=a;else{if(!(t[2*a+1]<i)){o=t[2*a+2];break}r=a+1}}var l=o?o.indexOf("cm-overlay "):-1;return 0>l?o:0==l?null:o.slice(0,l-1)},getModeAt:function(t){var r=this.doc.mode;return r.innerMode?e.innerMode(r,this.getTokenAt(t).state).mode:r},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var r=[];if(!Ca.hasOwnProperty(t))return Ca;var n=Ca[t],i=this.getModeAt(e);if("string"==typeof i[t])n[i[t]]&&r.push(n[i[t]]);else if(i[t])for(var o=0;o<i[t].length;o++){var a=n[i[t][o]];a&&r.push(a)}else i.helperType&&n[i.helperType]?r.push(n[i.helperType]):n[i.name]&&r.push(n[i.name]);for(var o=0;o<n._global.length;o++){var l=n._global[o];l.pred(i,this)&&-1==eo(r,l.val)&&r.push(l.val)}return r},getStateAfter:function(e,t){var r=this.doc;return e=X(r,null==e?r.first+r.size-1:e),xt(this,e+1,t)},cursorCoords:function(e,t){var r,n=this.doc.sel.primary();return r=null==e?n.head:"object"==typeof e?Z(this.doc,e):e?n.from():n.to(),Rt(this,r,t||"page")},charCoords:function(e,t){return Bt(this,Z(this.doc,e),t||"page")},coordsChar:function(e,t){return e=Ft(this,e,t||"page"),Gt(this,e.left,e.top)},lineAtHeight:function(e,t){return e=Ft(this,{top:e,left:0},t||"page").top,Ci(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t){var r=!1,n=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>n&&(e=n,r=!0);var i=yi(this.doc,e);return _t(this,i,{top:0,left:0},t||"page").top+(r?this.doc.height-Li(i):0)},defaultTextHeight:function(){return Ut(this.display)},defaultCharWidth:function(){return Kt(this.display)},setGutterMarker:Qt(function(e,t,r){return un(this,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});return n[t]=r,!r&&oo(n)&&(e.gutterMarkers=null),!0})}),clearGutter:Qt(function(e){var t=this,r=t.doc,n=r.first;r.iter(function(r){r.gutterMarkers&&r.gutterMarkers[e]&&(r.gutterMarkers[e]=null,nr(t,n,"gutter"),oo(r.gutterMarkers)&&(r.gutterMarkers=null)),++n})}),addLineClass:Qt(function(e,t,r){return un(this,e,"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"wrapClass";if(e[n]){if(new RegExp("(?:^|\\s)"+r+"(?:$|\\s)").test(e[n]))return!1;e[n]+=" "+r}else e[n]=r;return!0})}),removeLineClass:Qt(function(e,t,r){return un(this,e,"class",function(e){var n="text"==t?"textClass":"background"==t?"bgClass":"wrapClass",i=e[n];if(!i)return!1;if(null==r)e[n]=null;else{var o=i.match(new RegExp("(?:^|\\s+)"+r+"(?:$|\\s+)"));if(!o)return!1;var a=o.index+o[0].length;e[n]=i.slice(0,o.index)+(o.index&&a!=i.length?" ":"")+i.slice(a)||null}return!0})}),addLineWidget:Qt(function(e,t,r){return $n(this,e,t,r)}),removeLineWidget:function(e){e.clear()},lineInfo:function(e){if("number"==typeof e){if(!J(this.doc,e))return null;
4
  var t=e;if(e=yi(this.doc,e),!e)return null}else{var t=ki(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display;e=Rt(this,Z(this.doc,e));var a=e.bottom,l=e.left;if(t.style.position="absolute",o.sizer.appendChild(t),"over"==n)a=e.top;else if("above"==n||"near"==n){var s=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>s)&&e.top>t.offsetHeight?a=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=s&&(a=e.bottom),l+t.offsetWidth>u&&(l=u-t.offsetWidth)}t.style.top=a+"px",t.style.left=t.style.right="","right"==i?(l=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?l=0:"middle"==i&&(l=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=l+"px"),r&&rn(this,l,a,l+t.offsetWidth,a+t.offsetHeight)},triggerOnKeyDown:Qt(Er),triggerOnKeyPress:Qt(Pr),triggerOnKeyUp:Qt(Dr),execCommand:function(e){return Ma.hasOwnProperty(e)?Ma[e](this):void 0},findPosH:function(e,t,r,n){var i=1;0>t&&(i=-1,t=-t);for(var o=0,a=Z(this.doc,e);t>o&&(a=fn(this.doc,a,i,r,n),!a.hitSide);++o);return a},moveH:Qt(function(e,t){var r=this;r.extendSelectionsBy(function(n){return r.display.shift||r.doc.extend||n.empty()?fn(r.doc,n.head,e,t,r.options.rtlMoveVisually):0>e?n.from():n.to()},tl)}),deleteH:Qt(function(e,t){var r=this.doc.sel,n=this.doc;r.somethingSelected()?n.replaceSelection("",null,"+delete"):cn(this,function(r){var i=fn(n,r.head,e,t,!1);return 0>e?{from:i,to:r.head}:{from:r.head,to:i}})}),findPosV:function(e,t,r,n){var i=1,o=n;0>t&&(i=-1,t=-t);for(var a=0,l=Z(this.doc,e);t>a;++a){var s=Rt(this,l,"div");if(null==o?o=s.left:s.left=o,l=dn(this,s,i,r),l.hitSide)break}return l},moveV:Qt(function(e,t){var r=this,n=this.doc,i=[],o=!r.display.shift&&!n.extend&&n.sel.somethingSelected();if(n.extendSelectionsBy(function(a){if(o)return 0>e?a.from():a.to();var l=Rt(r,a.head,"div");null!=a.goalColumn&&(l.left=a.goalColumn),i.push(l.left);var s=dn(r,l,e,t);return"page"==t&&a==n.sel.primary()&&on(r,null,Bt(r,s,"div").top-l.top),s},tl),i.length)for(var a=0;a<n.sel.ranges.length;a++)n.sel.ranges[a].goalColumn=i[a]}),toggleOverwrite:function(e){(null==e||e!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?mo(this.display.cursorDiv,"CodeMirror-overwrite"):po(this.display.cursorDiv,"CodeMirror-overwrite"),$a(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return fo()==this.display.input},scrollTo:Qt(function(e,t){(null!=e||null!=t)&&ln(this),null!=e&&(this.curOp.scrollLeft=e),null!=t&&(this.curOp.scrollTop=t)}),getScrollInfo:function(){var e=this.display.scroller,t=Za;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-t,width:e.scrollWidth-t,clientHeight:e.clientHeight-t,clientWidth:e.clientWidth-t}},scrollIntoView:Qt(function(e,t){if(null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:ra(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line)ln(this),this.curOp.scrollToPos=e;else{var r=nn(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(r.scrollLeft,r.scrollTop)}}),setSize:Qt(function(e,t){function r(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e}null!=e&&(this.display.wrapper.style.width=r(e)),null!=t&&(this.display.wrapper.style.height=r(t)),this.options.lineWrapping&&Et(this),this.curOp.forceUpdate=!0,$a(this,"refresh",this)}),operation:function(e){return Xt(this,e)},refresh:Qt(function(){var e=this.display.cachedTextHeight;rr(this),this.curOp.forceUpdate=!0,It(this),this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop),f(this),(null==e||Math.abs(e-Ut(this.display))>.5)&&a(this),$a(this,"refresh",this)}),swapDoc:Qt(function(e){var t=this.doc;return t.cm=null,vi(this,e),It(this),dr(this),this.scrollTo(e.scrollLeft,e.scrollTop),Gi(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}},Yi(e);var ga=e.defaults={},va=e.optionHandlers={},ya=e.Init={toString:function(){return"CodeMirror.Init"}};pn("value","",function(e,t){e.setValue(t)},!0),pn("mode",null,function(e,t){e.doc.modeOption=t,r(e)},!0),pn("indentUnit",2,r,!0),pn("indentWithTabs",!1),pn("smartIndent",!0),pn("tabSize",4,function(e){n(e),It(e),rr(e)},!0),pn("specialChars",/[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\ufeff]/g,function(e,t){e.options.specialChars=new RegExp(t.source+(t.test(" ")?"":"| "),"g"),e.refresh()},!0),pn("specialCharPlaceholder",ai,function(e){e.refresh()},!0),pn("electricChars",!0),pn("rtlMoveVisually",!Xo),pn("wholeLineUpdateBefore",!0),pn("theme","default",function(e){s(e),u(e)},!0),pn("keyMap","default",l),pn("extraKeys",null),pn("lineWrapping",!1,i,!0),pn("gutters",[],function(e){p(e.options),u(e)},!0),pn("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?x(e.display)+"px":"0",e.refresh()},!0),pn("coverGutterNextToScrollbar",!1,g,!0),pn("lineNumbers",!1,function(e){p(e.options),u(e)},!0),pn("firstLineNumber",1,u,!0),pn("lineNumberFormatter",function(e){return e},u,!0),pn("showCursorWhenSelecting",!1,pt,!0),pn("resetSelectionOnContextMenu",!0),pn("readOnly",!1,function(e,t){"nocursor"==t?(Fr(e),e.display.input.blur(),e.display.disabled=!0):(e.display.disabled=!1,t||dr(e))}),pn("disableInput",!1,function(e,t){t||dr(e)},!0),pn("dragDrop",!0),pn("cursorBlinkRate",530),pn("cursorScrollMargin",0),pn("cursorHeight",1),pn("workTime",100),pn("workDelay",100),pn("flattenSpans",!0,n,!0),pn("addModeClass",!1,n,!0),pn("pollInterval",100),pn("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),pn("historyEventDelay",1250),pn("viewportMargin",10,function(e){e.refresh()},!0),pn("maxHighlightLength",1e4,n,!0),pn("moveInputWithCursor",!0,function(e,t){t||(e.display.inputDiv.style.top=e.display.inputDiv.style.left=0)}),pn("tabindex",null,function(e,t){e.display.input.tabIndex=t||""}),pn("autofocus",null);var ba=e.modes={},wa=e.mimeModes={};e.defineMode=function(t,r){if(e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2){r.dependencies=[];for(var n=2;n<arguments.length;++n)r.dependencies.push(arguments[n])}ba[t]=r},e.defineMIME=function(e,t){wa[e]=t},e.resolveMode=function(t){if("string"==typeof t&&wa.hasOwnProperty(t))t=wa[t];else if(t&&"string"==typeof t.name&&wa.hasOwnProperty(t.name)){var r=wa[t.name];"string"==typeof r&&(r={name:r}),t=ro(r,t),t.name=r.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,r){var r=e.resolveMode(r),n=ba[r.name];if(!n)return e.getMode(t,"text/plain");var i=n(t,r);if(xa.hasOwnProperty(r.name)){var o=xa[r.name];for(var a in o)o.hasOwnProperty(a)&&(i.hasOwnProperty(a)&&(i["_"+a]=i[a]),i[a]=o[a])}if(i.name=r.name,r.helperType&&(i.helperType=r.helperType),r.modeProps)for(var a in r.modeProps)i[a]=r.modeProps[a];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var xa=e.modeExtensions={};e.extendMode=function(e,t){var r=xa.hasOwnProperty(e)?xa[e]:xa[e]={};no(t,r)},e.defineExtension=function(t,r){e.prototype[t]=r},e.defineDocExtension=function(e,t){Ba.prototype[e]=t},e.defineOption=pn;var ka=[];e.defineInitHook=function(e){ka.push(e)};var Ca=e.helpers={};e.registerHelper=function(t,r,n){Ca.hasOwnProperty(t)||(Ca[t]=e[t]={_global:[]}),Ca[t][r]=n},e.registerGlobalHelper=function(t,r,n,i){e.registerHelper(t,r,i),Ca[t]._global.push({pred:n,val:i})};var La=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r},Sa=e.startState=function(e,t,r){return e.startState?e.startState(t,r):!0};e.innerMode=function(e,t){for(;e.innerMode;){var r=e.innerMode(t);if(!r||r.mode==e)break;t=r.state,e=r.mode}return r||{mode:e,state:t}};var Ma=e.commands={selectAll:function(e){e.setSelection(ra(e.firstLine(),0),ra(e.lastLine()),Ja)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Ja)},killLine:function(e){cn(e,function(t){if(t.empty()){var r=yi(e.doc,t.head.line).text.length;return t.head.ch==r&&t.head.line<e.lastLine()?{from:t.head,to:ra(t.head.line+1,0)}:{from:t.head,to:ra(t.head.line,r)}}return{from:t.from(),to:t.to()}})},deleteLine:function(e){cn(e,function(t){return{from:ra(t.from().line,0),to:Z(e.doc,ra(t.to().line+1,0))}})},delLineLeft:function(e){cn(e,function(e){return{from:ra(e.from().line,0),to:e.from()}})},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(ra(e.firstLine(),0))},goDocEnd:function(e){e.extendSelection(ra(e.lastLine()))},goLineStart:function(e){e.extendSelectionsBy(function(t){return So(e,t.head.line)},tl)},goLineStartSmart:function(e){e.extendSelectionsBy(function(t){var r=So(e,t.head.line),n=e.getLineHandle(r.line),i=Si(n);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),a=t.head.line==r.line&&t.head.ch<=o&&t.head.ch;return ra(r.line,a?0:o)}return r},tl)},goLineEnd:function(e){e.extendSelectionsBy(function(t){return Mo(e,t.head.line)},tl)},goLineRight:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:r},"div")},tl)},goLineLeft:function(e){e.extendSelectionsBy(function(t){var r=e.charCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:r},"div")},tl)},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){for(var t=[],r=e.listSelections(),n=e.options.tabSize,i=0;i<r.length;i++){var o=r[i].from(),a=rl(e.getLine(o.line),o.ch,n);t.push(new Array(n-a%n+1).join(" "))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){Xt(e,function(){for(var t=e.listSelections(),r=0;r<t.length;r++){var n=t[r].head,i=yi(e.doc,n.line).text;n.ch>0&&n.ch<i.length-1&&e.replaceRange(i.charAt(n.ch)+i.charAt(n.ch-1),ra(n.line,n.ch-1),ra(n.line,n.ch+1))}})},newlineAndIndent:function(e){Xt(e,function(){for(var t=e.listSelections().length,r=0;t>r;r++){var n=e.listSelections()[r];e.replaceRange("\n",n.anchor,n.head,"+input"),e.indentLine(n.from().line+1,null,!0),an(e)}})},toggleOverwrite:function(e){e.toggleOverwrite()}},Ta=e.keyMap={};Ta.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"},Ta.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Ta.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delLineLeft","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection",fallthrough:["basic","emacsy"]},Ta.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"},Ta["default"]=Yo?Ta.macDefault:Ta.pcDefault;var Aa=e.lookupKey=function(e,t,r){function n(t){t=mn(t);var i=t[e];if(i===!1)return"stop";if(null!=i&&r(i))return!0;if(t.nofallthrough)return"stop";var o=t.fallthrough;if(null==o)return!1;if("[object Array]"!=Object.prototype.toString.call(o))return n(o);for(var a=0;a<o.length;++a){var l=n(o[a]);if(l)return l}return!1}for(var i=0;i<t.length;++i){var o=n(t[i]);if(o)return"stop"!=o}},Na=e.isModifierKey=function(e){var t=gl[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t},Ha=e.keyName=function(e,t){if(jo&&34==e.keyCode&&e["char"])return!1;var r=gl[e.keyCode];return null==r||e.altGraphKey?!1:(e.altKey&&(r="Alt-"+r),(Qo?e.metaKey:e.ctrlKey)&&(r="Ctrl-"+r),(Qo?e.ctrlKey:e.metaKey)&&(r="Cmd-"+r),!t&&e.shiftKey&&(r="Shift-"+r),r)};e.fromTextArea=function(t,r){function n(){t.value=u.getValue()}if(r||(r={}),r.value=t.value,!r.tabindex&&t.tabindex&&(r.tabindex=t.tabindex),!r.placeholder&&t.placeholder&&(r.placeholder=t.placeholder),null==r.autofocus){var i=fo();r.autofocus=i==t||null!=t.getAttribute("autofocus")&&i==document.body}if(t.form&&(Ua(t.form,"submit",n),!r.leaveSubmitMethodAlone)){var o=t.form,a=o.submit;try{var l=o.submit=function(){n(),o.submit=a,o.submit(),o.submit=l}}catch(s){}}t.style.display="none";var u=e(function(e){t.parentNode.insertBefore(e,t.nextSibling)},r);return u.save=n,u.getTextArea=function(){return t},u.toTextArea=function(){n(),t.parentNode.removeChild(u.getWrapperElement()),t.style.display="",t.form&&(Ka(t.form,"submit",n),"function"==typeof t.form.submit&&(t.form.submit=a))},u};var Oa=e.StringStream=function(e,t){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0};Oa.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(e){var t=this.string.charAt(this.pos);if("string"==typeof e)var r=t==e;else var r=t&&(e.test?e.test(t):e(t));return r?(++this.pos,t):void 0},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=rl(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?rl(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return rl(this.string,null,this.tabSize)-(this.lineStart?rl(this.string,this.lineStart,this.tabSize):0)},match:function(e,t,r){if("string"!=typeof e){var n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var za=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e};Yi(za),za.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&$t(e),$i(this,"clear")){var r=this.find();r&&Gi(this,"clear",r.from,r.to)}for(var n=null,i=null,o=0;o<this.lines.length;++o){var a=this.lines[o],l=kn(a.markedSpans,this);e&&!this.collapsed?nr(e,ki(a),"text"):e&&(null!=l.to&&(i=ki(a)),null!=l.from&&(n=ki(a))),a.markedSpans=Cn(a.markedSpans,l),null==l.from&&this.collapsed&&!Gn(this.doc,a)&&e&&xi(a,Ut(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var o=0;o<this.lines.length;++o){var s=Bn(this.lines[o]),u=d(s);u>e.display.maxLineLength&&(e.display.maxLine=s,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=n&&e&&this.collapsed&&rr(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&ft(e.doc)),e&&Gi(e,"markerCleared",e,this),t&&Yt(e),this.parent&&this.parent.clear()}},za.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var r,n,i=0;i<this.lines.length;++i){var o=this.lines[i],a=kn(o.markedSpans,this);if(null!=a.from&&(r=ra(t?o:ki(o),a.from),-1==e))return r;if(null!=a.to&&(n=ra(t?o:ki(o),a.to),1==e))return n}return r&&{from:r,to:n}},za.prototype.changed=function(){var e=this.find(-1,!0),t=this,r=this.doc.cm;e&&r&&Xt(r,function(){var n=e.line,i=ki(e.line),o=Nt(r,i);if(o&&(Wt(o),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Gn(t.doc,n)&&null!=t.height){var a=t.height;t.height=null;var l=Kn(t)-a;l&&xi(n,n.height+l)}})},za.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&-1!=eo(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},za.prototype.detachLine=function(e){if(this.lines.splice(eo(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};var Wa=0,Ea=e.SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var r=0;r<e.length;++r)e[r].parent=this};Yi(Ea),Ea.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();Gi(this,"clear")}},Ea.prototype.find=function(e,t){return this.primary.find(e,t)};var Ia=e.LineWidget=function(e,t,r){if(r)for(var n in r)r.hasOwnProperty(n)&&(this[n]=r[n]);this.cm=e,this.node=t};Yi(Ia),Ia.prototype.clear=function(){var e=this.cm,t=this.line.widgets,r=this.line,n=ki(r);if(null!=n&&t){for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(r.widgets=null);var o=Kn(this);Xt(e,function(){Un(e,r,-o),nr(e,n,"widget"),xi(r,Math.max(0,r.height-o))})}},Ia.prototype.changed=function(){var e=this.height,t=this.cm,r=this.line;this.height=null;var n=Kn(this)-e;n&&Xt(t,function(){t.curOp.forceUpdate=!0,Un(t,r,n),xi(r,r.height+n)})};var Da=e.Line=function(e,t,r){this.text=e,zn(this,t),this.height=r?r(this):1};Yi(Da),Da.prototype.lineNo=function(){return ki(this)};var Pa={},_a={};pi.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var r=e,n=e+t;n>r;++r){var i=this.lines[r];this.height-=i.height,Xn(i),Gi(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,r){this.height+=r,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var n=0;n<t.length;++n)t[n].parent=this},iterN:function(e,t,r){for(var n=e+t;n>e;++e)if(r(this.lines[e]))return!0}},mi.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var r=0;r<this.children.length;++r){var n=this.children[r],i=n.chunkSize();if(i>e){var o=Math.min(t,i-e),a=n.height;if(n.removeInner(e,o),this.height-=a-n.height,i==o&&(this.children.splice(r--,1),n.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof pi))){var l=[];this.collapse(l),this.children=[new pi(l)],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,r){this.size+=t.length,this.height+=r;for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>=e){if(i.insertInner(e,t,r),i.lines&&i.lines.length>50){for(;i.lines.length>50;){var a=i.lines.splice(i.lines.length-25,25),l=new pi(a);i.height-=l.height,this.children.splice(n+1,0,l),l.parent=this}this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=e.children.splice(e.children.length-5,5),r=new mi(t);if(e.parent){e.size-=r.size,e.height-=r.height;var n=eo(e.parent.children,e);e.parent.children.splice(n+1,0,r)}else{var i=new mi(e.children);i.parent=e,e.children=[i,r],e=i}r.parent=e.parent}while(e.children.length>10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;n<this.children.length;++n){var i=this.children[n],o=i.chunkSize();if(o>e){var a=Math.min(t,o-e);if(i.iterN(e,a,r))return!0;if(0==(t-=a))break;e=0}else e-=o}}};var Fa=0,Ba=e.Doc=function(e,t,r){if(!(this instanceof Ba))return new Ba(e,t,r);null==r&&(r=0),mi.call(this,[new pi([new Da("",null)])]),this.first=r,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=r;var n=ra(r,0);this.sel=Y(n),this.history=new Mi(null),this.id=++Fa,this.modeOption=t,"string"==typeof e&&(e=hl(e)),hi(this,{from:n,to:n,text:e}),st(this,Y(n),Ja)};Ba.prototype=ro(mi.prototype,{constructor:Ba,iter:function(e,t,r){r?this.iterN(e-this.first,t-e,r):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var r=0,n=0;n<t.length;++n)r+=t[n].height;this.insertInner(e-this.first,t,r)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=wi(this,this.first,this.first+this.size);return e===!1?t:t.join(e||"\n")},setValue:Jt(function(e){var t=ra(this.first,0),r=this.first+this.size-1;Kr(this,{from:t,to:ra(r,yi(this,r).text.length),text:hl(e),origin:"setValue"},!0),st(this,Y(t))}),replaceRange:function(e,t,r,n){t=Z(this,t),r=r?Z(this,r):t,Jr(this,e,t,r,n)},getRange:function(e,t,r){var n=bi(this,Z(this,e),Z(this,t));return r===!1?n:n.join(r||"\n")},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){return J(this,e)?yi(this,e):void 0},getLineNumber:function(e){return ki(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=yi(this,e)),Bn(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return Z(this,e)},getCursor:function(e){var t=this.sel.primary(),r;return r=null==e||"head"==e?t.head:"anchor"==e?t.anchor:"end"==e||"to"==e||e===!1?t.to():t.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:Jt(function(e,t,r){ot(this,Z(this,"number"==typeof e?ra(e,t||0):e),null,r)}),setSelection:Jt(function(e,t,r){ot(this,Z(this,e),Z(this,t||e),r)}),extendSelection:Jt(function(e,t,r){rt(this,Z(this,e),t&&Z(this,t),r)}),extendSelections:Jt(function(e,t){nt(this,et(this,e,t))}),extendSelectionsBy:Jt(function(e,t){nt(this,to(this.sel.ranges,e),t)}),setSelections:Jt(function(e,t,r){if(e.length){for(var n=0,i=[];n<e.length;n++)i[n]=new K(Z(this,e[n].anchor),Z(this,e[n].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),st(this,$(i,t),r)}}),addSelection:Jt(function(e,t,r){var n=this.sel.ranges.slice(0);n.push(new K(Z(this,e),Z(this,t||e))),st(this,$(n,n.length-1),r)}),getSelection:function(e){for(var t=this.sel.ranges,r,n=0;n<t.length;n++){var i=bi(this,t[n].from(),t[n].to());r=r?r.concat(i):i}return e===!1?r:r.join(e||"\n")},getSelections:function(e){for(var t=[],r=this.sel.ranges,n=0;n<r.length;n++){var i=bi(this,r[n].from(),r[n].to());e!==!1&&(i=i.join(e||"\n")),t[n]=i}return t},replaceSelection:function(e,t,r){for(var n=[],i=0;i<this.sel.ranges.length;i++)n[i]=e;this.replaceSelections(n,t,r||"+input")},replaceSelections:Jt(function(e,t,r){for(var n=[],i=this.sel,o=0;o<i.ranges.length;o++){var a=i.ranges[o];n[o]={from:a.from(),to:a.to(),text:hl(e[o]),origin:r}}for(var l=t&&"end"!=t&&qr(this,n,t),o=n.length-1;o>=0;o--)Kr(this,n[o]);l?lt(this,l):this.cm&&an(this.cm)}),undo:Jt(function(){Yr(this,"undo")}),redo:Jt(function(){Yr(this,"redo")}),undoSelection:Jt(function(){Yr(this,"undo",!0)}),redoSelection:Jt(function(){Yr(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,r=0,n=0;n<e.done.length;n++)e.done[n].ranges||++t;for(var n=0;n<e.undone.length;n++)e.undone[n].ranges||++r;return{undo:t,redo:r}},clearHistory:function(){this.history=new Mi(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:Pi(this.history.done),undone:Pi(this.history.undone)}},setHistory:function(e){var t=this.history=new Mi(this.history.maxGeneration);t.done=Pi(e.done.slice(0),null,!0),t.undone=Pi(e.undone.slice(0),null,!0)},markText:function(e,t,r){return gn(this,Z(this,e),Z(this,t),r,"range")},setBookmark:function(e,t){var r={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared};return e=Z(this,e),gn(this,e,e,r,"bookmark")},findMarksAt:function(e){e=Z(this,e);var t=[],r=yi(this,e.line).markedSpans;if(r)for(var n=0;n<r.length;++n){var i=r[n];(null==i.from||i.from<=e.ch)&&(null==i.to||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=Z(this,e),t=Z(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var a=o.markedSpans;if(a)for(var l=0;l<a.length;l++){var s=a[l];i==e.line&&e.ch>s.to||null==s.from&&i!=e.line||i==t.line&&s.from>t.ch||r&&!r(s.marker)||n.push(s.marker.parent||s.marker)}++i}),n},getAllMarks:function(){var e=[];return this.iter(function(t){var r=t.markedSpans;if(r)for(var n=0;n<r.length;++n)null!=r[n].from&&e.push(r[n].marker)}),e},posFromIndex:function(e){var t,r=this.first;return this.iter(function(n){var i=n.text.length+1;return i>e?(t=e,!0):(e-=i,void++r)}),Z(this,ra(r,t))},indexFromPos:function(e){e=Z(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 Ba(wi(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,r=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<r&&(r=e.to);var n=new Ba(wi(this,t,r),e.mode||this.modeOption,t);return e.sharedHist&&(n.history=this.history),(this.linked||(this.linked=[])).push({doc:n,sharedHist:e.sharedHist}),n.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],bn(n,yn(this)),n},unlinkDoc:function(t){if(t instanceof e&&(t=t.doc),this.linked)for(var r=0;r<this.linked.length;++r){var n=this.linked[r];if(n.doc==t){this.linked.splice(r,1),t.unlinkDoc(this),wn(yn(this));break}}if(t.history==this.history){var i=[t.id];gi(t,function(e){i.push(e.id)},!0),t.history=new Mi(null),t.history.done=Pi(this.history.done,i),t.history.undone=Pi(this.history.undone,i)}},iterLinkedDocs:function(e){gi(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),Ba.prototype.eachLine=Ba.prototype.iter;var Ra="iter insert remove copy getEditor".split(" ");for(var ja in Ba.prototype)Ba.prototype.hasOwnProperty(ja)&&eo(Ra,ja)<0&&(e.prototype[ja]=function(e){return function(){return e.apply(this.doc,arguments)}}(Ba.prototype[ja]));Yi(Ba);var Va=e.e_preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},Ga=e.e_stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},qa=e.e_stop=function(e){Va(e),Ga(e)},Ua=e.on=function(e,t,r){if(e.addEventListener)e.addEventListener(t,r,!1);else if(e.attachEvent)e.attachEvent("on"+t,r);else{var n=e._handlers||(e._handlers={}),i=n[t]||(n[t]=[]);i.push(r)}},Ka=e.off=function(e,t,r){if(e.removeEventListener)e.removeEventListener(t,r,!1);else if(e.detachEvent)e.detachEvent("on"+t,r);else{var n=e._handlers&&e._handlers[t];if(!n)return;for(var i=0;i<n.length;++i)if(n[i]==r){n.splice(i,1);break}}},$a=e.signal=function(e,t){var r=e._handlers&&e._handlers[t];if(r)for(var n=Array.prototype.slice.call(arguments,2),i=0;i<r.length;++i)r[i].apply(null,n)},Ya,Xa=0,Za=30,Qa=e.Pass={toString:function(){return"CodeMirror.Pass"}},Ja={scroll:!1},el={origin:"*mouse"},tl={origin:"+move"};Xi.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var rl=e.countColumn=function(e,t,r,n,i){null==t&&(t=e.search(/[^\s\u00a0]/),-1==t&&(t=e.length));for(var o=n||0,a=i||0;;){var l=e.indexOf(" ",o);if(0>l||l>=t)return a+(t-o);a+=l-o,a+=r-a%r,o=l+1}},nl=[""],il=function(e){e.select()};Ko?il=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:_o&&(il=function(e){try{e.select()}catch(t){}}),[].indexOf&&(eo=function(e,t){return e.indexOf(t)}),[].map&&(to=function(e,t){return e.map(t)});var ol=/[\u00df\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,al=e.isWordChar=function(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||ol.test(e))},ll=/[\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]/,sl;
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: nixdns
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DC9K7UMY8AGUJ
4
  Tags: html editor, syntax highlighter, plugin editor, syntax, highlighting, syntax highlighting, text editor, editor, text editor syntax, editor, editor syntax
5
  Requires at least: 3.3
6
- Tested up to: 3.9.1
7
- Stable tag: 1.6.0
8
 
9
  Add syntax highlighting to the HTML editor.
10
 
@@ -31,6 +31,9 @@ If you like the plugin, don’t hesitate to support me and leave a review :)
31
 
32
  == Changelog ==
33
 
 
 
 
34
  = 1.6.0 =
35
  * You can change font size in the editor
36
  * Fixed issue with restoring cursor position
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DC9K7UMY8AGUJ
4
  Tags: html editor, syntax highlighter, plugin editor, syntax, highlighting, syntax highlighting, text editor, editor, text editor syntax, editor, editor syntax
5
  Requires at least: 3.3
6
+ Tested up to: 4.0
7
+ Stable tag: 1.6.1
8
 
9
  Add syntax highlighting to the HTML editor.
10
 
31
 
32
  == Changelog ==
33
 
34
+ = 1.6.1 =
35
+ * Compatibility with WP 4.0
36
+
37
  = 1.6.0 =
38
  * You can change font size in the editor
39
  * Fixed issue with restoring cursor position