Liferay.Loader.define("liferay!object-web$codemirror@5.65.12/addon/fold/foldgutter",["module","exports","require","../../lib/codemirror","./foldcode"],(function(o,t,e){var n,r=void 0;window;n=function(o){"use strict";o.defineOption("foldGutter",!1,(function(t,e,n){n&&n!=o.Init&&(t.clearGutter(t.state.foldGutter.options.gutter),t.state.foldGutter=null,t.off("gutterClick",onGutterClick),t.off("changes",onChange),t.off("viewportChange",onViewportChange),t.off("fold",onFold),t.off("unfold",onFold),t.off("swapDoc",onChange),t.off("optionChange",optionChange)),e&&(t.state.foldGutter=new State(function parseOptions(o){return!0===o&&(o={}),null==o.gutter&&(o.gutter="CodeMirror-foldgutter"),null==o.indicatorOpen&&(o.indicatorOpen="CodeMirror-foldgutter-open"),null==o.indicatorFolded&&(o.indicatorFolded="CodeMirror-foldgutter-folded"),o}(e)),updateInViewport(t),t.on("gutterClick",onGutterClick),t.on("changes",onChange),t.on("viewportChange",onViewportChange),t.on("fold",onFold),t.on("unfold",onFold),t.on("swapDoc",onChange),t.on("optionChange",optionChange))}));var t=o.Pos;function State(o){this.options=o,this.from=this.to=0}function isFolded(o,e){for(var n=o.findMarks(t(e,0),t(e+1,0)),r=0;r<n.length;++r)if(n[r].__isFold){var i=n[r].find(-1);if(i&&i.line===e)return n[r]}}function marker(o){if("string"==typeof o){var t=document.createElement("div");return t.className=o+" CodeMirror-guttermarker-subtle",t}return o.cloneNode(!0)}function updateFoldInfo(o,e,n){var r=o.state.foldGutter.options,i=e-1,a=o.foldOption(r,"minFoldSize"),d=o.foldOption(r,"rangeFinder"),f="string"==typeof r.indicatorFolded&&classTest(r.indicatorFolded),l="string"==typeof r.indicatorOpen&&classTest(r.indicatorOpen);o.eachLine(e,n,(function(e){++i;var n=null,u=e.gutterMarkers;if(u&&(u=u[r.gutter]),isFolded(o,i)){if(f&&u&&f.test(u.className))return;n=marker(r.indicatorFolded)}else{var c=t(i,0),p=d&&d(o,c);if(p&&p.to.line-p.from.line>=a){if(l&&u&&l.test(u.className))return;n=marker(r.indicatorOpen)}}(n||u)&&o.setGutterMarker(e,r.gutter,n)}))}function classTest(o){return new RegExp("(^|\\s)"+o+"(?:$|\\s)\\s*")}function updateInViewport(o){var t=o.getViewport(),e=o.state.foldGutter;e&&(o.operation((function(){updateFoldInfo(o,t.from,t.to)})),e.from=t.from,e.to=t.to)}function onGutterClick(o,e,n){var r=o.state.foldGutter;if(r){var i=r.options;if(n==i.gutter){var a=isFolded(o,e);a?a.clear():o.foldCode(t(e,0),i)}}}function optionChange(o,t){"mode"==t&&onChange(o)}function onChange(o){var t=o.state.foldGutter;if(t){var e=t.options;t.from=t.to=0,clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout((function(){updateInViewport(o)}),e.foldOnChangeTimeSpan||600)}}function onViewportChange(o){var t=o.state.foldGutter;if(t){var e=t.options;clearTimeout(t.changeUpdate),t.changeUpdate=setTimeout((function(){var e=o.getViewport();t.from==t.to||e.from-t.to>20||t.from-e.to>20?updateInViewport(o):o.operation((function(){e.from<t.from&&(updateFoldInfo(o,e.from,t.from),t.from=e.from),e.to>t.to&&(updateFoldInfo(o,t.to,e.to),t.to=e.to)}))}),e.updateViewportTimeSpan||400)}}function onFold(o,t){var e=o.state.foldGutter;if(e){var n=t.line;n>=e.from&&n<e.to&&updateFoldInfo(o,n,n+1)}}},"object"==typeof t&&"object"==typeof o?n(e("../../lib/codemirror"),e("./foldcode")):"function"==typeof r&&r.amd?r(["../../lib/codemirror","./foldcode"],n):n(CodeMirror)}));
//# sourceMappingURL=foldgutter.js.map