!function(){"use strict";if(!window.parent.Joomla||"function"!=typeof window.parent.Joomla.getOptions)throw new Error("Joomla API not found");var e,n,t,r=window.parent.Joomla.getOptions("system.paths").rootFull+"/media/vendor/codemirror",o={indentOnInit:!0,config:{mode:"htmlmixed",theme:"default",lineNumbers:!0,lineWrapping:!0,indentUnit:2,tabSize:2,indentWithTabs:!0,matchBrackets:!0,saveCursorPosition:!0,styleActiveLine:!0},jsFiles:[r+"/lib/codemirror.min.js",r+"/addon/edit/matchbrackets.min.js",r+"/mode/xml/xml.min.js",r+"/mode/javascript/javascript.min.js",r+"/mode/css/css.min.js",r+"/mode/htmlmixed/htmlmixed.min.js",r+"/addon/dialog/dialog.min.js",r+"/addon/search/searchcursor.min.js",r+"/addon/search/search.min.js",r+"/addon/selection/active-line.min.js"],cssFiles:[r+"/lib/codemirror.css",r+"/addon/dialog/dialog.css"]},i=/macintosh|mac os/i.test(navigator.userAgent);window.tinymceHighlighterSubmit=function(){var e="&#x0;",r=t.isDirty,o=t.doc;o.somethingSelected()&&o.setCursor(o.getCursor()),o.replaceSelection(e);var i=t.getCursor(),s=o.getLine(i.line);0!==function(e,n){for(var t=0,r=e.indexOf(n)-1;r>=0;r-=1)switch(e.charAt(r)){case"<":t-=1;break;case">":case"&":t+=1}return t}(s,e)&&(s=s.replace(e,""),o.replaceRange(s,window.CodeMirror.Pos(i.line,0),window.CodeMirror.Pos(i.line)));var a=t.getValue(),d=new RegExp("<script(.*?)>(.*?)&#x0;(.*?)<\/script>","ms"),c=new RegExp("<style(.*?)>(.*?)&#x0;(.*?)</style>","ms"),l=new RegExp("<[^>]*(&#x0;).*>|^(&#x0;)|(&#x0;)$");-1!==a.search(d)||-1!==a.search(c)||-1!==a.search(l)?n.setContent(a.replace(e,"")):n.setContent(a.replace(e,'<span id="CmCaReT"></span>')),n.isNotDirty=!r,r&&n.nodeChanged();var m=n.dom.select("span#CmCaReT")[0];m&&(n.selection.scrollIntoView(m),n.selection.setCursorLocation(m,0),n.dom.remove(m))},document.addEventListener("keydown",(function(n){var t=n||window.event;("key"in t?"Escape"===t.key||"Esc"===t.key:27===t.keyCode)&&e.activeEditor.windowManager.close()}));if(!(e=window.parent.tinymce))throw new Error("tinyMCE not found");var s=(n=e.activeEditor).settings.codemirror;s.fullscreen&&(o.jsFiles.push(r+"/addon/display/fullscreen.min.js"),o.cssFiles.push(r+"/addon/display/fullscreen.css")),(o=Object.assign({},o,s)).cssFiles.forEach((function(e){var n=document.createElement("link");n.rel="stylesheet",n.href=e,document.head.appendChild(n)})),o.jsFiles.reduce((function(e,n){return e.then((function(){return e=n,new Promise((function(n,t){var r=document.createElement("script");r.src=e,r.onload=function(){return n()},r.onerror=function(){return t(new Error("Failed to load the script "+e))},document.head.appendChild(r)}));var e}))}),Promise.resolve(!0)).then((function(){o.config.theme&&(document.documentElement.className+=o.config.theme.replace(/(^|\s)\s*/g," cm-s-")),function(){if("function"!=typeof window.CodeMirror)throw new Error('CodeMirror not found in "'+o.path+'", aborting...');var r=window.parent.document.querySelectorAll(".tox-dialog__footer")[0],s=window.parent.document.createElement("div"),a='<td style="font-size:11px;background:#777;color:#fff;padding:0 4px">',d='<td style="font-size:11px;padding-right:5px">';s.innerHTML='\n<table cellspacing="0" cellpadding="0" style="border-spacing:4px">\n  <tr>\n    '+a+(i?"&#8984;-F":"Ctrl-F</td>")+d+e.translate("Start search")+"</td>\n    "+a+(i?"&#8984;-G":"Ctrl-G")+"</td>\n    "+d+e.translate("Find next")+"</td>\n    "+a+(i?"&#8984;-Alt-F":"Shift-Ctrl-F")+"</td>\n    "+d+e.translate("Find previous")+"</td>\n  </tr>\n  <tr>\n    "+a+(i?"&#8984;-Alt-F":"Shift-Ctrl-F")+"</td>\n    "+d+e.translate("Replace")+"</td>\n    "+a+(i?"Shift-&#8984;-Alt-F":"Shift-Ctrl-R")+"</td>\n    "+d+e.translate("Replace all")+"</td>\n  </tr>\n</table>",r.insertAdjacentElement("afterbegin",s);var c=n.getContent({source_view:!0});c=c.replace(/<span\s+style="display: none;"\s+class="CmCaReT"([^>]*)>([^<]*)<\/span>/gm,String.fromCharCode(0)),n.dom.remove(n.dom.select(".CmCaReT")),e.each(n.contextToolbars,(function(e){e.panel&&e.panel.hide()})),window.CodeMirror.defineInitHook((function(e){e.focus();var t=e.getSearchCursor(String.fromCharCode(0),!1);if(t.findNext()&&(e.setCursor(t.to()),t.replace("")),n.settings.codemirror.indentOnInit){var r=e.lineCount();e.operation((function(){for(var n=0;n<r;++n)e.indentLine(n)}))}})),o.config.value=c,(t=window.CodeMirror(document.body,o.config)).isDirty=!1,t.on("change",(function(e){e.isDirty=!0})),t.setSize("100%","100%"),t.refresh()}()}))}();