!function(){"use strict";function t(t,e,i,n,r,o,s){try{var a=t[o](s),l=a.value}catch(t){return void i(t)}a.done?e(l):Promise.resolve(l).then(n,r)}function e(t,e){for(var i=0;i1?e[1].split(/[?]/)[0].split(".").pop().trim():t.split(/[#?]/)[0].split(".").pop().trim();r.images.includes(a)&&(o="images"),r.audios.includes(a)&&(o="audios"),r.videos.includes(a)&&(o="videos"),r.documents.includes(a)&&(o="documents");var l={images:function(){r.images.includes(a)&&((s=new Image).src=/http/.test(n)?n:Joomla.getOptions("system.paths").rootFull+n,s.setAttribute("alt",""))},audios:function(){r.audios.includes(a)&&((s=document.createElement("audio")).src=/http/.test(n)?n:Joomla.getOptions("system.paths").rootFull+n,s.setAttribute("controls",""))},videos:function(){if(r.videos.includes(a)){s=document.createElement("video");var t=document.createElement("source");t.src=/http/.test(n)?n:Joomla.getOptions("system.paths").rootFull+n,t.type="video/"+a,s.setAttribute("controls",""),s.setAttribute("width",i.previewWidth),s.setAttribute("height",i.previewHeight),s.appendChild(t)}},documents:function(){r.documents.includes(a)&&((s=document.createElement("object")).data=/http/.test(n)?n:Joomla.getOptions("system.paths").rootFull+n,s.type="application/"+a,s.setAttribute("width",i.previewWidth),s.setAttribute("height",i.previewHeight))}};if(this.givenType&&["images","audios","videos","documents"].includes(this.givenType))l[this.givenType]();else{if(!o||!["images","audios","videos","documents"].includes(o))return;l[o]()}this.previewElement.style.width=this.previewWidth,this.previewElement.appendChild(s)}else this.buttonClearEl.style.display="none",this.previewElement.innerHTML=Joomla.sanitizeHtml('')}},l=s,c=[{key:"observedAttributes",get:function(){return["type","base-path","root-folder","url","modal-container","modal-width","modal-height","input","button-select","button-clear","button-save-selected","preview","preview-width","preview-height"]}}],(u=[{key:"type",get:function(){return this.getAttribute("type")},set:function(t){this.setAttribute("type",t)}},{key:"basePath",get:function(){return this.getAttribute("base-path")},set:function(t){this.setAttribute("base-path",t)}},{key:"rootFolder",get:function(){return this.getAttribute("root-folder")},set:function(t){this.setAttribute("root-folder",t)}},{key:"url",get:function(){return this.getAttribute("url")},set:function(t){this.setAttribute("url",t)}},{key:"modalContainer",get:function(){return this.getAttribute("modal-container")},set:function(t){this.setAttribute("modal-container",t)}},{key:"input",get:function(){return this.getAttribute("input")},set:function(t){this.setAttribute("input",t)}},{key:"buttonSelect",get:function(){return this.getAttribute("button-select")},set:function(t){this.setAttribute("button-select",t)}},{key:"buttonClear",get:function(){return this.getAttribute("button-clear")},set:function(t){this.setAttribute("button-clear",t)}},{key:"buttonSaveSelected",get:function(){return this.getAttribute("button-save-selected")},set:function(t){this.setAttribute("button-save-selected",t)}},{key:"modalWidth",get:function(){return parseInt(this.getAttribute("modal-width"),10)},set:function(t){this.setAttribute("modal-width",t)}},{key:"modalHeight",get:function(){return parseInt(this.getAttribute("modal-height"),10)},set:function(t){this.setAttribute("modal-height",t)}},{key:"previewWidth",get:function(){return parseInt(this.getAttribute("preview-width"),10)},set:function(t){this.setAttribute("preview-width",t)}},{key:"previewHeight",get:function(){return parseInt(this.getAttribute("preview-height"),10)},set:function(t){this.setAttribute("preview-height",t)}},{key:"preview",get:function(){return this.getAttribute("preview")},set:function(t){this.setAttribute("preview",t)}},{key:"previewContainer",get:function(){return this.getAttribute("preview-container")}}])&&e(l.prototype,u),c&&e(l,c),Object.defineProperty(l,"prototype",{writable:!1}),s}(s(HTMLElement));customElements.define("joomla-field-media",l)}();