import{r as registerInstance,c as createEvent,h,H as Host}from"./index-980f930f.js";import{c as classnames}from"./index-c3e4004b.js";var indexCss='img[src=""]{opacity:0}taro-image-core{display:inline-block;overflow:hidden;position:relative;width:320px;height:240px;font-size:0}.taro-img.taro-img__widthfix{height:100%}.taro-img__mode-scaletofill{width:100%;height:100%}.taro-img__mode-aspectfit{max-width:100%;max-height:100%}.taro-img__mode-aspectfill{position:absolute;left:50%;top:50%;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%)}.taro-img__mode-aspectfill--width{min-width:100%;height:100%}.taro-img__mode-aspectfill--height{width:100%;min-height:100%}.taro-img__mode-widthfix{width:100%}.taro-img__mode-heightfix{height:100%}.taro-img__mode-top{width:100%}.taro-img__mode-bottom{position:absolute;bottom:0;width:100%}.taro-img__mode-left{height:100%}.taro-img__mode-right{position:absolute;right:0;height:100%}.taro-img__mode-topright{position:absolute;right:0}.taro-img__mode-bottomleft{position:absolute;bottom:0}.taro-img__mode-bottomright{position:absolute;right:0;bottom:0}';import("./intersection-observer-8e4c7135.js");var Image=function(){function t(t){registerInstance(this,t);this.onLoad=createEvent(this,"load",7);this.onError=createEvent(this,"error",7);this.src=undefined;this.mode="scaleToFill";this.lazyLoad=false;this.nativeProps={};this.aspectFillMode="width";this.didLoad=false}t.prototype.componentDidLoad=function(){var t=this;if(!this.lazyLoad)return;var i=new IntersectionObserver((function(o){if(o[o.length-1].isIntersecting){i.unobserve(t.imgRef);t.didLoad=true}}),{rootMargin:"300px 0px"});i.observe(this.imgRef)};t.prototype.imageOnLoad=function(){var t=this.imgRef,i=t.width,o=t.height,e=t.naturalWidth,a=t.naturalHeight;this.onLoad.emit({width:i,height:o});this.aspectFillMode=e>a?"width":"height"};t.prototype.imageOnError=function(t){this.onError.emit(t)};t.prototype.render=function(){var t;var i=this;var o=this,e=o.src,a=o.mode,r=a===void 0?"scaleToFill":a,s=o.lazyLoad,n=s===void 0?false:s,d=o.aspectFillMode,m=d===void 0?"width":d,g=o.imageOnLoad,l=o.imageOnError,c=o.nativeProps,f=o.didLoad;var p=classnames({"taro-img__widthfix":r==="widthFix"});var _=classnames("taro-img__mode-".concat(r.toLowerCase().replace(/\s/g,"")),(t={},t["taro-img__mode-aspectfill--".concat(m)]=r==="aspectFill",t));return h(Host,{class:p},h("img",Object.assign({ref:function(t){return i.imgRef=t},class:_,src:n&&!f?undefined:e,onLoad:g.bind(this),onError:l.bind(this)},c)))};return t}();Image.style=indexCss;export{Image as taro_image_core};