!function(){"use strict";function e(e,t,i,n,a,l,o){try{var r=e[l](o),s=r.value}catch(e){return void i(e)}r.done?t(s):Promise.resolve(s).then(n,a)}function t(t){return function(){var i=this,n=arguments;return new Promise((function(a,l){var o=t.apply(i,n);function r(t){e(o,a,l,r,s,"next",t)}function s(t){e(o,a,l,r,s,"throw",t)}r(void 0)}))}}function i(e,t){for(var i=0;i\n'));case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());var c=function(e){return"object"==typeof HTMLElement?e instanceof HTMLElement:e&&"object"==typeof e&&1===e.nodeType&&"string"==typeof e.nodeName},u=function(e){return new Promise((function(t,i){var n=new Image;n.src=e,n.onload=function(){Joomla.selectedMediaFile.width=n.width,Joomla.selectedMediaFile.height=n.height,t(!0)},n.onerror=function(){i(!1)}}))},d=function(){var e=t(regeneratorRuntime.mark((function e(t,i,n){var a,l,o,r,s,d,p,h,m,f,b,g;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.url?(a=Joomla.getOptions("system.paths"),l=a.rootFull,(o=t.url.split(l)).length>1?(Joomla.selectedMediaFile.url=o[1],t.thumb_path?Joomla.selectedMediaFile.thumb=t.thumb_path:Joomla.selectedMediaFile.thumb=!1):t.thumb_path&&(Joomla.selectedMediaFile.url=t.url,Joomla.selectedMediaFile.thumb=t.thumb_path)):Joomla.selectedMediaFile.url=!1,!Joomla.selectedMediaFile.url){e.next=47;break}if(s="",d="",p="",h="",m="",f="",b="",c(i)){e.next=35;break}if(g=n.closest(".modal-content"),!(r=g.querySelector("joomla-field-mediamore"))){e.next=30;break}if("true"===r.getAttribute("alt-check")&&(p=' alt=""'),d=r.getAttribute("alt-value")?' alt="'+r.getAttribute("alt-value")+'"':p,h=r.getAttribute("img-classes")?' class="'+r.getAttribute("img-classes")+'"':"",m=r.getAttribute("fig-classes")?' class="image '+r.getAttribute("fig-classes")+'"':' class="image"',f=r.getAttribute("fig-caption")?""+r.getAttribute("fig-caption"):"","true"!==r.getAttribute("is-lazy")){e.next=30;break}if(s=' loading="lazy" width="'+Joomla.selectedMediaFile.width+'" height="'+Joomla.selectedMediaFile.height+'"',0!==Joomla.selectedMediaFile.width&&0!==Joomla.selectedMediaFile.height){e.next=30;break}return e.prev=21,e.next=24,u(Joomla.selectedMediaFile.url);case 24:s=' loading="lazy" width="'+Joomla.selectedMediaFile.width+'" height="'+Joomla.selectedMediaFile.height+'"',e.next=30;break;case 27:e.prev=27,e.t0=e.catch(21),s="";case 30:b=f?"
'+f+"
":'',r&&r.parentNode.removeChild(r),Joomla.editors.instances[i].replaceSelection(b),e.next=47;break;case 35:if(0!==Joomla.selectedMediaFile.width&&0!==Joomla.selectedMediaFile.height){e.next=45;break}return e.prev=36,e.next=39,u(Joomla.selectedMediaFile.url);case 39:e.next=45;break;case 41:e.prev=41,e.t1=e.catch(36),Joomla.selectedMediaFile.height=0,Joomla.selectedMediaFile.width=0;case 45:n.markValid(),n.setValue(Joomla.selectedMediaFile.url+"#joomlaImage://"+t.path.replace(":","")+"?width="+Joomla.selectedMediaFile.width+"&height="+Joomla.selectedMediaFile.height);case 47:case"end":return e.stop()}}),e,null,[[21,27],[36,41]])})));return function(t,i,n){return e.apply(this,arguments)}}(),p=function(e,t,i,n){if(e.url){var a=Joomla.getOptions("system.paths").rootFull,l=e.url.split(a);l.length>1?Joomla.selectedMediaFile.url=l[1]:Joomla.selectedMediaFile.url=e.url}else Joomla.selectedMediaFile.url=!1;var o;if(Joomla.selectedMediaFile.url)if(c(t))i.markValid(),i.givenType=n,i.setValue(Joomla.selectedMediaFile.url);else{var r;if(o=i.closest(".modal-content").querySelector("joomla-field-mediamore")){var s=o.getAttribute("embed-it");if(s&&"true"===s){if("audios"===n&&(r=''),"documents"===n){var u=o.getAttribute("title");r='\n '+Joomla.Text._("JFIELD_MEDIA_UNSUPPORTED").replace("{tag}",'').replace(/{extension}/g,Joomla.selectedMediaFile.extension)+"\n"}"videos"===n&&(r='')}else if(""!==Joomla.editors.instances[t].getSelection())r=''+Joomla.editors.instances[t].getSelection()+"";else{var d=/([\w-]+)\./.exec(Joomla.selectedMediaFile.url);r=''+Joomla.Text._("JFIELD_MEDIA_DOWNLOAD_FILE").replace("{file}",d[1])+""}}o&&o.parentNode.removeChild(o),Joomla.editors.instances[t].replaceSelection(r)}},h=function(){var e=t(regeneratorRuntime.mark((function e(t,i,n){var a,l,o,r,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!0!==t.success){e.next=12;break}if(a=t.data[0],l=s.images,o=s.audios,r=s.videos,c=s.documents,!Joomla.selectedMediaFile.extension||!l.includes(a.extension.toLowerCase())){e.next=5;break}return e.abrupt("return",d(a,i,n));case 5:if(!Joomla.selectedMediaFile.extension||!o.includes(a.extension.toLowerCase())){e.next=7;break}return e.abrupt("return",p(a,i,n,"audios"));case 7:if(!Joomla.selectedMediaFile.extension||!c.includes(a.extension.toLowerCase())){e.next=9;break}return e.abrupt("return",p(a,i,n,"documents"));case 9:if(!Joomla.selectedMediaFile.extension||!r.includes(a.extension.toLowerCase())){e.next=11;break}return e.abrupt("return",p(a,i,n,"videos"));case 11:case 12:return e.abrupt("return","");case 13:case"end":return e.stop()}}),e)})));return function(t,i,n){return e.apply(this,arguments)}}();Joomla.getMedia=function(e,i,n){return new Promise((function(a,l){if(!e||"object"==typeof e&&(!e.path||""===e.path))return Joomla.selectedMediaFile={},void a({resp:{success:!1}});var o=Joomla.getOptions("system.paths").baseFull+"index.php?option=com_media&task=api.files&url=true&path="+e.path+"&mediatypes=0,1,2,3&"+Joomla.getOptions("csrf.token")+"=1&format=json";fetch(o,{method:"GET",headers:{"Content-Type":"application/json"}}).then((function(e){return e.json()})).then(function(){var e=t(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=a,e.next=3,h(t,i,n);case 3:return e.t1=e.sent,e.abrupt("return",(0,e.t0)(e.t1));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){return l(e)}))}))},Joomla.getImage=Joomla.getMedia;var m=function(e){var t,n;function l(){return e.apply(this,arguments)||this}n=e,(t=l).prototype=Object.create(n.prototype),t.prototype.constructor=t,a(t,n);var o,r,s,c=l.prototype;return c.connectedCallback=function(){var e=this;"images"===this.type?(this.innerHTML="
\n"+this.summarytext+'\n
\n
\n
\n \n \n
\n
\n
\n
\n \n \n
'+this.altcheckdesctext+'
\n
\n
\n
\n
\n \n \n
\n
\n
\n
\n \n \n
\n
\n
\n
\n \n \n
\n
\n
\n
\n \n \n
\n
\n
\n
',this.lazyInputFn=this.lazyInputFn.bind(this),this.altCheckFn=this.altCheckFn.bind(this),this.inputFn=this.inputFn.bind(this),this.lazyInput=this.querySelector("#"+this.parentId+"-lazy"),this.lazyInput.addEventListener("change",this.lazyInputFn),this.altCheck=this.querySelector("#"+this.parentId+"-alt-check"),this.altCheck.addEventListener("input",this.altCheckFn),[].slice.call(this.querySelectorAll('input[type="text"]')).map((function(t){t.addEventListener("input",e.inputFn);var i=t.dataset.is;return i&&e.setAttribute(i,t.value.replace(/"/g,""")),t})),this.setAttribute("is-lazy",!!this.lazyInput.checked),this.setAttribute("alt-check",!1)):["audios","videos","documents"].includes(this.type)&&(this.innerHTML="
\n"+this.summarytext+'\n
\n
\n
\n \n \n
\n
\n \n \n
\n
\n \n
',this.embedInputFn=this.embedInputFn.bind(this),this.inputFn=this.inputFn.bind(this),[].slice.call(this.querySelectorAll(".form-check-input.radio")).map((function(t){return t.addEventListener("input",e.embedInputFn)})),this.setAttribute("embed-it",!1),[].slice.call(this.querySelectorAll('input[type="text"]')).map((function(t){t.addEventListener("input",e.inputFn);var i=t.dataset.is;return i&&e.setAttribute(i,t.value.replace(/"/g,""")),t})))},c.disconnectedCallback=function(){var e=this;"image"===this.type&&(this.lazyInput.removeEventListener("input",this.lazyInputFn),this.altInput.removeEventListener("input",this.inputFn),this.altCheck.removeEventListener("input",this.altCheckFn)),["audio","video","document"].includes(this.type)&&([].slice.call(this.querySelectorAll(".form-check-input.radio")).map((function(t){return t.removeEventListener("input",e.embedInputFn)})),[].slice.call(this.querySelectorAll('input[type="text"]')).map((function(t){return t.removeEventListener("input",e.embedInputFn)}))),this.innerHTML=""},c.lazyInputFn=function(e){this.setAttribute("is-lazy",!!e.target.checked)},c.altCheckFn=function(e){this.setAttribute("alt-check",!!e.target.checked)},c.inputFn=function(e){var t=e.target.dataset.is;t&&this.setAttribute(t,e.target.value.replace(/"/g,"""))},c.embedInputFn=function(e){var t=e.target.value;this.setAttribute("embed-it","0"!==t);var i=this.querySelector(".toggable-parts");i&&("block"!==i.style.display?i.style.display="block":i.style.display="none")},o=l,(r=[{key:"type",get:function(){return this.getAttribute("type")}},{key:"parentId",get:function(){return this.getAttribute("parent-id")}},{key:"lazytext",get:function(){return this.getAttribute("lazy-label")}},{key:"alttext",get:function(){return this.getAttribute("alt-label")}},{key:"altchecktext",get:function(){return this.getAttribute("alt-check-label")}},{key:"altcheckdesctext",get:function(){return this.getAttribute("alt-check-desc-label")}},{key:"embedchecktext",get:function(){return this.getAttribute("embed-check-label")}},{key:"embedcheckdesctext",get:function(){return this.getAttribute("embed-check-desc-label")}},{key:"downloadchecktext",get:function(){return this.getAttribute("download-check-label")}},{key:"downloadcheckdesctext",get:function(){return this.getAttribute("download-check-desc-label")}},{key:"classestext",get:function(){return this.getAttribute("classes-label")}},{key:"figclassestext",get:function(){return this.getAttribute("figure-classes-label")}},{key:"figcaptiontext",get:function(){return this.getAttribute("figure-caption-label")}},{key:"summarytext",get:function(){return this.getAttribute("summary-label")}},{key:"widthtext",get:function(){return this.getAttribute("width-label")}},{key:"heighttext",get:function(){return this.getAttribute("height-label")}},{key:"titletext",get:function(){return this.getAttribute("title-label")}}])&&i(o.prototype,r),s&&i(o,s),Object.defineProperty(o,"prototype",{writable:!1}),l}(r(HTMLElement));customElements.define("joomla-field-mediamore",m)}();