(function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){function k(c,f){var e=c.getRange(a(f.line,f.ch-1),a(f.line,f.ch+1));return 2==e.length?e:null}function h(c){for(var f={name:"autoCloseBrackets",Backspace:function(f){var e,j,i;if(f.getOption("disableInput"))return b.Pass;e=f.listSelections();for(i=0;i1&&j.getRange(a(n.line,n.ch-2),n)==c+c&&(n.ch<=2||j.getRange(a(n.line,n.ch-3),a(n.line,n.ch-2))!=c))g="addFour";else if(!(c==i&&b.isWordChar(g))&&(j.getLine(n.line).length==n.ch||e.indexOf(g)>=0||d.test(g)))g="both";else return b.Pass;else g="surround";if(p){if(p!=g)return b.Pass}else p=g}j.operation(function(){var a,f;if(p=="skip")j.execCommand("goCharRight");else if(p=="skipThree")for(f=0;f<3;f++)j.execCommand("goCharRight");else if(p=="surround"){a=j.getSelections();for(f=0;f< a.length;f++)a[f]=c+a[f]+i;j.replaceSelections(a,"around")}else p=="both"?(j.replaceSelection(c+i,null),j.execCommand("goCharLeft")):p=="addFour"&&(j.replaceSelection(c+c+c+c,"before"),j.execCommand("goCharRight"))})};c!=i&&(f["'"+i+"'"]=function(c){for(var f=c.listSelections(),e,d=0;dj.ch&&(m=m.slice(0,m.length-o.end+j.ch)),i=m.toLowerCase(),!m||"string"==o.type&&(o.end!=j.ch||!/[\"\']/.test(o.string.charAt(o.string.length-1))||1==o.string.length)||"tag"==o.type&&"closeTag"==p.type||o.string.indexOf("/")==o.string.length-1||q&&-1"+(o?"\n\n":"")+"",newPos:o?b.Pos(j.line+1,0):b.Pos(j.line,j.ch+1)}}for(l=f.length-1;0<=l;l--)i=e[l],c.replaceRange(i.text,f[l].head,f[l].anchor,"+insert"),j=c.listSelections().slice(0),j[l]={head:i.newPos,anchor:i.newPos},c.setSelections(j),i.indent&&(c.indentLine(i.newPos.line,null,!0),c.indentLine(i.newPos.line+1,null,!0))}function h(a,f){if(a.indexOf)return a.indexOf(f);for(var e=0,i=a.length;e"}a.replaceSelections(j)}}return c});(typeof f!="object"||f.whenOpening)&&(e["'>'"]=function(a){return k(a)});a.addKeyMap(e)}});var d="area base br col command embed hr img input keygen link meta param source track wbr".split(" "), a="applet blockquote body button div dl fieldset form frameset h1 h2 h3 h4 h5 h6 head html iframe layer legend object ol p select table ul".split(" ")}); (function(){function b(b){var d=b.getCursor(),a=b.getTokenAt(d),c=CodeMirror.innerMode(b.getMode(),a.state).mode,f,e,i,h;if("comment"==a.type&&c.blockCommentStart&&(e=a.string.indexOf(c.blockCommentEnd),i=b.getRange(CodeMirror.Pos(d.line,0),CodeMirror.Pos(d.line,a.end)),-1==e||e!=a.string.length-c.blockCommentEnd.length))if(0==a.string.indexOf(c.blockCommentStart)){if(f=i.slice(0,a.start),!/^\s*$/.test(f)){f="";for(d=0;d a.start&&/^\s*$/.test(i.slice(0,h))&&(f=i.slice(0,h));if(null!=f)b.replaceSelection("\n"+f+c.blockCommentContinue,"end");else return CodeMirror.Pass}for(var k=["clike","css","javascript"],h=0;hh)))for(u==e.line&&(k=e.ch-(0>b?1:0));k!=t;k+=b)if(v=n.charAt(k),d.test(v)&&(void 0===j||a.getTokenTypeAt(c(u,k+1))==j))if(w=f[v],">"==w.charAt(1)==0document.documentMode),c=b.Pos,f={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},e=null;b.defineOption("matchBrackets", !1,function(a,e,c){if(c&&c!=b.Init&&a.off("cursorActivity",d),e){a.state.matchBrackets=typeof e=="object"?e:{};a.on("cursorActivity",d)}});b.defineExtension("matchBrackets",function(){g(this,!0)});b.defineExtension("findMatchingBracket",function(a,e,c){return k(this,a,e,c)});b.defineExtension("scanForBracket",function(a,e,c,j){return h(this,a,e,c,j)})}); (function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror"),require("../fold/xml-fold")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../fold/xml-fold"],b):b(CodeMirror)})(function(b){function k(b){b.state.tagHit&&b.state.tagHit.clear();b.state.tagOther&&b.state.tagOther.clear();b.state.tagHit=b.state.tagOther=null}function h(d){d.state.failedTagMatch=!1;d.operation(function(){var a,c,f,e,i;(k(d),d.somethingSelected())||(a=d.getCursor(), c=d.getViewport(),c.from=Math.min(c.from,a.line),c.to=Math.max(a.line+1,c.to),f=b.findMatchingTag(d,a,c),f)&&(d.state.matchBothTags&&(e="open"==f.at?f.open:f.close,e&&(d.state.tagHit=d.markText(e.from,e.to,{className:"CodeMirror-matchingtag"}))),i="close"==f.at?f.open:f.close,i?d.state.tagOther=d.markText(i.from,i.to,{className:"CodeMirror-matchingtag"}):d.state.failedTagMatch=!0)})}function g(b){b.state.failedTagMatch&&h(b)}b.defineOption("matchTags",!1,function(d,a,c){if(c&&c!=b.Init&&(d.off("cursorActivity", h),d.off("viewportChange",g),k(d)),a){d.state.matchBothTags=typeof a=="object"&&a.bothTags;d.on("cursorActivity",h);d.on("viewportChange",g);h(d)}});b.commands.toMatchingTag=function(d){var a=b.findMatchingTag(d,d.getCursor()),c;a&&(c="close"==a.at?a.open:a.close,c&&d.extendSelection(c.to,c.from))}}); (function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){b.defineOption("showTrailingSpace",!1,function(k,h,g){g==b.Init&&(g=false);g&&!h?k.removeOverlay("trailingspace"):!g&&h&&k.addOverlay({token:function(b){for(var a=b.string.length,c=a;c&&/\s/.test(b.string.charAt(c-1));--c);return c>b.pos?(b.pos=c,null):(b.pos=a,"trailingspace")},name:"trailingspace"})})}); (function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){function k(a,c,f,e){function d(b){var j=k(a,c),f,i;if(!j||j.to.line-j.from.linea.firstLine();)c=b.Pos(c.line-1,0),j=d(!1);j&&(!j.cleared&&"unfold"!==e)&&(f=h(a,f),b.on(f,"mousedown",function(a){q.clear();b.e_preventDefault(a)}),q=a.markText(j.from,j.to,{replacedWith:f,clearOnEnter:!0,__isFold:!0}),q.on("clear",function(e,c){b.signal(a,"unfold",a,e,c)}),b.signal(a,"fold",a,j.from,j.to))}function h(a,c){var b=g(a,c,"widget"),e;return"string"==typeof b&&(e=document.createTextNode(b),b=document.createElement("span"), b.appendChild(e),b.className="CodeMirror-foldmarker"),b}function g(a,c,b){return c&&void 0!==c[b]?c[b]:(a=a.options.foldOptions)&&void 0!==a[b]?a[b]:d[b]}b.newFoldFunction=function(a,b){return function(f,e){k(f,e,{rangeFinder:a,widget:b})}};b.defineExtension("foldCode",function(a,b,f){k(this,a,b,f)});b.defineExtension("isFolded",function(a){for(var a=this.findMarksAt(a),b=0;b=f?-1:a.lastIndexOf(e,f-1),-1==j){if(1==i)break;i=1;f=a.length}else{if(1==i&&jn&&(n=m.length),0>s&&(s=m.length),r=Math.min(n,s),r==m.length);){if(k.getTokenTypeAt(b.Pos(p,r+1))==c)if(r==n)++o;else if(!--o){j=p;q=r;break a}++r}}if(null!=j&&(d!=j||q!=i))return{from:b.Pos(d,i),to:b.Pos(j,q)}}});b.registerHelper("fold","import",function(k,h){function g(a){var e,c,d,h;if(ak.lastLine()|| (e=k.getTokenAt(b.Pos(a,1)),/\S/.test(e.string)||(e=k.getTokenAt(b.Pos(a,e.end+1))),"keyword"!=e.type||"import"!=e.string))return null;c=a;for(a=Math.min(k.lastLine(),a+10);c<=a;++c)if(d=k.getLine(c),h=d.indexOf(";"),-1!=h)return{startCh:e.end,end:b.Pos(c,h)}}var h=h.line,d=g(h),a,c;if(!d||g(h-1)||(a=g(h-2))&&a.end.line==h-1)return null;for(a=d.end;!(c=g(a.line+1),null==c);)a=c.end;return{from:k.clipPos(b.Pos(h,d.startCh+1)),to:a}});b.registerHelper("fold","include",function(k,h){function g(a){if(a< k.firstLine()||a>k.lastLine())return null;var e=k.getTokenAt(b.Pos(a,1));return/\S/.test(e.string)||(e=k.getTokenAt(b.Pos(a,e.end+1))),"meta"==e.type&&"#include"==e.string.slice(0,8)?e.start+8:void 0}var h=h.line,d=g(h),a,c;if(null==d||null!=g(h-1))return null;for(a=h;!(c=g(a+1),null==c);)++a;return{from:b.Pos(h,d+1),to:k.clipPos(b.Pos(a))}})}); (function(b){"object"==typeof exports&&"object"==typeof module?b(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],b):b(CodeMirror)})(function(b){function k(a,b,e,c){this.line=b;this.ch=e;this.cm=a;this.text=a.getLine(b);this.min=c?c.from:a.firstLine();this.max=c?c.to-1:a.lastLine()}function h(a,b){var e=a.cm.getTokenTypeAt(o(a.line,b));return e&&/\btag\b/.test(e)}function g(a){if(!(a.line>=a.max))return a.ch=0,a.text=a.cm.getLine(++a.line),!0} function d(a){if(!(a.line<=a.min))return a.text=a.cm.getLine(--a.line),a.ch=a.text.length,!0}function a(a){for(var b,e,c;;){if(b=a.text.indexOf(">",a.ch),-1==b)if(g(a))continue;else break;if(h(a,b+1))return e=a.text.lastIndexOf("/",b),c=-1d&&(!e||e==i[2]))return{tag:i[2],from:o(g,k),to:o(b.line,b.ch)}}else c.push(i[2])}}function i(a,b){for(var e=[],f,i;;){var g;a:{g=a;for(var k= void 0,l=i=void 0;;){if(k=g.ch?g.text.lastIndexOf(">",g.ch-1):-1,-1==k)if(d(g))continue;else{g=void 0;break a}if(h(g,k+1)){g=(i=g.text.lastIndexOf("/",k),l=-1i&&(!b||b==k[2]))return{tag:k[2],from:o(a.line,a.ch),to:o(l,g)}}}}}var o=b.Pos, l=RegExp("<(/?)([A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*)","g");b.registerHelper("fold","xml",function(b,c){for(var d=new k(b,c.line,0),i,g,h;!(i=f(d), !i||d.line!=c.line||!(g=a(d)));)if(!i[1]&&"selfClose"!=g)return c=o(d.line,d.ch),h=e(d,i[2]),h&&{from:c,to:h.from}});b.findMatchingTag=function(b,d,f){var g=new k(b,d.line,d.ch,f),h;if(-1!=g.text.indexOf(">")||-1!=g.text.indexOf("<")){var l=a(g),s=l&&o(g.line,g.ch),t=l&&c(g);if(l&&"selfClose"!=l&&t&&!(0<(g.line-d.line||g.ch-d.ch)))return h={from:o(g.line,g.ch),to:s,tag:t[2]},t[1]?{open:i(g,t[2]),close:h,at:"close"}:(g=new k(b,s.line,s.ch,f),{open:h,close:e(g,t[2]),at:"open"})}};b.findEnclosingTag= function(a,b,c){for(var d=new k(a,b.line,b.ch,c),f,g,h;!(f=i(d),!f);)if(g=new k(a,b.line,b.ch,c),h=e(g,f.tag),h)return{open:f,close:h}};b.scanForClosingTag=function(a,b,c,d){a=new k(a,b.line,b.ch,d?{from:0,to:d}:null);return e(a,c)}}); (function(){CodeMirror.defineExtension("autoFormatAll",function(b,k){for(var h=this,g=h.getMode(),d=h.getRange(b,k).split("\n"),a=CodeMirror.copyState(g,h.getTokenAt(b).state),c=h.getOption("tabSize"),f="",e=0,i=0==b.ch,o,l=0;lh&&(a+=g(k.substring(h,d[c].start)),h=d[c].start),d[c].start<=h&&d[c].end>=h&&(a+=k.substring(h,d[c].end),h=d[c].end);h",noBreak:!1,noBreakEmpty:null,tagType:"",tagName:"",isXML:!1,newlineAfterToken:function(b,h,g){var d=!1,a=null,c="",f;if(this.isXML="xml"==this.configuration?!0:!1,"comment"==b||/<\!--/.test(g))return!1;if("tag"==b){if(0==h.indexOf("<")&&0==!h.indexOf("")&&"open"==this.tagType)return(this.tagType="",f=this.isXML?"[^<]*?":"",RegExp("^"+f+"","i").test(g))?(this.noBreak=!1,this.isXML||(this.tagName=""),!1):(d=this.noBreak,this.noBreak=!1,d?!1:!0);if(0==h.indexOf("")&&"close"==this.tagType)return(this.tagType="",0==g.indexOf("<")&&(a=g.match(/^<\/?\s*?([\w]+?)(\s|>)/i),c=null!=a?a[1].toLowerCase():"",-1=="|label|li|option|textarea|title|a|b|bdi|bdo|big|center|cite|del|em|font|i|img|ins|s|small|span|strike|strong|sub|sup|u|".indexOf("|"+c+"|")))?(this.noBreak=!1,!0):(d=this.noBreak,this.noBreak=!1,d?!1:!0)}return 0==g.indexOf("<")?(this.noBreak=!1,this.isXML&&""!=this.tagName)?(this.tagName="",!1):(a=g.match(/^<\/?\s*?([\w]+?)(\s|>)/i),c=null!= a?a[1].toLowerCase():"",-1!="|label|li|option|textarea|title|a|b|bdi|bdo|big|center|cite|del|em|font|i|img|ins|s|small|span|strike|strong|sub|sup|u|".indexOf("|"+c+"|")?!1:!0):!1}});CodeMirror.defineExtension("commentRange",function(b,h,g){var d=this,a=CodeMirror.innerMode(d.getMode(),d.getTokenAt(h).state).mode;d.operation(function(){if(b)d.replaceRange(a.commentEnd,g),d.replaceRange(a.commentStart,h),h.line==g.line&&h.ch==g.ch&&d.setCursor(h.line,h.ch+a.commentStart.length);else{var c=d.getRange(h, g),f=c.indexOf(a.commentStart),e=c.lastIndexOf(a.commentEnd);-1f&&(c=c.substr(0,f)+c.substring(f+a.commentStart.length,e)+c.substr(e+a.commentEnd.length));d.replaceRange(c,h,g)}})});CodeMirror.defineExtension("autoIndentRange",function(b,h){var g=this;this.operation(function(){for(var d=b.line;d<=h.line;d++)g.indentLine(d,"smart")})});CodeMirror.defineExtension("autoFormatRange",function(b,h){for(var g=this,d=g.getMode(),a=g.getRange(b,h).split("\n"),c=CodeMirror.copyState(d,g.getTokenAt(b).state), f=g.getOption("tabSize"),e="",i=0,o=0==b.ch,l,j=0;j=b.minChars&&a.addOverlay(b.overlay=d(g,!1,b.style)))})}function d(a,b,c){return{token:function(d){if(d.match(a)&&(!b||(!d.start||!b.test(d.string.charAt(d.start-1)))&&(d.pos==d.string.length||!b.test(d.string.charAt(d.pos)))))return c;d.next();d.skipTo(a.charAt(0))||d.skipToEnd()}}}var a=2,c="matchhighlight",f=100;b.defineOption("highlightSelectionMatches",!1,function(a,c,d){if(d&&d!=b.Init){(d=a.state.matchHighlighter.overlay)&& a.removeOverlay(d);clearTimeout(a.state.matchHighlighter.timeout);a.state.matchHighlighter=null;a.off("cursorActivity",h)}if(c){a.state.matchHighlighter=new k(c);g(a);a.on("cursorActivity",h)}})});