/* jce - 2.9.2 | 2021-01-28 | https://www.joomlacontenteditor.net | Copyright (C) 2006 - 2020 Ryan Demmer. All rights reserved | GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html */
!function(){function isMediaObject(node){return node.getAttribute("data-mce-object")}function isImage(node){return node&&"IMG"===node.nodeName&&!isMediaObject(node)}function getImageProps(ed,value){var params=ed.getParam("imgmanager_ext",{}),attribs=["alt","title","id","dir","class","usemap","style","longdesc","loading","width","height"],args={src:value,alt:""};if(tinymce.each(attribs,function(key){tinymce.is(params[key])&&(args[key]=params[key])}),args.style){var styles=ed.dom.parseStyle(ed.dom.serializeStyle(args.style));args.style=ed.dom.serializeStyle(styles,"IMG")}return args}function validateImage(ed,value){return new Promise(function(resolve,reject){if(!value)return resolve();var img=new Image;img.onload=function(){resolve()},img.onerror=function(){reject()},img.src=ed.documentBaseURI.toAbsolute(value)})}function isSupportedImage(value){return/\.(jpg|jpeg|png|gif|webp|avif)$/.test(value)}var extend=(tinymce.each,tinymce.extend);tinymce.dom.Event,tinymce.DOM;tinymce.create("tinymce.plugins.ImageManagerExtended",{init:function(ed,url){this.editor=ed,this.url=url,ed.onPreInit.add(function(){ed.parser.addNodeFilter("img",function(nodes){for(var node,i=nodes.length;i--;){node=nodes[i];var src=node.attr("src");if(src&&src.indexOf("?")===-1&&isSupportedImage(src)){var stamp="?"+(new Date).getTime();src=ed.convertURL(src,"src",node.name),node.attr("src",src+stamp),node.attr("data-mce-src",src)}}})}),ed.addCommand("mceImageManagerExtended",function(){var n=ed.selection.getNode();"IMG"==n.nodeName&&isMediaObject(n)||ed.windowManager.open({file:ed.getParam("site_url")+"index.php?option=com_jce&task=plugin.display&plugin=imagepro",size:"mce-modal-portrait-full"},{plugin_url:url})}),ed.addButton("imgmanager_ext",{title:"imgmanager_ext.desc",cmd:"mceImageManagerExtended"}),ed.onNodeChange.add(function(ed,cm,n){cm.setActive("imgmanager_ext",isImage(n))}),ed.onInit.add(function(){if(ed&&ed.plugins.contextmenu&&ed.plugins.contextmenu.onContextMenu.add(function(th,m,e){m.add({title:"imgmanager_ext.desc",icon:"imgmanager_ext",cmd:"mceImageManagerExtended"})}),ed.settings.compress.css||ed.dom.loadCSS(url+"/css/content.css"),ed.getParam("imgmanager_convert_img_links",1)&&ed.plugins.clipboard){var data=ed.getParam("imgmanager_ext",{}),filetypes=data.filetypes||["jpg","jpeg","png","gif","webp","avif"],ux="^((http|https)://[-!#$%&'*+\\/0-9=?A-Z^_`a-z{|}~;]+[-!#$%&*+\\/0-9=?A-Z^_`a-z{|}~;.]+?).("+filetypes.join("|")+")$";ed.onGetClipboardContent.add(function(ed,content){var value=content["text/plain"]||"";if(value){var match=new RegExp(ux).exec(value);match&&(content["text/plain"]="",content["text/html"]=content["x-tinymce/html"]=ed.dom.createHTML("img",getImageProps(ed,match[0])),ed.setProgressState(!0),validateImage(ed,value).then(function(){ed.setProgressState(!1)},function(){ed.setProgressState(!1)}))}})}})},getAttributes:function(data){var ed=this.editor,attr={style:{}},supported=["alt","title","id","dir","class","usemap","style","longdesc","loading"],attribs=data.attributes||{};return attribs.style&&tinymce.is(attribs.style,"string")&&(attribs.style=ed.dom.parseStyle(attribs.style)),attribs.styles&&tinymce.is(attribs.styles,"object")&&(attribs.style=extend(attribs.styles,attribs.style||{}),delete attribs.styles),attribs.style&&(attribs.style=ed.dom.serializeStyle(attribs.style)),tinymce.each(supported,function(key){tinymce.is(attribs[key])&&(attr[key]=attribs[key])}),data.width&&(attr.width=data.width),data.height&&(attr.height=data.height),attr},insertUploadedFile:function(o){var ed=this.editor,data=this.getUploadConfig();if(data&&data.filetypes&&new RegExp(".("+data.filetypes.join("|")+")$","i").test(o.name)){var args={src:o.file,alt:o.alt||o.name,style:{}};return args=extend(args,this.getAttributes(o)),ed.dom.create("img",args)}return!1},getUploadURL:function(file){var ed=this.editor,data=this.getUploadConfig();return!!(data&&data.filetypes&&new RegExp(".("+data.filetypes.join("|")+")$","i").test(file.name))&&ed.getParam("site_url")+"index.php?option=com_jce&task=plugin.display&plugin=imagepro"},getUploadConfig:function(){var ed=this.editor,data=ed.getParam("imgmanager_ext",{});return data.upload||{}}}),tinymce.PluginManager.add("imgmanager_ext",tinymce.plugins.ImageManagerExtended)}();