From cc1f32067f78a6b3360db979c43510c3ed733677 Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Tue, 1 Dec 2020 19:11:40 +0100 Subject: [PATCH] Update CodeMirror to 5.58.3 - fix vim-mode cursor invisible (#5172) * Update codemirror to v5.58.3 * Update jump-to-line.js * Update search.js --- .../files/addon/search/jump-to-line.js | 2 +- .../codemirror-search-replace/files/addon/search/search.js | 2 +- plugins/tiddlywiki/codemirror/files/codemirror.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/jump-to-line.js b/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/jump-to-line.js index c4285a645..05172fa03 100644 --- a/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/jump-to-line.js +++ b/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/jump-to-line.js @@ -1,3 +1,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE -!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../dialog/dialog"],e):e(CodeMirror)}(function(e){"use strict";function u(e,o){var r=Number(o);return/^[-+]/.test(o)?e.getCursor().line+r:r-1}e.commands.jumpToLine=function(t){var e,o,r,s,i,n,l=t.getCursor();o=(n=e=t).phrase("Jump to line:")+' '+n.phrase("(Use line:column or scroll% syntax)")+"",r=t.phrase("Jump to line:"),s=l.line+1+":"+l.ch,i=function(e){var o,r;e&&((o=/^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(e))?t.setCursor(u(t,o[1]),Number(o[2])):(o=/^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(e))?(r=Math.round(t.lineCount()*Number(o[1])/100),/^[-+]/.test(o[1])&&(r=l.line+r+1),t.setCursor(r-1,l.ch)):(o=/^\s*\:?\s*([\+\-]?\d+)\s*/.exec(e))&&t.setCursor(u(t,o[1]),l.ch))},e.openDialog?e.openDialog(o,i,{value:s,selectValueOnOpen:!0}):i(prompt(r,s))},e.keyMap.default["Alt-G"]="jumpToLine"}); +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../dialog/dialog"],e):e(CodeMirror)}(function(e){"use strict";function u(e,o){var r=Number(o);return/^[-+]/.test(o)?e.getCursor().line+r:r-1}e.defineOption("search",{bottom:!1}),e.commands.jumpToLine=function(t){var e,o,r,s,i,n,l=t.getCursor();o=(n=e=t).phrase("Jump to line:")+' '+n.phrase("(Use line:column or scroll% syntax)")+"",r=t.phrase("Jump to line:"),s=l.line+1+":"+l.ch,i=function(e){var o,r;e&&((o=/^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(e))?t.setCursor(u(t,o[1]),Number(o[2])):(o=/^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(e))?(r=Math.round(t.lineCount()*Number(o[1])/100),/^[-+]/.test(o[1])&&(r=l.line+r+1),t.setCursor(r-1,l.ch)):(o=/^\s*\:?\s*([\+\-]?\d+)\s*/.exec(e))&&t.setCursor(u(t,o[1]),l.ch))},e.openDialog?e.openDialog(o,i,{value:s,selectValueOnOpen:!0,bottom:e.options.search.bottom}):i(prompt(r,s))},e.keyMap.default["Alt-G"]="jumpToLine"}); diff --git a/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/search.js b/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/search.js index 7efd7994a..134d0f307 100644 --- a/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/search.js +++ b/plugins/tiddlywiki/codemirror-search-replace/files/addon/search/search.js @@ -1,3 +1,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE -!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],e):e(CodeMirror)}(function(d){"use strict";function n(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}function y(e){return e.state.search||(e.state.search=new n)}function a(e){return"string"==typeof e&&e==e.toLowerCase()}function m(e,n,o){return e.getSearchCursor(n,o,{caseFold:a(n),multiline:!0})}function h(e,n,o,r,t){e.openDialog?e.openDialog(n,t,{value:r,selectValueOnOpen:!0}):t(prompt(o,r))}function r(e){return e.replace(/\\([nrt\\])/g,function(e,n){return"n"==n?"\n":"r"==n?"\r":"t"==n?"\t":"\\"==n?"\\":e})}function s(e){var n=e.match(/^\/(.*)\/([a-z]*)$/);if(n)try{e=new RegExp(n[1],-1==n[2].indexOf("i")?"":"i")}catch(e){}else e=r(e);return("string"==typeof e?""==e:e.test(""))&&(e=/x^/),e}function g(e,n,o){var r,t;n.queryText=o,n.query=s(o),e.removeOverlay(n.overlay,a(n.query)),n.overlay=(r=n.query,t=a(n.query),"string"==typeof r?r=new RegExp(r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),t?"gi":"g"):r.global||(r=new RegExp(r.source,r.ignoreCase?"gi":"g")),{token:function(e){r.lastIndex=e.pos;var n=r.exec(e.string);if(n&&n.index==e.pos)return e.pos+=n[0].length||1,"searching";n?e.pos=n.index:e.skipToEnd()}}),e.addOverlay(n.overlay),e.showMatchesOnScrollbar&&(n.annotate&&(n.annotate.clear(),n.annotate=null),n.annotate=e.showMatchesOnScrollbar(n.query,a(n.query)))}function o(a,n,e,o){var r=y(a);if(r.query)return x(a,n);var t,s,i,c,l,u,p,f=a.getSelection()||r.lastQuery;f instanceof RegExp&&"x^"==f.source&&(f=null),e&&a.openDialog?(t=null,s=function(e,n){d.e_stop(n),e&&(e!=r.queryText&&(g(a,r,e),r.posFrom=r.posTo=a.getCursor()),t&&(t.style.opacity=1),x(a,n.shiftKey,function(e,n){var o;n.line<3&&document.querySelector&&(o=a.display.wrapper.querySelector(".CodeMirror-dialog"))&&o.getBoundingClientRect().bottom-4>a.cursorCoords(n,"window").top&&((t=o).style.opacity=.4)}))},c=C(i=a),l=f,u=s,p=function(e,n){var o=d.keyName(e),r=a.getOption("extraKeys"),t=r&&r[o]||d.keyMap[a.getOption("keyMap")][o];"findNext"==t||"findPrev"==t||"findPersistentNext"==t||"findPersistentPrev"==t?(d.e_stop(e),g(a,y(a),n),a.execCommand(t)):"find"!=t&&"findPersistent"!=t||(d.e_stop(e),s(n,e))},i.openDialog(c,u,{value:l,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){v(i)},onKeyDown:p}),o&&f&&(g(a,r,f),x(a,n))):h(a,C(a),"Search for:",f,function(e){e&&!r.query&&a.operation(function(){g(a,r,e),r.posFrom=r.posTo=a.getCursor(),x(a,n)})})}function x(o,r,t){o.operation(function(){var e=y(o),n=m(o,e.query,r?e.posFrom:e.posTo);(n.find(r)||(n=m(o,e.query,r?d.Pos(o.lastLine()):d.Pos(o.firstLine(),0))).find(r))&&(o.setSelection(n.from(),n.to()),o.scrollIntoView({from:n.from(),to:n.to()},20),e.posFrom=n.from(),e.posTo=n.to(),t&&t(n.from(),n.to()))})}function v(n){n.operation(function(){var e=y(n);e.lastQuery=e.query,e.query&&(e.query=e.queryText=null,n.removeOverlay(e.overlay),e.annotate&&(e.annotate.clear(),e.annotate=null))})}function C(e){return''+e.phrase("Search:")+' '+e.phrase("(Use /re/ syntax for regexp search)")+""}function q(n,r,t){n.operation(function(){for(var o,e=m(n,r);e.findNext();){"string"!=typeof r?(o=n.getRange(e.from(),e.to()).match(r),e.replace(t.replace(/\$(\d)/g,function(e,n){return o[n]}))):e.replace(t)}})}function t(f,e){var n,o;f.getOption("readOnly")||(n=f.getSelection()||y(f).lastQuery,o=''+(e?f.phrase("Replace all:"):f.phrase("Replace:"))+"",h(f,o+(' '+f.phrase("(Use /re/ syntax for regexp search)")+""),o,n,function(p){p&&(p=s(p),h(f,''+f.phrase("With:")+' ',f.phrase("Replace with:"),"",function(i){var c,l,u;i=r(i),e?q(f,p,i):(v(f),c=m(f,p,f.getCursor("from")),l=function(){var e,n,o,r,t,a,s=c.from();!(e=c.findNext())&&(c=m(f,p),!(e=c.findNext())||s&&c.from().line==s.line&&c.from().ch==s.ch)||(f.setSelection(c.from(),c.to()),f.scrollIntoView({from:c.from(),to:c.to()}),o=''+(a=n=f).phrase("Replace?")+" ",r=f.phrase("Replace?"),t=[function(){u(e)},l,function(){q(f,p,i)}],n.openConfirm?n.openConfirm(o,t):confirm(r)&&t[0]())},u=function(o){c.replace("string"==typeof p?i:i.replace(/\$(\d)/g,function(e,n){return o[n]})),l()},l())}))}))}d.commands.find=function(e){v(e),o(e)},d.commands.findPersistent=function(e){v(e),o(e,!1,!0)},d.commands.findPersistentNext=function(e){o(e,!1,!0,!0)},d.commands.findPersistentPrev=function(e){o(e,!0,!0,!0)},d.commands.findNext=o,d.commands.findPrev=function(e){o(e,!0)},d.commands.clearSearch=v,d.commands.replace=t,d.commands.replaceAll=function(e){t(e,!0)}}); +!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],e):e(CodeMirror)}(function(d){"use strict";function o(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}function m(e){return e.state.search||(e.state.search=new o)}function a(e){return"string"==typeof e&&e==e.toLowerCase()}function y(e,o,n){return e.getSearchCursor(o,n,{caseFold:a(o),multiline:!0})}function h(e,o,n,r,t){e.openDialog?e.openDialog(o,t,{value:r,selectValueOnOpen:!0,bottom:e.options.search.bottom}):t(prompt(n,r))}function r(e){return e.replace(/\\([nrt\\])/g,function(e,o){return"n"==o?"\n":"r"==o?"\r":"t"==o?"\t":"\\"==o?"\\":e})}function s(e){var o=e.match(/^\/(.*)\/([a-z]*)$/);if(o)try{e=new RegExp(o[1],-1==o[2].indexOf("i")?"":"i")}catch(e){}else e=r(e);return("string"==typeof e?""==e:e.test(""))&&(e=/x^/),e}function g(e,o,n){var r,t;o.queryText=n,o.query=s(n),e.removeOverlay(o.overlay,a(o.query)),o.overlay=(r=o.query,t=a(o.query),"string"==typeof r?r=new RegExp(r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),t?"gi":"g"):r.global||(r=new RegExp(r.source,r.ignoreCase?"gi":"g")),{token:function(e){r.lastIndex=e.pos;var o=r.exec(e.string);if(o&&o.index==e.pos)return e.pos+=o[0].length||1,"searching";o?e.pos=o.index:e.skipToEnd()}}),e.addOverlay(o.overlay),e.showMatchesOnScrollbar&&(o.annotate&&(o.annotate.clear(),o.annotate=null),o.annotate=e.showMatchesOnScrollbar(o.query,a(o.query)))}function n(a,o,e,n){var r=m(a);if(r.query)return x(a,o);var t,s,i,c,l,u,p,f=a.getSelection()||r.lastQuery;f instanceof RegExp&&"x^"==f.source&&(f=null),e&&a.openDialog?(t=null,s=function(e,o){d.e_stop(o),e&&(e!=r.queryText&&(g(a,r,e),r.posFrom=r.posTo=a.getCursor()),t&&(t.style.opacity=1),x(a,o.shiftKey,function(e,o){var n;o.line<3&&document.querySelector&&(n=a.display.wrapper.querySelector(".CodeMirror-dialog"))&&n.getBoundingClientRect().bottom-4>a.cursorCoords(o,"window").top&&((t=n).style.opacity=.4)}))},c=b(i=a),l=f,u=s,p=function(e,o){var n=d.keyName(e),r=a.getOption("extraKeys"),t=r&&r[n]||d.keyMap[a.getOption("keyMap")][n];"findNext"==t||"findPrev"==t||"findPersistentNext"==t||"findPersistentPrev"==t?(d.e_stop(e),g(a,m(a),o),a.execCommand(t)):"find"!=t&&"findPersistent"!=t||(d.e_stop(e),s(o,e))},i.openDialog(c,u,{value:l,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){v(i)},onKeyDown:p,bottom:i.options.search.bottom}),n&&f&&(g(a,r,f),x(a,o))):h(a,b(a),"Search for:",f,function(e){e&&!r.query&&a.operation(function(){g(a,r,e),r.posFrom=r.posTo=a.getCursor(),x(a,o)})})}function x(n,r,t){n.operation(function(){var e=m(n),o=y(n,e.query,r?e.posFrom:e.posTo);(o.find(r)||(o=y(n,e.query,r?d.Pos(n.lastLine()):d.Pos(n.firstLine(),0))).find(r))&&(n.setSelection(o.from(),o.to()),n.scrollIntoView({from:o.from(),to:o.to()},20),e.posFrom=o.from(),e.posTo=o.to(),t&&t(o.from(),o.to()))})}function v(o){o.operation(function(){var e=m(o);e.lastQuery=e.query,e.query&&(e.query=e.queryText=null,o.removeOverlay(e.overlay),e.annotate&&(e.annotate.clear(),e.annotate=null))})}function b(e){return''+e.phrase("Search:")+' '+e.phrase("(Use /re/ syntax for regexp search)")+""}function C(o,r,t){o.operation(function(){for(var n,e=y(o,r);e.findNext();){"string"!=typeof r?(n=o.getRange(e.from(),e.to()).match(r),e.replace(t.replace(/\$(\d)/g,function(e,o){return n[o]}))):e.replace(t)}})}function t(f,e){var o,n;f.getOption("readOnly")||(o=f.getSelection()||m(f).lastQuery,n=''+(e?f.phrase("Replace all:"):f.phrase("Replace:"))+"",h(f,n+(' '+f.phrase("(Use /re/ syntax for regexp search)")+""),n,o,function(p){p&&(p=s(p),h(f,''+f.phrase("With:")+' ',f.phrase("Replace with:"),"",function(i){var c,l,u;i=r(i),e?C(f,p,i):(v(f),c=y(f,p,f.getCursor("from")),l=function(){var e,o,n,r,t,a,s=c.from();!(e=c.findNext())&&(c=y(f,p),!(e=c.findNext())||s&&c.from().line==s.line&&c.from().ch==s.ch)||(f.setSelection(c.from(),c.to()),f.scrollIntoView({from:c.from(),to:c.to()}),n=''+(a=o=f).phrase("Replace?")+" ",r=f.phrase("Replace?"),t=[function(){u(e)},l,function(){C(f,p,i)}],o.openConfirm?o.openConfirm(n,t):confirm(r)&&t[0]())},u=function(n){c.replace("string"==typeof p?i:i.replace(/\$(\d)/g,function(e,o){return n[o]})),l()},l())}))}))}d.defineOption("search",{bottom:!1}),d.commands.find=function(e){v(e),n(e)},d.commands.findPersistent=function(e){v(e),n(e,!1,!0)},d.commands.findPersistentNext=function(e){n(e,!1,!0,!0)},d.commands.findPersistentPrev=function(e){n(e,!0,!0,!0)},d.commands.findNext=n,d.commands.findPrev=function(e){n(e,!0)},d.commands.clearSearch=v,d.commands.replace=t,d.commands.replaceAll=function(e){t(e,!0)}}); diff --git a/plugins/tiddlywiki/codemirror/files/codemirror.js b/plugins/tiddlywiki/codemirror/files/codemirror.js index 231e8a0da..0c80808ae 100755 --- a/plugins/tiddlywiki/codemirror/files/codemirror.js +++ b/plugins/tiddlywiki/codemirror/files/codemirror.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).CodeMirror=t()}(this,function(){"use strict";var e=navigator.userAgent,t=navigator.platform,g=/gecko\/\d/i.test(e),n=/MSIE \d/.test(e),r=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e),i=/Edge\/(\d+)/.exec(e),x=n||r||i,C=x&&(n?document.documentMode||6:+(i||r)[1]),v=!i&&/WebKit\//.test(e),o=v&&/Qt\/\d+\.\d+/.test(e),l=!i&&/Chrome\//.test(e),m=/Opera\//.test(e),c=/Apple Computer/.test(navigator.vendor),s=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e),u=/PhantomJS/.test(e),a=!i&&/AppleWebKit/.test(e)&&/Mobile\/\w+/.test(e),h=/Android/.test(e),d=a||h||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),y=a||/Mac/.test(t),f=/\bCrOS\b/.test(e),p=/win/i.test(t),b=m&&e.match(/Version\/(\d*\.\d*)/);(b=b&&Number(b[1]))&&15<=b&&(v=!(m=!1));var w=y&&(o||m&&(null==b||b<12.11)),S=g||x&&9<=C;function L(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var k,T=function(e,t){var n,r=e.className,i=L(t).exec(r);i&&(n=r.slice(i.index+i[0].length),e.className=r.slice(0,i.index)+(n?i[1]+n:""))};function M(e){for(var t=e.childNodes.length;0t)return i;o.to==t&&(o.from!=o.to&&"before"==n?r=i:se=i),o.from==t&&(o.from!=o.to&&"before"!=n?r=i:se=i)}return null!=r?r:se}var ue,ce,he,de,fe,pe,ge,me=(ue="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",ce="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",he=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,de=/[stwN]/,fe=/[LRr]/,pe=/[Lb1n]/,ge=/[1n]/,function(e,t){var n="ltr"==t?"L":"R";if(0==e.length||"ltr"==t&&!he.test(e))return!1;for(var r,i=e.length,o=[],l=0;l=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],o=i.chunkSize();if(t=e.first&&to?lt(o,Qe(e,o).text.length):(r=Qe(e,(n=t).line).text.length,null==(i=n.ch)||r=this.string.length},Ze.prototype.sol=function(){return this.pos==this.lineStart},Ze.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Ze.prototype.next=function(){if(this.post},Ze.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Ze.prototype.skipToEnd=function(){this.pos=this.string.length},Ze.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(-1e.options.maxHighlightLength&&_e(e.doc.mode,r.state),o=vt(e,t,r),i&&(r.state=i),t.stateAfter=r.save(!i),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))),t.styles}function bt(n,r,e){var t=n.doc,i=n.display;if(!t.mode.startState)return new mt(t,!0,r);var o=function(e,t,n){for(var r,i,o=e.doc,l=n?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;lt.first&&Qe(t,o-1).stateAfter,s=l?mt.fromSaved(t,l,o):new mt(t,qe(t.mode),o);return t.iter(o,r,function(e){wt(n,e.text,s);var t=s.line;e.stateAfter=t==r-1||t%5==0||t>=i.viewFrom&&tt.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}mt.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},mt.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},mt.prototype.nextLine=function(){this.line++,0e.options.maxHighlightLength?(s=!1,l&&wt(e,t,r,c.pos),c.pos=t.length,null):kt(Ct(n,c,r.state,h),o);if(!h||(d=h[0].name)&&(f="m-"+(f?d+" "+f:d)),!s||u!=f){for(;a=t:l.to>t),(r=r||[]).push(new At(s,l.from,o?null:l.to)))}return r}(n,i,l),a=function(e,t,n){var r;if(e)for(var i=0;i=t:l.to>t))&&(l.from!=t||"bookmark"!=s.type||n&&!l.marker.insertLeft)||(o=null==l.from||(s.inclusiveLeft?l.from<=t:l.frome.lastLine())return t;var n,r=Qe(e,t);if(!jt(e,r))return t;for(;n=Bt(r);)r=n.find(1,!0).line;return nt(r)+1}function jt(e,t){var n=Nt&&t.markedSpans;if(n)for(var r=void 0,i=0;in.maxLineLength&&(n.maxLineLength=t,n.maxLine=e)})}var $t=function(e,t,n){this.text=e,Ft(this,t),this.height=n?n(this):1};$t.prototype.lineNo=function(){return nt(this)},Me($t);var qt={},Zt={};function Qt(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?Zt:qt;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Jt(e,t){var n=A("span",null,null,v?"padding-right: .1px":null),r={pre:A("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var i,o=0;o<=(t.rest?t.rest.length:0);o++){var l=o?t.rest[o-1]:t.line,s=void 0;r.pos=0,r.addToken=tn,function(e){if(null!=Pe)return Pe;var t=N(e,document.createTextNode("AخA")),n=k(t,0,1).getBoundingClientRect(),r=k(t,1,2).getBoundingClientRect();return M(e),n&&n.left!=n.right&&(Pe=r.right-n.right<3)}(e.display.measure)&&(s=ye(l,e.doc.direction))&&(r.addToken=function(h,d){return function(e,t,n,r,i,o,l){n=n?n+" cm-force-border":"cm-force-border";for(var s=e.pos,a=s+t.length;;){for(var u=void 0,c=0;cs&&u.from<=s);c++);if(u.to>=a)return h(e,t,n,r,i,o,l);h(e,t.slice(0,u.to-s),n,r,null,o,l),r=null,t=t.slice(u.to-s),s=u.to}}}(r.addToken,s)),r.map=[],function(e,t,n){var r=e.markedSpans,i=e.text,o=0;if(!r){for(var l=1;lg||S.collapsed&&C.to==g&&C.from==g)){if(null!=C.to&&C.to!=g&&y>C.to&&(y=C.to,c=""),S.className&&(u+=" "+S.className),S.css&&(a=(a?a+";":"")+S.css),S.startStyle&&C.from==g&&(h+=" "+S.startStyle),S.endStyle&&C.to==y&&(w=w||[]).push(S.endStyle,C.to),S.title&&((f=f||{}).title=S.title),S.attributes)for(var L in S.attributes)(f=f||{})[L]=S.attributes[L];S.collapsed&&(!d||It(d.marker,S)<0)&&(d=C)}else C.from>g&&y>C.from&&(y=C.from)}if(w)for(var k=0;kn)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Mn(e,t,n,r){return On(e,An(e,t),n,r)}function Nn(e,t){if(t>=e.display.viewFrom&&t=n.lineN&&tt)&&(i=(o=a-s)-1,a<=t&&(l="right")),null!=i){if(r=e[u+2],s==a&&n==(r.insertLeft?"left":"right")&&(l=n),"left"==n&&0==i)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)r=e[2+(u-=3)],l="left";if("right"==n&&i==a-s)for(;u=o.text.length?(t=o.text.length,n="before"):t<=0&&(t=0,n="after"),!u)return a("before"==n?t-1:t,"before"==n);function c(e,t,n){return a(n?e-1:e,1==u[t].level!=n)}var h=ae(u,t,n),d=se,f=c(t,h,"before"==n);return null!=d&&(f.other=c(t,d,"before"!=n)),f}function Kn(e,t){var n=0;t=ft(e.doc,t),e.options.lineWrapping||(n=Zn(e.display)*t.ch);var r=Qe(e.doc,t.line),i=Xt(r)+wn(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function jn(e,t,n,r,i){var o=lt(e,t,n);return o.xRel=i,r&&(o.outside=r),o}function Xn(e,t,n){var r=e.doc;if((n+=e.display.viewOffset)<0)return jn(r.first,0,null,-1,-1);var i=rt(r,n),o=r.first+r.size-1;if(o=u||m.to<=a||(f=1!=m.level,p=On(e,r,f?Math.min(u,m.to)-1:Math.max(a,m.from)).right,g=pu&&(c={from:c.from,to:u,level:c.level});return c}:function(r,i,o,l,s,a,u){var e=le(function(e){var t=s[e],n=1!=t.level;return $n(Vn(r,lt(o,n?t.to:t.from,n?"before":"after"),"line",i,l),a,u,!0)},0,s.length-1),t=s[e];{var n,c;0u&&(t=s[e-1]))}return t})(n,e,t,o,c,r,i),u=1!=h.level,s=u?h.from:h.to-1,a=u?h.to:h.from-1)}var d,f,p=null,g=null,m=le(function(e){var t=On(n,o,e);return t.top+=l,t.bottom+=l,$n(t,r,i,!1)&&(t.top<=i&&t.left<=r&&(p=e,g=t),1)},s,a),v=!1;{var y,b,w;g?(y=r-g.left=w.bottom?1:0)}return m=oe(e.text,m,1),jn(t,m,f,v,r-d)}(e,l,i,t,n),a=function(e,t){var n,r=Nt&&e.markedSpans;if(r)for(var i=0;it)&&(!n||It(n,o.marker)<0)&&(n=o.marker)}return n}(l,s.ch+(0r},o,i)}}function _n(e,t,n,r){return Yn(e,t,n=n||An(e,t),Bn(e,t,On(e,n,r),"line").top)}function $n(e,t,n,r){return!(e.bottom<=n)&&(e.top>n||(r?e.left:e.right)>t)}function qn(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Dn){Dn=O("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Dn.appendChild(document.createTextNode("x")),Dn.appendChild(O("br"));Dn.appendChild(document.createTextNode("x"))}N(e.measure,Dn);var n=Dn.offsetHeight/50;return 3=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var n=e.display.view,r=0;rt)&&(a.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=a.viewTo?Nt&&Vt(e.doc,t)a.viewFrom?lr(e):(a.viewFrom+=r,a.viewTo+=r):t<=a.viewFrom&&n>=a.viewTo?lr(e):t<=a.viewFrom?(i=sr(e,n,n+r,1))?(a.view=a.view.slice(i.index),a.viewFrom=i.lineN,a.viewTo+=r):lr(e):n>=a.viewTo?(o=sr(e,t,t,-1))?(a.view=a.view.slice(0,o.index),a.viewTo=o.lineN):lr(e):(l=sr(e,t,t,-1),s=sr(e,n,n+r,1),l&&s?(a.view=a.view.slice(0,l.index).concat(on(e,l.lineN,s.lineN)).concat(a.view.slice(s.index)),a.viewTo+=r):lr(e));var u=a.externalMeasured;u&&(n=l.lineN&&t=o.viewTo||(null==(r=o.view[rr(e,t)]).node||-1==B(i=r.changes||(r.changes=[]),n)&&i.push(n))}function lr(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function sr(e,t,n,r){var i,o=rr(e,t),l=e.display.view;if(!Nt||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var s=e.display.viewFrom,a=0;a=e.display.viewTo||n.to().linet||t==n&&l.to==t)&&(r(Math.max(l.from,t),Math.min(l.to,n),1==l.level?"rtl":"ltr",o),i=!0)}i||r(t,n,"ltr")}(k,y||0,null==b?C:b,function(e,t,n,r){var i,o,l,s,a,u,c,h="ltr"==n,d=S(e,h?"left":"right"),f=S(t-1,h?"right":"left"),p=null==y&&0==e,g=null==b&&t==C,m=0==r,v=!k||r==k.length-1;f.top-d.top<=3?(i=(N?g:p)&&v,o=(N?p:g)&&m?T:(h?d:f).left,l=i?M:(h?f:d).right,A(o,d.top,l-o,d.bottom)):(c=h?(s=N&&p&&m?T:d.left,a=N?M:L(e,n,"before"),u=N?T:L(t,n,"after"),N&&g&&v?M:f.right):(s=N?L(e,n,"before"):T,a=!N&&p&&m?M:d.right,u=!N&&g&&v?T:f.left,N?L(t,n,"after"):M),A(s,d.top,a-s,d.bottom),d.bottome.display.sizerWidth&&((c=Math.ceil(u/Zn(e.display)))>e.display.maxLineLength&&(e.display.maxLineLength=c,e.display.maxLine=l.line,e.display.maxLineChanged=!0))}}}function br(e){if(e.widgets)for(var t=0;t=a&&(s=rt(t,Xt(Qe(t,i))-e.wrapper.clientHeight),a=i)),{from:s,to:Math.max(a,s+1)}}function xr(e,t){var n=e.display,r=qn(e.display);t.top<0&&(t.top=0);var i=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:n.scroller.scrollTop,o=kn(e),l={};t.bottom-t.top>o&&(t.bottom=t.top+o);var s,a=e.doc.height+xn(n),u=t.topa-r;t.topi+o&&((s=Math.min(t.top,(c?a:t.bottom)-o))!=i&&(l.scrollTop=s));var h=e.options.fixedGutter?0:n.gutters.offsetWidth,d=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:n.scroller.scrollLeft-h,f=Ln(e)-n.gutters.offsetWidth,p=t.right-t.left>f;return p&&(t.right=t.left+f),t.left<10?l.scrollLeft=0:t.leftf+d-3&&(l.scrollLeft=t.right+(p?0:10)-f),l}function Cr(e,t){null!=t&&(kr(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Sr(e){kr(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Lr(e,t,n){null==t&&null==n||kr(e),null!=t&&(e.curOp.scrollLeft=t),null!=n&&(e.curOp.scrollTop=n)}function kr(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,Tr(e,Kn(e,t.from),Kn(e,t.to),t.margin))}function Tr(e,t,n,r){var i=xr(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-r,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+r});Lr(e,i.scrollLeft,i.scrollTop)}function Mr(e,t){Math.abs(e.doc.scrollTop-t)<2||(g||$r(e,{top:t}),Nr(e,t,!0),g&&$r(e),Kr(e,100))}function Nr(e,t,n){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!n||(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function Ar(e,t,n,r){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r||(e.doc.scrollLeft=t,Qr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Or(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+xn(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+Sn(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}function Dr(e,t,n){this.cm=n;var r=this.vert=O("div",[O("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=O("div",[O("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=i.tabIndex=-1,e(r),e(i),we(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),we(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,x&&C<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}Dr.prototype.update=function(e){var t,n,r=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,o=e.nativeBarWidth;return i?(this.vert.style.display="block",this.vert.style.bottom=r?o+"px":"0",t=e.viewHeight-(r?o:0),this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+t)+"px"):(this.vert.style.display="",this.vert.firstChild.style.height="0"),r?(this.horiz.style.display="block",this.horiz.style.right=i?o+"px":"0",this.horiz.style.left=e.barLeft+"px",n=e.viewWidth-e.barLeft-(i?o:0),this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+n)+"px"):(this.horiz.style.display="",this.horiz.firstChild.style.width="0"),!this.checkedZeroWidth&&0=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Xr(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}(t[n]);for(var r=0;r(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null==i||u||(o=O("div","​",null,"position: absolute;\n top: "+(t.top-n.viewOffset-wn(e.display))+"px;\n height: "+(t.bottom-t.top+Sn(e)+n.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;"),e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)))}(t,i))}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var s=0;s=a.display.viewTo||(u=+new Date+a.options.workTime,c=bt(a,d.highlightFrontier),h=[],d.iter(c.line,Math.min(d.first+d.size,a.display.viewTo+500),function(e){if(c.line>=a.display.viewFrom){var t=e.styles,n=e.text.length>a.options.maxHighlightLength?_e(d.mode,c.state):null,r=vt(a,e,c,!0);n&&(c.state=n),e.styles=r.styles;var i=e.styleClasses,o=r.classes;o?e.styleClasses=o:i&&(e.styleClasses=null);for(var l=!t||t.length!=e.styles.length||i!=o&&(!i||!o||i.bgClass!=o.bgClass||i.textClass!=o.textClass),s=0;!l&&su)return Kr(a,a.options.workDelay),!0}),d.highlightFrontier=c.line,d.modeFrontier=Math.max(d.modeFrontier,c.line),h.length&&Br(a,function(){for(var e=0;e=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==ar(e))return!1;Jr(e)&&(lr(e),t.dims=Qn(e));var i=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFroml&&n.viewTo-l<20&&(l=Math.min(i,n.viewTo)),Nt&&(o=Vt(e.doc,o),l=Kt(e.doc,l));var s,a,u,c,h=o!=n.viewFrom||l!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;a=o,u=l,0==(c=(s=e).display).view.length||a>=c.viewTo||u<=c.viewFrom?(c.view=on(s,a,u),c.viewFrom=a):(c.viewFrom>a?c.view=on(s,a,c.viewFrom).concat(c.view):c.viewFromu&&(c.view=c.view.slice(0,rr(s,u)))),c.viewTo=u,n.viewOffset=Xt(Qe(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var d=ar(e);if(!h&&0==d&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var f,p,g,m=function(e){if(e.hasFocus())return null;var t=W();if(!t||!D(e.display.lineDiv,t))return null;var n,r={activeElt:t};return!window.getSelection||(n=window.getSelection()).anchorNode&&n.extend&&D(e.display.lineDiv,n.anchorNode)&&(r.anchorNode=n.anchorNode,r.anchorOffset=n.anchorOffset,r.focusNode=n.focusNode,r.focusOffset=n.focusOffset),r}(e);return 4=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!Yr(e,t))break;yr(e);var i=Or(e);ur(e),Hr(e,i),Zr(e,i),t.force=!1}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function $r(e,t){var n,r=new Xr(e,t);Yr(e,r)&&(yr(e),_r(e,r),n=Or(e),ur(e),Hr(e,n),Zr(e,n),r.finish())}function qr(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Zr(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Sn(e)+"px"}function Qr(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=Jn(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",l=0;lu.clientWidth,h=u.scrollHeight>u.clientHeight;if(l&&c||s&&h){if(s&&y&&v)e:for(var d=t.target,f=a.view;d!=u;d=d.parentNode)for(var p=0;pa-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(o=(s=i).lastOp==r?(Ti(s.done),$(s.done)):s.done.length&&!$(s.done).ranges?$(s.done):1i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=a,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,l||Se(e,"historyAdded")}function Ni(e,t,n,r){var i,o,l,s,a,u=e.history,c=r&&r.origin;n==u.lastSelOp||c&&u.lastSelOrigin==c&&(u.lastModTime==u.lastSelTime&&u.lastOrigin==c||(i=e,o=c,l=$(u.done),s=t,"*"==(a=o.charAt(0))||"+"==a&&l.ranges.length==s.ranges.length&&l.somethingSelected()==s.somethingSelected()&&new Date-i.history.lastSelTime<=(i.cm?i.cm.options.historyEventDelay:500)))?u.done[u.done.length-1]=t:Ai(t,u.done),u.lastSelTime=+new Date,u.lastSelOrigin=c,u.lastSelOp=n,r&&!1!==r.clearRedo&&Ti(u.undone)}function Ai(e,t){var n=$(t);n&&n.ranges&&n.equals(e)||t.push(e)}function Oi(t,n,e,r){var i=n["spans_"+t.id],o=0;t.iter(Math.max(t.first,e),Math.min(t.first+t.size,r),function(e){e.markedSpans&&((i=i||(n["spans_"+t.id]={}))[o]=e.markedSpans),++o})}function Di(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var r=[],i=0;i=t.ch:s.to>t.ch))){if(i&&(Se(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(n){var h=a.find(r<0?1:-1),d=void 0;if((r<0?c:u)&&(h=Yi(e,h,-r,h&&h.line==t.line?o:null)),h&&h.line==t.line&&(d=st(h,n))&&(r<0?d<0:0e.first?ft(e,lt(t.line-1)):null:0e.lastLine()||(t.from.lineo&&(t={from:t.from,to:lt(o,Qe(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Je(e,t.from,t.to),n=n||gi(e,t),e.cm?function(e,t,n){var r=e.doc,i=e.display,o=t.from,l=t.to,s=!1,a=o.line;e.options.lineWrapping||(a=nt(Ut(Qe(r,o.line))),r.iter(a,l.line+1,function(e){if(e==i.maxLine)return s=!0}));-1i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0));(function(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontiert.display.maxLineLength&&(t.display.maxLine=u,t.display.maxLineLength=c,t.display.maxLineChanged=!0)}null!=r&&t&&this.collapsed&&ir(t,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&Vi(t.doc)),t&&un(t,"markerCleared",t,this,r,i),n&&zr(t),this.parent&&this.parent.clear()}},ho.prototype.find=function(e,t){var n,r;null==e&&"bookmark"==this.type&&(e=1);for(var i=0;i=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(i,o,l){i=ft(this,i),o=ft(this,o);var s=[],a=i.line;return this.iter(i.line,o.line+1,function(e){var t=e.markedSpans;if(t)for(var n=0;n=r.to||null==r.from&&a!=i.line||null!=r.from&&a==o.line&&r.from>=o.ch||l&&!l(r.marker)||s.push(r.marker.parent||r.marker)}++a}),s},getAllMarks:function(){var r=[];return this.iter(function(e){var t=e.markedSpans;if(t)for(var n=0;nt&&(t=e.from),null!=e.to&&e.toe.text.length?null:r}function zo(e,t,n){var r=Ro(e,t.ch,n);return null==r?null:new lt(t.line,r,n<0?"after":"before")}function Bo(e,t,n,r,i){if(e){"rtl"==t.doc.direction&&(i=-i);var o=ye(n,t.doc.direction);if(o){var l,s,a,u=i<0?$(o):o[0],c=i<0==(1==u.level)?"after":"before";return 0=n.text.length?(s.ch=n.text.length,s.sticky="before"):s.ch<=0&&(s.ch=0,s.sticky="after");var r=ae(a,s.ch,s.sticky),i=a[r];if("ltr"==t.doc.direction&&i.level%2==0&&(0s.ch:i.from=i.from&&d>=c.begin)){var f=h?"before":"after";return new lt(s.line,d,f)}}function p(e,t,n){for(var r=function(e,t){return t?new lt(s.line,u(e,1),"before"):new lt(s.line,e,"after")};0<=e&&el.doc.first&&((n=Qe(l.doc,e.line-1).text)&&(e=new lt(e.line,1),l.replaceRange(t.charAt(0)+l.doc.lineSeparator()+n.charAt(n.length-1),lt(e.line-1,n.length-1),e,"+transpose")))),i.push(new ci(e,e)))}l.setSelections(i)})},newlineAndIndent:function(r){return Br(r,function(){for(var e=r.listSelections(),t=e.length-1;0<=t;t--)r.replaceRange(r.doc.lineSeparator(),e[t].anchor,e[t].head,"+input");e=r.listSelections();for(var n=0;nc&&t.push(new ci(lt(s,c),lt(s,X(u,l,n))))}t.length||t.push(new ci(v,v)),Bi(b,hi(m,C.ranges.slice(0,x).concat(t),x),{origin:"*mouse",scroll:!1}),m.scrollIntoView(e)}else{var h,d=w,f=il(m,e,y.unit),p=d.anchor,p=0=n.to||o.linea.bottom?20:0)&&setTimeout(Gr(m,function(){u==i&&(l.scroller.scrollTop+=r,e(t))}),50))}:r)(e)}),o=Gr(m,r);m.state.selectingText=o,we(l.wrapper.ownerDocument,"mousemove",i),we(l.wrapper.ownerDocument,"mouseup",o)})(e,r,t,o)}(s,t,r,e):We(e)==a.scroller&&Ne(e):2==n?(t&&Pi(s.doc,t),setTimeout(function(){return a.input.focus()},20)):3==n&&(S?s.display.input.onContextMenu(e):gr(s)))))}function il(e,t,n){if("char"==n)return new ci(t,t);if("word"==n)return e.findWordAt(t);if("line"==n)return new ci(lt(t.line,0),ft(e.doc,lt(t.line+1,0)));var r=n(e,t);return new ci(r.from,r.to)}function ol(e,t,n,r){var i,o;if(t.touches)i=t.touches[0].clientX,o=t.touches[0].clientY;else try{i=t.clientX,o=t.clientY}catch(e){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Ne(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!Te(e,n))return Oe(t);o-=s.top-l.viewOffset;for(var a=0;a=i)return Se(e,n,e,rt(e.doc,o),e.display.gutterSpecs[a].className,t),Oe(t)}}function ll(e,t){return ol(e,t,"gutterClick",!0)}function sl(e,t){var n,r;bn(e.display,t)||(r=t,Te(n=e,"gutterContextMenu")&&ol(n,r,"gutterContextMenu",!1))||Le(e,t,"contextmenu")||S||e.display.input.onContextMenu(t)}function al(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),En(e)}nl.prototype.compare=function(e,t,n){return this.time+400>e&&0==st(t,this.pos)&&n==this.button};var ul={toString:function(){return"CodeMirror.Init"}},cl={},hl={};function dl(e,t,n){var r,i;!t!=!(n&&n!=ul)&&(r=e.display.dragFunctions,(i=t?we:Ce)(e.display.scroller,"dragstart",r.start),i(e.display.scroller,"dragenter",r.enter),i(e.display.scroller,"dragover",r.over),i(e.display.scroller,"dragleave",r.leave),i(e.display.scroller,"drop",r.drop))}function fl(e){e.options.lineWrapping?(H(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(T(e.display.wrapper,"CodeMirror-wrap"),_t(e)),tr(e),ir(e),En(e),setTimeout(function(){return Hr(e)},100)}function pl(e,t){var n=this;if(!(this instanceof pl))return new pl(e,t);this.options=t=t?I(t):{},I(cl,t,!1);var r=t.value;"string"==typeof r?r=new vo(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var i=new pl.inputStyles[t.inputStyle](this),o=this.display=new ri(e,r,i,t);for(var l in al(o.wrapper.CodeMirror=this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Er(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new z,keySeq:null,specialChars:null},t.autofocus&&!d&&o.input.focus(),x&&C<11&&setTimeout(function(){return n.display.input.reset(!0)},20),function(i){var o=i.display;we(o.scroller,"mousedown",Gr(i,rl)),we(o.scroller,"dblclick",x&&C<11?Gr(i,function(e){var t,n;Le(i,e)||(!(t=nr(i,e))||ll(i,e)||bn(i.display,e)||(Ne(e),n=i.findWordAt(t),Pi(i.doc,n.anchor,n.head)))}):function(e){return Le(i,e)||Ne(e)});we(o.scroller,"contextmenu",function(e){return sl(i,e)}),we(o.input.getField(),"contextmenu",function(e){o.scroller.contains(e.target)||sl(i,e)});var n,r={end:0};function l(){o.activeTouch&&(n=setTimeout(function(){return o.activeTouch=null},1e3),(r=o.activeTouch).end=+new Date)}function s(e,t){if(null==t.left)return 1;var n=t.left-e.left,r=t.top-e.top;return 400o.first?R(Qe(o,t-1).text,null,l):0:"add"==n?u=a+e.options.indentUnit:"subtract"==n?u=a-e.options.indentUnit:"number"==typeof n&&(u=a+n),u=Math.max(0,u);var h="",d=0;if(e.options.indentWithTabs)for(var f=Math.floor(u/l);f;--f)d+=l,h+="\t";if(dl,a=Re(t),u=null;if(s&&1l?"cut":"+input")};qi(e.doc,m),un(e,"inputRead",e,m)}t&&!s&&xl(e,t),Sr(e),e.curOp.updateInput<2&&(e.curOp.updateInput=h),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function wl(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");return n&&(e.preventDefault(),t.isReadOnly()||t.options.disableInput||Br(t,function(){return bl(t,n,0,null,"paste")}),1)}function xl(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,r=n.ranges.length-1;0<=r;r--){var i=n.ranges[r];if(!(100=i.first+i.size||(o=new lt(r,o.ch,o.sticky),!(u=Qe(i,r))))return;o=Bo(a,i.cm,u,o.line,c)}else o=n;return 1}if("char"==s||"codepoint"==s)n();else if("column"==s)n(!0);else if("word"==s||"group"==s)for(var r=null,h="group"==s,d=i.cm&&i.cm.getHelper(o,"wordChars"),f=!0;!(l<0)||n(!f);f=!1){var p=u.text.charAt(o.ch)||"\n",g=te(p,d)?"w":h&&"\n"==p?"n":!h||/\s/.test(p)?null:"p";if(!h||f||g||(g="s"),r&&r!=g){l<0&&(l=1,n(),o.sticky="after");break}if(g&&(r=g),0=a.height){s.hitSide=!0;break}l+=5*n}return s}function Ml(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new z,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null}function Nl(e,t){var n=Nn(e,t.line);if(!n||n.hidden)return null;var r=Qe(e.doc,t.line),i=Tn(n,r,t.line),o=ye(r,e.doc.direction),l="left";o&&(l=ae(o,t.ch)%2?"right":"left");var s=Hn(i.map,t.ch,l);return s.offset="right"==s.collapse?s.end:s.start,s}function Al(e,t){return t&&(e.bad=!0),e}function Ol(e,t,n){var r;if(t==e.display.lineDiv){if(!(r=e.display.lineDiv.childNodes[n]))return Al(e.clipPos(lt(e.display.viewTo-1)),!0);t=null,n=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var i=0;i=t.display.viewTo||i.line=t.display.viewFrom&&Nl(t,r)||{node:u[0].measure.map[2],offset:0},h=i.liner.firstLine()&&(l=lt(l.line-1,Qe(r.doc,l.line-1).length)),s.ch==Qe(r.doc,s.line).text.length&&s.linei.viewTo-1)return!1;n=l.line==i.viewFrom||0==(e=rr(r,l.line))?(t=nt(i.view[0].line),i.view[0].node):(t=nt(i.view[e].line),i.view[e-1].node.nextSibling);var a,u=rr(r,s.line),c=u==i.view.length-1?(a=i.viewTo-1,i.lineDiv.lastChild):(a=nt(i.view[u+1].line)-1,i.view[u+1].node.previousSibling);if(!n)return!1;for(var h=r.doc.splitLines(function(u,e,t,c,h){var n="",d=!1,f=u.doc.lineSeparator(),p=!1;function g(){d&&(n+=f,p&&(n+=f),d=p=!1)}function m(e){e&&(g(),n+=e)}for(;!function e(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(n)return void m(n);var r,i=t.getAttribute("cm-marker");if(i){var o=u.findMarks(lt(c,0),lt(h+1,0),(a=+i,function(e){return e.id==a}));return void(o.length&&(r=o[0].find(0))&&m(Je(u.doc,r.from,r.to).join(f)))}if("false"==t.getAttribute("contenteditable"))return;var l=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length)return;l&&g();for(var s=0;sl.ch&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)f--,p++;h[h.length-1]=y.slice(0,y.length-p).replace(/^\u200b+/,""),h[0]=h[0].slice(f).replace(/\u200b+$/,"");var x=lt(t,f),C=lt(a,d.length?$(d).length-p:0);return 1n&&(ml(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&Sr(this));else{for(var o=i.from(),l=i.to(),s=Math.max(n,o.line),n=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1,a=s;a>1;if((l?n[2*l-1]:0)>=o)i=l;else{if(!(n[2*l+1]o)&&e.top>t.offsetHeight?h=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=o&&(h=e.bottom),d+t.offsetWidth>l&&(d=l-t.offsetWidth)),t.style.top=h+"px",t.style.left=t.style.right="","right"==i?(d=c.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?d=0:"middle"==i&&(d=(c.sizer.clientWidth-t.offsetWidth)/2),t.style.left=d+"px"),n&&(s=this,a={left:d,top:h,right:d+t.offsetWidth,bottom:h+t.offsetHeight},null!=(u=xr(s,a)).scrollTop&&Mr(s,u.scrollTop),null!=u.scrollLeft&&Ar(s,u.scrollLeft))},triggerOnKeyDown:Ur(Zo),triggerOnKeyPress:Ur(Jo),triggerOnKeyUp:Qo,triggerOnMouseDown:Ur(rl),execCommand:function(e){if(Uo.hasOwnProperty(e))return Uo[e].call(null,this)},triggerElectric:Ur(function(e){xl(this,e)}),findPosH:function(e,t,n,r){var i=1;t<0&&(i=-1,t=-t);for(var o=ft(this.doc,e),l=0;lt)return i;o.to==t&&(o.from!=o.to&&"before"==n?r=i:se=i),o.from==t&&(o.from!=o.to&&"before"!=n?r=i:se=i)}return null!=r?r:se}var ue,ce,he,de,fe,pe,ge,me=(ue="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",ce="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",he=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,de=/[stwN]/,fe=/[LRr]/,pe=/[Lb1n]/,ge=/[1n]/,function(e,t){var n="ltr"==t?"L":"R";if(0==e.length||"ltr"==t&&!he.test(e))return!1;for(var r,i=e.length,o=[],l=0;l=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],o=i.chunkSize();if(t=e.first&&to?lt(o,Qe(e,o).text.length):(r=Qe(e,(n=t).line).text.length,null==(i=n.ch)||r=this.string.length},Ze.prototype.sol=function(){return this.pos==this.lineStart},Ze.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Ze.prototype.next=function(){if(this.post},Ze.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Ze.prototype.skipToEnd=function(){this.pos=this.string.length},Ze.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(-1e.options.maxHighlightLength&&_e(e.doc.mode,r.state),o=vt(e,t,r),i&&(r.state=i),t.stateAfter=r.save(!i),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))),t.styles}function bt(n,r,e){var t=n.doc,i=n.display;if(!t.mode.startState)return new mt(t,!0,r);var o=function(e,t,n){for(var r,i,o=e.doc,l=n?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;lt.first&&Qe(t,o-1).stateAfter,s=l?mt.fromSaved(t,l,o):new mt(t,qe(t.mode),o);return t.iter(o,r,function(e){wt(n,e.text,s);var t=s.line;e.stateAfter=t==r-1||t%5==0||t>=i.viewFrom&&tt.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}mt.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},mt.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},mt.prototype.nextLine=function(){this.line++,0e.options.maxHighlightLength?(s=!1,l&&wt(e,t,r,c.pos),c.pos=t.length,null):kt(Ct(n,c,r.state,h),o);if(!h||(d=h[0].name)&&(f="m-"+(f?d+" "+f:d)),!s||u!=f){for(;a=t:l.to>t),(r=r||[]).push(new At(s,l.from,o?null:l.to)))}return r}(n,i,l),a=function(e,t,n){var r;if(e)for(var i=0;i=t:l.to>t))&&(l.from!=t||"bookmark"!=s.type||n&&!l.marker.insertLeft)||(o=null==l.from||(s.inclusiveLeft?l.from<=t:l.frome.lastLine())return t;var n,r=Qe(e,t);if(!jt(e,r))return t;for(;n=Bt(r);)r=n.find(1,!0).line;return nt(r)+1}function jt(e,t){var n=Nt&&t.markedSpans;if(n)for(var r=void 0,i=0;in.maxLineLength&&(n.maxLineLength=t,n.maxLine=e)})}var $t=function(e,t,n){this.text=e,Ft(this,t),this.height=n?n(this):1};$t.prototype.lineNo=function(){return nt(this)},Me($t);var qt={},Zt={};function Qt(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?Zt:qt;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Jt(e,t){var n=A("span",null,null,v?"padding-right: .1px":null),r={pre:A("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var i,o=0;o<=(t.rest?t.rest.length:0);o++){var l=o?t.rest[o-1]:t.line,s=void 0;r.pos=0,r.addToken=tn,function(e){if(null!=Ee)return Ee;var t=N(e,document.createTextNode("AخA")),n=k(t,0,1).getBoundingClientRect(),r=k(t,1,2).getBoundingClientRect();return M(e),n&&n.left!=n.right&&(Ee=r.right-n.right<3)}(e.display.measure)&&(s=ye(l,e.doc.direction))&&(r.addToken=function(h,d){return function(e,t,n,r,i,o,l){n=n?n+" cm-force-border":"cm-force-border";for(var s=e.pos,a=s+t.length;;){for(var u=void 0,c=0;cs&&u.from<=s);c++);if(u.to>=a)return h(e,t,n,r,i,o,l);h(e,t.slice(0,u.to-s),n,r,null,o,l),r=null,t=t.slice(u.to-s),s=u.to}}}(r.addToken,s)),r.map=[],function(e,t,n){var r=e.markedSpans,i=e.text,o=0;if(!r){for(var l=1;lg||S.collapsed&&C.to==g&&C.from==g)){if(null!=C.to&&C.to!=g&&y>C.to&&(y=C.to,c=""),S.className&&(u+=" "+S.className),S.css&&(a=(a?a+";":"")+S.css),S.startStyle&&C.from==g&&(h+=" "+S.startStyle),S.endStyle&&C.to==y&&(w=w||[]).push(S.endStyle,C.to),S.title&&((f=f||{}).title=S.title),S.attributes)for(var L in S.attributes)(f=f||{})[L]=S.attributes[L];S.collapsed&&(!d||It(d.marker,S)<0)&&(d=C)}else C.from>g&&y>C.from&&(y=C.from)}if(w)for(var k=0;kn)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Mn(e,t,n,r){return On(e,An(e,t),n,r)}function Nn(e,t){if(t>=e.display.viewFrom&&t=n.lineN&&tt)&&(i=(o=a-s)-1,a<=t&&(l="right")),null!=i){if(r=e[u+2],s==a&&n==(r.insertLeft?"left":"right")&&(l=n),"left"==n&&0==i)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)r=e[2+(u-=3)],l="left";if("right"==n&&i==a-s)for(;u=o.text.length?(t=o.text.length,n="before"):t<=0&&(t=0,n="after"),!u)return a("before"==n?t-1:t,"before"==n);function c(e,t,n){return a(n?e-1:e,1==u[t].level!=n)}var h=ae(u,t,n),d=se,f=c(t,h,"before"==n);return null!=d&&(f.other=c(t,d,"before"!=n)),f}function Kn(e,t){var n=0;t=ft(e.doc,t),e.options.lineWrapping||(n=Zn(e.display)*t.ch);var r=Qe(e.doc,t.line),i=Xt(r)+wn(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function jn(e,t,n,r,i){var o=lt(e,t,n);return o.xRel=i,r&&(o.outside=r),o}function Xn(e,t,n){var r=e.doc;if((n+=e.display.viewOffset)<0)return jn(r.first,0,null,-1,-1);var i=rt(r,n),o=r.first+r.size-1;if(o=u||m.to<=a||(f=1!=m.level,p=On(e,r,f?Math.min(u,m.to)-1:Math.max(a,m.from)).right,g=pu&&(c={from:c.from,to:u,level:c.level});return c}:function(r,i,o,l,s,a,u){var e=le(function(e){var t=s[e],n=1!=t.level;return $n(Vn(r,lt(o,n?t.to:t.from,n?"before":"after"),"line",i,l),a,u,!0)},0,s.length-1),t=s[e];{var n,c;0u&&(t=s[e-1]))}return t})(n,e,t,o,c,r,i),u=1!=h.level,s=u?h.from:h.to-1,a=u?h.to:h.from-1)}var d,f,p=null,g=null,m=le(function(e){var t=On(n,o,e);return t.top+=l,t.bottom+=l,$n(t,r,i,!1)&&(t.top<=i&&t.left<=r&&(p=e,g=t),1)},s,a),v=!1;{var y,b,w;g?(y=r-g.left=w.bottom?1:0)}return m=oe(e.text,m,1),jn(t,m,f,v,r-d)}(e,l,i,t,n),a=function(e,t){var n,r=Nt&&e.markedSpans;if(r)for(var i=0;it)&&(!n||It(n,o.marker)<0)&&(n=o.marker)}return n}(l,s.ch+(0r},o,i)}}function _n(e,t,n,r){return Yn(e,t,n=n||An(e,t),Bn(e,t,On(e,n,r),"line").top)}function $n(e,t,n,r){return!(e.bottom<=n)&&(e.top>n||(r?e.left:e.right)>t)}function qn(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Dn){Dn=O("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Dn.appendChild(document.createTextNode("x")),Dn.appendChild(O("br"));Dn.appendChild(document.createTextNode("x"))}N(e.measure,Dn);var n=Dn.offsetHeight/50;return 3=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var n=e.display.view,r=0;rt)&&(a.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=a.viewTo?Nt&&Vt(e.doc,t)a.viewFrom?lr(e):(a.viewFrom+=r,a.viewTo+=r):t<=a.viewFrom&&n>=a.viewTo?lr(e):t<=a.viewFrom?(i=sr(e,n,n+r,1))?(a.view=a.view.slice(i.index),a.viewFrom=i.lineN,a.viewTo+=r):lr(e):n>=a.viewTo?(o=sr(e,t,t,-1))?(a.view=a.view.slice(0,o.index),a.viewTo=o.lineN):lr(e):(l=sr(e,t,t,-1),s=sr(e,n,n+r,1),l&&s?(a.view=a.view.slice(0,l.index).concat(on(e,l.lineN,s.lineN)).concat(a.view.slice(s.index)),a.viewTo+=r):lr(e));var u=a.externalMeasured;u&&(n=l.lineN&&t=o.viewTo||(null==(r=o.view[rr(e,t)]).node||-1==B(i=r.changes||(r.changes=[]),n)&&i.push(n))}function lr(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function sr(e,t,n,r){var i,o=rr(e,t),l=e.display.view;if(!Nt||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var s=e.display.viewFrom,a=0;a=e.display.viewTo||n.to().linet||t==n&&l.to==t)&&(r(Math.max(l.from,t),Math.min(l.to,n),1==l.level?"rtl":"ltr",o),i=!0)}i||r(t,n,"ltr")}(k,y||0,null==b?C:b,function(e,t,n,r){var i,o,l,s,a,u,c,h="ltr"==n,d=S(e,h?"left":"right"),f=S(t-1,h?"right":"left"),p=null==y&&0==e,g=null==b&&t==C,m=0==r,v=!k||r==k.length-1;f.top-d.top<=3?(i=(N?g:p)&&v,o=(N?p:g)&&m?T:(h?d:f).left,l=i?M:(h?f:d).right,A(o,d.top,l-o,d.bottom)):(c=h?(s=N&&p&&m?T:d.left,a=N?M:L(e,n,"before"),u=N?T:L(t,n,"after"),N&&g&&v?M:f.right):(s=N?L(e,n,"before"):T,a=!N&&p&&m?M:d.right,u=!N&&g&&v?T:f.left,N?L(t,n,"after"):M),A(s,d.top,a-s,d.bottom),d.bottome.display.sizerWidth&&((c=Math.ceil(u/Zn(e.display)))>e.display.maxLineLength&&(e.display.maxLineLength=c,e.display.maxLine=l.line,e.display.maxLineChanged=!0))}}}function br(e){if(e.widgets)for(var t=0;t=a&&(s=rt(t,Xt(Qe(t,i))-e.wrapper.clientHeight),a=i)),{from:s,to:Math.max(a,s+1)}}function xr(e,t){var n=e.display,r=qn(e.display);t.top<0&&(t.top=0);var i=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:n.scroller.scrollTop,o=kn(e),l={};t.bottom-t.top>o&&(t.bottom=t.top+o);var s,a=e.doc.height+xn(n),u=t.topa-r;t.topi+o&&((s=Math.min(t.top,(c?a:t.bottom)-o))!=i&&(l.scrollTop=s));var h=e.options.fixedGutter?0:n.gutters.offsetWidth,d=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:n.scroller.scrollLeft-h,f=Ln(e)-n.gutters.offsetWidth,p=t.right-t.left>f;return p&&(t.right=t.left+f),t.left<10?l.scrollLeft=0:t.leftf+d-3&&(l.scrollLeft=t.right+(p?0:10)-f),l}function Cr(e,t){null!=t&&(kr(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Sr(e){kr(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Lr(e,t,n){null==t&&null==n||kr(e),null!=t&&(e.curOp.scrollLeft=t),null!=n&&(e.curOp.scrollTop=n)}function kr(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,Tr(e,Kn(e,t.from),Kn(e,t.to),t.margin))}function Tr(e,t,n,r){var i=xr(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-r,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+r});Lr(e,i.scrollLeft,i.scrollTop)}function Mr(e,t){Math.abs(e.doc.scrollTop-t)<2||(g||$r(e,{top:t}),Nr(e,t,!0),g&&$r(e),Kr(e,100))}function Nr(e,t,n){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!n||(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function Ar(e,t,n,r){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r||(e.doc.scrollLeft=t,Qr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Or(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+xn(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+Sn(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}function Dr(e,t,n){this.cm=n;var r=this.vert=O("div",[O("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=O("div",[O("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=i.tabIndex=-1,e(r),e(i),we(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),we(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,L&&x<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}Dr.prototype.update=function(e){var t,n,r=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,o=e.nativeBarWidth;return i?(this.vert.style.display="block",this.vert.style.bottom=r?o+"px":"0",t=e.viewHeight-(r?o:0),this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+t)+"px"):(this.vert.style.display="",this.vert.firstChild.style.height="0"),r?(this.horiz.style.display="block",this.horiz.style.right=i?o+"px":"0",this.horiz.style.left=e.barLeft+"px",n=e.viewWidth-e.barLeft-(i?o:0),this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+n)+"px"):(this.horiz.style.display="",this.horiz.firstChild.style.width="0"),!this.checkedZeroWidth&&0=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Xr(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}(t[n]);for(var r=0;r(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null==i||u||(o=O("div","​",null,"position: absolute;\n top: "+(t.top-n.viewOffset-wn(e.display))+"px;\n height: "+(t.bottom-t.top+Sn(e)+n.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;"),e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)))}(t,i))}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var s=0;s=a.display.viewTo||(u=+new Date+a.options.workTime,c=bt(a,d.highlightFrontier),h=[],d.iter(c.line,Math.min(d.first+d.size,a.display.viewTo+500),function(e){if(c.line>=a.display.viewFrom){var t=e.styles,n=e.text.length>a.options.maxHighlightLength?_e(d.mode,c.state):null,r=vt(a,e,c,!0);n&&(c.state=n),e.styles=r.styles;var i=e.styleClasses,o=r.classes;o?e.styleClasses=o:i&&(e.styleClasses=null);for(var l=!t||t.length!=e.styles.length||i!=o&&(!i||!o||i.bgClass!=o.bgClass||i.textClass!=o.textClass),s=0;!l&&su)return Kr(a,a.options.workDelay),!0}),d.highlightFrontier=c.line,d.modeFrontier=Math.max(d.modeFrontier,c.line),h.length&&Br(a,function(){for(var e=0;e=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==ar(e))return!1;Jr(e)&&(lr(e),t.dims=Qn(e));var i=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFroml&&n.viewTo-l<20&&(l=Math.min(i,n.viewTo)),Nt&&(o=Vt(e.doc,o),l=Kt(e.doc,l));var s,a,u,c,h=o!=n.viewFrom||l!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;a=o,u=l,0==(c=(s=e).display).view.length||a>=c.viewTo||u<=c.viewFrom?(c.view=on(s,a,u),c.viewFrom=a):(c.viewFrom>a?c.view=on(s,a,c.viewFrom).concat(c.view):c.viewFromu&&(c.view=c.view.slice(0,rr(s,u)))),c.viewTo=u,n.viewOffset=Xt(Qe(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var d=ar(e);if(!h&&0==d&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var f,p,g,m=function(e){if(e.hasFocus())return null;var t=W();if(!t||!D(e.display.lineDiv,t))return null;var n,r={activeElt:t};return!window.getSelection||(n=window.getSelection()).anchorNode&&n.extend&&D(e.display.lineDiv,n.anchorNode)&&(r.anchorNode=n.anchorNode,r.anchorOffset=n.anchorOffset,r.focusNode=n.focusNode,r.focusOffset=n.focusOffset),r}(e);return 4=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!Yr(e,t))break;yr(e);var i=Or(e);ur(e),Hr(e,i),Zr(e,i),t.force=!1}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function $r(e,t){var n,r=new Xr(e,t);Yr(e,r)&&(yr(e),_r(e,r),n=Or(e),ur(e),Hr(e,n),Zr(e,n),r.finish())}function qr(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Zr(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Sn(e)+"px"}function Qr(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=Jn(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",l=0;lu.clientWidth,h=u.scrollHeight>u.clientHeight;if(l&&c||s&&h){if(s&&y&&v)e:for(var d=t.target,f=a.view;d!=u;d=d.parentNode)for(var p=0;pa-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(o=(s=i).lastOp==r?(Ti(s.done),$(s.done)):s.done.length&&!$(s.done).ranges?$(s.done):1i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=a,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,l||Se(e,"historyAdded")}function Ni(e,t,n,r){var i,o,l,s,a,u=e.history,c=r&&r.origin;n==u.lastSelOp||c&&u.lastSelOrigin==c&&(u.lastModTime==u.lastSelTime&&u.lastOrigin==c||(i=e,o=c,l=$(u.done),s=t,"*"==(a=o.charAt(0))||"+"==a&&l.ranges.length==s.ranges.length&&l.somethingSelected()==s.somethingSelected()&&new Date-i.history.lastSelTime<=(i.cm?i.cm.options.historyEventDelay:500)))?u.done[u.done.length-1]=t:Ai(t,u.done),u.lastSelTime=+new Date,u.lastSelOrigin=c,u.lastSelOp=n,r&&!1!==r.clearRedo&&Ti(u.undone)}function Ai(e,t){var n=$(t);n&&n.ranges&&n.equals(e)||t.push(e)}function Oi(t,n,e,r){var i=n["spans_"+t.id],o=0;t.iter(Math.max(t.first,e),Math.min(t.first+t.size,r),function(e){e.markedSpans&&((i=i||(n["spans_"+t.id]={}))[o]=e.markedSpans),++o})}function Di(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var r=[],i=0;i=t.ch:s.to>t.ch))){if(i&&(Se(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(n){var h=a.find(r<0?1:-1),d=void 0;if((r<0?c:u)&&(h=Yi(e,h,-r,h&&h.line==t.line?o:null)),h&&h.line==t.line&&(d=st(h,n))&&(r<0?d<0:0e.first?ft(e,lt(t.line-1)):null:0e.lastLine()||(t.from.lineo&&(t={from:t.from,to:lt(o,Qe(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Je(e,t.from,t.to),n=n||gi(e,t),e.cm?function(e,t,n){var r=e.doc,i=e.display,o=t.from,l=t.to,s=!1,a=o.line;e.options.lineWrapping||(a=nt(Ut(Qe(r,o.line))),r.iter(a,l.line+1,function(e){if(e==i.maxLine)return s=!0}));-1i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0));(function(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontiert.display.maxLineLength&&(t.display.maxLine=u,t.display.maxLineLength=c,t.display.maxLineChanged=!0)}null!=r&&t&&this.collapsed&&ir(t,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&Vi(t.doc)),t&&un(t,"markerCleared",t,this,r,i),n&&zr(t),this.parent&&this.parent.clear()}},ho.prototype.find=function(e,t){var n,r;null==e&&"bookmark"==this.type&&(e=1);for(var i=0;i=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(i,o,l){i=ft(this,i),o=ft(this,o);var s=[],a=i.line;return this.iter(i.line,o.line+1,function(e){var t=e.markedSpans;if(t)for(var n=0;n=r.to||null==r.from&&a!=i.line||null!=r.from&&a==o.line&&r.from>=o.ch||l&&!l(r.marker)||s.push(r.marker.parent||r.marker)}++a}),s},getAllMarks:function(){var r=[];return this.iter(function(e){var t=e.markedSpans;if(t)for(var n=0;nt&&(t=e.from),null!=e.to&&e.toe.text.length?null:r}function zo(e,t,n){var r=Ro(e,t.ch,n);return null==r?null:new lt(t.line,r,n<0?"after":"before")}function Bo(e,t,n,r,i){if(e){"rtl"==t.doc.direction&&(i=-i);var o=ye(n,t.doc.direction);if(o){var l,s,a,u=i<0?$(o):o[0],c=i<0==(1==u.level)?"after":"before";return 0=n.text.length?(s.ch=n.text.length,s.sticky="before"):s.ch<=0&&(s.ch=0,s.sticky="after");var r=ae(a,s.ch,s.sticky),i=a[r];if("ltr"==t.doc.direction&&i.level%2==0&&(0s.ch:i.from=i.from&&d>=c.begin)){var f=h?"before":"after";return new lt(s.line,d,f)}}function p(e,t,n){for(var r=function(e,t){return t?new lt(s.line,u(e,1),"before"):new lt(s.line,e,"after")};0<=e&&el.doc.first&&((n=Qe(l.doc,e.line-1).text)&&(e=new lt(e.line,1),l.replaceRange(t.charAt(0)+l.doc.lineSeparator()+n.charAt(n.length-1),lt(e.line-1,n.length-1),e,"+transpose")))),i.push(new ci(e,e)))}l.setSelections(i)})},newlineAndIndent:function(r){return Br(r,function(){for(var e=r.listSelections(),t=e.length-1;0<=t;t--)r.replaceRange(r.doc.lineSeparator(),e[t].anchor,e[t].head,"+input");e=r.listSelections();for(var n=0;nc&&t.push(new ci(lt(s,c),lt(s,X(u,l,n))))}t.length||t.push(new ci(v,v)),Bi(b,hi(m,C.ranges.slice(0,x).concat(t),x),{origin:"*mouse",scroll:!1}),m.scrollIntoView(e)}else{var h,d=w,f=il(m,e,y.unit),p=d.anchor,p=0=n.to||o.linea.bottom?20:0)&&setTimeout(Gr(m,function(){u==i&&(l.scroller.scrollTop+=r,e(t))}),50))}:r)(e)}),o=Gr(m,r);m.state.selectingText=o,we(l.wrapper.ownerDocument,"mousemove",i),we(l.wrapper.ownerDocument,"mouseup",o)})(e,r,t,o)}(s,t,r,e):We(e)==a.scroller&&Ne(e):2==n?(t&&Ei(s.doc,t),setTimeout(function(){return a.input.focus()},20)):3==n&&(C?s.display.input.onContextMenu(e):gr(s)))))}function il(e,t,n){if("char"==n)return new ci(t,t);if("word"==n)return e.findWordAt(t);if("line"==n)return new ci(lt(t.line,0),ft(e.doc,lt(t.line+1,0)));var r=n(e,t);return new ci(r.from,r.to)}function ol(e,t,n,r){var i,o;if(t.touches)i=t.touches[0].clientX,o=t.touches[0].clientY;else try{i=t.clientX,o=t.clientY}catch(e){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Ne(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!Te(e,n))return Oe(t);o-=s.top-l.viewOffset;for(var a=0;a=i)return Se(e,n,e,rt(e.doc,o),e.display.gutterSpecs[a].className,t),Oe(t)}}function ll(e,t){return ol(e,t,"gutterClick",!0)}function sl(e,t){var n,r;bn(e.display,t)||(r=t,Te(n=e,"gutterContextMenu")&&ol(n,r,"gutterContextMenu",!1))||Le(e,t,"contextmenu")||C||e.display.input.onContextMenu(t)}function al(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),Pn(e)}nl.prototype.compare=function(e,t,n){return this.time+400>e&&0==st(t,this.pos)&&n==this.button};var ul={toString:function(){return"CodeMirror.Init"}},cl={},hl={};function dl(e,t,n){var r,i;!t!=!(n&&n!=ul)&&(r=e.display.dragFunctions,(i=t?we:Ce)(e.display.scroller,"dragstart",r.start),i(e.display.scroller,"dragenter",r.enter),i(e.display.scroller,"dragover",r.over),i(e.display.scroller,"dragleave",r.leave),i(e.display.scroller,"drop",r.drop))}function fl(e){e.options.lineWrapping?(H(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(T(e.display.wrapper,"CodeMirror-wrap"),_t(e)),tr(e),ir(e),Pn(e),setTimeout(function(){return Hr(e)},100)}function pl(e,t){var n=this;if(!(this instanceof pl))return new pl(e,t);this.options=t=t?I(t):{},I(cl,t,!1);var r=t.value;"string"==typeof r?r=new vo(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var i=new pl.inputStyles[t.inputStyle](this),o=this.display=new ri(e,r,i,t);for(var l in al(o.wrapper.CodeMirror=this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Pr(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new z,keySeq:null,specialChars:null},t.autofocus&&!d&&o.input.focus(),L&&x<11&&setTimeout(function(){return n.display.input.reset(!0)},20),function(i){var o=i.display;we(o.scroller,"mousedown",Gr(i,rl)),we(o.scroller,"dblclick",L&&x<11?Gr(i,function(e){var t,n;Le(i,e)||(!(t=nr(i,e))||ll(i,e)||bn(i.display,e)||(Ne(e),n=i.findWordAt(t),Ei(i.doc,n.anchor,n.head)))}):function(e){return Le(i,e)||Ne(e)});we(o.scroller,"contextmenu",function(e){return sl(i,e)}),we(o.input.getField(),"contextmenu",function(e){o.scroller.contains(e.target)||sl(i,e)});var n,r={end:0};function l(){o.activeTouch&&(n=setTimeout(function(){return o.activeTouch=null},1e3),(r=o.activeTouch).end=+new Date)}function s(e,t){if(null==t.left)return 1;var n=t.left-e.left,r=t.top-e.top;return 400o.first?R(Qe(o,t-1).text,null,l):0:"add"==n?u=a+e.options.indentUnit:"subtract"==n?u=a-e.options.indentUnit:"number"==typeof n&&(u=a+n),u=Math.max(0,u);var h="",d=0;if(e.options.indentWithTabs)for(var f=Math.floor(u/l);f;--f)d+=l,h+="\t";if(dl,a=Re(t),u=null;if(s&&1l?"cut":"+input")};qi(e.doc,m),un(e,"inputRead",e,m)}t&&!s&&xl(e,t),Sr(e),e.curOp.updateInput<2&&(e.curOp.updateInput=h),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function wl(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");return n&&(e.preventDefault(),t.isReadOnly()||t.options.disableInput||Br(t,function(){return bl(t,n,0,null,"paste")}),1)}function xl(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,r=n.ranges.length-1;0<=r;r--){var i=n.ranges[r];if(!(100=i.first+i.size||(o=new lt(r,o.ch,o.sticky),!(u=Qe(i,r))))return;o=Bo(a,i.cm,u,o.line,c)}else o=n;return 1}if("char"==s||"codepoint"==s)n();else if("column"==s)n(!0);else if("word"==s||"group"==s)for(var r=null,h="group"==s,d=i.cm&&i.cm.getHelper(o,"wordChars"),f=!0;!(l<0)||n(!f);f=!1){var p=u.text.charAt(o.ch)||"\n",g=te(p,d)?"w":h&&"\n"==p?"n":!h||/\s/.test(p)?null:"p";if(!h||f||g||(g="s"),r&&r!=g){l<0&&(l=1,n(),o.sticky="after");break}if(g&&(r=g),0=a.height){s.hitSide=!0;break}l+=5*n}return s}function Ml(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new z,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null}function Nl(e,t){var n=Nn(e,t.line);if(!n||n.hidden)return null;var r=Qe(e.doc,t.line),i=Tn(n,r,t.line),o=ye(r,e.doc.direction),l="left";o&&(l=ae(o,t.ch)%2?"right":"left");var s=Hn(i.map,t.ch,l);return s.offset="right"==s.collapse?s.end:s.start,s}function Al(e,t){return t&&(e.bad=!0),e}function Ol(e,t,n){var r;if(t==e.display.lineDiv){if(!(r=e.display.lineDiv.childNodes[n]))return Al(e.clipPos(lt(e.display.viewTo-1)),!0);t=null,n=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var i=0;i=t.display.viewTo||i.line=t.display.viewFrom&&Nl(t,r)||{node:u[0].measure.map[2],offset:0},h=i.liner.firstLine()&&(l=lt(l.line-1,Qe(r.doc,l.line-1).length)),s.ch==Qe(r.doc,s.line).text.length&&s.linei.viewTo-1)return!1;n=l.line==i.viewFrom||0==(e=rr(r,l.line))?(t=nt(i.view[0].line),i.view[0].node):(t=nt(i.view[e].line),i.view[e-1].node.nextSibling);var a,u=rr(r,s.line),c=u==i.view.length-1?(a=i.viewTo-1,i.lineDiv.lastChild):(a=nt(i.view[u+1].line)-1,i.view[u+1].node.previousSibling);if(!n)return!1;for(var h=r.doc.splitLines(function(u,e,t,c,h){var n="",d=!1,f=u.doc.lineSeparator(),p=!1;function g(){d&&(n+=f,p&&(n+=f),d=p=!1)}function m(e){e&&(g(),n+=e)}for(;!function e(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(n)return void m(n);var r,i=t.getAttribute("cm-marker");if(i){var o=u.findMarks(lt(c,0),lt(h+1,0),(a=+i,function(e){return e.id==a}));return void(o.length&&(r=o[0].find(0))&&m(Je(u.doc,r.from,r.to).join(f)))}if("false"==t.getAttribute("contenteditable"))return;var l=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length)return;l&&g();for(var s=0;sl.ch&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)f--,p++;h[h.length-1]=y.slice(0,y.length-p).replace(/^\u200b+/,""),h[0]=h[0].slice(f).replace(/\u200b+$/,"");var x=lt(t,f),C=lt(a,d.length?$(d).length-p:0);return 1n&&(ml(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&Sr(this));else{for(var o=i.from(),l=i.to(),s=Math.max(n,o.line),n=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1,a=s;a>1;if((l?n[2*l-1]:0)>=o)i=l;else{if(!(n[2*l+1]o)&&e.top>t.offsetHeight?h=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=o&&(h=e.bottom),d+t.offsetWidth>l&&(d=l-t.offsetWidth)),t.style.top=h+"px",t.style.left=t.style.right="","right"==i?(d=c.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?d=0:"middle"==i&&(d=(c.sizer.clientWidth-t.offsetWidth)/2),t.style.left=d+"px"),n&&(s=this,a={left:d,top:h,right:d+t.offsetWidth,bottom:h+t.offsetHeight},null!=(u=xr(s,a)).scrollTop&&Mr(s,u.scrollTop),null!=u.scrollLeft&&Ar(s,u.scrollLeft))},triggerOnKeyDown:Ur(Zo),triggerOnKeyPress:Ur(Jo),triggerOnKeyUp:Qo,triggerOnMouseDown:Ur(rl),execCommand:function(e){if(Uo.hasOwnProperty(e))return Uo[e].call(null,this)},triggerElectric:Ur(function(e){xl(this,e)}),findPosH:function(e,t,n,r){var i=1;t<0&&(i=-1,t=-t);for(var o=ft(this.doc,e),l=0;l