Liferay.Loader.define("liferay!template-web$codemirror@5.65.2/addon/selection/mark-selection",["module","exports","require","../../lib/codemirror"],(function(e,t,r){var o,n=void 0;window;o=function(e){"use strict";function onCursorActivity(e){e.state.markedSelection&&e.operation((function(){!function update(e){if(!e.somethingSelected())return clear(e);if(e.listSelections().length>1)return reset(e);var t=e.getCursor("start"),o=e.getCursor("end"),n=e.state.markedSelection;if(!n.length)return coverRange(e,t,o);var i=n[0].find(),a=n[n.length-1].find();if(!i||!a||o.line-t.line<=8||r(t,a.to)>=0||r(o,i.from)<=0)return reset(e);for(;r(t,i.from)>0;)n.shift().clear(),i=n[0].find();for(r(t,i.from)<0&&(i.to.line-t.line<8?(n.shift().clear(),coverRange(e,t,i.to,0)):coverRange(e,t,i.from,0));r(o,a.to)<0;)n.pop().clear(),a=n[n.length-1].find();r(o,a.to)>0&&(o.line-a.from.line<8?(n.pop().clear(),coverRange(e,a.from,o)):coverRange(e,a.to,o))}(e)}))}function onChange(e){e.state.markedSelection&&e.state.markedSelection.length&&e.operation((function(){clear(e)}))}e.defineOption("styleSelectedText",!1,(function(t,r,o){var n=o&&o!=e.Init;r&&!n?(t.state.markedSelection=[],t.state.markedSelectionStyle="string"==typeof r?r:"CodeMirror-selectedtext",reset(t),t.on("cursorActivity",onCursorActivity),t.on("change",onChange)):!r&&n&&(t.off("cursorActivity",onCursorActivity),t.off("change",onChange),clear(t),t.state.markedSelection=t.state.markedSelectionStyle=null)}));var t=e.Pos,r=e.cmpPos;function coverRange(e,o,n,i){if(0!=r(o,n))for(var a=e.state.markedSelection,c=e.state.markedSelectionStyle,l=o.line;;){var f=l==o.line?o:t(l,0),s=l+8,d=s>=n.line,m=d?n:t(s,0),u=e.markText(f,m,{className:c});if(null==i?a.push(u):a.splice(i++,0,u),d)break;l=s}}function clear(e){for(var t=e.state.markedSelection,r=0;r<t.length;++r)t[r].clear();t.length=0}function reset(e){clear(e);for(var t=e.listSelections(),r=0;r<t.length;r++)coverRange(e,t[r].from(),t[r].to())}},"object"==typeof t&&"object"==typeof e?o(r("../../lib/codemirror")):"function"==typeof n&&n.amd?n(["../../lib/codemirror"],o):o(CodeMirror)}));
//# sourceMappingURL=mark-selection.js.map