/*! * (C) Ionic http://ionicframework.com - MIT License */ import{r as registerInstance,d as createEvent,h,H as Host,f as getElement}from"./index-73fa3fe8.js";import{k as inheritAttributes}from"./helpers-be245865.js";import{b as getIonMode}from"./ionic-global-d89a6ff6.js";var imgCss=":host{display:block;-o-object-fit:contain;object-fit:contain}img{display:block;width:100%;height:100%;-o-object-fit:inherit;object-fit:inherit;-o-object-position:inherit;object-position:inherit}";var IonImgStyle0=imgCss;var Img=function(){function t(t){var e=this;registerInstance(this,t);this.ionImgWillLoad=createEvent(this,"ionImgWillLoad",7);this.ionImgDidLoad=createEvent(this,"ionImgDidLoad",7);this.ionError=createEvent(this,"ionError",7);this.inheritedAttributes={};this.onLoad=function(){e.ionImgDidLoad.emit()};this.onError=function(){e.ionError.emit()};this.loadSrc=undefined;this.loadError=undefined;this.alt=undefined;this.src=undefined}t.prototype.srcChanged=function(){this.addIO()};t.prototype.componentWillLoad=function(){this.inheritedAttributes=inheritAttributes(this.el,["draggable"])};t.prototype.componentDidLoad=function(){this.addIO()};t.prototype.addIO=function(){var t=this;if(this.src===undefined){return}if(typeof window!=="undefined"&&"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"isIntersecting"in window.IntersectionObserverEntry.prototype){this.removeIO();this.io=new IntersectionObserver((function(e){if(e[e.length-1].isIntersecting){t.load();t.removeIO()}}));this.io.observe(this.el)}else{setTimeout((function(){return t.load()}),200)}};t.prototype.load=function(){this.loadError=this.onError;this.loadSrc=this.src;this.ionImgWillLoad.emit()};t.prototype.removeIO=function(){if(this.io){this.io.disconnect();this.io=undefined}};t.prototype.render=function(){var t=this,e=t.loadSrc,i=t.alt,n=t.onLoad,s=t.loadError,r=t.inheritedAttributes;var o=r.draggable;return h(Host,{key:"212cb19b83defa47a677e44659eccc5e7e1bc5a2",class:getIonMode(this)},h("img",{key:"975230d5ef5f262c8e5f040eb59cd1033241f3c8",decoding:"async",src:e,alt:i,onLoad:n,onError:s,part:"image",draggable:isDraggable(o)}))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{src:["srcChanged"]}},enumerable:false,configurable:true});return t}();var isDraggable=function(t){switch(t){case"true":return true;case"false":return false;default:return undefined}};Img.style=IonImgStyle0;export{Img as ion_img};