import{LitElement as e,html as t}from"../../../lit/index.js";class ImgLoader extends e{render(){return t``}static get tag(){return"img-loader"}static get properties(){return{src:{type:String},loaded:{type:Boolean},loading:{type:Boolean},describedBy:{type:String,attribute:"described-by"},error:{type:Boolean}}}constructor(){super(),this.loaded=!1,this.error=!1,this.loading=!1}updated(e){e.forEach(((e,t)=>{"src"==t&&this._loadPageSrc(),["error","loaded","loading"].includes(t)&&this.dispatchEvent(new CustomEvent(`${t}-changed`,{detail:{value:this[t]}}))}))}_loadPageSrc(){this.__imageLoader&&this.__imageLoader.remove(),this.src&&(this.__imageLoader=new Image,this.__imageLoader.onload=()=>{this.loading=!1,this.loaded=!0,this.__imageLoader&&this.__imageLoader.remove()},this.__imageLoader.onerror=()=>{this.loading=!1,this.loaded=!1,this.__imageLoader&&this.__imageLoader.remove()},this.__imageLoader.src=this.src),this.loading=!!this.src,this.loaded=!1}}customElements.define(ImgLoader.tag,ImgLoader);export{ImgLoader};