Liferay.Loader.define("portal-search-web$codemirror@5.62.0/addon/search/matchesonscrollbar",["module","exports","require","../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],(function(t,o,e){var i;window,i=function(t){"use strict";function o(t,o,e,i){this.cm=t,this.options=i;var a={listenForChanges:!1};for(var s in i)a[s]=i[s];a.className||(a.className="CodeMirror-search-match"),this.annotation=t.annotateScrollbar(a),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 e(t,o,e){return t<=o?t:Math.max(o,t+e)}t.defineExtension("showMatchesOnScrollbar",(function(t,e,i){return"string"==typeof i&&(i={className:i}),i||(i={}),new o(this,t,e,i)})),o.prototype.findMatches=function(){if(this.gap){for(var o=0;o<this.matches.length&&!((a=this.matches[o]).from.line>=this.gap.to);o++)a.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 a;if((a={from:e.from(),to:e.to()}).from.line>=this.gap.to)break;if(this.matches.splice(o++,0,a),this.matches.length>i)break}this.gap=null}},o.prototype.onChange=function(o){var i=o.from.line,a=t.changeEnd(o).line,s=a-o.to.line;if(this.gap?(this.gap.from=Math.min(e(this.gap.from,i,s),o.from.line),this.gap.to=Math.max(e(this.gap.to,i,s),o.from.line)):this.gap={from:o.from.line,to:a+1},s)for(var r=0;r<this.matches.length;r++){var n=this.matches[r],h=e(n.from.line,i,s);h!=n.from.line&&(n.from=t.Pos(h,n.from.ch));var c=e(n.to.line,i,s);c!=n.to.line&&(n.to=t.Pos(c,n.to.ch))}clearTimeout(this.update);var l=this;this.update=setTimeout((function(){l.updateAfterChange()}),250)},o.prototype.updateAfterChange=function(){this.findMatches(),this.annotation.update(this.matches)},o.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")):i(CodeMirror)}));
//# sourceMappingURL=matchesonscrollbar.js.map