var __awaiter=this&&this.__awaiter||function(t,e,i,n){function s(t){return t instanceof i?t:new i((function(e){e(t)}))}return new(i||(i=Promise))((function(i,r){function a(t){try{u(n.next(t))}catch(t){r(t)}}function h(t){try{u(n["throw"](t))}catch(t){r(t)}}function u(t){t.done?i(t.value):s(t.value).then(a,h)}u((n=n.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var i={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},n,s,r,a;return a={next:h(0),throw:h(1),return:h(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function h(t){return function(e){return u([t,e])}}function u(h){if(n)throw new TypeError("Generator is already executing.");while(a&&(a=0,h[0]&&(i=0)),i)try{if(n=1,s&&(r=h[0]&2?s["return"]:h[0]?s["throw"]||((r=s["return"])&&r.call(s),0):s.next)&&!(r=r.call(s,h[1])).done)return r;if(s=0,r)h=[h[0]&2,r.value];switch(h[0]){case 0:case 1:r=h;break;case 4:i.label++;return{value:h[1],done:false};case 5:i.label++;s=h[1];h=[0];continue;case 7:h=i.ops.pop();i.trys.pop();continue;default:if(!(r=i.trys,r=r.length>0&&r[r.length-1])&&(h[0]===6||h[0]===2)){i=0;continue}if(h[0]===3&&(!r||h[1]>r[0]&&h[1]<r[3])){i.label=h[1];break}if(h[0]===6&&i.label<r[1]){i.label=r[1];r=h;break}if(r&&i.label<r[2]){i.label=r[2];i.ops.push(h);break}if(r[2])i.ops.pop();i.trys.pop();continue}h=e.call(t,i)}catch(t){h=[6,t];s=0}finally{n=r=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:true}}};import{r as registerInstance,h}from"./index-2bf16536.js";var imageCss=":host{display:inline-block}";var BdsImageStyle0=imageCss;var Image=function(){function t(t){registerInstance(this,t);this.src=undefined;this.alt=undefined;this.width=undefined;this.height=undefined;this.objectFit="cover";this.dataTest=null;this.imageLoaded=false;this.loadError=false;this.currentSrc=undefined}t.prototype.loadImage=function(){return __awaiter(this,void 0,void 0,(function(){var t,e,i,n;return __generator(this,(function(s){switch(s.label){case 0:if(!this.src)return[3,7];s.label=1;case 1:s.trys.push([1,6,,7]);return[4,fetch(this.src)];case 2:t=s.sent();if(!t.ok)return[3,4];return[4,t.blob()];case 3:e=s.sent();i=URL.createObjectURL(e);this.currentSrc=i;this.imageLoaded=true;return[3,5];case 4:this.loadError=true;s.label=5;case 5:return[3,7];case 6:n=s.sent();this.loadError=true;return[3,7];case 7:return[2]}}))}))};t.prototype.render=function(){if(!this.imageLoaded&&!this.loadError){this.loadImage()}if(this.imageLoaded){return h("img",{src:this.currentSrc,alt:this.alt,style:{objectFit:this.objectFit,width:this.width,height:this.height},"data-test":this.dataTest})}else if(!this.src){return h("div",{style:{width:this.width||this.height?this.width:"100%"}},h("bds-illustration",{type:"empty-states",name:"image-not-found",alt:this.alt,"data-test":this.dataTest}))}else{return h("div",{style:{width:this.width||this.height?this.width:"100%"}},h("bds-illustration",{type:"empty-states",name:"broken-image",alt:this.alt,"data-test":this.dataTest}))}};return t}();Image.style=BdsImageStyle0;export{Image as bds_image};
//# sourceMappingURL=bds-image.entry.js.map