Liferay.Loader.define("liferay!object-web$codemirror@5.65.12/addon/search/matchesonscrollbar",["module","exports","require","../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],(function(t,o,e){var i,n=void 0;window;i=function(t){"use strict";function SearchAnnotation(t,o,e,i){this.cm=t,this.options=i;var n={listenForChanges:!1};for(var a in i)n[a]=i[a];n.className||(n.className="CodeMirror-search-match"),this.annotation=t.annotateScrollbar(n),this.query=o,this.caseFold=e,this.gap={from:t.firstLine(),to:t.lastLine()+1},this.matches=[],this.update=null,this.findMatches(),this.annotation.update(this.matches);var r=this;t.on("change",this.changeHandler=function(t,o){r.onChange(o)})}function offsetLine(t,o,e){return t<=o?t:Math.max(o,t+e)}t.defineExtension("showMatchesOnScrollbar",(function(t,o,e){return"string"==typeof e&&(e={className:e}),e||(e={}),new SearchAnnotation(this,t,o,e)})),SearchAnnotation.prototype.findMatches=function(){if(this.gap){for(var o=0;o<this.matches.length&&!((n=this.matches[o]).from.line>=this.gap.to);o++)n.to.line>=this.gap.from&&this.matches.splice(o--,1);for(var e=this.cm.getSearchCursor(this.query,t.Pos(this.gap.from,0),{caseFold:this.caseFold,multiline:this.options.multiline}),i=this.options&&this.options.maxMatches||1e3;e.findNext();){var n;if((n={from:e.from(),to:e.to()}).from.line>=this.gap.to)break;if(this.matches.splice(o++,0,n),this.matches.length>i)break}this.gap=null}},SearchAnnotation.prototype.onChange=function(o){var e=o.from.line,i=t.changeEnd(o).line,n=i-o.to.line;if(this.gap?(this.gap.from=Math.min(offsetLine(this.gap.from,e,n),o.from.line),this.gap.to=Math.max(offsetLine(this.gap.to,e,n),o.from.line)):this.gap={from:o.from.line,to:i+1},n)for(var a=0;a<this.matches.length;a++){var r=this.matches[a],s=offsetLine(r.from.line,e,n);s!=r.from.line&&(r.from=t.Pos(s,r.from.ch));var h=offsetLine(r.to.line,e,n);h!=r.to.line&&(r.to=t.Pos(h,r.to.ch))}clearTimeout(this.update);var c=this;this.update=setTimeout((function(){c.updateAfterChange()}),250)},SearchAnnotation.prototype.updateAfterChange=function(){this.findMatches(),this.annotation.update(this.matches)},SearchAnnotation.prototype.clear=function(){this.cm.off("change",this.changeHandler),this.annotation.clear()}},"object"==typeof o&&"object"==typeof t?i(e("../../lib/codemirror"),e("./searchcursor"),e("../scroll/annotatescrollbar")):"function"==typeof n&&n.amd?n(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],i):i(CodeMirror)}));
//# sourceMappingURL=matchesonscrollbar.js.map