Liferay.Loader.define("fragment-web$codemirror@5.65.2/addon/edit/closebrackets",["module","exports","require","../../lib/codemirror"],(function(e,t,n){var r,i=void 0;window;r=function(e){var t={pairs:"()[]{}''\"\"",closeBefore:")]}'\":;>",triples:"",explode:"[]{}"},n=e.Pos;function getOption(e,n){return"pairs"==n&&"string"==typeof e?e:"object"==typeof e&&null!=e[n]?e[n]:t[n]}e.defineOption("autoCloseBrackets",!1,(function(t,n,i){i&&i!=e.Init&&(t.removeKeyMap(r),t.state.closeBrackets=null),n&&(ensureBound(getOption(n,"pairs")),t.state.closeBrackets=n,t.addKeyMap(r))}));var r={Backspace:function handleBackspace(t){var r=getConfig(t);if(!r||t.getOption("disableInput"))return e.Pass;for(var i=getOption(r,"pairs"),o=t.listSelections(),a=0;a<o.length;a++){if(!o[a].empty())return e.Pass;var s=charsAround(t,o[a].head);if(!s||i.indexOf(s)%2!=0)return e.Pass}for(a=o.length-1;a>=0;a--){var l=o[a].head;t.replaceRange("",n(l.line,l.ch-1),n(l.line,l.ch+1),"+delete")}},Enter:function handleEnter(t){var n=getConfig(t),r=n&&getOption(n,"explode");if(!r||t.getOption("disableInput"))return e.Pass;for(var i=t.listSelections(),o=0;o<i.length;o++){if(!i[o].empty())return e.Pass;var a=charsAround(t,i[o].head);if(!a||r.indexOf(a)%2!=0)return e.Pass}t.operation((function(){var e=t.lineSeparator()||"\n";t.replaceSelection(e+e,null),moveSel(t,-1),i=t.listSelections();for(var n=0;n<i.length;n++){var r=i[n].head.line;t.indentLine(r,null,!0),t.indentLine(r+1,null,!0)}}))}};function ensureBound(e){for(var t=0;t<e.length;t++){var n=e.charAt(t),i="'"+n+"'";r[i]||(r[i]=handler(n))}}function handler(t){return function(r){return function handleChar(t,r){var i=getConfig(t);if(!i||t.getOption("disableInput"))return e.Pass;var o=getOption(i,"pairs"),a=o.indexOf(r);if(-1==a)return e.Pass;for(var s,l=getOption(i,"closeBefore"),c=getOption(i,"triples"),h=o.charAt(a+1)==r,f=t.listSelections(),u=a%2==0,d=0;d<f.length;d++){var g,p=f[d],v=p.head,S=t.getRange(v,n(v.line,v.ch+1));if(u&&!p.empty())g="surround";else if(!h&&u||S!=r)if(h&&v.ch>1&&c.indexOf(r)>=0&&t.getRange(n(v.line,v.ch-2),v)==r+r){if(v.ch>2&&/\bstring/.test(t.getTokenTypeAt(n(v.line,v.ch-2))))return e.Pass;g="addFour"}else if(h){var b=0==v.ch?" ":t.getRange(n(v.line,v.ch-1),v);if(e.isWordChar(S)||b==r||e.isWordChar(b))return e.Pass;g="both"}else{if(!u||!(0===S.length||/\s/.test(S)||l.indexOf(S)>-1))return e.Pass;g="both"}else g=h&&stringStartsAfter(t,v)?"both":c.indexOf(r)>=0&&t.getRange(v,n(v.line,v.ch+3))==r+r+r?"skipThree":"skip";if(s){if(s!=g)return e.Pass}else s=g}var m=a%2?o.charAt(a-1):r,O=a%2?r:o.charAt(a+1);t.operation((function(){if("skip"==s)moveSel(t,1);else if("skipThree"==s)moveSel(t,3);else if("surround"==s){for(var e=t.getSelections(),n=0;n<e.length;n++)e[n]=m+e[n]+O;for(t.replaceSelections(e,"around"),e=t.listSelections().slice(),n=0;n<e.length;n++)e[n]=contractSelection(e[n]);t.setSelections(e)}else"both"==s?(t.replaceSelection(m+O,null),t.triggerElectric(m+O),moveSel(t,-1)):"addFour"==s&&(t.replaceSelection(m+m+m+m,"before"),moveSel(t,1))}))}(r,t)}}function getConfig(e){var t=e.state.closeBrackets;return!t||t.override?t:e.getModeAt(e.getCursor()).closeBrackets||t}function moveSel(e,t){for(var n=[],r=e.listSelections(),i=0,o=0;o<r.length;o++){var a=r[o];a.head==e.getCursor()&&(i=o);var s=a.head.ch||t>0?{line:a.head.line,ch:a.head.ch+t}:{line:a.head.line-1};n.push({anchor:s,head:s})}e.setSelections(n,i)}function contractSelection(t){var r=e.cmpPos(t.anchor,t.head)>0;return{anchor:new n(t.anchor.line,t.anchor.ch+(r?-1:1)),head:new n(t.head.line,t.head.ch+(r?1:-1))}}function charsAround(e,t){var r=e.getRange(n(t.line,t.ch-1),n(t.line,t.ch+1));return 2==r.length?r:null}function stringStartsAfter(e,t){var r=e.getTokenAt(n(t.line,t.ch+1));return/\bstring/.test(r.type)&&r.start==t.ch&&(0==t.ch||!/\bstring/.test(e.getTokenTypeAt(t)))}ensureBound(t.pairs+"`")},"object"==typeof t&&"object"==typeof e?r(n("../../lib/codemirror")):"function"==typeof i&&i.amd?i(["../../lib/codemirror"],r):r(CodeMirror)}));
//# sourceMappingURL=closebrackets.js.map