Liferay.Loader.define("liferay!template-web$codemirror@5.65.2/addon/edit/matchbrackets",["module","exports","require","../../lib/codemirror"],(function(t,e,r){var a,c=void 0;window;a=function(t){var e=/MSIE \d/.test(navigator.userAgent)&&(null==document.documentMode||document.documentMode<8),r=t.Pos,a={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function bracketRegex(t){return t&&t.bracketRegex||/[(){}[\]]/}function findMatchingBracket(t,e,c){var n=t.getLineHandle(e.line),i=e.ch-1,o=c&&c.afterCursor;null==o&&(o=/(^| )cm-fat-cursor($| )/.test(t.getWrapperElement().className));var h=bracketRegex(c),l=!o&&i>=0&&h.test(n.text.charAt(i))&&a[n.text.charAt(i)]||h.test(n.text.charAt(i+1))&&a[n.text.charAt(++i)];if(!l)return null;var s=">"==l.charAt(1)?1:-1;if(c&&c.strict&&s>0!=(i==e.ch))return null;var f=t.getTokenTypeAt(r(e.line,i+1)),u=scanForBracket(t,r(e.line,i+(s>0?1:0)),s,f,c);return null==u?null:{from:r(e.line,i),to:u&&u.pos,match:u&&u.ch==l.charAt(0),forward:s>0}}function scanForBracket(t,e,c,n,i){for(var o=i&&i.maxScanLineLength||1e4,h=i&&i.maxScanLines||1e3,l=[],s=bracketRegex(i),f=c>0?Math.min(e.line+h,t.lastLine()+1):Math.max(t.firstLine()-1,e.line-h),u=e.line;u!=f;u+=c){var g=t.getLine(u);if(g){var d=c>0?0:g.length-1,m=c>0?g.length:-1;if(!(g.length>o))for(u==e.line&&(d=e.ch-(c<0?1:0));d!=m;d+=c){var k=g.charAt(d);if(s.test(k)&&(void 0===n||(t.getTokenTypeAt(r(u,d+1))||"")==(n||""))){var B=a[k];if(B&&">"==B.charAt(1)==c>0)l.push(k);else{if(!l.length)return{pos:r(u,d),ch:k};l.pop()}}}}}return u-c!=(c>0?t.lastLine():t.firstLine())&&null}function matchBrackets(t,a,c){for(var n=t.state.matchBrackets.maxHighlightLineLength||1e3,i=c&&c.highlightNonMatching,o=[],h=t.listSelections(),l=0;l<h.length;l++){var s=h[l].empty()&&findMatchingBracket(t,h[l].head,c);if(s&&(s.match||!1!==i)&&t.getLine(s.from.line).length<=n){var f=s.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket";o.push(t.markText(s.from,r(s.from.line,s.from.ch+1),{className:f})),s.to&&t.getLine(s.to.line).length<=n&&o.push(t.markText(s.to,r(s.to.line,s.to.ch+1),{className:f}))}}if(o.length){e&&t.state.focused&&t.focus();var clear=function(){t.operation((function(){for(var t=0;t<o.length;t++)o[t].clear()}))};if(!a)return clear;setTimeout(clear,800)}}function doMatchBrackets(t){t.operation((function(){t.state.matchBrackets.currentlyHighlighted&&(t.state.matchBrackets.currentlyHighlighted(),t.state.matchBrackets.currentlyHighlighted=null),t.state.matchBrackets.currentlyHighlighted=matchBrackets(t,!1,t.state.matchBrackets)}))}function clearHighlighted(t){t.state.matchBrackets&&t.state.matchBrackets.currentlyHighlighted&&(t.state.matchBrackets.currentlyHighlighted(),t.state.matchBrackets.currentlyHighlighted=null)}t.defineOption("matchBrackets",!1,(function(e,r,a){a&&a!=t.Init&&(e.off("cursorActivity",doMatchBrackets),e.off("focus",doMatchBrackets),e.off("blur",clearHighlighted),clearHighlighted(e)),r&&(e.state.matchBrackets="object"==typeof r?r:{},e.on("cursorActivity",doMatchBrackets),e.on("focus",doMatchBrackets),e.on("blur",clearHighlighted))})),t.defineExtension("matchBrackets",(function(){matchBrackets(this,!0)})),t.defineExtension("findMatchingBracket",(function(t,e,r){return(r||"boolean"==typeof e)&&(r?(r.strict=e,e=r):e=e?{strict:!0}:null),findMatchingBracket(this,t,e)})),t.defineExtension("scanForBracket",(function(t,e,r,a){return scanForBracket(this,t,e,r,a)}))},"object"==typeof e&&"object"==typeof t?a(r("../../lib/codemirror")):"function"==typeof c&&c.amd?c(["../../lib/codemirror"],a):a(CodeMirror)}));
//# sourceMappingURL=matchbrackets.js.map