Liferay.Loader.define("fragment-web$codemirror@5.65.2/addon/edit/closetag",["module","exports","require","../../lib/codemirror","../fold/xml-fold"],(function(e,t,n){var o,r=void 0;window;o=function(e){e.defineOption("autoCloseTags",!1,(function(o,r,i){if(i!=e.Init&&i&&o.removeKeyMap("autoCloseTags"),r){var a={name:"autoCloseTags"};"object"==typeof r&&!1===r.whenClosing||(a["'/'"]=function(t){return function autoCloseSlash(t){return t.getOption("disableInput")?e.Pass:autoCloseCurrent(t,!0)}(t)}),"object"==typeof r&&!1===r.whenOpening||(a["'>'"]=function(o){return function autoCloseGT(o){if(o.getOption("disableInput"))return e.Pass;for(var r=o.listSelections(),i=[],a=o.getOption("autoCloseTags"),s=0;s<r.length;s++){if(!r[s].empty())return e.Pass;var l=r[s].head,d=o.getTokenAt(l),c=e.innerMode(o.getMode(),d.state),f=c.state,g=c.mode.xmlCurrentTag&&c.mode.xmlCurrentTag(f),u=g&&g.name;if(!u)return e.Pass;var m="html"==c.mode.configuration,h="object"==typeof a&&a.dontCloseTags||m&&t,p="object"==typeof a&&a.indentTags||m&&n;d.end>l.ch&&(u=u.slice(0,u.length-d.end+l.ch));var C=u.toLowerCase();if(!u||"string"==d.type&&(d.end!=l.ch||!/[\"\']/.test(d.string.charAt(d.string.length-1))||1==d.string.length)||"tag"==d.type&&g.close||d.string.indexOf("/")==l.ch-d.start-1||h&&indexOf(h,C)>-1||closingTagExists(o,c.mode.xmlCurrentContext&&c.mode.xmlCurrentContext(f)||[],u,l,!0))return e.Pass;var x="object"==typeof a&&a.emptyTags;if(x&&indexOf(x,u)>-1)i[s]={text:"/>",newPos:e.Pos(l.line,l.ch+2)};else{var b=p&&indexOf(p,C)>-1;i[s]={indent:b,text:">"+(b?"\n\n":"")+"</"+u+">",newPos:b?e.Pos(l.line+1,0):e.Pos(l.line,l.ch+1)}}}var v="object"==typeof a&&a.dontIndentOnAutoClose;for(s=r.length-1;s>=0;s--){var y=i[s];o.replaceRange(y.text,r[s].head,r[s].anchor,"+insert");var T=o.listSelections().slice(0);T[s]={head:y.newPos,anchor:y.newPos},o.setSelections(T),!v&&y.indent&&(o.indentLine(y.newPos.line,null,!0),o.indentLine(y.newPos.line+1,null,!0))}}(o)}),o.addKeyMap(a)}}));var t=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],n=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"];function autoCloseCurrent(t,n){for(var o=t.listSelections(),r=[],i=n?"/":"</",a=t.getOption("autoCloseTags"),s="object"==typeof a&&a.dontIndentOnSlash,l=0;l<o.length;l++){if(!o[l].empty())return e.Pass;var d=o[l].head,c=t.getTokenAt(d),f=e.innerMode(t.getMode(),c.state),g=f.state;if(n&&("string"==c.type||"<"!=c.string.charAt(0)||c.start!=d.ch-1))return e.Pass;var u,m="xml"!=f.mode.name&&"htmlmixed"==t.getMode().name;if(m&&"javascript"==f.mode.name)u=i+"script";else if(m&&"css"==f.mode.name)u=i+"style";else{var h=f.mode.xmlCurrentContext&&f.mode.xmlCurrentContext(g),p=h.length?h[h.length-1]:"";if(!h||h.length&&closingTagExists(t,h,p,d))return e.Pass;u=i+p}">"!=t.getLine(d.line).charAt(c.end)&&(u+=">"),r[l]=u}if(t.replaceSelections(r),o=t.listSelections(),!s)for(l=0;l<o.length;l++)(l==o.length-1||o[l].head.line<o[l+1].head.line)&&t.indentLine(o[l].head.line)}function indexOf(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,o=e.length;n<o;++n)if(e[n]==t)return n;return-1}function closingTagExists(t,n,o,r,i){if(!e.scanForClosingTag)return!1;var a=Math.min(t.lastLine()+1,r.line+500),s=e.scanForClosingTag(t,r,null,a);if(!s||s.tag!=o)return!1;for(var l=i?1:0,d=n.length-1;d>=0&&n[d]==o;d--)++l;for(r=s.to,d=1;d<l;d++){var c=e.scanForClosingTag(t,r,null,a);if(!c||c.tag!=o)return!1;r=c.to}return!0}e.commands.closeTag=function(e){return autoCloseCurrent(e)}},"object"==typeof t&&"object"==typeof e?o(n("../../lib/codemirror"),n("../fold/xml-fold")):"function"==typeof r&&r.amd?r(["../../lib/codemirror","../fold/xml-fold"],o):o(CodeMirror)}));
//# sourceMappingURL=closetag.js.map