!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(u){function l(n){if(n.getOption("disableInput"))return u.Pass;for(var e,t=n.listSelections(),o=[],i=0;i<t.length;i++){var l=t[i].head;if(!/\bcomment\b/.test(n.getTokenTypeAt(l)))return u.Pass;var r=n.getModeAt(l);if(e){if(e!=r)return u.Pass}else e=r;var m=null;if(e.blockCommentStart&&e.blockCommentContinue){var c,f,s=(c=n.getLine(l.line).slice(0,l.ch)).lastIndexOf(e.blockCommentEnd);if(-1!=s&&s==l.ch-e.blockCommentEnd.length);else if(-1<(f=c.lastIndexOf(e.blockCommentStart))&&s<f){if(m=c.slice(0,f),/\S/.test(m)){m="";for(var a=0;a<f;++a)m+=" "}}else-1<(f=c.indexOf(e.blockCommentContinue))&&!/\S/.test(c.slice(0,f))&&(m=c.slice(0,f));null!=m&&(m+=e.blockCommentContinue)}if(null==m&&e.lineComment&&d(n))-1<(f=(c=n.getLine(l.line)).indexOf(e.lineComment))&&(m=c.slice(0,f),/\S/.test(m)?m=null:m+=e.lineComment+c.slice(f+e.lineComment.length).match(/^\s*/)[0]);if(null==m)return u.Pass;o[i]="\n"+m}n.operation(function(){for(var e=t.length-1;0<=e;e--)n.replaceRange(o[e],t[e].from(),t[e].to(),"+insert")})}function d(e){var n=e.getOption("continueComments");return!n||"object"!=typeof n||!1!==n.continueLineComment}u.defineOption("continueComments",null,function(e,n,t){if(t&&t!=u.Init&&e.removeKeyMap("continueComment"),n){var o="Enter";"string"==typeof n?o=n:"object"==typeof n&&n.key&&(o=n.key);var i={name:"continueComment"};i[o]=l,e.addKeyMap(i)}})});