Liferay.Loader.define("journal-web$codemirror@5.65.2/addon/comment/comment",["module","exports","require","../../lib/codemirror"],(function(e,n,t){var i,o=void 0;window;i=function(e){"use strict";var n={},t=/[^\s\u00a0]/,i=e.Pos,o=e.cmpPos;function firstNonWS(e){var n=e.search(t);return-1==n?0:n}function getMode(e,n){var t=e.getMode();return!1!==t.useInnerComments&&t.innerMode?e.getModeAt(n):t}e.commands.toggleComment=function(e){e.toggleComment()},e.defineExtension("toggleComment",(function(e){e||(e=n);for(var t=this,o=1/0,l=this.listSelections(),r=null,a=l.length-1;a>=0;a--){var m=l[a].from(),c=l[a].to();m.line>=o||(c.line>=o&&(c=i(o,0)),o=m.line,null==r?t.uncomment(m,c,e)?r="un":(t.lineComment(m,c,e),r="line"):"un"==r?t.uncomment(m,c,e):t.lineComment(m,c,e))}})),e.defineExtension("lineComment",(function(e,o,l){l||(l=n);var r=this,a=getMode(r,e),m=r.getLine(e.line);if(null!=m&&!function probablyInsideString(e,n,t){return/\bstring\b/.test(e.getTokenTypeAt(i(n.line,0)))&&!/^[\'\"\`]/.test(t)}(r,e,m)){var c=l.lineComment||a.lineComment;if(c){var g=Math.min(0!=o.ch||o.line==e.line?o.line+1:o.line,r.lastLine()+1),f=null==l.padding?" ":l.padding,s=l.commentBlankLines||e.line==o.line;r.operation((function(){if(l.indent){for(var n=null,o=e.line;o<g;++o){var a=(m=r.getLine(o)).slice(0,firstNonWS(m));(null==n||n.length>a.length)&&(n=a)}for(o=e.line;o<g;++o){var m=r.getLine(o),d=n.length;(s||t.test(m))&&(m.slice(0,d)!=n&&(d=firstNonWS(m)),r.replaceRange(n+c+f,i(o,0),i(o,d)))}}else for(o=e.line;o<g;++o)(s||t.test(r.getLine(o)))&&r.replaceRange(c+f,i(o,0))}))}else(l.blockCommentStart||a.blockCommentStart)&&(l.fullLines=!0,r.blockComment(e,o,l))}})),e.defineExtension("blockComment",(function(e,l,r){r||(r=n);var a=this,m=getMode(a,e),c=r.blockCommentStart||m.blockCommentStart,g=r.blockCommentEnd||m.blockCommentEnd;if(c&&g){if(!/\bcomment\b/.test(a.getTokenTypeAt(i(e.line,0)))){var f=Math.min(l.line,a.lastLine());f!=e.line&&0==l.ch&&t.test(a.getLine(f))&&--f;var s=null==r.padding?" ":r.padding;e.line>f||a.operation((function(){if(0!=r.fullLines){var n=t.test(a.getLine(f));a.replaceRange(s+g,i(f)),a.replaceRange(c+s,i(e.line,0));var d=r.blockCommentLead||m.blockCommentLead;if(null!=d)for(var u=e.line+1;u<=f;++u)(u!=f||n)&&a.replaceRange(d+s,i(u,0))}else{var h=0==o(a.getCursor("to"),l),v=!a.somethingSelected();a.replaceRange(g,l),h&&a.setSelection(v?l:a.getCursor("from"),l),a.replaceRange(c,e)}}))}}else(r.lineComment||m.lineComment)&&0!=r.fullLines&&a.lineComment(e,l,r)})),e.defineExtension("uncomment",(function(e,o,l){l||(l=n);var r,a=this,m=getMode(a,e),c=Math.min(0!=o.ch||o.line==e.line?o.line:o.line-1,a.lastLine()),g=Math.min(e.line,c),f=l.lineComment||m.lineComment,s=[],d=null==l.padding?" ":l.padding;e:if(f){for(var u=g;u<=c;++u){var h=a.getLine(u),v=h.indexOf(f);if(v>-1&&!/comment/.test(a.getTokenTypeAt(i(u,v+1)))&&(v=-1),-1==v&&t.test(h))break e;if(v>-1&&t.test(h.slice(0,v)))break e;s.push(h)}if(a.operation((function(){for(var e=g;e<=c;++e){var n=s[e-g],t=n.indexOf(f),o=t+f.length;t<0||(n.slice(o,o+d.length)==d&&(o+=d.length),r=!0,a.replaceRange("",i(e,t),i(e,o)))}})),r)return!0}var p=l.blockCommentStart||m.blockCommentStart,C=l.blockCommentEnd||m.blockCommentEnd;if(!p||!C)return!1;var b=l.blockCommentLead||m.blockCommentLead,k=a.getLine(g),L=k.indexOf(p);if(-1==L)return!1;var x=c==g?k:a.getLine(c),S=x.indexOf(C,c==g?L+p.length:0),M=i(g,L+1),R=i(c,S+1);if(-1==S||!/comment/.test(a.getTokenTypeAt(M))||!/comment/.test(a.getTokenTypeAt(R))||a.getRange(M,R,"\n").indexOf(C)>-1)return!1;var y=k.lastIndexOf(p,e.ch),O=-1==y?-1:k.slice(0,e.ch).indexOf(C,y+p.length);if(-1!=y&&-1!=O&&O+C.length!=e.ch)return!1;O=x.indexOf(C,o.ch);var T=x.slice(o.ch).lastIndexOf(p,O-o.ch);return y=-1==O||-1==T?-1:o.ch+T,(-1==O||-1==y||y==o.ch)&&(a.operation((function(){a.replaceRange("",i(c,S-(d&&x.slice(S-d.length,S)==d?d.length:0)),i(c,S+C.length));var e=L+p.length;if(d&&k.slice(e,e+d.length)==d&&(e+=d.length),a.replaceRange("",i(g,L),i(g,e)),b)for(var n=g+1;n<=c;++n){var o=a.getLine(n),l=o.indexOf(b);if(-1!=l&&!t.test(o.slice(0,l))){var r=l+b.length;d&&o.slice(r,r+d.length)==d&&(r+=d.length),a.replaceRange("",i(n,l),i(n,r))}}})),!0)}))},"object"==typeof n&&"object"==typeof e?i(t("../../lib/codemirror")):"function"==typeof o&&o.amd?o(["../../lib/codemirror"],i):i(CodeMirror)}));
//# sourceMappingURL=comment.js.map