(function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)})(function(e){function q(c){if(c.getOption("disableInput"))return e.Pass;for(var d=c.listSelections(),a,l=[],m=0;m<d.length;m++){var f=d[m].head,g=c.getTokenAt(f);if("comment"!=g.type)return e.Pass;var b=e.innerMode(c.getMode(),g.state).mode;if(!a)a=b;else if(a!=b)return e.Pass;b=null;if(a.blockCommentStart&&a.blockCommentContinue){var k=
g.string.indexOf(a.blockCommentEnd),n=c.getRange(e.Pos(f.line,0),e.Pos(f.line,g.end)),h;if(!(-1!=k&&k==g.string.length-a.blockCommentEnd.length&&f.ch>=k))if(0==g.string.indexOf(a.blockCommentStart)){if(b=n.slice(0,g.start),!/^\s*$/.test(b))for(b="",k=0;k<g.start;++k)b+=" "}else-1!=(h=n.indexOf(a.blockCommentContinue))&&h+a.blockCommentContinue.length>g.start&&/^\s*$/.test(n.slice(0,h))&&(b=n.slice(0,h));null!=b&&(b+=a.blockCommentContinue)}null==b&&a.lineComment&&r(c)&&(f=c.getLine(f.line),h=f.indexOf(a.lineComment),
-1<h&&(b=f.slice(0,h),b=/\S/.test(b)?null:b+(a.lineComment+f.slice(h+a.lineComment.length).match(/^\s*/)[0])));if(null==b)return e.Pass;l[m]="\n"+b}c.operation(function(){for(var a=d.length-1;0<=a;a--)c.replaceRange(l[a],d[a].from(),d[a].to(),"+insert")})}function r(c){return(c=c.getOption("continueComments"))&&"object"==typeof c?!1!==c.continueLineComment:!0}for(var p=["clike","css","javascript"],l=0;l<p.length;++l)e.extendMode(p[l],{blockCommentContinue:" * "});e.defineOption("continueComments",
null,function(c,d,a){a&&a!=e.Init&&c.removeKeyMap("continueComment");d&&(a="Enter","string"==typeof d?a=d:"object"==typeof d&&d.key&&(a=d.key),d={name:"continueComment"},d[a]=q,c.addKeyMap(d))})});
