import{W as e,s as t,h as i,w as r}from"./index-814b5497.js";import{f as s}from"./browser-fixes-ad0e4ba1.js";export default class extends e{init(){this.props.src=e=>{this.load(e)},this.props.loading=e=>{this.ref&&this.ref!==this.host&&t(this.ref,"loading",e)},super.init()}connected(){[...this.host.querySelectorAll("img:not([src])")].forEach((e=>{e.parentNode.removeChild(e)}))}load(e){const{host:o}=this;if(!(e=e&&e.trim())||e===this.cachedSrc)return;this.cachedSrc=e;let a=o.querySelector("img")||i("img");return t(a,"loading",o.getAttribute("loading")),a.src=e,a.alt="",this.ref=a,a.parentNode||o.appendChild(a),s(o),a.onerror=()=>{this.removeChild(a);const t=i("nu-icon");t.setAttribute("name","image"),o.appendChild(t),r("image not loaded",e)},e}}
