Liferay.Loader.define("liferay!object-js-components-web$codemirror@5.65.12/addon/wrap/hardwrap",["module","exports","require","../../lib/codemirror"],(function(r,t,e){var n,a=void 0;window;n=function(r){"use strict";var t=r.Pos;function findParagraph(r,t,e){for(var n=e.paragraphStart||r.getHelper(t,"paragraphStart"),a=t.line,o=r.firstLine();a>o;--a){var i=r.getLine(a);if(n&&n.test(i))break;if(!/\S/.test(i)){++a;break}}for(var f=e.paragraphEnd||r.getHelper(t,"paragraphEnd"),l=t.line+1,h=r.lastLine();l<=h;++l){if(i=r.getLine(l),f&&f.test(i)){++l;break}if(!/\S/.test(i))break}return{from:a,to:l}}function findBreakPoint(r,t,e,n,a){for(var o=t;o<r.length&&" "==r.charAt(o);)o++;for(;o>0&&!e.test(r.slice(o-1,o+1));--o);if(!a&&o<=r.match(/^[ \t]*/)[0].length)for(o=t+1;o<r.length-1&&!e.test(r.slice(o-1,o+1));++o);for(var i=!0;;i=!1){var f=o;if(n)for(;" "==r.charAt(f-1);)--f;if(0!=f||!i)return{from:f,to:o};o=t}}function wrapRange(e,n,a,o){n=e.clipPos(n),a=e.clipPos(a);var i=o.column||80,f=o.wrapOn||/\s\S|-[^\.\d]/,l=!1!==o.forceBreak,h=!1!==o.killTrailingSpace,g=[],p="",c=n.line,s=e.getRange(n,a,!1);if(!s.length)return null;var m=s[0].match(/^[ \t]*/)[0];m.length>=i&&(i=m.length+1);for(var d=0;d<s.length;++d){var u=s[d],v=p.length,w=0;p&&u&&!f.test(p.charAt(p.length-1)+u.charAt(0))&&(p+=" ",w=1);var P="";if(d&&(P=u.match(/^\s*/)[0],u=u.slice(P.length)),p+=u,d){var b=p.length>i&&m==P&&findBreakPoint(p,i,f,h,l);b&&b.from==v&&b.to==v+w?(p=m+u,++c):g.push({text:[w?" ":""],from:t(c,v),to:t(c+1,P.length)})}for(;p.length>i;){var k=findBreakPoint(p,i,f,h,l);if(!(k.from!=k.to||l&&m!==p.slice(0,k.to)))break;g.push({text:["",m],from:t(c,k.from),to:t(c,k.to)}),p=m+p.slice(k.to),++c}}return g.length&&e.operation((function(){for(var t=0;t<g.length;++t){var n=g[t];(n.text||r.cmpPos(n.from,n.to))&&e.replaceRange(n.text,n.from,n.to)}})),g.length?{from:g[0].from,to:r.changeEnd(g[g.length-1])}:null}r.defineExtension("wrapParagraph",(function(r,e){e=e||{},r||(r=this.getCursor());var n=findParagraph(this,r,e);return wrapRange(this,t(n.from,0),t(n.to-1),e)})),r.commands.wrapLines=function(r){r.operation((function(){for(var e=r.listSelections(),n=r.lastLine()+1,a=e.length-1;a>=0;a--){var o,i=e[a];if(i.empty()){var f=findParagraph(r,i.head,{});o={from:t(f.from,0),to:t(f.to-1)}}else o={from:i.from(),to:i.to()};o.to.line>=n||(n=o.from.line,wrapRange(r,o.from,o.to,{}))}}))},r.defineExtension("wrapRange",(function(r,t,e){return wrapRange(this,r,t,e||{})})),r.defineExtension("wrapParagraphsInRange",(function(r,e,n){n=n||{};for(var a=this,o=[],i=r.line;i<=e.line;){var f=findParagraph(a,t(i,0),n);o.push(f),i=f.to}var l=!1;return o.length&&a.operation((function(){for(var r=o.length-1;r>=0;--r)l=l||wrapRange(a,t(o[r].from,0),t(o[r].to-1),n)})),l}))},"object"==typeof t&&"object"==typeof r?n(e("../../lib/codemirror")):"function"==typeof a&&a.amd?a(["../../lib/codemirror"],n):n(CodeMirror)}));
//# sourceMappingURL=hardwrap.js.map